Add RFS format support
Change-Id: Ifd1e5ce9875c3eaacc1cec1759b67e672894e279
diff --git a/bmlutils/bmlutils.c b/bmlutils/bmlutils.c
index a6b5415..c5de8b9 100644
--- a/bmlutils/bmlutils.c
+++ b/bmlutils/bmlutils.c
@@ -171,3 +171,37 @@
{
return -1;
}
+
+int run_exec_process ( char **argv);
+
+int format_rfs_device (const char *device, const char *path) {
+ const char *fatsize = "32";
+ const char *sectorsize = "1";
+
+ if (strcmp(path, "/datadata") == 0 || strcmp(path, "/cache") == 0) {
+ fatsize = "16";
+ }
+
+ // Just in case /data sector size needs to be altered
+ else if (strcmp(path, "/data") == 0 ) {
+ sectorsize = "1";
+ }
+
+ // dump 10KB of zeros to partition before format due to fat.format bug
+ char ofdevice[PATH_MAX];
+ snprintf(ofdevice, sizeof(ofdevice), "of=%s", device);
+ const char *rfszerodump[] = {"/sbin/dd", "if=/dev/zero", ofdevice, "bs=4096", "count=10", NULL};
+ if(run_exec_process((char **)rfszerodump)) {
+ printf("failure while running rfszerodump\n");
+ return -1;
+ }
+
+ // Run fat.format
+ const char *fatformat[] = {"/sbin/fat.format", "-F", fatsize, "-S", "4096", "-s", sectorsize, device, NULL};
+ if(run_exec_process((char **)fatformat)) {
+ printf("failure while running fat.format\n");
+ return -1;
+ }
+
+ return 0;
+}
diff --git a/bmlutils/bmlutils.h b/bmlutils/bmlutils.h
new file mode 100644
index 0000000..e6ffeee
--- /dev/null
+++ b/bmlutils/bmlutils.h
@@ -0,0 +1,6 @@
+#ifndef BMLUTILS_H_
+#define BMLUTILS_H_
+
+int format_rfs_device (const char *device, const char *path);
+
+#endif // BMLUTILS_H_
diff --git a/extendedcommands.c b/extendedcommands.c
index dfd196c..8e9ee54 100644
--- a/extendedcommands.c
+++ b/extendedcommands.c
@@ -41,6 +41,7 @@
#include "edify/expr.h"
#include <libgen.h>
#include "mtdutils/mtdutils.h"
+#include "bmlutils/bmlutils.h"
int signature_check_enabled = 1;
@@ -450,6 +451,18 @@
return -1;
}
+ if (strcmp(fs_type, "rfs") == 0) {
+ if (ensure_path_unmounted(path) != 0) {
+ LOGE("format_volume failed to unmount \"%s\"\n", v->mount_point);
+ return -1;
+ }
+ if (0 != format_rfs_device(device, path)) {
+ LOGE("format_volume: format_rfs_device failed on %s\n", device);
+ return -1;
+ }
+ return 0;
+ }
+
if (strcmp(v->mount_point, path) != 0) {
return format_unknown_device(v->device, path, NULL);
}
diff --git a/utilities/Android.mk b/utilities/Android.mk
index ffaf0e7..14dace0 100755
--- a/utilities/Android.mk
+++ b/utilities/Android.mk
@@ -61,3 +61,16 @@
endif
+
+ifdef BOARD_HAS_RFS_FILESYSTEM
+
+include $(CLEAR_VARS)
+LOCAL_MODULE := fat.format
+LOCAL_MODULE_TAGS := eng
+LOCAL_MODULE_CLASS := RECOVERY_EXECUTABLES
+LOCAL_MODULE_PATH := $(TARGET_RECOVERY_ROOT_OUT)/sbin
+LOCAL_SRC_FILES := $(LOCAL_MODULE)
+include $(BUILD_PREBUILT)
+
+endif
+
diff --git a/utilities/fat.format b/utilities/fat.format
new file mode 100755
index 0000000..6a743e7
--- /dev/null
+++ b/utilities/fat.format
Binary files differ