FS helpers #604
@ -248,6 +248,7 @@ ReturnValue_t CoreController::executeAction(ActionId_t actionId, MessageQueueId_
|
|||||||
}
|
}
|
||||||
auto &sourceTgt = parser.destTgtPair();
|
auto &sourceTgt = parser.destTgtPair();
|
||||||
oss << sourceTgt.sourceName << " " << sourceTgt.targetName;
|
oss << sourceTgt.sourceName << " " << sourceTgt.targetName;
|
||||||
|
sif::info << "CoreController: Performing copy command: " << oss.str() << std::endl;
|
||||||
int ret = std::system(oss.str().c_str());
|
int ret = std::system(oss.str().c_str());
|
||||||
if (ret != 0) {
|
if (ret != 0) {
|
||||||
return returnvalue::FAILED;
|
return returnvalue::FAILED;
|
||||||
@ -263,6 +264,7 @@ ReturnValue_t CoreController::executeAction(ActionId_t actionId, MessageQueueId_
|
|||||||
std::ostringstream oss("mv ", std::ostringstream::ate);
|
std::ostringstream oss("mv ", std::ostringstream::ate);
|
||||||
auto &sourceTgt = parser.destTgtPair();
|
auto &sourceTgt = parser.destTgtPair();
|
||||||
oss << sourceTgt.sourceName << " " << sourceTgt.targetName;
|
oss << sourceTgt.sourceName << " " << sourceTgt.targetName;
|
||||||
|
sif::info << "CoreController: Performing move command: " << oss.str() << std::endl;
|
||||||
int ret = std::system(oss.str().c_str());
|
int ret = std::system(oss.str().c_str());
|
||||||
if (ret != 0) {
|
if (ret != 0) {
|
||||||
return returnvalue::FAILED;
|
return returnvalue::FAILED;
|
||||||
@ -288,6 +290,21 @@ ReturnValue_t CoreController::executeAction(ActionId_t actionId, MessageQueueId_
|
|||||||
size_t removeTargetSize = 0;
|
size_t removeTargetSize = 0;
|
||||||
const char *removeTgt = parser.getRemoveTarget(removeTargetSize);
|
const char *removeTgt = parser.getRemoveTarget(removeTargetSize);
|
||||||
oss << " " << removeTgt;
|
oss << " " << removeTgt;
|
||||||
|
sif::info << "CoreController: Performing remove command: " << oss.str() << std::endl;
|
||||||
|
int ret = std::system(oss.str().c_str());
|
||||||
|
if (ret != 0) {
|
||||||
|
return returnvalue::FAILED;
|
||||||
|
}
|
||||||
|
return EXECUTION_FINISHED;
|
||||||
|
}
|
||||||
|
case (MKDIR_HELPER): {
|
||||||
|
if (size < 1) {
|
||||||
|
return HasActionsIF::INVALID_PARAMETERS;
|
||||||
|
}
|
||||||
|
std::string createdDir = std::string(reinterpret_cast<const char *>(data), size);
|
||||||
|
std::ostringstream oss("mkdir ", std::ostringstream::ate);
|
||||||
|
oss << createdDir;
|
||||||
|
sif::info << "CoreController: Performing directory creation: " << oss.str() << std::endl;
|
||||||
int ret = std::system(oss.str().c_str());
|
int ret = std::system(oss.str().c_str());
|
||||||
if (ret != 0) {
|
if (ret != 0) {
|
||||||
return returnvalue::FAILED;
|
return returnvalue::FAILED;
|
||||||
@ -1000,17 +1017,17 @@ ReturnValue_t CoreController::actionListDirectoryDumpDirectly(ActionId_t actionI
|
|||||||
return returnvalue::FAILED;
|
return returnvalue::FAILED;
|
||||||
}
|
}
|
||||||
if (parser.compressionOptionSet()) {
|
if (parser.compressionOptionSet()) {
|
||||||
std::string compressedName = LIST_DIR_DUMP_WORK_FILE + std::string(".tar.xz");
|
std::string compressedName = LIST_DIR_DUMP_WORK_FILE + std::string(".gz");
|
||||||
oss.str("");
|
oss.str("");
|
||||||
oss << "tar -cJvf /tmp/dir_listing_compressed.tmp " << LIST_DIR_DUMP_WORK_FILE;
|
oss << "gzip " << LIST_DIR_DUMP_WORK_FILE;
|
||||||
ret = std::system(oss.str().c_str());
|
ret = std::system(oss.str().c_str());
|
||||||
if (ret != 0) {
|
if (ret != 0) {
|
||||||
utility::handleSystemError(result, "CoreController::actionListDirectoryDumpDirectly");
|
utility::handleSystemError(result, "CoreController::actionListDirectoryDumpDirectly");
|
||||||
return returnvalue::FAILED;
|
return returnvalue::FAILED;
|
||||||
}
|
}
|
||||||
oss.str("");
|
oss.str("");
|
||||||
// Overwrite the old work file with the compressed archive.
|
// Overwrite the work file with the compressed archive.
|
||||||
oss << "mv /tmp/dir_listing_compressed.tmp " << LIST_DIR_DUMP_WORK_FILE;
|
oss << "mv " << compressedName << " " << LIST_DIR_DUMP_WORK_FILE;
|
||||||
ret = std::system(oss.str().c_str());
|
ret = std::system(oss.str().c_str());
|
||||||
if (ret != 0) {
|
if (ret != 0) {
|
||||||
utility::handleSystemError(result, "CoreController::actionListDirectoryDumpDirectly");
|
utility::handleSystemError(result, "CoreController::actionListDirectoryDumpDirectly");
|
||||||
@ -1085,9 +1102,9 @@ ReturnValue_t CoreController::actionListDirectoryIntoFile(ActionId_t actionId,
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (parser.compressionOptionSet()) {
|
if (parser.compressionOptionSet()) {
|
||||||
std::string compressedName = targetFileName + std::string(".tar.xz");
|
std::string compressedName = targetFileName + std::string(".gz");
|
||||||
oss.str("");
|
oss.str("");
|
||||||
oss << "tar -cJvf " << compressedName << " " << targetFileName;
|
oss << "gzip -c " << compressedName << " > " << targetFileName;
|
||||||
sif::info << "Compressing directory listing: " << oss.str() << std::endl;
|
sif::info << "Compressing directory listing: " << oss.str() << std::endl;
|
||||||
ret = std::system(oss.str().c_str());
|
ret = std::system(oss.str().c_str());
|
||||||
if (ret != 0) {
|
if (ret != 0) {
|
||||||
|
@ -63,6 +63,7 @@ static constexpr ActionId_t LIST_DIRECTORY_DUMP_DIRECTLY = 51;
|
|||||||
static constexpr ActionId_t CP_HELPER = 52;
|
static constexpr ActionId_t CP_HELPER = 52;
|
||||||
static constexpr ActionId_t MV_HELPER = 53;
|
static constexpr ActionId_t MV_HELPER = 53;
|
||||||
static constexpr ActionId_t RM_HELPER = 54;
|
static constexpr ActionId_t RM_HELPER = 54;
|
||||||
|
static constexpr ActionId_t MKDIR_HELPER = 55;
|
||||||
|
|
||||||
static constexpr uint8_t SUBSYSTEM_ID = SUBSYSTEM_ID::CORE;
|
static constexpr uint8_t SUBSYSTEM_ID = SUBSYSTEM_ID::CORE;
|
||||||
|
|
||||||
@ -211,7 +212,7 @@ static ReturnValue_t parseDestTargetString(const uint8_t* data, size_t maxLen,
|
|||||||
return HasActionsIF::INVALID_PARAMETERS;
|
return HasActionsIF::INVALID_PARAMETERS;
|
||||||
}
|
}
|
||||||
destTgt.sourceName = reinterpret_cast<const char*>(data);
|
destTgt.sourceName = reinterpret_cast<const char*>(data);
|
||||||
size_t remainingLen = maxLen - destTgt.sourceNameSize + 1;
|
size_t remainingLen = maxLen - destTgt.sourceNameSize - 1;
|
||||||
if (remainingLen == 0) {
|
if (remainingLen == 0) {
|
||||||
return HasActionsIF::INVALID_PARAMETERS;
|
return HasActionsIF::INVALID_PARAMETERS;
|
||||||
}
|
}
|
||||||
@ -220,7 +221,7 @@ static ReturnValue_t parseDestTargetString(const uint8_t* data, size_t maxLen,
|
|||||||
if (destTgt.targetNameSize >= remainingLen) {
|
if (destTgt.targetNameSize >= remainingLen) {
|
||||||
return HasActionsIF::INVALID_PARAMETERS;
|
return HasActionsIF::INVALID_PARAMETERS;
|
||||||
}
|
}
|
||||||
destTgt.targetName = reinterpret_cast<const char*>(data + destTgt.targetNameSize + 1);
|
destTgt.targetName = reinterpret_cast<const char*>(data + destTgt.sourceNameSize + 1);
|
||||||
return returnvalue::OK;
|
return returnvalue::OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
2
tmtc
2
tmtc
@ -1 +1 @@
|
|||||||
Subproject commit 37bb164cc461abd51668038e02c5f76db70e7ca6
|
Subproject commit 77e90328a1e1ffd0d79bc4c26932ad48adbf2920
|
Loading…
Reference in New Issue
Block a user