Skip to content

Commit 5b9c4ce

Browse files
Michael RungeAndroid Git Automerger
authored andcommitted
am b278c25: Add support for tune2fs file operations
* commit 'b278c252e148798346f85fc92eeea6afeb33fbf0': Add support for tune2fs file operations
2 parents de27d4c + b278c25 commit 5b9c4ce

File tree

2 files changed

+43
-0
lines changed

2 files changed

+43
-0
lines changed

updater/Android.mk

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,16 @@ LOCAL_STATIC_LIBRARIES += libapplypatch libedify libmtdutils libminzip libz
3434
LOCAL_STATIC_LIBRARIES += libmincrypt libbz
3535
LOCAL_STATIC_LIBRARIES += libcutils liblog libstdc++ libc
3636
LOCAL_STATIC_LIBRARIES += libselinux
37+
tune2fs_static_libraries := \
38+
libext2_com_err \
39+
libext2_blkid \
40+
libext2_quota \
41+
libext2_uuid_static \
42+
libext2_e2p \
43+
libext2fs
44+
LOCAL_STATIC_LIBRARIES += libtune2fs $(tune2fs_static_libraries)
45+
46+
LOCAL_C_INCLUDES += external/e2fsprogs/misc
3747
LOCAL_C_INCLUDES += $(LOCAL_PATH)/..
3848

3949
# Each library in TARGET_RECOVERY_UPDATER_LIBS should have a function

updater/install.c

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,7 @@
4646
#include "mtdutils/mtdutils.h"
4747
#include "updater.h"
4848
#include "install.h"
49+
#include "tune2fs.h"
4950

5051
#ifdef USE_EXT4
5152
#include "make_ext4fs.h"
@@ -1539,6 +1540,37 @@ Value* EnableRebootFn(const char* name, State* state, int argc, Expr* argv[]) {
15391540
return StringValue(strdup("t"));
15401541
}
15411542

1543+
Value* Tune2FsFn(const char* name, State* state, int argc, Expr* argv[]) {
1544+
if (argc == 0) {
1545+
return ErrorAbort(state, "%s() expects args, got %d", name, argc);
1546+
}
1547+
1548+
char** args = ReadVarArgs(state, argc, argv);
1549+
if (args == NULL) {
1550+
return ErrorAbort(state, "%s() could not read args", name);
1551+
}
1552+
1553+
int i;
1554+
char** args2 = malloc(sizeof(char*) * (argc+1));
1555+
// Tune2fs expects the program name as its args[0]
1556+
args2[0] = strdup(name);
1557+
for (i = 0; i < argc; ++i) {
1558+
args2[i + 1] = args[i];
1559+
}
1560+
int result = tune2fs_main(argc + 1, args2);
1561+
for (i = 0; i < argc; ++i) {
1562+
free(args[i]);
1563+
}
1564+
free(args);
1565+
1566+
free(args2[0]);
1567+
free(args2);
1568+
if (result != 0) {
1569+
return ErrorAbort(state, "%s() returned error code %d", name, result);
1570+
}
1571+
return StringValue(strdup("t"));
1572+
}
1573+
15421574
void RegisterInstallFunctions() {
15431575
RegisterFunction("mount", MountFn);
15441576
RegisterFunction("is_mounted", IsMountedFn);
@@ -1589,4 +1621,5 @@ void RegisterInstallFunctions() {
15891621
RegisterFunction("set_stage", SetStageFn);
15901622

15911623
RegisterFunction("enable_reboot", EnableRebootFn);
1624+
RegisterFunction("tune2fs", Tune2FsFn);
15921625
}

0 commit comments

Comments
 (0)