aboutsummaryrefslogtreecommitdiffstats
path: root/updater
diff options
context:
space:
mode:
authorMichael Runge <mrunge@google.com>2014-11-24 02:37:03 +0000
committerAndroid Git Automerger <android-git-automerger@android.com>2014-11-24 02:37:03 +0000
commit5b9c4ce5a15bb76919e1556ae59993e9c310c0bc (patch)
tree4e02448a8100b317689be2772fc9479fdd52210b /updater
parentde27d4cbb75a9c2f5ad0fc24edf5295d0f3d9fe0 (diff)
parentb278c252e148798346f85fc92eeea6afeb33fbf0 (diff)
downloadbootable_recovery-5b9c4ce5a15bb76919e1556ae59993e9c310c0bc.zip
bootable_recovery-5b9c4ce5a15bb76919e1556ae59993e9c310c0bc.tar.gz
bootable_recovery-5b9c4ce5a15bb76919e1556ae59993e9c310c0bc.tar.bz2
am b278c252: Add support for tune2fs file operations
* commit 'b278c252e148798346f85fc92eeea6afeb33fbf0': Add support for tune2fs file operations
Diffstat (limited to 'updater')
-rw-r--r--updater/Android.mk10
-rw-r--r--updater/install.c33
2 files changed, 43 insertions, 0 deletions
diff --git a/updater/Android.mk b/updater/Android.mk
index a3a900a..11e7bb8 100644
--- a/updater/Android.mk
+++ b/updater/Android.mk
@@ -34,6 +34,16 @@ LOCAL_STATIC_LIBRARIES += libapplypatch libedify libmtdutils libminzip libz
LOCAL_STATIC_LIBRARIES += libmincrypt libbz
LOCAL_STATIC_LIBRARIES += libcutils liblog libstdc++ libc
LOCAL_STATIC_LIBRARIES += libselinux
+tune2fs_static_libraries := \
+ libext2_com_err \
+ libext2_blkid \
+ libext2_quota \
+ libext2_uuid_static \
+ libext2_e2p \
+ libext2fs
+LOCAL_STATIC_LIBRARIES += libtune2fs $(tune2fs_static_libraries)
+
+LOCAL_C_INCLUDES += external/e2fsprogs/misc
LOCAL_C_INCLUDES += $(LOCAL_PATH)/..
# Each library in TARGET_RECOVERY_UPDATER_LIBS should have a function
diff --git a/updater/install.c b/updater/install.c
index ff7de47..2b2ffb0 100644
--- a/updater/install.c
+++ b/updater/install.c
@@ -46,6 +46,7 @@
#include "mtdutils/mtdutils.h"
#include "updater.h"
#include "install.h"
+#include "tune2fs.h"
#ifdef USE_EXT4
#include "make_ext4fs.h"
@@ -1539,6 +1540,37 @@ Value* EnableRebootFn(const char* name, State* state, int argc, Expr* argv[]) {
return StringValue(strdup("t"));
}
+Value* Tune2FsFn(const char* name, State* state, int argc, Expr* argv[]) {
+ if (argc == 0) {
+ return ErrorAbort(state, "%s() expects args, got %d", name, argc);
+ }
+
+ char** args = ReadVarArgs(state, argc, argv);
+ if (args == NULL) {
+ return ErrorAbort(state, "%s() could not read args", name);
+ }
+
+ int i;
+ char** args2 = malloc(sizeof(char*) * (argc+1));
+ // Tune2fs expects the program name as its args[0]
+ args2[0] = strdup(name);
+ for (i = 0; i < argc; ++i) {
+ args2[i + 1] = args[i];
+ }
+ int result = tune2fs_main(argc + 1, args2);
+ for (i = 0; i < argc; ++i) {
+ free(args[i]);
+ }
+ free(args);
+
+ free(args2[0]);
+ free(args2);
+ if (result != 0) {
+ return ErrorAbort(state, "%s() returned error code %d", name, result);
+ }
+ return StringValue(strdup("t"));
+}
+
void RegisterInstallFunctions() {
RegisterFunction("mount", MountFn);
RegisterFunction("is_mounted", IsMountedFn);
@@ -1589,4 +1621,5 @@ void RegisterInstallFunctions() {
RegisterFunction("set_stage", SetStageFn);
RegisterFunction("enable_reboot", EnableRebootFn);
+ RegisterFunction("tune2fs", Tune2FsFn);
}