Author: aschnell
Date: Fri May 15 12:07:36 2009
New Revision: 57193
URL: http://svn.opensuse.org/viewcvs/yast?rev=57193&view=rev
Log:
- added environment parameter to Storage constructor and factories
- pass instsys flag from YCP to libstorage (bnc #399390)
Modified:
trunk/storage/libstorage/bindings/ycp/LibStorage.i
trunk/storage/libstorage/examples/SaveGraph.cc
trunk/storage/libstorage/examples/TestDisk.cc
trunk/storage/libstorage/examples/TestDiskLog.cc
trunk/storage/libstorage/examples/TestLoop.cc
trunk/storage/libstorage/examples/TestLvm.cc
trunk/storage/libstorage/examples/TestMd.cc
trunk/storage/libstorage/examples/TestProbing.cc
trunk/storage/libstorage/examples/TestStorage.cc
trunk/storage/libstorage/src/Disk.cc
trunk/storage/libstorage/src/Storage.cc
trunk/storage/libstorage/src/Storage.h
trunk/storage/libstorage/src/StorageInterface.h
trunk/storage/libstorage/src/Volume.cc
trunk/storage/libstorage/testsuite-real/lvmcreate1.cc
trunk/storage/libstorage/testsuite-real/lvmcreate2.cc
trunk/storage/libstorage/testsuite-real/lvmextend1.cc
trunk/storage/libstorage/testsuite-real/lvmextend2.cc
trunk/storage/libstorage/testsuite/Makefile.am
trunk/storage/libstorage/testsuite/common.h
trunk/storage/libstorage/testsuite/format1.cc
trunk/storage/libstorage/testsuite/fstab1.cc
trunk/storage/libstorage/testsuite/lvm_create.cc
trunk/storage/libstorage/testsuite/lvm_extend.cc
trunk/storage/libstorage/testsuite/md_create.cc
trunk/storage/libstorage/testsuite/partition1.cc
trunk/storage/libstorage/testsuite/uuid1.cc
trunk/storage/package/yast2-storage.changes
trunk/storage/storage/src/modules/Storage.ycp
Modified: trunk/storage/libstorage/bindings/ycp/LibStorage.i
URL: http://svn.opensuse.org/viewcvs/yast/trunk/storage/libstorage/bindings/ycp/LibStorage.i?rev=57193&r1=57192&r2=57193&view=diff
==============================================================================
--- trunk/storage/libstorage/bindings/ycp/LibStorage.i (original)
+++ trunk/storage/libstorage/bindings/ycp/LibStorage.i Fri May 15 12:07:36 2009
@@ -39,6 +39,8 @@
specialize_sequence(storage::PartitionSlotInfo, TO_PACK, FROM_PACK, CHECK)
specialize_sequence(storage::CommitInfo, TO_PACK, FROM_PACK, CHECK)
+specialize_sequence(storage::Environment, TO_PACK, FROM_PACK, CHECK)
+
%include "../../src/StorageInterface.h"
%include "../../src/HumanString.h"
%include "../../src/Graph.h"
Modified: trunk/storage/libstorage/examples/SaveGraph.cc
URL: http://svn.opensuse.org/viewcvs/yast/trunk/storage/libstorage/examples/SaveGraph.cc?rev=57193&r1=57192&r2=57193&view=diff
==============================================================================
--- trunk/storage/libstorage/examples/SaveGraph.cc (original)
+++ trunk/storage/libstorage/examples/SaveGraph.cc Fri May 15 12:07:36 2009
@@ -11,7 +11,7 @@
{
initDefaultLogger();
- StorageInterface* s = createStorageInterface(true, false, true);
+ StorageInterface* s = createStorageInterface(Environment(true));
saveGraph(s, "storage.gv");
Modified: trunk/storage/libstorage/examples/TestDisk.cc
URL: http://svn.opensuse.org/viewcvs/yast/trunk/storage/libstorage/examples/TestDisk.cc?rev=57193&r1=57192&r2=57193&view=diff
==============================================================================
--- trunk/storage/libstorage/examples/TestDisk.cc (original)
+++ trunk/storage/libstorage/examples/TestDisk.cc Fri May 15 12:07:36 2009
@@ -11,7 +11,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: trunk/storage/libstorage/examples/TestDiskLog.cc
URL: http://svn.opensuse.org/viewcvs/yast/trunk/storage/libstorage/examples/TestDiskLog.cc?rev=57193&r1=57192&r2=57193&view=diff
==============================================================================
--- trunk/storage/libstorage/examples/TestDiskLog.cc (original)
+++ trunk/storage/libstorage/examples/TestDiskLog.cc Fri May 15 12:07:36 2009
@@ -12,7 +12,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: trunk/storage/libstorage/examples/TestLoop.cc
URL: http://svn.opensuse.org/viewcvs/yast/trunk/storage/libstorage/examples/TestLoop.cc?rev=57193&r1=57192&r2=57193&view=diff
==============================================================================
--- trunk/storage/libstorage/examples/TestLoop.cc (original)
+++ trunk/storage/libstorage/examples/TestLoop.cc Fri May 15 12:07:36 2009
@@ -47,8 +47,7 @@
{
int ret = 0;
initDefaultLogger();
- //StorageInterface* s = createStorageInterface(false,true);
- StorageInterface* s = createDefaultStorageInterface();
+ StorageInterface* s = createStorageInterface(Environment(false));
s->setCallbackProgressBar( progressbarCb );
s->setCallbackShowInstallInfo( installInfoCb );
string disk = "/dev/hdb";
Modified: trunk/storage/libstorage/examples/TestLvm.cc
URL: http://svn.opensuse.org/viewcvs/yast/trunk/storage/libstorage/examples/TestLvm.cc?rev=57193&r1=57192&r2=57193&view=diff
==============================================================================
--- trunk/storage/libstorage/examples/TestLvm.cc (original)
+++ trunk/storage/libstorage/examples/TestLvm.cc Fri May 15 12:07:36 2009
@@ -45,8 +45,7 @@
{
int ret = 0;
initDefaultLogger();
- //StorageInterface* s = createStorageInterface(false,true);
- StorageInterface* s = createDefaultStorageInterface();
+ StorageInterface* s = createStorageInterface(Environment(false));
s->setCallbackProgressBar( progressbarCb );
s->setCallbackShowInstallInfo( installInfoCb );
string disk = "/dev/hdb";
Modified: trunk/storage/libstorage/examples/TestMd.cc
URL: http://svn.opensuse.org/viewcvs/yast/trunk/storage/libstorage/examples/TestMd.cc?rev=57193&r1=57192&r2=57193&view=diff
==============================================================================
--- trunk/storage/libstorage/examples/TestMd.cc (original)
+++ trunk/storage/libstorage/examples/TestMd.cc Fri May 15 12:07:36 2009
@@ -47,8 +47,7 @@
{
int ret = 0;
initDefaultLogger();
- //StorageInterface* s = createStorageInterface(false,true);
- StorageInterface* s = createDefaultStorageInterface();
+ StorageInterface* s = createStorageInterface(Environment(false));
s->setCallbackProgressBar( progressbarCb );
s->setCallbackShowInstallInfo( installInfoCb );
string disk = "/dev/hdb";
Modified: trunk/storage/libstorage/examples/TestProbing.cc
URL: http://svn.opensuse.org/viewcvs/yast/trunk/storage/libstorage/examples/TestProbing.cc?rev=57193&r1=57192&r2=57193&view=diff
==============================================================================
--- trunk/storage/libstorage/examples/TestProbing.cc (original)
+++ trunk/storage/libstorage/examples/TestProbing.cc Fri May 15 12:07:36 2009
@@ -16,7 +16,8 @@
main (int argc, char** argv)
{
initDefaultLogger();
- StorageInterface* s = createStorageInterface (true, false, true);
+
+ StorageInterface* s = createStorageInterface(Environment(true));
deque<ContainerInfo> containers;
s->getContainers (containers);
Modified: trunk/storage/libstorage/examples/TestStorage.cc
URL: http://svn.opensuse.org/viewcvs/yast/trunk/storage/libstorage/examples/TestStorage.cc?rev=57193&r1=57192&r2=57193&view=diff
==============================================================================
--- trunk/storage/libstorage/examples/TestStorage.cc (original)
+++ trunk/storage/libstorage/examples/TestStorage.cc Fri May 15 12:07:36 2009
@@ -53,7 +53,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: trunk/storage/libstorage/src/Disk.cc
URL: http://svn.opensuse.org/viewcvs/yast/trunk/storage/libstorage/src/Disk.cc?rev=57193&r1=57192&r2=57193&view=diff
==============================================================================
--- trunk/storage/libstorage/src/Disk.cc (original)
+++ trunk/storage/libstorage/src/Disk.cc Fri May 15 12:07:36 2009
@@ -2017,7 +2017,7 @@
Disk::getPartedValues( Partition *p ) const
{
bool ret = false;
- if( getStorage()->test() )
+ if (getStorage()->testmode())
{
ret = true;
p->setSize( p->sizeK() );
@@ -2063,7 +2063,7 @@
unsigned long long& end ) const
{
bool ret = false;
- if( getStorage()->test() )
+ if (getStorage()->testmode())
{
ret = true;
start = p->cylStart()*new_head*new_sector;
Modified: trunk/storage/libstorage/src/Storage.cc
URL: http://svn.opensuse.org/viewcvs/yast/trunk/storage/libstorage/src/Storage.cc?rev=57193&r1=57192&r2=57193&view=diff
==============================================================================
--- trunk/storage/libstorage/src/Storage.cc (original)
+++ trunk/storage/libstorage/src/Storage.cc Fri May 15 12:07:36 2009
@@ -73,27 +73,25 @@
}
-Storage::Storage( bool ronly, bool tmode, bool autodetec )
- : lock(ronly, tmode), readonly(ronly), testmode(tmode), initialized(false),
- autodetect(autodetec), fstab(NULL)
+Storage::Storage(const Environment& env)
+ : env(env), lock(readonly(), testmode()), initialized(false), fstab(NULL)
{
- y2mil("constructed Storage ronly:" << ronly << " testmode:" << testmode <<
- " autodetect:" << autodetect);
+ y2mil("constructed Storage with readonly:" << readonly() << " testmode:" << testmode()
+ << " autodetect:" << autodetect() << " instsys:" << instsys());
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";
+ char* tenv = getenv("Y2MAXLOGNUM");
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);
+
+ logdir = "/var/log/YaST2";
+
progress_bar_cb = NULL;
install_info_cb = NULL;
info_popup_cb = NULL;
@@ -149,12 +147,12 @@
setDefaultMountBy( MOUNTBY_LABEL );
}
}
- if( autodetect )
+ if (autodetect())
{
detectArch();
efiboot = (arch() == "ia64");
}
- if( testmode )
+ if (testmode())
{
char * tenv = getenv( "YAST2_STORAGE_TDIR" );
if( tenv!=NULL && strlen(tenv)>0 )
@@ -166,7 +164,7 @@
testdir = logdir;
}
}
- y2mil("instsys:" << inst_sys << " testdir:" << testdir);
+ y2mil("instsys:" << instsys() << " testdir:" << testdir);
detectObjects();
setCacheChanges( true );
dumpObjectList();
@@ -227,7 +225,7 @@
for( LvmVgIterator i=p.begin(); i!=p.end(); ++i )
i->normalizeDmDevices();
- if( testmode )
+ if (testmode())
{
SystemCmd::setTestmode();
rootprefix = testdir;
@@ -353,7 +351,7 @@
void
Storage::detectDisks( ProcPart& ppart )
{
- if( test() )
+ if (testmode())
{
glob_t globbuf;
if( glob( (testdir+"/disk_*[!~0-9]").c_str(), GLOB_NOSORT, 0, &globbuf) == 0)
@@ -363,7 +361,7 @@
}
globfree (&globbuf);
}
- else if( autodetect )
+ else if (autodetect())
{
autodetectDisks( ppart );
}
@@ -372,7 +370,7 @@
void Storage::detectMds()
{
- if( test() )
+ if (testmode())
{
string file = testdir+"/md";
if( access( file.c_str(), R_OK )==0 )
@@ -392,7 +390,7 @@
void Storage::detectLoops( ProcPart& ppart )
{
- if( test() )
+ if (testmode())
{
string file = testdir+"/loop";
if( access( file.c_str(), R_OK )==0 )
@@ -414,7 +412,7 @@
void
Storage::detectNfs(const EtcFstab& fstab, const ProcMounts& mounts)
{
- if( test() )
+ if (testmode())
{
string file = testdir+"/nfs";
if( access( file.c_str(), R_OK )==0 )
@@ -435,7 +433,7 @@
void
Storage::detectLvmVgs()
{
- if( test() )
+ if (testmode())
{
glob_t globbuf;
if( glob( (testdir+"/lvm_*[!~0-9]").c_str(), GLOB_NOSORT, 0, &globbuf) == 0)
@@ -471,7 +469,7 @@
void
Storage::detectDmraid(ProcPart& ppart)
{
- if( test() )
+ if (testmode())
{
glob_t globbuf;
if( glob( (testdir+"/dmraid_*[!~0-9]").c_str(), GLOB_NOSORT, 0, &globbuf) == 0)
@@ -512,7 +510,7 @@
void
Storage::detectDmmultipath(ProcPart& ppart)
{
- if( test() )
+ if (testmode())
{
glob_t globbuf;
if( glob( (testdir+"/dmmultipath_*[!~0-9]").c_str(), GLOB_NOSORT, 0, &globbuf) == 0)
@@ -553,7 +551,7 @@
void
Storage::detectDm( ProcPart& ppart )
{
- if( test() )
+ if (testmode())
{
glob_t globbuf;
if( glob( (testdir+"/dm_*[!~0-9]").c_str(), GLOB_NOSORT, 0,
@@ -930,22 +928,16 @@
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)
{
@@ -968,7 +960,7 @@
bool done = false;
assertInit();
y2mil("disk:" << disk << " type:" << type << " start:" << start << " size:" << size);
- if( readonly )
+ if (readonly())
{
ret = STORAGE_CHANGE_READONLY;
}
@@ -1021,7 +1013,7 @@
bool done = false;
assertInit();
y2mil("disk:" << disk << " type:" << type << " start:" << start << " sizeK:" << sizeK);
- if( readonly )
+ if (readonly())
{
ret = STORAGE_CHANGE_READONLY;
}
@@ -1083,7 +1075,7 @@
bool done = false;
assertInit();
y2mil("disk:" << disk << " sizeK:" << sizeK);
- if( readonly )
+ if (readonly())
{
ret = STORAGE_CHANGE_READONLY;
}
@@ -1165,7 +1157,7 @@
assertInit();
y2mil("disk:" << disk << " type:" << type);
DiskIterator i = findDisk( disk );
- if( readonly )
+ if (readonly())
{
ret = STORAGE_CHANGE_READONLY;
}
@@ -1265,7 +1257,7 @@
y2mil("partition:" << partition);
VolIterator vol;
ContIterator cont;
- if( readonly )
+ if (readonly())
{
ret = STORAGE_CHANGE_READONLY;
}
@@ -1337,7 +1329,7 @@
y2mil("partition:" << partition << " start:" << start << " size:" << size);
VolIterator vol;
ContIterator cont;
- if( readonly )
+ if (readonly())
{
ret = STORAGE_CHANGE_READONLY;
}
@@ -1443,7 +1435,7 @@
y2mil("partition:" << partition << " id:" << hex << id);
VolIterator vol;
ContIterator cont;
- if( readonly )
+ if (readonly())
{
ret = STORAGE_CHANGE_READONLY;
}
@@ -1511,7 +1503,7 @@
y2mil("partition:" << partition << " newCyl:" << sizeCyl << " ignoreFs:" << ignoreFs);
VolIterator vol;
ContIterator cont;
- if( readonly )
+ if (readonly())
{
ret = STORAGE_CHANGE_READONLY;
}
@@ -1572,7 +1564,7 @@
y2mil("partition:" << partition);
VolIterator vol;
ContIterator cont;
- if( readonly )
+ if (readonly())
{
ret = STORAGE_CHANGE_READONLY;
}
@@ -1731,7 +1723,7 @@
assertInit();
y2mil("disk:" << disk << " label:" << label);
- if( readonly )
+ if (readonly())
{
ret = STORAGE_CHANGE_READONLY;
}
@@ -1773,7 +1765,7 @@
assertInit();
y2mil("disk:" << disk << " value:" << value);
- if( readonly )
+ if (readonly())
{
ret = STORAGE_CHANGE_READONLY;
}
@@ -1835,7 +1827,7 @@
y2mil("device:" << device << " format:" << format << " type:" << Volume::fsTypeString(fs));
VolIterator vol;
ContIterator cont;
- if( readonly )
+ if (readonly())
{
ret = STORAGE_CHANGE_READONLY;
}
@@ -1863,7 +1855,7 @@
y2mil("device:" << device << " label:" << label);
VolIterator vol;
ContIterator cont;
- if( readonly )
+ if (readonly())
{
ret = STORAGE_CHANGE_READONLY;
}
@@ -1891,7 +1883,7 @@
y2mil("device:" << device);
VolIterator vol;
ContIterator cont;
- if( readonly )
+ if (readonly())
{
ret = STORAGE_CHANGE_READONLY;
}
@@ -1915,7 +1907,7 @@
y2mil("device:" << device << " opts:" << opts);
VolIterator vol;
ContIterator cont;
- if( readonly )
+ if (readonly())
{
ret = STORAGE_CHANGE_READONLY;
}
@@ -1943,7 +1935,7 @@
y2mil("device:" << device << " opts:" << opts);
VolIterator vol;
ContIterator cont;
- if( readonly )
+ if (readonly())
{
ret = STORAGE_CHANGE_READONLY;
}
@@ -1971,7 +1963,7 @@
y2mil("device:" << device << " txt:" << txt);
VolIterator vol;
ContIterator cont;
- if( readonly )
+ if (readonly())
{
ret = STORAGE_CHANGE_READONLY;
}
@@ -1999,7 +1991,7 @@
y2mil("device:" << device << " mount:" << mount);
VolIterator vol;
ContIterator cont;
- if( readonly )
+ if (readonly())
{
ret = STORAGE_CHANGE_READONLY;
}
@@ -2047,7 +2039,7 @@
y2mil("device:" << device << " mby:" << Volume::mbyTypeString(mby));
VolIterator vol;
ContIterator cont;
- if( readonly )
+ if (readonly())
{
ret = STORAGE_CHANGE_READONLY;
}
@@ -2102,7 +2094,7 @@
y2mil("device:" << device << " options:" << options);
VolIterator vol;
ContIterator cont;
- if( readonly )
+ if (readonly())
{
ret = STORAGE_CHANGE_READONLY;
}
@@ -2150,7 +2142,7 @@
y2mil("device:" << device << " options:" << options);
VolIterator vol;
ContIterator cont;
- if( readonly )
+ if (readonly())
{
ret = STORAGE_CHANGE_READONLY;
}
@@ -2185,7 +2177,7 @@
y2mil("device:" << device << " options:" << options);
VolIterator vol;
ContIterator cont;
- if( readonly )
+ if (readonly())
{
ret = STORAGE_CHANGE_READONLY;
}
@@ -2226,7 +2218,7 @@
y2mil("device:" << device << " val:" << val << " type:" << typ);
VolIterator vol;
ContIterator cont;
- if( readonly )
+ if (readonly())
{
ret = STORAGE_CHANGE_READONLY;
}
@@ -2277,7 +2269,7 @@
#endif
VolIterator vol;
- if( readonly )
+ if (readonly())
{
ret = STORAGE_CHANGE_READONLY;
}
@@ -2305,7 +2297,7 @@
y2mil("device:" << device);
VolIterator vol;
- if( readonly )
+ if (readonly())
{
ret = STORAGE_CHANGE_READONLY;
}
@@ -2361,7 +2353,7 @@
y2mil("device:" << device << " val:" << val);
VolIterator vol;
ContIterator cont;
- if( readonly )
+ if (readonly())
{
ret = STORAGE_CHANGE_READONLY;
}
@@ -2422,7 +2414,7 @@
y2mil("device:" << device << " newSizeMb:" << newSizeMb << " ignoreFs:" << ignoreFs);
VolIterator vol;
ContIterator cont;
- if( readonly )
+ if (readonly())
{
ret = STORAGE_CHANGE_READONLY;
}
@@ -2455,7 +2447,7 @@
y2mil("device:" << device);
VolIterator vol;
ContIterator cont;
- if( readonly )
+ if (readonly())
{
ret = STORAGE_CHANGE_READONLY;
}
@@ -2484,7 +2476,7 @@
VolIterator vol;
ContIterator cont;
- if( readonly )
+ if (readonly())
{
ret = STORAGE_CHANGE_READONLY;
}
@@ -2522,7 +2514,7 @@
y2mil( "name:" << name << " peSizeK:" << peSizeK << " lvm1:" << lvm1 <<
" devices:" << devs );
LvmVgIterator i = findLvmVg( name );
- if( readonly )
+ if (readonly())
{
ret = STORAGE_CHANGE_READONLY;
}
@@ -2567,7 +2559,7 @@
assertInit();
y2mil("name:" << name);
LvmVgIterator i = findLvmVg( name );
- if( readonly )
+ if (readonly())
{
ret = STORAGE_CHANGE_READONLY;
}
@@ -2596,7 +2588,7 @@
assertInit();
y2mil( "name:" << name << " devices:" << devs );
LvmVgIterator i = findLvmVg( name );
- if( readonly )
+ if (readonly())
{
ret = STORAGE_CHANGE_READONLY;
}
@@ -2626,7 +2618,7 @@
assertInit();
y2mil( "name:" << name << " devices:" << devs );
LvmVgIterator i = findLvmVg( name );
- if( readonly )
+ if (readonly())
{
ret = STORAGE_CHANGE_READONLY;
}
@@ -2658,7 +2650,7 @@
assertInit();
y2mil("vg:" << vg << " name:" << name << " sizeM:" << sizeM << " stripe:" << stripe);
LvmVgIterator i = findLvmVg( vg );
- if( readonly )
+ if (readonly())
{
ret = STORAGE_CHANGE_READONLY;
}
@@ -2705,7 +2697,7 @@
assertInit();
y2mil("vg:" << vg << " name:" << name);
LvmVgIterator i = findLvmVg( vg );
- if( readonly )
+ if (readonly())
{
ret = STORAGE_CHANGE_READONLY;
}
@@ -2733,7 +2725,7 @@
assertInit();
y2mil("vg:" << vg << " name:" << name << " stripe:" << stripe);
LvmVgIterator i = findLvmVg( vg );
- if( readonly )
+ if (readonly())
{
ret = STORAGE_CHANGE_READONLY;
}
@@ -2761,7 +2753,7 @@
assertInit();
y2mil("vg:" << vg << " name:" << name << " stripeSize:" << stripeSize);
LvmVgIterator i = findLvmVg( vg );
- if( readonly )
+ if (readonly())
{
ret = STORAGE_CHANGE_READONLY;
}
@@ -2792,7 +2784,7 @@
assertInit();
y2mil("vg:" << vg << " origin:" << origin << " name:" << name << " cowSizeK:" << cowSizeK);
LvmVgIterator i = findLvmVg(vg);
- if (readonly)
+ if (readonly())
{
ret = STORAGE_CHANGE_READONLY;
}
@@ -2820,7 +2812,7 @@
assertInit();
y2mil("vg:" << vg << " name:" << name);
LvmVgIterator i = findLvmVg(vg);
- if (readonly)
+ if (readonly())
{
ret = STORAGE_CHANGE_READONLY;
}
@@ -2885,7 +2877,7 @@
y2mil( "name:" << name << " MdType:" << Md::pName(rtype) <<
" devices:" << devs );
unsigned num = 0;
- if( readonly )
+ if (readonly())
{
ret = STORAGE_CHANGE_READONLY;
}
@@ -2928,7 +2920,7 @@
int ret = 0;
assertInit();
y2mil( "MdType:" << Md::pName(rtype) << " devices:" << devs );
- if( readonly )
+ if (readonly())
{
ret = STORAGE_CHANGE_READONLY;
}
@@ -2977,7 +2969,7 @@
int ret = 0;
assertInit();
y2mil("name:" << name << " destroySb:" << destroySb);
- if( readonly )
+ if (readonly())
{
ret = STORAGE_CHANGE_READONLY;
}
@@ -3007,7 +2999,7 @@
int ret = 0;
assertInit();
y2mil("name:" << name << " dev:" << dev);
- if( readonly )
+ if (readonly())
{
ret = STORAGE_CHANGE_READONLY;
}
@@ -3037,7 +3029,7 @@
int ret = 0;
assertInit();
y2mil("name:" << name << " dev:" << dev);
- if( readonly )
+ if (readonly())
{
ret = STORAGE_CHANGE_READONLY;
}
@@ -3067,7 +3059,7 @@
int ret = 0;
assertInit();
y2mil("name:" << name << " rtype:" << rtype);
- if( readonly )
+ if (readonly())
{
ret = STORAGE_CHANGE_READONLY;
}
@@ -3097,7 +3089,7 @@
int ret = 0;
assertInit();
y2mil("name:" << name << " chunk:" << chunk);
- if( readonly )
+ if (readonly())
{
ret = STORAGE_CHANGE_READONLY;
}
@@ -3127,7 +3119,7 @@
int ret = 0;
assertInit();
y2mil("name:" << name << " parity:" << ptype);
- if( readonly )
+ if (readonly())
{
ret = STORAGE_CHANGE_READONLY;
}
@@ -3297,7 +3289,7 @@
int ret = 0;
assertInit();
y2mil( "name:" << nfsDev << " sizeK:" << sizeK << " mp:" << mp );
- if( readonly )
+ if (readonly())
{
ret = STORAGE_CHANGE_READONLY;
}
@@ -3381,7 +3373,7 @@
#ifdef DEBUG_LOOP_CRYPT_PASSWORD
y2mil("pwd:" << pwd);
#endif
- if( readonly )
+ if (readonly())
{
ret = STORAGE_CHANGE_READONLY;
}
@@ -3448,7 +3440,7 @@
int ret = 0;
assertInit();
y2mil("device:" << device << " lname:" << lname << " reuse:" << reuseExisting << " sizeK:" << sizeK);
- if( readonly )
+ if (readonly())
{
ret = STORAGE_CHANGE_READONLY;
}
@@ -3474,7 +3466,7 @@
int ret = 0;
assertInit();
y2mil("lname:" << lname << " removeFile:" << removeFile);
- if( readonly )
+ if (readonly())
{
ret = STORAGE_CHANGE_READONLY;
}
@@ -5266,7 +5258,7 @@
assertInit();
y2mil("device:" << device);
VolIterator vol;
- if( !readonly && findVolume( device, vol ) )
+ if( !readonly() && findVolume( device, vol ) )
{
if( vol->umount()==0 )
{
@@ -5286,7 +5278,7 @@
assertInit();
y2mil("device:" << device << " mp:" << mp << " ro:" << ro << " opts:" << opts);
VolIterator vol;
- if( !readonly && findVolume( device, vol ) )
+ if( !readonly() && findVolume( device, vol ) )
{
if( vol->needCrsetup() )
{
@@ -5559,7 +5551,7 @@
int
Storage::createBackupState( const string& name )
{
- int ret = readonly?STORAGE_CHANGE_READONLY:0;
+ int ret = readonly()?STORAGE_CHANGE_READONLY:0;
assertInit();
y2mil("name:" << name);
if (ret == 0 && name.empty())
@@ -5581,7 +5573,7 @@
int
Storage::removeBackupState( const string& name )
{
- int ret = readonly?STORAGE_CHANGE_READONLY:0;
+ int ret = readonly()?STORAGE_CHANGE_READONLY:0;
assertInit();
y2mil("name:" << name);
if( ret==0 )
@@ -5608,7 +5600,7 @@
int
Storage::restoreBackupState( const string& name )
{
- int ret = readonly?STORAGE_CHANGE_READONLY:0;
+ int ret = readonly()?STORAGE_CHANGE_READONLY:0;
assertInit();
y2mil("name:" << name);
if( ret==0 )
@@ -5742,7 +5734,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();
y2mil("device:" << device << " mount:" << mount << " vfs:" << vfs << " opts:" << options <<
" freq:" << freq << " passno:" << passno);
Modified: trunk/storage/libstorage/src/Storage.h
URL: http://svn.opensuse.org/viewcvs/yast/trunk/storage/libstorage/src/Storage.h?rev=57193&r1=57192&r2=57193&view=diff
==============================================================================
--- trunk/storage/libstorage/src/Storage.h (original)
+++ trunk/storage/libstorage/src/Storage.h Fri May 15 12:07:36 2009
@@ -207,9 +207,13 @@
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; }
+
void setCacheChanges( bool val=true ) { cache = val; }
bool isCacheChanges() const { return( cache ); }
void assertInit() { if( !initialized ) initialize(); }
@@ -1704,13 +1708,10 @@
bool& resize_ok) const;
// 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;
Modified: trunk/storage/libstorage/src/StorageInterface.h
URL: http://svn.opensuse.org/viewcvs/yast/trunk/storage/libstorage/src/StorageInterface.h?rev=57193&r1=57192&r2=57193&view=diff
==============================================================================
--- trunk/storage/libstorage/src/StorageInterface.h (original)
+++ trunk/storage/libstorage/src/StorageInterface.h Fri May 15 12:07:36 2009
@@ -68,19 +68,22 @@
* using namespace storage;
*
* int
- * main ()
+ * main()
* {
+ * // Environment for StorageInterface with read-write enabled.
+ * Environment env(false);
+ *
* // First we must create a concrete StorageInterface object.
- * StorageInterface* s = createStorageInterface (false, false, true);
+ * StorageInterface* s = createStorageInterface(env);
*
* int ret;
* string name;
*
* // Create a primary partition on /dev/hda.
- * ret = s->createPartitionKb ("/dev/hda", PRIMARY, 0, 100000, name);
+ * ret = s->createPartitionKb("/dev/hda", PRIMARY, 0, 100000, name);
*
* // Commit the change to the system.
- * ret = s->commit ();
+ * ret = s->commit();
*
* // Finally destroy the StorageInterface object.
* delete s;
@@ -2125,11 +2128,17 @@
/**
- * 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) {}
+
+ bool readonly;
+ bool testmode;
+ bool autodetect;
+ bool instsys;
+ };
/**
@@ -2137,8 +2146,7 @@
*
* Throws an exception when locking fails.
*/
- StorageInterface* createStorageInterface (bool readonly, bool testmode,
- bool autodetect);
+ StorageInterface* createStorageInterface(const Environment& env);
/**
@@ -2148,8 +2156,7 @@
* 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);
/**
Modified: trunk/storage/libstorage/src/Volume.cc
URL: http://svn.opensuse.org/viewcvs/yast/trunk/storage/libstorage/src/Volume.cc?rev=57193&r1=57192&r2=57193&view=diff
==============================================================================
--- trunk/storage/libstorage/src/Volume.cc (original)
+++ trunk/storage/libstorage/src/Volume.cc Fri May 15 12:07:36 2009
@@ -702,7 +702,7 @@
ret = umount( orig_mp );
needMount = ret==0;
}
- if( ret==0 && !cont->getStorage()->test() )
+ if( ret==0 && !cont->getStorage()->testmode() )
{
ret = checkDevice();
}
@@ -714,7 +714,7 @@
{
ret = Storage::zeroDevice(mountDevice(), size_k, true);
}
- if( ret==0 && mountDevice()!=dev && !cont->getStorage()->test() )
+ if( ret==0 && mountDevice()!=dev && !cont->getStorage()->testmode() )
{
ret = checkDevice(mountDevice());
}
@@ -862,7 +862,7 @@
{
format = false;
detected_fs = fs;
- if( fs != SWAP && !cont->getStorage()->test() )
+ if( fs != SWAP && !cont->getStorage()->testmode() )
{
FsType old=fs;
updateFsData();
@@ -1134,7 +1134,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 )
{
@@ -1638,7 +1638,7 @@
{
EncryptType ret = ENC_UNKNOWN;
- if( getContainer()->getStorage()->test() )
+ if (getContainer()->getStorage()->testmode())
{
ret = encryption = orig_encryption = ENC_TWOFISH;
y2mil("ret:" << encTypeString(ret));
Modified: trunk/storage/libstorage/testsuite-real/lvmcreate1.cc
URL: http://svn.opensuse.org/viewcvs/yast/trunk/storage/libstorage/testsuite-real/lvmcreate1.cc?rev=57193&r1=57192&r2=57193&view=diff
==============================================================================
--- trunk/storage/libstorage/testsuite-real/lvmcreate1.cc (original)
+++ trunk/storage/libstorage/testsuite-real/lvmcreate1.cc Fri May 15 12:07:36 2009
@@ -11,7 +11,7 @@
void
doit ()
{
- StorageInterface* s = createDefaultStorageInterface ();
+ StorageInterface* s = createStorageInterface(Environment(false));
cout << s->destroyPartitionTable ("hdb", s->defaultDiskLabel ()) << '\n';
Modified: trunk/storage/libstorage/testsuite-real/lvmcreate2.cc
URL: http://svn.opensuse.org/viewcvs/yast/trunk/storage/libstorage/testsuite-real/lvmcreate2.cc?rev=57193&r1=57192&r2=57193&view=diff
==============================================================================
--- trunk/storage/libstorage/testsuite-real/lvmcreate2.cc (original)
+++ trunk/storage/libstorage/testsuite-real/lvmcreate2.cc Fri May 15 12:07:36 2009
@@ -11,7 +11,7 @@
void
doit ()
{
- StorageInterface* s = createDefaultStorageInterface ();
+ StorageInterface* s = createStorageInterface(Environment(false));
cout << s->destroyPartitionTable ("hdb", s->defaultDiskLabel ()) << '\n';
Modified: trunk/storage/libstorage/testsuite-real/lvmextend1.cc
URL: http://svn.opensuse.org/viewcvs/yast/trunk/storage/libstorage/testsuite-real/lvmextend1.cc?rev=57193&r1=57192&r2=57193&view=diff
==============================================================================
--- trunk/storage/libstorage/testsuite-real/lvmextend1.cc (original)
+++ trunk/storage/libstorage/testsuite-real/lvmextend1.cc Fri May 15 12:07:36 2009
@@ -11,7 +11,7 @@
void
doit ()
{
- StorageInterface* s = createDefaultStorageInterface ();
+ StorageInterface* s = createStorageInterface(Environment(false));
cout << s->destroyPartitionTable ("hdb", s->defaultDiskLabel ()) << '\n';
Modified: trunk/storage/libstorage/testsuite-real/lvmextend2.cc
URL: http://svn.opensuse.org/viewcvs/yast/trunk/storage/libstorage/testsuite-real/lvmextend2.cc?rev=57193&r1=57192&r2=57193&view=diff
==============================================================================
--- trunk/storage/libstorage/testsuite-real/lvmextend2.cc (original)
+++ trunk/storage/libstorage/testsuite-real/lvmextend2.cc Fri May 15 12:07:36 2009
@@ -11,7 +11,7 @@
void
doit ()
{
- StorageInterface* s = createDefaultStorageInterface ();
+ StorageInterface* s = createStorageInterface(Environment(false));
cout << s->destroyPartitionTable ("hdb", s->defaultDiskLabel ()) << '\n';
@@ -48,7 +48,7 @@
delete s;
- s = createDefaultStorageInterface ();
+ s = createStorageInterface(Environment(false));
deque <string> pds34;
Modified: trunk/storage/libstorage/testsuite/Makefile.am
URL: http://svn.opensuse.org/viewcvs/yast/trunk/storage/libstorage/testsuite/Makefile.am?rev=57193&r1=57192&r2=57193&view=diff
==============================================================================
--- trunk/storage/libstorage/testsuite/Makefile.am (original)
+++ trunk/storage/libstorage/testsuite/Makefile.am Fri May 15 12:07:36 2009
@@ -15,25 +15,25 @@
lvm_create.single lvm_extend.single md_create.single \
humanstring1.single humanstring2.single
-partition1_single_SOURCES = partition1.cc
+partition1_single_SOURCES = partition1.cc common.cc common.h
partition1_single_LDADD = ../src/liby2storage.la
-format1_single_SOURCES = format1.cc
+format1_single_SOURCES = format1.cc common.cc common.h
format1_single_LDADD = ../src/liby2storage.la
uuid1_single_SOURCES = uuid1.cc common.cc common.h
uuid1_single_LDADD = ../src/liby2storage.la
-fstab1_single_SOURCES = fstab1.cc
+fstab1_single_SOURCES = fstab1.cc common.cc common.h
fstab1_single_LDADD = ../src/liby2storage.la
-lvm_create_single_SOURCES = lvm_create.cc
+lvm_create_single_SOURCES = lvm_create.cc common.cc common.h
lvm_create_single_LDADD = ../src/liby2storage.la
-lvm_extend_single_SOURCES = lvm_extend.cc
+lvm_extend_single_SOURCES = lvm_extend.cc common.cc common.h
lvm_extend_single_LDADD = ../src/liby2storage.la
-md_create_single_SOURCES = md_create.cc
+md_create_single_SOURCES = md_create.cc common.cc common.h
md_create_single_LDADD = ../src/liby2storage.la
humanstring1_single_SOURCES = humanstring1.cc
Modified: trunk/storage/libstorage/testsuite/common.h
URL: http://svn.opensuse.org/viewcvs/yast/trunk/storage/libstorage/testsuite/common.h?rev=57193&r1=57192&r2=57193&view=diff
==============================================================================
--- trunk/storage/libstorage/testsuite/common.h (original)
+++ trunk/storage/libstorage/testsuite/common.h Fri May 15 12:07:36 2009
@@ -1,6 +1,9 @@
#include <string>
+#include