diff --git a/extract/ExtractOperation.cpp b/extract/ExtractOperation.cpp index b493229f..2b636f5d 100644 --- a/extract/ExtractOperation.cpp +++ b/extract/ExtractOperation.cpp @@ -286,20 +286,20 @@ namespace skkk { } } - void ExtractOperation::extractErofsNode() const { + void ExtractOperation::extractErofsNode(bool isSilent) const { extractNodeDirs(); if (!nodeOther.empty()) { int nodeOtherSize = nodeOther.size(); for (int i = 0; i < nodeOtherSize; i++) { extractNodeTask(nodeOther[i], outDir); - printExtractProgress(nodeOtherSize, i + 1, 2, true); + if (!isSilent) printExtractProgress(nodeOtherSize, i + 1, 2, true); } } // If there is an exception writeExceptionInfo2File(); } - void ExtractOperation::extractErofsNodeMultiThread() const { + void ExtractOperation::extractErofsNodeMultiThread(bool isSilent) const { extractNodeDirs(); LOGCI(GREEN2_BOLD "Use " COLOR_NONE RED2 "%d" COLOR_NONE GREEN2_BOLD " therads" COLOR_NONE, threadNum); @@ -309,16 +309,18 @@ namespace skkk { tp.commit(extractNodeTaskMultiThread, eNode, outDir); } - int i = 0; - while (extractTaskRunCount < nodeOtherSize) { - if (i != extractTaskRunCount) { - printExtractProgress(nodeOtherSize, extractTaskRunCount, 1, false); - i = extractTaskRunCount; + if (!isSilent) { + int i = 0; + while (extractTaskRunCount < nodeOtherSize) { + if (i != extractTaskRunCount) { + printExtractProgress(nodeOtherSize, extractTaskRunCount, 1, false); + i = extractTaskRunCount; + } + sleep(0); } - sleep(0); + printExtractProgress(1, 1, 1, true); + LOGCD("extractTaskRunCount=%d nodeFilesSize=%d", i, nodeOtherSize, nodeOther.size()); } - printExtractProgress(1, 1, 1, true); - LOGCD("extractTaskRunCount=%d nodeFilesSize=%d", i, nodeOtherSize, nodeOther.size()); writeExceptionInfo2File(); } diff --git a/extract/include/ExtractOperation.h b/extract/include/ExtractOperation.h index 273ca85d..7091e0a6 100644 --- a/extract/include/ExtractOperation.h +++ b/extract/include/ExtractOperation.h @@ -67,6 +67,7 @@ namespace skkk { string targetPath; string targetConfigPath; bool extractOnlyConfAndSeLabel = false; + bool isSilent = false; public: @@ -130,9 +131,9 @@ namespace skkk { void extractNodeDirs() const; - void extractErofsNode() const; + void extractErofsNode(bool isSilent) const; - void extractErofsNodeMultiThread() const; + void extractErofsNodeMultiThread(bool isSilent) const; }; /** diff --git a/extract/main.cpp b/extract/main.cpp index 5ca08145..b987a90c 100644 --- a/extract/main.cpp +++ b/extract/main.cpp @@ -47,6 +47,7 @@ static inline void usage() { " " GREEN2_BOLD "-X, --extract=X" COLOR_NONE " " BROWN "Extract the target of path X" COLOR_NONE "\n" " " GREEN2_BOLD "-c, --config=[FILE]" COLOR_NONE " " BROWN "Target of config" COLOR_NONE "\n" " " GREEN2_BOLD "-r" COLOR_NONE " " BROWN "When using config, recurse directories" COLOR_NONE "\n" + " " GREEN2_BOLD "-s" COLOR_NONE " " BROWN "Silent mode, Don't show progress" COLOR_NONE "\n" " " GREEN2_BOLD "-f, --overwrite" COLOR_NONE " " BROWN "[" GREEN2_BOLD "default: skip" COLOR_NONE BROWN "] overwrite files that already exist" COLOR_NONE "\n" " " GREEN2_BOLD "-T#" COLOR_NONE " " BROWN "[" GREEN2_BOLD "1-%u" COLOR_NONE BROWN "] Use # threads, -T0: " GREEN2_BOLD "%u" COLOR_NONE COLOR_NONE "\n" " " GREEN2_BOLD "--only-cfg" COLOR_NONE " " BROWN "Only extract fs_config|file_contexts|fs_options" COLOR_NONE "\n" @@ -85,7 +86,7 @@ static int parseAndCheckExtractCfg(int argc, char **argv) { int opt; int rc = RET_EXTRACT_CONFIG_FAIL; bool enterParseOpt = false; - while ((opt = getopt_long(argc, argv, "hi:pxfrc:P:T:o:X:V", arg_options, nullptr)) != -1) { + while ((opt = getopt_long(argc, argv, "hi:psxfrc:P:T:o:X:V", arg_options, nullptr)) != -1) { enterParseOpt = true; switch (opt) { case 'h': @@ -135,6 +136,10 @@ static int parseAndCheckExtractCfg(int argc, char **argv) { if (optarg) eo->targetConfigPath = optarg; LOGCD("targetConfig=%s", eo->targetConfigPath.c_str()); break; + case 's': + eo->isSilent = true; + LOGCD("isSilent=%d", eo->isSilent); + break; case 'r': eo->targetConfigRecurse = true; LOGCD("targetConfigRecurse=%d", eo->targetConfigRecurse); @@ -282,7 +287,7 @@ int main(int argc, char **argv) { LOGCW("Failed change case sensitive."); #endif eo->extractFsConfigAndSelinuxLabelAndFsOptions(); - eo->useMultiThread ? eo->extractErofsNodeMultiThread() : eo->extractErofsNode(); + eo->useMultiThread ? eo->extractErofsNodeMultiThread(eo->isSilent) : eo->extractErofsNode(eo->isSilent); goto end; }