From 04652731809fc1c0c44c8f1f248a706a42a01970 Mon Sep 17 00:00:00 2001 From: Yi-Yo Chiang Date: Wed, 17 Aug 2022 01:09:41 +0800 Subject: [PATCH] remount: Remove unused option -C/--clean_scratch_files The option was added for debugging purposes in case the "test argv[0] == clean_scratch_files" method breaks. Now it has no user at all and no reason to maintain it, so just remove it. Also don't use MyLogger() when running as clean_scratch_files, as clean_scratch_files don't have stdout/stderr. Bug: 241179247 Test: Presubmit Change-Id: I2d8069f59fe6b85fc84ab07bb2df6efb39d6ecaa --- fs_mgr/fs_mgr_remount.cpp | 16 ++++++---------- 1 file changed, 6 insertions(+), 10 deletions(-) diff --git a/fs_mgr/fs_mgr_remount.cpp b/fs_mgr/fs_mgr_remount.cpp index 01517b036..4a927d03c 100644 --- a/fs_mgr/fs_mgr_remount.cpp +++ b/fs_mgr/fs_mgr_remount.cpp @@ -475,17 +475,16 @@ static int do_remount(Fstab& fstab, const std::vector& partition_ar return retval; } -static int do_clean_scratch_files() { - android::fs_mgr::CleanupOldScratchFiles(); - return 0; -} - int main(int argc, char* argv[]) { - android::base::InitLogging(argv, MyLogger); + // Do not use MyLogger() when running as clean_scratch_files, as stdout/stderr of daemon process + // are discarded. if (argc > 0 && android::base::Basename(argv[0]) == "clean_scratch_files"s) { - return do_clean_scratch_files(); + android::fs_mgr::CleanupOldScratchFiles(); + return 0; } + android::base::InitLogging(argv, MyLogger); + // Make sure we are root. if (::getuid() != 0) { LOG(ERROR) << "Not running as root. Try \"adb root\" first."; @@ -509,7 +508,6 @@ int main(int argc, char* argv[]) { {"help", no_argument, nullptr, 'h'}, {"reboot", no_argument, nullptr, 'R'}, {"verbose", no_argument, nullptr, 'v'}, - {"clean_scratch_files", no_argument, nullptr, 'C'}, {0, 0, nullptr, 0}, }; for (int opt; (opt = ::getopt_long(argc, argv, "hRT:v", longopts, nullptr)) != -1;) { @@ -530,8 +528,6 @@ int main(int argc, char* argv[]) { case 'v': verbose = true; break; - case 'C': - return do_clean_scratch_files(); default: LOG(ERROR) << "Bad Argument -" << char(opt); usage(BADARG);