Git-Url: 
http://git.frugalware.org/gitweb/gitweb.cgi?p=fwsetup-ng.git;a=commitdiff;h=3ea63804e6e9d949e70259bde6a4cbc3628f46b9

commit 3ea63804e6e9d949e70259bde6a4cbc3628f46b9
Author: James Buren <[email protected]>
Date:   Tue Aug 21 14:26:25 2012 -0500

import initial dospartitiontable write support

diff --git a/DosPartitionTable.cc b/DosPartitionTable.cc
index fbe2c1d..2813789 100644
--- a/DosPartitionTable.cc
+++ b/DosPartitionTable.cc
@@ -1,11 +1,16 @@
#include <blkid.h>
#include <fcntl.h>
#include <unistd.h>
+#include <sstream>
#include "DosPartition.hh"
#include "DosPartitionTable.hh"

#define MAX_PARTITIONS 60

+using std::stringstream;
+using std::dec;
+using std::hex;
+
DosPartitionTable::DosPartitionTable()
{
}
@@ -97,5 +102,33 @@ bail:

bool DosPartitionTable::write(const string &path)
{
+  stringstream cmd;
+  size_t i = 0;
+  DosPartition *part = 0;
+
+  if(_table.empty())
+    return false;
+
+  cmd << "echo -n -e '";
+
+  while(i < _table.size())
+  {
+    part = (DosPartition *) _table.at(i);
+    cmd << dec;
+    cmd << part->getStart();
+    cmd << " ";
+    cmd << part->getSectors();
+    cmd << " ";
+    cmd << hex;
+    cmd << "0x";
+    cmd << ((unsigned int) part->getType());
+    cmd << " ";
+    cmd << (part->getActive() ? "*" : "-");
+    cmd << "\\n";
+    ++i;
+  }
+
+  cmd << "' | sfdisk --unit S --Linux " << path;
+
return true;
}
_______________________________________________
Frugalware-git mailing list
[email protected]
http://frugalware.org/mailman/listinfo/frugalware-git

Reply via email to