Add support for creating ext4 images with mke2fs
We are investigating replacing make_ext4fs with the upstream tool mke2fs.
See b/23686092 for more informations.
To mitigate the trouble that may arise if the new tool behave differently
compared to the old one, there will be a transition period where both mke2fs
and make_ext4fs will be supported.
This patch does 3 things:
- add the necessary code to use mke2fs to format an ext4 partition;
- add a dependency to the binary used by vold.
Test: m -j32 with TARGET_USES_MKE2FS={,false,true}
TARGET_USERIMAGES_USE_EXT4={,true}
Change-Id: I89222642fe1d11a035155c8224b84b2e3719938b
diff --git a/cryptfs.c b/cryptfs.c
index a3ab2b9..4baa2db 100644
--- a/cryptfs.c
+++ b/cryptfs.c
@@ -2185,6 +2185,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";
@@ -2193,6 +2206,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) {