Author: aschnell
Date: Wed Jan 28 15:19:27 2009
New Revision: 55118
URL: http://svn.opensuse.org/viewcvs/yast?rev=55118&view=rev
Log:
- waitForDevice as a static function of Storage is even nicer
Modified:
trunk/storage/libstorage/src/AppUtil.cc
trunk/storage/libstorage/src/AppUtil.h
trunk/storage/libstorage/src/Disk.cc
trunk/storage/libstorage/src/DmCo.cc
trunk/storage/libstorage/src/DmPartCo.cc
trunk/storage/libstorage/src/DmraidCo.cc
trunk/storage/libstorage/src/LvmVg.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
Modified: trunk/storage/libstorage/src/AppUtil.cc
URL: http://svn.opensuse.org/viewcvs/yast/trunk/storage/libstorage/src/AppUtil.cc?rev=55118&r1=55117&r2=55118&view=diff
==============================================================================
--- trunk/storage/libstorage/src/AppUtil.cc (original)
+++ trunk/storage/libstorage/src/AppUtil.cc Wed Jan 28 15:19:27 2009
@@ -22,7 +22,6 @@
#include "y2storage/StorageTmpl.h"
#include "y2storage/AppUtil.h"
#include "y2storage/SystemCmd.h"
-#include "y2storage/StorageDefines.h"
using namespace std;
@@ -502,23 +501,6 @@
}
-void
-udevSettle()
-{
- if (access(UDEVADM, X_OK) == 0)
- {
- string cmd(UDEVADM " settle --timeout=20");
- y2mil("calling prog:" << cmd);
- SystemCmd c(cmd);
- y2mil("returned prog:" << cmd << " retcode:" << c.retcode());
- }
- else
- {
- y2error(UDEVADM " not available");
- }
-}
-
-
unsigned getMajorDevices( const string& driver )
{
unsigned ret=0;
Modified: trunk/storage/libstorage/src/AppUtil.h
URL: http://svn.opensuse.org/viewcvs/yast/trunk/storage/libstorage/src/AppUtil.h?rev=55118&r1=55117&r2=55118&view=diff
==============================================================================
--- trunk/storage/libstorage/src/AppUtil.h (original)
+++ trunk/storage/libstorage/src/AppUtil.h Wed Jan 28 15:19:27 2009
@@ -40,8 +40,6 @@
void getUdevMap(const char* path, std::map& m);
void getRevUdevMap(const char* path, std::map& m);
-void udevSettle();
-
string normalizeDevice( const string& dev );
void normalizeDevice( string& dev );
string undevDevice( const string& dev );
Modified: trunk/storage/libstorage/src/Disk.cc
URL: http://svn.opensuse.org/viewcvs/yast/trunk/storage/libstorage/src/Disk.cc?rev=55118&r1=55117&r2=55118&view=diff
==============================================================================
--- trunk/storage/libstorage/src/Disk.cc (original)
+++ trunk/storage/libstorage/src/Disk.cc Wed Jan 28 15:19:27 2009
@@ -1891,7 +1891,7 @@
if( ret==0 )
{
if( !dmp_slave )
- getStorage()->waitForDevice();
+ Storage::waitForDevice();
redetectGeometry();
}
gpt_enlarge = false;
@@ -2278,7 +2278,7 @@
if( p->type()!=EXTENDED )
getStorage()->waitForDevice( p->device() );
else
- getStorage()->waitForDevice();
+ Storage::waitForDevice();
if( p->type()==LOGICAL && getStorage()->instsys() )
{
// kludge to make the extended partition visible in
@@ -2376,7 +2376,7 @@
redetectGeometry();
}
if( ret==0 && !dmp_slave )
- getStorage()->waitForDevice();
+ Storage::waitForDevice();
}
else
{
Modified: trunk/storage/libstorage/src/DmCo.cc
URL: http://svn.opensuse.org/viewcvs/yast/trunk/storage/libstorage/src/DmCo.cc?rev=55118&r1=55117&r2=55118&view=diff
==============================================================================
--- trunk/storage/libstorage/src/DmCo.cc (original)
+++ trunk/storage/libstorage/src/DmCo.cc Wed Jan 28 15:19:27 2009
@@ -334,7 +334,7 @@
if( c.retcode()!=0 )
ret = DM_REMOVE_FAILED;
else
- getStorage()->waitForDevice();
+ Storage::waitForDevice();
y2mil( "this:" << *this );
getStorage()->logProcData( cmd );
}
Modified: trunk/storage/libstorage/src/DmPartCo.cc
URL: http://svn.opensuse.org/viewcvs/yast/trunk/storage/libstorage/src/DmPartCo.cc?rev=55118&r1=55117&r2=55118&view=diff
==============================================================================
--- trunk/storage/libstorage/src/DmPartCo.cc (original)
+++ trunk/storage/libstorage/src/DmPartCo.cc Wed Jan 28 15:19:27 2009
@@ -572,7 +572,7 @@
del_ptable = false;
removeFromMemory();
handleWholeDevice();
- getStorage()->waitForDevice();
+ Storage::waitForDevice();
}
y2mil("ret:" << ret);
return( ret );
@@ -826,7 +826,7 @@
updateMinor();
}
if( ret==0 )
- getStorage()->waitForDevice();
+ Storage::waitForDevice();
y2mil("ret:" << ret);
return( ret );
}
@@ -1072,7 +1072,7 @@
disk = NULL;
if( rhs.disk )
disk = new Disk( *rhs.disk );
- getStorage()->waitForDevice();
+ Storage::waitForDevice();
ConstDmPartPair p = rhs.dmpartPair();
for( ConstDmPartIter i = p.begin(); i!=p.end(); ++i )
{
Modified: trunk/storage/libstorage/src/DmraidCo.cc
URL: http://svn.opensuse.org/viewcvs/yast/trunk/storage/libstorage/src/DmraidCo.cc?rev=55118&r1=55117&r2=55118&view=diff
==============================================================================
--- trunk/storage/libstorage/src/DmraidCo.cc (original)
+++ trunk/storage/libstorage/src/DmraidCo.cc Wed Jan 28 15:19:27 2009
@@ -124,7 +124,7 @@
}
active = val;
}
- udevSettle();
+ Storage::waitForDevice();
}
void DmraidCo::getRaids( list<string>& l )
Modified: trunk/storage/libstorage/src/LvmVg.cc
URL: http://svn.opensuse.org/viewcvs/yast/trunk/storage/libstorage/src/LvmVg.cc?rev=55118&r1=55117&r2=55118&view=diff
==============================================================================
--- trunk/storage/libstorage/src/LvmVg.cc (original)
+++ trunk/storage/libstorage/src/LvmVg.cc Wed Jan 28 15:19:27 2009
@@ -1108,7 +1108,7 @@
active = val;
}
- udevSettle();
+ Storage::waitForDevice();
}
Modified: trunk/storage/libstorage/src/MdCo.cc
URL: http://svn.opensuse.org/viewcvs/yast/trunk/storage/libstorage/src/MdCo.cc?rev=55118&r1=55117&r2=55118&view=diff
==============================================================================
--- trunk/storage/libstorage/src/MdCo.cc (original)
+++ trunk/storage/libstorage/src/MdCo.cc Wed Jan 28 15:19:27 2009
@@ -585,7 +585,7 @@
}
active = val;
}
- udevSettle();
+ Storage::waitForDevice();
}
int
Modified: trunk/storage/libstorage/src/Storage.cc
URL: http://svn.opensuse.org/viewcvs/yast/trunk/storage/libstorage/src/Storage.cc?rev=55118&r1=55117&r2=55118&view=diff
==============================================================================
--- trunk/storage/libstorage/src/Storage.cc (original)
+++ trunk/storage/libstorage/src/Storage.cc Wed Jan 28 15:19:27 2009
@@ -5794,34 +5794,39 @@
}
-void Storage::waitForDevice() const
-{
- udevSettle();
+void
+Storage::waitForDevice()
+{
+ string cmd(UDEVADM " settle --timeout=20");
+ y2mil("calling prog:" << cmd);
+ SystemCmd c(cmd);
+ y2mil("returned prog:" << cmd << " retcode:" << c.retcode());
}
-int Storage::waitForDevice( const string& device ) const
- {
+int
+Storage::waitForDevice(const string& device) const
+{
int ret = 0;
- udevSettle();
- bool exist = access( device.c_str(), R_OK )==0;
- y2milestone( "device:%s exist:%d", device.c_str(), exist );
- if( !exist )
+ waitForDevice();
+ bool exist = access(device.c_str(), R_OK)==0;
+ y2mil("device:" << device << " exist:" << exist);
+ if (!exist)
+ {
+ for (int count = 0; count < 500; count++)
{
- unsigned count=0;
- while( !exist && count<500 )
- {
- usleep( 10000 );
- exist = access( device.c_str(), R_OK )==0;
- count++;
- }
- y2milestone( "device:%s exist:%d", device.c_str(), exist );
+ usleep(10000);
+ exist = access(device.c_str(), R_OK) == 0;
+ if (exist)
+ break;
}
- if( !exist )
+ y2mil("device:" << device << " exist:" << exist);
+ }
+ if (!exist)
ret = STORAGE_DEVICE_NODE_NOT_FOUND;
y2mil("ret:" << ret);
- return( ret );
- }
+ return ret;
+}
void Storage::checkDeviceExclusive( const string& device, unsigned secs )
Modified: trunk/storage/libstorage/src/Storage.h
URL: http://svn.opensuse.org/viewcvs/yast/trunk/storage/libstorage/src/Storage.h?rev=55118&r1=55117&r2=55118&view=diff
==============================================================================
--- trunk/storage/libstorage/src/Storage.h (original)
+++ trunk/storage/libstorage/src/Storage.h Wed Jan 28 15:19:27 2009
@@ -450,8 +450,8 @@
const string& getExtendedErrorMessage() const { return extendedError; }
void eraseFreeInfo( const string& device );
- void waitForDevice() const;
- int waitForDevice( const string& device ) const;
+ static void waitForDevice();
+ 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);
Modified: trunk/storage/libstorage/src/Volume.cc
URL: http://svn.opensuse.org/viewcvs/yast/trunk/storage/libstorage/src/Volume.cc?rev=55118&r1=55117&r2=55118&view=diff
==============================================================================
--- trunk/storage/libstorage/src/Volume.cc (original)
+++ trunk/storage/libstorage/src/Volume.cc Wed Jan 28 15:19:27 2009
@@ -904,7 +904,7 @@
y2mil( "writing \"add\" to " << path );
file << "add" << endl;
file.close();
- cont->getStorage()->waitForDevice();
+ Storage::waitForDevice();
}
else
y2mil( "error opening " << path << " err:" <<
--
To unsubscribe, e-mail: yast-commit+unsubscribe@opensuse.org
For additional commands, e-mail: yast-commit+help@opensuse.org