Loading fs_mgr/fs_mgr.cpp +22 −42 Original line number Diff line number Diff line Loading @@ -222,13 +222,11 @@ static void check_fs(const std::string& blk_device, const std::string& fs_type, } else { LINFO << "Running " << E2FSCK_BIN << " on " << realpath(blk_device); if (should_force_check(*fs_stat)) { ret = android_fork_execvp_ext( ARRAY_SIZE(e2fsck_forced_argv), const_cast<char**>(e2fsck_forced_argv), &status, true, LOG_KLOG | LOG_FILE, true, const_cast<char*>(FSCK_LOG_FILE), nullptr, 0); ret = logwrap_fork_execvp(ARRAY_SIZE(e2fsck_forced_argv), e2fsck_forced_argv, &status, false, LOG_KLOG | LOG_FILE, true, FSCK_LOG_FILE); } else { ret = android_fork_execvp_ext( ARRAY_SIZE(e2fsck_argv), const_cast<char**>(e2fsck_argv), &status, true, LOG_KLOG | LOG_FILE, true, const_cast<char*>(FSCK_LOG_FILE), nullptr, 0); ret = logwrap_fork_execvp(ARRAY_SIZE(e2fsck_argv), e2fsck_argv, &status, false, LOG_KLOG | LOG_FILE, true, FSCK_LOG_FILE); } if (ret < 0) { Loading @@ -246,14 +244,12 @@ static void check_fs(const std::string& blk_device, const std::string& fs_type, if (should_force_check(*fs_stat)) { LINFO << "Running " << F2FS_FSCK_BIN << " -f " << realpath(blk_device); ret = android_fork_execvp_ext( ARRAY_SIZE(f2fs_fsck_forced_argv), const_cast<char**>(f2fs_fsck_forced_argv), &status, true, LOG_KLOG | LOG_FILE, true, const_cast<char*>(FSCK_LOG_FILE), nullptr, 0); ret = logwrap_fork_execvp(ARRAY_SIZE(f2fs_fsck_forced_argv), f2fs_fsck_forced_argv, &status, false, LOG_KLOG | LOG_FILE, true, FSCK_LOG_FILE); } else { LINFO << "Running " << F2FS_FSCK_BIN << " -a " << realpath(blk_device); ret = android_fork_execvp_ext( ARRAY_SIZE(f2fs_fsck_argv), const_cast<char**>(f2fs_fsck_argv), &status, true, LOG_KLOG | LOG_FILE, true, const_cast<char*>(FSCK_LOG_FILE), nullptr, 0); ret = logwrap_fork_execvp(ARRAY_SIZE(f2fs_fsck_argv), f2fs_fsck_argv, &status, false, LOG_KLOG | LOG_FILE, true, FSCK_LOG_FILE); } if (ret < 0) { /* No need to check for error in fork, we can't really handle it now */ Loading Loading @@ -331,8 +327,7 @@ static bool tune2fs_available(void) { static bool run_tune2fs(const char* argv[], int argc) { int ret; ret = android_fork_execvp_ext(argc, const_cast<char**>(argv), nullptr, true, LOG_KLOG | LOG_FILE, true, nullptr, nullptr, 0); ret = logwrap_fork_execvp(argc, argv, nullptr, false, LOG_KLOG, true, nullptr); return ret == 0; } Loading Loading @@ -852,37 +847,22 @@ static int handle_encryptable(const FstabEntry& entry) { } } static bool call_vdc(const std::vector<std::string>& args) { static bool call_vdc(const std::vector<std::string>& args, int* ret) { std::vector<char const*> argv; argv.emplace_back("/system/bin/vdc"); for (auto& arg : args) { argv.emplace_back(arg.c_str()); } LOG(INFO) << "Calling: " << android::base::Join(argv, ' '); int ret = android_fork_execvp(argv.size(), const_cast<char**>(argv.data()), nullptr, false, true); if (ret != 0) { LOG(ERROR) << "vdc returned error code: " << ret; return false; } LOG(DEBUG) << "vdc finished successfully"; return true; } static bool call_vdc_ret(const std::vector<std::string>& args, int* ret) { std::vector<char const*> argv; argv.emplace_back("/system/bin/vdc"); for (auto& arg : args) { argv.emplace_back(arg.c_str()); } LOG(INFO) << "Calling: " << android::base::Join(argv, ' '); int err = android_fork_execvp(argv.size(), const_cast<char**>(argv.data()), ret, false, true); int err = logwrap_fork_execvp(argv.size(), argv.data(), ret, false, LOG_ALOG, false, nullptr); if (err != 0) { LOG(ERROR) << "vdc call failed with error code: " << err; return false; } LOG(DEBUG) << "vdc finished successfully"; if (ret != nullptr) { *ret = WEXITSTATUS(*ret); } return true; } Loading Loading @@ -914,11 +894,11 @@ class CheckpointManager { } if (entry->fs_mgr_flags.checkpoint_blk) { call_vdc({"checkpoint", "restoreCheckpoint", entry->blk_device}); call_vdc({"checkpoint", "restoreCheckpoint", entry->blk_device}, nullptr); } if (needs_checkpoint_ == UNKNOWN && !call_vdc_ret({"checkpoint", "needsCheckpoint"}, &needs_checkpoint_)) { !call_vdc({"checkpoint", "needsCheckpoint"}, &needs_checkpoint_)) { LERROR << "Failed to find if checkpointing is needed. Assuming no."; needs_checkpoint_ = NO; } Loading Loading @@ -1193,7 +1173,8 @@ int fs_mgr_mount_all(Fstab* fstab, int mount_mode) { encryptable = status; if (status == FS_MGR_MNTALL_DEV_NEEDS_METADATA_ENCRYPTION) { if (!call_vdc({"cryptfs", "encryptFstab", attempted_entry.blk_device, attempted_entry.mount_point})) { attempted_entry.mount_point}, nullptr)) { LERROR << "Encryption failed"; return FS_MGR_MNTALL_FAIL; } Loading Loading @@ -1265,7 +1246,8 @@ int fs_mgr_mount_all(Fstab* fstab, int mount_mode) { } else if (mount_errno != EBUSY && mount_errno != EACCES && should_use_metadata_encryption(attempted_entry)) { if (!call_vdc({"cryptfs", "mountFstab", attempted_entry.blk_device, attempted_entry.mount_point})) { attempted_entry.mount_point}, nullptr)) { ++error_count; } encryptable = FS_MGR_MNTALL_DEV_IS_METADATA_ENCRYPTED; Loading Loading @@ -1615,10 +1597,8 @@ bool fs_mgr_swapon_all(const Fstab& fstab) { MKSWAP_BIN, entry.blk_device.c_str(), }; int err = 0; int status; err = android_fork_execvp_ext(ARRAY_SIZE(mkswap_argv), const_cast<char**>(mkswap_argv), &status, true, LOG_KLOG, false, nullptr, nullptr, 0); int err = logwrap_fork_execvp(ARRAY_SIZE(mkswap_argv), mkswap_argv, nullptr, false, LOG_KLOG, false, nullptr); if (err) { LERROR << "mkswap failed for " << entry.blk_device; ret = false; Loading fs_mgr/fs_mgr_format.cpp +5 −6 Original line number Diff line number Diff line Loading @@ -76,8 +76,8 @@ static int format_ext4(const std::string& fs_blkdev, const std::string& fs_mnt_p "/system/bin/mke2fs", "-t", "ext4", "-b", "4096", fs_blkdev.c_str(), size_str.c_str(), nullptr}; rc = android_fork_execvp_ext(arraysize(mke2fs_args), const_cast<char**>(mke2fs_args), NULL, true, LOG_KLOG, true, nullptr, nullptr, 0); rc = logwrap_fork_execvp(arraysize(mke2fs_args), mke2fs_args, nullptr, false, LOG_KLOG, true, nullptr); if (rc) { LERROR << "mke2fs returned " << rc; return rc; Loading @@ -86,8 +86,8 @@ static int format_ext4(const std::string& fs_blkdev, const std::string& fs_mnt_p const char* const e2fsdroid_args[] = { "/system/bin/e2fsdroid", "-e", "-a", fs_mnt_point.c_str(), fs_blkdev.c_str(), nullptr}; rc = android_fork_execvp_ext(arraysize(e2fsdroid_args), const_cast<char**>(e2fsdroid_args), NULL, true, LOG_KLOG, true, nullptr, nullptr, 0); rc = logwrap_fork_execvp(arraysize(e2fsdroid_args), e2fsdroid_args, nullptr, false, LOG_KLOG, true, nullptr); if (rc) { LERROR << "e2fsdroid returned " << rc; } Loading Loading @@ -119,8 +119,7 @@ static int format_f2fs(const std::string& fs_blkdev, uint64_t dev_sz, bool crypt }; // clang-format on return android_fork_execvp_ext(arraysize(args), const_cast<char**>(args), NULL, true, LOG_KLOG, true, nullptr, nullptr, 0); return logwrap_fork_execvp(arraysize(args), args, nullptr, false, LOG_KLOG, true, nullptr); } int fs_mgr_do_format(const FstabEntry& entry, bool crypt_footer) { Loading init/reboot.cpp +9 −10 Original line number Diff line number Diff line Loading @@ -116,16 +116,16 @@ class MountEntry { "-a", mnt_fsname_.c_str(), }; android_fork_execvp_ext(arraysize(f2fs_argv), (char**)f2fs_argv, &st, true, LOG_KLOG, true, nullptr, nullptr, 0); logwrap_fork_execvp(arraysize(f2fs_argv), f2fs_argv, &st, false, LOG_KLOG, true, nullptr); } else if (IsExt4()) { const char* ext4_argv[] = { "/system/bin/e2fsck", "-y", mnt_fsname_.c_str(), }; android_fork_execvp_ext(arraysize(ext4_argv), (char**)ext4_argv, &st, true, LOG_KLOG, true, nullptr, nullptr, 0); logwrap_fork_execvp(arraysize(ext4_argv), ext4_argv, &st, false, LOG_KLOG, true, nullptr); } } Loading Loading @@ -163,8 +163,7 @@ static void TurnOffBacklight() { static void ShutdownVold() { const char* vdc_argv[] = {"/system/bin/vdc", "volume", "shutdown"}; int status; android_fork_execvp_ext(arraysize(vdc_argv), (char**)vdc_argv, &status, true, LOG_KLOG, true, nullptr, nullptr, 0); logwrap_fork_execvp(arraysize(vdc_argv), vdc_argv, &status, false, LOG_KLOG, true, nullptr); } static void LogShutdownTime(UmountStat stat, Timer* t) { Loading Loading @@ -221,8 +220,8 @@ static void DumpUmountDebuggingInfo() { if (!security_getenforce()) { LOG(INFO) << "Run lsof"; const char* lsof_argv[] = {"/system/bin/lsof"}; android_fork_execvp_ext(arraysize(lsof_argv), (char**)lsof_argv, &status, true, LOG_KLOG, true, nullptr, nullptr, 0); logwrap_fork_execvp(arraysize(lsof_argv), lsof_argv, &status, false, LOG_KLOG, true, nullptr); } FindPartitionsToUmount(nullptr, nullptr, true); // dump current CPU stack traces and uninterruptible tasks Loading Loading @@ -317,8 +316,8 @@ void RebootMonitorThread(unsigned int cmd, const std::string& rebootTarget, sem_ LOG(INFO) << "Try to dump init process call trace:"; const char* vdc_argv[] = {"/system/bin/debuggerd", "-b", "1"}; int status; android_fork_execvp_ext(arraysize(vdc_argv), (char**)vdc_argv, &status, true, LOG_KLOG, true, nullptr, nullptr, 0); logwrap_fork_execvp(arraysize(vdc_argv), vdc_argv, &status, false, LOG_KLOG, true, nullptr); } LOG(INFO) << "Show stack for all active CPU:"; WriteStringToFile("l", PROC_SYSRQ); Loading Loading
fs_mgr/fs_mgr.cpp +22 −42 Original line number Diff line number Diff line Loading @@ -222,13 +222,11 @@ static void check_fs(const std::string& blk_device, const std::string& fs_type, } else { LINFO << "Running " << E2FSCK_BIN << " on " << realpath(blk_device); if (should_force_check(*fs_stat)) { ret = android_fork_execvp_ext( ARRAY_SIZE(e2fsck_forced_argv), const_cast<char**>(e2fsck_forced_argv), &status, true, LOG_KLOG | LOG_FILE, true, const_cast<char*>(FSCK_LOG_FILE), nullptr, 0); ret = logwrap_fork_execvp(ARRAY_SIZE(e2fsck_forced_argv), e2fsck_forced_argv, &status, false, LOG_KLOG | LOG_FILE, true, FSCK_LOG_FILE); } else { ret = android_fork_execvp_ext( ARRAY_SIZE(e2fsck_argv), const_cast<char**>(e2fsck_argv), &status, true, LOG_KLOG | LOG_FILE, true, const_cast<char*>(FSCK_LOG_FILE), nullptr, 0); ret = logwrap_fork_execvp(ARRAY_SIZE(e2fsck_argv), e2fsck_argv, &status, false, LOG_KLOG | LOG_FILE, true, FSCK_LOG_FILE); } if (ret < 0) { Loading @@ -246,14 +244,12 @@ static void check_fs(const std::string& blk_device, const std::string& fs_type, if (should_force_check(*fs_stat)) { LINFO << "Running " << F2FS_FSCK_BIN << " -f " << realpath(blk_device); ret = android_fork_execvp_ext( ARRAY_SIZE(f2fs_fsck_forced_argv), const_cast<char**>(f2fs_fsck_forced_argv), &status, true, LOG_KLOG | LOG_FILE, true, const_cast<char*>(FSCK_LOG_FILE), nullptr, 0); ret = logwrap_fork_execvp(ARRAY_SIZE(f2fs_fsck_forced_argv), f2fs_fsck_forced_argv, &status, false, LOG_KLOG | LOG_FILE, true, FSCK_LOG_FILE); } else { LINFO << "Running " << F2FS_FSCK_BIN << " -a " << realpath(blk_device); ret = android_fork_execvp_ext( ARRAY_SIZE(f2fs_fsck_argv), const_cast<char**>(f2fs_fsck_argv), &status, true, LOG_KLOG | LOG_FILE, true, const_cast<char*>(FSCK_LOG_FILE), nullptr, 0); ret = logwrap_fork_execvp(ARRAY_SIZE(f2fs_fsck_argv), f2fs_fsck_argv, &status, false, LOG_KLOG | LOG_FILE, true, FSCK_LOG_FILE); } if (ret < 0) { /* No need to check for error in fork, we can't really handle it now */ Loading Loading @@ -331,8 +327,7 @@ static bool tune2fs_available(void) { static bool run_tune2fs(const char* argv[], int argc) { int ret; ret = android_fork_execvp_ext(argc, const_cast<char**>(argv), nullptr, true, LOG_KLOG | LOG_FILE, true, nullptr, nullptr, 0); ret = logwrap_fork_execvp(argc, argv, nullptr, false, LOG_KLOG, true, nullptr); return ret == 0; } Loading Loading @@ -852,37 +847,22 @@ static int handle_encryptable(const FstabEntry& entry) { } } static bool call_vdc(const std::vector<std::string>& args) { static bool call_vdc(const std::vector<std::string>& args, int* ret) { std::vector<char const*> argv; argv.emplace_back("/system/bin/vdc"); for (auto& arg : args) { argv.emplace_back(arg.c_str()); } LOG(INFO) << "Calling: " << android::base::Join(argv, ' '); int ret = android_fork_execvp(argv.size(), const_cast<char**>(argv.data()), nullptr, false, true); if (ret != 0) { LOG(ERROR) << "vdc returned error code: " << ret; return false; } LOG(DEBUG) << "vdc finished successfully"; return true; } static bool call_vdc_ret(const std::vector<std::string>& args, int* ret) { std::vector<char const*> argv; argv.emplace_back("/system/bin/vdc"); for (auto& arg : args) { argv.emplace_back(arg.c_str()); } LOG(INFO) << "Calling: " << android::base::Join(argv, ' '); int err = android_fork_execvp(argv.size(), const_cast<char**>(argv.data()), ret, false, true); int err = logwrap_fork_execvp(argv.size(), argv.data(), ret, false, LOG_ALOG, false, nullptr); if (err != 0) { LOG(ERROR) << "vdc call failed with error code: " << err; return false; } LOG(DEBUG) << "vdc finished successfully"; if (ret != nullptr) { *ret = WEXITSTATUS(*ret); } return true; } Loading Loading @@ -914,11 +894,11 @@ class CheckpointManager { } if (entry->fs_mgr_flags.checkpoint_blk) { call_vdc({"checkpoint", "restoreCheckpoint", entry->blk_device}); call_vdc({"checkpoint", "restoreCheckpoint", entry->blk_device}, nullptr); } if (needs_checkpoint_ == UNKNOWN && !call_vdc_ret({"checkpoint", "needsCheckpoint"}, &needs_checkpoint_)) { !call_vdc({"checkpoint", "needsCheckpoint"}, &needs_checkpoint_)) { LERROR << "Failed to find if checkpointing is needed. Assuming no."; needs_checkpoint_ = NO; } Loading Loading @@ -1193,7 +1173,8 @@ int fs_mgr_mount_all(Fstab* fstab, int mount_mode) { encryptable = status; if (status == FS_MGR_MNTALL_DEV_NEEDS_METADATA_ENCRYPTION) { if (!call_vdc({"cryptfs", "encryptFstab", attempted_entry.blk_device, attempted_entry.mount_point})) { attempted_entry.mount_point}, nullptr)) { LERROR << "Encryption failed"; return FS_MGR_MNTALL_FAIL; } Loading Loading @@ -1265,7 +1246,8 @@ int fs_mgr_mount_all(Fstab* fstab, int mount_mode) { } else if (mount_errno != EBUSY && mount_errno != EACCES && should_use_metadata_encryption(attempted_entry)) { if (!call_vdc({"cryptfs", "mountFstab", attempted_entry.blk_device, attempted_entry.mount_point})) { attempted_entry.mount_point}, nullptr)) { ++error_count; } encryptable = FS_MGR_MNTALL_DEV_IS_METADATA_ENCRYPTED; Loading Loading @@ -1615,10 +1597,8 @@ bool fs_mgr_swapon_all(const Fstab& fstab) { MKSWAP_BIN, entry.blk_device.c_str(), }; int err = 0; int status; err = android_fork_execvp_ext(ARRAY_SIZE(mkswap_argv), const_cast<char**>(mkswap_argv), &status, true, LOG_KLOG, false, nullptr, nullptr, 0); int err = logwrap_fork_execvp(ARRAY_SIZE(mkswap_argv), mkswap_argv, nullptr, false, LOG_KLOG, false, nullptr); if (err) { LERROR << "mkswap failed for " << entry.blk_device; ret = false; Loading
fs_mgr/fs_mgr_format.cpp +5 −6 Original line number Diff line number Diff line Loading @@ -76,8 +76,8 @@ static int format_ext4(const std::string& fs_blkdev, const std::string& fs_mnt_p "/system/bin/mke2fs", "-t", "ext4", "-b", "4096", fs_blkdev.c_str(), size_str.c_str(), nullptr}; rc = android_fork_execvp_ext(arraysize(mke2fs_args), const_cast<char**>(mke2fs_args), NULL, true, LOG_KLOG, true, nullptr, nullptr, 0); rc = logwrap_fork_execvp(arraysize(mke2fs_args), mke2fs_args, nullptr, false, LOG_KLOG, true, nullptr); if (rc) { LERROR << "mke2fs returned " << rc; return rc; Loading @@ -86,8 +86,8 @@ static int format_ext4(const std::string& fs_blkdev, const std::string& fs_mnt_p const char* const e2fsdroid_args[] = { "/system/bin/e2fsdroid", "-e", "-a", fs_mnt_point.c_str(), fs_blkdev.c_str(), nullptr}; rc = android_fork_execvp_ext(arraysize(e2fsdroid_args), const_cast<char**>(e2fsdroid_args), NULL, true, LOG_KLOG, true, nullptr, nullptr, 0); rc = logwrap_fork_execvp(arraysize(e2fsdroid_args), e2fsdroid_args, nullptr, false, LOG_KLOG, true, nullptr); if (rc) { LERROR << "e2fsdroid returned " << rc; } Loading Loading @@ -119,8 +119,7 @@ static int format_f2fs(const std::string& fs_blkdev, uint64_t dev_sz, bool crypt }; // clang-format on return android_fork_execvp_ext(arraysize(args), const_cast<char**>(args), NULL, true, LOG_KLOG, true, nullptr, nullptr, 0); return logwrap_fork_execvp(arraysize(args), args, nullptr, false, LOG_KLOG, true, nullptr); } int fs_mgr_do_format(const FstabEntry& entry, bool crypt_footer) { Loading
init/reboot.cpp +9 −10 Original line number Diff line number Diff line Loading @@ -116,16 +116,16 @@ class MountEntry { "-a", mnt_fsname_.c_str(), }; android_fork_execvp_ext(arraysize(f2fs_argv), (char**)f2fs_argv, &st, true, LOG_KLOG, true, nullptr, nullptr, 0); logwrap_fork_execvp(arraysize(f2fs_argv), f2fs_argv, &st, false, LOG_KLOG, true, nullptr); } else if (IsExt4()) { const char* ext4_argv[] = { "/system/bin/e2fsck", "-y", mnt_fsname_.c_str(), }; android_fork_execvp_ext(arraysize(ext4_argv), (char**)ext4_argv, &st, true, LOG_KLOG, true, nullptr, nullptr, 0); logwrap_fork_execvp(arraysize(ext4_argv), ext4_argv, &st, false, LOG_KLOG, true, nullptr); } } Loading Loading @@ -163,8 +163,7 @@ static void TurnOffBacklight() { static void ShutdownVold() { const char* vdc_argv[] = {"/system/bin/vdc", "volume", "shutdown"}; int status; android_fork_execvp_ext(arraysize(vdc_argv), (char**)vdc_argv, &status, true, LOG_KLOG, true, nullptr, nullptr, 0); logwrap_fork_execvp(arraysize(vdc_argv), vdc_argv, &status, false, LOG_KLOG, true, nullptr); } static void LogShutdownTime(UmountStat stat, Timer* t) { Loading Loading @@ -221,8 +220,8 @@ static void DumpUmountDebuggingInfo() { if (!security_getenforce()) { LOG(INFO) << "Run lsof"; const char* lsof_argv[] = {"/system/bin/lsof"}; android_fork_execvp_ext(arraysize(lsof_argv), (char**)lsof_argv, &status, true, LOG_KLOG, true, nullptr, nullptr, 0); logwrap_fork_execvp(arraysize(lsof_argv), lsof_argv, &status, false, LOG_KLOG, true, nullptr); } FindPartitionsToUmount(nullptr, nullptr, true); // dump current CPU stack traces and uninterruptible tasks Loading Loading @@ -317,8 +316,8 @@ void RebootMonitorThread(unsigned int cmd, const std::string& rebootTarget, sem_ LOG(INFO) << "Try to dump init process call trace:"; const char* vdc_argv[] = {"/system/bin/debuggerd", "-b", "1"}; int status; android_fork_execvp_ext(arraysize(vdc_argv), (char**)vdc_argv, &status, true, LOG_KLOG, true, nullptr, nullptr, 0); logwrap_fork_execvp(arraysize(vdc_argv), vdc_argv, &status, false, LOG_KLOG, true, nullptr); } LOG(INFO) << "Show stack for all active CPU:"; WriteStringToFile("l", PROC_SYSRQ); Loading