Added syncing and working directory param to execute
This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
#include "backing.h"
|
||||
|
||||
#include "sandbox.h"
|
||||
#include "container.h"
|
||||
#include "disk.h"
|
||||
|
||||
@@ -444,3 +445,42 @@ result_t get_backing_info(disk_info_t* _info, const char* backing) {
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
result_t sync_backing_pool(void) {
|
||||
// Execute /etc/sandbox.d/sync with the backing pool as the working directory
|
||||
int exit_code;
|
||||
// char* stdoutbuf;
|
||||
char* stderrbuf;
|
||||
|
||||
// Get the path of the backing pool
|
||||
char* pool_path;
|
||||
result_t result = get_backing_pool_path(&pool_path);
|
||||
if (result != success())
|
||||
return result;
|
||||
|
||||
// Execute the sync script
|
||||
result = execute(&exit_code, NULL, &stderrbuf, pool_path, "/etc/sandbox.d/sync", NULL);
|
||||
|
||||
free(pool_path);
|
||||
|
||||
// Check for errors during the execution
|
||||
if (result != success())
|
||||
return result;
|
||||
|
||||
// Check the exit code
|
||||
if (exit_code != 0) {
|
||||
// Remove all newlines from the stderr buffer
|
||||
for (char* c = stderrbuf; *c != '\0'; c++)
|
||||
if (*c == '\n')
|
||||
*c = ' ';
|
||||
|
||||
result = failure("Failed to synchronize the backing pool (%s).", stderrbuf);
|
||||
free(stderrbuf);
|
||||
return result;
|
||||
}
|
||||
|
||||
// Free the stderr buffer as it is not needed anymore
|
||||
free(stderrbuf);
|
||||
|
||||
return success();
|
||||
}
|
||||
|
Reference in New Issue
Block a user