diff options
author | JP Abgrall <jpa@google.com> | 2014-06-16 19:07:39 -0700 |
---|---|---|
committer | JP Abgrall <jpa@google.com> | 2014-06-16 19:07:39 -0700 |
commit | 37aedb3fafcccd0da5bd9089987f05895c27492d (patch) | |
tree | 62040a4e982abbf2db9c528f44cc3298301378f1 /updater | |
parent | ba545d7e2388e81e985a43fc86d191590b923c90 (diff) | |
download | bootable_recovery-37aedb3fafcccd0da5bd9089987f05895c27492d.zip bootable_recovery-37aedb3fafcccd0da5bd9089987f05895c27492d.tar.gz bootable_recovery-37aedb3fafcccd0da5bd9089987f05895c27492d.tar.bz2 |
Support F2FS for the data partition
This adds F2FS support
- for wiping a device
- for the install "format" command.
Note: crypto data in "footer" with a default/negative length
is not supported, unlike with "ext4".
Change-Id: I8d141a0d4d14df9fe84d3b131484e9696fcd8870
Signed-off-by: JP Abgrall <jpa@google.com>
Diffstat (limited to 'updater')
-rw-r--r-- | updater/install.c | 37 |
1 files changed, 35 insertions, 2 deletions
diff --git a/updater/install.c b/updater/install.c index 42f2289..edc386d 100644 --- a/updater/install.c +++ b/updater/install.c @@ -211,14 +211,29 @@ done: return StringValue(result); } +static int exec_cmd(const char* path, char* const argv[]) { + int status; + pid_t child; + if ((child = vfork()) == 0) { + execv(path, argv); + _exit(-1); + } + waitpid(child, &status, 0); + if (!WIFEXITED(status) || WEXITSTATUS(status) != 0) { + printf("%s failed with status %d\n", path, WEXITSTATUS(status)); + } + return WEXITSTATUS(status); +} + // format(fs_type, partition_type, location, fs_size, mount_point) // // fs_type="yaffs2" partition_type="MTD" location=partition fs_size=<bytes> mount_point=<location> // fs_type="ext4" partition_type="EMMC" location=device fs_size=<bytes> mount_point=<location> -// if fs_size == 0, then make_ext4fs uses the entire partition. +// fs_type="f2fs" partition_type="EMMC" location=device fs_size=<bytes> mount_point=<location> +// if fs_size == 0, then make fs uses the entire partition. // if fs_size > 0, that is the size to use -// if fs_size < 0, then reserve that many bytes at the end of the partition +// if fs_size < 0, then reserve that many bytes at the end of the partition (not for "f2fs") Value* FormatFn(const char* name, State* state, int argc, Expr* argv[]) { char* result = NULL; if (argc != 5) { @@ -290,6 +305,24 @@ Value* FormatFn(const char* name, State* state, int argc, Expr* argv[]) { goto done; } result = location; + } else if (strcmp(fs_type, "f2fs") == 0) { + char *num_sectors; + if (asprintf(&num_sectors, "%lld", atoll(fs_size) / 512) <= 0) { + printf("format_volume: failed to create %s command for %s\n", fs_type, location); + result = strdup(""); + goto done; + } + const char *f2fs_path = "/sbin/mkfs.f2fs"; + const char* const f2fs_argv[] = {"mkfs.f2fs", "-t", "-d1", location, num_sectors, NULL}; + int status = exec_cmd(f2fs_path, (char* const*)f2fs_argv); + free(num_sectors); + if (status != 0) { + printf("%s: mkfs.f2fs failed (%d) on %s", + name, status, location); + result = strdup(""); + goto done; + } + result = location; #endif } else { printf("%s: unsupported fs_type \"%s\" partition_type \"%s\"", |