Author: aschnell
Date: Fri Sep 25 12:19:24 2009
New Revision: 58770
URL: http://svn.opensuse.org/viewcvs/yast?rev=58770&view=rev
Log:
- added environment parameter to Storage constructor and factories
- pass instsys flag from YCP to libstorage (bnc #399390)
Removed:
branches/SuSE-Code-11-SP1-Branch/storage/libstorage/testsuite/common.cc
Modified:
branches/SuSE-Code-11-SP1-Branch/storage/VERSION
branches/SuSE-Code-11-SP1-Branch/storage/libstorage/examples/TestDisk.cc
branches/SuSE-Code-11-SP1-Branch/storage/libstorage/examples/TestDiskLog.cc
branches/SuSE-Code-11-SP1-Branch/storage/libstorage/examples/TestLoop.cc
branches/SuSE-Code-11-SP1-Branch/storage/libstorage/examples/TestLvm.cc
branches/SuSE-Code-11-SP1-Branch/storage/libstorage/examples/TestMd.cc
branches/SuSE-Code-11-SP1-Branch/storage/libstorage/examples/TestProbing.cc
branches/SuSE-Code-11-SP1-Branch/storage/libstorage/examples/TestStorage.cc
branches/SuSE-Code-11-SP1-Branch/storage/libstorage/src/Disk.cc
branches/SuSE-Code-11-SP1-Branch/storage/libstorage/src/Disk.h
branches/SuSE-Code-11-SP1-Branch/storage/libstorage/src/Storage.cc
branches/SuSE-Code-11-SP1-Branch/storage/libstorage/src/Storage.h
branches/SuSE-Code-11-SP1-Branch/storage/libstorage/src/StorageInterface.h
branches/SuSE-Code-11-SP1-Branch/storage/libstorage/src/Volume.cc
branches/SuSE-Code-11-SP1-Branch/storage/libstorage/testsuite-real/lvmcreate1.cc
branches/SuSE-Code-11-SP1-Branch/storage/libstorage/testsuite-real/lvmcreate2.cc
branches/SuSE-Code-11-SP1-Branch/storage/libstorage/testsuite-real/lvmextend1.cc
branches/SuSE-Code-11-SP1-Branch/storage/libstorage/testsuite-real/lvmextend2.cc
branches/SuSE-Code-11-SP1-Branch/storage/libstorage/testsuite/Makefile.am
branches/SuSE-Code-11-SP1-Branch/storage/libstorage/testsuite/common.h
branches/SuSE-Code-11-SP1-Branch/storage/libstorage/testsuite/format1.cc
branches/SuSE-Code-11-SP1-Branch/storage/libstorage/testsuite/fstab1.cc
branches/SuSE-Code-11-SP1-Branch/storage/libstorage/testsuite/humanstring1.cc
branches/SuSE-Code-11-SP1-Branch/storage/libstorage/testsuite/humanstring2.cc
branches/SuSE-Code-11-SP1-Branch/storage/libstorage/testsuite/lvm_create.cc
branches/SuSE-Code-11-SP1-Branch/storage/libstorage/testsuite/lvm_extend.cc
branches/SuSE-Code-11-SP1-Branch/storage/libstorage/testsuite/md_create.cc
branches/SuSE-Code-11-SP1-Branch/storage/libstorage/testsuite/partition1.cc
branches/SuSE-Code-11-SP1-Branch/storage/libstorage/testsuite/uuid1.cc
branches/SuSE-Code-11-SP1-Branch/storage/package/yast2-storage.changes
branches/SuSE-Code-11-SP1-Branch/storage/storage/src/modules/Storage.ycp
Modified: branches/SuSE-Code-11-SP1-Branch/storage/VERSION
URL: http://svn.opensuse.org/viewcvs/yast/branches/SuSE-Code-11-SP1-Branch/storage/VERSION?rev=58770&r1=58769&r2=58770&view=diff
==============================================================================
--- branches/SuSE-Code-11-SP1-Branch/storage/VERSION (original)
+++ branches/SuSE-Code-11-SP1-Branch/storage/VERSION Fri Sep 25 12:19:24 2009
@@ -1 +1 @@
-2.17.75
+2.17.76
Modified: branches/SuSE-Code-11-SP1-Branch/storage/libstorage/examples/TestDisk.cc
URL: http://svn.opensuse.org/viewcvs/yast/branches/SuSE-Code-11-SP1-Branch/storage/libstorage/examples/TestDisk.cc?rev=58770&r1=58769&r2=58770&view=diff
==============================================================================
--- branches/SuSE-Code-11-SP1-Branch/storage/libstorage/examples/TestDisk.cc (original)
+++ branches/SuSE-Code-11-SP1-Branch/storage/libstorage/examples/TestDisk.cc Fri Sep 25 12:19:24 2009
@@ -14,7 +14,7 @@
{
int ret;
initDefaultLogger();
- StorageInterface* s = createDefaultStorageInterface();
+ StorageInterface* s = createStorageInterface(Environment(false));
string disk = "/dev/hdb";
string dev;
ret = s->destroyPartitionTable( disk, s->defaultDiskLabel() );
Modified: branches/SuSE-Code-11-SP1-Branch/storage/libstorage/examples/TestDiskLog.cc
URL: http://svn.opensuse.org/viewcvs/yast/branches/SuSE-Code-11-SP1-Branch/storage/libstorage/examples/TestDiskLog.cc?rev=58770&r1=58769&r2=58770&view=diff
==============================================================================
--- branches/SuSE-Code-11-SP1-Branch/storage/libstorage/examples/TestDiskLog.cc (original)
+++ branches/SuSE-Code-11-SP1-Branch/storage/libstorage/examples/TestDiskLog.cc Fri Sep 25 12:19:24 2009
@@ -15,7 +15,7 @@
{
int ret;
initDefaultLogger();
- StorageInterface* s = createDefaultStorageInterface();
+ StorageInterface* s = createStorageInterface(Environment(false));
string dev;
ret = s->destroyPartitionTable( "/dev/hdb", s->defaultDiskLabel() );
if( ret ) cerr << "retcode:" << ret << endl;
Modified: branches/SuSE-Code-11-SP1-Branch/storage/libstorage/examples/TestLoop.cc
URL: http://svn.opensuse.org/viewcvs/yast/branches/SuSE-Code-11-SP1-Branch/storage/libstorage/examples/TestLoop.cc?rev=58770&r1=58769&r2=58770&view=diff
==============================================================================
--- branches/SuSE-Code-11-SP1-Branch/storage/libstorage/examples/TestLoop.cc (original)
+++ branches/SuSE-Code-11-SP1-Branch/storage/libstorage/examples/TestLoop.cc Fri Sep 25 12:19:24 2009
@@ -49,8 +49,7 @@
{
int ret = 0;
initDefaultLogger();
- //StorageInterface* s = createStorageInterface(false,true);
- StorageInterface* s = createDefaultStorageInterface();
+ StorageInterface* s = createStorageInterface(Environment(false));
s->setCallbackProgressBar( scrollbarCb );
s->setCallbackShowInstallInfo( installInfoCb );
string disk = "/dev/hdb";
Modified: branches/SuSE-Code-11-SP1-Branch/storage/libstorage/examples/TestLvm.cc
URL: http://svn.opensuse.org/viewcvs/yast/branches/SuSE-Code-11-SP1-Branch/storage/libstorage/examples/TestLvm.cc?rev=58770&r1=58769&r2=58770&view=diff
==============================================================================
--- branches/SuSE-Code-11-SP1-Branch/storage/libstorage/examples/TestLvm.cc (original)
+++ branches/SuSE-Code-11-SP1-Branch/storage/libstorage/examples/TestLvm.cc Fri Sep 25 12:19:24 2009
@@ -47,8 +47,7 @@
{
int ret = 0;
initDefaultLogger();
- //StorageInterface* s = createStorageInterface(false,true);
- StorageInterface* s = createDefaultStorageInterface();
+ StorageInterface* s = createStorageInterface(Environment(false));
s->setCallbackProgressBar( scrollbarCb );
s->setCallbackShowInstallInfo( installInfoCb );
string disk = "/dev/hdb";
Modified: branches/SuSE-Code-11-SP1-Branch/storage/libstorage/examples/TestMd.cc
URL: http://svn.opensuse.org/viewcvs/yast/branches/SuSE-Code-11-SP1-Branch/storage/libstorage/examples/TestMd.cc?rev=58770&r1=58769&r2=58770&view=diff
==============================================================================
--- branches/SuSE-Code-11-SP1-Branch/storage/libstorage/examples/TestMd.cc (original)
+++ branches/SuSE-Code-11-SP1-Branch/storage/libstorage/examples/TestMd.cc Fri Sep 25 12:19:24 2009
@@ -49,8 +49,7 @@
{
int ret = 0;
initDefaultLogger();
- //StorageInterface* s = createStorageInterface(false,true);
- StorageInterface* s = createDefaultStorageInterface();
+ StorageInterface* s = createStorageInterface(Environment(false));
s->setCallbackProgressBar( scrollbarCb );
s->setCallbackShowInstallInfo( installInfoCb );
string disk = "/dev/hdb";
Modified: branches/SuSE-Code-11-SP1-Branch/storage/libstorage/examples/TestProbing.cc
URL: http://svn.opensuse.org/viewcvs/yast/branches/SuSE-Code-11-SP1-Branch/storage/libstorage/examples/TestProbing.cc?rev=58770&r1=58769&r2=58770&view=diff
==============================================================================
--- branches/SuSE-Code-11-SP1-Branch/storage/libstorage/examples/TestProbing.cc (original)
+++ branches/SuSE-Code-11-SP1-Branch/storage/libstorage/examples/TestProbing.cc Fri Sep 25 12:19:24 2009
@@ -19,7 +19,7 @@
main (int argc, char** argv)
{
initDefaultLogger();
- StorageInterface* s = createStorageInterface (true, false, true);
+ StorageInterface* s = createStorageInterface(Environment(false));
deque<ContainerInfo> containers;
s->getContainers (containers);
Modified: branches/SuSE-Code-11-SP1-Branch/storage/libstorage/examples/TestStorage.cc
URL: http://svn.opensuse.org/viewcvs/yast/branches/SuSE-Code-11-SP1-Branch/storage/libstorage/examples/TestStorage.cc?rev=58770&r1=58769&r2=58770&view=diff
==============================================================================
--- branches/SuSE-Code-11-SP1-Branch/storage/libstorage/examples/TestStorage.cc (original)
+++ branches/SuSE-Code-11-SP1-Branch/storage/libstorage/examples/TestStorage.cc Fri Sep 25 12:19:24 2009
@@ -55,7 +55,7 @@
main( int argc_iv, char** argv_ppcv )
{
Storage::initDefaultLogger();
- Storage Sto( true, false, true );
+ Storage Sto(Environment(true));
for( Storage::ConstContIterator i=Sto.contBegin(); i!=Sto.contEnd(); ++i )
{
cout << *i << endl;
Modified: branches/SuSE-Code-11-SP1-Branch/storage/libstorage/src/Disk.cc
URL: http://svn.opensuse.org/viewcvs/yast/branches/SuSE-Code-11-SP1-Branch/storage/libstorage/src/Disk.cc?rev=58770&r1=58769&r2=58770&view=diff
==============================================================================
--- branches/SuSE-Code-11-SP1-Branch/storage/libstorage/src/Disk.cc (original)
+++ branches/SuSE-Code-11-SP1-Branch/storage/libstorage/src/Disk.cc Fri Sep 25 12:19:24 2009
@@ -429,7 +429,7 @@
if( detected_label.empty() )
detected_label = dlabel;
if( dlabel.empty() )
- dlabel = defaultLabel(getStorage(), size_k);
+ dlabel = defaultLabel(getStorage()->efiBoot(), size_k);
setLabelData( dlabel );
if (label == "unsupported")
@@ -992,10 +992,10 @@
#define PB (1024ULL * 1024ULL * 1024ULL * 1024ULL)
string
-Disk::defaultLabel(const Storage& storage, unsigned long long size_k)
+Disk::defaultLabel(bool efiboot, unsigned long long size_k)
{
string ret = "msdos";
- if (storage.efiBoot())
+ if (efiboot)
ret = "gpt";
else if( Storage::arch()=="ia64" )
ret = "gpt";
@@ -1007,7 +1007,7 @@
ret = "amiga";
if( size_k>2*TB )
ret = "gpt";
- y2mil("efiboot:" << storage.efiBoot() << " size_k:" << size_k << " ret:" << ret);
+ y2mil("efiboot:" << efiboot << " size_k:" << size_k << " ret:" << ret);
return ret;
}
@@ -2059,7 +2059,7 @@
Disk::getPartedValues( Partition *p )
{
bool ret = false;
- if( getStorage()->test() )
+ if( getStorage()->testmode() )
{
ret = true;
p->setSize( p->sizeK() );
@@ -2107,7 +2107,7 @@
unsigned long long& end )
{
bool ret = false;
- if( getStorage()->test() )
+ if( getStorage()->testmode() )
{
ret = true;
start = p->cylStart()*new_head*new_sector;
Modified: branches/SuSE-Code-11-SP1-Branch/storage/libstorage/src/Disk.h
URL: http://svn.opensuse.org/viewcvs/yast/branches/SuSE-Code-11-SP1-Branch/storage/libstorage/src/Disk.h?rev=58770&r1=58769&r2=58770&view=diff
==============================================================================
--- branches/SuSE-Code-11-SP1-Branch/storage/libstorage/src/Disk.h (original)
+++ branches/SuSE-Code-11-SP1-Branch/storage/libstorage/src/Disk.h Fri Sep 25 12:19:24 2009
@@ -202,7 +202,7 @@
void logData( const string& Dir );
void setLabelData( const string& );
- static string defaultLabel( const Storage&, unsigned long long size_k );
+ static string defaultLabel(bool efiboot, unsigned long long size_k);
static label_info labels[];
static string p_disks[];
Modified: branches/SuSE-Code-11-SP1-Branch/storage/libstorage/src/Storage.cc
URL: http://svn.opensuse.org/viewcvs/yast/branches/SuSE-Code-11-SP1-Branch/storage/libstorage/src/Storage.cc?rev=58770&r1=58769&r2=58770&view=diff
==============================================================================
--- branches/SuSE-Code-11-SP1-Branch/storage/libstorage/src/Storage.cc (original)
+++ branches/SuSE-Code-11-SP1-Branch/storage/libstorage/src/Storage.cc Fri Sep 25 12:19:24 2009
@@ -71,27 +71,33 @@
}
-Storage::Storage( bool ronly, bool tmode, bool autodetec )
- : lock(ronly, tmode), readonly(ronly), testmode(tmode), initialized(false),
- autodetect(autodetec)
+namespace storage
+{
+ std::ostream& operator<<(std::ostream& s, const Environment& env)
+ {
+ return s << "readonly:" << env.readonly << " testmode:" << env.testmode
+ << " autodetect:" << env.autodetect << " instsys:" << env.instsys
+ << " logdir:" << env.logdir << " testdir:" << env.testdir;
+ }
+}
+
+
+Storage::Storage(const Environment& env)
+ : env(env), lock(readonly(), testmode()), initialized(false)
{
- y2mil("constructed Storage ronly:" << ronly << " testmode:" << testmode <<
- " autodetect:" << autodetect);
+ y2mil("constructed Storage with " << env);
y2mil("package string \"" PACKAGE_STRING "\"");
char * tenv = getenv( "YAST_IS_RUNNING" );
- inst_sys = tenv!=NULL && strcmp(tenv,"instsys")==0;
- root_mounted = !inst_sys;
+ root_mounted = !instsys();
efiboot = false;
hald_pid = 0;
- if( !testmode )
- testmode = getenv( "YAST2_STORAGE_TMODE" )!=NULL;
+
max_log_num = 5;
tenv = getenv( "Y2MAXLOGNUM" );
- logdir = "/var/log/YaST2";
if( tenv!=0 )
string(tenv) >> max_log_num;
- y2mil("instsys:" << inst_sys << " testmode:" << testmode << " autodetect:" << autodetect <<
- " log:" << max_log_num);
+ y2mil("max_log_num:" << max_log_num);
+
progress_bar_cb = NULL;
install_info_cb = NULL;
info_popup_cb = NULL;
@@ -153,24 +159,13 @@
setDefaultMountBy( MOUNTBY_LABEL );
}
}
- if( autodetect )
+
+ if( autodetect() )
{
detectArch();
efiboot = (arch() == "ia64");
}
- if( testmode )
- {
- char * tenv = getenv( "YAST2_STORAGE_TDIR" );
- if( tenv!=NULL && strlen(tenv)>0 )
- {
- logdir = testdir = tenv;
- }
- else
- {
- testdir = logdir;
- }
- }
- y2mil("instsys:" << inst_sys << " testdir:" << testdir);
+
detectObjects();
setCacheChanges( true );
dumpObjectList();
@@ -227,12 +222,12 @@
for( LvmVgIterator i=p.begin(); i!=p.end(); ++i )
i->normalizeDmDevices();
- if( testmode )
+ if( testmode() )
{
SystemCmd::testmode = true;
- rootprefix = testdir;
+ rootprefix = testdir();
fstab = new EtcFstab( rootprefix );
- string t = testdir+"/volume_info";
+ string t = testdir() + "/volume_info";
if( access( t.c_str(), R_OK )==0 )
{
detectFsDataTestMode( t, vBegin(), vEnd() );
@@ -282,10 +277,10 @@
{
if( max_log_num>0 )
{
- logVolumes( logdir );
+ logVolumes( logdir() );
for( CIter i=cont.begin(); i!=cont.end(); ++i )
{
- (*i)->logData( logdir );
+ (*i)->logData( logdir() );
}
}
deleteClist(cont);
@@ -368,11 +363,11 @@
void
Storage::detectDisks( ProcPart& ppart )
{
- if( test() )
+ if( testmode() )
{
glob_t globbuf;
- if( glob( (testdir+"/disk_*[!~0-9]").c_str(), GLOB_NOSORT, 0,
+ if( glob( (testdir()+"/disk_*[!~0-9]").c_str(), GLOB_NOSORT, 0,
&globbuf) == 0)
{
for (char** p = globbuf.gl_pathv; *p != 0; *p++)
@@ -380,7 +375,7 @@
}
globfree (&globbuf);
}
- else if( autodetect )
+ else if( autodetect() )
{
autodetectDisks( ppart );
}
@@ -389,9 +384,9 @@
void Storage::detectMds()
{
- if( test() )
+ if( testmode() )
{
- string file = testdir+"/md";
+ string file = testdir()+"/md";
if( access( file.c_str(), R_OK )==0 )
{
addToList( new MdCo( this, file ) );
@@ -409,9 +404,9 @@
void Storage::detectLoops( ProcPart& ppart )
{
- if( test() )
+ if( testmode() )
{
- string file = testdir+"/loop";
+ string file = testdir()+"/loop";
if( access( file.c_str(), R_OK )==0 )
{
addToList( new LoopCo( this, file ) );
@@ -429,9 +424,9 @@
void Storage::detectNfs( ProcMounts& mounts )
{
- if( test() )
+ if( testmode() )
{
- string file = testdir+"/nfs";
+ string file = testdir()+"/nfs";
if( access( file.c_str(), R_OK )==0 )
{
addToList( new NfsCo( this, file ) );
@@ -450,10 +445,10 @@
void
Storage::detectLvmVgs()
{
- if( test() )
+ if( testmode() )
{
glob_t globbuf;
- if( glob( (testdir+"/lvm_*[!~0-9]").c_str(), GLOB_NOSORT, 0,
+ if( glob( (testdir()+"/lvm_*[!~0-9]").c_str(), GLOB_NOSORT, 0,
&globbuf) == 0)
{
for (char** p = globbuf.gl_pathv; *p != 0; *p++)
@@ -487,10 +482,10 @@
void
Storage::detectDmraid(ProcPart& ppart)
{
- if( test() )
+ if( testmode() )
{
glob_t globbuf;
- if( glob( (testdir+"/dmraid_*[!~0-9]").c_str(), GLOB_NOSORT, 0,
+ if( glob( (testdir()+"/dmraid_*[!~0-9]").c_str(), GLOB_NOSORT, 0,
&globbuf) == 0)
{
// TODO: load test data
@@ -530,10 +525,10 @@
void
Storage::detectDmmultipath(ProcPart& ppart)
{
- if( test() )
+ if( testmode() )
{
glob_t globbuf;
- if( glob( (testdir+"/dmmultipath_*[!~0-9]").c_str(), GLOB_NOSORT, 0,
+ if( glob( (testdir()+"/dmmultipath_*[!~0-9]").c_str(), GLOB_NOSORT, 0,
&globbuf) == 0)
{
// TODO: load test data
@@ -573,10 +568,10 @@
void
Storage::detectDm( ProcPart& ppart )
{
- if( test() )
+ if( testmode() )
{
glob_t globbuf;
- if( glob( (testdir+"/dm_*[!~0-9]").c_str(), GLOB_NOSORT, 0,
+ if( glob( (testdir()+"/dm_*[!~0-9]").c_str(), GLOB_NOSORT, 0,
&globbuf) == 0)
{
// TODO: load test data
@@ -662,7 +657,7 @@
(data.typ==DiskData::XEN||d->detect(pp)))
{
if( max_log_num>0 )
- d->logData( logdir );
+ d->logData( logdir() );
data.d = d;
}
else if( d )
@@ -784,7 +779,7 @@
}
}
if( max_log_num>0 )
- logVolumes( logdir );
+ logVolumes( logdir() );
y2milestone( "detectFsData end" );
}
@@ -961,22 +956,17 @@
Storage::initDefaultLogger ();
}
- StorageInterface* createDefaultStorageInterface ()
- {
- return new Storage ();
- }
- StorageInterface* createStorageInterface (bool ronly, bool testmode, bool autodetect)
+ StorageInterface* createStorageInterface(const Environment& env)
{
- return new Storage (ronly, testmode, autodetect);
+ return new Storage(env);
}
- StorageInterface* createStorageInterfacePid (bool ronly, bool testmode, bool autodetect,
- pid_t& locker_pid)
+ StorageInterface* createStorageInterfacePid(const Environment& env, pid_t& locker_pid)
{
try
{
- return new Storage (ronly, testmode, autodetect);
+ return new Storage(env);
}
catch (const LockException& e)
{
@@ -1001,7 +991,7 @@
assertInit();
y2milestone( "disk:%s type:%d start:%ld size:%ld", disk.c_str(),
type, start, size );
- if( readonly )
+ if( readonly() )
{
ret = STORAGE_CHANGE_READONLY;
}
@@ -1055,7 +1045,7 @@
assertInit();
y2milestone( "disk:%s type:%d start:%lld sizeK:%lld", disk.c_str(),
type, start, sizeK );
- if( readonly )
+ if( readonly() )
{
ret = STORAGE_CHANGE_READONLY;
}
@@ -1117,7 +1107,7 @@
bool done = false;
assertInit();
y2milestone( "disk:%s sizeK:%lld", disk.c_str(), sizeK );
- if( readonly )
+ if( readonly() )
{
ret = STORAGE_CHANGE_READONLY;
}
@@ -1199,7 +1189,7 @@
assertInit();
y2milestone( "disk:%s type:%u", disk.c_str(), type );
DiskIterator i = findDisk( disk );
- if( readonly )
+ if( readonly() )
{
ret = STORAGE_CHANGE_READONLY;
}
@@ -1299,7 +1289,7 @@
y2milestone( "partition:%s", partition.c_str() );
VolIterator vol;
ContIterator cont;
- if( readonly )
+ if( readonly() )
{
ret = STORAGE_CHANGE_READONLY;
}
@@ -1372,7 +1362,7 @@
start, size );
VolIterator vol;
ContIterator cont;
- if( readonly )
+ if( readonly() )
{
ret = STORAGE_CHANGE_READONLY;
}
@@ -1478,7 +1468,7 @@
y2milestone( "partition:%s id:%x", partition.c_str(), id );
VolIterator vol;
ContIterator cont;
- if( readonly )
+ if( readonly() )
{
ret = STORAGE_CHANGE_READONLY;
}
@@ -1547,7 +1537,7 @@
sizeCyl, ignoreFs );
VolIterator vol;
ContIterator cont;
- if( readonly )
+ if( readonly() )
{
ret = STORAGE_CHANGE_READONLY;
}
@@ -1608,7 +1598,7 @@
y2milestone( "partition:%s", partition.c_str() );
VolIterator vol;
ContIterator cont;
- if( readonly )
+ if( readonly() )
{
ret = STORAGE_CHANGE_READONLY;
}
@@ -1767,7 +1757,7 @@
assertInit();
y2milestone( "disk:%s label:%s", disk.c_str(), label.c_str() );
- if( readonly )
+ if( readonly() )
{
ret = STORAGE_CHANGE_READONLY;
}
@@ -1809,7 +1799,7 @@
assertInit();
y2milestone( "disk:%s value:%d", disk.c_str(), value );
- if( readonly )
+ if( readonly() )
{
ret = STORAGE_CHANGE_READONLY;
}
@@ -1847,13 +1837,13 @@
string
Storage::defaultDiskLabel() const
{
- return Disk::defaultLabel(this, 0);
+ return Disk::defaultLabel(efiBoot(), 0);
}
string
Storage::defaultDiskLabelSize( unsigned long long size_k ) const
{
- return Disk::defaultLabel(this, size_k);
+ return Disk::defaultLabel(efiBoot(), size_k);
}
@@ -1872,7 +1862,7 @@
Volume::fsTypeString(fs).c_str() );
VolIterator vol;
ContIterator cont;
- if( readonly )
+ if( readonly() )
{
ret = STORAGE_CHANGE_READONLY;
}
@@ -1900,7 +1890,7 @@
y2milestone( "device:%s label:%s", device.c_str(), label.c_str() );
VolIterator vol;
ContIterator cont;
- if( readonly )
+ if( readonly() )
{
ret = STORAGE_CHANGE_READONLY;
}
@@ -1928,7 +1918,7 @@
y2milestone( "device:%s", device.c_str() );
VolIterator vol;
ContIterator cont;
- if( readonly )
+ if( readonly() )
{
ret = STORAGE_CHANGE_READONLY;
}
@@ -1952,7 +1942,7 @@
y2milestone( "device:%s opts:%s", device.c_str(), opts.c_str() );
VolIterator vol;
ContIterator cont;
- if( readonly )
+ if( readonly() )
{
ret = STORAGE_CHANGE_READONLY;
}
@@ -1980,7 +1970,7 @@
y2milestone( "device:%s opts:%s", device.c_str(), opts.c_str() );
VolIterator vol;
ContIterator cont;
- if( readonly )
+ if( readonly() )
{
ret = STORAGE_CHANGE_READONLY;
}
@@ -2008,7 +1998,7 @@
y2milestone( "device:%s txt:%s", device.c_str(), txt.c_str() );
VolIterator vol;
ContIterator cont;
- if( readonly )
+ if( readonly() )
{
ret = STORAGE_CHANGE_READONLY;
}
@@ -2036,7 +2026,7 @@
y2milestone( "device:%s mount:%s", device.c_str(), mount.c_str() );
VolIterator vol;
ContIterator cont;
- if( readonly )
+ if( readonly() )
{
ret = STORAGE_CHANGE_READONLY;
}
@@ -2085,7 +2075,7 @@
Volume::mbyTypeString(mby).c_str() );
VolIterator vol;
ContIterator cont;
- if( readonly )
+ if( readonly() )
{
ret = STORAGE_CHANGE_READONLY;
}
@@ -2140,7 +2130,7 @@
y2milestone( "device:%s options:%s", device.c_str(), options.c_str() );
VolIterator vol;
ContIterator cont;
- if( readonly )
+ if( readonly() )
{
ret = STORAGE_CHANGE_READONLY;
}
@@ -2188,7 +2178,7 @@
y2milestone( "device:%s options:%s", device.c_str(), options.c_str() );
VolIterator vol;
ContIterator cont;
- if( readonly )
+ if( readonly() )
{
ret = STORAGE_CHANGE_READONLY;
}
@@ -2223,7 +2213,7 @@
y2milestone( "device:%s options:%s", device.c_str(), options.c_str() );
VolIterator vol;
ContIterator cont;
- if( readonly )
+ if( readonly() )
{
ret = STORAGE_CHANGE_READONLY;
}
@@ -2264,7 +2254,7 @@
y2milestone( "device:%s val:%d type:%d", device.c_str(), val, typ );
VolIterator vol;
ContIterator cont;
- if( readonly )
+ if( readonly() )
{
ret = STORAGE_CHANGE_READONLY;
}
@@ -2315,7 +2305,7 @@
#endif
VolIterator vol;
- if( readonly )
+ if( readonly() )
{
ret = STORAGE_CHANGE_READONLY;
}
@@ -2343,7 +2333,7 @@
y2milestone( "device:%s", device.c_str() );
VolIterator vol;
- if( readonly )
+ if( readonly() )
{
ret = STORAGE_CHANGE_READONLY;
}
@@ -2399,7 +2389,7 @@
y2milestone( "device:%s val:%d", device.c_str(), val );
VolIterator vol;
ContIterator cont;
- if( readonly )
+ if( readonly() )
{
ret = STORAGE_CHANGE_READONLY;
}
@@ -2461,7 +2451,7 @@
newSizeMb, ignoreFs );
VolIterator vol;
ContIterator cont;
- if( readonly )
+ if( readonly() )
{
ret = STORAGE_CHANGE_READONLY;
}
@@ -2494,7 +2484,7 @@
y2milestone( "device:%s", device.c_str() );
VolIterator vol;
ContIterator cont;
- if( readonly )
+ if( readonly() )
{
ret = STORAGE_CHANGE_READONLY;
}
@@ -2523,7 +2513,7 @@
VolIterator vol;
ContIterator cont;
- if( readonly )
+ if( readonly() )
{
ret = STORAGE_CHANGE_READONLY;
}
@@ -2561,7 +2551,7 @@
y2mil( "name:" << name << " peSizeK:" << peSizeK << " lvm1:" << lvm1 <<
" devices:" << devs );
LvmVgIterator i = findLvmVg( name );
- if( readonly )
+ if( readonly() )
{
ret = STORAGE_CHANGE_READONLY;
}
@@ -2606,7 +2596,7 @@
assertInit();
y2milestone( "name:%s", name.c_str() );
LvmVgIterator i = findLvmVg( name );
- if( readonly )
+ if( readonly() )
{
ret = STORAGE_CHANGE_READONLY;
}
@@ -2635,7 +2625,7 @@
assertInit();
y2mil( "name:" << name << " devices:" << devs );
LvmVgIterator i = findLvmVg( name );
- if( readonly )
+ if( readonly() )
{
ret = STORAGE_CHANGE_READONLY;
}
@@ -2665,7 +2655,7 @@
assertInit();
y2mil( "name:" << name << " devices:" << devs );
LvmVgIterator i = findLvmVg( name );
- if( readonly )
+ if( readonly() )
{
ret = STORAGE_CHANGE_READONLY;
}
@@ -2698,7 +2688,7 @@
y2milestone( "vg:%s name:%s sizeM:%llu stripe:%u", vg.c_str(),
name.c_str(), sizeM, stripe );
LvmVgIterator i = findLvmVg( vg );
- if( readonly )
+ if( readonly() )
{
ret = STORAGE_CHANGE_READONLY;
}
@@ -2745,7 +2735,7 @@
assertInit();
y2milestone( "vg:%s name:%s", vg.c_str(), name.c_str() );
LvmVgIterator i = findLvmVg( vg );
- if( readonly )
+ if( readonly() )
{
ret = STORAGE_CHANGE_READONLY;
}
@@ -2774,7 +2764,7 @@
y2milestone( "vg:%s name:%s stripe:%lu", vg.c_str(), name.c_str(),
stripe );
LvmVgIterator i = findLvmVg( vg );
- if( readonly )
+ if( readonly() )
{
ret = STORAGE_CHANGE_READONLY;
}
@@ -2803,7 +2793,7 @@
y2milestone( "vg:%s name:%s stripeSize:%llu", vg.c_str(), name.c_str(),
stripeSize );
LvmVgIterator i = findLvmVg( vg );
- if( readonly )
+ if( readonly() )
{
ret = STORAGE_CHANGE_READONLY;
}
@@ -2834,7 +2824,7 @@
assertInit();
y2mil("vg:" << vg << " origin:" << origin << " name:" << name << " cowSizeK:" << cowSizeK);
LvmVgIterator i = findLvmVg(vg);
- if (readonly)
+ if (readonly())
{
ret = STORAGE_CHANGE_READONLY;
}
@@ -2862,7 +2852,7 @@
assertInit();
y2mil("vg:" << vg << " name:" << name);
LvmVgIterator i = findLvmVg(vg);
- if (readonly)
+ if (readonly())
{
ret = STORAGE_CHANGE_READONLY;
}
@@ -2927,7 +2917,7 @@
y2mil( "name:" << name << " MdType:" << Md::pName(rtype) <<
" devices:" << devs );
unsigned num = 0;
- if( readonly )
+ if( readonly() )
{
ret = STORAGE_CHANGE_READONLY;
}
@@ -2970,7 +2960,7 @@
int ret = 0;
assertInit();
y2mil( "MdType:" << Md::pName(rtype) << " devices:" << devs );
- if( readonly )
+ if( readonly() )
{
ret = STORAGE_CHANGE_READONLY;
}
@@ -3019,7 +3009,7 @@
int ret = 0;
assertInit();
y2milestone( "name:%s destroySb:%d", name.c_str(), destroySb );
- if( readonly )
+ if( readonly() )
{
ret = STORAGE_CHANGE_READONLY;
}
@@ -3049,7 +3039,7 @@
int ret = 0;
assertInit();
y2milestone( "name:%s dev:%s", name.c_str(), dev.c_str() );
- if( readonly )
+ if( readonly() )
{
ret = STORAGE_CHANGE_READONLY;
}
@@ -3079,7 +3069,7 @@
int ret = 0;
assertInit();
y2milestone( "name:%s dev:%s", name.c_str(), dev.c_str() );
- if( readonly )
+ if( readonly() )
{
ret = STORAGE_CHANGE_READONLY;
}
@@ -3109,7 +3099,7 @@
int ret = 0;
assertInit();
y2milestone( "name:%s rtype:%d", name.c_str(), rtype );
- if( readonly )
+ if( readonly() )
{
ret = STORAGE_CHANGE_READONLY;
}
@@ -3139,7 +3129,7 @@
int ret = 0;
assertInit();
y2milestone( "name:%s dev:%lu", name.c_str(), chunk );
- if( readonly )
+ if( readonly() )
{
ret = STORAGE_CHANGE_READONLY;
}
@@ -3169,7 +3159,7 @@
int ret = 0;
assertInit();
y2milestone( "name:%s parity:%d", name.c_str(), ptype );
- if( readonly )
+ if( readonly() )
{
ret = STORAGE_CHANGE_READONLY;
}
@@ -3317,7 +3307,7 @@
int ret = 0;
assertInit();
y2mil( "name:" << nfsDev << " sizeK:" << sizeK << " mp:" << mp );
- if( readonly )
+ if( readonly() )
{
ret = STORAGE_CHANGE_READONLY;
}
@@ -3402,7 +3392,7 @@
#ifdef DEBUG_LOOP_CRYPT_PASSWORD
y2milestone( "pwd:%s", pwd.c_str() );
#endif
- if( readonly )
+ if( readonly() )
{
ret = STORAGE_CHANGE_READONLY;
}
@@ -3470,7 +3460,7 @@
assertInit();
y2milestone( "device:%s lname:%s reuse:%d sizeK:%lld", device.c_str(),
lname.c_str(), reuseExisting, sizeK );
- if( readonly )
+ if( readonly() )
{
ret = STORAGE_CHANGE_READONLY;
}
@@ -3496,7 +3486,7 @@
int ret = 0;
assertInit();
y2milestone( "lname:%s removeFile:%d", lname.c_str(), removeFile );
- if( readonly )
+ if( readonly() )
{
ret = STORAGE_CHANGE_READONLY;
}
@@ -5287,7 +5277,7 @@
assertInit();
y2milestone( "device:%s", device.c_str() );
VolIterator vol;
- if( !readonly && findVolume( device, vol ) )
+ if( !readonly() && findVolume( device, vol ) )
{
if( vol->umount()==0 )
{
@@ -5308,7 +5298,7 @@
y2milestone( "device:%s mp:%s ro:%d opts:%s", device.c_str(), mp.c_str(),
ro, opts.c_str() );
VolIterator vol;
- if( !readonly && findVolume( device, vol ) )
+ if( !readonly() && findVolume( device, vol ) )
{
if( vol->needCrsetup() )
{
@@ -5581,7 +5571,7 @@
int
Storage::createBackupState( const string& name )
{
- int ret = readonly?STORAGE_CHANGE_READONLY:0;
+ int ret = readonly()?STORAGE_CHANGE_READONLY:0;
assertInit();
y2milestone( "name:%s", name.c_str() );
if( ret==0 )
@@ -5605,7 +5595,7 @@
int
Storage::removeBackupState( const string& name )
{
- int ret = readonly?STORAGE_CHANGE_READONLY:0;
+ int ret = readonly()?STORAGE_CHANGE_READONLY:0;
assertInit();
y2milestone( "name:%s", name.c_str() );
if( ret==0 )
@@ -5632,7 +5622,7 @@
int
Storage::restoreBackupState( const string& name )
{
- int ret = readonly?STORAGE_CHANGE_READONLY:0;
+ int ret = readonly()?STORAGE_CHANGE_READONLY:0;
assertInit();
y2milestone( "name:%s", name.c_str() );
if( ret==0 )
@@ -5780,7 +5770,7 @@
const string& vfs, const string& options,
unsigned freq, unsigned passno )
{
- int ret = readonly?STORAGE_CHANGE_READONLY:0;
+ int ret = readonly()?STORAGE_CHANGE_READONLY:0;
assertInit();
y2milestone( "device:%s mount:%s vfs:%s opts:%s freq:%u passno:%u",
device.c_str(), mount.c_str(), vfs.c_str(), options.c_str(),
Modified: branches/SuSE-Code-11-SP1-Branch/storage/libstorage/src/Storage.h
URL: http://svn.opensuse.org/viewcvs/yast/branches/SuSE-Code-11-SP1-Branch/storage/libstorage/src/Storage.h?rev=58770&r1=58769&r2=58770&view=diff
==============================================================================
--- branches/SuSE-Code-11-SP1-Branch/storage/libstorage/src/Storage.h (original)
+++ branches/SuSE-Code-11-SP1-Branch/storage/libstorage/src/Storage.h Fri Sep 25 12:19:24 2009
@@ -209,15 +209,20 @@
static void initDefaultLogger ();
- Storage( bool ronly=false, bool testmode=false, bool autodetect=true );
- bool test() const { return( testmode ); }
- bool instsys() const { return( inst_sys ); }
+ Storage(const Environment& env);
+
+ bool readonly() const { return env.readonly; }
+ bool testmode() const { return env.testmode; }
+ bool autodetect() const { return env.autodetect; }
+ bool instsys() const { return env.instsys; }
+ string logdir() const { return env.logdir; }
+ string testdir() const { return env.testdir; }
+
void setCacheChanges( bool val=true ) { cache = val; }
bool isCacheChanges() const { return( cache ); }
void assertInit() { if( !initialized ) initialize(); }
void rescanEverything();
int checkCache();
- const string& tDir() const { return( testdir ); }
const string& root() const { return( rootprefix ); }
string prependRoot(const string& mp) const;
const string& tmpDir() const;
@@ -1716,22 +1721,17 @@
bool& resize_ok );
// protected internal member variables
+ const Environment env;
Lock lock;
- bool readonly;
- bool testmode;
- bool inst_sys;
bool cache;
bool initialized;
- bool autodetect;
bool recursiveRemove;
bool zeroNewPartitions;
MountByType defaultMountBy;
bool detectMounted;
bool root_mounted;
- string testdir;
string tempdir;
string rootprefix;
- string logdir;
unsigned hald_pid;
bool efiboot;
static string proc_arch;
Modified: branches/SuSE-Code-11-SP1-Branch/storage/libstorage/src/StorageInterface.h
URL: http://svn.opensuse.org/viewcvs/yast/branches/SuSE-Code-11-SP1-Branch/storage/libstorage/src/StorageInterface.h?rev=58770&r1=58769&r2=58770&view=diff
==============================================================================
--- branches/SuSE-Code-11-SP1-Branch/storage/libstorage/src/StorageInterface.h (original)
+++ branches/SuSE-Code-11-SP1-Branch/storage/libstorage/src/StorageInterface.h Fri Sep 25 12:19:24 2009
@@ -2172,15 +2172,24 @@
/**
* Initializes default logging.
*/
- void initDefaultLogger ();
+ void initDefaultLogger();
/**
- * Factory for creating a concrete StorageInterface object.
- *
- * Throws an exception when locking fails.
+ * Contains basic environment settings controlling the behaviour of libstorage.
*/
- StorageInterface* createDefaultStorageInterface ();
+ struct Environment
+ {
+ Environment(bool readonly) : readonly(readonly), testmode(false), autodetect(true),
+ instsys(false), logdir("/var/log/YaST2"), testdir("") {}
+
+ bool readonly;
+ bool testmode;
+ bool autodetect;
+ bool instsys;
+ string logdir;
+ string testdir;
+ };
/**
@@ -2188,8 +2197,7 @@
*
* Throws an exception when locking fails.
*/
- StorageInterface* createStorageInterface (bool readonly, bool testmode,
- bool autodetect);
+ StorageInterface* createStorageInterface(const Environment& env);
/**
@@ -2199,14 +2207,13 @@
* pid of one process holding a conflicting lock. If the pid cannot be
* determined it is set to 0. The lock holder may run on another system.
*/
- StorageInterface* createStorageInterfacePid (bool readonly, bool testmode,
- bool autodetect, int& locker_pid);
+ StorageInterface* createStorageInterfacePid(const Environment& env, int& locker_pid);
/**
* Destroy a StorageInterface object.
*/
- void destroyStorageInterface (StorageInterface*);
+ void destroyStorageInterface(StorageInterface*);
}
Modified: branches/SuSE-Code-11-SP1-Branch/storage/libstorage/src/Volume.cc
URL: http://svn.opensuse.org/viewcvs/yast/branches/SuSE-Code-11-SP1-Branch/storage/libstorage/src/Volume.cc?rev=58770&r1=58769&r2=58770&view=diff
==============================================================================
--- branches/SuSE-Code-11-SP1-Branch/storage/libstorage/src/Volume.cc (original)
+++ branches/SuSE-Code-11-SP1-Branch/storage/libstorage/src/Volume.cc Fri Sep 25 12:19:24 2009
@@ -704,7 +704,7 @@
ret = umount( orig_mp );
needMount = ret==0;
}
- if( ret==0 && !cont->getStorage()->test() )
+ if( ret==0 && !cont->getStorage()->testmode() )
{
ret = checkDevice();
}
@@ -716,7 +716,7 @@
{
ret = cont->getStorage()->zeroDevice(mountDevice(), size_k, true);
}
- if( ret==0 && mountDevice()!=dev && !cont->getStorage()->test() )
+ if( ret==0 && mountDevice()!=dev && !cont->getStorage()->testmode() )
{
ret = checkDevice(mountDevice());
}
@@ -848,7 +848,7 @@
{
format = false;
detected_fs = fs;
- if( fs != SWAP && !cont->getStorage()->test() )
+ if( fs != SWAP && !cont->getStorage()->testmode() )
{
FsType old=fs;
updateFsData();
@@ -1139,7 +1139,7 @@
{
ret = VOLUME_ALREADY_IN_USE;
}
- if( ret==0 && !mp.empty() && !cont->getStorage()->test() )
+ if( ret==0 && !mp.empty() && !cont->getStorage()->testmode() )
{
if( fs!=NFS )
{
@@ -1643,7 +1643,7 @@
{
EncryptType ret = ENC_UNKNOWN;
- if( getContainer()->getStorage()->test() )
+ if( getContainer()->getStorage()->testmode() )
{
ret = encryption = orig_encryption = ENC_TWOFISH;
y2milestone( "ret:%s", encTypeString(ret).c_str() );
Modified: branches/SuSE-Code-11-SP1-Branch/storage/libstorage/testsuite-real/lvmcreate1.cc
URL: http://svn.opensuse.org/viewcvs/yast/branches/SuSE-Code-11-SP1-Branch/storage/libstorage/testsuite-real/lvmcreate1.cc?rev=58770&r1=58769&r2=58770&view=diff
==============================================================================
--- branches/SuSE-Code-11-SP1-Branch/storage/libstorage/testsuite-real/lvmcreate1.cc (original)
+++ branches/SuSE-Code-11-SP1-Branch/storage/libstorage/testsuite-real/lvmcreate1.cc Fri Sep 25 12:19:24 2009
@@ -2,7 +2,7 @@
#include