Add length parameter to format /data f2fs filesystem
With metadata encryption, if partition is wiped (or) cryptfs failed ,
it will do format without length which make partition size is grown
large to occupy remaining space instead of restricting the Android
defined partition size.
Bug: 343159184
Test: Add length flag in fstab && fastboot erase userdata &&
fastboot reboot && df -h /data
Change-Id: Iad041e960c9337ab1b9d51b115db3c5f3f1f75e2
Signed-off-by: Ashok Mutyala <quic_amutyala@quicinc.com>
diff --git a/fs/F2fs.cpp b/fs/F2fs.cpp
index 99afc32..3cdf574 100644
--- a/fs/F2fs.cpp
+++ b/fs/F2fs.cpp
@@ -72,8 +72,10 @@
}
status_t Format(const std::string& source, bool is_zoned,
- const std::vector<std::string>& user_devices) {
+ const std::vector<std::string>& user_devices, int64_t length) {
std::vector<char const*> cmd;
+ /* '-g android' parameter passed here which defaults the sector size to 4096 */
+ static constexpr int kSectorSize = 4096;
cmd.emplace_back(kMkfsPath);
cmd.emplace_back("-f");
@@ -110,6 +112,9 @@
cmd.emplace_back(source.c_str());
+ if (length) {
+ cmd.emplace_back(std::to_string(length / kSectorSize).c_str());
+ }
return logwrap_fork_execvp(cmd.size(), cmd.data(), nullptr, false, LOG_KLOG,
false, nullptr);
}