Manually merge commit 'b406ffa' into stage-aosp-master am: 04c55e6ed7 am: 93722ead06
am: 43100e580f
Change-Id: I8a74fd730f0aa5a1f94c04c12286e96ac299b463
diff --git a/Android.mk b/Android.mk
index 2f97536..e18951c 100644
--- a/Android.mk
+++ b/Android.mk
@@ -70,6 +70,16 @@
vold_conlyflags := -std=c11
vold_cflags := -Werror -Wall -Wno-missing-field-initializers -Wno-unused-variable -Wno-unused-parameter
+required_modules :=
+ifeq ($(TARGET_USERIMAGES_USE_EXT4), true)
+ ifeq ($(TARGET_USES_MKE2FS), true)
+ vold_cflags += -DTARGET_USES_MKE2FS
+ required_modules += mke2fs
+ else
+ required_modules += make_ext4fs
+ endif
+endif
+
include $(CLEAR_VARS)
LOCAL_ADDITIONAL_DEPENDENCIES := $(LOCAL_PATH)/Android.mk
@@ -82,6 +92,7 @@
LOCAL_MODULE_TAGS := eng tests
LOCAL_CFLAGS := $(vold_cflags)
LOCAL_CONLYFLAGS := $(vold_conlyflags)
+LOCAL_REQUIRED_MODULES := $(required_modules)
include $(BUILD_STATIC_LIBRARY)
@@ -108,6 +119,7 @@
LOCAL_SHARED_LIBRARIES := $(common_shared_libraries)
LOCAL_STATIC_LIBRARIES := $(common_static_libraries)
+LOCAL_REQUIRED_MODULES := $(required_modules)
include $(BUILD_EXECUTABLE)
diff --git a/cryptfs.c b/cryptfs.c
index e432206..e2606ec 100644
--- a/cryptfs.c
+++ b/cryptfs.c
@@ -2194,6 +2194,19 @@
int rc = -1;
if (type == EXT4_FS) {
+#ifdef TARGET_USES_MKE2FS
+ args[0] = "/system/bin/mke2fs";
+ args[1] = "-M";
+ args[2] = "/data";
+ args[3] = "-b";
+ args[4] = "4096";
+ args[5] = "-t";
+ args[6] = "ext4";
+ args[7] = crypto_blkdev;
+ snprintf(size_str, sizeof(size_str), "%" PRId64, size / (4096 / 512));
+ args[8] = size_str;
+ num_args = 9;
+#else
args[0] = "/system/bin/make_ext4fs";
args[1] = "-a";
args[2] = "/data";
@@ -2202,6 +2215,7 @@
args[4] = size_str;
args[5] = crypto_blkdev;
num_args = 6;
+#endif
SLOGI("Making empty filesystem with command %s %s %s %s %s %s\n",
args[0], args[1], args[2], args[3], args[4], args[5]);
} else if (type == F2FS_FS) {
diff --git a/fs/Ext4.cpp b/fs/Ext4.cpp
index 0bd5b0c..0670bb5 100644
--- a/fs/Ext4.cpp
+++ b/fs/Ext4.cpp
@@ -55,7 +55,11 @@
namespace ext4 {
static const char* kResizefsPath = "/system/bin/resize2fs";
+#ifdef TARGET_USES_MKE2FS
+static const char* kMkfsPath = "/system/bin/mke2fs";
+#else
static const char* kMkfsPath = "/system/bin/make_ext4fs";
+#endif
static const char* kFsckPath = "/system/bin/e2fsck";
bool IsSupported() {
@@ -165,6 +169,25 @@
const std::string& target) {
std::vector<std::string> cmd;
cmd.push_back(kMkfsPath);
+
+#ifdef TARGET_USES_MKE2FS
+ cmd.push_back("-b");
+ cmd.push_back("4096");
+
+ cmd.push_back("-t");
+ cmd.push_back("ext4");
+
+ cmd.push_back("-M");
+ cmd.push_back(target);
+
+ cmd.push_back("-O");
+ cmd.push_back("^has_journal");
+
+ cmd.push_back(source);
+
+ if (numSectors)
+ cmd.push_back(StringPrintf("%lu", numSectors * (4096 / 512)));
+#else
cmd.push_back("-J");
cmd.push_back("-a");
@@ -178,6 +201,7 @@
// Always generate a real UUID
cmd.push_back("-u");
cmd.push_back(source);
+#endif
return ForkExecvp(cmd);
}