From 7e941586844e514d296dd755972902dd64a4c8ba Mon Sep 17 00:00:00 2001 From: Ethan Yonker Date: Fri, 22 Mar 2019 08:18:21 -0500 Subject: Support both old and new mkfs.f2fs Easiest way I could find to determine if we have the old or the new mkfs.f2fs version is to pipe the usage output to grep and grep the output for "reserved" and redirect the output to a file. If the file has any data in it, then we must have the old mkfs.f2fs that uses -r. Change-Id: I7f1ed88b577a3f9827a98f0868d8f82e4e4886ac --- twrp-functions.cpp | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) (limited to 'twrp-functions.cpp') diff --git a/twrp-functions.cpp b/twrp-functions.cpp index ff34828e2..84451b3b6 100755 --- a/twrp-functions.cpp +++ b/twrp-functions.cpp @@ -77,7 +77,7 @@ int TWFunc::Exec_Cmd(const string& cmd, string &result) { return ret; } -int TWFunc::Exec_Cmd(const string& cmd) { +int TWFunc::Exec_Cmd(const string& cmd, bool Show_Errors) { pid_t pid; int status; switch(pid = fork()) @@ -91,7 +91,7 @@ int TWFunc::Exec_Cmd(const string& cmd) { break; default: { - if (TWFunc::Wait_For_Child(pid, &status, cmd) != 0) + if (TWFunc::Wait_For_Child(pid, &status, cmd, Show_Errors) != 0) return -1; else return 0; @@ -121,18 +121,20 @@ string TWFunc::Get_Path(const string& Path) { return Path; } -int TWFunc::Wait_For_Child(pid_t pid, int *status, string Child_Name) { +int TWFunc::Wait_For_Child(pid_t pid, int *status, string Child_Name, bool Show_Errors) { pid_t rc_pid; rc_pid = waitpid(pid, status, 0); if (rc_pid > 0) { if (WIFSIGNALED(*status)) { - gui_msg(Msg(msg::kError, "pid_signal={1} process ended with signal: {2}")(Child_Name)(WTERMSIG(*status))); // Seg fault or some other non-graceful termination + if (Show_Errors) + gui_msg(Msg(msg::kError, "pid_signal={1} process ended with signal: {2}")(Child_Name)(WTERMSIG(*status))); // Seg fault or some other non-graceful termination return -1; } else if (WEXITSTATUS(*status) == 0) { LOGINFO("%s process ended with RC=%d\n", Child_Name.c_str(), WEXITSTATUS(*status)); // Success } else { - gui_msg(Msg(msg::kError, "pid_error={1} process ended with ERROR: {2}")(Child_Name)(WEXITSTATUS(*status))); // Graceful exit, but there was an error + if (Show_Errors) + gui_msg(Msg(msg::kError, "pid_error={1} process ended with ERROR: {2}")(Child_Name)(WEXITSTATUS(*status))); // Graceful exit, but there was an error return -1; } } else { // no PID returned -- cgit v1.2.3