pmt: add stdin parsing support, etc.
This commit is contained in:
@@ -31,7 +31,8 @@ namespace PartitionManager {
|
||||
RUN_ASYNC(const std::string &partitionName, const std::string &outputName,
|
||||
const uint64_t bufferSize) {
|
||||
if (!PART_MAP.hasPartition(partitionName))
|
||||
return {Helper::format("Couldn't find partition: %s", partitionName.data()), false};
|
||||
return {Helper::format("Couldn't find partition: %s", partitionName.data()),
|
||||
false};
|
||||
|
||||
LOGN(BFUN, INFO) << "Back upping " << partitionName << " as " << outputName
|
||||
<< std::endl;
|
||||
@@ -43,15 +44,15 @@ RUN_ASYNC(const std::string &partitionName, const std::string &outputName,
|
||||
<< " is exists but not logical. Ignoring (from --force, -f)."
|
||||
<< std::endl;
|
||||
else
|
||||
return {
|
||||
Helper::format("Used --logical (-l) flag but is not logical partition: %s",
|
||||
partitionName.data()),
|
||||
false};
|
||||
return {Helper::format(
|
||||
"Used --logical (-l) flag but is not logical partition: %s",
|
||||
partitionName.data()),
|
||||
false};
|
||||
}
|
||||
|
||||
if (Helper::fileIsExists(outputName) && !VARS.forceProcess)
|
||||
return {Helper::format("%s is exists. Remove it, or use --force (-f) flag.",
|
||||
outputName.data()),
|
||||
outputName.data()),
|
||||
false};
|
||||
|
||||
LOGN(BFUN, INFO) << "Using buffer size (for back upping " << partitionName
|
||||
@@ -64,14 +65,14 @@ RUN_ASYNC(const std::string &partitionName, const std::string &outputName,
|
||||
PART_MAP.getRealPathOf(partitionName), collector, O_RDONLY);
|
||||
if (pfd < 0)
|
||||
return {Helper::format("Can't open partition: %s: %s", partitionName.data(),
|
||||
strerror(errno)),
|
||||
strerror(errno)),
|
||||
false};
|
||||
|
||||
const int ffd = Helper::openAndAddToCloseList(
|
||||
outputName, collector, O_WRONLY | O_CREAT | O_TRUNC, 0644);
|
||||
if (ffd < 0)
|
||||
return {Helper::format("Can't create/open output file %s: %s", outputName.data(),
|
||||
strerror(errno)),
|
||||
return {Helper::format("Can't create/open output file %s: %s",
|
||||
outputName.data(), strerror(errno)),
|
||||
false};
|
||||
|
||||
LOGN(BFUN, INFO) << "Writing partition " << partitionName
|
||||
@@ -85,7 +86,7 @@ RUN_ASYNC(const std::string &partitionName, const std::string &outputName,
|
||||
if (const ssize_t bytesWritten = write(ffd, buffer, bytesRead);
|
||||
bytesWritten != bytesRead)
|
||||
return {Helper::format("Can't write partition to output file %s: %s",
|
||||
outputName.data(), strerror(errno)),
|
||||
outputName.data(), strerror(errno)),
|
||||
false};
|
||||
}
|
||||
|
||||
@@ -101,7 +102,7 @@ RUN_ASYNC(const std::string &partitionName, const std::string &outputName,
|
||||
<< std::endl;
|
||||
|
||||
return {Helper::format("%s partition successfully back upped to %s",
|
||||
partitionName.data(), outputName.data()),
|
||||
partitionName.data(), outputName.data()),
|
||||
true};
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user