Author: aschnell
Date: Fri Aug 22 14:12:55 2008
New Revision: 50332
URL: http://svn.opensuse.org/viewcvs/yast?rev=50332&view=rev
Log:
- refactored zeroing devices (maybe helps for bug #409528)
Modified:
trunk/storage/libstorage/src/Disk.cc
trunk/storage/libstorage/src/MdCo.cc
trunk/storage/libstorage/src/Storage.cc
trunk/storage/libstorage/src/Storage.h
trunk/storage/libstorage/src/Volume.cc
trunk/storage/package/yast2-storage.changes
Modified: trunk/storage/libstorage/src/Disk.cc
URL: http://svn.opensuse.org/viewcvs/yast/trunk/storage/libstorage/src/Disk.cc?rev=50332&r1=50331&r2=50332&view=diff
==============================================================================
--- trunk/storage/libstorage/src/Disk.cc (original)
+++ trunk/storage/libstorage/src/Disk.cc Fri Aug 22 14:12:55 2008
@@ -2282,18 +2282,7 @@
getStorage()->getZeroNewPartitions(), used_as_pv );
if( used_as_pv || getStorage()->getZeroNewPartitions() )
{
- string cmd;
- SystemCmd c;
- cmd = DDBIN " if=/dev/zero of=" + quote(p->device()) + " bs=1k count=200";
- c.execute( cmd );
- unsigned long long pos = p->sizeK();
- if( pos>200 )
- {
- pos -= 200;
- cmd = DDBIN " if=/dev/zero of=" + quote(p->device()) +
- " seek=" + decString(pos) + " bs=1k count=10";
- c.execute( cmd );
- }
+ ret = getStorage()->zeroDevice(p->device(), p->sizeK());
}
else if( !dmp_slave && !p->getFormat() )
{
Modified: trunk/storage/libstorage/src/MdCo.cc
URL: http://svn.opensuse.org/viewcvs/yast/trunk/storage/libstorage/src/MdCo.cc?rev=50332&r1=50331&r2=50332&view=diff
==============================================================================
--- trunk/storage/libstorage/src/MdCo.cc (original)
+++ trunk/storage/libstorage/src/MdCo.cc Fri Aug 22 14:12:55 2008
@@ -629,14 +629,7 @@
getStorage()->getZeroNewPartitions(), used_as_pv );
if( used_as_pv || getStorage()->getZeroNewPartitions() )
{
- string cmd;
- SystemCmd c;
- cmd = DDBIN " if=/dev/zero of=" + quote(m->device()) + " bs=1k count=200";
- c.execute( cmd );
- cmd = DDBIN " if=/dev/zero of=" + quote(m->device()) +
- " seek=" + decString(m->sizeK()-10) +
- " bs=1k count=10";
- c.execute( cmd );
+ ret = getStorage()->zeroDevice(m->device(), m->sizeK());
}
}
}
Modified: trunk/storage/libstorage/src/Storage.cc
URL: http://svn.opensuse.org/viewcvs/yast/trunk/storage/libstorage/src/Storage.cc?rev=50332&r1=50331&r2=50332&view=diff
==============================================================================
--- trunk/storage/libstorage/src/Storage.cc (original)
+++ trunk/storage/libstorage/src/Storage.cc Fri Aug 22 14:12:55 2008
@@ -5763,6 +5763,36 @@
}
+int
+Storage::zeroDevice(const string& device, unsigned long long sizeK, bool random,
+ unsigned long long startK, unsigned long long endK)
+{
+ y2mil("device:" << device << " sizeK:" << sizeK << " random:" << random <<
+ "startK:" << startK << " endK:" << endK);
+
+ int ret = 0;
+
+ const string source = (random ? "/dev/urandom" : "/dev/zero");
+
+ SystemCmd c;
+ string cmd;
+
+ startK = min(startK, sizeK);
+ cmd = DDBIN " if=" + source + " of=" + quote(device) + " bs=1k count=" + decString(startK);
+ if (c.execute(cmd) != 0)
+ ret = VOLUME_FORMAT_DD_FAILED;
+
+ endK = min(endK, sizeK);
+ cmd = DDBIN " if=" + source + " of=" + quote(device) + " seek=" + decString(sizeK - endK) +
+ " bs=1k count=" + decString(endK);
+ if (c.execute(cmd) != 0)
+ ret = VOLUME_FORMAT_DD_FAILED;
+
+ y2mil("ret:" << ret);
+ return ret;
+}
+
+
string Storage::byteToHumanString(unsigned long long size, bool classic, int precision,
bool omit_zeroes) const
{
Modified: trunk/storage/libstorage/src/Storage.h
URL: http://svn.opensuse.org/viewcvs/yast/trunk/storage/libstorage/src/Storage.h?rev=50332&r1=50331&r2=50332&view=diff
==============================================================================
--- trunk/storage/libstorage/src/Storage.h (original)
+++ trunk/storage/libstorage/src/Storage.h Fri Aug 22 14:12:55 2008
@@ -444,9 +444,13 @@
const string& getLastAction() const { return lastAction; }
const string& getExtendedErrorMessage() const { return extendedError; }
void eraseFreeInfo( const string& device );
+
int waitForDevice() const;
int waitForDevice( const string& device ) const;
void checkDeviceExclusive( const string& device, unsigned secs );
+ int zeroDevice(const string& device, unsigned long long sizeK, bool random = false,
+ unsigned long long beginK = 200, unsigned long long endK = 10);
+
void getDiskList( bool (* CheckFnc)( const Disk& ),
std::list