From 4358262b757a39fe7939369be4afa6869e8caa3a Mon Sep 17 00:00:00 2001 From: Jaegeuk Kim Date: Mon, 2 Apr 2018 13:37:35 -0700 Subject: mkfs.f2fs: specify sector size for target image size The total sectors that we want to format is used in different meanings from various users. This notifies its size based on 4096 bytes explicitly. Bug: 76407663 Change-Id: I3392646648264ad1ca78e4b87240edc9385a0cc4 Merged-In: I3392646648264ad1ca78e4b87240edc9385a0cc4 Reported-by: katao@xiaomi.com Signed-off-by: Jaegeuk Kim --- roots.cpp | 25 ++++++++++++++++++++----- 1 file changed, 20 insertions(+), 5 deletions(-) (limited to 'roots.cpp') diff --git a/roots.cpp b/roots.cpp index 9ff5186c1..8907bbd9b 100644 --- a/roots.cpp +++ b/roots.cpp @@ -324,19 +324,34 @@ int format_volume(const char* volume, const char* directory) { } // Has to be f2fs because we checked earlier. + static constexpr int kSectorSize = 4096; std::string cmd("/sbin/mkfs.f2fs"); - std::vector make_f2fs_cmd = { cmd, "-d1", "-f", "-O", - "encrypt", "-O", "quota", v->blk_device }; - if (length >= 512) { - make_f2fs_cmd.push_back(std::to_string(length / 512)); + // clang-format off + std::vector make_f2fs_cmd = { + cmd, + "-d1", + "-f", + "-O", "encrypt", + "-O", "quota", + "-w", std::to_string(kSectorSize), + v->blk_device, + }; + // clang-format on + if (length >= kSectorSize) { + make_f2fs_cmd.push_back(std::to_string(length / kSectorSize)); } int result = exec_cmd(make_f2fs_cmd); if (result == 0 && directory != nullptr) { cmd = "/sbin/sload.f2fs"; + // clang-format off std::vector sload_f2fs_cmd = { - cmd, "-f", directory, "-t", volume, v->blk_device, + cmd, + "-f", directory, + "-t", volume, + v->blk_device, }; + // clang-format on result = exec_cmd(sload_f2fs_cmd); } if (result != 0) { -- cgit v1.2.3