diff options
author | Keith Mok <kmok@cyngn.com> | 2015-09-28 10:57:47 -0700 |
---|---|---|
committer | Keith Mok <kmok@cyngn.com> | 2015-10-19 14:30:25 -0700 |
commit | 271398ad50d3e5df389b61954c29c92109a927f5 (patch) | |
tree | 4d148bddcc014415f54a3e8f1552f8f5313d44b9 | |
parent | 70ef33f58bb8199279136a613e89285631fb1f44 (diff) | |
download | bootable_recovery-271398ad50d3e5df389b61954c29c92109a927f5.tar.gz bootable_recovery-271398ad50d3e5df389b61954c29c92109a927f5.tar.bz2 bootable_recovery-271398ad50d3e5df389b61954c29c92109a927f5.zip |
Allow f2fs to reserve bytes for footer when formatting
Ticket: SAMBAR-729
Change-Id: I66630d2e24434e5b5587f0b0cb43e3e7543c960c
-rw-r--r-- | roots.cpp | 26 |
1 files changed, 13 insertions, 13 deletions
@@ -235,24 +235,24 @@ int format_volume(const char* volume) { if (strcmp(v->fs_type, "ext4") == 0) { result = make_ext4fs(v->blk_device, length, volume, sehandle); } else { /* Has to be f2fs because we checked earlier. */ - if (v->key_loc != NULL && strcmp(v->key_loc, "footer") == 0 && length < 0) { - LOGE("format_volume: crypt footer + negative length (%zd) not supported on %s\n", length, v->fs_type); - return -1; - } + char bytes_reserved[20], num_sectors[20]; + const char* f2fs_argv[6] = {"mkfs.f2fs", "-t1"}; if (length < 0) { - LOGE("format_volume: negative length (%zd) not supported on %s\n", length, v->fs_type); - return -1; - } - char *num_sectors; - if (asprintf(&num_sectors, "%zd", length / 512) <= 0) { - LOGE("format_volume: failed to create %s command for %s\n", v->fs_type, v->blk_device); - return -1; + snprintf(bytes_reserved, sizeof(bytes_reserved), "%zd", -length); + f2fs_argv[2] = "-r"; + f2fs_argv[3] = bytes_reserved; + f2fs_argv[4] = v->blk_device; + f2fs_argv[5] = NULL; + } else { + /* num_sectors can be zero which mean whole device space */ + snprintf(num_sectors, sizeof(num_sectors), "%zd", length / 512); + f2fs_argv[2] = v->blk_device; + f2fs_argv[3] = num_sectors; + f2fs_argv[4] = NULL; } const char *f2fs_path = "/sbin/mkfs.f2fs"; - const char* const f2fs_argv[] = {"mkfs.f2fs", "-t", "-d1", v->blk_device, num_sectors, NULL}; result = exec_cmd(f2fs_path, (char* const*)f2fs_argv); - free(num_sectors); } if (result != 0) { LOGE("format_volume: make %s failed on %s with %d(%s)\n", v->fs_type, v->blk_device, result, strerror(errno)); |