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

commit 350b5e74db18ba2f2553e01b19b5c79923bf3876
Author: James Buren <[email protected]>
Date:   Sun Aug 26 17:11:28 2012 -0500

implement device write method

diff --git a/Device.cc b/Device.cc
index ac18335..0601000 100644
--- a/Device.cc
+++ b/Device.cc
@@ -154,7 +154,7 @@ bool Device::read(const string &path)
size = blkid_probe_get_size(probe);

sectors = size / sectorsize;
-
+
// Now, perform some sanity checks on the topology data.
if(sectorsize == 0 || (MEBIBYTE % sectorsize) != 0 || size <= 0 || (size % 
sectorsize) != 0)
goto bail;
@@ -214,6 +214,14 @@ bail:
return rv;
}

+bool Device::write()
+{
+  if(!_initialized || !_disk || _table == 0 || _table->getTableSize() == 0)
+    return false;
+
+  return _table->write(_path);
+}
+
void Device::newPartitionTable(const string &label)
{
if(!_initialized || (label != "dos" && label != "gpt"))
diff --git a/Device.hh b/Device.hh
index 83df6fc..d2c9b12 100644
--- a/Device.hh
+++ b/Device.hh
@@ -15,6 +15,7 @@ public:
~Device();
static vector <Device> probeAll();
bool read(const string &path);
+  bool write();
unsigned long long sizeToSectors(unsigned long long size) { return size / 
_sectorsize; }
unsigned long long sectorsToSize(unsigned long long sectors) { return sectors * 
_sectorsize; }
string getLabelType() { return (_table != 0) ? _table->getLabelType() : 
"unknown"; }
_______________________________________________
Frugalware-git mailing list
[email protected]
http://frugalware.org/mailman/listinfo/frugalware-git

Reply via email to