From 2c1380f1abc1f39c8c55fc327d5b916a7a8b039d Mon Sep 17 00:00:00 2001 From: Jaegeuk Kim Date: Wed, 14 Apr 2021 12:02:41 -0700 Subject: [PATCH] mkfs_f2fs: give the log in kernel It's very useful to see the mkfs log in console to debug any issues. Bug: 172378121 Signed-off-by: Jaegeuk Kim Change-Id: Icdac3609860cf0bba3fa758cead885bd4960f2c0 --- fs/F2fs.cpp | 46 ++++++++++++++++++++++++---------------------- 1 file changed, 24 insertions(+), 22 deletions(-) diff --git a/fs/F2fs.cpp b/fs/F2fs.cpp index d6f3dab..f4a81ee 100644 --- a/fs/F2fs.cpp +++ b/fs/F2fs.cpp @@ -20,6 +20,7 @@ #include #include #include +#include #include #include @@ -71,45 +72,46 @@ status_t Mount(const std::string& source, const std::string& target) { } status_t Format(const std::string& source) { - std::vector cmd; - cmd.push_back(kMkfsPath); + std::vector cmd; + cmd.emplace_back(kMkfsPath); - cmd.push_back("-f"); - cmd.push_back("-d1"); + cmd.emplace_back("-f"); + cmd.emplace_back("-d1"); if (android::base::GetBoolProperty("vold.has_quota", false)) { - cmd.push_back("-O"); - cmd.push_back("quota"); + cmd.emplace_back("-O"); + cmd.emplace_back("quota"); } if (fscrypt_is_native()) { - cmd.push_back("-O"); - cmd.push_back("encrypt"); + cmd.emplace_back("-O"); + cmd.emplace_back("encrypt"); } if (android::base::GetBoolProperty("vold.has_compress", false)) { - cmd.push_back("-O"); - cmd.push_back("compression"); - cmd.push_back("-O"); - cmd.push_back("extra_attr"); + cmd.emplace_back("-O"); + cmd.emplace_back("compression"); + cmd.emplace_back("-O"); + cmd.emplace_back("extra_attr"); } - cmd.push_back("-O"); - cmd.push_back("verity"); + cmd.emplace_back("-O"); + cmd.emplace_back("verity"); const bool needs_casefold = android::base::GetBoolProperty("external_storage.casefold.enabled", false); const bool needs_projid = android::base::GetBoolProperty("external_storage.projid.enabled", false); if (needs_projid) { - cmd.push_back("-O"); - cmd.push_back("project_quota,extra_attr"); + cmd.emplace_back("-O"); + cmd.emplace_back("project_quota,extra_attr"); } if (needs_casefold) { - cmd.push_back("-O"); - cmd.push_back("casefold"); - cmd.push_back("-C"); - cmd.push_back("utf8"); + cmd.emplace_back("-O"); + cmd.emplace_back("casefold"); + cmd.emplace_back("-C"); + cmd.emplace_back("utf8"); } - cmd.push_back(source); - return ForkExecvp(cmd); + cmd.emplace_back(source.c_str()); + return logwrap_fork_execvp(cmd.size(), cmd.data(), nullptr, false, LOG_KLOG, + false, nullptr); } } // namespace f2fs