Git-Url: http://git.frugalware.org/gitweb/gitweb.cgi?p=fwsetup-ng.git;a=commitdiff;h=c1da9a06020ff94cde3aed502f651ae6b6db5117
commit c1da9a06020ff94cde3aed502f651ae6b6db5117 Author: James Buren <[email protected]> Date: Tue Aug 21 15:41:56 2012 -0500 complete write code for DosPartitionTable diff --git a/DosPartitionTable.cc b/DosPartitionTable.cc index 2813789..f571353 100644 --- a/DosPartitionTable.cc +++ b/DosPartitionTable.cc @@ -1,7 +1,11 @@ #include <blkid.h> #include <fcntl.h> #include <unistd.h> +#include <sys/wait.h> +#include <string.h> +#include <errno.h> #include <sstream> +#include "Utility.hh" #include "DosPartition.hh" #include "DosPartitionTable.hh" @@ -10,6 +14,7 @@ using std::stringstream; using std::dec; using std::hex; +using std::endl; DosPartitionTable::DosPartitionTable() { @@ -105,6 +110,8 @@ bool DosPartitionTable::write(const string &path) stringstream cmd; size_t i = 0; DosPartition *part = 0; + pid_t pid = -1; + int status = 0; if(_table.empty()) return false; @@ -130,5 +137,23 @@ bool DosPartitionTable::write(const string &path) cmd << "' | sfdisk --unit S --Linux " << path; + logfile << "Executing command: " << cmd.str() << endl; + + pid = execute(cmd.str()); + + if(pid == -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
