Git-Url: http://git.frugalware.org/gitweb/gitweb.cgi?p=fwsetup-ng.git;a=commitdiff;h=a68fccf4a5cd378592e430bf1b7e61c5d44c23f6
commit a68fccf4a5cd378592e430bf1b7e61c5d44c23f6 Author: James Buren <[email protected]> Date: Tue Aug 21 15:52:33 2012 -0500 implement writing in gpt partition table diff --git a/GptPartitionTable.cc b/GptPartitionTable.cc index 34fb633..4a7058d 100644 --- a/GptPartitionTable.cc +++ b/GptPartitionTable.cc @@ -3,8 +3,11 @@ #include <unistd.h> #include <stdio.h> #include <string.h> +#include <sys/wait.h> +#include <errno.h> #include <limits.h> #include <sstream> +#include "Utility.hh" #include "GptPartition.hh" #include "GptPartitionTable.hh" @@ -13,6 +16,7 @@ using std::stringstream; using std::dec; using std::hex; +using std::endl; static string get_gpt_label_uuid(const string &path) { @@ -147,7 +151,9 @@ bool GptPartitionTable::write(const string &path) stringstream cmd; size_t i = 0; GptPartition *part = 0; - + pid_t pid = -1; + int status = 0; + if(_table.empty()) return false; @@ -174,6 +180,22 @@ bool GptPartitionTable::write(const string &path) cmd << " " << path; + logfile << "Executing command: " << cmd.str() << endl; + + if((pid == execute(cmd.str())) == -1 || waitpid(pid,&status,0) == -1) + { + logfile << __func__ << ": " << strerror(errno) << endl; + return false; + } + + if(!WIFEXITED(status) || WEXITSTATUS(status) != 0) + { + logfile << "Command did not exit normally: " << cmd.str() << endl; + return false; + } + + logfile << "Finished executing command: " << cmd.str() << endl; + return true; } _______________________________________________ Frugalware-git mailing list [email protected] http://frugalware.org/mailman/listinfo/frugalware-git
