aboutsummaryrefslogtreecommitdiffstats
path: root/updater/install.c
diff options
context:
space:
mode:
authorMichael Runge <mrunge@google.com>2014-11-21 00:12:28 -0800
committerMichael Runge <mrunge@google.com>2014-11-21 21:10:20 -0800
commitacf47db238b2f4fff01969210945eec2528de9b7 (patch)
tree439cdd0fb8ccdffa3e6fa80e9e3db97241271586 /updater/install.c
parentdb1044ab6b4c0be3efe902c6c3d22cc2e1687346 (diff)
downloadbootable_recovery-acf47db238b2f4fff01969210945eec2528de9b7.zip
bootable_recovery-acf47db238b2f4fff01969210945eec2528de9b7.tar.gz
bootable_recovery-acf47db238b2f4fff01969210945eec2528de9b7.tar.bz2
Add support for tune2fs file operations
This allows tune2fs to be executed from within OTA scripts, allowing for file system modifications without formatting the partition Bug: 18430740 Change-Id: I0c2e05b5ef4a81ecea043e9b7b99b545d18fe5e6
Diffstat (limited to 'updater/install.c')
-rw-r--r--updater/install.c33
1 files changed, 33 insertions, 0 deletions
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);
}