YaST Commits
Threads by month
- ----- 2024 -----
- July
- June
- May
- April
- March
- February
- January
- ----- 2023 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2022 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2021 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2020 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2019 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2018 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2017 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2016 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2015 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2014 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2013 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2012 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2011 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2010 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2009 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2008 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2007 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
May 2011
- 16 participants
- 288 discussions
[yast-commit] r64021 - in /branches/SuSE-Code-11-SP2-Branch/storage: ./ storage/src/modules/
by fehr@svn2.opensuse.org 17 May '11
by fehr@svn2.opensuse.org 17 May '11
17 May '11
Author: fehr
Date: Tue May 17 19:22:27 2011
New Revision: 64021
URL: http://svn.opensuse.org/viewcvs/yast?rev=64021&view=rev
Log:
changes to keep compatible to bootloader package of SLES11 SP1
Added:
branches/SuSE-Code-11-SP2-Branch/storage/storage/src/modules/StorageUpdate.ycp
branches/SuSE-Code-11-SP2-Branch/storage/storage/src/modules/storage_update.ycp
Modified:
branches/SuSE-Code-11-SP2-Branch/storage/storage/src/modules/Makefile.am
branches/SuSE-Code-11-SP2-Branch/storage/storage/src/modules/Storage.ycp
branches/SuSE-Code-11-SP2-Branch/storage/storage/src/modules/StorageControllers.ycp
branches/SuSE-Code-11-SP2-Branch/storage/yast2-storage.spec.in
Modified: branches/SuSE-Code-11-SP2-Branch/storage/storage/src/modules/Makefile.am
URL: http://svn.opensuse.org/viewcvs/yast/branches/SuSE-Code-11-SP2-Branch/stora…
==============================================================================
--- branches/SuSE-Code-11-SP2-Branch/storage/storage/src/modules/Makefile.am (original)
+++ branches/SuSE-Code-11-SP2-Branch/storage/storage/src/modules/Makefile.am Tue May 17 19:22:27 2011
@@ -7,6 +7,11 @@
YCPC_LD_LIBRARY_PATH = ../../../libstorage/src/.libs
YCPC_Y2DIR = ../../../libstorage/src/.libs
+yncludedir = @yncludedir@/storage
+
+ynclude_DATA = storage_update.ycp
+
+
module_DATA = \
Partitions.ycp \
FileSystems.ycp \
@@ -27,6 +32,11 @@
DualMultiSelectionBox.ycp \
Region.ycp
-EXTRA_DIST = $(module_DATA)
+EXTRA_DIST = $(module_DATA) $(ynclude_DATA)
+
+include:
+ mkdir include && ln -sf ../../include include/partitioning
+
+ycpchook = include
include $(top_srcdir)/Makefile.am.common
Modified: branches/SuSE-Code-11-SP2-Branch/storage/storage/src/modules/Storage.ycp
URL: http://svn.opensuse.org/viewcvs/yast/branches/SuSE-Code-11-SP2-Branch/stora…
==============================================================================
--- branches/SuSE-Code-11-SP2-Branch/storage/storage/src/modules/Storage.ycp (original)
+++ branches/SuSE-Code-11-SP2-Branch/storage/storage/src/modules/Storage.ycp Tue May 17 19:22:27 2011
@@ -5956,4 +5956,6 @@
return( ret );
}
+include "./storage_update.ycp";
+
}
Modified: branches/SuSE-Code-11-SP2-Branch/storage/storage/src/modules/StorageControllers.ycp
URL: http://svn.opensuse.org/viewcvs/yast/branches/SuSE-Code-11-SP2-Branch/stora…
==============================================================================
--- branches/SuSE-Code-11-SP2-Branch/storage/storage/src/modules/StorageControllers.ycp (original)
+++ branches/SuSE-Code-11-SP2-Branch/storage/storage/src/modules/StorageControllers.ycp Tue May 17 19:22:27 2011
@@ -36,6 +36,8 @@
list<list> ModToInitrdLx = [];
list<list> ModToInitrd = [];
+ global string dasdParam = "";
+
list<map> controllers = []; // set by "Probe"
Added: branches/SuSE-Code-11-SP2-Branch/storage/storage/src/modules/StorageUpdate.ycp
URL: http://svn.opensuse.org/viewcvs/yast/branches/SuSE-Code-11-SP2-Branch/stora…
==============================================================================
--- branches/SuSE-Code-11-SP2-Branch/storage/storage/src/modules/StorageUpdate.ycp (added)
+++ branches/SuSE-Code-11-SP2-Branch/storage/storage/src/modules/StorageUpdate.ycp Tue May 17 19:22:27 2011
@@ -0,0 +1,18 @@
+/**
+ * Module: StorageUpdate.ycp
+ *
+ * Authors: Thomas Fehr <fehr(a)suse.de>
+ * Arvin Schnell <aschnell(a)suse.de>
+ */
+{
+module "StorageUpdate";
+
+textdomain "storage";
+
+import "Storage";
+
+global void Update(map oldv, map newv)
+ {
+ Storage::Update( oldv, newv );
+ }
+}
Added: branches/SuSE-Code-11-SP2-Branch/storage/storage/src/modules/storage_update.ycp
URL: http://svn.opensuse.org/viewcvs/yast/branches/SuSE-Code-11-SP2-Branch/stora…
==============================================================================
--- branches/SuSE-Code-11-SP2-Branch/storage/storage/src/modules/storage_update.ycp (added)
+++ branches/SuSE-Code-11-SP2-Branch/storage/storage/src/modules/storage_update.ycp Tue May 17 19:22:27 2011
@@ -0,0 +1,449 @@
+/**
+ * Module: storage_update.ycp
+ *
+ * Authors: Thomas Fehr <fehr(a)suse.de>
+ * Arvin Schnell <aschnell(a)suse.de>
+ */
+{
+ textdomain "storage";
+
+
+ import "AsciiFile";
+
+ // flag indicates calling Storage::Update()
+ boolean called_update = false;
+
+
+ void UpdateFstabSubfs()
+ {
+ y2milestone( "UpdateFstabSubfs removing fstab entries for cdrom and floppy" );
+ string tabpath = Storage::PathToDestdir( "/etc/fstab" );
+ map fstab = Partitions::GetFstab( tabpath );
+ integer line = 0;
+ list<integer> rem_lines = [];
+ while( line<=AsciiFile::NumLines( fstab ) )
+ {
+ map l = AsciiFile::GetLine( fstab, line );
+ if( search( l["fields",1]:"", "/media/floppy" )==0 )
+ {
+ rem_lines = add( rem_lines, line );
+ }
+ else if( search( l["fields",1]:"", "/media/cdrom" )==0 ||
+ search( l["fields",1]:"", "/media/dvd" )==0 ||
+ search( l["fields",1]:"", "/media/cdrecorder" )==0 ||
+ search( l["fields",1]:"", "/media/dvdrecorder" )==0 ||
+ search( l["fields",1]:"", "/cdrom" )==0 ||
+ search( l["fields",1]:"", "/dvd" )==0 ||
+ search( l["fields",1]:"", "/cdrecorder" )==0 ||
+ search( l["fields",1]:"", "/dvdrecorder" )==0 )
+ {
+ rem_lines = add( rem_lines, line );
+ }
+ line = line+1;
+ }
+ y2milestone( "UpdateFstabSubfs %1", rem_lines );
+ if( size(rem_lines)>0 )
+ {
+ rem_lines = sort(rem_lines);
+ AsciiFile::RemoveLines( fstab, rem_lines );
+ }
+ AsciiFile::RewriteFile( fstab, tabpath );
+ }
+
+
+ void UpdateFstabSysfs()
+ {
+ y2milestone( "UpdateFstabSysfs called" );
+ string tabpath = Storage::PathToDestdir( "/etc/fstab" );
+ map fstab = Partitions::GetFstab( tabpath );
+ integer line = 0;
+ boolean have_sysfs = false;
+ while( !have_sysfs && line<=AsciiFile::NumLines( fstab ) )
+ {
+ map l = AsciiFile::GetLine( fstab, line );
+ have_sysfs = l["fields",1]:"" == "/sys";
+ line = line+1;
+ }
+ if( !have_sysfs )
+ {
+ map entry = FileSystems::GetFstabDefaultMap( "sys" );
+ list fstlist = [ entry["spec"]:"", entry["mount"]:"",
+ entry["vfstype"]:"", entry["mntops"]:"",
+ sformat("%1",entry["freq"]:0),
+ sformat("%1",entry["passno"]:0) ];
+ y2milestone( "UpdateFstabSysfs entry %1", entry );
+ y2milestone( "UpdateFstabSysfs fstlist %1", fstlist );
+ AsciiFile::AppendLine( fstab, fstlist );
+ AsciiFile::RewriteFile( fstab, tabpath );
+ }
+ }
+
+
+define void UpdateFstabHotplugOption()
+ {
+ y2milestone( "UpdateFstabHotplugOption" );
+ string tabpath = Storage::PathToDestdir( "/etc/fstab" );
+ map fstab = Partitions::GetFstab( tabpath );
+ integer line = 0;
+ string n = "";
+ while( line<=AsciiFile::NumLines( fstab ) )
+ {
+ map l = AsciiFile::GetLine( fstab, line );
+ string options = l["fields", 3]:"";
+ if (regexpmatch (options, "^\(.*,\)\?hotplug\(,.*\)\?$")) {
+ options = regexpsub (options, "^\(.*,\)\?hotplug\(,.*\)\?$", "\\1nofail\\2");
+ AsciiFile::ChangeLineField( fstab, line, 3, options );
+ }
+ line = line+1;
+ }
+ AsciiFile::RewriteFile( fstab, tabpath );
+ }
+
+
+ void UpdateFstabPersistentNames()
+ {
+ y2milestone( "UpdateFstabPersistentDevNames updating to SLES10 names" );
+ string tabpath = Storage::PathToDestdir( "/etc/fstab" );
+ map fstab = Partitions::GetFstab( tabpath );
+ integer line = 0;
+ string n = "";
+ while( line<=AsciiFile::NumLines( fstab ) )
+ {
+ map l = AsciiFile::GetLine( fstab, line );
+ n = Storage::SLES9PersistentDevNames( l["fields",0]:"" );
+ if( n != l["fields",0]:"" )
+ {
+ AsciiFile::ChangeLineField( fstab, line, 0, n );
+ }
+ line = line+1;
+ }
+ AsciiFile::RewriteFile( fstab, tabpath );
+ }
+
+
+ void UpdateFstabEvms2Lvm()
+ {
+ y2milestone( "UpdateFstabEvms2Lvm migrating EVMS to LVM" );
+ string tabpath = Storage::PathToDestdir( "/etc/fstab" );
+ map fstab = Partitions::GetFstab( tabpath );
+ integer line = 0;
+ string n = "";
+ while( line<=AsciiFile::NumLines( fstab ) ) {
+ map l = AsciiFile::GetLine( fstab, line );
+ n = l["fields",0]:"";
+ if (substring (n, 0, 15) == "/dev/evms/lvm2/")
+ {
+ n = "/dev/" + substring (n, 15);
+ AsciiFile::ChangeLineField( fstab, line, 0, n );
+ }
+ line = line+1;
+ }
+ AsciiFile::RewriteFile( fstab, tabpath );
+ }
+
+
+ void UpdateMdadm()
+ {
+ y2milestone( "UpdateMdadm" );
+ string cpath = Storage::PathToDestdir( "/etc/mdadm.conf" );
+ map file = $[];
+ AsciiFile::SetComment( file, "^[ \t]*#" );
+ AsciiFile::ReadFile( file, cpath );
+ integer line = 0;
+ boolean changed = false;
+ while( line<=AsciiFile::NumLines( file ) )
+ {
+ if( search( file["l",line,"line"]:"", "DEVICE" )!=nil &&
+ search( file["l",line,"line"]:"", "/dev/" )!=nil )
+ {
+ changed = true;
+ file["l",line,"line"] = "DEVICE partitions";
+ y2milestone( "UpdateMdadm %1", file["l",line]:$[] );
+ }
+ line = line+1;
+ }
+ if( changed )
+ AsciiFile::RewriteFile( file, cpath );
+ }
+
+
+ void UpdateFstabDiskmap(map diskmap)
+ {
+ y2milestone( "UpdateFstabDiskmap map %1", diskmap );
+ string tabpath = Storage::PathToDestdir( "/etc/fstab" );
+ map fstab = Partitions::GetFstab( tabpath );
+ integer line = 0;
+ string n = "";
+ while( line<=AsciiFile::NumLines( fstab ) )
+ {
+ map l = AsciiFile::GetLine( fstab, line );
+ n = Storage::HdDiskMap( l["fields",0]:"", diskmap );
+ if( n != l["fields",0]:"" )
+ {
+ AsciiFile::ChangeLineField( fstab, line, 0, n );
+ }
+ line = line+1;
+ }
+ AsciiFile::RewriteFile( fstab, tabpath );
+ tabpath = Storage::PathToDestdir( "/etc/cryptotab" );
+ map crtab = Partitions::GetCrypto( tabpath );
+ line = 0;
+ while( line<=AsciiFile::NumLines( crtab ) )
+ {
+ map l = AsciiFile::GetLine( crtab, line );
+ n = Storage::HdDiskMap( l["fields",1]:"", diskmap );
+ if( n != l["fields",1]:"" )
+ {
+ AsciiFile::ChangeLineField( crtab, line, 1, n );
+ }
+ line = line+1;
+ }
+ AsciiFile::RewriteFile( crtab, tabpath );
+ }
+
+
+ void UpdateFstabUsbdevfs()
+ {
+ y2milestone( "UpdateFstabUsbdevfs updating usbdevfs to usbfs" );
+ boolean changed = false;
+ string tabpath = Storage::PathToDestdir( "/etc/fstab" );
+ map fstab = Partitions::GetFstab( tabpath );
+ integer line = 0;
+ while( line<=AsciiFile::NumLines( fstab ) )
+ {
+ map l = AsciiFile::GetLine( fstab, line );
+ if( l["fields",2]:"" == "usbdevfs" )
+ {
+ AsciiFile::ChangeLineField( fstab, line, 2, "usbfs" );
+ AsciiFile::ChangeLineField( fstab, line, 0, "usbfs" );
+ changed = true;
+ }
+ line = line+1;
+ }
+ if( changed )
+ {
+ y2milestone( "UpdateFstabUsbdevfs changed" );
+ AsciiFile::RewriteFile( fstab, tabpath );
+ }
+ }
+
+
+ void UpdateFstabIseriesVd()
+ {
+ y2milestone( "UpdateFstabIseriesVd updating hdx to iseries/vdx" );
+ string tabpath = Storage::PathToDestdir( "/etc/fstab" );
+ map fstab = Partitions::GetFstab( tabpath );
+ integer line = 0;
+ string n = "";
+ while( line<=AsciiFile::NumLines( fstab ) )
+ {
+ map l = AsciiFile::GetLine( fstab, line );
+ n = Storage::HdToIseries( l["fields",0]:"" );
+ if( n != l["fields",0]:"" )
+ {
+ AsciiFile::ChangeLineField( fstab, line, 0, n );
+ }
+ line = line+1;
+ }
+ AsciiFile::RewriteFile( fstab, tabpath );
+ tabpath = Storage::PathToDestdir( "/etc/cryptotab" );
+ map crtab = Partitions::GetCrypto( tabpath );
+ line = 0;
+ while( line<=AsciiFile::NumLines( crtab ) )
+ {
+ map l = AsciiFile::GetLine( crtab, line );
+ n = Storage::HdToIseries( l["fields",1]:"" );
+ if( n != l["fields",1]:"" )
+ {
+ AsciiFile::ChangeLineField( crtab, line, 1, n );
+ }
+ line = line+1;
+ }
+ AsciiFile::RewriteFile( crtab, tabpath );
+ }
+
+
+ void UpdateCryptoType()
+ {
+ y2milestone( "UpdateCryptoType" );
+ string tabpath = Storage::PathToDestdir( "/etc/fstab" );
+ map fstab = Partitions::GetFstab( tabpath );
+ integer line = 0;
+ integer pos = 0;
+ string searchstr = "encryption=twofish256";
+ while( line<=AsciiFile::NumLines( fstab ) )
+ {
+ map l = AsciiFile::GetLine( fstab, line );
+ pos = search( l["fields",3]:"", searchstr );
+ if( pos != nil )
+ {
+ string new = substring( l["fields",3]:"", 0, pos );
+ new = new + "encryption=twofishSL92";
+ new = new + substring( l["fields",3]:"", pos+size(searchstr) );
+ y2milestone( "new options line in %1 is %2", l, new );
+ AsciiFile::ChangeLineField( fstab, line, 3, new );
+ }
+ line = line+1;
+ }
+ AsciiFile::RewriteFile( fstab, tabpath );
+ tabpath = Storage::PathToDestdir( "/etc/cryptotab" );
+ map crtab = Partitions::GetCrypto( tabpath );
+ line = 0;
+ while( line<=AsciiFile::NumLines( crtab ) )
+ {
+ map l = AsciiFile::GetLine( crtab, line );
+ if( l["fields",4]:"" == "twofish256" )
+ {
+ y2milestone( "set twofishSL92 in line %1", l );
+ AsciiFile::ChangeLineField( crtab, line, 4, "twofishSL92" );
+ }
+ line = line+1;
+ }
+ AsciiFile::RewriteFile( crtab, tabpath );
+ }
+
+void UpdateFstabCryptNofail()
+ {
+ y2milestone( "UpdateFstabCryptNofail called" );
+ string tabpath = Storage::PathToDestdir( "/etc/fstab" );
+ map fstab = Partitions::GetFstab( tabpath );
+ integer line = 0;
+ boolean update = false;
+ while( line<=AsciiFile::NumLines( fstab ) )
+ {
+ map l = AsciiFile::GetLine( fstab, line );
+ if( search( l["fields",0]:"", "/dev/mapper/cr_" )==0 )
+ {
+ list<string> ls = splitstring( l["fields",3]:"", "," );
+ ls = filter( string s, ls, ``(s!="noauto"));
+ if( size(filter( string s, ls, ``(s=="nofail")))==0 )
+ {
+ ls = add( ls, "nofail" );
+ AsciiFile::ChangeLineField( fstab, line, 3,
+ mergestring( ls, "," ));
+ update = true;
+ }
+ }
+ line = line+1;
+ }
+ if( update )
+ {
+ AsciiFile::RewriteFile( fstab, tabpath );
+ }
+ }
+
+ /**
+ * Updates fstab on disk
+ *
+ * @param map old version
+ * @param map new version
+ *
+ * @struct version $[
+ * // This means version 9.1
+ * "major" : 9,
+ * "minor" : 1,
+ * ]
+ */
+ global void Update(map oldv, map newv)
+ {
+ if (!called_update)
+ {
+ y2milestone( "Update old:%1 new:%2", oldv, newv );
+
+ // Enterprise products do not have minor release number
+ // map enterprise releases to corresponding code bases of SL
+ map sles_major_to_minor = $[ 8 : 2, 9 : 1, 10 : 1 ];
+ if( haskey( oldv, "major" ) && !haskey( oldv, "minor" ) )
+ {
+ oldv["minor"] = sles_major_to_minor[oldv["major"]:0]:0;
+ y2milestone( "Update old:%1", oldv );
+ }
+ if( haskey( newv, "major" ) && !haskey( newv, "minor" ) )
+ {
+ newv["minor"] = sles_major_to_minor[newv["major"]:0]:0;
+ y2milestone( "Update new:%1", newv );
+ }
+ if( !haskey( oldv, "major" ) || !haskey( newv, "major" ) )
+ y2error( "Missing key major or minor" );
+
+ if( oldv["major"]:0<=9 )
+ {
+ UpdateFstabSysfs();
+ }
+ if( oldv["major"]:0<9 )
+ {
+ UpdateFstabUsbdevfs();
+ }
+ if( oldv["major"]:0==9 )
+ {
+ UpdateFstabPersistentNames();
+ }
+
+ if( oldv["major"]:0<=10 )
+ {
+ UpdateFstabHotplugOption();
+ }
+
+ // remove EVMS
+ // FIXME add appropriate condition if needed (does not seem so)
+ UpdateFstabEvms2Lvm();
+
+ map dm = Storage::BuildDiskmap( oldv );
+ if( size(dm)>0 )
+ {
+ UpdateFstabDiskmap( dm );
+ UpdateMdadm();
+ }
+ if( oldv["major"]:0<9 || (oldv["major"]:0==9 && oldv["minor"]:0<=2))
+ {
+ UpdateCryptoType();
+ }
+ if( oldv["major"]:0<10 || (oldv["major"]:0==10 && oldv["minor"]:0==0) )
+ {
+ string of = "/etc/udev/rules.d/20-cdrom.rules";
+ y2milestone( "removing obsolete %1", of );
+ SCR::Execute( .target.remove, of );
+ of = "/etc/udev/rules.d/55-cdrom.rules";
+ y2milestone( "removing obsolete %1", of );
+ SCR::Execute( .target.remove, of );
+ }
+ if( oldv["major"]:0<10 || (oldv["major"]:0==10 && oldv["minor"]:0<=2) )
+ {
+ string of = "/etc/udev/rules.d/65-cdrom.rules";
+ y2milestone( "removing obsolete %1", of );
+ SCR::Execute( .target.remove, of );
+ }
+ if( oldv["major"]:0<10 || (oldv["major"]:0==10 && oldv["minor"]:0==0))
+ UpdateFstabSubfs();
+ if( oldv["major"]:0<9 || (oldv["major"]:0==9 && oldv["minor"]:0==0))
+ {
+ if( Arch::board_iseries () )
+ {
+ UpdateFstabIseriesVd();
+ }
+ string cmd = "cd / && /sbin/insserv -r /etc/init.d/boot.evms";
+ y2milestone( "Update cmd %1", cmd );
+ map bo = (map)SCR::Execute (.target.bash_output, cmd );
+ y2milestone( "Update bo %1", bo );
+ }
+ if( oldv["major"]:0<10 || (oldv["major"]:0==10 && oldv["minor"]:0<=2))
+ {
+ string cmd = "cd / && /sbin/insserv /etc/init.d/boot.crypto";
+ map bo = (map)SCR::Execute (.target.bash_output, cmd );
+ y2milestone( "Update bo %1", bo );
+
+ cmd = "cd / && /sbin/insserv /etc/init.d/boot.crypto-early";
+ bo = (map)SCR::Execute (.target.bash_output, cmd );
+ y2milestone( "Update bo %1", bo );
+ }
+ if( oldv["major"]:0<11 || (oldv["major"]:0==11 && oldv["minor"]:0<=2))
+ UpdateFstabCryptNofail();
+ // set flag -> it indicates that Update was already called
+ called_update = true;
+ }
+ else
+ {
+ y2milestone("Skip calling Update() -> It was already called");
+ }
+ }
+}
Modified: branches/SuSE-Code-11-SP2-Branch/storage/yast2-storage.spec.in
URL: http://svn.opensuse.org/viewcvs/yast/branches/SuSE-Code-11-SP2-Branch/stora…
==============================================================================
--- branches/SuSE-Code-11-SP2-Branch/storage/yast2-storage.spec.in (original)
+++ branches/SuSE-Code-11-SP2-Branch/storage/yast2-storage.spec.in Tue May 17 19:22:27 2011
@@ -53,6 +53,8 @@
# storage
%dir @yncludedir@/partitioning
@yncludedir@/partitioning/*.ycp
+%dir @yncludedir@/storage
+@yncludedir@/storage/*.ycp
@clientdir@/inst_custom_part.ycp
@clientdir@/inst_resize_ui.ycp
@clientdir@/inst_resize_dialog.ycp
--
To unsubscribe, e-mail: yast-commit+unsubscribe(a)opensuse.org
For additional commands, e-mail: yast-commit+help(a)opensuse.org
1
0
17 May '11
Author: tgoettlicher
Date: Tue May 17 16:36:52 2011
New Revision: 64020
URL: http://svn.opensuse.org/viewcvs/yast?rev=64020&view=rev
Log:
updated maintainers file
Modified:
trunk/printer/MAINTAINER
Modified: trunk/printer/MAINTAINER
URL: http://svn.opensuse.org/viewcvs/yast/trunk/printer/MAINTAINER?rev=64020&r1=…
==============================================================================
--- trunk/printer/MAINTAINER (original)
+++ trunk/printer/MAINTAINER Tue May 17 16:36:52 2011
@@ -1 +1 @@
-Michal Zugec <mzugec(a)novell.com>
+Johannes Meixner <jsmeix(a)novell.com>
--
To unsubscribe, e-mail: yast-commit+unsubscribe(a)opensuse.org
For additional commands, e-mail: yast-commit+help(a)opensuse.org
1
0
[yast-commit] r64019 - in /branches/SuSE-Code-11-SP2-Branch/storage: libstorage/testsuite/data/empty/ libstorage/testsuite/data/scandium/ libstorage/testsuite/data/thalassa/ storage/src/testsuite/data/empty-efi/...
by fehr@svn2.opensuse.org 17 May '11
by fehr@svn2.opensuse.org 17 May '11
17 May '11
Author: fehr
Date: Tue May 17 16:29:13 2011
New Revision: 64019
URL: http://svn.opensuse.org/viewcvs/yast?rev=64019&view=rev
Log:
set svn:ignore
Modified:
branches/SuSE-Code-11-SP2-Branch/storage/libstorage/testsuite/data/empty/ (props changed)
branches/SuSE-Code-11-SP2-Branch/storage/libstorage/testsuite/data/scandium/ (props changed)
branches/SuSE-Code-11-SP2-Branch/storage/libstorage/testsuite/data/thalassa/ (props changed)
branches/SuSE-Code-11-SP2-Branch/storage/storage/src/testsuite/data/empty/ (props changed)
branches/SuSE-Code-11-SP2-Branch/storage/storage/src/testsuite/data/empty-efi/ (props changed)
branches/SuSE-Code-11-SP2-Branch/storage/storage/src/testsuite/data/half-empty/ (props changed)
branches/SuSE-Code-11-SP2-Branch/storage/storage/src/testsuite/data/reuse-home/ (props changed)
branches/SuSE-Code-11-SP2-Branch/storage/storage/src/testsuite/data/windows/ (props changed)
branches/SuSE-Code-11-SP2-Branch/storage/storage/src/testsuite/data/windows-only/ (props changed)
--
To unsubscribe, e-mail: yast-commit+unsubscribe(a)opensuse.org
For additional commands, e-mail: yast-commit+help(a)opensuse.org
1
0
[yast-commit] r64018 - /branches/SuSE-Code-11-SP2-Branch/storage/package/yast2-storage.changes
by aschnell@svn2.opensuse.org 17 May '11
by aschnell@svn2.opensuse.org 17 May '11
17 May '11
Author: aschnell
Date: Tue May 17 15:32:36 2011
New Revision: 64018
URL: http://svn.opensuse.org/viewcvs/yast?rev=64018&view=rev
Log:
- added more fate and bnc numbers
Modified:
branches/SuSE-Code-11-SP2-Branch/storage/package/yast2-storage.changes
Modified: branches/SuSE-Code-11-SP2-Branch/storage/package/yast2-storage.changes
URL: http://svn.opensuse.org/viewcvs/yast/branches/SuSE-Code-11-SP2-Branch/stora…
==============================================================================
--- branches/SuSE-Code-11-SP2-Branch/storage/package/yast2-storage.changes (original)
+++ branches/SuSE-Code-11-SP2-Branch/storage/package/yast2-storage.changes Tue May 17 15:32:36 2011
@@ -3,7 +3,8 @@
- huge backport from svn and git head for lots of features
in SLES11 SP2 (e.g. fate#307741, fate#311015, fate#310223,
- fate#303810, fate#306587l, fate#306960)
+ fate#303810, fate#306587l, fate#306960, fate#311533) and bug
+ fixes (e.g. bnc#640851 and bnc#612867)
- version 2.17.101
-------------------------------------------------------------------
--
To unsubscribe, e-mail: yast-commit+unsubscribe(a)opensuse.org
For additional commands, e-mail: yast-commit+help(a)opensuse.org
1
0
[yast-commit] r64017 - in /trunk/theme: ./ SLE/icons/16x16/apps/ SLE/icons/22x22/apps/ SLE/icons/256x256/apps/ SLE/icons/32x32/apps/ SLE/icons/48x48/apps/ SLE/icons/64x64/apps/ SLE/icons/scalable/apps/ openSUSE-...
by tgoettlicher@svn2.opensuse.org 17 May '11
by tgoettlicher@svn2.opensuse.org 17 May '11
17 May '11
Author: tgoettlicher
Date: Tue May 17 15:16:09 2011
New Revision: 64017
URL: http://svn.opensuse.org/viewcvs/yast?rev=64017&view=rev
Log:
- Added icons for FCoE (Fibre Channel over Ethernet)
- 2.21.3
Added:
trunk/theme/SLE/icons/16x16/apps/fcoe.png (with props)
trunk/theme/SLE/icons/22x22/apps/fcoe.png (with props)
trunk/theme/SLE/icons/256x256/apps/fcoe.png (with props)
trunk/theme/SLE/icons/32x32/apps/fcoe.png (with props)
trunk/theme/SLE/icons/48x48/apps/fcoe.png (with props)
trunk/theme/SLE/icons/64x64/apps/fcoe.png (with props)
trunk/theme/SLE/icons/scalable/apps/fcoe.svg
trunk/theme/openSUSE-Crystal/icons/22x22/apps/fcoe.png (with props)
trunk/theme/openSUSE-Crystal/icons/32x32/apps/fcoe.png (with props)
trunk/theme/openSUSE-Crystal/icons/48x48/apps/fcoe.png (with props)
trunk/theme/openSUSE-Oxygen/icons/22x22/apps/fcoe.png (with props)
trunk/theme/openSUSE-Oxygen/icons/32x32/apps/fcoe.png (with props)
trunk/theme/openSUSE-Oxygen/icons/48x48/apps/fcoe.png (with props)
trunk/theme/openSUSE-Oxygen/icons/64x64/apps/fcoe.png (with props)
trunk/theme/openSUSE/icons/16x16/apps/fcoe.png (with props)
trunk/theme/openSUSE/icons/22x22/apps/fcoe.png (with props)
trunk/theme/openSUSE/icons/256x256/apps/fcoe.png (with props)
trunk/theme/openSUSE/icons/32x32/apps/fcoe.png (with props)
trunk/theme/openSUSE/icons/48x48/apps/fcoe.png (with props)
trunk/theme/openSUSE/icons/64x64/apps/fcoe.png (with props)
trunk/theme/openSUSE/icons/scalable/apps/fcoe.svg
Modified:
trunk/theme/VERSION
trunk/theme/package/yast2-theme.changes
Added: trunk/theme/SLE/icons/16x16/apps/fcoe.png
URL: http://svn.opensuse.org/viewcvs/yast/trunk/theme/SLE/icons/16x16/apps/fcoe.…
==============================================================================
Binary file - no diff available.
Added: trunk/theme/SLE/icons/22x22/apps/fcoe.png
URL: http://svn.opensuse.org/viewcvs/yast/trunk/theme/SLE/icons/22x22/apps/fcoe.…
==============================================================================
Binary file - no diff available.
Added: trunk/theme/SLE/icons/256x256/apps/fcoe.png
URL: http://svn.opensuse.org/viewcvs/yast/trunk/theme/SLE/icons/256x256/apps/fco…
==============================================================================
Binary file - no diff available.
Added: trunk/theme/SLE/icons/32x32/apps/fcoe.png
URL: http://svn.opensuse.org/viewcvs/yast/trunk/theme/SLE/icons/32x32/apps/fcoe.…
==============================================================================
Binary file - no diff available.
Added: trunk/theme/SLE/icons/48x48/apps/fcoe.png
URL: http://svn.opensuse.org/viewcvs/yast/trunk/theme/SLE/icons/48x48/apps/fcoe.…
==============================================================================
Binary file - no diff available.
Added: trunk/theme/SLE/icons/64x64/apps/fcoe.png
URL: http://svn.opensuse.org/viewcvs/yast/trunk/theme/SLE/icons/64x64/apps/fcoe.…
==============================================================================
Binary file - no diff available.
Added: trunk/theme/SLE/icons/scalable/apps/fcoe.svg
URL: http://svn.opensuse.org/viewcvs/yast/trunk/theme/SLE/icons/scalable/apps/fc…
==============================================================================
--- trunk/theme/SLE/icons/scalable/apps/fcoe.svg (added)
+++ trunk/theme/SLE/icons/scalable/apps/fcoe.svg Tue May 17 15:16:09 2011
@@ -0,0 +1,1257 @@
+<?xml version="1.0" encoding="UTF-8" standalone="no"?>
+<!-- Created with Inkscape (http://www.inkscape.org/) -->
+
+<svg
+ xmlns:dc="http://purl.org/dc/elements/1.1/"
+ xmlns:cc="http://creativecommons.org/ns#"
+ xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
+ xmlns:svg="http://www.w3.org/2000/svg"
+ xmlns="http://www.w3.org/2000/svg"
+ xmlns:xlink="http://www.w3.org/1999/xlink"
+ xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"
+ xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
+ width="32px"
+ height="32px"
+ id="svg6350"
+ version="1.1"
+ inkscape:version="0.47 r22583"
+ sodipodi:docname="New document 12">
+ <defs
+ id="defs6352">
+ <inkscape:perspective
+ sodipodi:type="inkscape:persp3d"
+ inkscape:vp_x="0 : 16 : 1"
+ inkscape:vp_y="0 : 1000 : 0"
+ inkscape:vp_z="32 : 16 : 1"
+ inkscape:persp3d-origin="16 : 10.666667 : 1"
+ id="perspective6358" />
+ <inkscape:perspective
+ id="perspective4400"
+ inkscape:persp3d-origin="0.5 : 0.33333333 : 1"
+ inkscape:vp_z="1 : 0.5 : 1"
+ inkscape:vp_y="0 : 1000 : 0"
+ inkscape:vp_x="0 : 0.5 : 1"
+ sodipodi:type="inkscape:persp3d" />
+ <linearGradient
+ inkscape:collect="always"
+ xlink:href="#linearGradient13844"
+ id="linearGradient17909"
+ gradientUnits="userSpaceOnUse"
+ x1="173.25"
+ y1="79.5"
+ x2="160.85922"
+ y2="67.10923"
+ gradientTransform="translate(-106,-6)" />
+ <linearGradient
+ inkscape:collect="always"
+ id="linearGradient13844">
+ <stop
+ style="stop-color:#000000;stop-opacity:1;"
+ offset="0"
+ id="stop13846" />
+ <stop
+ style="stop-color:#000000;stop-opacity:0;"
+ offset="1"
+ id="stop13848" />
+ </linearGradient>
+ <linearGradient
+ inkscape:collect="always"
+ xlink:href="#linearGradient13836"
+ id="linearGradient17911"
+ gradientUnits="userSpaceOnUse"
+ x1="174.00658"
+ y1="81.231583"
+ x2="109.85642"
+ y2="17.08143"
+ gradientTransform="translate(-106,-6)" />
+ <linearGradient
+ inkscape:collect="always"
+ id="linearGradient13836">
+ <stop
+ style="stop-color:#ffffff;stop-opacity:1;"
+ offset="0"
+ id="stop13838" />
+ <stop
+ style="stop-color:#ffffff;stop-opacity:0;"
+ offset="1"
+ id="stop13840" />
+ </linearGradient>
+ <radialGradient
+ inkscape:collect="always"
+ xlink:href="#linearGradient10791"
+ id="radialGradient17907"
+ gradientUnits="userSpaceOnUse"
+ gradientTransform="matrix(2.0002364,0,0,0.66666666,-34.15327,0.33333)"
+ cx="25.000021"
+ cy="28.742769"
+ fx="25.000021"
+ fy="28.742769"
+ r="12" />
+ <linearGradient
+ id="linearGradient10791">
+ <stop
+ style="stop-color:#28282b;stop-opacity:1;"
+ offset="0"
+ id="stop10793" />
+ <stop
+ id="stop10799"
+ offset="0.27897844"
+ style="stop-color:#5f5f65;stop-opacity:1" />
+ <stop
+ style="stop-color:#242427;stop-opacity:1"
+ offset="1"
+ id="stop10795" />
+ </linearGradient>
+ <linearGradient
+ gradientTransform="translate(-249,-6)"
+ inkscape:collect="always"
+ xlink:href="#linearGradient17991"
+ id="linearGradient17997"
+ x1="265"
+ y1="39.276649"
+ x2="264.99997"
+ y2="1.7233521"
+ gradientUnits="userSpaceOnUse" />
+ <linearGradient
+ inkscape:collect="always"
+ id="linearGradient17991">
+ <stop
+ style="stop-color:#808083;stop-opacity:1;"
+ offset="0"
+ id="stop17993" />
+ <stop
+ style="stop-color:#808083;stop-opacity:0;"
+ offset="1"
+ id="stop17995" />
+ </linearGradient>
+ <linearGradient
+ inkscape:collect="always"
+ xlink:href="#linearGradient13675"
+ id="linearGradient17879"
+ gradientUnits="userSpaceOnUse"
+ gradientTransform="matrix(0.5,0,0,0.5,5,4)"
+ x1="9.9226456"
+ y1="33"
+ x2="19.819132"
+ y2="33" />
+ <linearGradient
+ id="linearGradient13675">
+ <stop
+ id="stop13677"
+ offset="0"
+ style="stop-color:#ffffff;stop-opacity:1" />
+ <stop
+ style="stop-color:#aaccee;stop-opacity:1"
+ offset="0.20050415"
+ id="stop13679" />
+ <stop
+ style="stop-color:#6699cc;stop-opacity:1"
+ offset="0.80037004"
+ id="stop13681" />
+ <stop
+ id="stop13683"
+ offset="1"
+ style="stop-color:#003366;stop-opacity:1" />
+ </linearGradient>
+ <linearGradient
+ inkscape:collect="always"
+ xlink:href="#linearGradient13675"
+ id="linearGradient17881"
+ gradientUnits="userSpaceOnUse"
+ gradientTransform="translate(0,4)"
+ x1="15"
+ y1="34.5"
+ x2="20"
+ y2="34.5" />
+ <linearGradient
+ id="linearGradient4428">
+ <stop
+ id="stop4430"
+ offset="0"
+ style="stop-color:#ffffff;stop-opacity:1" />
+ <stop
+ style="stop-color:#aaccee;stop-opacity:1"
+ offset="0.20050415"
+ id="stop4432" />
+ <stop
+ style="stop-color:#6699cc;stop-opacity:1"
+ offset="0.80037004"
+ id="stop4434" />
+ <stop
+ id="stop4436"
+ offset="1"
+ style="stop-color:#003366;stop-opacity:1" />
+ </linearGradient>
+ <linearGradient
+ inkscape:collect="always"
+ xlink:href="#linearGradient13173"
+ id="linearGradient17883"
+ gradientUnits="userSpaceOnUse"
+ x1="18.124208"
+ y1="26.54208"
+ x2="18.124208"
+ y2="31.151253" />
+ <linearGradient
+ inkscape:collect="always"
+ id="linearGradient13173">
+ <stop
+ style="stop-color:#2e2e2e;stop-opacity:1;"
+ offset="0"
+ id="stop13175" />
+ <stop
+ style="stop-color:#2e2e2e;stop-opacity:0;"
+ offset="1"
+ id="stop13177" />
+ </linearGradient>
+ <linearGradient
+ inkscape:collect="always"
+ xlink:href="#linearGradient16045"
+ id="linearGradient4338"
+ gradientUnits="userSpaceOnUse"
+ gradientTransform="matrix(0.5,0,0,0.5,5,14)"
+ x1="17.189102"
+ y1="32.180798"
+ x2="17.189102"
+ y2="43.288792" />
+ <linearGradient
+ id="linearGradient16045">
+ <stop
+ id="stop16047"
+ offset="0"
+ style="stop-color:#fafcfe;stop-opacity:1" />
+ <stop
+ style="stop-color:#7cb2eb;stop-opacity:1;"
+ offset="0.5"
+ id="stop16051" />
+ <stop
+ id="stop16049"
+ offset="1"
+ style="stop-color:#366ba1;stop-opacity:1" />
+ </linearGradient>
+ <linearGradient
+ inkscape:collect="always"
+ xlink:href="#linearGradient16037"
+ id="linearGradient4340"
+ gradientUnits="userSpaceOnUse"
+ x1="15.631318"
+ y1="44.702961"
+ x2="15.631318"
+ y2="34.056591" />
+ <linearGradient
+ id="linearGradient16037">
+ <stop
+ style="stop-color:#ddeaf8;stop-opacity:1"
+ offset="0"
+ id="stop16039" />
+ <stop
+ id="stop16041"
+ offset="0.46645069"
+ style="stop-color:#12569b;stop-opacity:1" />
+ <stop
+ style="stop-color:#28282a;stop-opacity:1"
+ offset="1"
+ id="stop16043" />
+ </linearGradient>
+ <linearGradient
+ inkscape:collect="always"
+ xlink:href="#linearGradient16075"
+ id="linearGradient4342"
+ gradientUnits="userSpaceOnUse"
+ x1="5.6098752"
+ y1="31.5"
+ x2="14.240004"
+ y2="31.5" />
+ <linearGradient
+ inkscape:collect="always"
+ id="linearGradient16075">
+ <stop
+ style="stop-color:#ffffff;stop-opacity:1;"
+ offset="0"
+ id="stop16077" />
+ <stop
+ style="stop-color:#ffffff;stop-opacity:0;"
+ offset="1"
+ id="stop16079" />
+ </linearGradient>
+ <linearGradient
+ inkscape:collect="always"
+ xlink:href="#linearGradient16547"
+ id="linearGradient4344"
+ gradientUnits="userSpaceOnUse"
+ x1="16.14299"
+ y1="30.5"
+ x2="15"
+ y2="30.5" />
+ <linearGradient
+ inkscape:collect="always"
+ id="linearGradient16547">
+ <stop
+ style="stop-color:#336699;stop-opacity:1;"
+ offset="0"
+ id="stop16549" />
+ <stop
+ style="stop-color:#336699;stop-opacity:0;"
+ offset="1"
+ id="stop16551" />
+ </linearGradient>
+ <linearGradient
+ inkscape:collect="always"
+ xlink:href="#linearGradient16075"
+ id="linearGradient4460"
+ gradientUnits="userSpaceOnUse"
+ x1="5.6098752"
+ y1="31.5"
+ x2="14.240004"
+ y2="31.5" />
+ <linearGradient
+ inkscape:collect="always"
+ xlink:href="#linearGradient16547"
+ id="linearGradient4468"
+ gradientUnits="userSpaceOnUse"
+ x1="16.14299"
+ y1="30.5"
+ x2="15"
+ y2="30.5" />
+ <linearGradient
+ inkscape:collect="always"
+ xlink:href="#linearGradient16075"
+ id="linearGradient4476"
+ gradientUnits="userSpaceOnUse"
+ x1="5.6098752"
+ y1="31.5"
+ x2="14.240004"
+ y2="31.5" />
+ <linearGradient
+ inkscape:collect="always"
+ xlink:href="#linearGradient16547"
+ id="linearGradient4484"
+ gradientUnits="userSpaceOnUse"
+ x1="16.14299"
+ y1="30.5"
+ x2="15"
+ y2="30.5" />
+ <linearGradient
+ inkscape:collect="always"
+ xlink:href="#linearGradient16075"
+ id="linearGradient4492"
+ gradientUnits="userSpaceOnUse"
+ x1="5.6098752"
+ y1="31.5"
+ x2="14.240004"
+ y2="31.5" />
+ <linearGradient
+ inkscape:collect="always"
+ xlink:href="#linearGradient16547"
+ id="linearGradient4500"
+ gradientUnits="userSpaceOnUse"
+ x1="16.14299"
+ y1="30.5"
+ x2="15"
+ y2="30.5" />
+ <linearGradient
+ inkscape:collect="always"
+ xlink:href="#linearGradient16075"
+ id="linearGradient4508"
+ gradientUnits="userSpaceOnUse"
+ x1="5.6098752"
+ y1="31.5"
+ x2="14.240004"
+ y2="31.5" />
+ <linearGradient
+ inkscape:collect="always"
+ xlink:href="#linearGradient16547"
+ id="linearGradient4516"
+ gradientUnits="userSpaceOnUse"
+ x1="16.14299"
+ y1="30.5"
+ x2="15"
+ y2="30.5" />
+ <linearGradient
+ inkscape:collect="always"
+ xlink:href="#linearGradient13713"
+ id="linearGradient17893"
+ gradientUnits="userSpaceOnUse"
+ gradientTransform="matrix(0.5,0,0,0.5,5,4)"
+ x1="9.9226456"
+ y1="33"
+ x2="19.819132"
+ y2="33" />
+ <linearGradient
+ id="linearGradient13713">
+ <stop
+ style="stop-color:#fffdb6;stop-opacity:1;"
+ offset="0"
+ id="stop13715" />
+ <stop
+ id="stop13717"
+ offset="0.20050415"
+ style="stop-color:#fdd29b;stop-opacity:1;" />
+ <stop
+ id="stop13719"
+ offset="0.80037004"
+ style="stop-color:#ea8c48;stop-opacity:1;" />
+ <stop
+ style="stop-color:#82452c;stop-opacity:1"
+ offset="1"
+ id="stop13721" />
+ </linearGradient>
+ <linearGradient
+ inkscape:collect="always"
+ xlink:href="#linearGradient13713"
+ id="linearGradient17895"
+ gradientUnits="userSpaceOnUse"
+ gradientTransform="translate(0,4)"
+ x1="15"
+ y1="34.5"
+ x2="20"
+ y2="34.5" />
+ <linearGradient
+ id="linearGradient4531">
+ <stop
+ style="stop-color:#fffdb6;stop-opacity:1;"
+ offset="0"
+ id="stop4533" />
+ <stop
+ id="stop4535"
+ offset="0.20050415"
+ style="stop-color:#fdd29b;stop-opacity:1;" />
+ <stop
+ id="stop4537"
+ offset="0.80037004"
+ style="stop-color:#ea8c48;stop-opacity:1;" />
+ <stop
+ style="stop-color:#82452c;stop-opacity:1"
+ offset="1"
+ id="stop4539" />
+ </linearGradient>
+ <linearGradient
+ inkscape:collect="always"
+ xlink:href="#linearGradient13173"
+ id="linearGradient17897"
+ gradientUnits="userSpaceOnUse"
+ x1="18.124208"
+ y1="26.423214"
+ x2="18.124208"
+ y2="31.151253" />
+ <linearGradient
+ inkscape:collect="always"
+ xlink:href="#linearGradient13723"
+ id="linearGradient17899"
+ gradientUnits="userSpaceOnUse"
+ gradientTransform="matrix(0.5,0,0,0.5,5,14)"
+ x1="12.811365"
+ y1="31.9375"
+ x2="16.899677"
+ y2="42.787495" />
+ <linearGradient
+ id="linearGradient13723">
+ <stop
+ id="stop13725"
+ offset="0"
+ style="stop-color:#fafcfe;stop-opacity:1" />
+ <stop
+ style="stop-color:#e49d81;stop-opacity:1;"
+ offset="0.5"
+ id="stop13795" />
+ <stop
+ id="stop13727"
+ offset="1"
+ style="stop-color:#ae4d25;stop-opacity:1" />
+ </linearGradient>
+ <linearGradient
+ inkscape:collect="always"
+ xlink:href="#linearGradient13729"
+ id="linearGradient17901"
+ gradientUnits="userSpaceOnUse"
+ x1="15.631318"
+ y1="43.611408"
+ x2="15.631318"
+ y2="30.073717" />
+ <linearGradient
+ id="linearGradient13729">
+ <stop
+ id="stop13731"
+ offset="0"
+ style="stop-color:#e3e3e3;stop-opacity:1" />
+ <stop
+ style="stop-color:#b93700;stop-opacity:1"
+ offset="0.36668861"
+ id="stop13733" />
+ <stop
+ id="stop13735"
+ offset="1"
+ style="stop-color:#28282a;stop-opacity:1" />
+ </linearGradient>
+ <linearGradient
+ inkscape:collect="always"
+ xlink:href="#linearGradient13675"
+ id="linearGradient4346"
+ gradientUnits="userSpaceOnUse"
+ gradientTransform="matrix(0.5,0,0,0.5,117,9.5)"
+ x1="9.9226456"
+ y1="33"
+ x2="19.819132"
+ y2="33" />
+ <linearGradient
+ id="linearGradient4559">
+ <stop
+ id="stop4561"
+ offset="0"
+ style="stop-color:#ffffff;stop-opacity:1" />
+ <stop
+ style="stop-color:#aaccee;stop-opacity:1"
+ offset="0.20050415"
+ id="stop4563" />
+ <stop
+ style="stop-color:#6699cc;stop-opacity:1"
+ offset="0.80037004"
+ id="stop4565" />
+ <stop
+ id="stop4567"
+ offset="1"
+ style="stop-color:#003366;stop-opacity:1" />
+ </linearGradient>
+ <linearGradient
+ inkscape:collect="always"
+ xlink:href="#linearGradient13173"
+ id="linearGradient4348"
+ gradientUnits="userSpaceOnUse"
+ x1="20.099268"
+ y1="23.78023"
+ x2="18.124208"
+ y2="31.151253" />
+ <linearGradient
+ inkscape:collect="always"
+ xlink:href="#linearGradient13675"
+ id="linearGradient4576"
+ gradientUnits="userSpaceOnUse"
+ gradientTransform="matrix(0.5,0,0,0.5,117,9.5)"
+ x1="9.9226456"
+ y1="33"
+ x2="19.819132"
+ y2="33" />
+ <linearGradient
+ id="linearGradient4578">
+ <stop
+ id="stop4580"
+ offset="0"
+ style="stop-color:#ffffff;stop-opacity:1" />
+ <stop
+ style="stop-color:#aaccee;stop-opacity:1"
+ offset="0.20050415"
+ id="stop4582" />
+ <stop
+ style="stop-color:#6699cc;stop-opacity:1"
+ offset="0.80037004"
+ id="stop4584" />
+ <stop
+ id="stop4586"
+ offset="1"
+ style="stop-color:#003366;stop-opacity:1" />
+ </linearGradient>
+ <linearGradient
+ inkscape:collect="always"
+ xlink:href="#linearGradient13173"
+ id="linearGradient4588"
+ gradientUnits="userSpaceOnUse"
+ x1="20.099268"
+ y1="23.78023"
+ x2="18.124208"
+ y2="31.151253" />
+ <linearGradient
+ inkscape:collect="always"
+ xlink:href="#linearGradient16045"
+ id="linearGradient4596"
+ gradientUnits="userSpaceOnUse"
+ gradientTransform="matrix(0.5,0,0,0.5,5,14)"
+ x1="17.189102"
+ y1="32.180798"
+ x2="17.189102"
+ y2="43.288792" />
+ <linearGradient
+ id="linearGradient4598">
+ <stop
+ id="stop4600"
+ offset="0"
+ style="stop-color:#fafcfe;stop-opacity:1" />
+ <stop
+ style="stop-color:#7cb2eb;stop-opacity:1;"
+ offset="0.5"
+ id="stop4602" />
+ <stop
+ id="stop4604"
+ offset="1"
+ style="stop-color:#366ba1;stop-opacity:1" />
+ </linearGradient>
+ <linearGradient
+ inkscape:collect="always"
+ xlink:href="#linearGradient16037"
+ id="linearGradient4606"
+ gradientUnits="userSpaceOnUse"
+ x1="15.631318"
+ y1="44.702961"
+ x2="15.631318"
+ y2="34.056591" />
+ <linearGradient
+ id="linearGradient4608">
+ <stop
+ style="stop-color:#ddeaf8;stop-opacity:1"
+ offset="0"
+ id="stop4610" />
+ <stop
+ id="stop4612"
+ offset="0.46645069"
+ style="stop-color:#12569b;stop-opacity:1" />
+ <stop
+ style="stop-color:#28282a;stop-opacity:1"
+ offset="1"
+ id="stop4614" />
+ </linearGradient>
+ <linearGradient
+ inkscape:collect="always"
+ xlink:href="#linearGradient16075"
+ id="linearGradient4616"
+ gradientUnits="userSpaceOnUse"
+ x1="5.6098752"
+ y1="31.5"
+ x2="14.240004"
+ y2="31.5" />
+ <linearGradient
+ inkscape:collect="always"
+ xlink:href="#linearGradient16547"
+ id="linearGradient4624"
+ gradientUnits="userSpaceOnUse"
+ x1="16.14299"
+ y1="30.5"
+ x2="15"
+ y2="30.5" />
+ <linearGradient
+ inkscape:collect="always"
+ xlink:href="#linearGradient16075"
+ id="linearGradient4632"
+ gradientUnits="userSpaceOnUse"
+ x1="5.6098752"
+ y1="31.5"
+ x2="14.240004"
+ y2="31.5" />
+ <linearGradient
+ inkscape:collect="always"
+ xlink:href="#linearGradient16547"
+ id="linearGradient4640"
+ gradientUnits="userSpaceOnUse"
+ x1="16.14299"
+ y1="30.5"
+ x2="15"
+ y2="30.5" />
+ <linearGradient
+ inkscape:collect="always"
+ xlink:href="#linearGradient16075"
+ id="linearGradient4648"
+ gradientUnits="userSpaceOnUse"
+ x1="5.6098752"
+ y1="31.5"
+ x2="14.240004"
+ y2="31.5" />
+ <linearGradient
+ inkscape:collect="always"
+ xlink:href="#linearGradient16547"
+ id="linearGradient4656"
+ gradientUnits="userSpaceOnUse"
+ x1="16.14299"
+ y1="30.5"
+ x2="15"
+ y2="30.5" />
+ <linearGradient
+ inkscape:collect="always"
+ xlink:href="#linearGradient16075"
+ id="linearGradient4664"
+ gradientUnits="userSpaceOnUse"
+ x1="5.6098752"
+ y1="31.5"
+ x2="14.240004"
+ y2="31.5" />
+ <linearGradient
+ inkscape:collect="always"
+ xlink:href="#linearGradient16547"
+ id="linearGradient4672"
+ gradientUnits="userSpaceOnUse"
+ x1="16.14299"
+ y1="30.5"
+ x2="15"
+ y2="30.5" />
+ <linearGradient
+ inkscape:collect="always"
+ xlink:href="#linearGradient16075"
+ id="linearGradient4680"
+ gradientUnits="userSpaceOnUse"
+ x1="5.6098752"
+ y1="31.5"
+ x2="14.240004"
+ y2="31.5" />
+ <linearGradient
+ inkscape:collect="always"
+ xlink:href="#linearGradient16547"
+ id="linearGradient4688"
+ gradientUnits="userSpaceOnUse"
+ x1="16.14299"
+ y1="30.5"
+ x2="15"
+ y2="30.5" />
+ <linearGradient
+ inkscape:collect="always"
+ xlink:href="#linearGradient16045"
+ id="linearGradient4696"
+ gradientUnits="userSpaceOnUse"
+ gradientTransform="matrix(0.5,0,0,0.5,5,14)"
+ x1="17.189102"
+ y1="32.180798"
+ x2="17.189102"
+ y2="43.288792" />
+ <linearGradient
+ id="linearGradient4698">
+ <stop
+ id="stop4700"
+ offset="0"
+ style="stop-color:#fafcfe;stop-opacity:1" />
+ <stop
+ style="stop-color:#7cb2eb;stop-opacity:1;"
+ offset="0.5"
+ id="stop4702" />
+ <stop
+ id="stop4704"
+ offset="1"
+ style="stop-color:#366ba1;stop-opacity:1" />
+ </linearGradient>
+ <linearGradient
+ inkscape:collect="always"
+ xlink:href="#linearGradient16037"
+ id="linearGradient4706"
+ gradientUnits="userSpaceOnUse"
+ x1="15.631318"
+ y1="44.702961"
+ x2="15.631318"
+ y2="34.056591" />
+ <linearGradient
+ id="linearGradient4708">
+ <stop
+ style="stop-color:#ddeaf8;stop-opacity:1"
+ offset="0"
+ id="stop4710" />
+ <stop
+ id="stop4712"
+ offset="0.46645069"
+ style="stop-color:#12569b;stop-opacity:1" />
+ <stop
+ style="stop-color:#28282a;stop-opacity:1"
+ offset="1"
+ id="stop4714" />
+ </linearGradient>
+ <linearGradient
+ inkscape:collect="always"
+ xlink:href="#linearGradient16075"
+ id="linearGradient4716"
+ gradientUnits="userSpaceOnUse"
+ x1="5.6098752"
+ y1="31.5"
+ x2="14.240004"
+ y2="31.5" />
+ <linearGradient
+ inkscape:collect="always"
+ xlink:href="#linearGradient16547"
+ id="linearGradient4724"
+ gradientUnits="userSpaceOnUse"
+ x1="16.14299"
+ y1="30.5"
+ x2="15"
+ y2="30.5" />
+ <linearGradient
+ inkscape:collect="always"
+ xlink:href="#linearGradient16075"
+ id="linearGradient4732"
+ gradientUnits="userSpaceOnUse"
+ x1="5.6098752"
+ y1="31.5"
+ x2="14.240004"
+ y2="31.5" />
+ <linearGradient
+ inkscape:collect="always"
+ xlink:href="#linearGradient16547"
+ id="linearGradient4740"
+ gradientUnits="userSpaceOnUse"
+ x1="16.14299"
+ y1="30.5"
+ x2="15"
+ y2="30.5" />
+ <linearGradient
+ inkscape:collect="always"
+ xlink:href="#linearGradient16075"
+ id="linearGradient4748"
+ gradientUnits="userSpaceOnUse"
+ x1="5.6098752"
+ y1="31.5"
+ x2="14.240004"
+ y2="31.5" />
+ <linearGradient
+ inkscape:collect="always"
+ xlink:href="#linearGradient16547"
+ id="linearGradient4756"
+ gradientUnits="userSpaceOnUse"
+ x1="16.14299"
+ y1="30.5"
+ x2="15"
+ y2="30.5" />
+ <linearGradient
+ inkscape:collect="always"
+ xlink:href="#linearGradient16075"
+ id="linearGradient4764"
+ gradientUnits="userSpaceOnUse"
+ x1="5.6098752"
+ y1="31.5"
+ x2="14.240004"
+ y2="31.5" />
+ <linearGradient
+ inkscape:collect="always"
+ xlink:href="#linearGradient16547"
+ id="linearGradient4772"
+ gradientUnits="userSpaceOnUse"
+ x1="16.14299"
+ y1="30.5"
+ x2="15"
+ y2="30.5" />
+ <linearGradient
+ inkscape:collect="always"
+ xlink:href="#linearGradient16075"
+ id="linearGradient4780"
+ gradientUnits="userSpaceOnUse"
+ x1="5.6098752"
+ y1="31.5"
+ x2="14.240004"
+ y2="31.5" />
+ <linearGradient
+ inkscape:collect="always"
+ xlink:href="#linearGradient16547"
+ id="linearGradient4788"
+ gradientUnits="userSpaceOnUse"
+ x1="16.14299"
+ y1="30.5"
+ x2="15"
+ y2="30.5" />
+ <linearGradient
+ inkscape:collect="always"
+ xlink:href="#linearGradient13173-8"
+ id="linearGradient17867"
+ gradientUnits="userSpaceOnUse"
+ gradientTransform="translate(1,-11)"
+ x1="18.124208"
+ y1="26.54208"
+ x2="18.124208"
+ y2="31.151253" />
+ <linearGradient
+ inkscape:collect="always"
+ id="linearGradient13173-8">
+ <stop
+ style="stop-color:#2e2e2e;stop-opacity:1;"
+ offset="0"
+ id="stop13175-9" />
+ <stop
+ style="stop-color:#2e2e2e;stop-opacity:0;"
+ offset="1"
+ id="stop13177-7" />
+ </linearGradient>
+ <linearGradient
+ inkscape:collect="always"
+ xlink:href="#linearGradient13173-8"
+ id="linearGradient17865"
+ gradientUnits="userSpaceOnUse"
+ gradientTransform="translate(6,-11)"
+ x1="18.124208"
+ y1="26.54208"
+ x2="18.124208"
+ y2="31.151253" />
+ <linearGradient
+ inkscape:collect="always"
+ xlink:href="#linearGradient16045"
+ id="linearGradient6933"
+ gradientUnits="userSpaceOnUse"
+ gradientTransform="matrix(0.5,0,0,0.5,5,14)"
+ x1="17.189102"
+ y1="32.180798"
+ x2="17.189102"
+ y2="43.288792" />
+ <linearGradient
+ inkscape:collect="always"
+ xlink:href="#linearGradient16037"
+ id="linearGradient6935"
+ gradientUnits="userSpaceOnUse"
+ x1="15.631318"
+ y1="44.702961"
+ x2="15.631318"
+ y2="34.056591" />
+ <linearGradient
+ inkscape:collect="always"
+ xlink:href="#linearGradient16075"
+ id="linearGradient6937"
+ gradientUnits="userSpaceOnUse"
+ x1="5.6098752"
+ y1="31.5"
+ x2="14.240004"
+ y2="31.5" />
+ <linearGradient
+ inkscape:collect="always"
+ xlink:href="#linearGradient16547"
+ id="linearGradient6939"
+ gradientUnits="userSpaceOnUse"
+ x1="16.14299"
+ y1="30.5"
+ x2="15"
+ y2="30.5" />
+ <linearGradient
+ inkscape:collect="always"
+ xlink:href="#linearGradient13675"
+ id="linearGradient6941"
+ gradientUnits="userSpaceOnUse"
+ gradientTransform="matrix(0.5,0,0,0.5,117,9.5)"
+ x1="9.9226456"
+ y1="33"
+ x2="19.819132"
+ y2="33" />
+ <linearGradient
+ inkscape:collect="always"
+ xlink:href="#linearGradient13173"
+ id="linearGradient6943"
+ gradientUnits="userSpaceOnUse"
+ x1="20.099268"
+ y1="23.78023"
+ x2="18.124208"
+ y2="31.151253" />
+ </defs>
+ <sodipodi:namedview
+ id="base"
+ pagecolor="#ffffff"
+ bordercolor="#666666"
+ borderopacity="1.0"
+ inkscape:pageopacity="0.0"
+ inkscape:pageshadow="2"
+ inkscape:zoom="11.197802"
+ inkscape:cx="16"
+ inkscape:cy="16"
+ inkscape:current-layer="layer1"
+ showgrid="true"
+ inkscape:grid-bbox="true"
+ inkscape:document-units="px"
+ inkscape:window-width="940"
+ inkscape:window-height="694"
+ inkscape:window-x="1529"
+ inkscape:window-y="154"
+ inkscape:window-maximized="0" />
+ <metadata
+ id="metadata6355">
+ <rdf:RDF>
+ <cc:Work
+ rdf:about="">
+ <dc:format>image/svg+xml</dc:format>
+ <dc:type
+ rdf:resource="http://purl.org/dc/dcmitype/StillImage" />
+ <dc:title></dc:title>
+ </cc:Work>
+ </rdf:RDF>
+ </metadata>
+ <g
+ id="layer1"
+ inkscape:label="Layer 1"
+ inkscape:groupmode="layer">
+ <path
+ style="fill:#cccccf"
+ d="M 9,0 23,0 23,4 9,4 z"
+ id="rect13631"
+ inkscape:connector-curvature="0"
+ sodipodi:nodetypes="ccccc"
+ inkscape:export-filename="/suse/tgoettlicher/fcoe/FCoE-256.png"
+ inkscape:export-xdpi="720"
+ inkscape:export-ydpi="720" />
+ <path
+ style="fill:#cacacd;fill-opacity:1"
+ d="M 0,3 32,3 32,26 0,26 z"
+ id="rect13633"
+ inkscape:connector-curvature="0"
+ sodipodi:nodetypes="ccccc"
+ inkscape:export-filename="/suse/tgoettlicher/fcoe/FCoE-256.png"
+ inkscape:export-xdpi="720"
+ inkscape:export-ydpi="720" />
+ <path
+ style="fill:#ffffff;fill-opacity:1"
+ d="M 0,4 10,4 10,5 0,5 z"
+ id="rect13659"
+ inkscape:connector-curvature="0"
+ sodipodi:nodetypes="ccccc"
+ inkscape:export-filename="/suse/tgoettlicher/fcoe/FCoE-256.png"
+ inkscape:export-xdpi="720"
+ inkscape:export-ydpi="720" />
+ <rect
+ style="fill:#cacacd;fill-opacity:1"
+ y="4.0000072"
+ x="11.00001"
+ height="1"
+ width="10"
+ id="rect13661"
+ inkscape:export-filename="/suse/tgoettlicher/fcoe/FCoE-256.png"
+ inkscape:export-xdpi="720"
+ inkscape:export-ydpi="720" />
+ <path
+ style="fill:#ffffff;fill-opacity:1"
+ d="M 10,1 22,1 22,1.5 22,2 10,2 z"
+ id="rect13657"
+ inkscape:connector-curvature="0"
+ sodipodi:nodetypes="cccccc"
+ inkscape:export-filename="/suse/tgoettlicher/fcoe/FCoE-256.png"
+ inkscape:export-xdpi="720"
+ inkscape:export-ydpi="720" />
+ <path
+ sodipodi:nodetypes="ccccccccccc"
+ inkscape:connector-curvature="0"
+ id="path13834"
+ d="m 3,9 6,0 2,0 0,-4 10,0 0,4 2,0 6,0 0,13 -26,0 z"
+ style="fill:url(#linearGradient17909);fill-opacity:1;stroke:url(#linearGradient17911);stroke-width:2;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none"
+ inkscape:export-filename="/suse/tgoettlicher/fcoe/FCoE-256.png"
+ inkscape:export-xdpi="720"
+ inkscape:export-ydpi="720" />
+ <path
+ style="fill:url(#radialGradient17907);fill-opacity:1"
+ d="m 4,9 5,0 2,0 0,-4 10,0 0,4 2,0 5,0 0,13 -24,0 z"
+ id="rect13635"
+ inkscape:connector-curvature="0"
+ sodipodi:nodetypes="ccccccccccc"
+ inkscape:export-filename="/suse/tgoettlicher/fcoe/FCoE-256.png"
+ inkscape:export-xdpi="720"
+ inkscape:export-ydpi="720" />
+ <path
+ style="fill:url(#linearGradient17997);fill-opacity:1"
+ d="m 0,3 0,1 0,21 0,1 32,0 0,-1 0,-21 0,-1 -9,0 0,1 8,0 0,21 L 1,25 1,4 9,4 9,3 z"
+ id="path17338"
+ inkscape:connector-curvature="0"
+ sodipodi:nodetypes="ccccccccccccccccc"
+ inkscape:export-filename="/suse/tgoettlicher/fcoe/FCoE-256.png"
+ inkscape:export-xdpi="720"
+ inkscape:export-ydpi="720" />
+ <g
+ transform="translate(-4,-3.5)"
+ id="g13637"
+ inkscape:export-filename="/suse/tgoettlicher/fcoe/FCoE-256.png"
+ inkscape:export-xdpi="720"
+ inkscape:export-ydpi="720">
+ <g
+ id="g13639">
+ <path
+ style="fill:url(#linearGradient17879);fill-opacity:1"
+ d="m 15,21.5 0,3 -1,1 -3,0 -1,-1 0,-3 1,-1 3,0 z"
+ id="path13641"
+ inkscape:connector-curvature="0"
+ sodipodi:nodetypes="ccccccccc" />
+ <rect
+ y="27"
+ x="15"
+ height="15"
+ width="5"
+ id="rect13643"
+ style="fill:url(#linearGradient17881);fill-opacity:1"
+ rx="2.5"
+ ry="2.5"
+ transform="translate(-5,-6.5)" />
+ <path
+ sodipodi:nodetypes="cccccccc"
+ inkscape:connector-curvature="0"
+ id="path13649"
+ d="m 15,28 1,-1 1.5,0 1.5,0 1,1 0,4 -5,0 z"
+ style="fill:url(#linearGradient17883);fill-opacity:1"
+ transform="translate(-5,-6.5)" />
+ <g
+ id="g15939">
+ <path
+ sodipodi:nodetypes="ccccccccc"
+ inkscape:connector-curvature="0"
+ id="path16053"
+ d="m 15,30.5 0,3 -1,1 -3,0 -1,-1 0,-3 1,-1 3.069786,0 z"
+ style="fill:#ffffff;fill-opacity:0.21690141" />
+ <path
+ style="fill:url(#linearGradient6933);fill-opacity:1"
+ d="m 15,31.5 0,3 -1,1 -3,0 -1,-1 0,-3 1,-1 3.069786,0 z"
+ id="path13645"
+ inkscape:connector-curvature="0"
+ sodipodi:nodetypes="ccccccccc" />
+ <path
+ transform="matrix(0.4,0,0,0.4,6.5,17.8)"
+ style="fill:url(#linearGradient6935);fill-opacity:1"
+ d="m 18.75,40.5 -1.25,1.25 -1.25,0 -3.75,0 -1.25,-1.25 0,-5 1.25,-1.25 3.75,0 1.25,0 1.25,1.25 z"
+ id="path13647"
+ inkscape:connector-curvature="0"
+ sodipodi:nodetypes="ccccccccccc" />
+ <g
+ id="g16063">
+ <path
+ sodipodi:nodetypes="ccccccccc"
+ inkscape:connector-curvature="0"
+ id="path16059"
+ d="m 15,31.5 0,1 -1,-1 -3,0 -1,1 0,-1 1,-1 3.069786,0 z"
+ style="fill:url(#linearGradient6937);fill-opacity:1" />
+ <path
+ style="fill:url(#linearGradient6939);fill-opacity:1"
+ d="m 15,30.5 0,1 -1,-1 -3,0 -1,1 0,-1 1,-1 3.069786,0 z"
+ id="path16061"
+ inkscape:connector-curvature="0"
+ sodipodi:nodetypes="ccccccccc" />
+ </g>
+ <use
+ height="48"
+ width="48"
+ transform="translate(0,-2)"
+ id="use16067"
+ xlink:href="#g16063"
+ y="0"
+ x="0" />
+ <use
+ x="0"
+ y="0"
+ xlink:href="#g16063"
+ id="use16069"
+ transform="translate(0,-4)"
+ width="48"
+ height="48" />
+ <use
+ height="48"
+ width="48"
+ transform="translate(0,-6)"
+ id="use16071"
+ xlink:href="#g16063"
+ y="0"
+ x="0" />
+ <use
+ x="0"
+ y="0"
+ xlink:href="#g16063"
+ id="use16073"
+ transform="translate(0,-8)"
+ width="48"
+ height="48" />
+ </g>
+ </g>
+ <g
+ id="use13651"
+ transform="translate(5,0)">
+ <path
+ style="fill:url(#linearGradient17893);fill-opacity:1"
+ d="m 15,21.5 0,3 -1,1 -3,0 -1,-1 0,-3 1,-1 3,0 z"
+ id="path13693"
+ inkscape:connector-curvature="0"
+ sodipodi:nodetypes="ccccccccc" />
+ <rect
+ y="27"
+ x="15"
+ height="15"
+ width="5"
+ id="rect13695"
+ style="fill:url(#linearGradient17895);fill-opacity:1"
+ rx="2.5"
+ ry="2.5"
+ transform="translate(-5,-6.5)" />
+ <path
+ sodipodi:nodetypes="cccccccc"
+ inkscape:connector-curvature="0"
+ id="path13701"
+ d="m 15,28 1,-1 1.5,0 1.5,0 1,1 0,4 -5,0 z"
+ style="fill:url(#linearGradient17897);fill-opacity:1"
+ transform="translate(-5,-6.5)" />
+ <path
+ sodipodi:nodetypes="ccccccccc"
+ inkscape:connector-curvature="0"
+ id="path13697"
+ d="m 15,31.5 0,3 -1,1 -3,0 -1,-1 0,-3 1,-1 3.069786,0 z"
+ style="fill:url(#linearGradient17899);fill-opacity:1" />
+ <path
+ sodipodi:nodetypes="ccccccc"
+ inkscape:connector-curvature="0"
+ id="path13699"
+ d="m 18.75,38 0,3.75 -7.5,0 0,-3.75 0,-3.75 7.5,0 z"
+ style="fill:url(#linearGradient17901);fill-opacity:1"
+ transform="matrix(0.4,0,0,0.4,6.5,17.8)" />
+ </g>
+ <g
+ id="use13653"
+ transform="translate(10,0)">
+ <path
+ sodipodi:nodetypes="ccccssscccccc"
+ inkscape:connector-curvature="0"
+ id="path13739"
+ transform="translate(-112,-5.5)"
+ d="m 123,26 -1,1 0,1.5 0,1.5 0,4.5 c 0,1.385 1.115,2.5 2.5,2.5 1.385,0 2.5,-1.115 2.5,-2.5 l 0,-4.5 0,-1.5 0,-1.5 -1,-1 -1.5,0 z"
+ style="fill:url(#linearGradient6941);fill-opacity:1" />
+ <path
+ sodipodi:nodetypes="cccccccc"
+ inkscape:connector-curvature="0"
+ id="path13747"
+ d="m 15,28 1,-1 1.5,0 1.5,0 1,1 0,5 -5,0 z"
+ style="fill:url(#linearGradient6943);fill-opacity:1"
+ transform="translate(-5,-6.5)" />
+ </g>
+ <use
+ x="0"
+ y="0"
+ xlink:href="#use13653"
+ id="use13797"
+ transform="translate(5,0)"
+ width="48"
+ height="48" />
+ <use
+ height="1"
+ width="1"
+ id="use15943"
+ xlink:href="#g15939"
+ y="0"
+ x="0"
+ transform="translate(10,-3)" />
+ <use
+ transform="translate(15,-3)"
+ x="0"
+ y="0"
+ xlink:href="#g15939"
+ id="use16035"
+ width="1"
+ height="1" />
+ </g>
+ <path
+ style="fill:url(#linearGradient17867);fill-opacity:1"
+ d="m 16,17 1,-1 1.5,0 1.5,0 1,1 0,4 -5,0 z"
+ id="path13649-1"
+ inkscape:connector-curvature="0"
+ sodipodi:nodetypes="cccccccc"
+ inkscape:export-filename="/suse/tgoettlicher/fcoe/FCoE-256.png"
+ inkscape:export-xdpi="720"
+ inkscape:export-ydpi="720" />
+ <path
+ sodipodi:nodetypes="cccccccc"
+ inkscape:connector-curvature="0"
+ id="path17250"
+ d="m 21,17 1,-1 1.5,0 1.5,0 1,1 0,4 -5,0 z"
+ style="fill:url(#linearGradient17865);fill-opacity:1"
+ inkscape:export-filename="/suse/tgoettlicher/fcoe/FCoE-256.png"
+ inkscape:export-xdpi="720"
+ inkscape:export-ydpi="720" />
+ <path
+ style="fill:#808083;fill-opacity:0.28450706"
+ d="M 9,0 23,0 23,1 9,1 z"
+ id="path17732"
+ inkscape:connector-curvature="0"
+ sodipodi:nodetypes="ccccc"
+ inkscape:export-filename="/suse/tgoettlicher/fcoe/FCoE-256.png"
+ inkscape:export-xdpi="720"
+ inkscape:export-ydpi="720" />
+ <path
+ sodipodi:nodetypes="ccccc"
+ inkscape:connector-curvature="0"
+ id="path17863"
+ d="M 22,4 32,4 32,5 22,5 z"
+ style="fill:#ffffff;fill-opacity:1"
+ inkscape:export-filename="/suse/tgoettlicher/fcoe/FCoE-256.png"
+ inkscape:export-xdpi="720"
+ inkscape:export-ydpi="720" />
+ </g>
+</svg>
Modified: trunk/theme/VERSION
URL: http://svn.opensuse.org/viewcvs/yast/trunk/theme/VERSION?rev=64017&r1=64016…
==============================================================================
--- trunk/theme/VERSION (original)
+++ trunk/theme/VERSION Tue May 17 15:16:09 2011
@@ -1 +1 @@
-2.21.2
+2.21.3
Added: trunk/theme/openSUSE-Crystal/icons/22x22/apps/fcoe.png
URL: http://svn.opensuse.org/viewcvs/yast/trunk/theme/openSUSE-Crystal/icons/22x…
==============================================================================
Binary file - no diff available.
Added: trunk/theme/openSUSE-Crystal/icons/32x32/apps/fcoe.png
URL: http://svn.opensuse.org/viewcvs/yast/trunk/theme/openSUSE-Crystal/icons/32x…
==============================================================================
Binary file - no diff available.
Added: trunk/theme/openSUSE-Crystal/icons/48x48/apps/fcoe.png
URL: http://svn.opensuse.org/viewcvs/yast/trunk/theme/openSUSE-Crystal/icons/48x…
==============================================================================
Binary file - no diff available.
Added: trunk/theme/openSUSE-Oxygen/icons/22x22/apps/fcoe.png
URL: http://svn.opensuse.org/viewcvs/yast/trunk/theme/openSUSE-Oxygen/icons/22x2…
==============================================================================
Binary file - no diff available.
Added: trunk/theme/openSUSE-Oxygen/icons/32x32/apps/fcoe.png
URL: http://svn.opensuse.org/viewcvs/yast/trunk/theme/openSUSE-Oxygen/icons/32x3…
==============================================================================
Binary file - no diff available.
Added: trunk/theme/openSUSE-Oxygen/icons/48x48/apps/fcoe.png
URL: http://svn.opensuse.org/viewcvs/yast/trunk/theme/openSUSE-Oxygen/icons/48x4…
==============================================================================
Binary file - no diff available.
Added: trunk/theme/openSUSE-Oxygen/icons/64x64/apps/fcoe.png
URL: http://svn.opensuse.org/viewcvs/yast/trunk/theme/openSUSE-Oxygen/icons/64x6…
==============================================================================
Binary file - no diff available.
Added: trunk/theme/openSUSE/icons/16x16/apps/fcoe.png
URL: http://svn.opensuse.org/viewcvs/yast/trunk/theme/openSUSE/icons/16x16/apps/…
==============================================================================
Binary file - no diff available.
Added: trunk/theme/openSUSE/icons/22x22/apps/fcoe.png
URL: http://svn.opensuse.org/viewcvs/yast/trunk/theme/openSUSE/icons/22x22/apps/…
==============================================================================
Binary file - no diff available.
Added: trunk/theme/openSUSE/icons/256x256/apps/fcoe.png
URL: http://svn.opensuse.org/viewcvs/yast/trunk/theme/openSUSE/icons/256x256/app…
==============================================================================
Binary file - no diff available.
Added: trunk/theme/openSUSE/icons/32x32/apps/fcoe.png
URL: http://svn.opensuse.org/viewcvs/yast/trunk/theme/openSUSE/icons/32x32/apps/…
==============================================================================
Binary file - no diff available.
Added: trunk/theme/openSUSE/icons/48x48/apps/fcoe.png
URL: http://svn.opensuse.org/viewcvs/yast/trunk/theme/openSUSE/icons/48x48/apps/…
==============================================================================
Binary file - no diff available.
Added: trunk/theme/openSUSE/icons/64x64/apps/fcoe.png
URL: http://svn.opensuse.org/viewcvs/yast/trunk/theme/openSUSE/icons/64x64/apps/…
==============================================================================
Binary file - no diff available.
Added: trunk/theme/openSUSE/icons/scalable/apps/fcoe.svg
URL: http://svn.opensuse.org/viewcvs/yast/trunk/theme/openSUSE/icons/scalable/ap…
==============================================================================
--- trunk/theme/openSUSE/icons/scalable/apps/fcoe.svg (added)
+++ trunk/theme/openSUSE/icons/scalable/apps/fcoe.svg Tue May 17 15:16:09 2011
@@ -0,0 +1,1257 @@
+<?xml version="1.0" encoding="UTF-8" standalone="no"?>
+<!-- Created with Inkscape (http://www.inkscape.org/) -->
+
+<svg
+ xmlns:dc="http://purl.org/dc/elements/1.1/"
+ xmlns:cc="http://creativecommons.org/ns#"
+ xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
+ xmlns:svg="http://www.w3.org/2000/svg"
+ xmlns="http://www.w3.org/2000/svg"
+ xmlns:xlink="http://www.w3.org/1999/xlink"
+ xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"
+ xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
+ width="32px"
+ height="32px"
+ id="svg6350"
+ version="1.1"
+ inkscape:version="0.47 r22583"
+ sodipodi:docname="New document 12">
+ <defs
+ id="defs6352">
+ <inkscape:perspective
+ sodipodi:type="inkscape:persp3d"
+ inkscape:vp_x="0 : 16 : 1"
+ inkscape:vp_y="0 : 1000 : 0"
+ inkscape:vp_z="32 : 16 : 1"
+ inkscape:persp3d-origin="16 : 10.666667 : 1"
+ id="perspective6358" />
+ <inkscape:perspective
+ id="perspective4400"
+ inkscape:persp3d-origin="0.5 : 0.33333333 : 1"
+ inkscape:vp_z="1 : 0.5 : 1"
+ inkscape:vp_y="0 : 1000 : 0"
+ inkscape:vp_x="0 : 0.5 : 1"
+ sodipodi:type="inkscape:persp3d" />
+ <linearGradient
+ inkscape:collect="always"
+ xlink:href="#linearGradient13844"
+ id="linearGradient17909"
+ gradientUnits="userSpaceOnUse"
+ x1="173.25"
+ y1="79.5"
+ x2="160.85922"
+ y2="67.10923"
+ gradientTransform="translate(-106,-6)" />
+ <linearGradient
+ inkscape:collect="always"
+ id="linearGradient13844">
+ <stop
+ style="stop-color:#000000;stop-opacity:1;"
+ offset="0"
+ id="stop13846" />
+ <stop
+ style="stop-color:#000000;stop-opacity:0;"
+ offset="1"
+ id="stop13848" />
+ </linearGradient>
+ <linearGradient
+ inkscape:collect="always"
+ xlink:href="#linearGradient13836"
+ id="linearGradient17911"
+ gradientUnits="userSpaceOnUse"
+ x1="174.00658"
+ y1="81.231583"
+ x2="109.85642"
+ y2="17.08143"
+ gradientTransform="translate(-106,-6)" />
+ <linearGradient
+ inkscape:collect="always"
+ id="linearGradient13836">
+ <stop
+ style="stop-color:#ffffff;stop-opacity:1;"
+ offset="0"
+ id="stop13838" />
+ <stop
+ style="stop-color:#ffffff;stop-opacity:0;"
+ offset="1"
+ id="stop13840" />
+ </linearGradient>
+ <radialGradient
+ inkscape:collect="always"
+ xlink:href="#linearGradient10791"
+ id="radialGradient17907"
+ gradientUnits="userSpaceOnUse"
+ gradientTransform="matrix(2.0002364,0,0,0.66666666,-34.15327,0.33333)"
+ cx="25.000021"
+ cy="28.742769"
+ fx="25.000021"
+ fy="28.742769"
+ r="12" />
+ <linearGradient
+ id="linearGradient10791">
+ <stop
+ style="stop-color:#28282b;stop-opacity:1;"
+ offset="0"
+ id="stop10793" />
+ <stop
+ id="stop10799"
+ offset="0.27897844"
+ style="stop-color:#5f5f65;stop-opacity:1" />
+ <stop
+ style="stop-color:#242427;stop-opacity:1"
+ offset="1"
+ id="stop10795" />
+ </linearGradient>
+ <linearGradient
+ gradientTransform="translate(-249,-6)"
+ inkscape:collect="always"
+ xlink:href="#linearGradient17991"
+ id="linearGradient17997"
+ x1="265"
+ y1="39.276649"
+ x2="264.99997"
+ y2="1.7233521"
+ gradientUnits="userSpaceOnUse" />
+ <linearGradient
+ inkscape:collect="always"
+ id="linearGradient17991">
+ <stop
+ style="stop-color:#808083;stop-opacity:1;"
+ offset="0"
+ id="stop17993" />
+ <stop
+ style="stop-color:#808083;stop-opacity:0;"
+ offset="1"
+ id="stop17995" />
+ </linearGradient>
+ <linearGradient
+ inkscape:collect="always"
+ xlink:href="#linearGradient13675"
+ id="linearGradient17879"
+ gradientUnits="userSpaceOnUse"
+ gradientTransform="matrix(0.5,0,0,0.5,5,4)"
+ x1="9.9226456"
+ y1="33"
+ x2="19.819132"
+ y2="33" />
+ <linearGradient
+ id="linearGradient13675">
+ <stop
+ id="stop13677"
+ offset="0"
+ style="stop-color:#ffffff;stop-opacity:1" />
+ <stop
+ style="stop-color:#aaccee;stop-opacity:1"
+ offset="0.20050415"
+ id="stop13679" />
+ <stop
+ style="stop-color:#6699cc;stop-opacity:1"
+ offset="0.80037004"
+ id="stop13681" />
+ <stop
+ id="stop13683"
+ offset="1"
+ style="stop-color:#003366;stop-opacity:1" />
+ </linearGradient>
+ <linearGradient
+ inkscape:collect="always"
+ xlink:href="#linearGradient13675"
+ id="linearGradient17881"
+ gradientUnits="userSpaceOnUse"
+ gradientTransform="translate(0,4)"
+ x1="15"
+ y1="34.5"
+ x2="20"
+ y2="34.5" />
+ <linearGradient
+ id="linearGradient4428">
+ <stop
+ id="stop4430"
+ offset="0"
+ style="stop-color:#ffffff;stop-opacity:1" />
+ <stop
+ style="stop-color:#aaccee;stop-opacity:1"
+ offset="0.20050415"
+ id="stop4432" />
+ <stop
+ style="stop-color:#6699cc;stop-opacity:1"
+ offset="0.80037004"
+ id="stop4434" />
+ <stop
+ id="stop4436"
+ offset="1"
+ style="stop-color:#003366;stop-opacity:1" />
+ </linearGradient>
+ <linearGradient
+ inkscape:collect="always"
+ xlink:href="#linearGradient13173"
+ id="linearGradient17883"
+ gradientUnits="userSpaceOnUse"
+ x1="18.124208"
+ y1="26.54208"
+ x2="18.124208"
+ y2="31.151253" />
+ <linearGradient
+ inkscape:collect="always"
+ id="linearGradient13173">
+ <stop
+ style="stop-color:#2e2e2e;stop-opacity:1;"
+ offset="0"
+ id="stop13175" />
+ <stop
+ style="stop-color:#2e2e2e;stop-opacity:0;"
+ offset="1"
+ id="stop13177" />
+ </linearGradient>
+ <linearGradient
+ inkscape:collect="always"
+ xlink:href="#linearGradient16045"
+ id="linearGradient4338"
+ gradientUnits="userSpaceOnUse"
+ gradientTransform="matrix(0.5,0,0,0.5,5,14)"
+ x1="17.189102"
+ y1="32.180798"
+ x2="17.189102"
+ y2="43.288792" />
+ <linearGradient
+ id="linearGradient16045">
+ <stop
+ id="stop16047"
+ offset="0"
+ style="stop-color:#fafcfe;stop-opacity:1" />
+ <stop
+ style="stop-color:#7cb2eb;stop-opacity:1;"
+ offset="0.5"
+ id="stop16051" />
+ <stop
+ id="stop16049"
+ offset="1"
+ style="stop-color:#366ba1;stop-opacity:1" />
+ </linearGradient>
+ <linearGradient
+ inkscape:collect="always"
+ xlink:href="#linearGradient16037"
+ id="linearGradient4340"
+ gradientUnits="userSpaceOnUse"
+ x1="15.631318"
+ y1="44.702961"
+ x2="15.631318"
+ y2="34.056591" />
+ <linearGradient
+ id="linearGradient16037">
+ <stop
+ style="stop-color:#ddeaf8;stop-opacity:1"
+ offset="0"
+ id="stop16039" />
+ <stop
+ id="stop16041"
+ offset="0.46645069"
+ style="stop-color:#12569b;stop-opacity:1" />
+ <stop
+ style="stop-color:#28282a;stop-opacity:1"
+ offset="1"
+ id="stop16043" />
+ </linearGradient>
+ <linearGradient
+ inkscape:collect="always"
+ xlink:href="#linearGradient16075"
+ id="linearGradient4342"
+ gradientUnits="userSpaceOnUse"
+ x1="5.6098752"
+ y1="31.5"
+ x2="14.240004"
+ y2="31.5" />
+ <linearGradient
+ inkscape:collect="always"
+ id="linearGradient16075">
+ <stop
+ style="stop-color:#ffffff;stop-opacity:1;"
+ offset="0"
+ id="stop16077" />
+ <stop
+ style="stop-color:#ffffff;stop-opacity:0;"
+ offset="1"
+ id="stop16079" />
+ </linearGradient>
+ <linearGradient
+ inkscape:collect="always"
+ xlink:href="#linearGradient16547"
+ id="linearGradient4344"
+ gradientUnits="userSpaceOnUse"
+ x1="16.14299"
+ y1="30.5"
+ x2="15"
+ y2="30.5" />
+ <linearGradient
+ inkscape:collect="always"
+ id="linearGradient16547">
+ <stop
+ style="stop-color:#336699;stop-opacity:1;"
+ offset="0"
+ id="stop16549" />
+ <stop
+ style="stop-color:#336699;stop-opacity:0;"
+ offset="1"
+ id="stop16551" />
+ </linearGradient>
+ <linearGradient
+ inkscape:collect="always"
+ xlink:href="#linearGradient16075"
+ id="linearGradient4460"
+ gradientUnits="userSpaceOnUse"
+ x1="5.6098752"
+ y1="31.5"
+ x2="14.240004"
+ y2="31.5" />
+ <linearGradient
+ inkscape:collect="always"
+ xlink:href="#linearGradient16547"
+ id="linearGradient4468"
+ gradientUnits="userSpaceOnUse"
+ x1="16.14299"
+ y1="30.5"
+ x2="15"
+ y2="30.5" />
+ <linearGradient
+ inkscape:collect="always"
+ xlink:href="#linearGradient16075"
+ id="linearGradient4476"
+ gradientUnits="userSpaceOnUse"
+ x1="5.6098752"
+ y1="31.5"
+ x2="14.240004"
+ y2="31.5" />
+ <linearGradient
+ inkscape:collect="always"
+ xlink:href="#linearGradient16547"
+ id="linearGradient4484"
+ gradientUnits="userSpaceOnUse"
+ x1="16.14299"
+ y1="30.5"
+ x2="15"
+ y2="30.5" />
+ <linearGradient
+ inkscape:collect="always"
+ xlink:href="#linearGradient16075"
+ id="linearGradient4492"
+ gradientUnits="userSpaceOnUse"
+ x1="5.6098752"
+ y1="31.5"
+ x2="14.240004"
+ y2="31.5" />
+ <linearGradient
+ inkscape:collect="always"
+ xlink:href="#linearGradient16547"
+ id="linearGradient4500"
+ gradientUnits="userSpaceOnUse"
+ x1="16.14299"
+ y1="30.5"
+ x2="15"
+ y2="30.5" />
+ <linearGradient
+ inkscape:collect="always"
+ xlink:href="#linearGradient16075"
+ id="linearGradient4508"
+ gradientUnits="userSpaceOnUse"
+ x1="5.6098752"
+ y1="31.5"
+ x2="14.240004"
+ y2="31.5" />
+ <linearGradient
+ inkscape:collect="always"
+ xlink:href="#linearGradient16547"
+ id="linearGradient4516"
+ gradientUnits="userSpaceOnUse"
+ x1="16.14299"
+ y1="30.5"
+ x2="15"
+ y2="30.5" />
+ <linearGradient
+ inkscape:collect="always"
+ xlink:href="#linearGradient13713"
+ id="linearGradient17893"
+ gradientUnits="userSpaceOnUse"
+ gradientTransform="matrix(0.5,0,0,0.5,5,4)"
+ x1="9.9226456"
+ y1="33"
+ x2="19.819132"
+ y2="33" />
+ <linearGradient
+ id="linearGradient13713">
+ <stop
+ style="stop-color:#fffdb6;stop-opacity:1;"
+ offset="0"
+ id="stop13715" />
+ <stop
+ id="stop13717"
+ offset="0.20050415"
+ style="stop-color:#fdd29b;stop-opacity:1;" />
+ <stop
+ id="stop13719"
+ offset="0.80037004"
+ style="stop-color:#ea8c48;stop-opacity:1;" />
+ <stop
+ style="stop-color:#82452c;stop-opacity:1"
+ offset="1"
+ id="stop13721" />
+ </linearGradient>
+ <linearGradient
+ inkscape:collect="always"
+ xlink:href="#linearGradient13713"
+ id="linearGradient17895"
+ gradientUnits="userSpaceOnUse"
+ gradientTransform="translate(0,4)"
+ x1="15"
+ y1="34.5"
+ x2="20"
+ y2="34.5" />
+ <linearGradient
+ id="linearGradient4531">
+ <stop
+ style="stop-color:#fffdb6;stop-opacity:1;"
+ offset="0"
+ id="stop4533" />
+ <stop
+ id="stop4535"
+ offset="0.20050415"
+ style="stop-color:#fdd29b;stop-opacity:1;" />
+ <stop
+ id="stop4537"
+ offset="0.80037004"
+ style="stop-color:#ea8c48;stop-opacity:1;" />
+ <stop
+ style="stop-color:#82452c;stop-opacity:1"
+ offset="1"
+ id="stop4539" />
+ </linearGradient>
+ <linearGradient
+ inkscape:collect="always"
+ xlink:href="#linearGradient13173"
+ id="linearGradient17897"
+ gradientUnits="userSpaceOnUse"
+ x1="18.124208"
+ y1="26.423214"
+ x2="18.124208"
+ y2="31.151253" />
+ <linearGradient
+ inkscape:collect="always"
+ xlink:href="#linearGradient13723"
+ id="linearGradient17899"
+ gradientUnits="userSpaceOnUse"
+ gradientTransform="matrix(0.5,0,0,0.5,5,14)"
+ x1="12.811365"
+ y1="31.9375"
+ x2="16.899677"
+ y2="42.787495" />
+ <linearGradient
+ id="linearGradient13723">
+ <stop
+ id="stop13725"
+ offset="0"
+ style="stop-color:#fafcfe;stop-opacity:1" />
+ <stop
+ style="stop-color:#e49d81;stop-opacity:1;"
+ offset="0.5"
+ id="stop13795" />
+ <stop
+ id="stop13727"
+ offset="1"
+ style="stop-color:#ae4d25;stop-opacity:1" />
+ </linearGradient>
+ <linearGradient
+ inkscape:collect="always"
+ xlink:href="#linearGradient13729"
+ id="linearGradient17901"
+ gradientUnits="userSpaceOnUse"
+ x1="15.631318"
+ y1="43.611408"
+ x2="15.631318"
+ y2="30.073717" />
+ <linearGradient
+ id="linearGradient13729">
+ <stop
+ id="stop13731"
+ offset="0"
+ style="stop-color:#e3e3e3;stop-opacity:1" />
+ <stop
+ style="stop-color:#b93700;stop-opacity:1"
+ offset="0.36668861"
+ id="stop13733" />
+ <stop
+ id="stop13735"
+ offset="1"
+ style="stop-color:#28282a;stop-opacity:1" />
+ </linearGradient>
+ <linearGradient
+ inkscape:collect="always"
+ xlink:href="#linearGradient13675"
+ id="linearGradient4346"
+ gradientUnits="userSpaceOnUse"
+ gradientTransform="matrix(0.5,0,0,0.5,117,9.5)"
+ x1="9.9226456"
+ y1="33"
+ x2="19.819132"
+ y2="33" />
+ <linearGradient
+ id="linearGradient4559">
+ <stop
+ id="stop4561"
+ offset="0"
+ style="stop-color:#ffffff;stop-opacity:1" />
+ <stop
+ style="stop-color:#aaccee;stop-opacity:1"
+ offset="0.20050415"
+ id="stop4563" />
+ <stop
+ style="stop-color:#6699cc;stop-opacity:1"
+ offset="0.80037004"
+ id="stop4565" />
+ <stop
+ id="stop4567"
+ offset="1"
+ style="stop-color:#003366;stop-opacity:1" />
+ </linearGradient>
+ <linearGradient
+ inkscape:collect="always"
+ xlink:href="#linearGradient13173"
+ id="linearGradient4348"
+ gradientUnits="userSpaceOnUse"
+ x1="20.099268"
+ y1="23.78023"
+ x2="18.124208"
+ y2="31.151253" />
+ <linearGradient
+ inkscape:collect="always"
+ xlink:href="#linearGradient13675"
+ id="linearGradient4576"
+ gradientUnits="userSpaceOnUse"
+ gradientTransform="matrix(0.5,0,0,0.5,117,9.5)"
+ x1="9.9226456"
+ y1="33"
+ x2="19.819132"
+ y2="33" />
+ <linearGradient
+ id="linearGradient4578">
+ <stop
+ id="stop4580"
+ offset="0"
+ style="stop-color:#ffffff;stop-opacity:1" />
+ <stop
+ style="stop-color:#aaccee;stop-opacity:1"
+ offset="0.20050415"
+ id="stop4582" />
+ <stop
+ style="stop-color:#6699cc;stop-opacity:1"
+ offset="0.80037004"
+ id="stop4584" />
+ <stop
+ id="stop4586"
+ offset="1"
+ style="stop-color:#003366;stop-opacity:1" />
+ </linearGradient>
+ <linearGradient
+ inkscape:collect="always"
+ xlink:href="#linearGradient13173"
+ id="linearGradient4588"
+ gradientUnits="userSpaceOnUse"
+ x1="20.099268"
+ y1="23.78023"
+ x2="18.124208"
+ y2="31.151253" />
+ <linearGradient
+ inkscape:collect="always"
+ xlink:href="#linearGradient16045"
+ id="linearGradient4596"
+ gradientUnits="userSpaceOnUse"
+ gradientTransform="matrix(0.5,0,0,0.5,5,14)"
+ x1="17.189102"
+ y1="32.180798"
+ x2="17.189102"
+ y2="43.288792" />
+ <linearGradient
+ id="linearGradient4598">
+ <stop
+ id="stop4600"
+ offset="0"
+ style="stop-color:#fafcfe;stop-opacity:1" />
+ <stop
+ style="stop-color:#7cb2eb;stop-opacity:1;"
+ offset="0.5"
+ id="stop4602" />
+ <stop
+ id="stop4604"
+ offset="1"
+ style="stop-color:#366ba1;stop-opacity:1" />
+ </linearGradient>
+ <linearGradient
+ inkscape:collect="always"
+ xlink:href="#linearGradient16037"
+ id="linearGradient4606"
+ gradientUnits="userSpaceOnUse"
+ x1="15.631318"
+ y1="44.702961"
+ x2="15.631318"
+ y2="34.056591" />
+ <linearGradient
+ id="linearGradient4608">
+ <stop
+ style="stop-color:#ddeaf8;stop-opacity:1"
+ offset="0"
+ id="stop4610" />
+ <stop
+ id="stop4612"
+ offset="0.46645069"
+ style="stop-color:#12569b;stop-opacity:1" />
+ <stop
+ style="stop-color:#28282a;stop-opacity:1"
+ offset="1"
+ id="stop4614" />
+ </linearGradient>
+ <linearGradient
+ inkscape:collect="always"
+ xlink:href="#linearGradient16075"
+ id="linearGradient4616"
+ gradientUnits="userSpaceOnUse"
+ x1="5.6098752"
+ y1="31.5"
+ x2="14.240004"
+ y2="31.5" />
+ <linearGradient
+ inkscape:collect="always"
+ xlink:href="#linearGradient16547"
+ id="linearGradient4624"
+ gradientUnits="userSpaceOnUse"
+ x1="16.14299"
+ y1="30.5"
+ x2="15"
+ y2="30.5" />
+ <linearGradient
+ inkscape:collect="always"
+ xlink:href="#linearGradient16075"
+ id="linearGradient4632"
+ gradientUnits="userSpaceOnUse"
+ x1="5.6098752"
+ y1="31.5"
+ x2="14.240004"
+ y2="31.5" />
+ <linearGradient
+ inkscape:collect="always"
+ xlink:href="#linearGradient16547"
+ id="linearGradient4640"
+ gradientUnits="userSpaceOnUse"
+ x1="16.14299"
+ y1="30.5"
+ x2="15"
+ y2="30.5" />
+ <linearGradient
+ inkscape:collect="always"
+ xlink:href="#linearGradient16075"
+ id="linearGradient4648"
+ gradientUnits="userSpaceOnUse"
+ x1="5.6098752"
+ y1="31.5"
+ x2="14.240004"
+ y2="31.5" />
+ <linearGradient
+ inkscape:collect="always"
+ xlink:href="#linearGradient16547"
+ id="linearGradient4656"
+ gradientUnits="userSpaceOnUse"
+ x1="16.14299"
+ y1="30.5"
+ x2="15"
+ y2="30.5" />
+ <linearGradient
+ inkscape:collect="always"
+ xlink:href="#linearGradient16075"
+ id="linearGradient4664"
+ gradientUnits="userSpaceOnUse"
+ x1="5.6098752"
+ y1="31.5"
+ x2="14.240004"
+ y2="31.5" />
+ <linearGradient
+ inkscape:collect="always"
+ xlink:href="#linearGradient16547"
+ id="linearGradient4672"
+ gradientUnits="userSpaceOnUse"
+ x1="16.14299"
+ y1="30.5"
+ x2="15"
+ y2="30.5" />
+ <linearGradient
+ inkscape:collect="always"
+ xlink:href="#linearGradient16075"
+ id="linearGradient4680"
+ gradientUnits="userSpaceOnUse"
+ x1="5.6098752"
+ y1="31.5"
+ x2="14.240004"
+ y2="31.5" />
+ <linearGradient
+ inkscape:collect="always"
+ xlink:href="#linearGradient16547"
+ id="linearGradient4688"
+ gradientUnits="userSpaceOnUse"
+ x1="16.14299"
+ y1="30.5"
+ x2="15"
+ y2="30.5" />
+ <linearGradient
+ inkscape:collect="always"
+ xlink:href="#linearGradient16045"
+ id="linearGradient4696"
+ gradientUnits="userSpaceOnUse"
+ gradientTransform="matrix(0.5,0,0,0.5,5,14)"
+ x1="17.189102"
+ y1="32.180798"
+ x2="17.189102"
+ y2="43.288792" />
+ <linearGradient
+ id="linearGradient4698">
+ <stop
+ id="stop4700"
+ offset="0"
+ style="stop-color:#fafcfe;stop-opacity:1" />
+ <stop
+ style="stop-color:#7cb2eb;stop-opacity:1;"
+ offset="0.5"
+ id="stop4702" />
+ <stop
+ id="stop4704"
+ offset="1"
+ style="stop-color:#366ba1;stop-opacity:1" />
+ </linearGradient>
+ <linearGradient
+ inkscape:collect="always"
+ xlink:href="#linearGradient16037"
+ id="linearGradient4706"
+ gradientUnits="userSpaceOnUse"
+ x1="15.631318"
+ y1="44.702961"
+ x2="15.631318"
+ y2="34.056591" />
+ <linearGradient
+ id="linearGradient4708">
+ <stop
+ style="stop-color:#ddeaf8;stop-opacity:1"
+ offset="0"
+ id="stop4710" />
+ <stop
+ id="stop4712"
+ offset="0.46645069"
+ style="stop-color:#12569b;stop-opacity:1" />
+ <stop
+ style="stop-color:#28282a;stop-opacity:1"
+ offset="1"
+ id="stop4714" />
+ </linearGradient>
+ <linearGradient
+ inkscape:collect="always"
+ xlink:href="#linearGradient16075"
+ id="linearGradient4716"
+ gradientUnits="userSpaceOnUse"
+ x1="5.6098752"
+ y1="31.5"
+ x2="14.240004"
+ y2="31.5" />
+ <linearGradient
+ inkscape:collect="always"
+ xlink:href="#linearGradient16547"
+ id="linearGradient4724"
+ gradientUnits="userSpaceOnUse"
+ x1="16.14299"
+ y1="30.5"
+ x2="15"
+ y2="30.5" />
+ <linearGradient
+ inkscape:collect="always"
+ xlink:href="#linearGradient16075"
+ id="linearGradient4732"
+ gradientUnits="userSpaceOnUse"
+ x1="5.6098752"
+ y1="31.5"
+ x2="14.240004"
+ y2="31.5" />
+ <linearGradient
+ inkscape:collect="always"
+ xlink:href="#linearGradient16547"
+ id="linearGradient4740"
+ gradientUnits="userSpaceOnUse"
+ x1="16.14299"
+ y1="30.5"
+ x2="15"
+ y2="30.5" />
+ <linearGradient
+ inkscape:collect="always"
+ xlink:href="#linearGradient16075"
+ id="linearGradient4748"
+ gradientUnits="userSpaceOnUse"
+ x1="5.6098752"
+ y1="31.5"
+ x2="14.240004"
+ y2="31.5" />
+ <linearGradient
+ inkscape:collect="always"
+ xlink:href="#linearGradient16547"
+ id="linearGradient4756"
+ gradientUnits="userSpaceOnUse"
+ x1="16.14299"
+ y1="30.5"
+ x2="15"
+ y2="30.5" />
+ <linearGradient
+ inkscape:collect="always"
+ xlink:href="#linearGradient16075"
+ id="linearGradient4764"
+ gradientUnits="userSpaceOnUse"
+ x1="5.6098752"
+ y1="31.5"
+ x2="14.240004"
+ y2="31.5" />
+ <linearGradient
+ inkscape:collect="always"
+ xlink:href="#linearGradient16547"
+ id="linearGradient4772"
+ gradientUnits="userSpaceOnUse"
+ x1="16.14299"
+ y1="30.5"
+ x2="15"
+ y2="30.5" />
+ <linearGradient
+ inkscape:collect="always"
+ xlink:href="#linearGradient16075"
+ id="linearGradient4780"
+ gradientUnits="userSpaceOnUse"
+ x1="5.6098752"
+ y1="31.5"
+ x2="14.240004"
+ y2="31.5" />
+ <linearGradient
+ inkscape:collect="always"
+ xlink:href="#linearGradient16547"
+ id="linearGradient4788"
+ gradientUnits="userSpaceOnUse"
+ x1="16.14299"
+ y1="30.5"
+ x2="15"
+ y2="30.5" />
+ <linearGradient
+ inkscape:collect="always"
+ xlink:href="#linearGradient13173-8"
+ id="linearGradient17867"
+ gradientUnits="userSpaceOnUse"
+ gradientTransform="translate(1,-11)"
+ x1="18.124208"
+ y1="26.54208"
+ x2="18.124208"
+ y2="31.151253" />
+ <linearGradient
+ inkscape:collect="always"
+ id="linearGradient13173-8">
+ <stop
+ style="stop-color:#2e2e2e;stop-opacity:1;"
+ offset="0"
+ id="stop13175-9" />
+ <stop
+ style="stop-color:#2e2e2e;stop-opacity:0;"
+ offset="1"
+ id="stop13177-7" />
+ </linearGradient>
+ <linearGradient
+ inkscape:collect="always"
+ xlink:href="#linearGradient13173-8"
+ id="linearGradient17865"
+ gradientUnits="userSpaceOnUse"
+ gradientTransform="translate(6,-11)"
+ x1="18.124208"
+ y1="26.54208"
+ x2="18.124208"
+ y2="31.151253" />
+ <linearGradient
+ inkscape:collect="always"
+ xlink:href="#linearGradient16045"
+ id="linearGradient6933"
+ gradientUnits="userSpaceOnUse"
+ gradientTransform="matrix(0.5,0,0,0.5,5,14)"
+ x1="17.189102"
+ y1="32.180798"
+ x2="17.189102"
+ y2="43.288792" />
+ <linearGradient
+ inkscape:collect="always"
+ xlink:href="#linearGradient16037"
+ id="linearGradient6935"
+ gradientUnits="userSpaceOnUse"
+ x1="15.631318"
+ y1="44.702961"
+ x2="15.631318"
+ y2="34.056591" />
+ <linearGradient
+ inkscape:collect="always"
+ xlink:href="#linearGradient16075"
+ id="linearGradient6937"
+ gradientUnits="userSpaceOnUse"
+ x1="5.6098752"
+ y1="31.5"
+ x2="14.240004"
+ y2="31.5" />
+ <linearGradient
+ inkscape:collect="always"
+ xlink:href="#linearGradient16547"
+ id="linearGradient6939"
+ gradientUnits="userSpaceOnUse"
+ x1="16.14299"
+ y1="30.5"
+ x2="15"
+ y2="30.5" />
+ <linearGradient
+ inkscape:collect="always"
+ xlink:href="#linearGradient13675"
+ id="linearGradient6941"
+ gradientUnits="userSpaceOnUse"
+ gradientTransform="matrix(0.5,0,0,0.5,117,9.5)"
+ x1="9.9226456"
+ y1="33"
+ x2="19.819132"
+ y2="33" />
+ <linearGradient
+ inkscape:collect="always"
+ xlink:href="#linearGradient13173"
+ id="linearGradient6943"
+ gradientUnits="userSpaceOnUse"
+ x1="20.099268"
+ y1="23.78023"
+ x2="18.124208"
+ y2="31.151253" />
+ </defs>
+ <sodipodi:namedview
+ id="base"
+ pagecolor="#ffffff"
+ bordercolor="#666666"
+ borderopacity="1.0"
+ inkscape:pageopacity="0.0"
+ inkscape:pageshadow="2"
+ inkscape:zoom="11.197802"
+ inkscape:cx="16"
+ inkscape:cy="16"
+ inkscape:current-layer="layer1"
+ showgrid="true"
+ inkscape:grid-bbox="true"
+ inkscape:document-units="px"
+ inkscape:window-width="940"
+ inkscape:window-height="694"
+ inkscape:window-x="1529"
+ inkscape:window-y="154"
+ inkscape:window-maximized="0" />
+ <metadata
+ id="metadata6355">
+ <rdf:RDF>
+ <cc:Work
+ rdf:about="">
+ <dc:format>image/svg+xml</dc:format>
+ <dc:type
+ rdf:resource="http://purl.org/dc/dcmitype/StillImage" />
+ <dc:title></dc:title>
+ </cc:Work>
+ </rdf:RDF>
+ </metadata>
+ <g
+ id="layer1"
+ inkscape:label="Layer 1"
+ inkscape:groupmode="layer">
+ <path
+ style="fill:#cccccf"
+ d="M 9,0 23,0 23,4 9,4 z"
+ id="rect13631"
+ inkscape:connector-curvature="0"
+ sodipodi:nodetypes="ccccc"
+ inkscape:export-filename="/suse/tgoettlicher/fcoe/FCoE-256.png"
+ inkscape:export-xdpi="720"
+ inkscape:export-ydpi="720" />
+ <path
+ style="fill:#cacacd;fill-opacity:1"
+ d="M 0,3 32,3 32,26 0,26 z"
+ id="rect13633"
+ inkscape:connector-curvature="0"
+ sodipodi:nodetypes="ccccc"
+ inkscape:export-filename="/suse/tgoettlicher/fcoe/FCoE-256.png"
+ inkscape:export-xdpi="720"
+ inkscape:export-ydpi="720" />
+ <path
+ style="fill:#ffffff;fill-opacity:1"
+ d="M 0,4 10,4 10,5 0,5 z"
+ id="rect13659"
+ inkscape:connector-curvature="0"
+ sodipodi:nodetypes="ccccc"
+ inkscape:export-filename="/suse/tgoettlicher/fcoe/FCoE-256.png"
+ inkscape:export-xdpi="720"
+ inkscape:export-ydpi="720" />
+ <rect
+ style="fill:#cacacd;fill-opacity:1"
+ y="4.0000072"
+ x="11.00001"
+ height="1"
+ width="10"
+ id="rect13661"
+ inkscape:export-filename="/suse/tgoettlicher/fcoe/FCoE-256.png"
+ inkscape:export-xdpi="720"
+ inkscape:export-ydpi="720" />
+ <path
+ style="fill:#ffffff;fill-opacity:1"
+ d="M 10,1 22,1 22,1.5 22,2 10,2 z"
+ id="rect13657"
+ inkscape:connector-curvature="0"
+ sodipodi:nodetypes="cccccc"
+ inkscape:export-filename="/suse/tgoettlicher/fcoe/FCoE-256.png"
+ inkscape:export-xdpi="720"
+ inkscape:export-ydpi="720" />
+ <path
+ sodipodi:nodetypes="ccccccccccc"
+ inkscape:connector-curvature="0"
+ id="path13834"
+ d="m 3,9 6,0 2,0 0,-4 10,0 0,4 2,0 6,0 0,13 -26,0 z"
+ style="fill:url(#linearGradient17909);fill-opacity:1;stroke:url(#linearGradient17911);stroke-width:2;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none"
+ inkscape:export-filename="/suse/tgoettlicher/fcoe/FCoE-256.png"
+ inkscape:export-xdpi="720"
+ inkscape:export-ydpi="720" />
+ <path
+ style="fill:url(#radialGradient17907);fill-opacity:1"
+ d="m 4,9 5,0 2,0 0,-4 10,0 0,4 2,0 5,0 0,13 -24,0 z"
+ id="rect13635"
+ inkscape:connector-curvature="0"
+ sodipodi:nodetypes="ccccccccccc"
+ inkscape:export-filename="/suse/tgoettlicher/fcoe/FCoE-256.png"
+ inkscape:export-xdpi="720"
+ inkscape:export-ydpi="720" />
+ <path
+ style="fill:url(#linearGradient17997);fill-opacity:1"
+ d="m 0,3 0,1 0,21 0,1 32,0 0,-1 0,-21 0,-1 -9,0 0,1 8,0 0,21 L 1,25 1,4 9,4 9,3 z"
+ id="path17338"
+ inkscape:connector-curvature="0"
+ sodipodi:nodetypes="ccccccccccccccccc"
+ inkscape:export-filename="/suse/tgoettlicher/fcoe/FCoE-256.png"
+ inkscape:export-xdpi="720"
+ inkscape:export-ydpi="720" />
+ <g
+ transform="translate(-4,-3.5)"
+ id="g13637"
+ inkscape:export-filename="/suse/tgoettlicher/fcoe/FCoE-256.png"
+ inkscape:export-xdpi="720"
+ inkscape:export-ydpi="720">
+ <g
+ id="g13639">
+ <path
+ style="fill:url(#linearGradient17879);fill-opacity:1"
+ d="m 15,21.5 0,3 -1,1 -3,0 -1,-1 0,-3 1,-1 3,0 z"
+ id="path13641"
+ inkscape:connector-curvature="0"
+ sodipodi:nodetypes="ccccccccc" />
+ <rect
+ y="27"
+ x="15"
+ height="15"
+ width="5"
+ id="rect13643"
+ style="fill:url(#linearGradient17881);fill-opacity:1"
+ rx="2.5"
+ ry="2.5"
+ transform="translate(-5,-6.5)" />
+ <path
+ sodipodi:nodetypes="cccccccc"
+ inkscape:connector-curvature="0"
+ id="path13649"
+ d="m 15,28 1,-1 1.5,0 1.5,0 1,1 0,4 -5,0 z"
+ style="fill:url(#linearGradient17883);fill-opacity:1"
+ transform="translate(-5,-6.5)" />
+ <g
+ id="g15939">
+ <path
+ sodipodi:nodetypes="ccccccccc"
+ inkscape:connector-curvature="0"
+ id="path16053"
+ d="m 15,30.5 0,3 -1,1 -3,0 -1,-1 0,-3 1,-1 3.069786,0 z"
+ style="fill:#ffffff;fill-opacity:0.21690141" />
+ <path
+ style="fill:url(#linearGradient6933);fill-opacity:1"
+ d="m 15,31.5 0,3 -1,1 -3,0 -1,-1 0,-3 1,-1 3.069786,0 z"
+ id="path13645"
+ inkscape:connector-curvature="0"
+ sodipodi:nodetypes="ccccccccc" />
+ <path
+ transform="matrix(0.4,0,0,0.4,6.5,17.8)"
+ style="fill:url(#linearGradient6935);fill-opacity:1"
+ d="m 18.75,40.5 -1.25,1.25 -1.25,0 -3.75,0 -1.25,-1.25 0,-5 1.25,-1.25 3.75,0 1.25,0 1.25,1.25 z"
+ id="path13647"
+ inkscape:connector-curvature="0"
+ sodipodi:nodetypes="ccccccccccc" />
+ <g
+ id="g16063">
+ <path
+ sodipodi:nodetypes="ccccccccc"
+ inkscape:connector-curvature="0"
+ id="path16059"
+ d="m 15,31.5 0,1 -1,-1 -3,0 -1,1 0,-1 1,-1 3.069786,0 z"
+ style="fill:url(#linearGradient6937);fill-opacity:1" />
+ <path
+ style="fill:url(#linearGradient6939);fill-opacity:1"
+ d="m 15,30.5 0,1 -1,-1 -3,0 -1,1 0,-1 1,-1 3.069786,0 z"
+ id="path16061"
+ inkscape:connector-curvature="0"
+ sodipodi:nodetypes="ccccccccc" />
+ </g>
+ <use
+ height="48"
+ width="48"
+ transform="translate(0,-2)"
+ id="use16067"
+ xlink:href="#g16063"
+ y="0"
+ x="0" />
+ <use
+ x="0"
+ y="0"
+ xlink:href="#g16063"
+ id="use16069"
+ transform="translate(0,-4)"
+ width="48"
+ height="48" />
+ <use
+ height="48"
+ width="48"
+ transform="translate(0,-6)"
+ id="use16071"
+ xlink:href="#g16063"
+ y="0"
+ x="0" />
+ <use
+ x="0"
+ y="0"
+ xlink:href="#g16063"
+ id="use16073"
+ transform="translate(0,-8)"
+ width="48"
+ height="48" />
+ </g>
+ </g>
+ <g
+ id="use13651"
+ transform="translate(5,0)">
+ <path
+ style="fill:url(#linearGradient17893);fill-opacity:1"
+ d="m 15,21.5 0,3 -1,1 -3,0 -1,-1 0,-3 1,-1 3,0 z"
+ id="path13693"
+ inkscape:connector-curvature="0"
+ sodipodi:nodetypes="ccccccccc" />
+ <rect
+ y="27"
+ x="15"
+ height="15"
+ width="5"
+ id="rect13695"
+ style="fill:url(#linearGradient17895);fill-opacity:1"
+ rx="2.5"
+ ry="2.5"
+ transform="translate(-5,-6.5)" />
+ <path
+ sodipodi:nodetypes="cccccccc"
+ inkscape:connector-curvature="0"
+ id="path13701"
+ d="m 15,28 1,-1 1.5,0 1.5,0 1,1 0,4 -5,0 z"
+ style="fill:url(#linearGradient17897);fill-opacity:1"
+ transform="translate(-5,-6.5)" />
+ <path
+ sodipodi:nodetypes="ccccccccc"
+ inkscape:connector-curvature="0"
+ id="path13697"
+ d="m 15,31.5 0,3 -1,1 -3,0 -1,-1 0,-3 1,-1 3.069786,0 z"
+ style="fill:url(#linearGradient17899);fill-opacity:1" />
+ <path
+ sodipodi:nodetypes="ccccccc"
+ inkscape:connector-curvature="0"
+ id="path13699"
+ d="m 18.75,38 0,3.75 -7.5,0 0,-3.75 0,-3.75 7.5,0 z"
+ style="fill:url(#linearGradient17901);fill-opacity:1"
+ transform="matrix(0.4,0,0,0.4,6.5,17.8)" />
+ </g>
+ <g
+ id="use13653"
+ transform="translate(10,0)">
+ <path
+ sodipodi:nodetypes="ccccssscccccc"
+ inkscape:connector-curvature="0"
+ id="path13739"
+ transform="translate(-112,-5.5)"
+ d="m 123,26 -1,1 0,1.5 0,1.5 0,4.5 c 0,1.385 1.115,2.5 2.5,2.5 1.385,0 2.5,-1.115 2.5,-2.5 l 0,-4.5 0,-1.5 0,-1.5 -1,-1 -1.5,0 z"
+ style="fill:url(#linearGradient6941);fill-opacity:1" />
+ <path
+ sodipodi:nodetypes="cccccccc"
+ inkscape:connector-curvature="0"
+ id="path13747"
+ d="m 15,28 1,-1 1.5,0 1.5,0 1,1 0,5 -5,0 z"
+ style="fill:url(#linearGradient6943);fill-opacity:1"
+ transform="translate(-5,-6.5)" />
+ </g>
+ <use
+ x="0"
+ y="0"
+ xlink:href="#use13653"
+ id="use13797"
+ transform="translate(5,0)"
+ width="48"
+ height="48" />
+ <use
+ height="1"
+ width="1"
+ id="use15943"
+ xlink:href="#g15939"
+ y="0"
+ x="0"
+ transform="translate(10,-3)" />
+ <use
+ transform="translate(15,-3)"
+ x="0"
+ y="0"
+ xlink:href="#g15939"
+ id="use16035"
+ width="1"
+ height="1" />
+ </g>
+ <path
+ style="fill:url(#linearGradient17867);fill-opacity:1"
+ d="m 16,17 1,-1 1.5,0 1.5,0 1,1 0,4 -5,0 z"
+ id="path13649-1"
+ inkscape:connector-curvature="0"
+ sodipodi:nodetypes="cccccccc"
+ inkscape:export-filename="/suse/tgoettlicher/fcoe/FCoE-256.png"
+ inkscape:export-xdpi="720"
+ inkscape:export-ydpi="720" />
+ <path
+ sodipodi:nodetypes="cccccccc"
+ inkscape:connector-curvature="0"
+ id="path17250"
+ d="m 21,17 1,-1 1.5,0 1.5,0 1,1 0,4 -5,0 z"
+ style="fill:url(#linearGradient17865);fill-opacity:1"
+ inkscape:export-filename="/suse/tgoettlicher/fcoe/FCoE-256.png"
+ inkscape:export-xdpi="720"
+ inkscape:export-ydpi="720" />
+ <path
+ style="fill:#808083;fill-opacity:0.28450706"
+ d="M 9,0 23,0 23,1 9,1 z"
+ id="path17732"
+ inkscape:connector-curvature="0"
+ sodipodi:nodetypes="ccccc"
+ inkscape:export-filename="/suse/tgoettlicher/fcoe/FCoE-256.png"
+ inkscape:export-xdpi="720"
+ inkscape:export-ydpi="720" />
+ <path
+ sodipodi:nodetypes="ccccc"
+ inkscape:connector-curvature="0"
+ id="path17863"
+ d="M 22,4 32,4 32,5 22,5 z"
+ style="fill:#ffffff;fill-opacity:1"
+ inkscape:export-filename="/suse/tgoettlicher/fcoe/FCoE-256.png"
+ inkscape:export-xdpi="720"
+ inkscape:export-ydpi="720" />
+ </g>
+</svg>
Modified: trunk/theme/package/yast2-theme.changes
URL: http://svn.opensuse.org/viewcvs/yast/trunk/theme/package/yast2-theme.change…
==============================================================================
--- trunk/theme/package/yast2-theme.changes (original)
+++ trunk/theme/package/yast2-theme.changes Tue May 17 15:16:09 2011
@@ -1,4 +1,10 @@
-------------------------------------------------------------------
+Tue May 17 15:14:02 CEST 2011 - tgoettlicher(a)suse.de
+
+- Added icons for FCoE (Fibre Channel over Ethernet)
+- 2.21.3
+
+-------------------------------------------------------------------
Fri Apr 29 14:31:58 CEST 2011 - tgoettlicher(a)suse.de
- Removed openSUSE-Metal theme (bnc #690851)
--
To unsubscribe, e-mail: yast-commit+unsubscribe(a)opensuse.org
For additional commands, e-mail: yast-commit+help(a)opensuse.org
1
0
[yast-commit] r64016 - in /branches/SuSE-Code-11-SP2-Branch/installation: VERSION package/yast2-installation.changes src/include/misc.ycp yast2-installation.spec.in
by aschnell@svn2.opensuse.org 17 May '11
by aschnell@svn2.opensuse.org 17 May '11
17 May '11
Author: aschnell
Date: Tue May 17 14:36:52 2011
New Revision: 64016
URL: http://svn.opensuse.org/viewcvs/yast?rev=64016&view=rev
Log:
- adapted to yast2-storage backport change
Modified:
branches/SuSE-Code-11-SP2-Branch/installation/VERSION
branches/SuSE-Code-11-SP2-Branch/installation/package/yast2-installation.changes
branches/SuSE-Code-11-SP2-Branch/installation/src/include/misc.ycp
branches/SuSE-Code-11-SP2-Branch/installation/yast2-installation.spec.in
Modified: branches/SuSE-Code-11-SP2-Branch/installation/VERSION
URL: http://svn.opensuse.org/viewcvs/yast/branches/SuSE-Code-11-SP2-Branch/insta…
==============================================================================
--- branches/SuSE-Code-11-SP2-Branch/installation/VERSION (original)
+++ branches/SuSE-Code-11-SP2-Branch/installation/VERSION Tue May 17 14:36:52 2011
@@ -1 +1 @@
-2.17.79
+2.17.80
Modified: branches/SuSE-Code-11-SP2-Branch/installation/package/yast2-installation.changes
URL: http://svn.opensuse.org/viewcvs/yast/branches/SuSE-Code-11-SP2-Branch/insta…
==============================================================================
--- branches/SuSE-Code-11-SP2-Branch/installation/package/yast2-installation.changes (original)
+++ branches/SuSE-Code-11-SP2-Branch/installation/package/yast2-installation.changes Tue May 17 14:36:52 2011
@@ -1,4 +1,10 @@
-------------------------------------------------------------------
+Tue May 17 14:33:58 CEST 2011 - aschnell(a)suse.de
+
+- adapted to yast2-storage backport change
+- 2.17.80
+
+-------------------------------------------------------------------
Wed Apr 27 15:09:25 CEST 2011 - jsuchome(a)suse.cz
- added option to configure FCoE Interfaces when started with
Modified: branches/SuSE-Code-11-SP2-Branch/installation/src/include/misc.ycp
URL: http://svn.opensuse.org/viewcvs/yast/branches/SuSE-Code-11-SP2-Branch/insta…
==============================================================================
--- branches/SuSE-Code-11-SP2-Branch/installation/src/include/misc.ycp (original)
+++ branches/SuSE-Code-11-SP2-Branch/installation/src/include/misc.ycp Tue May 17 14:36:52 2011
@@ -139,8 +139,11 @@
// Text for confirmation popup before the installation really starts 1/3
body = _("<p>All information required for the base installation is now complete.</p>");
- map<symbol, any> commit_info = Storage::GetCommitInfo();
- if (commit_info[`destructive]:false)
+ boolean some_destructive = find(map info, Storage::GetCommitInfos(), {
+ return info[`destructive]:false;
+ }) != nil;
+
+ if (some_destructive)
{
// Text for confirmation popup before the installation really starts 2/3
body = body + _("<p>If you continue now, <b>existing
Modified: branches/SuSE-Code-11-SP2-Branch/installation/yast2-installation.spec.in
URL: http://svn.opensuse.org/viewcvs/yast/branches/SuSE-Code-11-SP2-Branch/insta…
==============================================================================
--- branches/SuSE-Code-11-SP2-Branch/installation/yast2-installation.spec.in (original)
+++ branches/SuSE-Code-11-SP2-Branch/installation/yast2-installation.spec.in Tue May 17 14:36:52 2011
@@ -40,8 +40,8 @@
# New API to ProductLicense module
Requires: yast2-packager >= 2.17.64
-# Storage::GetCommitInfo() call in include/misc.ycp
-Requires: yast2-storage >= 2.17.47
+# Storage::GetCommitInfos() call in include/misc.ycp
+Requires: yast2-storage >= 2.17.101
# use in startup scripts
Requires: initviocons
--
To unsubscribe, e-mail: yast-commit+unsubscribe(a)opensuse.org
For additional commands, e-mail: yast-commit+help(a)opensuse.org
1
0
[yast-commit] r64015 - /tags/branch-Code-11-SP2-2_17_0/testsuite/
by fehr@svn2.opensuse.org 17 May '11
by fehr@svn2.opensuse.org 17 May '11
17 May '11
Author: fehr
Date: Tue May 17 14:26:19 2011
New Revision: 64015
URL: http://svn.opensuse.org/viewcvs/yast?rev=64015&view=rev
Log:
Created tag branch-Code-11-SP2-2_17_0 for testsuite
Added:
tags/branch-Code-11-SP2-2_17_0/testsuite/ (props changed)
- copied from r64014, branches/SuSE-Code-11-SP2-Branch/testsuite/
--
To unsubscribe, e-mail: yast-commit+unsubscribe(a)opensuse.org
For additional commands, e-mail: yast-commit+help(a)opensuse.org
1
0
[yast-commit] r64014 - in /branches/SuSE-Code-11-SP1-Branch/testsuite: VERSION package/yast2-testsuite.changes skel/Makefile.testsuite.in skel/runtest.sh skel/testsuite.exp
by fehr@svn2.opensuse.org 17 May '11
by fehr@svn2.opensuse.org 17 May '11
17 May '11
Author: fehr
Date: Tue May 17 14:24:24 2011
New Revision: 64014
URL: http://svn.opensuse.org/viewcvs/yast?rev=64014&view=rev
Log:
revert last change which should go only into SLES11 SP2 branch
Modified:
branches/SuSE-Code-11-SP1-Branch/testsuite/VERSION
branches/SuSE-Code-11-SP1-Branch/testsuite/package/yast2-testsuite.changes
branches/SuSE-Code-11-SP1-Branch/testsuite/skel/Makefile.testsuite.in
branches/SuSE-Code-11-SP1-Branch/testsuite/skel/runtest.sh
branches/SuSE-Code-11-SP1-Branch/testsuite/skel/testsuite.exp
Modified: branches/SuSE-Code-11-SP1-Branch/testsuite/VERSION
URL: http://svn.opensuse.org/viewcvs/yast/branches/SuSE-Code-11-SP1-Branch/tests…
==============================================================================
--- branches/SuSE-Code-11-SP1-Branch/testsuite/VERSION (original)
+++ branches/SuSE-Code-11-SP1-Branch/testsuite/VERSION Tue May 17 14:24:24 2011
@@ -1 +1 @@
-2.17.0
+2.16.2
Modified: branches/SuSE-Code-11-SP1-Branch/testsuite/package/yast2-testsuite.changes
URL: http://svn.opensuse.org/viewcvs/yast/branches/SuSE-Code-11-SP1-Branch/tests…
==============================================================================
--- branches/SuSE-Code-11-SP1-Branch/testsuite/package/yast2-testsuite.changes (original)
+++ branches/SuSE-Code-11-SP1-Branch/testsuite/package/yast2-testsuite.changes Tue May 17 14:24:24 2011
@@ -1,13 +1,4 @@
-------------------------------------------------------------------
-Tue May 17 11:16:32 CEST 2011 - fehr(a)suse.de
-
-- backport changes by Arvin needed for ycp testsuite in storage
-- don't override Makefile.am
-- extended runtest.sh
-- run all tests even if some fail
-- 2.17.0
-
--------------------------------------------------------------------
Tue Apr 8 13:09:41 CEST 2008 - mvidner(a)suse.cz
- Enable make check before make install, by telling y2base to search
Modified: branches/SuSE-Code-11-SP1-Branch/testsuite/skel/Makefile.testsuite.in
URL: http://svn.opensuse.org/viewcvs/yast/branches/SuSE-Code-11-SP1-Branch/tests…
==============================================================================
--- branches/SuSE-Code-11-SP1-Branch/testsuite/skel/Makefile.testsuite.in (original)
+++ branches/SuSE-Code-11-SP1-Branch/testsuite/skel/Makefile.testsuite.in Tue May 17 14:24:24 2011
@@ -14,7 +14,7 @@
files_config=$(srcdir)/config/default.exp $(srcdir)/config/unix.exp $(srcdir)/config/unknown.exp
files_run=$(srcdir)/run/runtest.sh
files_test=$(srcdir)/$(RPMNAME).test/testsuite.exp
-files_tmpl=$(srcdir)/.cvsignore
+files_tmpl=$(srcdir)/Makefile.am $(srcdir)/.cvsignore
files_all=$(files_config) $(files_test) $(files_tmpl) $(files_run)
all: $(files_all) $(testsuite_dirs)
@@ -28,8 +28,11 @@
# Overwrite the tested package's testsuite/Makefile.am only
# if the template file is newer in content (which shouldn't
# happen as it is only a proxy). Prevents automake mismatch errors.
-#$(srcdir)/Makefile.am: $(skeldir)/Makefile_am
-# cmp -s $< $@ || cp -f $< $@
+$(srcdir)/Makefile.am: $(skeldir)/Makefile_am
+ cmp -s $< $@ || cp -f $< $@
+
+$(srcdir)/.cvsignore: $(skeldir)/_cvsignore
+ cp -f $< $@
$(srcdir)/run/runtest.sh: $(skeldir)/runtest.sh run
cp -f $< $@
Modified: branches/SuSE-Code-11-SP1-Branch/testsuite/skel/runtest.sh
URL: http://svn.opensuse.org/viewcvs/yast/branches/SuSE-Code-11-SP1-Branch/tests…
==============================================================================
--- branches/SuSE-Code-11-SP1-Branch/testsuite/skel/runtest.sh (original)
+++ branches/SuSE-Code-11-SP1-Branch/testsuite/skel/runtest.sh Tue May 17 14:24:24 2011
@@ -77,7 +77,7 @@
rm -f "$file"
}
-( Y2DIR=$Y2DIR:$Y2BASE_Y2DIR LD_LIBRARY_PATH=$Y2BASE_LD_LIBRARY_PATH $Y2BASE -l - -c "$logconf" $Y2BASEFLAGS $OPTIONS "$1" UI 2>&1 ) | parse >"$2" 2>"$3"
+( $Y2BASE -l - -c "$logconf" $OPTIONS "$1" UI 2>&1 ) | parse >"$2" 2>"$3"
retcode="$PIPESTATUS"
if [ "$retcode" -gt 0 ]; then
Modified: branches/SuSE-Code-11-SP1-Branch/testsuite/skel/testsuite.exp
URL: http://svn.opensuse.org/viewcvs/yast/branches/SuSE-Code-11-SP1-Branch/tests…
==============================================================================
--- branches/SuSE-Code-11-SP1-Branch/testsuite/skel/testsuite.exp (original)
+++ branches/SuSE-Code-11-SP1-Branch/testsuite/skel/testsuite.exp Tue May 17 14:24:24 2011
@@ -19,6 +19,10 @@
puts "\nChecking started\n"
-foreach file $filenames { testsuite-run $file }
+foreach file $filenames {
+ if {[testsuite-run $file] < 0} {
+ return
+ }
+}
puts "\nChecking finished\n"
--
To unsubscribe, e-mail: yast-commit+unsubscribe(a)opensuse.org
For additional commands, e-mail: yast-commit+help(a)opensuse.org
1
0
[yast-commit] r64013 - /branches/SuSE-Code-11-SP2-Branch/testsuite/
by fehr@svn2.opensuse.org 17 May '11
by fehr@svn2.opensuse.org 17 May '11
17 May '11
Author: fehr
Date: Tue May 17 14:21:23 2011
New Revision: 64013
URL: http://svn.opensuse.org/viewcvs/yast?rev=64013&view=rev
Log:
copy to SP2 branch
Added:
branches/SuSE-Code-11-SP2-Branch/testsuite/ (props changed)
- copied from r64012, branches/SuSE-Code-11-SP1-Branch/testsuite/
--
To unsubscribe, e-mail: yast-commit+unsubscribe(a)opensuse.org
For additional commands, e-mail: yast-commit+help(a)opensuse.org
1
0
[yast-commit] r64012 - in /branches/SuSE-Code-11-SP2-Branch/storage: ./ disk/src/ libstorage/bindings/python/ libstorage/bindings/ycp/ libstorage/examples/ libstorage/src/ libstorage/testsuite/ libstorage/testsu...
by fehr@svn2.opensuse.org 17 May '11
by fehr@svn2.opensuse.org 17 May '11
17 May '11
Author: fehr
Date: Tue May 17 13:39:44 2011
New Revision: 64012
URL: http://svn.opensuse.org/viewcvs/yast?rev=64012&view=rev
Log:
- huge backport from svn and git head for lots of features
in SLES11 SP2 (e.g. fate#307741, fate#311015, fate#310223,
fate#303810, fate#306587l, fate#306960)
- version 2.17.101
Added:
branches/SuSE-Code-11-SP2-Branch/storage/libstorage/examples/SaveGraph.cc
branches/SuSE-Code-11-SP2-Branch/storage/libstorage/examples/ShowBytes.cc
branches/SuSE-Code-11-SP2-Branch/storage/libstorage/src/ArchInfo.cc
branches/SuSE-Code-11-SP2-Branch/storage/libstorage/src/ArchInfo.h
branches/SuSE-Code-11-SP2-Branch/storage/libstorage/src/Blkid.cc
branches/SuSE-Code-11-SP2-Branch/storage/libstorage/src/Blkid.h
branches/SuSE-Code-11-SP2-Branch/storage/libstorage/src/Btrfs.cc
branches/SuSE-Code-11-SP2-Branch/storage/libstorage/src/Btrfs.h
branches/SuSE-Code-11-SP2-Branch/storage/libstorage/src/BtrfsCo.cc
branches/SuSE-Code-11-SP2-Branch/storage/libstorage/src/BtrfsCo.h
branches/SuSE-Code-11-SP2-Branch/storage/libstorage/src/Dasdview.cc
branches/SuSE-Code-11-SP2-Branch/storage/libstorage/src/Dasdview.h
branches/SuSE-Code-11-SP2-Branch/storage/libstorage/src/Device.cc
branches/SuSE-Code-11-SP2-Branch/storage/libstorage/src/Device.h
branches/SuSE-Code-11-SP2-Branch/storage/libstorage/src/Enum.cc
branches/SuSE-Code-11-SP2-Branch/storage/libstorage/src/Enum.h
branches/SuSE-Code-11-SP2-Branch/storage/libstorage/src/EtcMdadm.cc
branches/SuSE-Code-11-SP2-Branch/storage/libstorage/src/EtcMdadm.h
branches/SuSE-Code-11-SP2-Branch/storage/libstorage/src/FreeInfo.cc
branches/SuSE-Code-11-SP2-Branch/storage/libstorage/src/FreeInfo.h
branches/SuSE-Code-11-SP2-Branch/storage/libstorage/src/Geometry.cc
branches/SuSE-Code-11-SP2-Branch/storage/libstorage/src/Geometry.h
branches/SuSE-Code-11-SP2-Branch/storage/libstorage/src/Graph.cc
branches/SuSE-Code-11-SP2-Branch/storage/libstorage/src/Graph.h
branches/SuSE-Code-11-SP2-Branch/storage/libstorage/src/HumanString.cc
branches/SuSE-Code-11-SP2-Branch/storage/libstorage/src/HumanString.h
branches/SuSE-Code-11-SP2-Branch/storage/libstorage/src/Lsscsi.cc
branches/SuSE-Code-11-SP2-Branch/storage/libstorage/src/Lsscsi.h
branches/SuSE-Code-11-SP2-Branch/storage/libstorage/src/Parted.cc
branches/SuSE-Code-11-SP2-Branch/storage/libstorage/src/Parted.h
branches/SuSE-Code-11-SP2-Branch/storage/libstorage/src/ProcMdstat.cc
branches/SuSE-Code-11-SP2-Branch/storage/libstorage/src/ProcMdstat.h
branches/SuSE-Code-11-SP2-Branch/storage/libstorage/src/ProcParts.cc
branches/SuSE-Code-11-SP2-Branch/storage/libstorage/src/ProcParts.h
branches/SuSE-Code-11-SP2-Branch/storage/libstorage/src/Region.cc
branches/SuSE-Code-11-SP2-Branch/storage/libstorage/src/SystemInfo.cc
branches/SuSE-Code-11-SP2-Branch/storage/libstorage/src/SystemInfo.h
branches/SuSE-Code-11-SP2-Branch/storage/libstorage/src/Tmpfs.cc
branches/SuSE-Code-11-SP2-Branch/storage/libstorage/src/Tmpfs.h
branches/SuSE-Code-11-SP2-Branch/storage/libstorage/src/TmpfsCo.cc
branches/SuSE-Code-11-SP2-Branch/storage/libstorage/src/TmpfsCo.h
branches/SuSE-Code-11-SP2-Branch/storage/libstorage/src/XmlFile.cc
branches/SuSE-Code-11-SP2-Branch/storage/libstorage/src/XmlFile.h
branches/SuSE-Code-11-SP2-Branch/storage/libstorage/testsuite/backupstate1.cc
branches/SuSE-Code-11-SP2-Branch/storage/libstorage/testsuite/common.cc
branches/SuSE-Code-11-SP2-Branch/storage/libstorage/testsuite/contvolinfo1.cc
branches/SuSE-Code-11-SP2-Branch/storage/libstorage/testsuite/data/empty/
branches/SuSE-Code-11-SP2-Branch/storage/libstorage/testsuite/data/empty/Makefile.am
branches/SuSE-Code-11-SP2-Branch/storage/libstorage/testsuite/data/empty/disk_sda.info
branches/SuSE-Code-11-SP2-Branch/storage/libstorage/testsuite/data/scandium/
branches/SuSE-Code-11-SP2-Branch/storage/libstorage/testsuite/data/scandium/Makefile.am
branches/SuSE-Code-11-SP2-Branch/storage/libstorage/testsuite/data/scandium/arch.info
branches/SuSE-Code-11-SP2-Branch/storage/libstorage/testsuite/data/scandium/disk_sda.info
branches/SuSE-Code-11-SP2-Branch/storage/libstorage/testsuite/data/thalassa/
branches/SuSE-Code-11-SP2-Branch/storage/libstorage/testsuite/data/thalassa/Makefile.am
branches/SuSE-Code-11-SP2-Branch/storage/libstorage/testsuite/data/thalassa/disk_sda.info
branches/SuSE-Code-11-SP2-Branch/storage/libstorage/testsuite/data/thalassa/disk_sdb.info
branches/SuSE-Code-11-SP2-Branch/storage/libstorage/testsuite/data/thalassa/disk_sdc.info
branches/SuSE-Code-11-SP2-Branch/storage/libstorage/testsuite/data/thalassa/free.info
branches/SuSE-Code-11-SP2-Branch/storage/libstorage/testsuite/data/thalassa/lvmvg_system.info
branches/SuSE-Code-11-SP2-Branch/storage/libstorage/testsuite/disklabel1.cc
branches/SuSE-Code-11-SP2-Branch/storage/libstorage/testsuite/freeinfo1.cc
branches/SuSE-Code-11-SP2-Branch/storage/libstorage/testsuite/fstab2.cc
branches/SuSE-Code-11-SP2-Branch/storage/libstorage/testsuite/fstab3.cc
branches/SuSE-Code-11-SP2-Branch/storage/libstorage/testsuite/fstab4.cc
branches/SuSE-Code-11-SP2-Branch/storage/libstorage/testsuite/lvm_create2.cc
branches/SuSE-Code-11-SP2-Branch/storage/libstorage/testsuite/partitionname.cc
branches/SuSE-Code-11-SP2-Branch/storage/libstorage/testsuite/partitionprefix.cc
branches/SuSE-Code-11-SP2-Branch/storage/libstorage/testsuite/recursive1.cc
branches/SuSE-Code-11-SP2-Branch/storage/libstorage/testsuite/recursive2.cc
branches/SuSE-Code-11-SP2-Branch/storage/libstorage/testsuite/renumber1.cc
branches/SuSE-Code-11-SP2-Branch/storage/libstorage/testsuite/renumber2.cc
branches/SuSE-Code-11-SP2-Branch/storage/libstorage/testsuite/renumber3.cc
branches/SuSE-Code-11-SP2-Branch/storage/libstorage/testsuite/single.out/backupstate1.err
branches/SuSE-Code-11-SP2-Branch/storage/libstorage/testsuite/single.out/backupstate1.out
branches/SuSE-Code-11-SP2-Branch/storage/libstorage/testsuite/single.out/contvolinfo1.err
branches/SuSE-Code-11-SP2-Branch/storage/libstorage/testsuite/single.out/contvolinfo1.out
branches/SuSE-Code-11-SP2-Branch/storage/libstorage/testsuite/single.out/disklabel1.err
branches/SuSE-Code-11-SP2-Branch/storage/libstorage/testsuite/single.out/disklabel1.out
branches/SuSE-Code-11-SP2-Branch/storage/libstorage/testsuite/single.out/freeinfo1.err
branches/SuSE-Code-11-SP2-Branch/storage/libstorage/testsuite/single.out/freeinfo1.out
branches/SuSE-Code-11-SP2-Branch/storage/libstorage/testsuite/single.out/fstab2.err
branches/SuSE-Code-11-SP2-Branch/storage/libstorage/testsuite/single.out/fstab2.out
branches/SuSE-Code-11-SP2-Branch/storage/libstorage/testsuite/single.out/fstab3.err
branches/SuSE-Code-11-SP2-Branch/storage/libstorage/testsuite/single.out/fstab3.out
branches/SuSE-Code-11-SP2-Branch/storage/libstorage/testsuite/single.out/fstab4.err
branches/SuSE-Code-11-SP2-Branch/storage/libstorage/testsuite/single.out/fstab4.out
branches/SuSE-Code-11-SP2-Branch/storage/libstorage/testsuite/single.out/lvm_create2.err
branches/SuSE-Code-11-SP2-Branch/storage/libstorage/testsuite/single.out/lvm_create2.out
branches/SuSE-Code-11-SP2-Branch/storage/libstorage/testsuite/single.out/partitionname.err
branches/SuSE-Code-11-SP2-Branch/storage/libstorage/testsuite/single.out/partitionname.out
branches/SuSE-Code-11-SP2-Branch/storage/libstorage/testsuite/single.out/partitionprefix.err
branches/SuSE-Code-11-SP2-Branch/storage/libstorage/testsuite/single.out/partitionprefix.out
branches/SuSE-Code-11-SP2-Branch/storage/libstorage/testsuite/single.out/recursive1.err
branches/SuSE-Code-11-SP2-Branch/storage/libstorage/testsuite/single.out/recursive1.out
branches/SuSE-Code-11-SP2-Branch/storage/libstorage/testsuite/single.out/recursive2.err
branches/SuSE-Code-11-SP2-Branch/storage/libstorage/testsuite/single.out/recursive2.out
branches/SuSE-Code-11-SP2-Branch/storage/libstorage/testsuite/single.out/renumber1.err
branches/SuSE-Code-11-SP2-Branch/storage/libstorage/testsuite/single.out/renumber1.out
branches/SuSE-Code-11-SP2-Branch/storage/libstorage/testsuite/single.out/renumber2.err
branches/SuSE-Code-11-SP2-Branch/storage/libstorage/testsuite/single.out/renumber2.out
branches/SuSE-Code-11-SP2-Branch/storage/libstorage/testsuite/single.out/renumber3.err
branches/SuSE-Code-11-SP2-Branch/storage/libstorage/testsuite/single.out/renumber3.out
branches/SuSE-Code-11-SP2-Branch/storage/libstorage/testsuite/single.out/udevdecode.err
branches/SuSE-Code-11-SP2-Branch/storage/libstorage/testsuite/single.out/udevdecode.out
branches/SuSE-Code-11-SP2-Branch/storage/libstorage/testsuite/single.out/udevencode.err
branches/SuSE-Code-11-SP2-Branch/storage/libstorage/testsuite/single.out/udevencode.out
branches/SuSE-Code-11-SP2-Branch/storage/libstorage/testsuite/single.out/usedby1.err
branches/SuSE-Code-11-SP2-Branch/storage/libstorage/testsuite/single.out/usedby1.out
branches/SuSE-Code-11-SP2-Branch/storage/libstorage/testsuite/udevdecode.cc
branches/SuSE-Code-11-SP2-Branch/storage/libstorage/testsuite/udevencode.cc
branches/SuSE-Code-11-SP2-Branch/storage/libstorage/testsuite/usedby1.cc
branches/SuSE-Code-11-SP2-Branch/storage/storage/src/include/ep-btrfs-dialogs.ycp
branches/SuSE-Code-11-SP2-Branch/storage/storage/src/include/ep-btrfs-lib.ycp
branches/SuSE-Code-11-SP2-Branch/storage/storage/src/include/ep-btrfs.ycp
branches/SuSE-Code-11-SP2-Branch/storage/storage/src/include/ep-graph.ycp
branches/SuSE-Code-11-SP2-Branch/storage/storage/src/include/ep-import.ycp
branches/SuSE-Code-11-SP2-Branch/storage/storage/src/include/ep-summary.ycp
branches/SuSE-Code-11-SP2-Branch/storage/storage/src/include/ep-tmpfs-dialogs.ycp
branches/SuSE-Code-11-SP2-Branch/storage/storage/src/include/ep-tmpfs-lib.ycp
branches/SuSE-Code-11-SP2-Branch/storage/storage/src/include/ep-tmpfs.ycp
branches/SuSE-Code-11-SP2-Branch/storage/storage/src/inst_resize_dialog.ycp
branches/SuSE-Code-11-SP2-Branch/storage/storage/src/modules/StorageIcons.ycp
branches/SuSE-Code-11-SP2-Branch/storage/storage/src/modules/StorageProposal.ycp
branches/SuSE-Code-11-SP2-Branch/storage/storage/src/modules/StorageUpdate.ycp
branches/SuSE-Code-11-SP2-Branch/storage/storage/src/testsuite/Makefile.am
branches/SuSE-Code-11-SP2-Branch/storage/storage/src/testsuite/README
branches/SuSE-Code-11-SP2-Branch/storage/storage/src/testsuite/data/Makefile.am
branches/SuSE-Code-11-SP2-Branch/storage/storage/src/testsuite/data/empty/
branches/SuSE-Code-11-SP2-Branch/storage/storage/src/testsuite/data/empty-efi/
branches/SuSE-Code-11-SP2-Branch/storage/storage/src/testsuite/data/empty-efi/Makefile.am
branches/SuSE-Code-11-SP2-Branch/storage/storage/src/testsuite/data/empty-efi/arch.info
branches/SuSE-Code-11-SP2-Branch/storage/storage/src/testsuite/data/empty-efi/disk_sda.info
branches/SuSE-Code-11-SP2-Branch/storage/storage/src/testsuite/data/empty/Makefile.am
branches/SuSE-Code-11-SP2-Branch/storage/storage/src/testsuite/data/empty/disk_sda.info
branches/SuSE-Code-11-SP2-Branch/storage/storage/src/testsuite/data/half-empty/
branches/SuSE-Code-11-SP2-Branch/storage/storage/src/testsuite/data/half-empty/Makefile.am
branches/SuSE-Code-11-SP2-Branch/storage/storage/src/testsuite/data/half-empty/disk_sda.info
branches/SuSE-Code-11-SP2-Branch/storage/storage/src/testsuite/data/reuse-home/
branches/SuSE-Code-11-SP2-Branch/storage/storage/src/testsuite/data/reuse-home/Makefile.am
branches/SuSE-Code-11-SP2-Branch/storage/storage/src/testsuite/data/reuse-home/disk_sda.info
branches/SuSE-Code-11-SP2-Branch/storage/storage/src/testsuite/data/reuse-home/free.info
branches/SuSE-Code-11-SP2-Branch/storage/storage/src/testsuite/data/windows/
branches/SuSE-Code-11-SP2-Branch/storage/storage/src/testsuite/data/windows-only/
branches/SuSE-Code-11-SP2-Branch/storage/storage/src/testsuite/data/windows-only/Makefile.am
branches/SuSE-Code-11-SP2-Branch/storage/storage/src/testsuite/data/windows-only/disk_sda.info
branches/SuSE-Code-11-SP2-Branch/storage/storage/src/testsuite/data/windows-only/free.info
branches/SuSE-Code-11-SP2-Branch/storage/storage/src/testsuite/data/windows/Makefile.am
branches/SuSE-Code-11-SP2-Branch/storage/storage/src/testsuite/data/windows/disk_sda.info
branches/SuSE-Code-11-SP2-Branch/storage/storage/src/testsuite/data/windows/free.info
branches/SuSE-Code-11-SP2-Branch/storage/storage/src/testsuite/lib/test.exp
branches/SuSE-Code-11-SP2-Branch/storage/storage/src/testsuite/lib/test_init.exp
branches/SuSE-Code-11-SP2-Branch/storage/storage/src/testsuite/tests/empty-efi1.err
branches/SuSE-Code-11-SP2-Branch/storage/storage/src/testsuite/tests/empty-efi1.out
branches/SuSE-Code-11-SP2-Branch/storage/storage/src/testsuite/tests/empty-efi1.ycp
branches/SuSE-Code-11-SP2-Branch/storage/storage/src/testsuite/tests/empty-efi2.err
branches/SuSE-Code-11-SP2-Branch/storage/storage/src/testsuite/tests/empty-efi2.out
branches/SuSE-Code-11-SP2-Branch/storage/storage/src/testsuite/tests/empty-efi2.ycp
branches/SuSE-Code-11-SP2-Branch/storage/storage/src/testsuite/tests/empty1.err
branches/SuSE-Code-11-SP2-Branch/storage/storage/src/testsuite/tests/empty1.out
branches/SuSE-Code-11-SP2-Branch/storage/storage/src/testsuite/tests/empty1.ycp
branches/SuSE-Code-11-SP2-Branch/storage/storage/src/testsuite/tests/empty2.err
branches/SuSE-Code-11-SP2-Branch/storage/storage/src/testsuite/tests/empty2.out
branches/SuSE-Code-11-SP2-Branch/storage/storage/src/testsuite/tests/empty2.ycp
branches/SuSE-Code-11-SP2-Branch/storage/storage/src/testsuite/tests/empty3.err
branches/SuSE-Code-11-SP2-Branch/storage/storage/src/testsuite/tests/empty3.out
branches/SuSE-Code-11-SP2-Branch/storage/storage/src/testsuite/tests/empty3.ycp
branches/SuSE-Code-11-SP2-Branch/storage/storage/src/testsuite/tests/empty4.err
branches/SuSE-Code-11-SP2-Branch/storage/storage/src/testsuite/tests/empty4.out
branches/SuSE-Code-11-SP2-Branch/storage/storage/src/testsuite/tests/empty4.ycp
branches/SuSE-Code-11-SP2-Branch/storage/storage/src/testsuite/tests/empty5.err
branches/SuSE-Code-11-SP2-Branch/storage/storage/src/testsuite/tests/empty5.out
branches/SuSE-Code-11-SP2-Branch/storage/storage/src/testsuite/tests/empty5.ycp
branches/SuSE-Code-11-SP2-Branch/storage/storage/src/testsuite/tests/empty6.err
branches/SuSE-Code-11-SP2-Branch/storage/storage/src/testsuite/tests/empty6.out
branches/SuSE-Code-11-SP2-Branch/storage/storage/src/testsuite/tests/empty6.ycp
branches/SuSE-Code-11-SP2-Branch/storage/storage/src/testsuite/tests/half-empty1.err
branches/SuSE-Code-11-SP2-Branch/storage/storage/src/testsuite/tests/half-empty1.out
branches/SuSE-Code-11-SP2-Branch/storage/storage/src/testsuite/tests/half-empty1.ycp
branches/SuSE-Code-11-SP2-Branch/storage/storage/src/testsuite/tests/helper1a.yh
branches/SuSE-Code-11-SP2-Branch/storage/storage/src/testsuite/tests/helper1b.yh
branches/SuSE-Code-11-SP2-Branch/storage/storage/src/testsuite/tests/reuse-home1.err
branches/SuSE-Code-11-SP2-Branch/storage/storage/src/testsuite/tests/reuse-home1.out
branches/SuSE-Code-11-SP2-Branch/storage/storage/src/testsuite/tests/reuse-home1.ycp
branches/SuSE-Code-11-SP2-Branch/storage/storage/src/testsuite/tests/setup-system.yh
branches/SuSE-Code-11-SP2-Branch/storage/storage/src/testsuite/tests/windows-only1.err
branches/SuSE-Code-11-SP2-Branch/storage/storage/src/testsuite/tests/windows-only1.out
branches/SuSE-Code-11-SP2-Branch/storage/storage/src/testsuite/tests/windows-only1.ycp
branches/SuSE-Code-11-SP2-Branch/storage/storage/src/testsuite/tests/windows1.err
branches/SuSE-Code-11-SP2-Branch/storage/storage/src/testsuite/tests/windows1.out
branches/SuSE-Code-11-SP2-Branch/storage/storage/src/testsuite/tests/windows1.ycp
Removed:
branches/SuSE-Code-11-SP2-Branch/storage/libstorage/src/ProcPart.cc
branches/SuSE-Code-11-SP2-Branch/storage/libstorage/src/ProcPart.h
branches/SuSE-Code-11-SP2-Branch/storage/libstorage/testsuite/data/disk_hda
branches/SuSE-Code-11-SP2-Branch/storage/libstorage/testsuite/data/disk_hdb
branches/SuSE-Code-11-SP2-Branch/storage/libstorage/testsuite/data/disk_sda
branches/SuSE-Code-11-SP2-Branch/storage/libstorage/testsuite/data/disk_sdb
branches/SuSE-Code-11-SP2-Branch/storage/libstorage/testsuite/data/volume_info
branches/SuSE-Code-11-SP2-Branch/storage/storage/src/inst_do_resize.ycp
branches/SuSE-Code-11-SP2-Branch/storage/storage/src/testsuite/tests/auto_part_functions.ycp
branches/SuSE-Code-11-SP2-Branch/storage/storage/src/testsuite/tests/size_calculations.ycp
branches/SuSE-Code-11-SP2-Branch/storage/storage/src/testsuite/tests/test_inst_target_part.ycp
Modified:
branches/SuSE-Code-11-SP2-Branch/storage/ (props changed)
branches/SuSE-Code-11-SP2-Branch/storage/VERSION
branches/SuSE-Code-11-SP2-Branch/storage/disk/src/disk_worker.ycp
branches/SuSE-Code-11-SP2-Branch/storage/libstorage/bindings/python/LibStorage.i
branches/SuSE-Code-11-SP2-Branch/storage/libstorage/bindings/python/Makefile
branches/SuSE-Code-11-SP2-Branch/storage/libstorage/bindings/ycp/LibStorage.i
branches/SuSE-Code-11-SP2-Branch/storage/libstorage/examples/ (props changed)
branches/SuSE-Code-11-SP2-Branch/storage/libstorage/examples/Makefile.am
branches/SuSE-Code-11-SP2-Branch/storage/libstorage/examples/TestLock.cc
branches/SuSE-Code-11-SP2-Branch/storage/libstorage/examples/TestLoop.cc
branches/SuSE-Code-11-SP2-Branch/storage/libstorage/examples/TestLvm.cc
branches/SuSE-Code-11-SP2-Branch/storage/libstorage/examples/TestMd.cc
branches/SuSE-Code-11-SP2-Branch/storage/libstorage/examples/TestProbing.cc
branches/SuSE-Code-11-SP2-Branch/storage/libstorage/examples/TestStorage.cc
branches/SuSE-Code-11-SP2-Branch/storage/libstorage/src/ (props changed)
branches/SuSE-Code-11-SP2-Branch/storage/libstorage/src/AppUtil.cc
branches/SuSE-Code-11-SP2-Branch/storage/libstorage/src/AppUtil.h
branches/SuSE-Code-11-SP2-Branch/storage/libstorage/src/AsciiFile.cc
branches/SuSE-Code-11-SP2-Branch/storage/libstorage/src/AsciiFile.h
branches/SuSE-Code-11-SP2-Branch/storage/libstorage/src/Container.cc
branches/SuSE-Code-11-SP2-Branch/storage/libstorage/src/Container.h
branches/SuSE-Code-11-SP2-Branch/storage/libstorage/src/Dasd.cc
branches/SuSE-Code-11-SP2-Branch/storage/libstorage/src/Dasd.h
branches/SuSE-Code-11-SP2-Branch/storage/libstorage/src/DerefIterator.h
branches/SuSE-Code-11-SP2-Branch/storage/libstorage/src/Disk.cc
branches/SuSE-Code-11-SP2-Branch/storage/libstorage/src/Disk.h
branches/SuSE-Code-11-SP2-Branch/storage/libstorage/src/Dm.cc
branches/SuSE-Code-11-SP2-Branch/storage/libstorage/src/Dm.h
branches/SuSE-Code-11-SP2-Branch/storage/libstorage/src/DmCo.cc
branches/SuSE-Code-11-SP2-Branch/storage/libstorage/src/DmCo.h
branches/SuSE-Code-11-SP2-Branch/storage/libstorage/src/DmPart.cc
branches/SuSE-Code-11-SP2-Branch/storage/libstorage/src/DmPart.h
branches/SuSE-Code-11-SP2-Branch/storage/libstorage/src/DmPartCo.cc
branches/SuSE-Code-11-SP2-Branch/storage/libstorage/src/DmPartCo.h
branches/SuSE-Code-11-SP2-Branch/storage/libstorage/src/Dmmultipath.cc
branches/SuSE-Code-11-SP2-Branch/storage/libstorage/src/Dmmultipath.h
branches/SuSE-Code-11-SP2-Branch/storage/libstorage/src/DmmultipathCo.cc
branches/SuSE-Code-11-SP2-Branch/storage/libstorage/src/DmmultipathCo.h
branches/SuSE-Code-11-SP2-Branch/storage/libstorage/src/Dmraid.cc
branches/SuSE-Code-11-SP2-Branch/storage/libstorage/src/Dmraid.h
branches/SuSE-Code-11-SP2-Branch/storage/libstorage/src/DmraidCo.cc
branches/SuSE-Code-11-SP2-Branch/storage/libstorage/src/DmraidCo.h
branches/SuSE-Code-11-SP2-Branch/storage/libstorage/src/EtcFstab.cc
branches/SuSE-Code-11-SP2-Branch/storage/libstorage/src/EtcFstab.h
branches/SuSE-Code-11-SP2-Branch/storage/libstorage/src/FilterIterator.h
branches/SuSE-Code-11-SP2-Branch/storage/libstorage/src/IterPair.h
branches/SuSE-Code-11-SP2-Branch/storage/libstorage/src/ListListIterator.h
branches/SuSE-Code-11-SP2-Branch/storage/libstorage/src/Lock.cc
branches/SuSE-Code-11-SP2-Branch/storage/libstorage/src/Lock.h
branches/SuSE-Code-11-SP2-Branch/storage/libstorage/src/Loop.cc
branches/SuSE-Code-11-SP2-Branch/storage/libstorage/src/Loop.h
branches/SuSE-Code-11-SP2-Branch/storage/libstorage/src/LoopCo.cc
branches/SuSE-Code-11-SP2-Branch/storage/libstorage/src/LoopCo.h
branches/SuSE-Code-11-SP2-Branch/storage/libstorage/src/LvmLv.cc
branches/SuSE-Code-11-SP2-Branch/storage/libstorage/src/LvmLv.h
branches/SuSE-Code-11-SP2-Branch/storage/libstorage/src/LvmVg.cc
branches/SuSE-Code-11-SP2-Branch/storage/libstorage/src/LvmVg.h
branches/SuSE-Code-11-SP2-Branch/storage/libstorage/src/Makefile.am
branches/SuSE-Code-11-SP2-Branch/storage/libstorage/src/Md.cc
branches/SuSE-Code-11-SP2-Branch/storage/libstorage/src/Md.h
branches/SuSE-Code-11-SP2-Branch/storage/libstorage/src/MdCo.cc
branches/SuSE-Code-11-SP2-Branch/storage/libstorage/src/MdCo.h
branches/SuSE-Code-11-SP2-Branch/storage/libstorage/src/MdPart.cc
branches/SuSE-Code-11-SP2-Branch/storage/libstorage/src/MdPart.h
branches/SuSE-Code-11-SP2-Branch/storage/libstorage/src/MdPartCo.cc
branches/SuSE-Code-11-SP2-Branch/storage/libstorage/src/MdPartCo.h
branches/SuSE-Code-11-SP2-Branch/storage/libstorage/src/Nfs.cc
branches/SuSE-Code-11-SP2-Branch/storage/libstorage/src/Nfs.h
branches/SuSE-Code-11-SP2-Branch/storage/libstorage/src/NfsCo.cc
branches/SuSE-Code-11-SP2-Branch/storage/libstorage/src/NfsCo.h
branches/SuSE-Code-11-SP2-Branch/storage/libstorage/src/OutputProcessor.cc
branches/SuSE-Code-11-SP2-Branch/storage/libstorage/src/OutputProcessor.h
branches/SuSE-Code-11-SP2-Branch/storage/libstorage/src/Partition.cc
branches/SuSE-Code-11-SP2-Branch/storage/libstorage/src/Partition.h
branches/SuSE-Code-11-SP2-Branch/storage/libstorage/src/PeContainer.cc
branches/SuSE-Code-11-SP2-Branch/storage/libstorage/src/PeContainer.h
branches/SuSE-Code-11-SP2-Branch/storage/libstorage/src/ProcMounts.cc
branches/SuSE-Code-11-SP2-Branch/storage/libstorage/src/ProcMounts.h
branches/SuSE-Code-11-SP2-Branch/storage/libstorage/src/Regex.cc
branches/SuSE-Code-11-SP2-Branch/storage/libstorage/src/Regex.h
branches/SuSE-Code-11-SP2-Branch/storage/libstorage/src/Region.h
branches/SuSE-Code-11-SP2-Branch/storage/libstorage/src/Storage.cc
branches/SuSE-Code-11-SP2-Branch/storage/libstorage/src/Storage.h
branches/SuSE-Code-11-SP2-Branch/storage/libstorage/src/StorageCallbacks.cc
branches/SuSE-Code-11-SP2-Branch/storage/libstorage/src/StorageCallbacks.h
branches/SuSE-Code-11-SP2-Branch/storage/libstorage/src/StorageDefines.h
branches/SuSE-Code-11-SP2-Branch/storage/libstorage/src/StorageInterface.h
branches/SuSE-Code-11-SP2-Branch/storage/libstorage/src/StorageTmpl.h
branches/SuSE-Code-11-SP2-Branch/storage/libstorage/src/StorageTypes.cc
branches/SuSE-Code-11-SP2-Branch/storage/libstorage/src/StorageTypes.h
branches/SuSE-Code-11-SP2-Branch/storage/libstorage/src/SystemCmd.cc
branches/SuSE-Code-11-SP2-Branch/storage/libstorage/src/SystemCmd.h
branches/SuSE-Code-11-SP2-Branch/storage/libstorage/src/Volume.cc
branches/SuSE-Code-11-SP2-Branch/storage/libstorage/src/Volume.h
branches/SuSE-Code-11-SP2-Branch/storage/libstorage/testsuite/Makefile.am
branches/SuSE-Code-11-SP2-Branch/storage/libstorage/testsuite/common.h
branches/SuSE-Code-11-SP2-Branch/storage/libstorage/testsuite/data/Makefile.am
branches/SuSE-Code-11-SP2-Branch/storage/libstorage/testsuite/format1.cc
branches/SuSE-Code-11-SP2-Branch/storage/libstorage/testsuite/fstab1.cc
branches/SuSE-Code-11-SP2-Branch/storage/libstorage/testsuite/humanstring1.cc
branches/SuSE-Code-11-SP2-Branch/storage/libstorage/testsuite/humanstring2.cc
branches/SuSE-Code-11-SP2-Branch/storage/libstorage/testsuite/lvm_create.cc
branches/SuSE-Code-11-SP2-Branch/storage/libstorage/testsuite/lvm_extend.cc
branches/SuSE-Code-11-SP2-Branch/storage/libstorage/testsuite/md_create.cc
branches/SuSE-Code-11-SP2-Branch/storage/libstorage/testsuite/partition1.cc
branches/SuSE-Code-11-SP2-Branch/storage/libstorage/testsuite/single.out/format1.out
branches/SuSE-Code-11-SP2-Branch/storage/libstorage/testsuite/single.out/humanstring1.out
branches/SuSE-Code-11-SP2-Branch/storage/libstorage/testsuite/single.out/humanstring2.out
branches/SuSE-Code-11-SP2-Branch/storage/libstorage/testsuite/single.out/lvm_create.out
branches/SuSE-Code-11-SP2-Branch/storage/libstorage/testsuite/single.out/lvm_extend.out
branches/SuSE-Code-11-SP2-Branch/storage/libstorage/testsuite/single.out/md_create.out
branches/SuSE-Code-11-SP2-Branch/storage/libstorage/testsuite/single.out/partition1.out
branches/SuSE-Code-11-SP2-Branch/storage/libstorage/testsuite/single.out/uuid1.out
branches/SuSE-Code-11-SP2-Branch/storage/libstorage/testsuite/uuid1.cc
branches/SuSE-Code-11-SP2-Branch/storage/package/yast2-storage.changes
branches/SuSE-Code-11-SP2-Branch/storage/storage/src/Makefile.am
branches/SuSE-Code-11-SP2-Branch/storage/storage/src/include/auto_part_create.ycp
branches/SuSE-Code-11-SP2-Branch/storage/storage/src/include/auto_part_functions.ycp
branches/SuSE-Code-11-SP2-Branch/storage/storage/src/include/auto_part_prepare.ycp
branches/SuSE-Code-11-SP2-Branch/storage/storage/src/include/auto_part_ui.ycp
branches/SuSE-Code-11-SP2-Branch/storage/storage/src/include/custom_part_check_generated.ycp
branches/SuSE-Code-11-SP2-Branch/storage/storage/src/include/custom_part_dialogs.ycp
branches/SuSE-Code-11-SP2-Branch/storage/storage/src/include/custom_part_helptexts.ycp
branches/SuSE-Code-11-SP2-Branch/storage/storage/src/include/custom_part_lib.ycp
branches/SuSE-Code-11-SP2-Branch/storage/storage/src/include/ep-all.ycp
branches/SuSE-Code-11-SP2-Branch/storage/storage/src/include/ep-dialogs.ycp
branches/SuSE-Code-11-SP2-Branch/storage/storage/src/include/ep-dm-dialogs.ycp
branches/SuSE-Code-11-SP2-Branch/storage/storage/src/include/ep-dm-lib.ycp
branches/SuSE-Code-11-SP2-Branch/storage/storage/src/include/ep-dm.ycp
branches/SuSE-Code-11-SP2-Branch/storage/storage/src/include/ep-hd-dialogs.ycp
branches/SuSE-Code-11-SP2-Branch/storage/storage/src/include/ep-hd-lib.ycp
branches/SuSE-Code-11-SP2-Branch/storage/storage/src/include/ep-hd.ycp
branches/SuSE-Code-11-SP2-Branch/storage/storage/src/include/ep-lib.ycp
branches/SuSE-Code-11-SP2-Branch/storage/storage/src/include/ep-log.ycp
branches/SuSE-Code-11-SP2-Branch/storage/storage/src/include/ep-loop-dialogs.ycp
branches/SuSE-Code-11-SP2-Branch/storage/storage/src/include/ep-loop-lib.ycp
branches/SuSE-Code-11-SP2-Branch/storage/storage/src/include/ep-loop.ycp
branches/SuSE-Code-11-SP2-Branch/storage/storage/src/include/ep-lvm-dialogs.ycp
branches/SuSE-Code-11-SP2-Branch/storage/storage/src/include/ep-lvm-lib.ycp
branches/SuSE-Code-11-SP2-Branch/storage/storage/src/include/ep-lvm.ycp
branches/SuSE-Code-11-SP2-Branch/storage/storage/src/include/ep-main.ycp
branches/SuSE-Code-11-SP2-Branch/storage/storage/src/include/ep-nfs.ycp
branches/SuSE-Code-11-SP2-Branch/storage/storage/src/include/ep-raid-dialogs.ycp
branches/SuSE-Code-11-SP2-Branch/storage/storage/src/include/ep-raid-lib.ycp
branches/SuSE-Code-11-SP2-Branch/storage/storage/src/include/ep-raid.ycp
branches/SuSE-Code-11-SP2-Branch/storage/storage/src/include/ep-settings.ycp
branches/SuSE-Code-11-SP2-Branch/storage/storage/src/include/ep-unused.ycp
branches/SuSE-Code-11-SP2-Branch/storage/storage/src/include/lvm_lib.ycp
branches/SuSE-Code-11-SP2-Branch/storage/storage/src/include/lvm_lv_lib.ycp
branches/SuSE-Code-11-SP2-Branch/storage/storage/src/include/lvm_pv_lib.ycp
branches/SuSE-Code-11-SP2-Branch/storage/storage/src/include/lvm_ui_dialogs.ycp
branches/SuSE-Code-11-SP2-Branch/storage/storage/src/include/partition_defines.ycp
branches/SuSE-Code-11-SP2-Branch/storage/storage/src/include/raid_lib.ycp
branches/SuSE-Code-11-SP2-Branch/storage/storage/src/inst_custom_part.ycp
branches/SuSE-Code-11-SP2-Branch/storage/storage/src/inst_disk_proposal.ycp
branches/SuSE-Code-11-SP2-Branch/storage/storage/src/inst_prepdisk.ycp
branches/SuSE-Code-11-SP2-Branch/storage/storage/src/inst_resize_ui.ycp
branches/SuSE-Code-11-SP2-Branch/storage/storage/src/inst_target_part.ycp
branches/SuSE-Code-11-SP2-Branch/storage/storage/src/inst_target_selection.ycp
branches/SuSE-Code-11-SP2-Branch/storage/storage/src/modules/FileSystems.ycp
branches/SuSE-Code-11-SP2-Branch/storage/storage/src/modules/Makefile.am
branches/SuSE-Code-11-SP2-Branch/storage/storage/src/modules/MiniWorkflow.ycp
branches/SuSE-Code-11-SP2-Branch/storage/storage/src/modules/Partitions.ycp
branches/SuSE-Code-11-SP2-Branch/storage/storage/src/modules/Storage.ycp
branches/SuSE-Code-11-SP2-Branch/storage/storage/src/modules/StorageClients.ycp
branches/SuSE-Code-11-SP2-Branch/storage/storage/src/modules/StorageControllers.ycp
branches/SuSE-Code-11-SP2-Branch/storage/storage/src/modules/StorageDevices.ycp
branches/SuSE-Code-11-SP2-Branch/storage/storage/src/modules/StorageFields.ycp
branches/SuSE-Code-11-SP2-Branch/storage/storage/src/modules/StorageSettings.ycp
branches/SuSE-Code-11-SP2-Branch/storage/storage/src/modules/TabPanel.ycp
branches/SuSE-Code-11-SP2-Branch/storage/storage/src/modules/TreePanel.ycp
branches/SuSE-Code-11-SP2-Branch/storage/storage/src/proposal/partitions_proposal.ycp
branches/SuSE-Code-11-SP2-Branch/storage/storage/src/storage_finish.ycp
branches/SuSE-Code-11-SP2-Branch/storage/storage/src/testsuite/ (props changed)
branches/SuSE-Code-11-SP2-Branch/storage/storage/src/testsuite/config/unix.exp
branches/SuSE-Code-11-SP2-Branch/storage/storage/src/testsuite/data/ (props changed)
branches/SuSE-Code-11-SP2-Branch/storage/yast2-storage.spec.in
Modified: branches/SuSE-Code-11-SP2-Branch/storage/VERSION
URL: http://svn.opensuse.org/viewcvs/yast/branches/SuSE-Code-11-SP2-Branch/stora…
==============================================================================
--- branches/SuSE-Code-11-SP2-Branch/storage/VERSION (original)
+++ branches/SuSE-Code-11-SP2-Branch/storage/VERSION Tue May 17 13:39:44 2011
@@ -1 +1 @@
-2.17.100
+2.17.101
Modified: branches/SuSE-Code-11-SP2-Branch/storage/disk/src/disk_worker.ycp
URL: http://svn.opensuse.org/viewcvs/yast/branches/SuSE-Code-11-SP2-Branch/stora…
==============================================================================
--- branches/SuSE-Code-11-SP2-Branch/storage/disk/src/disk_worker.ycp (original)
+++ branches/SuSE-Code-11-SP2-Branch/storage/disk/src/disk_worker.ycp Tue May 17 13:39:44 2011
@@ -33,6 +33,8 @@
Storage::SwitchUiAutomounter(true);
Storage::SaveUsedFs();
+ Storage::FinishLibstorage();
+
return ret;
}
Modified: branches/SuSE-Code-11-SP2-Branch/storage/libstorage/bindings/python/LibStorage.i
URL: http://svn.opensuse.org/viewcvs/yast/branches/SuSE-Code-11-SP2-Branch/stora…
==============================================================================
--- branches/SuSE-Code-11-SP2-Branch/storage/libstorage/bindings/python/LibStorage.i (original)
+++ branches/SuSE-Code-11-SP2-Branch/storage/libstorage/bindings/python/LibStorage.i Tue May 17 13:39:44 2011
@@ -6,23 +6,29 @@
%{
#include "../../src/StorageInterface.h"
+#include "../../src/HumanString.h"
+#include "../../src/Graph.h"
%}
using namespace std;
%include "std_string.i"
%include "std_deque.i"
+%include "std_list.i"
%typemap(out) std::string* {
- $result = PyString_FromString ($1->c_str ());
+ $result = PyString_FromString($1->c_str());
}
%include "../../src/StorageInterface.h"
+%include "../../src/HumanString.h"
+%include "../../src/Graph.h"
using namespace storage;
%template(dequestring) deque<string>;
%template(dequecontainerinfo) deque<ContainerInfo>;
%template(dequepartitioninfo) deque<PartitionInfo>;
+%template(dequemdinfo) deque<MdInfo>;
%template(dequelvmlvinfo) deque<LvmLvInfo>;
Modified: branches/SuSE-Code-11-SP2-Branch/storage/libstorage/bindings/python/Makefile
URL: http://svn.opensuse.org/viewcvs/yast/branches/SuSE-Code-11-SP2-Branch/stora…
==============================================================================
--- branches/SuSE-Code-11-SP2-Branch/storage/libstorage/bindings/python/Makefile (original)
+++ branches/SuSE-Code-11-SP2-Branch/storage/libstorage/bindings/python/Makefile Tue May 17 13:39:44 2011
@@ -9,8 +9,8 @@
LibStorage.pyo: LibStorage_wrap.cxx
python -O -c "import LibStorage"
-LibStorage_wrap.cxx: LibStorage.i ../../src/StorageInterface.h
+LibStorage_wrap.cxx: LibStorage.i ../../src/StorageInterface.h
swig -Wall -c++ -python LibStorage.i
- g++ -c -I/usr/include/python -O2 -fPIC -pipe LibStorage_wrap.cxx
- g++ -shared LibStorage_wrap.o -o _LibStorage.so -ly2storage
+ g++ -c -I/usr/include/python -I../../src -O2 -fPIC -pipe LibStorage_wrap.cxx
+ g++ -shared LibStorage_wrap.o -o _LibStorage.so -L../../src/.libs -ly2storage
Modified: branches/SuSE-Code-11-SP2-Branch/storage/libstorage/bindings/ycp/LibStorage.i
URL: http://svn.opensuse.org/viewcvs/yast/branches/SuSE-Code-11-SP2-Branch/stora…
==============================================================================
--- branches/SuSE-Code-11-SP2-Branch/storage/libstorage/bindings/ycp/LibStorage.i (original)
+++ branches/SuSE-Code-11-SP2-Branch/storage/libstorage/bindings/ycp/LibStorage.i Tue May 17 13:39:44 2011
@@ -7,7 +7,12 @@
%include "LiMaL.i"
%{
+// workaround for bnc #593954
+#undef seed
+
#include "../../src/StorageInterface.h"
+#include "../../src/HumanString.h"
+#include "../../src/Graph.h"
%}
using namespace std;
@@ -37,8 +42,16 @@
specialize_sequence(storage::DmPartInfo, TO_PACK, FROM_PACK, CHECK)
specialize_sequence(storage::DmraidInfo, TO_PACK, FROM_PACK, CHECK)
specialize_sequence(storage::DmmultipathInfo, TO_PACK, FROM_PACK, CHECK)
+specialize_sequence(storage::BtrfsInfo, TO_PACK, FROM_PACK, CHECK)
+specialize_sequence(storage::TmpfsInfo, TO_PACK, FROM_PACK, CHECK)
specialize_sequence(storage::PartitionSlotInfo, TO_PACK, FROM_PACK, CHECK)
specialize_sequence(storage::CommitInfo, TO_PACK, FROM_PACK, CHECK)
+specialize_sequence(storage::ResizeInfo, TO_PACK, FROM_PACK, CHECK)
+specialize_sequence(storage::ContentInfo, 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: branches/SuSE-Code-11-SP2-Branch/storage/libstorage/examples/Makefile.am
URL: http://svn.opensuse.org/viewcvs/yast/branches/SuSE-Code-11-SP2-Branch/stora…
==============================================================================
--- branches/SuSE-Code-11-SP2-Branch/storage/libstorage/examples/Makefile.am (original)
+++ branches/SuSE-Code-11-SP2-Branch/storage/libstorage/examples/Makefile.am Tue May 17 13:39:44 2011
@@ -9,7 +9,7 @@
AM_CXXFLAGS =
-noinst_PROGRAMS = TestDisk TestDiskLog TestStorage TestProbing TestLvm TestMd TestLoop TestLock
+noinst_PROGRAMS = TestDisk TestDiskLog TestStorage TestProbing TestLvm TestMd TestLoop TestLock SaveGraph ShowBytes
TestDisk_SOURCES = TestDisk.cc
@@ -27,9 +27,13 @@
TestLock_SOURCES = TestLock.cc
+SaveGraph_SOURCES = SaveGraph.cc
+
+ShowBytes_SOURCES = ShowBytes.cc
+
exampledir = $(docdir)/examples/libstorage
-example_DATA = TestDisk.cc TestDiskLog.cc TestProbing.cc TestLvm.cc TestMd.cc TestLoop.cc
+example_DATA = TestDisk.cc TestDiskLog.cc TestProbing.cc TestLvm.cc TestMd.cc TestLoop.cc SaveGraph.cc ShowBytes.cc
EXTRA_DIST = $(example_DATA) Makefile.example
Added: branches/SuSE-Code-11-SP2-Branch/storage/libstorage/examples/SaveGraph.cc
URL: http://svn.opensuse.org/viewcvs/yast/branches/SuSE-Code-11-SP2-Branch/stora…
==============================================================================
--- branches/SuSE-Code-11-SP2-Branch/storage/libstorage/examples/SaveGraph.cc (added)
+++ branches/SuSE-Code-11-SP2-Branch/storage/libstorage/examples/SaveGraph.cc Tue May 17 13:39:44 2011
@@ -0,0 +1,27 @@
+
+#include <stdlib.h>
+#include <iostream>
+
+#include <storage/StorageInterface.h>
+#include <storage/Graph.h>
+
+using namespace storage;
+using namespace std;
+
+int
+main (int argc, char** argv)
+{
+ initDefaultLogger();
+
+ StorageInterface* s = createStorageInterface(Environment(true));
+
+ saveDeviceGraph(s, "device.gv");
+ saveMountGraph(s, "mount.gv");
+
+ destroyStorageInterface(s);
+
+ cout << "run \"dot -T png -o device.png device.gv\" and "
+ "\"dot -T png -o mount.png mount.gv\" to generate pngs" << endl;
+
+ exit(EXIT_SUCCESS);
+}
Added: branches/SuSE-Code-11-SP2-Branch/storage/libstorage/examples/ShowBytes.cc
URL: http://svn.opensuse.org/viewcvs/yast/branches/SuSE-Code-11-SP2-Branch/stora…
==============================================================================
--- branches/SuSE-Code-11-SP2-Branch/storage/libstorage/examples/ShowBytes.cc (added)
+++ branches/SuSE-Code-11-SP2-Branch/storage/libstorage/examples/ShowBytes.cc Tue May 17 13:39:44 2011
@@ -0,0 +1,32 @@
+
+#include <iostream>
+
+#include <storage/HumanString.h>
+
+using namespace storage;
+using namespace std;
+
+int
+main(int argc, char** argv)
+{
+ if (argc != 2)
+ {
+ cerr << "no value provided" << endl;
+ return 1;
+ }
+
+ locale::global(locale(""));
+
+ unsigned long long bytes = 0;
+ if (!humanStringToByte(argv[1], false, bytes))
+ {
+ cerr << "parsing value failed" << endl;
+ return 1;
+ }
+
+ cout << bytes << " " << getSuffix(0, false) << endl;
+
+ cout << byteToHumanString(bytes, false, 2, true) << endl;
+
+ return 0;
+}
Modified: branches/SuSE-Code-11-SP2-Branch/storage/libstorage/examples/TestLock.cc
URL: http://svn.opensuse.org/viewcvs/yast/branches/SuSE-Code-11-SP2-Branch/stora…
==============================================================================
--- branches/SuSE-Code-11-SP2-Branch/storage/libstorage/examples/TestLock.cc (original)
+++ branches/SuSE-Code-11-SP2-Branch/storage/libstorage/examples/TestLock.cc Tue May 17 13:39:44 2011
@@ -95,7 +95,7 @@
usage();
}
- Storage::initDefaultLogger();
+ initDefaultLogger();
cout << "pid is " << getpid() << endl;
Modified: branches/SuSE-Code-11-SP2-Branch/storage/libstorage/examples/TestLoop.cc
URL: http://svn.opensuse.org/viewcvs/yast/branches/SuSE-Code-11-SP2-Branch/stora…
==============================================================================
--- branches/SuSE-Code-11-SP2-Branch/storage/libstorage/examples/TestLoop.cc (original)
+++ branches/SuSE-Code-11-SP2-Branch/storage/libstorage/examples/TestLoop.cc Tue May 17 13:39:44 2011
@@ -1,17 +1,13 @@
#include <iostream>
-#include <blocxx/AppenderLogger.hpp>
-#include <blocxx/FileAppender.hpp>
-
#include <y2storage/StorageInterface.h>
using namespace storage;
using namespace std;
-using namespace blocxx;
-void scrollbarCb( const string& id, unsigned cur, unsigned max )
+void progressbarCb( const string& id, unsigned cur, unsigned max )
{
- cout << "SCROLLBAR id:" << id << " cur:" << cur << " max:" << max << endl;
+ cout << "PROGRESSBAR id:" << id << " cur:" << cur << " max:" << max << endl;
}
void installInfoCb( const string& info )
@@ -20,12 +16,13 @@
}
void
-printCommitActions( StorageInterface* s )
- {
- deque<string> l = s->getCommitActions( false );
- for( deque<string>::iterator i=l.begin(); i!=l.end(); ++i )
- cout << *i << endl;
- }
+printCommitActions(StorageInterface* s)
+{
+ list<CommitInfo> l;
+ s->getCommitInfos(l);
+ for (list<CommitInfo>::iterator i=l.begin(); i!=l.end(); ++i)
+ cout << i->text << endl;
+}
int doCommit( StorageInterface* s )
{
@@ -50,7 +47,7 @@
int ret = 0;
initDefaultLogger();
StorageInterface* s = createStorageInterface(Environment(false));
- s->setCallbackProgressBar( scrollbarCb );
+ s->setCallbackProgressBar( progressbarCb );
s->setCallbackShowInstallInfo( installInfoCb );
string disk = "/dev/hdb";
string device;
Modified: branches/SuSE-Code-11-SP2-Branch/storage/libstorage/examples/TestLvm.cc
URL: http://svn.opensuse.org/viewcvs/yast/branches/SuSE-Code-11-SP2-Branch/stora…
==============================================================================
--- branches/SuSE-Code-11-SP2-Branch/storage/libstorage/examples/TestLvm.cc (original)
+++ branches/SuSE-Code-11-SP2-Branch/storage/libstorage/examples/TestLvm.cc Tue May 17 13:39:44 2011
@@ -7,11 +7,10 @@
using namespace storage;
using namespace std;
-using namespace blocxx;
-void scrollbarCb( const string& id, unsigned cur, unsigned max )
+void progressbarCb( const string& id, unsigned cur, unsigned max )
{
- cout << "SCROLLBAR id:" << id << " cur:" << cur << " max:" << max << endl;
+ cout << "PROGRESSBAR id:" << id << " cur:" << cur << " max:" << max << endl;
}
void installInfoCb( const string& info )
@@ -20,12 +19,13 @@
}
void
-printCommitActions( StorageInterface* s )
- {
- deque<string> l = s->getCommitActions( false );
- for( deque<string>::iterator i=l.begin(); i!=l.end(); ++i )
- cout << *i << endl;
- }
+printCommitActions(StorageInterface* s)
+{
+ list<CommitInfo> l;
+ s->getCommitInfos(l);
+ for (list<CommitInfo>::iterator i=l.begin(); i!=l.end(); ++i)
+ cout << i->text << endl;
+}
int doCommit( StorageInterface* s )
{
@@ -48,7 +48,7 @@
int ret = 0;
initDefaultLogger();
StorageInterface* s = createStorageInterface(Environment(false));
- s->setCallbackProgressBar( scrollbarCb );
+ s->setCallbackProgressBar( progressbarCb );
s->setCallbackShowInstallInfo( installInfoCb );
string disk = "/dev/hdb";
string device;
Modified: branches/SuSE-Code-11-SP2-Branch/storage/libstorage/examples/TestMd.cc
URL: http://svn.opensuse.org/viewcvs/yast/branches/SuSE-Code-11-SP2-Branch/stora…
==============================================================================
--- branches/SuSE-Code-11-SP2-Branch/storage/libstorage/examples/TestMd.cc (original)
+++ branches/SuSE-Code-11-SP2-Branch/storage/libstorage/examples/TestMd.cc Tue May 17 13:39:44 2011
@@ -7,11 +7,10 @@
using namespace storage;
using namespace std;
-using namespace blocxx;
-void scrollbarCb( const string& id, unsigned cur, unsigned max )
+void progressbarCb( const string& id, unsigned cur, unsigned max )
{
- cout << "SCROLLBAR id:" << id << " cur:" << cur << " max:" << max << endl;
+ cout << "PROGRESSBAR id:" << id << " cur:" << cur << " max:" << max << endl;
}
void installInfoCb( const string& info )
@@ -20,12 +19,13 @@
}
void
-printCommitActions( StorageInterface* s )
- {
- deque<string> l = s->getCommitActions( false );
- for( deque<string>::iterator i=l.begin(); i!=l.end(); ++i )
- cout << *i << endl;
- }
+printCommitActions(StorageInterface* s)
+{
+ list<CommitInfo> l;
+ s->getCommitInfos(l);
+ for (list<CommitInfo>::iterator i=l.begin(); i!=l.end(); ++i)
+ cout << i->text << endl;
+}
int doCommit( StorageInterface* s )
{
@@ -50,7 +50,7 @@
int ret = 0;
initDefaultLogger();
StorageInterface* s = createStorageInterface(Environment(false));
- s->setCallbackProgressBar( scrollbarCb );
+ s->setCallbackProgressBar( progressbarCb );
s->setCallbackShowInstallInfo( installInfoCb );
string disk = "/dev/hdb";
string device;
@@ -80,49 +80,49 @@
}
if( ret==0 )
{
- deque<string> ds;
+ list<string> ds;
ds.push_back( "/dev/hdb5" );
ds.push_back( "/dev/hdb6" );
ds.push_back( "/dev/hdb7" );
- ret = s->createMd( "md0", RAID0, ds );
+ ret = s->createMd("md0", RAID0, ds, list<string>());
if( ret ) cerr << "retcode:" << ret << endl;
}
if( ret==0 )
{
- deque<string> ds;
+ list<string> ds;
ds.push_back( "/dev/hdb8" );
ds.push_back( "/dev/hdb9" );
- ret = s->createMdAny( RAID1, ds, device );
+ ret = s->createMdAny(RAID1, ds, list<string>(), device);
cout << "device:" << device << endl;
if( ret ) cerr << "retcode:" << ret << endl;
}
if( ret==0 )
{
- deque<string> ds;
+ list<string> ds;
ds.push_back( "/dev/hdb10" );
ds.push_back( "/dev/hdb11" );
ds.push_back( "/dev/hdb12" );
- ret = s->createMd( "/dev/md2", RAID5, ds );
+ ret = s->createMd("/dev/md2", RAID5, ds, list<string>());
if( ret ) cerr << "retcode:" << ret << endl;
}
if( ret==0 )
{
- deque<string> ds;
+ list<string> ds;
ds.push_back( "/dev/hdb13" );
ds.push_back( "/dev/hdb14" );
ds.push_back( "/dev/hdb15" );
ds.push_back( "/dev/hdb16" );
- ret = s->createMd( "/dev/md3", RAID6, ds );
+ ret = s->createMd("/dev/md3", RAID6, ds, list<string>());
if( ret ) cerr << "retcode:" << ret << endl;
}
if( ret==0 )
{
- deque<string> ds;
+ list<string> ds;
ds.push_back( "/dev/hdb17" );
ds.push_back( "/dev/hdb18" );
ds.push_back( "/dev/hdb19" );
ds.push_back( "/dev/hdb1" );
- ret = s->createMd( "/dev/md4", RAID10, ds );
+ ret = s->createMd("/dev/md4", RAID10, ds, list<string>());
if( ret ) cerr << "retcode:" << ret << endl;
}
if( ret==0 )
Modified: branches/SuSE-Code-11-SP2-Branch/storage/libstorage/examples/TestProbing.cc
URL: http://svn.opensuse.org/viewcvs/yast/branches/SuSE-Code-11-SP2-Branch/stora…
==============================================================================
--- branches/SuSE-Code-11-SP2-Branch/storage/libstorage/examples/TestProbing.cc (original)
+++ branches/SuSE-Code-11-SP2-Branch/storage/libstorage/examples/TestProbing.cc Tue May 17 13:39:44 2011
@@ -19,13 +19,14 @@
main (int argc, char** argv)
{
initDefaultLogger();
- StorageInterface* s = createStorageInterface(Environment(false));
+
+ StorageInterface* s = createStorageInterface(Environment(true));
deque<ContainerInfo> containers;
s->getContainers (containers);
- for (deque<ContainerInfo>::iterator i1 = containers.begin ();
- i1 != containers.end(); i1++)
+ for (deque<ContainerInfo>::const_iterator i1 = containers.begin();
+ i1 != containers.end(); ++i1)
{
switch (i1->type)
{
@@ -40,8 +41,8 @@
exit (EXIT_FAILURE);
}
- for (deque<PartitionInfo>::iterator i2 = partitions.begin ();
- i2 != partitions.end(); i2++)
+ for (deque<PartitionInfo>::const_iterator i2 = partitions.begin();
+ i2 != partitions.end(); ++i2)
{
cout << " " << i2->v.name << ' ';
switch (i2->partitionType)
@@ -57,6 +58,8 @@
case REISERFS: cout << "REISERFS"; break;
case EXT2: cout << "EXT2"; break;
case EXT3: cout << "EXT3"; break;
+ case EXT4: cout << "EXT4"; break;
+ case BTRFS: cout << "BTRFS"; break;
case VFAT: cout << "VFAT"; break;
case XFS: cout << "XFS"; break;
case JFS: cout << "JFS"; break;
@@ -65,6 +68,8 @@
case NTFS: cout << "NTFS"; break;
case SWAP: cout << "SWAP"; break;
case NFS: cout << "NFS"; break;
+ case NFS4: cout << "NFS4"; break;
+ case TMPFS: cout << "TMPFS"; break;
case FSNONE: cout << "NONE"; break;
}
cout << '\n';
@@ -72,6 +77,26 @@
} break;
+ case MD:
+ {
+ cout << "found special container (md) " << i1->name << '\n';
+
+ deque<MdInfo> mds;
+ if (s->getMdInfo(mds) != 0)
+ {
+ cerr << "getMdInfo failed\n";
+ exit (EXIT_FAILURE);
+ }
+
+ for (deque<MdInfo>::const_iterator i2 = mds.begin();
+ i2 != mds.end(); ++i2)
+ {
+ cout << " " << i2->v.name;
+ cout << '\n';
+ }
+
+ } break;
+
case LVM: {
cout << "found container (lvm) " << i1->name << '\n';
@@ -83,8 +108,8 @@
exit (EXIT_FAILURE);
}
- for (deque<LvmLvInfo>::iterator i2 = lvmlvs.begin ();
- i2 != lvmlvs.end(); i2++)
+ for (deque<LvmLvInfo>::const_iterator i2 = lvmlvs.begin();
+ i2 != lvmlvs.end(); ++i2)
{
cout << " " << i2->v.name;
cout << '\n';
Modified: branches/SuSE-Code-11-SP2-Branch/storage/libstorage/examples/TestStorage.cc
URL: http://svn.opensuse.org/viewcvs/yast/branches/SuSE-Code-11-SP2-Branch/stora…
==============================================================================
--- branches/SuSE-Code-11-SP2-Branch/storage/libstorage/examples/TestStorage.cc (original)
+++ branches/SuSE-Code-11-SP2-Branch/storage/libstorage/examples/TestStorage.cc Tue May 17 13:39:44 2011
@@ -10,13 +10,14 @@
using namespace std;
using namespace storage;
-struct test_hdb { bool operator()(const Container&d) const {return( d.name().find( "hdb" )!=string::npos);}};
+struct test_sdb { bool operator()(const Container&d) const {return( d.name().find( "sdb" )!=string::npos);}};
+struct NotDeleted { bool operator()(const Container& d) const { return !d.deleted(); } };
struct Smaller5 { bool operator()(const Volume&d) const {return(d.nr()<5);}};
-struct Smaller150 { bool operator()(const Disk&d) const {return(d.cylinders()<150);}};
-struct Larger150 { bool operator()(const Disk&d) const {return(d.cylinders()>150);}};
+struct Smaller20000 { bool operator()(const Disk&d) const {return(d.cylinders()<20000);}};
+struct Larger20000 { bool operator()(const Disk&d) const {return(d.cylinders()>20000);}};
struct Equal150 { bool operator()(const Disk&d) const {return(d.cylinders()==150);}};
struct Larger10 { bool operator()(const Partition&d) const {return(d.cylSize()>10);}};
-struct DiskStart { bool operator()(const Partition&d) const {return(d.cylStart()==1);}};
+struct DiskStart { bool operator()(const Partition&d) const {return(d.cylStart()==0);}};
template <class C> struct First
{ bool operator()(const C&d) const {return(d.nr()==0);}};
@@ -54,29 +55,29 @@
int
main( int argc_iv, char** argv_ppcv )
{
- Storage::initDefaultLogger();
+ initDefaultLogger();
Storage Sto(Environment(true));
+ Sto.assertInit();
for( Storage::ConstContIterator i=Sto.contBegin(); i!=Sto.contEnd(); ++i )
{
cout << *i << endl;
}
{
- struct test_hdb t;
- Storage::ContCondIPair<test_hdb>::type p=Sto.contCondPair<test_hdb>(t);
- cout << "test_hdb pair empty:" << p.empty() << " length:" << p.length() << endl;
- for( Storage::ConstContainerI<test_hdb>::type i=p.begin(); i!=p.end(); ++i )
+ struct test_sdb t;
+ Storage::ContCondIPair<test_sdb>::type p=Sto.contCondPair<test_sdb>(t);
+ cout << "test_sdb pair empty:" << p.empty() << " length:" << p.length() << endl;
+ for( Storage::ConstContainerI<test_sdb>::type i=p.begin(); i!=p.end(); ++i )
{
cout << *i << endl;
}
}
{
- Storage::ContCondIPair<Storage::SkipDeleted>::type p =
- Sto.contCondPair<Storage::SkipDeleted>( Storage::SkipDel );
- cout << "SkipDeleted pair empty:" << p.empty() << " length:" << p.length() << endl;
- for( Storage::ConstContainerI<Storage::SkipDeleted>::type i=p.begin();
- i!=p.end(); ++i )
+ NotDeleted NotDel;
+ Storage::ContCondIPair<NotDeleted>::type p = Sto.contCondPair<NotDeleted>(NotDel);
+ cout << "NotDeleted pair empty:" << p.empty() << " length:" << p.length() << endl;
+ for (Storage::ConstContainerI<NotDeleted>::type i = p.begin(); i != p.end(); ++i)
{
- cout << *i << endl;
+ cout << *i << endl;
}
}
struct tmp {
@@ -115,7 +116,7 @@
{
cout << *i << endl;
}
- p = Sto.contPair( Storage::notDeleted );
+ p = Sto.contPair( Container::notDeleted );
cout << "not deleted empty:" << p.empty() << " length:" << p.length() << endl;
for( Storage::ConstContIterator i=p.begin(); i!=p.end(); ++i )
{
@@ -161,7 +162,9 @@
Storage::ConstVolIterator j = i;
//cout << endl << "type(j)=" << typeid(j).name() << endl;
//cout << "type(--j)=" << typeid(--j).name() << endl;
- cout << " P Name:" << (*--j).device() << endl;
+ if( j!=p.begin() )
+ cout << " P Name:" << (*--j).device();
+ cout << endl;
}
cout << "Inverted order" << endl;
for( Storage::ConstVolIterator i=p.end(); i!=p.begin(); )
@@ -169,11 +172,11 @@
--i;
cout << *i << endl;
}
- p = Sto.volPair( Storage::notDeleted );
+ p = Sto.volPair( Container::notDeleted );
PrintPair<Storage::ConstVolPair>( cout, p, "All Volumes on undel disks\n" );
p = Sto.volPair( tmp::TestIsEven );
PrintPair<Storage::ConstVolPair>( cout, p, "All Volumes with even numbers\n" );
- p = Sto.volPair( tmp::TestIsEven, Storage::notDeleted );
+ p = Sto.volPair( tmp::TestIsEven, Container::notDeleted );
PrintPair<Storage::ConstVolPair>( cout, p, "All Volumes with even numbers on undel disks\n" );
cout << "Inverted order" << endl;
for( Storage::ConstVolIterator i=p.end(); i!=p.begin(); )
@@ -191,27 +194,27 @@
Storage::ConstDiskPair p = Sto.diskPair();
PrintPair<Storage::ConstDiskPair>( cout, p, "Disks " );
struct tmp {
- static bool TestLarger150( const Disk& d )
- { return( d.cylinders()>150 ); };
- static bool TestSmaller150( const Disk& d )
- { return( d.cylinders()<150 ); };
+ static bool TestLarger20000( const Disk& d )
+ { return( d.cylinders()>20000 ); };
+ static bool TestSmaller20000( const Disk& d )
+ { return( d.cylinders()<20000 ); };
static bool TestEqual150( const Disk& d )
{ return( d.cylinders()==150 ); };
};
- p = Sto.diskPair(tmp::TestLarger150);
- PrintPair<Storage::ConstDiskPair>( cout, p, "Disks >150 " );
- p = Sto.diskPair(tmp::TestSmaller150);
- PrintPair<Storage::ConstDiskPair>( cout, p, "Disks <150 " );
+ p = Sto.diskPair(tmp::TestLarger20000);
+ PrintPair<Storage::ConstDiskPair>( cout, p, "Disks >20000 " );
+ p = Sto.diskPair(tmp::TestSmaller20000);
+ PrintPair<Storage::ConstDiskPair>( cout, p, "Disks <20000 " );
p = Sto.diskPair(tmp::TestEqual150);
PrintPair<Storage::ConstDiskPair>( cout, p, "Disks ==150 " );
}
{
- Storage::DiskCondIPair<Larger150>::type p = Sto.diskCondPair<Larger150>( Larger150() );
- PrintPair<Storage::DiskCondIPair<Larger150>::type>( cout, p, "Disks >150 " );
+ Storage::DiskCondIPair<Larger20000>::type p = Sto.diskCondPair<Larger20000>( Larger20000() );
+ PrintPair<Storage::DiskCondIPair<Larger20000>::type>( cout, p, "Disks >20000 " );
}
{
- Storage::DiskCondIPair<Smaller150>::type p = Sto.diskCondPair<Smaller150>( Smaller150() );
- PrintPair<Storage::DiskCondIPair<Smaller150>::type>( cout, p, "Disks <150 " );
+ Storage::DiskCondIPair<Smaller20000>::type p = Sto.diskCondPair<Smaller20000>( Smaller20000() );
+ PrintPair<Storage::DiskCondIPair<Smaller20000>::type>( cout, p, "Disks <20000 " );
}
{
Storage::DiskCondIPair<Equal150>::type p = Sto.diskCondPair<Equal150>( Equal150() );
@@ -222,7 +225,7 @@
PrintPair<Storage::ConstPartPair>( cout, p, "Part " );
struct tmp {
static bool TestStart( const Partition& d )
- { return( d.cylStart()==1 ); };
+ { return( d.cylStart()==0 ); };
static bool TestLarger10( const Partition& d )
{ return( d.cylSize()>10 ); };
};
Modified: branches/SuSE-Code-11-SP2-Branch/storage/libstorage/src/AppUtil.cc
URL: http://svn.opensuse.org/viewcvs/yast/branches/SuSE-Code-11-SP2-Branch/stora…
==============================================================================
--- branches/SuSE-Code-11-SP2-Branch/storage/libstorage/src/AppUtil.cc (original)
+++ branches/SuSE-Code-11-SP2-Branch/storage/libstorage/src/AppUtil.cc Tue May 17 13:39:44 2011
@@ -1,5 +1,5 @@
/*
- * Copyright (c) [2004-2009] Novell, Inc.
+ * Copyright (c) [2004-2010] Novell, Inc.
*
* All Rights Reserved.
*
@@ -19,19 +19,18 @@
* find current contact information at www.novell.com.
*/
-// Maintainer: fehr(a)suse.de
-/*
- Textdomain "storage"
-*/
-
+#include <errno.h>
+#include <stdarg.h>
#include <unistd.h>
-#include <string>
+#include <fcntl.h>
+#include <glob.h>
#include <sys/stat.h>
+#include <sys/statvfs.h>
#include <sys/types.h>
+#include <sys/utsname.h>
#include <dirent.h>
-
-#include <locale>
+#include <string>
#include <boost/algorithm/string.hpp>
#include <blocxx/AppenderLogger.hpp>
@@ -39,89 +38,31 @@
#include <blocxx/Logger.hpp>
#include <blocxx/LogMessage.hpp>
-#include "y2storage/AsciiFile.h"
-#include "y2storage/StorageTmpl.h"
-#include "y2storage/AppUtil.h"
-#include "y2storage/SystemCmd.h"
+#include "storage/AsciiFile.h"
+#include "storage/StorageTmpl.h"
+#include "storage/AppUtil.h"
+#include "storage/StorageTypes.h"
-using namespace std;
namespace storage
{
-
-string dupDash(const string& s)
- {
- string ret(s);
- string::size_type pos = ret.find("-");
- while(pos!=string::npos)
- {
- ret.insert(pos,1,'-');
- pos = ret.find("-",pos+2);
- }
- return(ret);
- }
-
-bool
-searchFile(AsciiFile& File_Cr, string Pat_Cv, string& Line_Cr)
-{
- int LineNr_ii = 0;
- return searchFile(File_Cr, Pat_Cv, Line_Cr, LineNr_ii);
-}
-
-bool
-searchFile(AsciiFile& File_Cr, string Pat_Cv, string& Line_Cr, int& LineNr_ir)
-{
- int End_ii;
- bool Found_bi = false;
- bool BeginOfLine_bi;
- string Tmp_Ci;
- int LineNr_ii;
- string Search_Ci(Pat_Cv);
-
- BeginOfLine_bi = Search_Ci.length() > 0 && Search_Ci[0] == '^';
- if (BeginOfLine_bi)
- Search_Ci.erase(0, 1);
- End_ii = File_Cr.numLines();
- LineNr_ii = LineNr_ir;
- while (!Found_bi && LineNr_ii < End_ii)
- {
- string::size_type Idx_ii;
-
- Tmp_Ci = File_Cr[LineNr_ii++];
- Idx_ii = Tmp_Ci.find(Search_Ci);
- if (Idx_ii != string::npos)
- {
- if (BeginOfLine_bi)
- Found_bi = Idx_ii == 0;
- else
- Found_bi = true;
- }
- }
- if (Found_bi)
- {
- Line_Cr = Tmp_Ci;
- LineNr_ir = LineNr_ii - 1;
- }
- return Found_bi;
-}
+ using namespace std;
-void createPath(string Path_Cv)
+void createPath(const string& Path_Cv)
{
- string Path_Ci = Path_Cv;
- string Tmp_Ci;
-
string::size_type Pos_ii = 0;
- while ((Pos_ii = Path_Ci.find('/', Pos_ii + 1)) != string::npos)
+ while ((Pos_ii = Path_Cv.find('/', Pos_ii + 1)) != string::npos)
{
- Tmp_Ci = Path_Ci.substr(0, Pos_ii);
+ string Tmp_Ci = Path_Cv.substr(0, Pos_ii);
mkdir(Tmp_Ci.c_str(), 0777);
}
- mkdir(Path_Ci.c_str(), 0777);
+ mkdir(Path_Cv.c_str(), 0777);
}
+
bool
-checkDir(string Path_Cv)
+checkDir(const string& Path_Cv)
{
struct stat Stat_ri;
@@ -129,26 +70,33 @@
S_ISDIR(Stat_ri.st_mode));
}
+
bool
-checkSymlink(string Path_Cv)
+getStatMode(const string& Path_Cv, mode_t& val )
{
struct stat Stat_ri;
+ int ret_ii = stat(Path_Cv.c_str(), &Stat_ri);
+
+ if( ret_ii==0 )
+ val = Stat_ri.st_mode;
+ else
+ y2mil( "stat " << Path_Cv << " ret:" << ret_ii );
- return (lstat(Path_Cv.c_str(), &Stat_ri) >= 0 &&
- S_ISLNK(Stat_ri.st_mode));
+ return (ret_ii==0);
}
bool
-checkBlockDevice(string Path_Cv)
+setStatMode(const string& Path_Cv, mode_t val )
{
- struct stat Stat_ri;
-
- return (stat(Path_Cv.c_str(), &Stat_ri) >= 0 &&
- S_ISBLK(Stat_ri.st_mode));
+ int ret_ii = chmod( Path_Cv.c_str(), val );
+ if( ret_ii!=0 )
+ y2mil( "chmod " << Path_Cv << " ret:" << ret_ii );
+ return( ret_ii==0 );
}
+
bool
-checkNormalFile(string Path_Cv)
+checkNormalFile(const string& Path_Cv)
{
struct stat Stat_ri;
@@ -156,6 +104,71 @@
S_ISREG(Stat_ri.st_mode));
}
+
+ list<string>
+ glob(const string& path, int flags)
+ {
+ list<string> ret;
+
+ glob_t globbuf;
+ if (glob(path.c_str(), flags, 0, &globbuf) == 0)
+ {
+ for (char** p = globbuf.gl_pathv; *p != 0; p++)
+ ret.push_back(*p);
+ }
+ globfree (&globbuf);
+
+ return ret;
+ }
+
+
+ bool
+ getStatVfs(const string& path, StatVfs& buf)
+ {
+ struct statvfs64 fsbuf;
+ if (statvfs64(path.c_str(), &fsbuf) != 0)
+ {
+ buf.sizeK = buf.freeK = 0;
+
+ y2err("errno:" << errno << " " << strerror(errno));
+ return false;
+ }
+
+ buf.sizeK = fsbuf.f_blocks;
+ buf.sizeK *= fsbuf.f_bsize;
+ buf.sizeK /= 1024;
+
+ buf.freeK = fsbuf.f_bfree;
+ buf.freeK *= fsbuf.f_bsize;
+ buf.freeK /= 1024;
+
+ y2mil("blocks:" << fsbuf.f_blocks << " bfree:" << fsbuf.f_bfree <<
+ " bsize:" << fsbuf.f_bsize << " sizeK:" << buf.sizeK <<
+ " freeK:" << buf.freeK);
+ return true;
+ }
+
+
+ bool
+ getMajorMinor(const string& device, unsigned long& major, unsigned long& minor)
+ {
+ bool ret = false;
+ string dev = normalizeDevice(device);
+ struct stat sbuf;
+ if (stat(device.c_str(), &sbuf) == 0)
+ {
+ major = gnu_dev_major(sbuf.st_rdev);
+ minor = gnu_dev_minor(sbuf.st_rdev);
+ ret = true;
+ }
+ else
+ {
+ y2err("stat for " << device << " failed errno:" << errno << " (" << strerror(errno) << ")");
+ }
+ return ret;
+ }
+
+
string extractNthWord(int Num_iv, const string& Line_Cv, bool GetRest_bi)
{
string::size_type pos;
@@ -249,13 +262,6 @@
}
-string
-mergeString(const list<string>& l, const string& del)
-{
- return boost::join(l, del);
-}
-
-
map<string,string>
makeMap( const list<string>& l, const string& delim, const string& removeSur )
{
@@ -289,44 +295,42 @@
}
-string normalizeDevice( const string& dev )
+ string normalizeDevice(const string& dev)
{
- string ret( dev );
- normalizeDevice( ret );
- return( ret );
+ if (!boost::starts_with(dev, "/dev/") && !isNfsDev(dev))
+ return "/dev/" + dev;
+ return dev;
}
-bool isNfsDev( const string& dev )
- {
- return( !dev.empty() && dev[0]!='/' &&
- dev.find( ':' )!=string::npos );
- }
-void normalizeDevice( string& dev )
+ list<string> normalizeDevices(const list<string>& devs)
{
- if( dev.find( "/dev/" )!=0 && !isNfsDev(dev) )
- dev = "/dev/" + dev;
+ list<string> ret;
+ for (list<string>::const_iterator it = devs.begin(); it != devs.end(); ++it)
+ ret.push_back(normalizeDevice(*it));
+ return ret;
}
-string undevDevice( const string& dev )
+
+bool isNfsDev( const string& dev )
{
- string ret( dev );
- undevDevice( ret );
- return( ret );
+ return( !dev.empty() && dev[0]!='/' &&
+ dev.find( ':' )!=string::npos );
}
-void undevDevice( string& dev )
+
+ string undevDevice(const string& dev)
{
- if( dev.find( "/dev/" )==0 )
- dev.erase( 0, 5 );
+ if (boost::starts_with(dev, "/dev/"))
+ return string(dev, 5);
+ return dev;
}
static const blocxx::String component = "libstorage";
-void createLogger(const string& lcomponent, const string& name,
- const string& logpath, const string& logfile)
+void createLogger(const string& name, const string& logpath, const string& logfile)
{
using namespace blocxx;
@@ -398,16 +402,26 @@
void
-prepareLogStream(std::ostringstream& s)
+prepareLogStream(ostringstream& stream)
{
- s.imbue(std::locale::classic());
- s.setf(std::ios::showbase);
+ stream.imbue(std::locale::classic());
+ stream.setf(std::ios::boolalpha);
+ stream.setf(std::ios::showbase);
+}
+
+
+ostringstream*
+logStreamOpen()
+{
+ std::ostringstream* stream = new ostringstream;
+ prepareLogStream(*stream);
+ return stream;
}
void
-logMsg(LogLevel level, const char* file, unsigned line, const char* func,
- const string& str)
+logStreamClose(LogLevel level, const char* file, unsigned line, const char* func,
+ ostringstream* stream)
{
using namespace blocxx;
@@ -440,32 +454,99 @@
if (!category.empty())
{
- LogAppender::getCurrentLogAppender()->logMessage(LogMessage(component, category,
- String(str), file,
- line, func));
+ string tmp = stream->str();
+
+ string::size_type pos1 = 0;
+
+ while (true)
+ {
+ string::size_type pos2 = tmp.find('\n', pos1);
+
+ if (pos2 != string::npos || pos1 != tmp.length())
+ LogAppender::getCurrentLogAppender()->logMessage(LogMessage(component, category,
+ String(tmp.substr(pos1, pos2 - pos1)),
+ file, line, func));
+
+ if (pos2 == string::npos)
+ break;
+
+ pos1 = pos2 + 1;
+ }
}
+
+ delete stream;
}
-void
-logMsgVaArgs(LogLevel level, const char* file, unsigned line, const char* func,
- const char* format, ...)
-{
- if (testLogLevel(level))
+ string
+ udevAppendPart(const string& s, unsigned num)
{
- char* str;
- va_list ap;
+ return s + "-part" + decString(num);
+ }
- va_start(ap, format);
- if (vasprintf(&str, format, ap) == -1)
- return;
- va_end(ap);
- logMsg(level, file, line, func, str);
+ string
+ udevEncode(const string& s)
+ {
+ string r = s;
- free(str);
+ string::size_type pos = 0;
+
+ while (true)
+ {
+ pos = r.find_first_of(" '\\/", pos);
+ if (pos == string::npos)
+ break;
+
+ char tmp[16];
+ sprintf(tmp, "\\x%02x", r[pos]);
+ r.replace(pos, 1, tmp);
+
+ pos += 4;
+ }
+
+ return r;
+ }
+
+
+ string
+ udevDecode(const string& s)
+ {
+ string r = s;
+
+ string::size_type pos = 0;
+
+ while (true)
+ {
+ pos = r.find("\\x", pos);
+ if (pos == string::npos || pos > r.size() - 4)
+ break;
+
+ unsigned int tmp;
+ if (sscanf(r.substr(pos + 2, 2).c_str(), "%x", &tmp) == 1)
+ r.replace(pos, 4, 1, (char) tmp);
+
+ pos += 1;
+ }
+
+ return r;
+ }
+
+
+ bool
+ mkdtemp(string& path)
+ {
+ char* tmp = strdup(path.c_str());
+ if (!::mkdtemp(tmp))
+ {
+ free(tmp);
+ return false;
+ }
+
+ path = tmp;
+ free(tmp);
+ return true;
}
-}
bool
@@ -479,232 +560,191 @@
}
- string
- udevAppendPart(const string& s, unsigned num)
+ bool
+ readlinkat(int fd, const string& path, string& buf)
{
- return s + "-part" + decString(num);
+ char tmp[1024];
+ int count = ::readlinkat(fd, path.c_str(), tmp, sizeof(tmp));
+ if (count >= 0)
+ buf = string(tmp, count);
+ return count != -1;
}
-map<string, string>
-getUdevLinks(const char* path)
-{
- map<string, string> links;
-
- DIR* dir;
- if ((dir = opendir(path)) != NULL)
+ map<string, string>
+ getUdevLinks(const char* path)
{
- struct dirent* entry;
- while ((entry = readdir(dir)) != NULL)
- {
- if (strcmp(entry->d_name, ".") == 0 || strcmp(entry->d_name, "..") == 0)
- continue;
+ map<string, string> links;
- string full = string(path) + "/" + entry->d_name;
+ int fd = open(path, O_RDONLY);
+ if (fd >= 0)
+ {
+ DIR* dir;
+ if ((dir = fdopendir(fd)) != NULL)
+ {
+ struct dirent* entry;
+ while ((entry = readdir(dir)) != NULL)
+ {
+ if (strcmp(entry->d_name, ".") == 0 || strcmp(entry->d_name, "..") == 0)
+ continue;
- string tmp;
- if (readlink(full, tmp))
+ string tmp;
+ if (!readlinkat(fd, entry->d_name, tmp))
+ continue;
+
+ string::size_type pos = tmp.find_first_not_of("./");
+ if (pos != string::npos)
+ links[udevDecode(entry->d_name)] = tmp.substr(pos);
+ }
+ closedir(dir);
+ }
+ else
{
- string::size_type pos = tmp.find_first_not_of("./");
- if (pos != string::npos)
- links[entry->d_name] = tmp.substr(pos);
+ close(fd);
}
}
- closedir(dir);
- }
- return links;
-}
+ return links;
+ }
-void
-getUdevMap(const char* path, map<string, list<string>>& m)
-{
- y2mil( "path: " << path );
+ UdevMap::UdevMap(const string& path)
+ {
+ y2mil("path: " << path);
- map<string, string> links = getUdevLinks(path);
+ const map<string, string> links = getUdevLinks(path.c_str());
- m.clear();
- for (map<string, string>::const_iterator it = links.begin(); it != links.end(); it++)
- m[it->second].push_back(it->first);
+ for (map<string, string>::const_iterator it = links.begin(); it != links.end(); ++it)
+ data[it->second].push_back(it->first);
- y2mil("map: " << m);
-}
+ for (const_iterator it = begin(); it != end(); ++it)
+ y2mil("data[" << it->first << "] -> " << boost::join(it->second, " "));
+ }
-void
-getRevUdevMap(const char* path, map<string, string>& m)
+unsigned
+getMajorDevices(const char* driver)
{
- y2mil("path: " << path);
+ unsigned ret = 0;
+
+ AsciiFile file("/proc/devices");
+ const vector<string>& lines = file.lines();
+
+ Regex rx("^" + Regex::ws + "([0-9]+)" + Regex::ws + string(driver) + "$");
- m = getUdevLinks(path);
+ if (find_if(lines, regex_matches(rx)) != lines.end())
+ rx.cap(1) >> ret;
+ else
+ y2err("did not find " << driver << " in /proc/devices");
- y2mil("map: " << m);
+ y2mil("driver:" << driver << " ret:" << ret);
+ return ret;
}
-unsigned getMajorDevices( const string& driver )
+ void
+ Text::clear()
{
- unsigned ret=0;
- string cmd = "grep \" " + driver + "$\" /proc/devices";
- SystemCmd c( cmd );
- if( c.numLines()>0 )
- {
- extractNthWord( 0, *c.getLine(0)) >> ret;
- }
- y2mil( "driver:" << driver << " ret:" << ret );
- return( ret );
+ native.clear();
+ text.clear();
}
-string sformat(const char* format, ...)
-{
- char* result;
- va_list ap;
+ const Text&
+ Text::operator+=(const Text& a)
+ {
+ native += a.native;
+ text += a.text;
+ return *this;
+ }
- va_start(ap, format);
- if (vasprintf(&result, format, ap) == -1)
- return string();
- va_end(ap);
- string str(result);
- free(result);
- return str;
-}
+ string
+ sformat(const string& format, va_list ap)
+ {
+ char* result;
+ if (vasprintf(&result, format.c_str(), ap) == -1)
+ return string();
-int
-numSuffixes()
-{
- return 6;
-}
+ string str(result);
+ free(result);
+ return str;
+ }
-string
-getSuffix(int i, bool classic, bool sloppy = false)
-{
- switch (i)
+ Text
+ sformat(const Text& format, ...)
{
- case 0:
- if (sloppy)
- return "";
- else
- /* Byte abbreviated */
- return classic ? "B" : _("B");
-
- case 1:
- if (sloppy)
- /* Kilo abbreviated */
- return classic ? "k" : _("k");
- else
- /* KiloByte abbreviated */
- return classic ? "kB" : _("kB");
-
- case 2:
- if (sloppy)
- /* Mega abbreviated */
- return classic ? "M" : _("M");
- else
- /* MegaByte abbreviated */
- return classic ? "MB" : _("MB");
+ Text text;
+ va_list ap;
- case 3:
- if (sloppy)
- /* Giga abbreviated */
- return classic ? "G" : _("G");
- else
- /* GigaByte abbreviated */
- return classic ? "GB" : _("GB");
+ va_start(ap, format);
+ text.native = sformat(format.native, ap);
+ va_end(ap);
- case 4:
- if (sloppy)
- /* Tera abbreviated */
- return classic ? "T" : _("T");
- else
- /* TeraByte abbreviated */
- return classic ? "TB" : _("TB");
+ va_start(ap, format);
+ text.text = sformat(format.text, ap);
+ va_end(ap);
- case 5:
- if (sloppy)
- /* Peta abbreviated */
- return classic ? "P" : _("P");
- else
- /* PetaByte abbreviated */
- return classic ? "PB" : _("PB");
+ return text;
}
- return string("error");
-}
-
-
-string
-byteToHumanString(unsigned long long size, bool classic, int precision, bool omit_zeroes)
-{
- const locale loc = classic ? locale::classic() : locale();
-
- double f = size;
- int i = 0;
- while (f >= 1024.0 && i + 1 < numSuffixes())
+ Text _(const char* msgid)
{
- f /= 1024.0;
- i++;
+ return Text(msgid, dgettext("libstorage", msgid));
}
- if (omit_zeroes && (f == (unsigned long long)(f)))
+ Text _(const char* msgid, const char* msgid_plural, unsigned long int n)
{
- precision = 0;
+ return Text(n == 1 ? msgid : msgid_plural, dngettext("libstorage", msgid, msgid_plural, n));
}
- ostringstream s;
- s.imbue(loc);
- s.setf(ios::fixed);
- s.precision(precision);
-
- s << f << ' ' << getSuffix(i, classic);
-
- return s.str();
-}
+ string
+ hostname()
+ {
+ struct utsname buf;
+ if (uname(&buf) != 0)
+ return string("unknown");
+ string hostname(buf.nodename);
+ if (strlen(buf.domainname) > 0)
+ hostname += "." + string(buf.domainname);
+ return hostname;
+ }
-bool
-humanStringToByte(const string& str, bool classic, unsigned long long& size)
-{
- const locale loc = classic ? locale::classic() : locale();
- const string str_trimmed = boost::trim_copy(str, loc);
+ string
+ datetime()
+ {
+ time_t t1 = time(NULL);
+ struct tm t2;
+ gmtime_r(&t1, &t2);
+ char buf[64 + 1];
+ if (strftime(buf, sizeof(buf), "%F %T %Z", &t2) == 0)
+ return string("unknown");
+ return string(buf);
+ }
- double f = 1.0;
- for (int i = 0; i < numSuffixes(); i++)
+ StopWatch::StopWatch()
{
- for (int j = 0; j < (classic ? 1 : 2); j++)
- {
- string suffix = getSuffix(i, classic, j != 0);
- if (boost::iends_with(str_trimmed, suffix, loc))
- {
- string number = str_trimmed.substr(0, str_trimmed.size() - suffix.size());
+ gettimeofday(&start_tv, NULL);
+ }
- istringstream s(boost::trim_copy(number, loc));
- s.imbue(loc);
- double g;
- s >> g;
+ std::ostream& operator<<(std::ostream& s, const StopWatch& sw)
+ {
+ struct timeval stop_tv;
+ gettimeofday(&stop_tv, NULL);
- if (!s.fail() && s.eof() && g >= 0.0)
- {
- size = g * f;
- return true;
- }
- }
- }
+ struct timeval tv;
+ timersub(&stop_tv, &sw.start_tv, &tv);
- f *= 1024.0;
+ return s << fixed << double(tv.tv_sec) + (double)(tv.tv_usec) / 1000000.0 << "s";
}
- return false;
-}
-
const string app_ws = " \t\n";
Modified: branches/SuSE-Code-11-SP2-Branch/storage/libstorage/src/AppUtil.h
URL: http://svn.opensuse.org/viewcvs/yast/branches/SuSE-Code-11-SP2-Branch/stora…
==============================================================================
--- branches/SuSE-Code-11-SP2-Branch/storage/libstorage/src/AppUtil.h (original)
+++ branches/SuSE-Code-11-SP2-Branch/storage/libstorage/src/AppUtil.h Tue May 17 13:39:44 2011
@@ -1,5 +1,5 @@
/*
- * Copyright (c) [2004-2009] Novell, Inc.
+ * Copyright (c) [2004-2010] Novell, Inc.
*
* All Rights Reserved.
*
@@ -23,55 +23,87 @@
#ifndef APP_UTIL_H
#define APP_UTIL_H
-#include <time.h>
#include <libintl.h>
-#include <string.h>
-#include <cstdarg>
-#include <cstdio>
-#include <fstream>
+#include <sys/time.h>
+#include <sys/types.h>
#include <sstream>
#include <locale>
#include <string>
#include <list>
#include <map>
-using std::string;
namespace storage
{
+ using std::string;
+ using std::list;
+ using std::map;
-class AsciiFile;
-bool searchFile(AsciiFile& File_Cr, string Pat_Cv, string& Line_Cr);
-bool searchFile(AsciiFile& File_Cr, string Pat_Cv, string& Line_Cr,
- int& StartLine_ir);
-void createPath(string Path_Cv);
-bool checkNormalFile(string Path_Cv);
-bool checkDir(string Path_Cv);
+void createPath(const string& Path_Cv);
+bool checkNormalFile(const string& Path_Cv);
+bool checkDir(const string& Path_Cv);
+bool getStatMode(const string& Path_Cv, mode_t& val );
+bool setStatMode(const string& Path_Cv, mode_t val );
+
+ list<string> glob(const string& path, int flags);
+
+ struct StatVfs
+ {
+ unsigned long long sizeK;
+ unsigned long long freeK;
+ };
+
+ bool getStatVfs(const string& path, StatVfs&);
+
+ bool getMajorMinor(const string& device, unsigned long& major, unsigned long& minor);
+
-string dupDash(const string& s);
string extractNthWord(int Num_iv, const string& Line_Cv, bool GetRest_bi = false);
std::list<string> splitString( const string& s, const string& delChars=" \t\n",
bool multipleDelim=true, bool skipEmpty=true,
const string& quotes="" );
-string mergeString( const std::list<string>& l, const string& del=" " );
-std::map<string,string> makeMap( const std::list<string>& l,
+std::map<string,string> makeMap( const std::list<string>& l,
const string& delim = "=",
const string& removeSur = " \t\n" );
+ string udevAppendPart(const string&, unsigned num);
+
+ string udevEncode(const string&);
+ string udevDecode(const string&);
+
+ bool mkdtemp(string& path);
+
bool readlink(const string& path, string& buf);
- string udevAppendPart(const string&, unsigned num);
-void getUdevMap(const char* path, std::map<string, std::list<string>>& m);
-void getRevUdevMap(const char* path, std::map<string, string>& m);
+ class UdevMap
+ {
+ public:
+
+ UdevMap(const string& path);
+
+ typedef map<string, list<string>>::const_iterator const_iterator;
+
+ const_iterator begin() const { return data.begin(); }
+ const_iterator end() const { return data.end(); }
+
+ const_iterator find(const string& nm) const { return data.find(nm); }
+
+ private:
+
+ map<string, list<string>> data;
+
+ };
+
+
+ string normalizeDevice(const string& dev);
+ list<string> normalizeDevices(const list<string>& devs);
+ string undevDevice(const string& dev);
-string normalizeDevice( const string& dev );
-void normalizeDevice( string& dev );
-string undevDevice( const string& dev );
-void undevDevice( string& dev );
bool isNfsDev( const string& dev );
-unsigned getMajorDevices( const string& driver );
+
+unsigned getMajorDevices(const char* driver);
template<class StreamType>
@@ -83,64 +115,71 @@
enum LogLevel { DEBUG, MILESTONE, WARNING, ERROR };
-void createLogger(const string& component, const string& name,
- const string& logpath, const string& logfile);
+void createLogger(const string& name, const string& logpath, const string& logfile);
bool testLogLevel(LogLevel level);
-void logMsg(LogLevel level, const char* file, unsigned line,
- const char* func, const string& str);
+void prepareLogStream(std::ostringstream& stream);
+
+std::ostringstream* logStreamOpen();
-void logMsgVaArgs(LogLevel level, const char* file, unsigned line,
- const char* func, const char* format, ...)
- __attribute__ ((format(printf, 5, 6)));
-
-void prepareLogStream(std::ostringstream& s);
-
-#define y2debug(format, ...) \
- logMsgVaArgs(storage::DEBUG, __FILE__, __LINE__, __FUNCTION__, format, ##__VA_ARGS__)
-#define y2milestone(format, ...) \
- logMsgVaArgs(storage::MILESTONE, __FILE__, __LINE__, __FUNCTION__, format, ##__VA_ARGS__)
-#define y2warning(format, ...) \
- logMsgVaArgs(storage::WARNING, __FILE__, __LINE__, __FUNCTION__, format, ##__VA_ARGS__)
-#define y2error(format, ...) \
- logMsgVaArgs(storage::ERROR, __FILE__, __LINE__, __FUNCTION__, format, ##__VA_ARGS__)
+void logStreamClose(LogLevel level, const char* file, unsigned line,
+ const char* func, std::ostringstream*);
#define y2deb(op) y2log_op(storage::DEBUG, __FILE__, __LINE__, __FUNCTION__, op)
#define y2mil(op) y2log_op(storage::MILESTONE, __FILE__, __LINE__, __FUNCTION__, op)
#define y2war(op) y2log_op(storage::WARNING, __FILE__, __LINE__, __FUNCTION__, op)
#define y2err(op) y2log_op(storage::ERROR, __FILE__, __LINE__, __FUNCTION__, op)
-#define y2log_op(level, file, line, function, op) \
+#define y2log_op(level, file, line, func, op) \
do { \
if (storage::testLogLevel(level)) \
{ \
- std::ostringstream __buf; \
- storage::prepareLogStream(__buf); \
- __buf << op; \
- storage::logMsg(level, file, line, function, __buf.str()); \
+ std::ostringstream* __buf = storage::logStreamOpen(); \
+ *__buf << op; \
+ storage::logStreamClose(level, file, line, func, __buf); \
} \
} while (0)
-string sformat(const char* format, ...);
+ string hostname();
+ string datetime();
-string byteToHumanString(unsigned long long size, bool classic, int precision,
- bool omit_zeroes);
+ class StopWatch
+ {
+ public:
-bool humanStringToByte(const string& str, bool classic, unsigned long long& size);
+ StopWatch();
+ friend std::ostream& operator<<(std::ostream& s, const StopWatch& sw);
-inline const char* _(const char* msgid)
-{
- return dgettext("storage", msgid);
-}
+ protected:
-inline const char* _(const char* msgid, const char* msgid_plural, unsigned long int n)
-{
- return dngettext("storage", msgid, msgid_plural, n);
-}
+ struct timeval start_tv;
+
+ };
+
+
+ struct Text
+ {
+ Text() : native(), text() {}
+ Text(const string& native, const string& text) : native(native), text(text) {}
+
+ void clear();
+
+ const Text& operator+=(const Text& a);
+
+ string native;
+ string text;
+ };
+
+
+ Text sformat(const Text& format, ...);
+
+
+ Text _(const char* msgid);
+ Text _(const char* msgid, const char* msgid_plural, unsigned long int n);
extern const string app_ws;
Added: branches/SuSE-Code-11-SP2-Branch/storage/libstorage/src/ArchInfo.cc
URL: http://svn.opensuse.org/viewcvs/yast/branches/SuSE-Code-11-SP2-Branch/stora…
==============================================================================
--- branches/SuSE-Code-11-SP2-Branch/storage/libstorage/src/ArchInfo.cc (added)
+++ branches/SuSE-Code-11-SP2-Branch/storage/libstorage/src/ArchInfo.cc Tue May 17 13:39:44 2011
@@ -0,0 +1,141 @@
+/*
+ * Copyright (c) [2004-2010] Novell, Inc.
+ *
+ * All Rights Reserved.
+ *
+ * This program is free software; you can redistribute it and/or modify it
+ * under the terms of version 2 of the GNU General Public License as published
+ * by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
+ * more details.
+ *
+ * You should have received a copy of the GNU General Public License along
+ * with this program; if not, contact Novell, Inc.
+ *
+ * To contact Novell about this file by physical or electronic mail, you may
+ * find current contact information at www.novell.com.
+ */
+
+
+#include <string.h>
+#include <sys/utsname.h>
+
+#include "storage/ArchInfo.h"
+#include "storage/AsciiFile.h"
+#include "storage/StorageTypes.h"
+
+
+namespace storage
+{
+
+ ArchInfo::ArchInfo()
+ : arch("i386"), is_ppc_mac(false), is_ppc_pegasos(false), is_efiboot(false)
+ {
+ }
+
+
+ void
+ ArchInfo::readData(const xmlNode* node)
+ {
+ getChildValue(node, "arch", arch);
+
+ if (!getChildValue(node, "efiboot", is_efiboot))
+ is_efiboot = false;
+ }
+
+
+ void
+ ArchInfo::saveData(xmlNode* node) const
+ {
+ setChildValue(node, "arch", arch);
+
+ if (is_efiboot)
+ setChildValue(node, "efiboot", is_efiboot);
+ }
+
+
+ void
+ ArchInfo::detect(bool instsys)
+ {
+ arch = "i386";
+ struct utsname buf;
+ if (uname(&buf) == 0)
+ {
+ if (strncmp(buf.machine, "ppc", 3) == 0)
+ {
+ arch = "ppc";
+ }
+ else if (strncmp(buf.machine, "x86_64", 5) == 0)
+ {
+ arch = "x86_64";
+ }
+ else if (strncmp(buf.machine, "ia64", 4) == 0)
+ {
+ arch = "ia64";
+ }
+ else if (strncmp(buf.machine, "s390", 4) == 0)
+ {
+ arch = "s390";
+ }
+ else if (strncmp(buf.machine, "sparc", 5) == 0)
+ {
+ arch = "sparc";
+ }
+ }
+
+ if (arch == "ppc")
+ {
+ AsciiFile cpuinfo("/proc/cpuinfo");
+ vector<string>::const_iterator it = find_if(cpuinfo.lines(), string_starts_with("machine\t"));
+ if (it != cpuinfo.lines().end())
+ {
+ y2mil("line:" << *it);
+
+ string tmp1 = extractNthWord(2, *it);
+ y2mil("tmp1:" << tmp1);
+ is_ppc_mac = boost::starts_with(tmp1, "PowerMac") || boost::starts_with(tmp1, "PowerBook");
+ is_ppc_pegasos = boost::starts_with(tmp1, "EFIKA5K2");
+
+ if (!is_ppc_mac && !is_ppc_pegasos)
+ {
+ string tmp2 = extractNthWord(3, *it);
+ y2mil("tmp2:" << tmp2);
+ is_ppc_pegasos = boost::starts_with(tmp2, "Pegasos");
+ }
+ }
+ }
+
+ if (arch == "ia64")
+ {
+ is_efiboot = true;
+ }
+ else
+ {
+ string val;
+ if (instsys)
+ {
+ InstallInfFile ii("/etc/install.inf");
+ if (ii.getValue("EFI", val))
+ is_efiboot = val == "1";
+ }
+ else
+ {
+ SysconfigFile sc("/etc/sysconfig/bootloader");
+ if (sc.getValue("LOADER_TYPE", val))
+ is_efiboot = val == "elilo";
+ }
+ }
+ }
+
+
+ std::ostream& operator<<(std::ostream& s, const ArchInfo& archinfo)
+ {
+ return s << "arch:" << archinfo.arch << " is_ppc_mac:" << archinfo.is_ppc_mac
+ << " is_ppc_pegasos:" << archinfo.is_ppc_pegasos << " is_efiboot:"
+ << archinfo.is_efiboot;
+ }
+
+}
Added: branches/SuSE-Code-11-SP2-Branch/storage/libstorage/src/ArchInfo.h
URL: http://svn.opensuse.org/viewcvs/yast/branches/SuSE-Code-11-SP2-Branch/stora…
==============================================================================
--- branches/SuSE-Code-11-SP2-Branch/storage/libstorage/src/ArchInfo.h (added)
+++ branches/SuSE-Code-11-SP2-Branch/storage/libstorage/src/ArchInfo.h Tue May 17 13:39:44 2011
@@ -0,0 +1,57 @@
+/*
+ * Copyright (c) [2004-2010] Novell, Inc.
+ *
+ * All Rights Reserved.
+ *
+ * This program is free software; you can redistribute it and/or modify it
+ * under the terms of version 2 of the GNU General Public License as published
+ * by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
+ * more details.
+ *
+ * You should have received a copy of the GNU General Public License along
+ * with this program; if not, contact Novell, Inc.
+ *
+ * To contact Novell about this file by physical or electronic mail, you may
+ * find current contact information at www.novell.com.
+ */
+
+
+#ifndef ARCH_INFO_H
+#define ARCH_INFO_H
+
+
+#include "storage/XmlFile.h"
+
+
+namespace storage
+{
+
+ class ArchInfo
+ {
+ public:
+
+ ArchInfo();
+
+ void readData(const xmlNode* node);
+ void saveData(xmlNode* node) const;
+
+ void detect(bool instsys);
+
+ string arch;
+ bool is_ppc_mac;
+ bool is_ppc_pegasos;
+ bool is_efiboot;
+
+ };
+
+
+ std::ostream& operator<<(std::ostream& s, const ArchInfo& archinfo);
+
+}
+
+
+#endif
Modified: branches/SuSE-Code-11-SP2-Branch/storage/libstorage/src/AsciiFile.cc
URL: http://svn.opensuse.org/viewcvs/yast/branches/SuSE-Code-11-SP2-Branch/stora…
==============================================================================
--- branches/SuSE-Code-11-SP2-Branch/storage/libstorage/src/AsciiFile.cc (original)
+++ branches/SuSE-Code-11-SP2-Branch/storage/libstorage/src/AsciiFile.cc Tue May 17 13:39:44 2011
@@ -1,5 +1,5 @@
/*
- * Copyright (c) [2004-2009] Novell, Inc.
+ * Copyright (c) [2004-2010] Novell, Inc.
*
* All Rights Reserved.
*
@@ -19,80 +19,50 @@
* find current contact information at www.novell.com.
*/
-// Maintainer: fehr(a)suse.de
-/*
- Textdomain "storage"
-*/
#include <assert.h>
-#include <sys/stat.h>
#include <unistd.h>
#include <fstream>
-#include "y2storage/AppUtil.h"
-#include "y2storage/Regex.h"
-#include "y2storage/SystemCmd.h"
-#include "y2storage/AsciiFile.h"
-
-using namespace std;
-using namespace storage;
+#include "storage/AppUtil.h"
+#include "storage/AsciiFile.h"
+#include "storage/StorageTypes.h"
-AsciiFile::AsciiFile( bool CreateBackup_bv, const char* BackupExt_Cv ) :
- BackupCreated_b(!CreateBackup_bv),
- BackupExtension_C( BackupExt_Cv )
+namespace storage
{
-}
+ using namespace std;
-AsciiFile::AsciiFile( const char* Name_Cv, bool CreateBackup_bv,
- const char* BackupExt_Cv ) :
- BackupCreated_b(!CreateBackup_bv),
- BackupExtension_C( BackupExt_Cv )
- {
- loadFile( Name_Cv );
- }
-AsciiFile::AsciiFile( const string& Name_Cv, bool CreateBackup_bv,
- const char* BackupExt_Cv ) :
- BackupCreated_b(!CreateBackup_bv),
- BackupExtension_C( BackupExt_Cv )
- {
- loadFile( Name_Cv.c_str() );
- }
-
-AsciiFile::~AsciiFile()
- {
- }
+AsciiFile::AsciiFile(const char* Name_Cv, bool remove_empty)
+ : Name_C(Name_Cv),
+ remove_empty(remove_empty)
+{
+ reload();
+}
-bool AsciiFile::loadFile( const string& Name_Cv )
- {
- bool Ret_bi;
- y2mil("Loading File:\"" << Name_Cv << "\"");
- Lines_C.clear();
- Ret_bi = appendFile( Name_Cv, Lines_C );
- Name_C = Name_Cv;
- return Ret_bi;
- }
+AsciiFile::AsciiFile(const string& Name_Cv, bool remove_empty)
+ : Name_C(Name_Cv),
+ remove_empty(remove_empty)
+{
+ reload();
+}
-const string& AsciiFile::fileName() const
- {
- return Name_C;
- }
-bool AsciiFile::appendFile( const string& Name_Cv )
+bool
+AsciiFile::reload()
+{
+ if (Name_C.empty())
{
- return appendFile( Name_Cv, Lines_C );
+ y2err("trying to load nameless AsciiFile");
+ return false;
}
-bool AsciiFile::appendFile( AsciiFile& File_Cv )
-{
- return appendFile( File_Cv, Lines_C );
-}
+ y2mil("loading file " << Name_C);
+ clear();
-bool AsciiFile::appendFile( const string& Name_Cv, vector<string>& Lines_Cr )
-{
- ifstream File_Ci( Name_Cv.c_str() );
+ ifstream File_Ci(Name_C.c_str());
classic(File_Ci);
string Line_Ci;
@@ -100,140 +70,55 @@
File_Ci.unsetf(ifstream::skipws);
getline( File_Ci, Line_Ci );
while( File_Ci.good() )
- {
- Lines_Cr.push_back( Line_Ci );
+ {
+ Lines_C.push_back( Line_Ci );
getline( File_Ci, Line_Ci );
- }
+ }
return Ret_bi;
}
-bool AsciiFile::appendFile( AsciiFile& File_Cv, vector<string>& Lines_Cr )
-{
- unsigned Idx_ii = 0;
-
- while( Idx_ii<File_Cv.numLines() )
- {
- Lines_Cr.push_back( File_Cv[Idx_ii] );
- Idx_ii++;
- }
- return true;
-}
-bool AsciiFile::insertFile( const string& Name_Cv, unsigned int BeforeLine_iv )
+bool
+AsciiFile::save()
{
- ifstream File_Ci( Name_Cv.c_str() );
- classic(File_Ci);
- string Line_Ci;
- vector<string> New_Ci;
-
- bool Ret_bi = File_Ci.good();
- if( Ret_bi )
- {
- unsigned int Idx_ii=0;
- while( Idx_ii<BeforeLine_iv )
- {
- New_Ci.push_back( Lines_C[Idx_ii] );
- Idx_ii++;
- }
- Ret_bi = appendFile( Name_Cv, New_Ci );
- while( Idx_ii<Lines_C.size() )
- {
- New_Ci.push_back( Lines_C[Idx_ii] );
- Idx_ii++;
- }
- Lines_C = New_Ci;
- }
- return Ret_bi;
+ if (Name_C.empty())
+ {
+ y2err("trying to save nameless AsciiFile");
+ return false;
}
-bool AsciiFile::insertFile( AsciiFile& File_Cv, unsigned int BeforeLine_iv )
+ if (remove_empty && Lines_C.empty())
{
- string Line_Ci;
- vector<string> New_Ci;
- bool Ret_bi;
+ y2mil("deleting file " << Name_C);
- unsigned int Idx_ii=0;
- while( Idx_ii<BeforeLine_iv )
- {
- New_Ci.push_back( Lines_C[Idx_ii] );
- Idx_ii++;
- }
- Ret_bi = appendFile( File_Cv, New_Ci );
- while( Idx_ii<Lines_C.size() )
- {
- New_Ci.push_back( Lines_C[Idx_ii] );
- Idx_ii++;
- }
- Lines_C = New_Ci;
- return Ret_bi;
- }
+ if (access(Name_C.c_str(), F_OK) != 0)
+ return true;
-bool AsciiFile::updateFile()
+ return unlink(Name_C.c_str()) == 0;
+ }
+ else
{
- struct stat Stat_ri;
- bool Status_b = stat( Name_C.c_str(), &Stat_ri )==0;
+ y2mil("saving file " << Name_C);
- if( !BackupCreated_b )
- {
- string BakName_Ci = Name_C + BackupExtension_C;
- if( access( Name_C.c_str(), R_OK ) == 0 )
- {
- string OldBakName_Ci = BakName_Ci + ".o";
- if( access( BakName_Ci.c_str(), R_OK ) == 0 &&
- access( OldBakName_Ci.c_str(), R_OK ) != 0 )
- {
- int r = link( BakName_Ci.c_str(), OldBakName_Ci.c_str() );
- if( r==0 )
- unlink( BakName_Ci.c_str() );
- }
- SystemCmd Cmd_Ci;
- string Tmp_Ci = "cp -a ";
- Tmp_Ci += Name_C;
- Tmp_Ci += ' ';
- Tmp_Ci += BakName_Ci;
- Cmd_Ci.execute( Tmp_Ci );
- }
- BackupCreated_b = true;
- }
- ofstream File_Ci( Name_C.c_str() );
- classic(File_Ci);
- unsigned int Idx_ii = 0;
+ ofstream file( Name_C.c_str() );
+ classic(file);
- while( File_Ci.good() && Idx_ii<Lines_C.size() )
- {
- File_Ci << Lines_C[Idx_ii] << std::endl;
- Idx_ii++;
- }
- if( Status_b )
- {
- chmod( Name_C.c_str(), Stat_ri.st_mode );
- }
- return File_Ci.good();
- }
+ for (vector<string>::const_iterator it = Lines_C.begin(); it != Lines_C.end(); ++it)
+ file << *it << std::endl;
-bool AsciiFile::removeIfEmpty()
- {
- bool ret = Lines_C.empty();
- if( ret && access( Name_C.c_str(), W_OK )==0 )
- {
- unlink( Name_C.c_str() );
- y2mil( "deleting file " << Name_C );
- }
- return ret;
+ file.close();
+
+ return file.good();
}
+}
-bool AsciiFile::saveToFile( const string& Name_Cv )
- {
- ofstream File_Ci( Name_Cv.c_str() );
- classic(File_Ci);
- unsigned int Idx_ii = 0;
- while( File_Ci.good() && Idx_ii < Lines_C.size() )
- {
- File_Ci << Lines_C[Idx_ii] << std::endl;
- Idx_ii++;
- }
- return File_Ci.good();
+ void
+ AsciiFile::logContent() const
+ {
+ y2mil("content of " << (Name_C.empty() ? "<nameless>" : Name_C));
+ for (vector<string>::const_iterator it = Lines_C.begin(); it != Lines_C.end(); ++it)
+ y2mil(*it);
}
@@ -251,28 +136,36 @@
Lines_C.push_back( Line_Ci );
}
-void AsciiFile::append( const list<string>& lines )
+void AsciiFile::append( const vector<string>& lines )
{
- for( list<string>::const_iterator i=lines.begin(); i!=lines.end(); ++i )
+ for( vector<string>::const_iterator i=lines.begin(); i!=lines.end(); ++i )
append( *i );
}
-void AsciiFile::replace( unsigned int Start_iv, unsigned int Cnt_iv,
+void AsciiFile::replace( unsigned int Start_iv, unsigned int Cnt_iv,
const string& Lines_Cv )
{
remove( Start_iv, Cnt_iv );
insert( Start_iv, Lines_Cv );
}
-void AsciiFile::replace( unsigned int Start_iv, unsigned int Cnt_iv,
- const list<string>& lines )
+void AsciiFile::replace( unsigned int Start_iv, unsigned int Cnt_iv,
+ const vector<string>& lines )
{
remove( Start_iv, Cnt_iv );
- for( list<string>::const_reverse_iterator i=lines.rbegin(); i!=lines.rend();
+ for( vector<string>::const_reverse_iterator i=lines.rbegin(); i!=lines.rend();
++i )
insert( Start_iv, *i );
}
+
+void
+AsciiFile::clear()
+{
+ Lines_C.clear();
+}
+
+
void AsciiFile::remove( unsigned int Start_iv, unsigned int Cnt_iv )
{
Start_iv = max( 0u, Start_iv );
@@ -339,85 +232,39 @@
return Lines_C[Idx_iv];
}
-int AsciiFile::find( unsigned Start_iv, Regex& Pat_Cv ) const
- {
- unsigned Idx_ii = Start_iv;
- int Ret_ii = -1;
- while( Ret_ii<0 && Idx_ii<Lines_C.size() )
- {
- if( Pat_Cv.match( Lines_C[Idx_ii] ))
- {
- Ret_ii = Idx_ii;
- }
- else
- {
- Idx_ii++;
- }
- }
- return Ret_ii;
- }
-int AsciiFile::find( unsigned int Start_iv, const string& Pat_Cv ) const
+void AsciiFile::removeLastIf (string& Text_Cr, char Char_cv) const
+{
+ if (Text_Cr.length() > 0 && Text_Cr[Text_Cr.length() - 1] == Char_cv)
+ Text_Cr.erase(Text_Cr.length() - 1);
+}
+
+
+ bool
+ SysconfigFile::getValue(const string& key, string& value) const
{
- string::size_type Pos_ii;
- unsigned int Idx_ii = Start_iv;
- int Ret_ii = -1;
- string Pat_Ci = Pat_Cv;
- bool BeginOfLine_bi = Pat_Ci.length()>0 && Pat_Ci[0]=='^';
+ Regex rx('^' + Regex::ws + key + '=' + "(['\"]?)([^'\"]*)\\1" + Regex::ws + '$');
- if( BeginOfLine_bi )
- {
- Pat_Ci.erase( 0, 1 );
- }
- while( Ret_ii<0 && Idx_ii<Lines_C.size() )
- {
- if( (Pos_ii=Lines_C[Idx_ii].find( Pat_Ci )) != string::npos )
- {
- if( !BeginOfLine_bi || (BeginOfLine_bi && Pos_ii==0) )
- {
- Ret_ii = Idx_ii;
- }
- else
- {
- Idx_ii++;
- }
- }
- else
- {
- Idx_ii++;
- }
- }
- return Ret_ii;
+ if (find_if(lines(), regex_matches(rx)) == lines().end())
+ return false;
+
+ value = rx.cap(2);
+ y2mil("key:" << key << " value:" << value);
+ return true;
}
-unsigned AsciiFile::numLines() const
+
+ bool
+ InstallInfFile::getValue(const string& key, string& value) const
{
- return Lines_C.size();
- }
+ Regex rx('^' + key + ":" + Regex::ws + "([^ ]*)" + '$');
-unsigned AsciiFile::differentLine( const AsciiFile& File_Cv ) const
- {
- int Ret_ii = -1;
- unsigned Cnt_ii = min( numLines(), File_Cv.numLines() );
- unsigned I_ii = 0;
- while( I_ii<Cnt_ii && (*this)[I_ii]==File_Cv[I_ii] )
- {
- I_ii++;
- }
- if( I_ii<Cnt_ii )
- {
- Ret_ii = I_ii;
- }
- else if( numLines()>Cnt_ii || File_Cv.numLines()>Cnt_ii )
- {
- Ret_ii = Cnt_ii;
- }
- return Ret_ii;
- }
+ if (find_if(lines(), regex_matches(rx)) == lines().end())
+ return false;
+ value = rx.cap(1);
+ y2mil("key:" << key << " value:" << value);
+ return true;
+ }
-void AsciiFile::removeLastIf (string& Text_Cr, char Char_cv) const
-{
- if (Text_Cr.length() > 0 && Text_Cr[Text_Cr.length() - 1] == Char_cv)
- Text_Cr.erase(Text_Cr.length() - 1);
}
Modified: branches/SuSE-Code-11-SP2-Branch/storage/libstorage/src/AsciiFile.h
URL: http://svn.opensuse.org/viewcvs/yast/branches/SuSE-Code-11-SP2-Branch/stora…
==============================================================================
--- branches/SuSE-Code-11-SP2-Branch/storage/libstorage/src/AsciiFile.h (original)
+++ branches/SuSE-Code-11-SP2-Branch/storage/libstorage/src/AsciiFile.h Tue May 17 13:39:44 2011
@@ -1,5 +1,5 @@
/*
- * Copyright (c) [2004-2009] Novell, Inc.
+ * Copyright (c) [2004-2010] Novell, Inc.
*
* All Rights Reserved.
*
@@ -23,63 +23,93 @@
#ifndef ASCII_FILE_H
#define ASCII_FILE_H
+
+#include <string>
#include <vector>
-#include <list>
+#include <algorithm>
-using std::string;
namespace storage
{
-
-class Regex;
+ using std::string;
+ using std::vector;
-class AsciiFile
+ class AsciiFile
{
public:
- AsciiFile( bool CreateBackup_bv=false,
- const char* BackupExt_Cv=".orig" );
- AsciiFile( const string& Name_Cv, bool CreateBackup_bv=false,
- const char* BackupExt_Cv=".orig" );
- AsciiFile( const char* Name_Cv, bool CreateBackup_bv=false,
- const char* BackupExt_Cv=".orig" );
- ~AsciiFile();
- bool insertFile( AsciiFile& File_Cv, unsigned int BeforeLine_iv=0 );
- bool appendFile( AsciiFile& File_Cv );
- bool insertFile( const string& Name_Cv, unsigned int BeforeLine_iv=0 );
- bool appendFile( const string& Name_Cv );
- bool loadFile( const string& Name_Cv );
- bool updateFile();
- bool saveToFile( const string& Name_Cv );
+
+ explicit AsciiFile(const char* name, bool remove_empty = false);
+ explicit AsciiFile(const string& name, bool remove_empty = false);
+
+ string name() const { return Name_C; }
+
+ bool reload();
+ bool save();
+
+ void logContent() const;
+
void append( const string& Line_Cv );
- void append( const std::list<string>& Lines_Cv );
+ void append( const vector<string>& Lines_Cv );
void insert( unsigned int Before_iv, const string& Line_Cv );
+ void clear();
void remove( unsigned int Start_iv, unsigned int Cnt_iv );
void replace( unsigned int Start_iv, unsigned int Cnt_iv,
const string& Line_Cv );
void replace( unsigned int Start_iv, unsigned int Cnt_iv,
- const std::list<string>& Line_Cv );
+ const vector<string>& Line_Cv );
+
const string& operator []( unsigned int Index_iv ) const;
string& operator []( unsigned int Index_iv );
- int find( unsigned int Start_iv, const string& Pat_Cv ) const;
- int find( unsigned int Start_iv, Regex& Pat_Cv ) const;
- unsigned numLines() const;
- std::vector<string>& lines() { return Lines_C; }
- const string& fileName() const;
- unsigned differentLine( const AsciiFile& File_Cv ) const;
- bool removeIfEmpty();
+
+ template <class Pred>
+ int find_if_idx(Pred pred) const
+ {
+ vector<string>::const_iterator it = std::find_if(Lines_C.begin(), Lines_C.end(), pred);
+ if (it == Lines_C.end())
+ return -1;
+ return std::distance(Lines_C.begin(), it);
+ }
+
+ unsigned numLines() const { return Lines_C.size(); }
+
+ vector<string>& lines() { return Lines_C; }
+ const vector<string>& lines() const { return Lines_C; }
protected:
- bool appendFile( const string& Name_Cv, std::vector<string>& Lines_Cr );
- bool appendFile( AsciiFile& File_Cv, std::vector<string>& Lines_Cr );
+
void removeLastIf(string& Text_Cr, char Char_cv) const;
- bool BackupCreated_b;
- string BackupExtension_C;
- std::vector<string> Lines_C;
- string Name_C;
+ const string Name_C;
+ const bool remove_empty;
+
+ vector<string> Lines_C;
+
+ };
+
+
+ class SysconfigFile : protected AsciiFile
+ {
+ public:
+
+ SysconfigFile(const char* name) : AsciiFile(name) {}
+
+ bool getValue(const string& key, string& value) const;
+
+ };
+
+
+ class InstallInfFile : protected AsciiFile
+ {
+ public:
+
+ InstallInfFile(const char* name) : AsciiFile(name) {}
+
+ bool getValue(const string& key, string& value) const;
+
};
}
+
#endif
Added: branches/SuSE-Code-11-SP2-Branch/storage/libstorage/src/Blkid.cc
URL: http://svn.opensuse.org/viewcvs/yast/branches/SuSE-Code-11-SP2-Branch/stora…
==============================================================================
--- branches/SuSE-Code-11-SP2-Branch/storage/libstorage/src/Blkid.cc (added)
+++ branches/SuSE-Code-11-SP2-Branch/storage/libstorage/src/Blkid.cc Tue May 17 13:39:44 2011
@@ -0,0 +1,208 @@
+/*
+ * Copyright (c) [2004-2009] Novell, Inc.
+ *
+ * All Rights Reserved.
+ *
+ * This program is free software; you can redistribute it and/or modify it
+ * under the terms of version 2 of the GNU General Public License as published
+ * by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
+ * more details.
+ *
+ * You should have received a copy of the GNU General Public License along
+ * with this program; if not, contact Novell, Inc.
+ *
+ * To contact Novell about this file by physical or electronic mail, you may
+ * find current contact information at www.novell.com.
+ */
+
+
+#include "storage/AppUtil.h"
+#include "storage/SystemCmd.h"
+#include "storage/StorageDefines.h"
+#include "storage/Blkid.h"
+#include "storage/Volume.h"
+
+
+namespace storage
+{
+ using namespace std;
+
+
+ Blkid::Blkid()
+ {
+ SystemCmd cmd("BLKID_SKIP_CHECK_MDRAID=1 " BLKIDBIN " -c /dev/null");
+ if (cmd.retcode() == 0)
+ parse(cmd.stdout());
+ }
+
+
+ Blkid::Blkid(const string& device)
+ {
+ SystemCmd cmd("BLKID_SKIP_CHECK_MDRAID=1 " BLKIDBIN " -c /dev/null " + quote(device));
+ if (cmd.retcode() == 0)
+ parse(cmd.stdout());
+ }
+
+
+ void
+ Blkid::parse(const vector<string>& lines)
+ {
+ data.clear();
+
+ for (vector<string>::const_iterator it = lines.begin(); it != lines.end(); ++it)
+ {
+ string::size_type pos = it->find(":");
+ if (pos == string::npos)
+ continue;
+
+ string device = string(*it, 0, pos);
+ list<string> l = splitString(string(*it, pos + 1), " \t\n", true, true, "\"");
+
+ Entry entry;
+
+ const map<string, string> m = makeMap(l, "=", "\"");
+
+ map<string, string>::const_iterator i = m.find("TYPE");
+ if (i != m.end())
+ {
+ if (i->second == "reiserfs")
+ {
+ entry.is_fs = true;
+ entry.fs_type = REISERFS;
+ }
+ else if (i->second == "swap")
+ {
+ entry.is_fs = true;
+ entry.fs_type = SWAP;
+ }
+ else if (i->second == "ext2")
+ {
+ entry.is_fs = true;
+ entry.fs_type = EXT2;
+ }
+ else if (i->second == "ext3")
+ {
+ entry.is_fs = true;
+ entry.fs_type = EXT3;
+ }
+ else if (i->second == "ext4")
+ {
+ entry.is_fs = true;
+ entry.fs_type = EXT4;
+ }
+ else if (i->second == "btrfs")
+ {
+ entry.is_fs = true;
+ entry.fs_type = BTRFS;
+ }
+ else if (i->second == "vfat")
+ {
+ entry.is_fs = true;
+ entry.fs_type = VFAT;
+ }
+ else if (i->second == "ntfs" || i->second == "ntfs-3g")
+ {
+ entry.is_fs = true;
+ entry.fs_type = NTFS;
+ }
+ else if (i->second == "jfs")
+ {
+ entry.is_fs = true;
+ entry.fs_type = JFS;
+ }
+ else if (i->second == "hfs")
+ {
+ entry.is_fs = true;
+ entry.fs_type = HFS;
+ }
+ else if (i->second == "hfsplus")
+ {
+ entry.is_fs = true;
+ entry.fs_type = HFSPLUS;
+ }
+ else if (i->second == "xfs")
+ {
+ entry.is_fs = true;
+ entry.fs_type = XFS;
+ }
+ else if (i->second == "LVM2_member")
+ {
+ entry.is_lvm = true;
+ }
+ else if (i->second == "crypto_LUKS")
+ {
+ entry.is_luks = true;
+ }
+ }
+
+ if (entry.is_fs)
+ {
+ i = m.find("UUID");
+ if (i != m.end())
+ entry.fs_uuid = i->second;
+
+ i = m.find("LABEL");
+ if (i != m.end())
+ entry.fs_label = i->second;
+ }
+
+ if (entry.is_luks)
+ {
+ i = m.find("UUID");
+ if (i != m.end())
+ entry.luks_uuid = i->second;
+ }
+
+ if (entry.is_fs || entry.is_lvm || entry.is_luks)
+ data[device] = entry;
+ }
+
+ for (const_iterator it = data.begin(); it != data.end(); ++it)
+ y2mil("data[" << it->first << "] -> " << it->second);
+ }
+
+
+ bool
+ Blkid::getEntry(const string& device, Entry& entry) const
+ {
+ const_iterator i = data.find(device);
+ if (i == data.end())
+ return false;
+
+ entry = i->second;
+ return true;
+ }
+
+
+ std::ostream& operator<<(std::ostream& s, const Blkid::Entry& entry)
+ {
+ if (entry.is_fs)
+ {
+ s << "is_fs:" << entry.is_fs;
+ s << " fs_type:" << toString(entry.fs_type);
+ if (!entry.fs_uuid.empty())
+ s << " fs_uuid:" << entry.fs_uuid;
+ if (!entry.fs_label.empty())
+ s << " fs_label:" << entry.fs_label;
+ }
+
+ if (entry.is_lvm)
+ {
+ s << "is_lvm:" << entry.is_lvm;
+ }
+
+ if (entry.is_luks)
+ {
+ s << "is_luks:" << entry.is_luks;
+ if (!entry.luks_uuid.empty())
+ s << " luks_uuid:" << entry.luks_uuid;
+ }
+
+ return s;
+ }
+
+}
Added: branches/SuSE-Code-11-SP2-Branch/storage/libstorage/src/Blkid.h
URL: http://svn.opensuse.org/viewcvs/yast/branches/SuSE-Code-11-SP2-Branch/stora…
==============================================================================
--- branches/SuSE-Code-11-SP2-Branch/storage/libstorage/src/Blkid.h (added)
+++ branches/SuSE-Code-11-SP2-Branch/storage/libstorage/src/Blkid.h Tue May 17 13:39:44 2011
@@ -0,0 +1,79 @@
+/*
+ * Copyright (c) [2004-2009] Novell, Inc.
+ *
+ * All Rights Reserved.
+ *
+ * This program is free software; you can redistribute it and/or modify it
+ * under the terms of version 2 of the GNU General Public License as published
+ * by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
+ * more details.
+ *
+ * You should have received a copy of the GNU General Public License along
+ * with this program; if not, contact Novell, Inc.
+ *
+ * To contact Novell about this file by physical or electronic mail, you may
+ * find current contact information at www.novell.com.
+ */
+
+
+#ifndef BLKID_H
+#define BLKID_H
+
+#include <string>
+#include <map>
+#include <vector>
+
+#include "storage/StorageInterface.h"
+
+
+namespace storage
+{
+ using std::map;
+ using std::vector;
+
+
+ class Blkid
+ {
+ public:
+
+ Blkid();
+ Blkid(const string& device);
+
+ struct Entry
+ {
+ Entry() : is_fs(false), fs_type(FSUNKNOWN), fs_uuid(), fs_label(),
+ is_lvm(false), is_luks(false), luks_uuid() {}
+
+ bool is_fs;
+ FsType fs_type;
+ string fs_uuid;
+ string fs_label;
+
+ bool is_lvm;
+
+ bool is_luks;
+ string luks_uuid;
+ };
+
+ friend std::ostream& operator<<(std::ostream& s, const Entry& entry);
+
+ bool getEntry(const string& device, Entry& entry) const;
+
+ protected:
+
+ void parse(const vector<string>& lines);
+
+ typedef map<string, Entry>::const_iterator const_iterator;
+
+ map<string, Entry> data;
+
+ };
+
+}
+
+
+#endif
Added: branches/SuSE-Code-11-SP2-Branch/storage/libstorage/src/Btrfs.cc
URL: http://svn.opensuse.org/viewcvs/yast/branches/SuSE-Code-11-SP2-Branch/stora…
==============================================================================
--- branches/SuSE-Code-11-SP2-Branch/storage/libstorage/src/Btrfs.cc (added)
+++ branches/SuSE-Code-11-SP2-Branch/storage/libstorage/src/Btrfs.cc Tue May 17 13:39:44 2011
@@ -0,0 +1,765 @@
+/*
+ * Copyright (c) [2004-2011] Novell, Inc.
+ *
+ * All Rights Reserved.
+ *
+ * This program is free software; you can redistribute it and/or modify it
+ * under the terms of version 2 of the GNU General Public License as published
+ * by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
+ * more details.
+ *
+ * You should have received a copy of the GNU General Public License along
+ * with this program; if not, contact Novell, Inc.
+ *
+ * To contact Novell about this file by physical or electronic mail, you may
+ * find current contact information at www.novell.com.
+ */
+
+
+#include <sys/stat.h>
+#include <sstream>
+
+#include "storage/Btrfs.h"
+#include "storage/StorageTypes.h"
+#include "storage/Container.h"
+#include "storage/AppUtil.h"
+#include "storage/SystemInfo.h"
+#include "storage/Storage.h"
+#include "storage/SystemCmd.h"
+#include "storage/StorageDefines.h"
+
+
+namespace storage
+{
+using namespace std;
+
+Btrfs::Btrfs(const BtrfsCo& d, const Volume& v, unsigned long long sz,
+ const list<string>& devs ) : Volume(d, v), devices(devs)
+ {
+ y2mil("constructed btrfs vol size:" << sz << " devs:" << devs );
+ y2mil("constructed btrfs vol from:" << v );
+ changeMountBy(MOUNTBY_UUID);
+ setSize( sz );
+ }
+
+Btrfs::Btrfs(const BtrfsCo& d, const Volume& v ) : Volume(d, v)
+ {
+ y2mil("constructed btrfs vol from:" << v );
+ y2mil( "fs:" << fs << " det:" << detected_fs );
+ changeMountBy(MOUNTBY_UUID);
+ devices.push_back(v.device());
+ }
+
+Btrfs::Btrfs(const BtrfsCo& d, const xmlNode* node ) : Volume(d, node)
+ {
+ list<const xmlNode*> l = getChildNodes(node, "devices");
+ for( list<const xmlNode*>::const_iterator it=l.begin(); it!=l.end(); ++it )
+ {
+ string s;
+ getChildValue(*it, "devices", s);
+ devices.push_back(s);
+ }
+ l = getChildNodes(node, "dev_add");
+ for( list<const xmlNode*>::const_iterator it=l.begin(); it!=l.end(); ++it )
+ {
+ string s;
+ getChildValue(*it, "devices", s);
+ dev_add.push_back(s);
+ }
+ l = getChildNodes(node, "dev_rem");
+ for( list<const xmlNode*>::const_iterator it=l.begin(); it!=l.end(); ++it )
+ {
+ string s;
+ getChildValue(*it, "devices", s);
+ dev_rem.push_back(s);
+ }
+ l = getChildNodes(node, "subvolumes");
+ for (list<const xmlNode*>::const_iterator it=l.begin(); it!=l.end(); ++it )
+ {
+ subvol.push_back(Subvolume(*it));
+ }
+ }
+
+
+Btrfs::Btrfs(const BtrfsCo& c, const Btrfs& v) : Volume(c, v),
+ devices(v.devices), subvol(v.subvol)
+ {
+ y2deb("copy-constructed Btrfs from " << v.dev);
+ }
+
+
+Btrfs::~Btrfs()
+ {
+ y2deb("destructed Btrfs " << dev);
+ }
+
+void Btrfs::addSubvol( const string& path )
+ {
+ y2mil( "path:\"" << path << "\"" );
+ Subvolume v( path );
+ if( !contains( subvol, v ))
+ subvol.push_back( v );
+ else
+ y2war( "subvolume " << v << " already exists!" );
+ }
+
+int
+Btrfs::createSubvolume( const string& name )
+ {
+ int ret=0;
+ y2mil( "name:" << name );
+ list<Subvolume>::iterator i=subvol.begin();
+ while( i!=subvol.end() && !i->deleted() && i->path()!=name )
+ ++i;
+ if( i==subvol.end() )
+ {
+ Subvolume v( name );
+ v.setCreated();
+ subvol.push_back( v );
+ }
+ else
+ ret = BTRFS_SUBVOL_EXISTS;
+ y2mil( "ret:" << ret );
+ return( ret );
+ }
+
+int
+Btrfs::deleteSubvolume( const string& name )
+ {
+ int ret=0;
+ y2mil( "name:" << name );
+ list<Subvolume>::iterator i=subvol.begin();
+ while( i!=subvol.end() && i->path()!=name )
+ ++i;
+ if( i!=subvol.end() )
+ {
+ if( i->created() )
+ subvol.erase(i);
+ else
+ i->setDeleted();
+ }
+ else
+ ret = BTRFS_SUBVOL_NON_EXISTS;
+ y2mil( "ret:" << ret );
+ return( ret );
+ }
+
+int Btrfs::extendVolume( const string& dev )
+ {
+ list<string> d;
+ d.push_back(dev);
+ return( extendVolume(d));
+ }
+
+int Btrfs::extendVolume( const list<string>& devs )
+ {
+ int ret = 0;
+ y2mil( "name:" << name() << " devices:" << devs );
+ y2mil( "this:" << *this );
+
+ list<string>::const_iterator i=devs.begin();
+ list<string>::iterator p;
+ while( ret==0 && i!=devs.end() )
+ {
+ string d = normalizeDevice( *i );
+ if( (p=find( devices.begin(), devices.end(), d ))!=devices.end() ||
+ (p=find( dev_add.begin(), dev_add.end(), d ))!=dev_add.end())
+ ret = BTRFS_DEV_ALREADY_CONTAINED;
+ else if( (p=find( dev_rem.begin(), dev_rem.end(), d )) != dev_rem.end() &&
+ !getStorage()->deletedDevice( d ) )
+ {
+ }
+ else if( !getStorage()->knownDevice( d, true ) )
+ {
+ ret = BTRFS_DEVICE_UNKNOWN;
+ }
+ else if( !getStorage()->canUseDevice( d, true ) )
+ {
+ ret = BTRFS_DEVICE_USED;
+ }
+ ++i;
+ }
+ i=devs.begin();
+ while( ret==0 && i!=devs.end() )
+ {
+ string d = normalizeDevice( *i );
+ if( (p=find( dev_rem.begin(), dev_rem.end(), d )) != dev_rem.end() &&
+ !getStorage()->deletedDevice( d ) )
+ {
+ devices.push_back( *p );
+ dev_rem.erase( p );
+ }
+ else
+ {
+ dev_add.push_back( d );
+ if( !getStorage()->isDisk(d))
+ getStorage()->changeFormatVolume( d, false, FSNONE );
+ }
+ getStorage()->setUsedBy(d, UB_BTRFS, device());
+ setSize( size_k+getStorage()->deviceSize( d ) );
+ ++i;
+ }
+ if( ret==0 && dev_add.size()+devices.size()-dev_rem.size()<=0 )
+ ret = BTRFS_HAS_NONE_DEV;
+ y2mil( "this:" << *this );
+ y2mil("ret:" << ret);
+ return( ret );
+ }
+
+int Btrfs::shrinkVolume( const string& dev )
+ {
+ list<string> d;
+ d.push_back(dev);
+ return( shrinkVolume(d));
+ }
+
+int Btrfs::shrinkVolume( const list<string>& devs )
+ {
+ int ret = 0;
+ y2mil("name:" << name() << " devices:" << devs);
+ y2mil("this:" << *this);
+
+ list<string>::const_iterator i = devs.begin();
+ list<string>::iterator p;
+ while( ret==0 && i!=devs.end() )
+ {
+ string d = normalizeDevice( *i );
+ if( (p=find( devices.begin(), devices.end(), d ))==devices.end() &&
+ (p=find( dev_add.begin(), dev_add.end(), d ))==dev_add.end())
+ ret = BTRFS_DEV_NOT_FOUND;
+ ++i;
+ }
+ unsigned long long s = size_k;
+ i = devs.begin();
+ while( ret==0 && i!=devs.end() )
+ {
+ string d = normalizeDevice( *i );
+ if( (p=find( dev_add.begin(), dev_add.end(), d ))!=dev_add.end())
+ dev_add.erase(p);
+ else
+ dev_rem.push_back(d);
+ getStorage()->clearUsedBy(d);
+ s -= min(getStorage()->deviceSize( d ),s);
+ setSize( size_k-getStorage()->deviceSize( d ) );
+ ++i;
+ }
+ if( ret==0 && dev_add.size()+devices.size()-devs.size()<=0 )
+ ret = BTRFS_HAS_NONE_DEV;
+ if( ret == 0 )
+ {
+ setSize( s );
+ }
+ y2mil("this:" << *this);
+ y2mil("ret:" << ret);
+ return ret;
+ }
+
+int Btrfs::doExtend()
+ {
+ y2mil( "this:" << *this );
+ int ret = 0;
+ bool needUmount = false;
+ Storage* st = NULL;
+ string m = getMount();
+ if( !isMounted() )
+ {
+ st = getContainer()->getStorage();
+ if( st->mountTmp( this, m ) )
+ needUmount = true;
+ else
+ ret = BTRFS_CANNOT_TMP_MOUNT;
+ }
+ list<string> devs = dev_add;
+ list<string>::const_iterator d = devs.begin();
+ SystemCmd c;
+ while( ret==0 && d!=devs.end() )
+ {
+ if( !silent )
+ getStorage()->showInfoCb(extendText(true, *d));
+ string cmd = BTRFSBIN " device add " + quote(*d) + " " + m;
+ c.execute( cmd );
+ if( c.retcode()==0 )
+ {
+ devices.push_back(*d);
+ dev_add.remove_if( bind2nd(equal_to<string>(),*d));
+ }
+ else
+ ret = BTRFS_EXTEND_FAIL;
+ ++d;
+ }
+ if( needUmount )
+ {
+ if( !st->umountDev( device() ) && ret==0 )
+ {
+ ret = BTRFS_CANNOT_TMP_UMOUNT;
+ }
+ }
+ y2mil( "this:" << *this );
+ y2mil("ret:" << ret);
+ return( ret );
+ }
+
+int Btrfs::doReduce()
+ {
+ y2mil( "this:" << *this );
+ int ret = 0;
+ bool needUmount = false;
+ Storage* st = NULL;
+ string m = getMount();
+ if( !isMounted() )
+ {
+ st = getContainer()->getStorage();
+ if( st->mountTmp( this, m ) )
+ needUmount = true;
+ else
+ ret = BTRFS_CANNOT_TMP_MOUNT;
+ }
+ list<string> devs = dev_rem;
+ list<string>::const_iterator d = devs.begin();
+ SystemCmd c;
+ while( ret==0 && d!=devs.end() )
+ {
+ if( !silent )
+ getStorage()->showInfoCb(reduceText(true, *d));
+ string cmd = BTRFSBIN " device delete " + quote(*d) + " " + m;
+ c.execute( cmd );
+ if( c.retcode()==0 )
+ {
+ devices.remove_if( bind2nd(equal_to<string>(),*d));
+ dev_rem.remove_if( bind2nd(equal_to<string>(),*d));
+ }
+ else
+ ret = BTRFS_REDUCE_FAIL;
+ ++d;
+ }
+ if( needUmount )
+ {
+ if( !st->umountDev( device() ) && ret==0 )
+ {
+ ret = BTRFS_CANNOT_TMP_UMOUNT;
+ }
+ }
+ y2mil( "this:" << *this );
+ y2mil("ret:" << ret);
+ return( ret );
+ }
+
+int Btrfs::doDeleteSubvol()
+ {
+ int ret = 0;
+ bool needUmount = false;
+ Storage* st = NULL;
+ string m = getMount();
+ if( !isMounted() )
+ {
+ st = getContainer()->getStorage();
+ if( st->mountTmp( this, m ) )
+ needUmount = true;
+ else
+ ret = BTRFS_CANNOT_TMP_MOUNT;
+ }
+ if( ret==0 )
+ {
+ SystemCmd c;
+ string cmd = BTRFSBIN " subvolume delete " + m + '/';
+ for( list<Subvolume>::iterator i=subvol.begin(); i!=subvol.end(); ++i )
+ {
+ if( i->deleted() )
+ {
+ if( !silent )
+ getStorage()->showInfoCb( deleteSubvolText(true,i->path()));
+ c.execute( cmd + i->path() );
+ if( c.retcode()==0 )
+ i->setDeleted(false);
+ else
+ ret = BTRFS_DELETE_SUBVOL_FAIL;
+ }
+ }
+ }
+ if( needUmount )
+ {
+ if( !st->umountDev( device() ) && ret==0 )
+ {
+ ret = BTRFS_CANNOT_TMP_UMOUNT;
+ }
+ }
+ y2mil( "ret:" << ret );
+ return( ret );
+ }
+
+int Btrfs::doCreateSubvol()
+ {
+ int ret = 0;
+ bool needUmount = false;
+ Storage* st = NULL;
+ string m = getMount();
+ if( !isMounted() )
+ {
+ st = getContainer()->getStorage();
+ if( st->mountTmp( this, m ) )
+ needUmount = true;
+ else
+ ret = BTRFS_CANNOT_TMP_MOUNT;
+ }
+ if( ret==0 )
+ {
+ SystemCmd c;
+ string cmd = BTRFSBIN " subvolume create " + m + '/';
+ for( list<Subvolume>::iterator i=subvol.begin(); i!=subvol.end(); ++i )
+ {
+ if( i->created() )
+ {
+ if( !silent )
+ getStorage()->showInfoCb( createSubvolText(true,i->path()));
+ c.execute( cmd + i->path() );
+ if( c.retcode()==0 )
+ i->setCreated(false);
+ else
+ ret = BTRFS_CREATE_SUBVOL_FAIL;
+ }
+ }
+ }
+ if( needUmount )
+ {
+ if( !st->umountDev( device() ) && ret==0 )
+ {
+ ret = BTRFS_CANNOT_TMP_UMOUNT;
+ }
+ }
+ y2mil( "ret:" << ret );
+ return( ret );
+ }
+
+list<string> Btrfs::getSubvolAddDel( bool add ) const
+ {
+ list<string> ret;
+ list<Subvolume>::const_iterator i;
+ for( i=subvol.begin(); i!=subvol.end(); ++i )
+ {
+ if( !add && i->deleted() )
+ ret.push_back(i->path());
+ if( add && i->created() )
+ ret.push_back(i->path());
+ }
+ if( !ret.empty() )
+ y2mil( "add:" << add << " ret:" << ret );
+ return( ret );
+ }
+
+void
+Btrfs::countSubvolAddDel( unsigned& add, unsigned& del ) const
+ {
+ add = del = 0;
+ for( list<Subvolume>::const_iterator i=subvol.begin();
+ i!=subvol.end(); ++i )
+ {
+ if( i->deleted() )
+ del++;
+ if( i->created() )
+ add++;
+ }
+ if( add>0 || del>0 )
+ y2mil( "add:" << add << " del:" << del );
+ }
+
+string
+Btrfs::subvolNames( bool added ) const
+ {
+ string ret;
+ for( list<Subvolume>::const_iterator i=subvol.begin();
+ i!=subvol.end(); ++i )
+ {
+ if( (added && i->created()) ||
+ (!added && i->deleted()))
+ {
+ if( !ret.empty() )
+ ret += ' ';
+ ret += i->path();
+ }
+ }
+ y2mil( "ret:" << ret );
+ return( ret );
+ }
+
+void Btrfs::unuseDev() const
+ {
+ for( list<string>::const_iterator s=devices.begin(); s!=devices.end(); ++s )
+ getContainer()->getStorage()->clearUsedBy(*s);
+ for( list<string>::const_iterator s=dev_add.begin(); s!=dev_add.end(); ++s )
+ getContainer()->getStorage()->clearUsedBy(*s);
+ }
+
+int Btrfs::clearSignature()
+ {
+ int ret = 0;
+ // no need to actually remove signature from single volume btrfs filesystems
+ if( devices.size()>1 )
+ {
+ for( list<string>::const_iterator s=devices.begin(); s!=devices.end(); ++s )
+ getContainer()->getStorage()->zeroDevice(*s,0);
+ }
+ y2mil( "ret:" << ret );
+ return( ret );
+ }
+
+Text Btrfs::removeText(bool doing) const
+ {
+ Text txt;
+ string d = boost::join( devices, " " );
+ if( doing )
+ {
+ // displayed text during action, %1$s is replaced by device names e.g /dev/sda1 /dev/sda2
+ txt = sformat( _("Deleting Btrfs volume on devices %1$s"), d.c_str() );
+ }
+ else
+ {
+ // displayed text before action, %1$s is replaced by device names e.g /dev/sda1 /dev/sda2
+ // %2$s is replaced by size (e.g. 623.5 MB)
+ txt = sformat( _("Delete Btrfs volume on devices %1$s (%2$s)"),
+ d.c_str(), sizeString().c_str() );
+ }
+ return( txt );
+ }
+
+void
+Btrfs::getCommitActions(list<commitAction>& l) const
+ {
+ Volume::getCommitActions( l );
+ unsigned rem, add;
+ list<string>::const_iterator i;
+ if( !dev_add.empty() )
+ for( i=dev_add.begin(); i!=dev_add.end(); ++i )
+ l.push_back(commitAction(INCREASE, cont->type(),
+ extendText(false, *i), this, true));
+ if( !dev_rem.empty() )
+ for( i=dev_rem.begin(); i!=dev_rem.end(); ++i )
+ l.push_back(commitAction(DECREASE, cont->type(),
+ reduceText(false, *i), this, false));
+ countSubvolAddDel( add, rem );
+ if( rem>0 )
+ {
+ list<string> sl = getSubvolAddDel( false );
+ for( list<string>::const_iterator i=sl.begin(); i!=sl.end(); ++i )
+ l.push_back(commitAction(SUBVOL, cont->type(),
+ deleteSubvolText(false,*i), this, true));
+ }
+ if( add>0 )
+ {
+ list<string> sl = getSubvolAddDel( true );
+ for( list<string>::const_iterator i=sl.begin(); i!=sl.end(); ++i )
+ l.push_back(commitAction(SUBVOL, cont->type(),
+ createSubvolText(false,*i), this, true));
+ }
+ }
+
+Text
+Btrfs::extendText(bool doing, const string& dev) const
+ {
+ Text txt;
+ if( doing )
+ {
+ // displayed text during action,
+ // %1$s and %2$s are replaced by a device names (e.g. /dev/hda1)
+ txt = sformat( _("Extending BTRFS volume %1$s by %2$s"), name().c_str(),
+ dev.c_str() );
+ }
+ else
+ {
+ // displayed text before action,
+ // %1$s and %2$s are replaced by a device names (e.g. /dev/hda1)
+ txt = sformat( _("Extend BTRFS volume %1$s by %2$s"), name().c_str(),
+ dev.c_str() );
+ }
+ return( txt );
+ }
+
+Text
+Btrfs::reduceText(bool doing, const string& dev) const
+ {
+ Text txt;
+ if( doing )
+ {
+ // displayed text during action,
+ // %1$s and %2$s are replaced by a device names (e.g. /dev/hda1)
+ txt = sformat( _("Reducing BTRFS volume %1$s by %2$s"), name().c_str(),
+ dev.c_str() );
+ }
+ else
+ {
+ // displayed text before action,
+ // %1$s and %2$s are replaced by a device names (e.g. /dev/hda1)
+ txt = sformat( _("Reduce BTRFS volume %1$s by %2$s"), name().c_str(),
+ dev.c_str() );
+ }
+ return( txt );
+ }
+
+Text Btrfs::createSubvolText(bool doing, const string& name) const
+ {
+ Text txt;
+ if( doing )
+ {
+ // displayed text during action, %1$s is replaced by subvolume name e.g. tmp
+ // %2$s is replaced by device name e.g. /dev/hda1
+ txt = sformat( _("Creating subvolume %1$s on device %2$s"),
+ name.c_str(), dev.c_str() );
+ }
+ else
+ {
+ // displayed text before action, %1$s is replaced by subvolume name e.g. tmp
+ // %2$s is replaced by device name e.g. /dev/hda1
+ txt = sformat( _("Create subvolume %1$s on device %2$s"),
+ name.c_str(), dev.c_str() );
+ }
+ return( txt );
+ }
+
+Text Btrfs::deleteSubvolText(bool doing, const string& name) const
+ {
+ Text txt;
+ if( doing )
+ {
+ // displayed text during action, %1$s is replaced by subvolume name e.g. tmp
+ // %2$s is replaced by device name e.g. /dev/hda1
+ txt = sformat( _("Removing subvolume %1$s on device %2$s"),
+ name.c_str(), dev.c_str() );
+ }
+ else
+ {
+ // displayed text before action, %1$s is replaced by subvolume name e.g. tmp
+ // %2$s is replaced by device name e.g. /dev/hda1
+ txt = sformat( _("Remove subvolume %1$s on device %2$s"),
+ name.c_str(), dev.c_str() );
+ }
+ return( txt );
+ }
+
+void Btrfs::getInfo( BtrfsInfo& tinfo ) const
+ {
+ Volume::getInfo(info.v);
+ info.devices = boost::join( devices, "\n" );
+ info.devices_add = boost::join( dev_add, "\n" );
+ info.devices_rem = boost::join( dev_rem, "\n" );
+ info.subvol.erase();
+
+ for( list<Subvolume>::const_iterator i=subvol.begin();
+ i!=subvol.end(); ++i )
+ {
+ if( !info.subvol.empty() )
+ info.subvol += '\n';
+ if( !i->deleted() )
+ info.subvol += i->path();
+ }
+ tinfo = info;
+ }
+
+std::ostream& operator<< (std::ostream& s, const Btrfs& v )
+ {
+ s << "Btrfs " << dynamic_cast<const Volume&>(v);
+ s << " devices:" << v.devices;
+ if( !v.dev_add.empty() )
+ s << " dev_add:" << v.dev_add;
+ if( !v.dev_rem.empty() )
+ s << " dev_rem:" << v.dev_rem;
+ if( !v.subvol.empty() )
+ s << " subvol:" << v.subvol;
+ return( s );
+ }
+
+
+bool Btrfs::equalContent( const Btrfs& rhs ) const
+ {
+ return( Volume::equalContent(rhs) && devices==rhs.devices &&
+ dev_add==rhs.dev_add && dev_rem==rhs.dev_rem &&
+ subvol==rhs.subvol );
+ }
+
+
+void Btrfs::logDifference(std::ostream& log, const Btrfs& rhs) const
+ {
+ Volume::logDifference(log, rhs);
+ list<string>::const_iterator i;
+ string tmp;
+ for( i = devices.begin(); i != devices.end(); ++i)
+ if (!contains(rhs.devices, *i))
+ tmp += *i + "-->";
+ for( i = rhs.devices.begin(); i != rhs.devices.end(); ++i)
+ if (!contains(devices, *i))
+ tmp += "<--" + *i;
+ if (!tmp.empty())
+ log << " Devices:" << tmp;
+
+ tmp.erase();
+ for( i = dev_add.begin(); i != dev_add.end(); ++i)
+ if (!contains(rhs.dev_add, *i))
+ tmp += *i + "-->";
+ for( i = rhs.dev_add.begin(); i != rhs.dev_add.end(); ++i)
+ if (!contains(dev_add, *i))
+ tmp += "<--" + *i;
+ if (!tmp.empty())
+ log << " DevAdd:" << tmp;
+
+ tmp.erase();
+ for( i = dev_rem.begin(); i != dev_rem.end(); ++i)
+ if (!contains(rhs.dev_rem, *i))
+ tmp += *i + "-->";
+ for( i = rhs.dev_rem.begin(); i != rhs.dev_rem.end(); ++i)
+ if (!contains(dev_rem, *i))
+ tmp += "<--" + *i;
+ if (!tmp.empty())
+ log << " DevRem:" << tmp;
+
+ tmp.erase();
+ list<Subvolume>::const_iterator s;
+ for( s=subvol.begin(); s!=subvol.end(); ++s )
+ {
+ if( s->deleted() )
+ tmp += "<--" + s->path();
+ else if( s->created() )
+ tmp += s->path() + "-->";
+ }
+ if (!tmp.empty())
+ log << " SubVol:" << tmp;
+ }
+
+void Btrfs::saveData(xmlNode* node) const
+ {
+ Volume::saveData(node);
+ setChildValue(node, "devices", devices);
+ if( !dev_add.empty() )
+ setChildValue(node, "dev_add", dev_add);
+ if( !dev_rem.empty() )
+ setChildValue(node, "dev_rem", dev_rem);
+ if (!subvol.empty())
+ setChildValue(node, "subvolume", subvol);
+ }
+
+bool Btrfs::needCreateSubvol( const Btrfs& v )
+ {
+ unsigned dummy, cnt;
+ v.countSubvolAddDel( cnt, dummy );
+ return( cnt>0 );
+ }
+
+bool Btrfs::needDeleteSubvol( const Btrfs& v )
+ {
+ unsigned dummy, cnt;
+ v.countSubvolAddDel( dummy, cnt );
+ return( cnt>0 );
+ }
+
+bool Btrfs::needReduce( const Btrfs& v )
+ {
+ return( !v.dev_rem.empty() );
+ }
+
+bool Btrfs::needExtend( const Btrfs& v )
+ {
+ return( !v.dev_add.empty() );
+ }
+
+}
Added: branches/SuSE-Code-11-SP2-Branch/storage/libstorage/src/Btrfs.h
URL: http://svn.opensuse.org/viewcvs/yast/branches/SuSE-Code-11-SP2-Branch/stora…
==============================================================================
--- branches/SuSE-Code-11-SP2-Branch/storage/libstorage/src/Btrfs.h (added)
+++ branches/SuSE-Code-11-SP2-Branch/storage/libstorage/src/Btrfs.h Tue May 17 13:39:44 2011
@@ -0,0 +1,106 @@
+/*
+ * Copyright (c) [2004-2011] Novell, Inc.
+ *
+ * All Rights Reserved.
+ *
+ * This program is free software; you can redistribute it and/or modify it
+ * under the terms of version 2 of the GNU General Public License as published
+ * by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
+ * more details.
+ *
+ * You should have received a copy of the GNU General Public License along
+ * with this program; if not, contact Novell, Inc.
+ *
+ * To contact Novell about this file by physical or electronic mail, you may
+ * find current contact information at www.novell.com.
+ */
+
+
+#ifndef BTRFS_H
+#define BTRFS_H
+
+#include "storage/Volume.h"
+
+namespace storage
+{
+class BtrfsCo;
+class SystemInfo;
+
+
+class Btrfs : public Volume
+ {
+ public:
+
+ Btrfs( const BtrfsCo& d, const Volume& v, unsigned long long sz,
+ const list<string>& devices );
+ Btrfs( const BtrfsCo& d, const Volume& v );
+ Btrfs( const BtrfsCo& d, const xmlNode* node );
+ Btrfs( const BtrfsCo& c, const Btrfs& v);
+ virtual ~Btrfs();
+
+ void clearSubvol() { subvol.clear(); }
+ void addSubvol( const string& path );
+ const list<string>& getDevices() const { return devices; }
+ void getDevices( list<string>& devs ) const { devs=devices; }
+ void getSubvolumes( list<Subvolume>& sv ) const { sv = subvol; }
+
+ int createSubvolume( const string& name );
+ int deleteSubvolume( const string& name );
+ int extendVolume( const string& dev );
+ int extendVolume( const list<string>& devs );
+ int shrinkVolume( const string& dev );
+ int shrinkVolume( const list<string>& devs );
+
+ void getCommitActions(list<commitAction>& l) const;
+ int doDeleteSubvol();
+ int doCreateSubvol();
+ int doReduce();
+ int doExtend();
+ Text createSubvolText(bool doing, const string& name) const;
+ Text deleteSubvolText(bool doing, const string& name) const;
+ Text extendText(bool doing, const string& device) const;
+ Text reduceText(bool doing, const string& device) const;
+ Text removeText( bool doing ) const;
+
+ void countSubvolAddDel( unsigned& add, unsigned& rem ) const;
+ list<string> getSubvolAddDel( bool ) const;
+
+ void saveData(xmlNode* node) const;
+ friend std::ostream& operator<< (std::ostream& s, const Btrfs& l );
+ virtual void print( std::ostream& s ) const { s << *this; }
+ void getInfo( storage::BtrfsInfo& info ) const;
+ bool equalContent( const Btrfs& rhs ) const;
+ void logDifference(std::ostream& log, const Btrfs& rhs) const;
+ void unuseDev() const;
+ int clearSignature();
+
+
+ static bool notDeleted( const Btrfs& l ) { return( !l.deleted() ); }
+ static bool needCreateSubvol( const Btrfs& v );
+ static bool needDeleteSubvol( const Btrfs& v );
+ static bool needReduce( const Btrfs& v );
+ static bool needExtend( const Btrfs& v );
+
+ protected:
+ string subvolNames( bool added ) const;
+ list<string> devices;
+ list<string> dev_add;
+ list<string> dev_rem;
+ list<Subvolume> subvol;
+
+ mutable storage::BtrfsInfo info; // workaround for broken ycp bindings
+
+ private:
+
+ Btrfs& operator=(const Btrfs& v); // disallow
+ Btrfs(const Btrfs&); // disallow
+
+ };
+
+}
+
+#endif
Added: branches/SuSE-Code-11-SP2-Branch/storage/libstorage/src/BtrfsCo.cc
URL: http://svn.opensuse.org/viewcvs/yast/branches/SuSE-Code-11-SP2-Branch/stora…
==============================================================================
--- branches/SuSE-Code-11-SP2-Branch/storage/libstorage/src/BtrfsCo.cc (added)
+++ branches/SuSE-Code-11-SP2-Branch/storage/libstorage/src/BtrfsCo.cc Tue May 17 13:39:44 2011
@@ -0,0 +1,487 @@
+/*
+ * Copyright (c) [2004-2011] Novell, Inc.
+ *
+ * All Rights Reserved.
+ *
+ * This program is free software; you can redistribute it and/or modify it
+ * under the terms of version 2 of the GNU General Public License as published
+ * by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
+ * more details.
+ *
+ * You should have received a copy of the GNU General Public License along
+ * with this program; if not, contact Novell, Inc.
+ *
+ * To contact Novell about this file by physical or electronic mail, you may
+ * find current contact information at www.novell.com.
+ */
+
+
+#include <ostream>
+#include <sstream>
+
+#include "storage/BtrfsCo.h"
+#include "storage/Btrfs.h"
+#include "storage/SystemCmd.h"
+#include "storage/Dm.h"
+#include "storage/SystemInfo.h"
+#include "storage/ProcMounts.h"
+#include "storage/AppUtil.h"
+#include "storage/Storage.h"
+#include "storage/EtcFstab.h"
+#include "storage/StorageDefines.h"
+
+
+namespace storage
+{
+ using namespace std;
+
+
+ BtrfsCo::BtrfsCo(Storage* s)
+ : Container(s, "btrfs", "/dev/btrfs", staticType())
+ {
+ y2deb("constructing BtrfsCo");
+ }
+
+
+ BtrfsCo::BtrfsCo(Storage* s, SystemInfo& systeminfo)
+ : Container(s, "btrfs", "/dev/btrfs", staticType(), systeminfo)
+ {
+ y2deb("constructing BtrfsCo");
+ getBtrfsData(systeminfo);
+ }
+
+
+ BtrfsCo::BtrfsCo(const BtrfsCo& c)
+ : Container(c)
+ {
+ y2deb("copy-constructed BtrfsCo from " << c.dev);
+
+ ConstBtrfsPair p = c.btrfsPair();
+ for (ConstBtrfsIter i = p.begin(); i != p.end(); ++i)
+ {
+ Btrfs* p = new Btrfs(*this, *i);
+ vols.push_back(p);
+ }
+ }
+
+
+ BtrfsCo::~BtrfsCo()
+ {
+ y2deb("destructed BtrfsCo " << dev);
+ }
+
+
+void BtrfsCo::getBtrfsData(SystemInfo& systeminfo)
+ {
+ y2mil("begin");
+ list<string> uuids = systeminfo.getCmdBtrfsShow().getUuids();
+ CmdBtrfsShow::Entry e;
+ for( list<string>::const_iterator i=uuids.begin(); i!=uuids.end(); ++i )
+ {
+ if( systeminfo.getCmdBtrfsShow().getEntry( *i, e ))
+ {
+ Volume const* cv = NULL;
+ unsigned long long sum_size = 0;
+ list<string> an;
+ for( list<string>::const_iterator d=e.devices.begin(); d!=e.devices.end(); ++d )
+ {
+ Volume const* v;
+ if( getStorage()->findVolume( *d, v ))
+ {
+ if( cv==NULL ||
+ (cv->getMount().empty() && !v->getMount().empty()) ||
+ (!cv->getFormat() && v->getFormat() ))
+ cv = v;
+ sum_size += v->sizeK();
+ list<string> li = v->altNames();
+ an.splice( an.end(), li );
+ }
+ else
+ y2war( "device " << *d << " not found" );
+ }
+ list<string> devs;
+ for( list<string>::const_iterator i=e.devices.begin(); i!=e.devices.end(); ++i )
+ {
+ const Device* v;
+ if( getStorage()->findDevice( *i, v ) )
+ devs.push_back( v->device() );
+ else
+ devs.push_back( *i );
+ }
+ Btrfs* b = new Btrfs( *this, *cv, sum_size, devs );
+ y2mil( "alt_names:" << an );
+ b->setAltNames( an );
+ vols.push_back(b);
+ }
+ else
+ y2war( "uuid " << *i << " not found" );
+ }
+ BtrfsPair p( btrfsPair() );
+ for( BtrfsIter i=p.begin(); i!=p.end(); ++i )
+ {
+ y2mil( "dev:" << i->device() );
+ bool mounted = false;
+ string mp = i->getMount();
+ if( !i->isMounted() && getStorage()->mountTmpRo( &(*i), mp ) )
+ mounted = true;
+ if( !mp.empty() )
+ {
+ i->clearSubvol();
+ SystemCmd cmd( "btrfs subvolume list " + mp );
+ for( vector<string>::const_iterator s=cmd.stdout().begin();
+ s!=cmd.stdout().end(); ++s )
+ {
+ string subvol;
+ string::size_type pos = s->find( " path " );
+ if( pos!=string::npos )
+ pos = s->find_first_not_of( app_ws, pos+5 );
+ if( pos!=string::npos )
+ subvol = s->substr( pos, s->find_last_not_of( app_ws ) );
+ if( !subvol.empty() )
+ i->addSubvol( subvol );
+ }
+ }
+ if( mounted )
+ {
+ getStorage()->umountDev( i->device() );
+ rmdir( mp.c_str() );
+ }
+ }
+ y2mil("end");
+ }
+
+void
+BtrfsCo::addFromVolume( const Volume& v )
+ {
+ Btrfs* b = new Btrfs( *this, v );
+ vols.push_back(b);
+ }
+
+int BtrfsCo::createSubvolume( const string& device, const string& name )
+ {
+ int ret = 0;
+ y2mil( "device:" << device << " name:" << name );
+ BtrfsIter i;
+ if( readonly() )
+ ret = BTRFS_CHANGE_READONLY;
+ else if( findBtrfs( device, i ))
+ ret = i->createSubvolume( name );
+ else
+ ret = BTRFS_VOLUME_NOT_FOUND;
+ y2mil( "ret:" << ret );
+ return( ret );
+ }
+
+int BtrfsCo::removeSubvolume( const string& device, const string& name )
+ {
+ int ret = 0;
+ y2mil( "device:" << device << " name:" << name );
+ BtrfsIter i;
+ if( readonly() )
+ ret = BTRFS_CHANGE_READONLY;
+ else if( findBtrfs( device, i ))
+ ret = i->deleteSubvolume( name );
+ else
+ ret = BTRFS_VOLUME_NOT_FOUND;
+ y2mil( "ret:" << ret );
+ return( ret );
+ }
+
+int BtrfsCo::extendVolume( const string& device, const string& dev )
+ {
+ list<string> d;
+ d.push_back(dev);
+ return( extendVolume(device,d));
+ }
+
+int BtrfsCo::extendVolume( const string& device, const list<string>& devs )
+ {
+ int ret = 0;
+ y2mil( "device:" << device << " devices:" << devs );
+ BtrfsIter i;
+ if( readonly() )
+ ret = BTRFS_CHANGE_READONLY;
+ else if( findBtrfs( device, i ))
+ ret = i->extendVolume( devs );
+ else
+ ret = BTRFS_VOLUME_NOT_FOUND;
+ y2mil( "ret:" << ret );
+ return( ret );
+ }
+
+int BtrfsCo::shrinkVolume( const string& device, const string& dev )
+ {
+ list<string> d;
+ d.push_back(dev);
+ return( shrinkVolume(device,d));
+ }
+
+int BtrfsCo::shrinkVolume( const string& device, const list<string>& devs )
+ {
+ int ret = 0;
+ y2mil( "device:" << device << " devs:" << devs );
+ BtrfsIter i;
+ if( readonly() )
+ ret = BTRFS_CHANGE_READONLY;
+ else if( findBtrfs( device, i ))
+ ret = i->shrinkVolume( devs );
+ else
+ ret = BTRFS_VOLUME_NOT_FOUND;
+ y2mil( "ret:" << ret );
+ return( ret );
+ }
+
+void
+BtrfsCo::eraseVolume( Volume* v )
+ {
+ BtrfsPair p=btrfsPair(Btrfs::notDeleted);
+ BtrfsIter i = p.begin();
+ while( i!=p.end() && i->device()!=v->device() )
+ ++i;
+ if( i!=p.end() )
+ removeFromList( v );
+ }
+
+bool
+BtrfsCo::findBtrfs( const string& id, BtrfsIter& i )
+ {
+ BtrfsPair p=btrfsPair(Btrfs::notDeleted);
+ string uuid( id );
+ if( boost::starts_with( uuid, "UUID=" ))
+ uuid = uuid.substr( 5 );
+ i=p.begin();
+ while( i!=p.end() && i->getUuid()!=uuid )
+ ++i;
+ if( i==p.end() && !p.empty() )
+ {
+ i=p.begin();
+ bool found = false;
+ while( i!=p.end() && !found )
+ {
+ found = i->device()==id;
+ if( !found )
+ {
+ const list<string>& al( i->altNames() );
+ found = find( al.begin(), al.end(), id )!=al.end();
+ }
+ if( !found )
+ ++i;
+ }
+ }
+ y2mil( "id:" << id << " ret:" << (i!=p.end()) );
+ return( i!=p.end() );
+ }
+
+bool BtrfsCo::deviceToUuid( const string& device, string& uuid )
+ {
+ bool ret = false;
+ y2mil( "device:" << device );
+ const Volume* v = getStorage()->getVolume( device );
+ list<UsedBy>::const_iterator ul = v->getUsedBy().begin();
+ uuid.clear();
+ while( v && ul != v->getUsedBy().end() )
+ {
+ if( ul->type()==UB_BTRFS )
+ {
+ uuid = v->getUsedBy().front().device();
+ ret = true;
+ }
+ ++ul;
+ }
+ y2mil( "ret:" << ret << " uuid:" << (ret?uuid:"") );
+ return( ret );
+ }
+
+int BtrfsCo::commitChanges( CommitStage stage, Volume* vol )
+ {
+ y2mil("name:" << name() << " stage:" << stage);
+ int ret = Container::commitChanges( stage, vol );
+ if( ret==0 && stage==DECREASE )
+ {
+ Btrfs * b = dynamic_cast<Btrfs *>(vol);
+ if( b!=NULL )
+ ret = b->doReduce();
+ else
+ ret = BTRFS_COMMIT_INVALID_VOLUME;
+ }
+ else if( ret==0 && stage==INCREASE )
+ {
+ Btrfs * b = dynamic_cast<Btrfs *>(vol);
+ if( b!=NULL )
+ ret = b->doExtend();
+ else
+ ret = BTRFS_COMMIT_INVALID_VOLUME;
+ }
+ else if( ret==0 && stage==SUBVOL )
+ {
+ Btrfs * b = dynamic_cast<Btrfs *>(vol);
+ if( b!=NULL )
+ {
+ if( Btrfs::needDeleteSubvol( *b ) )
+ ret = b->doDeleteSubvol();
+ else if( Btrfs::needCreateSubvol( *b ) )
+ ret = b->doCreateSubvol();
+ }
+ else
+ ret = BTRFS_COMMIT_INVALID_VOLUME;
+ }
+ y2mil("ret:" << ret);
+ return( ret );
+ }
+
+void BtrfsCo::getToCommit( storage::CommitStage stage, list<const Container*>& col,
+ list<const Volume*>& vol ) const
+ {
+ unsigned long oco = col.size();
+ unsigned long ovo = vol.size();
+ Container::getToCommit( stage, col, vol );
+ if( stage==DECREASE )
+ {
+ ConstBtrfsPair p = btrfsPair( Btrfs::needReduce );
+ for( ConstBtrfsIter i=p.begin(); i!=p.end(); ++i )
+ if( find( vol.begin(), vol.end(), &(*i) )==vol.end() )
+ vol.push_back( &(*i) );
+ }
+ else if( stage==INCREASE )
+ {
+ ConstBtrfsPair p = btrfsPair( Btrfs::needExtend );
+ for( ConstBtrfsIter i=p.begin(); i!=p.end(); ++i )
+ if( find( vol.begin(), vol.end(), &(*i) )==vol.end() )
+ vol.push_back( &(*i) );
+ }
+ else if( stage==SUBVOL )
+ {
+ ConstBtrfsPair p = btrfsPair( Btrfs::needDeleteSubvol );
+ for( ConstBtrfsIter i=p.begin(); i!=p.end(); ++i )
+ if( find( vol.begin(), vol.end(), &(*i) )==vol.end() )
+ vol.push_back( &(*i) );
+ p = btrfsPair( Btrfs::needCreateSubvol );
+ for( ConstBtrfsIter i=p.begin(); i!=p.end(); ++i )
+ if( find( vol.begin(), vol.end(), &(*i) )==vol.end() )
+ vol.push_back( &(*i) );
+ }
+ if( col.size()!=oco || vol.size()!=ovo )
+ y2mil("stage:" << stage << " col:" << col.size() << " vol:" << vol.size());
+ }
+
+
+int BtrfsCo::removeUuid( const string& uuid )
+ {
+ int ret = 0;
+ y2mil( "uuid:" << uuid );
+ BtrfsIter b;
+ if( findBtrfs( uuid, b ) )
+ ret = removeVolume( &(*b), true );
+ else
+ ret = BTRFS_REMOVE_NOT_FOUND;
+ y2mil( "ret:" << ret );
+ return( ret );
+ }
+
+int BtrfsCo::removeVolume( Volume* v, bool quiet )
+ {
+ int ret = 0;
+ y2mil("qiet:" << quiet);
+ y2mil("vol:" << *v);
+ v->setDeleted();
+ if( quiet )
+ v->setSilent();
+ Btrfs * b = dynamic_cast<Btrfs *>(v);
+ if( b )
+ b->unuseDev();
+ else
+ y2err( "no btrfs volume:" << *v );
+ y2mil("ret:" << ret);
+ return( ret );
+ }
+
+int BtrfsCo::removeVolume( Volume* v )
+ {
+ return( removeVolume( v, false ));
+ }
+
+int
+BtrfsCo::doRemove( Volume* v )
+ {
+ int ret = 0;
+ Btrfs *b = dynamic_cast<Btrfs *>(v);
+ if( b != NULL )
+ {
+ if( !silent )
+ {
+ getStorage()->showInfoCb( b->removeText(true) );
+ }
+ ret = b->clearSignature();
+ if( ret==0 && !removeFromList(v) )
+ ret = BTRFS_REMOVE_NO_BTRFS;
+ }
+ else
+ ret = BTRFS_REMOVE_INVALID_VOLUME;
+ y2mil("ret:" << ret);
+ return( ret );
+ }
+
+void
+BtrfsCo::logData(const string& Dir) const
+ {
+ string fname(Dir + "/btrfs.info.tmp");
+
+ XmlFile xml;
+ xmlNode* node = xmlNewNode("btrfs");
+ xml.setRootElement(node);
+ saveData(node);
+ xml.save(fname);
+
+ getStorage()->handleLogFile( fname );
+ }
+
+void
+BtrfsCo::saveData(xmlNode* node) const
+ {
+ Container::saveData(node);
+ ConstBtrfsPair vp = btrfsPair();
+ for (ConstBtrfsIter v = vp.begin(); v != vp.end(); ++v)
+ v->saveData(xmlNewChild(node, "btrfs"));
+ }
+
+
+std::ostream& operator<<(std::ostream& s, const BtrfsCo& d)
+ {
+ s << dynamic_cast<const Container&>(d);
+ return( s );
+ }
+
+
+void BtrfsCo::logDifferenceWithVolumes(std::ostream& log, const Container& rhs_c) const
+ {
+ const BtrfsCo& rhs = dynamic_cast<const BtrfsCo&>(rhs_c);
+
+ logDifference(log, rhs);
+ log << endl;
+
+ ConstBtrfsPair pp = btrfsPair();
+ ConstBtrfsPair pc = rhs.btrfsPair();
+ logVolumesDifference(log, pp.begin(), pp.end(), pc.begin(), pc.end());
+ }
+
+
+bool BtrfsCo::equalContent( const Container& rhs ) const
+ {
+ const BtrfsCo * p = NULL;
+ bool ret = Container::equalContent(rhs);
+ if( ret )
+ p = dynamic_cast<const BtrfsCo*>(&rhs);
+ if( ret && p )
+ {
+ ConstBtrfsPair pp = btrfsPair();
+ ConstBtrfsPair pc = p->btrfsPair();
+ ret = ret && storage::equalContent(pp.begin(), pp.end(), pc.begin(), pc.end());
+ }
+ return( ret );
+ }
+
+}
Added: branches/SuSE-Code-11-SP2-Branch/storage/libstorage/src/BtrfsCo.h
URL: http://svn.opensuse.org/viewcvs/yast/branches/SuSE-Code-11-SP2-Branch/stora…
==============================================================================
--- branches/SuSE-Code-11-SP2-Branch/storage/libstorage/src/BtrfsCo.h (added)
+++ branches/SuSE-Code-11-SP2-Branch/storage/libstorage/src/BtrfsCo.h Tue May 17 13:39:44 2011
@@ -0,0 +1,140 @@
+/*
+ * Copyright (c) [2004-2011] Novell, Inc.
+ *
+ * All Rights Reserved.
+ *
+ * This program is free software; you can redistribute it and/or modify it
+ * under the terms of version 2 of the GNU General Public License as published
+ * by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
+ * more details.
+ *
+ * You should have received a copy of the GNU General Public License along
+ * with this program; if not, contact Novell, Inc.
+ *
+ * To contact Novell about this file by physical or electronic mail, you may
+ * find current contact information at www.novell.com.
+ */
+
+
+#ifndef BTRFS_CO_H
+#define BTRFS_CO_H
+
+#include "storage/Container.h"
+#include "storage/Btrfs.h"
+
+
+namespace storage
+{
+ class SystemInfo;
+
+
+class BtrfsCo : public Container
+ {
+ friend class Storage;
+
+ public:
+
+ BtrfsCo(Storage * const s);
+ BtrfsCo(Storage * const s, SystemInfo& systeminfo);
+ BtrfsCo(const BtrfsCo& c);
+ virtual ~BtrfsCo();
+
+ void addFromVolume( const Volume& v );
+ void eraseVolume( Volume* v );
+
+ int createSubvolume( const string& device, const string& name );
+ int removeSubvolume( const string& device, const string& name );
+ int extendVolume( const string& device, const string& dev );
+ int extendVolume( const string& device, const list<string>& devs );
+ int shrinkVolume( const string& device, const string& dev );
+ int shrinkVolume( const string& device, const list<string>& devs );
+ bool deviceToUuid( const string& device, string& uuid );
+
+ int doRemove( Volume* v );
+
+ static storage::CType staticType() { return storage::BTRFSC; }
+ friend std::ostream& operator<< (std::ostream&, const BtrfsCo& );
+
+ int commitChanges( CommitStage stage, Volume* vol );
+ void getToCommit( storage::CommitStage stage, list<const Container*>& col,
+ list<const Volume*>& vo ) const;
+
+ int removeVolume( Volume* v );
+ int removeVolume( Volume* v, bool quiet );
+ int removeUuid( const string& uuid );
+ bool equalContent( const Container& rhs ) const;
+ void saveData(xmlNode* node) const;
+
+ virtual void logDifferenceWithVolumes(std::ostream& log, const Container& rhs) const;
+ virtual void logData(const string& Dir) const;
+
+
+ protected:
+ // iterators over BTRFS volumes
+ // protected typedefs for iterators over BTRFS volumes
+ typedef CastIterator<VIter, Btrfs *> BtrfsInter;
+ typedef CastIterator<CVIter, const Btrfs *> BtrfsCInter;
+ template< class Pred >
+ struct BtrfsPI { typedef ContainerIter<Pred, BtrfsInter> type; };
+ template< class Pred >
+ struct BtrfsCPI { typedef ContainerIter<Pred, BtrfsCInter> type; };
+ typedef CheckFnc<const Btrfs> CheckFncBtrfs;
+ typedef CheckerIterator< CheckFncBtrfs, BtrfsPI<CheckFncBtrfs>::type,
+ BtrfsInter, Btrfs > BtrfsPIterator;
+ typedef CheckerIterator< CheckFncBtrfs, BtrfsCPI<CheckFncBtrfs>::type,
+ BtrfsCInter, const Btrfs > BtrfsCPIterator;
+ typedef DerefIterator<BtrfsPIterator,Btrfs> BtrfsIter;
+ typedef DerefIterator<BtrfsCPIterator,const Btrfs> ConstBtrfsIter;
+ typedef IterPair<BtrfsIter> BtrfsPair;
+ typedef IterPair<ConstBtrfsIter> ConstBtrfsPair;
+
+ BtrfsPair btrfsPair( bool (* Check)( const Btrfs& )=NULL)
+ {
+ return( BtrfsPair( btrfsBegin( Check ), btrfsEnd( Check ) ));
+ }
+ BtrfsIter btrfsBegin( bool (* Check)( const Btrfs& )=NULL)
+ {
+ IterPair<BtrfsInter> p( (BtrfsInter(begin())), (BtrfsInter(end())) );
+ return( BtrfsIter( BtrfsPIterator( p, Check )) );
+ }
+ BtrfsIter btrfsEnd( bool (* Check)( const Btrfs& )=NULL)
+ {
+ IterPair<BtrfsInter> p( (BtrfsInter(begin())), (BtrfsInter(end())) );
+ return( BtrfsIter( BtrfsPIterator( p, Check, true )) );
+ }
+
+ ConstBtrfsPair btrfsPair( bool (* Check)( const Btrfs& )=NULL) const
+ {
+ return( ConstBtrfsPair( btrfsBegin( Check ), btrfsEnd( Check ) ));
+ }
+ ConstBtrfsIter btrfsBegin( bool (* Check)( const Btrfs& )=NULL) const
+ {
+ IterPair<BtrfsCInter> p( (BtrfsCInter(begin())), (BtrfsCInter(end())) );
+ return( ConstBtrfsIter( BtrfsCPIterator( p, Check )) );
+ }
+ ConstBtrfsIter btrfsEnd( bool (* Check)( const Btrfs& )=NULL) const
+ {
+ IterPair<BtrfsCInter> p( (BtrfsCInter(begin())), (BtrfsCInter(end())) );
+ return( ConstBtrfsIter( BtrfsCPIterator( p, Check, true )) );
+ }
+
+ void getBtrfsData(SystemInfo& systeminfo);
+ bool findBtrfs( const string& uuid, BtrfsIter& i );
+ void addBtrfs( Btrfs* m );
+
+ virtual void print( std::ostream& s ) const { s << *this; }
+ virtual Container* getCopy() const { return( new BtrfsCo( *this ) ); }
+
+ private:
+
+ BtrfsCo& operator=(const BtrfsCo&); // disallow
+
+ };
+
+}
+
+#endif
Modified: branches/SuSE-Code-11-SP2-Branch/storage/libstorage/src/Container.cc
URL: http://svn.opensuse.org/viewcvs/yast/branches/SuSE-Code-11-SP2-Branch/stora…
==============================================================================
--- branches/SuSE-Code-11-SP2-Branch/storage/libstorage/src/Container.cc (original)
+++ branches/SuSE-Code-11-SP2-Branch/storage/libstorage/src/Container.cc Tue May 17 13:39:44 2011
@@ -1,5 +1,5 @@
/*
- * Copyright (c) [2004-2009] Novell, Inc.
+ * Copyright (c) [2004-2010] Novell, Inc.
*
* All Rights Reserved.
*
@@ -19,64 +19,105 @@
* find current contact information at www.novell.com.
*/
-/*
- Textdomain "storage"
-*/
-#include <iostream>
+#include <ostream>
#include <algorithm>
#include <list>
-#include "y2storage/Container.h"
-#include "y2storage/SystemCmd.h"
-#include "y2storage/Storage.h"
-#include "y2storage/AppUtil.h"
+#include "storage/Container.h"
+#include "storage/SystemCmd.h"
+#include "storage/Storage.h"
+#include "storage/AppUtil.h"
+#include "storage/Device.h"
+
+
+namespace storage
+{
+ using namespace std;
-using namespace std;
-using namespace storage;
-Container::Container( Storage * const s, const string& Name, CType t ) :
- sto(s), nm(Name)
+ /* This is our constructor for Container used for containers created via
+ the storage interface. This is recognisable by the fact that it does
+ not have a parameter of type SystemInfo or xmlNode. */
+ Container::Container(Storage* s, const string& name, const string& device, CType t)
+ : Device(name, device), sto(s), typ(t), ronly(false)
{
- del = silent = ronly = create = false;
- dev = "/dev/" + nm;
- size_k = mnr = mjr = 0;
- typ = t;
- y2deb("constructed cont " << nm);
+ y2deb("constructed Container " << dev);
+
+ assert(!nm.empty() && !dev.empty());
}
-Container::~Container()
+
+ /* This is our constructor for Container used during detection. This is
+ recognisable by the fact that it has an parameter of type
+ SystemInfo. */
+ Container::Container(Storage* s, const string& name, const string& device, CType t,
+ SystemInfo& systeminfo)
+ : Device(name, device, systeminfo), sto(s), typ(t), ronly(false)
{
- for( PlainIterator i=begin(); i!=end(); i++ )
- {
- delete( *i );
- }
- y2deb("destructed cont " << dev);
+ y2deb("constructed Container " << dev);
+
+ assert(!nm.empty() && !dev.empty());
+ assert(!s->testmode());
}
-static bool notDeleted( const Volume& v )
- { return( !v.deleted()); }
-unsigned Container::numVolumes() const
+ /* This is our constructor for Container used during fake detection in
+ testmode. This is recognisable by the fact that it has an parameter of
+ type xmlNode. */
+ Container::Container(Storage* s, CType t, const xmlNode* node)
+ : Device(node), sto(s), typ(t), ronly(false)
{
- ConstVolPair p = volPair( notDeleted );
- return( p.length() );
+ getChildValue(node, "readonly", ronly);
+
+ y2deb("constructed Container " << dev);
+
+ assert(s->testmode());
}
-bool Container::isEmpty() const
+
+ /* This is our copy-constructor for Container. Every class derived from
+ Container needs an equivalent one. */
+ Container::Container(const Container& c)
+ : Device(c), sto(c.sto), typ(c.typ), ronly(c.ronly)
+ {
+ y2deb("copy-constructed Container " << dev);
+ }
+
+
+ Container::~Container()
{
- ConstVolPair p = volPair( notDeleted );
- return( p.empty() );
+ clearPointerList(vols);
+ y2deb("destructed Container " << dev);
}
-bool Container::sameDevice( const string& device ) const
+
+ void
+ Container::saveData(xmlNode* node) const
+ {
+ Device::saveData(node);
+
+ if (ronly)
+ setChildValue(node, "readonly", ronly);
+ }
+
+
+ bool
+ Container::isEmpty() const
{
- string d = normalizeDevice(device);
- return( d==dev ||
- find( alt_names.begin(), alt_names.end(), d )!=alt_names.end() );
+ ConstVolPair p = volPair(Volume::notDeleted);
+ return p.empty();
}
+bool Container::isPartitionable() const
+ {
+ return( typ==DISK || typ==DMRAID || typ==DMMULTIPATH || typ==MDPART );
+ }
+bool Container::isDeviceUsable() const
+ {
+ return( typ==DISK || typ==DMRAID || typ==DMMULTIPATH || typ==MDPART );
+ }
bool Container::stageDecrease(const Volume& v)
{
@@ -98,18 +139,18 @@
return v.needRemount() || v.needFstabUpdate();
}
-int Container::getToCommit( CommitStage stage, list<Container*>& col,
- list<Volume*>& vol )
+
+void
+Container::getToCommit(CommitStage stage, list<const Container*>& col, list<const Volume*>& vol) const
{
- int ret = 0;
unsigned long oco = col.size();
unsigned long ovo = vol.size();
switch( stage )
{
case DECREASE:
{
- VolPair p = volPair( stageDecrease );
- for( VolIterator i=p.begin(); i!=p.end(); ++i )
+ ConstVolPair p = volPair( stageDecrease );
+ for( ConstVolIterator i=p.begin(); i!=p.end(); ++i )
vol.push_back( &(*i) );
if( deleted() )
col.push_back( this );
@@ -117,8 +158,8 @@
break;
case INCREASE:
{
- VolPair p = volPair(stageIncrease);
- for( VolIterator i=p.begin(); i!=p.end(); ++i )
+ ConstVolPair p = volPair(stageIncrease);
+ for( ConstVolIterator i=p.begin(); i!=p.end(); ++i )
vol.push_back( &(*i) );
if( created() )
col.push_back( this );
@@ -126,26 +167,25 @@
break;
case FORMAT:
{
- VolPair p = volPair( stageFormat );
- for( VolIterator i=p.begin(); i!=p.end(); ++i )
+ ConstVolPair p = volPair( stageFormat );
+ for( ConstVolIterator i=p.begin(); i!=p.end(); ++i )
vol.push_back( &(*i) );
}
break;
case MOUNT:
{
- VolPair p = volPair( stageMount );
- for( VolIterator i=p.begin(); i!=p.end(); ++i )
+ ConstVolPair p = volPair( stageMount );
+ for( ConstVolIterator i=p.begin(); i!=p.end(); ++i )
vol.push_back( &(*i) );
}
break;
- default:
+ case SUBVOL:
break;
}
if( col.size()!=oco || vol.size()!=ovo )
- y2mil("ret:" << ret << " stage:" << stage << " col:" << col.size() << " vol:" <<
- vol.size());
- return( ret );
- }
+ y2mil("stage:" << stage << " col:" << col.size() << " vol:" << vol.size());
+}
+
int Container::commitChanges( CommitStage stage, Volume* vol )
{
@@ -197,6 +237,8 @@
vol->fstabUpdateDone();
}
break;
+ case SUBVOL:
+ break;
default:
ret = VOLUME_COMMIT_UNKNOWN_STAGE;
@@ -213,17 +255,20 @@
return( ret );
}
-void Container::getCommitActions( list<commitAction*>& l ) const
+
+void
+Container::getCommitActions(list<commitAction>& l) const
{
ConstVolPair p = volPair();
for( ConstVolIterator i=p.begin(); i!=p.end(); ++i )
- if( !i->silent() )
+ if( !i->isSilent() )
i->getCommitActions( l );
}
-string Container::createText( bool doing ) const
+
+Text Container::createText( bool doing ) const
{
- string txt;
+ Text txt;
if( doing )
{
// displayed text during action, %1$s is replaced by device name e.g. /dev/hda1
@@ -237,9 +282,9 @@
return( txt );
}
-string Container::removeText( bool doing ) const
+Text Container::removeText( bool doing ) const
{
- string txt;
+ Text txt;
if( doing )
{
// displayed text during action, %1$s is replaced by device name e.g. /dev/hda1
@@ -255,25 +300,25 @@
int Container::doCreate( Volume * v )
{
- y2war("invalid container:" << type_names[typ] << " name:" << name());
+ y2war("invalid container:" << toString(typ) << " name:" << name());
return( CONTAINER_INVALID_VIRTUAL_CALL );
}
int Container::doRemove( Volume * v )
{
- y2war("invalid container:" << type_names[typ] << " name:" << name());
+ y2war("invalid container:" << toString(typ) << " name:" << name());
return( CONTAINER_INVALID_VIRTUAL_CALL );
}
int Container::doResize( Volume * v )
{
- y2war("invalid container:" << type_names[typ] << " name:" << name());
+ y2war("invalid container:" << toString(typ) << " name:" << name());
return( CONTAINER_INVALID_VIRTUAL_CALL );
}
int Container::removeVolume( Volume * v )
{
- y2war("invalid container:" << type_names[typ] << " name:" << name());
+ y2war("invalid container:" << toString(typ) << " name:" << name());
return( CONTAINER_INVALID_VIRTUAL_CALL );
}
@@ -282,6 +327,14 @@
return( VOLUME_RESIZE_UNSUPPORTED_BY_CONTAINER );
}
+
+ void
+ Container::addToList(Volume* e)
+ {
+ pointerIntoSortedList<Volume>(vols, e);
+ }
+
+
bool Container::removeFromList( Volume* e )
{
bool ret=false;
@@ -290,11 +343,11 @@
++i;
if( i!=vols.end() )
{
- delete( *i );
+ delete *i;
vols.erase( i );
ret = true;
}
- y2milestone( "P:%p ret:%d", e, ret );
+ y2mil("P:" << e << " ret:" << ret);
return( ret );
}
@@ -306,14 +359,11 @@
void Container::setExtError( const SystemCmd& cmd, bool serr ) const
{
- const string& s = serr ? cmd.stderr() : cmd.stdout();
- if( s.size()>0 )
- {
+ string s = boost::join(serr ? cmd.stderr() : cmd.stdout(), "\n");
+ if (!s.empty())
sto->setExtError( cmd.cmd() + ":\n" + s );
- }
else
- y2warning( "called with empty %s cmd:%s",
- (serr?"stderr":"stdout"), cmd.cmd().c_str());
+ y2war("called with empty " << (serr?"stderr":"stdout") << " cmd:" << cmd.cmd());
}
bool Container::findVolume( const string& device, Volume*& vol )
@@ -335,96 +385,59 @@
void Container::getInfo(storage::ContainerInfo& tinfo) const
{
- Container::ConstVolPair vp = volPair( Volume::notDeleted );
info.type = type();
info.name = name();
info.device = device();
- info.volcnt = vp.length();
- info.usedByType = uby.type();
- info.usedByName = uby.name();
- info.usedByDevice = uby.device();
+
+ info.udevPath = udevPath();
+ info.udevId = boost::join(udevId(), " ");
+
+ info.usedBy = list<UsedByInfo>(uby.begin(), uby.end());
+
+ if (uby.empty())
+ {
+ info.usedByType = UB_NONE;
+ info.usedByDevice = "";
+ }
+ else
+ {
+ info.usedByType = uby.front().type();
+ info.usedByDevice = uby.front().device();
+ }
+
info.readonly = readonly();
tinfo = info;
}
-namespace storage
-{
-
std::ostream& operator<< ( std::ostream& s, const Container &c )
{
- s << "Type:" << Container::type_names[c.typ]
- << " Name:" << c.nm
- << " Device:" << c.dev
- << " Vcnt:" << c.vols.size();
- if( c.del )
- s << " deleted";
- if( c.create )
- s << " created";
+ s << "CType:" << toString(c.typ)
+ << " " << dynamic_cast<const Device&>(c);
if( c.ronly )
s << " readonly";
- if( c.silent )
- s << " silent";
- s << c.uby;
- return( s );
+ if (!c.uby.empty())
+ s << " usedby:" << c.uby;
+ if (!c.alt_names.empty())
+ s << " alt_names:" << c.alt_names;
+ return s;
}
-}
-void
-Container::logDifference( const Container& c ) const
-{
- y2mil(getDiffString(c));
-}
-
-string
-Container::getDiffString( const Container& c ) const
- {
- string ret = "Name:" + nm;
- if( nm!=c.nm )
- ret += "-->"+c.nm;
- if( typ!=c.typ )
- ret += " Type:" + Container::type_names[typ] + "-->" +
- Container::type_names[c.typ];
- if( dev!=c.dev )
- ret += " Device:" + dev + "-->" + c.dev;
- if( del!=c.del )
- {
- if( c.del )
- ret += " -->deleted";
- else
- ret += " deleted-->";
- }
- if( create!=c.create )
- {
- if( c.create )
- ret += " -->created";
- else
- ret += " created-->";
- }
- if( ronly!=c.ronly )
- {
- if( c.ronly )
- ret += " -->readonly";
- else
- ret += " readonly-->";
- }
- if( silent!=c.silent )
- {
- if( c.silent )
- ret += " -->silent";
- else
- ret += " silent-->";
- }
- if( uby!=c.uby )
- {
- std::ostringstream b;
- classic(b);
- b << uby << "-->" << string(c.uby);
- ret += b.str();
- }
- return( ret );
+
+ void
+ Container::logDifference(std::ostream& log, const Container& rhs) const
+ {
+ Device::logDifference(log, rhs);
+
+ logDiffEnum(log, "type", typ, rhs.typ);
+
+ logDiff(log, "readonly", ronly, rhs.ronly);
+ logDiff(log, "silent", silent, rhs.silent);
+
+ logDiff(log, "usedby", uby, rhs.uby);
}
+
bool Container::equalContent( const Container& rhs ) const
{
return( typ==rhs.typ && nm==rhs.nm && dev==rhs.dev && del==rhs.del &&
@@ -432,49 +445,34 @@
uby==rhs.uby );
}
-bool Container::compareContainer( const Container* c, bool verbose ) const
+
+ bool
+ Container::compareContainer(const Container& rhs, bool verbose) const
{
- bool ret = typ == c->typ;
- if( !ret )
+ assert(typ != CUNKNOWN);
+ if (typ == CUNKNOWN)
{
- if( verbose )
- y2mil(getDiffString( *c ));
+ y2err("unknown container type lhs:" << *this);
+ return false;
}
- else
+
+ assert(typ == rhs.typ);
+ if (typ != rhs.typ)
{
- ret = equalContent( *c );
- if( !ret && verbose )
- logDifference( *c );
- if( typ==COTYPE_LAST_ENTRY || typ==CUNKNOWN )
- y2err( "Unknown Container:" << *c );
+ y2err("comparing different container types lhs:" << *this << " rhs:" << rhs);
+ return false;
}
- return( ret );
- }
+ bool ret = equalContent(rhs);
+ if (!ret && verbose)
+ {
+ std::ostringstream log;
+ prepareLogStream(log);
+ logDifferenceWithVolumes(log, rhs);
+ y2mil(log.str());
+ }
-Container& Container::operator= ( const Container& rhs )
- {
- y2deb("operator= from " << rhs.nm);
- typ = rhs.typ;
- nm = rhs.nm;
- dev = rhs.dev;
- del = rhs.del;
- mjr = rhs.mjr;
- mnr = rhs.mnr;
- size_k = rhs.size_k;
- create = rhs.create;
- ronly = rhs.ronly;
- silent = rhs.silent;
- uby = rhs.uby;
- return( *this );
- }
-
-Container::Container( const Container& rhs ) : sto(rhs.sto)
- {
- y2deb("constructed cont by copy constructor from " << rhs.nm);
- *this = rhs;
+ return ret;
}
-const string Container::type_names[] = { "UNKNOWN", "DISK", "MD", "LOOP", "LVM",
- "DM", "DMRAID", "NFS", "DMMULTIPATH", "MDPART" };
-
+}
Modified: branches/SuSE-Code-11-SP2-Branch/storage/libstorage/src/Container.h
URL: http://svn.opensuse.org/viewcvs/yast/branches/SuSE-Code-11-SP2-Branch/stora…
==============================================================================
--- branches/SuSE-Code-11-SP2-Branch/storage/libstorage/src/Container.h (original)
+++ branches/SuSE-Code-11-SP2-Branch/storage/libstorage/src/Container.h Tue May 17 13:39:44 2011
@@ -1,5 +1,5 @@
/*
- * Copyright (c) [2004-2009] Novell, Inc.
+ * Copyright (c) [2004-2010] Novell, Inc.
*
* All Rights Reserved.
*
@@ -25,14 +25,17 @@
#include <list>
-#include "y2storage/Volume.h"
-#include "y2storage/StorageTypes.h"
-#include "y2storage/StorageTmpl.h"
+#include "storage/Volume.h"
+#include "storage/StorageTypes.h"
+#include "storage/StorageTmpl.h"
+
namespace storage
{
+ using std::list;
+
-class Container
+ class Container : public Device
{
friend class Storage;
protected:
@@ -65,26 +68,24 @@
{ return( !(*this<rhs) ); }
bool operator> ( const Container& rhs ) const
{ return( !(*this<=rhs) ); }
- bool sameDevice( const string& device ) const;
virtual bool equalContent( const Container& rhs ) const;
- virtual string getDiffString( const Container& c ) const;
- virtual void logDifference( const Container& c ) const;
- const std::list<string>& altNames() const { return( alt_names ); }
+ void logDifference(std::ostream& log, const Container& rhs) const;
+ virtual void logDifferenceWithVolumes(std::ostream& log, const Container& rhs) const = 0;
- virtual void getCommitActions( std::list<storage::commitAction*>& l ) const;
- virtual int getToCommit( storage::CommitStage stage,
- std::list<Container*>& col,
- std::list<Volume*>& vol );
+ virtual void getCommitActions(list<commitAction>& l) const;
+ virtual void getToCommit(storage::CommitStage stage, list<const Container*>& col,
+ list<const Volume*>& vol) const;
virtual int commitChanges( storage::CommitStage stage );
virtual int commitChanges( storage::CommitStage stage, Volume* vol );
virtual void changeDeviceName( const string& old, const string& nw ) {}
- unsigned numVolumes() const;
bool isEmpty() const;
void getInfo( storage::ContainerInfo& info ) const;
bool findVolume( const string& device, Volume*& vol );
+ static bool notDeleted(const Container& c) { return !c.deleted(); }
+
// iterators over volumes of a container
protected:
// protected typedefs for iterators over volumes
@@ -154,36 +155,38 @@
}
public:
- Container( Storage * const, const string& Name, storage::CType typ );
- Container( const Container& );
- Storage * getStorage() const { return sto; }
+
+ Container(Storage* s, const string& name, const string& device, CType typ);
+ Container(Storage* s, const string& name, const string& device, CType typ,
+ SystemInfo& systemInfo);
+ Container(Storage* s, CType typ, const xmlNode* node);
+ Container(const Container& c);
virtual ~Container();
- const string& name() const { return nm; }
- const string& device() const { return dev; }
- storage::CType type() const { return typ; }
- bool deleted() const { return del; }
- bool created() const { return create; }
- void setDeleted( bool val=true ) { del=val; }
- void setCreated( bool val=true ) { create=val; }
- void setSilent( bool val=true ) { silent=val; }
-
- void clearUsedBy() { uby.clear(); }
- void setUsedBy(storage::UsedByType ub_type, const string& ub_name) { uby.set(ub_type, ub_name); }
- const storage::usedBy& getUsedBy() const { return uby; }
- storage::UsedByType getUsedByType() const { return uby.type(); }
+
+ void saveData(xmlNode* node) const;
+
+ Storage* getStorage() const { return sto; }
+ const Storage* getStorageConst() const { return sto; }
+ CType type() const { return typ; }
+ bool isPartitionable() const;
+ static bool Partitionable( const Container&d )
+ { return( d.isPartitionable() ); }
+ bool isDeviceUsable() const;
+ static bool DeviceUsable( const Container&d )
+ { return( d.isDeviceUsable() ); }
bool readonly() const { return ronly; }
- unsigned long minorNr() const { return mnr; }
- unsigned long majorNr() const { return mjr; }
- unsigned long long sizeK() const { return size_k; }
- virtual string removeText(bool doing=true) const;
- virtual string createText(bool doing=true) const;
+
+ virtual Text removeText(bool doing) const;
+ virtual Text createText(bool doing) const;
virtual int resizeVolume( Volume* v, unsigned long long newSize );
virtual int removeVolume( Volume* v );
static storage::CType staticType() { return storage::CUNKNOWN; }
friend std::ostream& operator<< (std::ostream& s, const Container &c );
- virtual Container* getCopy() const { return( new Container( *this ) ); }
- bool compareContainer( const Container* c, bool verbose ) const;
+
+ virtual Container* getCopy() const = 0; // Container is always derived
+
+ bool compareContainer(const Container& rhs, bool verbose) const;
void setExtError( const string& txt ) const;
void setExtError( const SystemCmd& cmd, bool serr=true ) const;
@@ -197,37 +200,31 @@
PlainIterator end() { return vols.end(); }
virtual void print( std::ostream& s ) const { s << *this; }
- void addToList( Volume* e )
- { pointerIntoSortedList<Volume>( vols, e ); }
+ void addToList(Volume* e);
bool removeFromList( Volume* e );
virtual int doCreate( Volume * v );
virtual int doRemove( Volume * v );
virtual int doResize( Volume * v );
- virtual void logData( const string& Dir ) {}
- Container& operator=( const Container& );
+
+ virtual void logData(const string& Dir) const {}
static bool stageDecrease(const Volume& v);
static bool stageIncrease(const Volume& v);
static bool stageFormat(const Volume& v);
static bool stageMount(const Volume& v);
- static const string type_names[COTYPE_LAST_ENTRY];
-
- Storage * const sto;
- storage::CType typ;
- string nm;
- string dev;
- bool del;
- bool create;
- bool silent;
+ Storage* const sto;
+ const CType typ;
bool ronly;
- storage::usedBy uby;
- std::list<string> alt_names;
- unsigned long long size_k;
- unsigned long mnr;
- unsigned long mjr;
+
VCont vols;
- mutable storage::ContainerInfo info;
+
+ mutable storage::ContainerInfo info; // workaround for broken ycp bindings
+
+ private:
+
+ Container& operator=(const Container&); // disallow
+
};
}
Modified: branches/SuSE-Code-11-SP2-Branch/storage/libstorage/src/Dasd.cc
URL: http://svn.opensuse.org/viewcvs/yast/branches/SuSE-Code-11-SP2-Branch/stora…
==============================================================================
--- branches/SuSE-Code-11-SP2-Branch/storage/libstorage/src/Dasd.cc (original)
+++ branches/SuSE-Code-11-SP2-Branch/storage/libstorage/src/Dasd.cc Tue May 17 13:39:44 2011
@@ -1,5 +1,5 @@
/*
- * Copyright (c) [2004-2009] Novell, Inc.
+ * Copyright (c) [2004-2010] Novell, Inc.
*
* All Rights Reserved.
*
@@ -19,105 +19,92 @@
* find current contact information at www.novell.com.
*/
-/*
- Textdomain "storage"
-*/
-#include <iostream>
#include <stdio.h>
-
#include <string>
-#include <sstream>
+#include <ostream>
+#include <fstream>
#include <iomanip>
#include <boost/algorithm/string.hpp>
-#include "y2storage/SystemCmd.h"
-#include "y2storage/ProcPart.h"
-#include "y2storage/Storage.h"
-#include "y2storage/OutputProcessor.h"
-#include "y2storage/Dasd.h"
-#include "y2storage/StorageDefines.h"
+#include "storage/SystemCmd.h"
+#include "storage/ProcParts.h"
+#include "storage/Storage.h"
+#include "storage/OutputProcessor.h"
+#include "storage/Dasd.h"
+#include "storage/StorageDefines.h"
+#include "storage/SystemInfo.h"
+#include "storage/Dasdview.h"
+
+
+namespace storage
+{
+ using namespace std;
-using namespace std;
-using namespace storage;
-Dasd::Dasd( Storage * const s, const string& Name,
- unsigned long long SizeK ) :
- Disk(s,Name,SizeK)
+ Dasd::Dasd(Storage* s, const string& name, const string& device, unsigned long long SizeK,
+ SystemInfo& systeminfo)
+ : Disk(s, name, device, SizeK, systeminfo), fmt(DASDF_NONE)
{
- fmt = DASDF_NONE;
- y2deb("constructed dasd " << dev);
+ y2deb("constructed Dasd " << dev);
}
-Dasd::~Dasd()
+
+ Dasd::Dasd(const Dasd& c)
+ : Disk(c), fmt(c.fmt)
{
- y2deb("destructed dasd " << dev);
+ y2deb("copy-constructed Dasd from " << c.dev);
}
-bool Dasd::detectPartitionsFdasd( ProcPart& ppart )
+
+ Dasd::~Dasd()
+ {
+ y2deb("destructed Dasd " << dev);
+ }
+
+
+ bool
+ Dasd::detectPartitionsFdasd(SystemInfo& systeminfo)
{
bool ret = true;
- string cmd_line = FDASDBIN " -p " + quote(device());
- system_stderr.erase();
- y2milestone( "executing cmd:%s", cmd_line.c_str() );
- SystemCmd Cmd( cmd_line );
- y2milestone( "retcode:%d", Cmd.retcode() );
- if( Cmd.retcode() == 0 )
- checkFdasdOutput( Cmd, ppart );
- y2milestone( "ret:%d partitons:%zd", ret, vols.size() );
+ checkFdasdOutput(systeminfo);
+ y2mil("ret:" << ret << " partitions:" << vols.size());
return( ret );
}
-bool Dasd::detectPartitions( ProcPart& ppart )
+
+ bool
+ Dasd::detectPartitions(SystemInfo& systeminfo)
{
bool ret = true;
- string cmd_line = DASDVIEWBIN " -x " + quote(device());
- system_stderr.erase();
+
detected_label = "dasd";
setLabelData( "dasd" );
- y2milestone( "executing cmd:%s", cmd_line.c_str() );
- SystemCmd Cmd( cmd_line );
- y2milestone( "retcode:%d", Cmd.retcode() );
- if( Cmd.retcode() == 0 )
- {
- if( Cmd.select( "^format" )>0 )
- {
- string tmp = *Cmd.getLine(0, true);
- y2milestone( "Format line:%s", tmp.c_str() );
- tmp = tmp.erase( 0, tmp.find( ':' ) + 1 );
- tmp = boost::to_lower_copy(extractNthWord(4, tmp), locale::classic());
- if( tmp == "cdl" )
- fmt = DASDF_CDL;
- else if( tmp == "ldl" )
- fmt = DASDF_LDL;
- }
- getGeometry( Cmd, cyl, head, sector );
- new_cyl = cyl;
- new_head = head;
- new_sector = sector;
- y2milestone( "After dasdview Head:%u Sector:%u Cylinder:%lu SizeK:%llu",
- head, sector, cyl, size_k );
- byte_cyl = head * sector * 512;
- y2milestone( "byte_cyl:%lu", byte_cyl );
+
+ Dasdview dasdview(device());
+ new_geometry = geometry = dasdview.getGeometry();
+ fmt = dasdview.getDasdFormat();
+ ronly = fmt != DASDF_CDL;
+
if( size_k==0 )
{
- size_k = (head*sector*cyl)/2;
- y2milestone( "New SizeK:%llu", size_k );
+ size_k = geometry.sizeK();
+ y2mil("New SizeK:" << size_k);
}
- y2mil( "fmt:" << fmt );
+
switch( fmt )
{
case DASDF_CDL:
- ret = Dasd::detectPartitionsFdasd(ppart);
+ ret = Dasd::detectPartitionsFdasd(systeminfo);
break;
case DASDF_LDL:
{
max_primary = 1;
- unsigned long long s = cylinderToKb(cyl);
- Partition *p = new Partition( *this, 1, s, 0, cyl,
- PRIMARY, Partition::ID_LINUX,
- false );
- if( ppart.getSize( p->device(), s ))
+ unsigned long long s = cylinderToKb(cylinders());
+ Partition *p = new Partition(*this, getPartName(1), getPartDevice(1), 1,
+ systeminfo, s, Region(0, cylinders()), PRIMARY);
+ const ProcParts& parts = systeminfo.getProcParts();
+ if (parts.getSize(p->device(), s))
{
p->setSize( s );
}
@@ -128,105 +115,84 @@
default:
break;
}
+
+ y2mil("ret:" << ret << " partitions:" << vols.size() << " detected label:" << label);
+ y2mil("geometry:" << geometry << " fmt:" << toString(fmt) << " readonly:" << ronly);
+ return ret;
+ }
+
+
+ bool
+ Dasd::checkPartitionsValid(SystemInfo& systeminfo, const list<Partition*>& pl) const
+ {
+ const ProcParts& parts = systeminfo.getProcParts();
+ const Fdasd& fdasd = systeminfo.getFdasd(dev);
+
+ list<string> ps = partitionsKernelKnowns(parts);
+ if (pl.size() != ps.size())
+ {
+ y2err("number of partitions fdasd and kernel see differs");
+ return false;
}
- else
+
+ for (list<Partition*>::const_iterator i = pl.begin(); i != pl.end(); ++i)
{
- new_sector = sector = 96;
- y2milestone( "new sector:%u", sector );
+ const Partition& p = **i;
+
+ Fdasd::Entry entry;
+ if (fdasd.getEntry(p.nr(), entry))
+ {
+ // maybe too strict but should be ok
+
+ Region head_fdasd = entry.headRegion;
+ Region head_kernel = p.detectSysfsBlkRegion() / (geometry.headSize() / 512);
+
+ if (head_fdasd != head_kernel)
+ {
+ y2err("region mismatch dev:" << dev << " nr:" << p.nr() << " head_fdasd:" <<
+ head_fdasd << " head_kernel:" << head_kernel);
+ return false;
+ }
+ }
}
- byte_cyl = head * sector * 512;
- y2milestone( "byte_cyl:%lu", byte_cyl );
- y2milestone( "ret:%d partitons:%zd detected label:%s", ret, vols.size(),
- label.c_str() );
- ronly = fmt!=DASDF_CDL;
- y2milestone( "fmt:%d readonly:%d", fmt, ronly );
- return( ret );
+
+ return true;
}
+
bool
-Dasd::scanFdasdLine( const string& Line, unsigned& nr, unsigned long& start,
- unsigned long& csize )
+ Dasd::checkFdasdOutput(SystemInfo& systeminfo)
{
- unsigned long StartM, EndM;
- string PartitionType, TInfo;
+ const ProcParts& parts = systeminfo.getProcParts();
+ const Fdasd& fdasd = systeminfo.getFdasd(dev);
- y2deb("Line:" << Line);
- std::istringstream Data( Line );
- classic(Data);
-
- nr=0;
- StartM = EndM = 0;
- string devname;
- Data >> devname >> StartM >> EndM;
- devname.erase(0,device().size());
- devname >> nr;
- y2milestone( "Fields Num:%d Start:%lu End:%lu", nr, StartM, EndM );
- if( nr>0 )
- {
- start = StartM/head;
- csize = EndM/head-start+1;
- if( start+csize > cylinders() )
- {
- csize = cylinders()-start;
- y2milestone( "new csize:%lu", csize );
- }
- y2milestone( "Fields Num:%d Start:%ld Size:%ld", nr, start, csize );
- }
- return( nr>0 );
- }
+ assert(geometry == fdasd.getGeometry());
-bool
-Dasd::checkFdasdOutput( SystemCmd& cmd, ProcPart& ppart )
- {
- int cnt;
- string line;
- string tmp;
list<Partition *> pl;
- Regex part( "^"+device()+"[0123456789]+$" );
- cmd.select( device() );
- cnt = cmd.numLines();
- for( int i=0; i<cnt; i++)
+ for (Fdasd::const_iterator it = fdasd.getEntries().begin();
+ it != fdasd.getEntries().end(); ++it)
{
- unsigned pnr;
- unsigned long c_start;
- unsigned long c_size;
-
- line = *cmd.getLine(i);
- tmp = extractNthWord( 0, line );
- if( part.match(tmp) )
- {
- if( scanFdasdLine( line, pnr, c_start, c_size ))
- {
- if( pnr<range )
+ if( it->num < range )
{
- unsigned long long s = cylinderToKb(c_size);
- Partition *p = new Partition( *this, pnr, s,
- c_start, c_size, PRIMARY,
- Partition::ID_LINUX, false );
- if( ppart.getSize( p->device(), s ))
+ unsigned long long s = cylinderToKb(it->cylRegion.len());
+ Partition *p = new Partition(*this, getPartName(it->num), getPartDevice(it->num),
+ it->num, systeminfo, s, it->cylRegion, PRIMARY);
+ if (parts.getSize(p->device(), s))
{
p->setSize( s );
}
pl.push_back( p );
}
else
- y2warning( "partition nr %d outside range %lu", pnr, range );
- }
- }
+ y2war("partition nr " << it->num << " outside range " << range);
}
- y2mil( "nm:" << nm );
- string reg = nm;
- if( !reg.empty() && reg.find( '/' )!=string::npos &&
- isdigit(reg[reg.length()-1]) )
- reg += "p";
- reg += "[0-9]+";
- list<string> ps = ppart.getMatchingEntries( reg );
- y2mil( "regex " << reg << " ps " << ps );
+
+ y2mil("nm:" << nm);
unsigned long dummy = 0;
- if( !checkPartedValid( ppart, nm, pl, dummy ) )
+ if (!checkPartedValid(systeminfo, pl, dummy))
{
- string txt = sformat(
+ Text txt = sformat(
// popup text %1$s is replaced by disk name e.g. /dev/hda
_("The partitioning on disk %1$s is not readable by\n"
"the partitioning tool fdasd, which is used to change the\n"
@@ -247,58 +213,6 @@
return( true );
}
-void Dasd::getGeometry( SystemCmd& cmd, unsigned long& c,
- unsigned& h, unsigned& s )
- {
- string tmp;
- unsigned long val;
- if( cmd.select( "cylinders" )>0 )
- {
- val = 0;
- tmp = *cmd.getLine(0, true);
- y2milestone( "Cylinder line:%s", tmp.c_str() );
- tmp = tmp.erase( 0, tmp.find( ':' ) + 1 );
- tmp = extractNthWord( 3, tmp );
- tmp >> val;
- y2mil( "val:" << val );
- c=val;
- }
- if( cmd.select( "tracks per" )>0 )
- {
- val = 0;
- tmp = *cmd.getLine(0, true);
- y2milestone( "Tracks line:%s", tmp.c_str() );
- tmp = tmp.erase( 0, tmp.find( ':' ) + 1 );
- tmp = extractNthWord( 3, tmp );
- tmp >> val;
- y2mil( "val:" << val );
- h=val;
- }
- if( cmd.select( "blocks per" )>0 )
- {
- val = 0;
- tmp = *cmd.getLine(0, true);
- y2milestone( "Blocks line:%s", tmp.c_str() );
- tmp = tmp.erase( 0, tmp.find( ':' ) + 1 );
- tmp = extractNthWord( 3, tmp );
- tmp >> val;
- y2mil( "val:" << val );
- s=val;
- }
- if( cmd.select( "blocksize" )>0 )
- {
- val = 0;
- tmp = *cmd.getLine(0, true);
- y2milestone( "Bytes line:%s", tmp.c_str() );
- tmp = tmp.erase( 0, tmp.find( ':' ) + 1 );
- tmp = extractNthWord( 3, tmp );
- tmp >> val;
- y2mil( "val:" << val );
- s*=val/512;
- }
- y2milestone( "c:%lu h:%u s:%u", c, h, s );
- }
-
int Dasd::doResize( Volume* v )
{
@@ -312,11 +226,11 @@
int Dasd::removePartition( unsigned nr )
{
- y2milestone( "begin nr %u", nr );
+ y2mil("begin nr:" << nr);
int ret = Disk::removePartition( nr );
if( ret==0 )
{
- PartPair p = partPair( notDeleted );
+ PartPair p = partPair(Partition::notDeleted);
changeNumbers( p.begin(), p.end(), nr, -1 );
}
y2mil("ret:" << ret);
@@ -327,9 +241,9 @@
unsigned long len, string& device,
bool checkRelaxed )
{
- y2milestone( "begin type %d at %ld len %ld relaxed:%d", type, start, len,
- checkRelaxed );
- int ret = createChecks( type, start, len, checkRelaxed );
+ y2mil("begin type:" << toString(type) << " start:" << start << " len:" << len << " relaxed:"
+ << checkRelaxed);
+ int ret = createChecks(type, Region(start, len), checkRelaxed);
int number = 0;
if( ret==0 )
{
@@ -340,7 +254,7 @@
}
else
{
- PartPair p = partPair( notDeleted );
+ PartPair p = partPair(Partition::notDeleted);
number = 1;
PartIter i = p.begin();
while( i!=p.end() && i->cylStart()<start )
@@ -348,14 +262,14 @@
number++;
++i;
}
- y2milestone( "number %u", number );
+ y2mil("number:" << number);
changeNumbers( p.begin(), p.end(), number-1, 1 );
}
}
if( ret==0 )
{
- Partition * p = new Partition( *this, number, cylinderToKb(len), start,
- len, type );
+ Partition * p = new Partition(*this, getPartName(number), getPartDevice(number), number,
+ cylinderToKb(len), Region(start, len), type);
p->setCreated();
device = p->device();
addToList( p );
@@ -364,11 +278,11 @@
return( ret );
}
-string Dasd::fdasdText() const
+Text Dasd::fdasdText() const
{
- string txt;
+ Text txt;
// displayed text during action, %1$s is replaced by disk name (e.g. /dev/dasda),
- txt = sformat( _("Executing fdasd for disk %1$s..."), dev.c_str() );
+ txt = sformat( _("Executing fdasd for disk %1$s"), dev.c_str() );
return( txt );
}
@@ -382,12 +296,12 @@
string inpname = getStorage()->tmpDir()+"/fdasd_inp";
ofstream inpfile( inpname.c_str() );
classic(inpfile);
- PartPair p = partPair( notDeleted );
+ PartPair p = partPair(Partition::notDeleted);
PartIter i = p.begin();
while( i!=p.end() )
{
- string start = decString(i->cylStart()*new_head);
- string end = decString((i->cylEnd()+1)*new_head-1);
+ string start = decString(i->cylStart() * new_geometry.heads);
+ string end = decString((i->cylEnd() + 1) * new_geometry.heads - 1);
if( i->cylStart()==0 )
start = "first";
if( i->cylEnd()>=cylinders()-1 )
@@ -404,7 +318,7 @@
}
if( ret==0 )
{
- ProcPart ppart;
+ ProcParts parts;
p = partPair();
i = p.begin();
list<Partition*> rem_list;
@@ -418,13 +332,13 @@
if( i->created() )
{
unsigned long long s;
- getStorage()->waitForDevice( i->device() );
+ Storage::waitForDevice(i->device());
i->setCreated( false );
- if( ppart.getSize( i->device(), s ))
+ if (parts.getSize(i->device(), s))
{
i->setSize( s );
}
- ret = i->zeroIfNeeded();
+ ret = i->zeroIfNeeded();
}
++i;
}
@@ -441,68 +355,59 @@
return( ret );
}
-void Dasd::getCommitActions( list<commitAction*>& l ) const
+
+void
+Dasd::getCommitActions(list<commitAction>& l) const
{
- y2mil( "begin:" << name() << " init_disk:" << init_disk );
+ y2mil("begin:" << name() << " init_disk:" << init_disk);
Disk::getCommitActions( l );
if( init_disk )
{
- list<commitAction*>::iterator i = l.begin();
- while( i!=l.end() )
- {
- if( (*i)->stage==DECREASE )
- {
- delete( *i );
- i=l.erase( i );
- }
- else
- ++i;
- }
- l.push_front( new commitAction( DECREASE, staticType(),
- dasdfmtText(false), this, true ));
+ l.remove_if(stage_is(DECREASE));
+ l.push_front(commitAction(DECREASE, staticType(), dasdfmtText(false), this, true));
}
}
-string Dasd::dasdfmtTexts( bool single, const string& devs )
+
+ Text
+ Dasd::dasdfmtTexts(bool doing, const list<string>& devs)
{
- string txt;
- if( single )
+ Text txt;
+ if (doing)
{
- // displayed text during action, %1$s is replaced by disk name (e.g. dasda),
- txt = sformat( _("Executing dasdfmt for disk %1$s..."), devs.c_str() );
+ // displayed text during action, %1$s is replaced by disk name (e.g. dasda)
+ txt = sformat(_("Executing dasdfmt for disk %1$s",
+ "Executing dasdfmt for disks %1$s", devs.size()),
+ boost::join(devs, " ").c_str());
}
- else
+ else
{
- // displayed text during action, %1$s is replaced by list of disk names (e.g. dasda dasdb dasdc),
- txt = sformat( _("Executing dasdfmt for disks: %1$s..."), devs.c_str() );
+ // displayed text during action, %1$s is replaced by disk name (e.g. dasda)
+ txt = sformat(_("Execute dasdfmt on disk %1$s",
+ "Execute dasdfmt on disks %1$s", devs.size()),
+ boost::join(devs, " ").c_str());
}
- return( txt );
+ return txt;
}
-string Dasd::dasdfmtText( bool doing ) const
+
+ Text
+ Dasd::dasdfmtText(bool doing) const
{
- string txt;
- if( doing )
- {
- txt = dasdfmtTexts( true, dev );
- }
- else
- {
- // displayed text before action, %1$s is replaced by disk name (e.g. /dev/dasda),
- txt = sformat( _("Execute dasdfmt on disk %1$s"), dev.c_str() );
- }
- return( txt );
+ list<string> tmp;
+ tmp.push_back(dev);
+ return dasdfmtTexts(doing, tmp);
}
-int Dasd::getToCommit( CommitStage stage, list<Container*>& col,
- list<Volume*>& vol )
- {
- int ret = 0;
+
+void
+Dasd::getToCommit(CommitStage stage, list<const Container*>& col, list<const Volume*>& vol) const
+{
unsigned long oco = col.size();
unsigned long ovo = vol.size();
if( stage==DECREASE )
{
- VolPair p = volPair( stageDecrease );
+ ConstVolPair p = volPair( stageDecrease );
if( !p.empty() )
vol.push_back( &(*(p.begin())) );
if( deleted() || init_disk )
@@ -510,20 +415,20 @@
}
else if( stage==INCREASE )
{
- VolPair p = volPair(stageIncrease);
+ ConstVolPair p = volPair(stageIncrease);
if( !p.empty() )
vol.push_back( &(*(p.begin())) );
}
else
- ret = Disk::getToCommit( stage, col, vol );
+ Disk::getToCommit( stage, col, vol );
if( col.size()!=oco || vol.size()!=ovo )
- y2milestone( "ret:%d col:%zd vol:%zd", ret, col.size(), vol.size());
- return( ret );
- }
+ y2mil("stage:" << stage << " col:" << col.size() << " vol:" << vol.size());
+}
+
int Dasd::commitChanges( CommitStage stage )
{
- y2milestone( "name %s stage %d", name().c_str(), stage );
+ y2mil("name:" << name() << " stage:" << stage);
int ret = 0;
if( stage==DECREASE && init_disk )
{
@@ -546,7 +451,7 @@
int Dasd::doDasdfmt()
{
int ret = 0;
- y2milestone( "dasd:%s", device().c_str() );
+ y2mil("dasd:" << device());
list<Disk*> dl;
list<string> devs;
getStorage()->getDiskList( needDasdfmt, dl );
@@ -556,58 +461,56 @@
{
devs.push_back( undevDevice((*i)->device()) );
}
- y2mil( "devs:" << devs );
+ y2mil("devs:" << devs);
if( !silent )
{
- string txt = dasdfmtTexts( dl.size()==1, mergeString(devs) );
+ Text txt = dasdfmtTexts(true, devs);
getStorage()->showInfoCb( txt );
}
for( list<string>::iterator i = devs.begin(); i!=devs.end(); ++i )
{
- normalizeDevice(*i);
- *i = "-f " + quote(*i);
+ *i = "-f " + quote(normalizeDevice(*i));
}
- string cmd_line = DASDFMTBIN " -Y -P 4 -b 4096 -y -m 1 -d cdl " + mergeString(devs);
- y2milestone( "cmdline:%s", cmd_line.c_str() );
+ string cmd_line = DASDFMTBIN " -Y -P 4 -b 4096 -y -m 1 -d cdl " + boost::join(devs, " ");
+ y2mil("cmdline:" << cmd_line);
CallbackProgressBar cb = getStorage()->getCallbackProgressBarTheOne();
- ScrollBarHandler* sb = new DasdfmtScrollbar( cb );
+ ProgressBar* progressbar = new DasdfmtProgressBar( cb );
SystemCmd cmd;
- cmd.setOutputProcessor( sb );
+ cmd.setOutputProcessor(progressbar);
if( execCheckFailed( cmd, cmd_line ) )
{
ret = DASD_DASDFMT_FAILED;
}
if( ret==0 )
{
- ProcPart ppart;
+ SystemInfo systeminfo;
for( list<Disk*>::iterator i = dl.begin(); i!=dl.end(); ++i )
{
Dasd * ds = static_cast<Dasd *>(*i);
- ds->detectPartitions( ppart );
+ ds->detectPartitions(systeminfo);
ds->resetInitDisk();
ds->removeFromMemory();
}
}
+ delete progressbar;
}
return( ret );
}
int Dasd::initializeDisk( bool value )
{
- y2milestone( "value:%d old:%d", value, init_disk );
+ y2mil("value:" << value << " old:" << init_disk);
int ret = 0;
if( init_disk != value )
{
init_disk = value;
if( init_disk )
{
- new_sector = sector = 96;
- new_head = head = 15;
- y2milestone( "new sector:%u head:%u", sector, head );
- size_k = (head*sector*cyl)/2;
- y2milestone( "new SizeK:%llu", size_k );
- byte_cyl = head * sector * 512;
- y2milestone( "new byte_cyl:%lu", byte_cyl );
+ new_geometry.heads = geometry.heads = 15;
+ new_geometry.sectors = geometry.sectors = 12;
+ y2mil("new geometry:" << geometry);
+ size_k = geometry.sizeK();
+ y2mil("new SizeK:" << size_k);
ret = destroyPartitionTable( "dasd" );
}
else
@@ -639,26 +542,21 @@
return( ret );
}
-Dasd& Dasd::operator= ( const Dasd& rhs )
- {
- y2deb("operator= from " << rhs.nm);
- *((Disk*)this) = rhs;
- fmt = rhs.fmt;
- return( *this );
- }
-
-Dasd::Dasd( const Dasd& rhs ) : Disk(rhs)
- {
- fmt = DASDF_NONE;
- y2deb("constructed dasd by copy constructor from " << rhs.nm);
- }
-namespace storage
-{
std::ostream& operator<< (std::ostream& s, const Dasd& d )
{
- s << *((Disk*)&d);
- s << " fmt:" << d.fmt;
- return( s );
+ s << dynamic_cast<const Disk&>(d);
+ s << " fmt:" << toString(d.fmt);
+ return s;
}
+
+
+ static const string dasd_format_names[] = {
+ "NONE", "LDL", "CDL"
+ };
+
+ const vector<string> EnumInfo<Dasd::DasdFormat>::names(dasd_format_names, dasd_format_names +
+ lengthof(dasd_format_names));
+
+
}
Modified: branches/SuSE-Code-11-SP2-Branch/storage/libstorage/src/Dasd.h
URL: http://svn.opensuse.org/viewcvs/yast/branches/SuSE-Code-11-SP2-Branch/stora…
==============================================================================
--- branches/SuSE-Code-11-SP2-Branch/storage/libstorage/src/Dasd.h (original)
+++ branches/SuSE-Code-11-SP2-Branch/storage/libstorage/src/Dasd.h Tue May 17 13:39:44 2011
@@ -1,5 +1,5 @@
/*
- * Copyright (c) [2004-2009] Novell, Inc.
+ * Copyright (c) [2004-2010] Novell, Inc.
*
* All Rights Reserved.
*
@@ -23,21 +23,30 @@
#ifndef DASD_H
#define DASD_H
-#include "y2storage/Disk.h"
+#include "storage/Disk.h"
+
namespace storage
{
+ using std::list;
+
+
+ class ProcParts;
-class SystemCmd;
-class ProcPart;
class Dasd : public Disk
{
friend class Storage;
+
public:
- Dasd( Storage * const s, const string& Name, unsigned long long Size );
- Dasd( const Dasd& rhs );
+
+ enum DasdFormat { DASDF_NONE, DASDF_LDL, DASDF_CDL };
+
+ Dasd(Storage* s, const string& name, const string& device, unsigned long long Size,
+ SystemInfo& systeminfo);
+ Dasd(const Dasd& c);
virtual ~Dasd();
+
int createPartition( storage::PartitionType type, long unsigned start,
long unsigned len, string& device,
bool checkRelaxed=false );
@@ -45,26 +54,22 @@
int changePartitionId( unsigned nr, unsigned id ) { return 0; }
int resizePartition( Partition* p, unsigned long newCyl );
int initializeDisk( bool value );
- string fdasdText() const;
- string dasdfmtText( bool doing ) const;
- static string dasdfmtTexts( bool single, const string& devs );
- void getCommitActions( std::list<storage::commitAction*>& l ) const;
- int getToCommit( storage::CommitStage stage, std::list<Container*>& col,
- std::list<Volume*>& vol );
+ Text fdasdText() const;
+ Text dasdfmtText( bool doing ) const;
+ static Text dasdfmtTexts(bool doing, const list<string>& devs);
+ void getCommitActions(list<commitAction>& l) const;
+ void getToCommit(storage::CommitStage stage, list<const Container*>& col,
+ list<const Volume*>& vol) const;
int commitChanges( storage::CommitStage stage );
protected:
- enum DasdFormat { DASDF_NONE, DASDF_LDL, DASDF_CDL };
virtual void print( std::ostream& s ) const { s << *this; }
virtual Container* getCopy() const { return( new Dasd( *this ) ); }
- bool detectPartitionsFdasd(ProcPart& ppart);
- bool detectPartitions( ProcPart& ppart );
- bool checkFdasdOutput( SystemCmd& Cmd, ProcPart& ppart );
- bool scanFdasdLine( const string& Line, unsigned& nr,
- unsigned long& start, unsigned long& csize );
- void getGeometry( SystemCmd& cmd, unsigned long& c,
- unsigned& h, unsigned& s );
+ bool detectPartitionsFdasd(SystemInfo& systeminfo);
+ bool detectPartitions(SystemInfo& systeminfo);
+ virtual bool checkPartitionsValid(SystemInfo& systeminfo, const list<Partition*>& pl) const;
+ bool checkFdasdOutput(SystemInfo& systeminfo);
void redetectGeometry() {};
int doCreate( Volume* v ) { return(doFdasd()); }
int doRemove( Volume* v ) { return(init_disk?0:doFdasd()); }
@@ -73,13 +78,20 @@
int doSetType( Volume* v ) { return 0; }
int doCreateLabel() { return 0; }
int doDasdfmt();
+
DasdFormat fmt;
- Dasd& operator= ( const Dasd& rhs );
friend std::ostream& operator<< (std::ostream&, const Dasd& );
+ private:
+
+ Dasd& operator=(const Dasd&); // disallow
+
};
+
+ template <> struct EnumInfo<Dasd::DasdFormat> { static const vector<string> names; };
+
}
#endif
Added: branches/SuSE-Code-11-SP2-Branch/storage/libstorage/src/Dasdview.cc
URL: http://svn.opensuse.org/viewcvs/yast/branches/SuSE-Code-11-SP2-Branch/stora…
==============================================================================
--- branches/SuSE-Code-11-SP2-Branch/storage/libstorage/src/Dasdview.cc (added)
+++ branches/SuSE-Code-11-SP2-Branch/storage/libstorage/src/Dasdview.cc Tue May 17 13:39:44 2011
@@ -0,0 +1,247 @@
+/*
+ * Copyright (c) [2004-2010] Novell, Inc.
+ *
+ * All Rights Reserved.
+ *
+ * This program is free software; you can redistribute it and/or modify it
+ * under the terms of version 2 of the GNU General Public License as published
+ * by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
+ * more details.
+ *
+ * You should have received a copy of the GNU General Public License along
+ * with this program; if not, contact Novell, Inc.
+ *
+ * To contact Novell about this file by physical or electronic mail, you may
+ * find current contact information at www.novell.com.
+ */
+
+
+#include "storage/Dasdview.h"
+#include "storage/StorageDefines.h"
+#include "storage/SystemCmd.h"
+
+
+namespace storage
+{
+
+ Dasdview::Dasdview(const string& device)
+ : dasd_format(Dasd::DASDF_NONE)
+ {
+ SystemCmd cmd(DASDVIEWBIN " --extended " + quote(device));
+
+ if (cmd.retcode() == 0)
+ {
+ if (cmd.select("^format") > 0)
+ {
+ string tmp = cmd.getLine(0, true);
+ y2mil("Format line:" << tmp);
+ tmp = tmp.erase( 0, tmp.find( ':' ) + 1 );
+ tmp = boost::to_lower_copy(extractNthWord(4, tmp), locale::classic());
+ if( tmp == "cdl" )
+ dasd_format = Dasd::DASDF_CDL;
+ else if( tmp == "ldl" )
+ dasd_format = Dasd::DASDF_LDL;
+ }
+
+ scanGeometry(cmd);
+ }
+ else
+ {
+ y2err("dasdview failed");
+
+ geometry.heads = 15;
+ geometry.sectors = 12;
+ geometry.sector_size = 4096;
+ }
+
+ y2mil("device: " << device << " geometry:" << geometry << " dasd_format:" <<
+ toString(dasd_format));
+ }
+
+
+ void
+ Dasdview::scanGeometry(SystemCmd& cmd)
+ {
+ if (cmd.select("number of cylinders") > 0)
+ {
+ string tmp = cmd.getLine(0, true);
+ y2mil("Cylinder line:" << tmp);
+ tmp = tmp.erase( 0, tmp.find( ':' ) + 1 );
+ tmp = extractNthWord( 3, tmp );
+ tmp >> geometry.cylinders;
+ }
+
+ if (cmd.select("tracks per cylinder") > 0)
+ {
+ string tmp = cmd.getLine(0, true);
+ y2mil("Tracks line:" << tmp);
+ tmp = tmp.erase( 0, tmp.find( ':' ) + 1 );
+ tmp = extractNthWord( 3, tmp );
+ tmp >> geometry.heads;
+ }
+
+ if (cmd.select("blocks per track") > 0)
+ {
+ string tmp = cmd.getLine(0, true);
+ y2mil("Blocks line:" << tmp);
+ tmp = tmp.erase( 0, tmp.find( ':' ) + 1 );
+ tmp = extractNthWord( 3, tmp );
+ tmp >> geometry.sectors;
+ }
+
+ if (cmd.select("blocksize") > 0)
+ {
+ string tmp = cmd.getLine(0, true);
+ y2mil("Bytes line:" << tmp);
+ tmp = tmp.erase( 0, tmp.find( ':' ) + 1 );
+ tmp = extractNthWord( 3, tmp );
+ tmp >> geometry.sector_size;
+ }
+ }
+
+
+ Fdasd::Fdasd(const string& device)
+ {
+ SystemCmd cmd(FDASDBIN " --table " + quote(device));
+
+ if (cmd.retcode() == 0)
+ {
+ scanGeometry(cmd);
+
+ Regex part("^" + device + "[0123456789]+$");
+ cmd.select( device );
+ int cnt = cmd.numLines();
+ for (int i = 0; i < cnt; ++i)
+ {
+ string line = cmd.getLine(i);
+ string tmp = extractNthWord( 0, line );
+ if( part.match(tmp) )
+ {
+ scanEntryLine(line);
+ }
+ }
+ }
+ else
+ {
+ y2err("fdasd failed");
+ }
+
+ y2mil("device:" << device << " geometry:" << geometry);
+
+ for (const_iterator it = entries.begin(); it != entries.end(); ++it)
+ y2mil(*it);
+ }
+
+
+ bool
+ Fdasd::getEntry(unsigned num, Entry& entry) const
+ {
+ for (const_iterator it = entries.begin(); it != entries.end(); ++it)
+ {
+ if (it->num == num)
+ {
+ entry = *it;
+ return true;
+ }
+ }
+
+ return false;
+ }
+
+
+ std::ostream& operator<<(std::ostream& s, const Fdasd::Entry& e)
+ {
+ return s << "num:" << e.num << " cylRegion:" << e.cylRegion << " headRegion:"
+ << e.headRegion;
+ }
+
+
+ void
+ Fdasd::scanGeometry(SystemCmd& cmd)
+ {
+ if (cmd.select("cylinders") > 0)
+ {
+ string tmp = cmd.getLine(0, true);
+ y2mil("Cylinder line:" << tmp);
+ tmp = tmp.erase( 0, tmp.find( ':' ) + 1 );
+ tmp >> geometry.cylinders;
+ }
+
+ if (cmd.select("tracks per cylinder") > 0)
+ {
+ string tmp = cmd.getLine(0, true);
+ y2mil("Tracks line:" << tmp);
+ tmp = tmp.erase( 0, tmp.find( ':' ) + 1 );
+ tmp >> geometry.heads;
+ }
+
+ if (cmd.select("blocks per track") > 0)
+ {
+ string tmp = cmd.getLine(0, true);
+ y2mil("Blocks line:" << tmp);
+ tmp = tmp.erase( 0, tmp.find( ':' ) + 1 );
+ tmp >> geometry.sectors;
+ }
+
+ if (cmd.select("bytes per block") > 0)
+ {
+ string tmp = cmd.getLine(0, true);
+ y2mil("Bytes line:" << tmp);
+ tmp = tmp.erase( 0, tmp.find( ':' ) + 1 );
+ tmp >> geometry.sector_size;
+ }
+ }
+
+
+ void
+ Fdasd::scanEntryLine(const string& line)
+ {
+ std::istringstream Data(line);
+ classic(Data);
+
+ Entry entry;
+
+ unsigned long StartM = 0;
+ unsigned long EndM = 0;
+ unsigned long SizeM = 0;
+
+ string devname;
+ Data >> devname >> StartM >> EndM >> SizeM;
+
+ string::size_type pos = devname.find_last_not_of("0123456789");
+ string(devname, pos + 1) >> entry.num;
+
+ y2mil("Fields Num:" << entry.num << " Start:" << StartM << " End:" << EndM <<
+ " Size:" << SizeM);
+
+ assert(!Data.fail());
+ assert(entry.num != 0);
+
+ if (Data.fail() || entry.num == 0)
+ {
+ y2err("invalid line:" << line);
+ return;
+ }
+
+ unsigned long start = StartM / geometry.heads;
+ unsigned long csize = EndM / geometry.heads - start + 1;
+ if( start+csize > geometry.cylinders )
+ {
+ csize = geometry.cylinders - start;
+ y2mil("new csize:" << csize);
+ }
+ entry.cylRegion = Region(start, csize);
+
+ entry.headRegion = Region(StartM, SizeM);
+
+ y2mil("Fields num:" << entry.num << " cylRegion:" << entry.cylRegion << " headRegion:" <<
+ entry.headRegion);
+
+ entries.push_back(entry);
+ }
+
+}
Added: branches/SuSE-Code-11-SP2-Branch/storage/libstorage/src/Dasdview.h
URL: http://svn.opensuse.org/viewcvs/yast/branches/SuSE-Code-11-SP2-Branch/stora…
==============================================================================
--- branches/SuSE-Code-11-SP2-Branch/storage/libstorage/src/Dasdview.h (added)
+++ branches/SuSE-Code-11-SP2-Branch/storage/libstorage/src/Dasdview.h Tue May 17 13:39:44 2011
@@ -0,0 +1,96 @@
+/*
+ * Copyright (c) [2004-2010] Novell, Inc.
+ *
+ * All Rights Reserved.
+ *
+ * This program is free software; you can redistribute it and/or modify it
+ * under the terms of version 2 of the GNU General Public License as published
+ * by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
+ * more details.
+ *
+ * You should have received a copy of the GNU General Public License along
+ * with this program; if not, contact Novell, Inc.
+ *
+ * To contact Novell about this file by physical or electronic mail, you may
+ * find current contact information at www.novell.com.
+ */
+
+
+#ifndef DASDVIEW_H
+#define DASDVIEW_H
+
+#include "storage/StorageInterface.h"
+#include "storage/Geometry.h"
+#include "storage/Dasd.h"
+
+
+namespace storage
+{
+ class SystemCmd;
+
+
+ class Dasdview
+ {
+
+ public:
+
+ Dasdview(const string& device);
+
+ const Geometry& getGeometry() const { return geometry; }
+ Dasd::DasdFormat getDasdFormat() const { return dasd_format; }
+
+ private:
+
+ Geometry geometry;
+ Dasd::DasdFormat dasd_format;
+
+ void scanGeometry(SystemCmd& cmd);
+
+ };
+
+
+ class Fdasd
+ {
+
+ public:
+
+ Fdasd(const string& device);
+
+ struct Entry
+ {
+ Entry() : num(0) {}
+
+ unsigned num;
+ Region cylRegion;
+ Region headRegion;
+
+ friend std::ostream& operator<<(std::ostream& s, const Entry& e);
+ };
+
+ const Geometry& getGeometry() const { return geometry; }
+
+ typedef vector<Entry>::const_iterator const_iterator;
+
+ const vector<Entry>& getEntries() const { return entries; }
+
+ bool getEntry(unsigned num, Entry& entry) const;
+
+ private:
+
+ typedef vector<Entry>::iterator iterator;
+
+ Geometry geometry;
+ vector<Entry> entries;
+
+ void scanGeometry(SystemCmd& cmd);
+ void scanEntryLine(const string& line);
+
+ };
+
+}
+
+#endif
Modified: branches/SuSE-Code-11-SP2-Branch/storage/libstorage/src/DerefIterator.h
URL: http://svn.opensuse.org/viewcvs/yast/branches/SuSE-Code-11-SP2-Branch/stora…
==============================================================================
--- branches/SuSE-Code-11-SP2-Branch/storage/libstorage/src/DerefIterator.h (original)
+++ branches/SuSE-Code-11-SP2-Branch/storage/libstorage/src/DerefIterator.h Tue May 17 13:39:44 2011
@@ -23,7 +23,7 @@
#ifndef DEREF_ITERATOR_H
#define DEREF_ITERATOR_H
-#include "y2storage/AppUtil.h"
+#include "storage/AppUtil.h"
namespace storage
{
@@ -40,7 +40,8 @@
DerefIterator() {}
- DerefIterator( const Iter& i ) : Iter(i) {}
+ template< class It >
+ DerefIterator( const It& i ) : Iter(i) {}
DerefIterator& operator++() { Iter::operator++(); return(*this); }
DerefIterator operator++(int)
Added: branches/SuSE-Code-11-SP2-Branch/storage/libstorage/src/Device.cc
URL: http://svn.opensuse.org/viewcvs/yast/branches/SuSE-Code-11-SP2-Branch/stora…
==============================================================================
--- branches/SuSE-Code-11-SP2-Branch/storage/libstorage/src/Device.cc (added)
+++ branches/SuSE-Code-11-SP2-Branch/storage/libstorage/src/Device.cc Tue May 17 13:39:44 2011
@@ -0,0 +1,199 @@
+/*
+ * Copyright (c) [2004-2010] Novell, Inc.
+ *
+ * All Rights Reserved.
+ *
+ * This program is free software; you can redistribute it and/or modify it
+ * under the terms of version 2 of the GNU General Public License as published
+ * by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
+ * more details.
+ *
+ * You should have received a copy of the GNU General Public License along
+ * with this program; if not, contact Novell, Inc.
+ *
+ * To contact Novell about this file by physical or electronic mail, you may
+ * find current contact information at www.novell.com.
+ */
+
+
+#include "storage/Device.h"
+#include "storage/AppUtil.h"
+#include "storage/StorageTmpl.h"
+#include "storage/HumanString.h"
+
+
+namespace storage
+{
+ using namespace std;
+
+
+ Device::Device(const string& nm, const string& dev)
+ : nm(nm), dev(dev), create(false), del(false), silent(false), size_k(0), mjr(0), mnr(0)
+ {
+ y2deb("constructed Device " << dev);
+ }
+
+
+ Device::Device(const string& nm, const string& dev, SystemInfo& systeminfo)
+ : nm(nm), dev(dev), create(false), del(false), silent(false), size_k(0), mjr(0), mnr(0)
+ {
+ y2deb("constructed Device " << dev);
+
+ assert(!nm.empty() && !dev.empty());
+ }
+
+
+ Device::Device(const xmlNode* node)
+ : nm(), dev(), create(false), del(false), silent(false), size_k(0), mjr(0), mnr(0)
+ {
+ getChildValue(node, "name", nm);
+ getChildValue(node, "device", dev);
+
+ getChildValue(node, "size_k", size_k);
+
+ getChildValue(node, "major", mjr);
+ getChildValue(node, "minor", mnr);
+
+ y2deb("constructed Device " << dev);
+
+ assert(!nm.empty() && !dev.empty());
+ }
+
+
+ Device::Device(const Device& d)
+ : nm(d.nm), dev(d.dev), create(d.create), del(d.del), silent(d.silent), size_k(d.size_k),
+ mjr(d.mjr), mnr(d.mnr), uby(d.uby), alt_names(d.alt_names)
+ {
+ y2deb("copy-constructed Device " << dev);
+ }
+
+
+ Device::~Device()
+ {
+ y2deb("destructed Device " << dev);
+ }
+
+
+ void
+ Device::saveData(xmlNode* node) const
+ {
+ setChildValue(node, "name", nm);
+ setChildValue(node, "device", dev);
+ setChildValue(node, "size_k", size_k);
+ setChildValue(node, "major", mjr);
+ setChildValue(node, "minor", mnr);
+
+ if (!uby.empty())
+ setChildValue(node, "used_by", uby);
+ }
+
+
+ void
+ Device::setNameDevice(const string& name, const string& device)
+ {
+ nm = name;
+ dev = device;
+ }
+
+
+ string
+ Device::sizeString() const
+ {
+ return byteToHumanString(1024 * sizeK(), false, 2, false);
+ }
+
+
+ bool
+ Device::getMajorMinor()
+ {
+ return storage::getMajorMinor(dev, mjr, mnr);
+ }
+
+
+ string
+ Device::udevPath() const
+ {
+ return string();
+ }
+
+ list<string>
+ Device::udevId() const
+ {
+ return list<string>();
+ }
+
+
+ void
+ Device::setUsedBy(UsedByType type, const string& device)
+ {
+ uby.clear();
+ uby.push_back(UsedBy(type, device));
+ }
+
+ void
+ Device::addUsedBy(UsedByType type, const string& device)
+ {
+ uby.push_back(UsedBy(type, device));
+ }
+
+ void
+ Device::removeUsedBy(UsedByType type, const string& device)
+ {
+ uby.remove(UsedBy(type, device));
+ }
+
+ bool
+ Device::isUsedBy(UsedByType type) const
+ {
+ for (list<UsedBy>::const_iterator it = uby.begin(); it != uby.end(); ++it)
+ if (it->type() == type)
+ return true;
+
+ return false;
+ }
+
+
+bool Device::sameDevice( const string& device ) const
+ {
+ string d = normalizeDevice(device);
+ return( d==dev ||
+ find( alt_names.begin(), alt_names.end(), d )!=alt_names.end() );
+ }
+
+
+ void
+ Device::logDifference(std::ostream& log, const Device& rhs) const
+ {
+ log << "nm:" + nm;
+ if (nm != rhs.nm)
+ log << "-->" << rhs.nm;
+ logDiff(log, "dev", dev, rhs.dev);
+
+ logDiff(log, "deleted", del, rhs.del);
+ logDiff(log, "created", create, rhs.create);
+
+ logDiff(log, "mjr", mjr, rhs.mjr);
+ logDiff(log, "mnr", mnr, rhs.mnr);
+ }
+
+
+ std::ostream& operator<<(std::ostream& s, const Device& d)
+ {
+ s << "Name:" << d.nm << " Device:" << d.dev;
+ s << " SizeK:" << d.size_k;
+ if (d.mjr != 0 || d.mnr != 0)
+ s << " Node:<" << d.mjr << ":" << d.mnr << ">";
+ if (d.create)
+ s << " created";
+ if (d.del)
+ s << " deleted";
+ if (d.silent)
+ s << " silent";
+ return s;
+ }
+
+}
Added: branches/SuSE-Code-11-SP2-Branch/storage/libstorage/src/Device.h
URL: http://svn.opensuse.org/viewcvs/yast/branches/SuSE-Code-11-SP2-Branch/stora…
==============================================================================
--- branches/SuSE-Code-11-SP2-Branch/storage/libstorage/src/Device.h (added)
+++ branches/SuSE-Code-11-SP2-Branch/storage/libstorage/src/Device.h Tue May 17 13:39:44 2011
@@ -0,0 +1,127 @@
+/*
+ * Copyright (c) [2004-2010] Novell, Inc.
+ *
+ * All Rights Reserved.
+ *
+ * This program is free software; you can redistribute it and/or modify it
+ * under the terms of version 2 of the GNU General Public License as published
+ * by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
+ * more details.
+ *
+ * You should have received a copy of the GNU General Public License along
+ * with this program; if not, contact Novell, Inc.
+ *
+ * To contact Novell about this file by physical or electronic mail, you may
+ * find current contact information at www.novell.com.
+ */
+
+
+#ifndef DEVICE_H
+#define DEVICE_H
+
+
+#include <string>
+#include <list>
+
+#include "storage/StorageTypes.h"
+#include "storage/XmlFile.h"
+
+
+namespace storage
+{
+ using std::string;
+ using std::list;
+
+
+ class SystemInfo;
+
+
+ class Device
+ {
+ public:
+
+ Device(const string& nm, const string& dev);
+ Device(const string& nm, const string& dev, SystemInfo& systeminfo);
+ Device(const xmlNode* node);
+ Device(const Device&);
+ virtual ~Device();
+
+ void saveData(xmlNode* node) const;
+
+ const string& name() const { return nm; }
+ const string& device() const { return dev; }
+ void setNameDevice(const string& nm, const string& dev);
+
+ bool created() const { return create; }
+ bool deleted() const { return del; }
+ void setCreated(bool val = true) { create = val; }
+ void setDeleted(bool val = true) { del = val; }
+
+ bool isSilent() const { return silent; }
+ void setSilent(bool val = true) { silent = val; }
+
+ unsigned long long sizeK() const { return size_k; }
+ string sizeString() const;
+
+ bool getMajorMinor();
+ unsigned long majorNr() const { return mjr; }
+ unsigned long minorNr() const { return mnr; }
+
+ const std::list<string>& altNames() const { return( alt_names ); }
+ void setAltNames( std::list<string>& li ) { alt_names=li; }
+ bool sameDevice( const string& device ) const;
+
+ // udev path and ids (without leading "/dev/disk/by-*/")
+ virtual string udevPath() const;
+ virtual list<string> udevId() const;
+
+ // name for device in /proc/partitions
+ virtual string procName() const { return ""; }
+
+ // full path for device in /sys/block
+ virtual string sysfsPath() const { return ""; }
+
+ void clearUsedBy() { uby.clear(); }
+ void setUsedBy(UsedByType type, const string& device);
+ void addUsedBy(UsedByType type, const string& device);
+ void removeUsedBy(UsedByType type, const string& device);
+ bool isUsedBy() const { return !uby.empty(); }
+ bool isUsedBy(UsedByType type) const;
+ const list<UsedBy>& getUsedBy() const { return uby; }
+
+ void logDifference(std::ostream& log, const Device& rhs) const;
+
+ friend std::ostream& operator<<(std::ostream& s, const Device& d);
+
+ protected:
+
+ string nm;
+ string dev;
+
+ bool create;
+ bool del;
+
+ bool silent;
+
+ unsigned long long size_k;
+
+ unsigned long mjr;
+ unsigned long mnr;
+
+ list<UsedBy> uby;
+ list<string> alt_names;
+
+ private:
+
+ Device& operator=(const Device&); // disallow
+
+ };
+
+}
+
+
+#endif
Modified: branches/SuSE-Code-11-SP2-Branch/storage/libstorage/src/Disk.cc
URL: http://svn.opensuse.org/viewcvs/yast/branches/SuSE-Code-11-SP2-Branch/stora…
==============================================================================
--- branches/SuSE-Code-11-SP2-Branch/storage/libstorage/src/Disk.cc (original)
+++ branches/SuSE-Code-11-SP2-Branch/storage/libstorage/src/Disk.cc Tue May 17 13:39:44 2011
@@ -1,5 +1,5 @@
/*
- * Copyright (c) [2004-2009] Novell, Inc.
+ * Copyright (c) [2004-2010] Novell, Inc.
*
* All Rights Reserved.
*
@@ -19,180 +19,155 @@
* find current contact information at www.novell.com.
*/
-/*
- Textdomain "storage"
-*/
-
-#include <fcntl.h>
-#include <sys/mount.h> /* for BLKGETSIZE */
-#include <linux/hdreg.h> /* for HDIO_GETGEO */
-#include <iostream>
#include <string>
+#include <ostream>
+#include <fstream>
#include <sstream>
#include <iomanip>
#include <boost/algorithm/string.hpp>
-#include "y2storage/Region.h"
-#include "y2storage/Partition.h"
-#include "y2storage/ProcPart.h"
-#include "y2storage/Disk.h"
-#include "y2storage/Storage.h"
-#include "y2storage/AsciiFile.h"
-#include "y2storage/AppUtil.h"
-#include "y2storage/SystemCmd.h"
-#include "y2storage/StorageDefines.h"
-
-using namespace std;
-using namespace storage;
-
-Disk::Disk( Storage * const s, const string& Name,
- unsigned long long SizeK ) :
- Container(s,"",staticType())
- {
- init_disk = dmp_slave = iscsi = gpt_enlarge = no_addpart = false;
- logical_sector_size = 512;
- nm = Name;
- undevDevice(nm);
- logfile_name = nm;
- string::size_type pos = 0;
- while( (pos=logfile_name.find( '/', pos )) != string::npos )
- logfile_name[pos] = '_';
- if( Name.find( "/dev/" )==0 )
- dev = Name;
- else
- dev = "/dev/" + Name;
+#include "storage/Region.h"
+#include "storage/Partition.h"
+#include "storage/SystemInfo.h"
+#include "storage/ProcParts.h"
+#include "storage/Disk.h"
+#include "storage/Storage.h"
+#include "storage/AppUtil.h"
+#include "storage/SystemCmd.h"
+#include "storage/StorageDefines.h"
+#include "storage/Parted.h"
+
+
+namespace storage
+{
+ using namespace std;
+
+ const unsigned int fuzz_cyl = 2;
+
+
+ Disk::Disk(Storage* s, const string& name, const string& device,
+ unsigned long long SizeK, SystemInfo& systeminfo)
+ : Container(s, name, device, staticType(), systeminfo),
+ init_disk(false), transport(TUNKNOWN), dmp_slave(false), no_addpart(false),
+ gpt_enlarge(false), del_ptable(false)
+ {
+ logfile_name = boost::replace_all_copy(nm, "/", "_");
+ getMajorMinor();
+
+ Lsscsi::Entry entry;
+ if (systeminfo.getLsscsi().getEntry(device, entry))
+ transport = entry.transport;
+
size_k = SizeK;
- y2deb("constructed disk " << dev);
+ y2deb("constructed Disk name:" << name);
}
-Disk::Disk( Storage * const s, const string& Name,
- unsigned num, unsigned long long SizeK, ProcPart& ppart ) :
- Container(s,Name,staticType())
- {
- y2milestone( "constructed disk %s nr %u sizeK:%llu", Name.c_str(), num,
- SizeK );
- logfile_name = Name + decString(num);
- init_disk = dmp_slave = iscsi = gpt_enlarge = no_addpart = false;
- logical_sector_size = 512;
+
+ Disk::Disk(Storage* s, const string& name, const string& device, unsigned num,
+ unsigned long long SizeK, SystemInfo& systeminfo)
+ : Container(s, name, device, staticType(), systeminfo),
+ init_disk(false), transport(TUNKNOWN), dmp_slave(false), no_addpart(false),
+ gpt_enlarge(false), del_ptable(false)
+ {
+ y2mil("constructed Disk name:" << name << " nr " << num << " sizeK:" << SizeK);
+ logfile_name = name + decString(num);
ronly = true;
size_k = SizeK;
- head = new_head = 16;
- sector = new_sector = 32;
- byte_cyl = head * sector * logical_sector_size;
- cyl = new_cyl = 0;
- addPartition( num, size_k, ppart );
+ addPartition( num, size_k, systeminfo );
}
-Disk::Disk( Storage * const s, const string& fname ) :
- Container(s,"",staticType())
+
+ Disk::Disk(Storage* s, const xmlNode* node)
+ : Container(s, staticType(), node), label(), udev_path(),
+ udev_id(), max_primary(0), ext_possible(false), max_logical(0),
+ init_disk(false), transport(TUNKNOWN), dmp_slave(false), no_addpart(false),
+ gpt_enlarge(false), range(4), del_ptable(false)
{
- init_disk = dmp_slave = iscsi = gpt_enlarge = no_addpart = false;
- logical_sector_size = 512;
- nm = fname.substr( fname.find_last_of( '/' )+1);
- if( nm.find("disk_")==0 )
- nm.erase( 0, 5 );
- AsciiFile file( fname );
- string line;
- if( searchFile( file, "^Device:", line ) )
- {
- dev = extractNthWord( 1, line );
- }
- mnr = mjr = 0;
- if( searchFile( file, "^Major:", line ) )
- {
- extractNthWord( 1, line ) >> mjr;
- }
- if( searchFile( file, "^Minor:", line ) )
- {
- extractNthWord( 1, line ) >> mnr;
- }
- range = 4;
- if( searchFile( file, "^Range:", line ) )
- {
- extractNthWord( 1, line ) >> range;
- }
- cyl = 1024;
- if( searchFile( file, "^Cylinder:", line ) )
- {
- extractNthWord( 1, line ) >> cyl;
- }
- head = 1024;
- if( searchFile( file, "^Head:", line ) )
- {
- extractNthWord( 1, line ) >> head;
- }
- sector = 32;
- if( searchFile( file, "^Sector:", line ) )
- {
- extractNthWord( 1, line ) >> sector;
- }
- byte_cyl = head * sector * logical_sector_size;
- if( searchFile( file, "^Label:", line ) )
- {
- label = extractNthWord( 1, line );
- }
- max_primary = 0;
- if( searchFile( file, "^MaxPrimary:", line ) )
- {
- extractNthWord( 1, line ) >> max_primary;
- }
- ext_possible = false;
- if( searchFile( file, "^ExtPossible:", line ) )
- {
- extractNthWord( 1, line ) >> ext_possible;
- }
- max_logical = 0;
- if( searchFile( file, "^MaxLogical:", line ) )
- {
- extractNthWord( 1, line ) >> max_logical;
- }
- ronly = false;
- if( searchFile( file, "^Readonly:", line ) )
- {
- extractNthWord( 1, line ) >> ronly;
- }
- if( FakeDisk() && isdigit( nm[nm.size()-1] ))
- {
- string::size_type p = nm.find_last_not_of( "0123456789" );
- nm.erase( p+1 );
- }
- size_k = 0;
- if( searchFile( file, "^SizeK:", line ) )
- {
- extractNthWord( 1, line ) >> size_k;
- }
- logical_sector_size = 512;
- if( searchFile( file, "^LogicalSectorSize:", line ) )
- {
- extractNthWord( 1, line ) >> logical_sector_size;
- }
- udev_path.clear();
- if( searchFile( file, "^UdevPath:", line ) )
- {
- udev_path = extractNthWord( 1, line );
- }
- udev_id.clear();
- if( searchFile( file, "^UdevId:", line ) )
+ logfile_name = nm;
+
+ getChildValue(node, "range", range);
+
+ getChildValue(node, "geometry", geometry);
+
+ getChildValue(node, "label", label);
+ getChildValue(node, "max_primary", max_primary);
+ getChildValue(node, "ext_possible", ext_possible);
+ getChildValue(node, "max_logical", max_logical);
+
+ const list<const xmlNode*> l = getChildNodes(node, "partition");
+ for (list<const xmlNode*>::const_iterator it = l.begin(); it != l.end(); ++it)
+ addToList(new Partition(*this, *it));
+
+ y2deb("constructed Disk " << dev);
+ }
+
+
+ Disk::Disk(const Disk& c)
+ : Container(c), geometry(c.geometry), new_geometry(c.new_geometry),
+ label(c.label), udev_path(c.udev_path), udev_id(c.udev_id),
+ detected_label(c.detected_label), logfile_name(c.logfile_name),
+ max_primary(c.max_primary),
+ ext_possible(c.ext_possible), max_logical(c.max_logical),
+ init_disk(c.init_disk), transport(c.transport),
+ dmp_slave(c.dmp_slave), no_addpart(c.no_addpart),
+ gpt_enlarge(c.gpt_enlarge), range(c.range),
+ del_ptable(c.del_ptable)
+ {
+ y2deb("copy-constructed Disk " << dev);
+
+ ConstPartPair p = c.partPair();
+ for (ConstPartIter i = p.begin(); i != p.end(); ++i)
{
- udev_id.push_back( extractNthWord( 1, line ));
+ Partition* p = new Partition(*this, *i);
+ vols.push_back(p);
}
- int lnr = 0;
- while( searchFile( file, "^Partition:", line, lnr ))
+ }
+
+
+ Disk::~Disk()
+ {
+ y2deb("destructed Disk " << dev);
+ }
+
+
+ void
+ Disk::saveData(xmlNode* node) const
+ {
+ Container::saveData(node);
+
+ setChildValue(node, "range", range);
+
+ setChildValue(node, "geometry", geometry);
+
+ setChildValue(node, "label", label);
+ setChildValue(node, "max_primary", max_primary);
+ if (ext_possible)
{
- lnr++;
- Partition *p = new Partition( *this, extractNthWord( 1, line, true ));
- addToList( p );
+ setChildValue(node, "ext_possible", ext_possible);
+ setChildValue(node, "max_logical", max_logical);
}
- y2deb("constructed disk " << dev << " from file " << fname);
+
+ if (!udev_path.empty())
+ setChildValue(node, "udev_path", udev_path);
+ if (!udev_id.empty())
+ setChildValue(node, "udev_id", udev_id);
+
+ if (transport != TUNKNOWN)
+ setChildValue(node, "transport", toString(transport));
+
+ ConstPartPair vp = partPair();
+ for (ConstPartIter v = vp.begin(); v != vp.end(); ++v)
+ v->saveData(xmlNewChild(node, "partition"));
}
-Disk::~Disk()
+
+ string
+ Disk::sysfsPath() const
{
- y2deb("destructed disk " << dev);
+ return SYSFSDIR "/" + boost::replace_all_copy(procName(), "/", "!");
}
- const unsigned int fuzz_cyl = 2;
void
Disk::triggerUdevUpdate() const
@@ -212,19 +187,8 @@
y2mil("disk:" << nm << " path:" << path << "id:" << id);
udev_path = path;
udev_id = id;
-
- udev_id.erase(remove_if(udev_id.begin(), udev_id.end(), find_begin("edd-")), udev_id.end());
-
- if( udev_id.size()>1 )
- {
- list<string>::iterator i = find_if( udev_id.begin(), udev_id.end(), find_begin( "ata-" ) );
- if( i!=udev_id.end() && i!=udev_id.begin() )
- {
- string tmp = *i;
- udev_id.erase( i );
- udev_id.push_front(tmp);
- }
- }
+ udev_id.remove_if(string_starts_with("edd-"));
+ partition(udev_id.begin(), udev_id.end(), string_starts_with("ata-"));
y2mil("id:" << udev_id);
alt_names.remove_if(string_contains("/by-path/"));
@@ -243,161 +207,58 @@
}
-unsigned long long
-Disk::cylinderToKb( unsigned long cylinder ) const
- {
- return (unsigned long long)byte_cyl * cylinder / 1024;
- }
-
-unsigned long
-Disk::kbToCylinder( unsigned long long kb ) const
+ bool
+ Disk::detect(SystemInfo& systeminfo)
{
- unsigned long long bytes = kb * 1024;
- bytes += byte_cyl - 1;
- unsigned long ret = bytes/byte_cyl;
- y2milestone( "KB:%lld ret:%ld byte_cyl:%ld", kb, ret, byte_cyl );
- return (ret);
+ return detectGeometry() && detectPartitions(systeminfo);
}
-bool Disk::detect( ProcPart& ppart )
- {
- return( detectGeometry() && detectPartitions(ppart) );
- }
bool Disk::detectGeometry()
{
- y2milestone( "disk:%s", device().c_str() );
- bool ret = false;
- int fd = open( device().c_str(), O_RDONLY );
- if( fd >= 0 )
- {
- int rcode = ioctl(fd, BLKSSZGET, &logical_sector_size);
- y2mil("BLKSSZGET ret:" << rcode << " sector_size:" << logical_sector_size);
-
- head = 255;
- sector = 63;
- cyl = 16;
- struct hd_geometry geometry;
- rcode = ioctl( fd, HDIO_GETGEO, &geometry );
- if( rcode==0 )
- {
- head = geometry.heads>0?geometry.heads:head;
- sector = geometry.sectors>0?geometry.sectors:sector;
- cyl = geometry.cylinders>0?geometry.cylinders:cyl;
- }
- y2milestone( "After HDIO_GETGEO ret %d Head:%u Sector:%u Cylinder:%lu",
- rcode, head, sector, cyl );
- __uint64_t sect = 0;
- rcode = ioctl( fd, BLKGETSIZE64, §);
- y2milestone( "BLKGETSIZE64 Ret:%d Bytes:%llu", rcode,
- (unsigned long long int) sect );
- if( rcode==0 && sect!=0 )
- {
- sect /= logical_sector_size;
- cyl = (unsigned)(sect / (__uint64_t)(head*sector));
- ret = true;
- }
- else
- {
- unsigned long lsect;
- rcode = ioctl( fd, BLKGETSIZE, &lsect );
- y2milestone( "BLKGETSIZE Ret:%d Sect:%lu", rcode, lsect );
- if( rcode==0 && lsect!=0 )
- {
- cyl = lsect / (unsigned long)(head*sector);
- ret = true;
- }
- }
- y2milestone( "After getsize Cylinder:%lu", cyl );
- close( fd );
- }
- byte_cyl = head * sector * logical_sector_size;
- y2milestone( "ret:%d byte_cyl:%lu", ret, byte_cyl );
- return( ret );
- }
-
-
- unsigned long long
- Disk::sectorToKb(unsigned long long sector) const
- {
- // TODO use 128 arithmetic
- return sector * logical_sector_size / 1024;
- }
-
-
- unsigned long long
- Disk::kbToSector(unsigned long long kb) const
- {
- // TODO use 128 arithmetic
- return kb * 1024 / logical_sector_size;
+ return storage::detectGeometry(dev, geometry);
}
bool
Disk::getSysfsInfo(const string& sysfsdir, SysfsInfo& sysfsinfo)
{
- string sysfsfile = sysfsdir + "/dev";
- if (access(sysfsfile.c_str(), R_OK) == 0)
+ string devtype;
+ if (read_sysfs_property(sysfsdir + "/device/devtype", devtype, false))
{
- ifstream file(sysfsfile.c_str());
- classic(file);
- char c;
- file >> sysfsinfo.mjr >> c >> sysfsinfo.mnr;
+ sysfsinfo.vbd = devtype == "vbd";
}
else
{
- y2war("reading " << sysfsfile << " failed");
- return false;
- }
-
- sysfsfile = sysfsdir + "/device";
- if (!readlink(sysfsfile, sysfsinfo.device))
- {
// not always available so no error
- sysfsinfo.device.clear();
+ sysfsinfo.vbd = false;
}
- if (!read_sysfs_property(sysfsdir + "/range", sysfsinfo.range))
- return false;
-
- unsigned long ext_range;
- if (read_sysfs_property(sysfsdir + "/ext_range", ext_range, false))
- sysfsinfo.range = ext_range;
+ if (!read_sysfs_property(sysfsdir + "/ext_range", sysfsinfo.range, false))
+ if (!read_sysfs_property(sysfsdir + "/range", sysfsinfo.range))
+ return false;
if (!read_sysfs_property(sysfsdir + "/size", sysfsinfo.size))
return false;
- y2mil("sysfsdir:" << sysfsdir << " mjr:" << sysfsinfo.mjr << " mnr:" << sysfsinfo.mnr <<
- " device:" << sysfsinfo.device << " range:" << sysfsinfo.range << " size:" <<
- sysfsinfo.size);
+ y2mil("sysfsdir:" << sysfsdir << " devtype:" << devtype << " range:" << sysfsinfo.range <<
+ " size:" << sysfsinfo.size);
return true;
}
bool
- Disk::getSysfsInfo(const string& SysfsDir)
+ Disk::getSysfsInfo()
{
bool ret = true;
- sysfs_dir = SysfsDir;
- y2mil("sysfs_dir:" << sysfs_dir);
SysfsInfo sysfsinfo;
- if (getSysfsInfo(sysfs_dir, sysfsinfo))
+ if (getSysfsInfo(sysfsPath(), sysfsinfo))
{
range = sysfsinfo.range;
if (range <= 1)
ret = false;
-
- mjr = sysfsinfo.mjr;
- mnr = sysfsinfo.mnr;
-
- string link;
- if (readlink(sysfs_dir, link))
- {
- y2mil("link:" << link);
- iscsi = boost::contains(link, "/session");
- }
}
else
{
@@ -405,119 +266,43 @@
}
y2mil("dev:" << dev << " ret:" << ret << " range:" << range << " major:" << mjr <<
- " minor:" << mnr << " iscsi:" << iscsi);
+ " minor:" << mnr);
return ret;
}
-void Disk::getGeometry( const string& line, unsigned long& c, unsigned& h,
- unsigned& s )
+ bool
+ Disk::detectPartitions(SystemInfo& systeminfo)
{
- string tmp( line );
- tmp.erase( 0, tmp.find(':')+1 );
- tmp = extractNthWord( 0, tmp );
- list<string> geo = splitString( extractNthWord( 0, tmp ), "," );
- list<string>::const_iterator i = geo.begin();
- unsigned long val = 0;
- bool sect_head_changed = false;
- bool cyl_changed = false;
- if( i!=geo.end() )
- {
- *i >> val;
- if( val>0 )
- {
- c = val;
- cyl_changed = true;
- }
- }
- ++i;
- val = 0;
- if( i!=geo.end() )
- {
- *i >> val;
- if( val>0 )
- {
- h = (unsigned)val;
- sect_head_changed = true;
- }
- }
- ++i;
- val = 0;
- if( i!=geo.end() )
- {
- *i >> val;
- if( val>0 )
- {
- s = (unsigned)val;
- sect_head_changed = true;
- }
- }
- if( !cyl_changed && sect_head_changed )
- {
- c = sizeK()*2/(s*h);
- if( c<=0 )
- c=1;
- y2mil( "new c:" << c );
- }
- y2milestone( "line:%s", line.c_str() );
- y2milestone( "c:%lu h:%u s:%u", c, h, s );
- }
+ bool ret = true;
+
+ const Parted& parted = systeminfo.getParted(dev);
+
+ string dlabel = parted.getLabel();
+
+ new_geometry = geometry = parted.getGeometry();
+
+ gpt_enlarge = parted.getGptEnlarge();
+
+ y2mil("dlabel:" << dlabel << " geometry:" << geometry << " gpt_enlarge:" << gpt_enlarge);
-bool Disk::detectPartitions( ProcPart& ppart )
- {
- bool ret = true;
- string cmd_line = PARTEDCMD + quote(device()) + " unit cyl print | sort -n";
- string dlabel;
- system_stderr.erase();
- y2milestone( "executing cmd:%s", cmd_line.c_str() );
- SystemCmd Cmd( cmd_line );
- checkSystemError( cmd_line, Cmd );
- if( Cmd.select( "Partition Table:" )>0 )
- {
- string tmp = *Cmd.getLine(0, true);
- y2milestone( "Label line:%s", tmp.c_str() );
- dlabel = extractNthWord( 2, tmp );
- }
- if( Cmd.select( "BIOS cylinder" )>0 )
- {
- string tmp = *Cmd.getLine(0, true);
- getGeometry( tmp, cyl, head, sector );
- new_cyl = cyl;
- new_head = head;
- new_sector = sector;
- y2milestone( "After parted Head:%u Sector:%u Cylinder:%lu",
- head, sector, cyl );
- byte_cyl = head * sector * logical_sector_size;
- y2milestone( "byte_cyl:%lu", byte_cyl );
- }
- gpt_enlarge = Cmd.select( "fix the GPT to use all" )>0;
- y2milestone( "Label:%s gpt_enlarge:%d", dlabel.c_str(), gpt_enlarge );
if( dlabel!="loop" )
{
setLabelData( dlabel );
- checkPartedOutput( Cmd, ppart );
- if( dlabel.empty() )
- {
- Cmd.setCombine();
- Cmd.execute(FDISKBIN " -l " + quote(device()));
- if( Cmd.select( "AIX label" )>0 )
- {
- detected_label = "aix";
- }
- }
+ checkPartedOutput(systeminfo);
}
else
dlabel.erase();
if( detected_label.empty() )
detected_label = dlabel;
if( dlabel.empty() )
- dlabel = defaultLabel(getStorage()->efiBoot(), kbToSector(size_k));
+ dlabel = defaultLabel();
setLabelData( dlabel );
if (label == "unsupported")
{
- string txt = sformat(
+ Text txt = sformat(
// popup text %1$s is replaced by disk name e.g. /dev/hda
_("The partition table type on disk %1$s cannot be handled by\n"
"this tool.\n"
@@ -526,90 +311,57 @@
"You can format them and assign mount points to them, but you\n"
"cannot add, edit, resize, or remove partitions from that\n"
"disk with this tool."), dev.c_str() );
- y2war( "unsupported disk label on " << dev << " txt:" << txt );
+ y2war( "unsupported disk label on " << dev << " txt:" << txt.native );
detected_label = label;
ronly = true;
}
- y2milestone( "ret:%d partitons:%zd detected label:%s label:%s", ret,
- vols.size(), detected_label.c_str(), label.c_str() );
+ y2mil("ret:" << ret << " partitions:" << vols.size() << " detected label:" << detected_label <<
+ " label:" << label);
return( ret );
}
+
void
-Disk::logData( const string& Dir )
+Disk::logData(const string& Dir) const
{
- string fname( Dir + "/disk_" + logfile_name + ".tmp" );
- ofstream file( fname.c_str() );
- classic(file);
- file << "Device: " << dev << endl;
- if( !udev_path.empty() )
- file << "UdevPath: " << udev_path << endl;
- if( !udev_id.empty() )
- file << "UdevId: " << udev_id << endl;
- file << "Major: " << mjr << endl;
- file << "Minor: " << mnr << endl;
- file << "Range: " << range << endl;
-
- file << "Cylinder: " << cyl << endl;
- file << "Head: " << head << endl;
- file << "Sector: " << sector << endl;
- if( logical_sector_size!=512 )
- file << "LogicalSectorSize: " << logical_sector_size << endl;
-
- file << "Label: " << label << endl;
- file << "MaxPrimary: " << max_primary << endl;
- if( ext_possible )
- {
- file << "ExtPossible: " << ext_possible << endl;
- file << "MaxLogical: " << max_logical << endl;
- }
- if( ronly )
- {
- file << "Readonly: " << ronly << endl;
- }
- file << "SizeK: " << size_k << endl;
+ string fname(Dir + "/disk_" + logfile_name + ".info.tmp");
+
+ XmlFile xml;
+ xmlNode* node = xmlNewNode("disk");
+ xml.setRootElement(node);
+ saveData(node);
+ xml.save(fname);
- PartPair pp = partPair();
- for( PartIter p=pp.begin(); p!=pp.end(); ++p )
- {
- file << "Partition: ";
- p->logData(file);
- file << endl;
- }
- file.close();
getStorage()->handleLogFile( fname );
}
-void
-Disk::setLabelData( const string& disklabel )
+
+ void
+ Disk::setLabelData(const string& disklabel)
{
- y2milestone( "disklabel:%s", disklabel.c_str() );
- int i=0;
- while( !labels[i].name.empty() && labels[i].name!=disklabel )
- {
- i++;
+ y2mil("disklabel:" << disklabel);
+ DlabelCapabilities caps;
+ if (getDlabelCapabilities(disklabel, caps))
+ {
+ max_primary = min(caps.maxPrimary, (unsigned)(range - 1));
+ ext_possible = caps.extendedPossible;
+ max_logical = min(caps.maxLogical, (unsigned)(range - 1));
+ label = disklabel;
}
- if( labels[i].name.empty() )
+ else
{
- y2error ("unknown disklabel %s", disklabel.c_str());
- ext_possible = false;
- max_primary = 0;
- max_logical = 0;
- label = "unsupported";
- }
- else
- {
- ext_possible = labels[i].extended;
- max_primary = min(labels[i].primary,unsigned(range-1));
- max_logical = min(labels[i].logical,unsigned(range-1));
- label = labels[i].name;
+ max_primary = 0;
+ ext_possible = false;
+ max_logical = 0;
+ label = "unsupported";
}
- y2milestone( "name:%s ext:%d primary:%d logical:%d", label.c_str(),
- ext_possible, max_primary, max_logical );
+ y2mil("label:" << label << " max_primary:" << max_logical << " ext_possible:" <<
+ ext_possible << " max_logical:" << max_logical);
}
+
bool
Disk::getDlabelCapabilities(const string& dlabel, DlabelCapabilities& dlabelcapabilities)
{
@@ -632,31 +384,20 @@
}
-
int
-Disk::checkSystemError( const string& cmd_line, const SystemCmd& cmd )
+Disk::checkSystemError( const string& cmd_line, const SystemCmd& cmd ) const
{
- string tmp = *cmd.getString(SystemCmd::IDX_STDERR);
- if( tmp.length()>0 )
+ string tmp = boost::join(cmd.stderr(), "\n");
+ if (!tmp.empty())
{
- y2error( "cmd:%s", cmd_line.c_str() );
- y2error( "err:%s", tmp.c_str() );
- if( !system_stderr.empty() )
- {
- system_stderr += "\n";
- }
- system_stderr += tmp;
+ y2err("cmd:" << cmd_line);
+ y2err("err:" << tmp);
}
- tmp = *cmd.getString(SystemCmd::IDX_STDOUT);
- if( tmp.length()>0 )
+ tmp = boost::join(cmd.stdout(), "\n");
+ if (!tmp.empty())
{
- y2milestone( "cmd:%s", cmd_line.c_str() );
- y2milestone( "out:%s", tmp.c_str() );
- if( !system_stderr.empty() )
- {
- system_stderr += "\n";
- }
- system_stderr += tmp;
+ y2mil("cmd:" << cmd_line);
+ y2mil("out:" << tmp);
}
int ret = cmd.retcode();
if( ret!=0 && tmp.find( "kernel failed to re-read" )!=string::npos )
@@ -672,7 +413,7 @@
ret = 0;
}
else
- y2error( "retcode:%d", cmd.retcode() );
+ y2err("retcode:" << cmd.retcode());
}
return( ret );
}
@@ -699,246 +440,39 @@
}
-
bool
-Disk::scanPartedSectors( const string& Line, unsigned& nr,
- unsigned long long& start,
- unsigned long long& ssize ) const
- {
- std::istringstream Data( Line );
- classic(Data);
-
- nr=0;
- string skip;
- char c;
- Data >> nr >> start >> c >> skip >> ssize;
- y2mil( "nr:" << nr << " st:" << start << " sz:" << ssize << " c:" << c );
- return( nr>0 );
- }
-
-bool
-Disk::scanPartedLine( const string& Line, unsigned& nr, unsigned long& start,
- unsigned long& csize, PartitionType& type, unsigned& id,
- bool& boot )
+ Disk::checkPartedOutput(SystemInfo& systeminfo)
{
- unsigned long StartM, EndM;
- string PartitionType, TInfo;
+ const ProcParts& parts = systeminfo.getProcParts();
+ const Parted& parted = systeminfo.getParted(dev);
- y2deb("Line:" << Line);
- std::istringstream Data( Line );
- classic(Data);
+ unsigned long range_exceed = 0;
+ list<Partition *> pl;
- nr=0;
- StartM = EndM = 0;
- type = PRIMARY;
- string skip;
- if( label == "msdos" )
- {
- Data >> nr >> StartM >> skip >> EndM >> skip >> skip >> PartitionType;
- }
- else
- {
- Data >> nr >> StartM >> skip >> EndM >> skip >> skip;
- }
- if (Data.fail())
+ for (Parted::const_iterator it = parted.getEntries().begin();
+ it != parted.getEntries().end(); ++it)
{
- y2mil( "invalid line:" << Line );
- nr = 0;
- }
- char c;
- TInfo = ",";
- Data.unsetf(ifstream::skipws);
- Data >> c;
- char last_char = ',';
- while( Data.good() && !Data.eof() )
- {
- if( !isspace(c) )
+ if (it->num < range)
{
- TInfo += c;
- last_char = c;
- }
- else
- {
- if( last_char != ',' )
+ unsigned long long s = cylinderToKb(it->cylRegion.len());
+ Partition* p = new Partition(*this, getPartName(it->num), getPartDevice(it->num),
+ it->num, systeminfo, s, it->cylRegion, it->type,
+ it->id, it->boot);
+ if (parts.getSize(p->procName(), s))
{
- TInfo += ",";
- last_char = ',';
+ if( s>0 && p->type() != EXTENDED )
+ p->setSize( s );
}
+ pl.push_back( p );
}
- Data >> c;
- }
- TInfo += ",";
- if( nr>0 )
- {
- y2milestone( "Fields Num:%d Start:%lu End:%lu Type:%d",
- nr, StartM, EndM, type );
- y2milestone( "TInfo:%s", TInfo.c_str() );
- start = StartM;
- csize = EndM-StartM+1;
- if( start+csize > cylinders() )
- {
- csize = cylinders()-start;
- y2milestone( "new csize:%lu", csize );
- }
- id = Partition::ID_LINUX;
- boot = TInfo.find( ",boot," ) != string::npos;
- string OrigTInfo = TInfo;
- boost::to_lower(TInfo, locale::classic());
- if( ext_possible )
- {
- if( PartitionType == "extended" )
- {
- type = EXTENDED;
- id = Partition::ID_EXTENDED;
- }
- else if( nr>=5 )
- {
- type = LOGICAL;
- }
- }
- else if( TInfo.find( ",fat" )!=string::npos )
- {
- id = Partition::ID_DOS;
- }
- else if( TInfo.find( ",ntfs," )!=string::npos )
- {
- id = Partition::ID_NTFS;
- }
- else if( TInfo.find( "swap," )!=string::npos )
- {
- id = Partition::ID_SWAP;
- }
- else if( TInfo.find( ",raid," )!=string::npos )
- {
- id = Partition::ID_RAID;
- }
- else if( TInfo.find( ",lvm," )!=string::npos )
- {
- id = Partition::ID_LVM;
- }
- string::size_type pos = TInfo.find( ",type=" );
- if( pos != string::npos )
- {
- string val;
- int tmp_id = 0;
- if( label != "mac" )
- {
- val = TInfo.substr( pos+6, 2 );
- Data.clear();
- Data.str( val );
- Data >> std::hex >> tmp_id;
- y2debug( "val=%s id=%d", val.c_str(), tmp_id );
- if( tmp_id>0 )
- {
- id = tmp_id;
- }
- }
else
- {
- pos = OrigTInfo.find("type=");
- val = OrigTInfo.substr( pos+5 );
- if( (pos=val.find_first_of( ", \t\n" )) != string::npos )
- {
- val = val.substr( 0, pos );
- }
- if( id == Partition::ID_LINUX )
- {
- if( val.find( "Apple_HFS" ) != string::npos ||
- val.find( "Apple_Bootstrap" ) != string::npos )
- {
- id = Partition::ID_APPLE_HFS;
- }
- else if( val.find( "Apple_partition" ) != string::npos ||
- val.find( "Apple_Driver" ) != string::npos ||
- val.find( "Apple_Loader" ) != string::npos ||
- val.find( "Apple_Boot" ) != string::npos ||
- val.find( "Apple_ProDOS" ) != string::npos ||
- val.find( "Apple_FWDriver" ) != string::npos ||
- val.find( "Apple_Patches" ) != string::npos )
- {
- id = Partition::ID_APPLE_OTHER;
- }
- else if( val.find( "Apple_UFS" ) != string::npos )
- {
- id = Partition::ID_APPLE_UFS;
- }
- }
- }
- }
- if( label == "gpt" )
- {
- if( TInfo.find( ",boot," ) != string::npos &&
- TInfo.find( ",fat" ) != string::npos )
- {
- id = Partition::ID_GPT_BOOT;
- }
- if( TInfo.find( ",hp-service," ) != string::npos )
- {
- id = Partition::ID_GPT_SERVICE;
- }
- if( TInfo.find( ",msftres," ) != string::npos )
- {
- id = Partition::ID_GPT_MSFTRES;
- }
- if( TInfo.find( ",hfs+," ) != string::npos ||
- TInfo.find( ",hfs," ) != string::npos )
- {
- id = Partition::ID_APPLE_HFS;
- }
- }
- y2milestone( "Fields Num:%d Id:%x Ptype:%d Start:%ld Size:%ld",
- nr, id, type, start, csize );
+ range_exceed = max(range_exceed, (unsigned long) it->num);
}
- return( nr>0 );
- }
-bool
-Disk::checkPartedOutput( const SystemCmd& Cmd, ProcPart& ppart )
- {
- int cnt;
- string line;
- string tmp;
- unsigned long range_exceed = 0;
- list<Partition *> pl;
-
- cnt = Cmd.numLines();
- for( int i=0; i<cnt; i++ )
- {
- unsigned pnr;
- unsigned long c_start;
- unsigned long c_size;
- PartitionType type;
- unsigned id;
- bool boot;
-
- line = *Cmd.getLine(i);
- tmp = extractNthWord( 0, line );
- if( tmp.length()>0 && isdigit(tmp[0]) )
- {
- if( scanPartedLine( line, pnr, c_start, c_size, type, id, boot ))
- {
- if( pnr<range )
- {
- unsigned long long s = cylinderToKb(c_size);
- Partition *p = new Partition( *this, pnr, s,
- c_start, c_size, type,
- id, boot );
- if( ppart.getSize( p->device(), s ))
- {
- if( s>0 && p->type() != EXTENDED )
- p->setSize( s );
- }
- pl.push_back( p );
- }
- else
- range_exceed = max( range_exceed, (unsigned long)pnr );
- }
- }
- }
- y2mil( "nm:" << nm );
- if( !dmp_slave && !checkPartedValid( ppart, nm, pl, range_exceed ) )
+ y2mil("nm:" << nm);
+ if (!dmp_slave && !checkPartedValid(systeminfo, pl, range_exceed))
{
- string txt = sformat(
+ Text txt = sformat(
// popup text %1$s is replaced by disk name e.g. /dev/hda
_("The partitioning on disk %1$s is not readable by\n"
"the partitioning tool parted, which is used to change the\n"
@@ -954,14 +488,14 @@
}
if( range_exceed>0 )
{
- string txt = sformat(
+ Text txt = sformat(
// popup text %1$s is replaced by disk name e.g. /dev/hda
// %2$lu and %3$lu are replaced by numbers.
_("Your disk %1$s contains %2$lu partitions. The maximum number\n"
"of partitions that the kernel driver of the disk can handle is %3$lu.\n"
"Partitions numbered above %3$lu cannot be accessed."),
- (char*)dev.c_str(), range_exceed, range-1 );
- txt += "\n";
+ dev.c_str(), range_exceed, range-1 );
+ txt += Text("\n", "\n");
txt +=
// popup text
_("You have the following options:\n"
@@ -981,70 +515,72 @@
}
+ list<string>
+ Disk::partitionsKernelKnowns(const ProcParts& parts) const
+ {
+ // does not work for device-mapper based disks
+
+ string reg = "^" + dev + partNaming(dev) + "[0-9]+" "$";
+ list<string> ps = parts.getMatchingEntries(regex_matches(reg));
+ y2mil("dev:" << dev << " reg:\"" << reg << "\" ps:" << ps);
+ return ps;
+ }
+
+
bool
-Disk::checkPartedValid(const ProcPart& pp, const string& diskname,
- list<Partition*>& pl, unsigned long& range_exceed)
+Disk::checkPartitionsValid(SystemInfo& systeminfo, const list<Partition*>& pl) const
{
- unsigned ext_nr = 0;
- bool ret=true;
- unsigned long Dummy;
- unsigned long long SizeK;
- map<unsigned,unsigned long> proc_l;
- map<unsigned,unsigned long> parted_l;
- for( list<Partition*>::const_iterator i=pl.begin(); i!=pl.end(); i++ )
- {
- if( (*i)->type()==EXTENDED )
- ext_nr = (*i)->nr();
- else
- {
- parted_l[(*i)->nr()] = (*i)->cylSize();
- }
- }
- string reg = diskname;
- if( !reg.empty() && isdigit(reg[reg.length()-1]) )
- reg += "p";
- reg += "[0-9]+";
- list<string> ps = pp.getMatchingEntries( reg );
- y2mil( "regex " << reg << " ps " << ps );
- for( list<string>::const_iterator i=ps.begin(); i!=ps.end(); i++ )
- {
- pair<string,unsigned> p = getDiskPartition( *i );
- if( p.second>0 && p.second!=ext_nr &&
- pp.getInfo( *i, SizeK, Dummy, Dummy ))
- {
- proc_l[p.second] = kbToCylinder( SizeK );
- }
- }
- y2mil( "proc :" << proc_l );
- y2mil( "parted:" << parted_l );
- if( proc_l.size()>=parted_l.size() && !parted_l.empty() )
+ const Parted& parted = systeminfo.getParted(dev);
+
+ // It's allowed that the kernel sees more partitions than parted. This is
+ // the case with BSD slices.
+
+ for (list<Partition*>::const_iterator i = pl.begin(); i != pl.end(); ++i)
+ {
+ const Partition& p = **i;
+
+ if (p.type() != EXTENDED)
{
- map<unsigned,unsigned long>::const_iterator i, j;
- for( i=proc_l.begin(); i!=proc_l.end(); i++ )
+ Parted::Entry entry;
+ if (parted.getEntry(p.nr(), entry))
{
- j=parted_l.find(i->first);
- if( j!=parted_l.end() )
- {
- ret = ret && (abs((long)i->second-(long)j->second)<=2 ||
- abs((long)i->second-(long)j->second)<(long)j->second/100);
- }
- }
- for( i=parted_l.begin(); i!=parted_l.end(); i++ )
- {
- j=proc_l.find(i->first);
- if( j==proc_l.end() )
- ret = false;
- else
+ Region sec_parted = entry.secRegion;
+ Region sec_kernel = p.detectSysfsBlkRegion() / (sectorSize() / 512);
+
+ if (sec_parted != sec_kernel)
{
- ret = ret && (abs((long)i->second-(long)j->second)<=2 ||
- abs((long)i->second-(long)j->second)<(long)j->second/100);
+ y2err("region mismatch dev:" << dev << " nr:" << p.nr() << " sec_parted:" <<
+ sec_parted << " sec_kernel:" << sec_kernel);
+ return false;
}
}
}
- else
+ }
+
+ // But if parted sees no disk the kernel must also see no disks.
+
+ if (pl.empty())
+ {
+ const ProcParts& parts = systeminfo.getProcParts();
+ list<string> ps = partitionsKernelKnowns(parts);
+
+ if (!ps.empty())
{
- ret = parted_l.empty() && proc_l.empty();
+ y2err("parted sees no partitions but kernel does");
+ return false;
}
+ }
+
+ return true;
+}
+
+
+bool
+Disk::checkPartedValid(SystemInfo& systeminfo, list<Partition*>& pl,
+ unsigned long& range_exceed) const
+{
+ bool ret = checkPartitionsValid(systeminfo, pl);
+
if( !ret || label=="unsupported" )
{
range_exceed = 0;
@@ -1053,13 +589,15 @@
delete *i;
}
pl.clear();
- unsigned cyl_start = 1;
+ unsigned long cyl_start = 1;
+ const ProcParts& parts = systeminfo.getProcParts();
+ list<string> ps = partitionsKernelKnowns(parts);
for( list<string>::const_iterator i=ps.begin(); i!=ps.end(); i++ )
{
unsigned long cyl;
unsigned long long s;
pair<string,unsigned> pr = getDiskPartition( *i );
- if( pp.getSize( *i, s ))
+ if (parts.getSize(*i, s))
{
cyl = kbToCylinder(s);
if( pr.second!=0 && pr.second < range )
@@ -1068,7 +606,7 @@
PartitionType type = PRIMARY;
if( ext_possible )
{
- if( s==1 )
+ if (2 * s == procExtendedBlks())
{
type = EXTENDED;
id = Partition::ID_EXTENDED;
@@ -1078,9 +616,9 @@
type = LOGICAL;
}
}
- Partition *p =
- new Partition( *this, pr.second, s, cyl_start, cyl,
- type, id, false );
+ Partition *p = new Partition(*this, getPartName(pr.second), getPartDevice(pr.second),
+ pr.second, systeminfo, s, Region(cyl_start, cyl), type,
+ id);
pl.push_back( p );
}
else if( pr.second>0 )
@@ -1089,44 +627,59 @@
}
}
}
- y2mil("pr.size:" << proc_l.size() << " pa.size:" << parted_l.size());
+
y2mil("ret:" << ret);
return ret;
}
string
-Disk::defaultLabel(bool efiboot, unsigned long long num_sectors)
+Disk::defaultLabel() const
{
string ret = "msdos";
- if (efiboot)
- ret = "gpt";
- else if (num_sectors > (1ULL << 32) - 1)
- ret = "gpt";
- else if( Storage::arch()=="ia64" )
- ret = "gpt";
- else if( Storage::arch()=="sparc" )
- ret = "sun";
- else if( Storage::arch()=="ppc" && Storage::isPPCMac() )
- ret = "mac";
- else if( Storage::arch()=="ppc" && Storage::isPPCPegasos() )
- ret = "amiga";
- y2mil("efiboot:" << efiboot << " num_sectors:" << num_sectors << " ret:" << ret);
+
+ if (isDasd())
+ {
+ ret = "dasd";
+ }
+ else
+ {
+ const ArchInfo& archinfo = getStorage()->getArchInfo();
+ unsigned long long num_sectors = kbToSector(size_k);
+ y2mil("num_sectors:" << num_sectors);
+
+ ret = "msdos";
+ if (archinfo.is_efiboot)
+ ret = "gpt";
+ else if (num_sectors > (1ULL << 32) - 1)
+ ret = "gpt";
+ else if (archinfo.arch == "ia64")
+ ret = "gpt";
+ else if (archinfo.arch == "sparc")
+ ret = "sun";
+ else if (archinfo.arch == "ppc" && archinfo.is_ppc_mac)
+ ret = "mac";
+ else if (archinfo.arch == "ppc" && archinfo.is_ppc_pegasos)
+ ret = "amiga";
+ }
+
+ y2mil("ret:" << ret);
return ret;
}
-const Disk::label_info Disk::labels[] = {
- { "msdos", true, 4, 256, (1ULL << 32) - 1 }, // actually unlimited number of logical partitions
- { "gpt", false, 128, 0, (1ULL << 48) - 1 }, // actually 64 bit but we cannot calculate with that,
- // 48 bit looks nice since it matches LBA48
- { "bsd", false, 8, 0, (1ULL << 32) - 1 },
- { "sun", false, 8, 0, (1ULL << 32) - 1 },
- { "mac", false, 64, 0, (1ULL << 32) - 1 },
- { "dasd", false, 3, 0, (1ULL << 32) - 1 },
- { "aix", false, 0, 0, (1ULL << 32) - 1 },
- { "amiga", false, 63, 0, (1ULL << 32) - 1 },
- { "", false, 0, 0, 0 }
-};
+
+ const Disk::label_info Disk::labels[] = {
+ { "msdos", true, 4, 256, (1ULL << 32) - 1 }, // actually unlimited number of logical partitions
+ { "gpt", false, 128, 0, (1ULL << 48) - 1 }, // actually 64 bit but we cannot calculate with that,
+ // 48 bit looks nice since it matches LBA48
+ { "bsd", false, 8, 0, (1ULL << 32) - 1 },
+ { "sun", false, 8, 0, (1ULL << 32) - 1 },
+ { "mac", false, 64, 0, (1ULL << 32) - 1 },
+ { "dasd", false, 3, 0, (1ULL << 32) - 1 },
+ { "aix", false, 0, 0, (1ULL << 32) - 1 },
+ { "amiga", false, 63, 0, (1ULL << 32) - 1 },
+ { "", false, 0, 0, 0 }
+ };
Region Disk::usableCylRegion() const
@@ -1139,32 +692,20 @@
}
-const string Disk::p_disks [] = { "cciss/", "ida/", "ataraid/", "etherd/", "rd/" };
+ const string Disk::p_disks[] = { "cciss/", "ida/", "ataraid/", "etherd/", "rd/", "mmcblk[0-9]+",
+ "md[0-9]+" };
+
-bool Disk::needP( const string& disk )
+ bool
+ Disk::needP(const string& disk)
{
- bool need_p = false;
- unsigned i=0;
- static Regex mdpart( "md[0123456789]+$" );
- if ( mdpart.match( disk ) == true )
- {
- return true;
- }
- static Regex mmcblkpart( "mmcblk[0123456789]+$" );
- if ( mmcblkpart.match( disk ) == true )
- {
- return true;
- }
- while( !need_p && i<lengthof(p_disks) )
+ for (unsigned i = 0; i < lengthof(p_disks); ++i)
{
- string::size_type p = disk.find(p_disks[i]);
- if( p==0 || (p==5 && disk.find( "/dev/" )==0 ))
- {
- need_p = true;
- }
- i++;
+ Regex rx("^(/dev/)?" + p_disks[i]);
+ if (rx.match(disk))
+ return true;
}
- return( need_p );
+ return false;
}
@@ -1181,21 +722,20 @@
}
-string Disk::getPartName( const string& disk, unsigned nr )
+ string
+ Disk::getPartName(unsigned nr) const
{
- return( disk + (Disk::needP(disk)?"p":"") + decString(nr) );
+ return nm + partNaming(dev) + decString(nr);
}
-string Disk::getPartName( const string& disk, const string& nr )
- {
- return( disk + "/" + nr );
- }
-string Disk::getPartName( unsigned nr ) const
+ string
+ Disk::getPartDevice(unsigned nr) const
{
- return( getPartName( dev, nr ) );
+ return dev + partNaming(dev) + decString(nr);
}
+
pair<string,unsigned> Disk::getDiskPartition( const string& dev )
{
static Regex prx( "[0123456789]p[0123456789]+$" );
@@ -1217,7 +757,7 @@
disk = dev.substr( 0, pos );
}
y2mil( "dev:" << dev << " disk:" << disk << " nr:" << nr );
- return( make_pair(disk,nr) );
+ return make_pair(disk, nr);
}
@@ -1256,9 +796,9 @@
unsigned
Disk::availablePartNumber(PartitionType type) const
{
- y2mil("begin name:" << name() << " type:" << type);
+ y2mil("begin name:" << name() << " type:" << toString(type));
unsigned ret = 0;
- ConstPartPair p = partPair( notDeleted );
+ ConstPartPair p = partPair(Partition::notDeleted);
if( !ext_possible && type==LOGICAL )
{
ret = 0;
@@ -1348,7 +888,7 @@
list<Region> tmp;
for (ConstPartIter i = p.begin(); i != p.end(); ++i)
- tmp.push_back(Region(i->cylStart(), i->cylEnd() - i->cylStart() + 1));
+ tmp.push_back(i->cylRegion());
tmp.sort();
for (list<Region>::const_iterator i = tmp.begin(); i != tmp.end(); ++i)
@@ -1373,7 +913,7 @@
list<Region> tmp;
for (ConstPartIter i = p.begin(); i != p.end(); ++i)
- tmp.push_back(Region(i->cylStart(), i->cylEnd() - i->cylStart() + 1));
+ tmp.push_back(i->cylRegion());
tmp.sort();
for (list<Region>::const_iterator i = tmp.begin(); i != tmp.end(); ++i)
@@ -1417,22 +957,22 @@
int Disk::createPartition( unsigned long cylLen, string& device,
bool checkRelaxed )
{
- y2milestone( "len %ld relaxed:%d", cylLen, checkRelaxed );
+ y2mil("len:" << cylLen << " relaxed:" << checkRelaxed);
getStorage()->logCo( this );
int ret = 0;
list<Region> free;
getUnusedSpace( free );
- y2milestone( "free:" );
+ y2mil("free:");
if( !free.empty() )
{
free.sort( regions_sort_size );
- list<Region>::iterator i = free.begin();
+ list<Region>::const_iterator i = free.begin();
while( i!=free.end() && i->len()>=cylLen )
++i;
--i;
if( i->len()>=cylLen )
{
- PartPair ext = partPair(notDeletedExt);
+ ConstPartPair ext = partPair(notDeletedExt);
PartitionType t = PRIMARY;
bool usable = false;
do
@@ -1464,15 +1004,15 @@
int Disk::createPartition( PartitionType type, string& device )
{
- y2milestone( "type %u", type );
+ y2mil("type " << toString(type));
int ret = 0;
list<Region> free;
getUnusedSpace( free, type==PTYPE_ANY, type==LOGICAL );
if( !free.empty() )
{
free.sort( regions_sort_size );
- list<Region>::iterator i = free.begin();
- PartPair ext = partPair(notDeletedExt);
+ list<Region>::const_iterator i = free.begin();
+ ConstPartPair ext = partPair(notDeletedExt);
PartitionType t = type;
bool usable = false;
do
@@ -1505,18 +1045,14 @@
{
int ret = 0;
device = "";
- nr = 0;
- unsigned number = availablePartNumber( type );
- if( number==0 )
+ nr = availablePartNumber( type );
+ if (nr == 0)
{
ret = DISK_PARTITION_NO_FREE_NUMBER;
}
else
{
- Partition * p = new Partition( *this, number, 0, 0, 1, type );
- device = p->device();
- nr = p->nr();
- delete( p );
+ device = getPartDevice(nr);
}
y2mil("ret:" << ret << " nr:" << nr << " device:" << device);
return ret;
@@ -1527,10 +1063,10 @@
unsigned long len, string& device,
bool checkRelaxed )
{
- y2milestone( "begin type %d at %ld len %ld relaxed:%d", type, start, len,
- checkRelaxed );
+ y2mil("begin type " << toString(type) << " at " << start << " len " << len << " relaxed:" <<
+ checkRelaxed);
getStorage()->logCo( this );
- int ret = createChecks( type, start, len, checkRelaxed );
+ int ret = createChecks(type, Region(start, len), checkRelaxed);
unsigned number = 0;
if( ret==0 )
{
@@ -1544,10 +1080,10 @@
{
if( label=="sun" && start==0 )
start=1;
- Partition * p = new Partition( *this, number, cylinderToKb(len), start,
- len, type );
- PartPair pp = partPair();
- PartIter i=pp.begin();
+ Partition * p = new Partition(*this, getPartName(number), getPartDevice(number), number,
+ cylinderToKb(len), Region(start, len), type);
+ ConstPartPair pp = partPair();
+ ConstPartIter i = pp.begin();
while( i!=pp.end() && !(i->deleted() && i->cylStart()==start) )
++i;
if( i!=pp.end() )
@@ -1574,22 +1110,22 @@
addToList( p );
}
getStorage()->logCo( this );
- y2milestone( "ret:%d device:%s", ret, ret==0?device.c_str():"" );
+ y2mil("ret:" << ret << " device:" << (ret==0?device:""));
return( ret );
}
-int Disk::createChecks( PartitionType& type, unsigned long start,
- unsigned long len, bool checkRelaxed )
+
+ int
+ Disk::createChecks(PartitionType& type, const Region& cylRegion, bool checkRelaxed) const
{
- y2milestone( "begin type %d at %ld len %ld relaxed:%d", type, start, len,
- checkRelaxed );
+ y2mil("type:" << toString(type) << " cylRegion:" << cylRegion << " relaxed:" <<
+ checkRelaxed);
unsigned fuzz = checkRelaxed ? fuzz_cyl : 0;
int ret = 0;
- Region r( start, len );
- PartPair ext = partPair(notDeletedExt);
+ ConstPartPair ext = partPair(notDeletedExt);
if( type==PTYPE_ANY )
{
- if( ext.empty() || !ext.begin()->contains( Region(start,1) ))
+ if( ext.empty() || !ext.begin()->contains( Region(cylRegion.start(), 1) ))
type = PRIMARY;
else
type = LOGICAL;
@@ -1599,12 +1135,12 @@
{
ret = DISK_CHANGE_READONLY;
}
- if( ret==0 && (r.end() > cylinders()+fuzz) )
+ if( ret==0 && (cylRegion.end() > cylinders()+fuzz) )
{
- y2milestone( "too large for disk cylinders %lu", cylinders() );
+ y2mil("too large for disk cylinders " << cylinders());
ret = DISK_PARTITION_EXCEEDS_DISK;
}
- if( ret==0 && len==0 )
+ if( ret==0 && cylRegion.empty() )
{
ret = DISK_PARTITION_ZERO_SIZE;
}
@@ -1614,24 +1150,23 @@
}
if( ret==0 )
{
- PartPair p = (type!=LOGICAL) ? partPair( notDeleted )
- : partPair( notDeletedLog );
- PartIter i = p.begin();
- while( i!=p.end() && !i->intersectArea( r, fuzz ))
+ ConstPartPair p = (type != LOGICAL) ? partPair(Partition::notDeleted) : partPair(notDeletedLog);
+ ConstPartIter i = p.begin();
+ while( i!=p.end() && !i->intersectArea( cylRegion, fuzz ))
{
++i;
}
if( i!=p.end() )
{
- y2war( "overlaps r:" << r << " p:" << i->region() <<
- " inter:" << i->region().intersect(r) );
+ y2war("overlaps r:" << cylRegion << " p:" << i->cylRegion() <<
+ " inter:" << i->cylRegion().intersect(cylRegion) );
ret = DISK_PARTITION_OVERLAPS_EXISTING;
}
}
- if( ret==0 && type==LOGICAL && !ext.begin()->contains( r, fuzz ))
+ if( ret==0 && type==LOGICAL && !ext.begin()->contains( cylRegion, fuzz ))
{
- y2war( "outside ext r:" << r << " ext:" << ext.begin()->region() <<
- "inter:" << ext.begin()->region().intersect(r) );
+ y2war("outside ext r:" << cylRegion << " ext:" << ext.begin()->cylRegion() <<
+ "inter:" << ext.begin()->cylRegion().intersect(cylRegion) );
ret = DISK_PARTITION_LOGICAL_OUTSIDE_EXT;
}
if( ret==0 && type==EXTENDED )
@@ -1643,22 +1178,21 @@
}
}
y2mil("ret:" << ret);
- return( ret );
+ return ret;
}
-int Disk::changePartitionArea( unsigned nr, unsigned long start,
- unsigned long len, bool checkRelaxed )
+
+ int
+ Disk::changePartitionArea(unsigned nr, const Region& cylRegion, bool checkRelaxed)
{
- y2milestone( "begin nr %u at %ld len %ld relaxed:%d", nr, start, len,
- checkRelaxed );
+ y2mil("begin nr:" << nr << " cylRegion:" << cylRegion << " relaxed:" << checkRelaxed);
int ret = 0;
- Region r( start, len );
unsigned fuzz = checkRelaxed ? fuzz_cyl : 0;
if( readonly() )
{
ret = DISK_CHANGE_READONLY;
}
- PartPair p = partPair( notDeleted );
+ PartPair p = partPair(Partition::notDeleted);
PartIter part = p.begin();
while( ret==0 && part!=p.end() && part->nr()!=nr)
{
@@ -1668,55 +1202,55 @@
{
ret = DISK_PARTITION_NOT_FOUND;
}
- if( ret==0 && r.end() > cylinders()+fuzz )
+ if( ret==0 && cylRegion.end() > cylinders()+fuzz )
{
- y2milestone( "too large for disk cylinders %lu", cylinders() );
+ y2mil("too large for disk cylinders " << cylinders());
ret = DISK_PARTITION_EXCEEDS_DISK;
}
- if( ret==0 && len==0 )
+ if( ret==0 && cylRegion.empty() )
{
ret = DISK_PARTITION_ZERO_SIZE;
}
if( ret==0 && part->type()==LOGICAL )
{
- PartPair ext = partPair(notDeletedExt);
+ ConstPartPair ext = partPair(notDeletedExt);
p = partPair( notDeletedLog );
- PartIter i = p.begin();
- while( i!=p.end() && (i==part||!i->intersectArea( r, fuzz )) )
+ ConstPartIter i = p.begin();
+ while( i!=p.end() && (i==part||!i->intersectArea( cylRegion, fuzz )) )
{
++i;
}
if( i!=p.end() )
{
- y2war( "overlaps r:" << r << " p:" << i->region() <<
- " inter:" << i->region().intersect(r) );
+ y2war("overlaps r:" << cylRegion << " p:" << i->cylRegion() <<
+ " inter:" << i->cylRegion().intersect(cylRegion) );
ret = DISK_PARTITION_OVERLAPS_EXISTING;
}
- if( ret==0 && !ext.begin()->contains( r, fuzz ))
+ if( ret==0 && !ext.begin()->contains( cylRegion, fuzz ))
{
- y2war( "outside ext r:" << r << " ext:" << ext.begin()->region() <<
- "inter:" << ext.begin()->region().intersect(r) );
+ y2war("outside ext r:" << cylRegion << " ext:" << ext.begin()->cylRegion() <<
+ "inter:" << ext.begin()->cylRegion().intersect(cylRegion) );
ret = DISK_PARTITION_LOGICAL_OUTSIDE_EXT;
}
}
if( ret==0 && part->type()!=LOGICAL )
{
- PartIter i = p.begin();
+ ConstPartIter i = p.begin();
while( i!=p.end() &&
- (i==part || i->nr()>max_primary || !i->intersectArea( r, fuzz )))
+ (i==part || i->nr()>max_primary || !i->intersectArea( cylRegion, fuzz )))
{
++i;
}
if( i!=p.end() )
{
- y2war( "overlaps r:" << r << " p:" << i->region() <<
- " inter:" << i->region().intersect(r) );
+ y2war("overlaps r:" << cylRegion << " p:" << i->cylRegion() <<
+ " inter:" << i->cylRegion().intersect(cylRegion) );
ret = DISK_PARTITION_OVERLAPS_EXISTING;
}
}
if( ret==0 )
{
- part->changeRegion( start, len, cylinderToKb(len) );
+ part->changeRegion(cylRegion, cylinderToKb(cylRegion.len()));
}
y2mil("ret:" << ret);
return( ret );
@@ -1729,10 +1263,10 @@
int Disk::removePartition( unsigned nr )
{
- y2milestone( "begin nr %u", nr );
+ y2mil("begin nr " << nr);
getStorage()->logCo( this );
int ret = 0;
- PartPair p = partPair( notDeleted );
+ PartPair p = partPair(Partition::notDeleted);
PartIter i = p.begin();
while( i!=p.end() && i->nr()!=nr)
{
@@ -1746,7 +1280,7 @@
{
ret = DISK_CHANGE_READONLY;
}
- else if( i->getUsedByType() != UB_NONE )
+ else if (i->isUsedBy())
{
ret = DISK_REMOVE_USED_BY;
}
@@ -1757,7 +1291,7 @@
{
if( !removeFromList( &(*i) ))
ret = DISK_REMOVE_PARTITION_CREATE_NOT_FOUND;
- p = partPair( notDeleted );
+ p = partPair(Partition::notDeleted);
}
else
i->setDeleted();
@@ -1823,7 +1357,7 @@
void Disk::changeNumbers( const PartIter& b, const PartIter& e,
unsigned start, int incr )
{
- y2milestone( "start:%u incr:%d", start, incr );
+ y2mil("start:" << start << " incr:" << incr);
PartIter i(b);
while( i!=e )
{
@@ -1837,7 +1371,7 @@
int Disk::destroyPartitionTable( const string& new_label )
{
- y2milestone( "begin" );
+ y2mil("begin");
int ret = 0;
setLabelData( new_label );
if( max_primary==0 )
@@ -1861,7 +1395,7 @@
}
bool save = getStorage()->getRecursiveRemoval();
getStorage()->setRecursiveRemoval(true);
- if( getUsedByType() != UB_NONE )
+ if (isUsedBy())
{
getStorage()->removeUsing( device(), getUsedBy() );
}
@@ -1874,7 +1408,7 @@
++i;
}
getStorage()->setRecursiveRemoval(save);
- setDeleted( true );
+ del_ptable = true;
}
y2mil("ret:" << ret);
return( ret );
@@ -1886,7 +1420,7 @@
{
y2mil("begin nr:" << nr << " id:" << hex << id);
int ret = 0;
- PartPair p = partPair( notDeleted );
+ PartPair p = partPair(Partition::notDeleted);
PartIter i = p.begin();
while( i!=p.end() && i->nr()!=nr)
{
@@ -1913,9 +1447,9 @@
int Disk::forgetChangePartitionId( unsigned nr )
{
- y2milestone( "begin nr:%u", nr );
+ y2mil("begin nr:" << nr);
int ret = 0;
- PartPair p = partPair( notDeleted );
+ PartPair p = partPair(Partition::notDeleted);
PartIter i = p.begin();
while( i!=p.end() && i->nr()!=nr)
{
@@ -1937,28 +1471,29 @@
return( ret );
}
-int Disk::getToCommit( CommitStage stage, list<Container*>& col,
- list<Volume*>& vol )
+
+void
+Disk::getToCommit(CommitStage stage, list<const Container*>& col, list<const Volume*>& vol) const
{
- int ret = 0;
unsigned long oco = col.size();
unsigned long ovo = vol.size();
Container::getToCommit( stage, col, vol );
if( stage==INCREASE )
{
- PartPair p = partPair( Partition::toChangeId );
- for( PartIter i=p.begin(); i!=p.end(); ++i )
+ ConstPartPair p = partPair( Partition::toChangeId );
+ for( ConstPartIter i=p.begin(); i!=p.end(); ++i )
if( find( vol.begin(), vol.end(), &(*i) )==vol.end() )
vol.push_back( &(*i) );
}
+ if( del_ptable && find( col.begin(), col.end(), this )==col.end() )
+ col.push_back( this );
if( col.size()!=oco || vol.size()!=ovo )
- y2milestone( "ret:%d col:%zd vol:%zd", ret, col.size(), vol.size());
- return( ret );
+ y2mil("stage:" << stage << " col:" << col.size() << " vol:" << vol.size());
}
int Disk::commitChanges( CommitStage stage, Volume* vol )
{
- y2milestone( "name %s stage %d", name().c_str(), stage );
+ y2mil("name:" << name() << " stage:" << stage);
int ret = Container::commitChanges( stage, vol );
if( ret==0 && stage==INCREASE )
{
@@ -1977,9 +1512,9 @@
int Disk::commitChanges( CommitStage stage )
{
- y2milestone( "name %s stage %d", name().c_str(), stage );
+ y2mil("name:" << name() << " stage:" << stage);
int ret = 0;
- if( stage==DECREASE && deleted() )
+ if( stage==DECREASE && del_ptable )
{
ret = doCreateLabel();
}
@@ -1989,51 +1524,44 @@
return( ret );
}
-void Disk::getCommitActions( list<commitAction*>& l ) const
+
+void
+Disk::getCommitActions(list<commitAction>& l) const
{
Container::getCommitActions( l );
- if( deleted() )
+ if( del_ptable )
{
- list<commitAction*>::iterator i = l.begin();
- while( i!=l.end() )
- {
- if( (*i)->stage==DECREASE )
- {
- delete( *i );
- i=l.erase( i );
- }
- else
- ++i;
- }
- l.push_front( new commitAction( DECREASE, staticType(),
- setDiskLabelText(false), this, true ));
+ l.remove_if(stage_is(DECREASE));
+ l.push_front(commitAction(DECREASE, staticType(), setDiskLabelText(false), this, true));
}
}
-string Disk::setDiskLabelText( bool doing ) const
+
+ Text
+ Disk::setDiskLabelText(bool doing) const
{
- string txt;
- string d = dev;
+ Text txt;
if( doing )
{
// displayed text during action, %1$s is replaced by disk name (e.g. /dev/hda),
// %2$s is replaced by label name (e.g. msdos)
- txt = sformat( _("Setting disk label of disk %1$s to %2$s"),
- d.c_str(), label.c_str() );
+ txt = sformat(_("Setting disk label of %1$s to %2$s"), dev.c_str(),
+ boost::to_upper_copy(label).c_str());
}
else
{
// displayed text before action, %1$s is replaced by disk name (e.g. /dev/hda),
// %2$s is replaced by label name (e.g. msdos)
- txt = sformat( _("Set disk label of disk %1$s to %2$s"),
- d.c_str(), label.c_str() );
+ txt = sformat(_("Set disk label of %1$s to %2$s"), dev.c_str(),
+ boost::to_upper_copy(label).c_str());
}
- return( txt );
+ return txt;
}
+
int Disk::doCreateLabel()
{
- y2milestone( "label:%s", label.c_str() );
+ y2mil("label:" << label);
int ret = 0;
if( !silent )
{
@@ -2042,9 +1570,11 @@
if( !dmp_slave )
getStorage()->removeDmMapsTo( device() );
removePresentPartitions();
- system_stderr.erase();
std::ostringstream cmd_line;
classic(cmd_line);
+ cmd_line << MDADMBIN " --zero-superblock --force " << quote(device());
+ execCheckFailed( cmd_line.str() );
+ cmd_line.str("");
cmd_line << PARTEDCMD << quote(device()) << " mklabel " << label;
if( execCheckFailed( cmd_line.str() ) )
{
@@ -2052,13 +1582,13 @@
}
else
{
- setDeleted(false);
+ del_ptable = false;
removeFromMemory();
}
if( ret==0 )
{
if( !dmp_slave )
- getStorage()->waitForDevice();
+ Storage::waitForDevice();
redetectGeometry();
}
gpt_enlarge = false;
@@ -2096,6 +1626,7 @@
y2mil( "rem:" << *i );
if( !(*i)->created() )
{
+ delete *i;
i = vols.erase( i );
}
else
@@ -2103,33 +1634,23 @@
}
}
-void Disk::redetectGeometry()
+
+ void
+ Disk::redetectGeometry()
{
- string cmd_line = PARTEDCMD + quote(device()) + " unit cyl print";
- y2milestone( "executing cmd:%s", cmd_line.c_str() );
- SystemCmd Cmd( cmd_line );
- if( Cmd.select( "BIOS cylinder" )>0 )
- {
- unsigned long c;
- unsigned h;
- unsigned s;
- string tmp = *Cmd.getLine(0, true);
- getGeometry( tmp, c, h, s );
- if( c!=0 && c!=cyl )
- {
- new_cyl = c;
- new_head = h;
- new_sector = s;
- y2milestone( "new parted geometry Head:%u Sector:%u Cylinder:%lu",
- new_head, new_sector, new_cyl );
- }
+ Parted parted(device());
+ Geometry tmp_geometry = parted.getGeometry();
+ if (tmp_geometry != geometry)
+ {
+ new_geometry = tmp_geometry;
+ y2mil("new parted geometry " << new_geometry);
}
}
+
int Disk::doSetType( Volume* v )
{
- y2milestone( "doSetType container %s name %s", name().c_str(),
- v->name().c_str() );
+ y2mil("doSetType container " << name() << " name " << v->name());
Partition * p = dynamic_cast<Partition *>(v);
int ret = 0;
if( p != NULL )
@@ -2140,66 +1661,39 @@
}
if( p->id()!=Partition::ID_LINUX && p->id()!=Partition::ID_SWAP )
p->eraseLabel();
- system_stderr.erase();
- std::ostringstream cmd_line;
- classic(cmd_line);
- cmd_line << PARTEDCMD << quote(device()) << " set " << p->nr() << " ";
- string start_cmd = cmd_line.str();
- if( ret==0 )
- {
- cmd_line.str( start_cmd );
- cmd_line.seekp(0, ios_base::end );
- cmd_line << "lvm " << (p->id()==Partition::ID_LVM ? "on" : "off");
- if( execCheckFailed( cmd_line.str() ) && !dmp_slave )
- {
- ret = DISK_SET_TYPE_PARTED_FAILED;
- }
- }
- if( ret==0 && (label!="sun"))
- {
- cmd_line.str( start_cmd );
- cmd_line.seekp(0, ios_base::end );
- cmd_line << "raid " << (p->id()==Partition::ID_RAID?"on":"off");
- if( execCheckFailed( cmd_line.str() ) && !dmp_slave )
- {
- ret = DISK_SET_TYPE_PARTED_FAILED;
- }
- }
- if( ret==0 && (label=="dvh"||label=="mac"))
- {
- cmd_line.str( start_cmd );
- cmd_line.seekp(0, ios_base::end );
- cmd_line << "swap " << (p->id()==Partition::ID_SWAP?"on":"off");
- if( execCheckFailed( cmd_line.str() ) && !dmp_slave )
- {
- ret = DISK_SET_TYPE_PARTED_FAILED;
- }
- }
+
+ std::ostringstream options;
+ classic(options);
+
if( ret==0 )
+ {
+ options << " set " << p->nr() << " lvm " << (p->id()==Partition::ID_LVM ? "on" : "off");
+
+ if (label != "sun")
+ options << " set " << p->nr() << " raid " << (p->id()==Partition::ID_RAID?"on":"off");
+
+ if (label == "dvh" || label == "mac")
+ options << " set " << p->nr() << " swap " << (p->id()==Partition::ID_SWAP?"on":"off");
+
+ options << " set " << p->nr() << " boot " << ((p->boot()||p->id()==Partition::ID_GPT_BOOT)?"on":"off");
+
+ if (p->id() <= 255 && label == "msdos")
+ options << " set " << p->nr() << " type " << p->id();
+ }
+
+ if (!options.str().empty())
+ {
+ string cmd_line = PARTEDCMD + quote(device()) + options.str();
+ if( execCheckFailed( cmd_line ) && !dmp_slave )
{
- cmd_line.str( start_cmd );
- cmd_line.seekp(0, ios_base::end );
- cmd_line << "boot " <<
- ((p->boot()||p->id()==Partition::ID_GPT_BOOT)?"on":"off");
- if( execCheckFailed( cmd_line.str() ) && !dmp_slave )
- {
- ret = DISK_SET_TYPE_PARTED_FAILED;
- }
- }
- if( ret==0 && p->id()<=255 && label=="msdos" )
- {
- cmd_line.str( start_cmd );
- cmd_line.seekp(0, ios_base::end );
- cmd_line << "type " << p->id();
- if( execCheckFailed( cmd_line.str() ) && !dmp_slave )
- {
ret = DISK_SET_TYPE_PARTED_FAILED;
- }
}
+ }
+
if( ret==0 )
{
if( !dmp_slave )
- getStorage()->waitForDevice( p->device() );
+ Storage::waitForDevice(p->device());
p->changeIdDone();
}
}
@@ -2211,135 +1705,116 @@
return( ret );
}
-int
-Disk::callDelpart( unsigned nr ) const
+
+ bool
+ Disk::callDelpart(unsigned nr) const
{
- SystemCmd c( DELPARTBIN " " + quote(device()) + ' ' + decString(nr) );
- return( c.retcode() );
+ SystemCmd c(DELPARTBIN " " + quote(device()) + ' ' + decString(nr));
+ return c.retcode() == 0;
}
-int
-Disk::callAddpart( unsigned nr, unsigned long long sstart,
- unsigned long long ssize ) const
+
+ bool
+ Disk::callAddpart(unsigned nr, const Region& blkRegion) const
{
- SystemCmd c( ADDPARTBIN " " + quote(device()) + ' ' + decString(nr) + ' ' +
- decString(sstart) + ' ' + decString(ssize) );
- return( c.retcode() );
+ SystemCmd c(ADDPARTBIN " " + quote(device()) + ' ' + decString(nr) + ' ' +
+ decString(blkRegion.start()) + ' ' + decString(blkRegion.len()));
+ return c.retcode() == 0;
}
+
+unsigned long long
+Disk::procExtendedBlks() const
+{
+ return std::max(2U, sectorSize() / 512);
+}
+
+
bool
-Disk::getPartedValues( Partition *p )
+Disk::getPartedValues( Partition *p ) const
{
y2mil( "nr:" << p->nr() );
bool ret = false;
- if( getStorage()->testmode() )
+ if (getStorage()->testmode())
{
ret = true;
p->setSize( p->sizeK() );
}
else
{
- std::ostringstream cmd_line;
- classic(cmd_line);
- cmd_line << PARTEDCMD << quote(device()) << " unit cyl print unit s print";
- std::string cmd_str = cmd_line.str();
- cmd_line << " | grep -w \"^[ \t]*\"" << p->nr();
- SystemCmd cmd( cmd_line.str() );
- unsigned nr, id;
- unsigned long start, csize;
- unsigned long long sstart, ssize;
- PartitionType type;
- bool boot;
- if( cmd.numLines()>1 &&
- scanPartedSectors( *cmd.getLine(1), nr, sstart, ssize ))
- {
- string start_p = p->sysfsPath() + "/start";
- string size_p = p->sysfsPath() + "/size";
- y2mil("start_p:" << start_p << " size_p:" << size_p);
- unsigned long long sysfs_start = 0;
- unsigned long long sysfs_size = 0;
- read_sysfs_property(start_p, sysfs_start, false);
- read_sysfs_property(size_p, sysfs_size, false);
- if( p->type()==EXTENDED )
- ssize=2;
- y2mil( "sectors nr:" << nr << " sysfs start:" << sysfs_start <<
- " size:" << sysfs_size );
- y2mil( "sectors nr:" << nr << " parted start:" << sstart <<
- " size:" << ssize );
- if( nr == p->nr() && !no_addpart &&
- (sysfs_start!=sstart || sysfs_size!=ssize) )
- {
- callDelpart( nr );
- callAddpart( nr, sstart, ssize );
- read_sysfs_property(start_p, sysfs_start);
- read_sysfs_property(size_p, sysfs_size);
- if( sysfs_start!=sstart || sysfs_size!=ssize )
- y2err( "addpart failed sectors parted:" << sstart << ' ' <<
- ssize << " sysfs:" << sysfs_start << ' ' <<
- sysfs_size );
- }
- }
- if( cmd.numLines()>0 &&
- scanPartedLine( *cmd.getLine(0), nr, start, csize, type,
- id, boot ))
- {
- ProcPart ppart;
- y2milestone( "really created at cyl:%ld csize:%ld", start, csize );
- p->changeRegion( start, csize, cylinderToKb(csize) );
- unsigned long long s=0;
+ Parted parted(device());
+ Parted::Entry entry;
+ if (parted.getEntry(p->nr(), entry))
+ {
+ Region partedBlkRegion = sectorSize() / 512 * entry.secRegion;
+ y2mil("partedBlkRegion:" << partedBlkRegion);
+
+ if (p->type() == EXTENDED)
+ partedBlkRegion.setLen(procExtendedBlks());
+
+ Region sysfsBlkRegion = p->detectSysfsBlkRegion(false);
+ y2mil("sysfsBlkRegion:" << sysfsBlkRegion);
+
+ if (!no_addpart && partedBlkRegion != sysfsBlkRegion)
+ {
+ callDelpart(p->nr());
+ callAddpart(p->nr(), partedBlkRegion);
+
+ sysfsBlkRegion = p->detectSysfsBlkRegion();
+
+ if (partedBlkRegion != sysfsBlkRegion)
+ y2err("addpart failed sysfsBlkRegion:" << sysfsBlkRegion);
+ }
+
+ const Region& partedCylRegion = entry.cylRegion;
+ y2mil("partedCylRegion:" << partedCylRegion);
+ p->changeRegion(partedCylRegion, cylinderToKb(partedCylRegion.len()));
+
ret = true;
+
if( !dmp_slave && p->type() != EXTENDED )
{
- if( !ppart.getSize( p->device(), s ) || s==0 )
+ ProcParts parts;
+ unsigned long long s = 0;
+ if (!parts.getSize(p->procName(), s) || s == 0)
{
- y2error( "device %s not found in /proc/partitions",
- p->device().c_str() );
+ y2err("device " << p->device() << " not found in /proc/partitions");
ret = false;
}
else
p->setSize( s );
}
}
- cmd.execute( cmd_str );
}
return( ret );
}
bool
Disk::getPartedSectors( const Partition *p, unsigned long long& start,
- unsigned long long& end )
+ unsigned long long& end ) const
{
bool ret = false;
- if( getStorage()->testmode() )
+ if (getStorage()->testmode())
{
ret = true;
- start = p->cylStart()*new_head*new_sector;
- end = (p->cylEnd()+1)*new_head*new_sector-1;
+ start = p->cylStart() * new_geometry.heads * new_geometry.sectors;
+ end = (p->cylEnd() + 1) * new_geometry.heads * new_geometry.sectors - 1;
}
else
{
- std::ostringstream cmd_line;
- classic(cmd_line);
- cmd_line << PARTEDCMD << quote(device()) << " unit s print | grep -w \"^[ \t]*\"" << p->nr();
- SystemCmd cmd( cmd_line.str() );
- if( cmd.numLines()>0 )
- {
- string dummy, s1, s2;
- std::istringstream data( *cmd.getLine(0) );
- classic(data);
- data >> dummy >> s1 >> s2;
- y2milestone( "dummy:\"%s\" s1:\"%s\" s2:\"%s\"", dummy.c_str(),
- s1.c_str(), s2.c_str() );
- start = end = 0;
- s1 >> start;
- s2 >> end;
- y2milestone( "start:%llu end:%llu", start, end );
- ret = end>0;
- }
+ Parted parted(device());
+ Parted::Entry entry;
+ if (parted.getEntry(p->nr(), entry))
+ {
+ start = entry.secRegion.start();
+ end = entry.secRegion.end();
+ ret = true;
+ }
}
return( ret );
}
+
void Disk::enlargeGpt()
{
y2mil( "gpt_enlarge:" << gpt_enlarge );
@@ -2369,13 +1844,9 @@
{
getStorage()->showInfoCb( p->createText(true) );
}
- system_stderr.erase();
- y2milestone( "doCreate container %s name %s", name().c_str(),
- p->name().c_str() );
- y2milestone( "doCreate nr:%d start %ld len %ld", p->nr(),
- p->cylStart(), p->cylSize() );
- y2milestone( "doCreate detected_label:%s label:%s",
- detected_label.c_str(), label.c_str() );
+ y2mil("doCreate container " << name() << " name " << p->name());
+ y2mil("doCreate nr:" << p->nr() << " start " << p->cylStart() << " len " << p->cylSize());
+ y2mil("doCreate detected_label:" << detected_label << " label:" << label);
if( detected_label != label )
{
ret = doCreateLabel();
@@ -2391,10 +1862,7 @@
if( ret==0 )
{
cmd_line << PARTEDCMD;
- if( getStorage()->getPartitionAlignment()==ALIGN_CYLINDER )
- cmd_line << "--align=cylinder ";
- else
- cmd_line << "--align=optimal ";
+ cmd_line << "--align=" << toString(getStorage()->getPartitionAlignment()) << " ";
cmd_line << quote(device()) << " unit cyl mkpart ";
if( label != "sun" )
{
@@ -2423,7 +1891,7 @@
}
else if( p->id()==Partition::ID_GPT_BOOT ||
p->id()==Partition::ID_DOS16 ||
- p->id()==Partition::ID_DOS )
+ p->id()==Partition::ID_DOS32 )
{
cmd_line << "fat32 ";
}
@@ -2441,18 +1909,18 @@
{
unsigned long start = p->cylStart();
unsigned long end = p->cylStart()+p->cylSize();
- PartPair pp = (p->type()!=LOGICAL) ? partPair( existingNotLog )
- : partPair( existingLog );
+ ConstPartPair pp = (p->type()!=LOGICAL) ? partPair( existingNotLog )
+ : partPair( existingLog );
unsigned long maxc = cylinders();
if( p->type()==LOGICAL )
{
- PartPair ext = partPair(notDeletedExt);
+ ConstPartPair ext = partPair(notDeletedExt);
if( !ext.empty() )
maxc = ext.begin()->cylEnd();
}
- y2milestone( "max %lu end:%lu", maxc, end );
- y2mil( "pp " << *p );
- for( PartIter i=pp.begin(); i!=pp.end(); ++i )
+ y2mil("max " << maxc << " end:" << end);
+ y2mil("pp " << *p);
+ for (ConstPartIter i = pp.begin(); i != pp.end(); ++i)
{
y2mil( "i " << *i );
if( i->cylStart()<maxc && i->cylStart()<end &&
@@ -2462,21 +1930,19 @@
y2mil( "new maxc " << maxc );
}
}
- y2milestone( "max %lu", maxc );
- if( new_cyl!=cyl )
+ y2mil("max " << maxc);
+ if( new_geometry != geometry )
{
- y2milestone( "parted geometry changed old c:%lu h:%u s:%u",
- cyl, head, sector );
- y2milestone( "parted geometry changed new c:%lu h:%u s:%u",
- new_cyl, new_head, new_sector );
- y2milestone( "old start:%lu end:%lu", start, end );
- start = start * new_cyl / cyl;
- end = end * new_cyl / cyl;
- y2milestone( "new start:%lu end:%lu", start, end );
+ y2mil("parted geometry changed old geometry:" << geometry);
+ y2mil("parted geometry changed new geometry:" << new_geometry);
+ y2mil("old start:" << start << " end:" << end);
+ start = start * new_geometry.cylinders / geometry.cylinders;
+ end = end * new_geometry.cylinders / geometry.cylinders;
+ y2mil("new start:" << start << " end:" << end);
}
if( end>maxc && maxc<=cylinders() )
{
- y2milestone( "corrected end from %lu to max %lu", end, maxc );
+ y2mil("corrected end from " << end << " to max " << maxc);
end = maxc;
}
if( start==0 && (label == "mac" || label == "amiga") )
@@ -2515,7 +1981,7 @@
// kludge to make the extended partition visible in
// /proc/partitions otherwise grub refuses to install if root
// filesystem is a logical partition
- PartPair lc = partPair(logicalCreated);
+ ConstPartPair lc = partPair(logicalCreated);
call_blockdev = lc.length()<=1;
y2mil("logicalCreated:" << lc.length() << " call_blockdev:" << call_blockdev);
}
@@ -2543,9 +2009,9 @@
}
if( !dmp_slave && call_blockdev )
{
- SystemCmd c("/sbin/blockdev --rereadpt " + quote(device()));
+ SystemCmd c(BLOCKDEVBIN " --rereadpt " + quote(device()));
if( p->type()!=EXTENDED )
- getStorage()->waitForDevice( p->device() );
+ Storage::waitForDevice(p->device());
}
}
else
@@ -2566,12 +2032,10 @@
{
getStorage()->showInfoCb( p->removeText(true) );
}
- system_stderr.erase();
- y2milestone( "doRemove container %s name %s", name().c_str(),
- p->name().c_str() );
+ y2mil("doRemove container " << name() << " name " << p->name());
if( !dmp_slave )
{
- getStorage()->removeDmMapsTo( getPartName(p->OrigNr()) );
+ getStorage()->removeDmMapsTo( getPartDevice(p->OrigNr()) );
ret = v->prepareRemove();
}
if( ret==0 && !p->created() )
@@ -2584,8 +2048,8 @@
{
ret = DISK_REMOVE_PARTITION_PARTED_FAILED;
}
- ProcPart parts;
- if( parts.findDevice(getPartName(device(), p->OrigNr())) )
+ ProcParts parts;
+ if( parts.findDevice(getPartName(p->OrigNr())) )
callDelpart( p->OrigNr() );
getStorage()->handleHald(false);
}
@@ -2596,12 +2060,12 @@
}
if( ret==0 )
{
- PartPair p = partPair( notCreatedPrimary );
+ ConstPartPair p = partPair( notCreatedPrimary );
if( p.empty() )
redetectGeometry();
}
if( ret==0 && !dmp_slave )
- getStorage()->waitForDevice();
+ Storage::waitForDevice();
}
else
{
@@ -2622,11 +2086,13 @@
const unsigned long endBefore = p->cylStart() - 1;
const unsigned long startAfter = p->cylEnd() + 1;
unsigned long endAfter = cylinders();
+ Region usable_region = usableCylRegion();
if (p->type() == LOGICAL && hasExtended())
{
ConstPartPair pp = partPair(notDeletedExt);
startBefore = pp.begin()->cylStart() - 1;
endAfter = pp.begin()->cylEnd() + 1;
+ usable_region = pp.begin()->cylRegion();
}
y2mil("startBefore:" << startBefore << " endBefore:" << endBefore);
@@ -2687,12 +2153,12 @@
if (endAfter > startAfter)
freeCylsAfter = endAfter - startAfter;
- Region around(p->cylStart() - freeCylsBefore, p->cylEnd() + freeCylsAfter - 1);
- Region usable_region = usableCylRegion();
-
+ y2mil( "bef:" << freeCylsBefore << " aft:" << freeCylsAfter );
+ Region around(p->cylStart() - freeCylsBefore, p->cylSize() + freeCylsAfter + freeCylsBefore );
+ y2mil( "around:" << around );
if (usable_region.doIntersect(around))
{
- around = around.intersect(usableCylRegion());
+ around = around.intersect(usable_region);
freeCylsBefore = freeCylsAfter = 0;
if (around.start() < p->cylStart())
@@ -2709,6 +2175,7 @@
return ret;
}
+
int
Disk::resizePartition(Partition* p, unsigned long newCyl)
{
@@ -2726,7 +2193,7 @@
if( ret==0 && newCyl<p->cylSize() )
{
if( p->created() )
- p->changeRegion( p->cylStart(), newCyl, newSize );
+ p->changeRegion(Region(p->cylStart(), newCyl), newSize);
else
p->setResizedSize( newSize );
}
@@ -2746,7 +2213,7 @@
else
{
if( p->created() )
- p->changeRegion( p->cylStart(), newCyl, newSize );
+ p->changeRegion(Region(p->cylStart(), newCyl), newSize);
else
p->setResizedSize( newSize );
}
@@ -2791,7 +2258,7 @@
bool Disk::isLogical( unsigned nr ) const
{
bool ret = ext_possible && nr>max_primary;
- y2milestone( "nr:%u ret:%d", nr, ret );
+ y2mil("nr:" << nr << " ret:" << ret);
return( ret );
}
@@ -2819,17 +2286,15 @@
ret = p->resizeFs();
if( ret==0 )
{
- system_stderr.erase();
- y2milestone( "doResize container %s name %s", name().c_str(),
- p->name().c_str() );
+ y2mil("doResize container " << name() << " name " << p->name());
std::ostringstream cmd_line;
classic(cmd_line);
unsigned long long start_sect, end_sect;
getPartedSectors( p, start_sect, end_sect );
- end_sect = start_sect + p->sizeK()*2 - 1;
- y2milestone( "end_sect %llu", end_sect );
+ end_sect = start_sect + kbToSector(p->sizeK()) - 1;
+ y2mil("end_sect " << end_sect);
const Partition * after = getPartitionAfter( p );
- unsigned long max_end = sizeK()*2-1;
+ unsigned long max_end = kbToSector(sizeK()) - 1;
if( after!=NULL )
{
unsigned long long start_after, end_after;
@@ -2840,7 +2305,7 @@
}
else if( p->type()==LOGICAL )
{
- PartPair ext = partPair(notDeletedExt);
+ ConstPartPair ext = partPair(notDeletedExt);
if( !ext.empty() )
{
unsigned long long start_ext, end_ext;
@@ -2850,7 +2315,7 @@
}
y2mil( "max_end:" << max_end << " end_sect:" << end_sect );
if( max_end<end_sect ||
- max_end-end_sect < byte_cyl/logical_sector_size*2 )
+ max_end-end_sect < geometry.cylinderSize() / sectorSize() * 2 )
{
end_sect = max_end;
y2mil( "new end_sect:" << end_sect );
@@ -2870,9 +2335,8 @@
}
getStorage()->handleHald(false);
if( ret==0 && !dmp_slave )
- getStorage()->waitForDevice( p->device() );
- y2milestone( "after resize size:%llu resize:%d", p->sizeK(),
- p->needShrink()||p->needExtend() );
+ Storage::waitForDevice(p->device());
+ y2mil("after resize size:" << p->sizeK() << " resize:" << (p->needShrink()||p->needExtend()));
}
if( needExtend && !dmp_slave &&
p->getFs()!=HFS && p->getFs()!=HFSPLUS && p->getFs()!=VFAT &&
@@ -2889,12 +2353,12 @@
return( ret );
}
-const Partition * Disk::getPartitionAfter( const Partition * p )
+const Partition* Disk::getPartitionAfter(const Partition* p) const
{
- const Partition * ret = NULL;
+ const Partition* ret = NULL;
y2mil( "p:" << *p );
- PartPair pp = partPair( (p->type()==LOGICAL)?notDeleted:notDeletedLog );
- for( PartIter pi=pp.begin(); pi!=pp.end(); ++pi )
+ ConstPartPair pp = partPair((p->type() == LOGICAL) ? Partition::notDeleted : notDeletedLog);
+ for (ConstPartIter pi = pp.begin(); pi != pp.end(); ++pi)
{
if( !pi->created() &&
pi->cylStart()>p->cylStart() &&
@@ -2902,21 +2366,21 @@
ret = &(*pi);
}
if( ret==NULL )
- y2milestone( "ret:NULL" );
+ y2mil( "ret:NULL" );
else
y2mil( "ret:" << *ret );
- return( ret );
+ return ret;
}
void Disk::addPartition( unsigned num, unsigned long long sz,
- ProcPart& ppart )
+ SystemInfo& systeminfo )
{
- y2mil( "dev:" << device() << " num:" << num << " sizek" << sz );
- unsigned long cyl_inc = std::max( sz*2 / head / sector, 1ULL );
- Partition *p = new Partition( *this, num, sz, cyl, cyl_inc, PRIMARY );
- cyl += cyl_inc;
- new_cyl = cyl;
- if( ppart.getSize( p->device(), sz ) && sz>0 )
+ unsigned long cyl_inc = std::max(kbToSector(size_k) / geometry.heads / geometry.sectors, 1ULL);
+ Partition *p = new Partition(*this, getPartName(num), getPartDevice(num), num, systeminfo, sz,
+ Region(geometry.cylinders, cyl_inc), PRIMARY);
+ geometry.cylinders += cyl_inc;
+ new_geometry.cylinders = geometry.cylinders;
+ if( systeminfo.getProcParts().getSize(p->procName(), sz) && sz>0 )
{
p->setSize( sz );
}
@@ -2925,7 +2389,7 @@
unsigned Disk::numPartitions() const
{
- return(partPair( notDeleted ).length());
+ return partPair(Partition::notDeleted).length();
}
void Disk::getInfo( DiskInfo& tinfo ) const
@@ -2934,34 +2398,28 @@
info.cyl = cylinders();
info.heads = heads();
info.sectors = sectors();
- info.sectorSize = logical_sector_size;
- info.cylSizeB = cylSizeB();
+ info.sectorSize = sectorSize();
+ info.cylSize = geometry.cylinderSize();
info.disklabel = labelName();
- info.maxLogical = maxLogical();
info.maxPrimary = maxPrimary();
+ info.extendedPossible = extendedPossible();
+ info.maxLogical = maxLogical();
info.initDisk = init_disk;
- info.iscsi = iscsi;
- info.udevPath = udev_path;
- info.udevId = mergeString( udev_id );
+ info.iscsi = transport == ISCSI;
+ info.transport = transport;
tinfo = info;
}
-namespace storage
-{
std::ostream& operator<< (std::ostream& s, const Disk& d )
{
- s << *((Container*)&d);
- s << " Cyl:" << d.cyl
- << " Head:" << d.head
- << " Sect:" << d.sector
- << " Node <" << d.mjr << ":" << d.mnr << ">"
+ s << dynamic_cast<const Container&>(d);
+ s << " geometry:" << d.geometry
<< " Range:" << d.range
- << " SizeM:" << d.size_k/1024
+ << " SizeK:" << d.size_k
<< " Label:" << d.label;
if( d.detected_label!=d.label )
s << " DetectedLabel:" << d.detected_label;
- s << " SysfsDir:" << d.sysfs_dir;
if( !d.udev_path.empty() )
s << " UdevPath:" << d.udev_path;
if( !d.udev_id.empty() )
@@ -2971,105 +2429,55 @@
s << " ExtPossible MaxLogical:" << d.max_logical;
if( d.init_disk )
s << " InitDisk";
- if( d.iscsi )
- s << " iSCSI";
+ s << " transport:" << toString(d.transport);
if( d.dmp_slave )
s << " DmpSlave";
if( d.no_addpart )
s << " NoAddpart";
if( d.gpt_enlarge )
s << " GptEnlarge";
+ if (d.del_ptable)
+ s << " delPT";
return( s );
}
-}
-void Disk::logDifference( const Container& d ) const
+ void
+ Disk::logDifference(std::ostream& log, const Disk& rhs) const
{
- string log = getDiffString( d );
- const Disk * p = dynamic_cast<const Disk*>(&d);
- if( p != NULL )
- {
- if( cyl!=p->cyl )
- log += " Cyl:" + decString(cyl) + "-->" + decString(p->cyl);
- if( head!=p->head )
- log += " Head:" + decString(head) + "-->" + decString(p->head);
- if( sector!=p->sector )
- log += " Sect:" + decString(sector) + "-->" + decString(p->sector);
- if( mjr!=p->mjr )
- log += " Mjr:" + decString(mjr) + "-->" + decString(p->mjr);
- if( mnr!=p->mnr )
- log += " Mnr:" + decString(mnr) + "-->" + decString(p->mnr);
- if( range!=p->range )
- log += " Range:" + decString(range) + "-->" + decString(p->range);
- if( size_k!=p->size_k )
- log += " SizeK:" + decString(size_k) + "-->" + decString(p->size_k);
- if( label!=p->label )
- log += " Label:" + label + "-->" + p->label;
- if( sysfs_dir!=p->sysfs_dir )
- log += " SysfsDir:" + sysfs_dir + "-->" + p->sysfs_dir;
- if( max_primary!=p->max_primary )
- log += " MaxPrimary:" + decString(max_primary) + "-->" + decString(p->max_primary);
- if( ext_possible!=p->ext_possible )
- {
- if( p->ext_possible )
- log += " -->ExtPossible";
- else
- log += " ExtPossible-->";
- }
- if( max_logical!=p->max_logical )
- log += " MaxLogical:" + decString(max_logical) + "-->" + decString(p->max_logical);
- if( init_disk!=p->init_disk )
- {
- if( p->init_disk )
- log += " -->InitDisk";
- else
- log += " InitDisk-->";
- }
- if( iscsi!=p->iscsi )
- {
- if( p->iscsi )
- log += " -->iSCSI";
- else
- log += " iSCSI-->";
- }
- y2mil(log);
- ConstPartPair pp=partPair();
- ConstPartIter i=pp.begin();
- while( i!=pp.end() )
- {
- ConstPartPair pc=p->partPair();
- ConstPartIter j = pc.begin();
- while( j!=pc.end() &&
- (i->device()!=j->device() || i->created()!=j->created()) )
- ++j;
- if( j!=pc.end() )
- {
- if( !i->equalContent( *j ) )
- i->logDifference( *j );
- }
- else
- y2mil( " -->" << *i );
- ++i;
- }
- pp=p->partPair();
- i=pp.begin();
- while( i!=pp.end() )
- {
- ConstPartPair pc=partPair();
- ConstPartIter j = pc.begin();
- while( j!=pc.end() &&
- (i->device()!=j->device() || i->created()!=j->created()) )
- ++j;
- if( j==pc.end() )
- y2mil( " <--" << *i );
- ++i;
- }
- }
- else
- y2mil(log);
+ Container::logDifference(log, rhs);
+
+ logDiff(log, "geometry", geometry, rhs.geometry);
+ logDiff(log, "size_k", size_k, rhs.size_k);
+
+ logDiff(log, "label", label, rhs.label);
+ logDiff(log, "range", range, rhs.range);
+ logDiff(log, "max_primary", max_primary, rhs.max_primary);
+ logDiff(log, "ext_possible", ext_possible, rhs.ext_possible);
+ logDiff(log, "max_logical", max_logical, rhs.max_logical);
+
+ logDiff(log, "init_disk", init_disk, rhs.init_disk);
+
+ logDiffEnum(log, "transport", transport, rhs.transport);
+
+ logDiff(log, "del_ptable", del_ptable, rhs.del_ptable);
}
+
+ void
+ Disk::logDifferenceWithVolumes(std::ostream& log, const Container& rhs_c) const
+ {
+ const Disk& rhs = dynamic_cast<const Disk&>(rhs_c);
+
+ logDifference(log, rhs);
+ log << endl;
+
+ ConstPartPair pp = partPair();
+ ConstPartPair pc = rhs.partPair();
+ logVolumesDifference(log, pp.begin(), pp.end(), pc.begin(), pc.end());
+ }
+
+
bool Disk::equalContent( const Container& rhs ) const
{
const Disk * p = NULL;
@@ -3077,68 +2485,21 @@
if( ret )
p = dynamic_cast<const Disk*>(&rhs);
if( ret && p )
- ret = cyl==p->cyl && head==p->head && sector==p->sector &&
+ ret = geometry == p->geometry &&
mjr==p->mjr && mnr==p->mnr && range==p->range &&
size_k==p->size_k && max_primary==p->max_primary &&
ext_possible==p->ext_possible && max_logical==p->max_logical &&
init_disk==p->init_disk && label==p->label &&
- iscsi==p->iscsi && sysfs_dir==p->sysfs_dir &&
- no_addpart==p->no_addpart &&
- dmp_slave==p->dmp_slave && gpt_enlarge==p->gpt_enlarge;
+ transport == p->transport &&
+ dmp_slave==p->dmp_slave && no_addpart==p->no_addpart &&
+ gpt_enlarge==p->gpt_enlarge && del_ptable == p->del_ptable;
if( ret && p )
{
ConstPartPair pp = partPair();
ConstPartPair pc = p->partPair();
- ConstPartIter i = pp.begin();
- ConstPartIter j = pc.begin();
- while( ret && i!=pp.end() && j!=pc.end() )
- {
- ret = ret && i->equalContent( *j );
- ++i;
- ++j;
- }
- ret = ret && i==pp.end() && j==pc.end();
+ ret = ret && storage::equalContent(pp.begin(), pp.end(), pc.begin(), pc.end());
}
return( ret );
}
-Disk& Disk::operator= ( const Disk& rhs )
- {
- y2deb("operator= from " << rhs.nm);
- cyl = rhs.cyl;
- head = rhs.head;
- sector = rhs.sector;
- new_cyl = rhs.new_cyl;
- new_head = rhs.new_head;
- new_sector = rhs.new_sector;
- label = rhs.label;
- detected_label = rhs.detected_label;
- range = rhs.range;
- byte_cyl = rhs.byte_cyl;
- max_primary = rhs.max_primary;
- ext_possible = rhs.ext_possible;
- max_logical = rhs.max_logical;
- init_disk = rhs.init_disk;
- iscsi = rhs.iscsi;
- udev_path = rhs.udev_path;
- udev_id = rhs.udev_id;
- logfile_name = rhs.logfile_name;
- sysfs_dir = rhs.sysfs_dir;
- dmp_slave = rhs.dmp_slave;
- no_addpart = rhs.no_addpart;
- gpt_enlarge = rhs.gpt_enlarge;
- return( *this );
- }
-
-Disk::Disk( const Disk& rhs ) : Container(rhs)
- {
- y2deb("constructed disk by copy constructor from " << rhs.nm);
- *this = rhs;
- ConstPartPair p = rhs.partPair();
- for( ConstPartIter i = p.begin(); i!=p.end(); ++i )
- {
- Partition * p = new Partition( *this, *i );
- vols.push_back( p );
- }
- }
-
+}
Modified: branches/SuSE-Code-11-SP2-Branch/storage/libstorage/src/Disk.h
URL: http://svn.opensuse.org/viewcvs/yast/branches/SuSE-Code-11-SP2-Branch/stora…
==============================================================================
--- branches/SuSE-Code-11-SP2-Branch/storage/libstorage/src/Disk.h (original)
+++ branches/SuSE-Code-11-SP2-Branch/storage/libstorage/src/Disk.h Tue May 17 13:39:44 2011
@@ -1,5 +1,5 @@
/*
- * Copyright (c) [2004-2009] Novell, Inc.
+ * Copyright (c) [2004-2010] Novell, Inc.
*
* All Rights Reserved.
*
@@ -25,17 +25,24 @@
#include <list>
-#include "y2storage/Container.h"
-#include "y2storage/Partition.h"
+#include "storage/Container.h"
+#include "storage/Partition.h"
+#include "storage/Geometry.h"
+
namespace storage
{
+ using std::list;
+
class Storage;
class SystemCmd;
-class ProcPart;
+ class SystemInfo;
+ class ArchInfo;
+class ProcParts;
class Region;
+
class Disk : public Container
{
friend class Storage;
@@ -52,35 +59,45 @@
};
public:
- Disk( Storage * const s, const string& Name, unsigned long long Size );
- Disk( Storage * const s, const string& Name, unsigned num,
- unsigned long long Size, ProcPart& ppart );
- Disk( const Disk& rhs );
+
+ Disk(Storage* s, const string& name, const string& device, unsigned long long Size,
+ SystemInfo& systeminfo);
+ Disk(Storage* s, const string& name, const string& device, unsigned num,
+ unsigned long long Size, SystemInfo& systeminfo);
+ Disk(Storage* s, const xmlNode* node);
+ Disk(const Disk& c);
virtual ~Disk();
- unsigned long cylinders() const { return cyl; }
- unsigned heads() const { return head; }
- unsigned sectors() const { return sector; }
+ void saveData(xmlNode* node) const;
+
+ unsigned long cylinders() const { return geometry.cylinders; }
+ unsigned heads() const { return geometry.heads; }
+ unsigned sectors() const { return geometry.sectors; }
+ unsigned sectorSize() const { return geometry.sector_size; }
+ const Geometry& getGeometry() const { return geometry; }
Region usableCylRegion() const;
unsigned long numMinor() const { return range; }
- unsigned long cylSizeB() const { return byte_cyl; }
unsigned maxPrimary() const { return max_primary; }
bool extendedPossible() const { return ext_possible; }
unsigned maxLogical() const { return max_logical; }
const string& labelName() const { return label; }
- const string& udevPath() const { return udev_path; }
- const std::list<string>& udevId() const { return udev_id; }
+ virtual string udevPath() const { return udev_path; }
+ virtual list<string> udevId() const { return udev_id; }
void setSlave( bool val=true ) { dmp_slave=val; }
void setAddpart( bool val=true ) { no_addpart=!val; }
void setNumMinor( unsigned long val ) { range=val; }
- const string& sysfsDir() const { return sysfs_dir; }
+
+ virtual string procName() const { return nm; }
+ virtual string sysfsPath() const;
+
unsigned numPartitions() const;
bool isDasd() const { return( nm.find("dasd")==0 ); }
- bool isIScsi() const { return iscsi; }
+ bool isIScsi() const { return transport == ISCSI; }
+ static bool isIScsi(const Disk& d) { return d.isIScsi(); }
bool isLogical( unsigned nr ) const;
- bool detect( ProcPart& ppart );
+ bool detect(SystemInfo& systeminfo);
static storage::CType staticType() { return storage::DISK; }
friend std::ostream& operator<< (std::ostream&, const Disk& );
void triggerUdevUpdate() const;
@@ -100,16 +117,14 @@
bool initializeDisk() const { return init_disk; }
void resetInitDisk() { init_disk=false; }
int forgetChangePartitionId( unsigned nr );
- int changePartitionArea( unsigned nr, unsigned long start,
- unsigned long size, bool checkRelaxed=false );
+ int changePartitionArea(unsigned nr, const Region& cylRegion, bool checkRelaxed = false);
int nextFreePartition(storage::PartitionType type, unsigned& nr,
string& device) const;
int destroyPartitionTable( const string& new_label );
unsigned availablePartNumber(storage::PartitionType type = storage::PRIMARY) const;
- virtual void getCommitActions( std::list<storage::commitAction*>& l ) const;
- virtual int getToCommit( storage::CommitStage stage,
- std::list<Container*>& col,
- std::list<Volume*>& vol );
+ virtual void getCommitActions(list<commitAction>& l) const;
+ virtual void getToCommit(storage::CommitStage stage, list<const Container*>& col,
+ list<const Volume*>& vol) const;
virtual int commitChanges( storage::CommitStage stage );
int commitChanges( storage::CommitStage stage, Volume* vol );
int freeCylindersAroundPartition(const Partition* p, unsigned long& freeCylsBefore,
@@ -122,34 +137,39 @@
unsigned int numPrimary() const;
bool hasExtended() const;
unsigned int numLogical() const;
- string setDiskLabelText( bool doing=true ) const;
+ Text setDiskLabelText(bool doing) const;
- unsigned long long cylinderToKb( unsigned long ) const;
- unsigned long kbToCylinder( unsigned long long ) const;
+ unsigned long long cylinderToKb(unsigned long cylinder) const
+ { return geometry.cylinderToKb(cylinder); }
+ unsigned long kbToCylinder(unsigned long long kb) const
+ { return geometry.kbToCylinder(kb); }
+
+ unsigned long long sectorToKb(unsigned long long sector) const
+ { return geometry.sectorToKb(sector); }
+ unsigned long long kbToSector(unsigned long long kb) const
+ { return geometry.kbToSector(kb); }
- unsigned long long sectorToKb(unsigned long long sector) const;
- unsigned long long kbToSector(unsigned long long kb) const;
+ string getPartName(unsigned nr) const;
+ string getPartDevice(unsigned nr) const;
- string getPartName( unsigned nr ) const;
void getInfo( storage::DiskInfo& info ) const;
bool equalContent( const Container& rhs ) const;
- void logDifference( const Container& d ) const;
- Disk& operator= ( const Disk& rhs );
+
+ void logDifference(std::ostream& log, const Disk& rhs) const;
+ virtual void logDifferenceWithVolumes(std::ostream& log, const Container& rhs) const;
+
bool FakeDisk() const { return(range==1); }
- static string getPartName( const string& disk, unsigned nr );
- static string getPartName( const string& disk, const string& nr );
static std::pair<string,unsigned> getDiskPartition( const string& dev );
+
static bool getDlabelCapabilities(const string& dlabel,
storage::DlabelCapabilities& dlabelcapabilities);
struct SysfsInfo
{
- unsigned long mjr;
- unsigned long mnr;
- string device;
unsigned long range;
unsigned long long size;
+ bool vbd;
};
static bool getSysfsInfo(const string& sysfsdir, SysfsInfo& sysfsinfo);
@@ -206,47 +226,41 @@
}
protected:
- Disk( Storage * const s, const string& File );
+
virtual bool detectGeometry();
- virtual bool detectPartitions( ProcPart& ppart );
- bool getSysfsInfo( const string& SysFsDir );
- int checkSystemError( const string& cmd_line, const SystemCmd& cmd );
+ virtual bool detectPartitions(SystemInfo& systeminfo);
+ bool getSysfsInfo();
+ int checkSystemError( const string& cmd_line, const SystemCmd& cmd ) const;
int execCheckFailed( const string& cmd_line, bool stop_hald=true );
int execCheckFailed( SystemCmd& cmd, const string& cmd_line,
- bool stop_hald=true );
- bool checkPartedOutput( const SystemCmd& cmd, ProcPart& ppart );
- bool scanPartedLine( const string& Line, unsigned& nr,
- unsigned long& start, unsigned long& csize,
- storage::PartitionType& type,
- unsigned& id, bool& boot );
- bool scanPartedSectors( const string& Line, unsigned& nr,
- unsigned long long& start,
- unsigned long long& ssize ) const;
- bool checkPartedValid( const ProcPart& pp, const string& diskname,
- std::list<Partition*>& pl, unsigned long& rng );
- int callDelpart( unsigned nr ) const;
- int callAddpart( unsigned nr, unsigned long long sstart,
- unsigned long long ssize ) const;
- bool getPartedValues( Partition *p );
+ bool stop_hald=true );
+ bool checkPartedOutput(SystemInfo& systeminfo);
+ list<string> partitionsKernelKnowns(const ProcParts& parts) const;
+ bool checkPartedValid(SystemInfo& systeminfo, list<Partition*>& pl,
+ unsigned long& rng) const;
+ virtual bool checkPartitionsValid(SystemInfo& systeminfo, const list<Partition*>& pl) const;
+
+ bool callDelpart(unsigned nr) const;
+ bool callAddpart(unsigned nr, const Region& blkRegion) const;
+
+ bool getPartedValues( Partition *p ) const;
bool getPartedSectors( const Partition *p, unsigned long long& start,
- unsigned long long& end );
- const Partition * getPartitionAfter( const Partition * p );
+ unsigned long long& end ) const;
+ const Partition * getPartitionAfter( const Partition * p ) const;
void addPartition( unsigned num, unsigned long long sz,
- ProcPart& ppart );
+ SystemInfo& ppart );
virtual void print( std::ostream& s ) const { s << *this; }
virtual Container* getCopy() const { return( new Disk( *this ) ); }
- void getGeometry( const string& line, unsigned long& c,
- unsigned& h, unsigned& s );
virtual void redetectGeometry();
void changeNumbers( const PartIter& b, const PartIter& e,
unsigned start, int incr );
- int createChecks( storage::PartitionType& type, unsigned long start,
- unsigned long len, bool checkRelaxed );
+ int createChecks(PartitionType& type, const Region& cylRegion, bool checkRelaxed) const;
void removePresentPartitions();
void removeFromMemory();
void enlargeGpt();
- static bool notDeleted( const Partition&d ) { return( !d.deleted() ); }
+ /* size of extended partition in proc and sysfs in 512 byte blocks */
+ unsigned long long procExtendedBlks() const;
virtual int doCreate( Volume* v );
virtual int doRemove( Volume* v );
@@ -254,40 +268,40 @@
virtual int doSetType( Volume* v );
virtual int doCreateLabel();
- void logData( const string& Dir );
+ virtual void logData(const string& Dir) const;
+
void setLabelData( const string& );
- static string defaultLabel(bool efiboot, unsigned long long num_sectors);
+ string defaultLabel() const;
static const label_info labels[];
static const string p_disks[];
- unsigned int logical_sector_size;
+ Geometry geometry;
+ Geometry new_geometry;
- unsigned long cyl;
- unsigned head;
- unsigned sector;
- unsigned long new_cyl;
- unsigned new_head;
- unsigned new_sector;
string label;
string udev_path;
- std::list<string> udev_id;
+ list<string> udev_id;
string detected_label;
- string system_stderr;
string logfile_name;
- string sysfs_dir;
unsigned max_primary;
bool ext_possible;
unsigned max_logical;
bool init_disk;
- bool iscsi;
+ Transport transport;
bool dmp_slave;
bool no_addpart;
bool gpt_enlarge;
- unsigned long byte_cyl;
unsigned long range;
- mutable storage::DiskInfo info;
+ bool del_ptable;
+
+ mutable storage::DiskInfo info; // workaround for broken ycp bindings
+
+ private:
+
+ Disk& operator=(const Disk&); // disallow
+
};
}
Modified: branches/SuSE-Code-11-SP2-Branch/storage/libstorage/src/Dm.cc
URL: http://svn.opensuse.org/viewcvs/yast/branches/SuSE-Code-11-SP2-Branch/stora…
==============================================================================
--- branches/SuSE-Code-11-SP2-Branch/storage/libstorage/src/Dm.cc (original)
+++ branches/SuSE-Code-11-SP2-Branch/storage/libstorage/src/Dm.cc Tue May 17 13:39:44 2011
@@ -1,5 +1,5 @@
/*
- * Copyright (c) [2004-2009] Novell, Inc.
+ * Copyright (c) [2004-2010] Novell, Inc.
*
* All Rights Reserved.
*
@@ -19,72 +19,117 @@
* find current contact information at www.novell.com.
*/
-/*
- Textdomain "storage"
-*/
#include <sstream>
-#include "y2storage/Dm.h"
-#include "y2storage/PeContainer.h"
-#include "y2storage/SystemCmd.h"
-#include "y2storage/AppUtil.h"
-#include "y2storage/Regex.h"
-#include "y2storage/Storage.h"
-#include "y2storage/StorageDefines.h"
-
-using namespace storage;
-using namespace std;
-
-Dm::Dm( const PeContainer& d, const string& tn ) :
- Volume( d ), tname(tn)
- {
- num_le = 0;
- stripe = 1;
- stripe_size = 0;
- inactiv = true;
- y2deb("constructed dm dev");
- }
-
-Dm::Dm( const PeContainer& d, const string& tn, unsigned mnum ) :
- Volume( d ), tname(tn)
- {
- y2milestone( "constructed dm dev table \"%s\" %u", tn.c_str(), mnum );
- num_le = 0;
- stripe = 1;
- stripe_size = 0;
- inactiv = true;
- nm = tn;
- init();
+#include "storage/Dm.h"
+#include "storage/PeContainer.h"
+#include "storage/SystemCmd.h"
+#include "storage/AppUtil.h"
+#include "storage/Regex.h"
+#include "storage/Storage.h"
+#include "storage/StorageDefines.h"
+
+
+namespace storage
+{
+ using namespace std;
+
+
+ // this ctr is used for volumes of LvmVg and DmPart
+ Dm::Dm(const PeContainer& c, const string& name, const string& device, const string& tname)
+ : Volume(c, name, device), tname(tname), num_le(0), stripe(1), stripe_size(0),
+ inactiv(true)
+ {
+ y2mil("constructed Dm tname:" << tname);
+ }
+
+
+ // this ctr is used for volumes of DmCo
+ Dm::Dm(const PeContainer& c, const string& name, const string& device, const string& tname,
+ SystemInfo& systeminfo)
+ : Volume(c, name, device, systeminfo), tname(tname), num_le(0), stripe(1), stripe_size(0),
+ inactiv(true)
+ {
+ y2mil("constructed Dm dev:" << dev << " tname:" << tname);
+
+ string dmn = "/dev/mapper/" + tname;
+ if (dmn != dev)
+ alt_names.push_back(dmn);
+
+ updateMajorMinor();
+
getTableInfo();
+
+ getStorage()->fetchDanglingUsedBy(dev, uby);
+ for (list<string>::const_iterator it = alt_names.begin(); it != alt_names.end(); ++it)
+ getStorage()->fetchDanglingUsedBy(*it, uby);
}
-Dm::~Dm()
-{
- y2deb("destructed dm dev " << dev);
-}
+ Dm::Dm(const PeContainer& c, const xmlNode* node)
+ : Volume(c, node), tname(), num_le(0), stripe(1), stripe_size(0), inactiv(true)
+ {
+ getChildValue(node, "table_name", tname);
+
+ getChildValue(node, "stripes", stripe);
+ getChildValue(node, "stripe_size_k", stripe_size);
+
+ y2deb("constructed Dm " << dev);
+
+ assert(!tname.empty());
+ assert(stripe == 1 || stripe_size > 0);
+ }
+
+
+ Dm::Dm(const PeContainer& c, const Dm& v)
+ : Volume(c, v), tname(v.tname), num_le(v.num_le), stripe(v.stripe),
+ stripe_size(v.stripe_size), inactiv(v.inactiv), pe_map(v.pe_map)
+ {
+ y2deb("copy-constructed Dm " << dev);
+ }
+
+
+ Dm::~Dm()
+ {
+ y2deb("destructed Dm dev " << dev);
+ }
+
+
+ void
+ Dm::saveData(xmlNode* node) const
+ {
+ Volume::saveData(node);
+
+ setChildValue(node, "table_name", tname);
+
+ setChildValue(node, "stripes", stripe);
+ if (stripe > 1)
+ setChildValue(node, "stripe_size_k", stripe_size);
+ }
unsigned Dm::dmMajor()
{
if( dm_major==0 )
- getDmMajor();
+ {
+ dm_major = getMajorDevices("device-mapper");
+ y2mil("dm_major:" << dm_major);
+ }
return( dm_major );
}
+
void
Dm::getTableInfo()
{
- if( dm_major==0 )
- getDmMajor();
SystemCmd c(DMSETUPBIN " table " + quote(tname));
inactiv = c.retcode()!=0;
- y2milestone( "table %s retcode:%d numLines:%u inactive:%d",
- tname.c_str(), c.retcode(), c.numLines(), inactiv );
+ y2mil("table:" << tname << " retcode:" << c.retcode() << " numLines:" << c.numLines() <<
+ " inactive:" << inactiv);
if( c.numLines()>0 )
{
- string line = *c.getLine(0);
+ string line = c.getLine(0);
target = extractNthWord( 2, line );
if( target=="striped" )
extractNthWord( 3, line ) >> stripe;
@@ -98,7 +143,7 @@
unsigned long le;
string dev;
string majmin;
- string line = *c.getLine(i);
+ string line = c.getLine(i);
if( target=="linear" )
{
extractNthWord( 1, line ) >> le;
@@ -106,7 +151,7 @@
le += pesize-1;
le /= pesize;
majmin = extractNthWord( 3, line );
- dev = getDevice( majmin );
+ dev = pec()->getDeviceByNumber( majmin );
if( !dev.empty() )
{
if( (mit=pe_map.find( dev ))==pe_map.end() )
@@ -115,8 +160,7 @@
mit->second += le;
}
else
- y2warning( "could not find major/minor pair %s",
- majmin.c_str());
+ y2war("could not find major/minor pair " << majmin);
}
else if (target == "snapshot-origin")
{
@@ -137,14 +181,14 @@
stripe_size /= 2;
extractNthWord( 3, line ) >> str;
if( str<2 )
- y2warning( "invalid stripe count %u", str );
+ y2war("invalid stripe count " << str);
else
{
le = (le+str-1)/str;
for( unsigned j=0; j<str; j++ )
{
majmin = extractNthWord( 5+j*2, line );
- dev = getDevice( majmin );
+ dev = pec()->getDeviceByNumber( majmin );
if( !dev.empty() )
{
if( (mit=pe_map.find( dev ))==pe_map.end() )
@@ -153,8 +197,7 @@
mit->second += le;
}
else
- y2warning( "could not find major/minor pair %s",
- majmin.c_str());
+ y2war("could not find major/minor pair " << majmin);
}
}
}
@@ -162,7 +205,7 @@
{
if( find( known_types.begin(), known_types.end(), target ) ==
known_types.end() )
- y2warning( "unknown target type \"%s\"", target.c_str() );
+ y2war("unknown target type \"" << target << "\"");
extractNthWord( 1, line ) >> le;
y2mil( "le:" << le );
le /= 2;
@@ -182,7 +225,7 @@
if( devspec.match( *i ))
{
y2mil( "match \"" << *i << "\"" );
- dev = getDevice( *i );
+ dev = pec()->getDeviceByNumber( *i );
if( !dev.empty() )
{
if( (mit=pe_map.find( dev ))==pe_map.end() )
@@ -191,8 +234,7 @@
mit->second += le;
}
else
- y2warning( "could not find major/minor pair %s",
- majmin.c_str());
+ y2war("could not find major/minor pair " << majmin);
}
}
}
@@ -201,58 +243,7 @@
bool Dm::removeTable()
{
- return( getContainer()->getStorage()->removeDmTable( tname ));
- }
-
-string Dm::getDevice( const string& majmin )
- {
- string ret = cont->getStorage()->deviceByNumber( majmin );
- if( ret.empty() )
- {
- unsigned mj = 0;
- unsigned mi = 0;
- string pair( majmin );
- SystemCmd c;
- do
- {
- mj = mi = 0;
- string::size_type pos = pair.find( ':' );
- if( pos != string::npos )
- pair[pos] = ' ';
- istringstream i( pair );
- classic(i);
- i >> mj >> mi;
- list<string> ls = splitString(pair);
- if( cont->majorNr()>0 && mj==cont->majorNr() && mi==cont->minorNr())
- ret = cont->device();
- if( mj==Loop::major() )
- ret = Loop::loopDeviceName(mi);
- if( ret.empty() && mj==dmMajor() && ls.size()>=2 )
- {
- c.execute(DMSETUPBIN " info -c --noheadings -j " + *ls.begin() +
- " -m " + *(++ls.begin()) + " | sed -e \"s/:.*//\"" );
- if( c.retcode()==0 && c.numLines()>0 )
- {
- string tmp = "/dev/"+*c.getLine(0);
- if( cont->getStorage()->knownDevice( tmp, true ) )
- {
- ret = tmp;
- }
- else
- {
- c.execute(DMSETUPBIN " table " + quote(*c.getLine(0)));
- if( c.retcode()==0 && c.numLines()>0 )
- {
- pair = extractNthWord( 3, *c.getLine(0) );
- ret = cont->getStorage()->deviceByNumber( pair );
- }
- }
- }
- }
- }
- while( ret.empty() && mj==dm_major && c.retcode()==0 );
- }
- return( ret );
+ return getStorage()->removeDmTable(tname);
}
unsigned long long
@@ -287,8 +278,8 @@
ret = mit != pe_map.end();
if( ret )
{
- y2mil( "map:" << pe_map );
- y2milestone( "table:%s dev:%s ret:%d", tname.c_str(), dev.c_str(), ret );
+ y2mil("map:" << pe_map);
+ y2mil("table:" << tname << " dev:" << dev << " ret:" << ret);
}
return( ret );
}
@@ -302,7 +293,7 @@
mit!=pe_map.end(); ++mit )
sum += mit->second;
if( sum != num_le )
- y2warning( "lv:%s sum:%lu num:%llu", dev.c_str(), sum, num_le );
+ y2war("lv:" << dev << " sum:" << sum << " num:" << num_le);
else
ret = true;
return( ret );
@@ -317,20 +308,16 @@
void Dm::init()
{
string dmn = "/dev/mapper/" + tname;
- if( dev.empty() )
- {
- dev = dmn;
- nm = tname;
- }
- else if( dmn != dev )
+ if( dmn != dev )
alt_names.push_back( dmn );
//alt_names.push_back( "/dev/"+tname );
- updateMajorMinor();
+ if (!getStorage()->testmode())
+ updateMajorMinor();
}
void Dm::updateMajorMinor()
{
- getMajorMinor( dev, mjr, mnr );
+ getMajorMinor();
if( majorNr()==Dm::dmMajor() )
{
string d = "/dev/dm-" + decString(minorNr());
@@ -387,9 +374,9 @@
}
}
-string Dm::removeText( bool doing ) const
+Text Dm::removeText( bool doing ) const
{
- string txt;
+ Text txt;
if( doing )
{
// displayed text during action, %1$s is replaced by device name e.g. /dev/mapper/system
@@ -405,9 +392,9 @@
return( txt );
}
-string Dm::formatText( bool doing ) const
+Text Dm::formatText( bool doing ) const
{
- string txt;
+ Text txt;
if( doing )
{
// displayed text during action, %1$s is replaced by device name e.g. /dev/mapper/system
@@ -456,7 +443,10 @@
void Dm::activate( bool val )
{
- y2milestone( "old active:%d val:%d", active, val );
+ if (getenv("LIBSTORAGE_NO_DM") != NULL)
+ return;
+
+ y2mil("old active:" << active << " val:" << val);
if( active!=val )
{
SystemCmd c;
@@ -465,18 +455,24 @@
c.execute(DMSETUPBIN " version");
if( c.retcode()!=0 )
{
- c.execute("grep \"^dm[-_]mod[ \t]\" /proc/modules");
- if( c.numLines()<=0 )
c.execute(MODPROBEBIN " dm-mod");
- c.execute("grep \"^dm[-_]snapshot[ \t]\" /proc/modules");
- if( c.numLines()<=0 )
c.execute(MODPROBEBIN " dm-snapshot");
- c.execute("/sbin/devmap_mknod.sh");
+ c.execute(DMSETUPBIN " version");
}
}
else
{
- c.execute(DMSETUPBIN " remove_all");
+ c.execute(DMSETUPBIN " info -c -o name,subsystem");
+ SystemCmd rm;
+ for( unsigned i=0; i<c.numLines(); i++ )
+ {
+ if( extractNthWord(1, c.getLine(i)) != "CRYPT" )
+ {
+ string cmd = DMSETUPBIN " remove ";
+ cmd += extractNthWord(0, c.getLine(i));
+ rm.execute( cmd );
+ }
+ }
}
active = val;
}
@@ -484,93 +480,40 @@
string Dm::devToTable( const string& dev )
{
- string ret(undevDevice(dev));
- string::iterator it = ret.begin();
- while( it!=ret.end() )
- {
- if( *it == '/' )
- *it = '|';
- ++it;
- }
+ string ret = boost::replace_all_copy(undevDevice(dev), "/", "|");
if( dev!=ret )
- y2milestone( "dev:%s --> %s", dev.c_str(), ret.c_str() );
+ y2mil("dev:" << dev << " ret:" << ret);
return( ret );
}
-string Dm::dmName( const string& table )
- {
- string ret = "";
- int num = Dm::dmNumber( table );
- if( num>=0 )
- ret = "dm-" + decString(num);
- y2mil( "table:" << table << " ret:" << ret );
- return( ret );
- }
string Dm::dmDeviceName( unsigned long num )
{
return( "/dev/dm-" + decString(num));
}
-int Dm::dmNumber( const string& table )
- {
- int ret = -1;
- SystemCmd c(DMSETUPBIN " -c --noheadings info " + quote(table));
- if( c.retcode()==0 && c.numLines()>0 )
- {
- list<string> sl = splitString( *c.getLine(0), ":" );
- if( sl.size()>=3 )
- {
- list<string>::const_iterator ci = sl.begin();
- ++ci;
- ++ci;
- *ci >> ret;
- }
- }
- y2mil( "table:" << table << " ret:" << ret );
- return( ret );
- }
-string Dm::sysfsPath() const
+ string
+ Dm::sysfsPath() const
{
- string ret = SYSFSDIR "/";
- list<string>::const_iterator i =
- find_if( alt_names.begin(), alt_names.end(), find_begin( "/dev/dm-" ) );
- if( i != alt_names.end() )
- {
- string::size_type pos = i->rfind( '/' ) + 1;
- ret += i->substr( pos );
- }
- else
- {
- y2mil( "no dm device found " << *this );
- }
- y2mil( "ret:" << ret );
- return( ret );
+ return SYSFSDIR "/" + procName();
}
-void Dm::getDmMajor()
- {
- dm_major = getMajorDevices( "device-mapper" );
- y2milestone( "dm_major:%u", dm_major );
- }
void Dm::getInfo( DmInfo& tinfo ) const
{
- ((Volume*)this)->getInfo( info.v );
+ Volume::getInfo(info.v);
info.nr = num;
info.table = tname;
info.target = target;
tinfo = info;
}
-namespace storage
-{
std::ostream& operator<< (std::ostream& s, const Dm &p )
{
s << p.shortPrintedName() << " ";
- s << *(Volume*)&p;
+ s << dynamic_cast<const Volume&>(p);
if( p.num_le>0 )
s << " LE:" << p.num_le;
s << " Table:" << p.tname;
@@ -591,7 +534,6 @@
return( s );
}
-}
bool Dm::equalContent( const Dm& rhs ) const
{
@@ -600,53 +542,24 @@
stripe_size==rhs.stripe_size && pe_map==rhs.pe_map );
}
-void Dm::logDifference( const Dm& rhs ) const
-{
- string log = stringDifference(rhs);
- y2mil(log);
-}
-string Dm::stringDifference( const Dm& rhs ) const
+ void
+ Dm::logDifference(std::ostream& log, const Dm& rhs) const
{
- string ret = Volume::logDifference( rhs );
- if( num_le!=rhs.num_le )
- ret += " LE:" + decString(num_le) + "-->" + decString(rhs.num_le);
- if( stripe!=rhs.stripe )
- ret += " Stripes:" + decString(stripe) + "-->" + decString(rhs.stripe);
- if( stripe_size!=rhs.stripe_size )
- ret += " StripeSize:" + decString(stripe_size) + "-->" +
- decString(rhs.stripe_size);
- if( pe_map!=rhs.pe_map )
- {
- std::ostringstream b;
- classic(b);
- b << " pe_map:" << pe_map << "-->" << rhs.pe_map;
- ret += b.str();
- }
- return( ret );
- }
+ Volume::logDifference(log, rhs);
-Dm& Dm::operator= ( const Dm& rhs )
- {
- y2deb("operator= from " << rhs.nm);
- *((Volume*)this) = rhs;
- num_le = rhs.num_le;
- stripe = rhs.stripe;
- stripe_size = rhs.stripe_size;
- inactiv = rhs.inactiv;
- tname = rhs.tname;
- pe_map = rhs.pe_map;
- return( *this );
- }
+ logDiff(log, "num_le", num_le, rhs.num_le);
+ logDiff(log, "stripes", stripe, rhs.stripe);
+ logDiff(log, "stripe_size", stripe_size, rhs.stripe_size);
-Dm::Dm( const PeContainer& d, const Dm& rhs ) : Volume(d)
- {
- y2deb("constructed dm by copy constructor from " << rhs.dev);
- *this = rhs;
+ logDiff(log, "pe_map", pe_map, rhs.pe_map);
}
+
bool Dm::active = false;
unsigned Dm::dm_major = 0;
-static const char* elem[] = { "crypt" };
-list<string> Dm::known_types( elem, elem+lengthof(elem) );
+ static const char* elem[] = { "crypt" };
+ const list<string> Dm::known_types(elem, elem + lengthof(elem));
+
+}
Modified: branches/SuSE-Code-11-SP2-Branch/storage/libstorage/src/Dm.h
URL: http://svn.opensuse.org/viewcvs/yast/branches/SuSE-Code-11-SP2-Branch/stora…
==============================================================================
--- branches/SuSE-Code-11-SP2-Branch/storage/libstorage/src/Dm.h (original)
+++ branches/SuSE-Code-11-SP2-Branch/storage/libstorage/src/Dm.h Tue May 17 13:39:44 2011
@@ -25,7 +25,7 @@
#include <map>
-#include "y2storage/Volume.h"
+#include "storage/Volume.h"
namespace storage
{
@@ -35,12 +35,16 @@
class Dm : public Volume
{
public:
- Dm( const PeContainer& d, const string& tn );
- Dm( const PeContainer& d, const string& tn, unsigned mnum );
- Dm( const PeContainer& d, const Dm& rhs );
- Dm& operator=( const Dm& );
+ Dm(const PeContainer& c, const string& name, const string& device, const string& tname);
+ Dm(const PeContainer& c, const string& name, const string& device, const string& tname,
+ SystemInfo& systeminfo);
+ Dm(const PeContainer& c, const xmlNode* node);
+ Dm(const PeContainer& c, const Dm& v);
virtual ~Dm();
+
+ void saveData(xmlNode* node) const;
+
const string& getTableName() const { return( tname ); }
const string& getTargetName() const { return( target ); }
void setTableName( const string& name ) { tname=name; }
@@ -60,28 +64,31 @@
unsigned setStripes( unsigned long val ) { return stripe=val; }
unsigned long long stripeSize() const { return stripe_size; }
void setStripeSize( unsigned long long val ) { stripe_size=val; }
- string sysfsPath() const;
+
+ virtual string procName() const { return "dm-" + decString(mnr); }
+ virtual string sysfsPath() const;
+
void updateMajorMinor();
- virtual const std::list<string> udevId() const { return Volume::udevId(); }
friend std::ostream& operator<< (std::ostream& s, const Dm &p );
virtual void print( std::ostream& s ) const { s << *this; }
- virtual string removeText( bool doing ) const;
- virtual string formatText( bool doing ) const;
+ virtual Text removeText( bool doing ) const;
+ virtual Text formatText( bool doing ) const;
void getInfo( storage::DmInfo& info ) const;
void changeDeviceName( const string& old, const string& nw );
static bool notDeleted( const Dm& l ) { return( !l.deleted() ); }
+ static bool isDeleted(const Dm& l) { return l.deleted(); }
- static void activate( bool val=true );
+ static void activate(bool val);
static bool isActive() { return active; }
static string devToTable( const string& dev );
- static string dmName( const string& table );
- static int dmNumber( const string& table );
- bool equalContent( const Dm& rhs ) const;
- void logDifference( const Dm& d ) const;
- string stringDifference( const Dm& d ) const;
+
+ bool equalContent(const Dm& rhs) const;
+
+ void logDifference(std::ostream& log, const Dm& rhs) const;
+
static unsigned dmMajor();
static string dmDeviceName( unsigned long num );
@@ -89,8 +96,6 @@
void init();
const PeContainer* pec() const;
virtual const string shortPrintedName() const { return( "Dm" ); }
- string getDevice( const string& majmin );
- static void getDmMajor();
string tname;
string target;
@@ -101,8 +106,16 @@
std::map<string,unsigned long> pe_map;
static bool active;
static unsigned dm_major;
- static std::list<string> known_types;
- mutable storage::DmInfo info;
+
+ static const list<string> known_types;
+
+ mutable storage::DmInfo info; // workaround for broken ycp bindings
+
+ private:
+
+ Dm(const Dm&); // disallow
+ Dm& operator=(const Dm&); // disallow
+
};
}
Modified: branches/SuSE-Code-11-SP2-Branch/storage/libstorage/src/DmCo.cc
URL: http://svn.opensuse.org/viewcvs/yast/branches/SuSE-Code-11-SP2-Branch/stora…
==============================================================================
--- branches/SuSE-Code-11-SP2-Branch/storage/libstorage/src/DmCo.cc (original)
+++ branches/SuSE-Code-11-SP2-Branch/storage/libstorage/src/DmCo.cc Tue May 17 13:39:44 2011
@@ -19,55 +19,107 @@
* find current contact information at www.novell.com.
*/
-/*
- Textdomain "storage"
-*/
-#include <iostream>
+#include <ostream>
#include <sstream>
-#include "y2storage/DmCo.h"
-#include "y2storage/Dm.h"
-#include "y2storage/SystemCmd.h"
-#include "y2storage/ProcPart.h"
-#include "y2storage/AppUtil.h"
-#include "y2storage/Storage.h"
-#include "y2storage/StorageDefines.h"
-
-using namespace std;
-using namespace storage;
-
- DmCo::DmCo(Storage * const s, bool detect, ProcPart& ppart, bool only_crypt)
- : PeContainer(s, staticType())
- {
- y2deb("constructing DmCo detect:" << detect);
- init();
- if (detect)
- getDmData(ppart, only_crypt);
+#include "storage/DmCo.h"
+#include "storage/Dm.h"
+#include "storage/SystemCmd.h"
+#include "storage/SystemInfo.h"
+#include "storage/ProcParts.h"
+#include "storage/AppUtil.h"
+#include "storage/Storage.h"
+#include "storage/StorageDefines.h"
+
+
+namespace storage
+{
+ using namespace std;
+
+
+ CmdDmsetup::CmdDmsetup()
+ {
+ SystemCmd c(DMSETUPBIN " --columns --noheadings -o name,major,minor,segments,uuid info");
+ if (c.retcode() != 0 || c.numLines() == 0)
+ return;
+
+ for (vector<string>::const_iterator it = c.stdout().begin(); it != c.stdout().end(); ++it)
+ {
+ list<string> sl = splitString(*it, ":");
+ if (sl.size() >= 4)
+ {
+ Entry entry;
+
+ list<string>::const_iterator ci = sl.begin();
+ string name = *ci++;
+ *ci++ >> entry.mjr;
+ *ci++ >> entry.mnr;
+ *ci++ >> entry.segments;
+ entry.uuid = *ci++;
+
+ data[name] = entry;
+ }
+ }
+
+ for (const_iterator it = data.begin(); it != data.end(); ++it)
+ y2mil("data[" << it->first << "] -> mjr:" << it->second.mjr << " mnr:" <<
+ it->second.mnr << " segments:" << it->second.segments << " uuid:" <<
+ it->second.uuid);
}
- void
- DmCo::second(bool detect, ProcPart& ppart, bool only_crypt)
+ bool
+ CmdDmsetup::getEntry(const string& name, Entry& entry) const
{
- y2deb("second DmCo detect:" << detect);
- if (detect)
- getDmData(ppart, only_crypt);
+ const_iterator it = data.find(name);
+ if (it == data.end())
+ return false;
+
+ entry = it->second;
+ return true;
+ }
+
+
+ list<string>
+ CmdDmsetup::getEntries() const
+ {
+ list<string> ret;
+ for (const_iterator i = data.begin(); i != data.end(); ++i)
+ ret.push_back(i->first);
+ return ret;
}
-DmCo::DmCo( Storage * const s, const string& file ) :
- PeContainer(s,staticType())
+ DmCo::DmCo(Storage* s)
+ : PeContainer(s, "mapper", "/dev/mapper", staticType())
{
- y2deb("constructing DmCo file:" << file);
- init();
+ y2deb("constructing DmCo");
}
-DmCo::~DmCo()
+
+ DmCo::DmCo(Storage* s, SystemInfo& systeminfo, bool only_crypt)
+ : PeContainer(s, "mapper", "/dev/mapper", staticType(), systeminfo)
+ {
+ y2deb("constructing DmCo");
+ getDmData(systeminfo, only_crypt);
+ }
+
+
+ void
+ DmCo::second(SystemInfo& systeminfo, bool only_crypt)
+ {
+ y2deb("second DmCo");
+ getDmData(systeminfo, only_crypt);
+ }
+
+
+ DmCo::~DmCo()
{
y2deb("destructed DmCo");
}
+
void DmCo::updateDmMaps()
{
DmPair dp = dmPair();
@@ -92,13 +144,6 @@
while( success );
}
-void
-DmCo::init()
- {
- nm = "dm";
- dev = "/dev/mapper";
- }
-
// dev should be something like /dev/mapper/cr_test
storage::EncryptType
@@ -114,7 +159,7 @@
string cipher, keysize;
for( unsigned int i = 0; i < c.numLines(); i++)
{
- string line = *c.getLine(i);
+ string line = c.getLine(i);
string key = extractNthWord( 0, line );
if( key == "cipher:" )
cipher = extractNthWord( 1, line );
@@ -132,32 +177,34 @@
ret = ENC_TWOFISH256_OLD;
}
- y2mil("ret:" << ret);
+ y2mil("ret:" << toString(ret));
return ret;
}
void
-DmCo::getDmData(ProcPart& ppart, bool only_crypt)
+ DmCo::getDmData(SystemInfo& systeminfo, bool only_crypt)
{
Storage::ConstLvmLvPair lv = getStorage()->lvmLvPair();
Storage::ConstDmraidCoPair dmrco = getStorage()->dmraidCoPair();
Storage::ConstDmraidPair dmr = getStorage()->dmrPair();
Storage::ConstDmmultipathCoPair dmmco = getStorage()->dmmultipathCoPair();
Storage::ConstDmmultipathPair dmm = getStorage()->dmmPair();
- y2mil("begin");
- SystemCmd c(DMSETUPBIN " ls | grep \"(.*)\"" );
- for( unsigned i=0; i<c.numLines(); ++i )
- {
- string line = *c.getLine(i);
- string table = extractNthWord( 0, line );
+
+ const CmdDmsetup& cmddmsetup = systeminfo.getCmdDmsetup();
+ for (CmdDmsetup::const_iterator it1 = cmddmsetup.begin(); it1 != cmddmsetup.end(); ++it1)
+ {
+ string table = it1->first;
bool found=false;
- Storage::ConstLvmLvIterator i=lv.begin();
- while( !found && i!=lv.end() )
+ if (!found)
+ {
+ Storage::ConstLvmLvIterator i=lv.begin();
+ while( !found && i!=lv.end() )
{
- found = i->getTableName()==table;
- ++i;
+ found = i->getTableName()==table;
+ ++i;
}
+ }
if( !found )
{
Storage::ConstDmraidCoIterator i=dmrco.begin();
@@ -196,18 +243,13 @@
}
if( !found )
{
- string minor = extractNthWord( 2, line );
- unsigned min_num;
- string::size_type pos;
- if( (pos=minor.find( ")" ))!=string::npos )
- minor.erase( pos );
- minor >> min_num;
- y2mil( "minor:\"" << minor << "\" minor:" << min_num );
- Dm * m = new Dm( *this, table, min_num );
- y2mil( "new Dm:" << *m );
+ const CmdDmsetup::Entry& entry = it1->second;
+
+ Dm* m = new Dm(*this, table, "/dev/mapper/" + table, table, systeminfo);
+ y2mil("new Dm:" << *m);
unsigned long long s = 0;
- string dev = "/dev/dm-" + decString(min_num);
- if( ppart.getSize( dev, s ))
+ string dev = "/dev/dm-" + decString(entry.mnr);
+ if (systeminfo.getProcParts().getSize(dev, s))
{
y2mil( "new dm size:" << s );
m->setSize( s );
@@ -222,7 +264,7 @@
if( !getStorage()->canUseDevice( it->first, true ))
in_use = true;
if( !in_use || multipath )
- getStorage()->setUsedBy( it->first, UB_DM, table );
+ getStorage()->setUsedBy(it->first, UB_DM, "/dev/mapper/" + table);
}
string tmp = m->device();
tmp.erase( 5, 7 );
@@ -234,13 +276,12 @@
getStorage()->knownDevice( it->first ))
{
skip = true;
- getStorage()->setDmcryptData( it->first, m->device(), min_num,
+ getStorage()->setDmcryptData( it->first, m->device(), entry.mnr,
m->sizeK(), detectEncryption (m->device()) );
- if (getStorage()->usedBy(it->first) == UB_DM)
+ if (getStorage()->isUsedBy(it->first, UB_DM))
getStorage()->clearUsedBy(it->first);
}
- if (!skip && m->sizeK() > 0 && ((only_crypt && m->getTargetName() == "crypt") ||
- (!only_crypt && m->getTargetName() != "crypt")))
+ if (!skip && m->sizeK()>0 && !only_crypt )
addDm( m );
else
delete( m );
@@ -309,7 +350,7 @@
if( !findDm( tname, i ))
ret = DM_UNKNOWN_TABLE;
}
- if( ret==0 && i->getUsedByType() != UB_NONE )
+ if (ret == 0 && i->isUsedBy())
{
ret = DM_REMOVE_USED_BY;
}
@@ -328,7 +369,7 @@
{
getStorage()->clearUsedBy(it->first);
}
- i->setDeleted( true );
+ i->setDeleted();
}
}
y2mil("ret:" << ret);
@@ -367,7 +408,7 @@
if( c.retcode()!=0 )
ret = DM_REMOVE_FAILED;
else
- getStorage()->waitForDevice();
+ Storage::waitForDevice();
y2mil( "this:" << *this );
getStorage()->logProcData( cmd );
}
@@ -383,57 +424,28 @@
return( ret );
}
-namespace storage
-{
-inline std::ostream& operator<< (std::ostream& s, const DmCo& d )
+ std::ostream& operator<<(std::ostream& s, const DmCo& d)
{
- s << *((Container*)&d);
+ s << dynamic_cast<const Container&>(d);
return( s );
}
-}
-void DmCo::logDifference( const Container& d ) const
+ void
+ DmCo::logDifferenceWithVolumes(std::ostream& log, const Container& rhs_c) const
{
- y2mil(getDiffString(d));
- const DmCo * p = dynamic_cast<const DmCo*>(&d);
- if( p != NULL )
- {
- ConstDmPair pp=dmPair();
- ConstDmIter i=pp.begin();
- while( i!=pp.end() )
- {
- ConstDmPair pc=p->dmPair();
- ConstDmIter j = pc.begin();
- while( j!=pc.end() &&
- (i->device()!=j->device() || i->created()!=j->created()) )
- ++j;
- if( j!=pc.end() )
- {
- if( !i->equalContent( *j ) )
- i->logDifference( *j );
- }
- else
- y2mil( " -->" << *i );
- ++i;
- }
- pp=p->dmPair();
- i=pp.begin();
- while( i!=pp.end() )
- {
- ConstDmPair pc=dmPair();
- ConstDmIter j = pc.begin();
- while( j!=pc.end() &&
- (i->device()!=j->device() || i->created()!=j->created()) )
- ++j;
- if( j==pc.end() )
- y2mil( " <--" << *i );
- ++i;
- }
- }
+ const DmCo& rhs = dynamic_cast<const DmCo&>(rhs_c);
+
+ logDifference(log, rhs);
+ log << endl;
+
+ ConstDmPair pp = dmPair();
+ ConstDmPair pc = rhs.dmPair();
+ logVolumesDifference(log, pp.begin(), pp.end(), pc.begin(), pc.end());
}
+
bool DmCo::equalContent( const Container& rhs ) const
{
const DmCo * p = NULL;
@@ -444,15 +456,7 @@
{
ConstDmPair pp = dmPair();
ConstDmPair pc = p->dmPair();
- ConstDmIter i = pp.begin();
- ConstDmIter j = pc.begin();
- while( ret && i!=pp.end() && j!=pc.end() )
- {
- ret = ret && i->equalContent( *j );
- ++i;
- ++j;
- }
- ret = ret && i==pp.end() && j==pc.end();
+ ret = ret && storage::equalContent(pp.begin(), pp.end(), pc.begin(), pc.end());
}
return( ret );
}
@@ -468,5 +472,4 @@
}
}
-
-void DmCo::logData( const string& Dir ) {;}
+}
Modified: branches/SuSE-Code-11-SP2-Branch/storage/libstorage/src/DmCo.h
URL: http://svn.opensuse.org/viewcvs/yast/branches/SuSE-Code-11-SP2-Branch/stora…
==============================================================================
--- branches/SuSE-Code-11-SP2-Branch/storage/libstorage/src/DmCo.h (original)
+++ branches/SuSE-Code-11-SP2-Branch/storage/libstorage/src/DmCo.h Tue May 17 13:39:44 2011
@@ -23,48 +23,93 @@
#ifndef DM_CO_H
#define DM_CO_H
-#include "y2storage/PeContainer.h"
-#include "y2storage/Dm.h"
+#include "storage/PeContainer.h"
+#include "storage/Dm.h"
namespace storage
{
-class ProcPart;
+ class SystemInfo;
+
+
+ class CmdDmsetup
+ {
+
+ public:
+
+ CmdDmsetup();
+
+ struct Entry
+ {
+ Entry() : name(), mjr(0), mnr(0), segments(0), uuid() {}
+
+ string name;
+ unsigned long mjr;
+ unsigned long mnr;
+ unsigned segments;
+ string uuid;
+ };
+
+ bool getEntry(const string& name, Entry& entry) const;
+
+ list<string> getEntries() const;
+
+ template<class Pred>
+ list<string> getMatchingEntries(Pred pred) const
+ {
+ list<string> ret;
+ for (const_iterator i = data.begin(); i != data.end(); ++i)
+ if (pred(i->first))
+ ret.push_back(i->first);
+ return ret;
+ }
+
+ typedef map<string, Entry>::const_iterator const_iterator;
+
+ const_iterator begin() const { return data.begin(); }
+ const_iterator end() const { return data.end(); }
+
+ private:
+
+ map<string, Entry> data;
+
+ };
+
class DmCo : public PeContainer
{
friend class Storage;
public:
- DmCo(Storage * const s, bool detect, ProcPart& ppart, bool only_crypt);
- DmCo( const DmCo& rhs );
-
- void second(bool detect, ProcPart& ppart, bool only_crypt);
+ DmCo(Storage * const s);
+ DmCo(Storage * const s, SystemInfo& systeminfo, bool only_crypt);
+ DmCo(const DmCo& c);
virtual ~DmCo();
+ void second(SystemInfo& systeminfo, bool only_crypt);
+
static storage::CType staticType() { return storage::DM; }
friend std::ostream& operator<< (std::ostream&, const DmCo& );
bool equalContent( const Container& rhs ) const;
- void logDifference( const Container& d ) const;
+
+ virtual void logDifferenceWithVolumes(std::ostream& log, const Container& rhs) const;
+
void updateDmMaps();
int removeDm( const string& table );
int removeVolume( Volume* v );
protected:
- DmCo( Storage * const s, const string& File );
- void getDmData(ProcPart& ppart, bool only_crypt);
+ void getDmData(SystemInfo& systeminfo, bool only_crypt);
bool findDm( unsigned num, DmIter& i );
bool findDm( unsigned num );
bool findDm( const string& dev, DmIter& i );
bool findDm( const string& dev );
void addDm( Dm* m );
void checkDm( Dm* m );
- void updateEntry( const Dm* m );
- virtual Container* getCopy() const { return( new DmCo( *this ) ); }
- void init();
+ virtual Container* getCopy() const { return( new DmCo( *this ) ); }
storage::EncryptType detectEncryption( const string& device ) const;
@@ -72,7 +117,10 @@
int doRemove( Volume* v );
- void logData( const string& Dir );
+ private:
+
+ DmCo& operator=(const DmCo&); // disallow
+
};
}
Modified: branches/SuSE-Code-11-SP2-Branch/storage/libstorage/src/DmPart.cc
URL: http://svn.opensuse.org/viewcvs/yast/branches/SuSE-Code-11-SP2-Branch/stora…
==============================================================================
--- branches/SuSE-Code-11-SP2-Branch/storage/libstorage/src/DmPart.cc (original)
+++ branches/SuSE-Code-11-SP2-Branch/storage/libstorage/src/DmPart.cc Tue May 17 13:39:44 2011
@@ -19,57 +19,50 @@
* find current contact information at www.novell.com.
*/
-/*
- Textdomain "storage"
-*/
#include <sstream>
-#include "y2storage/DmPart.h"
-#include "y2storage/DmPartCo.h"
-#include "y2storage/SystemCmd.h"
-#include "y2storage/ProcPart.h"
-#include "y2storage/AppUtil.h"
-#include "y2storage/Storage.h"
+#include "storage/DmPart.h"
+#include "storage/DmPartCo.h"
+#include "storage/SystemCmd.h"
+#include "storage/ProcParts.h"
+#include "storage/AppUtil.h"
+#include "storage/Storage.h"
-using namespace storage;
-using namespace std;
-
-DmPart::DmPart(const DmPartCo& d, unsigned nr, Partition* pa)
- : Dm(d, "")
+namespace storage
{
- init( d.numToName(nr) );
+ using namespace std;
+
+
+ DmPart::DmPart(const DmPartCo& c, const string& name, const string& device, unsigned nr,
+ Partition* pa)
+ : Dm(c, name, device, name), p(pa)
+ {
+ Dm::init();
+
numeric = true;
num = nr;
getTableInfo();
- p = pa;
if( pa )
setSize( pa->sizeK() );
- y2mil("constructed DmPart " << dev << " on co " << cont->name());
+ y2mil("constructed DmPart " << dev << " on " << cont->device());
}
-DmPart::~DmPart()
-{
- y2deb("destructed DmPart " << dev);
-}
+ DmPart::DmPart(const DmPartCo& c, const DmPart& v)
+ : Dm(c, v)
+ {
+ y2deb("copy-constructed DmPart from " << v.dev);
+ }
-void DmPart::init( const string& name )
+ DmPart::~DmPart()
{
- p = NULL;
- nm = name;
- dev = "/dev/mapper/" + name;
- string::size_type pos = name.find_last_of( "/" );
- if( pos!=string::npos )
- nm = name.substr( pos+1 );
- else
- nm = name;
- tname = nm;
- Dm::init();
+ y2deb("destructed DmPart " << dev);
}
+
const DmPartCo* DmPart::co() const
{
return(dynamic_cast<const storage::DmPartCo*>(cont));
@@ -80,21 +73,18 @@
if( p && p->nr() != num )
{
num = p->nr();
- nm = co()->numToName(num);
- dev = "/dev/mapper/" + nm;
+ setNameDevice(co()->getPartName(num), co()->getPartDevice(num));
}
}
void DmPart::updateMinor()
{
- unsigned long mj=mjr;
- unsigned long mi=mnr;
- getMajorMinor( dev, mj, mi );
- if( mi!=mnr || mj!=mjr )
+ unsigned long old_mjr = mjr;
+ unsigned long old_mnr = mnr;
+ getMajorMinor();
+ if (mjr != old_mjr || mnr != old_mnr)
{
- mnr = mi;
- mjr = mj;
- replaceAltName( "/dev/dm-", "/dev/dm-"+decString(mnr) );
+ replaceAltName("/dev/dm-", "/dev/dm-" + decString(mnr));
getTableInfo();
}
}
@@ -108,75 +98,64 @@
}
}
-void DmPart::updateSize( ProcPart& pp )
+
+ void
+ DmPart::updateSize(const ProcParts& parts)
{
unsigned long long si = 0;
updateSize();
- if( mjr>0 && pp.getSize( "dm-"+decString(mnr), si ))
+ if (mjr > 0 && parts.getSize("/dev/dm-" + decString(mnr), si))
setSize( si );
}
+
void DmPart::addUdevData()
{
addAltUdevId( num );
}
-static string udevCompleteIdPath( const string& s, unsigned nr )
+
+ void
+ DmPart::addAltUdevId(unsigned num)
{
- return( "/dev/disk/by-id/" + s + "-part" + decString(nr) );
- }
+ alt_names.remove_if(string_contains("/by-id/"));
+ const list<string> tmp = co()->udevId();
+ for (list<string>::const_iterator i = tmp.begin(); i != tmp.end(); ++i)
+ alt_names.push_back("/dev/disk/by-id/" + udevAppendPart(*i, num));
-void
-DmPart::addAltUdevId( unsigned num )
-{
- list<string>::iterator i = alt_names.begin();
- while( i!=alt_names.end() )
- {
- if( i->find( "/by-id/" ) != string::npos )
- i = alt_names.erase( i );
- else
- ++i;
- }
- list<string>::const_iterator j = co()->udevId().begin();
- while( j!=co()->udevId().end() )
- {
- alt_names.push_back( udevCompleteIdPath( *j, num ));
- ++j;
- }
- mount_by = orig_mount_by = defaultMountBy();
-}
+ mount_by = orig_mount_by = defaultMountBy();
+ }
-const std::list<string>
-DmPart::udevId() const
-{
- list<string> ret;
- for (list<string>::const_iterator i = alt_names.begin();
- i != alt_names.end(); i++)
+ list<string>
+ DmPart::udevId() const
{
- if (i->find("/by-id/") != string::npos)
- ret.push_back(*i);
+ list<string> ret;
+ const list<string> tmp = co()->udevId();
+ for (list<string>::const_iterator i = tmp.begin(); i != tmp.end(); ++i)
+ ret.push_back(udevAppendPart(*i, num));
+ return ret;
}
- return ret;
-}
-void DmPart::getCommitActions( std::list<storage::commitAction*>& l ) const
+void
+DmPart::getCommitActions(list<commitAction>& l) const
{
unsigned s = l.size();
Dm::getCommitActions(l);
if( p )
{
if( s==l.size() && Partition::toChangeId( *p ) )
- l.push_back( new commitAction( INCREASE, cont->staticType(),
- setTypeText(false), this, false ));
+ l.push_back(commitAction(INCREASE, cont->type(),
+ setTypeText(false), this, false));
}
}
-string DmPart::setTypeText( bool doing ) const
+
+Text DmPart::setTypeText( bool doing ) const
{
- string txt;
+ Text txt;
string d = dev;
if( doing )
{
@@ -197,7 +176,7 @@
void DmPart::getInfo( DmPartInfo& tinfo ) const
{
- ((Volume*)this)->getInfo( info.v );
+ Volume::getInfo(info.v);
if( p )
p->getInfo( info.p );
info.part = p!=NULL;
@@ -206,40 +185,24 @@
tinfo = info;
}
-namespace storage
-{
std::ostream& operator<< (std::ostream& s, const DmPart &p )
{
- s << *(Dm*)&p;
+ s << dynamic_cast<const Dm&>(p);
return( s );
}
-}
bool DmPart::equalContent( const DmPart& rhs ) const
{
return( Dm::equalContent(rhs) );
}
-void DmPart::logDifference( const DmPart& rhs ) const
-{
- string log = stringDifference(rhs);
- y2mil(log);
-}
-
-
-DmPart& DmPart::operator=(const DmPart& rhs)
-{
- y2deb("operator= from " << rhs.nm);
- *((Dm*)this) = rhs;
- return *this;
-}
+ void
+ DmPart::logDifference(std::ostream& log, const DmPart& rhs) const
+ {
+ Dm::logDifference(log, rhs);
+ }
-DmPart::DmPart(const DmPartCo& d, const DmPart& rhs)
- : Dm(d, rhs)
-{
- y2deb("constructed dmraid by copy constructor from " << rhs.dev);
- *this = rhs;
}
Modified: branches/SuSE-Code-11-SP2-Branch/storage/libstorage/src/DmPart.h
URL: http://svn.opensuse.org/viewcvs/yast/branches/SuSE-Code-11-SP2-Branch/stora…
==============================================================================
--- branches/SuSE-Code-11-SP2-Branch/storage/libstorage/src/DmPart.h (original)
+++ branches/SuSE-Code-11-SP2-Branch/storage/libstorage/src/DmPart.h Tue May 17 13:39:44 2011
@@ -23,50 +23,59 @@
#ifndef DM_PART_H
#define DM_PART_H
-#include "y2storage/Dm.h"
-#include "y2storage/Partition.h"
+#include "storage/Dm.h"
+#include "storage/Partition.h"
namespace storage
{
class DmPartCo;
-class ProcPart;
+ class ProcParts;
+
class DmPart : public Dm
{
public:
- DmPart( const DmPartCo& d, unsigned nr, Partition* p=NULL );
- DmPart( const DmPartCo& d, const DmPart& rd );
- DmPart& operator=( const DmPart& );
+ DmPart(const DmPartCo& c, const string& name, const string& device, unsigned nr,
+ Partition* p);
+ DmPart(const DmPartCo& c, const DmPart& v);
virtual ~DmPart();
+
friend std::ostream& operator<< (std::ostream& s, const DmPart &p );
virtual void print( std::ostream& s ) const { s << *this; }
void getInfo( storage::DmPartInfo& info ) const;
bool equalContent( const DmPart& rhs ) const;
- void logDifference( const DmPart& d ) const;
+
+ void logDifference(std::ostream& log, const DmPart& rhs) const;
+
void setPtr( Partition* pa ) { p=pa; };
Partition* getPtr() const { return p; };
unsigned id() const { return p?p->id():0; }
void updateName();
void updateMinor();
- void updateSize( ProcPart& pp );
+ void updateSize(const ProcParts& parts);
void updateSize();
- void getCommitActions( std::list<storage::commitAction*>& l ) const;
+ void getCommitActions(list<commitAction>& l) const;
void addUdevData();
- virtual const std::list<string> udevId() const;
- virtual string setTypeText( bool doing=true ) const;
+ virtual list<string> udevId() const;
+ virtual Text setTypeText(bool doing) const;
static bool notDeleted( const DmPart& l ) { return( !l.deleted() ); }
protected:
- void init( const string& name );
- void dataFromPart( const Partition* p );
+
virtual const string shortPrintedName() const { return( "DmPart" ); }
const DmPartCo* co() const;
void addAltUdevId( unsigned num );
Partition* p;
- mutable storage::DmPartInfo info;
+ mutable storage::DmPartInfo info; // workaround for broken ycp bindings
+
+ private:
+
+ DmPart(const DmPart&); // disallow
+ DmPart& operator=(const DmPart&); // disallow
+
};
}
Modified: branches/SuSE-Code-11-SP2-Branch/storage/libstorage/src/DmPartCo.cc
URL: http://svn.opensuse.org/viewcvs/yast/branches/SuSE-Code-11-SP2-Branch/stora…
==============================================================================
--- branches/SuSE-Code-11-SP2-Branch/storage/libstorage/src/DmPartCo.cc (original)
+++ branches/SuSE-Code-11-SP2-Branch/storage/libstorage/src/DmPartCo.cc Tue May 17 13:39:44 2011
@@ -19,38 +19,36 @@
* find current contact information at www.novell.com.
*/
-/*
- Textdomain "storage"
-*/
-#include <iostream>
+#include <ostream>
#include <sstream>
-#include "y2storage/DmPartCo.h"
-#include "y2storage/DmPart.h"
-#include "y2storage/ProcPart.h"
-#include "y2storage/Partition.h"
-#include "y2storage/SystemCmd.h"
-#include "y2storage/AppUtil.h"
-#include "y2storage/Storage.h"
-#include "y2storage/StorageDefines.h"
-
-using namespace std;
-using namespace storage;
-
-DmPartCo::DmPartCo( Storage * const s, const string& name, storage::CType t,
- ProcPart& ppart ) :
- PeContainer(s,t)
- {
- y2deb("constructing DmPart co " << name);
- dev = name;
- nm = undevName(name);
- num_part = num_pe = free_pe = 0;
- active = del_ptable = false;
- disk = NULL;
- init( ppart );
+#include "storage/DmPartCo.h"
+#include "storage/DmPart.h"
+#include "storage/ProcParts.h"
+#include "storage/Partition.h"
+#include "storage/SystemCmd.h"
+#include "storage/AppUtil.h"
+#include "storage/Storage.h"
+#include "storage/StorageDefines.h"
+#include "storage/SystemInfo.h"
+
+
+namespace storage
+{
+ using namespace std;
+
+
+ DmPartCo::DmPartCo(Storage* s, const string& name, const string& device, CType t,
+ SystemInfo& systeminfo)
+ : PeContainer(s, name, device, t, systeminfo), disk(NULL), active(false)
+ {
+ y2deb("constructing DmPartCo name:" << name);
+ getMajorMinor();
+ init(systeminfo);
}
+
DmPartCo::~DmPartCo()
{
if( disk )
@@ -58,7 +56,14 @@
delete disk;
disk = NULL;
}
- y2deb("destructed DmPart co " << dev);
+ y2deb("destructed DmPartCo " << dev);
+ }
+
+
+ string
+ DmPartCo::sysfsPath() const
+ {
+ return SYSFSDIR "/" + procName();
}
@@ -75,7 +80,7 @@
unsigned number;
device.substr(pos + 5) >> number;
y2mil("num:" << number);
- device = "/dev/mapper/" + numToName(number);
+ device = getPartDevice(number);
Partition *p = getPartition( number, false );
if( p==NULL )
ret = DMPART_PARTITION_NOT_FOUND;
@@ -86,6 +91,7 @@
newP( dm, p->nr(), p );
dm->getFsInfo( p );
dm->setCreated();
+ dm->addUdevData();
addToList( dm );
}
handleWholeDevice();
@@ -99,8 +105,8 @@
DmPartCo::createPartition( storage::PartitionType type, long unsigned start,
long unsigned len, string& device, bool checkRelaxed )
{
- y2milestone( "begin type %d at %ld len %ld relaxed:%d", type, start, len,
- checkRelaxed );
+ y2mil("begin type:" << toString(type) << " start:" << start << " len:" << len <<
+ " relaxed:" << checkRelaxed);
int ret = disk ? 0 : DMPART_INTERNAL_ERR;
if( ret==0 && readonly() )
ret = DMPART_CHANGE_READONLY;
@@ -115,7 +121,7 @@
int
DmPartCo::createPartition( long unsigned len, string& device, bool checkRelaxed )
{
- y2milestone( "len %ld relaxed:%d", len, checkRelaxed );
+ y2mil("len:" << len << " relaxed:" << checkRelaxed);
int ret = disk ? 0 : DMPART_INTERNAL_ERR;
if( ret==0 && readonly() )
ret = DMPART_CHANGE_READONLY;
@@ -130,7 +136,7 @@
int
DmPartCo::createPartition( storage::PartitionType type, string& device )
{
- y2milestone( "type %u", type );
+ y2mil("type:" << toString(type));
int ret = disk ? 0 : DMPART_INTERNAL_ERR;
if( ret==0 && readonly() )
ret = DMPART_CHANGE_READONLY;
@@ -277,73 +283,70 @@
return( ret );
}
+
void
-DmPartCo::init( ProcPart& ppart )
+ DmPartCo::init(SystemInfo& systeminfo)
{
- SystemCmd c(DMSETUPBIN " table " + quote(nm));
- if( c.retcode()==0 && c.numLines()>=1 && isdigit( c.stdout()[0] ))
+ CmdDmsetup::Entry entry;
+ if (systeminfo.getCmdDmsetup().getEntry(nm, entry) && entry.segments > 0)
{
- mnr = Dm::dmNumber( nm );
- ppart.getSize( "dm-"+decString(mnr), size_k );
- y2mil( "mnr:" << mnr << " nm:" << nm );
+ systeminfo.getProcParts().getSize("/dev/dm-" + decString(entry.mnr), size_k);
+ y2mil("minor:" << entry.mnr << " nm:" << nm);
y2mil( "pe_size:" << pe_size << " size_k:" << size_k );
if( size_k>0 )
pe_size = size_k;
else
- y2war( "size_k zero for dm minor " << mnr );
+ y2war("size_k zero for dm minor " << entry.mnr);
num_pe = 1;
- createDisk( ppart );
+ createDisk(systeminfo);
if( disk->numPartitions()>0 )
{
- string pat = numToName(1);
+ string pat = getPartName(1);
pat.erase( pat.length()-1, 1 );
- c.execute(DMSETUPBIN " ls | grep -w ^" + pat + "[0-9]\\\\+" );
- if( c.numLines()==0 )
+ string reg = "^" + pat + "[0-9]+" "$";
+ list<string> tmp = systeminfo.getCmdDmsetup().getMatchingEntries(regex_matches(reg));
+ if (tmp.empty())
activate_part(true);
}
- getVolumes( ppart );
+ getVolumes(systeminfo.getProcParts());
active = true;
}
- else
- {
- y2err("error dm " << nm << " table not found");
- }
}
+
void
-DmPartCo::createDisk( ProcPart& ppart )
+ DmPartCo::createDisk(SystemInfo& systeminfo)
{
if( disk )
delete disk;
- disk = new Disk( getStorage(), dev, size_k );
+ disk = new Disk(getStorage(), nm, dev, size_k, systeminfo);
disk->setNumMinor( 64 );
disk->setSilent();
disk->setSlave();
disk->setAddpart(false);
- disk->detect(ppart);
+ disk->detect(systeminfo);
}
+
void
DmPartCo::newP( DmPart*& dm, unsigned num, Partition* p )
{
y2mil( "num:" << num );
- dm = new DmPart( *this, num, p );
+ dm = new DmPart( *this, getPartName(num), getPartDevice(num), num, p );
}
+
void
-DmPartCo::getVolumes( ProcPart& ppart )
+ DmPartCo::getVolumes(const ProcParts& parts)
{
- vols.clear();
- num_part = 0;
+ clearPointerList(vols);
Disk::PartPair pp = disk->partPair();
Disk::PartIter i = pp.begin();
DmPart * p = NULL;
while( i!=pp.end() )
{
newP( p, i->nr(), &(*i) );
- p->updateSize( ppart );
- i->setSize(p->sizeK());
- num_part++;
+ p->updateSize(parts);
addToList( p );
++i;
}
@@ -353,7 +356,7 @@
void DmPartCo::handleWholeDevice()
{
Disk::PartPair pp = disk->partPair( Partition::notDeleted );
- y2milestone( "empty:%d", pp.empty() );
+ y2mil("empty:" << pp.empty());
if( pp.empty() )
{
DmPart * p = NULL;
@@ -419,15 +422,13 @@
void DmPartCo::updateMinor()
{
DmPartPair p=dmpartPair();
- DmPartIter i=p.begin();
- while( i!=p.end() )
- {
+ for (DmPartIter i = p.begin(); i != p.end(); ++i)
i->updateMinor();
- ++i;
- }
}
-string DmPartCo::numToName( unsigned num ) const
+
+ string
+ DmPartCo::getPartName(unsigned num) const
{
string ret = nm;
if( num>0 )
@@ -439,6 +440,21 @@
return( ret );
}
+
+ string
+ DmPartCo::getPartDevice(unsigned num) const
+ {
+ string ret = dev;
+ if( num>0 )
+ {
+ ret += "_part";
+ ret += decString(num);
+ }
+ y2mil( "num:" << num << " ret:" << ret );
+ return( ret );
+ }
+
+
string DmPartCo::undevName( const string& name )
{
string ret = name;
@@ -451,7 +467,7 @@
int DmPartCo::destroyPartitionTable( const string& new_label )
{
- y2milestone( "begin" );
+ y2mil("begin");
int ret = disk->destroyPartitionTable( new_label );
if( ret==0 )
{
@@ -468,7 +484,7 @@
}
bool save = getStorage()->getRecursiveRemoval();
getStorage()->setRecursiveRemoval(true);
- if( getUsedByType() != UB_NONE )
+ if (isUsedBy())
{
getStorage()->removeUsing( device(), getUsedBy() );
}
@@ -481,7 +497,6 @@
++i;
}
getStorage()->setRecursiveRemoval(save);
- del_ptable = true;
}
y2mil("ret:" << ret);
return( ret );
@@ -513,23 +528,29 @@
int
DmPartCo::nextFreePartition(PartitionType type, unsigned& nr, string& device) const
{
- int ret = disk->nextFreePartition( type, nr, device );
- if( ret==0 )
+ int ret = 0;
+ device = "";
+ nr = disk->availablePartNumber( type );
+ if (nr == 0)
{
- device = "/dev/mapper/" + numToName(nr);
+ ret = DISK_PARTITION_NO_FREE_NUMBER;
+ }
+ else
+ {
+ device = getPartDevice(nr);
}
y2mil("ret:" << ret << " nr:" << nr << " device:" << device);
return ret;
}
-int DmPartCo::changePartitionArea( unsigned nr, unsigned long start,
- unsigned long len, bool checkRelaxed )
+ int
+ DmPartCo::changePartitionArea(unsigned nr, const Region& cylRegion, bool checkRelaxed)
{
int ret = nr>0?0:DMPART_PARTITION_NOT_FOUND;
if( ret==0 )
{
- ret = disk->changePartitionArea( nr, start, len, checkRelaxed );
+ ret = disk->changePartitionArea(nr, cylRegion, checkRelaxed);
DmPartIter i;
if( findDm( nr, i ))
i->updateSize();
@@ -549,27 +570,12 @@
void DmPartCo::activate_part( bool val )
{
- y2milestone( "old active:%d val:%d", active, val );
- if( active != val )
- {
- SystemCmd c;
- if( val )
- {
- Dm::activate(true);
- c.execute(KPARTXBIN " -a -p _part " + quote(dev));
- }
- else
- {
- c.execute(KPARTXBIN " -d -p _part " + quote(dev));
- }
active = val;
- }
}
int DmPartCo::doSetType( DmPart* dm )
{
- y2milestone( "doSetType container %s name %s", name().c_str(),
- dm->name().c_str() );
+ y2mil("doSetType container " << name() << " name " << dm->name());
Partition * p = dm->getPtr();
int ret = p?0:DMPART_PARTITION_NOT_FOUND;
if( ret==0 )
@@ -586,7 +592,7 @@
int DmPartCo::doCreateLabel()
{
- y2milestone( "label:%s", labelName().c_str() );
+ y2mil("label:" << labelName());
int ret = 0;
if( !silent )
{
@@ -597,10 +603,9 @@
ret = disk->doCreateLabel();
if( ret==0 )
{
- del_ptable = false;
removeFromMemory();
handleWholeDevice();
- getStorage()->waitForDevice();
+ Storage::waitForDevice();
}
y2mil("ret:" << ret);
return( ret );
@@ -610,7 +615,7 @@
DmPartCo::removeDmPart()
{
int ret = 0;
- y2milestone( "begin" );
+ y2mil("begin");
if( readonly() )
{
ret = DMPART_CHANGE_READONLY;
@@ -629,7 +634,7 @@
if( !removeFromList( &(*p.begin()) ))
y2err( "not found:" << *p.begin() );
}
- setDeleted( true );
+ setDeleted();
}
if( ret==0 )
{
@@ -669,6 +674,7 @@
y2mil( "rem:" << *i );
if( !(*i)->created() )
{
+ delete *i;
i = vols.erase( i );
}
else
@@ -682,33 +688,32 @@
return( p!=NULL && !d.deleted() && Partition::toChangeId(*p) );
}
-int DmPartCo::getToCommit( CommitStage stage, list<Container*>& col,
- list<Volume*>& vol )
- {
- int ret = 0;
- y2milestone( "ret:%d col:%zd vol:%zd", ret, col.size(), vol.size());
+
+void
+DmPartCo::getToCommit(CommitStage stage, list<const Container*>& col, list<const Volume*>& vol) const
+{
+ y2mil("col:" << col.size() << " vol:" << vol.size());
getStorage()->logCo( this );
unsigned long oco = col.size();
unsigned long ovo = vol.size();
Container::getToCommit( stage, col, vol );
if( stage==INCREASE )
{
- DmPartPair p = dmpartPair( toChangeId );
- for( DmPartIter i=p.begin(); i!=p.end(); ++i )
+ ConstDmPartPair p = dmpartPair( toChangeId );
+ for( ConstDmPartIter i=p.begin(); i!=p.end(); ++i )
if( find( vol.begin(), vol.end(), &(*i) )==vol.end() )
vol.push_back( &(*i) );
}
- if( del_ptable && find( col.begin(), col.end(), this )==col.end() )
+ if( disk->del_ptable && find( col.begin(), col.end(), this )==col.end() )
col.push_back( this );
if( col.size()!=oco || vol.size()!=ovo )
- y2milestone( "ret:%d col:%zd vol:%zd", ret, col.size(), vol.size());
- return( ret );
- }
+ y2mil("stage:" << stage << " col:" << col.size() << " vol:" << vol.size());
+}
int DmPartCo::commitChanges( CommitStage stage, Volume* vol )
{
- y2milestone( "name %s stage %d", name().c_str(), stage );
+ y2mil("name:" << name() << " stage:" << stage);
int ret = Container::commitChanges( stage, vol );
if( ret==0 && stage==INCREASE )
{
@@ -728,13 +733,13 @@
int DmPartCo::commitChanges( CommitStage stage )
{
- y2milestone( "name %s stage %d", name().c_str(), stage );
+ y2mil("name:" << name() << " stage:" << stage);
int ret = 0;
if( stage==DECREASE && deleted() )
{
ret = doRemove();
}
- else if( stage==DECREASE && del_ptable )
+ else if( stage==DECREASE && disk->del_ptable )
{
ret = doCreateLabel();
}
@@ -744,36 +749,27 @@
return( ret );
}
-void DmPartCo::getCommitActions( list<commitAction*>& l ) const
+
+void
+DmPartCo::getCommitActions(list<commitAction>& l) const
{
y2mil( "l:" << l );
Container::getCommitActions( l );
y2mil( "l:" << l );
- if( deleted() || del_ptable )
+ if( deleted() || disk->del_ptable )
{
- list<commitAction*>::iterator i = l.begin();
- while( i!=l.end() )
- {
- if( (*i)->stage==DECREASE )
- {
- delete( *i );
- i=l.erase( i );
- }
- else
- ++i;
- }
- string txt = deleted() ? removeText(false) :
- setDiskLabelText(false);
- l.push_front( new commitAction( DECREASE, staticType(),
- txt, this, true ));
+ l.remove_if(stage_is(DECREASE));
+ Text txt = deleted() ? removeText(false) : setDiskLabelText(false);
+ l.push_front(commitAction(DECREASE, staticType(), txt, this, true));
}
y2mil( "l:" << l );
}
+
int
DmPartCo::doCreate( Volume* v )
{
- y2milestone( "Raid:%s part:%s", name().c_str(), v->name().c_str() );
+ y2mil("DmPart:" << name() << " name:" << v->name());
DmPart * l = dynamic_cast<DmPart *>(v);
int ret = disk ? 0 : DMPART_INTERNAL_ERR;
if( ret==0 && l == NULL )
@@ -800,12 +796,12 @@
{
activate_part(false);
activate_part(true);
- ProcPart pp;
+ ProcParts parts;
updateMinor();
- l->updateSize( pp );
+ l->updateSize(parts);
}
if( p->type()!=EXTENDED )
- getStorage()->waitForDevice( l->device() );
+ Storage::waitForDevice(l->device());
}
y2mil("ret:" << ret);
return( ret );
@@ -818,7 +814,7 @@
int DmPartCo::doRemove( Volume* v )
{
- y2milestone( "Raid:%s name:%s", name().c_str(), v->name().c_str() );
+ y2mil("DmPart:" << name() << " name:" << v->name());
DmPart * l = dynamic_cast<DmPart *>(v);
bool save_act = false;
int ret = disk ? 0 : DMPART_INTERNAL_ERR;
@@ -854,14 +850,14 @@
updateMinor();
}
if( ret==0 )
- getStorage()->waitForDevice();
+ Storage::waitForDevice();
y2mil("ret:" << ret);
return( ret );
}
int DmPartCo::doResize( Volume* v )
{
- y2milestone( "DmPart:%s name:%s", name().c_str(), v->name().c_str() );
+ y2mil("DmPart:" << name() << " name:" << v->name());
DmPart * l = dynamic_cast<DmPart *>(v);
int ret = disk ? 0 : DMPART_INTERNAL_ERR;
if( ret==0 && l == NULL )
@@ -901,10 +897,10 @@
ret = l->resizeFs();
if( ret==0 )
{
- ProcPart pp;
+ ProcParts parts;
updateMinor();
- l->updateSize( pp );
- getStorage()->waitForDevice( l->device() );
+ l->updateSize(parts);
+ Storage::waitForDevice(l->device());
}
if( ret==0 && remount )
ret = l->mount();
@@ -912,30 +908,14 @@
return( ret );
}
-string DmPartCo::setDiskLabelText( bool doing ) const
+Text DmPartCo::setDiskLabelText( bool doing ) const
{
- string txt;
- string d = dev;
- if( doing )
- {
- // displayed text during action, %1$s is replaced by name (e.g. pdc_igeeeadj),
- // %2$s is replaced by label name (e.g. msdos)
- txt = sformat( _("Setting disk label of %1$s to %2$s"),
- d.c_str(), labelName().c_str() );
- }
- else
- {
- // displayed text before action, %1$s is replaced by name (e.g. pdc_igeeeadj),
- // %2$s is replaced by label name (e.g. msdos)
- txt = sformat( _("Set disk label of %1$s to %2$s"),
- d.c_str(), labelName().c_str() );
- }
- return( txt );
+ return disk->setDiskLabelText(doing);
}
-string DmPartCo::removeText( bool doing ) const
+Text DmPartCo::removeText( bool doing ) const
{
- string txt;
+ Text txt;
if( doing )
{
// displayed text during action, %1$s is replaced by a name (e.g. pdc_igeeeadj),
@@ -980,125 +960,60 @@
tinfo = info;
}
-namespace storage
-{
std::ostream& operator<< (std::ostream& s, const DmPartCo& d )
{
- s << *((PeContainer*)&d);
- s << " DmNr:" << d.mnr
- << " PNum:" << d.num_part;
+ s << dynamic_cast<const PeContainer&>(d);
if( !d.udev_id.empty() )
s << " UdevId:" << d.udev_id;
- if( d.del_ptable )
- s << " delPT";
if( !d.active )
s << " inactive";
+ s << " geometry:" << d.disk->getGeometry();
return( s );
}
-}
-string DmPartCo::getDiffString( const Container& d ) const
+ void
+ DmPartCo::logDifference(std::ostream& log, const DmPartCo& rhs) const
{
- string log = Container::getDiffString( d );
- const DmPartCo* p = dynamic_cast<const DmPartCo*>(&d);
- if( p )
- {
- if( del_ptable!=p->del_ptable )
- {
- if( p->del_ptable )
- log += " -->delPT";
- else
- log += " delPT-->";
- }
- if( active!=p->active )
- {
- if( p->active )
- log += " -->active";
- else
- log += " active-->";
- }
- }
- return( log );
- }
+ PeContainer::logDifference(log, rhs);
-void DmPartCo::logDifference( const DmPartCo& d ) const
- {
- string log = getDiffString( d );
- y2mil(log);
- ConstDmPartPair pp=dmpartPair();
- ConstDmPartIter i=pp.begin();
- while( i!=pp.end() )
- {
- ConstDmPartPair pc=d.dmpartPair();
- ConstDmPartIter j = pc.begin();
- while( j!=pc.end() &&
- (i->device()!=j->device() || i->created()!=j->created()) )
- ++j;
- if( j!=pc.end() )
- {
- if( !i->equalContent( *j ) )
- i->logDifference( *j );
- }
- else
- y2mil( " -->" << *i );
- ++i;
- }
- pp=d.dmpartPair();
- i=pp.begin();
- while( i!=pp.end() )
- {
- ConstDmPartPair pc=dmpartPair();
- ConstDmPartIter j = pc.begin();
- while( j!=pc.end() &&
- (i->device()!=j->device() || i->created()!=j->created()) )
- ++j;
- if( j==pc.end() )
- y2mil( " <--" << *i );
- ++i;
- }
+ logDiff(log, "active", active, rhs.active);
}
+
bool DmPartCo::equalContent( const DmPartCo& rhs ) const
{
bool ret = PeContainer::equalContent(rhs,false) &&
- active==rhs.active &&
- del_ptable==rhs.del_ptable;
+ active==rhs.active;
if( ret )
{
ConstDmPartPair pp = dmpartPair();
ConstDmPartPair pc = rhs.dmpartPair();
- ConstDmPartIter i = pp.begin();
- ConstDmPartIter j = pc.begin();
- while( ret && i!=pp.end() && j!=pc.end() )
- {
- ret = ret && i->equalContent( *j );
- ++i;
- ++j;
- }
- ret = ret && i==pp.end() && j==pc.end();
+ ret = ret && storage::equalContent(pp.begin(), pp.end(), pc.begin(), pc.end());
}
return( ret );
}
-DmPartCo::DmPartCo( const DmPartCo& rhs ) : PeContainer(rhs)
+
+ DmPartCo::DmPartCo(const DmPartCo& c)
+ : PeContainer(c), udev_id(c.udev_id), active(c.active)
{
- y2deb("constructed DmPartCo by copy constructor from " << rhs.nm);
- active = rhs.active;
- del_ptable = rhs.del_ptable;
- disk = NULL;
- if( rhs.disk )
- disk = new Disk( *rhs.disk );
- getStorage()->waitForDevice();
- ConstDmPartPair p = rhs.dmpartPair();
- for( ConstDmPartIter i = p.begin(); i!=p.end(); ++i )
+ y2deb("copy-constructed DmPartCo from " << c.dev);
+
+ disk = NULL;
+ if (c.disk)
+ disk = new Disk(*c.disk);
+
+ Storage::waitForDevice();
+ ConstDmPartPair p = c.dmpartPair();
+ for (ConstDmPartIter i = p.begin(); i != p.end(); ++i)
{
- DmPart * p = new DmPart( *this, *i );
- vols.push_back( p );
+ DmPart* p = new DmPart(*this, *i);
+ vols.push_back(p);
}
- updatePointers(true);
- }
-void DmPartCo::logData( const string& Dir ) {;}
+ updatePointers(true);
+ }
+}
Modified: branches/SuSE-Code-11-SP2-Branch/storage/libstorage/src/DmPartCo.h
URL: http://svn.opensuse.org/viewcvs/yast/branches/SuSE-Code-11-SP2-Branch/stora…
==============================================================================
--- branches/SuSE-Code-11-SP2-Branch/storage/libstorage/src/DmPartCo.h (original)
+++ branches/SuSE-Code-11-SP2-Branch/storage/libstorage/src/DmPartCo.h Tue May 17 13:39:44 2011
@@ -25,37 +25,43 @@
#include <list>
-#include "y2storage/PeContainer.h"
-#include "y2storage/Disk.h"
-#include "y2storage/DmPart.h"
+#include "storage/PeContainer.h"
+#include "storage/Disk.h"
+#include "storage/DmPart.h"
+
namespace storage
{
+ using std::list;
+
class Storage;
-class SystemCmd;
-class ProcPart;
+ class SystemInfo;
class Region;
+
class DmPartCo : public PeContainer
{
friend class Storage;
public:
- DmPartCo( Storage * const s, const string& Name, storage::CType t,
- ProcPart& ppart );
- DmPartCo( const DmPartCo& rhs );
+
+ DmPartCo(Storage* s, const string& name, const string& device, CType t,
+ SystemInfo& systeminfo);
+ DmPartCo(const DmPartCo& c);
virtual ~DmPartCo();
unsigned long long sizeK() const { return size_k; }
const string& labelName() const { return disk->labelName(); }
- const string& udevPath() const { return udev_path; }
- const std::list<string>& udevId() const { return udev_id; }
+ virtual list<string> udevId() const { return udev_id; }
unsigned numPartitions() const { return disk->numPartitions(); }
static storage::CType staticType() { return storage::DMRAID; }
friend std::ostream& operator<< (std::ostream&, const DmPartCo& );
void setUdevData(const list<string>& id);
+ virtual string procName() const { return "dm-" + decString(mnr); }
+ virtual string sysfsPath() const;
+
int createPartition( storage::PartitionType type, long unsigned start,
long unsigned len, string& device,
bool checkRelaxed=false );
@@ -65,8 +71,7 @@
int removePartition( unsigned nr );
int changePartitionId( unsigned nr, unsigned id );
int forgetChangePartitionId( unsigned nr );
- int changePartitionArea( unsigned nr, unsigned long start,
- unsigned long size, bool checkRelaxed=false );
+ int changePartitionArea(unsigned nr, const Region& cylRegion, bool checkRelaxed = false);
int nextFreePartition(storage::PartitionType type, unsigned& nr,
string& device) const;
int destroyPartitionTable( const string& new_label );
@@ -92,23 +97,23 @@
{ return disk->cylinderToKb( val ); }
unsigned long kbToCylinder( unsigned long long val ) const
{ return disk->kbToCylinder( val ); }
- string getPartName( unsigned nr ) const;
- virtual void getCommitActions( std::list<storage::commitAction*>& l ) const;
- virtual int getToCommit( storage::CommitStage stage,
- std::list<Container*>& col,
- std::list<Volume*>& vol );
+ string getPartName(unsigned nr) const;
+ string getPartDevice(unsigned nr) const;
+
+ virtual void getCommitActions(list<commitAction>& l) const;
+ virtual void getToCommit(storage::CommitStage stage, list<const Container*>& col,
+ list<const Volume*>& vol) const;
virtual int commitChanges( storage::CommitStage stage );
int commitChanges( storage::CommitStage stage, Volume* vol );
Partition* getPartition( unsigned nr, bool del );
void getInfo( storage::DmPartCoInfo& info ) const;
bool equalContent( const DmPartCo& rhs ) const;
- virtual string getDiffString( const Container& d ) const;
- void logDifference( const DmPartCo& d ) const;
- DmPartCo& operator= ( const DmPartCo& rhs );
+
+ void logDifference(std::ostream& log, const DmPartCo& rhs) const;
+
static string undevName( const string& name );
- string numToName( unsigned num ) const;
protected:
// iterators over partitions
@@ -159,13 +164,12 @@
return( ConstDmPartIter( DmPartCPIterator( p, CheckDmPart, true )) );
}
- DmPartCo( Storage * const s, const string& File );
virtual void print( std::ostream& s ) const { s << *this; }
- virtual Container* getCopy() const { return( new DmPartCo( *this ) ); }
+ virtual Container* getCopy() const = 0; // { return( new DmPartCo( *this ) ); }
void activate_part( bool val );
- void init( ProcPart& ppart );
- void createDisk( ProcPart& ppart );
- void getVolumes( ProcPart& ppart );
+ void init(SystemInfo& systeminfo);
+ void createDisk(SystemInfo& systeminfo);
+ void getVolumes(const ProcParts& parts);
void updatePointers( bool invalid=false );
void updateMinor();
virtual void newP( DmPart*& dm, unsigned num, Partition* p );
@@ -177,28 +181,25 @@
bool validPartition( const Partition* p );
bool findDm( unsigned nr, DmPartIter& i );
- static bool partNotDeleted( const DmPart&d ) { return( !d.deleted() ); }
-
int doCreate( Volume* v );
int doRemove( Volume* v );
int doResize( Volume* v );
int doSetType( DmPart* v );
int doCreateLabel();
virtual int doRemove();
- virtual string removeText( bool doing ) const;
- virtual string setDiskLabelText( bool doing ) const;
-
- void logData( const string& Dir );
- string udev_path;
- std::list<string> udev_id;
- string logfile_name;
+ virtual Text removeText( bool doing ) const;
+ virtual Text setDiskLabelText( bool doing ) const;
+ list<string> udev_id;
Disk* disk;
bool active;
- bool del_ptable;
- unsigned num_part;
- mutable storage::DmPartCoInfo info;
+ mutable storage::DmPartCoInfo info; // workaround for broken ycp bindings
+
+ private:
+
+ DmPartCo& operator=(const DmPartCo&); // disallow
+
};
}
Modified: branches/SuSE-Code-11-SP2-Branch/storage/libstorage/src/Dmmultipath.cc
URL: http://svn.opensuse.org/viewcvs/yast/branches/SuSE-Code-11-SP2-Branch/stora…
==============================================================================
--- branches/SuSE-Code-11-SP2-Branch/storage/libstorage/src/Dmmultipath.cc (original)
+++ branches/SuSE-Code-11-SP2-Branch/storage/libstorage/src/Dmmultipath.cc Tue May 17 13:39:44 2011
@@ -19,41 +19,48 @@
* find current contact information at www.novell.com.
*/
-/*
- Textdomain "storage"
-*/
#include <sstream>
-#include "y2storage/Dmmultipath.h"
-#include "y2storage/DmmultipathCo.h"
-#include "y2storage/SystemCmd.h"
-#include "y2storage/AppUtil.h"
-#include "y2storage/Storage.h"
+#include "storage/Dmmultipath.h"
+#include "storage/DmmultipathCo.h"
+#include "storage/SystemCmd.h"
+#include "storage/AppUtil.h"
+#include "storage/Storage.h"
-using namespace storage;
-using namespace std;
-
-Dmmultipath::Dmmultipath(const DmmultipathCo& d, unsigned nr, Partition* p)
- : DmPart(d, nr, p)
+namespace storage
{
- y2mil("constructed dmmultipath " << dev << " on co " << cont->name());
-}
+ using namespace std;
-Dmmultipath::~Dmmultipath()
-{
- y2deb("destructed dmmultipath " << dev);
-}
+ Dmmultipath::Dmmultipath(const DmmultipathCo& c, const string& name, const string& device,
+ unsigned nr, Partition* p)
+ : DmPart(c, name, device, nr, p)
+ {
+ y2mil("constructed Dmmultipath " << dev << " on " << cont->device());
+ }
+
+
+ Dmmultipath::Dmmultipath(const DmmultipathCo& c, const Dmmultipath& v)
+ : DmPart(c, v)
+ {
+ y2deb("copy-constructed Dmmultipath from " << v.dev);
+ }
-string Dmmultipath::removeText( bool doing ) const
+ Dmmultipath::~Dmmultipath()
{
- string txt;
+ y2deb("destructed Dmmultipath " << dev);
+ }
+
+
+Text Dmmultipath::removeText( bool doing ) const
+ {
+ Text txt;
string d = dev.substr(12);
if( p && p->OrigNr()!=p->nr() )
- d = co()->numToName(p->OrigNr());
+ d = co()->getPartName(p->OrigNr());
if( doing )
{
// displayed text during action, %1$s is replaced by multipath partition name e.g. 3600508b400105f590000900000300000_part1
@@ -69,9 +76,9 @@
return( txt );
}
-string Dmmultipath::createText( bool doing ) const
+Text Dmmultipath::createText( bool doing ) const
{
- string txt;
+ Text txt;
string d = dev.substr(12);
if( doing )
{
@@ -128,9 +135,9 @@
return( txt );
}
-string Dmmultipath::formatText( bool doing ) const
+Text Dmmultipath::formatText( bool doing ) const
{
- string txt;
+ Text txt;
string d = dev.substr(12);
if( doing )
{
@@ -185,9 +192,9 @@
return( txt );
}
-string Dmmultipath::resizeText( bool doing ) const
+Text Dmmultipath::resizeText( bool doing ) const
{
- string txt;
+ Text txt;
string d = dev.substr(12);
if( doing )
{
@@ -199,8 +206,9 @@
// displayed text during action, %1$s is replaced by multipath partition e.g. 3600508b400105f590000900000300000_part1
// %2$s is replaced by size (e.g. 623.5 MB)
txt = sformat( _("Extending multipath partition %1$s to %2$s"), d.c_str(), sizeString().c_str() );
+ txt += Text(" ", " ");
// text displayed during action
- txt += string(" ") + _("(progress bar might not move)");
+ txt += _("(progress bar might not move)");
}
else
{
@@ -217,9 +225,9 @@
return( txt );
}
-string Dmmultipath::setTypeText( bool doing ) const
+Text Dmmultipath::setTypeText( bool doing ) const
{
- string txt;
+ Text txt;
string d = dev.substr(12);
if( doing )
{
@@ -244,31 +252,24 @@
tinfo.p = info;
}
-namespace storage
-{
std::ostream& operator<< (std::ostream& s, const Dmmultipath &p )
{
- s << *(DmPart*)&p;
+ s << dynamic_cast<const DmPart&>(p);
return( s );
}
-}
bool Dmmultipath::equalContent( const Dmmultipath& rhs ) const
{
return( DmPart::equalContent(rhs) );
}
-void Dmmultipath::logDifference( const Dmmultipath& rhs ) const
+
+ void
+ Dmmultipath::logDifference(std::ostream& log, const Dmmultipath& rhs) const
{
- DmPart::logDifference(rhs);
+ DmPart::logDifference(log, rhs);
}
-
-Dmmultipath& Dmmultipath::operator=(const Dmmultipath& rhs)
-{
- y2deb("operator= from " << rhs.nm);
- *((DmPart*)this) = rhs;
- return *this;
}
Modified: branches/SuSE-Code-11-SP2-Branch/storage/libstorage/src/Dmmultipath.h
URL: http://svn.opensuse.org/viewcvs/yast/branches/SuSE-Code-11-SP2-Branch/stora…
==============================================================================
--- branches/SuSE-Code-11-SP2-Branch/storage/libstorage/src/Dmmultipath.h (original)
+++ branches/SuSE-Code-11-SP2-Branch/storage/libstorage/src/Dmmultipath.h Tue May 17 13:39:44 2011
@@ -23,7 +23,7 @@
#ifndef DMMULTIPATH_H
#define DMMULTIPATH_H
-#include "y2storage/DmPart.h"
+#include "storage/DmPart.h"
namespace storage
{
@@ -34,25 +34,34 @@
class Dmmultipath : public DmPart
{
public:
- Dmmultipath( const DmmultipathCo& d, unsigned nr, Partition* p=NULL );
- Dmmultipath( const DmmultipathCo& d, const Dmmultipath& rd );
+ Dmmultipath(const DmmultipathCo& c, const string& name, const string& device, unsigned nr,
+ Partition* p);
+ Dmmultipath(const DmmultipathCo& c, const Dmmultipath& v);
virtual ~Dmmultipath();
+
void getInfo( storage::DmmultipathInfo& info ) const;
friend std::ostream& operator<< (std::ostream& s, const Dmmultipath &p );
virtual void print( std::ostream& s ) const { s << *this; }
- string removeText( bool doing ) const;
- string createText( bool doing ) const;
- string formatText( bool doing ) const;
- string resizeText( bool doing ) const;
- string setTypeText( bool doing=true ) const;
+ Text removeText( bool doing ) const;
+ Text createText( bool doing ) const;
+ Text formatText( bool doing ) const;
+ Text resizeText( bool doing ) const;
+ Text setTypeText(bool doing) const;
bool equalContent( const Dmmultipath& rhs ) const;
- void logDifference( const Dmmultipath& d ) const;
+
+ void logDifference(std::ostream& log, const Dmmultipath& rhs) const;
+
static bool notDeleted( const Dmmultipath& l ) { return( !l.deleted() ); }
protected:
virtual const string shortPrintedName() const { return( "Dmmultipath" ); }
- Dmmultipath& operator=( const Dmmultipath& );
+
+ private:
+
+ Dmmultipath(const Dmmultipath&); // disallow
+ Dmmultipath& operator=(const Dmmultipath&); // disallow
+
};
}
Modified: branches/SuSE-Code-11-SP2-Branch/storage/libstorage/src/DmmultipathCo.cc
URL: http://svn.opensuse.org/viewcvs/yast/branches/SuSE-Code-11-SP2-Branch/stora…
==============================================================================
--- branches/SuSE-Code-11-SP2-Branch/storage/libstorage/src/DmmultipathCo.cc (original)
+++ branches/SuSE-Code-11-SP2-Branch/storage/libstorage/src/DmmultipathCo.cc Tue May 17 13:39:44 2011
@@ -19,24 +19,24 @@
* find current contact information at www.novell.com.
*/
-/*
- Textdomain "storage"
-*/
-#include <iostream>
+#include <ostream>
#include <sstream>
#include <locale>
#include <boost/algorithm/string.hpp>
-#include "y2storage/DmmultipathCo.h"
-#include "y2storage/Dmmultipath.h"
-#include "y2storage/SystemCmd.h"
-#include "y2storage/AppUtil.h"
-#include "y2storage/Storage.h"
-#include "y2storage/StorageDefines.h"
+#include "storage/DmmultipathCo.h"
+#include "storage/Dmmultipath.h"
+#include "storage/SystemCmd.h"
+#include "storage/AppUtil.h"
+#include "storage/Storage.h"
+#include "storage/StorageDefines.h"
+#include "storage/SystemInfo.h"
-using namespace std;
-using namespace storage;
+
+namespace storage
+{
+ using namespace std;
CmdMultipath::CmdMultipath()
@@ -45,8 +45,7 @@
if (c.retcode() != 0 || c.numLines() == 0)
return;
- vector<string> lines;
- c.getStdout(lines);
+ const vector<string>& lines = c.stdout();
vector<string>::const_iterator it1 = lines.begin();
while (it1 != lines.end())
@@ -58,7 +57,9 @@
string name = extractNthWord(0, *it1);
y2mil("mp name:" << name);
- list<string> tmp = splitString(extractNthWord(2, *it1, true), ",");
+ bool has_alias = boost::starts_with(extractNthWord(1, *it1), "(");
+
+ list<string> tmp = splitString(extractNthWord(has_alias ? 3 : 2, *it1, true), ",");
if (tmp.size() >= 2)
{
list<string>::const_iterator it2 = tmp.begin();
@@ -120,41 +121,51 @@
}
-DmmultipathCo::DmmultipathCo( Storage * const s, const string& Name, ProcPart& ppart ) :
- DmPartCo(s, "/dev/mapper/"+Name, staticType(), ppart )
-{
- DmPartCo::init( ppart );
- getMultipathData( Name );
- y2deb("constructing dmmultipath co " << Name);
-}
+ DmmultipathCo::DmmultipathCo(Storage* s, const string& name, const string& device,
+ SystemInfo& systeminfo)
+ : DmPartCo(s, name, device, staticType(), systeminfo)
+ {
+ getMultipathData(name, systeminfo);
+ const UdevMap& by_id = systeminfo.getUdevMap("/dev/disk/by-id");
+ UdevMap::const_iterator it = by_id.find("dm-" + decString(minorNr()));
+ if (it != by_id.end())
+ setUdevData(it->second);
-DmmultipathCo::~DmmultipathCo()
-{
- y2deb("destructed multipath co " << dev);
-}
+ y2deb("constructing DmmultipathCo " << name);
+ }
-void
-DmmultipathCo::getMultipathData(const string& name)
-{
- y2mil("name:" << name);
+ DmmultipathCo::DmmultipathCo(const DmmultipathCo& c)
+ : DmPartCo(c), vendor(c.vendor), model(c.model)
+ {
+ y2deb("copy-constructed DmmultipathCo from " << c.dev);
+ }
+
- CmdMultipath::Entry entry;
- if (CmdMultipath().getEntry(name, entry))
+ DmmultipathCo::~DmmultipathCo()
{
- vendor = entry.vendor;
- model = entry.model;
+ y2deb("destructed DmMultipathCo " << dev);
+ }
+
- Pv *pv = new Pv;
- for (list<string>::const_iterator it = entry.devices.begin(); it != entry.devices.end(); ++it)
+ void
+ DmmultipathCo::getMultipathData(const string& name, SystemInfo& systeminfo)
+ {
+ CmdMultipath::Entry entry;
+ if (systeminfo.getCmdMultipath().getEntry(name, entry))
{
- pv->device = *it;
- addPv(pv);
+ vendor = entry.vendor;
+ model = entry.model;
+
+ for (list<string>::const_iterator it = entry.devices.begin(); it != entry.devices.end(); ++it)
+ {
+ Pv pv;
+ pv.device = *it;
+ addPv(pv);
+ }
}
- delete pv;
}
-}
void
@@ -162,8 +173,7 @@
{
y2mil("disk:" << nm << " id:" << id);
udev_id = id;
- udev_id.erase(remove_if(udev_id.begin(), udev_id.end(), find_begin("dm-")), udev_id.end());
- udev_id.sort();
+ udev_id.remove_if(string_starts_with("dm-"));
y2mil("id:" << udev_id);
DmPartCo::setUdevData(udev_id);
@@ -180,23 +190,25 @@
DmmultipathCo::newP( DmPart*& dm, unsigned num, Partition* p )
{
y2mil( "num:" << num );
- dm = new Dmmultipath( *this, num, p );
+ dm = new Dmmultipath( *this, getPartName(num), getPartDevice(num), num, p );
}
void
-DmmultipathCo::addPv(Pv*& p)
+ DmmultipathCo::addPv(const Pv& p)
{
- PeContainer::addPv(p);
+ PeContainer::addPv(p);
if (!deleted())
- getStorage()->setUsedBy(p->device, UB_DMMULTIPATH, name());
- p = new Pv;
+ getStorage()->setUsedBy(p.device, UB_DMMULTIPATH, device());
}
void
DmmultipathCo::activate(bool val)
{
+ if (getenv("LIBSTORAGE_NO_DMMULTIPATH") != NULL)
+ return;
+
y2mil("old active:" << active << " val:" << val);
if (active != val)
@@ -228,27 +240,20 @@
}
- bool
- DmmultipathCo::isActivated(const string& name)
- {
- SystemCmd c(DMSETUPBIN " table " + quote(name));
- return c.retcode() == 0 && c.numLines() >= 1 && isdigit(c.stdout()[0]);
- }
-
-
list<string>
- DmmultipathCo::getMultipaths()
+ DmmultipathCo::getMultipaths(SystemInfo& systeminfo)
{
list<string> l;
- list<string> entries = CmdMultipath().getEntries();
+ list<string> entries = systeminfo.getCmdMultipath().getEntries();
for (list<string>::const_iterator it = entries.begin(); it != entries.end(); ++it)
- {
- if (isActivated(*it))
+ {
+ CmdDmsetup::Entry entry;
+ if (systeminfo.getCmdDmsetup().getEntry(*it, entry) && entry.segments > 0)
l.push_back(*it);
else
y2mil("ignoring inactive dmmultipath " << *it);
- }
+ }
if (!l.empty())
active = true;
@@ -258,28 +263,6 @@
}
-string DmmultipathCo::setDiskLabelText( bool doing ) const
- {
- string txt;
- string d = nm;
- if( doing )
- {
- // displayed text during action, %1$s is replaced by multipath name (e.g. 3600508b400105f590000900000300000),
- // %2$s is replaced by label name (e.g. msdos)
- txt = sformat( _("Setting disk label of multipath disk %1$s to %2$s"),
- d.c_str(), labelName().c_str() );
- }
- else
- {
- // displayed text before action, %1$s is replaced by multipath name (e.g. 3600508b400105f590000900000300000),
- // %2$s is replaced by label name (e.g. msdos)
- txt = sformat( _("Set disk label of multipath disk %1$s to %2$s"),
- d.c_str(), labelName().c_str() );
- }
- return( txt );
- }
-
-
void DmmultipathCo::getInfo( DmmultipathCoInfo& tinfo ) const
{
DmPartCo::getInfo( info );
@@ -288,32 +271,39 @@
tinfo.model = model;
}
-namespace storage
-{
std::ostream& operator<<(std::ostream& s, const DmmultipathCo& d)
{
- s << *((DmPartCo*)&d);
+ s << dynamic_cast<const DmPartCo&>(d);
s << " Vendor:" << d.vendor
<< " Model:" << d.model;
return s;
}
-}
-string DmmultipathCo::getDiffString( const Container& d ) const
-{
- string log = DmPartCo::getDiffString(d);
- const DmmultipathCo * p = dynamic_cast<const DmmultipathCo*>(&d);
- if (p)
- {
- if (vendor != p->vendor)
- log += " vendor:" + vendor + "-->" + p->vendor;
- if (model != p->model)
- log += " model:" + model + "-->" + p->model;
+ void
+ DmmultipathCo::logDifference(std::ostream& log, const DmmultipathCo& rhs) const
+ {
+ DmPartCo::logDifference(log, rhs);
+
+ logDiff(log, "vendor", vendor, rhs.vendor);
+ logDiff(log, "model", model, rhs.model);
}
- return log;
-}
+
+
+ void
+ DmmultipathCo::logDifferenceWithVolumes(std::ostream& log, const Container& rhs_c) const
+ {
+ const DmmultipathCo& rhs = dynamic_cast<const DmmultipathCo&>(rhs_c);
+
+ logDifference(log, rhs);
+ log << endl;
+
+ ConstDmPartPair pp = dmpartPair();
+ ConstDmPartPair pc = rhs.dmpartPair();
+ logVolumesDifference(log, pp.begin(), pp.end(), pc.begin(), pc.end());
+ }
+
bool DmmultipathCo::equalContent( const Container& rhs ) const
{
@@ -327,12 +317,7 @@
return ret;
}
-DmmultipathCo::DmmultipathCo( const DmmultipathCo& rhs ) : DmPartCo(rhs)
-{
- vendor = rhs.vendor;
- model = rhs.model;
-}
-
-void DmmultipathCo::logData( const string& Dir ) {}
bool DmmultipathCo::active = false;
+
+}
Modified: branches/SuSE-Code-11-SP2-Branch/storage/libstorage/src/DmmultipathCo.h
URL: http://svn.opensuse.org/viewcvs/yast/branches/SuSE-Code-11-SP2-Branch/stora…
==============================================================================
--- branches/SuSE-Code-11-SP2-Branch/storage/libstorage/src/DmmultipathCo.h (original)
+++ branches/SuSE-Code-11-SP2-Branch/storage/libstorage/src/DmmultipathCo.h Tue May 17 13:39:44 2011
@@ -25,18 +25,14 @@
#include <list>
-#include "y2storage/DmPartCo.h"
-#include "y2storage/Dmmultipath.h"
+#include "storage/DmPartCo.h"
+#include "storage/Dmmultipath.h"
namespace storage
{
- using std::map;
-
class Storage;
-class SystemCmd;
-class ProcPart;
-class Region;
+ class SystemInfo;
class CmdMultipath
@@ -71,10 +67,9 @@
friend class Storage;
public:
- DmmultipathCo( Storage * const s, const string& Name, ProcPart& ppart );
- DmmultipathCo( Storage * const s, const string& Name, unsigned num,
- unsigned long long Size, ProcPart& ppart );
- DmmultipathCo( const DmmultipathCo& rhs );
+
+ DmmultipathCo(Storage* s, const string& name, const string& device, SystemInfo& systeminfo);
+ DmmultipathCo(const DmmultipathCo& c);
virtual ~DmmultipathCo();
static storage::CType staticType() { return storage::DMMULTIPATH; }
@@ -83,8 +78,9 @@
void setUdevData(const list<string>& id);
bool equalContent( const Container& rhs ) const;
- string getDiffString( const Container& d ) const;
- DmmultipathCo& operator= ( const DmmultipathCo& rhs );
+
+ void logDifference(std::ostream& log, const DmmultipathCo& rhs) const;
+ virtual void logDifferenceWithVolumes(std::ostream& log, const Container& rhs) const;
protected:
@@ -136,31 +132,26 @@
return( ConstDmmultipathIter( DmmultipathCPIterator( p, CheckDmmultipath, true )) );
}
- DmmultipathCo( Storage * const s, const string& File );
virtual void print( std::ostream& s ) const { s << *this; }
virtual Container* getCopy() const { return( new DmmultipathCo( *this ) ); }
- void getMultipathData( const string& name );
- void addMultipath( const string& name );
- void addPv( Pv*& p );
+ void getMultipathData(const string& name, SystemInfo& systeminfo);
+ void addPv(const Pv& pv);
void newP( DmPart*& dm, unsigned num, Partition* p );
- string setDiskLabelText( bool doing ) const;
- static string undevName( const string& name );
-
- static void activate( bool val=true );
+ static void activate(bool val);
static bool isActive() { return active; }
- static bool isActivated(const string& name);
- static list<string> getMultipaths();
-
- static bool multipathNotDeleted( const Dmmultipath&d ) { return( !d.deleted() ); }
-
- void logData( const string& Dir );
+ static list<string> getMultipaths(SystemInfo& systeminfo);
string vendor;
string model;
static bool active;
+
+ private:
+
+ DmmultipathCo& operator=(const DmmultipathCo&); // disallow
+
};
}
Modified: branches/SuSE-Code-11-SP2-Branch/storage/libstorage/src/Dmraid.cc
URL: http://svn.opensuse.org/viewcvs/yast/branches/SuSE-Code-11-SP2-Branch/stora…
==============================================================================
--- branches/SuSE-Code-11-SP2-Branch/storage/libstorage/src/Dmraid.cc (original)
+++ branches/SuSE-Code-11-SP2-Branch/storage/libstorage/src/Dmraid.cc Tue May 17 13:39:44 2011
@@ -19,41 +19,48 @@
* find current contact information at www.novell.com.
*/
-/*
- Textdomain "storage"
-*/
#include <sstream>
-#include "y2storage/Dmraid.h"
-#include "y2storage/DmraidCo.h"
-#include "y2storage/SystemCmd.h"
-#include "y2storage/AppUtil.h"
-#include "y2storage/Storage.h"
+#include "storage/Dmraid.h"
+#include "storage/DmraidCo.h"
+#include "storage/SystemCmd.h"
+#include "storage/AppUtil.h"
+#include "storage/Storage.h"
-using namespace storage;
-using namespace std;
-
-Dmraid::Dmraid(const DmraidCo& d, unsigned nr, Partition* p)
- : DmPart(d, nr, p)
+namespace storage
{
- y2mil("constructed dmraid " << dev << " on co " << cont->name());
-}
+ using namespace std;
-Dmraid::~Dmraid()
-{
- y2deb("destructed dmraid " << dev);
-}
+ Dmraid::Dmraid(const DmraidCo& c, const string& name, const string& device, unsigned nr,
+ Partition* p)
+ : DmPart(c, name, device, nr, p)
+ {
+ y2mil("constructed Dmraid " << dev << " on " << cont->device());
+ }
+
+
+ Dmraid::Dmraid(const DmraidCo& c, const Dmraid& v)
+ : DmPart(c, v)
+ {
+ y2deb("copy-constructed Dmraid from " << v.dev);
+ }
-string Dmraid::removeText( bool doing ) const
+ Dmraid::~Dmraid()
{
- string txt;
+ y2deb("destructed Dmraid " << dev);
+ }
+
+
+Text Dmraid::removeText( bool doing ) const
+ {
+ Text txt;
string d = dev.substr(12);
if( p && p->OrigNr()!=p->nr() )
- d = co()->numToName(p->OrigNr());
+ d = co()->getPartName(p->OrigNr());
if( doing )
{
// displayed text during action, %1$s is replaced by raid partition name e.g. pdc_dabaheedj_part1
@@ -69,9 +76,9 @@
return( txt );
}
-string Dmraid::createText( bool doing ) const
+Text Dmraid::createText( bool doing ) const
{
- string txt;
+ Text txt;
string d = dev.substr(12);
if( doing )
{
@@ -128,9 +135,9 @@
return( txt );
}
-string Dmraid::formatText( bool doing ) const
+Text Dmraid::formatText( bool doing ) const
{
- string txt;
+ Text txt;
string d = dev.substr(12);
if( doing )
{
@@ -185,9 +192,9 @@
return( txt );
}
-string Dmraid::resizeText( bool doing ) const
+Text Dmraid::resizeText( bool doing ) const
{
- string txt;
+ Text txt;
string d = dev.substr(12);
if( doing )
{
@@ -199,8 +206,9 @@
// displayed text during action, %1$s is replaced by raid partition e.g. pdc_dabaheedj_part1
// %2$s is replaced by size (e.g. 623.5 MB)
txt = sformat( _("Extending raid partition %1$s to %2$s"), d.c_str(), sizeString().c_str() );
+ txt += Text(" ", " ");
// text displayed during action
- txt += string(" ") + _("(progress bar might not move)");
+ txt += _("(progress bar might not move)");
}
else
{
@@ -217,9 +225,9 @@
return( txt );
}
-string Dmraid::setTypeText( bool doing ) const
+Text Dmraid::setTypeText( bool doing ) const
{
- string txt;
+ Text txt;
string d = dev.substr(12);
if( doing )
{
@@ -244,31 +252,24 @@
tinfo.p = info;
}
-namespace storage
-{
std::ostream& operator<< (std::ostream& s, const Dmraid &p )
{
- s << *(DmPart*)&p;
+ s << dynamic_cast<const DmPart&>(p);
return( s );
}
-}
bool Dmraid::equalContent( const Dmraid& rhs ) const
{
return( DmPart::equalContent(rhs) );
}
-void Dmraid::logDifference( const Dmraid& rhs ) const
+
+ void
+ Dmraid::logDifference(std::ostream& log, const Dmraid& rhs) const
{
- DmPart::logDifference(rhs);
+ DmPart::logDifference(log, rhs);
}
-
-Dmraid& Dmraid::operator=(const Dmraid& rhs)
-{
- y2deb("operator= from " << rhs.nm);
- *((DmPart*)this) = rhs;
- return *this;
}
Modified: branches/SuSE-Code-11-SP2-Branch/storage/libstorage/src/Dmraid.h
URL: http://svn.opensuse.org/viewcvs/yast/branches/SuSE-Code-11-SP2-Branch/stora…
==============================================================================
--- branches/SuSE-Code-11-SP2-Branch/storage/libstorage/src/Dmraid.h (original)
+++ branches/SuSE-Code-11-SP2-Branch/storage/libstorage/src/Dmraid.h Tue May 17 13:39:44 2011
@@ -23,7 +23,7 @@
#ifndef DMRAID_H
#define DMRAID_H
-#include "y2storage/DmPart.h"
+#include "storage/DmPart.h"
namespace storage
{
@@ -34,25 +34,34 @@
class Dmraid : public DmPart
{
public:
- Dmraid( const DmraidCo& d, unsigned nr, Partition* p=NULL );
- Dmraid( const DmraidCo& d, const Dmraid& rd );
+ Dmraid(const DmraidCo& c, const string& name, const string& device, unsigned nr,
+ Partition* p);
+ Dmraid(const DmraidCo& c, const Dmraid& v);
virtual ~Dmraid();
+
void getInfo( storage::DmraidInfo& info ) const;
friend std::ostream& operator<< (std::ostream& s, const Dmraid &p );
virtual void print( std::ostream& s ) const { s << *this; }
- string removeText( bool doing ) const;
- string createText( bool doing ) const;
- string formatText( bool doing ) const;
- string resizeText( bool doing ) const;
- string setTypeText( bool doing=true ) const;
+ Text removeText( bool doing ) const;
+ Text createText( bool doing ) const;
+ Text formatText( bool doing ) const;
+ Text resizeText( bool doing ) const;
+ Text setTypeText(bool doing) const;
bool equalContent( const Dmraid& rhs ) const;
- void logDifference( const Dmraid& d ) const;
+
+ void logDifference(std::ostream& log, const Dmraid& rhs) const;
+
static bool notDeleted( const Dmraid& l ) { return( !l.deleted() ); }
protected:
virtual const string shortPrintedName() const { return( "Dmraid" ); }
- Dmraid& operator=( const Dmraid& );
+
+ private:
+
+ Dmraid(const Dmraid&); // disallow
+ Dmraid& operator=(const Dmraid&); // disallow
+
};
}
Modified: branches/SuSE-Code-11-SP2-Branch/storage/libstorage/src/DmraidCo.cc
URL: http://svn.opensuse.org/viewcvs/yast/branches/SuSE-Code-11-SP2-Branch/stora…
==============================================================================
--- branches/SuSE-Code-11-SP2-Branch/storage/libstorage/src/DmraidCo.cc (original)
+++ branches/SuSE-Code-11-SP2-Branch/storage/libstorage/src/DmraidCo.cc Tue May 17 13:39:44 2011
@@ -19,80 +19,135 @@
* find current contact information at www.novell.com.
*/
-/*
- Textdomain "storage"
-*/
-#include <iostream>
+#include <ostream>
#include <sstream>
-#include "y2storage/DmraidCo.h"
-#include "y2storage/Dmraid.h"
-#include "y2storage/MdPartCo.h"
-#include "y2storage/SystemCmd.h"
-#include "y2storage/AppUtil.h"
-#include "y2storage/Storage.h"
-#include "y2storage/StorageDefines.h"
+#include "storage/DmraidCo.h"
+#include "storage/Dmraid.h"
+#include "storage/SystemCmd.h"
+#include "storage/AppUtil.h"
+#include "storage/Storage.h"
+#include "storage/StorageDefines.h"
+#include "storage/SystemInfo.h"
-using namespace std;
-using namespace storage;
-
-DmraidCo::DmraidCo(Storage * const s, const string& Name, ProcPart& ppart)
- : DmPartCo(s, "/dev/mapper/"+Name, staticType(), ppart)
-{
- DmPartCo::init(ppart);
- getRaidData(Name);
- y2deb("constructing dmraid co " << Name);
-}
-
-
-DmraidCo::~DmraidCo()
+namespace storage
{
- y2deb("destructed raid co " << dev);
-}
+ using namespace std;
-void DmraidCo::getRaidData( const string& name )
+ CmdDmraid::CmdDmraid()
{
- y2milestone( "name:%s", name.c_str() );
- SystemCmd c(DMRAIDBIN " -s -c -c -c " + quote(name));
- list<string>::const_iterator ci;
- list<string> sl;
- if( c.numLines()>0 )
- sl = splitString( *c.getLine(0), ":" );
- Pv *pve = new Pv;
- if( sl.size()>=4 )
- {
- ci = sl.begin();
- ++ci; ++ci; ++ci;
- raidtype = *ci;
- }
- unsigned num = 1;
- while( num<c.numLines() )
+ SystemCmd c(DMRAIDBIN " -s -c -c -c");
+ if (c.retcode() != 0 || c.stdout().empty())
+ return;
+
+ const vector<string>& lines = c.stdout();
+ vector<string>::const_iterator it = lines.begin();
+ while (it != lines.end())
{
- sl = splitString( *c.getLine(num), ":" );
- y2mil( "sl:" << sl );
- if( sl.size()>=3 )
+ const list<string> sl = splitString(*it++, ":");
+ if (sl.size() >= 4)
{
- ci = sl.begin();
- ++ci; ++ci;
- if( *ci == name )
+ Entry entry;
+
+ list<string>::const_iterator ci = sl.begin();
+ string name = *ci;
+ advance(ci, 3);
+ entry.raidtype = *ci;
+
+ while (it != lines.end() && boost::starts_with(*it, "/dev/"))
{
- --ci;
- if( controller.empty() && !ci->empty() )
- controller = *ci;
- --ci;
- if( ci->find( "/dev/" )==0 )
+ const list<string> sl = splitString(*it, ":");
+ if (sl.size() >= 4)
{
- pve->device = *ci;
- addPv( pve );
+ list<string>::const_iterator ci = sl.begin();
+ entry.devices.push_back(*ci);
+ advance(ci, 1);
+ entry.controller = *ci;
}
+
+ ++it;
}
+
+ data[name] = entry;
+ }
+ }
+
+ for (const_iterator it = data.begin(); it != data.end(); ++it)
+ y2mil("data[" << it->first << "] -> controller:" << it->second.controller <<
+ " raidtype:" << it->second.raidtype << " devices:" << it->second.devices);
+ }
+
+
+ list<string>
+ CmdDmraid::getEntries() const
+ {
+ list<string> ret;
+ for (const_iterator it = data.begin(); it != data.end(); ++it)
+ ret.push_back(it->first);
+ return ret;
+ }
+
+
+ bool
+ CmdDmraid::getEntry(const string& name, Entry& entry) const
+ {
+ const_iterator it = data.find(name);
+ if (it == data.end())
+ return false;
+
+ entry = it->second;
+ return true;
+ }
+
+
+ DmraidCo::DmraidCo(Storage* s, const string& name, const string& device, SystemInfo& systeminfo)
+ : DmPartCo(s, name, device, staticType(), systeminfo)
+ {
+ getRaidData(name, systeminfo);
+
+ const UdevMap& by_id = systeminfo.getUdevMap("/dev/disk/by-id");
+ UdevMap::const_iterator it = by_id.find("dm-" + decString(minorNr()));
+ if (it != by_id.end())
+ setUdevData(it->second);
+
+ y2deb("constructing DmraidCo " << name);
+ }
+
+
+ DmraidCo::DmraidCo(const DmraidCo& c)
+ : DmPartCo(c), raidtype(c.raidtype), controller(c.controller)
+ {
+ y2deb("copy-constructed DmraidCo from " << c.dev);
+ }
+
+
+ DmraidCo::~DmraidCo()
+ {
+ y2deb("destructed DmraidCo " << dev);
+ }
+
+
+ void
+ DmraidCo::getRaidData(const string& name, SystemInfo& systeminfo)
+ {
+ y2mil("name:" << name);
+
+ CmdDmraid::Entry entry;
+ if (systeminfo.getCmdDmraid().getEntry(name, entry))
+ {
+ controller = entry.controller;
+ raidtype = entry.raidtype;
+
+ for (list<string>::const_iterator it = entry.devices.begin(); it != entry.devices.end(); ++it)
+ {
+ Pv pv;
+ pv.device = *it;
+ addPv(pv);
}
- ++num;
}
- delete( pve );
}
@@ -101,8 +156,7 @@
{
y2mil("disk:" << nm << " id:" << id);
udev_id = id;
- udev_id.erase(remove_if(udev_id.begin(), udev_id.end(), find_begin("dm-")), udev_id.end());
- udev_id.sort();
+ udev_id.remove_if(string_starts_with("dm-"));
y2mil("id:" << udev_id);
DmPartCo::setUdevData(udev_id);
@@ -119,26 +173,32 @@
DmraidCo::newP( DmPart*& dm, unsigned num, Partition* p )
{
y2mil( "num:" << num );
- dm = new Dmraid( *this, num, p );
+ dm = new Dmraid( *this, getPartName(num), getPartDevice(num), num, p );
}
-void DmraidCo::addPv( Pv*& p )
+
+ void
+ DmraidCo::addPv(const Pv& pv)
{
- PeContainer::addPv( p );
- if( !deleted() )
- getStorage()->setUsedBy( p->device, UB_DMRAID, name() );
- p = new Pv;
+ PeContainer::addPv(pv);
+ if (!deleted())
+ getStorage()->addUsedBy(pv.device, UB_DMRAID, device());
}
+
void DmraidCo::activate( bool val )
{
- y2milestone( "old active:%d val:%d", active, val );
+ if (getenv("LIBSTORAGE_NO_DMRAID") != NULL)
+ return;
+
+ y2mil("old active:" << active << " val:" << val);
if( active != val )
{
SystemCmd c;
if( val )
{
Dm::activate(true);
+ // option '-p' since udev creates the partition nodes
c.execute(DMRAIDBIN " -ay -p");
}
else
@@ -147,53 +207,33 @@
}
active = val;
}
- }
-
-
- bool
- DmraidCo::isActivated(const string& name)
- {
- SystemCmd c(DMSETUPBIN " table " + quote(name));
- return c.retcode() == 0 && c.numLines() >= 1 && isdigit(c.stdout()[0]);
+ Storage::waitForDevice();
}
list<string>
- DmraidCo::getRaids()
+ DmraidCo::getRaids(SystemInfo& systeminfo)
{
- list<string> l;
+ list<string> l;
- SystemCmd c(DMRAIDBIN " -s -c -c -c");
- for( unsigned i=0; i<c.numLines(); ++i )
- {
- list<string> sl = splitString( *c.getLine(i), ":" );
- if( sl.size()>=3 )
- {
- list<string>::const_iterator ci = sl.begin();
- if( !ci->empty()
- && ci->find( "/dev/" )==string::npos
- && find( l.begin(), l.end(), *ci )==l.end())
- {
- if (isActivated(*ci))
- {
- l.push_back( *ci );
- }
- else
- {
- y2mil("ignoring inactive dmraid " << *ci);
- }
- }
- }
- }
+ list<string> entries = systeminfo.getCmdDmraid().getEntries();
+ for (list<string>::const_iterator it = entries.begin(); it != entries.end(); ++it)
+ {
+ CmdDmsetup::Entry entry;
+ if (systeminfo.getCmdDmsetup().getEntry(*it, entry) && entry.segments > 0)
+ l.push_back(*it);
+ else
+ y2mil("ignoring inactive dmraid " << *it);
+ }
- y2mil("detected dmraids " << l);
- return l;
+ y2mil("detected dmraids " << l);
+ return l;
}
-string DmraidCo::removeText( bool doing ) const
+Text DmraidCo::removeText( bool doing ) const
{
- string txt;
+ Text txt;
if( doing )
{
// displayed text during action, %1$s is replaced by a name (e.g. pdc_igeeeadj),
@@ -208,31 +248,10 @@
}
-string DmraidCo::setDiskLabelText( bool doing ) const
- {
- string txt;
- string d = nm;
- if( doing )
- {
- // displayed text during action, %1$s is replaced by raid name (e.g. pdc_igeeeadj),
- // %2$s is replaced by label name (e.g. msdos)
- txt = sformat( _("Setting disk label of raid %1$s to %2$s"),
- d.c_str(), labelName().c_str() );
- }
- else
- {
- // displayed text before action, %1$s is replaced by raid name (e.g. pdc_igeeeadj),
- // %2$s is replaced by label name (e.g. msdos)
- txt = sformat( _("Set disk label of raid %1$s to %2$s"),
- d.c_str(), labelName().c_str() );
- }
- return( txt );
- }
-
int
DmraidCo::doRemove()
{
- y2milestone( "Raid:%s", name().c_str() );
+ y2mil("Raid:" << name());
int ret = 0;
if( deleted() )
{
@@ -271,33 +290,40 @@
tinfo.p = info;
}
-namespace storage
-{
std::ostream& operator<< (std::ostream& s, const DmraidCo& d )
{
- s << *((DmPartCo*)&d);
+ s << dynamic_cast<const DmPartCo&>(d);
s << " Cont:" << d.controller
<< " RType:" << d.raidtype;
return( s );
}
-}
-string DmraidCo::getDiffString( const Container& d ) const
+ void
+ DmraidCo::logDifference(std::ostream& log, const DmraidCo& rhs) const
{
- string log = DmPartCo::getDiffString( d );
- const DmraidCo * p = dynamic_cast<const DmraidCo*>(&d);
- if( p )
- {
- if( controller!=p->controller )
- log += " controller:" + controller + "-->" + p->controller;
- if( raidtype!=p->raidtype )
- log += " raidtype:" + raidtype + "-->" + p->raidtype;
- }
- return( log );
+ DmPartCo::logDifference(log, rhs);
+
+ logDiff(log, "controller", controller, rhs.controller);
+ logDiff(log, "raidtype", raidtype, rhs.raidtype);
}
+
+ void
+ DmraidCo::logDifferenceWithVolumes(std::ostream& log, const Container& rhs_c) const
+ {
+ const DmraidCo& rhs = dynamic_cast<const DmraidCo&>(rhs_c);
+
+ logDifference(log, rhs);
+ log << endl;
+
+ ConstDmPartPair pp = dmpartPair();
+ ConstDmPartPair pc = rhs.dmpartPair();
+ logVolumesDifference(log, pp.begin(), pp.end(), pc.begin(), pc.end());
+ }
+
+
bool DmraidCo::equalContent( const Container& rhs ) const
{
bool ret = Container::equalContent(rhs);
@@ -310,12 +336,7 @@
return( ret );
}
-DmraidCo::DmraidCo( const DmraidCo& rhs ) : DmPartCo(rhs)
- {
- raidtype = rhs.raidtype;
- controller = rhs.controller;
- }
-
-void DmraidCo::logData( const string& Dir ) {;}
bool DmraidCo::active = false;
+
+}
Modified: branches/SuSE-Code-11-SP2-Branch/storage/libstorage/src/DmraidCo.h
URL: http://svn.opensuse.org/viewcvs/yast/branches/SuSE-Code-11-SP2-Branch/stora…
==============================================================================
--- branches/SuSE-Code-11-SP2-Branch/storage/libstorage/src/DmraidCo.h (original)
+++ branches/SuSE-Code-11-SP2-Branch/storage/libstorage/src/DmraidCo.h Tue May 17 13:39:44 2011
@@ -25,26 +25,50 @@
#include <list>
-#include "y2storage/DmPartCo.h"
-#include "y2storage/Dmraid.h"
+#include "storage/DmPartCo.h"
+#include "storage/Dmraid.h"
namespace storage
{
-
class Storage;
-class SystemCmd;
-class ProcPart;
-class Region;
+ class SystemInfo;
+
+
+ class CmdDmraid
+ {
+
+ public:
+
+ CmdDmraid();
+
+ struct Entry
+ {
+ string raidtype;
+ string controller;
+ list<string> devices;
+ };
+
+ list<string> getEntries() const;
+
+ bool getEntry(const string& name, Entry& entry) const;
+
+ private:
+
+ typedef map<string, Entry>::const_iterator const_iterator;
+
+ map<string, Entry> data;
+
+ };
+
class DmraidCo : public DmPartCo
{
friend class Storage;
public:
- DmraidCo( Storage * const s, const string& Name, ProcPart& ppart );
- DmraidCo( Storage * const s, const string& Name, unsigned num,
- unsigned long long Size, ProcPart& ppart );
- DmraidCo( const DmraidCo& rhs );
+
+ DmraidCo(Storage* s, const string& name, const string& device, SystemInfo& systeminfo);
+ DmraidCo(const DmraidCo& c);
virtual ~DmraidCo();
static storage::CType staticType() { return storage::DMRAID; }
@@ -53,8 +77,9 @@
void setUdevData(const list<string>& id);
bool equalContent( const Container& rhs ) const;
- string getDiffString( const Container& d ) const;
- DmraidCo& operator= ( const DmraidCo& rhs );
+
+ void logDifference(std::ostream& log, const DmraidCo& rhs) const;
+ virtual void logDifferenceWithVolumes(std::ostream& log, const Container& rhs) const;
protected:
@@ -106,32 +131,28 @@
return( ConstDmraidIter( DmraidCPIterator( p, CheckDmraid, true )) );
}
- DmraidCo( Storage * const s, const string& File );
virtual void print( std::ostream& s ) const { s << *this; }
virtual Container* getCopy() const { return( new DmraidCo( *this ) ); }
- static void activate( bool val );
- void getRaidData( const string& name );
- void addRaid( const string& name );
- void addPv( Pv*& p );
+ static void activate(bool val);
+ void getRaidData(const string& name, SystemInfo& systeminfo);
+ void addPv(const Pv& pv);
void newP( DmPart*& dm, unsigned num, Partition* p );
- string removeText( bool doing ) const;
- string setDiskLabelText( bool doing ) const;
- static string undevName( const string& name );
+ Text removeText( bool doing ) const;
- static bool isActivated(const string& name);
- static list<string> getRaids();
-
- static bool raidNotDeleted( const Dmraid&d ) { return( !d.deleted() ); }
+ static list<string> getRaids(SystemInfo& systeminfo);
int doRemove();
- void logData( const string& Dir );
-
string raidtype;
string controller;
- static bool active;
+ static bool active;
+
+ private:
+
+ DmraidCo& operator=(const DmraidCo&); // disallow
+
};
}
Added: branches/SuSE-Code-11-SP2-Branch/storage/libstorage/src/Enum.cc
URL: http://svn.opensuse.org/viewcvs/yast/branches/SuSE-Code-11-SP2-Branch/stora…
==============================================================================
--- branches/SuSE-Code-11-SP2-Branch/storage/libstorage/src/Enum.cc (added)
+++ branches/SuSE-Code-11-SP2-Branch/storage/libstorage/src/Enum.cc Tue May 17 13:39:44 2011
@@ -0,0 +1,136 @@
+/*
+ * Copyright (c) [2004-2010] Novell, Inc.
+ *
+ * All Rights Reserved.
+ *
+ * This program is free software; you can redistribute it and/or modify it
+ * under the terms of version 2 of the GNU General Public License as published
+ * by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
+ * more details.
+ *
+ * You should have received a copy of the GNU General Public License along
+ * with this program; if not, contact Novell, Inc.
+ *
+ * To contact Novell about this file by physical or electronic mail, you may
+ * find current contact information at www.novell.com.
+ */
+
+
+#include "storage/Enum.h"
+#include "storage/StorageTmpl.h"
+
+
+namespace storage
+{
+
+ // strings must match /etc/fstab
+ static const string fs_type_names[] = {
+ "unknown", "reiserfs", "ext2", "ext3", "ext4", "btrfs", "vfat", "xfs", "jfs", "hfs",
+ "ntfs-3g", "swap", "hfsplus", "nfs", "nfs4", "tmpfs", "none"
+ };
+
+ const vector<string> EnumInfo<FsType>::names(fs_type_names, fs_type_names +
+ lengthof(fs_type_names));
+
+
+ static const string partition_type_names[] = {
+ "primary", "extended", "logical", "any"
+ };
+
+ const vector<string> EnumInfo<PartitionType>::names(partition_type_names, partition_type_names +
+ lengthof(partition_type_names));
+
+
+ static const string mount_by_names[] = {
+ "device", "uuid", "label", "id", "path"
+ };
+
+ const vector<string> EnumInfo<MountByType>::names(mount_by_names, mount_by_names +
+ lengthof(mount_by_names));
+
+
+ static const string encrypt_names[] = {
+ "none", "twofish256", "twofish", "twofishSL92", "luks", "unknown"
+ };
+
+ const vector<string> EnumInfo<EncryptType>::names(encrypt_names, encrypt_names +
+ lengthof(encrypt_names));
+
+
+ // strings must match /proc/mdstat
+ static const string md_type_names[] = {
+ "unknown", "raid0", "raid1", "raid5", "raid6", "raid10", "multipath"
+ };
+
+ const vector<string> EnumInfo<MdType>::names(md_type_names, md_type_names +
+ lengthof(md_type_names));
+
+
+ // strings must match "mdadm --parity" option
+ static const string md_parity_names[] = {
+ "default", "left-asymmetric", "left-symmetric", "right-asymmetric", "right-symmetric",
+ "parity-first", "parity-last",
+ "left-asymmetric-6", "left-symmetric-6", "right-asymmetric-6", "right-symmetric-6",
+ "parity-first-6",
+ "n2", "o2", "f2", "n3", "o3", "f3"
+ };
+
+ const vector<string> EnumInfo<MdParity>::names(md_parity_names, md_parity_names +
+ lengthof(md_parity_names));
+
+
+ // strings must match /sys/block/md*/md/array_state
+ static const string md_array_state_names[] = {
+ "unknown", "clear", "inactive", "suspended", "readonly", "read-auto", "clean", "active",
+ "write-pending", "active-idle"
+ };
+
+ const vector<string> EnumInfo<MdArrayState>::names(md_array_state_names, md_array_state_names +
+ lengthof(md_array_state_names));
+
+
+ static const string used_by_type_names[] = {
+ "NONE", "LVM", "MD", "MDPART", "DM", "DMRAID", "DMMULTIPATH", "BTRFS"
+ };
+
+ const vector<string> EnumInfo<UsedByType>::names(used_by_type_names, used_by_type_names +
+ lengthof(used_by_type_names));
+
+
+ static const string c_type_names[] = {
+ "UNKNOWN", "DISK", "MD", "LOOP", "LVM", "DM", "DMRAID", "NFS", "DMMULTIPATH", "MDPART", "BTRFS", "TMPFS"
+ };
+
+ const vector<string> EnumInfo<CType>::names(c_type_names, c_type_names +
+ lengthof(c_type_names));
+
+
+ static const string transport_names[] = {
+ "UNKNOWN", "SBP", "ATA", "FC", "iSCSI", "SAS", "SATA", "SPI", "USB"
+ };
+
+ const vector<string> EnumInfo<Transport>::names(transport_names, transport_names +
+ lengthof(transport_names));
+
+
+ static const string imsm_driver_names[] = {
+ "UNDECIDED", "DMRAID", "MDADM"
+ };
+
+ const vector<string> EnumInfo<ImsmDriver>::names(imsm_driver_names, imsm_driver_names +
+ lengthof(imsm_driver_names));
+
+
+ // strings must match "parted --align" option
+ static const string part_align_names[] = {
+ "optimal", "cylinder"
+ };
+
+ const vector<string> EnumInfo<PartAlign>::names(part_align_names, part_align_names +
+ lengthof(part_align_names));
+
+}
Added: branches/SuSE-Code-11-SP2-Branch/storage/libstorage/src/Enum.h
URL: http://svn.opensuse.org/viewcvs/yast/branches/SuSE-Code-11-SP2-Branch/stora…
==============================================================================
--- branches/SuSE-Code-11-SP2-Branch/storage/libstorage/src/Enum.h (added)
+++ branches/SuSE-Code-11-SP2-Branch/storage/libstorage/src/Enum.h Tue May 17 13:39:44 2011
@@ -0,0 +1,108 @@
+/*
+ * Copyright (c) 2010 Novell, Inc.
+ *
+ * All Rights Reserved.
+ *
+ * This program is free software; you can redistribute it and/or modify it
+ * under the terms of version 2 of the GNU General Public License as published
+ * by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
+ * more details.
+ *
+ * You should have received a copy of the GNU General Public License along
+ * with this program; if not, contact Novell, Inc.
+ *
+ * To contact Novell about this file by physical or electronic mail, you may
+ * find current contact information at www.novell.com.
+ */
+
+
+#ifndef ENUM_H
+#define ENUM_H
+
+
+#include <assert.h>
+#include <string>
+#include <vector>
+#include <algorithm>
+
+#include "storage/StorageInterface.h"
+#include "storage/AppUtil.h"
+
+
+namespace storage
+{
+ using std::string;
+ using std::vector;
+
+
+ template <typename EnumType> struct EnumInfo {};
+
+ template <> struct EnumInfo<FsType> { static const vector<string> names; };
+ template <> struct EnumInfo<PartitionType> { static const vector<string> names; };
+ template <> struct EnumInfo<MountByType> { static const vector<string> names; };
+ template <> struct EnumInfo<EncryptType> { static const vector<string> names; };
+ template <> struct EnumInfo<MdType> { static const vector<string> names; };
+ template <> struct EnumInfo<MdParity> { static const vector<string> names; };
+ template <> struct EnumInfo<MdArrayState> { static const vector<string> names; };
+ template <> struct EnumInfo<UsedByType> { static const vector<string> names; };
+ template <> struct EnumInfo<CType> { static const vector<string> names; };
+ template <> struct EnumInfo<Transport> { static const vector<string> names; };
+ template <> struct EnumInfo<ImsmDriver> { static const vector<string> names; };
+ template <> struct EnumInfo<PartAlign> { static const vector<string> names; };
+
+
+ template <typename EnumType>
+ const string& toString(EnumType value)
+ {
+ static_assert(std::is_enum<EnumType>::value, "not enum");
+
+ const vector<string>& names = EnumInfo<EnumType>::names;
+
+ // Comparisons must not be done with type of enum since the enum may
+ // define comparison operators.
+ assert((size_t)(value) < names.size());
+
+ return names[value];
+ }
+
+
+ template <typename EnumType>
+ bool toValue(const string& str, EnumType& value, bool log_error = true)
+ {
+ static_assert(std::is_enum<EnumType>::value, "not enum");
+
+ const vector<string>& names = EnumInfo<EnumType>::names;
+
+ vector<string>::const_iterator it = find(names.begin(), names.end(), str);
+
+ if (it == names.end())
+ {
+ if (log_error)
+ y2err("converting '" << str << "' to enum failed");
+ return false;
+ }
+
+ value = EnumType(it - names.begin());
+ return true;
+ }
+
+
+ template <typename EnumType>
+ EnumType toValueWithFallback(const string& str, EnumType fallback, bool log_error = true)
+ {
+ EnumType value;
+
+ if (toValue(str, value, log_error))
+ return value;
+
+ return fallback;
+ }
+
+}
+
+
+#endif
Modified: branches/SuSE-Code-11-SP2-Branch/storage/libstorage/src/EtcFstab.cc
URL: http://svn.opensuse.org/viewcvs/yast/branches/SuSE-Code-11-SP2-Branch/stora…
==============================================================================
--- branches/SuSE-Code-11-SP2-Branch/storage/libstorage/src/EtcFstab.cc (original)
+++ branches/SuSE-Code-11-SP2-Branch/storage/libstorage/src/EtcFstab.cc Tue May 17 13:39:44 2011
@@ -1,5 +1,5 @@
/*
- * Copyright (c) [2004-2009] Novell, Inc.
+ * Copyright (c) [2004-2010] Novell, Inc.
*
* All Rights Reserved.
*
@@ -19,31 +19,31 @@
* find current contact information at www.novell.com.
*/
-// Maintainer: fehr(a)suse.de
-/*
- Textdomain "storage"
-*/
#include <fstream>
#include <algorithm>
-#include "y2storage/AppUtil.h"
-#include "y2storage/StorageTypes.h"
-#include "y2storage/AsciiFile.h"
-#include "y2storage/Regex.h"
-#include "y2storage/StorageTmpl.h"
-#include "y2storage/Volume.h"
-#include "y2storage/EtcFstab.h"
-
-using namespace storage;
-using namespace std;
-
-EtcFstab::EtcFstab( const string& pfx, bool rootMounted ) : prefix(pfx)
- {
- y2milestone( "prefix:%s rootMounted:%d", pfx.c_str(), rootMounted );
- if( rootMounted )
+#include "storage/AppUtil.h"
+#include "storage/StorageTypes.h"
+#include "storage/AsciiFile.h"
+#include "storage/Regex.h"
+#include "storage/StorageTmpl.h"
+#include "storage/Volume.h"
+#include "storage/EtcFstab.h"
+
+
+namespace storage
+{
+ using namespace std;
+
+
+EtcFstab::EtcFstab(const string& pfx, bool rootMounted)
+ : prefix(pfx)
+{
+ y2mil("prefix:" << pfx << " rootMounted:" << rootMounted);
+ if (rootMounted)
readFiles();
- }
+}
void
EtcFstab::readFiles()
@@ -72,9 +72,9 @@
{
Entry *p = new Entry;
if( i!=l.end() )
- p->old.device = p->old.dentry = *i++;
+ p->old.device = p->old.dentry = fstabDecode(*i++);
if( i!=l.end() )
- p->old.mount = *i++;
+ p->old.mount = fstabDecode(*i++);
if( i!=l.end() )
{
p->old.fs = *i++;
@@ -83,8 +83,6 @@
p->old.dmcrypt = true;
p->old.encr = ENC_LUKS;
}
- else if( p->old.fs=="ntfs-3g" )
- p->old.fs=="ntfs";
}
if( i!=l.end() )
p->old.opts = splitString( *i++, "," );
@@ -124,11 +122,9 @@
if( i!=l.end() )
{
p->old.fs = *i++;
- if( p->old.fs=="ntfs-3g" )
- p->old.fs=="ntfs";
}
if( i!=l.end() )
- p->old.encr = Volume::toEncType( *i++ );
+ p->old.encr = toValueWithFallback(*i++, ENC_UNKNOWN);
if( i!=l.end() )
p->old.opts = splitString( *i++, "," );
p->nnew = p->old;
@@ -169,22 +165,21 @@
p->old.noauto = false;
p->old.encr = ENC_LUKS;
p->old.device = *i;
- list<string>::iterator li = p->old.opts.begin();
- while( li != p->old.opts.end() )
- {
- if( *li == "noauto" || *li == "nofail" )
- li = p->old.opts.erase(li);
- else
- ++li;
- }
+ p->old.opts.remove("nofail");
++i;
if( *i != "none" )
p->old.cr_key = *i;
+ p->old.tmpcrypt = p->old.cr_key == "/dev/urandom";
++i;
if( i!=l.end() )
{
if( *i != "none" )
p->old.cr_opts = *i;
+ list<string> tls = splitString( *i, "," );
+ p->old.noauto =
+ find( tls.begin(), tls.end(), "noauto" ) != tls.end();
+ if( p->old.noauto )
+ p->old.opts.push_back("noauto");
++i;
}
p->nnew = p->old;
@@ -194,9 +189,10 @@
}
mounts.close();
- y2milestone( "entries:%zd", co.size() );
+ y2mil("entries:" << co.size());
}
+
void
FstabEntry::calcDependent()
{
@@ -205,7 +201,7 @@
noauto = find( beg, end, "noauto" ) != end;
- list<string>::const_iterator i = find_if( beg, end, find_begin("loop") );
+ list<string>::const_iterator i = find_if( beg, end, string_starts_with("loop") );
if( i!=end )
{
loop = true;
@@ -215,36 +211,52 @@
loop_dev = i->substr( pos+1 );
}
}
- i = find_if( beg, end, find_begin("encryption=") );
+ i = find_if( beg, end, string_starts_with("encryption=") );
if( i!=end )
{
string::size_type pos = i->find("=");
if( pos!=string::npos )
{
- encr = Volume::toEncType( i->substr( pos+1 ) );
+ encr = toValueWithFallback(i->substr(pos + 1), ENC_UNKNOWN);
}
}
- if( device.find( "LABEL=" )==0 )
+
+ if (boost::starts_with(device, "LABEL="))
{
- mount_by = MOUNTBY_LABEL;
- device.erase();
+ mount_by = MOUNTBY_LABEL;
+ device.erase();
}
- else if( device.find( "UUID=" )==0 )
+ else if (boost::starts_with(device, "UUID="))
{
- mount_by = MOUNTBY_UUID;
- device.erase();
+ mount_by = MOUNTBY_UUID;
+ device.erase();
}
- else if( device.substr(0, 16) == "/dev/disk/by-id/" )
+ else if (boost::starts_with(device, "/dev/disk/by-id/"))
{
- mount_by = MOUNTBY_ID;
+ mount_by = MOUNTBY_ID;
}
- else if( device.substr(0, 18) == "/dev/disk/by-path/" )
+ else if (boost::starts_with(device, "/dev/disk/by-path/"))
{
- mount_by = MOUNTBY_PATH;
+ mount_by = MOUNTBY_PATH;
+ }
+ else if (boost::starts_with(device, "/dev/disk/by-label/"))
+ {
+ mount_by = MOUNTBY_LABEL;
+ }
+ else if (boost::starts_with(device, "/dev/disk/by-uuid/"))
+ {
+ mount_by = MOUNTBY_UUID;
}
+
dmcrypt = encr==ENC_LUKS;
- cryptotab = !noauto && encr!=ENC_NONE && !dmcrypt;
- crypttab = !noauto && dmcrypt;
+ cryptotab = encr!=ENC_NONE && !dmcrypt;
+ crypttab = dmcrypt;
+ }
+
+bool
+FstabEntry::optUser() const
+ {
+ return find( opts.begin(), opts.end(), "user" ) != opts.end();
}
bool
@@ -283,7 +295,7 @@
int EtcFstab::changeRootPrefix( const string& prfix )
{
- y2milestone( "new prefix:%s", prfix.c_str() );
+ y2mil("new prefix:" << prfix);
int ret = 0;
if( prfix != prefix )
{
@@ -311,58 +323,86 @@
i->nnew.device = i->old.device = device;
}
-bool
-EtcFstab::findUuidLabel( const string& uuid, const string& label,
- FstabEntry& entry ) const
- {
- y2milestone( "uuid:%s label:%s", uuid.c_str(), label.c_str() );
- list<Entry>::const_iterator i = co.end();
- if( !uuid.empty() )
- {
- string dev = "UUID=" + uuid;
- i = co.begin();
- while( i!=co.end() && i->nnew.dentry != dev )
- ++i;
+
+ bool
+ EtcFstab::findUuidLabel(const string& uuid, const string& label,
+ FstabEntry& entry) const
+ {
+ y2mil("uuid:" << uuid << " label:" << label);
+ list<Entry>::const_iterator i = co.end();
+ if (!uuid.empty())
+ {
+ string dentry = "UUID=" + uuid;
+ i = co.begin();
+ while (i != co.end() && i->nnew.dentry != dentry)
+ ++i;
}
- if( i==co.end() && !label.empty() )
+ if (i == co.end() && !uuid.empty())
{
- string dev = "LABEL=" + label;
- i = co.begin();
- while( i!=co.end() && i->nnew.dentry != dev )
- ++i;
+ string dentry = "/dev/disk/by-uuid/" + uuid;
+ i = co.begin();
+ while (i != co.end() && i->nnew.dentry != dentry)
+ ++i;
}
- if( i!=co.end())
- entry = i->nnew;
- y2mil("ret:" << (i != co.end()));
- return i != co.end();
+ if (i == co.end() && !label.empty())
+ {
+ string dentry = "LABEL=" + label;
+ i = co.begin();
+ while (i != co.end() && i->nnew.dentry != dentry)
+ ++i;
+ }
+ if (i == co.end() && !label.empty())
+ {
+ string dentry = "/dev/disk/by-label/" + udevEncode(label);
+ i = co.begin();
+ while (i != co.end() && i->nnew.dentry != dentry)
+ ++i;
+ }
+ if (i != co.end())
+ entry = i->nnew;
+ y2mil("ret:" << (i != co.end()));
+ return i != co.end();
}
-bool
-EtcFstab::findIdPath( const std::list<string>& id, const string& path,
- FstabEntry& entry ) const
+
+ bool
+ EtcFstab::findIdPath(const list<string>& id, const string& path, FstabEntry& entry ) const
{
- y2mil( "id:" << id << " path:" << path );
- list<Entry>::const_iterator i = co.begin();
- if( !id.empty() )
+ y2mil("id:" << id << " path:" << path);
+ list<Entry>::const_iterator i = co.end();
+
+ if (!id.empty())
{
- while( i!=co.end() &&
- find( id.begin(), id.end(), i->nnew.dentry )==id.end() )
- ++i;
+ for (list<string>::const_iterator j = id.begin(); j != id.end(); ++j)
+ {
+ const string full = "/dev/disk/by-id/" + *j;
+
+ i = co.begin();
+ while(i != co.end() && i->nnew.dentry != full)
+ ++i;
+
+ if (i != co.end())
+ break;
+ }
}
- else
- i = co.end();
- if( i==co.end() && !path.empty() )
+
+ if (i == co.end() && !path.empty())
{
- i = co.begin();
- while( i!=co.end() && i->nnew.dentry != path )
- ++i;
+ const string full = "/dev/disk/by-path/" + path;
+
+ i = co.begin();
+ while(i != co.end() && i->nnew.dentry != full)
+ ++i;
}
- if( i!=co.end())
- entry = i->nnew;
- y2mil("ret:" << (i != co.end()));
- return( i!=co.end() );
+
+ bool ret = i != co.end();
+ if (ret)
+ entry = i->nnew;
+ y2mil("ret:" << ret);
+ return ret;
}
+
int EtcFstab::removeEntry( const FstabEntry& entry )
{
y2mil("dentry:" << entry.dentry << " mount:" << entry.mount);
@@ -407,7 +447,7 @@
int EtcFstab::addEntry( const FstabChange& entry )
{
- y2mil("dentry:" << entry.dentry << " mount:" << entry.mount);
+ y2mil("dentry:" << entry.dentry << " mount:" << entry.mount);
Entry e;
e.op = Entry::ADD;
e.nnew = entry;
@@ -419,78 +459,78 @@
AsciiFile* EtcFstab::findFile( const FstabEntry& e, AsciiFile*& fstab,
AsciiFile*& cryptotab, int& lineno ) const
{
- y2mil("dentry:" << e.dentry << " mount:" << e.mount << " fstab:" << fstab <<
- " cryptotab:" << cryptotab);
+ y2mil("dentry:" << e.dentry << " mount:" << e.mount << " fstab:" << fstab <<
+ " cryptotab:" << cryptotab);
AsciiFile* ret=NULL;
- Regex *fi = NULL;
+ string reg;
if( e.cryptotab )
{
if( cryptotab==NULL )
- cryptotab = new AsciiFile( prefix + "/cryptotab" );
+ cryptotab = new AsciiFile( prefix + "/cryptotab", true );
ret = cryptotab;
- fi = new Regex( "[ \t]" + e.dentry + "[ \t]" );
+ reg = "[ \t]" + boost::replace_all_copy(fstabEncode(e.dentry), "\\", "\\\\") + "[ \t]";
}
else
{
if( fstab==NULL )
fstab = new AsciiFile( prefix + "/fstab" );
ret = fstab;
- fi = new Regex( "^[ \t]*" + e.dentry + "[ \t]" );
+ reg = "^[ \t]*" + boost::replace_all_copy(fstabEncode(e.dentry), "\\", "\\\\") + "[ \t]";
}
- lineno = ret->find( 0, *fi );
- delete fi;
- y2milestone( "fstab:%p cryptotab:%p lineno:%d", fstab, cryptotab, lineno );
+ if( e.dentry != "tmpfs" )
+ lineno = ret->find_if_idx(regex_matches(reg));
+ else
+ {
+ reg = "[ \t]+" + boost::replace_all_copy(fstabEncode(e.mount), "\\", "\\\\") + "[ \t]";
+ lineno = ret->find_if_idx(regex_matches(reg));
+ }
+ y2mil("fstab:" << fstab << " cryptotab:" << cryptotab << " lineno:" << lineno);
return( ret );
}
int EtcFstab::findPrefix( const AsciiFile& tab, const string& mount ) const
{
- bool crypto = tab.fileName().find( "/cryptotab" )!=string::npos;
- y2mil("file:" << tab.fileName() << " mount:" << mount << " crypto:" << crypto);
+ bool crypto = tab.name().find( "/cryptotab" )!=string::npos;
+ y2mil("file:" << tab.name() << " mount:" << mount << " crypto:" << crypto);
string reg = "^[ \t]*[^ \t]+";
if( crypto )
reg += "[ \t]+[^ \t]+";
reg += "[ \t]+" + mount;
if( mount.length()>0 && mount[mount.length()-1] != '/' )
reg += "/";
- Regex *fi = new Regex( reg );
- int lineno = tab.find( 0, *fi );
- delete fi;
- y2milestone( "reg:%s lineno:%d", reg.c_str(), lineno );
+ int lineno = tab.find_if_idx(regex_matches(reg));
+ y2mil("reg:" << reg << " lineno:" << lineno);
return( lineno );
}
bool EtcFstab::findCrtab( const FstabEntry& e, const AsciiFile& tab,
int& lineno ) const
{
- y2milestone( "dev:%s", e.device.c_str() );
+ y2mil("dev:" << e.device);
string reg = "^[ \t]*[^ \t]+[ \t]+" + e.device + "[ \t]";
- Regex fi( reg );
- lineno = tab.find( 0, fi );
+ lineno = tab.find_if_idx(regex_matches(reg));
if( lineno<0 )
{
reg = "^[ \t]*" + e.dentry + "[ \t]";
- Regex fil( reg );
- lineno = tab.find( 0, fil );
+ lineno = tab.find_if_idx(regex_matches(reg));
}
- y2milestone( "reg:%s lineno:%d", reg.c_str(), lineno );
+ y2mil("reg:" << reg << " lineno:" << lineno);
return( lineno>=0 );
}
bool EtcFstab::findCrtab( const string& dev, const AsciiFile& tab,
int& lineno ) const
{
- y2milestone( "dev:%s", dev.c_str() );
+ y2mil("dev:" << dev.c_str());
string reg = "^[ \t]*[^ \t]+[ \t]+" + dev + "[ \t]";
- Regex fi( reg );
- lineno = tab.find( 0, fi );
- y2milestone( "reg:%s lineno:%d", reg.c_str(), lineno );
+ lineno = tab.find_if_idx(regex_matches(reg));
+ y2mil("reg:" << reg << " lineno:" << lineno);
return( lineno>=0 );
}
-list<string> EtcFstab::makeStringList(const FstabEntry& e) const
+static list<string> makeStringList(const FstabEntry& e)
{
- list<string> ls;
+ list<string> ls;
if( e.cryptotab )
{
ls.push_back( e.loop_dev );
@@ -506,10 +546,10 @@
ls.push_back( (e.fs!="ntfs")?e.fs:"ntfs-3g" );
if( e.cryptotab )
{
- ls.push_back( Volume::encTypeString(e.encr) );
+ ls.push_back(toString(e.encr));
}
- ls.push_back( mergeString( e.opts, "," ) );
- if( e.dmcrypt && e.mount!="swap" )
+ ls.push_back( boost::join( e.opts, "," ) );
+ if( e.dmcrypt && e.mount!="swap" )
{
if( find( e.opts.begin(), e.opts.end(), "nofail" )==e.opts.end() )
{
@@ -524,11 +564,11 @@
ls.push_back( decString(e.freq) );
ls.push_back( decString(e.passno) );
}
- return ls;
+ return ls;
}
string EtcFstab::createLine( const list<string>& ls, unsigned fields,
- unsigned* flen ) const
+ const unsigned* flen ) const
{
string ret;
unsigned count=0;
@@ -536,7 +576,7 @@
{
if( i != ls.begin() )
ret += " ";
- ret += *i;
+ ret += fstabEncode(*i);
if( count<fields && i->size()<flen[count] )
{
ret.replace( ret.size(), 0, flen[count]-i->size(), ' ' );
@@ -551,30 +591,31 @@
{
y2mil("dentry:" << e.dentry << " mount:" << e.mount << " device:" << e.device);
const list<string> ls = makeStringList(e);
- y2mil( "list:" << ls );
unsigned max_fields = e.cryptotab ? lengthof(cryptotabFields)
: lengthof(fstabFields);
- unsigned* fields = e.cryptotab ? cryptotabFields : fstabFields;
+ const unsigned* fields = e.cryptotab ? cryptotabFields : fstabFields;
return createLine(ls, max_fields, fields);
}
-list<string> EtcFstab::makeCrStringList(const FstabEntry& e) const
+static list<string> makeCrStringList(const FstabEntry& e)
{
- list<string> ls;
+ list<string> ls;
ls.push_back( e.dentry.substr(e.dentry.rfind( '/' )+1) );
string tmp = e.device;
ls.push_back( tmp );
tmp = e.cr_key;
if( e.tmpcrypt )
tmp = "/dev/urandom";
+ if( !e.tmpcrypt && tmp=="/dev/urandom" )
+ tmp.clear();
ls.push_back( tmp.empty()?"none":tmp );
tmp = e.cr_opts;
list<string>::iterator i;
list<string> tls = splitString( tmp );
- if( e.mount=="swap" &&
+ if( e.mount=="swap" && e.tmpcrypt &&
find( tls.begin(), tls.end(), "swap" )==tls.end() )
tls.push_back("swap");
- else if( e.mount!="swap" &&
+ else if( (e.mount!="swap"||!e.tmpcrypt) &&
(i=find( tls.begin(), tls.end(), "swap" ))!=tls.end() )
tls.erase(i);
bool need_tmp = e.tmpcrypt && e.mount!="swap";
@@ -582,48 +623,52 @@
tls.push_back("tmp");
else if( !need_tmp && (i=find( tls.begin(), tls.end(), "tmp" ))!=tls.end() )
tls.erase(i);
- tmp = mergeString( tls, "," );
+ if( !e.noauto && (i=find( tls.begin(), tls.end(), "noauto" ))!=tls.end() )
+ tls.erase(i);
+ else if( e.noauto && (i=find( tls.begin(), tls.end(), "noauto" ))==tls.end() )
+ tls.push_back("noauto");
+ tmp = boost::join( tls, "," );
ls.push_back( tmp.empty()?"none":tmp );
return ls;
}
string EtcFstab::createCrtabLine( const FstabEntry& e ) const
{
- y2mil("dentry:" << e.dentry << " mount:" << e.mount << " device:" << e.device);
- const list<string> ls = makeCrStringList(e);
- return createLine(ls, lengthof(crypttabFields), crypttabFields);
+ y2mil("dentry:" << e.dentry << " mount:" << e.mount << " device:" << e.device);
+ const list<string> ls = makeCrStringList(e);
+ return createLine(ls, lengthof(crypttabFields), crypttabFields);
}
-void EtcFstab::getFileBasedLoops( const string& prefix, list<FstabEntry>& l ) const
+
+void
+EtcFstab::getFileBasedLoops(const string& prefix, list<FstabEntry>& l) const
{
l.clear();
- list<Entry>::const_iterator i = co.begin();
- while( i!=co.end() )
+ for (list<Entry>::const_iterator i = co.begin(); i != co.end(); ++i)
{
- if( i->op==Entry::NONE )
+ if (i->op == Entry::NONE)
{
string lfile = prefix + i->old.device;
- if( checkNormalFile( lfile ))
- l.push_back( i->old );
+ if (checkNormalFile(lfile))
+ l.push_back(i->old);
}
- ++i;
}
}
-void EtcFstab::getEntries( list<FstabEntry>& l ) const
+
+list<FstabEntry>
+EtcFstab::getEntries() const
{
- l.clear();
- list<Entry>::const_iterator i = co.begin();
- while( i!=co.end() )
+ list<FstabEntry> ret;
+ for (list<Entry>::const_iterator i = co.begin(); i != co.end(); ++i)
{
- if( i->op==Entry::NONE )
- {
- l.push_back( i->old );
- }
- ++i;
+ if (i->op == Entry::NONE)
+ ret.push_back(i->old);
}
+ return ret;
}
+
string EtcFstab::updateLine( const list<string>& ol,
const list<string>& nl, const string& oldline ) const
{
@@ -669,38 +714,36 @@
return( line );
}
-static void printFile( const string& fname )
- {
- y2mil( "name:" << fname );
- ifstream file( fname.c_str() );
- classic(file);
- string line;
- int count = 1;
- getline( file, line );
- while( file.good() )
- {
- y2mil( "line:" << count++ << " \"" << line << "\"" );
- getline( file, line );
- }
- file.close();
+void EtcFstab::updateTabLine( list<string>(*fnc)(const FstabEntry&),
+ const FstabEntry& old, const FstabEntry& nnew,
+ string& line ) const
+ {
+ const list<string> nl = (*fnc)(nnew);
+ const list<string> ol = (*fnc)(old);
+ y2mil( "old line:" << line );
+ line = updateLine( ol, nl, line );
+ y2mil( "new line:" << line );
}
int EtcFstab::flush()
{
int ret = 0;
- list<Entry>::iterator i = co.begin();
AsciiFile *fstab = NULL;
AsciiFile *cryptotab = NULL;
AsciiFile *cur = NULL;
- AsciiFile crypttab( prefix + "/crypttab" );
- int lineno;
- if( i!=co.end() && !checkDir( prefix ) )
+ AsciiFile crypttab( prefix + "/crypttab", true );
+ if (!co.empty() && !checkDir(prefix))
createPath( prefix );
+
+ list<Entry>::iterator i = co.begin();
while( i!=co.end() && ret==0 )
{
switch( i->op )
{
case Entry::REMOVE:
+ {
+ y2mil( "REMOVE:" << i->old.device );
+ int lineno;
cur = findFile( i->old, fstab, cryptotab, lineno );
if( lineno>=0 )
{
@@ -718,8 +761,12 @@
ret = FSTAB_REMOVE_ENTRY_NOT_FOUND;
}
i = co.erase( i );
- break;
+ } break;
+
case Entry::UPDATE:
+ {
+ y2mil( "UPDATE:" << i->nnew.device );
+ int lineno;
cur = findFile( i->old, fstab, cryptotab, lineno );
if( lineno<0 )
cur = findFile( i->nnew, fstab, cryptotab, lineno );
@@ -735,11 +782,9 @@
}
else if( !i->nnew.mount.empty() )
{
- line = (*cur)[lineno];
- const list<string> nl = makeStringList(i->nnew);
- const list<string> ol = makeStringList(i->old);
- line = updateLine( ol, nl, line );
- (*cur)[lineno] = line;
+ y2mil( "lineno:" << lineno );
+ updateTabLine( makeStringList,
+ i->old, i->nnew, (*cur)[lineno] );
}
else
{
@@ -754,11 +799,9 @@
if( findCrtab( i->old, crypttab, lineno ) ||
findCrtab( i->nnew, crypttab, lineno ))
{
- line = crypttab[lineno];
- const list<string> nl = makeCrStringList(i->nnew);
- const list<string> ol = makeCrStringList(i->old);
- line = updateLine( ol, nl, line );
- crypttab[lineno] = line;
+ y2mil( "lineno:" << lineno );
+ updateTabLine( makeCrStringList,
+ i->old, i->nnew, crypttab[lineno] );
}
else
crypttab.append( line );
@@ -768,18 +811,27 @@
}
else if( findCrtab( i->nnew, crypttab, lineno ))
{
+ int oldln;
string line = createTabLine( i->nnew );
if (!i->nnew.mount.empty())
fstab->append( line );
if( i->old.crypttab > i->nnew.crypttab &&
- findCrtab( i->old, crypttab, lineno ))
- crypttab.remove( lineno, 1 );
+ findCrtab( i->old, crypttab, oldln ))
+ crypttab.remove( oldln, 1 );
+ else if( i->nnew.crypttab )
+ {
+ updateTabLine( makeCrStringList,
+ i->old, i->nnew, crypttab[oldln] );
+ }
}
else
ret = FSTAB_UPDATE_ENTRY_NOT_FOUND;
- break;
+ } break;
+
case Entry::ADD:
{
+ int lineno;
+ y2mil( "ADD:" << i->nnew.device );
cur = findFile( i->nnew, fstab, cryptotab, lineno );
string line = createTabLine( i->nnew );
string before_dev;
@@ -793,10 +845,10 @@
cur->insert( lineno, line );
}
else
- {
+ {
if (!i->nnew.mount.empty())
cur->append( line );
- }
+ }
}
else
{
@@ -822,8 +874,8 @@
}
i->old = i->nnew;
i->op = Entry::NONE;
- }
- break;
+ } break;
+
default:
break;
}
@@ -831,28 +883,29 @@
}
if( fstab != NULL )
{
- fstab->updateFile();
+ fstab->save();
delete( fstab );
}
if( cryptotab != NULL )
{
- if( !cryptotab->removeIfEmpty() )
- cryptotab->updateFile();
+ cryptotab->save();
delete( cryptotab );
}
- if( !crypttab.removeIfEmpty() )
- crypttab.updateFile();
- printFile( prefix + "/fstab" );
- printFile( prefix + "/cryptotab" );
- printFile( prefix + "/crypttab" );
+ if( true )
+ {
+ crypttab.save();
+ }
+ AsciiFile(prefix + "/fstab").logContent();
+ AsciiFile(prefix + "/cryptotab").logContent();
+ AsciiFile(prefix + "/crypttab").logContent();
y2mil("ret:" << ret);
return( ret );
}
-string EtcFstab::addText( bool doing, bool crypto, const string& mp ) const
+Text EtcFstab::addText( bool doing, bool crypto, const string& mp ) const
{
const char* file = crypto?"/etc/cryptotab":"/etc/fstab";
- string txt;
+ Text txt;
if( doing )
{
// displayed text during action, %1$s is replaced by mount point e.g. /home
@@ -870,10 +923,10 @@
return( txt );
}
-string EtcFstab::updateText( bool doing, bool crypto, const string& mp ) const
+Text EtcFstab::updateText( bool doing, bool crypto, const string& mp ) const
{
const char* file = crypto?"/etc/cryptotab":"/etc/fstab";
- string txt;
+ Text txt;
if( doing )
{
// displayed text during action, %1$s is replaced by mount point e.g. /home
@@ -891,10 +944,10 @@
return( txt );
}
-string EtcFstab::removeText( bool doing, bool crypto, const string& mp ) const
+Text EtcFstab::removeText( bool doing, bool crypto, const string& mp ) const
{
const char* file = crypto?"/etc/cryptotab":"/etc/fstab";
- string txt;
+ Text txt;
if( doing )
{
// displayed text during action, %1$s is replaced by mount point e.g. /home
@@ -912,13 +965,88 @@
return( txt );
}
-bool
-FstabEntry::optUser() const
+
+ FstabEntry& FstabEntry::operator=(const FstabChange& rhs)
{
- return find( opts.begin(), opts.end(), "user" ) != opts.end();
+ device = rhs.device; dentry = rhs.dentry; mount = rhs.mount;
+ fs = rhs.fs; opts = rhs.opts; freq = rhs.freq; passno = rhs.passno;
+ loop_dev = rhs.loop_dev; encr = rhs.encr; tmpcrypt = rhs.tmpcrypt;
+ calcDependent();
+ return *this;
+ }
+
+
+ FstabChange& FstabChange::operator=(const FstabEntry& rhs)
+ {
+ device = rhs.device; dentry = rhs.dentry; mount = rhs.mount;
+ fs = rhs.fs; opts = rhs.opts; freq = rhs.freq; passno = rhs.passno;
+ loop_dev = rhs.loop_dev; encr = rhs.encr; tmpcrypt = rhs.tmpcrypt;
+ return *this;
}
-unsigned EtcFstab::fstabFields[] = { 20, 20, 10, 21, 1, 1 };
-unsigned EtcFstab::cryptotabFields[] = { 11, 15, 20, 10, 10, 1 };
-unsigned EtcFstab::crypttabFields[] = { 15, 20, 10, 1 };
+ std::ostream& operator<<(std::ostream& s, const FstabEntry& v)
+ {
+ s << "device:" << v.device
+ << " dentry:" << v.dentry << " mount:" << v.mount
+ << " fs:" << v.fs << " opts:" << boost::join(v.opts, ",")
+ << " freq:" << v.freq << " passno:" << v.passno;
+ if( v.noauto )
+ s << " noauto";
+ if( v.cryptotab )
+ s << " cryptotab";
+ if( v.crypttab )
+ s << " crypttab";
+ if( v.tmpcrypt )
+ s << " tmpcrypt";
+ if( v.loop )
+ s << " loop";
+ if( v.dmcrypt )
+ s << " dmcrypt";
+ if( !v.loop_dev.empty() )
+ s << " loop_dev:" << v.loop_dev;
+ if( !v.cr_key.empty() )
+ s << " cr_key:" << v.cr_key;
+ if( !v.cr_opts.empty() )
+ s << " cr_opts:" << v.cr_opts;
+ if( v.encr != storage::ENC_NONE )
+ s << " encr:" << toString(v.encr);
+ return s;
+ }
+
+
+ std::ostream& operator<<(std::ostream& s, const FstabChange& v)
+ {
+ s << "device:" << v.device
+ << " dentry:" << v.dentry << " mount:" << v.mount
+ << " fs:" << v.fs << " opts:" << boost::join(v.opts, ",")
+ << " freq:" << v.freq << " passno:" << v.passno;
+ if( !v.loop_dev.empty() )
+ s << " loop_dev:" << v.loop_dev;
+ if( v.encr != storage::ENC_NONE )
+ s << " encr:" << toString(v.encr);
+ if( v.tmpcrypt )
+ s << " tmpcrypt";
+ return s;
+ }
+
+
+ string
+ EtcFstab::fstabEncode(const string& s)
+ {
+ return boost::replace_all_copy(s, " ", "\\040");
+ }
+
+
+ string
+ EtcFstab::fstabDecode(const string& s)
+ {
+ return boost::replace_all_copy(s, "\\040", " ");
+ }
+
+
+ const unsigned EtcFstab::fstabFields[] = { 20, 20, 10, 21, 1, 1 };
+ const unsigned EtcFstab::cryptotabFields[] = { 11, 15, 20, 10, 10, 1 };
+ const unsigned EtcFstab::crypttabFields[] = { 15, 20, 10, 1 };
+
+}
Modified: branches/SuSE-Code-11-SP2-Branch/storage/libstorage/src/EtcFstab.h
URL: http://svn.opensuse.org/viewcvs/yast/branches/SuSE-Code-11-SP2-Branch/stora…
==============================================================================
--- branches/SuSE-Code-11-SP2-Branch/storage/libstorage/src/EtcFstab.h (original)
+++ branches/SuSE-Code-11-SP2-Branch/storage/libstorage/src/EtcFstab.h Tue May 17 13:39:44 2011
@@ -1,5 +1,5 @@
/*
- * Copyright (c) [2004-2009] Novell, Inc.
+ * Copyright (c) [2004-2010] Novell, Inc.
*
* All Rights Reserved.
*
@@ -25,12 +25,17 @@
#include <string>
#include <list>
-#include <map>
+#include <boost/algorithm/string.hpp>
+
+#include "storage/StorageInterface.h"
+#include "storage/AppUtil.h"
-#include "y2storage/StorageInterface.h"
namespace storage
{
+ using std::string;
+ using std::list;
+
class AsciiFile;
struct FstabChange;
@@ -41,7 +46,9 @@
cryptotab(false), crypttab(false), tmpcrypt(false), encr(ENC_NONE),
mount_by(MOUNTBY_DEVICE) {}
- FstabEntry& operator=( const FstabChange& rhs );
+ explicit FstabEntry(const FstabChange& change) { *this = change; }
+
+ FstabEntry& operator=(const FstabChange& rhs);
friend std::ostream& operator<< (std::ostream& s, const FstabEntry &v );
@@ -68,50 +75,14 @@
bool optUser() const;
};
-inline std::ostream& operator<< (std::ostream& s, const FstabEntry &v )
- {
- s << "device:" << v.device
- << " dentry:" << v.dentry << " mount:" << v.mount
- << " fs:" << v.fs << " opts:" << mergeString( v.opts, "," )
- << " freq:" << v.freq << " passno:" << v.passno;
- if( v.noauto )
- s << " noauto";
- if( v.cryptotab )
- s << " cryptotab";
- if( v.crypttab )
- s << " crypttab";
- if( v.tmpcrypt )
- s << " tmpcrypt";
- if( v.loop )
- s << " loop";
- if( v.dmcrypt )
- s << " dmcrypt";
- if( !v.loop_dev.empty() )
- s << " loop_dev:" << v.loop_dev;
- if( !v.cr_key.empty() )
- s << " cr_key:" << v.cr_key;
- if( !v.cr_opts.empty() )
- s << " cr_opts:" << v.cr_opts;
- if( v.encr != storage::ENC_NONE )
- s << " encr:" << v.encr;
- return( s );
- }
struct FstabChange
{
FstabChange() : freq(0), passno(0), encr(ENC_NONE), tmpcrypt(false) {}
- FstabChange( const FstabEntry& e ) { *this = e; }
+ explicit FstabChange(const FstabEntry& entry) { *this = entry; }
- FstabChange& operator=( const FstabEntry& rhs )
- {
- device = rhs.device;
- dentry = rhs.dentry; mount = rhs.mount; fs = rhs.fs;
- opts = rhs.opts; freq = rhs.freq; passno = rhs.passno;
- loop_dev = rhs.loop_dev; encr = rhs.encr;
- tmpcrypt = rhs.tmpcrypt;
- return( *this );
- }
+ FstabChange& operator=(const FstabEntry& rhs);
friend std::ostream& operator<< (std::ostream& s, const FstabChange &v );
@@ -127,31 +98,6 @@
bool tmpcrypt;
};
-inline FstabEntry& FstabEntry::operator=( const FstabChange& rhs )
- {
- device = rhs.device;
- dentry = rhs.dentry; mount = rhs.mount; fs = rhs.fs;
- opts = rhs.opts; freq = rhs.freq; passno = rhs.passno;
- loop_dev = rhs.loop_dev; encr = rhs.encr;
- tmpcrypt = rhs.tmpcrypt;
- calcDependent();
- return( *this );
- }
-
-inline std::ostream& operator<< (std::ostream& s, const FstabChange &v )
- {
- s << "device:" << v.device
- << " dentry:" << v.dentry << " mount:" << v.mount
- << " fs:" << v.fs << " opts:" << mergeString( v.opts, "," )
- << " freq:" << v.freq << " passno:" << v.passno;
- if( !v.loop_dev.empty() )
- s << " loop_dev:" << v.loop_dev;
- if( v.encr != storage::ENC_NONE )
- s << " encr:" << v.encr;
- if( v.tmpcrypt )
- s << " tmpcrypt";
- return( s );
- }
class EtcFstab
{
@@ -160,24 +106,22 @@
bool findDevice( const string& dev, FstabEntry& entry ) const;
bool findDevice( const std::list<string>& dl, FstabEntry& entry ) const;
bool findMount( const string& mount, FstabEntry& entry ) const;
+ bool findMount( const string& mount ) const
+ { FstabEntry e; return( findMount( mount,e )); }
bool findUuidLabel( const string& uuid, const string& label,
FstabEntry& entry ) const;
- bool findIdPath( const std::list<string>& id, const string& path,
- FstabEntry& entry ) const;
+ bool findIdPath(const list<string>& id, const string& path, FstabEntry& entry) const;
void setDevice( const FstabEntry& entry, const string& device );
- int updateEntry( const string& dev, const string& mount,
- const string& fs, const string& opts="defaults" );
int updateEntry( const FstabChange& entry );
int addEntry( const FstabChange& entry );
int removeEntry( const FstabEntry& entry );
int changeRootPrefix( const string& prfix );
void getFileBasedLoops( const string& prefix, std::list<FstabEntry>& l ) const;
- void getEntries( std::list<FstabEntry>& l ) const;
- string addText( bool doing, bool crypto, const string& mp ) const;
- string updateText( bool doing, bool crypto, const string& mp ) const;
- string removeText( bool doing, bool crypto, const string& mp ) const;
+ list<FstabEntry> getEntries() const;
+ Text addText( bool doing, bool crypto, const string& mp ) const;
+ Text updateText( bool doing, bool crypto, const string& mp ) const;
+ Text removeText( bool doing, bool crypto, const string& mp ) const;
int flush();
- int findPrefix( const AsciiFile& tab, const string& mount ) const;
protected:
struct Entry
@@ -191,27 +135,33 @@
void readFiles();
+ int findPrefix( const AsciiFile& tab, const string& mount ) const;
+
AsciiFile* findFile( const FstabEntry& e, AsciiFile*& fstab,
AsciiFile*& cryptotab, int& lineno ) const;
+
bool findCrtab( const FstabEntry& e, const AsciiFile& crtab,
int& lineno ) const;
bool findCrtab( const string& device, const AsciiFile& crtab,
int& lineno ) const;
- list<string> makeStringList(const FstabEntry& e) const;
- list<string> makeCrStringList(const FstabEntry& e) const;
-
string updateLine( const std::list<string>& ol,
const std::list<string>& nl, const string& line ) const;
string createLine( const std::list<string>& ls, unsigned fields,
- unsigned* flen ) const;
+ const unsigned* flen ) const;
string createTabLine( const FstabEntry& e ) const;
string createCrtabLine( const FstabEntry& e ) const;
-
- static unsigned fstabFields[6];
- static unsigned cryptotabFields[6];
- static unsigned crypttabFields[6];
+ void updateTabLine( list<string>(*fnc)(const FstabEntry& e),
+ const FstabEntry& old, const FstabEntry& nnew,
+ string& line ) const;
+
+ static string fstabEncode(const string&);
+ static string fstabDecode(const string&);
+
+ static const unsigned fstabFields[6];
+ static const unsigned cryptotabFields[6];
+ static const unsigned crypttabFields[6];
string prefix;
std::list<Entry> co;
Added: branches/SuSE-Code-11-SP2-Branch/storage/libstorage/src/EtcMdadm.cc
URL: http://svn.opensuse.org/viewcvs/yast/branches/SuSE-Code-11-SP2-Branch/stora…
==============================================================================
--- branches/SuSE-Code-11-SP2-Branch/storage/libstorage/src/EtcMdadm.cc (added)
+++ branches/SuSE-Code-11-SP2-Branch/storage/libstorage/src/EtcMdadm.cc Tue May 17 13:39:44 2011
@@ -0,0 +1,203 @@
+/*
+ * Copyright (c) [2004-2010] Novell, Inc.
+ *
+ * All Rights Reserved.
+ *
+ * This program is free software; you can redistribute it and/or modify it
+ * under the terms of version 2 of the GNU General Public License as published
+ * by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
+ * more details.
+ *
+ * You should have received a copy of the GNU General Public License along
+ * with this program; if not, contact Novell, Inc.
+ *
+ * To contact Novell about this file by physical or electronic mail, you may
+ * find current contact information at www.novell.com.
+ */
+
+
+#include "storage/AppUtil.h"
+#include "storage/EtcMdadm.h"
+#include "storage/AsciiFile.h"
+#include "storage/StorageTypes.h"
+
+
+namespace storage
+{
+ using namespace std;
+
+
+ EtcMdadm::EtcMdadm(const Storage* sto, const string& prefix)
+ : sto(sto), mdadm(prefix + "/etc/mdadm.conf")
+ {
+ }
+
+
+ bool
+ EtcMdadm::updateEntry(const mdconf_info& info)
+ {
+ y2mil("uuid:" << info.uuid << " device:" << info.device);
+
+ if (info.uuid.empty())
+ {
+ y2err("empty UUID " << info);
+ return false;
+ }
+
+ if (info.container_present && info.container_uuid.empty())
+ {
+ y2err("empty UUID for container " << info);
+ return false;
+ }
+
+ if (info.container_present)
+ setArrayLine(ContLine(info), info.container_uuid);
+
+ setArrayLine(ArrayLine(info), info.uuid);
+
+ setDeviceLine("DEVICE containers partitions");
+
+ if (sto->hasIScsiDisks())
+ setAutoLine("AUTO -all");
+
+ mdadm.save();
+
+ return true;
+ }
+
+
+ bool
+ EtcMdadm::removeEntry(const string& uuid)
+ {
+ y2mil("uuid:" << uuid);
+
+ if (uuid.empty())
+ {
+ y2err("empty UUID");
+ return false;
+ }
+
+ vector<string>& lines = mdadm.lines();
+ vector<string>::iterator it = findArray(uuid);
+ if (it == lines.end())
+ {
+ y2war("line not found");
+ return false;
+ }
+
+ lines.erase(it);
+
+ mdadm.save();
+
+ return true;
+ }
+
+
+ void
+ EtcMdadm::setDeviceLine(const string& line)
+ {
+ vector<string>& lines = mdadm.lines();
+ vector<string>::iterator it = find_if(lines, string_starts_with("DEVICE"));
+ if (it == lines.end())
+ lines.insert(lines.begin(), line);
+ else
+ *it = line;
+ }
+
+
+ void
+ EtcMdadm::setAutoLine(const string& line)
+ {
+ vector<string>& lines = mdadm.lines();
+ vector<string>::iterator it = find_if(lines, string_starts_with("AUTO"));
+ if (it == lines.end())
+ lines.insert(lines.begin(), line);
+ else
+ *it = line;
+ }
+
+
+ void
+ EtcMdadm::setArrayLine(const string& line, const string& uuid)
+ {
+ vector<string>& lines = mdadm.lines();
+ vector<string>::iterator it = findArray(uuid);
+ if (it == lines.end())
+ lines.push_back(line);
+ else
+ *it = line;
+ }
+
+
+ string
+ EtcMdadm::ContLine(const mdconf_info& info) const
+ {
+ string line = "ARRAY";
+ line += " metadata=" + info.container_metadata;
+ line += " UUID=" + info.container_uuid;
+ return line;
+ }
+
+
+ string
+ EtcMdadm::ArrayLine(const mdconf_info& info) const
+ {
+ string line = "ARRAY " + info.device;
+ if (info.container_present)
+ {
+ line += " container=" + info.container_uuid;
+ line += " member=" + info.container_member;
+ }
+ line += " UUID=" + info.uuid;
+ return line;
+ }
+
+
+ vector<string>::iterator
+ EtcMdadm::findArray(const string& uuid)
+ {
+ vector<string>& lines = mdadm.lines();
+ for (vector<string>::iterator it = lines.begin(); it != lines.end(); ++it)
+ {
+ if (boost::starts_with(*it, "ARRAY"))
+ {
+ string tmp = getUuid(*it);
+ if (!tmp.empty() && tmp == uuid)
+ return it;
+ }
+ }
+
+ return lines.end();
+ }
+
+
+ string
+ EtcMdadm::getUuid(const string& line) const
+ {
+ string::size_type pos1 = line.find("UUID=");
+ if (pos1 == string::npos)
+ return "";
+
+ pos1 += 5;
+ string::size_type pos2 = line.find_first_not_of("0123456789abcdefABCDEF:", pos1);
+ return line.substr(pos1, pos2 - pos1);
+ }
+
+
+ std::ostream& operator<<(std::ostream& s, const EtcMdadm::mdconf_info& info)
+ {
+ s << "device:" << info.device << " uuid:" << info.uuid;
+
+ if (info.container_present)
+ {
+ s << " container_present container_uuid:" << info.container_uuid << " container_member:"
+ << info.container_member << " container_metadata:" << info.container_metadata;
+ }
+
+ return s;
+ }
+}
Added: branches/SuSE-Code-11-SP2-Branch/storage/libstorage/src/EtcMdadm.h
URL: http://svn.opensuse.org/viewcvs/yast/branches/SuSE-Code-11-SP2-Branch/stora…
==============================================================================
--- branches/SuSE-Code-11-SP2-Branch/storage/libstorage/src/EtcMdadm.h (added)
+++ branches/SuSE-Code-11-SP2-Branch/storage/libstorage/src/EtcMdadm.h Tue May 17 13:39:44 2011
@@ -0,0 +1,90 @@
+/*
+ * Copyright (c) [2004-2010] Novell, Inc.
+ *
+ * All Rights Reserved.
+ *
+ * This program is free software; you can redistribute it and/or modify it
+ * under the terms of version 2 of the GNU General Public License as published
+ * by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
+ * more details.
+ *
+ * You should have received a copy of the GNU General Public License along
+ * with this program; if not, contact Novell, Inc.
+ *
+ * To contact Novell about this file by physical or electronic mail, you may
+ * find current contact information at www.novell.com.
+ */
+
+
+#ifndef ETC_MDADM_H
+#define ETC_MDADM_H
+
+#include <string>
+#include <map>
+
+#include "storage/AsciiFile.h"
+#include "storage/Storage.h"
+
+
+namespace storage
+{
+
+ class EtcMdadm
+ {
+
+ public:
+
+ EtcMdadm(const Storage* sto, const string& prefix = "");
+
+ // From this structure line 'ARRAY' will be build in config file.
+ // Not all fields are mandatory
+ // If container is present then container line will be build
+ // before volume line.
+ struct mdconf_info
+ {
+ mdconf_info() : container_present(false) {}
+
+ string device;
+ string uuid;
+
+ bool container_present;
+
+ /* following members only valid if container_present is true */
+ string container_member;
+ string container_metadata;
+ string container_uuid;
+
+ friend std::ostream& operator<<(std::ostream& s, const mdconf_info& info);
+ };
+
+ bool updateEntry(const mdconf_info& info);
+
+ bool removeEntry(const string& uuid);
+
+ protected:
+
+ void setDeviceLine(const string& line);
+ void setAutoLine(const string& line);
+ void setArrayLine(const string& line, const string& uuid);
+
+ string ContLine(const mdconf_info& info) const;
+ string ArrayLine(const mdconf_info& info) const;
+
+ vector<string>::iterator findArray(const string& uuid);
+
+ string getUuid(const string& line) const;
+
+ const Storage* sto;
+
+ AsciiFile mdadm;
+
+ };
+
+}
+
+
+#endif
Modified: branches/SuSE-Code-11-SP2-Branch/storage/libstorage/src/FilterIterator.h
URL: http://svn.opensuse.org/viewcvs/yast/branches/SuSE-Code-11-SP2-Branch/stora…
==============================================================================
--- branches/SuSE-Code-11-SP2-Branch/storage/libstorage/src/FilterIterator.h (original)
+++ branches/SuSE-Code-11-SP2-Branch/storage/libstorage/src/FilterIterator.h Tue May 17 13:39:44 2011
@@ -23,8 +23,8 @@
#ifndef FILTER_ITERATOR_H
#define FILTER_ITERATOR_H
-#include "y2storage/AppUtil.h"
-#include "y2storage/IterPair.h"
+#include "storage/AppUtil.h"
+#include "storage/IterPair.h"
namespace storage
{
@@ -42,7 +42,8 @@
FilterIterator() { }
- FilterIterator( const Iter& begin, const Iter& end, Pred f, bool setend=false ) :
+ template<class It>
+ FilterIterator( const It& begin, const It& end, Pred f, bool setend=false ) :
m_begin(begin), m_end(end), m_cur(begin), m_f(f)
{
initialize( setend );
@@ -103,11 +104,13 @@
{
return( &(*m_cur) );
}
- bool operator==(const FilterIterator& x) const
+ template <class Other>
+ bool operator==(const Other& x) const
{
return( m_cur == x.cur() );
}
- bool operator!=(const FilterIterator& x) const
+ template <class Other>
+ bool operator!=(const Other& x) const
{
return( m_cur != x.cur() );
}
@@ -117,7 +120,7 @@
Iter cur() const {return m_cur;}
Iter begin() const {return m_begin;}
- private:
+ protected:
Iter m_begin;
Iter m_end;
Iter m_cur;
@@ -139,7 +142,6 @@
m_f = x.pred();
}
-
void assertPred( bool forward=true )
{
if( forward )
Added: branches/SuSE-Code-11-SP2-Branch/storage/libstorage/src/FreeInfo.cc
URL: http://svn.opensuse.org/viewcvs/yast/branches/SuSE-Code-11-SP2-Branch/stora…
==============================================================================
--- branches/SuSE-Code-11-SP2-Branch/storage/libstorage/src/FreeInfo.cc (added)
+++ branches/SuSE-Code-11-SP2-Branch/storage/libstorage/src/FreeInfo.cc Tue May 17 13:39:44 2011
@@ -0,0 +1,237 @@
+/*
+ * Copyright (c) [2004-2010] Novell, Inc.
+ *
+ * All Rights Reserved.
+ *
+ * This program is free software; you can redistribute it and/or modify it
+ * under the terms of version 2 of the GNU General Public License as published
+ * by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
+ * more details.
+ *
+ * You should have received a copy of the GNU General Public License along
+ * with this program; if not, contact Novell, Inc.
+ *
+ * To contact Novell about this file by physical or electronic mail, you may
+ * find current contact information at www.novell.com.
+ */
+
+
+#include <glob.h>
+
+#include "storage/FreeInfo.h"
+#include "storage/Volume.h"
+#include "storage/SystemCmd.h"
+
+
+namespace storage
+{
+
+ FreeInfo::FreeInfo(const xmlNode* node)
+ : resize_cached(false), content_cached(false)
+ {
+ if (getChildValue(node, "resize_cached", resize_cached) && resize_cached)
+ {
+ getChildValue(node, "df_free_k", resize_info.df_freeK);
+ getChildValue(node, "resize_free_k", resize_info.resize_freeK);
+ getChildValue(node, "used_k", resize_info.usedK);
+ getChildValue(node, "resize_ok", resize_info.resize_ok);
+ }
+
+ if (getChildValue(node, "content_cached", content_cached) && content_cached)
+ {
+ getChildValue(node, "windows", content_info.windows);
+ getChildValue(node, "efi", content_info.efi);
+ getChildValue(node, "homes", content_info.homes);
+ }
+ }
+
+
+ void
+ FreeInfo::saveData(xmlNode* node) const
+ {
+ if (resize_cached)
+ {
+ setChildValue(node, "resize_cached", resize_cached);
+
+ setChildValue(node, "df_free_k", resize_info.df_freeK);
+ setChildValue(node, "resize_free_k", resize_info.resize_freeK);
+ setChildValue(node, "used_k", resize_info.usedK);
+ setChildValue(node, "resize_ok", resize_info.resize_ok);
+ }
+
+ if (content_cached)
+ {
+ setChildValue(node, "content_cached", content_cached);
+
+ setChildValue(node, "windows", content_info.windows);
+ setChildValue(node, "efi", content_info.efi);
+ setChildValue(node, "homes", content_info.homes);
+ }
+ }
+
+
+ void
+ FreeInfo::update(bool new_resize_cached, const ResizeInfo& new_resize_info,
+ bool new_content_cached, const ContentInfo& new_content_info)
+ {
+ if (new_resize_cached)
+ {
+ resize_cached = true;
+ resize_info = new_resize_info;
+ }
+
+ if (new_content_cached)
+ {
+ content_cached = true;
+ content_info = new_content_info;
+ }
+ }
+
+
+ bool
+ FreeInfo::isWindows(const string& mp)
+ {
+ const char* files[] = { "boot.ini", "msdos.sys", "io.sys", "config.sys", "MSDOS.SYS",
+ "IO.SYS", "bootmgr", "$Boot" };
+
+ for (unsigned int i = 0; i < lengthof(files); ++i)
+ {
+ string file = mp + "/" + files[i];
+ if (access(file.c_str(), R_OK) == 0)
+ {
+ y2mil("found windows file " << quote(file));
+ return true;
+ }
+ }
+
+ return false;
+ }
+
+
+ unsigned
+ FreeInfo::numHomes(const string& mp)
+ {
+ const char* files[] = { ".profile", ".bashrc", ".ssh", ".kde", ".kde4", ".gnome",
+ ".gnome2" };
+
+ unsigned num = 0;
+
+ const list<string> dirs = glob(mp + "/*", GLOB_NOSORT | GLOB_ONLYDIR);
+ for (list<string>::const_iterator dir = dirs.begin(); dir != dirs.end(); ++dir)
+ {
+ if (*dir != "root" && checkDir(*dir))
+ {
+ for (unsigned int i = 0; i < lengthof(files); ++i)
+ {
+ string file = *dir + "/" + files[i];
+ if (access(file.c_str(), R_OK) == 0)
+ {
+ y2mil("found home file " << quote(file));
+ ++num;
+ break;
+ }
+ }
+ }
+
+ if (num >= 2)
+ return num;
+ }
+
+ return num;
+ }
+
+
+ std::ostream& operator<<(std::ostream& s, const ResizeInfo& resize_info)
+ {
+ return s << "df_freeK:" << resize_info.df_freeK << " resize_freeK:" << resize_info.resize_freeK
+ << " usedK:" << resize_info.usedK << " resize_ok:" << resize_info.resize_ok;
+ }
+
+
+ std::ostream& operator<<(std::ostream& s, const ContentInfo& content_info)
+ {
+ return s << "windows:" << content_info.windows << " efi:" << content_info.efi
+ << " homes:" << content_info.homes;
+ }
+
+
+ std::ostream& operator<<(std::ostream& s, const FreeInfo& free_info)
+ {
+ s << "resize_cached:" << free_info.resize_cached;
+ if (free_info.resize_cached)
+ s << " resize_info " << free_info.resize_info;
+
+ s << "content_cached:" << free_info.content_cached;
+ if (free_info.content_cached)
+ s << " content_info " << free_info.content_info;
+
+ return s;
+ }
+
+
+ ResizeInfo
+ FreeInfo::detectResizeInfo(const string& mp, const Volume& vol)
+ {
+ ResizeInfo resize_info;
+
+ StatVfs vfsbuf;
+ bool ret = getStatVfs(mp, vfsbuf);
+ if (ret)
+ {
+ resize_info.df_freeK = vfsbuf.freeK;
+ resize_info.usedK = vfsbuf.sizeK - vfsbuf.freeK;
+ resize_info.resize_freeK = resize_info.df_freeK;
+ resize_info.resize_ok = true;
+ }
+
+ if (ret && vol.getFs() == NTFS)
+ {
+ SystemCmd c("/usr/sbin/ntfsresize -f -i " + quote(vol.device()));
+ string fstr = " might resize at ";
+ string::size_type pos;
+ string stdout = boost::join(c.stdout(), "\n");
+ if (c.retcode()==0 && (pos=stdout.find(fstr))!=string::npos)
+ {
+ y2mil("pos:" << pos);
+ pos = stdout.find_first_not_of(" \t\n", pos + fstr.size());
+ y2mil("pos:" << pos);
+ string number = stdout.substr(pos, stdout.find_first_not_of("0123456789", pos));
+ y2mil("number:\"" << number << "\"");
+ unsigned long long t;
+ number >> t;
+ y2mil("number:" << t);
+ if (t - vol.sizeK() < resize_info.resize_freeK)
+ resize_info.resize_freeK = t - vol.sizeK();
+ }
+ else
+ {
+ resize_info.resize_ok = false;
+ }
+ }
+
+ y2mil("device:" << vol.device() << " " << resize_info);
+ return resize_info;
+ }
+
+
+ ContentInfo
+ FreeInfo::detectContentInfo(const string& mp, const Volume& vol)
+ {
+ ContentInfo content_info;
+
+ content_info.efi = vol.getFs() == VFAT && checkDir(mp + "/efi");
+
+ if (!content_info.efi && (vol.getFs() == VFAT || vol.getFs() == NTFS))
+ content_info.windows = isWindows(mp);
+
+ content_info.homes = numHomes(mp);
+
+ y2mil("device:" << vol.device() << " " << content_info);
+ return content_info;
+ }
+
+}
Added: branches/SuSE-Code-11-SP2-Branch/storage/libstorage/src/FreeInfo.h
URL: http://svn.opensuse.org/viewcvs/yast/branches/SuSE-Code-11-SP2-Branch/stora…
==============================================================================
--- branches/SuSE-Code-11-SP2-Branch/storage/libstorage/src/FreeInfo.h (added)
+++ branches/SuSE-Code-11-SP2-Branch/storage/libstorage/src/FreeInfo.h Tue May 17 13:39:44 2011
@@ -0,0 +1,77 @@
+/*
+ * Copyright (c) [2004-2010] Novell, Inc.
+ *
+ * All Rights Reserved.
+ *
+ * This program is free software; you can redistribute it and/or modify it
+ * under the terms of version 2 of the GNU General Public License as published
+ * by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
+ * more details.
+ *
+ * You should have received a copy of the GNU General Public License along
+ * with this program; if not, contact Novell, Inc.
+ *
+ * To contact Novell about this file by physical or electronic mail, you may
+ * find current contact information at www.novell.com.
+ */
+
+
+#ifndef FREE_INFO_H
+#define FREE_INFO_H
+
+#include <ostream>
+
+#include "storage/StorageInterface.h"
+#include "storage/XmlFile.h"
+
+
+namespace storage
+{
+ class Volume;
+
+
+ class FreeInfo
+ {
+
+ public:
+
+ FreeInfo(bool resize_cached, const ResizeInfo& resize_info,
+ bool content_cached, const ContentInfo& content_info)
+ : resize_cached(resize_cached), resize_info(resize_info),
+ content_cached(content_cached), content_info(content_info) {}
+
+ FreeInfo(const xmlNode* node);
+
+ void saveData(xmlNode* node) const;
+
+ bool resize_cached;
+ ResizeInfo resize_info;
+
+ bool content_cached;
+ ContentInfo content_info;
+
+ void update(bool resize_cached, const ResizeInfo& resize_info,
+ bool content_cached, const ContentInfo& content_info);
+
+ static ResizeInfo detectResizeInfo(const string& mp, const Volume& vol);
+ static ContentInfo detectContentInfo(const string& mp, const Volume& vol);
+
+ protected:
+
+ static bool isWindows(const string& mp);
+ static unsigned numHomes(const string& mp);
+
+ };
+
+ std::ostream& operator<<(std::ostream& s, const ResizeInfo& resize_info);
+ std::ostream& operator<<(std::ostream& s, const ContentInfo& content_info);
+ std::ostream& operator<<(std::ostream& s, const FreeInfo& free_info);
+
+}
+
+
+#endif
Added: branches/SuSE-Code-11-SP2-Branch/storage/libstorage/src/Geometry.cc
URL: http://svn.opensuse.org/viewcvs/yast/branches/SuSE-Code-11-SP2-Branch/stora…
==============================================================================
--- branches/SuSE-Code-11-SP2-Branch/storage/libstorage/src/Geometry.cc (added)
+++ branches/SuSE-Code-11-SP2-Branch/storage/libstorage/src/Geometry.cc Tue May 17 13:39:44 2011
@@ -0,0 +1,208 @@
+/*
+ * Copyright (c) [2004-2010] Novell, Inc.
+ *
+ * All Rights Reserved.
+ *
+ * This program is free software; you can redistribute it and/or modify it
+ * under the terms of version 2 of the GNU General Public License as published
+ * by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
+ * more details.
+ *
+ * You should have received a copy of the GNU General Public License along
+ * with this program; if not, contact Novell, Inc.
+ *
+ * To contact Novell about this file by physical or electronic mail, you may
+ * find current contact information at www.novell.com.
+ */
+
+
+#include <fcntl.h>
+#include <sys/types.h>
+#include <sys/stat.h>
+#include <sys/mount.h>
+#include <linux/hdreg.h>
+
+#include "storage/AppUtil.h"
+#include "storage/SystemCmd.h"
+#include "storage/StorageDefines.h"
+#include "storage/Parted.h"
+#include "storage/Enum.h"
+#include "storage/Partition.h"
+
+
+namespace storage
+{
+ using namespace std;
+
+
+ Geometry::Geometry()
+ : cylinders(0), heads(32), sectors(16), sector_size(512)
+ {
+ }
+
+
+ unsigned long long
+ Geometry::sizeK() const
+ {
+ return (unsigned long long)(cylinders) * cylinderSize() / 1024;
+ }
+
+
+ unsigned long
+ Geometry::cylinderSize() const
+ {
+ return heads * sectors * sector_size;
+ }
+
+ unsigned long
+ Geometry::headSize() const
+ {
+ return sectors * sector_size;
+ }
+
+
+ unsigned long long
+ Geometry::cylinderToKb(unsigned long cylinder) const
+ {
+ const unsigned long long cyl_size = cylinderSize();
+
+ return cyl_size * cylinder / 1024;
+ }
+
+
+ unsigned long
+ Geometry::kbToCylinder(unsigned long long kb) const
+ {
+ const unsigned long long cyl_size = cylinderSize();
+
+ unsigned long long bytes = kb * 1024;
+ bytes += cyl_size - 1;
+ return bytes / cyl_size;
+ }
+
+
+ unsigned long long
+ Geometry::sectorToKb(unsigned long long sector) const
+ {
+ // TODO use 128 arithmetic
+ return sector * sector_size / 1024;
+ }
+
+
+ unsigned long long
+ Geometry::kbToSector(unsigned long long kb) const
+ {
+ // TODO use 128 arithmetic
+ return kb * 1024 / sector_size;
+ }
+
+
+ bool
+ Geometry::operator==(const Geometry& rhs) const
+ {
+ return cylinders == rhs.cylinders && heads == rhs.heads && sectors == rhs.sectors &&
+ sector_size == rhs.sector_size;
+ }
+
+
+ std::ostream& operator<<(std::ostream& s, const Geometry& geo)
+ {
+ return s << "[" << geo.cylinders << "," << geo.heads << "," << geo.sectors << ","
+ << geo.sector_size << "]";
+ }
+
+
+ bool
+ getChildValue(const xmlNode* node, const char* name, Geometry& value)
+ {
+ const xmlNode* tmp = getChildNode(node, name);
+ if (!tmp)
+ return false;
+
+ getChildValue(tmp, "cylinders", value.cylinders);
+ getChildValue(tmp, "heads", value.heads);
+ getChildValue(tmp, "sectors", value.sectors);
+
+ if (!getChildValue(tmp, "sector_size", value.sector_size))
+ value.sector_size = 512;
+
+ return true;
+ }
+
+
+ void
+ setChildValue(xmlNode* node, const char* name, const Geometry& value)
+ {
+ xmlNode* tmp = xmlNewChild(node, name);
+
+ setChildValue(tmp, "cylinders", value.cylinders);
+ setChildValue(tmp, "heads", value.heads);
+ setChildValue(tmp, "sectors", value.sectors);
+
+ if (value.sector_size != 512)
+ setChildValue(tmp, "sector_size", value.sector_size);
+ }
+
+
+ bool
+ detectGeometry(const string& device, Geometry& geo)
+ {
+ y2mil("device:" << device);
+
+ bool ret = false;
+
+ int fd = open(device.c_str(), O_RDONLY);
+ if (fd >= 0)
+ {
+ int rcode = ioctl(fd, BLKSSZGET, &geo.sector_size);
+ y2mil("BLKSSZGET rcode:" << rcode << " sector_size:" << geo.sector_size);
+
+ geo.cylinders = 16;
+ geo.heads = 255;
+ geo.sectors = 63;
+
+ struct hd_geometry hd_geo;
+ rcode = ioctl(fd, HDIO_GETGEO, &hd_geo);
+ y2mil("HDIO_GETGEO rcode:" << rcode << " cylinders:" << (unsigned) hd_geo.cylinders <<
+ " heads:" << (unsigned) hd_geo.heads << " sectors:" << (unsigned) hd_geo.sectors);
+ if (rcode == 0)
+ {
+ geo.cylinders = hd_geo.cylinders > 0 ? hd_geo.cylinders : geo.cylinders;
+ geo.heads = hd_geo.heads > 0 ? hd_geo.heads : geo.heads;
+ geo.sectors = hd_geo.sectors > 0 ? hd_geo.sectors : geo.sectors;
+ }
+
+ uint64_t bytes = 0;
+ rcode = ioctl(fd, BLKGETSIZE64, &bytes);
+ y2mil("BLKGETSIZE64 rcode:" << rcode << " bytes:" << bytes);
+ if (rcode == 0 && bytes != 0)
+ {
+ geo.cylinders = bytes / (uint64_t)(geo.cylinderSize());
+ y2mil("calc cylinders:" << geo.cylinders);
+ ret = true;
+ }
+ else
+ {
+ unsigned long blocks;
+ rcode = ioctl(fd, BLKGETSIZE, &blocks);
+ y2mil("BLKGETSIZE rcode:" << rcode << " blocks:" << blocks);
+ if (rcode == 0 && blocks != 0)
+ {
+ geo.cylinders = (uint64_t)(blocks) * 512 / (uint64_t)(geo.cylinderSize());
+ y2mil("calc cylinders:" << geo.cylinders);
+ ret = true;
+ }
+ }
+
+ close(fd);
+ }
+
+ y2mil("device:" << device << " ret:" << ret << " geo:" << geo);
+ return ret;
+ }
+
+}
Added: branches/SuSE-Code-11-SP2-Branch/storage/libstorage/src/Geometry.h
URL: http://svn.opensuse.org/viewcvs/yast/branches/SuSE-Code-11-SP2-Branch/stora…
==============================================================================
--- branches/SuSE-Code-11-SP2-Branch/storage/libstorage/src/Geometry.h (added)
+++ branches/SuSE-Code-11-SP2-Branch/storage/libstorage/src/Geometry.h Tue May 17 13:39:44 2011
@@ -0,0 +1,67 @@
+/*
+ * Copyright (c) [2004-2010] Novell, Inc.
+ *
+ * All Rights Reserved.
+ *
+ * This program is free software; you can redistribute it and/or modify it
+ * under the terms of version 2 of the GNU General Public License as published
+ * by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
+ * more details.
+ *
+ * You should have received a copy of the GNU General Public License along
+ * with this program; if not, contact Novell, Inc.
+ *
+ * To contact Novell about this file by physical or electronic mail, you may
+ * find current contact information at www.novell.com.
+ */
+
+
+#ifndef GEOMETRY_H
+#define GEOMETRY_H
+
+#include "storage/XmlFile.h"
+
+
+namespace storage
+{
+
+ struct Geometry
+ {
+ Geometry();
+
+ unsigned long cylinders;
+ unsigned int heads;
+ unsigned int sectors;
+ unsigned int sector_size;
+
+ unsigned long long sizeK() const;
+
+ unsigned long cylinderSize() const;
+ unsigned long headSize() const;
+
+ unsigned long long cylinderToKb(unsigned long cylinder) const;
+ unsigned long kbToCylinder(unsigned long long kb) const;
+
+ unsigned long long sectorToKb(unsigned long long sector) const;
+ unsigned long long kbToSector(unsigned long long kb) const;
+
+ bool operator==(const Geometry& rhs) const;
+ bool operator!=(const Geometry& rhs) const { return !(*this == rhs); }
+
+ friend std::ostream& operator<<(std::ostream& s, const Geometry& geo);
+
+ friend bool getChildValue(const xmlNode* node, const char* name, Geometry& value);
+ friend void setChildValue(xmlNode* node, const char* name, const Geometry& value);
+ };
+
+
+ bool detectGeometry(const string& device, Geometry& geometry);
+
+}
+
+
+#endif
Added: branches/SuSE-Code-11-SP2-Branch/storage/libstorage/src/Graph.cc
URL: http://svn.opensuse.org/viewcvs/yast/branches/SuSE-Code-11-SP2-Branch/stora…
==============================================================================
--- branches/SuSE-Code-11-SP2-Branch/storage/libstorage/src/Graph.cc (added)
+++ branches/SuSE-Code-11-SP2-Branch/storage/libstorage/src/Graph.cc Tue May 17 13:39:44 2011
@@ -0,0 +1,609 @@
+/*
+ * Copyright (c) [2004-2010] Novell, Inc.
+ *
+ * All Rights Reserved.
+ *
+ * This program is free software; you can redistribute it and/or modify it
+ * under the terms of version 2 of the GNU General Public License as published
+ * by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
+ * more details.
+ *
+ * You should have received a copy of the GNU General Public License along
+ * with this program; if not, contact Novell, Inc.
+ *
+ * To contact Novell about this file by physical or electronic mail, you may
+ * find current contact information at www.novell.com.
+ */
+
+
+#include <string>
+#include <fstream>
+#include <boost/algorithm/string.hpp>
+
+#include "config.h"
+#include "storage/Graph.h"
+#include "storage/AppUtil.h"
+#include "storage/HumanString.h"
+#include "storage/StorageInterface.h"
+
+
+namespace storage
+{
+ using namespace std;
+
+
+ class Graph
+ {
+
+ public:
+
+ bool save(const string& filename) const;
+
+ protected:
+
+ enum NodeType { NODE_DISK, NODE_DMMULTIPATH, NODE_DMRAID, NODE_PARTITION, NODE_MD, NODE_MDPART,
+ NODE_LVMVG, NODE_LVMLV, NODE_DM, NODE_BTRFS, NODE_MOUNTPOINT };
+
+ struct Node
+ {
+ Node(NodeType type, const string& device, const string& label, unsigned long long sizeK)
+ : type(type), device(device), label(label), sizeK(sizeK) {}
+
+ string id() const { return (type == NODE_MOUNTPOINT ? "mountpoint:" : "device:") + device; }
+
+ NodeType type;
+ string device;
+ string label;
+ unsigned long long sizeK;
+ };
+
+ enum EdgeType { EDGE_SUBDEVICE, EDGE_MOUNT, EDGE_USED };
+
+ struct Edge
+ {
+ Edge(EdgeType type, const string& id1, const string& id2)
+ : type(type), id1(id1), id2(id2) {}
+
+ EdgeType type;
+ string id1;
+ string id2;
+ };
+
+ enum RankType { RANK_SOURCE, RANK_SAME, RANK_SINK };
+
+ struct Rank
+ {
+ Rank(RankType type = RANK_SAME)
+ : type(type) {}
+
+ RankType type;
+ list<string> ids;
+ };
+
+ friend ostream& operator<<(ostream& s, const Node& node);
+ friend ostream& operator<<(ostream& s, const Edge& edge);
+ friend ostream& operator<<(ostream& s, const Rank& rank);
+
+ list<Node> nodes;
+ list<Edge> edges;
+ list<Rank> ranks;
+
+ private:
+
+ static string quote(const string& str);
+ static string makeTooltip(const Text& text, const string& label, unsigned long long sizeK);
+
+ };
+
+
+ class DeviceGraph : public Graph
+ {
+
+ public:
+
+ DeviceGraph(StorageInterface* s);
+
+ private:
+
+ Rank disks_rank;
+ Rank partitions_rank;
+ Rank mounts_rank;
+
+ void processUsedby(const Node& node, const list<UsedByInfo>& usedBy);
+ void processMount(const Node& node, const VolumeInfo& volume);
+
+ };
+
+
+ class MountGraph : public Graph
+ {
+
+ public:
+
+ MountGraph(StorageInterface* s);
+
+ private:
+
+ map<int, Rank> mount_ranks;
+
+ typedef map<string, string> Entries;
+
+ Entries entries;
+
+ Entries::const_iterator findParent(const Entries::const_iterator& child) const;
+
+ };
+
+
+ DeviceGraph::DeviceGraph(StorageInterface* s)
+ : disks_rank(RANK_SOURCE), partitions_rank(), mounts_rank(RANK_SINK)
+ {
+ deque<ContainerInfo> containers;
+ s->getContainers(containers);
+ for (deque<ContainerInfo>::const_iterator i1 = containers.begin(); i1 != containers.end(); ++i1)
+ {
+ switch (i1->type)
+ {
+ case DISK: {
+
+ DiskInfo diskinfo;
+ s->getDiskInfo(i1->device, diskinfo);
+
+ Node disk_node(NODE_DISK, i1->device, i1->name, diskinfo.sizeK);
+ nodes.push_back(disk_node);
+ disks_rank.ids.push_back(disk_node.id());
+
+ processUsedby(disk_node, i1->usedBy);
+
+ deque<PartitionInfo> partitions;
+ s->getPartitionInfo(i1->name, partitions);
+ for (deque<PartitionInfo>::const_iterator i2 = partitions.begin(); i2 != partitions.end(); ++i2)
+ {
+ if (i2->partitionType == EXTENDED)
+ continue;
+
+ Node partition_node(NODE_PARTITION, i2->v.device, i2->v.name, i2->v.sizeK);
+ nodes.push_back(partition_node);
+ partitions_rank.ids.push_back(partition_node.id());
+
+ edges.push_back(Edge(EDGE_SUBDEVICE, disk_node.id(), partition_node.id()));
+
+ processUsedby(partition_node, i2->v.usedBy);
+ processMount(partition_node, i2->v);
+ }
+
+ } break;
+
+ case LVM: {
+
+ LvmVgInfo lvmvginfo;
+ s->getLvmVgInfo(i1->name, lvmvginfo);
+
+ Node vg_node(NODE_LVMVG, i1->device, i1->name, lvmvginfo.sizeK);
+ nodes.push_back(vg_node);
+
+ processUsedby(vg_node, i1->usedBy);
+
+ Rank rank;
+
+ deque<LvmLvInfo> lvs;
+ s->getLvmLvInfo(i1->name, lvs);
+ for (deque<LvmLvInfo>::const_iterator i2 = lvs.begin(); i2 != lvs.end(); ++i2)
+ {
+ Node lv_node(NODE_LVMLV, i2->v.device, i2->v.name, i2->v.sizeK);
+ nodes.push_back(lv_node);
+ rank.ids.push_back(lv_node.id());
+
+ edges.push_back(Edge(EDGE_SUBDEVICE, vg_node.id(), lv_node.id()));
+
+ processUsedby(lv_node, i2->v.usedBy);
+ processMount(lv_node, i2->v);
+ }
+
+ if (!rank.ids.empty())
+ ranks.push_back(rank);
+
+ } break;
+
+ case MD: {
+
+ deque<MdInfo> mds;
+ s->getMdInfo(mds);
+
+ for (deque<MdInfo>::const_iterator i2 = mds.begin(); i2 != mds.end(); ++i2)
+ {
+ Node md_node(NODE_MD, i2->v.device, i2->v.name, i2->v.sizeK);
+ nodes.push_back(md_node);
+
+ processUsedby(md_node, i2->v.usedBy);
+ processMount(md_node, i2->v);
+ }
+
+ } break;
+
+ case MDPART: {
+
+ MdPartCoInfo mdpartcoinfo;
+ s->getMdPartCoInfo(i1->device, mdpartcoinfo);
+
+ Node mdpart_node(NODE_MDPART, i1->device, i1->name, mdpartcoinfo.d.sizeK);
+ nodes.push_back(mdpart_node);
+
+ processUsedby(mdpart_node, i1->usedBy);
+
+ Rank rank;
+
+ deque<MdPartInfo> partitions;
+ s->getMdPartInfo(i1->name, partitions);
+ for (deque<MdPartInfo>::const_iterator i2 = partitions.begin(); i2 != partitions.end(); ++i2)
+ {
+ if (i2->p.partitionType == EXTENDED)
+ continue;
+
+ Node partition_node(NODE_PARTITION, i2->v.device, i2->v.name, i2->v.sizeK);
+ nodes.push_back(partition_node);
+ rank.ids.push_back(partition_node.id());
+
+ edges.push_back(Edge(EDGE_SUBDEVICE, mdpart_node.id(), partition_node.id()));
+
+ processUsedby(partition_node, i2->v.usedBy);
+ processMount(partition_node, i2->v);
+ }
+
+ if (!rank.ids.empty())
+ ranks.push_back(rank);
+
+ } break;
+
+ case DM: {
+
+ deque<DmInfo> dms;
+ s->getDmInfo(dms);
+
+ for (deque<DmInfo>::const_iterator i2 = dms.begin(); i2 != dms.end(); ++i2)
+ {
+ Node dm_node(NODE_DM, i2->v.device, i2->v.name, i2->v.sizeK);
+ nodes.push_back(dm_node);
+
+ processUsedby(dm_node, i2->v.usedBy);
+ processMount(dm_node, i2->v);
+ }
+
+ } break;
+
+ case DMRAID: {
+
+ DmraidCoInfo dmraidcoinfo;
+ s->getDmraidCoInfo(i1->device, dmraidcoinfo);
+
+ Node dmraid_node(NODE_DMRAID, i1->device, i1->name, dmraidcoinfo.p.d.sizeK);
+ nodes.push_back(dmraid_node);
+
+ processUsedby(dmraid_node, i1->usedBy);
+
+ Rank rank;
+
+ deque<DmraidInfo> partitions;
+ s->getDmraidInfo(i1->name, partitions);
+ for (deque<DmraidInfo>::const_iterator i2 = partitions.begin(); i2 != partitions.end(); ++i2)
+ {
+ if (i2->p.p.partitionType == EXTENDED)
+ continue;
+
+ Node partition_node(NODE_PARTITION, i2->p.v.device, i2->p.v.name, i2->p.v.sizeK);
+ nodes.push_back(partition_node);
+ rank.ids.push_back(partition_node.id());
+
+ edges.push_back(Edge(EDGE_SUBDEVICE, dmraid_node.id(), partition_node.id()));
+
+ processUsedby(partition_node, i2->p.v.usedBy);
+ processMount(partition_node, i2->p.v);
+ }
+
+ if (!rank.ids.empty())
+ ranks.push_back(rank);
+
+ } break;
+
+ case DMMULTIPATH: {
+
+ DmmultipathCoInfo dmmultipathcoinfo;
+ s->getDmmultipathCoInfo(i1->device, dmmultipathcoinfo);
+
+ Node dmmultipath_node(NODE_DMMULTIPATH, i1->device, i1->name, dmmultipathcoinfo.p.d.sizeK);
+ nodes.push_back(dmmultipath_node);
+
+ processUsedby(dmmultipath_node, i1->usedBy);
+
+ Rank rank;
+
+ deque<DmmultipathInfo> partitions;
+ s->getDmmultipathInfo(i1->name, partitions);
+ for (deque<DmmultipathInfo>::const_iterator i2 = partitions.begin(); i2 != partitions.end(); ++i2)
+ {
+ if (i2->p.p.partitionType == EXTENDED)
+ continue;
+
+ Node partition_node(NODE_PARTITION, i2->p.v.device, i2->p.v.name, i2->p.v.sizeK);
+ nodes.push_back(partition_node);
+ rank.ids.push_back(partition_node.id());
+
+ edges.push_back(Edge(EDGE_SUBDEVICE, dmmultipath_node.id(), partition_node.id()));
+
+ processUsedby(partition_node, i2->p.v.usedBy);
+ processMount(partition_node, i2->p.v);
+ }
+
+ if (!rank.ids.empty())
+ ranks.push_back(rank);
+
+ } break;
+
+ case BTRFSC: {
+
+ deque<BtrfsInfo> btrfss;
+ s->getBtrfsInfo(btrfss);
+
+ for (deque<BtrfsInfo>::const_iterator i2 = btrfss.begin(); i2 != btrfss.end(); ++i2)
+ {
+ Node btrfs_node(NODE_BTRFS, i2->v.uuid, i2->v.name, i2->v.sizeK);
+ nodes.push_back(btrfs_node);
+
+ processUsedby(btrfs_node, i2->v.usedBy);
+ processMount(btrfs_node, i2->v);
+ }
+
+ } break;
+
+ case LOOP:
+ case NFSC:
+ case TMPFSC:
+ case CUNKNOWN:
+ break;
+ }
+ }
+
+ if (!disks_rank.ids.empty())
+ ranks.push_back(disks_rank);
+
+ if (!partitions_rank.ids.empty())
+ ranks.push_back(partitions_rank);
+
+ if (!mounts_rank.ids.empty())
+ ranks.push_back(mounts_rank);
+ }
+
+
+ void
+ DeviceGraph::processUsedby(const Node& node, const list<UsedByInfo>& usedBy)
+ {
+ for (list<UsedByInfo>::const_iterator i = usedBy.begin(); i != usedBy.end(); ++i)
+ {
+ edges.push_back(Edge(EDGE_USED, node.id(), "device:" + i->device));
+ }
+ }
+
+
+ void
+ DeviceGraph::processMount(const Node& node, const VolumeInfo& volume)
+ {
+ if (!volume.mount.empty())
+ {
+ Node mountpoint_node(NODE_MOUNTPOINT, volume.device, volume.mount, volume.sizeK);
+ nodes.push_back(mountpoint_node);
+ mounts_rank.ids.push_back(mountpoint_node.id());
+
+ edges.push_back(Edge(EDGE_MOUNT, node.id(), mountpoint_node.id()));
+ }
+ }
+
+
+ MountGraph::MountGraph(StorageInterface* s)
+ {
+ mount_ranks[0].type = RANK_SOURCE;
+
+ deque<VolumeInfo> volumes;
+ s->getVolumes(volumes);
+ for (deque<VolumeInfo>::const_iterator i1 = volumes.begin(); i1 != volumes.end(); ++i1)
+ {
+ if (!i1->mount.empty() && i1->mount != "swap")
+ {
+ Node mountpoint_node(NODE_MOUNTPOINT, i1->device, i1->mount, i1->sizeK);
+ nodes.push_back(mountpoint_node);
+
+ int r = i1->mount == "/" ? 0 : count(i1->mount.begin(), i1->mount.end(), '/');
+ mount_ranks[r].ids.push_back(mountpoint_node.id());
+
+ entries[i1->mount] = i1->device;
+ }
+ }
+
+ for (map<int, Rank>::const_iterator i1 = mount_ranks.begin(); i1 != mount_ranks.end(); ++i1)
+ if (!i1->second.ids.empty())
+ ranks.push_back(i1->second);
+
+ for (Entries::const_iterator i1 = entries.begin(); i1 != entries.end(); ++i1)
+ {
+ Entries::const_iterator i2 = findParent(i1);
+ if (i2 != entries.end())
+ edges.push_back(Edge(EDGE_MOUNT, "mountpoint:" + i2->second, "mountpoint:" + i1->second));
+ }
+ }
+
+
+ MountGraph::Entries::const_iterator
+ MountGraph::findParent(const Entries::const_iterator& child) const
+ {
+ string mount = child->first;
+
+ while (mount != "/")
+ {
+ string::size_type pos = mount.rfind("/");
+ if (pos == string::npos)
+ return entries.end();
+
+ mount.erase(pos);
+ if (mount.empty())
+ mount = "/";
+
+ Entries::const_iterator i1 = entries.find(mount);
+ if (i1 != entries.end())
+ return i1;
+ }
+
+ return entries.end();
+ }
+
+
+ string
+ Graph::quote(const string& str)
+ {
+ return '"' + boost::replace_all_copy(str, "\"", "\\\"") + '"';
+ }
+
+
+ string
+ Graph::makeTooltip(const Text& text, const string& label, unsigned long long sizeK)
+ {
+ return quote(text.text + "\\n" + label + "\\n" + byteToHumanString(1024 * sizeK, false, 2, false));
+ }
+
+
+ ostream& operator<<(ostream& s, const Graph::Node& node)
+ {
+ s << Graph::quote(node.id()) << " [label=" << Graph::quote(node.label);
+ switch (node.type)
+ {
+ case Graph::NODE_DISK:
+ s << ", color=\"#ff0000\", fillcolor=\"#ffaaaa\"" << ", tooltip="
+ << Graph::makeTooltip(_("Hard Disk"), node.device, node.sizeK);
+ break;
+ case Graph::NODE_DMRAID:
+ s << ", color=\"#ff0000\", fillcolor=\"#ffaaaa\"" << ", tooltip="
+ << Graph::makeTooltip(_("DM RAID"), node.device, node.sizeK);
+ break;
+ case Graph::NODE_DMMULTIPATH:
+ s << ", color=\"#ff0000\", fillcolor=\"#ffaaaa\"" << ", tooltip="
+ << Graph::makeTooltip(_("DM Multipath"), node.device, node.sizeK);
+ break;
+ case Graph::NODE_PARTITION:
+ s << ", color=\"#cc33cc\", fillcolor=\"#eeaaee\"" << ", tooltip="
+ << Graph::makeTooltip(_("Partition"), node.device, node.sizeK);
+ break;
+ case Graph::NODE_MD:
+ s << ", color=\"#aaaa00\", fillcolor=\"#ffffaa\"" << ", tooltip="
+ << Graph::makeTooltip(_("MD RAID"), node.device, node.sizeK);
+ break;
+ case Graph::NODE_MDPART:
+ s << ", color=\"#aaaa00\", fillcolor=\"#ffffaa\"" << ", tooltip="
+ << Graph::makeTooltip(_("MD RAID"), node.device, node.sizeK);
+ break;
+ case Graph::NODE_LVMVG:
+ s << ", color=\"#0000ff\", fillcolor=\"#aaaaff\"" << ", tooltip="
+ << Graph::makeTooltip(_("Volume Group"), node.device, node.sizeK);
+ break;
+ case Graph::NODE_LVMLV:
+ s << ", color=\"#6622dd\", fillcolor=\"#bb99ff\"" << ", tooltip="
+ << Graph::makeTooltip(_("Logical Volume"), node.device, node.sizeK);
+ break;
+ case Graph::NODE_BTRFS:
+ s << ", color=\"#17534f\", fillcolor=\"#28e3d8\"" << ", tooltip="
+ << Graph::makeTooltip(_("Btrfs Volume"), node.device, node.sizeK);
+ break;
+ case Graph::NODE_DM:
+ s << ", color=\"#885511\", fillcolor=\"#ddbb99\"" << ", tooltip="
+ << Graph::makeTooltip(_("DM Device"), node.device, node.sizeK);
+ break;
+ case Graph::NODE_MOUNTPOINT:
+ s << ", color=\"#008800\", fillcolor=\"#99ee99\"" << ", tooltip="
+ << Graph::makeTooltip(_("Mount Point"), node.device, node.sizeK);
+ break;
+ }
+ return s << "];";
+ }
+
+
+ ostream& operator<<(ostream& s, const Graph::Edge& edge)
+ {
+ s << Graph::quote(edge.id1) << " -> " << Graph::quote(edge.id2);
+ switch (edge.type)
+ {
+ case Graph::EDGE_SUBDEVICE:
+ s << " [style=solid]";
+ break;
+ case Graph::EDGE_MOUNT:
+ s << " [style=dashed]";
+ break;
+ case Graph::EDGE_USED:
+ s << " [style=dotted]";
+ break;
+ }
+ return s << ";";
+ }
+
+
+ ostream& operator<<(ostream& s, const Graph::Rank& rank)
+ {
+ static const char* names[] = { "source", "same", "sink" };
+
+ s << "{ rank=" << names[rank.type] << "; ";
+ for (list<string>::const_iterator id = rank.ids.begin(); id != rank.ids.end(); ++id)
+ s << Graph::quote(*id) << " ";
+ return s << "};";
+ }
+
+
+ bool
+ Graph::save(const string& filename) const
+ {
+ ofstream out(filename.c_str());
+ classic(out);
+
+ out << "// generated by libstorage version " VERSION << endl;
+ out << "// " << hostname() << ", " << datetime() << endl;
+ out << endl;
+
+ out << "digraph storage" << endl;
+ out << "{" << endl;
+ out << " node [shape=rectangle, style=filled, fontname=\"Arial\"];" << endl;
+ out << " edge [color=\"#444444\"];" << endl;
+ out << endl;
+
+ for (list<Node>::const_iterator node = nodes.begin(); node != nodes.end(); ++node)
+ out << " " << (*node) << endl;
+
+ out << endl;
+
+ for (list<Rank>::const_iterator rank = ranks.begin(); rank != ranks.end(); ++rank)
+ out << " " << (*rank) << endl;
+
+ out << endl;
+
+ for (list<Edge>::const_iterator edge = edges.begin(); edge != edges.end(); ++edge)
+ out << " " << (*edge) << endl;
+
+ out << "}" << endl;
+
+ out.close();
+
+ return !out.bad();
+ }
+
+
+ bool
+ saveDeviceGraph(StorageInterface* s, const string& filename)
+ {
+ return DeviceGraph(s).save(filename);
+ }
+
+
+ bool
+ saveMountGraph(StorageInterface* s, const string& filename)
+ {
+ return MountGraph(s).save(filename);
+ }
+}
Added: branches/SuSE-Code-11-SP2-Branch/storage/libstorage/src/Graph.h
URL: http://svn.opensuse.org/viewcvs/yast/branches/SuSE-Code-11-SP2-Branch/stora…
==============================================================================
--- branches/SuSE-Code-11-SP2-Branch/storage/libstorage/src/Graph.h (added)
+++ branches/SuSE-Code-11-SP2-Branch/storage/libstorage/src/Graph.h Tue May 17 13:39:44 2011
@@ -0,0 +1,59 @@
+/*
+ * Copyright (c) [2004-2009] Novell, Inc.
+ *
+ * All Rights Reserved.
+ *
+ * This program is free software; you can redistribute it and/or modify it
+ * under the terms of version 2 of the GNU General Public License as published
+ * by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
+ * more details.
+ *
+ * You should have received a copy of the GNU General Public License along
+ * with this program; if not, contact Novell, Inc.
+ *
+ * To contact Novell about this file by physical or electronic mail, you may
+ * find current contact information at www.novell.com.
+ */
+
+
+#ifndef GRAPH_H
+#define GRAPH_H
+
+
+#include <string>
+
+using std::string;
+
+
+namespace storage
+{
+ class StorageInterface;
+
+
+ /**
+ * Saves a graph of the storage devices as a DOT file for graphviz.
+ *
+ * @param s StorageInterface
+ * @param filename filename of graph
+ * @return true on successful writing of graph
+ */
+ bool saveDeviceGraph(StorageInterface* s, const string& filename);
+
+
+ /**
+ * Saves a graph of the mount points as a DOT file for graphviz.
+ *
+ * @param s StorageInterface
+ * @param filename filename of graph
+ * @return true on successful writing of graph
+ */
+ bool saveMountGraph(StorageInterface* s, const string& filename);
+
+}
+
+
+#endif
Added: branches/SuSE-Code-11-SP2-Branch/storage/libstorage/src/HumanString.cc
URL: http://svn.opensuse.org/viewcvs/yast/branches/SuSE-Code-11-SP2-Branch/stora…
==============================================================================
--- branches/SuSE-Code-11-SP2-Branch/storage/libstorage/src/HumanString.cc (added)
+++ branches/SuSE-Code-11-SP2-Branch/storage/libstorage/src/HumanString.cc Tue May 17 13:39:44 2011
@@ -0,0 +1,205 @@
+/*
+ * Copyright (c) [2004-2010] Novell, Inc.
+ *
+ * All Rights Reserved.
+ *
+ * This program is free software; you can redistribute it and/or modify it
+ * under the terms of version 2 of the GNU General Public License as published
+ * by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
+ * more details.
+ *
+ * You should have received a copy of the GNU General Public License along
+ * with this program; if not, contact Novell, Inc.
+ *
+ * To contact Novell about this file by physical or electronic mail, you may
+ * find current contact information at www.novell.com.
+ */
+
+
+#include <locale>
+#include <boost/algorithm/string.hpp>
+
+#include "storage/AppUtil.h"
+#include "storage/HumanString.h"
+
+
+namespace storage
+{
+ using namespace std;
+
+
+ int
+ numSuffixes()
+ {
+ return 7;
+ }
+
+
+ list<Text>
+ getAllSuffixes(int i, bool all = false, bool sloppy = false)
+ {
+ list<Text> ret;
+
+ switch (i)
+ {
+ case 0:
+ /* symbol for "bytes" (best keep untranslated) */
+ ret.push_back(_("B"));
+ if (sloppy)
+ ret.push_back(Text("", ""));
+ break;
+
+ case 1:
+ /* symbol for "kilo bytes" (best keep untranslated) */
+ ret.push_back(_("kB"));
+ if (all)
+ /* symbol for "kibi bytes" (best keep untranslated) */
+ ret.push_back(_("KiB"));
+ if (sloppy)
+ /* symbol for "kilo" (best keep untranslated) */
+ ret.push_back(_("k"));
+ break;
+
+ case 2:
+ /* symbol for "mega bytes" (best keep untranslated) */
+ ret.push_back(_("MB"));
+ if (all)
+ /* symbol for "mebi bytes" (best keep untranslated) */
+ ret.push_back(_("MiB"));
+ if (sloppy)
+ /* symbol for "mega" (best keep untranslated) */
+ ret.push_back(_("M"));
+ break;
+
+ case 3:
+ /* symbol for "giga bytes" (best keep untranslated) */
+ ret.push_back(_("GB"));
+ if (all)
+ /* symbol for "gibi bytes" (best keep untranslated) */
+ ret.push_back(_("GiB"));
+ if (sloppy)
+ /* symbol for "giga" (best keep untranslated) */
+ ret.push_back(_("G"));
+ break;
+
+ case 4:
+ /* symbol for "tera bytes" (best keep untranslated) */
+ ret.push_back(_("TB"));
+ if (all)
+ /* symbol for "tebi bytes" (best keep untranslated) */
+ ret.push_back(_("TiB"));
+ if (sloppy)
+ /* symbol for "tera" (best keep untranslated) */
+ ret.push_back(_("T"));
+ break;
+
+ case 5:
+ /* symbol for "peta bytes" (best keep untranslated) */
+ ret.push_back(_("PB"));
+ if (all)
+ /* symbol for "pebi bytes" (best keep untranslated) */
+ ret.push_back(_("PiB"));
+ if (sloppy)
+ /* symbol for "peta" (best keep untranslated) */
+ ret.push_back(_("P"));
+ break;
+
+ case 6:
+ /* symbol for "exa bytes" (best keep untranslated) */
+ ret.push_back(_("EB"));
+ if (all)
+ /* symbol for "exbi bytes" (best keep untranslated) */
+ ret.push_back(_("EiB"));
+ if (sloppy)
+ /* symbol for "exa" (best keep untranslated) */
+ ret.push_back(_("E"));
+ break;
+ }
+
+ return ret;
+ }
+
+
+ string
+ getSuffix(int i, bool classic)
+ {
+ return classic ? getAllSuffixes(i).front().native : getAllSuffixes(i).front().text;
+ }
+
+
+ string
+ byteToHumanString(unsigned long long size, bool classic, int precision, bool omit_zeroes)
+ {
+ const locale loc = classic ? locale::classic() : locale();
+
+ double f = size;
+ int i = 0;
+
+ while (f >= 1024.0 && i + 1 < numSuffixes())
+ {
+ f /= 1024.0;
+ i++;
+ }
+
+ if ((i == 0) || (omit_zeroes && (f == (unsigned long long)(f))))
+ {
+ precision = 0;
+ }
+
+ ostringstream s;
+ s.imbue(loc);
+ s.setf(ios::fixed);
+ s.precision(precision);
+
+ s << f << ' ' << getSuffix(i, classic);
+
+ return s.str();
+ }
+
+
+ bool
+ humanStringToByte(const string& str, bool classic, unsigned long long& size)
+ {
+ const locale loc = classic ? locale::classic() : locale();
+
+ const string str_trimmed = boost::trim_copy(str, loc);
+
+ double f = 1.0;
+
+ for (int i = 0; i < numSuffixes(); ++i)
+ {
+ list<Text> suffix = getAllSuffixes(i, true, !classic);
+
+ for (list<Text>::const_iterator j = suffix.begin(); j != suffix.end(); ++j)
+ {
+ const string& tmp = classic ? j->native : j->text;
+
+ if (boost::iends_with(str_trimmed, tmp, loc))
+ {
+ string number = str_trimmed.substr(0, str_trimmed.size() - tmp.size());
+
+ istringstream s(boost::trim_copy(number, loc));
+ s.imbue(loc);
+
+ double g;
+ s >> g;
+
+ if (!s.fail() && s.eof() && g >= 0.0)
+ {
+ size = g * f;
+ return true;
+ }
+ }
+ }
+
+ f *= 1024.0;
+ }
+
+ return false;
+ }
+
+}
Added: branches/SuSE-Code-11-SP2-Branch/storage/libstorage/src/HumanString.h
URL: http://svn.opensuse.org/viewcvs/yast/branches/SuSE-Code-11-SP2-Branch/stora…
==============================================================================
--- branches/SuSE-Code-11-SP2-Branch/storage/libstorage/src/HumanString.h (added)
+++ branches/SuSE-Code-11-SP2-Branch/storage/libstorage/src/HumanString.h Tue May 17 13:39:44 2011
@@ -0,0 +1,81 @@
+/*
+ * Copyright (c) [2004-2010] Novell, Inc.
+ *
+ * All Rights Reserved.
+ *
+ * This program is free software; you can redistribute it and/or modify it
+ * under the terms of version 2 of the GNU General Public License as published
+ * by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
+ * more details.
+ *
+ * You should have received a copy of the GNU General Public License along
+ * with this program; if not, contact Novell, Inc.
+ *
+ * To contact Novell about this file by physical or electronic mail, you may
+ * find current contact information at www.novell.com.
+ */
+
+
+#ifndef HUMAN_STRING_H
+#define HUMAN_STRING_H
+
+
+#include <string>
+
+using std::string;
+
+
+namespace storage
+{
+
+ /**
+ * Return number of suffixes.
+ *
+ * @return number of suffixes
+ */
+ int numSuffixes();
+
+ /**
+ * Return a suffix.
+ *
+ * @param i index of suffix
+ * @param classic use classic locale instead of global C++ locale
+ * @return suffix
+ */
+ string getSuffix(int i, bool classic);
+
+
+ /**
+ * Return a pretty description of a size with required precision
+ * and using B, kB, MB, GB, TB or PB as unit as appropriate.
+ *
+ * @param size size in bytes
+ * @param classic use classic locale instead of global C++ locale
+ * @param precision number of fraction digits in output
+ * @param omit_zeroes if true omit trailing zeroes for exact values
+ * @return formatted string
+ */
+ string byteToHumanString(unsigned long long size, bool classic, int precision,
+ bool omit_zeroes);
+
+ /**
+ * Converts a size description using B, kB, MB, GB, TB or PB into an integer.
+ *
+ * @param str size string
+ * @param classic use classic locale instead of global C++ locale
+ * @param size size in bytes
+ * @return true on successful conversion
+ *
+ * The conversion is always case-insensitive. With classic set to
+ * false the conversion is also sloppy concerning omission of 'B'.
+ */
+ bool humanStringToByte(const string& str, bool classic, unsigned long long& size);
+
+}
+
+
+#endif
Modified: branches/SuSE-Code-11-SP2-Branch/storage/libstorage/src/IterPair.h
URL: http://svn.opensuse.org/viewcvs/yast/branches/SuSE-Code-11-SP2-Branch/stora…
==============================================================================
--- branches/SuSE-Code-11-SP2-Branch/storage/libstorage/src/IterPair.h (original)
+++ branches/SuSE-Code-11-SP2-Branch/storage/libstorage/src/IterPair.h Tue May 17 13:39:44 2011
@@ -33,20 +33,26 @@
{
public:
typedef Iter itype;
- IterPair( const Iter b, const Iter e ) : m_begin(b), m_end(e) {}
+ IterPair(const Iter& b, const Iter& e) : m_begin(b), m_end(e) {}
IterPair( const IterPair& x )
{
*this = x;
}
- IterPair& operator=(const IterPair& x)
+
+ template <class Ip>
+ IterPair(const Ip& x) : m_begin(x.begin()), m_end(x.end()) {}
+
+ template< class Ip >
+ IterPair& operator=(const Ip& x)
{
- m_begin=x.m_begin;
- m_end=x.m_end;
+ m_begin=x.begin();
+ m_end=x.end();
return( *this );
}
- bool operator==(const IterPair& x) const
+ template< class Ip >
+ bool operator==(const Ip& x) const
{
- return( m_begin==x.m_begin && m_end==x.m_end );
+ return( m_begin==x.begin() && m_end==x.end() );
}
bool empty() const { return( m_begin==m_end ); }
unsigned length() const { return( std::distance( m_begin, m_end )); }
Modified: branches/SuSE-Code-11-SP2-Branch/storage/libstorage/src/ListListIterator.h
URL: http://svn.opensuse.org/viewcvs/yast/branches/SuSE-Code-11-SP2-Branch/stora…
==============================================================================
--- branches/SuSE-Code-11-SP2-Branch/storage/libstorage/src/ListListIterator.h (original)
+++ branches/SuSE-Code-11-SP2-Branch/storage/libstorage/src/ListListIterator.h Tue May 17 13:39:44 2011
@@ -23,8 +23,8 @@
#ifndef LIST_LIST_ITERATOR_H
#define LIST_LIST_ITERATOR_H
-#include "y2storage/AppUtil.h"
-#include "y2storage/IterPair.h"
+#include "storage/AppUtil.h"
+#include "storage/IterPair.h"
namespace storage
{
@@ -53,9 +53,13 @@
initialize( p.begin(), p.end(), setend );
}
- ListListIterator( const ListListIterator& x )
+ template< class It >
+ ListListIterator( const It& x )
{
- copyMembers( x );
+ m_begin = x.begin();
+ m_end = x.end();
+ m_lcur = x.cur();
+ m_pcur = x.pcur();
}
ListListIterator& operator=(const ListListIterator& x)
@@ -99,11 +103,13 @@
{
return( &(*m_pcur) );
}
- bool operator==(const ListListIterator& x) const
+ template< class It >
+ bool operator==(const It& x) const
{
return( m_pcur == x.pcur() );
}
- bool operator!=(const ListListIterator& x) const
+ template< class It >
+ bool operator!=(const It& x) const
{
return( m_pcur != x.pcur() );
}
Modified: branches/SuSE-Code-11-SP2-Branch/storage/libstorage/src/Lock.cc
URL: http://svn.opensuse.org/viewcvs/yast/branches/SuSE-Code-11-SP2-Branch/stora…
==============================================================================
--- branches/SuSE-Code-11-SP2-Branch/storage/libstorage/src/Lock.cc (original)
+++ branches/SuSE-Code-11-SP2-Branch/storage/libstorage/src/Lock.cc Tue May 17 13:39:44 2011
@@ -19,10 +19,6 @@
* find current contact information at www.novell.com.
*/
-/*
- * Author: Arvin Schnell <aschnell(a)suse.de>
- */
-
#include <stdio.h>
#include <unistd.h>
@@ -32,8 +28,8 @@
#include <sys/types.h>
#include <stdlib.h>
-#include "y2storage/AppUtil.h"
-#include "y2storage/Lock.h"
+#include "storage/AppUtil.h"
+#include "storage/Lock.h"
namespace storage
@@ -51,7 +47,7 @@
Lock::Lock(bool readonly, bool disable)
- : disabled(disable || getenv("YAST2_STORAGE_NO_LOCKING") != NULL),
+ : disabled(disable || getenv("LIBSTORAGE_NO_LOCKING") != NULL),
fd(-1)
{
if (disabled)
@@ -71,7 +67,7 @@
{
// Opening lock-file failed.
y2err("opening lock-file failed: " << strerror(errno));
- throw(LockException(0));
+ throw LockException(0);
}
struct flock lock;
@@ -89,13 +85,15 @@
// release. In that case we don't get the pid (and it is
// still 0).
fcntl(fd, F_GETLK, &lock);
+ close(fd);
y2err("locked by process " << lock.l_pid);
- throw(LockException(lock.l_pid));
+ throw LockException(lock.l_pid);
default:
// Some other error.
+ close(fd);
y2err("getting lock failed: " << strerror(errno));
- throw(LockException(0));
+ throw LockException(0);
}
}
Modified: branches/SuSE-Code-11-SP2-Branch/storage/libstorage/src/Lock.h
URL: http://svn.opensuse.org/viewcvs/yast/branches/SuSE-Code-11-SP2-Branch/stora…
==============================================================================
--- branches/SuSE-Code-11-SP2-Branch/storage/libstorage/src/Lock.h (original)
+++ branches/SuSE-Code-11-SP2-Branch/storage/libstorage/src/Lock.h Tue May 17 13:39:44 2011
@@ -24,11 +24,6 @@
#define LOCK_H
-/*
- * Author: Arvin Schnell <aschnell(a)suse.de>
- */
-
-
#include <stdexcept>
#include <boost/noncopyable.hpp>
@@ -66,7 +61,7 @@
private:
- bool disabled;
+ const bool disabled;
int fd;
};
Modified: branches/SuSE-Code-11-SP2-Branch/storage/libstorage/src/Loop.cc
URL: http://svn.opensuse.org/viewcvs/yast/branches/SuSE-Code-11-SP2-Branch/stora…
==============================================================================
--- branches/SuSE-Code-11-SP2-Branch/storage/libstorage/src/Loop.cc (original)
+++ branches/SuSE-Code-11-SP2-Branch/storage/libstorage/src/Loop.cc Tue May 17 13:39:44 2011
@@ -19,47 +19,39 @@
* find current contact information at www.novell.com.
*/
-/*
- Textdomain "storage"
-*/
+#include <sys/stat.h>
#include <sstream>
-#include <sys/stat.h>
+#include "storage/Loop.h"
+#include "storage/StorageTypes.h"
+#include "storage/Container.h"
+#include "storage/AppUtil.h"
+#include "storage/SystemInfo.h"
+#include "storage/Storage.h"
+#include "storage/SystemCmd.h"
+#include "storage/StorageDefines.h"
-#include "y2storage/Loop.h"
-#include "y2storage/StorageTypes.h"
-#include "y2storage/Container.h"
-#include "y2storage/AppUtil.h"
-#include "y2storage/ProcPart.h"
-#include "y2storage/Storage.h"
-#include "y2storage/SystemCmd.h"
-#include "y2storage/StorageDefines.h"
-using namespace storage;
-using namespace std;
+namespace storage
+{
+ using namespace std;
Loop::Loop(const LoopCo& d, const string& LoopDev, const string& LoopFile,
- bool dmcrypt, const string& dm_dev, ProcPart& ppart,
+ bool dmcrypt, const string& dm_dev, SystemInfo& systeminfo,
SystemCmd& losetup)
- : Volume(d, 0, 0)
+ : Volume(d, 0, 0), lfile(LoopFile), reuseFile(true), delFile(false)
{
y2mil("constructed loop dev:" << LoopDev << " file:" << LoopFile <<
" dmcrypt:" << dmcrypt << " dmdev:" << dm_dev);
if( d.type() != LOOP )
y2err("constructed loop with wrong container");
- init();
- lfile = LoopFile;
loop_dev = fstab_loop_dev = LoopDev;
if( loop_dev.empty() )
getLoopData( losetup );
if( loop_dev.empty() )
- {
- list<unsigned> l;
- d.loopIds( l );
- getFreeLoop( losetup, l );
- }
+ getFreeLoop(losetup, d.usedNumbers());
string proc_dev;
if( !dmcrypt )
{
@@ -67,7 +59,7 @@
if( loopStringNum( loop_dev, num ))
{
setNameDev();
- getMajorMinor( dev, mjr, mnr );
+ getMajorMinor();
}
proc_dev = loop_dev;
}
@@ -84,7 +76,7 @@
is_loop = true;
unsigned long long s = 0;
if( !proc_dev.empty() )
- ppart.getSize( proc_dev, s );
+ systeminfo.getProcParts().getSize(proc_dev, s);
if( s>0 )
{
setSize( s );
@@ -100,15 +92,12 @@
Loop::Loop(const LoopCo& d, const string& file, bool reuseExisting,
unsigned long long sizeK, bool dmcr)
- : Volume(d, 0, 0)
+ : Volume(d, 0, 0), lfile(file), reuseFile(reuseExisting), delFile(false)
{
y2mil("constructed loop file:" << file << " reuseExisting:" << reuseExisting <<
" sizek:" << sizeK << " dmcrypt:" << dmcr);
if( d.type() != LOOP )
y2err("constructed loop with wrong container");
- init();
- reuseFile = reuseExisting;
- lfile = file;
getFreeLoop();
is_loop = true;
if( !dmcr )
@@ -117,7 +106,7 @@
if( loopStringNum( dev, num ))
{
setNameDev();
- getMajorMinor( dev, mjr, mnr );
+ getMajorMinor();
}
}
else
@@ -134,19 +123,20 @@
}
-Loop::~Loop()
-{
- y2deb("destructed loop " << dev);
-}
+ Loop::Loop(const LoopCo& c, const Loop& v)
+ : Volume(c, v), lfile(v.lfile), reuseFile(v.reuseFile),
+ delFile(v.delFile)
+ {
+ y2deb("copy-constructed Loop from " << v.dev);
+ }
-void
-Loop::init()
+ Loop::~Loop()
{
- delFile = false;
- reuseFile = true;
+ y2deb("destructed Loop " << dev);
}
+
void
Loop::setDmcryptDev( const string& dm_dev, bool active )
{
@@ -155,7 +145,7 @@
nm = dm_dev.substr( dm_dev.find_last_of( '/' )+1);
if( active )
{
- getMajorMinor( dev, mjr, mnr );
+ getMajorMinor();
replaceAltName( "/dev/dm-", "/dev/dm-"+decString(mnr) );
}
Volume::setDmcryptDev( dm_dev, active );
@@ -222,21 +212,20 @@
string
Loop::lfileRealPath() const
{
- return( cont->getStorage()->root() + lfile );
+ return getStorage()->root() + lfile;
}
-unsigned Loop::major()
+
+unsigned Loop::loopMajor()
{
if( loop_major==0 )
- getLoopMajor();
+ {
+ loop_major = getMajorDevices("loop");
+ y2mil("loop_major:" << loop_major);
+ }
return( loop_major );
}
-void Loop::getLoopMajor()
- {
- loop_major = getMajorDevices( "loop" );
- y2mil("loop_major:" << loop_major);
- }
string Loop::loopDeviceName( unsigned num )
{
@@ -245,7 +234,7 @@
int Loop::setEncryption( bool val, storage::EncryptType typ )
{
- y2mil( "val:" << val << " type:" << typ );
+ y2mil("val:" << val << " enc_type:" << toString(typ));
int ret = Volume::setEncryption( val, typ );
if( ret==0 && encryption!=orig_encryption )
{
@@ -265,9 +254,9 @@
return(ret);
}
-string Loop::removeText( bool doing ) const
+Text Loop::removeText( bool doing ) const
{
- string txt;
+ Text txt;
string d = dev;
if( doing )
{
@@ -284,9 +273,9 @@
return( txt );
}
-string Loop::createText( bool doing ) const
+Text Loop::createText( bool doing ) const
{
- string txt;
+ Text txt;
string d = dev;
if( doing )
{
@@ -337,9 +326,9 @@
}
-string Loop::formatText( bool doing ) const
+Text Loop::formatText( bool doing ) const
{
- string txt;
+ Text txt;
string d = dev;
if( doing )
{
@@ -397,19 +386,17 @@
void Loop::getInfo( LoopInfo& tinfo ) const
{
- ((Volume*)this)->getInfo( info.v );
+ Volume::getInfo(info.v);
info.nr = num;
info.file = lfile;
info.reuseFile = reuseFile;
tinfo = info;
}
-namespace storage
-{
std::ostream& operator<< (std::ostream& s, const Loop& l )
{
- s << "Loop " << *(Volume*)&l
+ s << "Loop " << dynamic_cast<const Volume&>(l)
<< " LoopFile:" << l.lfile;
if( l.reuseFile )
s << " reuse";
@@ -418,7 +405,6 @@
return( s );
}
-}
bool Loop::equalContent( const Loop& rhs ) const
{
@@ -427,46 +413,18 @@
delFile==rhs.delFile );
}
-void Loop::logDifference( const Loop& rhs ) const
+
+ void
+ Loop::logDifference(std::ostream& log, const Loop& rhs) const
{
- string log = Volume::logDifference( rhs );
- if( lfile!=rhs.lfile )
- log += " LoopFile:" + lfile + "-->" + rhs.lfile;
- if( reuseFile!=rhs.reuseFile )
- {
- if( rhs.reuseFile )
- log += " -->reuse";
- else
- log += " reuse-->";
- }
- if( delFile!=rhs.delFile )
- {
- if( rhs.delFile )
- log += " -->delFile";
- else
- log += " delFile-->";
- }
- y2mil(log);
+ Volume::logDifference(log, rhs);
+
+ logDiff(log, "loopfile", lfile, rhs.lfile);
+ logDiff(log, "reusefile", reuseFile, rhs.reuseFile);
+ logDiff(log, "delfile", delFile, rhs.delFile);
}
-Loop& Loop::operator=(const Loop& rhs)
-{
- y2deb("operator= from " << rhs.nm);
- *((Volume*)this) = rhs;
- lfile = rhs.lfile;
- reuseFile = rhs.reuseFile;
- delFile = rhs.delFile;
- return *this;
-}
-
+unsigned Loop::loop_major = 0;
-Loop::Loop(const LoopCo& d, const Loop& rhs)
- : Volume(d)
-{
- y2deb("constructed loop by copy constructor from " << rhs.nm);
- *this = rhs;
}
-
-
-unsigned Loop::loop_major = 0;
Modified: branches/SuSE-Code-11-SP2-Branch/storage/libstorage/src/Loop.h
URL: http://svn.opensuse.org/viewcvs/yast/branches/SuSE-Code-11-SP2-Branch/stora…
==============================================================================
--- branches/SuSE-Code-11-SP2-Branch/storage/libstorage/src/Loop.h (original)
+++ branches/SuSE-Code-11-SP2-Branch/storage/libstorage/src/Loop.h Tue May 17 13:39:44 2011
@@ -23,26 +23,29 @@
#ifndef LOOP_H
#define LOOP_H
-#include "y2storage/Volume.h"
+#include "storage/Volume.h"
namespace storage
{
class LoopCo;
-class ProcPart;
+ class SystemInfo;
+
class Loop : public Volume
{
public:
+
Loop( const LoopCo& d, const string& LoopDev, const string& LoopFile,
bool dmcrypt, const string& dm_dev,
- ProcPart& ppart, SystemCmd& losetup );
+ SystemInfo& systeminfo, SystemCmd& losetup);
Loop( const LoopCo& d, const string& file, bool reuseExisting,
unsigned long long sizeK, bool dmcr );
- Loop( const LoopCo& d, const Loop& rhs );
+ Loop(const LoopCo& c, const Loop& v);
virtual ~Loop();
+
const string& loopFile() const { return lfile; }
void setLoopFile( const string& file );
- bool getReuse() { return( reuseFile ); }
+ bool getReuse() const { return reuseFile; }
void setReuse( bool reuseExisting );
void setDelFile( bool val=true ) { delFile=val; }
bool removeFile();
@@ -54,30 +57,37 @@
virtual void print( std::ostream& s ) const { s << *this; }
virtual int setEncryption( bool val, storage::EncryptType typ=storage::ENC_LUKS );
- string removeText( bool doing ) const;
- string createText( bool doing ) const;
- string formatText( bool doing ) const;
+ Text removeText( bool doing ) const;
+ Text createText( bool doing ) const;
+ Text formatText( bool doing ) const;
void getInfo( storage::LoopInfo& info ) const;
bool equalContent( const Loop& rhs ) const;
- void logDifference( const Loop& d ) const;
- static unsigned major();
+
+ void logDifference(std::ostream& log, const Loop& rhs) const;
+
+ static unsigned loopMajor();
static string loopDeviceName( unsigned num );
static bool notDeleted( const Loop& l ) { return( !l.deleted() ); }
protected:
- void init();
+
void checkReuse();
- static void getLoopMajor();
- Loop& operator=( const Loop& );
string lfile;
bool reuseFile;
bool delFile;
static unsigned loop_major;
- mutable storage::LoopInfo info;
+
+ mutable storage::LoopInfo info; // workaround for broken ycp bindings
+
+ private:
+
+ Loop(const Loop&); // disallow
+ Loop& operator=(const Loop&); // disallow
+
};
}
Modified: branches/SuSE-Code-11-SP2-Branch/storage/libstorage/src/LoopCo.cc
URL: http://svn.opensuse.org/viewcvs/yast/branches/SuSE-Code-11-SP2-Branch/stora…
==============================================================================
--- branches/SuSE-Code-11-SP2-Branch/storage/libstorage/src/LoopCo.cc (original)
+++ branches/SuSE-Code-11-SP2-Branch/storage/libstorage/src/LoopCo.cc Tue May 17 13:39:44 2011
@@ -19,63 +19,68 @@
* find current contact information at www.novell.com.
*/
-/*
- Textdomain "storage"
-*/
-#include <iostream>
+#include <ostream>
#include <sstream>
-#include "y2storage/LoopCo.h"
-#include "y2storage/Loop.h"
-#include "y2storage/SystemCmd.h"
-#include "y2storage/Dm.h"
-#include "y2storage/ProcMounts.h"
-#include "y2storage/AppUtil.h"
-#include "y2storage/Storage.h"
-#include "y2storage/EtcFstab.h"
-#include "y2storage/StorageDefines.h"
+#include "storage/LoopCo.h"
+#include "storage/Loop.h"
+#include "storage/SystemCmd.h"
+#include "storage/Dm.h"
+#include "storage/SystemInfo.h"
+#include "storage/ProcMounts.h"
+#include "storage/AppUtil.h"
+#include "storage/Storage.h"
+#include "storage/EtcFstab.h"
+#include "storage/StorageDefines.h"
-using namespace storage;
-using namespace std;
-
-LoopCo::LoopCo(Storage * const s, bool detect, ProcPart& ppart)
- : Container(s, "loop", staticType())
+namespace storage
{
- y2deb("constructing LoopCo detect:" << detect);
- init();
- if( detect )
- getLoopData( ppart );
-}
+ using namespace std;
-LoopCo::LoopCo(Storage * const s, const string& file)
- : Container(s, "loop", staticType())
-{
- y2deb("constructing LoopCo file:" << file);
- init();
-}
+ LoopCo::LoopCo(Storage* s)
+ : Container(s, "loop", "/dev/loop", staticType())
+ {
+ y2deb("constructing LoopCo");
+ }
-LoopCo::~LoopCo()
-{
- y2deb("destructed LoopCo");
-}
+ LoopCo::LoopCo(Storage* s, SystemInfo& systeminfo)
+ : Container(s, "loop", "/dev/loop", staticType(), systeminfo)
+ {
+ y2deb("constructing LoopCo");
+ getLoopData(systeminfo);
+ }
-void
-LoopCo::init()
+ LoopCo::LoopCo(const LoopCo& c)
+ : Container(c)
+ {
+ y2deb("copy-constructed LoopCo from " << c.dev);
+
+ ConstLoopPair p = c.loopPair();
+ for (ConstLoopIter i = p.begin(); i != p.end(); ++i)
+ {
+ Loop* p = new Loop(*this, *i);
+ vols.push_back(p);
+ }
+ }
+
+
+ LoopCo::~LoopCo()
{
- mjr = Loop::major();
+ y2deb("destructed LoopCo " << dev);
}
+
void
-LoopCo::getLoopData( ProcPart& ppart )
+ LoopCo::getLoopData(SystemInfo& systeminfo)
{
y2mil("begin");
list<FstabEntry> l;
- EtcFstab* fstab = getStorage()->getFstab();
+ const EtcFstab* fstab = getStorage()->getFstab();
fstab->getFileBasedLoops( getStorage()->root(), l );
if( !l.empty() )
{
@@ -95,16 +100,16 @@
{
Loop *l = new Loop( *this, i->loop_dev, lfile,
i->dmcrypt, !i->noauto?i->dentry:"",
- ppart, c );
+ systeminfo, c);
l->setEncryption( i->encr );
- l->setFs( Volume::toFsType(i->fs) );
+ l->setFs(toValueWithFallback(i->fs, FSUNKNOWN));
y2mil( "l:" << *l );
addToList( l );
}
}
LoopPair p=loopPair(Loop::notDeleted);
LoopIter i=p.begin();
- std::map<string,string> mp = ProcMounts(getStorage()).allMounts();
+ map<string, string> mp = systeminfo.getProcMounts().allMounts();
while( i!=p.end() )
{
if( i->dmcrypt() )
@@ -138,18 +143,20 @@
}
}
-void LoopCo::loopIds( std::list<unsigned>& l ) const
+
+ list<unsigned>
+ LoopCo::usedNumbers() const
{
- l.clear();
- ConstLoopPair p=loopPair(Loop::notDeleted);
- ConstLoopIter i=p.begin();
- while( i!=p.end() )
- {
- l.push_back( i->nr() );
- ++i;
- }
+ list<unsigned> nums;
+
+ ConstLoopPair p = loopPair(Loop::notDeleted);
+ for (ConstLoopIter i = p.begin(); i != p.end(); ++i)
+ nums.push_back(i->nr());
+
+ return nums;
}
+
bool
LoopCo::findLoop( unsigned num, LoopIter& i )
{
@@ -268,7 +275,7 @@
if( !findLoop( file, i ) && !findLoopDev( file, i ) )
ret = LOOP_UNKNOWN_FILE;
}
- if( ret==0 && i->getUsedByType() != UB_NONE )
+ if (ret == 0 && i->isUsedBy())
{
ret = LOOP_REMOVE_USED_BY;
}
@@ -281,7 +288,7 @@
}
else
{
- i->setDeleted( true );
+ i->setDeleted();
i->setDelFile( removeFile );
}
}
@@ -358,59 +365,28 @@
return( ret );
}
-void LoopCo::logData( const string& Dir ) {;}
-
-namespace storage
-{
-inline std::ostream& operator<< (std::ostream& s, const LoopCo& d )
+ std::ostream& operator<<(std::ostream& s, const LoopCo& d)
{
- s << *((Container*)&d);
+ s << dynamic_cast<const Container&>(d);
return( s );
}
-}
-void LoopCo::logDifference( const Container& d ) const
+ void
+ LoopCo::logDifferenceWithVolumes(std::ostream& log, const Container& rhs_c) const
{
- y2mil(getDiffString(d));
- const LoopCo * p = dynamic_cast<const LoopCo*>(&d);
- if( p != NULL )
- {
- ConstLoopPair pp=loopPair();
- ConstLoopIter i=pp.begin();
- while( i!=pp.end() )
- {
- ConstLoopPair pc=p->loopPair();
- ConstLoopIter j = pc.begin();
- while( j!=pc.end() &&
- (i->device()!=j->device() || i->created()!=j->created()) )
- ++j;
- if( j!=pc.end() )
- {
- if( !i->equalContent( *j ) )
- i->logDifference( *j );
- }
- else
- y2mil( " -->" << *i );
- ++i;
- }
- pp=p->loopPair();
- i=pp.begin();
- while( i!=pp.end() )
- {
- ConstLoopPair pc=loopPair();
- ConstLoopIter j = pc.begin();
- while( j!=pc.end() &&
- (i->device()!=j->device() || i->created()!=j->created()) )
- ++j;
- if( j==pc.end() )
- y2mil( " <--" << *i );
- ++i;
- }
- }
+ const LoopCo& rhs = dynamic_cast<const LoopCo&>(rhs_c);
+
+ logDifference(log, rhs);
+ log << endl;
+
+ ConstLoopPair pp = loopPair();
+ ConstLoopPair pc = rhs.loopPair();
+ logVolumesDifference(log, pp.begin(), pp.end(), pc.begin(), pc.end());
}
+
bool LoopCo::equalContent( const Container& rhs ) const
{
const LoopCo * p = NULL;
@@ -421,29 +397,10 @@
{
ConstLoopPair pp = loopPair();
ConstLoopPair pc = p->loopPair();
- ConstLoopIter i = pp.begin();
- ConstLoopIter j = pc.begin();
- while( ret && i!=pp.end() && j!=pc.end() )
- {
- ret = ret && i->equalContent( *j );
- ++i;
- ++j;
- }
- ret = ret && i==pp.end() && j==pc.end();
+ ret = ret && storage::equalContent(pp.begin(), pp.end(), pc.begin(), pc.end());
}
return( ret );
}
-LoopCo::LoopCo(const LoopCo& rhs)
- : Container(rhs)
-{
- y2deb("constructed LoopCo by copy constructor from " << rhs.nm);
- *this = rhs;
- ConstLoopPair p = rhs.loopPair();
- for( ConstLoopIter i=p.begin(); i!=p.end(); ++i )
- {
- Loop * p = new Loop( *this, *i );
- vols.push_back( p );
- }
}
Modified: branches/SuSE-Code-11-SP2-Branch/storage/libstorage/src/LoopCo.h
URL: http://svn.opensuse.org/viewcvs/yast/branches/SuSE-Code-11-SP2-Branch/stora…
==============================================================================
--- branches/SuSE-Code-11-SP2-Branch/storage/libstorage/src/LoopCo.h (original)
+++ branches/SuSE-Code-11-SP2-Branch/storage/libstorage/src/LoopCo.h Tue May 17 13:39:44 2011
@@ -23,22 +23,26 @@
#ifndef LOOP_CO_H
#define LOOP_CO_H
-#include "y2storage/Container.h"
-#include "y2storage/Loop.h"
+#include "storage/Container.h"
+#include "storage/Loop.h"
+
namespace storage
{
-class ProcPart;
+ class SystemInfo;
+
class LoopCo : public Container
{
friend class Storage;
public:
- LoopCo( Storage * const s, bool detect, ProcPart& ppart );
- LoopCo( const LoopCo& rhs );
+ LoopCo(Storage * const s);
+ LoopCo(Storage * const s, SystemInfo& systeminfo);
+ LoopCo(const LoopCo& c);
virtual ~LoopCo();
+
static storage::CType staticType() { return storage::LOOP; }
friend std::ostream& operator<< (std::ostream&, const LoopCo& );
@@ -47,11 +51,13 @@
int updateLoop( const string& device, const string& file,
bool reuseExisting, unsigned long long sizeK );
int removeLoop( const string& file, bool removeFile = false );
- void loopIds( std::list<unsigned>& l ) const;
+
+ list<unsigned> usedNumbers() const;
int removeVolume( Volume* v );
bool equalContent( const Container& rhs ) const;
- void logDifference( const Container& d ) const;
+
+ virtual void logDifferenceWithVolumes(std::ostream& log, const Container& rhs) const;
protected:
// iterators over LOOP volumes
@@ -102,18 +108,13 @@
return( ConstLoopIter( LoopCPIterator( p, Check, true )) );
}
- LoopCo( Storage * const s, const string& File );
-
- void getLoopData( ProcPart& ppart );
+ void getLoopData(SystemInfo& systeminfo);
bool findLoop( unsigned num, LoopIter& i );
bool findLoop( unsigned num );
bool findLoop( const string& file, LoopIter& i );
bool findLoop( const string& file );
bool findLoopDev( const string& dev, LoopIter& i );
void addLoop( Loop* m );
- void updateEntry( const Loop* m );
-
- void init();
virtual void print( std::ostream& s ) const { s << *this; }
virtual Container* getCopy() const { return( new LoopCo( *this ) ); }
@@ -121,7 +122,10 @@
int doCreate( Volume* v );
int doRemove( Volume* v );
- void logData( const string& Dir );
+ private:
+
+ LoopCo& operator=(const LoopCo&); // disallow
+
};
}
Added: branches/SuSE-Code-11-SP2-Branch/storage/libstorage/src/Lsscsi.cc
URL: http://svn.opensuse.org/viewcvs/yast/branches/SuSE-Code-11-SP2-Branch/stora…
==============================================================================
--- branches/SuSE-Code-11-SP2-Branch/storage/libstorage/src/Lsscsi.cc (added)
+++ branches/SuSE-Code-11-SP2-Branch/storage/libstorage/src/Lsscsi.cc Tue May 17 13:39:44 2011
@@ -0,0 +1,104 @@
+/*
+ * Copyright (c) 2010 Novell, Inc.
+ *
+ * All Rights Reserved.
+ *
+ * This program is free software; you can redistribute it and/or modify it
+ * under the terms of version 2 of the GNU General Public License as published
+ * by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
+ * more details.
+ *
+ * You should have received a copy of the GNU General Public License along
+ * with this program; if not, contact Novell, Inc.
+ *
+ * To contact Novell about this file by physical or electronic mail, you may
+ * find current contact information at www.novell.com.
+ */
+
+
+#include <boost/algorithm/string.hpp>
+
+#include "storage/AppUtil.h"
+#include "storage/SystemCmd.h"
+#include "storage/StorageDefines.h"
+#include "storage/Lsscsi.h"
+#include "storage/Enum.h"
+
+
+namespace storage
+{
+ using namespace std;
+
+
+ Lsscsi::Lsscsi()
+ {
+ SystemCmd cmd(LSSCSIBIN " --transport");
+ if (cmd.retcode() == 0)
+ parse(cmd.stdout());
+ }
+
+
+ void
+ Lsscsi::parse(const vector<string>& lines)
+ {
+ data.clear();
+
+ for (vector<string>::const_iterator it = lines.begin(); it != lines.end(); ++it)
+ {
+ string line = boost::replace_all_copy(*it, " usb: ", " usb:");
+
+ string transport = extractNthWord(2, line);
+ string device = extractNthWord(3, line);
+
+ if (!boost::starts_with(device, "/dev/"))
+ continue;
+
+ Entry entry;
+
+ if (boost::starts_with(transport, "sbp:"))
+ entry.transport = SBP;
+ else if (boost::starts_with(transport, "ata:"))
+ entry.transport = ATA;
+ else if (boost::starts_with(transport, "fc:"))
+ entry.transport = FC;
+ else if (boost::starts_with(transport, "iqn"))
+ entry.transport = ISCSI;
+ else if (boost::starts_with(transport, "sas:"))
+ entry.transport = SAS;
+ else if (boost::starts_with(transport, "sata:"))
+ entry.transport = SATA;
+ else if (boost::starts_with(transport, "spi:"))
+ entry.transport = SPI;
+ else if (boost::starts_with(transport, "usb:"))
+ entry.transport = USB;
+
+ data[device] = entry;
+ }
+
+ for (const_iterator it = data.begin(); it != data.end(); ++it)
+ y2mil("data[" << it->first << "] -> " << it->second);
+ }
+
+
+ bool
+ Lsscsi::getEntry(const string& device, Entry& entry) const
+ {
+ const_iterator i = data.find(device);
+ if (i == data.end())
+ return false;
+
+ entry = i->second;
+ return true;
+ }
+
+
+ std::ostream& operator<<(std::ostream& s, const Lsscsi::Entry& entry)
+ {
+ return s << "transport:" << toString(entry.transport);
+ }
+
+}
Added: branches/SuSE-Code-11-SP2-Branch/storage/libstorage/src/Lsscsi.h
URL: http://svn.opensuse.org/viewcvs/yast/branches/SuSE-Code-11-SP2-Branch/stora…
==============================================================================
--- branches/SuSE-Code-11-SP2-Branch/storage/libstorage/src/Lsscsi.h (added)
+++ branches/SuSE-Code-11-SP2-Branch/storage/libstorage/src/Lsscsi.h Tue May 17 13:39:44 2011
@@ -0,0 +1,69 @@
+/*
+ * Copyright (c) 2010 Novell, Inc.
+ *
+ * All Rights Reserved.
+ *
+ * This program is free software; you can redistribute it and/or modify it
+ * under the terms of version 2 of the GNU General Public License as published
+ * by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
+ * more details.
+ *
+ * You should have received a copy of the GNU General Public License along
+ * with this program; if not, contact Novell, Inc.
+ *
+ * To contact Novell about this file by physical or electronic mail, you may
+ * find current contact information at www.novell.com.
+ */
+
+
+#ifndef LSSCSI_H
+#define LSSCSI_H
+
+#include <string>
+#include <map>
+#include <vector>
+
+#include "storage/StorageInterface.h"
+
+
+namespace storage
+{
+ using std::map;
+ using std::vector;
+
+
+ class Lsscsi
+ {
+ public:
+
+ Lsscsi();
+
+ struct Entry
+ {
+ Entry() : transport(TUNKNOWN) {}
+
+ Transport transport;
+ };
+
+ friend std::ostream& operator<<(std::ostream& s, const Entry& entry);
+
+ bool getEntry(const string& device, Entry& entry) const;
+
+ protected:
+
+ void parse(const vector<string>& lines);
+
+ typedef map<string, Entry>::const_iterator const_iterator;
+
+ map<string, Entry> data;
+
+ };
+
+}
+
+
+#endif
Modified: branches/SuSE-Code-11-SP2-Branch/storage/libstorage/src/LvmLv.cc
URL: http://svn.opensuse.org/viewcvs/yast/branches/SuSE-Code-11-SP2-Branch/stora…
==============================================================================
--- branches/SuSE-Code-11-SP2-Branch/storage/libstorage/src/LvmLv.cc (original)
+++ branches/SuSE-Code-11-SP2-Branch/storage/libstorage/src/LvmLv.cc Tue May 17 13:39:44 2011
@@ -1,5 +1,5 @@
/*
- * Copyright (c) [2004-2009] Novell, Inc.
+ * Copyright (c) [2004-2010] Novell, Inc.
*
* All Rights Reserved.
*
@@ -19,30 +19,28 @@
* find current contact information at www.novell.com.
*/
-/*
- Textdomain "storage"
-*/
#include <sstream>
+#include <boost/algorithm/string.hpp>
+
+#include "storage/LvmLv.h"
+#include "storage/LvmVg.h"
+#include "storage/SystemCmd.h"
+#include "storage/AppUtil.h"
+#include "storage/Storage.h"
+#include "storage/StorageDefines.h"
+
+
+namespace storage
+{
+ using namespace std;
-#include "y2storage/LvmLv.h"
-#include "y2storage/LvmVg.h"
-#include "y2storage/SystemCmd.h"
-#include "y2storage/AppUtil.h"
-#include "y2storage/Storage.h"
-#include "y2storage/StorageDefines.h"
-
-using namespace storage;
-using namespace std;
-
-
-LvmLv::LvmLv(const LvmVg& d, const string& name, const string& origi,
- unsigned long le, const string& uuid, const string& stat,
- const string& alloc)
- : Dm( d, dupDash(d.name())+"-"+dupDash(name) ),
- origin(origi)
+
+ LvmLv::LvmLv(const LvmVg& c, const string& name, const string& device, const string& origi,
+ unsigned long le, const string& uuid, const string& stat, const string& alloc)
+ : Dm(c, name, device, makeDmTableName(c.name(), name)), origin(origi)
{
- init( name );
+ Dm::init();
setUuid( uuid );
setStatus( stat );
setAlloc( alloc );
@@ -54,26 +52,50 @@
}
-LvmLv::LvmLv(const LvmVg& d, const string& name, const string& origi,
- unsigned long le, unsigned str)
- : Dm( d, dupDash(d.name())+"-"+dupDash(name) ),
- origin(origi)
+ LvmLv::LvmLv(const LvmVg& c, const string& name, const string& device, const string& origi,
+ unsigned long le, unsigned str)
+ : Dm(c, name, device, makeDmTableName(c.name(), name)), origin(origi)
{
- init( name );
+ Dm::init();
setLe( le );
calcSize();
stripe = str;
fs = detected_fs = FSNONE;
- alt_names.push_back( "/dev/mapper/" + dupDash(cont->name()) + "-" + dupDash(name) );
+ alt_names.push_back("/dev/mapper/" + getTableName());
y2deb("constructed lvm lv dev:" << dev << " vg:" << cont->name() << " origin:" << origin);
}
-LvmLv::~LvmLv()
-{
- y2deb("destructed lvm lv dev:" << dev);
-}
+ LvmLv::LvmLv(const LvmVg& c, const xmlNode* node)
+ : Dm(c, node)
+ {
+ assert(!numeric);
+ assert(num == 0);
+
+ y2deb("constructed LvmLv " << dev);
+ }
+
+
+ LvmLv::LvmLv(const LvmVg& c, const LvmLv& v)
+ : Dm(c, v), origin(v.origin), vol_uuid(v.vol_uuid), status(v.status),
+ allocation(v.allocation)
+ {
+ y2deb("copy-constructed LvmLv " << dev);
+ }
+
+
+ LvmLv::~LvmLv()
+ {
+ y2deb("destructed LvmLv " << dev);
+ }
+
+
+ void
+ LvmLv::saveData(xmlNode* node) const
+ {
+ Dm::saveData(node);
+ }
const LvmVg* LvmLv::vg() const
@@ -82,11 +104,11 @@
}
-void LvmLv::init( const string& name )
+ string
+ LvmLv::makeDmTableName(const string& vg_name, const string& lv_name)
{
- nm = name;
- dev = normalizeDevice( cont->name() + "/" + name );
- Dm::init();
+ return boost::replace_all_copy(vg_name, "-", "--") + "-" +
+ boost::replace_all_copy(lv_name, "-", "--");
}
@@ -98,7 +120,7 @@
}
else
{
- LvmVg::ConstLvmLvPair p = vg()->LvmVg::lvmLvPair(LvmVg::lvNotDeleted);
+ LvmVg::ConstLvmLvPair p = vg()->LvmVg::lvmLvPair(LvmLv::notDeleted);
LvmVg::ConstLvmLvIter i = p.begin();
while( i!=p.end() && i->name()!=origin )
++i;
@@ -118,7 +140,7 @@
bool
LvmLv::hasSnapshots() const
{
- LvmVg::ConstLvmLvPair p = vg()->LvmVg::lvmLvPair(LvmVg::lvNotDeleted);
+ LvmVg::ConstLvmLvPair p = vg()->LvmVg::lvmLvPair(LvmLv::notDeleted);
LvmVg::ConstLvmLvIter i = p.begin();
while( i!=p.end() && i->getOrigin()!=name() )
++i;
@@ -135,7 +157,7 @@
{
for (unsigned int l = 1; l < cmd.numLines(); l++)
{
- string line = *cmd.getLine(l);
+ string line = cmd.getLine(l);
if (extractNthWord(0, line) == name())
{
@@ -150,9 +172,9 @@
}
-string LvmLv::removeText( bool doing ) const
+Text LvmLv::removeText( bool doing ) const
{
- string txt;
+ Text txt;
if( doing )
{
// displayed text during action, %1$s is replaced by device name e.g. /dev/system/var
@@ -168,9 +190,9 @@
return( txt );
}
-string LvmLv::createText( bool doing ) const
+Text LvmLv::createText( bool doing ) const
{
- string txt;
+ Text txt;
if( doing )
{
// displayed text during action, %1$s is replaced by device name e.g. /dev/system/var
@@ -219,9 +241,9 @@
return( txt );
}
-string LvmLv::formatText( bool doing ) const
+Text LvmLv::formatText( bool doing ) const
{
- string txt;
+ Text txt;
if( doing )
{
// displayed text during action, %1$s is replaced by device name e.g. /dev/system/var
@@ -275,9 +297,9 @@
return( txt );
}
-string LvmLv::resizeText( bool doing ) const
+Text LvmLv::resizeText( bool doing ) const
{
- string txt;
+ Text txt;
if( doing )
{
if( needShrink() )
@@ -288,8 +310,9 @@
// displayed text during action, %1$s is replaced by device name e.g. /dev/system/var
// %2$s is replaced by size (e.g. 623.5 MB)
txt = sformat( _("Extending logical volume %1$s to %2$s"), dev.c_str(), sizeString().c_str() );
+ txt += Text(" ", " ");
// text displayed during action
- txt += string(" ") + _("(progress bar might not move)");
+ txt += _("(progress bar might not move)");
}
else
{
@@ -308,9 +331,9 @@
void LvmLv::getInfo( LvmLvInfo& tinfo ) const
{
- ((Volume*)this)->getInfo( info.v );
- info.stripe = stripe;
- info.stripe_size = stripe_size;
+ Volume::getInfo(info.v);
+ info.stripes = stripe;
+ info.stripeSizeK = stripe_size;
info.uuid = vol_uuid;
info.status = status;
info.allocation = allocation;
@@ -323,12 +346,10 @@
tinfo = info;
}
-namespace storage
-{
std::ostream& operator<< (std::ostream& s, const LvmLv &p )
{
- s << *(Dm*)&p;
+ s << dynamic_cast<const Dm&>(p);
if( !p.vol_uuid.empty() )
s << " UUID:" << p.vol_uuid;
if( !p.status.empty() )
@@ -338,7 +359,6 @@
return( s );
}
-}
bool LvmLv::equalContent( const LvmLv& rhs ) const
{
@@ -347,31 +367,15 @@
allocation==rhs.allocation );
}
-void LvmLv::logDifference( const LvmLv& rhs ) const
- {
- string log = stringDifference( rhs );
- if( vol_uuid!=rhs.vol_uuid )
- log += " UUID:" + vol_uuid + "-->" + rhs.vol_uuid;
- if( status!=rhs.status )
- log += " Status:" + status + "-->" + rhs.status;
- if( allocation!=rhs.allocation )
- log += " Alloc:" + allocation + "-->" + rhs.allocation;
- y2mil(log);
- }
-LvmLv& LvmLv::operator= ( const LvmLv& rhs )
+ void
+ LvmLv::logDifference(std::ostream& log, const LvmLv& rhs) const
{
- y2deb("operator= from " << rhs.nm);
- *((Dm*)this) = rhs;
- vol_uuid = rhs.vol_uuid;
- status = rhs.status;
- allocation = rhs.allocation;
- return( *this );
- }
+ Dm::logDifference(log, rhs);
-LvmLv::LvmLv( const LvmVg& d, const LvmLv& rhs ) : Dm(d,rhs)
- {
- y2deb("constructed lvm lv by copy constructor from " << rhs.dev);
- *this = rhs;
+ logDiff(log, "vol_uuid", vol_uuid, rhs.vol_uuid);
+ logDiff(log, "status", status, rhs.status);
+ logDiff(log, "alloc", allocation, rhs.allocation);
}
+}
Modified: branches/SuSE-Code-11-SP2-Branch/storage/libstorage/src/LvmLv.h
URL: http://svn.opensuse.org/viewcvs/yast/branches/SuSE-Code-11-SP2-Branch/stora…
==============================================================================
--- branches/SuSE-Code-11-SP2-Branch/storage/libstorage/src/LvmLv.h (original)
+++ branches/SuSE-Code-11-SP2-Branch/storage/libstorage/src/LvmLv.h Tue May 17 13:39:44 2011
@@ -1,5 +1,5 @@
/*
- * Copyright (c) [2004-2009] Novell, Inc.
+ * Copyright (c) [2004-2010] Novell, Inc.
*
* All Rights Reserved.
*
@@ -23,9 +23,8 @@
#ifndef LVM_LV_H
#define LVM_LV_H
-#include <map>
+#include "storage/Dm.h"
-#include "y2storage/Dm.h"
namespace storage
{
@@ -35,14 +34,17 @@
class LvmLv : public Dm
{
public:
- LvmLv(const LvmVg& d, const string& name, const string& origin, unsigned long le,
- const string& uuid, const string& status, const string& alloc);
- LvmLv(const LvmVg& d, const string& name, const string& origin, unsigned long le,
- unsigned stripe);
- LvmLv(const LvmVg& d, const LvmLv& l);
+ LvmLv(const LvmVg& c, const string& name, const string& device, const string& origin,
+ unsigned long le, const string& uuid, const string& status, const string& alloc);
+ LvmLv(const LvmVg& c, const string& name, const string& device, const string& origin,
+ unsigned long le, unsigned stripe);
+ LvmLv(const LvmVg& c, const xmlNode* node);
+ LvmLv(const LvmVg& c, const LvmLv& v);
virtual ~LvmLv();
+ void saveData(xmlNode* node) const;
+
const LvmVg* vg() const;
void calcSize();
@@ -60,25 +62,35 @@
void setAlloc( const string& a ) { allocation=a; }
friend std::ostream& operator<< (std::ostream& s, const LvmLv &p );
virtual void print( std::ostream& s ) const { s << *this; }
- string removeText( bool doing ) const;
- string createText( bool doing ) const;
- string formatText( bool doing ) const;
- string resizeText( bool doing ) const;
+ Text removeText( bool doing ) const;
+ Text createText( bool doing ) const;
+ Text formatText( bool doing ) const;
+ Text resizeText( bool doing ) const;
void getInfo( storage::LvmLvInfo& info ) const;
bool equalContent( const LvmLv& rhs ) const;
- void logDifference( const LvmLv& d ) const;
+
+ void logDifference(std::ostream& log, const LvmLv& rhs) const;
+
+ static bool notDeleted(const LvmLv& l) { return !l.deleted(); }
protected:
- void init( const string& name );
- virtual const string shortPrintedName() const { return( "Lv" ); }
- LvmLv& operator=( const LvmLv& );
+ static string makeDmTableName(const string& vg_name, const string& lv_name);
+
+ virtual const string shortPrintedName() const { return "Lv"; }
string origin; // only for snapshots, empty otherwise
string vol_uuid;
string status;
string allocation;
- mutable storage::LvmLvInfo info;
+
+ mutable storage::LvmLvInfo info; // workaround for broken ycp bindings
+
+ private:
+
+ LvmLv(const LvmLv&); // disallow
+ LvmLv& operator=(const LvmLv&); // disallow
+
};
}
Modified: branches/SuSE-Code-11-SP2-Branch/storage/libstorage/src/LvmVg.cc
URL: http://svn.opensuse.org/viewcvs/yast/branches/SuSE-Code-11-SP2-Branch/stora…
==============================================================================
--- branches/SuSE-Code-11-SP2-Branch/storage/libstorage/src/LvmVg.cc (original)
+++ branches/SuSE-Code-11-SP2-Branch/storage/libstorage/src/LvmVg.cc Tue May 17 13:39:44 2011
@@ -1,5 +1,5 @@
/*
- * Copyright (c) [2004-2009] Novell, Inc.
+ * Copyright (c) [2004-2010] Novell, Inc.
*
* All Rights Reserved.
*
@@ -19,88 +19,112 @@
* find current contact information at www.novell.com.
*/
-/*
- Textdomain "storage"
-*/
-#include <iostream>
+#include <ostream>
#include <sstream>
-#include "y2storage/LvmVg.h"
-#include "y2storage/LvmLv.h"
-#include "y2storage/SystemCmd.h"
-#include "y2storage/AppUtil.h"
-#include "y2storage/Storage.h"
-#include "y2storage/StorageDefines.h"
+#include "storage/LvmVg.h"
+#include "storage/LvmLv.h"
+#include "storage/SystemCmd.h"
+#include "storage/AppUtil.h"
+#include "storage/Storage.h"
+#include "storage/StorageDefines.h"
+
+
+namespace storage
+{
+ using namespace std;
-using namespace std;
-using namespace storage;
static bool lvNotCreated( const LvmLv& l ) { return( !l.created() ); }
static bool lvNotDeletedCreated( const LvmLv& l ) { return( !l.created()&&!l.deleted() ); }
-LvmVg::LvmVg( Storage * const s, const string& Name ) :
- PeContainer(s,staticType())
+
+ LvmVg::LvmVg(Storage* s, const string& name, const string& device, bool lvm1)
+ : PeContainer(s, name, device, staticType()), lvm1(lvm1)
{
- nm = Name;
- y2deb("constructing lvm vg " << Name);
- init();
- if( !Name.empty() )
- {
- getVgData( Name, false );
- LvmLvPair p=lvmLvPair(lvNotCreated);
- if( !p.empty() )
- getStorage()->waitForDevice( p.begin()->device() );
- }
- else
- {
- y2err("empty name in constructor");
- }
+ y2deb("constructing LvmVg name:" << name << " lvm1:" << lvm1);
+ setCreated(true);
+ }
+
+
+ LvmVg::LvmVg(Storage* s, const string& name, const string& device, SystemInfo& systeminfo)
+ : PeContainer(s, name, device, staticType(), systeminfo), lvm1(false)
+ {
+ y2deb("constructing LvmVg name:" << name);
+ getVgData(name, false);
}
-LvmVg::LvmVg( Storage * const s, const string& Name, bool lv1 ) :
- PeContainer(s,staticType())
+
+ LvmVg::LvmVg(Storage* s, const xmlNode* node)
+ : PeContainer(s, staticType(), node), lvm1(false)
+ {
+ const list<const xmlNode*> l = getChildNodes(node, "logical_volume");
+ for (list<const xmlNode*>::const_iterator it = l.begin(); it != l.end(); ++it)
+ addToList(new LvmLv(*this, *it));
+
+ y2deb("constructed LvmVg " << dev);
+ }
+
+
+ LvmVg::LvmVg(const LvmVg& c)
+ : PeContainer(c), status(c.status), uuid(c.uuid), lvm1(c.lvm1)
{
- nm = Name;
- y2debug( "constructing lvm vg %s lvm1:%d", Name.c_str(), lv1 );
- init();
- lvm1 = lv1;
- if( Name.empty() )
+ y2deb("copy-constructed LvmVg " << dev);
+
+ ConstLvmLvPair p = c.lvmLvPair();
+ for (ConstLvmLvIter i = p.begin(); i != p.end(); ++i)
{
- y2error("empty name in constructor");
+ LvmLv* p = new LvmLv(*this, *i);
+ vols.push_back(p);
}
}
-LvmVg::LvmVg( Storage * const s, const string& file, int ) :
- PeContainer(s,staticType())
+
+ LvmVg::~LvmVg()
{
- y2debug( "constructing lvm vg %s from file %s", dev.c_str(), file.c_str() );
+ y2deb("destructed LvmVg " << dev);
}
-LvmVg::~LvmVg()
+
+ void
+ LvmVg::saveData(xmlNode* node) const
{
- y2deb("destructed lvm vg " << dev);
+ PeContainer::saveData(node);
+
+ ConstLvmLvPair vp = lvmLvPair();
+ for (ConstLvmLvIter v = vp.begin(); v != vp.end(); ++v)
+ v->saveData(xmlNewChild(node, "logical_volume"));
}
+
static bool lvDeleted( const LvmLv& l ) { return( l.deleted() ); }
static bool lvCreated( const LvmLv& l ) { return( l.created() ); }
static bool lvResized( const LvmLv& l ) { return( l.extendSize()!=0 ); }
+
+unsigned
+LvmVg::numLv() const
+{
+ return lvmLvPair(LvmLv::notDeleted).length();
+}
+
+
int
LvmVg::removeVg()
{
int ret = 0;
- y2milestone( "begin" );
+ y2mil("begin");
if( readonly() )
{
ret = LVM_CHANGE_READONLY;
}
if( ret==0 && !created() )
{
- LvmLvPair p=lvmLvPair(lvNotDeleted);
+ LvmLvPair p = lvmLvPair(LvmLv::notDeleted);
for( LvmLvIter i=p.begin(); i!=p.end(); ++i )
ret = removeLv( i->name() );
- setDeleted( true );
+ setDeleted();
}
if( ret==0 )
{
@@ -132,6 +156,10 @@
{
ret = LVM_CHANGE_READONLY;
}
+ else if( devs.empty() )
+ {
+ ret = LVM_LIST_EMPTY;
+ }
while( ret==0 && i!=devs.end() )
{
string d = normalizeDevice( *i );
@@ -180,9 +208,10 @@
if( !getStorage()->isDisk(d))
getStorage()->changeFormatVolume( d, false, FSNONE );
}
- getStorage()->setUsedBy( d, UB_LVM, name() );
+ getStorage()->setUsedBy(d, UB_LVM, device());
free_pe += pe;
num_pe += pe;
+ calcSize();
++i;
}
if( ret==0 && pv_add.size()+pv.size()-pv_remove.size()<=0 )
@@ -221,6 +250,10 @@
{
ret = LVM_CHANGE_READONLY;
}
+ else if( devs.empty() )
+ {
+ ret = LVM_LIST_EMPTY;
+ }
list<string>::const_iterator i = devs.begin();
while( ret==0 && i!=devs.end() )
@@ -239,6 +272,7 @@
pv_remove = plrem;
free_pe -= rem_pe;
num_pe -= rem_pe;
+ calcSize();
}
if( ret==0 )
checkConsistency();
@@ -254,7 +288,7 @@
LvmVg::setPeSize( long long unsigned peSizeK )
{
int ret = 0;
- y2milestone( "old:%llu new:%llu", pe_size, peSizeK );
+ y2mil("old:" << pe_size << " new:" << peSizeK);
if( peSizeK != pe_size )
{
unsigned long long old_pe = pe_size;
@@ -279,7 +313,7 @@
string& device )
{
int ret = 0;
- y2milestone( "name:%s sizeK:%llu stripe:%u", name.c_str(), sizeK, stripe );
+ y2mil("name:" << name << " sizeK:" << sizeK << " stripe:" << stripe);
checkConsistency();
if( readonly() )
{
@@ -291,8 +325,8 @@
}
if( ret==0 )
{
- LvmLvPair p=lvmLvPair(lvNotDeleted);
- LvmLvIter i=p.begin();
+ ConstLvmLvPair p = lvmLvPair(LvmLv::notDeleted);
+ ConstLvmLvIter i = p.begin();
while( i!=p.end() && i->name()!=name )
++i;
if( i!=p.end() )
@@ -310,7 +344,7 @@
ret = addLvPeDistribution( num_le, stripe, pv, pv_add, pe_map );
if( ret==0 )
{
- LvmLv* l = new LvmLv( *this, name, "", num_le, stripe );
+ LvmLv* l = new LvmLv( *this, name, dev + "/" + name, "", num_le, stripe );
l->setCreated( true );
l->setPeMap( pe_map );
device = l->device();
@@ -319,14 +353,14 @@
}
if( ret==0 )
checkConsistency();
- y2milestone( "ret:%d device:%s", ret, ret?"":device.c_str() );
+ y2mil("ret:" << ret << " device:" << (ret?"":device));
return( ret );
}
int LvmVg::resizeVolume( Volume* v, unsigned long long newSize )
{
int ret = 0;
- y2milestone( "newSizeK:%llu vol:%s", newSize, v->name().c_str() );
+ y2mil("newSizeK:" << newSize << " vol:" << v->name());
checkConsistency();
LvmLv * l = dynamic_cast<LvmLv *>(v);
@@ -405,7 +439,7 @@
LvmVg::removeLv( const string& name )
{
int ret = 0;
- y2milestone( "name:%s", name.c_str() );
+ y2mil("name:" << name);
LvmLvIter i;
checkConsistency();
if( readonly() )
@@ -414,7 +448,7 @@
}
if( ret==0 )
{
- LvmLvPair p=lvmLvPair(lvNotDeleted);
+ LvmLvPair p = lvmLvPair(LvmLv::notDeleted);
i=p.begin();
while( i!=p.end() && i->name()!=name )
++i;
@@ -423,9 +457,10 @@
else if (i->hasSnapshots())
ret = LVM_LV_HAS_SNAPSHOTS;
}
- if( ret==0 && i->getUsedByType() != UB_NONE )
+ if (ret == 0 && i->isUsedBy())
{
- if( getStorage()->getRecursiveRemoval() )
+ if( getStorage()->getRecursiveRemoval() ||
+ getStorage()->isUsedBySingleBtrfs(*i) )
ret = getStorage()->removeUsing( i->device(), i->getUsedBy() );
else
ret = LVM_LV_REMOVE_USED_BY;
@@ -444,7 +479,7 @@
ret = LVM_LV_NOT_IN_LIST;
}
else
- i->setDeleted( true );
+ i->setDeleted();
}
y2mil("ret:" << ret);
return( ret );
@@ -454,7 +489,7 @@
LvmVg::changeStripe( const string& name, unsigned long stripe )
{
int ret = 0;
- y2milestone( "name:%s stripe:%lu", name.c_str(), stripe );
+ y2mil("name:" << name << " stripe:" << stripe);
LvmLvIter i;
checkConsistency();
if( readonly() )
@@ -463,7 +498,7 @@
}
if( ret==0 )
{
- LvmLvPair p=lvmLvPair(lvNotDeleted);
+ LvmLvPair p = lvmLvPair(LvmLv::notDeleted);
i=p.begin();
while( i!=p.end() && i->name()!=name )
++i;
@@ -506,7 +541,7 @@
LvmVg::changeStripeSize( const string& name, unsigned long long stripeSize )
{
int ret = 0;
- y2milestone( "name:%s stripeSize:%llu", name.c_str(), stripeSize );
+ y2mil("name:" << name << " stripeSize:" << stripeSize);
LvmLvIter i;
checkConsistency();
if( readonly() )
@@ -515,7 +550,7 @@
}
if( ret==0 )
{
- LvmLvPair p=lvmLvPair(lvNotDeleted);
+ LvmLvPair p = lvmLvPair(LvmLv::notDeleted);
i=p.begin();
while( i!=p.end() && i->name()!=name )
++i;
@@ -558,7 +593,7 @@
int stripe = 1;
if (ret == 0)
{
- LvmLvPair p = lvmLvPair(lvNotDeleted);
+ LvmLvPair p = lvmLvPair(LvmLv::notDeleted);
LvmLvIter i = p.begin();
while (i != p.end() && i->name() != origin)
++i;
@@ -569,7 +604,7 @@
}
if (ret == 0)
{
- LvmLvPair p = lvmLvPair(lvNotDeleted);
+ LvmLvPair p = lvmLvPair(LvmLv::notDeleted);
LvmLvIter i = p.begin();
while (i != p.end() && i->name() != name)
++i;
@@ -588,7 +623,7 @@
ret = addLvPeDistribution(num_le, stripe, pv, pv_add, pe_map);
if (ret == 0)
{
- LvmLv* l = new LvmLv(*this, name, origin, num_le, stripe);
+ LvmLv* l = new LvmLv(*this, name, dev + "/" + name, origin, num_le, stripe);
l->setCreated(true);
l->setPeMap(pe_map);
device = l->device();
@@ -609,7 +644,7 @@
y2mil("name:" << name);
if( ret==0 )
{
- LvmLvPair p=lvmLvPair(lvNotDeleted);
+ LvmLvPair p = lvmLvPair(LvmLv::notDeleted);
LvmLvIter i=p.begin();
while( i!=p.end() && i->name()!=name )
++i;
@@ -636,7 +671,7 @@
checkConsistency();
if (ret == 0)
{
- LvmLvPair p=lvmLvPair(lvNotDeleted);
+ LvmLvPair p = lvmLvPair(LvmLv::notDeleted);
i=p.begin();
while( i!=p.end() && i->name()!=name )
++i;
@@ -660,20 +695,19 @@
void LvmVg::getVgData( const string& name, bool exists )
{
- y2milestone( "name:%s", name.c_str() );
+ y2mil("name:" << name);
SystemCmd c(VGDISPLAYBIN " --units k -v " + quote(name));
unsigned cnt = c.numLines();
unsigned i = 0;
- num_lv = 0;
string line;
string tmp;
string::size_type pos;
while( i<cnt )
{
- line = *c.getLine( i++ );
+ line = c.getLine( i++ );
if( line.find( "Volume group" )!=string::npos )
{
- line = *c.getLine( i++ );
+ line = c.getLine( i++ );
while( line.find( "Logical volume" )==string::npos &&
line.find( "Physical volume" )==string::npos &&
i<cnt )
@@ -683,8 +717,7 @@
{
bool lv1 = extractNthWord( 1, line )=="lvm1";
if( exists && lv1 != lvm1 )
- y2warning( "inconsistent lvm1 my:%d lvm:%d",
- lvm1, lv1 );
+ y2war("inconsistent lvm1 my:" << lvm1 << " lvm:" << lv1);
lvm1 = lv1;
}
else if( line.find( "PE Size" ) == 0 )
@@ -696,13 +729,14 @@
tmp.erase( pos );
tmp >> pes;
if( exists && pes != pe_size )
- y2warning( "inconsistent pe_size my:%llu lvm:%llu",
- pe_size, pes );
+ y2war("inconsistent pe_size my:" << pe_size << " lvm:" << pes);
pe_size = pes;
+ calcSize();
}
else if( line.find( "Total PE" ) == 0 )
{
extractNthWord( 2, line ) >> num_pe;
+ calcSize();
}
else if( line.find( "Free PE" ) == 0 )
{
@@ -720,7 +754,7 @@
{
uuid = extractNthWord( 2, line );
}
- line = *c.getLine( i++ );
+ line = c.getLine( i++ );
}
string vname;
string origin;
@@ -778,7 +812,7 @@
{
uuid = extractNthWord( 2, line );
}
- line = *c.getLine( i++ );
+ line = c.getLine( i++ );
}
if( !vname.empty() )
{
@@ -816,8 +850,9 @@
{
extractNthWord( 5, line ) >> p->num_pe;
extractNthWord( 7, line ) >> p->free_pe;
+ calcSize();
}
- line = *c.getLine( i++ );
+ line = c.getLine( i++ );
}
if( !p->device.empty() )
{
@@ -837,7 +872,6 @@
p=lvmLvPair(lvCreated);
for( LvmLvIter i=p.begin(); i!=p.end(); ++i )
{
- num_lv++;
//cout << "Created:" << *i << endl;
map<string,unsigned long> pe_map;
if( addLvPeDistribution( i->getLe(), i->stripes(), pv, pv_add,
@@ -864,24 +898,19 @@
}
free_pe -= size_diff;
}
- if( num_lv>0 && lvmLvPair().empty() )
- {
- y2milestone( "inactive VG %s num_lv:%u", nm.c_str(), num_lv );
- inactiv = true;
- }
}
void LvmVg::addLv(unsigned long& le, string& name, string& origin, string& uuid,
string& status, string& alloc, bool& ro)
{
- y2milestone( "addLv:%s", name.c_str() );
+ y2mil("addLv:" << name);
LvmLvPair p=lvmLvPair(lvNotDeletedCreated);
LvmLvIter i=p.begin();
while( i!=p.end() && i->name()!=name )
{
++i;
}
- y2milestone( "addLv exists %d", i!=p.end() );
+ y2mil("addLv exists " << (i!=p.end()));
if( i!=p.end() )
{
if( !lvResized( *i ))
@@ -907,18 +936,17 @@
{
++i;
}
- y2milestone( "addLv exists deleted %d", i!=p.end() );
+ y2mil("addLv exists deleted " << (i!=p.end()));
if( i==p.end() )
{
- num_lv++;
- LvmLv *n = new LvmLv( *this, name, origin, le, uuid, status, alloc );
+ LvmLv *n = new LvmLv( *this, name, dev + "/" + name, origin, le, uuid, status, alloc );
if( ro )
n->setReadonly();
if( !n->inactive() )
addToList( n );
else
{
- y2milestone( "inactive Lv %s", name.c_str() );
+ y2mil("inactive Lv " << name);
delete n;
}
}
@@ -931,17 +959,18 @@
void LvmVg::addPv( Pv*& p )
{
- PeContainer::addPv( p );
+ PeContainer::addPv( *p );
if( !deleted() &&
find( pv_remove.begin(), pv_remove.end(), *p )==pv_remove.end() )
- getStorage()->setUsedBy( p->device, UB_LVM, name() );
+ getStorage()->setUsedBy(p->device, UB_LVM, device());
+ delete p;
p = new Pv;
}
-int LvmVg::getToCommit( CommitStage stage, list<Container*>& col,
- list<Volume*>& vol )
- {
- int ret = 0;
+
+void
+LvmVg::getToCommit(CommitStage stage, list<const Container*>& col, list<const Volume*>& vol) const
+{
unsigned long oco = col.size();
unsigned long ovo = vol.size();
Container::getToCommit( stage, col, vol );
@@ -962,13 +991,13 @@
}
}
if( col.size()!=oco || vol.size()!=ovo )
- y2milestone( "ret:%d col:%zd vol:%zd", ret, col.size(), vol.size());
- return( ret );
- }
+ y2mil("stage:" << stage << " col:" << col.size() << " vol:" << vol.size());
+}
+
int LvmVg::commitChanges( CommitStage stage )
{
- y2milestone( "name %s stage %d", name().c_str(), stage );
+ y2mil("name:" << name() << " stage:" << stage);
int ret = 0;
switch( stage )
{
@@ -1004,41 +1033,40 @@
return( ret );
}
-void LvmVg::getCommitActions( list<commitAction*>& l ) const
+
+void
+LvmVg::getCommitActions(list<commitAction>& l) const
{
Container::getCommitActions( l );
y2mil( "Container::getCommitActions:" << l );
if( deleted() )
{
- l.push_back( new commitAction( DECREASE, staticType(),
- removeVgText(false), this, true ));
+ l.push_back(commitAction(DECREASE, staticType(), removeText(false), this, true));
}
else if( created() )
{
- l.push_front( new commitAction( INCREASE, staticType(),
- createVgText(false), this, true ));
+ l.push_front(commitAction(INCREASE, staticType(), createText(false), this, true));
}
else
{
if( !pv_add.empty() )
for( list<Pv>::const_iterator i=pv_add.begin(); i!=pv_add.end();
++i )
- l.push_back( new commitAction( INCREASE, staticType(),
- extendVgText(false,i->device),
- this, true ));
+ l.push_back(commitAction(INCREASE, staticType(),
+ extendText(false, i->device), this, true));
if( !pv_remove.empty() )
for( list<Pv>::const_iterator i=pv_remove.begin();
i!=pv_remove.end(); ++i )
- l.push_back( new commitAction( DECREASE, staticType(),
- reduceVgText(false,i->device),
- this, false ));
+ l.push_back(commitAction(DECREASE, staticType(),
+ reduceText(false, i->device), this, false));
}
}
-string
-LvmVg::removeVgText( bool doing ) const
+
+Text
+LvmVg::removeText(bool doing) const
{
- string txt;
+ Text txt;
if( doing )
{
// displayed text during action, %1$s is replaced by a name (e.g. system),
@@ -1052,31 +1080,35 @@
return( txt );
}
-string
-LvmVg::createVgText( bool doing ) const
+Text
+LvmVg::createText(bool doing) const
{
- string txt;
+ Text txt;
if( doing )
{
- // displayed text during action, %1$s is replaced by a name (e.g. system),
- // %2$ is replaced by one or more devices (e.g /dev/sda1 /dev/sda2)
- txt = sformat( _("Creating volume group %1$s from %2$s"), name().c_str(),
- addList().c_str() );
+ // displayed text during action
+ // %1$s is replaced by a name (e.g. system)
+ // %2$s is replaced by size (e.g. 623.5 MB)
+ // %3$s is replaced by one or more devices (e.g /dev/sda1 /dev/sda2)
+ txt = sformat(_("Creating volume group %1$s (%2$s) from %3$s"), name().c_str(),
+ sizeString().c_str(), addList().c_str());
}
else
{
- // displayed text before action, %1$s is replaced by a name (e.g. system),
- // %2$ is replaced by one or more devices (e.g /dev/sda1 /dev/sda2)
- txt = sformat( _("Create volume group %1$s from %2$s"), name().c_str(),
- addList().c_str() );
+ // displayed text before action
+ // %1$s is replaced by a name (e.g. system)
+ // %2$s is replaced by size (e.g. 623.5 MB)
+ // %3$s is replaced by one or more devices (e.g /dev/sda1 /dev/sda2)
+ txt = sformat(_("Create volume group %1$s (%2$s) from %3$s"), name().c_str(),
+ sizeString().c_str(), addList().c_str());
}
return( txt );
}
-string
-LvmVg::extendVgText( bool doing, const string& dev ) const
+Text
+LvmVg::extendText(bool doing, const string& dev) const
{
- string txt;
+ Text txt;
if( doing )
{
// displayed text during action, %1$s is replaced by a name (e.g. system),
@@ -1094,10 +1126,11 @@
return( txt );
}
-string
-LvmVg::reduceVgText( bool doing, const string& dev ) const
+
+Text
+LvmVg::reduceText(bool doing, const string& dev) const
{
- string txt;
+ Text txt;
if( doing )
{
// displayed text during action, %1$s is replaced by a name (e.g. system),
@@ -1115,20 +1148,13 @@
return( txt );
}
-void
-LvmVg::init()
- {
- PeContainer::init();
- dev = nm;
- normalizeDevice(dev);
- num_lv = 0;
- inactiv = lvm1 = false;
- }
-
void
LvmVg::activate(bool val)
{
+ if (getenv("LIBSTORAGE_NO_LVM") != NULL)
+ return;
+
y2mil("old active:" << active << " val:" << val);
if (active != val)
@@ -1146,47 +1172,41 @@
}
active = val;
}
-}
+ Storage::waitForDevice();
+}
-void
-LvmVg::getVgs(list<string>& l)
-{
- l.clear();
- SystemCmd c(VGDISPLAYBIN " -s");
- if (c.numLines() > 0)
+ list<string>
+ LvmVg::getVgs()
{
- active = true;
+ list<string> l;
- for( unsigned i=0; i<c.numLines(); ++i )
+ SystemCmd c(VGSBIN " --noheadings -o vg_name");
+ if (c.retcode() == 0 && !c.stdout().empty())
{
- string vgname = *c.getLine(i);
- string::size_type pos=vgname.find_first_not_of( app_ws+"\"" );
- if( pos>0 )
- vgname.erase( 0, pos );
- pos=vgname.find_first_of( app_ws+"\"" );
- if( pos>0 )
- vgname.erase( pos );
- l.push_back(vgname);
+ active = true;
+
+ for (vector<string>::const_iterator it = c.stdout().begin(); it != c.stdout().end(); ++it)
+ l.push_back(boost::trim_copy(*it, locale::classic()));
}
- }
- y2mil("detected vgs " << l);
-}
+ y2mil("detected vgs " << l);
+ return l;
+ }
int
LvmVg::doCreateVg()
{
- y2milestone( "Vg:%s", name().c_str() );
+ y2mil("Vg:" << name());
int ret = 0;
if( created() )
{
checkConsistency();
if( !silent )
{
- getStorage()->showInfoCb( createVgText(true) );
+ getStorage()->showInfoCb(createText(true));
}
string devices;
if( pv_add.size()+pv.size()-pv_remove.size()<=0 )
@@ -1202,11 +1222,10 @@
}
if( ret==0 )
{
- string ddir = "/dev/" + name();
- if( access( ddir.c_str(), R_OK )==0 )
+ if (access(device().c_str(), R_OK) == 0)
{
- SystemCmd c( "find " + ddir + " -type l | xargs -r rm" );
- rmdir( ddir.c_str() );
+ SystemCmd c("find " + device() + " -type l | xargs -r rm");
+ rmdir(device().c_str());
}
string cmd = VGCREATEBIN " " + instSysString() + metaString() +
"-s " + decString(pe_size) + "k " + quote(name()) + " " + devices;
@@ -1237,7 +1256,7 @@
int
LvmVg::doRemoveVg()
{
- y2milestone( "Vg:%s", name().c_str() );
+ y2mil("Vg:" << name());
int ret = 0;
if( deleted() )
{
@@ -1245,7 +1264,7 @@
activate(true);
if( !silent )
{
- getStorage()->showInfoCb( removeVgText(true) );
+ getStorage()->showInfoCb(removeText(true));
}
checkConsistency();
string cmd = VGREMOVEBIN " " + quote(name());
@@ -1267,7 +1286,7 @@
int
LvmVg::doExtendVg()
{
- y2milestone( "Vg:%s", name().c_str() );
+ y2mil("Vg:" << name());
y2mil( "this:" << *this );
int ret = 0;
if( !active )
@@ -1279,7 +1298,7 @@
checkConsistency();
if( !silent )
{
- getStorage()->showInfoCb(extendVgText(true, d->device));
+ getStorage()->showInfoCb(extendText(true, d->device));
}
ret = doCreatePv(*d);
if( ret==0 )
@@ -1306,7 +1325,7 @@
}
++d;
}
- if( devs.size()>0 )
+ if (!devs.empty())
checkCreateConstraints();
y2mil( "this:" << *this );
y2mil("ret:" << ret);
@@ -1316,7 +1335,7 @@
int
LvmVg::doReduceVg()
{
- y2milestone( "Vg:%s", name().c_str() );
+ y2mil("Vg:" << name());
y2mil( "this:" << *this );
int ret = 0;
if( !active )
@@ -1328,7 +1347,7 @@
checkConsistency();
if( !silent )
{
- getStorage()->showInfoCb(reduceVgText(true, d->device));
+ getStorage()->showInfoCb(reduceText(true, d->device));
}
string cmd = VGREDUCEBIN " " + instSysString() + quote(name()) + " " + quote(d->realDevice());
SystemCmd c( cmd );
@@ -1357,7 +1376,7 @@
int
LvmVg::doCreate( Volume* v )
{
- y2milestone( "Vg:%s name:%s", name().c_str(), v->name().c_str() );
+ y2mil("Vg:" << name() << " name:" << v->name());
LvmLv * l = dynamic_cast<LvmLv *>(v);
int ret = 0;
if( l != NULL )
@@ -1395,7 +1414,7 @@
}
if( ret==0 )
{
- getStorage()->waitForDevice( l->device() );
+ Storage::waitForDevice(l->device());
l->setCreated(false);
getVgData( name() );
checkConsistency();
@@ -1409,7 +1428,7 @@
int LvmVg::doRemove( Volume* v )
{
- y2milestone( "Vg:%s name:%s", name().c_str(), v->name().c_str() );
+ y2mil("Vg:" << name() << " name:" << v->name());
y2mil( "this:" << *this );
LvmLv * l = dynamic_cast<LvmLv *>(v);
int ret = 0;
@@ -1453,7 +1472,7 @@
int LvmVg::doResize( Volume* v )
{
- y2milestone( "Vg:%s name:%s", name().c_str(), v->name().c_str() );
+ y2mil("Vg:" << name() << " name:" << v->name());
LvmLv * l = dynamic_cast<LvmLv *>(v);
int ret = 0;
if( l != NULL )
@@ -1520,12 +1539,14 @@
return( ret );
}
+
string LvmVg::metaString() const
{
return( (lvm1)?"-M1 ":"-M2 " );
}
-string LvmVg::instSysString()
+
+string LvmVg::instSysString() const
{
string ret;
if( getStorage()->instsys() )
@@ -1535,10 +1556,11 @@
int
- LvmVg::doCreatePv(const Pv& pv) const
+ LvmVg::doCreatePv(const Pv& pv)
{
int ret = 0;
y2mil("device:" << pv.device << " realDevice:" << pv.realDevice());
+ getStorage()->unaccessDev(pv.device);
SystemCmd c;
string cmd = MDADMBIN " --zero-superblock " + quote(pv.realDevice());
c.execute( cmd );
@@ -1562,16 +1584,15 @@
void LvmVg::normalizeDmDevices()
{
+ y2mil( "normalizeDmDevices:" << name() );
string dm = decString(Dm::dmMajor());
- SystemCmd c;
for( list<Pv>::iterator i=pv.begin(); i!=pv.end(); ++i )
{
if( i->device.find( "/dev/dm-" )==0 )
{
- c.execute( "devmap_name "+dm+":"+i->device.substr( 8 ) );
- if( c.retcode()==0 )
+ string dev = getDeviceByNumber( dm+":"+i->device.substr( 8 ) );
+ if( !dev.empty() )
{
- string dev = "/dev/" + *c.getLine( 0 );
y2mil( "dev:" << i->device << " normal dev:" << dev );
if( getStorage()->knownDevice( dev ) )
{
@@ -1586,7 +1607,7 @@
void LvmVg::getInfo( LvmVgInfo& tinfo ) const
{
info.sizeK = sizeK();
- info.peSize = peSize();
+ info.peSizeK = peSize();
info.peCount = peCount();
info.peFree = peFree();
info.lvm2 = lvm2();
@@ -1619,83 +1640,51 @@
info.devices_rem += i->device;
++i;
}
- y2mil( "device:" << info.devices << " devices_add:" << info.devices_add <<
- " devices_rem:" << info.devices_rem );
+ y2mil( "device:" << info.devices );
+ if( !info.devices_add.empty() )
+ y2mil( " devices_add:" << info.devices_add );
+ if( !info.devices_rem.empty() )
+ y2mil( " devices_rem:" << info.devices_rem );
tinfo = info;
}
-namespace storage
-{
std::ostream& operator<< (std::ostream& s, const LvmVg& d )
{
- s << *((PeContainer*)&d);
+ s << dynamic_cast<const PeContainer&>(d);
s << " status:" << d.status;
if( d.lvm1 )
s << " lvm1";
- if( d.inactiv )
- s << " inactive";
- s << " UUID:" << d.uuid
- << " lv:" << d.num_lv;
+ s << " UUID:" << d.uuid;
return( s );
}
-}
-void LvmVg::logDifference( const Container& d ) const
+ void
+ LvmVg::logDifference(std::ostream& log, const LvmVg& rhs) const
{
- const LvmVg * p = dynamic_cast<const LvmVg*>(&d);
- if( p )
- {
- string log = PeContainer::getDiffString( *p );
- if( status!=p->status )
- log += " status:" + status + "-->" + p->status;
- if( lvm1!=p->lvm1 )
- {
- if( p->lvm1 )
- log += " -->lvm1";
- else
- log += " lvm1-->";
- }
- if( uuid!=p->uuid )
- log += " UUID:" + uuid + "-->" + p->uuid;
- y2mil(log);
- ConstLvmLvPair pp=lvmLvPair();
- ConstLvmLvIter i=pp.begin();
- while( i!=pp.end() )
- {
- ConstLvmLvPair pc=p->lvmLvPair();
- ConstLvmLvIter j = pc.begin();
- while( j!=pc.end() &&
- (i->device()!=j->device() || i->created()!=j->created()) )
- ++j;
- if( j!=pc.end() )
- {
- if( !i->equalContent( *j ) )
- i->logDifference( *j );
- }
- else
- y2mil( " -->" << *i );
- ++i;
- }
- pp=p->lvmLvPair();
- i=pp.begin();
- while( i!=pp.end() )
- {
- ConstLvmLvPair pc=lvmLvPair();
- ConstLvmLvIter j = pc.begin();
- while( j!=pc.end() &&
- (i->device()!=j->device() || i->created()!=j->created()) )
- ++j;
- if( j==pc.end() )
- y2mil( " <--" << *i );
- ++i;
- }
- }
- else
- y2mil(Container::getDiffString(d));
+ PeContainer::logDifference(log, rhs);
+
+ logDiff(log, "status", status, rhs.status);
+ logDiff(log, "lvm1", lvm1, rhs.lvm1);
+ logDiff(log, "uuid", uuid, rhs.uuid);
+ }
+
+
+ void
+ LvmVg::logDifferenceWithVolumes(std::ostream& log, const Container& rhs_c) const
+ {
+ const LvmVg& rhs = dynamic_cast<const LvmVg&>(rhs_c);
+
+ logDifference(log, rhs);
+ log << endl;
+
+ ConstLvmLvPair pp = lvmLvPair();
+ ConstLvmLvPair pc = rhs.lvmLvPair();
+ logVolumesDifference(log, pp.begin(), pp.end(), pc.begin(), pc.end());
}
+
bool LvmVg::equalContent( const Container& rhs ) const
{
const LvmVg * p = NULL;
@@ -1704,42 +1693,32 @@
p = dynamic_cast<const LvmVg*>(&rhs);
if( ret && p )
ret = PeContainer::equalContent(*p,false) &&
- status==p->status && uuid==p->uuid && lvm1==p->lvm1 &&
- inactiv==p->inactiv && num_lv==p->num_lv;
+ status==p->status && uuid==p->uuid && lvm1==p->lvm1;
if( ret && p )
{
ConstLvmLvPair pp = lvmLvPair();
ConstLvmLvPair pc = p->lvmLvPair();
- ConstLvmLvIter i = pp.begin();
- ConstLvmLvIter j = pc.begin();
- while( ret && i!=pp.end() && j!=pc.end() )
- {
- ret = ret && i->equalContent( *j );
- ++i;
- ++j;
- }
- ret = ret && i==pp.end() && j==pc.end();
+ ret = ret && storage::equalContent(pp.begin(), pp.end(), pc.begin(), pc.end());
}
return( ret );
}
-LvmVg::LvmVg( const LvmVg& rhs ) : PeContainer(rhs)
+
+ void
+ LvmVg::logData(const string& Dir) const
{
- y2deb("constructed LvmVg by copy constructor from " << rhs.nm);
- status = rhs.status;
- uuid = rhs.uuid;
- lvm1 = rhs.lvm1;
- inactiv = rhs.inactiv;
- num_lv = rhs.num_lv;
- ConstLvmLvPair p = rhs.lvmLvPair();
- for( ConstLvmLvIter i = p.begin(); i!=p.end(); ++i )
- {
- LvmLv * p = new LvmLv( *this, *i );
- vols.push_back( p );
- }
+ string fname(Dir + "/lvmvg_" + name() + ".info.tmp");
+
+ XmlFile xml;
+ xmlNode* node = xmlNewNode("volume_group");
+ xml.setRootElement(node);
+ saveData(node);
+ xml.save(fname);
+
+ getStorage()->handleLogFile( fname );
}
-void LvmVg::logData( const string& Dir ) {;}
bool LvmVg::active = false;
+}
Modified: branches/SuSE-Code-11-SP2-Branch/storage/libstorage/src/LvmVg.h
URL: http://svn.opensuse.org/viewcvs/yast/branches/SuSE-Code-11-SP2-Branch/stora…
==============================================================================
--- branches/SuSE-Code-11-SP2-Branch/storage/libstorage/src/LvmVg.h (original)
+++ branches/SuSE-Code-11-SP2-Branch/storage/libstorage/src/LvmVg.h Tue May 17 13:39:44 2011
@@ -1,5 +1,5 @@
/*
- * Copyright (c) [2004-2009] Novell, Inc.
+ * Copyright (c) [2004-2010] Novell, Inc.
*
* All Rights Reserved.
*
@@ -23,11 +23,14 @@
#ifndef LVM_VG_H
#define LVM_VG_H
-#include "y2storage/PeContainer.h"
-#include "y2storage/LvmLv.h"
+#include "storage/PeContainer.h"
+#include "storage/LvmLv.h"
+
namespace storage
{
+ using std::list;
+
class LvmVg : public PeContainer
{
@@ -35,13 +38,17 @@
friend class LvmLv;
public:
- LvmVg( Storage * const s, const string& Name );
- LvmVg( Storage * const s, const string& Name, bool lvm1 );
- LvmVg( const LvmVg& c );
+
+ LvmVg(Storage* s, const string& name, const string& device, bool lvm1);
+ LvmVg(Storage* s, const string& name, const string& device, SystemInfo& systeminfo);
+ LvmVg(Storage* s, const xmlNode* node);
+ LvmVg(const LvmVg& c);
virtual ~LvmVg();
- unsigned numLv() const { return vols.size(); }
+
+ void saveData(xmlNode* node) const;
+
+ unsigned numLv() const;
bool lvm2() const { return( !lvm1 ); }
- bool inactive() const { return( inactiv ); }
static storage::CType staticType() { return storage::LVM; }
friend std::ostream& operator<< (std::ostream&, const LvmVg& );
@@ -64,21 +71,22 @@
int setPeSize( long long unsigned peSizeK );
void normalizeDmDevices();
- void getCommitActions( std::list<storage::commitAction*>& l ) const;
+ void getCommitActions(list<commitAction>& l) const;
+ void getToCommit(storage::CommitStage stage, list<const Container*>& col,
+ list<const Volume*>& vol) const;
int commitChanges( storage::CommitStage stage );
- int getToCommit( storage::CommitStage stage, std::list<Container*>& col,
- std::list<Volume*>& vol );
int resizeVolume( Volume* v, unsigned long long newSize );
int removeVolume( Volume* v );
void getInfo( storage::LvmVgInfo& info ) const;
bool equalContent( const Container& rhs ) const;
- void logDifference( const Container& rhs ) const;
- static void activate( bool val=true );
+ void logDifference(std::ostream& log, const LvmVg& rhs) const;
+ virtual void logDifferenceWithVolumes(std::ostream& log, const Container& rhs) const;
+
+ static void activate(bool val);
static bool isActive() { return active; }
- static void getVgs( std::list<string>& l );
- static bool lvNotDeleted( const LvmLv& l ) { return( !l.deleted() ); }
+ static list<string> getVgs();
protected:
// iterators over LVM LVs
@@ -129,17 +137,15 @@
return( ConstLvmLvIter( LvmLvCPIterator( p, Check, true )) );
}
- LvmVg( Storage * const s, const string& File, int );
-
void getVgData( const string& name, bool exists=true );
- void init();
+
virtual void print( std::ostream& s ) const { s << *this; }
virtual Container* getCopy() const { return( new LvmVg( *this ) ); }
- string createVgText( bool doing ) const;
- string removeVgText( bool doing ) const;
- string extendVgText( bool doing, const string& dev ) const;
- string reduceVgText( bool doing, const string& dev ) const;
+ Text createText(bool doing) const;
+ Text removeText(bool doing) const;
+ Text extendText(bool doing, const string& dev) const;
+ Text reduceText(bool doing, const string& dev) const;
int doCreateVg();
int doRemoveVg();
@@ -148,12 +154,13 @@
int doCreate( Volume* v );
int doRemove( Volume* v );
int doResize( Volume* v );
- int doCreatePv(const Pv& pv) const;
+ int doCreatePv(const Pv& pv);
string metaString() const;
- string instSysString();
+ string instSysString() const;
+
+ virtual void logData(const string& Dir) const;
- void logData( const string& Dir );
void addLv(unsigned long& le, string& name, string& origin, string& uuid,
string& status, string& alloc, bool& ro);
void addPv( Pv*& p );
@@ -161,10 +168,15 @@
string status;
string uuid;
bool lvm1;
- bool inactiv;
- unsigned num_lv;
+
static bool active;
- mutable storage::LvmVgInfo info;
+
+ mutable storage::LvmVgInfo info; // workaround for broken ycp bindings
+
+ private:
+
+ LvmVg& operator=(const LvmVg&); // disallow
+
};
}
Modified: branches/SuSE-Code-11-SP2-Branch/storage/libstorage/src/Makefile.am
URL: http://svn.opensuse.org/viewcvs/yast/branches/SuSE-Code-11-SP2-Branch/stora…
==============================================================================
--- branches/SuSE-Code-11-SP2-Branch/storage/libstorage/src/Makefile.am (original)
+++ branches/SuSE-Code-11-SP2-Branch/storage/libstorage/src/Makefile.am Tue May 17 13:39:44 2011
@@ -5,11 +5,17 @@
AM_CXXFLAGS =
INCLUDES = -I$(includedir)
-y2storage:
- ln -sf . y2storage
- mkdir .libs
+.libs:
+ mkdir -p .libs
ln -sf . .libs/plugin
+storage:
+ ln -sf . storage
+
+y2storage: storage .libs
+ rm -f y2storage
+ ln -sf . y2storage
+
BUILT_SOURCES = y2storage StorageCallbacksBuiltinTable.h StorageCallbacksBuiltinCalls.h
StorageCallbacksBuiltinTable.h : StorageCallbacks.h
@@ -24,6 +30,7 @@
liby2storage_la_SOURCES = \
StorageInterface.h \
Storage.cc Storage.h \
+ Device.cc Device.h \
Container.cc Container.h \
Disk.cc Disk.h \
Dasd.cc Dasd.h \
@@ -35,6 +42,8 @@
DmCo.cc DmCo.h \
MdPartCo.cc MdPartCo.h \
MdCo.cc MdCo.h \
+ BtrfsCo.cc BtrfsCo.h \
+ TmpfsCo.cc TmpfsCo.h \
LoopCo.cc LoopCo.h \
NfsCo.cc NfsCo.h \
Volume.cc Volume.h \
@@ -46,26 +55,41 @@
Dmmultipath.cc Dmmultipath.h \
MdPart.cc MdPart.h \
Md.cc Md.h \
+ Btrfs.cc Btrfs.h \
+ Tmpfs.cc Tmpfs.h \
Loop.cc Loop.h \
Nfs.cc Nfs.h \
+ HumanString.cc HumanString.h \
+ Graph.cc Graph.h \
SystemCmd.cc SystemCmd.h \
OutputProcessor.cc OutputProcessor.h \
Regex.cc Regex.h \
+ FreeInfo.cc FreeInfo.h \
+ ArchInfo.cc ArchInfo.h \
AsciiFile.cc AsciiFile.h \
- ProcPart.cc ProcPart.h \
- EtcRaidtab.cc EtcRaidtab.h \
+ XmlFile.cc XmlFile.h \
+ SystemInfo.cc SystemInfo.h \
+ ProcParts.cc ProcParts.h \
+ Blkid.cc Blkid.h \
+ Lsscsi.cc Lsscsi.h \
+ Parted.cc Parted.h \
+ Dasdview.cc Dasdview.h \
ProcMounts.cc ProcMounts.h \
+ ProcMdstat.cc ProcMdstat.h \
EtcFstab.cc EtcFstab.h \
+ EtcMdadm.cc EtcMdadm.h \
+ Geometry.cc Geometry.h \
AppUtil.cc AppUtil.h \
+ Enum.cc Enum.h \
Lock.cc Lock.h \
StorageTypes.cc StorageTypes.h \
FilterIterator.h ListListIterator.h \
DerefIterator.h IterPair.h \
- Region.h StorageTmpl.h \
- StorageDefines.h
+ Region.cc Region.h \
+ StorageTmpl.h StorageDefines.h
liby2storage_la_LDFLAGS = -version-info 2:0
-liby2storage_la_LIBADD = -lblocxx
+liby2storage_la_LIBADD = -lblocxx -lxml2
plugin_LTLIBRARIES = libpy2StorageCallbacks.la
Modified: branches/SuSE-Code-11-SP2-Branch/storage/libstorage/src/Md.cc
URL: http://svn.opensuse.org/viewcvs/yast/branches/SuSE-Code-11-SP2-Branch/stora…
==============================================================================
--- branches/SuSE-Code-11-SP2-Branch/storage/libstorage/src/Md.cc (original)
+++ branches/SuSE-Code-11-SP2-Branch/storage/libstorage/src/Md.cc Tue May 17 13:39:44 2011
@@ -1,5 +1,5 @@
/*
- * Copyright (c) [2004-2009] Novell, Inc.
+ * Copyright (c) [2004-2010] Novell, Inc.
*
* All Rights Reserved.
*
@@ -19,269 +19,243 @@
* find current contact information at www.novell.com.
*/
-/*
- Textdomain "storage"
-*/
#include <sstream>
#include <boost/algorithm/string.hpp>
-#include <boost/tokenizer.hpp>
-#include "y2storage/Md.h"
-#include "y2storage/StorageTypes.h"
-#include "y2storage/Storage.h"
-#include "y2storage/AppUtil.h"
-#include "y2storage/SystemCmd.h"
-#include "y2storage/Regex.h"
-#include "y2storage/Container.h"
-#include "y2storage/EtcRaidtab.h"
-#include "y2storage/StorageDefines.h"
-#include "y2storage/MdPartCo.h"
-
-using namespace storage;
-using namespace std;
-
-Md::Md( const MdCo& d, unsigned PNr, MdType Type,
- const list<string>& devices ) : Volume( d, PNr, 0 )
- {
- y2deb("constructed md " << dev << " on container " << cont->name());
- if( d.type() != MD )
- y2err("constructed md with wrong container");
- init();
- md_type = Type;
- has_container = false;
- for( list<string>::const_iterator i=devices.begin(); i!=devices.end(); ++i )
- devs.push_back( normalizeDevice( *i ) );
- computeSize();
- }
+#include "storage/Md.h"
+#include "storage/StorageTypes.h"
+#include "storage/Storage.h"
+#include "storage/AppUtil.h"
+#include "storage/SystemCmd.h"
+#include "storage/Regex.h"
+#include "storage/Container.h"
+#include "storage/EtcMdadm.h"
+#include "storage/StorageDefines.h"
+#include "storage/SystemInfo.h"
-Md::Md( const MdCo& d, const string& line1, const string& line2 )
- : Volume( d, 0, 0 )
- {
- y2mil("constructed md line1:\"" << line1 << "\" line2:\"" << line2 << "\"");
- if( d.type() != MD )
- y2err("constructed md with wrong container");
- init();
- if( mdStringNum( extractNthWord( 0, line1 ), num ))
- {
- nm.clear();
- setNameDev();
- getMajorMinor( dev, mjr, mnr );
- }
- SystemCmd c(MDADMBIN " --detail " + quote(device()));
- c.select( "UUID : " );
- string::size_type pos;
- if( c.retcode()==0 && c.numLines(true)>0 )
- {
- md_uuid = *c.getLine(0,true);
- if( (pos=md_uuid.find( "UUID : " ))!=string::npos )
- md_uuid.erase( 0, pos+7 );
- md_uuid = extractNthWord( 0, md_uuid );
- }
- // "Container" raid: IMSM, DDF
- // "Version" with persistent block
- has_container=false;
- if( c.retcode()==0 )
- {
- if( c.select( "Version : " ) )
- {
- sb_ver = extractNthWord( 2, *c.getLine(0,true) );
- }
- else if ( c.select( "Container : " ) )
- {
- string tmpLine = *c.getLine(0,true);
- string::size_type tmpPos;
- // Line like: Container : /dev/md/imsm0, member 0
- sb_ver = extractNthWord( 2, tmpLine );
- //remove ',' after word.
- tmpPos = sb_ver.find(",");
- sb_ver.erase(tmpPos,tmpPos+1);
- // get Member number
- string member = extractNthWord( 4, tmpLine );
- y2mil("Md " << nm << " has container. Member " << member);
- member >> md_member;
- has_container = true;
- }
- else
- {
- y2war("Did not found neither Version nor Container line!");
- }
- }
- if (c.retcode()==0 && c.numLines(true)>0 )
- {
- y2mil( "line:\"" << *c.getLine(0,true) << "\"" );
- y2mil( "sb_ver:\"" << sb_ver << "\"" );
- y2mil( "word0:\"" << extractNthWord( 0, *c.getLine(0,true)) << "\"" );
- y2mil( "word1:\"" << extractNthWord( 1, *c.getLine(0,true)) << "\"" );
- y2mil( "word2:\"" << extractNthWord( 2, *c.getLine(0,true)) << "\"" );
- }
- string tmp;
- string line = line1;
- if( (pos=line.find( ':' ))!=string::npos )
- line.erase( 0, pos+1 );
- boost::trim_left(line, locale::classic());
- if( (pos=line.find_first_of( app_ws ))!=string::npos )
+
+namespace storage
+{
+ using namespace std;
+
+
+ Md::Md(const MdCo& c, const string& name, const string& device, MdType Type,
+ const list<string>& devices, const list<string>& spares)
+ : Volume(c, name, device), md_type(Type), md_parity(PAR_DEFAULT), chunk_k(0),
+ sb_ver("01.00.00"), destrSb(false), devs(devices), spare(spares), has_container(false)
{
- if (line.substr(0, pos) == "active")
- line.erase(0, pos);
+ y2deb("constructed Md " << dev << " on " << cont->device());
+
+ assert(c.type() == MD);
+
+ numeric = true;
+ mdStringNum(name, num);
+
+ getStorage()->addUsedBy(devs, UB_MD, dev);
+ getStorage()->addUsedBy(spares, UB_MD, dev);
+
+ computeSize();
}
- boost::trim_left(line, locale::classic());
- if( (pos=line.find_first_of( app_ws ))!=string::npos )
+
+
+ Md::Md(const MdCo& c, const string& name, const string& device, SystemInfo& systeminfo)
+ : Volume(c, name, device, systeminfo), md_type(RAID_UNK), md_parity(PAR_DEFAULT),
+ chunk_k(0), sb_ver("01.00.00"), destrSb(false), has_container(false)
+ {
+ y2deb("constructed Md " << device << " on " << cont->device());
+
+ assert(c.type() == MD);
+
+ numeric = true;
+ mdStringNum(name, num);
+
+ getMajorMinor();
+ getStorage()->fetchDanglingUsedBy(dev, uby);
+
+ ProcMdstat::Entry entry;
+ if (!systeminfo.getProcMdstat().getEntry(nm, entry))
+ y2err("not found in mdstat nm:" << nm);
+
+ md_type = entry.md_type;
+ md_parity = entry.md_parity;
+
+ setSize(entry.size_k);
+ chunk_k = entry.chunk_k;
+
+ devs = entry.devices;
+ spare = entry.spares;
+
+ if (entry.readonly)
+ setReadonly();
+
+ if (entry.has_container)
{
- tmp = line.substr( 0, pos );
- if( tmp=="(read-only)" || tmp=="(auto-read-only)" || tmp=="inactive" )
+ has_container = true;
+ parent_container = entry.container_name;
+
+ MdadmDetails details;
+ if (getMdadmDetails("/dev/" + entry.container_name, details))
{
- setReadonly();
- y2war("readonly or inactive md device " << nr());
- line.erase( 0, pos );
- boost::trim_left(line, locale::classic());
+ parent_uuid = details.uuid;
+ parent_md_name = details.devname;
+ parent_metadata = details.metadata;
}
+
+ parent_member = entry.container_member;
+
+ sb_ver = parent_metadata;
}
- boost::trim_left(line, locale::classic());
- if( (pos=line.find_first_of( app_ws ))!=string::npos )
+ else
{
- if( line.substr( 0, pos ).find( "active" )!=string::npos )
- line.erase( 0, pos );
+ sb_ver = entry.super;
}
- boost::trim_left(line, locale::classic());
- tmp = extractNthWord( 0, line );
- md_type = toMdType( tmp );
- if( md_type == RAID_UNK )
- {
- y2war("unknown raid type " << tmp);
- }
- if( (pos=line.find_first_of( app_ws ))!=string::npos )
- line.erase( 0, pos );
- if( (pos=line.find_first_not_of( app_ws ))!=string::npos && pos!=0 )
- line.erase( 0, pos );
- while( (pos=line.find_first_not_of( app_ws ))==0 )
- {
- tmp = extractNthWord( 0, line );
- string::size_type bracket = tmp.find( '[' );
- if( bracket!=string::npos )
- devs.push_back( normalizeDevice(tmp.substr( 0, bracket )));
- else
- {
- normalizeDevice(tmp);
- devs.push_back( tmp );
- }
- line.erase( 0, tmp.length() );
- if( (pos=line.find_first_not_of( app_ws ))!=string::npos && pos!=0 )
- line.erase( 0, pos );
- }
- unsigned long long longnum;
- extractNthWord( 0, line2 ) >> longnum;
- setSize( longnum );
- chunk = 0;
- pos = line2.find( "chunk" );
- if( pos != string::npos )
- {
- pos = line2.find_last_not_of( app_ws, pos-1 );
- pos = line2.find_last_of( app_ws, pos );
- line2.substr( pos+1 ) >> chunk;
- }
- md_parity = PAR_NONE;
- pos = line2.find( "algorithm" );
- if( pos != string::npos )
- {
- unsigned alg = 999;
- pos = line2.find_first_of( app_ws, pos );
- pos = line2.find_first_not_of( app_ws, pos );
- line2.substr( pos ) >> alg;
- switch( alg )
- {
- case 0:
- md_parity = LEFT_ASYMMETRIC;
- break;
- case 1:
- md_parity = RIGHT_ASYMMETRIC;
- break;
- case 2:
- md_parity = LEFT_SYMMETRIC;
- break;
- case 3:
- md_parity = RIGHT_SYMMETRIC;
- break;
- default:
- y2war("unknown parity " << line2.substr(pos));
- break;
- }
+
+ setUdevData(systeminfo);
+
+ MdadmDetails details;
+ if (getMdadmDetails(dev, details))
+ {
+ md_uuid = details.uuid;
+ md_name = details.devname;
}
- if( has_container )
- {
- getParent();
- }
- // Get md_name. It's important.
- string tmpUuid;
- MdPartCo::getUuidName(nm,tmpUuid,md_name);
+
+ getStorage()->addUsedBy(devs, UB_MD, dev);
+ getStorage()->addUsedBy(spare, UB_MD, dev);
}
-Md::~Md()
+
+ Md::Md(const MdCo& c, const Md& v)
+ : Volume(c, v), md_type(v.md_type), md_parity(v.md_parity),
+ chunk_k(v.chunk_k), md_uuid(v.md_uuid), md_name(v.md_name),
+ sb_ver(v.sb_ver), destrSb(v.destrSb), devs(v.devs), spare(v.spare),
+ udev_id(udev_id),
+ has_container(v.has_container), parent_container(v.parent_container),
+ parent_uuid(v.parent_uuid), parent_md_name(v.parent_md_name),
+ parent_metadata(v.parent_metadata), parent_member(v.parent_member)
{
- y2deb("destructed md " << dev);
+ y2deb("copy-constructed Md from " << v.dev);
}
-void
-Md::init()
+
+ Md::~Md()
{
- destrSb = false;
- md_parity = PAR_NONE;
- chunk = 0;
- sb_ver = "01.00.00";
- md_type = RAID_UNK;
+ y2deb("destructed Md " << dev);
}
-void
-Md::getDevs( list<string>& devices, bool all, bool spares ) const
+
+ void
+ Md::updateData(SystemInfo& systeminfo)
{
- if( !all )
- devices = spares ? spare : devs;
- else
+ ProcMdstat::Entry entry;
+ if (systeminfo.getProcMdstat().getEntry(nm, entry))
+ {
+ if (md_type != entry.md_type)
+ y2war("inconsistent md_type my:" << toString(md_type) << " kernel:" << toString(entry.md_type));
+ if (md_parity != PAR_DEFAULT && md_parity != entry.md_parity)
+ y2war("inconsistent md_parity my:" << toString(md_parity) << " kernel:" << toString(entry.md_parity));
+ if (chunk_k > 0 && chunk_k != entry.chunk_k)
+ y2war("inconsistent chunk my:" << chunk_k << " kernel:" << entry.chunk_k);
+
+ md_type = entry.md_type;
+ md_parity = entry.md_parity;
+
+ setSize(entry.size_k);
+ chunk_k = entry.chunk_k;
+ }
+ else
+ {
+ y2err("not found in mdstat nm:" << nm);
+ }
+
+ MdadmDetails details;
+ if (getMdadmDetails("/dev/" + nm, details))
{
- devices = devs;
- devices.insert( devices.end(), spare.begin(), spare.end() );
+ setMdUuid(details.uuid);
}
}
+
+ void
+ Md::setUdevData(SystemInfo& systeminfo)
+ {
+ const UdevMap& by_id = systeminfo.getUdevMap("/dev/disk/by-id");
+ UdevMap::const_iterator it = by_id.find(nm);
+ if (it != by_id.end())
+ {
+ udev_id = it->second;
+ partition(udev_id.begin(), udev_id.end(), string_starts_with("md-uuid-"));
+ }
+ else
+ {
+ udev_id.clear();
+ }
+
+ y2mil("dev:" << dev << " udev_id:" << udev_id);
+
+ alt_names.remove_if(string_starts_with("/dev/disk/by-id/"));
+ for (list<string>::const_iterator i = udev_id.begin(); i != udev_id.end(); ++i)
+ alt_names.push_back("/dev/disk/by-id/" + *i);
+ }
+
+
+ list<string>
+ Md::getDevs(bool all, bool spares) const
+ {
+ list<string> ret;
+ if (!all)
+ {
+ ret = spares ? spare : devs;
+ }
+ else
+ {
+ ret = devs;
+ ret.insert(ret.end(), spare.begin(), spare.end());
+ }
+ return ret;
+ }
+
+
int
-Md::addDevice( const string& dev, bool to_spare )
+Md::addDevice(const string& new_dev, bool to_spare)
{
int ret = 0;
- string d = normalizeDevice( dev );
- if( find( devs.begin(), devs.end(), dev )!=devs.end() ||
- find( spare.begin(), spare.end(), dev )!=spare.end() )
+ if (find(devs.begin(), devs.end(), new_dev) != devs.end() ||
+ find(spare.begin(), spare.end(), new_dev) != spare.end())
{
ret = MD_ADD_DUPLICATE;
}
if( ret==0 )
{
- if( to_spare )
- {
- spare.push_back(d);
- }
+ if (!to_spare)
+ devs.push_back(new_dev);
else
- {
- devs.push_back(d);
- computeSize();
- }
+ spare.push_back(new_dev);
+ getStorage()->addUsedBy(new_dev, UB_MD, dev);
+ computeSize();
}
- y2mil("dev:" << dev << " spare:" << to_spare << " ret:" << ret);
- return( ret );
+ y2mil("new_dev:" << new_dev << " to_spare:" << to_spare << " ret:" << ret);
+ return ret;
}
+
int
Md::removeDevice( const string& dev )
{
int ret = 0;
- string d = normalizeDevice( dev );
list<string>::iterator i;
if( (i=find( devs.begin(), devs.end(), dev ))!=devs.end() )
{
devs.erase(i);
+ getStorage()->clearUsedBy(dev);
computeSize();
}
else if( (i=find( spare.begin(), spare.end(), dev ))!=spare.end() )
+ {
spare.erase(i);
+ getStorage()->clearUsedBy(dev);
+ computeSize();
+ }
else
ret = MD_REMOVE_NONEXISTENT;
y2mil("dev:" << dev << " ret:" << ret);
@@ -304,60 +278,36 @@
break;
}
int ret = devs.size()<nmin ? MD_TOO_FEW_DEVICES : 0;
- y2mil("type:" << md_type << " min:" << nmin << " size:" << devs.size() <<
+
+ if (ret == 0 && md_type == RAID0 && !spare.empty())
+ ret = MD_TOO_MANY_SPARES;
+
+ y2mil("type:" << toString(md_type) << " min:" << nmin << " size:" << devs.size() <<
" ret:" << ret);
return( ret );
}
-void
+
+int
Md::getState(MdStateInfo& info) const
{
- SystemCmd c(MDADMBIN " --detail " + quote(device()));
+ string value;
+ if (read_sysfs_property(sysfsPath() + "/md/array_state", value))
+ if (toValue(value, info.state))
+ return STORAGE_NO_ERROR;
- c.select("State : ");
- if( c.retcode()==0 && c.numLines(true)>0 )
- {
- string state = *c.getLine(0,true);
- string::size_type pos;
- if( (pos=state.find( "State : " ))!=string::npos )
- state.erase( 0, pos+8 );
-
- typedef boost::tokenizer<boost::char_separator<char>> char_tokenizer;
- char_tokenizer toker(state, boost::char_separator<char>(","));
-
- info.active = false;
- info.degraded = false;
- for (char_tokenizer::const_iterator it = toker.begin(); it != toker.end(); it++)
- {
- string s = boost::trim_copy(*it, locale::classic());
- if (s == "active")
- info.active = true;
- else if (s == "degraded")
- info.degraded = true;
- }
- }
+ return MD_GET_STATE_FAILED;
}
+
void
Md::computeSize()
{
- unsigned long long size_k;
- getContainer()->getStorage()->computeMdSize(md_type, devs, size_k);
+ unsigned long long size_k = 0;
+ getStorage()->computeMdSize(md_type, devs, spare, size_k);
setSize(size_k);
}
-void
-Md::addSpareDevice( const string& dev )
- {
- string d = normalizeDevice(dev);
- if( find( spare.begin(), spare.end(), d )!=spare.end() ||
- find( devs.begin(), devs.end(), d )!=devs.end() )
- {
- y2war("spare " << dev << " already present");
- }
- else
- spare.push_back(d);
- }
void Md::changeDeviceName( const string& old, const string& nw )
{
@@ -373,16 +323,15 @@
string
Md::createCmd() const
{
- string cmd = "ls -l --full-time " + quote(devs) + " " + quote(spare) + "; ";
- cmd += MODPROBEBIN " " + pName() + "; " MDADMBIN " --create " + quote(device()) +
- " --run --level=" + pName() + " -e 1.0";
- if (pName() == "raid1" || pName() == "raid5" || pName() == "raid6" ||
- pName() == "raid10")
+ string cmd = LSBIN " -l --full-time " + quote(devs) + " " + quote(spare) + "; "
+ MODPROBEBIN " " + toString(md_type) + "; " MDADMBIN " --create " + quote(device()) +
+ " --run --level=" + toString(md_type) + " -e 1.0";
+ if (md_type == RAID1 || md_type == RAID5 || md_type == RAID6 || md_type == RAID10)
cmd += " -b internal";
- if (chunk > 0)
- cmd += " --chunk=" + decString(chunk);
- if (md_parity != PAR_NONE)
- cmd += " --parity=" + ptName();
+ if (chunk_k > 0)
+ cmd += " --chunk=" + decString(chunk_k);
+ if (md_parity != PAR_DEFAULT)
+ cmd += " --parity=" + toString(md_parity);
cmd += " --raid-devices=" + decString(devs.size());
if (!spare.empty())
cmd += " --spare-devices=" + decString(spare.size());
@@ -392,197 +341,123 @@
}
-string Md::mdadmLine() const
- {
- string line = "ARRAY " + device() + " level=" + pName();
- line += " UUID=" + md_uuid;
- y2mil("line:" << line);
- return( line );
- }
-
-void Md::raidtabLines( list<string>& lines ) const
- {
- lines.clear();
- lines.push_back( "raiddev " + device() );
- string tmp = " raid-level ";
- switch( md_type )
- {
- case RAID1:
- tmp += "1";
- break;
- case RAID5:
- tmp += "5";
- break;
- case RAID6:
- tmp += "6";
- break;
- case RAID10:
- tmp += "10";
- break;
- case MULTIPATH:
- tmp += "multipath";
- break;
- default:
- tmp += "0";
- break;
- }
- lines.push_back( tmp );
- lines.push_back( " nr-raid-disks " + decString(devs.size()));
- lines.push_back( " nr-spare-disks " + decString(spare.size()));
- lines.push_back( " persistent-superblock 1" );
- if( md_parity!=PAR_NONE )
- lines.push_back( " parity-algorithm " + ptName());
- if( chunk>0 )
- lines.push_back( " chunk-size " + decString(chunk));
- unsigned cnt = 0;
- for( list<string>::const_iterator i=devs.begin(); i!=devs.end(); ++i )
- {
- lines.push_back( " device " + *i);
- lines.push_back( " raid-disk " + decString(cnt++));
- }
- cnt = 0;
- for( list<string>::const_iterator i=spare.begin(); i!=spare.end(); ++i )
- {
- lines.push_back( " device " + *i);
- lines.push_back( " spare-disk " + decString(cnt++));
- }
- }
-
-string Md::removeText( bool doing ) const
- {
- string txt;
- string d = dev;
+Text Md::removeText( bool doing ) const
+{
+ Text txt;
if( doing )
- {
+ {
// displayed text during action, %1$s is replaced by device name e.g. /dev/md0
- txt = sformat( _("Deleting software RAID %1$s"), d.c_str() );
- }
+ txt = sformat(_("Deleting software RAID %1$s"), dev.c_str());
+ }
else
- {
+ {
// displayed text before action, %1$s is replaced by device name e.g. md0
// %2$s is replaced by size (e.g. 623.5 MB)
- txt = sformat( _("Delete software RAID %1$s (%2$s)"), d.c_str(),
- sizeString().c_str() );
- }
- return( txt );
+ txt = sformat(_("Delete software RAID %1$s (%2$s)"), dev.c_str(),
+ sizeString().c_str());
}
+ return txt;
+}
-string Md::createText( bool doing ) const
- {
- string txt;
- string d = dev;
+
+Text Md::createText( bool doing ) const
+{
+ Text txt;
if( doing )
- {
+ {
// displayed text during action, %1$s is replaced by device name e.g. /dev/md0
- txt = sformat( _("Creating software RAID %1$s"), d.c_str() );
- }
+ // %2$s is replaced by one or more devices (e.g /dev/sda1 /dev/sda2)
+ txt = sformat(_("Creating software RAID %1$s from %2$s"), dev.c_str(),
+ boost::join(devs, " ").c_str());
+ }
else
- {
+ {
if( !mp.empty() )
- {
+ {
if( encryption==ENC_NONE )
- {
+ {
// displayed text before action, %1$s is replaced by device name e.g. md0
// %2$s is replaced by size (e.g. 623.5 MB)
// %3$s is replaced by file system type (e.g. reiserfs)
// %4$s is replaced by mount point (e.g. /usr)
- txt = sformat( _("Create software RAID %1$s (%2$s) for %4$s with %3$s"),
- d.c_str(), sizeString().c_str(), fsTypeString().c_str(),
- mp.c_str() );
- }
+ // %5$s is replaced by one or more devices (e.g /dev/sda1 /dev/sda2)
+ txt = sformat(_("Create software RAID %1$s (%2$s) from %5$s for %4$s with %3$s"),
+ dev.c_str(), sizeString().c_str(), fsTypeString().c_str(),
+ mp.c_str(), boost::join(devs, " ").c_str());
+ }
else
- {
+ {
// displayed text before action, %1$s is replaced by device name e.g. md0
// %2$s is replaced by size (e.g. 623.5 MB)
// %3$s is replaced by file system type (e.g. reiserfs)
// %4$s is replaced by mount point (e.g. /usr)
- txt = sformat( _("Create encrypted software RAID %1$s (%2$s) for %4$s with %3$s"),
- d.c_str(), sizeString().c_str(), fsTypeString().c_str(),
- mp.c_str() );
- }
+ // %5$s is replaced by one or more devices (e.g /dev/sda1 /dev/sda2)
+ txt = sformat(_("Create encrypted software RAID %1$s (%2$s) from %5$s for %4$s with %3$s"),
+ dev.c_str(), sizeString().c_str(), fsTypeString().c_str(),
+ mp.c_str(), boost::join(devs, " ").c_str());
}
+ }
else
- {
+ {
// displayed text before action, %1$s is replaced by device name e.g. md0
// %2$s is replaced by size (e.g. 623.5 MB)
- txt = sformat( _("Create software RAID %1$s (%2$s)"),
- dev.c_str(), sizeString().c_str() );
- }
+ // %3$s is replaced by one or more devices (e.g /dev/sda1 /dev/sda2)
+ txt = sformat(_("Create software RAID %1$s (%2$s) from %3$s"), dev.c_str(),
+ sizeString().c_str(), boost::join(devs, " ").c_str());
}
- return( txt );
}
+ return txt;
+}
-string Md::formatText( bool doing ) const
- {
- string txt;
- string d = dev;
+
+Text Md::formatText( bool doing ) const
+{
+ Text txt;
if( doing )
- {
+ {
// displayed text during action, %1$s is replaced by device name e.g. /dev/md0
// %2$s is replaced by size (e.g. 623.5 MB)
// %3$s is replaced by file system type (e.g. reiserfs)
- txt = sformat( _("Formatting software RAID %1$s (%2$s) with %3$s "),
- d.c_str(), sizeString().c_str(), fsTypeString().c_str() );
- }
+ txt = sformat(_("Formatting software RAID %1$s (%2$s) with %3$s "),
+ dev.c_str(), sizeString().c_str(), fsTypeString().c_str());
+ }
else
- {
+ {
if( !mp.empty() )
- {
+ {
if( encryption==ENC_NONE )
- {
+ {
// displayed text before action, %1$s is replaced by device name e.g. /dev/md0
// %2$s is replaced by size (e.g. 623.5 MB)
// %3$s is replaced by file system type (e.g. reiserfs)
// %4$s is replaced by mount point (e.g. /usr)
- txt = sformat( _("Format software RAID %1$s (%2$s) for %4$s with %3$s"),
- d.c_str(), sizeString().c_str(),
- fsTypeString().c_str(), mp.c_str() );
- }
+ txt = sformat(_("Format software RAID %1$s (%2$s) for %4$s with %3$s"),
+ dev.c_str(), sizeString().c_str(), fsTypeString().c_str(),
+ mp.c_str());
+ }
else
- {
+ {
// displayed text before action, %1$s is replaced by device name e.g. /dev/md0
// %2$s is replaced by size (e.g. 623.5 MB)
// %3$s is replaced by file system type (e.g. reiserfs)
// %4$s is replaced by mount point (e.g. /usr)
- txt = sformat( _("Format encrypted software RAID %1$s (%2$s) for %4$s with %3$s"),
- d.c_str(), sizeString().c_str(),
- fsTypeString().c_str(), mp.c_str() );
- }
+ txt = sformat(_("Format encrypted software RAID %1$s (%2$s) for %4$s with %3$s"),
+ dev.c_str(), sizeString().c_str(), fsTypeString().c_str(),
+ mp.c_str());
}
+ }
else
- {
+ {
// displayed text before action, %1$s is replaced by device name e.g. /dev/md0
// %2$s is replaced by size (e.g. 623.5 MB)
// %3$s is replaced by file system type (e.g. reiserfs)
- txt = sformat( _("Format software RAID %1$s (%2$s) with %3$s"),
- d.c_str(), sizeString().c_str(),
- fsTypeString().c_str() );
- }
- }
- return( txt );
- }
-
-MdType
-Md::toMdType( const string& val )
- {
- enum MdType ret = MULTIPATH;
- while( ret!=RAID_UNK && val!=md_names[ret] )
- {
- ret = MdType(ret-1);
+ txt = sformat(_("Format software RAID %1$s (%2$s) with %3$s"),
+ dev.c_str(), sizeString().c_str(), fsTypeString().c_str());
}
- return( ret );
}
+ return txt;
+}
-MdParity
-Md::toMdParity( const string& val )
- {
- enum MdParity ret = RIGHT_SYMMETRIC;
- while( ret!=PAR_NONE && val!=par_names[ret] )
- {
- ret = MdParity(ret-1);
- }
- return( ret );
- }
bool Md::matchRegex( const string& dev )
{
@@ -615,220 +490,130 @@
computeSize();
}
+int Md::setParity( MdParity val )
+ {
+ int ret = 0;
+ list<int> pars = getStorage()->getMdAllowedParity( md_type, devs.size() );
+ if( find( pars.begin(), pars.end(), val )!=pars.end() )
+ md_parity=val;
+ else
+ ret = MD_INVALID_PARITY;
+ return( ret );
+ }
+
unsigned Md::mdMajor()
{
if( md_major==0 )
- getMdMajor();
+ {
+ md_major = getMajorDevices("md");
+ y2mil("md_major:" << md_major);
+ }
return( md_major );
}
-void Md::getMdMajor()
+
+ string
+ Md::sysfsPath() const
{
- md_major = getMajorDevices( "md" );
- y2mil("md_major:" << md_major);
+ return SYSFSDIR "/" + procName();
}
void Md::getInfo( MdInfo& tinfo ) const
{
- ((Volume*)this)->getInfo( info.v );
+ Volume::getInfo(info.v);
info.nr = num;
info.type = md_type;
info.uuid = md_uuid;
info.sb_ver = sb_ver;
- info.chunk = chunk;
+ info.chunkSizeK = chunk_k;
info.parity = md_parity;
info.devices = boost::join(devs, " ");
+ info.spares = boost::join(spare, " ");
tinfo = info;
}
-namespace storage
-{
std::ostream& operator<< (std::ostream& s, const Md& m )
{
- s << "Md " << *(Volume*)&m
- << " Personality:" << m.pName();
- if( m.chunk>0 )
- s << " Chunk:" << m.chunk;
- if( m.md_parity!=storage::PAR_NONE )
- s << " Parity:" << m.ptName();
+ s << "Md " << dynamic_cast<const Volume&>(m)
+ << " Personality:" << toString(m.md_type);
+ if (m.chunk_k > 0)
+ s << " ChunkK:" << m.chunk_k;
+ if (m.md_parity != PAR_DEFAULT)
+ s << " Parity:" << toString(m.md_parity);
if( !m.sb_ver.empty() )
s << " SbVer:" << m.sb_ver;
- if( !m.md_uuid.empty() )
- s << " MD UUID:" << m.md_uuid;
+ if (!m.md_uuid.empty())
+ s << " md_uuid:" << m.md_uuid;
+ if (!m.md_name.empty())
+ s << " md_name:" << m.md_name;
if( m.destrSb )
s << " destroySb";
s << " Devices:" << m.devs;
if( !m.spare.empty() )
s << " Spares:" << m.spare;
- return( s );
+ return s;
}
-}
bool Md::equalContent( const Md& rhs ) const
{
return( Volume::equalContent(rhs) &&
md_type==rhs.md_type && md_parity==rhs.md_parity &&
- chunk==rhs.chunk && md_uuid==rhs.md_uuid && sb_ver==rhs.sb_ver &&
+ chunk_k==rhs.chunk_k && md_uuid==rhs.md_uuid && sb_ver==rhs.sb_ver &&
destrSb==rhs.destrSb && devs == rhs.devs && spare==rhs.spare );
}
-void Md::logDifference( const Md& rhs ) const
- {
- string log = Volume::logDifference( rhs );
- if( md_type!=rhs.md_type )
- log += " Personality:" + md_names[md_type] + "-->" +
- md_names[rhs.md_type];
- if( md_parity!=rhs.md_parity )
- log += " Parity:" + par_names[md_parity] + "-->" +
- par_names[rhs.md_parity];
- if( chunk!=rhs.chunk )
- log += " Chunk:" + decString(chunk) + "-->" + decString(rhs.chunk);
- if( sb_ver!=rhs.sb_ver )
- log += " SbVer:" + sb_ver + "-->" + rhs.sb_ver;
- if( md_uuid!=rhs.md_uuid )
- log += " MD-UUID:" + md_uuid + "-->" + rhs.md_uuid;
- if( destrSb!=rhs.destrSb )
- {
- if( rhs.destrSb )
- log += " -->destrSb";
- else
- log += " destrSb-->";
- }
- if( devs!=rhs.devs )
- {
- std::ostringstream b;
- classic(b);
- b << " Devices:" << devs << "-->" << rhs.devs;
- log += b.str();
- }
- if( spare!=rhs.spare )
- {
- std::ostringstream b;
- classic(b);
- b << " Spares:" << spare << "-->" << rhs.spare;
- log += b.str();
- }
- y2mil(log);
- }
-Md& Md::operator= ( const Md& rhs )
+ void
+ Md::logDifference(std::ostream& log, const Md& rhs) const
{
- y2deb("operator= from " << rhs.nm);
- *((Volume*)this) = rhs;
- md_type = rhs.md_type;
- md_parity = rhs.md_parity;
- chunk = rhs.chunk;
- md_uuid = rhs.md_uuid;
- sb_ver = rhs.sb_ver;
- destrSb = rhs.destrSb;
- devs = rhs.devs;
- spare = rhs.spare;
+ Volume::logDifference(log, rhs);
- has_container = rhs.has_container;
- md_metadata = rhs.md_metadata;
- parent_container = rhs.parent_container;
- parent_uuid = rhs.parent_uuid;
- parent_md_name = rhs.parent_md_name;
- parent_metadata = rhs.parent_metadata;
- md_member = rhs.md_member;
+ logDiffEnum(log, "md_type", md_type, rhs.md_type);
+ logDiffEnum(log, "md_parity", md_parity, rhs.md_parity);
+ logDiff(log, "chunk_k", chunk_k, rhs.chunk_k);
+ logDiff(log, "sb_ver", sb_ver, rhs.sb_ver);
+ logDiff(log, "md_uuid", md_uuid, rhs.md_uuid);
+ logDiff(log, "md_name", md_name, rhs.md_name);
+ logDiff(log, "destrSb", destrSb, rhs.destrSb);
+ logDiff(log, "devices", devs, rhs.devs);
+ logDiff(log, "spares", spare, rhs.spare);
- return( *this );
+ logDiff(log, "parent_container", parent_container, rhs.parent_container);
+ logDiff(log, "parent_md_name", parent_md_name, rhs.parent_md_name);
+ logDiff(log, "parent_metadata", parent_metadata, rhs.parent_metadata);
+ logDiff(log, "parent_uuid", parent_uuid, rhs.parent_uuid);
}
-Md::Md( const MdCo& d, const Md& rhs ) : Volume(d)
+
+ bool
+ Md::updateEntry(EtcMdadm* mdadm) const
{
- y2deb("constructed md by copy constructor from " << rhs.dev);
- *this = rhs;
- }
+ EtcMdadm::mdconf_info info;
+ if (!md_name.empty())
+ info.device = "/dev/md/" + md_name;
+ else
+ info.device = dev;
-void Md::getParent()
-{
- //in this case sb_ver will contain something like /dev/md/imsm0
- string tmp;
- string::size_type pos;
- SystemCmd c(MDADMBIN " --detail " + quote(sb_ver) + " --export");
- if( c.retcode() != 0 )
- {
- return;
- }
- parent_container = sb_ver;
- if( c.select( "MD_METADATA" ) > 0 )
- {
- md_metadata = sb_ver;
- tmp = *c.getLine(0,true);
- pos = tmp.find("=");
- tmp.erase(0,pos+1);
- parent_metadata = sb_ver = tmp;
- }
- if(c.select( "MD_UUID" ) > 0)
- {
- tmp = *c.getLine(0,true);
- pos = tmp.find("=");
- tmp.erase(0,pos+1);
- parent_uuid = tmp;
- }
- if( c.select( "MD_DEVNAME" ) > 0)
- {
- tmp = *c.getLine(0,true);
- pos = tmp.find("=");
- tmp.erase(0,pos+1);
- parent_md_name = tmp;
- }
- y2mil("parent_container="<<parent_container<<", sb_ver="<<sb_ver<<", parent_uuid="<<parent_uuid
- <<", parent_md_name="<<parent_md_name<<", member="<<md_member);
-}
+ info.uuid = md_uuid;
-int Md::updateEntry(EtcRaidtab* tab)
-{
- if( !tab )
- {
- return -1;
- }
- EtcRaidtab::mdconf_info info;
- if( !md_name.empty() )
- {
- //Raid name is preferred.
- info.fs_name = "/dev/md/" + md_name;
- }
- else
- {
- info.fs_name = dev;
- }
- info.md_uuid = md_uuid;
- if( has_container )
- {
- info.container_present = true;
- info.container_info.md_uuid = parent_uuid;
- info.container_info.metadata = parent_metadata;
- stringstream ss;
- ss << md_member;
- info.member = ss.str();
- }
- else
- {
- info.container_present = false;
- }
- if( tab->updateEntry( info ) )
- {
- return 0;
- }
- else
- {
- return -1;
- }
-}
+ if (has_container)
+ {
+ info.container_present = true;
+ info.container_uuid = parent_uuid;
+ info.container_metadata = parent_metadata;
+ info.container_member = parent_member;
+ }
+ return mdadm->updateEntry(info);
+ }
-string Md::md_names[] = { "unknown", "raid0", "raid1", "raid5", "raid6",
- "raid10", "multipath" };
-string Md::par_names[] = { "none", "left-asymmetric", "left-symmetric",
- "right-asymmetric", "right-symmetric" };
unsigned Md::md_major = 0;
+}
Modified: branches/SuSE-Code-11-SP2-Branch/storage/libstorage/src/Md.h
URL: http://svn.opensuse.org/viewcvs/yast/branches/SuSE-Code-11-SP2-Branch/stora…
==============================================================================
--- branches/SuSE-Code-11-SP2-Branch/storage/libstorage/src/Md.h (original)
+++ branches/SuSE-Code-11-SP2-Branch/storage/libstorage/src/Md.h Tue May 17 13:39:44 2011
@@ -1,5 +1,5 @@
/*
- * Copyright (c) [2004-2009] Novell, Inc.
+ * Copyright (c) [2004-2010] Novell, Inc.
*
* All Rights Reserved.
*
@@ -23,99 +23,105 @@
#ifndef MD_H
#define MD_H
-#include "y2storage/StorageInterface.h"
-#include "y2storage/Volume.h"
+#include "storage/StorageInterface.h"
+#include "storage/Volume.h"
namespace storage
{
-class EtcRaidtab;
-class MdCo;
+ class MdCo;
+ class EtcMdadm;
+
class Md : public Volume
{
- public:
- Md( const MdCo& d, unsigned Pnr, storage::MdType Type,
- const std::list<string>& devs );
- Md( const MdCo& d, const string& line, const string& line2 );
- Md( const MdCo& d, const Md& m );
+ friend class MdPartCo;
+ public:
+ Md(const MdCo& c, const string& name, const string& device, MdType Type,
+ const list<string>& devs, const list<string>& spares);
+ Md(const MdCo& c, const string& name, const string& device, SystemInfo& systeminfo);
+ Md(const MdCo& c, const Md& v);
virtual ~Md();
+
storage::MdType personality() const { return md_type; }
void setPersonality( storage::MdType val );
storage::MdParity parity() const { return md_parity; }
- void setParity( storage::MdParity val ) { md_parity=val; }
- unsigned long chunkSize() const { return chunk; }
- void setChunkSize( unsigned long val ) { chunk=val; }
+ int setParity( storage::MdParity val );
+ unsigned long chunkSizeK() const { return chunk_k; }
+ void setChunkSizeK(unsigned long val) { chunk_k = val; }
void setMdUuid( const string&val ) { md_uuid=val; }
bool destroySb() const { return( destrSb ); }
void setDestroySb( bool val=true ) { destrSb=val; }
const string& getMdUuid() const { return(md_uuid); }
- const string& pName() const { return md_names[md_type]; }
- const string& ptName() const { return par_names[md_parity]; }
- void getDevs( std::list<string>& devices, bool all=true, bool spare=false ) const;
- void addSpareDevice( const string& dev );
+ list<string> getDevs(bool all = true, bool spare = false) const;
int checkDevices();
int addDevice( const string& dev, bool spare=false );
int removeDevice( const string& dev );
- void raidtabLines( std::list<string>& ) const ;
- string mdadmLine() const;
string createCmd() const;
static bool matchRegex( const string& dev );
static unsigned mdMajor();
- static const string& pName( storage::MdType t ) { return md_names[t]; }
+ void updateData(SystemInfo& systeminfo);
+ void setUdevData(SystemInfo& systeminfo);
+
+ virtual list<string> udevId() const { return udev_id; }
+
+ virtual string procName() const { return nm; }
+ virtual string sysfsPath() const;
+
static bool mdStringNum( const string& name, unsigned& num );
static string mdDevice( unsigned num );
friend std::ostream& operator<< (std::ostream& s, const Md& m );
virtual void print( std::ostream& s ) const { s << *this; }
- string removeText( bool doing ) const;
- string createText( bool doing ) const;
- string formatText( bool doing ) const;
+ Text removeText( bool doing ) const;
+ Text createText( bool doing ) const;
+ Text formatText( bool doing ) const;
static bool notDeleted( const Md& l ) { return( !l.deleted() ); }
void changeDeviceName( const string& old, const string& nw );
void getInfo( storage::MdInfo& info ) const;
bool equalContent( const Md& rhs ) const;
- void logDifference( const Md& d ) const;
- void getState(MdStateInfo& info) const;
- int updateEntry(EtcRaidtab* tab);
+ void logDifference(std::ostream& log, const Md& rhs) const;
+
+ int getState(MdStateInfo& info) const;
+
+ bool updateEntry(EtcMdadm* mdadm) const;
protected:
- void init();
+
void computeSize();
- Md& operator=( const Md& );
- static void getMdMajor();
- static storage::MdType toMdType( const string& val );
- static storage::MdParity toMdParity( const string& val );
-
- void getParent();
- void setMetadata();
-
- storage::MdType md_type;
- storage::MdParity md_parity;
- unsigned long chunk;
+ MdType md_type;
+ MdParity md_parity;
+ unsigned long chunk_k;
string md_uuid;
+ string md_name; // line in /dev/md/*
string sb_ver;
bool destrSb;
- std::list<string> devs;
- std::list<string> spare;
- string md_name; // line in /dev/md/*
-
- //in case of IMSM and DDF raids there is 'container'.
- bool has_container;
- string md_metadata;
+ list<string> devs;
+ list<string> spare;
+
+ list<string> udev_id;
+
+ // In case of IMSM and DDF raids there is 'container'.
+ bool has_container;
string parent_container;
string parent_uuid;
string parent_md_name;
string parent_metadata;
- int md_member;
- static string md_names[storage::MULTIPATH+1];
- static string par_names[storage::RIGHT_SYMMETRIC+1];
+ string parent_member;
+
static unsigned md_major;
- mutable storage::MdInfo info;
+
+ mutable storage::MdInfo info; // workaround for broken ycp bindings
+
+ private:
+
+ Md(const Md&); // disallow
+ Md& operator=(const Md&); // disallow
+
};
}
Modified: branches/SuSE-Code-11-SP2-Branch/storage/libstorage/src/MdCo.cc
URL: http://svn.opensuse.org/viewcvs/yast/branches/SuSE-Code-11-SP2-Branch/stora…
==============================================================================
--- branches/SuSE-Code-11-SP2-Branch/storage/libstorage/src/MdCo.cc (original)
+++ branches/SuSE-Code-11-SP2-Branch/storage/libstorage/src/MdCo.cc Tue May 17 13:39:44 2011
@@ -1,5 +1,5 @@
/*
- * Copyright (c) [2004-2009] Novell, Inc.
+ * Copyright (c) [2004-2010] Novell, Inc.
*
* All Rights Reserved.
*
@@ -19,180 +19,79 @@
* find current contact information at www.novell.com.
*/
-/*
- Textdomain "storage"
-*/
-#include <iostream>
-#include <sstream>
+#include <ostream>
+#include <fstream>
-#include "y2storage/MdCo.h"
-#include "y2storage/Md.h"
-#include "y2storage/MdPartCo.h"
-#include "y2storage/SystemCmd.h"
-#include "y2storage/AppUtil.h"
-#include "y2storage/Storage.h"
-#include "y2storage/EtcRaidtab.h"
-#include "y2storage/StorageDefines.h"
+#include "storage/MdCo.h"
+#include "storage/Md.h"
+#include "storage/SystemCmd.h"
+#include "storage/AppUtil.h"
+#include "storage/Storage.h"
+#include "storage/EtcMdadm.h"
+#include "storage/StorageDefines.h"
+#include "storage/AsciiFile.h"
+#include "storage/SystemInfo.h"
-using namespace std;
-using namespace storage;
-MdCo::MdCo( Storage * const s, bool detect ) :
- Container(s,"md",staticType())
- {
- y2deb("constructing MdCo detect:" << detect);
- init();
- if( detect )
- getMdData();
- }
+namespace storage
+{
+ using namespace std;
-MdCo::MdCo( Storage * const s, const string& file ) :
- Container(s,"md",staticType())
- {
- y2deb("constructing MdCo file:" << file);
- init();
- }
-MdCo::~MdCo()
+ MdCo::MdCo(Storage* s)
+ : Container(s, "md", "/dev/md", staticType())
{
- y2deb("destructed MdCo");
+ y2deb("constructing MdCo");
}
-void
-MdCo::init()
- {
- mjr = Md::mdMajor();
- }
-
-void
-MdCo::syncRaidtab()
-{
- MdPair p=mdPair(Md::notDeleted);
- for( MdIter i=p.begin(); i!=p.end(); ++i )
+ MdCo::MdCo(Storage* s, SystemInfo& systeminfo)
+ : Container(s, "md", "/dev/md", staticType(), systeminfo)
{
- //updateEntry( &(*i) );
- i->updateEntry(getStorage()->getRaidtab());
+ y2deb("constructing MdCo");
+
+ const ProcMdstat& procmdstat = systeminfo.getProcMdstat();
+ for (ProcMdstat::const_iterator it = procmdstat.begin(); it != procmdstat.end(); ++it)
+ {
+ if (!it->second.is_container && !isHandledByMdPart(it->first))
+ {
+ Md* m = new Md(*this, it->first, "/dev/" + it->first, systeminfo);
+ addMd(m);
+ }
+ }
}
-}
-void MdCo::updateEntry( const Md* m )
+ MdCo::MdCo(const MdCo& c)
+ : Container(c)
{
- EtcRaidtab* tab = getStorage()->getRaidtab();
- if (tab)
+ y2deb("copy-constructed MdCo from " << c.dev);
+
+ ConstMdPair p = c.mdPair();
+ for (ConstMdIter i = p.begin(); i != p.end(); ++i)
{
- list<string> lines;
- list<string> devices;
- m->raidtabLines(lines);
- m->getDevs( devices );
- tab->updateEntry( m->nr(), lines, m->mdadmLine(), devices );
+ Md* p = new Md(*this, *i);
+ vols.push_back(p);
}
}
-void
-MdCo::getMdData()
+
+ MdCo::~MdCo()
{
- y2milestone( "begin" );
- string line;
- std::ifstream file( "/proc/mdstat" );
- classic(file);
- getline( file, line );
- while( file.good() )
- {
- string mdDev = extractNthWord( 0, line );
- string line2;
- getline(file,line2);
-
- if( canHandleDev(mdDev,line2) )
- {
- Md* m = new Md( *this, line, line2 );
- addMd( m );
- getline(file,line);
- }
- else
- {
- line = line2;
- }
- }
- file.close();
- file.clear();
- file.open( (getStorage()->root()+"/etc/raidtab").c_str() );
- MdIter i;
- getline( file, line );
- while( file.good() )
- {
- y2mil( "raidtab line:" << line );
- if( extractNthWord( 0, line )=="raiddev" )
- {
- string md = extractNthWord( 1, line );
- getline( file, line );
- y2mil( "raidtab line:" << line );
- if( findMd( md, i ))
- {
- string key;
- string device;
- while( file.good() &&
- (key=extractNthWord( 0, line ))!="raiddev" )
- {
- if( key=="device" )
- device = extractNthWord( 1, line );
- else if( key=="spare-disk" )
- {
- if( !device.empty() )
- {
- normalizeDevice(device);
- i->addSpareDevice( device );
- device.clear();
- }
- }
- getline( file, line );
- }
- }
- else
- y2warning( "raid %s from /etc/raidtab not found", md.c_str() );
- }
- getline( file, line );
- }
- MdPair p=mdPair(Md::notDeleted);
- for( MdIter i=p.begin(); i!=p.end(); ++i )
- {
- string num = "md"+decString(i->nr());
- list<string> devs;
- i->getDevs( devs );
- for( list<string>::iterator s=devs.begin(); s!=devs.end(); ++s )
- {
- y2mil( " Setting device " << *s << " as used by UB_MD" );
- getStorage()->setUsedBy( *s, UB_MD, num );
- }
- }
+ y2deb("destructed MdCo " << dev);
}
-void
-MdCo::getMdData( unsigned num )
+
+ void
+ MdCo::syncMdadm(EtcMdadm* mdadm) const
{
- y2milestone( "num:%u", num );
- string line;
- std::ifstream file( "/proc/mdstat" );
- classic(file);
- string md = "md" + decString(num);
- getline( file, line );
- while( file.good() )
- {
- y2mil( "mdstat line:" << line );
- if( extractNthWord( 0, line ) == md )
- {
- string line2;
- getline( file, line2 );
- y2mil( "mdstat line2:" << line );
- Md* m = new Md( *this, line, line2 );
- checkMd( m );
- }
- getline( file, line );
- }
+ ConstMdPair p = mdPair(Md::notDeleted);
+ for (ConstMdIter it = p.begin(); it != p.end(); ++it)
+ it->updateEntry(mdadm);
}
+
void
MdCo::addMd( Md* m )
{
@@ -200,37 +99,11 @@
addToList( m );
else
{
- y2warning( "addMd alread exists %u", m->nr() );
+ y2war("addMd already exists " << m->nr());
delete m;
}
}
-void
-MdCo::checkMd( Md* m )
- {
- MdIter i;
- if( findMd( m->nr(), i ))
- {
- i->setSize( m->sizeK() );
- i->setMdUuid( m->getMdUuid() );
- i->setCreated( false );
- if( m->personality()!=i->personality() )
- y2warning( "inconsistent raid type my:%s kernel:%s",
- i->pName().c_str(), m->pName().c_str() );
- if( i->parity()!=storage::PAR_NONE && m->parity()!=i->parity() )
- y2warning( "inconsistent parity my:%s kernel:%s",
- i->ptName().c_str(), m->ptName().c_str() );
- if( i->chunkSize()>0 && m->chunkSize()!=i->chunkSize() )
- y2warning( "inconsistent chunk size my:%lu kernel:%lu",
- i->chunkSize(), m->chunkSize() );
- }
- else
- {
- y2warning( "checkMd does not exist %u", m->nr() );
- }
- delete m;
- }
-
bool
MdCo::findMd( unsigned num, MdIter& i )
@@ -269,24 +142,24 @@
}
-int
-MdCo::usedNumbers(list<int>& nums)
-{
- MdPair p=mdPair(Md::notDeleted);
- MdIter i;
- nums.clear();
- for(i=p.begin(); i!=p.end(); i++ )
+ list<unsigned>
+ MdCo::usedNumbers() const
{
- nums.push_back(i->nr());
+ list<unsigned> nums;
+
+ ConstMdPair p = mdPair(Md::notDeleted);
+ for (ConstMdIter i = p.begin(); i != p.end(); ++i)
+ nums.push_back(i->nr());
+
+ return nums;
}
- return 0;
-}
+
int
-MdCo::createMd( unsigned num, MdType type, const list<string>& devs )
+MdCo::createMd(unsigned num, MdType type, const list<string>& devs, const list<string>& spares)
{
int ret = 0;
- y2mil( "num:" << num << " type:" << Md::pName(type) << " devs:" << devs );
+ y2mil("num:" << num << " type:" << toString(type) << " devs:" << devs << " spares:" << spares);
if( readonly() )
{
ret = MD_CHANGE_READONLY;
@@ -304,22 +177,14 @@
if( findMd( num ))
ret = MD_DUPLICATE_NUMBER;
}
- list<string>::const_iterator i=devs.begin();
- while( ret==0 && i!=devs.end() )
- {
- ret = checkUse( normalizeDevice( *i ) );
- ++i;
- }
- i=devs.begin();
- while( ret==0 && i!=devs.end() )
- {
- string d = normalizeDevice( *i );
- getStorage()->setUsedBy( d, UB_MD, "md"+decString(num) );
- ++i;
- }
+
+ if (ret == 0)
+ ret = checkUse(devs, spares);
+
if( ret==0 )
{
- Md* m = new Md( *this, num, type, devs );
+ string name = "md" + decString(num);
+ Md* m = new Md(*this, name, "/dev/" + name, type, devs, spares);
m->setCreated( true );
addToList( m );
}
@@ -327,27 +192,40 @@
return( ret );
}
-int MdCo::checkUse( const string& dev )
+
+ int
+ MdCo::checkUse(const list<string>& devs, const list<string>& spares) const
{
- int ret = 0;
- const Volume* v = getStorage()->getVolume( dev );
- if( v==NULL )
- {
- ret = MD_DEVICE_UNKNOWN;
- }
- else if( !v->canUseDevice() )
+ int ret = 0;
+
+ list<string> all = devs;
+ all.insert(all.end(), spares.begin(), spares.end());
+
+ for (list<string>::const_iterator it = all.begin(); it != all.end(); ++it)
{
- ret = MD_DEVICE_USED;
+ const Volume* v = getStorage()->getVolume(*it);
+ if (v == NULL)
+ {
+ ret = MD_DEVICE_UNKNOWN;
+ break;
+ }
+ else if (!v->canUseDevice())
+ {
+ ret = MD_DEVICE_USED;
+ break;
+ }
}
- y2milestone( "dev:%s ret:%d", dev.c_str(), ret );
- return( ret );
+
+ y2mil("devs:" << devs << " spares:" << spares << " ret:" << ret);
+ return ret;
}
+
int
MdCo::checkMd( unsigned num )
{
int ret = 0;
- y2milestone( "num:%u", num );
+ y2mil("num:" << num);
MdIter i;
if( !findMd( num, i ) )
ret = MD_DEVICE_UNKNOWN;
@@ -358,10 +236,10 @@
}
int
-MdCo::extendMd( unsigned num, const string& dev )
+MdCo::extendMd(unsigned num, const list<string>& devs, const list<string>& spares)
{
int ret = 0;
- y2milestone( "num:%u dev:%s", num, dev.c_str() );
+ y2mil("num:" << num << " devs:" << devs << " spares:" << spares);
MdIter i;
if( readonly() )
{
@@ -369,7 +247,7 @@
}
if( ret==0 )
{
- ret = checkUse( normalizeDevice( dev ) );
+ ret = checkUse(devs, spares);
}
if( ret==0 )
{
@@ -382,26 +260,29 @@
}
if( ret==0 )
{
- ret = i->addDevice( dev );
+ for (list<string>::const_iterator it = devs.begin(); it != devs.end(); ++it)
+ if ((ret = i->addDevice(*it)) != 0)
+ break;
}
- if( ret==0 && !getStorage()->isDisk(dev) )
+ if( ret==0 )
{
- getStorage()->changeFormatVolume( dev, false, FSNONE );
+ for (list<string>::const_iterator it = spares.begin(); it != spares.end(); ++it)
+ if ((ret = i->addDevice(*it, true)) != 0)
+ break;
}
- if( ret==0 )
+ if( ret==0 && !getStorage()->isDisk(dev) )
{
- string d = normalizeDevice( dev );
- getStorage()->setUsedBy( d, UB_MD, "md"+decString(num) );
+ getStorage()->changeFormatVolume( dev, false, FSNONE );
}
y2mil("ret:" << ret);
return( ret );
}
int
-MdCo::shrinkMd( unsigned num, const string& dev )
+MdCo::shrinkMd(unsigned num, const list<string>& devs, const list<string>& spares)
{
int ret = 0;
- y2milestone( "num:%u dev:%s", num, dev.c_str() );
+ y2mil("num:" << num << " devs:" << devs << " spares:" << spares);
MdIter i;
if( readonly() )
{
@@ -418,12 +299,15 @@
}
if( ret==0 )
{
- ret = i->removeDevice( dev );
+ for (list<string>::const_iterator it = devs.begin(); it != devs.end(); ++it)
+ if ((ret = i->removeDevice(*it)) != 0)
+ break;
}
if( ret==0 )
{
- string d = normalizeDevice( dev );
- getStorage()->clearUsedBy(d);
+ for (list<string>::const_iterator it = spares.begin(); it != spares.end(); ++it)
+ if ((ret = i->removeDevice(*it)) != 0)
+ break;
}
y2mil("ret:" << ret);
return( ret );
@@ -433,7 +317,7 @@
MdCo::changeMdType( unsigned num, MdType ptype )
{
int ret = 0;
- y2milestone( "num:%u md_type:%d", num, ptype );
+ y2mil("num:" << num << " md_type:" << toString(ptype));
MdIter i;
if( readonly() )
{
@@ -460,7 +344,7 @@
MdCo::changeMdChunk( unsigned num, unsigned long chunk )
{
int ret = 0;
- y2milestone( "num:%u chunk:%lu", num, chunk );
+ y2mil("num:" << num << " chunk:" << chunk);
MdIter i;
if( readonly() )
{
@@ -477,7 +361,7 @@
}
if( ret==0 )
{
- i->setChunkSize( chunk );
+ i->setChunkSizeK(chunk);
}
y2mil("ret:" << ret);
return( ret );
@@ -487,7 +371,7 @@
MdCo::changeMdParity( unsigned num, MdParity ptype )
{
int ret = 0;
- y2milestone( "num:%u parity:%d", num, ptype );
+ y2mil("num:" << num << " parity:" << toString(ptype));
MdIter i;
if( readonly() )
{
@@ -504,7 +388,7 @@
}
if( ret==0 )
{
- i->setParity( ptype );
+ ret = i->setParity( ptype );
}
y2mil("ret:" << ret);
return( ret );
@@ -526,9 +410,9 @@
}
if( ret==0 )
{
- i->getState(info);
+ ret = i->getState(info);
}
- y2milestone("ret:%d", ret);
+ y2mil("ret:" << ret);
return ret;
}
@@ -536,7 +420,7 @@
MdCo::removeMd( unsigned num, bool destroySb )
{
int ret = 0;
- y2milestone( "num:%u", num );
+ y2mil("num:" << num);
MdIter i;
if( readonly() )
{
@@ -547,16 +431,14 @@
if( !findMd( num, i ))
ret = MD_UNKNOWN_NUMBER;
}
- if( ret==0 && i->getUsedByType() != UB_NONE )
+ if (ret == 0 && i->isUsedBy())
{
ret = MD_REMOVE_USED_BY;
}
if( ret==0 )
{
- list<string> devs;
- i->getDevs( devs );
- for( list<string>::const_iterator s=devs.begin(); s!=devs.end(); ++s )
- getStorage()->clearUsedBy(*s);
+ getStorage()->clearUsedBy(i->getDevs());
+
if( i->created() )
{
if( !removeFromList( &(*i) ))
@@ -564,7 +446,7 @@
}
else
{
- i->setDeleted( true );
+ i->setDeleted();
i->setDestroySb( destroySb );
}
}
@@ -575,7 +457,7 @@
int MdCo::removeVolume( Volume* v )
{
int ret = 0;
- y2milestone( "name:%s", v->name().c_str() );
+ y2mil("name:" << v->name());
Md * m = dynamic_cast<Md *>(v);
if( m != NULL )
ret = removeMd( v->nr() );
@@ -586,21 +468,21 @@
void MdCo::activate( bool val, const string& tmpDir )
{
- y2milestone( "old active:%d val:%d tmp:%s", active, val, tmpDir.c_str() );
+ if (getenv("LIBSTORAGE_NO_MDRAID") != NULL)
+ return;
+
+ y2mil("old active:" << active << " val:" << val << " tmp:" << tmpDir);
if( active!=val )
{
SystemCmd c;
if( val )
{
string mdconf = tmpDir + "/mdadm.conf";
- string cmd = "echo 1 > /sys/module/md_mod/parameters/start_ro";
- c.execute( cmd );
- cmd = MDADMBIN " --examine --scan --config=partitions >" + mdconf;
- c.execute( cmd );
- cmd = "cat " + mdconf;
- c.execute( cmd );
- cmd = MDADMBIN " --assemble --scan --config=" + mdconf;
- c.execute( cmd );
+ c.execute("echo 1 > /sys/module/md_mod/parameters/start_ro");
+ c.execute(MDADMBIN " --examine --scan --config=partitions > " + mdconf);
+ AsciiFile(mdconf).logContent();
+ c.execute(MDADMBIN " --assemble --scan --config=" + mdconf);
+ unlink(mdconf.c_str());
}
else
{
@@ -608,12 +490,13 @@
}
active = val;
}
+ Storage::waitForDevice();
}
int
MdCo::doCreate( Volume* v )
{
- y2milestone( "name:%s", v->name().c_str() );
+ y2mil("name:" << v->name());
Md * m = dynamic_cast<Md *>(v);
int ret = 0;
if( m != NULL )
@@ -625,11 +508,11 @@
ret = m->checkDevices();
if( ret==0 )
{
- list<string> devs;
- m->getDevs( devs );
+ list<string> devs = m->getDevs();
for( list<string>::iterator i = devs.begin(); i!=devs.end(); ++i )
{
getStorage()->removeDmTableTo( *i );
+ getStorage()->unaccessDev(*i);
}
}
if( ret==0 )
@@ -644,15 +527,19 @@
}
if( ret==0 )
{
- getStorage()->waitForDevice( m->device() );
- getMdData( m->nr() );
- updateEntry( m );
- bool used_as_pv = m->getUsedByType() == UB_LVM;
- y2milestone( "zeroNew:%d used_as_pv:%d",
- getStorage()->getZeroNewPartitions(), used_as_pv );
+ m->setCreated(false);
+ Storage::waitForDevice(m->device());
+ SystemInfo systeminfo;
+ m->updateData(systeminfo);
+ m->setUdevData(systeminfo);
+ EtcMdadm* mdadm = getStorage()->getMdadm();
+ if (mdadm)
+ m->updateEntry(mdadm);
+ bool used_as_pv = m->isUsedBy(UB_LVM);
+ y2mil("zeroNew:" << getStorage()->getZeroNewPartitions() << " used_as_pv:" << used_as_pv);
if( used_as_pv || getStorage()->getZeroNewPartitions() )
{
- ret = getStorage()->zeroDevice(m->device(), m->sizeK());
+ ret = Storage::zeroDevice(m->device(), m->sizeK());
}
}
}
@@ -665,7 +552,7 @@
int
MdCo::doRemove( Volume* v )
{
- y2milestone( "name:%s", v->name().c_str() );
+ y2mil("name:" << v->name());
Md * m = dynamic_cast<Md *>(v);
int ret = 0;
if( m != NULL )
@@ -690,8 +577,7 @@
if( ret==0 && m->destroySb() )
{
SystemCmd c;
- list<string> d;
- m->getDevs( d );
+ list<string> d = m->getDevs();
for( list<string>::const_iterator i=d.begin(); i!=d.end(); ++i )
{
c.execute(MDADMBIN " --zero-superblock " + quote(*i));
@@ -699,11 +585,9 @@
}
if( ret==0 )
{
- EtcRaidtab* tab = getStorage()->getRaidtab();
- if( tab!=NULL )
- {
- tab->removeEntry( m->nr() );
- }
+ EtcMdadm* mdadm = getStorage()->getMdadm();
+ if (mdadm)
+ mdadm->removeEntry(m->getMdUuid());
if( !removeFromList( m ) )
ret = MD_NOT_IN_LIST;
}
@@ -724,57 +608,27 @@
}
-namespace storage
-{
-
std::ostream& operator<< (std::ostream& s, const MdCo& d )
{
- s << *((Container*)&d);
+ s << dynamic_cast<const Container&>(d);
return( s );
}
-}
-void MdCo::logDifference( const Container& d ) const
+ void
+ MdCo::logDifferenceWithVolumes(std::ostream& log, const Container& rhs_c) const
{
- y2mil(getDiffString(d));
- const MdCo * p = dynamic_cast<const MdCo*>(&d);
- if( p != NULL )
- {
- ConstMdPair pp=mdPair();
- ConstMdIter i=pp.begin();
- while( i!=pp.end() )
- {
- ConstMdPair pc=p->mdPair();
- ConstMdIter j = pc.begin();
- while( j!=pc.end() &&
- (i->device()!=j->device() || i->created()!=j->created()) )
- ++j;
- if( j!=pc.end() )
- {
- if( !i->equalContent( *j ) )
- i->logDifference( *j );
- }
- else
- y2mil( " -->" << *i );
- ++i;
- }
- pp=p->mdPair();
- i=pp.begin();
- while( i!=pp.end() )
- {
- ConstMdPair pc=mdPair();
- ConstMdIter j = pc.begin();
- while( j!=pc.end() &&
- (i->device()!=j->device() || i->created()!=j->created()) )
- ++j;
- if( j==pc.end() )
- y2mil( " <--" << *i );
- ++i;
- }
- }
+ const MdCo& rhs = dynamic_cast<const MdCo&>(rhs_c);
+
+ logDifference(log, rhs);
+ log << endl;
+
+ ConstMdPair pp = mdPair();
+ ConstMdPair pc = rhs.mdPair();
+ logVolumesDifference(log, pp.begin(), pp.end(), pc.begin(), pc.end());
}
+
bool MdCo::equalContent( const Container& rhs ) const
{
const MdCo * p = NULL;
@@ -785,77 +639,25 @@
{
ConstMdPair pp = mdPair();
ConstMdPair pc = p->mdPair();
- ConstMdIter i = pp.begin();
- ConstMdIter j = pc.begin();
- while( ret && i!=pp.end() && j!=pc.end() )
- {
- ret = ret && i->equalContent( *j );
- ++i;
- ++j;
- }
- ret = ret && i==pp.end() && j==pc.end();
+ ret = ret && storage::equalContent(pp.begin(), pp.end(), pc.begin(), pc.end());
}
return( ret );
}
-MdCo::MdCo( const MdCo& rhs ) : Container(rhs)
- {
- y2deb("constructed MdCo by copy constructor from " << rhs.nm);
- *this = rhs;
- ConstMdPair p = rhs.mdPair();
- for( ConstMdIter i=p.begin(); i!=p.end(); ++i )
- {
- Md * p = new Md( *this, *i );
- vols.push_back( p );
- }
- }
-
-
-void MdCo::logData( const string& Dir ) {;}
-
-// Not a class member. Just check function.
-static bool showMdPartContainers(const Container& c )
- {
- return( c.deleted()==false && c.type()==MDPART);
- }
-// No '/dev/' please.
-bool MdCo::isHandledByMdPart(const string& name)
+bool MdCo::isHandledByMdPart(const string& name) const
{
- if( sto )
+ Storage::ConstMdPartCoPair p = getStorage()->mdpartCoPair(MdPartCo::notDeleted);
+ for (Storage::ConstMdPartCoIterator i = p.begin(); i != p.end(); ++i)
{
- Storage::ConstContPair p = sto->contPair( showMdPartContainers );
- for( Storage::ConstContIterator i = p.begin(); i != p.end(); ++i)
- {
- if( i->name() == name )
- {
- return true;
- }
- }
+ if (i->name() == name)
+ return true;
}
- return false;
-}
-bool MdCo::canHandleDev(const string& name, const string& line2)
-{
- unsigned dummy;
- //If this is a valid MD name.
- if( Md::mdStringNum(name,dummy) )
- {
- // if it's not used by Md Part
- if (!isHandledByMdPart(name))
- {
- //Exclude 'container'
- if( line2.find("external:imsm") == string::npos &&
- line2.find("external:ddf") == string::npos )
- {
- y2mil("Device : " << name << " can be handled by Md.");
- return true;
- }
- }
- }
- return false;
+ return false;
}
+
bool MdCo::active = false;
+}
Modified: branches/SuSE-Code-11-SP2-Branch/storage/libstorage/src/MdCo.h
URL: http://svn.opensuse.org/viewcvs/yast/branches/SuSE-Code-11-SP2-Branch/stora…
==============================================================================
--- branches/SuSE-Code-11-SP2-Branch/storage/libstorage/src/MdCo.h (original)
+++ branches/SuSE-Code-11-SP2-Branch/storage/libstorage/src/MdCo.h Tue May 17 13:39:44 2011
@@ -1,5 +1,5 @@
/*
- * Copyright (c) [2004-2009] Novell, Inc.
+ * Copyright (c) [2004-2010] Novell, Inc.
*
* All Rights Reserved.
*
@@ -23,47 +23,50 @@
#ifndef MD_CO_H
#define MD_CO_H
-#include "y2storage/Container.h"
-#include "y2storage/Md.h"
+#include "storage/Container.h"
+#include "storage/Md.h"
namespace storage
{
-class EtcRaidtab;
+ class EtcMdadm;
class MdCo : public Container
{
friend class Storage;
public:
- MdCo( Storage * const s, bool detect );
- MdCo( const MdCo& rhs );
+ MdCo(Storage * const s);
+ MdCo(Storage * const s, SystemInfo& systeminfo);
+ MdCo(const MdCo& c);
virtual ~MdCo();
+
static storage::CType staticType() { return storage::MD; }
friend std::ostream& operator<< (std::ostream&, const MdCo& );
- int createMd( unsigned num, storage::MdType type,
- const std::list<string>& devs );
+ int createMd(unsigned num, MdType type, const list<string>& devs, const list<string>& spares);
int removeMd( unsigned num, bool destroySb=true );
- int extendMd( unsigned num, const string& dev );
- int shrinkMd( unsigned num, const string& dev );
+ int extendMd(unsigned num, const list<string>& devs, const list<string>& spares);
+ int shrinkMd(unsigned num, const list<string>& devs, const list<string>& spares);
int changeMdType( unsigned num, storage::MdType ptype );
int changeMdChunk( unsigned num, unsigned long chunk );
int changeMdParity( unsigned num, storage::MdParity ptype );
int checkMd( unsigned num );
int getMdState(unsigned num, MdStateInfo& info);
bool equalContent( const Container& rhs ) const;
- void logDifference( const Container& d ) const;
- void syncRaidtab();
+ virtual void logDifferenceWithVolumes(std::ostream& log, const Container& rhs) const;
+
+ void syncMdadm(EtcMdadm* mdadm) const;
+
void changeDeviceName( const string& old, const string& nw );
- static void activate( bool val, const string& tmpDir );
+ static void activate(bool val, const string& tmpDir);
int removeVolume( Volume* v );
/* returns in 'nums' numbers that are used by Md */
- int usedNumbers(list<int>& nums);
+ list<unsigned> usedNumbers() const;
protected:
// iterators over MD volumes
@@ -114,20 +117,12 @@
return( ConstMdIter( MdCPIterator( p, Check, true )) );
}
- MdCo( Storage * const s, const string& File );
-
- void getMdData();
- void getMdData( unsigned num );
bool findMd( unsigned num, MdIter& i );
bool findMd( unsigned num );
bool findMd( const string& dev, MdIter& i );
bool findMd( const string& dev );
- int checkUse( const string& dev );
+ int checkUse(const list<string>& dev, const list<string>& spares) const;
void addMd( Md* m );
- void checkMd( Md* m );
- void updateEntry( const Md* m );
-
- void init();
virtual void print( std::ostream& s ) const { s << *this; }
virtual Container* getCopy() const { return( new MdCo( *this ) ); }
@@ -135,17 +130,15 @@
int doCreate( Volume* v );
int doRemove( Volume* v );
- void logData( const string& Dir );
-
/* Return true if given device is alredy handled by MdPartCo. */
- bool isHandledByMdPart(const string& name);
+ bool isHandledByMdPart(const string& name) const;
+
+ static bool active;
+
+ private:
- /* Return true if md device found in /proc/mdstat given by 'name'
- * can be handled by Md classes.
- * The line2 is a line following device name in mdstat. */
- bool canHandleDev(const string& name, const string& line2);
+ MdCo& operator=(const MdCo&); // disallow
- static bool active;
};
}
Modified: branches/SuSE-Code-11-SP2-Branch/storage/libstorage/src/MdPart.cc
URL: http://svn.opensuse.org/viewcvs/yast/branches/SuSE-Code-11-SP2-Branch/stora…
==============================================================================
--- branches/SuSE-Code-11-SP2-Branch/storage/libstorage/src/MdPart.cc (original)
+++ branches/SuSE-Code-11-SP2-Branch/storage/libstorage/src/MdPart.cc Tue May 17 13:39:44 2011
@@ -21,18 +21,15 @@
* 51 Franklin St - Fifth Floor, Boston, MA 02110-1301 USA.
*/
-/*
- Textdomain "storage"
-*/
#include <sstream>
-#include "y2storage/MdPart.h"
-#include "y2storage/MdPartCo.h"
-#include "y2storage/SystemCmd.h"
-#include "y2storage/ProcPart.h"
-#include "y2storage/AppUtil.h"
-#include "y2storage/Storage.h"
+#include "storage/MdPart.h"
+#include "storage/MdPartCo.h"
+#include "storage/ProcParts.h"
+#include "storage/AppUtil.h"
+#include "storage/Storage.h"
+#include "storage/StorageDefines.h"
namespace storage
@@ -40,72 +37,62 @@
using namespace std;
-MdPart::MdPart(const MdPartCo& d, unsigned nr, Partition* pa) : Volume( d, nr, 0 )
+ MdPart::MdPart(const MdPartCo& c, const string& name, const string& device, unsigned nr,
+ Partition* pa)
+ : Volume(c, name, device), p(pa)
{
- init( d.numToName(nr) );
numeric = true;
num = nr;
- p = pa;
+
+ if (!getStorage()->testmode())
+ getMajorMinor();
+
if( pa )
{
setSize( pa->sizeK() );
}
- y2mil("constructed MdPart " << dev << " on MdPartCo : " << cont->name());
+ y2mil("constructed MdPart " << dev << " on " << cont->name());
}
-MdPart::MdPart(const MdPartCo& d, const MdPart& rhs)
- : Volume( d, 0, 0 )
-{
- y2deb("constructed MdPart by copy constructor from " << rhs.dev);
- *this = rhs;
-}
+ MdPart::MdPart(const MdPartCo& c, const MdPart& v)
+ : Volume(c, v)
+ {
+ y2deb("copy-constructed MdPart from " << v.dev);
+ }
-MdPart::~MdPart()
-{
- y2deb("destructed MdPart " << dev);
-}
-void MdPart::init( const string& name )
+ MdPart::~MdPart()
{
- p = NULL;
- dev = "/dev/" + name;
- string::size_type pos = name.find_last_of( "/" );
- if( pos!=string::npos )
- {
- nm = name.substr( pos+1 );
- }
- else
- {
- nm = name;
- }
+ y2deb("destructed MdPart " << dev);
}
+
const MdPartCo* MdPart::co() const
{
return(dynamic_cast<const storage::MdPartCo*>(cont));
}
+
+ string
+ MdPart::sysfsPath() const
+ {
+ return co()->sysfsPath() + "/" + procName();
+ }
+
+
void MdPart::updateName()
{
if( p && p->nr() != num )
{
num = p->nr();
- nm = co()->numToName(num);
- dev = "/dev/" + nm;
+ setNameDevice(co()->getPartName(num), co()->getPartDevice(num));
}
}
void MdPart::updateMinor()
{
- unsigned long mj=mjr;
- unsigned long mi=mnr;
- getMajorMinor( dev, mj, mi );
- if( mi!=mnr || mj!=mjr )
- {
- mnr = mi;
- mjr = mj;
- }
+ getMajorMinor();
}
void MdPart::updateSize()
@@ -117,14 +104,14 @@
}
}
-void MdPart::updateSize( ProcPart& pp )
+void MdPart::updateSize( const ProcParts& pp )
{
- unsigned long long si = 0;
updateSize();
//In case of extended partition /proc/partition contains size 1.
if( p && p->type() != storage::EXTENDED )
{
- if( mjr>0 && pp.getSize( nm, si ))
+ unsigned long long si = 0;
+ if( mjr>0 && pp.getSize(procName(), si))
{
setSize( si );
}
@@ -135,81 +122,70 @@
{
addAltUdevId( num );
}
-//TODO: Is it OK? Check it
-static string udevCompleteIdPath( const string& s, unsigned nr )
+
+
+ void
+ MdPart::addAltUdevId(unsigned num)
{
- return( "/dev/disk/by-id/" + s + "-part" + decString(nr) );
- }
+ alt_names.remove_if(string_contains("/by-id/"));
+ const list<string> tmp = co()->udevId();
+ for (list<string>::const_iterator i = tmp.begin(); i != tmp.end(); ++i)
+ alt_names.push_back("/dev/disk/by-id/" + udevAppendPart(*i, num));
-void
-MdPart::addAltUdevId( unsigned num )
-{
- list<string>::iterator i = alt_names.begin();
- while( i!=alt_names.end() )
- {
- if( i->find( "/by-id/" ) != string::npos )
- i = alt_names.erase( i );
- else
- ++i;
- }
- list<string>::const_iterator j = co()->udevId().begin();
- while( j!=co()->udevId().end() )
- {
- alt_names.push_back( udevCompleteIdPath( *j, num ));
- ++j;
- }
- mount_by = orig_mount_by = defaultMountBy();
-}
+ mount_by = orig_mount_by = defaultMountBy();
+ }
-const std::list<string>
+list<string>
MdPart::udevId() const
{
list<string> ret;
const list<string> tmp = co()->udevId();
for (list<string>::const_iterator i = tmp.begin(); i != tmp.end(); ++i)
- ret.push_back(udevAppendPart("/dev/disk/by-id/" + *i, num));
+ ret.push_back(udevAppendPart(*i, num));
return ret;
}
-void MdPart::getCommitActions( std::list<storage::commitAction*>& l ) const
+void
+MdPart::getCommitActions(list<commitAction>& l) const
{
unsigned s = l.size();
Volume::getCommitActions(l);
if( p )
{
if( s==l.size() && Partition::toChangeId( *p ) )
- l.push_back( new commitAction( INCREASE, cont->staticType(),
- setTypeText(false), this, false ));
+ l.push_back(commitAction(INCREASE, cont->type(),
+ setTypeText(false), this, false));
}
}
-string MdPart::setTypeText( bool doing ) const
+
+Text
+MdPart::setTypeText(bool doing) const
{
- string txt;
- string d = dev;
+ Text txt;
if( doing )
{
// displayed text during action, %1$s is replaced by partition name (e.g. pdc_dabaheedj1),
// %2$s is replaced by hexadecimal number (e.g. 8E)
txt = sformat( _("Setting type of partition %1$s to %2$X"),
- d.c_str(), id() );
+ dev.c_str(), id() );
}
else
{
// displayed text before action, %1$s is replaced by partition name (e.g. pdc_dabaheedj1),
// %2$s is replaced by hexadecimal number (e.g. 8E)
txt = sformat( _("Set type of partition %1$s to %2$X"),
- d.c_str(), id() );
+ dev.c_str(), id() );
}
- return( txt );
+ return txt;
}
void MdPart::getInfo( MdPartInfo& tinfo ) const
{
- ((Volume*)this)->getInfo( info.v );
+ Volume::getInfo(info.v);
if( p )
p->getInfo( info.p );
info.part = p!=NULL;
@@ -219,42 +195,21 @@
std::ostream& operator<< (std::ostream& s, const MdPart &p )
{
- s << "MdPart: ";
- s << *(Volume*)&p;
+ s << "MdPart ";
+ s << dynamic_cast<const Volume&>(p);
return( s );
}
bool MdPart::equalContent( const MdPart& rhs ) const
{
- return( Volume::equalContent(rhs) );
+ return Volume::equalContent(rhs);
}
-void MdPart::logDifference( const MdPart& rhs ) const
-{
- string log = Volume::logDifference(rhs);
- y2mil(log);
-}
-
-
-MdPart& MdPart::operator=(const MdPart& rhs)
-{
- y2deb("operator= from " << rhs.nm);
- *((Volume*)this) = rhs;
- return *this;
-}
-
-void MdPart::getPartitionInfo(storage::PartitionInfo& pinfo)
-{
- ((Volume*)this)->getInfo( pinfo.v );
- if( p )
+ void
+ MdPart::logDifference(std::ostream& log, const MdPart& rhs) const
{
- PartitionAddInfo info;
- p->getInfo( info );
- pinfo = info;
+ Volume::logDifference(log, rhs);
}
}
-
-
-}
Modified: branches/SuSE-Code-11-SP2-Branch/storage/libstorage/src/MdPart.h
URL: http://svn.opensuse.org/viewcvs/yast/branches/SuSE-Code-11-SP2-Branch/stora…
==============================================================================
--- branches/SuSE-Code-11-SP2-Branch/storage/libstorage/src/MdPart.h (original)
+++ branches/SuSE-Code-11-SP2-Branch/storage/libstorage/src/MdPart.h Tue May 17 13:39:44 2011
@@ -24,51 +24,64 @@
#ifndef MD_PART_H
#define MD_PART_H
-#include "y2storage/Md.h"
-#include "y2storage/Partition.h"
+
+#include "storage/Partition.h"
+
namespace storage
{
class MdPartCo;
-class ProcPart;
+class ProcParts;
class MdPart : public Volume
{
public:
- MdPart( const MdPartCo& d, unsigned nr, Partition* p=NULL );
- MdPart( const MdPartCo& d, const MdPart& rd );
- MdPart& operator=( const MdPart& );
+ MdPart(const MdPartCo& c, const string& name, const string& device, unsigned nr,
+ Partition* p);
+ MdPart(const MdPartCo& c, const MdPart& v);
virtual ~MdPart();
+
friend std::ostream& operator<< (std::ostream& s, const MdPart &p );
virtual void print( std::ostream& s ) const { s << *this; }
void getInfo( storage::MdPartInfo& info ) const;
- void getPartitionInfo(storage::PartitionInfo& pinfo);
+
bool equalContent( const MdPart& rhs ) const;
- void logDifference( const MdPart& d ) const;
+
+ void logDifference(std::ostream& log, const MdPart& rhs) const;
+
void setPtr( Partition* pa ) { p=pa; };
Partition* getPtr() const { return p; };
unsigned id() const { return p?p->id():0; }
void updateName();
void updateMinor();
- void updateSize( ProcPart& pp );
+ void updateSize(const ProcParts& pp);
void updateSize();
- void getCommitActions( std::list<storage::commitAction*>& l ) const;
+ void getCommitActions(list<commitAction>& l) const;
void addUdevData();
- virtual const std::list<string> udevId() const;
- virtual string setTypeText( bool doing=true ) const;
+ virtual list<string> udevId() const;
+
+ virtual Text setTypeText(bool doing) const;
+
static bool notDeleted( const MdPart& l ) { return( !l.deleted() ); }
+ virtual string procName() const { return nm; }
+ virtual string sysfsPath() const;
+
protected:
- void init( const string& name );
- void dataFromPart( const Partition* p );
- virtual const string shortPrintedName() const { return( "MdPart" ); }
+
const MdPartCo* co() const;
void addAltUdevId( unsigned num );
Partition* p;
- mutable storage::MdPartInfo info;
+ mutable storage::MdPartInfo info; // workaround for broken ycp bindings
+
+ private:
+
+ MdPart(const MdPart&); // disallow
+ MdPart& operator=(const MdPart&); // disallow
+
};
}
Modified: branches/SuSE-Code-11-SP2-Branch/storage/libstorage/src/MdPartCo.cc
URL: http://svn.opensuse.org/viewcvs/yast/branches/SuSE-Code-11-SP2-Branch/stora…
==============================================================================
--- branches/SuSE-Code-11-SP2-Branch/storage/libstorage/src/MdPartCo.cc (original)
+++ branches/SuSE-Code-11-SP2-Branch/storage/libstorage/src/MdPartCo.cc Tue May 17 13:39:44 2011
@@ -5,7 +5,7 @@
* Volume) like md126 which is a Container for partitions.
*
* Copyright (c) 2009, Intel Corporation.
- * Copyright (c) 2009 Novell, Inc.
+ * Copyright (c) [2009-2010] Novell, Inc.
*
* This program is free software; you can redistribute it and/or modify it
* under the terms and conditions of the GNU General Public License,
@@ -21,33 +21,29 @@
* 51 Franklin St - Fifth Floor, Boston, MA 02110-1301 USA.
*/
-/*
- Textdomain "storage"
-*/
-
-#include <sstream>
-#include <algorithm>
-#include <cctype>
-#include <string>
#include <unistd.h>
-#include <string>
+#include <glob.h>
#include <sys/stat.h>
#include <sys/types.h>
#include <dirent.h>
#include <stdlib.h>
-#include <boost/algorithm/string.hpp>
-#include "y2storage/MdPartCo.h"
-#include "y2storage/MdPart.h"
-#include "y2storage/ProcPart.h"
-#include "y2storage/Partition.h"
-#include "y2storage/SystemCmd.h"
-#include "y2storage/AppUtil.h"
-#include "y2storage/Storage.h"
-#include "y2storage/StorageDefines.h"
-#include "y2storage/Regex.h"
-#include "y2storage/EtcRaidtab.h"
+#include <sstream>
+#include <algorithm>
+#include <string>
+
+#include "storage/MdPartCo.h"
+#include "storage/MdPart.h"
+#include "storage/SystemInfo.h"
+#include "storage/ProcParts.h"
+#include "storage/Partition.h"
+#include "storage/SystemCmd.h"
+#include "storage/AppUtil.h"
+#include "storage/Storage.h"
+#include "storage/StorageDefines.h"
+#include "storage/Regex.h"
+#include "storage/EtcMdadm.h"
namespace storage
@@ -55,29 +51,48 @@
using namespace std;
-MdPartCo::MdPartCo( Storage * const s,
- const string& name,
- ProcPart* ppart )
- : Container(s,"",staticType()) // MD?
- {
- y2mil("constructing MdPartCo : " << name);
- makeDevName(name);
- nm = undevName(name);
-
- getMajorMinor();
-
- del_ptable = false;
- disk = NULL;
-
- /* First Initialize RAID properties. */
- initMd();
- /* Initialize 'disk' part, partitions.*/
- init( ppart );
+ MdPartCo::MdPartCo(Storage* s, const string& name, const string& device, SystemInfo& systeminfo)
+ : Container(s, name, device, staticType()), disk(NULL), md_type(RAID_UNK),
+ md_parity(PAR_DEFAULT), chunk_k(0), sb_ver("01.00.00"), destrSb(false),
+ has_container(false)
+ {
+ getMajorMinor();
+
+ /* First Initialize RAID properties. */
+ initMd(systeminfo);
+ /* Initialize 'disk' part, partitions.*/
+ init(systeminfo);
+
+ setUdevData(systeminfo);
+
+ y2deb("constructed MdPartCo " << dev);
+ }
+
- y2mil("MdPartCo (nm=" << nm << ", dev=" << dev << ", level=" << md_type << ", disks=" << devs << ") ready.");
+ MdPartCo::MdPartCo(const MdPartCo& c)
+ : Container(c), md_type(c.md_type), md_parity(c.md_parity),
+ chunk_k(c.chunk_k), md_uuid(c.md_uuid), md_name(c.md_name),
+ sb_ver(c.sb_ver), destrSb(c.destrSb), devs(c.devs), spare(c.spare),
+ udev_id(c.udev_id),
+ has_container(c.has_container), parent_container(c.parent_container),
+ parent_uuid(c.parent_uuid), parent_md_name(c.parent_md_name),
+ parent_metadata(c.parent_metadata), parent_member(c.parent_member)
+ {
+ y2deb("copy-constructed MdPartCo by from " << c.nm);
+ disk = NULL;
+ if( c.disk )
+ disk = new Disk( *c.disk );
+ ConstMdPartPair p = c.mdpartPair();
+ for (ConstMdPartIter i = p.begin(); i != p.end(); ++i)
+ {
+ MdPart* p = new MdPart(*this, *i);
+ vols.push_back(p);
+ }
+ updatePointers(true);
}
+
MdPartCo::~MdPartCo()
{
if( disk )
@@ -88,14 +103,23 @@
y2deb("destructed MdPartCo : " << dev);
}
-bool MdPartCo::isMdPart(const string& name)
+
+ string
+ MdPartCo::sysfsPath() const
+ {
+ return SYSFSDIR "/" + procName();
+ }
+
+
+bool MdPartCo::isMdPart(const string& name) const
{
string n = undevName(name);
static Regex mdpart( "^md[0123456789]+p[0123456789]+$" );
return (mdpart.match(n));
}
-void MdPartCo::getPartNum(const string& device, unsigned& num)
+
+void MdPartCo::getPartNum(const string& device, unsigned& num) const
{
string dev = device;
string::size_type pos;
@@ -126,7 +150,7 @@
unsigned number;
const string tmpS(device);
getPartNum(tmpS,number);
- device = "/dev/" + numToName(number);
+ device = getPartDevice(number);
Partition *p = getPartition( number, false );
if( p==NULL )
{
@@ -138,6 +162,7 @@
newP( md, p->nr(), p );
md->getFsInfo( p );
md->setCreated();
+ md->addUdevData();
addToList( md );
y2mil("device:" << device << " was added to MdPartCo : " << dev);
@@ -159,7 +184,8 @@
string& device,
bool checkRelaxed )
{
- y2mil("begin type:" << type << " start:" << start << " len:" << len << " relaxed:" << checkRelaxed);
+ y2mil("begin type:" << toString(type) << " start:" << start << " len:" << len <<
+ " relaxed:" << checkRelaxed);
int ret = disk ? 0 : MDPART_INTERNAL_ERR;
if( ret==0 && readonly() )
ret = MDPART_CHANGE_READONLY;
@@ -193,7 +219,7 @@
int
MdPartCo::createPartition( storage::PartitionType type, string& device )
{
- y2mil("type:" << type);
+ y2mil("type:" << toString(type));
int ret = disk ? 0 : MDPART_INTERNAL_ERR;
if( ret==0 && readonly() )
ret = MDPART_CHANGE_READONLY;
@@ -344,55 +370,46 @@
void
-MdPartCo::init( ProcPart* ppart )
+MdPartCo::init(SystemInfo& systeminfo)
{
- const string tmpS(nm);
- if( ppart )
- {
- ppart->getSize( nm, size_k );
- }
- y2mil( " nm: " << nm << " size_k: " << size_k);
- createDisk( ppart );
- getVolumes( ppart );
+ systeminfo.getProcParts().getSize(procName(), size_k);
+ y2mil("nm:" << nm << " size_k:" << size_k);
+ createDisk(systeminfo);
+ getVolumes(systeminfo.getProcParts());
}
+
void
-MdPartCo::createDisk( ProcPart* ppart )
+MdPartCo::createDisk(SystemInfo& systeminfo)
{
if( disk )
delete disk;
- disk = new Disk( getStorage(), dev, size_k );
+ disk = new Disk(getStorage(), nm, dev, size_k, systeminfo);
disk->setNumMinor( 64 );
disk->setSilent();
disk->setSlave();
- if( ppart )
- {
- disk->detect( *ppart );
- }
+ disk->detect(systeminfo);
}
// Creates new partition.
void
MdPartCo::newP( MdPart*& dm, unsigned num, Partition* p )
{
- dm = new MdPart( *this, num, p );
+ dm = new MdPart(*this, getPartName(num), getPartDevice(num), num, p);
}
//This seems to detect partitions from ppart and adds them to Container.
void
-MdPartCo::getVolumes( ProcPart* ppart )
+MdPartCo::getVolumes(const ProcParts& ppart)
{
vols.clear();
- num_part = 0;
Disk::PartPair pp = disk->partPair();
Disk::PartIter i = pp.begin();
MdPart * p = NULL;
while( i!=pp.end() )
{
newP( p, i->nr(), &(*i) );
- if( ppart )
- p->updateSize( *ppart );
- num_part++;
+ p->updateSize(ppart);
addToList( p );
++i;
}
@@ -451,8 +468,8 @@
MdPartCo::validPartition( const Partition* p )
{
bool ret = false;
- Disk::PartPair pp = disk->partPair();
- Disk::PartIter i = pp.begin();
+ Disk::ConstPartPair pp = disk->partPair();
+ Disk::ConstPartIter i = pp.begin();
while( i!=pp.end() && p != &(*i) )
++i;
ret = i!=pp.end();
@@ -476,16 +493,13 @@
void MdPartCo::updateMinor()
{
MdPartPair p=mdpartPair();
- MdPartIter i=p.begin();
- while( i!=p.end() )
- {
+ for (MdPartIter i = p.begin(); i != p.end(); ++i)
i->updateMinor();
- ++i;
- }
}
-// Makes complete partition name (like md125p5)
-string MdPartCo::numToName( unsigned mdNum ) const
+
+string
+MdPartCo::getPartName( unsigned mdNum ) const
{
string ret = nm;
if( mdNum>0 )
@@ -496,18 +510,18 @@
return( ret );
}
-int MdPartCo::nr(const string& name)
-{
- string tmp = name;
- int n;
- tmp.erase(0,2) >> n;
- return n;
-}
-int MdPartCo::nr()
-{
- return mnr;
-}
+string
+MdPartCo::getPartDevice( unsigned mdNum ) const
+ {
+ string ret = dev;
+ if( mdNum>0 )
+ {
+ ret += "p";
+ ret += decString(mdNum);
+ }
+ return( ret );
+ }
//
@@ -540,7 +554,7 @@
}
bool save = getStorage()->getRecursiveRemoval();
getStorage()->setRecursiveRemoval(true);
- if( getUsedByType() != UB_NONE )
+ if (isUsedBy())
{
getStorage()->removeUsing( device(), getUsedBy() );
}
@@ -553,7 +567,6 @@
++i;
}
getStorage()->setRecursiveRemoval(save);
- del_ptable = true;
}
y2mil("ret:" << ret);
return( ret );
@@ -585,23 +598,29 @@
int
MdPartCo::nextFreePartition(PartitionType type, unsigned& nr, string& device) const
{
- int ret = disk->nextFreePartition( type, nr, device );
- if( ret==0 )
- {
- device = "/dev/" + numToName(nr);
- }
+ int ret = 0;
+ device = "";
+ nr = disk->availablePartNumber( type );
+ if (nr == 0)
+ {
+ ret = DISK_PARTITION_NO_FREE_NUMBER;
+ }
+ else
+ {
+ device = getPartDevice(nr);
+ }
y2mil("ret:" << ret << " nr:" << nr << " device:" << device);
return ret;
}
-int MdPartCo::changePartitionArea( unsigned nr, unsigned long start,
- unsigned long len, bool checkRelaxed )
+ int
+ MdPartCo::changePartitionArea(unsigned nr, const Region& cylRegion, bool checkRelaxed)
{
int ret = nr>0?0:MDPART_PARTITION_NOT_FOUND;
if( ret==0 )
{
- ret = disk->changePartitionArea( nr, start, len, checkRelaxed );
+ ret = disk->changePartitionArea(nr, cylRegion, checkRelaxed);
MdPartIter i;
if( findMdPart( nr, i ))
i->updateSize();
@@ -655,7 +674,6 @@
ret = disk->doCreateLabel();
if( ret==0 )
{
- del_ptable = false;
removeFromMemory();
handleWholeDevice();
getStorage()->waitForDevice();
@@ -707,26 +725,18 @@
unuseDevs();
setDeleted( true );
destrSb = true;
- del_ptable = true;
}
y2mil("ret:" << ret);
return( ret );
}
-int MdPartCo::unuseDevs(void)
+
+void MdPartCo::unuseDevs() const
{
- list<string> rdevs;
- getDevs( rdevs );
- for( list<string>::const_iterator s=rdevs.begin();
- s!=rdevs.end(); s++ )
- {
- getStorage()->clearUsedBy(*s);
- }
- return 0;
+ getStorage()->clearUsedBy(getDevs());
}
-
void MdPartCo::removePresentPartitions()
{
VolPair p = volPair();
@@ -770,27 +780,25 @@
return( p!=NULL && !d.deleted() && Partition::toChangeId(*p) );
}
-int MdPartCo::getToCommit( CommitStage stage, list<Container*>& col,
- list<Volume*>& vol )
+void MdPartCo::getToCommit(CommitStage stage, list<const Container*>& col,
+ list<const Volume*>& vol) const
{
- int ret = 0;
- y2mil("ret:" << ret << " col:" << col.size() << " << vol:" << vol.size());
+ y2mil("col:" << col.size() << " << vol:" << vol.size());
getStorage()->logCo( this );
unsigned long oco = col.size();
unsigned long ovo = vol.size();
Container::getToCommit( stage, col, vol );
if( stage==INCREASE )
{
- MdPartPair p = mdpartPair( toChangeId );
- for( MdPartIter i=p.begin(); i!=p.end(); ++i )
+ ConstMdPartPair p = mdpartPair( toChangeId );
+ for( ConstMdPartIter i=p.begin(); i!=p.end(); ++i )
if( find( vol.begin(), vol.end(), &(*i) )==vol.end() )
vol.push_back( &(*i) );
}
- if( del_ptable && find( col.begin(), col.end(), this )==col.end() )
+ if( disk->del_ptable && find( col.begin(), col.end(), this )==col.end() )
col.push_back( this );
if( col.size()!=oco || vol.size()!=ovo )
- y2mil("ret:" << ret << " col:" << col.size() << " vol:" << vol.size());
- return( ret );
+ y2mil("col:" << col.size() << " vol:" << vol.size());
}
@@ -822,7 +830,7 @@
{
ret = doRemove();
}
- else if( stage==DECREASE && del_ptable )
+ else if( stage==DECREASE && disk->del_ptable )
{
ret = doCreateLabel();
}
@@ -832,28 +840,26 @@
return( ret );
}
-void MdPartCo::getCommitActions( list<commitAction*>& l ) const
+void
+MdPartCo::getCommitActions(list<commitAction>& l ) const
{
y2mil( "l:" << l );
Container::getCommitActions( l );
y2mil( "l:" << l );
- if( deleted() || del_ptable )
+ if( deleted() || disk->del_ptable )
{
- list<commitAction*>::iterator i = l.begin();
- while( i!=l.end() )
+ list<commitAction>::iterator i = l.begin();
+ while (i != l.end())
{
- if( (*i)->stage==DECREASE )
+ if (i->stage == DECREASE)
{
- delete( *i );
i=l.erase( i );
}
else
++i;
}
- string txt = deleted() ? removeText(false) :
- setDiskLabelText(false);
- l.push_front( new commitAction( DECREASE, staticType(),
- txt, this, true ));
+ Text txt = deleted() ? removeText(false) : setDiskLabelText(false);
+ l.push_front(commitAction( DECREASE, staticType(), txt, this, true));
}
y2mil( "l:" << l );
}
@@ -888,7 +894,7 @@
{
activate_part(false);
activate_part(true);
- ProcPart pp;
+ ProcParts pp;
updateMinor();
l->updateSize( pp );
}
@@ -908,7 +914,7 @@
// 1. Check Metadata.
if( sb_ver == "imsm" || sb_ver == "ddf" )
{
- y2error("Cannot remove IMSM or DDF SW RAIDs.");
+ y2err("Cannot remove IMSM or DDF SW RAIDs.");
return (MDPART_NO_REMOVE);
}
// 2. Check for partitions.
@@ -928,12 +934,12 @@
}
if( permitRemove == 1 )
{
- y2error("Cannot remove RAID with partitions.");
+ y2err("Cannot remove RAID with partitions.");
return (MDPART_NO_REMOVE);
}
}
/* Try to remove this. */
- y2milestone( "Raid:%s is going to be removed permanently.", name().c_str() );
+ y2mil("Raid:" << name() << " is going to be removed permanently");
int ret = 0;
if( deleted() )
{
@@ -951,8 +957,7 @@
if( ret==0 && destrSb )
{
SystemCmd c;
- list<string> d;
- getDevs( d );
+ list<string> d = getDevs();
for( list<string>::const_iterator i=d.begin(); i!=d.end(); ++i )
{
c.execute(MDADMBIN " --zero-superblock " + quote(*i));
@@ -960,11 +965,9 @@
}
if( ret==0 )
{
- EtcRaidtab* tab = getStorage()->getRaidtab();
- if( tab!=NULL )
- {
- tab->removeEntry( nr() );
- }
+ EtcMdadm* mdadm = getStorage()->getMdadm();
+ if (mdadm)
+ mdadm->removeEntry(getMdUuid());
}
}
y2mil("Done, ret:" << ret);
@@ -991,7 +994,7 @@
Partition *p = l->getPtr();
if( p==NULL )
{
- y2error("Partition not found");
+ y2err("Partition not found");
ret = MDPART_PARTITION_NOT_FOUND;
}
else
@@ -1003,7 +1006,7 @@
{
if( !removeFromList( l ) )
{
- y2warning("Couldn't remove parititon from list.");
+ y2war("Couldn't remove parititon from list.");
ret = MDPART_REMOVE_PARTITION_LIST_ERASE;
}
}
@@ -1055,7 +1058,7 @@
ret = l->resizeFs();
if( ret==0 )
{
- ProcPart pp;
+ ProcParts pp;
updateMinor();
l->updateSize( pp );
getStorage()->waitForDevice( l->device() );
@@ -1066,30 +1069,18 @@
return( ret );
}
-string MdPartCo::setDiskLabelText( bool doing ) const
+
+Text
+MdPartCo::setDiskLabelText(bool doing) const
{
- string txt;
- string d = dev;
- if( doing )
- {
- // displayed text during action, %1$s is replaced by name (e.g. pdc_igeeeadj),
- // %2$s is replaced by label name (e.g. msdos)
- txt = sformat( _("Setting disk label of %1$s to %2$s"),
- d.c_str(), labelName().c_str() );
- }
- else
- {
- // displayed text before action, %1$s is replaced by name (e.g. pdc_igeeeadj),
- // %2$s is replaced by label name (e.g. msdos)
- txt = sformat( _("Set disk label of %1$s to %2$s"),
- d.c_str(), labelName().c_str() );
- }
- return( txt );
+ return disk->setDiskLabelText(doing);
}
-string MdPartCo::removeText( bool doing ) const
+
+Text
+MdPartCo::removeText( bool doing ) const
{
- string txt;
+ Text txt;
if( doing )
{
// displayed text during action, %1$s is replaced by a name (e.g. pdc_igeeeadj),
@@ -1100,26 +1091,40 @@
// displayed text before action, %1$s is replaced by a name (e.g. pdc_igeeeadj),
txt = sformat( _("Remove software RAID %1$s"), name().c_str() );
}
- return( txt );
+ return txt;
}
void
-MdPartCo::setUdevData(const list<string>& id)
+MdPartCo::setUdevData(SystemInfo& systeminfo)
{
- y2mil("disk:" << nm << " id:" << id);
- udev_id = id;
- partition(udev_id.begin(), udev_id.end(), find_begin("md-uuid-"));
- y2mil("id:" << udev_id);
+ const UdevMap& by_id = systeminfo.getUdevMap("/dev/disk/by-id");
+ UdevMap::const_iterator it = by_id.find(nm);
+ if (it != by_id.end())
+ {
+ udev_id = it->second;
+ partition(udev_id.begin(), udev_id.end(), string_starts_with("md-uuid-"));
+ }
+ else
+ {
+ udev_id.clear();
+ }
+
+ y2mil("dev:" << dev << " udev_id:" << udev_id);
+
+ alt_names.remove_if(string_starts_with("/dev/disk/by-id/"));
+ for (list<string>::const_iterator i = udev_id.begin(); i != udev_id.end(); ++i)
+ alt_names.push_back("/dev/disk/by-id/" + *i);
+
if (disk)
{
- disk->setUdevData("", udev_id);
+ disk->setUdevData("", udev_id);
}
MdPartPair pp = mdpartPair();
for( MdPartIter p=pp.begin(); p!=pp.end(); ++p )
- {
- p->addUdevData();
- }
+ {
+ p->addUdevData();
+ }
}
@@ -1129,165 +1134,83 @@
{
disk->getInfo( info.d );
}
- info.minor = mnr;
- info.devices = boost::join(devs, " ");
- info.spares = boost::join(devs, " ");
-
- info.level = md_type;
+ info.type = md_type;
info.nr = mnr;
info.parity = md_parity;
info.uuid = md_uuid;
info.sb_ver = sb_ver;
- info.chunk = chunk_size;
- info.md_name = md_name;
-
- tinfo = info;
- }
+ info.chunkSizeK = chunk_k;
+ info.devices = boost::join(devs, " ");
+ info.spares = boost::join(spare, " ");
-int MdPartCo::getPartitionInfo(deque<storage::PartitionInfo>& plist)
-{
- int ret = 0;
- if( !disk )
- {
- ret = MDPART_INTERNAL_ERR;
- return ret;
+ tinfo = info;
}
- Disk::PartPair p = disk->partPair (Disk::notDeleted);
- for (Disk::PartIter i = p.begin(); i != p.end(); ++i)
- {
- plist.push_back( PartitionInfo() );
- i->getInfo( plist.back() );
- }
- return ret;
-}
std::ostream& operator<< (std::ostream& s, const MdPartCo& d )
{
- s << *((Container*)&d);
- s << " md_name:" << d.md_name
- << " MdNr:" << d.mnr
- << " PNum:" << d.num_part;
- if( !d.udev_id.empty() )
- s << " UdevId:" << d.udev_id;
- if( d.del_ptable )
- s << " delPT";
- if( !d.active )
- s << " inactive";
- return( s );
+ s << dynamic_cast<const Container&>(d)
+ << " Personality:" << toString(d.md_type);
+ if (d.chunk_k > 0)
+ s << " ChunkK:" << d.chunk_k;
+ if (d.md_parity != PAR_DEFAULT)
+ s << " Parity:" << toString(d.md_parity);
+ if (!d.sb_ver.empty() )
+ s << " SbVer:" << d.sb_ver;
+ if (!d.md_uuid.empty())
+ s << " md_uuid:" << d.md_uuid;
+ if (!d.md_name.empty())
+ s << " md_name:" << d.md_name;
+ if( d.destrSb )
+ s << " destroySb";
+ s << " Devices:" << d.devs;
+ if( !d.spare.empty() )
+ s << " Spares:" << d.spare;
+ s << " geometry:" << d.disk->getGeometry();
+ return s;
}
-string MdPartCo::getDiffString( const Container& d ) const
- {
- string log = Container::getDiffString( d );
- const MdPartCo* p = dynamic_cast<const MdPartCo*>(&d);
- if( p )
- {
- if( del_ptable!=p->del_ptable )
- {
- if( p->del_ptable )
- log += " -->delPT";
- else
- log += " delPT-->";
- }
- if( active!=p->active )
- {
- if( p->active )
- log += " -->active";
- else
- log += " active-->";
- }
- }
- return( log );
+ void
+ MdPartCo::logDifference(std::ostream& log, const MdPartCo& rhs) const
+ {
+ Container::logDifference(log, rhs);
+
+ logDiff(log, "active", active, rhs.active);
+
+ logDiffEnum(log, "md_type", md_type, rhs.md_type);
+ logDiffEnum(log, "md_parity", md_parity, rhs.md_parity);
+ logDiff(log, "chunk_k", chunk_k, rhs.chunk_k);
+ logDiff(log, "sb_ver", sb_ver, rhs.sb_ver);
+ logDiff(log, "md_uuid", md_uuid, rhs.md_uuid);
+ logDiff(log, "md_name", md_name, rhs.md_name);
+ logDiff(log, "destrSb", destrSb, rhs.destrSb);
+ logDiff(log, "devices", devs, rhs.devs);
+ logDiff(log, "spares", spare, rhs.spare);
+
+ logDiff(log, "parent_container", parent_container, rhs.parent_container);
+ logDiff(log, "parent_md_name", parent_md_name, rhs.parent_md_name);
+ logDiff(log, "parent_metadata", parent_metadata, rhs.parent_metadata);
+ logDiff(log, "parent_uuid", parent_uuid, rhs.parent_uuid);
}
-void MdPartCo::logDifference( const MdPartCo& d ) const
- {
- string log = getDiffString( d );
- if( md_type!=d.md_type )
- log += " Personality:" + md_names[md_type] + "-->" +
- md_names[d.md_type];
- if( md_parity!=d.md_parity )
- log += " Parity:" + par_names[md_parity] + "-->" +
- par_names[d.md_parity];
- if( chunk_size!=d.chunk_size )
- log += " Chunk:" + decString(chunk_size) + "-->" + decString(d.chunk_size);
- if( sb_ver!=d.sb_ver )
- log += " SbVer:" + sb_ver + "-->" + d.sb_ver;
- if( md_uuid!=d.md_uuid )
- log += " MD-UUID:" + md_uuid + "-->" + d.md_uuid;
- if( md_name!=d.md_name )
- {
- log += " MDName:" + md_name + "-->" + d.md_name;
- }
- if( destrSb!=d.destrSb )
- {
- if( d.destrSb )
- log += " -->destrSb";
- else
- log += " destrSb-->";
- }
- if( devs!=d.devs )
- {
- std::ostringstream b;
- classic(b);
- b << " Devices:" << devs << "-->" << d.devs;
- log += b.str();
- }
- if( spare!=d.spare )
- {
- std::ostringstream b;
- classic(b);
- b << " Spares:" << spare << "-->" << d.spare;
- log += b.str();
- }
- if( parent_container!=d.parent_container )
- log += " ParentContainer:" + parent_container + "-->" + d.parent_container;
- if( parent_md_name!=d.parent_md_name )
- log += " ParentContMdName:" + parent_md_name + "-->" + d.parent_md_name;
- if( parent_metadata!=d.parent_metadata )
- log += " ParentContMetadata:" + parent_metadata + "-->" + d.parent_metadata;
- if( parent_uuid!=d.parent_uuid )
- log += " ParentContUUID:" + parent_uuid + "-->" + d.parent_uuid;
-
- y2mil(log);
- ConstMdPartPair pp=mdpartPair();
- ConstMdPartIter i=pp.begin();
- while( i!=pp.end() )
- {
- ConstMdPartPair pc=d.mdpartPair();
- ConstMdPartIter j = pc.begin();
- while( j!=pc.end() &&
- (i->device()!=j->device() || i->created()!=j->created()) )
- ++j;
- if( j!=pc.end() )
- {
- if( !i->equalContent( *j ) )
- i->logDifference( *j );
- }
- else
- y2mil( " -->" << *i );
- ++i;
- }
- pp=d.mdpartPair();
- i=pp.begin();
- while( i!=pp.end() )
- {
- ConstMdPartPair pc=mdpartPair();
- ConstMdPartIter j = pc.begin();
- while( j!=pc.end() &&
- (i->device()!=j->device() || i->created()!=j->created()) )
- ++j;
- if( j==pc.end() )
- y2mil( " <--" << *i );
- ++i;
- }
+ void
+ MdPartCo::logDifferenceWithVolumes(std::ostream& log, const Container& rhs_c) const
+ {
+ const MdPartCo& rhs = dynamic_cast<const MdPartCo&>(rhs_c);
+
+ logDifference(log, rhs);
+ log << endl;
+
+ ConstMdPartPair pp = mdpartPair();
+ ConstMdPartPair pc = rhs.mdpartPair();
+ logVolumesDifference(log, pp.begin(), pp.end(), pc.begin(), pc.end());
}
+
bool MdPartCo::equalContent( const Container& rhs ) const
{
bool ret = Container::equalContent(rhs);
@@ -1299,14 +1222,11 @@
return false;
}
ret = ret &&
- active==mdp->active &&
- del_ptable==mdp->del_ptable;
-
+ active==mdp->active;
ret = ret &&
- (chunk_size == mdp->chunk_size &&
+ (chunk_k == mdp->chunk_k &&
md_type == mdp->md_type &&
md_parity == mdp->md_parity &&
- md_state == mdp->md_state &&
sb_ver == mdp->sb_ver &&
devs == mdp->devs &&
spare == mdp->spare &&
@@ -1328,64 +1248,13 @@
{
ConstMdPartPair pp = mdpartPair();
ConstMdPartPair pc = mdp->mdpartPair();
- ConstMdPartIter i = pp.begin();
- ConstMdPartIter j = pc.begin();
- while( ret && i!=pp.end() && j!=pc.end() )
- {
- ret = ret && i->equalContent( *j );
- ++i;
- ++j;
- }
- ret = ret && i==pp.end() && j==pc.end();
+ ret = ret && storage::equalContent(pp.begin(), pp.end(), pc.begin(), pc.end());
}
- }
- return( ret );
+ }
+ return ret;
}
-MdPartCo::MdPartCo( const MdPartCo& rhs ) : Container(rhs)
- {
- y2deb("constructed MdPartCo by copy constructor from " << rhs.nm);
- active = rhs.active;
- del_ptable = rhs.del_ptable;
- chunk_size = rhs.chunk_size;
- md_type = rhs.md_type;
- md_parity = rhs.md_parity;
- md_state = rhs.md_state;
- has_container = rhs.has_container;
- parent_container = rhs.parent_container;
- parent_md_name = rhs.parent_md_name;
- parent_metadata = rhs.parent_metadata;
- parent_uuid = rhs.parent_uuid;
- md_metadata = rhs.md_metadata;
- md_uuid = rhs.md_uuid;
- sb_ver = rhs.sb_ver;
- destrSb = rhs.destrSb;
- devs = rhs.devs;
- spare = rhs.spare;
- md_name = rhs.md_name;
-
- udev_path = rhs.udev_path;
- udev_id = rhs.udev_id;
-
- disk = NULL;
- if( rhs.disk )
- disk = new Disk( *rhs.disk );
- getStorage()->waitForDevice();
- ConstMdPartPair p = rhs.mdpartPair();
- for( ConstMdPartIter i = p.begin(); i!=p.end(); ++i )
- {
- MdPart * p = new MdPart( *this, *i );
- vols.push_back( p );
- }
- updatePointers(true);
- num_part = rhs.num_part;
- }
-bool MdPartCo::isMdName(const string& name)
-{
- static Regex md("^md[0123456789]+");
- return (md.match(name));
-}
// Get list of active MD RAID's
// cat /proc/mdstat
// If we're looking for Volume then
@@ -1403,402 +1272,93 @@
//unused devices: <none>
-list<string>
-MdPartCo::getMdRaids()
-{
- y2mil( " called " );
- list<string> l;
- string line;
- string dev_name;
- std::ifstream file( "/proc/mdstat" );
- classic(file);
- getline( file, line );
- while( file.good() )
- {
- string dev_name = extractNthWord( 0, line );
- if( isMdName(dev_name) )
- {
- string line2;
- getline(file,line2);
- if( line2.find("external:imsm") == string::npos &&
- line2.find("external:imsm") == string::npos)
- {
- // external:imsm or ddf not found. Assume that this is a Volume.
- l.push_back(dev_name);
- }
- }
- getline( file, line );
- }
- file.close();
- file.clear();
-
- y2mil("detected md devs : " << l);
- return l;
-}
-
-void
-MdPartCo::getDevs( list<string>& devices, bool all, bool spares ) const
+ list<string>
+ MdPartCo::getMdRaids(SystemInfo& systeminfo)
{
- if( !all )
- devices = spares ? spare : devs;
- else
- {
- devices = devs;
- devices.insert( devices.end(), spare.begin(), spare.end() );
- }
- }
+ list<string> ret;
+ const ProcMdstat& procmdstat = systeminfo.getProcMdstat();
+ for (ProcMdstat::const_iterator it = procmdstat.begin(); it != procmdstat.end(); ++it)
+ {
+ if (!it->second.is_container)
+ ret.push_back(it->first);
+ }
-void MdPartCo::getSpareDevs(std::list<string>& devices )
-{
- devices = spare;
-}
-
-
-bool MdPartCo::matchMdRegex( const string& dev )
- {
- static Regex md( "^md[0123456789]+$" );
- return( md.match(dev));
+ return ret;
}
-unsigned MdPartCo::mdMajor()
- {
- if( md_major==0 )
- getMdMajor();
- return( md_major );
- }
-
-void MdPartCo::getMdMajor()
+ list<string>
+ MdPartCo::getDevs(bool all, bool spares) const
{
- md_major = getMajorDevices( "md" );
- }
-
-void MdPartCo::setSize(unsigned long long size )
-{
- size_k = size;
-}
-
-void MdPartCo::getMdProps()
-{
- y2mil("Called dev:" << dev);
-
- string property;
-
- if( !readProp(METADATA, md_metadata) )
- {
- y2war("Failed to read metadata");
- }
- y2mil("md_metadata:" << md_metadata);
-
- property.clear();
- if( !readProp(COMPONENT_SIZE, property) )
- {
- y2war("Failed to read component_size");
- setSize(0);
- }
- else
- {
- unsigned long long tmpSize;
- property >> tmpSize;
- setSize(tmpSize);
- }
-
- property.clear();
- if( !readProp(CHUNK_SIZE, property) )
- {
- y2war("Failed to read chunk_size");
- chunk_size = 0;
- }
- else
- {
- property >> chunk_size;
- /* From 'B' in file to 'Kb' here. */
- chunk_size /= 1024;
- }
-
- property.clear();
- if( !readProp(ARRAY_STATE, property) )
- {
- md_state = storage::UNKNOWN;
- y2war("array state unknown ");
- }
- else
- {
- if( property == "readonly" )
- {
- //setReadonly();
- }
- md_state = toMdArrayState(property);
- }
-
- if( !readProp(LEVEL, property) )
- {
- y2war("RAID type unknown");
- md_type = storage::RAID_UNK;
- }
- else
- {
- md_type = toMdType(property);
- }
-
- setMdParity();
- setMdDevs();
- setSpares();
- setMetaData();
- MdPartCo::getUuidName(nm,md_uuid,md_name);
-
- y2mil("md_metadata:" << md_metadata);
- if( has_container )
- {
- MdPartCo::getUuidName(parent_container,parent_uuid,parent_md_name);
- y2mil("md_name:" << md_name << " parent_container:" << parent_container <<
- " parent_uuid:" << parent_uuid << " parent_md_name:" << parent_md_name);
- }
- y2mil("Done");
-}
-
-bool MdPartCo::readProp(enum MdProperty prop, string& val)
-{
- string path = sysfs_path + nm + "/md/" + md_props[prop];
- return read_sysfs_property(path, val);
-}
-
-
-void MdPartCo::getSlaves(const string name, std::list<string>& devs_list )
-{
- string path = sysfs_path + name + "/slaves";
- DIR* dir;
-
- devs_list.clear();
-
- if ((dir = opendir(path.c_str())) != NULL)
- {
- struct dirent* entry;
- while ((entry = readdir(dir)) != NULL)
- {
- string tmpS(entry->d_name);
- y2mil("Entry : " << tmpS);
- if (strcmp(entry->d_name, ".") == 0 || strcmp(entry->d_name, "..") == 0)
- {
- continue;
- }
- devs_list.push_back( ("/dev/"+tmpS) );
- }
- closedir(dir);
- }
- else
- {
- y2mil("Failed to opend directory");
- }
-}
-
-
-void MdPartCo::setMdDevs()
-{
- getSlaves(nm,devs);
-
- for( list<string>::iterator s=devs.begin(); s!=devs.end(); ++s )
- {
- //It will be set always to last RAID that was detected.
- getStorage()->setUsedBy( *s, UB_MDPART, nm );
- }
-}
-
-
-void
-MdPartCo::getParent()
-{
- string ret;
- string con = md_metadata;
- string::size_type pos1;
- string::size_type pos2;
-
- parent_container.clear();
- has_container = false;
- if( md_metadata.empty() )
- {
- (void)readProp(METADATA, md_metadata);
- con = md_metadata;
-
- }
- if( con.find("external:")==0 )
- {
- if( (pos1=con.find_first_of("/")) != string::npos )
- {
- if( (pos2=con.find_last_of("/")) != string::npos)
- {
- if( pos1 != pos2)
- {
- //Typically: external:/md127/0
- parent_container.clear();
- parent_container = con.substr(pos1+1,pos2-pos1-1);
- has_container = true;
- }
- }
- }
- else
+ list<string> ret;
+ if (!all)
+ {
+ ret = spares ? spare : devs;
+ }
+ else
{
- // this is the Container
+ ret = devs;
+ ret.insert(ret.end(), spare.begin(), spare.end());
}
- }
- else
- {
- // No external metadata.
- // Possibly this is raid with persistent metadata and no container.
- }
-}
-
-void MdPartCo::setMetaData()
-{
- if( parent_container.empty () )
- {
- getParent();
- }
- if( has_container == false )
- {
- // No parent container.
- sb_ver = md_metadata;
- parent_metadata.clear();
- return;
+ return ret;
}
- string path = sysfs_path + parent_container + "/md/" + md_props[METADATA];
- if( access( path.c_str(), R_OK )==0 )
- {
- std::ifstream file( path.c_str() );
- classic(file);
- string val;
- file >> val;
- file.close();
- file.clear();
- // It will be 'external:XXXX'
- string::size_type pos = val.find(":");
- if( pos != string::npos )
- {
- sb_ver = val.erase(0,pos+1);
- parent_metadata = sb_ver;
- }
- }
-}
-
-void MdPartCo::setMdParity()
+void MdPartCo::setSize(unsigned long long size )
{
- md_parity = PAR_NONE;
- //Level 5 & 6 - left-symmetric
- //Level 10 - n2 layout (0x102)
- if( hasParity() )
- {
- switch( md_type )
- {
- case RAID5:
- case RAID6:
- md_parity = LEFT_ASYMMETRIC;
- case RAID10:
- /* Parity 'n2' */
- //md_parity = PARITY_N2;
- default:
- return;
- }
- }
+ size_k = size;
}
-/* Spares: any disk that is in container and not in RAID. */
-void MdPartCo::setSpares()
-{
- std::list<string> parent_devs;
- std::list<string> diff_devs;
-
- parent_devs.clear();
- diff_devs.clear();
- int found;
-
- list<string>::const_iterator it1;
- list<string>::const_iterator it2;
-
- getParent();
- if( has_container == false )
+ void
+ MdPartCo::initMd(SystemInfo& systeminfo)
{
- spare.clear();
- return;
- }
- getSlaves(parent_container,parent_devs);
-
- for( it1 = parent_devs.begin(); it1 != parent_devs.end(); it1++ )
- {
- found = 0;
- for(it2 = devs.begin(); it2 != devs.end(); it2++ )
- {
- if( *it1 == *it2 )
- {
- found++;
- break;
- }
- }
- if( found == 0 )
- {
- diff_devs.push_back(*it1);
- }
- }
- spare = diff_devs;
+ ProcMdstat::Entry entry;
+ if (!systeminfo.getProcMdstat().getEntry(nm, entry))
+ y2err("not found in mdstat nm:" << nm);
+
+ md_type = entry.md_type;
+ md_parity = entry.md_parity;
+
+ setSize(entry.size_k);
+ chunk_k = entry.chunk_k;
+
+ devs = entry.devices;
+ spare = entry.spares;
+
+ if (entry.has_container)
+ {
+ has_container = true;
+ parent_container = entry.container_name;
+
+ MdadmDetails details;
+ if (getMdadmDetails("/dev/" + entry.container_name, details))
+ {
+ parent_uuid = details.uuid;
+ parent_md_name = details.devname;
+ parent_metadata = details.metadata;
+ }
+
+ parent_member = entry.container_member;
+
+ sb_ver = parent_metadata;
+ }
+ else
+ {
+ sb_ver = entry.super;
+ }
+
+ MdadmDetails details;
+ if (getMdadmDetails("/dev/" + nm, details))
+ {
+ md_uuid = details.uuid;
+ md_name = details.devname;
+ }
- for( list<string>::iterator s=spare.begin(); s!=spare.end(); ++s )
- {
- //It will be set always to last RAID that was detected.
- getStorage()->setUsedBy( *s, UB_MDPART, nm );
+ getStorage()->addUsedBy(devs, UB_MDPART, dev);
+ getStorage()->addUsedBy(spare, UB_MDPART, dev);
}
-}
-
-
-/* Will try to set: UUID, Name.*/
-/* Format: mdX metadata uuid /dev/md/md_name */
-bool MdPartCo::getUuidName(const string dev,string& uuid, string& mdName)
-{
- std::ifstream file;
- string line;
- classic(file);
-
- uuid.clear();
- mdName.clear();
-
- string tmp;
- string::size_type pos;
- //No file, employ mdadm -D name --export
- SystemCmd c(MDADMBIN " --detail " + quote(dev) + " --export");
- if( c.retcode() != 0 )
- {
- return false;
- }
- if(c.select( "MD_UUID" ) > 0)
- {
- tmp = *c.getLine(0,true);
- pos = tmp.find("=");
- tmp.erase(0,pos+1);
- uuid = tmp;
- }
- if( c.select( "MD_DEVNAME" ) > 0)
- {
- tmp = *c.getLine(0,true);
- pos = tmp.find("=");
- tmp.erase(0,pos+1);
- mdName = tmp;
- }
- if( !mdName.empty() && !uuid.empty() )
- {
- return true;
- }
-
- return false;
-}
-
-
-void MdPartCo::initMd()
-{
- /* Name is 'nm' read all props. */
- getMdProps();
-}
void MdPartCo::activate( bool val, const string& tmpDir )
@@ -1829,110 +1389,18 @@
}
-MdType
-MdPartCo::toMdType( const string& val )
- {
- enum MdType ret = MULTIPATH;
- while( ret!=RAID_UNK && val!=md_names[ret] )
- {
- ret = MdType(ret-1);
- }
- return( ret );
- }
-
-MdParity
-MdPartCo::toMdParity( const string& val )
- {
- enum MdParity ret = RIGHT_SYMMETRIC;
- while( ret!=PAR_NONE && val!=par_names[ret] )
- {
- ret = MdParity(ret-1);
- }
- return( ret );
- }
-
-
-
-storage::MdArrayState
-MdPartCo::toMdArrayState( const string& val )
-{
- enum storage::MdArrayState ret = storage::ACTIVE_IDLE;
- while( ret!=storage::UNKNOWN && val!=md_states[ret] )
- {
- ret = storage::MdArrayState(ret-1);
- }
- return( ret );
-}
-
-
-void MdPartCo::getMdPartCoState(storage::MdPartCoStateInfo& info)
+int
+MdPartCo::getMdPartCoState(MdPartCoStateInfo& info) const
{
- string prop;
-
- readProp(ARRAY_STATE,prop);
-
- info.state = toMdArrayState(prop);
+ string value;
+ if (read_sysfs_property(sysfsPath() + "/md/array_state", value))
+ if (toValue(value, info.state))
+ return STORAGE_NO_ERROR;
- info.active = true; //?
- info.degraded = false; //?
+ return MD_GET_STATE_FAILED;
}
-void MdPartCo::getMajorMinor()
-{
- string path = sysfs_path + nm + "/dev";
-
- if( access( path.c_str(), R_OK )==0 )
- {
- string val;
- unsigned pos;
-
- std::ifstream file( path.c_str() );
- classic(file);
- file >> val;
-
- pos = val.find(":");
- val.substr(0,pos) >> mjr;
- val.substr(pos+1) >> mnr;
-
- file.close();
- file.clear();
- }
-
-}
-
-void MdPartCo::makeDevName(const string& name )
-{
- if( name.find("/dev/") != string::npos )
- {
- dev = name;
- }
- else
- {
- dev = "/dev/" + name;
- }
-}
-
-
-bool MdPartCo::isImsmPlatform()
-{
- bool ret = false;
- SystemCmd c;
-
- c.execute(MDADMBIN " --detail-platform");
- c.select( "Platform : " );
- //c.retcode()==0 && - mdadm returns 1.
- if( c.numLines(true)>0 )
- {
- const string line = *c.getLine(0,true);
- if( line.find("Intel(R) Matrix Storage Manager") != string::npos )
- {
- ret = true;
- }
- }
- return ret;
-}
-
/*
* Return true if on RAID Volume has a partition table
*
@@ -1942,180 +1410,72 @@
*
* Ad 2. Clean newly created device or FS on device.
*/
-bool MdPartCo::hasPartitionTable(const string& name )
+bool MdPartCo::hasPartitionTable(const string& name, SystemInfo& systeminfo)
{
- //bool ret = false;
- SystemCmd c;
- bool ret = false;
-
- string cmd = PARTEDCMD " " + quote("/dev/" + name) + " print";
-
- c.execute(cmd);
-
- //For clear md125 (just created)
- //Error: /dev/md125: unrecognised disk label
- //so $? contains 1.
- //If dev has partition table then $? contains 0
- if( c.retcode() == 0 )
- {
- ret = true;
- //Still - it can contain:
- // del: Unknown (unknown)
- // Disk /dev/md125: 133GB
- // Sector size (logical/physical): 512B/512B
- // Partition Table: loop
-
- c.select("Partition Table:");
- if( c.numLines(true) > 0 )
- {
- string loop = *c.getLine(0,true);
- if( loop.find("loop") != string::npos )
- {
- // It has 'loop' partition table so it's actually a volume.
- ret = false;
- }
- }
- }
-return ret;
+ const Parted& parted = systeminfo.getParted("/dev/" + name);
+ string dlabel = parted.getLabel();
+ bool ret = !dlabel.empty() && dlabel != "loop";
+ y2mil("name:" << name << " ret:" << ret);
+ return ret;
}
-/* Return true if there is no partition table and no FS */
-bool MdPartCo::hasFileSystem(const string& name)
+bool
+MdPartCo::hasFileSystem(const string& name, SystemInfo& systeminfo)
{
- //bool ret = false;
- SystemCmd c;
- string cmd = BLKIDBIN " -c /dev/null " + quote("/dev/" + name);
-
- c.execute(cmd);
- // IF filesystem was bit found then it will return no output end error core 2.
- if( c.retcode() != 0 )
+ bool ret = false;
+
+ Blkid::Entry entry;
+ if (systeminfo.getBlkid().getEntry("/dev/" + name, entry))
{
- return false;
+ ret = entry.is_fs || entry.is_lvm || entry.is_luks;
}
- // if FS is on device then it will be in TYPE="fsType" pair.
- return true;
+
+ y2mil("name:" << name << " ret:" << ret);
+ return ret;
}
void
-MdPartCo::syncRaidtab()
+MdPartCo::syncMdadm(EtcMdadm* mdadm) const
{
- updateEntry();
+ updateEntry(mdadm);
}
-string
-MdPartCo::getContMember() const
-{
- y2mil("md_metadata:" << md_metadata);
- string::size_type pos = md_metadata.find_last_of("/");
- if (pos != string::npos)
- {
- string tmp = md_metadata;
- tmp.erase(0, pos + 1);
- return tmp;
- }
- return string();
-}
+ bool
+ MdPartCo::updateEntry(EtcMdadm* mdadm) const
+ {
+ EtcMdadm::mdconf_info info;
+ if (!md_name.empty())
+ info.device = "/dev/md/" + md_name;
+ else
+ info.device = dev;
-void MdPartCo::updateEntry()
- {
- EtcRaidtab* tab = getStorage()->getRaidtab();
- if( tab )
- {
- EtcRaidtab::mdconf_info info;
- if( !md_name.empty() )
- {
- //Raid name is preferred.
- info.fs_name = "/dev/md/" + md_name;
- }
- else
- {
- info.fs_name = dev;
- }
- info.md_uuid = md_uuid;
- if( has_container )
- {
- info.container_present = true;
- info.container_info.md_uuid = parent_uuid;
- info.container_info.metadata = parent_metadata;
- info.member = getContMember();
- }
- else
- {
- info.container_present = false;
- }
- tab->updateEntry( info );
- }
- }
+ info.uuid = md_uuid;
-string MdPartCo::mdadmLine() const
- {
- string line = "ARRAY " + device() + " level=" + pName();
- line += " UUID=" + md_uuid;
- y2mil("line:" << line);
- return( line );
- }
-
-void MdPartCo::raidtabLines( list<string>& lines ) const
- {
- lines.clear();
- lines.push_back( "raiddev " + device() );
- string tmp = " raid-level ";
- switch( md_type )
- {
- case RAID1:
- tmp += "1";
- break;
- case RAID5:
- tmp += "5";
- break;
- case RAID6:
- tmp += "6";
- break;
- case RAID10:
- tmp += "10";
- break;
- case MULTIPATH:
- tmp += "multipath";
- break;
- default:
- tmp += "0";
- break;
- }
- lines.push_back( tmp );
- lines.push_back( " nr-raid-disks " + decString(devs.size()));
- lines.push_back( " nr-spare-disks " + decString(spare.size()));
- lines.push_back( " persistent-superblock 1" );
- if( md_parity!=PAR_NONE )
- lines.push_back( " parity-algorithm " + ptName());
- if( chunk_size>0 )
- lines.push_back( " chunk-size " + decString(chunk_size));
- unsigned cnt = 0;
- for( list<string>::const_iterator i=devs.begin(); i!=devs.end(); ++i )
- {
- lines.push_back( " device " + *i);
- lines.push_back( " raid-disk " + decString(cnt++));
- }
- cnt = 0;
- for( list<string>::const_iterator i=spare.begin(); i!=spare.end(); ++i )
+ if (has_container)
{
- lines.push_back( " device " + *i);
- lines.push_back( " spare-disk " + decString(cnt++));
+ info.container_present = true;
+ info.container_uuid = parent_uuid;
+ info.container_metadata = parent_metadata;
+ info.container_member = parent_member;
}
+
+ return mdadm->updateEntry(info);
}
-int MdPartCo::scanForRaid(list<string>& raidNames)
+
+bool
+MdPartCo::scanForRaid(list<string>& raidNames)
{
- int ret = -1;
- SystemCmd c(MDADMBIN " -Es ");
+ bool ret = false;
raidNames.clear();
+ SystemCmd c(MDADMBIN " --examine --scan");
if( c.retcode() == 0 )
{
- raidNames.clear();
for(unsigned i = 0; i < c.numLines(false); i++ )
{
//Example:
@@ -2123,7 +1483,7 @@
//ARRAY /dev/md/Vol_r5 container=b...5 member=0 UUID=0...c
//ARRAY metadata=imsm UUID=8...b
//ARRAY /dev/md/Vol0 container=8...b member=0 UUID=7...9
- string line = *c.getLine(i);
+ string line = c.getLine(i);
string dev_name = extractNthWord( 1, line );
if( dev_name.find("/dev/md/") == 0 )
{
@@ -2131,20 +1491,18 @@
raidNames.push_back(dev_name);
}
}
- ret = 0;
+ ret = true;
}
y2mil(" Detected list of MD RAIDs : " << raidNames);
return ret;
}
-storage::CType
+
+CType
MdPartCo::envSelection(const string& name)
{
- string big = name;
- std::transform(name.begin(), name.end(),
- big.begin(),(int(*)(int))std::toupper);
- string str = "YAST_STORAGE_" + big;
- char * tenv = getenv( str.c_str() );
+ string str = "LIBSTORAGE_" + boost::to_upper_copy(name, locale::classic());
+ const char* tenv = getenv(str.c_str());
if( tenv == NULL )
{
return CUNKNOWN;
@@ -2161,52 +1519,51 @@
return CUNKNOWN;
}
-bool MdPartCo::havePartsInProc(const string& name, ProcPart& ppart)
+
+bool
+MdPartCo::havePartsInProc(const string& name, SystemInfo& systeminfo)
{
- string reg;
- list <string> parts;
- // Search /proc/partitions for partitions.
- reg = name + "p[1-9]+";
- parts.clear();
- parts = ppart.getMatchingEntries( reg );
- if( !parts.empty() )
- {
- return true;
- }
- return false;
+ string reg = "^" "/dev/" + name + "p[1-9]+" "$";
+ list <string> parts = systeminfo.getProcParts().getMatchingEntries(regex_matches(reg));
+ bool ret = !parts.empty();
+ y2mil("name:" << name << " ret:" << ret);
+ return ret;
}
-list<string> MdPartCo::filterMdPartCo(list<string>& raidList,
- ProcPart& ppart,
- bool isInst)
+
+list<string>
+MdPartCo::filterMdPartCo(const list<string>& raidList, SystemInfo& systeminfo, bool instsys)
{
- y2mil(" called ");
list<string> mdpList;
for( list<string>::const_iterator i=raidList.begin(); i!=raidList.end(); ++i )
{
- storage::CType ct = MdPartCo::envSelection(*i);
- if( ct == MD )
+ y2mil("name:" << *i);
+
+ CType ctype = envSelection(*i);
+ if (ctype == MD)
{
// skip
continue;
}
- if (ct == MDPART )
+ if (ctype == MDPART)
{
mdpList.push_back(*i);
continue;
}
- if( MdPartCo::havePartsInProc(*i,ppart) )
+
+ if (havePartsInProc(*i, systeminfo))
{
mdpList.push_back(*i);
continue;
}
- if( isInst )
+
+ if (instsys)
{
// 1. With Partition Table
// 2. Without Partition Table and without FS on it.
// 3. this gives: No FS.
- if (!MdPartCo::hasFileSystem(*i))
+ if (!hasFileSystem(*i, systeminfo))
{
mdpList.push_back(*i);
}
@@ -2215,35 +1572,17 @@
{
// In 'normal' mode ONLY volume with Partition Table.
// Partitions should be visible already so check it.
- if( MdPartCo::hasPartitionTable(*i))
+ if (hasPartitionTable(*i, systeminfo))
{
mdpList.push_back(*i);
}
}
- } // for
+ }
y2mil("List of partitionable devs: " << mdpList);
return mdpList;
}
-string MdPartCo::md_names[] = { "unknown", "raid0", "raid1", "raid5", "raid6",
- "raid10", "multipath" };
-string MdPartCo::par_names[] = { "none", "left-asymmetric", "left-symmetric",
- "right-asymmetric", "right-symmetric" };
-/* */
-string MdPartCo::md_states[] = {"clear", "inactive", "suspended", "readonly",
- "read-auto", "clean", "active", "write-pending",
- "active-idle"};
-
-string MdPartCo::md_props[] = {"metadata_version", "component_size", "chunk_size",
- "array_state", "level", "layout" };
-/* */
-string MdPartCo::sysfs_path = "/sys/devices/virtual/block/";
-
-unsigned MdPartCo::md_major = 0;
bool MdPartCo::active = false;
-void MdPartCo::logData( const string& Dir ) {}
-
-
}
Modified: branches/SuSE-Code-11-SP2-Branch/storage/libstorage/src/MdPartCo.h
URL: http://svn.opensuse.org/viewcvs/yast/branches/SuSE-Code-11-SP2-Branch/stora…
==============================================================================
--- branches/SuSE-Code-11-SP2-Branch/storage/libstorage/src/MdPartCo.h (original)
+++ branches/SuSE-Code-11-SP2-Branch/storage/libstorage/src/MdPartCo.h Tue May 17 13:39:44 2011
@@ -5,7 +5,7 @@
* Volume) like md126 which is a Container for partitions.
*
* Copyright (c) 2009, Intel Corporation.
- * Copyright (c) 2009 Novell, Inc.
+ * Copyright (c) [2009-2010] Novell, Inc.
*
* This program is free software; you can redistribute it and/or modify it
* under the terms and conditions of the GNU General Public License,
@@ -26,18 +26,17 @@
#include <list>
-#include "y2storage/Container.h"
-#include "y2storage/Disk.h"
-#include "y2storage/MdPart.h"
+#include "storage/Container.h"
+#include "storage/Disk.h"
+#include "storage/Md.h"
+#include "storage/MdPart.h"
namespace storage
{
+ class Storage;
+ class SystemInfo;
+ class Region;
-class Storage;
-class SystemCmd;
-class ProcPart;
-class Region;
-class EtcRaidtab;
/**
* Class: MdPartCo
@@ -48,29 +47,28 @@
class MdPartCo : public Container
{
friend class Storage;
+ friend class Md;
public:
- MdPartCo( Storage * const s,
- const string& Name,
- ProcPart* ppart = NULL);
-
- MdPartCo( const MdPartCo& rhs );
+ MdPartCo(Storage* s, const string& name, const string& device, SystemInfo& systeminfo);
+ MdPartCo(const MdPartCo& c);
virtual ~MdPartCo();
- unsigned long long sizeK() const { return size_k; }
const string& labelName() const { return disk->labelName(); }
- const string& udevPath() const { return udev_path; }
- const std::list<string>& udevId() const { return udev_id; }
+ virtual list<string> udevId() const { return udev_id; }
unsigned numPartitions() const { return disk->numPartitions(); }
static storage::CType staticType() { return storage::MDPART; }
friend std::ostream& operator<< (std::ostream&, const MdPartCo& );
- void setUdevData(const list<string>& id);
- /* Checks if name fits with MD name*/
- bool matchMdName(const string& name ) { return (name==nm); }
+ void setUdevData(SystemInfo& systeminfo);
+
+ virtual string procName() const { return nm; }
+ virtual string sysfsPath() const;
+
+ static bool notDeleted(const MdPartCo& c) { return !c.deleted(); }
- void getMdPartCoState(storage::MdPartCoStateInfo& info);
+ int getMdPartCoState(MdPartCoStateInfo& info) const;
int createPartition( storage::PartitionType type, long unsigned start,
long unsigned len, string& device,
@@ -81,8 +79,7 @@
int removePartition( unsigned nr );
int changePartitionId( unsigned nr, unsigned id );
int forgetChangePartitionId( unsigned nr );
- int changePartitionArea( unsigned nr, unsigned long start,
- unsigned long size, bool checkRelaxed=false );
+ int changePartitionArea(unsigned nr, const Region& cylRegion, bool checkRelaxed = false);
int nextFreePartition(storage::PartitionType type, unsigned& nr,
string& device) const;
int destroyPartitionTable( const string& new_label );
@@ -108,89 +105,63 @@
{ return disk->cylinderToKb( val ); }
unsigned long kbToCylinder( unsigned long long val ) const
{ return disk->kbToCylinder( val ); }
- string getPartName( unsigned nr ) const;
- virtual void getCommitActions( std::list<storage::commitAction*>& l ) const;
- virtual int getToCommit( storage::CommitStage stage,
- std::list<Container*>& col,
- std::list<Volume*>& vol );
+ string getPartName(unsigned nr) const;
+ string getPartDevice(unsigned nr) const;
+
+ virtual void getCommitActions(list<commitAction>& l) const;
+ virtual void getToCommit(CommitStage stage, list<const Container*>& col,
+ list<const Volume*>& vol) const;
virtual int commitChanges( storage::CommitStage stage );
int commitChanges( storage::CommitStage stage, Volume* vol );
Partition* getPartition( unsigned nr, bool del );
- int getPartitionInfo(deque<storage::PartitionInfo>& plist);
+
void getInfo( storage::MdPartCoInfo& info ) const;
bool equalContent( const Container& rhs ) const;
- virtual string getDiffString( const Container& d ) const;
- void logDifference( const MdPartCo& d ) const;
+
+ void logDifference(std::ostream& log, const MdPartCo& rhs) const;
+ virtual void logDifferenceWithVolumes(std::ostream& log, const Container& rhs) const;
+
MdPartCo& operator= ( const MdPartCo& rhs );
static string undevName( const string& name );
- string numToName( unsigned mdNum ) const;
- static list<string> getMdRaids();
+ static list<string> getMdRaids(SystemInfo& systeminfo);
- void syncRaidtab();
+ void syncMdadm(EtcMdadm* mdadm) const;
- /* Returns number from MD name */
- int nr(const string& name);
/* Returns Md number. */
- int nr();
- /* RAID Related functionality */
- unsigned long chunkSize() const { return chunk_size; }
+ unsigned nr() const { return mnr; }
- storage::MdType personality() const { return md_type; }
+ unsigned long chunkSizeK() const { return chunk_k; }
- storage::MdArrayState getArrayState() { return md_state; };
+ storage::MdType personality() const { return md_type; }
- void getMdUuid( string&val ) { val=md_uuid; }
+ const string& getMdUuid() const { return md_uuid; }
- /* Raid Level of the RAID as string. */
- const string& pName() const { return md_names[md_type]; }
- /* Parity for some of RAID's. */
- const string& ptName() const { return par_names[md_parity]; }
/* Devices from which RAID is composed. */
- void getDevs( std::list<string>& devices, bool all=true, bool spare=false ) const;
-
-
- void getSpareDevs(std::list<string>& devices );
-
- /* Is MD device? */
- static bool matchMdRegex( const string& dev );
- /* MD Device major number. */
- static unsigned mdMajor();
-
- /* Raid Level as string for given type. */
- static const string& pName( storage::MdType t ) { return md_names[t]; }
+ list<string> getDevs(bool all = true, bool spare = false) const;
static void activate( bool val, const string& tmpDir );
- static bool isActive( void ) { return active; }
+ static bool isActive() { return active; }
- /* Return true if on RAID Volume is partition table */
- static bool hasPartitionTable(const string& name );
- /* Return true if there is no Filesystem on device (it can contain partition table). */
- static bool hasFileSystem(const string& name);
-
- static bool isImsmPlatform();
+ static bool hasPartitionTable(const string& name, SystemInfo& systeminfo);
+ static bool hasFileSystem(const string& name, SystemInfo& systeminfo);
static bool matchRegex( const string& dev );
static bool mdStringNum( const string& name, unsigned& num );
- // This function will scann for MD RAIDs and will return
+ // This function will scan for MD RAIDs and will return
// list with detected RAID names.
- static int scanForRaid(list<string>& raidNames);
+ static bool scanForRaid(list<string>& raidNames);
/* filterMdPartCo
* Get list of detected MD RAIDs and filters them for
* those which can be handled by MdPartCo.
*/
- static list<string> filterMdPartCo(list<string>& raidList,
- ProcPart& ppart,
- bool isInst);
-
- /* Returns uuid and possibly mdName for given MD Device.
- * Input parameter: dev name - like md1 */
- static bool getUuidName(const string dev,string& uuid, string& mdName);
+ static list<string> filterMdPartCo(const list<string>& raidList, SystemInfo& systeminfo,
+ bool instsys);
protected:
// iterators over partitions
@@ -241,13 +212,12 @@
return( ConstMdPartIter( MdPartCPIterator( p, CheckMdPart, true )) );
}
- MdPartCo( Storage * const s, const string& File );
virtual void print( std::ostream& s ) const { s << *this; }
virtual Container* getCopy() const { return( new MdPartCo( *this ) ); }
void activate_part( bool val );
- void init( ProcPart* ppart );
- void createDisk( ProcPart* ppart );
- void getVolumes( ProcPart* ppart );
+ void init(SystemInfo& systeminfo);
+ void createDisk(SystemInfo& systeminfo);
+ void getVolumes(const ProcParts& ppart);
void updatePointers( bool invalid=false );
void updateMinor();
virtual void newP( MdPart*& dm, unsigned num, Partition* p );
@@ -259,12 +229,7 @@
bool validPartition( const Partition* p );
bool findMdPart( unsigned nr, MdPartIter& i );
- void updateEntry();
- string mdadmLine() const;
- void raidtabLines( list<string>& lines ) const;
-
-
- static bool partNotDeleted( const MdPart&d ) { return( !d.deleted() ); }
+ bool updateEntry(EtcMdadm* mdadm) const;
int doCreate( Volume* v );
int doRemove( Volume* v );
@@ -272,113 +237,47 @@
int doSetType( MdPart* v );
int doCreateLabel();
virtual int doRemove();
- virtual string removeText( bool doing ) const;
- virtual string setDiskLabelText( bool doing ) const;
-
- void getMajorMinor(void);
+ virtual Text removeText( bool doing ) const;
+ virtual Text setDiskLabelText( bool doing ) const;
- /* Makes sure that dev=/dev/name is name doesn't contains this prefix*/
- void makeDevName(const string& name );
/* Initialize the MD part of object.*/
- void initMd(void);
+ void initMd(SystemInfo& systeminfo);
void setSize(unsigned long long size );
- /* */
- static bool isMdName(const string& name);
- bool isMdPart(const string& name);
+ bool isMdPart(const string& name) const;
- void getPartNum(const string& device, unsigned& num);
+ void getPartNum(const string& device, unsigned& num) const;
- void getMdProps(void);
-
- void setSpares(void);
- /* Clear UsedBy for Disks. */
- int unuseDevs(void);
-
- void logData( const string& Dir );
- string udev_path;
- std::list<string> udev_id;
- string logfile_name;
+ void unuseDevs() const;
Disk* disk;
- bool del_ptable;
- unsigned num_part;
-
- /* RAID Related */
-
- /* Returns container */
- void getParent();
-
- void setMetaData();
-
- void setMdDevs();
-
- void setMdParity();
-
- /* returns devices listed as slaves in sysfs directory */
- void getSlaves(const string name, std::list<string>& devs_list );
-
- string getContMember() const;
//Input: 'mdXXX' device.
- static storage::CType envSelection(const string& name);
- static bool havePartsInProc(const string& name, ProcPart& ppart);
-
- static void getMdMajor();
- static storage::MdType toMdType( const string& val );
- static storage::MdParity toMdParity( const string& val );
- static storage::MdArrayState toMdArrayState( const string& val );
-
-
+ static CType envSelection(const string& name);
+ static bool havePartsInProc(const string& name, SystemInfo& systeminfo);
- unsigned long chunk_size;
- storage::MdType md_type;
- storage::MdParity md_parity;
- storage::MdArrayState md_state;
-
- /* Md Container - */
- bool has_container;
- string parent_container;
- string parent_uuid;
- string parent_metadata;
- string parent_md_name;
- string md_metadata;
- string md_uuid;
- string sb_ver;
- bool destrSb;
- std::list<string> devs;
- std::list<string> spare;
- static string md_names[storage::MULTIPATH+1];
- static string par_names[storage::RIGHT_SYMMETRIC+1];
- static string md_states[storage::ACTIVE_IDLE+1];
- static unsigned md_major;
-
- /* Name that is present in /dev/md directory.*/
- string md_name;
-
- static string sysfs_path;
-
- enum MdProperty
- {
- METADATA=0,
- COMPONENT_SIZE,
- CHUNK_SIZE,
- ARRAY_STATE,
- LEVEL,
- LAYOUT,
- /* ... */
- MDPROP_LAST,
- };
- static string md_props[MDPROP_LAST];
-
- bool readProp(enum MdProperty prop, string& val);
-
- /* For that RAID type parity means something */
- bool hasParity() const
- { return md_type == RAID5 || md_type == RAID6 || md_type == RAID10; }
+ MdType md_type;
+ MdParity md_parity;
+ unsigned long chunk_k;
+ string md_uuid;
+ string md_name; // line in /dev/md/*
+ string sb_ver;
+ bool destrSb;
+ list<string> devs;
+ list<string> spare;
+
+ list<string> udev_id;
+
+ // In case of IMSM and DDF raids there is 'container'.
+ bool has_container;
+ string parent_container;
+ string parent_uuid;
+ string parent_md_name;
+ string parent_metadata;
+ string parent_member;
- mutable storage::MdPartCoInfo info;
+ mutable storage::MdPartCoInfo info; // workaround for broken ycp bindings
static bool active;
Modified: branches/SuSE-Code-11-SP2-Branch/storage/libstorage/src/Nfs.cc
URL: http://svn.opensuse.org/viewcvs/yast/branches/SuSE-Code-11-SP2-Branch/stora…
==============================================================================
--- branches/SuSE-Code-11-SP2-Branch/storage/libstorage/src/Nfs.cc (original)
+++ branches/SuSE-Code-11-SP2-Branch/storage/libstorage/src/Nfs.cc Tue May 17 13:39:44 2011
@@ -1,5 +1,5 @@
/*
- * Copyright (c) [2004-2009] Novell, Inc.
+ * Copyright (c) [2004-2010] Novell, Inc.
*
* All Rights Reserved.
*
@@ -19,44 +19,51 @@
* find current contact information at www.novell.com.
*/
-/*
- Textdomain "storage"
-*/
#include <sstream>
-#include <sys/stat.h>
+#include "storage/Nfs.h"
+#include "storage/StorageTypes.h"
+#include "storage/Container.h"
+#include "storage/AppUtil.h"
+#include "storage/Storage.h"
-#include "y2storage/Nfs.h"
-#include "y2storage/StorageTypes.h"
-#include "y2storage/Container.h"
-#include "y2storage/AppUtil.h"
-#include "y2storage/Storage.h"
+namespace storage
+{
+ using namespace std;
-using namespace storage;
-using namespace std;
-Nfs::Nfs( const NfsCo& d, const string& NfsDev ) :
- Volume( d, 0, 0 )
+ Nfs::Nfs(const NfsCo& c, const string& NfsDev, bool nfs4)
+ : Volume(c, canonicalName(NfsDev), canonicalName(NfsDev))
{
- y2deb("constructed nfs dev:" << NfsDev);
- if( d.type() != NFSC )
- y2err("constructed nfs with wrong container");
- dev = canonicalName(NfsDev);
- if( dev != NfsDev )
- alt_names.push_back( NfsDev );
- init();
+ assert(c.type() == NFSC);
+
+ if (dev != NfsDev)
+ alt_names.push_back(NfsDev);
+
+ setFs(nfs4 ? NFS4 : NFS);
+
+ y2deb("constructed Nfs " << dev << " nfs4:" << nfs4);
}
-Nfs::~Nfs()
+
+ Nfs::Nfs(const NfsCo& c, const Nfs& v)
+ : Volume(c, v)
+ {
+ y2deb("copy-constructed Nfs from " << v.dev);
+ }
+
+
+ Nfs::~Nfs()
{
- y2deb("destructed nfs " << dev);
+ y2deb("destructed Nfs " << dev);
}
-string Nfs::removeText( bool doing ) const
+
+Text Nfs::removeText( bool doing ) const
{
- string txt;
+ Text txt;
if( doing )
{
// displayed text during action, %1$s is replaced by volume name e.g. hilbert:/work
@@ -70,64 +77,43 @@
return( txt );
}
-void
-Nfs::init()
+
+ string
+ Nfs::canonicalName(const string& d)
{
- numeric = false;
- nm = dev;
- setFs(NFS);
- }
-
-string Nfs::canonicalName( const string& d )
- {
- string dev(d);
- string::size_type pos = 0;
- while( (pos=dev.find("//",pos))!=string::npos )
- dev.erase(pos,1);
- if( !dev.empty() && *dev.rbegin()=='/' )
- dev.erase(dev.size()-1);
- if( dev!=d )
- y2mil( "dev:" << dev << " d:" << d );
- return(dev);
+ string dev = boost::replace_all_copy(d, "//", "/");
+ if (dev.size() > 2 && dev[dev.size() - 2] != ':' && dev[dev.size() - 1] == '/')
+ dev.erase(dev.size() - 1);
+ if (dev != d)
+ y2mil("old:" << d << " new:" << dev);
+ return dev;
}
+
void Nfs::getInfo( NfsInfo& tinfo ) const
{
- ((Volume*)this)->getInfo( info.v );
+ Volume::getInfo(info.v);
tinfo = info;
}
-namespace storage
-{
std::ostream& operator<< (std::ostream& s, const Nfs& l )
{
- s << "Nfs " << *(Volume*)&l;
+ s << "Nfs " << dynamic_cast<const Volume&>(l);
return( s );
}
-}
bool Nfs::equalContent( const Nfs& rhs ) const
{
return( Volume::equalContent(rhs) );
}
-void Nfs::logDifference( const Nfs& rhs ) const
-{
- string log = Volume::logDifference(rhs);
- y2mil(log);
-}
-Nfs& Nfs::operator= ( const Nfs& rhs )
+ void
+ Nfs::logDifference(std::ostream& log, const Nfs& rhs) const
{
- y2deb("operator= from " << rhs.nm);
- *((Volume*)this) = rhs;
- return( *this );
+ Volume::logDifference(log, rhs);
}
-Nfs::Nfs( const NfsCo& d, const Nfs& rhs ) : Volume(d)
- {
- y2deb("constructed nfs by copy constructor from " << rhs.nm);
- *this = rhs;
- }
+}
Modified: branches/SuSE-Code-11-SP2-Branch/storage/libstorage/src/Nfs.h
URL: http://svn.opensuse.org/viewcvs/yast/branches/SuSE-Code-11-SP2-Branch/stora…
==============================================================================
--- branches/SuSE-Code-11-SP2-Branch/storage/libstorage/src/Nfs.h (original)
+++ branches/SuSE-Code-11-SP2-Branch/storage/libstorage/src/Nfs.h Tue May 17 13:39:44 2011
@@ -23,7 +23,7 @@
#ifndef NFS_H
#define NFS_H
-#include "y2storage/Volume.h"
+#include "storage/Volume.h"
namespace storage
{
@@ -32,9 +32,11 @@
class Nfs : public Volume
{
public:
- Nfs( const NfsCo& d, const string& NfsDev );
- Nfs( const NfsCo& d, const Nfs& rhs );
+
+ Nfs(const NfsCo& c, const string& NfsDev, bool nfs4);
+ Nfs(const NfsCo& c, const Nfs& v);
virtual ~Nfs();
+
friend std::ostream& operator<< (std::ostream& s, const Nfs& l );
static string canonicalName( const string& dev );
@@ -44,15 +46,20 @@
void getInfo( storage::NfsInfo& info ) const;
bool equalContent( const Nfs& rhs ) const;
- void logDifference( const Nfs& d ) const;
- string removeText( bool doing=true ) const;
+ void logDifference(std::ostream& log, const Nfs& rhs) const;
+
+ Text removeText(bool doing) const;
protected:
- void init();
- Nfs& operator=( const Nfs& );
- mutable storage::NfsInfo info;
+ mutable storage::NfsInfo info; // workaround for broken ycp bindings
+
+ private:
+
+ Nfs(const Nfs&); // disallow
+ Nfs& operator=(const Nfs&); // disallow
+
};
}
Modified: branches/SuSE-Code-11-SP2-Branch/storage/libstorage/src/NfsCo.cc
URL: http://svn.opensuse.org/viewcvs/yast/branches/SuSE-Code-11-SP2-Branch/stora…
==============================================================================
--- branches/SuSE-Code-11-SP2-Branch/storage/libstorage/src/NfsCo.cc (original)
+++ branches/SuSE-Code-11-SP2-Branch/storage/libstorage/src/NfsCo.cc Tue May 17 13:39:44 2011
@@ -19,62 +19,58 @@
* find current contact information at www.novell.com.
*/
-/*
- Textdomain "storage"
-*/
-#include <iostream>
+#include <ostream>
#include <sstream>
-#include "y2storage/NfsCo.h"
-#include "y2storage/Nfs.h"
-#include "y2storage/AppUtil.h"
-#include "y2storage/ProcMounts.h"
-#include "y2storage/Storage.h"
-#include "y2storage/EtcFstab.h"
+#include "storage/NfsCo.h"
+#include "storage/Nfs.h"
+#include "storage/AppUtil.h"
+#include "storage/SystemInfo.h"
+#include "storage/Storage.h"
+#include "storage/EtcFstab.h"
-using namespace storage;
-using namespace std;
-NfsCo::NfsCo( Storage * const s, ProcMounts& mounts ) :
- Container(s,"nfs",staticType())
- {
- y2deb("constructing NfsCo detect");
- init();
- getNfsData( mounts );
- }
+namespace storage
+{
+ using namespace std;
-NfsCo::NfsCo( Storage * const s ) :
- Container(s,"nfs",staticType())
- {
- y2deb("constructing NfsCo");
- init();
- }
-NfsCo::NfsCo( Storage * const s, const string& file ) :
- Container(s,"nfs",staticType())
+ NfsCo::NfsCo(Storage* s)
+ : Container(s, "nfs", "/dev/nfs", staticType())
{
- y2deb("constructing NfsCo file:" << file);
- init();
+ y2deb("constructing NfsCo");
}
-NfsCo::~NfsCo()
+
+ NfsCo::NfsCo(Storage* s, const EtcFstab& fstab, SystemInfo& systeminfo)
+ : Container(s, "nfs", "/dev/nfs", staticType(), systeminfo)
{
- y2deb("destructed NfsCo");
+ y2deb("constructing NfsCo");
+ getNfsData(fstab, systeminfo);
}
-void
-NfsCo::init()
+
+ NfsCo::NfsCo(const NfsCo& c)
+ : Container(c)
{
+ y2deb("copy-constructed NfsCo from " << c.dev);
+
+ ConstNfsPair p = c.nfsPair();
+ for (ConstNfsIter i = p.begin(); i != p.end(); ++i)
+ {
+ Nfs* p = new Nfs(*this, *i);
+ vols.push_back(p);
+ }
}
-bool NfsCo::isNfsDev( const string& dev )
+
+ NfsCo::~NfsCo()
{
- bool ret = dev.find( ":/" )<dev.find( '/' );
- y2mil( "dev:" << dev << " ret:" << ret );
- return( ret );
+ y2deb("destructed NfsCo " << dev);
}
+
int
NfsCo::removeVolume( Volume* v )
{
@@ -131,42 +127,59 @@
}
int
-NfsCo::addNfs( const string& nfsDev, unsigned long long sizeK,
- const string& mp )
+NfsCo::addNfs(const string& nfsDev, unsigned long long sizeK,
+ const string& opts, const string& mp, bool nfs4)
{
- y2mil( "nfsDev:" << nfsDev << " sizeK:" << sizeK << " mp:" << mp );
- Nfs *n = new Nfs( *this, nfsDev );
+ y2mil("nfsDev:" << nfsDev << " sizeK:" << sizeK << "opts:" << opts <<
+ " mp:" << mp << " nfs4:" << nfs4);
+ Nfs *n = new Nfs(*this, nfsDev, nfs4);
n->changeMount( mp );
n->setSize( sizeK );
+ n->setFstabOption( opts );
addToList( n );
return( 0 );
}
+
+ list<string>
+ NfsCo::filterOpts(const list<string>& opts)
+ {
+ const char* ign_opt[] = { "hard", "rw", "v3", "v2", "lock" };
+ const char* ign_opt_start[] = { "proto=", "addr=", "vers=" };
+
+ list<string> ret = opts;
+
+ for (size_t i = 0; i < lengthof(ign_opt); ++i)
+ ret.remove(ign_opt[i]);
+
+ for (size_t i = 0; i < lengthof(ign_opt_start); ++i)
+ ret.remove_if(string_starts_with(ign_opt_start[i]));
+
+ return ret;
+ }
+
+
void
-NfsCo::getNfsData( ProcMounts& mounts )
+NfsCo::getNfsData(const EtcFstab& fstab, SystemInfo& systeminfo)
{
- y2mil( "begin fstab:" << getStorage()->getFstab() );
- list<FstabEntry> l;
- getStorage()->getFstab()->getEntries(l);
- for( list<FstabEntry>::const_iterator i=l.begin(); i!=l.end(); ++i )
+ const list<FstabEntry> l1 = fstab.getEntries();
+ for (list<FstabEntry>::const_iterator i = l1.begin(); i != l1.end(); ++i)
{
- if( i->fs == "nfs" )
+ if( i->fs == "nfs" || i->fs == "nfs4")
{
- Nfs *n = new Nfs( *this, i->device );
+ Nfs *n = new Nfs(*this, i->device, i->fs == "nfs4");
n->setMount( i->mount );
- string op = mergeString(i->opts, "," );
- if( op != "defaults" )
- n->setFstabOption( op );
+ string opt = boost::join(i->opts, ",");
+ if (opt != "defaults")
+ n->setFstabOption(opt);
addToList( n );
}
}
- l.clear();
- mounts.getEntries(l);
- const char * ign_opt[] = { "hard", "rw", "v3", "v2", "lock" };
- const char * ign_beg[] = { "proto=", "addr=", "vers=" };
- for( list<FstabEntry>::iterator i=l.begin(); i!=l.end(); ++i )
+
+ const list<FstabEntry> l2 = systeminfo.getProcMounts().getEntries();
+ for (list<FstabEntry>::const_iterator i = l2.begin(); i != l2.end(); ++i)
{
- if( i->fs == "nfs" )
+ if( i->fs == "nfs" || i->fs == "nfs4")
{
Nfs *n = NULL;
NfsIter nfs;
@@ -176,38 +189,21 @@
}
else
{
- n = new Nfs( *this, i->device );
- list<string>::iterator si = i->opts.begin();
- unsigned pos = 0;
- while( si!=i->opts.end() )
- {
- pos=0;
- while( pos<lengthof(ign_opt) && *si!=ign_opt[pos] )
- ++pos;
- if( pos<lengthof(ign_opt) )
- si = i->opts.erase(si);
- else
- {
- pos=0;
- while( pos<lengthof(ign_beg) && si->find(ign_beg[pos])!=0 )
- ++pos;
- if( pos<lengthof(ign_beg) )
- si = i->opts.erase(si);
- else
- ++si;
- }
- }
+ n = new Nfs(*this, i->device, i->fs == "nfs4");
n->setIgnoreFstab();
- n->setFstabOption( mergeString(i->opts, "," ) );
+ string opt = boost::join(filterOpts(i->opts), ",");
+ n->setFstabOption(opt);
addToList( n );
}
- unsigned long long sz = getStorage()->getDfSize( i->mount );
- n->setSize( sz );
+
+ StatVfs vfsbuf;
+ getStatVfs(i->mount, vfsbuf);
+ n->setSize(vfsbuf.sizeK);
}
}
- l.clear();
}
+
bool
NfsCo::findNfs( const string& dev, NfsIter& i )
{
@@ -226,59 +222,28 @@
}
-void NfsCo::logData( const string& Dir ) {;}
-
-namespace storage
-{
-
-inline std::ostream& operator<< (std::ostream& s, const NfsCo& d )
+ std::ostream& operator<<(std::ostream& s, const NfsCo& d)
{
- s << *((Container*)&d);
+ s << dynamic_cast<const Container&>(d);
return( s );
}
-}
-void NfsCo::logDifference( const Container& d ) const
+ void
+ NfsCo::logDifferenceWithVolumes(std::ostream& log, const Container& rhs_c) const
{
- y2mil(Container::getDiffString(d));
- const NfsCo* p = dynamic_cast<const NfsCo*>(&d);
- if( p != NULL )
- {
- ConstNfsPair pp=nfsPair();
- ConstNfsIter i=pp.begin();
- while( i!=pp.end() )
- {
- ConstNfsPair pc=p->nfsPair();
- ConstNfsIter j = pc.begin();
- while( j!=pc.end() &&
- (i->device()!=j->device() || i->created()!=j->created()) )
- ++j;
- if( j!=pc.end() )
- {
- if( !i->equalContent( *j ) )
- i->logDifference( *j );
- }
- else
- y2mil( " -->" << *i );
- ++i;
- }
- pp=p->nfsPair();
- i=pp.begin();
- while( i!=pp.end() )
- {
- ConstNfsPair pc=nfsPair();
- ConstNfsIter j = pc.begin();
- while( j!=pc.end() &&
- (i->device()!=j->device() || i->created()!=j->created()) )
- ++j;
- if( j==pc.end() )
- y2mil( " <--" << *i );
- ++i;
- }
- }
+ const NfsCo& rhs = dynamic_cast<const NfsCo&>(rhs_c);
+
+ logDifference(log, rhs);
+ log << endl;
+
+ ConstNfsPair pp = nfsPair();
+ ConstNfsPair pc = rhs.nfsPair();
+
+ logVolumesDifference(log, pp.begin(), pp.end(), pc.begin(), pc.end());
}
+
bool NfsCo::equalContent( const Container& rhs ) const
{
const NfsCo* p = NULL;
@@ -289,27 +254,9 @@
{
ConstNfsPair pp = nfsPair();
ConstNfsPair pc = p->nfsPair();
- ConstNfsIter i = pp.begin();
- ConstNfsIter j = pc.begin();
- while( ret && i!=pp.end() && j!=pc.end() )
- {
- ret = ret && i->equalContent( *j );
- ++i;
- ++j;
- }
- ret = ret && i==pp.end() && j==pc.end();
+ ret = ret && storage::equalContent(pp.begin(), pp.end(), pc.begin(), pc.end());
}
return( ret );
}
-NfsCo::NfsCo( const NfsCo& rhs ) : Container(rhs)
- {
- y2deb("constructed NfsCo by copy constructor from " << rhs.nm);
- *this = rhs;
- ConstNfsPair p = rhs.nfsPair();
- for( ConstNfsIter i=p.begin(); i!=p.end(); ++i )
- {
- Nfs * p = new Nfs( *this, *i );
- vols.push_back( p );
- }
- }
+}
Modified: branches/SuSE-Code-11-SP2-Branch/storage/libstorage/src/NfsCo.h
URL: http://svn.opensuse.org/viewcvs/yast/branches/SuSE-Code-11-SP2-Branch/stora…
==============================================================================
--- branches/SuSE-Code-11-SP2-Branch/storage/libstorage/src/NfsCo.h (original)
+++ branches/SuSE-Code-11-SP2-Branch/storage/libstorage/src/NfsCo.h Tue May 17 13:39:44 2011
@@ -23,32 +23,36 @@
#ifndef NFS_CO_H
#define NFS_CO_H
-#include "y2storage/Container.h"
-#include "y2storage/Nfs.h"
+#include "storage/Container.h"
+#include "storage/Nfs.h"
namespace storage
{
+ class SystemInfo;
+
+
class NfsCo : public Container
{
friend class Storage;
public:
- NfsCo( Storage * const s, ProcMounts& mounts );
- NfsCo( Storage * const s );
- NfsCo( const NfsCo& rhs );
+ NfsCo(Storage * const s);
+ NfsCo(Storage * const s, const EtcFstab& fstab, SystemInfo& systeminfo);
+ NfsCo(const NfsCo& c);
virtual ~NfsCo();
+
static storage::CType staticType() { return storage::NFSC; }
friend std::ostream& operator<< ( std::ostream&, const NfsCo& );
- int addNfs( const string& nfsDev, unsigned long long sizeK,
- const string& mp );
+ int addNfs(const string& nfsDev, unsigned long long sizeK, const string& opts,
+ const string& mp, bool nfs4);
- static bool isNfsDev( const string& dev );
int removeVolume( Volume* v );
int doRemove( Volume* );
bool equalContent( const Container& rhs ) const;
- void logDifference( const Container& d ) const;
+
+ virtual void logDifferenceWithVolumes(std::ostream& log, const Container& rhs) const;
protected:
// iterators over NFS volumes
@@ -99,17 +103,19 @@
return( ConstNfsIter( NfsCPIterator( p, Check, true )) );
}
- NfsCo( Storage * const s, const string& File );
-
bool findNfs( const string& dev, NfsIter& i );
bool findNfs( const string& dev );
- void getNfsData( ProcMounts& mounts );
- void init();
+
+ static list<string> filterOpts(const list<string>& opts);
+ void getNfsData(const EtcFstab& fstab, SystemInfo& systeminfo);
virtual void print( std::ostream& s ) const { s << *this; }
virtual Container* getCopy() const { return( new NfsCo( *this ) ); }
- void logData( const string& Dir );
+ private:
+
+ NfsCo& operator=(const NfsCo&); // disallow
+
};
}
Modified: branches/SuSE-Code-11-SP2-Branch/storage/libstorage/src/OutputProcessor.cc
URL: http://svn.opensuse.org/viewcvs/yast/branches/SuSE-Code-11-SP2-Branch/stora…
==============================================================================
--- branches/SuSE-Code-11-SP2-Branch/storage/libstorage/src/OutputProcessor.cc (original)
+++ branches/SuSE-Code-11-SP2-Branch/storage/libstorage/src/OutputProcessor.cc Tue May 17 13:39:44 2011
@@ -19,35 +19,19 @@
* find current contact information at www.novell.com.
*/
-/*
- Textdomain "storage"
-*/
-
-#include <sstream>
-
-#include "y2storage/AppUtil.h"
-#include "y2storage/StorageTmpl.h"
-#include "y2storage/OutputProcessor.h"
-using namespace std;
-using namespace storage;
+#include "storage/AppUtil.h"
+#include "storage/StorageTmpl.h"
+#include "storage/OutputProcessor.h"
-void
-OutputProcessor::process( const string& val, bool stderr )
- {
- y2mil("stderr:" << stderr << " val:" << val);
- }
-void
-ScrollBarHandler::process( const string& val, bool stderr )
- {
- OutputProcessor::process( val, stderr );
- static int cnt=0;
- setCurValue( cnt++/2 );
- }
+namespace storage
+{
+ using namespace std;
+
void
-ScrollBarHandler::setCurValue( unsigned val )
+ProgressBar::setCurValue(unsigned val)
{
if( first || val!=cur )
{
@@ -60,7 +44,7 @@
}
void
-Mke2fsScrollbar::process( const string& val, bool stderr )
+Mke2fsProgressBar::process(const string& val, bool stderr)
{
y2deb("val:" << val << " err:" << stderr << " done:" << done);
if( !stderr && !done )
@@ -108,14 +92,14 @@
}
if( seen.find( "done" )!=string::npos )
{
- setCurValue( max-4 );
+ setCurValue(getMaxValue() - 4);
done = true;
}
}
}
void
-ReiserScrollbar::process( const string& val, bool stderr )
+ReiserProgressBar::process(const string& val, bool stderr)
{
y2deb("val:" << val << " err:" << stderr);
if( !stderr )
@@ -146,7 +130,7 @@
}
void
-DasdfmtScrollbar::process( const string& val, bool stderr )
+DasdfmtProgressBar::process(const string& val, bool stderr)
{
y2deb("val:" << val << " err:" << stderr);
if( !stderr )
@@ -170,9 +154,11 @@
while( bpos != string::npos )
{
cur_cyl++;
- setCurValue( cur_cyl*max/max_cyl );
+ setCurValue( cur_cyl*getMaxValue()/max_cyl );
seen.erase( 0, bpos+1 );
bpos = seen.find( "|" );
}
}
}
+
+}
Modified: branches/SuSE-Code-11-SP2-Branch/storage/libstorage/src/OutputProcessor.h
URL: http://svn.opensuse.org/viewcvs/yast/branches/SuSE-Code-11-SP2-Branch/stora…
==============================================================================
--- branches/SuSE-Code-11-SP2-Branch/storage/libstorage/src/OutputProcessor.h (original)
+++ branches/SuSE-Code-11-SP2-Branch/storage/libstorage/src/OutputProcessor.h Tue May 17 13:39:44 2011
@@ -23,76 +23,107 @@
#ifndef OUTPUT_PROCESSOR_H
#define OUTPUT_PROCESSOR_H
-#include "y2storage/StorageInterface.h"
+
+#include "storage/StorageInterface.h"
+
namespace storage
{
-class OutputProcessor
+ class OutputProcessor
{
public:
OutputProcessor() {}
virtual ~OutputProcessor() {}
- virtual void reset() {}
- virtual void finished() {}
- virtual void process( const string& txt, bool stderr );
+ virtual void reset() = 0;
+ virtual void finish() = 0;
+ virtual void process(const string& txt, bool stderr) = 0;
};
-class ScrollBarHandler : public OutputProcessor
+
+ class ProgressBar : public OutputProcessor
{
public:
- ScrollBarHandler( const string& sid, storage::CallbackProgressBar cb )
- { id=sid; first=true; callback=cb; cur=0; max=100; }
- virtual ~ScrollBarHandler() {}
- virtual void reset() { first=true; cur=0; }
- virtual void finished() { setCurValue( max ); }
- virtual void process( const string& txt, bool stderr );
- void setMaxValue( unsigned val ) { max=val; }
- unsigned getMaxValue() { return( max ); }
- void setCurValue( unsigned val );
- unsigned getCurValue() { return( cur ); }
+ ProgressBar(const string& id, CallbackProgressBar callback)
+ : id(id), callback(callback), first(true), max(100), cur(0)
+ {}
+
+ virtual ~ProgressBar() {}
+
+ virtual void reset() { first = true; cur = 0; }
+ virtual void finish() { setCurValue(max); }
+ virtual void process(const string& txt, bool stderr) {}
+
+ void setMaxValue(unsigned val) { max = val; }
+ unsigned getMaxValue() const { return max; }
+ void setCurValue(unsigned val);
+ unsigned getCurValue() const { return cur; }
protected:
+ const string id;
+ const CallbackProgressBar callback;
+
+ bool first;
+
+ private:
unsigned long max;
unsigned long cur;
- bool first;
- string id;
- storage::CallbackProgressBar callback;
};
-class Mke2fsScrollbar : public ScrollBarHandler
+
+ class Mke2fsProgressBar : public ProgressBar
{
public:
- Mke2fsScrollbar( storage::CallbackProgressBar cb ) :
- ScrollBarHandler( "format", cb ) { done=false; }
- virtual void process( const string& txt, bool stderr );
+ Mke2fsProgressBar(CallbackProgressBar callback)
+ : ProgressBar("format", callback)
+ {
+ setMaxValue(100);
+ done = false;
+ }
+
+ virtual void process(const string& txt, bool stderr);
+
protected:
string seen;
bool done;
};
-class ReiserScrollbar : public ScrollBarHandler
+
+ class ReiserProgressBar : public ProgressBar
{
public:
- ReiserScrollbar( storage::CallbackProgressBar cb ) :
- ScrollBarHandler( "format", cb ) { max=100; }
- virtual void process( const string& txt, bool stderr );
+ ReiserProgressBar(CallbackProgressBar callback)
+ : ProgressBar("format", callback)
+ {
+ setMaxValue(100);
+ }
+
+ virtual void process(const string& txt, bool stderr);
+
protected:
string seen;
};
-class DasdfmtScrollbar : public ScrollBarHandler
+
+ class DasdfmtProgressBar : public ProgressBar
{
public:
- DasdfmtScrollbar( storage::CallbackProgressBar cb ) :
- ScrollBarHandler( "dasdfmt", cb ) { max=100; max_cyl=cur_cyl=0; }
- virtual void process( const string& txt, bool stderr );
+ DasdfmtProgressBar(CallbackProgressBar callback)
+ : ProgressBar("dasdfmt", callback)
+ {
+ setMaxValue(100);
+ max_cyl = cur_cyl = 0;
+ }
+
+ virtual void process(const string& txt, bool stderr);
+
protected:
string seen;
- unsigned long cur_cyl;
unsigned long max_cyl;
+ unsigned long cur_cyl;
};
}
+
#endif
Added: branches/SuSE-Code-11-SP2-Branch/storage/libstorage/src/Parted.cc
URL: http://svn.opensuse.org/viewcvs/yast/branches/SuSE-Code-11-SP2-Branch/stora…
==============================================================================
--- branches/SuSE-Code-11-SP2-Branch/storage/libstorage/src/Parted.cc (added)
+++ branches/SuSE-Code-11-SP2-Branch/storage/libstorage/src/Parted.cc Tue May 17 13:39:44 2011
@@ -0,0 +1,373 @@
+/*
+ * Copyright (c) [2004-2010] Novell, Inc.
+ *
+ * All Rights Reserved.
+ *
+ * This program is free software; you can redistribute it and/or modify it
+ * under the terms of version 2 of the GNU General Public License as published
+ * by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
+ * more details.
+ *
+ * You should have received a copy of the GNU General Public License along
+ * with this program; if not, contact Novell, Inc.
+ *
+ * To contact Novell about this file by physical or electronic mail, you may
+ * find current contact information at www.novell.com.
+ */
+
+
+#include <fstream>
+
+#include "storage/AppUtil.h"
+#include "storage/SystemCmd.h"
+#include "storage/StorageDefines.h"
+#include "storage/Parted.h"
+#include "storage/Enum.h"
+#include "storage/Partition.h"
+
+
+namespace storage
+{
+ using namespace std;
+
+
+ Parted::Parted(const string& device)
+ : gpt_enlarge(false)
+ {
+ SystemCmd cmd(PARTEDCMD + quote(device) + " unit cyl print unit s print");
+
+ if (cmd.select("Partition Table:") > 0)
+ label = extractNthWord(2, cmd.getLine(0, true));
+ else
+ y2war("could not find partition table");
+
+ // only present for unrecognised disk label due to patch in parted
+ if (cmd.select("BIOS cylinder") > 0)
+ scanGeometryLine(cmd.getLine(0, true));
+ else
+ y2err("could not find geometry");
+
+ // not present for unrecognised disk label
+ if (cmd.select("Sector size") > 0)
+ scanSectorSizeLine(cmd.getLine(0, true));
+ else
+ y2war("could not find sector size");
+
+ gpt_enlarge = cmd.select("fix the GPT to use all") > 0;
+
+ if (label != "loop")
+ {
+ int n = 0;
+
+ const vector<string>& lines = cmd.stdout();
+ for (vector<string>::const_iterator it = lines.begin(); it != lines.end(); ++it)
+ {
+ if (boost::starts_with(*it, "Number"))
+ n++;
+
+ string tmp = extractNthWord(0, *it);
+ if (!tmp.empty() && isdigit(tmp[0]))
+ {
+ assert(n == 1 || n == 2);
+ if (n == 1)
+ scanCylEntryLine(*it);
+ else if (n == 2)
+ scanSecEntryLine(*it);
+ }
+ }
+ }
+
+ y2mil("device:" << device << " label:" << label << " geometry:" << geometry <<
+ " gpt_enlarge:" << gpt_enlarge);
+
+ for (const_iterator it = entries.begin(); it != entries.end(); ++it)
+ y2mil(*it);
+ }
+
+
+ bool
+ Parted::getEntry(unsigned num, Entry& entry) const
+ {
+ for (const_iterator it = entries.begin(); it != entries.end(); ++it)
+ {
+ if (it->num == num)
+ {
+ entry = *it;
+ return true;
+ }
+ }
+
+ return false;
+ }
+
+
+ std::ostream& operator<<(std::ostream& s, const Parted::Entry& e)
+ {
+ s << "num:" << e.num << " cylRegion:" << e.cylRegion << " secRegion:" << e.secRegion
+ << " type:" << toString(e.type) << " id:" << e.id;
+
+ if (e.boot)
+ s << " boot";
+
+ return s;
+ }
+
+
+ void
+ Parted::scanGeometryLine(const string& line)
+ {
+ string tmp(line);
+ tmp.erase(0, tmp.find(':') + 1);
+ tmp = extractNthWord(0, tmp);
+
+ list<string> l = splitString(extractNthWord(0, tmp), ",");
+ assert(l.size() == 3);
+ if (l.size() == 3)
+ {
+ list<string>::const_iterator i = l.begin();
+ *i++ >> geometry.cylinders;
+ *i++ >> geometry.heads;
+ *i++ >> geometry.sectors;
+ }
+ else
+ {
+ y2err("could not find geometry");
+ }
+ }
+
+
+ void
+ Parted::scanSectorSizeLine(const string& line)
+ {
+ string tmp(line);
+ tmp.erase(0, tmp.find(':') + 1);
+ tmp = extractNthWord(0, tmp);
+
+ list<string> l = splitString(extractNthWord(0, tmp), "/");
+ assert(l.size() == 2);
+ if (l.size() == 2)
+ {
+ list<string>::const_iterator i = l.begin();
+ *i >> geometry.sector_size;
+ }
+ else
+ {
+ y2war("could not find sector size");
+ }
+ }
+
+
+ void
+ Parted::scanCylEntryLine(const string& line)
+ {
+ Entry entry;
+
+ std::istringstream Data(line);
+ classic(Data);
+
+ unsigned long StartM = 0;
+ unsigned long EndM = 0;
+ unsigned long SizeM = 0;
+ string PartitionTypeStr;
+ string skip;
+
+ if( label == "msdos" )
+ {
+ Data >> entry.num >> StartM >> skip >> EndM >> skip >> SizeM >> skip >> PartitionTypeStr;
+ }
+ else
+ {
+ Data >> entry.num >> StartM >> skip >> EndM >> skip >> SizeM >> skip;
+ }
+
+ assert(!Data.fail());
+ assert(entry.num != 0);
+
+ if (Data.fail() || entry.num == 0)
+ {
+ y2err("invalid line:" << line);
+ return;
+ }
+
+ char c;
+ string TInfo;
+ Data.unsetf(ifstream::skipws);
+ Data >> c;
+ char last_char = ',';
+ while( Data.good() && !Data.eof() )
+ {
+ if( !isspace(c) )
+ {
+ TInfo += c;
+ last_char = c;
+ }
+ else
+ {
+ if( last_char != ',' )
+ {
+ TInfo += ",";
+ last_char = ',';
+ }
+ }
+ Data >> c;
+ }
+
+ y2mil("num:" << entry.num << " Start:" << StartM << " End:" << EndM << " Size:" << SizeM);
+
+ unsigned long start = StartM;
+ unsigned long csize = EndM-StartM+1;
+ if( start + csize > geometry.cylinders )
+ {
+ csize = geometry.cylinders - start;
+ y2mil("new csize:" << csize);
+ }
+ entry.cylRegion = Region(start, csize);
+
+ boost::to_lower(TInfo, locale::classic());
+ list<string> flags = splitString(TInfo, ",");
+ y2mil("TInfo:" << TInfo << " flags:" << flags);
+
+ entry.boot = contains(flags, "boot");
+
+ entry.id = Partition::ID_LINUX;
+
+ if( label == "msdos" )
+ {
+ if( PartitionTypeStr == "extended" )
+ {
+ entry.type = EXTENDED;
+ entry.id = Partition::ID_EXTENDED;
+ }
+ else if( entry.num >= 5 )
+ {
+ entry.type = LOGICAL;
+ }
+ }
+ else if (contains_if(flags, string_starts_with("fat")))
+ {
+ entry.id = Partition::ID_DOS32;
+ }
+ else if (contains(flags, "ntfs"))
+ {
+ entry.id = Partition::ID_NTFS;
+ }
+ else if (contains_if(flags, string_contains("swap")))
+ {
+ entry.id = Partition::ID_SWAP;
+ }
+ else if (contains(flags, "raid"))
+ {
+ entry.id = Partition::ID_RAID;
+ }
+ else if (contains(flags, "lvm"))
+ {
+ entry.id = Partition::ID_LVM;
+ }
+
+ list<string>::const_iterator it1 = find_if(flags.begin(), flags.end(),
+ string_starts_with("type="));
+ if (it1 != flags.end())
+ {
+ string val = string(*it1, 5);
+
+ if( label != "mac" )
+ {
+ int tmp_id = 0;
+ std::istringstream Data2(val);
+ classic(Data2);
+ Data2 >> std::hex >> tmp_id;
+ if( tmp_id>0 )
+ {
+ entry.id = tmp_id;
+ }
+ }
+ else
+ {
+ if( entry.id == Partition::ID_LINUX )
+ {
+ if( val.find( "apple_hfs" ) != string::npos ||
+ val.find( "apple_bootstrap" ) != string::npos )
+ {
+ entry.id = Partition::ID_APPLE_HFS;
+ }
+ else if( val.find( "apple_partition" ) != string::npos ||
+ val.find( "apple_driver" ) != string::npos ||
+ val.find( "apple_loader" ) != string::npos ||
+ val.find( "apple_boot" ) != string::npos ||
+ val.find( "apple_prodos" ) != string::npos ||
+ val.find( "apple_fwdriver" ) != string::npos ||
+ val.find( "apple_patches" ) != string::npos )
+ {
+ entry.id = Partition::ID_APPLE_OTHER;
+ }
+ else if( val.find( "apple_ufs" ) != string::npos )
+ {
+ entry.id = Partition::ID_APPLE_UFS;
+ }
+ }
+ }
+ }
+
+ if( label == "gpt" )
+ {
+ if (contains(flags, "boot") && contains_if(flags, string_starts_with("fat")))
+ {
+ entry.id = Partition::ID_GPT_BOOT;
+ }
+ if (contains(flags, "hp-service"))
+ {
+ entry.id = Partition::ID_GPT_SERVICE;
+ }
+ if (contains(flags, "msftres"))
+ {
+ entry.id = Partition::ID_GPT_MSFTRES;
+ }
+ if (contains(flags, "hfs+") || contains(flags, "hfs"))
+ {
+ entry.id = Partition::ID_APPLE_HFS;
+ }
+ }
+ y2mil("num:" << entry.num << " id:" << entry.id << " type:" << toString(entry.type));
+
+ entries.push_back(entry);
+ }
+
+
+ void
+ Parted::scanSecEntryLine(const string& line)
+ {
+ std::istringstream Data(line);
+ classic(Data);
+
+ unsigned num;
+ unsigned long long startSec = 0;
+ unsigned long long endSec = 0;
+ unsigned long long sizeSec = 0;
+ string skip;
+
+ Data >> num >> startSec >> skip >> endSec >> skip >> sizeSec >> skip;
+
+ assert(!Data.fail());
+ assert(num != 0);
+
+ if (Data.fail() || num == 0)
+ {
+ y2err("invalid line:" << line);
+ return;
+ }
+
+ for (iterator it = entries.begin(); it != entries.end(); ++it)
+ {
+ if (it->num == num)
+ {
+ it->secRegion = Region(startSec, sizeSec);
+ return;
+ }
+ }
+ }
+
+}
Added: branches/SuSE-Code-11-SP2-Branch/storage/libstorage/src/Parted.h
URL: http://svn.opensuse.org/viewcvs/yast/branches/SuSE-Code-11-SP2-Branch/stora…
==============================================================================
--- branches/SuSE-Code-11-SP2-Branch/storage/libstorage/src/Parted.h (added)
+++ branches/SuSE-Code-11-SP2-Branch/storage/libstorage/src/Parted.h Tue May 17 13:39:44 2011
@@ -0,0 +1,84 @@
+/*
+ * Copyright (c) [2004-2010] Novell, Inc.
+ *
+ * All Rights Reserved.
+ *
+ * This program is free software; you can redistribute it and/or modify it
+ * under the terms of version 2 of the GNU General Public License as published
+ * by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
+ * more details.
+ *
+ * You should have received a copy of the GNU General Public License along
+ * with this program; if not, contact Novell, Inc.
+ *
+ * To contact Novell about this file by physical or electronic mail, you may
+ * find current contact information at www.novell.com.
+ */
+
+
+#ifndef PARTED_H
+#define PARTED_H
+
+#include "storage/StorageInterface.h"
+#include "storage/Geometry.h"
+#include "storage/Region.h"
+
+
+namespace storage
+{
+
+ class Parted
+ {
+
+ public:
+
+ Parted(const string& device);
+
+ struct Entry
+ {
+ Entry() : num(0), type(PRIMARY), id(0), boot(false) {}
+
+ unsigned num;
+ Region cylRegion;
+ Region secRegion;
+ PartitionType type;
+ unsigned id;
+ bool boot;
+
+ friend std::ostream& operator<<(std::ostream& s, const Entry& e);
+ };
+
+ const string& getLabel() const { return label; }
+ const Geometry& getGeometry() const { return geometry; }
+ bool getGptEnlarge() const { return gpt_enlarge; }
+
+ typedef vector<Entry>::const_iterator const_iterator;
+
+ const vector<Entry>& getEntries() const { return entries; }
+
+ bool getEntry(unsigned num, Entry& entry) const;
+
+ private:
+
+ typedef vector<Entry>::iterator iterator;
+
+ string label;
+ Geometry geometry;
+ bool gpt_enlarge;
+ vector<Entry> entries;
+
+ void scanSectorSizeLine(const string& line);
+ void scanGeometryLine(const string& line);
+ void scanCylEntryLine(const string& line);
+ void scanSecEntryLine(const string& line);
+
+ };
+
+}
+
+
+#endif
Modified: branches/SuSE-Code-11-SP2-Branch/storage/libstorage/src/Partition.cc
URL: http://svn.opensuse.org/viewcvs/yast/branches/SuSE-Code-11-SP2-Branch/stora…
==============================================================================
--- branches/SuSE-Code-11-SP2-Branch/storage/libstorage/src/Partition.cc (original)
+++ branches/SuSE-Code-11-SP2-Branch/storage/libstorage/src/Partition.cc Tue May 17 13:39:44 2011
@@ -1,5 +1,5 @@
/*
- * Copyright (c) [2004-2009] Novell, Inc.
+ * Copyright (c) [2004-2010] Novell, Inc.
*
* All Rights Reserved.
*
@@ -19,106 +19,131 @@
* find current contact information at www.novell.com.
*/
-/*
- Textdomain "storage"
-*/
#include <sstream>
-#include "y2storage/Partition.h"
-#include "y2storage/AppUtil.h"
-#include "y2storage/Disk.h"
-#include "y2storage/Storage.h"
+#include "storage/Partition.h"
+#include "storage/AppUtil.h"
+#include "storage/Disk.h"
+#include "storage/Storage.h"
+
+
+namespace storage
+{
+ using namespace std;
-using namespace storage;
-using namespace std;
-static string udevCompleteIdPath( const string& s, unsigned nr )
+ Partition::Partition(const Disk& c, const string& name, const string& device, unsigned PNr,
+ unsigned long long SizeK, const Region& cylRegion, PartitionType Type,
+ unsigned Id, bool Boot)
+ : Volume(c, name, device), reg(cylRegion), bootflag(Boot), typ(Type), idt(Id), orig_id(Id)
{
- return( "/dev/disk/by-id/" + s + "-part" + decString(nr) );
+ numeric = true;
+ num = orig_num = PNr;
+ size_k = orig_size_k = SizeK;
+
+ addUdevData();
+ y2deb("constructed Partition " << dev << " on " << cont->device());
}
-static string udevCompletePathPath( const string& s, unsigned nr )
+
+ Partition::Partition(const Disk& c, const string& name, const string& device, unsigned PNr,
+ SystemInfo& systeminfo, unsigned long long SizeK, const Region& cylRegion,
+ PartitionType Type, unsigned Id, bool Boot)
+ : Volume(c, name, device, systeminfo), reg(cylRegion), bootflag(Boot), typ(Type), idt(Id),
+ orig_id(Id)
{
- return( "/dev/disk/by-path/" + s + "-part" + decString(nr) );
+ numeric = true;
+ num = orig_num = PNr;
+ size_k = orig_size_k = SizeK;
+
+ getMajorMinor();
+
+ addUdevData();
+ y2deb("constructed Partition " << dev << " on " << cont->device());
}
-Partition::Partition( const Disk& d, unsigned PNr, unsigned long long SizeK,
- unsigned long Start, unsigned long CSize,
- PartitionType Type, unsigned Id, bool Boot )
- : Volume( d, PNr, SizeK ), reg( Start, CSize )
+
+ Partition::Partition(const Disk& c, const xmlNode* node)
+ : Volume(c, node), reg(0, 0), bootflag(false)
{
- bootflag = Boot;
- idt = orig_id = Id;
- typ = Type;
- orig_num = num;
- addUdevData();
- y2debug( "constructed partition %s on disk %s", dev.c_str(),
- cont->name().c_str() );
+ string tmp;
+
+ assert(numeric);
+ assert(num > 0);
+
+ getChildValue(node, "region", reg);
+
+ if (getChildValue(node, "partition_type", tmp))
+ typ = toValueWithFallback(tmp, PRIMARY);
+ getChildValue(node, "partition_id", idt);
+
+ getChildValue(node, "boot_flag", bootflag);
+
+ orig_num = num;
+ orig_id = idt;
+
+ y2deb("constructed Partition " << dev);
}
-Partition::Partition( const Disk& d, const string& Data ) :
- Volume( d, 0, 0 )
+
+ Partition::Partition(const Disk& c, const Partition& v)
+ : Volume(c, v), reg(v.reg), bootflag(v.bootflag), typ(v.typ),
+ idt(v.idt), orig_id(v.orig_id), orig_num(v.orig_num)
{
- string ts, rs;
- istringstream i( Data );
- classic(i);
- i >> num >> dev >> size_k >> mjr >> mnr >> reg >>
- hex >> idt >> dec >> ts >> rs;
- orig_size_k = size_k;
- orig_num = num;
- orig_id = idt;
- nm = dev;
- undevDevice(nm); // strip "/dev/"
- if( ts == "extended" )
- typ = EXTENDED;
- else if( ts == "logical" )
- typ = LOGICAL;
- else
- typ = PRIMARY;
- if( rs == "boot" )
- bootflag = true;
- else
- bootflag = false;
- addUdevData();
- y2debug( "constructed partition %s on disk %s", dev.c_str(),
- cont->name().c_str() );
+ y2deb("copy-constructed Partition " << dev);
}
-const list<string> Partition::udevId() const
- {
- list<string> ret;
- list<string>::const_iterator i = alt_names.begin();
- while( i != alt_names.end() )
- {
- if( i->find( "/by-id/" ) != string::npos )
- ret.push_back( *i );
- ++i;
- }
- return( ret );
+
+ Partition::~Partition()
+ {
+ y2deb("destructed Partition " << dev);
+ }
+
+
+ void
+ Partition::saveData(xmlNode* node) const
+ {
+ Volume::saveData(node);
+
+ setChildValue(node, "region", reg);
+
+ setChildValue(node, "partition_type", toString(typ));
+ setChildValue(node, "partition_id", idt);
+
+ if (bootflag)
+ setChildValue(node, "boot_flag", true);
}
-const string& Partition::udevPath() const
+
+ list<string>
+ Partition::udevId() const
{
- list<string>::const_iterator i =
- find_if( alt_names.begin(), alt_names.end(), find_any( "/by-path/" ));
- return( i==alt_names.end() ? empty_string : *i );
+ list<string> ret;
+ const list<string> tmp = disk()->udevId();
+ for (list<string>::const_iterator i = tmp.begin(); i != tmp.end(); ++i)
+ ret.push_back(udevAppendPart(*i, num));
+ return ret;
}
-string Partition::sysfsPath() const
+
+ string
+ Partition::udevPath() const
{
- string ret = disk()->sysfsDir() + "/";
- string tmp = undevDevice(dev);
- string::size_type pos = 0;
- while( (pos=tmp.find( '/', pos ))!=string::npos )
- {
- tmp[pos++] = '!';
- }
- ret += tmp;
- y2mil( "ret:" << ret );
- return( ret );
+ const string tmp = disk()->udevPath();
+ if (!tmp.empty())
+ return udevAppendPart(tmp, num);
+ return "";
}
+
+ string
+ Partition::sysfsPath() const
+ {
+ return disk()->sysfsPath() + "/" + boost::replace_all_copy(procName(), "/", "!");
+ }
+
+
bool Partition::intersectArea( const Region& r, unsigned fuzz ) const
{
return( r.intersect( reg ).len()>fuzz );
@@ -133,45 +158,32 @@
{
addAltUdevPath( num );
addAltUdevId( num );
- y2mil( "dev:" << dev << " mby:" << mbyTypeString(mount_by) <<
- " orig:" << mbyTypeString(orig_mount_by) );
+ y2mil("dev:" << dev << " mby:" << toString(mount_by) << " orig:" << toString(orig_mount_by));
mount_by = orig_mount_by = defaultMountBy();
- y2mil( "dev:" << dev << " mby:" << mbyTypeString(mount_by) <<
- " orig:" << mbyTypeString(orig_mount_by) );
+ y2mil("dev:" << dev << " mby:" << toString(mount_by) << " orig:" << toString(orig_mount_by));
}
+
void Partition::addAltUdevId( unsigned num )
{
- list<string>::iterator i = alt_names.begin();
- while( i!=alt_names.end() )
- {
- if( i->find( "/by-id/" ) != string::npos )
- i = alt_names.erase( i );
- else
- ++i;
- }
- list<string>::const_iterator j = disk()->udevId().begin();
- while( j!=disk()->udevId().end() )
- {
- alt_names.push_back( udevCompleteIdPath( *j, num ));
- ++j;
- }
+ alt_names.remove_if(string_contains("/by-id/"));
+
+ const list<string> tmp = disk()->udevId();
+ for (list<string>::const_iterator i = tmp.begin(); i != tmp.end(); ++i)
+ alt_names.push_back("/dev/disk/by-id/" + udevAppendPart(*i, num));
}
+
void Partition::addAltUdevPath( unsigned num )
{
- list<string>::iterator i = alt_names.begin();
- while( i!=alt_names.end() )
- {
- if( i->find( "/by-path/" ) != string::npos )
- i = alt_names.erase( i );
- else
- ++i;
- }
- if( !disk()->udevPath().empty() )
- alt_names.push_back( udevCompletePathPath( disk()->udevPath(), num ));
+ alt_names.remove_if(string_contains("/by-path/"));
+
+ const string tmp = disk()->udevPath();
+ if (!tmp.empty() )
+ alt_names.push_back("/dev/disk/by-path/" + udevAppendPart(tmp, num));
}
+
void Partition::changeNumber( unsigned new_num )
{
if( new_num!=num )
@@ -186,15 +198,14 @@
{
orig_num = num;
}
- addAltUdevId( num );
- list<string>::iterator i = find_if( alt_names.begin(), alt_names.end(),
- find_any( "/by-path/" ));
- if( i!=alt_names.end() )
- *i = udevCompletePathPath( disk()->udevPath(), num );
- nm.clear();
- setNameDev();
- getMajorMinor( dev, mjr, mnr );
- getContainer()->getStorage()->changeDeviceName( old, dev );
+
+ addAltUdevId(num);
+ addAltUdevPath(num);
+
+ setNameDevice(disk()->getPartName(num), disk()->getPartDevice(num));
+
+ getMajorMinor();
+ getStorage()->changeDeviceName(old, dev);
}
}
@@ -234,13 +245,15 @@
idt = orig_id;
}
-void Partition::changeRegion( unsigned long Start, unsigned long CSize,
- unsigned long long SizeK )
+
+ void
+ Partition::changeRegion(const Region& cylRegion, unsigned long long SizeK)
{
- reg = Region( Start, CSize );
- size_k = orig_size_k = SizeK;
+ reg = cylRegion;
+ size_k = orig_size_k = SizeK;
}
+
bool Partition::canUseDevice() const
{
bool ret = Volume::canUseDevice();
@@ -252,51 +265,37 @@
void Partition::setResizedSize( unsigned long long SizeK )
{
Volume::setResizedSize(SizeK);
- reg = Region( cylStart(), disk()->kbToCylinder(SizeK) );
+ reg.setLen(disk()->kbToCylinder(SizeK));
}
void Partition::forgetResize()
{
Volume::forgetResize();
- reg = Region( cylStart(), disk()->kbToCylinder(size_k) );
+ reg.setLen(disk()->kbToCylinder(size_k));
}
bool Partition::operator== ( const Partition& rhs ) const
{
return( orig_num == rhs.orig_num &&
num == rhs.num &&
- del == rhs.del );
+ del == rhs.del &&
+ cont == rhs.getContainer() );
}
bool Partition::operator< ( const Partition& rhs ) const
{
- if( orig_num!=rhs.orig_num )
+ if( cont != rhs.getContainer() )
+ return( *cont < *rhs.getContainer() );
+ else if( orig_num!=rhs.orig_num )
return( orig_num<rhs.orig_num );
else
return( !del );
}
-ostream& Partition::logData( ostream& file ) const
- {
- file << num << " " << dev << " " << size_k << " " << mjr << " "
- << mnr << " ";
- file << reg.start() << " " << reg.len() << " " << hex << idt << dec;
- if( typ == LOGICAL )
- file << " logical";
- else if( typ == EXTENDED )
- file << " extended";
- else
- file << " primary";
- if( bootflag )
- file << " boot";
- if( orig_num!=num )
- file << " OrigNr:" << orig_num;
- return( file );
- }
-string Partition::setTypeText( bool doing ) const
+Text Partition::setTypeText( bool doing ) const
{
- string txt;
+ Text txt;
string d = dev;
if( doing )
{
@@ -323,8 +322,7 @@
int Partition::setFormat( bool val, storage::FsType new_fs )
{
int ret = 0;
- y2milestone( "device:%s val:%d fs:%s", dev.c_str(), val,
- fs_names[new_fs].c_str() );
+ y2mil("device:" << dev << " val:" << val << " fs:" << toString(new_fs));
if( typ==EXTENDED )
{
if( val )
@@ -339,7 +337,7 @@
int Partition::changeMount( const string& val )
{
int ret = 0;
- y2milestone( "device:%s val:%s", dev.c_str(), val.c_str() );
+ y2mil("device:" << dev << " val:" << val);
if( typ==EXTENDED )
ret = VOLUME_MOUNT_EXTENDED_UNSUPPORTED;
else
@@ -348,10 +346,12 @@
return( ret );
}
-bool Partition::isWindows() const
+
+ bool
+ Partition::isWindows() const
{
- return( idt==6 || idt==0xb || idt==ID_DOS || idt==0xe || idt==1 || idt==4 ||
- idt==ID_NTFS || idt==0x17 );
+ return idt==ID_DOS16 || idt==0x0b || idt==ID_DOS32 || idt==0x0e || idt==ID_DOS12 || idt==0x04 ||
+ idt==ID_NTFS || idt==0x17;
}
@@ -361,26 +361,26 @@
int ret = 0;
bool zero_new = getContainer()->getStorage()->getZeroNewPartitions();
- bool used_as_pv = getUsedByType() == UB_LVM;
+ bool used_as_pv = isUsedBy(UB_LVM);
- y2milestone( "zero_new:%d used_as_pv:%d", zero_new, used_as_pv );
+ y2mil("zero_new:" << zero_new << " used_as_pv:" << used_as_pv);
if (zero_new || used_as_pv)
{
- ret = getContainer()->getStorage()->zeroDevice(device(), sizeK());
+ ret = getContainer()->getStorage()->zeroDevice(device(), sizeK());
}
return ret;
}
-string Partition::removeText( bool doing ) const
+Text Partition::removeText( bool doing ) const
{
- string txt;
+ Text txt;
string d = dev;
if( orig_num!=num )
{
- d = disk()->getPartName( orig_num );
+ d = disk()->getPartDevice( orig_num );
}
if( doing )
{
@@ -407,112 +407,36 @@
return( txt );
}
-string Partition::createText( bool doing ) const
+
+Text
+Partition::createText(bool doing) const
+{
+ Text txt;
+ if (doing)
{
- string txt;
- string d = dev;
- if( doing )
- {
- // displayed text during action, %1$s is replaced by device name e.g. /dev/hda1
- txt = sformat( _("Creating partition %1$s"), d.c_str() );
- }
+ txt = Volume::createText(doing);
+ }
else
+ {
+ if (typ == EXTENDED)
{
- if( typ==EXTENDED )
- {
// displayed text before action, %1$s is replaced by device name e.g. /dev/hda1
// %2$s is replaced by size (e.g. 623.5 MB)
- txt = sformat( _("Create extended partition %1$s (%2$s)"),
- d.c_str(), sizeString().c_str() );
- }
- else if( mp=="swap" )
- {
- // displayed text before action, %1$s is replaced by device name e.g. /dev/hda1
- // %2$s is replaced by size (e.g. 623.5 MB)
- txt = sformat( _("Create swap partition %1$s (%2$s)"),
- d.c_str(), sizeString().c_str() );
- }
- else if( mp=="/" )
- {
- // displayed text before action, %1$s is replaced by device name e.g. /dev/hda1
- // %2$s is replaced by size (e.g. 623.5 MB)
- // %3$s is replaced by file system type (e.g. reiserfs)
- txt = sformat( _("Create root partition %1$s (%2$s) with %3$s"),
- d.c_str(), sizeString().c_str(), fsTypeString().c_str() );
- }
- else if( mp==bootMount() )
- {
- // displayed text before action, %1$s is replaced by device name e.g. /dev/hda1
- // %2$s is replaced by size (e.g. 623.5 MB)
- // %3$s is replaced by file system type (e.g. reiserfs)
- txt = sformat( _("Create boot partition %1$s (%2$s) with %3$s"),
- d.c_str(), sizeString().c_str(), fsTypeString().c_str() );
- }
- else if( !mp.empty() )
- {
- if( encryption==ENC_NONE )
- {
- // displayed text before action, %1$s is replaced by device name e.g. /dev/hda1
- // %2$s is replaced by size (e.g. 623.5 MB)
- // %3$s is replaced by file system type (e.g. reiserfs)
- // %4$s is replaced by mount point (e.g. /usr)
- txt = sformat( _("Create partition %1$s (%2$s) for %4$s with %3$s"),
- d.c_str(), sizeString().c_str(), fsTypeString().c_str(),
- mp.c_str() );
- }
- else
- {
- // displayed text before action, %1$s is replaced by device name e.g. /dev/hda1
- // %2$s is replaced by size (e.g. 623.5 MB)
- // %3$s is replaced by file system type (e.g. reiserfs)
- // %4$s is replaced by mount point (e.g. /usr)
- txt = sformat( _("Create encrypted partition %1$s (%2$s) for %4$s with %3$s"),
- d.c_str(), sizeString().c_str(), fsTypeString().c_str(),
- mp.c_str() );
- }
- }
- else if( idt != ID_SWAP && idt != ID_LINUX && idt<256 )
- {
- if (encryption == ENC_NONE)
- {
- // displayed text before action, %1$s is replaced by device name e.g. /dev/hda1
- // %2$s is replaced by size (e.g. 623.5 MB)
- // %3$s is replaced by hexadecimal number (e.g. 8E)
- txt = sformat(_("Create partition %1$s (%2$s) with id=%3$X"), d.c_str(),
- sizeString().c_str(), idt);
- }
- else
- {
- // displayed text before action, %1$s is replaced by device name e.g. /dev/hda1
- // %2$s is replaced by size (e.g. 623.5 MB)
- // %3$s is replaced by hexadecimal number (e.g. 8E)
- txt = sformat(_("Create encrypted partition %1$s (%2$s) with id=%3$X"), d.c_str(),
- sizeString().c_str(), idt);
- }
+ txt = sformat(_("Create extended partition %1$s (%2$s)"), dev.c_str(),
+ sizeString().c_str());
}
else
{
- if (encryption == ENC_NONE)
- {
- // displayed text before action, %1$s is replaced by device name e.g. /dev/hda1
- // %2$s is replaced by size (e.g. 623.5 MB)
- txt = sformat(_("Create partition %1$s (%2$s)"), d.c_str(), sizeString().c_str());
- }
- else
- {
- // displayed text before action, %1$s is replaced by device name e.g. /dev/hda1
- // %2$s is replaced by size (e.g. 623.5 MB)
- txt = sformat(_("Create encrypted partition %1$s (%2$s)"), d.c_str(),
- sizeString().c_str());
- }
+ txt = Volume::createText(doing);
}
- }
- return txt;
}
+ return txt;
+}
+
-string Partition::formatText( bool doing ) const
+Text Partition::formatText( bool doing ) const
{
- string txt;
+ Text txt;
string d = dev;
if( doing )
{
@@ -566,9 +490,9 @@
return( txt );
}
-string Partition::resizeText( bool doing ) const
+Text Partition::resizeText( bool doing ) const
{
- string txt;
+ Text txt;
string d = dev;
if( doing )
{
@@ -580,8 +504,9 @@
// displayed text during action, %1$s is replaced by device name e.g. /dev/hda1
// %2$s is replaced by size (e.g. 623.5 MB)
txt = sformat( _("Extending partition %1$s to %2$s"), d.c_str(), sizeString().c_str() );
+ txt += Text(" ", " ");
// text displayed during action
- txt += string(" ") + _("(progress bar might not move)");
+ txt += _("(progress bar might not move)");
}
else
{
@@ -611,7 +536,9 @@
return( txt );
}
-void Partition::getCommitActions( list<commitAction*>& l ) const
+
+void
+Partition::getCommitActions(list<commitAction>& l) const
{
unsigned s = l.size();
bool change_id = idt!=orig_id;
@@ -620,16 +547,27 @@
change_id = false;
if( change_id )
{
- l.push_back( new commitAction( INCREASE, cont->staticType(),
- setTypeText(false), this, false ));
+ l.push_back(commitAction(INCREASE, cont->type(),
+ setTypeText(false), this, false));
}
}
-Partition::~Partition()
+
+ Region
+ Partition::detectSysfsBlkRegion(bool log_error) const
{
- y2deb("destructed partition " << dev);
+ string start_p = sysfsPath() + "/start";
+ string size_p = sysfsPath() + "/size";
+
+ unsigned long long start = 0;
+ unsigned long long len = 0;
+ read_sysfs_property(start_p, start, log_error);
+ read_sysfs_property(size_p, len, log_error);
+
+ return Region(start, len);
}
+
void
Partition::getInfo( PartitionAddInfo& tinfo ) const
{
@@ -639,26 +577,19 @@
tinfo.nr = num;
tinfo.id = idt;
tinfo.boot = bootflag;
- string tmp = udevPath();
- tinfo.udevPath = tmp.substr( tmp.find_last_of('/')+1 );
- list<string> l = udevId();
- for( list<string>::iterator i=l.begin(); i!=l.end(); ++i )
- i->erase( 0, i->find_last_of('/')+1 );
- tinfo.udevId = mergeString( l );
}
void
Partition::getInfo( PartitionInfo& tinfo ) const
{
- ((Volume*)this)->getInfo( info.v );
+ Volume::getInfo(info.v);
PartitionAddInfo tmp;
getInfo( tmp );
info = tmp;
tinfo = info;
}
-namespace storage
-{
+
PartitionInfo& PartitionInfo::operator=( const PartitionAddInfo& rhs )
{
nr = rhs.nr;
@@ -667,19 +598,16 @@
partitionType = rhs.partitionType;
id = rhs.id;
boot = rhs.boot;
- udevPath = rhs.udevPath;
- udevId = rhs.udevId;
return( *this );
}
std::ostream& operator<< (std::ostream& s, const Partition &p )
{
- s << "Partition " << *(Volume*)&p
- << " Start:" << p.reg.start()
- << " CylNum:" << p.reg.len()
+ s << "Partition " << dynamic_cast<const Volume&>(p)
+ << " cylRegion:" << p.reg
<< " Id:" << std::hex << p.idt << std::dec;
if( p.typ!=storage::PRIMARY )
- s << " " << Partition::pt_names[p.typ];
+ s << " " << toString(p.typ);
if( p.orig_num!=p.num )
s << " OrigNr:" << p.orig_num;
if( p.orig_id!=p.idt )
@@ -689,35 +617,21 @@
return( s );
}
-}
-void Partition::logDifference( const Partition& rhs ) const
+ void
+ Partition::logDifference(std::ostream& log, const Partition& rhs) const
{
- string log = Volume::logDifference( rhs );
- if( reg.start()!=rhs.reg.start() )
- log += " Start:" + decString(reg.start()) + "-->" +
- decString(rhs.reg.start());
- if( reg.len()!=rhs.reg.len() )
- log += " CylNum:" + decString(reg.len()) + "-->" +
- decString(rhs.reg.len());
- if( typ!=rhs.typ )
- log += " Typ:" + pt_names[typ] + "-->" + pt_names[rhs.typ];
- if( idt!=rhs.idt )
- log += " Id:" + hexString(idt) + "-->" + hexString(rhs.idt);
- if( orig_id!=rhs.orig_id )
- log += " OrigId:" + hexString(orig_id) + "-->" + hexString(rhs.orig_id);
- if( orig_num!=rhs.orig_num )
- log += " OrigNr:" + decString(orig_num) + "-->" + decString(rhs.orig_num);
- if( bootflag!=rhs.bootflag )
- {
- if( rhs.bootflag )
- log += " -->boot";
- else
- log += " boot-->";
- }
- y2mil(log);
+ Volume::logDifference(log, rhs);
+
+ logDiff(log, "reg", reg, rhs.reg);
+ logDiffEnum(log, "type", typ, rhs.typ);
+ logDiffHex(log, "id", idt, rhs.idt);
+ logDiffHex(log, "orig_id", orig_id, rhs.orig_id);
+ logDiff(log, "orig_num", orig_num, rhs.orig_num);
+ logDiff(log, "boot", bootflag, rhs.bootflag);
}
+
bool Partition::equalContent( const Partition& rhs ) const
{
return( Volume::equalContent(rhs) &&
@@ -725,24 +639,4 @@
idt==rhs.idt );
}
-Partition& Partition::operator= ( const Partition& rhs )
- {
- y2deb("operator= from " << rhs.nm);
- *((Volume*)this) = rhs;
- reg = rhs.reg;
- bootflag = rhs.bootflag;
- typ = rhs.typ;
- idt = rhs.idt;
- orig_id = rhs.orig_id;
- orig_num = rhs.orig_num;
- return( *this );
- }
-
-Partition::Partition( const Disk& d, const Partition& rhs ) : Volume(d)
- {
- y2deb("constructed partition by copy constructor from " << rhs.dev);
- *this = rhs;
- }
-
-string Partition::pt_names[] = { "primary", "extended", "logical", "any" };
-
+}
Modified: branches/SuSE-Code-11-SP2-Branch/storage/libstorage/src/Partition.h
URL: http://svn.opensuse.org/viewcvs/yast/branches/SuSE-Code-11-SP2-Branch/stora…
==============================================================================
--- branches/SuSE-Code-11-SP2-Branch/storage/libstorage/src/Partition.h (original)
+++ branches/SuSE-Code-11-SP2-Branch/storage/libstorage/src/Partition.h Tue May 17 13:39:44 2011
@@ -1,5 +1,5 @@
/*
- * Copyright (c) [2004-2009] Novell, Inc.
+ * Copyright (c) [2004-2010] Novell, Inc.
*
* All Rights Reserved.
*
@@ -23,9 +23,9 @@
#ifndef PARTITION_H
#define PARTITION_H
-#include "y2storage/StorageInterface.h"
-#include "y2storage/Volume.h"
-#include "y2storage/Region.h"
+#include "storage/StorageInterface.h"
+#include "storage/Volume.h"
+#include "storage/Region.h"
namespace storage
{
@@ -36,47 +36,53 @@
{
public:
- typedef enum { ID_DOS16=0x6, ID_DOS=0x0c, ID_NTFS=0x07,
- ID_EXTENDED=0x0f,
- ID_LINUX=0x83, ID_SWAP=0x82, ID_LVM=0x8e, ID_RAID=0xfd,
- ID_APPLE_OTHER=0x101, ID_APPLE_HFS=0x102,
- ID_GPT_BOOT=0x103, ID_GPT_SERVICE=0x104,
- ID_GPT_MSFTRES=0x105, ID_APPLE_UFS=0x106 } IdNum;
-
- Partition( const Disk& d, unsigned Pnr, unsigned long long SizeK,
- unsigned long Start, unsigned long CSize,
- storage::PartitionType Type,
- unsigned id=ID_LINUX, bool Boot=false );
- Partition( const Disk& d, const string& Data );
- Partition( const Disk& d, const Partition& p );
+ enum IdNum { ID_DOS12=0x01, ID_DOS16=0x06, ID_DOS32=0x0c, ID_NTFS=0x07,
+ ID_EXTENDED=0x0f, ID_LINUX=0x83, ID_SWAP=0x82, ID_LVM=0x8e,
+ ID_RAID=0xfd, ID_APPLE_OTHER=0x101, ID_APPLE_HFS=0x102,
+ ID_GPT_BOOT=0x103, ID_GPT_SERVICE=0x104, ID_GPT_MSFTRES=0x105,
+ ID_APPLE_UFS=0x106 };
+
+ Partition(const Disk& c, const string& name, const string& device, unsigned Pnr,
+ unsigned long long SizeK, const Region& cylRegion, PartitionType Type,
+ unsigned id = ID_LINUX, bool Boot = false);
+ Partition(const Disk& c, const string& name, const string& device, unsigned Pnr,
+ SystemInfo& systeminfo, unsigned long long SizeK, const Region& cylRegion,
+ PartitionType Type, unsigned id = ID_LINUX, bool Boot = false);
+ Partition(const Disk& c, const xmlNode* node);
+ Partition(const Disk& c, const Partition& v);
virtual ~Partition();
+ void saveData(xmlNode* node) const;
+
unsigned long cylStart() const { return reg.start(); }
unsigned long cylSize() const { return reg.len(); }
unsigned long cylEnd() const { return reg.end(); }
- const Region& region() const { return reg; }
- const std::list<string> udevId() const;
- const string& udevPath() const;
- string sysfsPath() const;
+ const Region& cylRegion() const { return reg; }
+
+ virtual string udevPath() const;
+ virtual list<string> udevId() const;
+
+ virtual string procName() const { return nm; }
+ virtual string sysfsPath() const;
+
bool intersectArea( const Region& r, unsigned fuzz=0 ) const;
bool contains( const Region& r, unsigned fuzz=0 ) const;
unsigned OrigNr() const { return( orig_num ); }
bool boot() const { return bootflag; }
unsigned id() const { return idt; }
storage::PartitionType type() const { return typ; }
- std::ostream& logData( std::ostream& file ) const;
- void changeRegion( unsigned long Start, unsigned long CSize,
- unsigned long long SizeK );
+
+ void changeRegion(const Region& cylRegion, unsigned long long SizeK);
void changeNumber( unsigned new_num );
int changeId(unsigned id);
void changeIdDone();
void unChangeId();
- string removeText( bool doing=true ) const;
- string createText( bool doing=true ) const;
- string formatText(bool doing=true) const;
- string resizeText(bool doing=true) const;
- void getCommitActions( std::list<storage::commitAction*>& l ) const;
- string setTypeText( bool doing=true ) const;
+ Text removeText(bool doing) const;
+ Text createText(bool doing) const;
+ Text formatText(bool doing) const;
+ Text resizeText(bool doing) const;
+ void getCommitActions(list<commitAction>& l) const;
+ Text setTypeText(bool doing) const;
int setFormat( bool format=true, storage::FsType fs=storage::REISERFS );
int changeMount( const string& val );
const Disk* disk() const;
@@ -89,10 +95,16 @@
void forgetResize();
bool canUseDevice() const;
+ /* partition region from sysfs in 512 byte blocks */
+ Region detectSysfsBlkRegion(bool log_error = true) const;
+
void getInfo( storage::PartitionInfo& info ) const;
void getInfo( storage::PartitionAddInfo& info ) const;
+
bool equalContent( const Partition& rhs ) const;
- void logDifference( const Partition& d ) const;
+
+ void logDifference(std::ostream& log, const Partition& rhs) const;
+
void addUdevData();
int zeroIfNeeded() const;
@@ -109,20 +121,24 @@
{ return( !(*this<=rhs) ); }
protected:
- Partition& operator=( const Partition& );
Region reg;
bool bootflag;
storage::PartitionType typ;
unsigned idt;
unsigned orig_id;
- string parted_start;
unsigned orig_num;
void addAltUdevId( unsigned num );
void addAltUdevPath( unsigned num );
- static string pt_names[storage::PTYPE_ANY+1];
- mutable storage::PartitionInfo info;
+
+ mutable storage::PartitionInfo info; // workaround for broken ycp bindings
+
+ private:
+
+ Partition(const Partition&); // disallow
+ Partition& operator=(const Partition&); // disallow
+
};
}
Modified: branches/SuSE-Code-11-SP2-Branch/storage/libstorage/src/PeContainer.cc
URL: http://svn.opensuse.org/viewcvs/yast/branches/SuSE-Code-11-SP2-Branch/stora…
==============================================================================
--- branches/SuSE-Code-11-SP2-Branch/storage/libstorage/src/PeContainer.cc (original)
+++ branches/SuSE-Code-11-SP2-Branch/storage/libstorage/src/PeContainer.cc Tue May 17 13:39:44 2011
@@ -19,34 +19,105 @@
* find current contact information at www.novell.com.
*/
-/*
- Textdomain "storage"
-*/
-#include <iostream>
+#include <ostream>
#include <sstream>
#include <utility>
-#include "y2storage/PeContainer.h"
-#include "y2storage/AppUtil.h"
-#include "y2storage/Storage.h"
+#include "storage/PeContainer.h"
+#include "storage/AppUtil.h"
+#include "storage/Storage.h"
+#include "storage/SystemCmd.h"
+#include "storage/StorageDefines.h"
+#include "storage/Regex.h"
-using namespace std;
-using namespace storage;
-PeContainer::PeContainer( Storage * const s, CType t ) :
- Container(s,"",t)
+namespace storage
+{
+ using namespace std;
+
+
+ PeContainer::PeContainer(Storage* s, const string& name, const string& device, CType t)
+ : Container(s, name, device, t), pe_size(1), num_pe(0), free_pe(0)
{
- y2deb("constructing pe container type " << t);
- init();
+ y2deb("constructing PeContainer name:" << name << " ctype:" << toString(t));
}
-PeContainer::~PeContainer()
+
+ PeContainer::PeContainer(Storage* s, const string& name, const string& device, CType t,
+ SystemInfo& systeminfo)
+ : Container(s, name, device, t, systeminfo), pe_size(1), num_pe(0), free_pe(0)
{
- y2deb("destructed pe container " << dev);
+ y2deb("constructing PeContainer name:" << name << " ctype:" << toString(t));
}
-void PeContainer::unuseDev()
+
+ PeContainer::PeContainer(Storage* s, CType t, const xmlNode* node)
+ : Container(s, t, node), pe_size(1), num_pe(0), free_pe(0)
+ {
+ getChildValue(node, "pe_size_k", pe_size);
+ getChildValue(node, "pe_count", num_pe);
+ getChildValue(node, "pe_free", free_pe);
+
+ const list<const xmlNode*> l = getChildNodes(node, "physical_extent");
+ for (list<const xmlNode*>::const_iterator it = l.begin(); it != l.end(); ++it)
+ {
+ Pv tmp = Pv(*it);
+ pv.push_back(tmp);
+
+ switch (t)
+ {
+ case LVM:
+ s->addUsedBy(tmp.device, UB_LVM, dev);
+ break;
+ case DM:
+ s->addUsedBy(tmp.device, UB_DM, dev);
+ break;
+ case DMRAID:
+ s->addUsedBy(tmp.device, UB_DMRAID, dev);
+ break;
+ case DMMULTIPATH:
+ s->addUsedBy(tmp.device, UB_DMMULTIPATH, dev);
+ break;
+ default:
+ break;
+ }
+ }
+
+ y2deb("constructed PeContainer " << dev);
+ }
+
+
+ PeContainer::PeContainer(const PeContainer& c)
+ : Container(c), pe_size(c.pe_size), num_pe(c.num_pe),
+ free_pe(c.free_pe), pv(c.pv), pv_add(c.pv_add),
+ pv_remove(c.pv_remove)
+ {
+ y2deb("copy-constructed PeContainer " << dev);
+ }
+
+
+ PeContainer::~PeContainer()
+ {
+ y2deb("destructed PeContainer " << dev);
+ }
+
+
+ void
+ PeContainer::saveData(xmlNode* node) const
+ {
+ Container::saveData(node);
+
+ setChildValue(node, "pe_size_k", peSize());
+ setChildValue(node, "pe_count", peCount());
+ setChildValue(node, "pe_free", peFree());
+
+ for (list<Pv>::const_iterator it = pv.begin(); it != pv.end(); ++it)
+ it->saveData(xmlNewChild(node, "physical_extent"));
+ }
+
+
+void PeContainer::unuseDev() const
{
for( list<Pv>::const_iterator s=pv.begin(); s!=pv.end(); ++s )
getStorage()->clearUsedBy(s->device);
@@ -58,7 +129,7 @@
PeContainer::setPeSize( unsigned long long peSizeK, bool lvm1 )
{
int ret = 0;
- y2milestone( "peSize:%llu", peSizeK );
+ y2mil("peSize:" << peSizeK);
if( pe_size!=peSizeK )
{
@@ -97,6 +168,7 @@
}
pe_size = peSizeK;
}
+ calcSize();
}
y2mil("ret:" << ret);
return( ret );
@@ -183,8 +255,7 @@
if( !added_pv )
plrem.push_back( cur_pv );
}
- y2milestone( "ret:%d removed_pe:%lu dev:%s", ret, removed_pe,
- cur_pv.device.c_str() );
+ y2mil("ret:" << ret << " removed_pe:" << removed_pe << " dev:" << cur_pv.device);
return( ret );
}
@@ -193,7 +264,7 @@
list<Pv>& pladd, map<string,unsigned long>& pe_map )
{
int ret=0;
- y2milestone( "le:%lu stripe:%u", le, stripe );
+ y2mil("le:" << le << " stripe:" << stripe);
map<string,unsigned long>::iterator mit;
list<Pv>::iterator i;
if( stripe>1 )
@@ -357,9 +428,9 @@
list< tpair > li;
DmPair lp=dmPair();
DmIter i=lp.begin();
- if( pv_add.size()>0 )
+ if (!pv_add.empty())
y2war( "should not happen pv_add:" << pv_add );
- if( pv_remove.size()>0 )
+ if (!pv_remove.empty())
y2war( "should not happen pv_rem:" << pv_remove );
while( i!=lp.end() )
{
@@ -424,14 +495,15 @@
return( ret );
}
-bool PeContainer::findPe( const string& dev, const std::list<Pv>& pl,
- std::list<Pv>::const_iterator& i ) const
+
+bool
+PeContainer::findPe(const string& dev, const list<Pv>& pl, list<Pv>::const_iterator& i) const
{
bool ret = !pl.empty();
if( ret )
{
- const Volume *vol;
- if( getStorage()->findVolume( dev, vol ))
+ const Device *vol;
+ if( getStorage()->findDevice( dev, vol, true ) )
{
i = pl.begin();
while( i!=pl.end() && !vol->sameDevice( i->device ))
@@ -448,14 +520,15 @@
return( ret );
}
-bool PeContainer::findPe( const string& dev, std::list<Pv>& pl,
- std::list<Pv>::iterator& i )
+
+bool
+PeContainer::findPe(const string& dev, list<Pv>& pl, list<Pv>::iterator& i) const
{
bool ret = !pl.empty();
if( ret )
{
- const Volume *vol;
- if( getStorage()->findVolume( dev, vol ))
+ const Device *vol;
+ if( getStorage()->findDevice( dev, vol, true ) )
{
i = pl.begin();
while( i!=pl.end() && !vol->sameDevice( i->device ))
@@ -472,20 +545,24 @@
return( ret );
}
-void PeContainer::addPv( const Pv* p )
+
+ void
+ PeContainer::addPv(const Pv& p)
{
- getStorage()->eraseLabelVolume( p->device );
- list<Pv>::iterator i;
- if( findPe( p->device, pv, i ))
- *i = *p;
- else if( !findPe( p->device, pv_remove, i ))
- {
- if( findPe( p->device, pv_add, i ))
- pv_add.erase(i);
- pv.push_back( *p );
+ getStorage()->eraseLabelVolume(p.device);
+
+ list<Pv>::iterator i;
+ if (findPe(p.device, pv, i))
+ *i = p;
+ else if (!findPe(p.device, pv_remove, i))
+ {
+ if (findPe(p.device, pv_add, i))
+ pv_add.erase(i);
+ pv.push_back(p);
}
}
+
string PeContainer::addList() const
{
string ret;
@@ -500,25 +577,15 @@
return( ret );
}
-void
-PeContainer::init()
- {
- y2mil( "init:" << nm );
- mjr = Dm::dmMajor();
- num_pe = free_pe = 0;
- pe_size = 1;
- }
-
-static bool isDeleted( const Dm& l ) { return( l.deleted() ); }
unsigned long
PeContainer::leByLvRemove() const
{
unsigned long ret=0;
- ConstDmPair p=dmPair(isDeleted);
+ ConstDmPair p = dmPair(Dm::isDeleted);
for( ConstDmIter i=p.begin(); i!=p.end(); ++i )
ret += i->getLe();
- y2milestone( "ret:%lu", ret );
+ y2mil("ret:" << ret);
return( ret );
}
@@ -553,23 +620,20 @@
{
if( mit->second != p->num_pe-p->free_pe )
{
- y2warning( "Vg:%s used pv %s is %lu should be %lu",
- name().c_str(), mit->first.c_str(),
- mit->second, p->num_pe-p->free_pe );
+ y2war("Vg:" << name() << " used pv " << mit->first << " is " <<
+ mit->second << " should be " << p->num_pe - p->free_pe);
ret = false;
}
}
else
{
- y2warning( "Vg:%s pv %s not found", name().c_str(),
- mit->first.c_str() );
+ y2war("Vg:" << name() << " pv " << mit->first << " not found");
ret = false;
}
}
if( sum != num_pe-free_pe )
{
- y2warning( "Vg:%s used PE is %lu should be %lu", name().c_str(),
- sum, num_pe-free_pe );
+ y2war("Vg:" << name() << " used PE is " << sum << " should be " << num_pe - free_pe);
ret = false;
}
return( ret );
@@ -587,8 +651,31 @@
}
}
-namespace storage
-{
+string PeContainer::getDeviceByNumber( const string& majmin ) const
+ {
+ string ret = getStorage()->deviceByNumber(majmin);
+ if( ret.empty() )
+ {
+ unsigned mj = 0;
+ unsigned mi = 0;
+ string pair( majmin );
+ SystemCmd c;
+ mj = mi = 0;
+ string::size_type pos = pair.find( ':' );
+ if( pos != string::npos )
+ pair[pos] = ' ';
+ istringstream i( pair );
+ classic(i);
+ i >> mj >> mi;
+ list<string> ls = splitString(pair);
+ if( majorNr()>0 && mj==majorNr() && mi==minorNr())
+ ret = device();
+ if( mj==Loop::loopMajor() )
+ ret = Loop::loopDeviceName(mi);
+ }
+ y2mil( "majmin " << majmin << " ret:" << ret );
+ return( ret );
+ }
void printDevList( std::ostream& s, const std::list<PeContainer::Pv>& l )
{
@@ -605,8 +692,8 @@
std::ostream& operator<< (std::ostream& s, const PeContainer& d )
{
- s << *((Container*)&d);
- s << " SizeM:" << d.sizeK()/1024
+ s << dynamic_cast<const Container&>(d);
+ s << " SizeK:" << d.sizeK()
<< " PeSize:" << d.pe_size
<< " NumPE:" << d.num_pe
<< " FreePE:" << d.free_pe;
@@ -641,80 +728,45 @@
return s;
}
-}
-string PeContainer::getDiffString( const Container& rhs ) const
+ void
+ PeContainer::logDifference(std::ostream& log, const PeContainer& rhs) const
{
- string ret = Container::getDiffString( rhs );
- const PeContainer* p = dynamic_cast<const PeContainer*>(&rhs);
- if( p )
- {
- if( pe_size!=p->pe_size )
- ret += " PeSize:" + decString(pe_size) + "-->" + decString(p->pe_size);
- if( num_pe!=p->num_pe )
- ret += " PE:" + decString(num_pe) + "-->" + decString(p->num_pe);
- if( free_pe!=p->free_pe )
- ret += " Free:" + decString(free_pe) + "-->" + decString(p->free_pe);
+ Container::logDifference(log, rhs);
+
+ logDiff(log, "pe_size", pe_size, rhs.pe_size);
+ logDiff(log, "num_pe", num_pe, rhs.num_pe);
+ logDiff(log, "free_pe", free_pe, rhs.free_pe);
+
string tmp;
- list<Pv>::const_iterator i = pv.begin();
- list<Pv>::const_iterator j;
- while( i!=pv.end() )
- {
- j = find( p->pv.begin(), p->pv.end(), *i );
- if( j==p->pv.end() )
+ for (list<Pv>::const_iterator i = pv.begin(); i != pv.end(); ++i)
+ if (!contains(rhs.pv, *i))
tmp += i->device + "-->";
- ++i;
- }
- i = p->pv.begin();
- while( i!=p->pv.end() )
- {
- j = find( pv.begin(), pv.end(), *i );
- if( j==pv.end() )
+ for (list<Pv>::const_iterator i = rhs.pv.begin(); i != rhs.pv.end(); ++i)
+ if (!contains(pv, *i))
tmp += "<--" + i->device;
- ++i;
- }
- if( !tmp.empty() )
- ret += " Pv:" + tmp;
+ if (!tmp.empty())
+ log << " Pv:" << tmp;
+
tmp.erase();
- i = pv_add.begin();
- while( i!=pv_add.end() )
- {
- j = find( p->pv_add.begin(), p->pv_add.end(), *i );
- if( j==p->pv_add.end() )
+ for (list<Pv>::const_iterator i = pv_add.begin(); i != pv_add.end(); ++i)
+ if (!contains(rhs.pv_add, *i))
tmp += i->device + "-->";
- ++i;
- }
- i = p->pv_add.begin();
- while( i!=p->pv_add.end() )
- {
- j = find( pv_add.begin(), pv_add.end(), *i );
- if( j==pv_add.end() )
+ for (list<Pv>::const_iterator i = rhs.pv_add.begin(); i != rhs.pv_add.end(); ++i)
+ if (!contains(pv_add, *i))
tmp += "<--" + i->device;
- ++i;
- }
- if( !tmp.empty() )
- ret += " PvAdd:" + tmp;
+ if (!tmp.empty())
+ log << " PvAdd:" << tmp;
+
tmp.erase();
- i = pv_remove.begin();
- while( i!=pv_remove.end() )
- {
- j = find( p->pv_remove.begin(), p->pv_remove.end(), *i );
- if( j==p->pv_remove.end() )
+ for (list<Pv>::const_iterator i = pv_remove.begin(); i != pv_remove.end(); ++i)
+ if (!contains(rhs.pv_remove, *i))
tmp += i->device + "-->";
- ++i;
- }
- i = p->pv_remove.begin();
- while( i!=p->pv_remove.end() )
- {
- j = find( pv_remove.begin(), pv_remove.end(), *i );
- if( j==pv_remove.end() )
+ for (list<Pv>::const_iterator i = rhs.pv_remove.begin(); i != rhs.pv_remove.end(); ++i)
+ if (!contains(pv_remove, *i))
tmp += "<--" + i->device;
- ++i;
- }
- if( !tmp.empty() )
- ret += " PvRemove:" + tmp;
- }
- return( ret );
+ if (!tmp.empty())
+ log << " PvRemove:" << tmp;
}
@@ -726,56 +778,42 @@
pv_remove==rhs.pv_remove;
if( ret )
{
- list<Pv>::const_iterator i = rhs.pv.begin();
- list<Pv>::const_iterator j = pv.begin();
- while( ret && i!=rhs.pv.end() )
- {
- ret = ret && i->equalContent(*j);
- ++i;
- ++j;
- }
- i = rhs.pv_add.begin();
- j = pv_add.begin();
- while( ret && i!=rhs.pv_add.end() )
- {
- ret = ret && i->equalContent(*j);
- ++i;
- ++j;
- }
- i = rhs.pv_remove.begin();
- j = pv_remove.begin();
- while( ret && i!=rhs.pv_remove.end() )
- {
- ret = ret && i->equalContent(*j);
- ++i;
- ++j;
- }
+ ret = ret && storage::equalContent(pv.begin(), pv.end(),
+ rhs.pv.begin(), rhs.pv.end());
+ ret = ret && storage::equalContent(pv_add.begin(), pv_add.end(),
+ rhs.pv_add.begin(), rhs.pv_add.end());
+ ret = ret && storage::equalContent(pv_remove.begin(), pv_remove.end(),
+ rhs.pv_remove.begin(), rhs.pv_remove.end());
}
if( ret && comp_vol )
{
- CVIter i = rhs.begin();
- CVIter j = begin();
- while( ret && i!=rhs.end() && j!=end() )
- ret = ret && ((Dm*)(&(*j)))->equalContent( *(Dm*)(&(*i)));
- ret = ret && i==rhs.end() && j==end();
- }
+ ConstDmPair pp = dmPair();
+ ConstDmPair pc = rhs.dmPair();
+ ret = ret && storage::equalContent(pp.begin(), pp.end(), pc.begin(), pc.end());
+ }
return( ret );
}
-PeContainer& PeContainer::operator=( const PeContainer& rhs )
+
+ PeContainer::Pv::Pv(const xmlNode* node)
+ : device(), num_pe(0), free_pe(0)
{
- pe_size = rhs.pe_size;
- num_pe = rhs.num_pe;
- free_pe = rhs.free_pe;
- pv = rhs.pv;
- pv_add = rhs.pv_add;
- pv_remove = rhs.pv_remove;
- return( *this );
+ getChildValue(node, "device", device);
+ getChildValue(node, "pe_count", num_pe);
+ getChildValue(node, "pe_free", free_pe);
+
+ y2deb("constructed Pv");
+
+ assert(!device.empty());
}
-PeContainer::PeContainer( const PeContainer& rhs ) : Container(rhs)
+
+ void
+ PeContainer::Pv::saveData(xmlNode* node) const
{
- y2deb("constructed PeContainer by copy constructor from " << rhs.nm);
- *this = rhs;
+ setChildValue(node, "device", device);
+ setChildValue(node, "pe_count", num_pe);
+ setChildValue(node, "pe_free", free_pe);
}
+}
Modified: branches/SuSE-Code-11-SP2-Branch/storage/libstorage/src/PeContainer.h
URL: http://svn.opensuse.org/viewcvs/yast/branches/SuSE-Code-11-SP2-Branch/stora…
==============================================================================
--- branches/SuSE-Code-11-SP2-Branch/storage/libstorage/src/PeContainer.h (original)
+++ branches/SuSE-Code-11-SP2-Branch/storage/libstorage/src/PeContainer.h Tue May 17 13:39:44 2011
@@ -23,8 +23,8 @@
#ifndef PE_CONTAINER_H
#define PE_CONTAINER_H
-#include "y2storage/Container.h"
-#include "y2storage/Dm.h"
+#include "storage/Container.h"
+#include "storage/Dm.h"
namespace storage
{
@@ -34,13 +34,17 @@
friend class Storage;
public:
- PeContainer( Storage * const s, storage::CType t );
- PeContainer( const PeContainer& c );
- PeContainer& operator= ( const PeContainer& rhs );
+
+ PeContainer(Storage* s, const string& name, const string& device, CType t);
+ PeContainer(Storage* s, const string& name, const string& device, CType t,
+ SystemInfo& systeminfo);
+ PeContainer(Storage* s, CType t, const xmlNode* node);
+ PeContainer(const PeContainer& c);
virtual ~PeContainer();
+ void saveData(xmlNode* node) const;
+
unsigned long long peSize() const { return pe_size; }
- unsigned long long sizeK() const { return pe_size*num_pe; }
unsigned long peCount() const { return num_pe; }
unsigned long peFree() const { return free_pe; }
unsigned numPv() const { return pv.size(); }
@@ -49,15 +53,23 @@
unsigned long sizeToLe( unsigned long long sizeK ) const;
int setPeSize( long long unsigned, bool lvm1 );
- void unuseDev();
+ void calcSize() { size_k = pe_size * num_pe; }
+ void unuseDev() const;
void changeDeviceName( const string& old, const string& nw );
+
bool equalContent( const PeContainer& rhs, bool comp_vol=true ) const;
- virtual string getDiffString( const Container& d ) const;
-
+
+ void logDifference(std::ostream& log, const PeContainer& rhs) const;
+
+ string getDeviceByNumber( const string& majmin ) const;
+
protected:
struct Pv
{
Pv() : num_pe(0), free_pe(0) {}
+ Pv(const xmlNode* node);
+
+ void saveData(xmlNode* node) const;
string device;
string dmcryptDevice;
@@ -135,14 +147,11 @@
friend std::ostream& operator<< (std::ostream&, const Pv& );
friend void printDevList (std::ostream&, const std::list<Pv>& );
- void init();
string addList() const;
virtual void print( std::ostream& s ) const { s << *this; }
- virtual Container* getCopy() const { return( new PeContainer( *this ) ); }
- bool findPe( const string& dev, const std::list<Pv>& pl,
- std::list<Pv>::const_iterator& i ) const;
- bool findPe( const string& dev, std::list<Pv>& pl,
- std::list<Pv>::iterator& i );
+ virtual Container* getCopy() const = 0; // { return( new PeContainer( *this ) ); }
+ bool findPe(const string& dev, const list<Pv>& pl, list<Pv>::const_iterator& i) const;
+ bool findPe(const string& dev, list<Pv>& pl, list<Pv>::iterator& i) const;
unsigned long leByLvRemove() const;
int tryUnusePe( const string& dev, std::list<Pv>& pl, std::list<Pv>& pladd,
std::list<Pv>& plrem, unsigned long& removed_pe );
@@ -154,7 +163,7 @@
std::list<Pv>& pl, std::list<Pv>& pladd );
virtual bool checkConsistency() const;
- void addPv( const Pv* p );
+ void addPv(const Pv& p);
unsigned long long pe_size;
unsigned long num_pe;
@@ -162,6 +171,11 @@
std::list<Pv> pv;
std::list<Pv> pv_add;
std::list<Pv> pv_remove;
+
+ private:
+
+ PeContainer& operator=(const PeContainer&); // disallow
+
};
}
Added: branches/SuSE-Code-11-SP2-Branch/storage/libstorage/src/ProcMdstat.cc
URL: http://svn.opensuse.org/viewcvs/yast/branches/SuSE-Code-11-SP2-Branch/stora…
==============================================================================
--- branches/SuSE-Code-11-SP2-Branch/storage/libstorage/src/ProcMdstat.cc (added)
+++ branches/SuSE-Code-11-SP2-Branch/storage/libstorage/src/ProcMdstat.cc Tue May 17 13:39:44 2011
@@ -0,0 +1,344 @@
+/*
+ * Copyright (c) [2004-2010] Novell, Inc.
+ *
+ * All Rights Reserved.
+ *
+ * This program is free software; you can redistribute it and/or modify it
+ * under the terms of version 2 of the GNU General Public License as published
+ * by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
+ * more details.
+ *
+ * You should have received a copy of the GNU General Public License along
+ * with this program; if not, contact Novell, Inc.
+ *
+ * To contact Novell about this file by physical or electronic mail, you may
+ * find current contact information at www.novell.com.
+ */
+
+
+#include <locale>
+#include <boost/algorithm/string.hpp>
+
+#include "storage/AppUtil.h"
+#include "storage/AsciiFile.h"
+#include "storage/StorageInterface.h"
+#include "storage/ProcMdstat.h"
+#include "storage/Enum.h"
+#include "storage/StorageDefines.h"
+#include "storage/SystemCmd.h"
+#include "storage/StorageTmpl.h"
+
+
+namespace storage
+{
+ using namespace std;
+
+
+ ProcMdstat::ProcMdstat()
+ {
+ AsciiFile mdstat("/proc/mdstat");
+ mdstat.logContent();
+
+ for (vector<string>::const_iterator it1 = mdstat.lines().begin(); it1 != mdstat.lines().end(); ++it1)
+ {
+ if (extractNthWord(1, *it1) == ":")
+ {
+ string name = extractNthWord(0, *it1);
+ if (boost::starts_with(name, "md"))
+ data[name] = parse(*it1, *(it1 + 1));
+ }
+ }
+
+ for (const_iterator it = data.begin(); it != data.end(); ++it)
+ y2mil("data[" << it->first << "] -> " << it->second);
+ }
+
+
+ ProcMdstat::Entry
+ ProcMdstat::parse(const string& line1, const string& line2)
+ {
+ ProcMdstat::Entry entry;
+
+ string::size_type pos;
+ string tmp;
+
+ string line = line1;
+ if( (pos=line.find( ':' ))!=string::npos )
+ line.erase( 0, pos+1 );
+ boost::trim_left(line, locale::classic());
+ if( (pos=line.find_first_of( app_ws ))!=string::npos )
+ {
+ if (line.substr(0, pos) == "active")
+ line.erase(0, pos);
+ }
+ boost::trim_left(line, locale::classic());
+ if( (pos=line.find_first_of( app_ws ))!=string::npos )
+ {
+ tmp = line.substr( 0, pos );
+ if( tmp=="(read-only)" || tmp=="(auto-read-only)" || tmp=="inactive" )
+ {
+ entry.readonly = true;
+ line.erase( 0, pos );
+ boost::trim_left(line, locale::classic());
+ }
+ }
+ boost::trim_left(line, locale::classic());
+ if( (pos=line.find_first_of( app_ws ))!=string::npos )
+ {
+ if( line.substr( 0, pos ).find( "active" )!=string::npos )
+ line.erase( 0, pos );
+ }
+ boost::trim_left(line, locale::classic());
+
+ tmp = extractNthWord( 0, line );
+ if (boost::starts_with(tmp, "raid"))
+ {
+ entry.md_type = toValueWithFallback(tmp, RAID_UNK);
+ if (entry.md_type == RAID_UNK)
+ y2war("unknown raid type " << tmp);
+
+ if( (pos=line.find_first_of( app_ws ))!=string::npos )
+ line.erase( 0, pos );
+ if( (pos=line.find_first_not_of( app_ws ))!=string::npos && pos!=0 )
+ line.erase( 0, pos );
+ }
+ else
+ {
+ entry.is_container = true;
+ }
+
+ while( (pos=line.find_first_not_of( app_ws ))==0 )
+ {
+ tmp = extractNthWord( 0, line );
+
+ string d;
+ string::size_type bracket = tmp.find( '[' );
+ if( bracket!=string::npos )
+ d = normalizeDevice(tmp.substr(0, bracket));
+ else
+ d = normalizeDevice(tmp);
+
+ bool is_spare = boost::ends_with(tmp, "(S)");
+ if (!is_spare)
+ entry.devices.push_back(d);
+ else
+ entry.spares.push_back(d);
+
+ line.erase( 0, tmp.length() );
+ if( (pos=line.find_first_not_of( app_ws ))!=string::npos && pos!=0 )
+ line.erase( 0, pos );
+ }
+
+ extractNthWord(0, line2) >> entry.size_k;
+
+ pos = line2.find( "chunk" );
+ if( pos != string::npos )
+ {
+ pos = line2.find_last_not_of( app_ws, pos-1 );
+ pos = line2.find_last_of( app_ws, pos );
+ line2.substr( pos+1 ) >> entry.chunk_k;
+ }
+
+ pos = line2.find("super");
+ if (pos != string::npos)
+ {
+ string::size_type pos1 = line2.find_first_of(app_ws, pos);
+ pos1 = line2.find_first_not_of(app_ws, pos1);
+ string::size_type pos2 = line2.find_first_of(app_ws, pos1);
+ entry.super = string(line2, pos1, pos2 - pos1);
+
+ if (!entry.is_container && boost::starts_with(entry.super, "external:"))
+ {
+ string::size_type pos1 = entry.super.find_first_of("/");
+ string::size_type pos2 = entry.super.find_last_of("/");
+
+ if (pos1 != string::npos && pos2 != string::npos && pos1 != pos2)
+ {
+ entry.has_container = true;
+ entry.container_name = string(entry.super, pos1 + 1, pos2 - pos1 - 1);
+ entry.container_member = string(entry.super, pos2 + 1);
+ }
+ }
+ }
+
+ entry.md_parity = PAR_DEFAULT;
+ pos = line2.find( "algorithm" );
+ if( pos != string::npos )
+ {
+ unsigned alg = 999;
+ pos = line2.find_first_of( app_ws, pos );
+ pos = line2.find_first_not_of( app_ws, pos );
+ line2.substr( pos ) >> alg;
+ switch( alg )
+ {
+ case 0:
+ entry.md_parity = LEFT_ASYMMETRIC;
+ break;
+ case 1:
+ entry.md_parity = RIGHT_ASYMMETRIC;
+ break;
+ case 2:
+ entry.md_parity = LEFT_SYMMETRIC;
+ break;
+ case 3:
+ entry.md_parity = RIGHT_SYMMETRIC;
+ break;
+ case 4:
+ entry.md_parity = PAR_FIRST;
+ break;
+ case 5:
+ entry.md_parity = PAR_LAST;
+ break;
+ case 16:
+ entry.md_parity = LEFT_ASYMMETRIC_6;
+ break;
+ case 17:
+ entry.md_parity = RIGHT_ASYMMETRIC_6;
+ break;
+ case 18:
+ entry.md_parity = LEFT_SYMMETRIC_6;
+ break;
+ case 19:
+ entry.md_parity = RIGHT_SYMMETRIC_6;
+ break;
+ case 20:
+ entry.md_parity = PAR_FIRST_6;
+ break;
+ default:
+ y2war("unknown parity " << line2.substr(pos));
+ break;
+ }
+ }
+ pos = line2.find( "-copies" );
+ if( pos != string::npos )
+ {
+ unsigned num = 0;
+ string where;
+ pos = line2.find_last_of( app_ws, pos );
+ line2.substr( pos ) >> where;
+ pos = line2.find_last_not_of( app_ws, pos );
+ pos = line2.find_last_of( app_ws, pos );
+ line2.substr( pos ) >> num;
+ y2mil( "where:" << where << " num:" << num );
+ if( where=="near-copies" )
+ entry.md_parity = (num==3)?PAR_NEAR_3:PAR_NEAR_2;
+ else if( where=="far-copies" )
+ entry.md_parity = (num==3)?PAR_FAR_3:PAR_FAR_2;
+ else if( where=="offset-copies" )
+ entry.md_parity = (num==3)?PAR_OFFSET_3:PAR_OFFSET_2;
+ }
+
+ return entry;
+ }
+
+
+ list<string>
+ ProcMdstat::getEntries() const
+ {
+ list<string> ret;
+ for (const_iterator i = data.begin(); i != data.end(); ++i)
+ ret.push_back(i->first);
+ return ret;
+ }
+
+
+ bool
+ ProcMdstat::getEntry(const string& name, Entry& entry) const
+ {
+ const_iterator i = data.find(name);
+ if (i == data.end())
+ return false;
+
+ entry = i->second;
+ return true;
+ }
+
+
+ std::ostream& operator<<(std::ostream& s, const ProcMdstat::Entry& entry)
+ {
+ s << "md_type:" << toString(entry.md_type);
+
+ if (entry.md_parity != PAR_DEFAULT)
+ s << " md_parity:" + toString(entry.md_parity);
+
+ if (!entry.super.empty())
+ s << " super:" + entry.super;
+
+ if (entry.chunk_k != 0)
+ s << " chunk_k:" << entry.chunk_k;
+
+ s << " size_k:" << entry.size_k;
+
+ if (entry.readonly)
+ s << " readonly";
+
+ s << " devices:" << entry.devices;
+ if (!entry.spares.empty())
+ s << " spares:" << entry.spares;
+
+ if (entry.is_container)
+ s << " is_container";
+
+ if (entry.has_container)
+ s << " has_container container_name:" << entry.container_name << " container_member:"
+ << entry.container_member;
+
+ return s;
+ }
+
+
+ bool
+ getMdadmDetails(const string& dev, MdadmDetails& detail)
+ {
+ SystemCmd cmd(MDADMBIN " --detail " + quote(dev) + " --export");
+ if (cmd.retcode() != 0)
+ {
+ y2err("running mdadm failed");
+ return false;
+ }
+
+ detail.uuid = detail.devname = detail.metadata = "";
+
+ const vector<string>& lines = cmd.stdout();
+ for (vector<string>::const_iterator it = lines.begin(); it != lines.end(); ++it)
+ {
+ if (boost::starts_with(*it, "MD_UUID="))
+ detail.uuid = string(*it, 8);
+ else if (boost::starts_with(*it, "MD_DEVNAME="))
+ detail.devname = string(*it, 11);
+ else if (boost::starts_with(*it, "MD_METADATA="))
+ detail.metadata = string(*it, 12);
+ }
+
+ y2mil("dev:" << dev << " uuid:" << detail.uuid << " devname:" << detail.devname <<
+ " metadata:" << detail.metadata);
+ return true;
+ }
+
+
+ bool
+ isImsmPlatform()
+ {
+ bool ret = false;
+
+ SystemCmd cmd(MDADMBIN " --detail-platform");
+
+ cmd.select("Platform : ");
+ if (cmd.numLines(true) > 0)
+ {
+ string line = cmd.getLine(0, true);
+ if (boost::contains(line, "Intel(R) Matrix Storage Manager"))
+ {
+ ret = true;
+ }
+ }
+
+ y2mil("ret:" << ret);
+ return ret;
+ }
+
+}
Added: branches/SuSE-Code-11-SP2-Branch/storage/libstorage/src/ProcMdstat.h
URL: http://svn.opensuse.org/viewcvs/yast/branches/SuSE-Code-11-SP2-Branch/stora…
==============================================================================
--- branches/SuSE-Code-11-SP2-Branch/storage/libstorage/src/ProcMdstat.h (added)
+++ branches/SuSE-Code-11-SP2-Branch/storage/libstorage/src/ProcMdstat.h Tue May 17 13:39:44 2011
@@ -0,0 +1,96 @@
+/*
+ * Copyright (c) [2004-2010] Novell, Inc.
+ *
+ * All Rights Reserved.
+ *
+ * This program is free software; you can redistribute it and/or modify it
+ * under the terms of version 2 of the GNU General Public License as published
+ * by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
+ * more details.
+ *
+ * You should have received a copy of the GNU General Public License along
+ * with this program; if not, contact Novell, Inc.
+ *
+ * To contact Novell about this file by physical or electronic mail, you may
+ * find current contact information at www.novell.com.
+ */
+
+
+#ifndef PROC_MDSTAT_H
+#define PROC_MDSTAT_H
+
+
+namespace storage
+{
+
+ class ProcMdstat
+ {
+ public:
+
+ ProcMdstat();
+
+ struct Entry
+ {
+ Entry() : md_type(RAID_UNK), md_parity(PAR_DEFAULT), size_k(0), chunk_k(0),
+ readonly(false), is_container(false), has_container(false) {}
+
+ MdType md_type;
+ MdParity md_parity;
+
+ string super;
+
+ unsigned long long size_k;
+ unsigned long chunk_k;
+
+ bool readonly;
+
+ list<string> devices;
+ list<string> spares;
+
+ bool is_container;
+
+ bool has_container;
+ string container_name;
+ string container_member;
+ };
+
+ friend std::ostream& operator<<(std::ostream& s, const Entry& entry);
+
+ list<string> getEntries() const;
+
+ bool getEntry(const string& name, Entry& entry) const;
+
+ typedef map<string, Entry>::const_iterator const_iterator;
+
+ const_iterator begin() const { return data.begin(); }
+ const_iterator end() const { return data.end(); }
+
+ private:
+
+ Entry parse(const string& line1, const string& line2);
+
+ map<string, Entry> data;
+
+ };
+
+
+ struct MdadmDetails
+ {
+ string uuid;
+ string devname;
+ string metadata;
+ };
+
+ bool getMdadmDetails(const string& dev, MdadmDetails& details);
+
+
+ bool isImsmPlatform();
+
+}
+
+
+#endif
Modified: branches/SuSE-Code-11-SP2-Branch/storage/libstorage/src/ProcMounts.cc
URL: http://svn.opensuse.org/viewcvs/yast/branches/SuSE-Code-11-SP2-Branch/stora…
==============================================================================
--- branches/SuSE-Code-11-SP2-Branch/storage/libstorage/src/ProcMounts.cc (original)
+++ branches/SuSE-Code-11-SP2-Branch/storage/libstorage/src/ProcMounts.cc Tue May 17 13:39:44 2011
@@ -1,5 +1,5 @@
/*
- * Copyright (c) [2004-2009] Novell, Inc.
+ * Copyright (c) [2004-2010] Novell, Inc.
*
* All Rights Reserved.
*
@@ -19,75 +19,96 @@
* find current contact information at www.novell.com.
*/
-// Maintainer: fehr(a)suse.de
-/*
- Textdomain "storage"
-*/
-#include <sstream>
+#include "storage/AppUtil.h"
+#include "storage/SystemCmd.h"
+#include "storage/AsciiFile.h"
+#include "storage/ProcMounts.h"
+#include "storage/StorageTmpl.h"
+#include "storage/StorageDefines.h"
+
+
+namespace storage
+{
+ using namespace std;
+
+
+ ProcMounts::ProcMounts()
+ {
+ reload();
+ }
+
+
+ void
+ ProcMounts::reload()
+ {
+ data.clear();
-#include "y2storage/AppUtil.h"
-#include "y2storage/SystemCmd.h"
-#include "y2storage/ProcMounts.h"
-#include "y2storage/StorageTmpl.h"
-#include "y2storage/Storage.h"
-#include "y2storage/StorageDefines.h"
-
-using namespace std;
-using namespace storage;
-
-ProcMounts::ProcMounts( Storage * const sto )
- {
- map<string,string> by_label;
- map<string,string> by_uuid;
- getRevUdevMap("/dev/disk/by-label", by_label);
- getRevUdevMap("/dev/disk/by-uuid", by_uuid);
- ifstream mounts( "/proc/mounts" );
- classic(mounts);
- string line;
- getline( mounts, line );
SystemCmd mt(MOUNTBIN);
- while( mounts.good() )
+
+ AsciiFile mounts("/proc/mounts");
+
+ for (vector<string>::const_iterator it = mounts.lines().begin(); it != mounts.lines().end(); ++it)
+ {
+ string dev = boost::replace_all_copy(extractNthWord(0, *it), "\\040", " ");
+ string dir = boost::replace_all_copy(extractNthWord(1, *it), "\\040", " ");
+
+ if (dev == "rootfs" || dev == "/dev/root" || isBind(mt, dir))
{
- string dev = extractNthWord( 0, line );
- if( dev.find( "/by-label/" ) != string::npos )
- {
- dev = dev.substr( dev.rfind( "/" )+1 );
- y2mil( "dev:" << dev );
- if( !by_label[dev].empty() )
- {
- dev = by_label[dev];
- normalizeDevice( dev );
- y2mil( "dev:" << dev );
- }
- }
- else if( dev.find( "/by-uuid/" ) != string::npos )
- {
- dev = dev.substr( dev.rfind( "/" )+1 );
- y2mil( "dev:" << dev );
- if( !by_uuid[dev].empty() )
- {
- dev = by_uuid[dev];
- normalizeDevice( dev );
- y2mil( "dev:" << dev );
- }
- }
- bool skip = false;
- string dir = extractNthWord( 1, line );
+ y2mil("skipping line:" << *it);
+ }
+ else
+ {
+ FstabEntry entry;
+ entry.device = dev;
+ entry.mount = dir;
+ entry.fs = extractNthWord(2, *it);
+ entry.opts = splitString(extractNthWord(3, *it), ",");
+ data.insert(make_pair(dev, entry));
+ }
+ }
+
+ AsciiFile swaps("/proc/swaps");
+ swaps.remove(0, 1);
+
+ for (vector<string>::const_iterator it = swaps.lines().begin(); it != swaps.lines().end(); ++it)
+ {
+ string dev = boost::replace_all_copy(extractNthWord(0, *it), "\\040", " ");
+ string::size_type pos = dev.find(" (deleted)");
+ if (pos != string::npos)
+ dev.erase(pos);
+
+ FstabEntry entry;
+ entry.device = dev;
+ entry.mount = "swap";
+ entry.fs = "swap";
+ data.insert(make_pair(dev, entry));
+ }
+
+ for (const_iterator it = data.begin(); it != data.end(); ++it)
+ y2mil("data[" << it->first << "] -> " << it->second);
+ }
+
+
+ bool
+ ProcMounts::isBind(SystemCmd& mt, const string& dir) const
+ {
+ bool ret = false;
+
mt.select( (string)" on "+dir+' ' );
if( mt.numLines(true)>0 )
- {
- list<string> sl = splitString( *mt.getLine(0,true) );
+ {
+ list<string> sl = splitString( mt.getLine(0,true) );
y2mil( "sl:" << sl );
if( sl.size()>=6 )
- {
+ {
list<string>::const_iterator i=sl.begin();
++i;
++i;
++i;
++i;
if( *i == "none" )
- {
+ {
++i;
string opt = *i;
if( !opt.empty() && opt[0]=='(' )
@@ -96,102 +117,83 @@
opt.erase( opt.size()-1, 1 );
sl = splitString( opt, "," );
y2mil( "sl:" << sl );
- skip = find( sl.begin(), sl.end(), "bind" )!=sl.end();
- if( skip )
- y2mil( "skiping line:" << line );
- }
+ ret = find(sl.begin(), sl.end(), "bind") != sl.end();
}
}
- if( !skip && dev!= "rootfs" && dev!="/dev/root" )
- {
- co[dev].device = dev;
- co[dev].mount = dir;
- co[dev].fs = extractNthWord( 2, line );
- co[dev].opts = splitString( extractNthWord( 3, line ), "," );
- }
- getline( mounts, line );
- }
- mt.select( " / " );
- if( mt.numLines()>0 )
- {
- y2mil( "root mount:" << *mt.getLine(0,true) );
- string dev = extractNthWord( 0, *mt.getLine(0,true));
- if( !dev.empty() && dev[0]!='/' )
- {
- dev = sto->findNormalDevice( dev );
- }
- co[dev].device = dev;
- co[dev].mount = "/";
- }
- mounts.close();
- mounts.clear();
- mounts.open( "/proc/swaps" );
- getline( mounts, line );
- y2mil( "swap line:\"" << line << "\"" );
- getline( mounts, line );
- while( mounts.good() )
- {
- y2mil( "swap line:\"" << line << "\"" );
- string::size_type pos;
- string dev = extractNthWord( 0, line );
- if( (pos=dev.find( "\\040(deleted)" ))!=string::npos )
- {
- y2mil( "dev:" << dev );
- dev.erase( pos );
- }
- co[dev].device = dev;
- co[dev].mount = "swap";
- co[dev].fs = "swap";
- getline( mounts, line );
- }
- map<string,FstabEntry>::const_iterator i = co.begin();
- while( i!=co.end() )
- {
- y2mil( "co:[" << i->first << "]-->" << i->second );
- ++i;
}
+
+ return ret;
}
-string
-ProcMounts::getMount( const string& dev ) const
+
+string
+ProcMounts::getMount(const string& device) const
{
string ret;
- map<string,FstabEntry>::const_iterator i = co.find( dev );
- if( i!=co.end() )
+ const_iterator i = data.find(device);
+ if (i != data.end())
ret = i->second.mount;
- return( ret );
+ return ret;
}
string
-ProcMounts::getMount( const list<string>& dl ) const
+ProcMounts::getMount(const list<string>& devices) const
{
string ret;
- list<string>::const_iterator i = dl.begin();
- while( ret.empty() && i!=dl.end() )
+ list<string>::const_iterator i = devices.begin();
+ while (ret.empty() && i != devices.end())
{
ret = getMount( *i );
++i;
}
- return( ret );
+ return ret;
+ }
+
+
+ list<string>
+ ProcMounts::getAllMounts(const string& device) const
+ {
+ list<string> ret;
+
+ pair<const_iterator, const_iterator> range = data.equal_range(device);
+ for (const_iterator i = range.first; i != range.second; ++i)
+ ret.push_back(i->second.mount);
+
+ return ret;
+ }
+
+
+ list<string>
+ ProcMounts::getAllMounts(const list<string>& devices) const
+ {
+ list<string> ret;
+
+ for (list<string>::const_iterator i = devices.begin(); i != devices.end(); ++i)
+ ret.splice(ret.end(), getAllMounts(*i));
+
+ return ret;
}
-map<string,string>
+
+map<string, string>
ProcMounts::allMounts() const
{
- map<string,string> ret;
- for( map<string,FstabEntry>::const_iterator i = co.begin(); i!=co.end(); ++i )
+ map<string, string> ret;
+ for (const_iterator i = data.begin(); i != data.end(); ++i)
{
ret[i->second.mount] = i->first;
}
- return( ret );
+ return ret;
}
-void ProcMounts::getEntries( list<FstabEntry>& l ) const
+
+ list<FstabEntry>
+ ProcMounts::getEntries() const
{
- l.clear();
- for( map<string,FstabEntry>::const_iterator i = co.begin(); i!=co.end(); ++i )
- {
- l.push_back( i->second );
- }
+ list<FstabEntry> ret;
+ for (const_iterator i = data.begin(); i != data.end(); ++i)
+ ret.push_back(i->second);
+ return ret;
}
+}
Modified: branches/SuSE-Code-11-SP2-Branch/storage/libstorage/src/ProcMounts.h
URL: http://svn.opensuse.org/viewcvs/yast/branches/SuSE-Code-11-SP2-Branch/stora…
==============================================================================
--- branches/SuSE-Code-11-SP2-Branch/storage/libstorage/src/ProcMounts.h (original)
+++ branches/SuSE-Code-11-SP2-Branch/storage/libstorage/src/ProcMounts.h Tue May 17 13:39:44 2011
@@ -1,5 +1,5 @@
/*
- * Copyright (c) [2004-2009] Novell, Inc.
+ * Copyright (c) [2004-2010] Novell, Inc.
*
* All Rights Reserved.
*
@@ -27,22 +27,42 @@
#include <list>
#include <map>
-#include "y2storage/EtcFstab.h"
+#include "storage/EtcFstab.h"
namespace storage
{
-class Storage;
+ using std::list;
+ using std::map;
+ using std::multimap;
-class ProcMounts
+ class SystemCmd;
+
+ class ProcMounts
{
public:
- ProcMounts( Storage * const s );
- string getMount( const string& Dev ) const;
- string getMount( const std::list<string>& dl ) const;
- std::map<string,string> allMounts() const;
- void getEntries( std::list<FstabEntry>& l ) const;
+
+ ProcMounts();
+
+ void reload();
+
+ string getMount(const string& device) const;
+ string getMount(const list<string>& devices) const;
+
+ list<string> getAllMounts(const string& device) const;
+ list<string> getAllMounts(const list<string>& devices) const;
+
+ map<string, string> allMounts() const;
+
+ list<FstabEntry> getEntries() const;
+
protected:
- std::map<string,FstabEntry> co;
+
+ bool isBind(SystemCmd& mt, const string& dir) const;
+
+ typedef multimap<string, FstabEntry>::const_iterator const_iterator;
+
+ multimap<string, FstabEntry> data;
+
};
}
Added: branches/SuSE-Code-11-SP2-Branch/storage/libstorage/src/ProcParts.cc
URL: http://svn.opensuse.org/viewcvs/yast/branches/SuSE-Code-11-SP2-Branch/stora…
==============================================================================
--- branches/SuSE-Code-11-SP2-Branch/storage/libstorage/src/ProcParts.cc (added)
+++ branches/SuSE-Code-11-SP2-Branch/storage/libstorage/src/ProcParts.cc Tue May 17 13:39:44 2011
@@ -0,0 +1,100 @@
+/*
+ * Copyright (c) [2004-2009] Novell, Inc.
+ *
+ * All Rights Reserved.
+ *
+ * This program is free software; you can redistribute it and/or modify it
+ * under the terms of version 2 of the GNU General Public License as published
+ * by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
+ * more details.
+ *
+ * You should have received a copy of the GNU General Public License along
+ * with this program; if not, contact Novell, Inc.
+ *
+ * To contact Novell about this file by physical or electronic mail, you may
+ * find current contact information at www.novell.com.
+ */
+
+
+#include "storage/AppUtil.h"
+#include "storage/StorageTmpl.h"
+#include "storage/AsciiFile.h"
+#include "storage/ProcParts.h"
+
+
+namespace storage
+{
+ using namespace std;
+
+
+ ProcParts::ProcParts()
+ {
+ reload();
+ }
+
+
+ void
+ ProcParts::reload()
+ {
+ data.clear();
+
+ AsciiFile parts("/proc/partitions");
+ parts.remove(0, 2);
+
+ for (vector<string>::const_iterator it = parts.lines().begin(); it != parts.lines().end(); ++it)
+ {
+ string device = "/dev/" + extractNthWord(3, *it);
+ unsigned long long sizeK;
+ extractNthWord(2, *it) >> sizeK;
+ data[device] = sizeK;
+ }
+
+ for (const_iterator it = data.begin(); it != data.end(); ++it)
+ y2mil("data[" << it->first << "] -> " << it->second);
+ }
+
+
+ bool
+ ProcParts::findDevice(const string& device) const
+ {
+ return( findEntry(device)!=data.end() );
+ }
+
+
+ bool
+ ProcParts::getSize(const string& device, unsigned long long& sizeK) const
+ {
+ const_iterator i = findEntry(device);
+ if (i == data.end())
+ {
+ y2err("dev:" << device << " not found");
+ return false;
+ }
+
+ sizeK = i->second;
+ y2mil("dev:" << device << " sizeK:" << sizeK);
+ return true;
+ }
+
+
+ list<string>
+ ProcParts::getEntries() const
+ {
+ list<string> ret;
+ for (const_iterator i = data.begin(); i != data.end(); ++i)
+ ret.push_back(i->first);
+ return ret;
+ }
+
+
+ ProcParts::const_iterator
+ ProcParts::findEntry(const string& device) const
+ {
+ return( data.find(normalizeDevice(device)) );
+ }
+
+}
Added: branches/SuSE-Code-11-SP2-Branch/storage/libstorage/src/ProcParts.h
URL: http://svn.opensuse.org/viewcvs/yast/branches/SuSE-Code-11-SP2-Branch/stora…
==============================================================================
--- branches/SuSE-Code-11-SP2-Branch/storage/libstorage/src/ProcParts.h (added)
+++ branches/SuSE-Code-11-SP2-Branch/storage/libstorage/src/ProcParts.h Tue May 17 13:39:44 2011
@@ -0,0 +1,75 @@
+/*
+ * Copyright (c) [2004-2009] Novell, Inc.
+ *
+ * All Rights Reserved.
+ *
+ * This program is free software; you can redistribute it and/or modify it
+ * under the terms of version 2 of the GNU General Public License as published
+ * by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
+ * more details.
+ *
+ * You should have received a copy of the GNU General Public License along
+ * with this program; if not, contact Novell, Inc.
+ *
+ * To contact Novell about this file by physical or electronic mail, you may
+ * find current contact information at www.novell.com.
+ */
+
+
+#ifndef PROC_PARTS_H
+#define PROC_PARTS_H
+
+
+#include <string>
+#include <list>
+#include <map>
+
+
+namespace storage
+{
+ using std::string;
+ using std::list;
+ using std::map;
+
+
+ class ProcParts
+ {
+ public:
+
+ ProcParts();
+
+ void reload();
+
+ bool getSize(const string& device, unsigned long long& sizeK) const;
+ bool findDevice(const string& device) const;
+
+ list<string> getEntries() const;
+
+ template<class Pred>
+ list<string> getMatchingEntries(Pred pred) const
+ {
+ list<string> ret;
+ for (const_iterator i = data.begin(); i != data.end(); ++i)
+ if (pred(i->first))
+ ret.push_back(i->first);
+ return ret;
+ }
+
+ protected:
+
+ typedef map<string, unsigned long long>::const_iterator const_iterator;
+
+ const_iterator findEntry(const string& device) const;
+
+ map<string, unsigned long long> data;
+
+ };
+
+}
+
+
+#endif
Modified: branches/SuSE-Code-11-SP2-Branch/storage/libstorage/src/Regex.cc
URL: http://svn.opensuse.org/viewcvs/yast/branches/SuSE-Code-11-SP2-Branch/stora…
==============================================================================
--- branches/SuSE-Code-11-SP2-Branch/storage/libstorage/src/Regex.cc (original)
+++ branches/SuSE-Code-11-SP2-Branch/storage/libstorage/src/Regex.cc Tue May 17 13:39:44 2011
@@ -19,20 +19,15 @@
* find current contact information at www.novell.com.
*/
-/*
- * Author: Arvin Schnell
- Textdomain "storage"
- */
-
-
-#include "Regex.h"
-
-using namespace storage;
+#include "storage/Regex.h"
extern int _nl_msg_cat_cntr;
+namespace storage
+{
+
Regex::Regex (const char* pattern, int cflags, unsigned int nm)
: pattern (pattern),
cflags (cflags),
@@ -99,5 +94,8 @@
return "";
}
+
const string Regex::ws = "[ \t]*";
const string Regex::number = "[0123456789]+";
+
+}
Modified: branches/SuSE-Code-11-SP2-Branch/storage/libstorage/src/Regex.h
URL: http://svn.opensuse.org/viewcvs/yast/branches/SuSE-Code-11-SP2-Branch/stora…
==============================================================================
--- branches/SuSE-Code-11-SP2-Branch/storage/libstorage/src/Regex.h (original)
+++ branches/SuSE-Code-11-SP2-Branch/storage/libstorage/src/Regex.h Tue May 17 13:39:44 2011
@@ -24,19 +24,15 @@
#define REGEX_H
-/*
- * Author: Arvin Schnell
- */
-
-
#include <regex.h>
#include <string>
#include <boost/noncopyable.hpp>
-using std::string;
namespace storage
{
+ using std::string;
+
class Regex : boost::noncopyable
{
@@ -46,7 +42,7 @@
Regex (const string& pattern, int cflags = REG_EXTENDED, unsigned int = 10);
~Regex ();
- string getPattern () const { return pattern; };
+ string getPattern () const { return pattern; }
int getCflags () const { return cflags; }
bool match (const string&, int eflags = 0) const;
Added: branches/SuSE-Code-11-SP2-Branch/storage/libstorage/src/Region.cc
URL: http://svn.opensuse.org/viewcvs/yast/branches/SuSE-Code-11-SP2-Branch/stora…
==============================================================================
--- branches/SuSE-Code-11-SP2-Branch/storage/libstorage/src/Region.cc (added)
+++ branches/SuSE-Code-11-SP2-Branch/storage/libstorage/src/Region.cc Tue May 17 13:39:44 2011
@@ -0,0 +1,57 @@
+/*
+ * Copyright (c) [2004-2010] Novell, Inc.
+ *
+ * All Rights Reserved.
+ *
+ * This program is free software; you can redistribute it and/or modify it
+ * under the terms of version 2 of the GNU General Public License as published
+ * by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
+ * more details.
+ *
+ * You should have received a copy of the GNU General Public License along
+ * with this program; if not, contact Novell, Inc.
+ *
+ * To contact Novell about this file by physical or electronic mail, you may
+ * find current contact information at www.novell.com.
+ */
+
+
+#include "storage/Region.h"
+
+
+namespace storage
+{
+
+ std::ostream& operator<<(std::ostream& s, const Region& p)
+ {
+ return s << "[" << p.s << "," << p.l << "]";
+ }
+
+
+ bool
+ getChildValue(const xmlNode* node, const char* name, Region& value)
+ {
+ const xmlNode* tmp = getChildNode(node, name);
+ if (!tmp)
+ return false;
+
+ getChildValue(tmp, "start", value.s);
+ getChildValue(tmp, "length", value.l);
+ return true;
+ }
+
+
+ void
+ setChildValue(xmlNode* node, const char* name, const Region& value)
+ {
+ xmlNode* tmp = xmlNewChild(node, name);
+
+ setChildValue(tmp, "start", value.s);
+ setChildValue(tmp, "length", value.l);
+ }
+
+}
Modified: branches/SuSE-Code-11-SP2-Branch/storage/libstorage/src/Region.h
URL: http://svn.opensuse.org/viewcvs/yast/branches/SuSE-Code-11-SP2-Branch/stora…
==============================================================================
--- branches/SuSE-Code-11-SP2-Branch/storage/libstorage/src/Region.h (original)
+++ branches/SuSE-Code-11-SP2-Branch/storage/libstorage/src/Region.h Tue May 17 13:39:44 2011
@@ -1,5 +1,5 @@
/*
- * Copyright (c) [2004-2009] Novell, Inc.
+ * Copyright (c) [2004-2010] Novell, Inc.
*
* All Rights Reserved.
*
@@ -25,30 +25,30 @@
#include <algorithm>
+#include "storage/XmlFile.h"
+
+
namespace storage
{
-class Region
+ class Region
{
public:
+
Region() : s(0), l(0) {}
- Region( unsigned long start, unsigned long len ) : s(start), l(len) {}
- Region( const Region& x )
- { *this = x; }
- Region& operator=(const Region& r)
- { s = r.start(); l = r.len(); return( *this ); }
+ Region(unsigned long long start, unsigned long long len) : s(start), l(len) {}
+
bool doIntersect( const Region& r ) const
{ return( r.start() <= end() && r.end() >= start() ); }
Region intersect( const Region& r ) const
{
- Region ret;
if (doIntersect(r))
{
- unsigned long s = std::max( r.start(), start() );
- unsigned long e = std::min( r.end(), end() );
- ret = Region( s, e-s+1 );
+ unsigned long long s = std::max(r.start(), start());
+ unsigned long long e = std::min(r.end(), end());
+ return Region(s, e - s + 1);
}
- return( ret );
+ return Region(0, 0);
}
bool inside( const Region& r ) const
{ return( start()>=r.start() && end() <= r.end() ); }
@@ -60,27 +60,41 @@
{ return( s < r.start() ); }
bool operator>(const Region& r) const
{ return( s > r.start() ); }
- unsigned long start() const { return( s ); }
- unsigned long end() const { return( s+l-1 ); }
- unsigned long len() const { return( l ); }
+
+ unsigned long long start() const { return s; }
+ unsigned long long len() const { return l; }
+ unsigned long long end() const { return s + l - 1; }
+
+ bool empty() const { return l == 0; }
+
+ void setStart(unsigned long long start) { s = start; }
+ void setLen(unsigned long long len) { l = len; }
+
+ template <typename Type> friend
+ Region operator*(Type i, const Region& r)
+ {
+ static_assert(std::is_integral<Type>::value, "not integral");
+ return Region(i * r.s, i * r.l);
+ }
+
+ template <typename Type> friend
+ Region operator/(const Region& r, Type i)
+ {
+ static_assert(std::is_integral<Type>::value, "not integral");
+ return Region(r.s / i, r.l / i);
+ }
+
+ friend std::ostream& operator<<(std::ostream& s, const Region& p);
+
+ friend bool getChildValue(const xmlNode* node, const char* name, Region& value);
+ friend void setChildValue(xmlNode* node, const char* name, const Region& value);
+
protected:
- unsigned long s;
- unsigned long l;
- };
-inline std::ostream& operator<< (std::ostream& s, const Region &p )
- {
- s << "[" << p.start() << "," << p.len() << "]";
- return( s );
- }
+ unsigned long long s;
+ unsigned long long l;
-inline std::istream& operator>> (std::istream& s, Region &p )
- {
- unsigned long start, len;
- s >> start >> len;
- p = Region( start, len );
- return( s );
- }
+ };
}
Modified: branches/SuSE-Code-11-SP2-Branch/storage/libstorage/src/Storage.cc
URL: http://svn.opensuse.org/viewcvs/yast/branches/SuSE-Code-11-SP2-Branch/stora…
==============================================================================
--- branches/SuSE-Code-11-SP2-Branch/storage/libstorage/src/Storage.cc (original)
+++ branches/SuSE-Code-11-SP2-Branch/storage/libstorage/src/Storage.cc Tue May 17 13:39:44 2011
@@ -1,5 +1,5 @@
/*
- * Copyright (c) [2004-2009] Novell, Inc.
+ * Copyright (c) [2004-2010] Novell, Inc.
*
* All Rights Reserved.
*
@@ -19,9 +19,6 @@
* find current contact information at www.novell.com.
*/
-/*
- Textdomain "storage"
-*/
#include <dirent.h>
#include <glob.h>
@@ -29,45 +26,45 @@
#include <fcntl.h>
#include <sys/stat.h>
#include <sys/types.h>
-#include <sys/statvfs.h>
#include <pwd.h>
-#include <config.h>
#include <signal.h>
-#include <sys/utsname.h>
-#include <errno.h>
-
#include <set>
+#include <array>
#include <fstream>
#include <sstream>
-#include <iostream>
#include <boost/algorithm/string.hpp>
-#include "y2storage/Storage.h"
-#include "y2storage/StorageTmpl.h"
-#include "y2storage/AppUtil.h"
-#include "y2storage/SystemCmd.h"
-#include "y2storage/Disk.h"
-#include "y2storage/Dasd.h"
-#include "y2storage/MdCo.h"
-#include "y2storage/MdPartCo.h"
-#include "y2storage/DmCo.h"
-#include "y2storage/LoopCo.h"
-#include "y2storage/LvmVg.h"
-#include "y2storage/IterPair.h"
-#include "y2storage/ProcMounts.h"
-#include "y2storage/ProcPart.h"
-#include "y2storage/EtcFstab.h"
-#include "y2storage/EtcRaidtab.h"
-#include "y2storage/AsciiFile.h"
-#include "y2storage/StorageDefines.h"
+#include "config.h"
+#include "storage/Storage.h"
+#include "storage/StorageTmpl.h"
+#include "storage/AppUtil.h"
+#include "storage/SystemCmd.h"
+#include "storage/Disk.h"
+#include "storage/Dasd.h"
+#include "storage/MdCo.h"
+#include "storage/MdPartCo.h"
+#include "storage/DmCo.h"
+#include "storage/LoopCo.h"
+#include "storage/LvmVg.h"
+#include "storage/IterPair.h"
+#include "storage/SystemInfo.h"
+#include "storage/ProcMounts.h"
+#include "storage/ProcParts.h"
+#include "storage/Blkid.h"
+#include "storage/EtcFstab.h"
+#include "storage/EtcMdadm.h"
+#include "storage/AsciiFile.h"
+#include "storage/StorageDefines.h"
-using namespace std;
-using namespace storage;
-
-void
-Storage::initDefaultLogger ()
+namespace storage
{
+ using namespace std;
+
+
+ void
+ initDefaultLogger()
+ {
string path;
string file;
if (geteuid ())
@@ -90,30 +87,28 @@
file = "y2log";
}
- storage::createLogger("libstorage", "default", path, file);
-}
+ createLogger("default", path, file);
+ }
-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), fstab(NULL), raidtab(NULL),
- imsm_driver(IMSM_UNDECIDED)
+ : env(env), lock(readonly(), testmode()), cache(true), initialized(false),
+ recursiveRemove(false), zeroNewPartitions(false),
+ partAlignment(ALIGN_OPTIMAL), defaultMountBy(MOUNTBY_ID),
+ defaultFs(EXT4), detectMounted(true), root_mounted(!instsys()),
+ rootprefix(), fstab(NULL), mdadm(NULL), imsm_driver(IMSM_UNDECIDED)
{
y2mil("constructed Storage with " << env);
- y2mil("package string \"" PACKAGE_STRING "\"");
+ y2mil("libstorage version " VERSION);
- root_mounted = !instsys();
- efiboot = false;
hald_pid = 0;
max_log_num = 5;
@@ -126,24 +121,18 @@
install_info_cb = NULL;
info_popup_cb = NULL;
yesno_popup_cb = NULL;
+ commit_error_popup_cb = NULL;
password_popup_cb = NULL;
- recursiveRemove = false;
- zeroNewPartitions = false;
- partAlignment = ALIGN_OPTIMAL;
- defaultMountBy = MOUNTBY_ID;
- detectMounted = true;
-
+ SystemCmd::setTestmode(testmode());
tenv = getenv("LIBSTORAGE_IMSM_DRIVER");
if (tenv)
{
- if (boost::iequals(tenv, "DMRAID", locale::classic()))
- imsm_driver = IMSM_DMRAID;
- else if (boost::iequals(tenv, "MDADM", locale::classic()))
- imsm_driver = IMSM_MDADM;
+ if (!toValue(tenv, imsm_driver, false))
+ y2war("unknown IMSM driver '" << tenv << "' in environment");
}
- y2mil("imsm_driver:" << imsm_driver);
+ y2mil("imsm_driver:" << toString(imsm_driver));
logSystemInfo();
}
@@ -152,14 +141,11 @@
void
Storage::logSystemInfo() const
{
- ifstream File( "/proc/version" );
- classic(File);
- string line;
- getline( File, line );
- File.close();
- y2mil( "kernel version:" << line );
-
- SystemCmd(LSBIN " -1 /lib/modules");
+ if (!testmode())
+ {
+ AsciiFile("/proc/version").logContent();
+ SystemCmd(LSBIN " -1 /lib/modules");
+ }
}
@@ -167,205 +153,260 @@
Storage::initialize()
{
initialized = true;
- char tbuf[100];
- strncpy( tbuf, "/tmp/liby2storageXXXXXX", sizeof(tbuf)-1 );
- if( mkdtemp( tbuf )==NULL )
- {
- cerr << "tmpdir creation " << tbuf << " failed. Aborting..." << endl;
- exit(1);
+
+ tempdir = "/tmp/libstorage-XXXXXX";
+ if (!mkdtemp(tempdir))
+ {
+ y2err("tmpdir creation " << tempdir << " failed. Aborting...");
+ exit(EXIT_FAILURE);
}
- else
+
+ bindtextdomain("libstorage", "/usr/share/locale");
+ bind_textdomain_codeset("libstorage", "UTF-8");
+
+ if (access(SYSCONFIGFILE, R_OK) == 0)
+ {
+ SysconfigFile sc(SYSCONFIGFILE);
+
+ string val;
+ if (sc.getValue("DEVICE_NAMES", val))
{
- tempdir = tbuf;
- rmdir( tempdir.c_str() );
- }
- if( access( "/etc/sysconfig/storage", R_OK )==0 )
- {
- AsciiFile sc( "/etc/sysconfig/storage" );
- Regex r('^' + Regex::ws + "DEVICE_NAMES" + '=' + "(['\"]?)([^'\"]*)\\1" + Regex::ws + '$');
- int line = sc.find( 0, r );
- if( line >= 0 )
- {
- string val = boost::to_lower_copy(r.cap(2), locale::classic());
- if( val == "id" )
- setDefaultMountBy( MOUNTBY_ID );
- else if( val == "path" )
- setDefaultMountBy( MOUNTBY_PATH );
- else if( val == "device" )
- setDefaultMountBy( MOUNTBY_DEVICE );
- else if( val == "uuid" )
- setDefaultMountBy( MOUNTBY_UUID );
- else if( val == "label" )
- setDefaultMountBy( MOUNTBY_LABEL );
- }
- Regex rx3('^' + Regex::ws + "PARTITION_ALIGN" + '=' + "(['\"]?)([^'\"]*)\\1" + Regex::ws + '$');
- line = sc.find( 0, rx3 );
- if( line >= 0 )
- {
- string val = boost::to_lower_copy(rx3.cap(2), locale::classic());
- if (val == "cylinder")
- setPartitionAlignment(ALIGN_CYLINDER);
- else if(val == "optimal")
- setPartitionAlignment(ALIGN_OPTIMAL);
+ boost::to_lower(val, locale::classic());
+ MountByType mount_by_type;
+ if (!toValue(val, mount_by_type, false))
+ y2war("unknown default mount-by method '" << val << "' in " SYSCONFIGFILE);
else
- y2war("unknown partition alignment '" << val << "' in /etc/sysconfig/storage");
+ setDefaultMountBy(mount_by_type);
+ }
+
+ if (sc.getValue("DEFAULT_FS", val))
+ {
+ boost::to_lower(val, locale::classic());
+ if (val == "reiser") val = "reiserfs";
+ FsType fs_type;
+ if (!toValue(val, fs_type, false))
+ y2war("unknown default filesystem '" << val << "' in " SYSCONFIGFILE);
+ else if (fs_type != EXT2 && fs_type != EXT3 && fs_type != EXT4 &&
+ fs_type != REISERFS && fs_type != XFS)
+ y2war("unallowed default filesystem '" << val << "' in " SYSCONFIGFILE);
+ else
+ setDefaultFs(fs_type);
}
- }
- if( autodetect() )
+ if (sc.getValue("PARTITION_ALIGN", val))
{
- detectArch();
- efiboot = (arch() == "ia64");
+ boost::to_lower(val, locale::classic());
+ PartAlign part_align;
+ if (!toValue(val, part_align, false))
+ y2war("unknown partition alignment '" << val << "' in " SYSCONFIGFILE);
+ else
+ setPartitionAlignment(part_align);
}
+ }
+
+ if (testmode())
+ {
+ string t = testdir() + "/arch.info";
+ if (access(t.c_str(), R_OK) == 0)
+ readArchInfo(t);
+ }
+ else if (autodetect())
+ {
+ archinfo.detect(instsys());
+ y2mil(archinfo);
+ }
detectObjects();
- setCacheChanges( true );
- dumpObjectList();
- std::list<std::pair<string,string> >::const_iterator i;
- for( i=infoPopupTxts.begin(); i!=infoPopupTxts.end(); ++i )
+ for (list<std::pair<string, Text>>::const_iterator i = infoPopupTxts.begin();
+ i != infoPopupTxts.end(); ++i)
{
- storage::usedBy ub;
- usedBy( i->first, ub );
- y2mil( "device:" << i->first << " used By:" << ub );
- if( ub.type()==UB_NONE )
+ if (!isUsedBy(i->first))
infoPopupCb( i->second );
else
- y2mil( "suppressing cb:" << i->second );
+ y2mil( "suppressing cb:" << i->second.native );
}
logProcData();
}
+
void Storage::dumpObjectList()
{
+ assertInit();
ostringstream buf;
- classic(buf);
+ prepareLogStream(buf);
printInfo(buf);
- std::list<string> l = splitString( buf.str(), "\n" );
- y2mil("DETECTED OBJECTS");
- for (std::list<string>::const_iterator i = l.begin(); i != l.end(); i++)
- y2mil(*i);
- y2mil("END DETECTED OBJECTS");
+ y2mil("DETECTED OBJECTS BEGIN");
+ y2mil(buf.str());
+ y2mil("DETECTED OBJECTS END");
}
+
void Storage::detectObjects()
- {
- ProcPart* ppart = new ProcPart;
- detectDisks( *ppart );
- if( instsys() )
+{
+ if (instsys())
{
- if( discoverMdPVols() == true )
- {
- // if 'yes' then activate md prior to dm
- MdPartCo::activate( true, tmpDir() );
- waitForDevice();
- }
- //Note:
- //dmraid will not activate devices that were activated by
- //mdadm. So this is safe.
- DmraidCo::activate( true );
- waitForDevice();
- //If user said No then this is the way it was before.
- if (getImsmDriver() != IMSM_MDADM)
- {
- MdPartCo::activate(true, tmpDir() );
- waitForDevice();
- }
- LvmVg::activate( true );
- waitForDevice();
- delete ppart;
- ppart = new ProcPart;
+ discoverMdPVols();
+
+ if (getImsmDriver() == IMSM_MDADM)
+ {
+ MdPartCo::activate(true, tmpDir());
+ DmraidCo::activate(true);
+ }
+ else
+ {
+ DmraidCo::activate(true);
+ MdPartCo::activate(true, tmpDir());
+ }
+
+ MdCo::activate(true, tmpDir());
+ LvmVg::activate(true);
}
- detectDmraid( *ppart );
- detectDmmultipath( *ppart );
- detectMdParts(*ppart);
- detectMds();
- detectDm(*ppart, true);
- detectLvmVgs();
- detectDm(*ppart, false);
+ danglingUsedBy.clear();
+
+ SystemInfo systeminfo;
+
+ detectDisks(systeminfo);
+ detectDmraid(systeminfo);
+ detectDmmultipath(systeminfo);
+ detectMdParts(systeminfo);
+ detectMds(systeminfo);
+ detectDm(systeminfo, true);
+ detectLvmVgs(systeminfo);
+ detectDm(systeminfo, false);
+ delete fstab;
+ if (testmode())
+ {
+ rootprefix = testdir();
+ fstab = new EtcFstab( rootprefix + "/etc" );
+ mdadm = new EtcMdadm(this, rootprefix);
+ }
+ else
+ {
+ fstab = new EtcFstab( "/etc", isRootMounted() );
+ if (!instsys())
+ mdadm = new EtcMdadm(this, root());
+ }
+
+ detectLoops(systeminfo);
+ if( !instsys() )
+ {
+ detectNfs(*fstab, systeminfo);
+ detectTmpfs(*fstab, systeminfo);
+ }
+ if (!danglingUsedBy.empty())
+ y2err("dangling used-by left after detection: " << danglingUsedBy);
+
LvmVgPair p = lvgPair();
y2mil( "p length:" << p.length() );
for( LvmVgIterator i=p.begin(); i!=p.end(); ++i )
i->normalizeDmDevices();
- if( testmode() )
+ if (testmode())
{
- SystemCmd::testmode = true;
- rootprefix = testdir();
- fstab = new EtcFstab( rootprefix );
- raidtab = new EtcRaidtab(this, rootprefix);
- string t = testdir() + "/volume_info";
+ for (VolIterator i = vBegin(); i != vEnd(); ++i)
+ i->getFstabData(*fstab);
+
+ string t = testdir() + "/free.info";
if( access( t.c_str(), R_OK )==0 )
- {
- detectFsDataTestMode( t, vBegin(), vEnd() );
- }
+ readFreeInfo(t);
}
else
{
- fstab = new EtcFstab( "/etc", isRootMounted() );
- if (!instsys())
- raidtab = new EtcRaidtab(this, root());
- detectLoops( *ppart );
- ProcMounts pm( this );
- if( !instsys() )
- detectNfs( pm );
- detectFsData( vBegin(), vEnd(), pm );
+ detectFsData(vBegin(), vEnd(), systeminfo);
+ logContainersAndVolumes(logdir());
}
+ detectBtrfs(systeminfo);
+
+ dumpObjectList();
if( instsys() )
{
- SystemCmd c( "grep ^md.*dm- /proc/mdstat" );
+ SystemCmd c(GREPBIN " ^md.*dm- /proc/mdstat");
SystemCmd rm;
for( unsigned i=0; i<c.numLines(); i++ )
{
- rm.execute(MDADMBIN " --stop " + quote("/dev/" + extractNthWord(0, *c.getLine(i))));
+ rm.execute(MDADMBIN " --stop " + quote("/dev/" + extractNthWord(0, c.getLine(i))));
}
}
- delete ppart;
}
-void Storage::deleteClist( CCont& co )
+
+bool
+Storage::discoverMdPVols()
+{
+ if( !instsys() )
{
- for( CIter i=co.begin(); i!=co.end(); ++i )
- delete( *i );
- co.clear();
+ return false;
}
-void Storage::deleteBackups()
+ bool ret = false;
+ if (isImsmPlatform())
{
- map<string,CCont>::iterator i = backups.begin();
- while( i!=backups.end() )
+ y2mil("Intel SW RAID Platform detected.");
+
+ list <string> l;
+ if (MdPartCo::scanForRaid(l) && !l.empty())
+ {
+ y2mil("md raids:" << l);
+
+ if (getImsmDriver() == IMSM_UNDECIDED)
{
- deleteClist( i->second );
- ++i;
+ Text txt = sformat(
+ // popup text %1$s is replaced by disk name e.g. /dev/hda
+ _("You are running on the Intel(R) Matrix Storage Manager compatible platform.\n"
+ "\n"
+ "Following MD compatible RAID devices were detected:\n"
+ "%1$s\n"
+ "If they are clean devices or contain partitions then you can choose to use\n"
+ "MD Partitionable RAID sysbsystem to handle them. In case of clean device you\n"
+ "will be able to install system on it and boot from such RAID.\n"
+ "Do you want MD Partitionable RAID subsystem to manage those partitions?"
+ ), boost::join(l, " ").c_str() );
+
+ if( yesnoPopupCb(txt) )
+ {
+ ret = true;
+ setImsmDriver(IMSM_MDADM);
+ }
+ else
+ {
+ ret = false;
+ setImsmDriver(IMSM_DMRAID);
+ }
+ }
+ else
+ {
+ ret = getImsmDriver() == IMSM_MDADM;
}
+ }
+ }
+ y2mil(" Exiting with status: " << ret);
+ return ret;
+}
+
+
+void Storage::deleteBackups()
+ {
+ for (map<string, CCont>::iterator i = backups.begin(); i != backups.end(); ++i)
+ clearPointerList(i->second);
backups.clear();
}
Storage::~Storage()
{
- if( max_log_num>0 )
- {
- logVolumes( logdir() );
- for( CIter i=cont.begin(); i!=cont.end(); ++i )
- {
- (*i)->logData( logdir() );
- }
- }
- deleteClist(cont);
+ logContainersAndVolumes(logdir());
+ clearPointerList(cont);
deleteBackups();
- if( !tempdir.empty() && access( tempdir.c_str(), R_OK )==0 )
- {
- SystemCmd c( "rmdir " + tempdir );
- if( c.retcode()!=0 )
- {
- y2err("stray tmpfile");
- c.execute( "ls -l" + tempdir );
- c.execute( "rm -rf " + tempdir );
- }
- }
+ if (!tempdir.empty() && rmdir(tempdir.c_str()) != 0)
+ {
+ y2err("stray tmpfile");
+ SystemCmd(LSBIN " -l " + quote(tempdir));
+ }
+ delete fstab;
+ delete mdadm;
y2mil("destructed Storage");
}
@@ -376,6 +417,12 @@
if (instsys())
{
bool dmmultipath_active = DmmultipathCo::isActive();
+ if (!dmmultipath_active)
+ {
+ SystemInfo systeminfo;
+ DmmultipathCo::getMultipaths(systeminfo);
+ dmmultipath_active = DmmultipathCo::isActive();
+ }
LvmVg::activate(false);
MdCo::activate(false, tmpDir());
@@ -390,135 +437,96 @@
}
}
- deleteClist(cont);
+ clearPointerList(cont);
detectObjects();
}
-const string& Storage::tmpDir() const
- {
- if( access( tempdir.c_str(), W_OK )!= 0 )
- mkdir( tempdir.c_str(), 0700 );
- return( tempdir );
- }
-
-void
-Storage::detectArch()
+bool Storage::rescanCryptedObjects()
{
- struct utsname buf;
- proc_arch = "i386";
- if( uname( &buf ) == 0 )
- {
- if( strncmp( buf.machine, "ppc", 3 )==0 )
- {
- proc_arch = "ppc";
- }
- else if( strncmp( buf.machine, "ia64", 4 )==0 )
- {
- proc_arch = "ia64";
- }
- else if( strncmp( buf.machine, "s390", 4 )==0 )
- {
- proc_arch = "s390";
- }
- else if( strncmp( buf.machine, "sparc", 5 )==0 )
- {
- proc_arch = "sparc";
- }
- }
- if( proc_arch == "ppc" )
+ bool ret = false;
+ LvmVg::activate(false);
+ LvmVg::activate(true);
+ SystemInfo systeminfo;
+ const list<string> l = LvmVg::getVgs();
+ for( list<string>::const_iterator i=l.begin(); i!=l.end(); ++i )
{
- AsciiFile cpu( "/proc/cpuinfo" );
- int l = cpu.find( 0, "^machine\t" );
- y2mil("line:" << l);
- if( l >= 0 )
+ if( findLvmVg( *i ) == lvgEnd() )
{
- string line = cpu[l];
- line = extractNthWord( 2, line );
- y2mil("line:" << line);
- is_ppc_mac = line.find( "PowerMac" )==0 || line.find( "PowerBook" )==0;
- is_ppc_pegasos = line.find( "EFIKA5K2" )==0;
- if( is_ppc_mac == 0 && is_ppc_pegasos == 0 )
- {
- line = cpu[l];
- line = extractNthWord( 3, line );
- y2mil("line:" << line);
- is_ppc_pegasos = line.find( "Pegasos" )==0;
- }
+ LvmVg* v = new LvmVg(this, *i, "/dev/" + *i, systeminfo);
+ addToList( v );
+ v->normalizeDmDevices();
+ v->checkConsistency();
+ for( LvmVg::LvmLvIter i=v->lvmLvBegin(); i!=v->lvmLvEnd(); ++i )
+ i->updateFsData();
+ ret = true;
}
}
- y2mil("Arch:" << proc_arch << " IsPPCMac:" << is_ppc_mac << " IsPPCPegasos:" << is_ppc_pegasos);
+ if( ret )
+ dumpObjectList();
+ y2mil( "ret:" << ret );
+ return( ret );
}
+ string
+ Storage::bootMount() const
+ {
+ if (archinfo.is_efiboot)
+ return "/boot/efi";
+ else
+ return "/boot";
+ }
+
+
void
-Storage::detectDisks( ProcPart& ppart )
+ Storage::detectDisks(SystemInfo& systeminfo)
{
- if( testmode() )
+ if (testmode())
{
- glob_t globbuf;
-
- if( glob( (testdir()+"/disk_*[!~0-9]").c_str(), GLOB_NOSORT, 0,
- &globbuf) == 0)
+ const list<string> l = glob(testdir() + "/disk_*.info", GLOB_NOSORT);
+ for (list<string>::const_iterator i = l.begin(); i != l.end(); ++i)
{
- for (char** p = globbuf.gl_pathv; *p != 0; *p++)
- addToList( new Disk( this, *p ) );
+ XmlFile file(*i);
+ const xmlNode* root = file.getRootElement();
+ const xmlNode* disk = getChildNode(root, "disk");
+ if (disk)
+ addToList(new Disk(this, disk));
}
- globfree (&globbuf);
}
- else if( autodetect() )
+ else if (autodetect() && getenv("LIBSTORAGE_NO_DISK") == NULL)
{
- autodetectDisks( ppart );
+ autodetectDisks(systeminfo);
}
}
-// Detect MD Partitionable Volumes.
-void Storage::detectMdParts(ProcPart& ppart)
+
+void
+Storage::detectMdParts(SystemInfo& systeminfo)
{
- if( testmode() )
+ if( testmode() )
{
- string file = testdir()+"/md";
- if( access( file.c_str(), R_OK )==0 )
- {
- y2mil("MD PART CO in test mode not available yet");
- }
}
- else
- {
- list<string> l = MdPartCo::getMdRaids();
- list<string> mdpartlist = MdPartCo::filterMdPartCo(l,ppart, instsys());
-
- if (!mdpartlist.empty())
+ else if (autodetect() && getenv("LIBSTORAGE_NO_MDPARTRAID") == NULL)
{
- map<string, list<string>> by_id;
- getUdevMap("/dev/disk/by-id", by_id);
- for( list<string>::const_iterator i = mdpartlist.begin();
- i != mdpartlist.end();
- i++)
- {
- MdPartCo * v = new MdPartCo( this, *i, &ppart );
- list<string> nm = by_id[v->name()];
- if( !nm.empty() )
- {
- v->setUdevData(nm);
- }
- addToList( v );
- }
- }
+ list<string> l = MdPartCo::getMdRaids(systeminfo);
+ list<string> mdpartlist = MdPartCo::filterMdPartCo(l, systeminfo, instsys());
+
+ for(list<string>::const_iterator i = mdpartlist.begin(); i != mdpartlist.end(); ++i)
+ {
+ MdPartCo* v = new MdPartCo(this, *i, "/dev/" + *i, systeminfo);
+ addToList( v );
+ }
}
}
-void Storage::detectMds()
+
+void Storage::detectMds(SystemInfo& systeminfo)
{
- if( testmode() )
+ if (testmode())
{
- string file = testdir()+"/md";
- if( access( file.c_str(), R_OK )==0 )
- {
- addToList( new MdCo( this, file ) );
- }
}
- else
+ else if (autodetect() && getenv("LIBSTORAGE_NO_MDRAID") == NULL)
{
- MdCo * v = new MdCo( this, true );
+ MdCo* v = new MdCo(this, systeminfo);
if( !v->isEmpty() )
addToList( v );
else
@@ -526,97 +534,45 @@
}
}
-bool Storage::discoverMdPVols()
-{
- if( !instsys() )
- {
- return false;
- }
- string mdDevs = "";
- bool ret = MdPartCo::isImsmPlatform();
- if( ret == true )
+void Storage::detectBtrfs(SystemInfo& systeminfo)
{
- y2mil("Intel SW RAID Platform detected.");
-
- list <string> l;
- if( MdPartCo::scanForRaid(l) != 0 )
- {
- MdPartCo::activate( true, tmpDir() );
- waitForDevice();
- l = MdPartCo::getMdRaids();
- MdPartCo::activate( false, "" );
- }
- if (!l.empty())
- {
- // At least ONE Volume must be detected
- mdDevs.clear();
- for( list<string>::const_iterator i=l.begin(); i!=l.end(); ++i )
- {
- mdDevs += " " + *i;
- }
- y2mil(" md raids:" + mdDevs);
- if( !mdDevs.empty())
- {
- if (getImsmDriver() == IMSM_UNDECIDED)
+ if (testmode())
{
- string txt = sformat(
- // popup text %1$s is replaced by disk name e.g. /dev/hda
- _("You are running on the Intel(R) Matrix Storage Manager compatible platform.\n"
- "\n"
- "Following MD compatible RAID devices were detected:\n"
- "%1$s\n"
- "If they are clean devices or contain partitions then you can choose to use\n"
- "MD Partitionable RAID sysbsystem to handle them. In case of clean device you\n"
- "will be able to install system on it and boot from such RAID.\n"
- "Do you want MD Partitionable RAID subsystem to manage those partitions?"
- ), mdDevs.c_str() );
-
- if( yesnoPopupCb(txt) )
- {
- ret = true;
- setImsmDriver(IMSM_MDADM);
- }
- else
- {
- ret = false;
- setImsmDriver(IMSM_DMRAID);
- }
}
- else
+ else if (autodetect() && getenv("LIBSTORAGE_NO_BTRFS") == NULL)
{
- ret = getImsmDriver() == IMSM_MDADM;
- }
+ BtrfsCo* v = new BtrfsCo(this, systeminfo);
+ if( !v->isEmpty() )
+ {
+ BtrfsCo::ConstBtrfsPair p(v->btrfsPair());
+ for( BtrfsCo::ConstBtrfsIter i=p.begin(); i!=p.end(); ++i )
+ {
+ const list<string>& devs = i->getDevices();
+ for( list<string>::const_iterator d=devs.begin(); d!=devs.end(); ++d )
+ {
+ VolIterator v;
+ if( findVolume( *d, v ))
+ {
+ v->setUsedByUuid( UB_BTRFS, i->getUuid() );
+ }
+ }
+ }
+ addToList( v );
+ }
+ else
+ delete v;
}
- else
- {
- /* No mdDevs */
- ret = false;
- }
- }
- else
- {
- /* No RAIDs at all */
- ret = false;
- }
}
- y2mil(" Exiting with status: " << ret);
- return ret;
-}
-
-void Storage::detectLoops( ProcPart& ppart )
+ void
+ Storage::detectLoops(SystemInfo& systeminfo)
{
- if( testmode() )
+ if (testmode())
{
- string file = testdir()+"/loop";
- if( access( file.c_str(), R_OK )==0 )
- {
- addToList( new LoopCo( this, file ) );
- }
}
- else
+ else if (autodetect() && getenv("LIBSTORAGE_NO_LOOP") == NULL)
{
- LoopCo * v = new LoopCo( this, true, ppart );
+ LoopCo* v = new LoopCo(this, systeminfo);
if( !v->isEmpty() )
addToList( v );
else
@@ -624,19 +580,16 @@
}
}
-void Storage::detectNfs( ProcMounts& mounts )
+
+ void
+ Storage::detectNfs(const EtcFstab& fstab, SystemInfo& systeminfo)
{
- if( testmode() )
+ if (testmode())
{
- string file = testdir()+"/nfs";
- if( access( file.c_str(), R_OK )==0 )
- {
- addToList( new NfsCo( this, file ) );
- }
}
- else if (getenv("YAST2_STORAGE_NO_NFS") == NULL)
+ else if (autodetect() && getenv("LIBSTORAGE_NO_NFS") == NULL)
{
- NfsCo * v = new NfsCo( this, mounts );
+ NfsCo* v = new NfsCo(this, fstab, systeminfo);
if( !v->isEmpty() )
addToList( v );
else
@@ -645,131 +598,102 @@
}
void
-Storage::detectLvmVgs()
+Storage::detectTmpfs(const EtcFstab& fstab, SystemInfo& systeminfo)
{
- if( testmode() )
+ if (testmode())
+ {
+ }
+ else if (autodetect() && getenv("LIBSTORAGE_NO_TMPFS") == NULL)
+ {
+ TmpfsCo* v = new TmpfsCo(this, fstab, systeminfo);
+ logCo( v );
+ if( !v->isEmpty() )
+ addToList( v );
+ else
+ delete v;
+ }
+ }
+
+void
+Storage::detectLvmVgs(SystemInfo& systeminfo)
+ {
+ if (testmode())
{
- glob_t globbuf;
- if( glob( (testdir()+"/lvm_*[!~0-9]").c_str(), GLOB_NOSORT, 0,
- &globbuf) == 0)
+ const list<string> l = glob(testdir() + "/lvmvg_*.info", GLOB_NOSORT);
+ for (list<string>::const_iterator i = l.begin(); i != l.end(); ++i)
{
- for (char** p = globbuf.gl_pathv; *p != 0; *p++)
- addToList( new LvmVg( this, *p, true ) );
+ XmlFile file(*i);
+ const xmlNode* root = file.getRootElement();
+ const xmlNode* volume_group = getChildNode(root, "volume_group");
+ if (volume_group)
+ addToList(new LvmVg(this, volume_group));
}
- globfree (&globbuf);
}
- else if( getenv( "YAST2_STORAGE_NO_LVM" )==NULL )
+ else if (autodetect() && getenv("LIBSTORAGE_NO_LVM") == NULL)
{
- list<string> l;
- LvmVg::getVgs( l );
+ const list<string> l = LvmVg::getVgs();
for( list<string>::const_iterator i=l.begin(); i!=l.end(); ++i )
{
- LvmVg * v = new LvmVg( this, *i );
- if( !v->inactive() )
- {
+ LvmVg* v = new LvmVg(this, *i, "/dev/" + *i, systeminfo);
addToList( v );
v->checkConsistency();
- }
- else
- {
- y2milestone( "inactive VG %s", i->c_str() );
- v->unuseDev();
- delete( v );
- }
}
}
}
void
-Storage::detectDmraid(ProcPart& ppart)
+ Storage::detectDmraid(SystemInfo& systeminfo)
{
- if( testmode() )
+ if (testmode())
{
- glob_t globbuf;
- if( glob( (testdir()+"/dmraid_*[!~0-9]").c_str(), GLOB_NOSORT, 0,
- &globbuf) == 0)
- {
- // TODO: load test data
- }
- globfree (&globbuf);
}
- else if( getenv( "YAST2_STORAGE_NO_DMRAID" )==NULL )
+ else if (autodetect() && getenv("LIBSTORAGE_NO_DMRAID") == NULL)
{
- const list<string> l = DmraidCo::getRaids();
- if (!l.empty())
- {
- map<string, list<string>> by_id;
- getUdevMap("/dev/disk/by-id", by_id);
+ const list<string> l = DmraidCo::getRaids(systeminfo);
for( list<string>::const_iterator i=l.begin(); i!=l.end(); ++i )
{
- DmraidCo * v = new DmraidCo( this, *i, ppart );
- list<string> nm = by_id["dm-"+decString(v->minorNr())];
- if( !nm.empty() )
- v->setUdevData( nm );
+ DmraidCo* v = new DmraidCo(this, *i, "/dev/mapper/" + *i, systeminfo);
addToList( v );
}
}
}
-}
void
-Storage::detectDmmultipath(ProcPart& ppart)
+ Storage::detectDmmultipath(SystemInfo& systeminfo)
{
- if( testmode() )
+ if (testmode())
{
- glob_t globbuf;
- if( glob( (testdir()+"/dmmultipath_*[!~0-9]").c_str(), GLOB_NOSORT, 0,
- &globbuf) == 0)
- {
- // TODO: load test data
- }
- globfree (&globbuf);
}
- else if( getenv( "YAST2_STORAGE_NO_DMMULTIPATH" )==NULL )
+ else if (autodetect() && getenv("LIBSTORAGE_NO_DMMULTIPATH") == NULL)
{
- const list<string> l = DmmultipathCo::getMultipaths();
- if (!l.empty())
- {
- map<string, list<string>> by_id;
- getUdevMap("/dev/disk/by-id", by_id);
+ const list<string> l = DmmultipathCo::getMultipaths(systeminfo);
for( list<string>::const_iterator i=l.begin(); i!=l.end(); ++i )
{
- DmmultipathCo * v = new DmmultipathCo( this, *i, ppart );
- list<string> nm = by_id["dm-"+decString(v->minorNr())];
- if (!nm.empty())
- v->setUdevData( nm );
+ DmmultipathCo* v = new DmmultipathCo(this, *i, "/dev/mapper/" + *i, systeminfo);
addToList( v );
}
}
}
-}
void
-Storage::detectDm(ProcPart& ppart, bool only_crypt)
+ Storage::detectDm(SystemInfo& systeminfo, bool only_crypt)
{
- if( testmode() )
+ if (testmode())
{
- glob_t globbuf;
- if( glob( (testdir()+"/dm_*[!~0-9]").c_str(), GLOB_NOSORT, 0,
- &globbuf) == 0)
- {
- // TODO: load test data
- }
- globfree (&globbuf);
}
- else if( getenv( "YAST2_STORAGE_NO_DM" )==NULL )
+ else if (autodetect() && getenv("LIBSTORAGE_NO_DM") == NULL)
{
DmCo* v = NULL;
if (haveDm(v))
{
- v->second(true, ppart, only_crypt);
+ v->second(systeminfo, only_crypt);
}
else
{
- v = new DmCo(this, true, ppart, only_crypt);
+ v = new DmCo(this, systeminfo, only_crypt);
if (!v->isEmpty() )
{
addToList( v );
@@ -781,14 +705,12 @@
}
}
-namespace storage
-{
+
struct DiskData
{
enum DTyp { DISK, DASD, XEN };
- DiskData() { d=0; s=0; typ=DISK; };
- DiskData( const string& n, DTyp t, unsigned long long sz ) { d=0; s=sz; typ=t; name=n; };
+ DiskData( const string& n, DTyp t, unsigned long long sz ) : d(NULL) { s=sz; typ=t; name=n; }
Disk* d;
DTyp typ;
@@ -797,6 +719,7 @@
string dev;
};
+
std::ostream& operator<< ( std::ostream& s, const storage::DiskData& d )
{
s << d.name << "," << d.typ << "," << d.s << "," << d.d;
@@ -804,34 +727,25 @@
s << "," << d.dev;
return( s );
}
-}
void
-Storage::initDisk( list<DiskData>& dl, ProcPart& pp )
+Storage::initDisk(list<DiskData>& dl, SystemInfo& systeminfo)
{
y2mil( "dl: " << dl );
for( list<DiskData>::iterator i = dl.begin(); i!=dl.end(); ++i )
{
DiskData& data( *i );
- y2mil( "data:" << data );
- data.dev = data.name;
- string::size_type pos = data.dev.find('!');
- while( pos!=string::npos )
- {
- data.dev[pos] = '/';
- pos = data.dev.find('!',pos+1);
- }
- y2milestone( "name sysfs:%s parted:%s", data.name.c_str(),
- data.dev.c_str() );
+ data.dev = boost::replace_all_copy(data.name, "!", "/");
+ y2mil("name sysfs:" << data.name << " parted:" << data.dev);
Disk * d = NULL;
switch( data.typ )
{
case DiskData::DISK:
- d = new Disk( this, data.dev, data.s );
+ d = new Disk(this, data.dev, "/dev/" + data.dev, data.s, systeminfo);
break;
case DiskData::DASD:
- d = new Dasd( this, data.dev, data.s );
+ d = new Dasd(this, data.dev, "/dev/" + data.dev, data.s, systeminfo);
break;
case DiskData::XEN:
{
@@ -842,44 +756,39 @@
y2mil( "data dev:" << data.dev << " nr:" << nr );
if( nr>=0 )
{
- list<DiskData>::iterator j = dl.begin();
+ list<DiskData>::iterator j = dl.begin();
while( j!=dl.end() && j->dev!=data.dev )
++j;
if( j!=dl.end() && j->d )
- j->d->addPartition( (unsigned)nr, data.s, pp );
+ j->d->addPartition( (unsigned)nr, data.s, systeminfo );
else
- d = new Disk( this, data.dev, (unsigned)nr, data.s, pp );
+ d = new Disk(this, data.dev, "/dev/" + data.dev, (unsigned) nr, data.s, systeminfo);
}
break;
}
}
if( d &&
- (d->getSysfsInfo(SYSFSDIR "/" + data.name)||data.typ==DiskData::XEN) &&
- (data.typ==DiskData::XEN||d->detect(pp)))
+ (d->getSysfsInfo()||data.typ==DiskData::XEN) &&
+ (data.typ == DiskData::XEN || d->detect(systeminfo)))
{
- if( max_log_num>0 )
- d->logData( logdir() );
data.d = d;
}
- else if( d )
+ else
{
delete d;
}
}
+ y2mil( "dl: " << dl );
}
void
- Storage::autodetectDisks(ProcPart& parts)
+ Storage::autodetectDisks(SystemInfo& systeminfo)
{
DIR *Dir;
struct dirent *Entry;
if( (Dir=opendir(SYSFSDIR))!=NULL )
{
- map<string,list<string>> by_path;
- map<string,list<string>> by_id;
- getUdevMap("/dev/disk/by-path", by_path);
- getUdevMap("/dev/disk/by-id", by_id);
list<DiskData> dl;
while( (Entry=readdir( Dir ))!=NULL )
{
@@ -888,20 +797,14 @@
if (dn == "." || dn == "..")
continue;
- // Do not allow to detect MD Device as 'disk'
- if( MdPartCo::isMdName(dn) )
- {
- continue;
- }
+ // we do not treat mds as disks although they can be partitioned since kernel 2.6.28
+ if (boost::starts_with(dn, "md"))
+ continue;
Disk::SysfsInfo sysfsinfo;
if (!Disk::getSysfsInfo(SYSFSDIR "/" + dn, sysfsinfo))
continue;
- // we do not treat mds as disks although they can be partitioned since kernel 2.6.28
- if (boost::starts_with(dn, "md"))
- continue;
-
if (sysfsinfo.range > 1 && (sysfsinfo.size > 0 || dn.find("dasd") == 0))
{
DiskData::DTyp t = (dn.find("dasd") == 0) ? DiskData::DASD : DiskData::DISK;
@@ -909,26 +812,27 @@
}
else if (sysfsinfo.range == 1 && sysfsinfo.size > 0)
{
- if (sysfsinfo.device.find( "/vbd" ) != string::npos && isdigit(dn[dn.size() - 1]))
+ if (sysfsinfo.vbd)
{
dl.push_back(DiskData(dn, DiskData::XEN, sysfsinfo.size / 2));
}
}
}
closedir( Dir );
- initDisk(dl, parts);
- y2mil( "dl: " << dl );
+ initDisk(dl, systeminfo);
+ const UdevMap& by_path = systeminfo.getUdevMap("/dev/disk/by-path");
+ const UdevMap& by_id = systeminfo.getUdevMap("/dev/disk/by-id");
for( list<DiskData>::const_iterator i = dl.begin(); i!=dl.end(); ++i )
{
if( i->d )
{
string tmp1;
- map<string, list<string>>::const_iterator it1 = by_path.find(i->dev);
+ UdevMap::const_iterator it1 = by_path.find(i->dev);
if (it1 != by_path.end())
tmp1 = it1->second.front();
list<string> tmp2;
- map<string, list<string>>::const_iterator it2 = by_id.find(i->dev);
+ UdevMap::const_iterator it2 = by_id.find(i->dev);
if (it2 != by_id.end())
tmp2 = it2->second;
@@ -944,117 +848,87 @@
}
-void
-Storage::detectFsData( const VolIterator& begin, const VolIterator& end,
- ProcMounts& mounts )
+ void
+ Storage::detectFsData(const VolIterator& begin, const VolIterator& end, SystemInfo& systeminfo)
{
- y2milestone( "detectFsData begin" );
- SystemCmd Blkid( "BLKID_SKIP_CHECK_MDRAID=1 /sbin/blkid -c /dev/null" );
+ y2mil("detectFsData begin");
SystemCmd Losetup(LOSETUPBIN " -a");
for( VolIterator i=begin; i!=end; ++i )
{
- if( i->getUsedByType()==UB_NONE )
+ if (!i->isUsedBy())
{
i->getLoopData( Losetup );
- i->getFsData( Blkid );
+ i->getFsData(systeminfo.getBlkid());
y2mil( "detect:" << *i );
}
}
for( VolIterator i=begin; i!=end; ++i )
{
- if( i->getUsedByType()==UB_NONE )
+ if (!i->isUsedBy())
{
- i->getMountData( mounts, !detectMounted );
+ i->getMountData(systeminfo.getProcMounts(), !detectMounted);
i->getFstabData( *fstab );
y2mil( "detect:" << *i );
if( i->getFs()==FSUNKNOWN && i->getEncryption()==ENC_NONE )
- i->getStartData();
- }
- }
- if( max_log_num>0 )
- logVolumes( logdir() );
- y2milestone( "detectFsData end" );
- }
-
-void
-Storage::printInfo( ostream& str, const string& name )
- {
- assertInit();
- ConstContPair p = contPair();
- string n = DmPartCo::undevName(name);
- for( ConstContIterator i=p.begin(); i!=p.end(); ++i )
- {
- if( name.empty() || i->name()==n )
- {
- Container::ConstVolPair vp = i->volPair();
- i->print( str );
- str << endl;
- for( Container::ConstVolIterator j=vp.begin(); j!=vp.end(); ++j )
{
- j->print( str );
- str << endl;
+ Blkid::Entry e;
+ if( i->findBlkid( systeminfo.getBlkid(), e ) && e.is_luks)
+ i->initEncryption(ENC_LUKS);
}
}
}
+ y2mil("detectFsData end");
}
void
-Storage::detectFsDataTestMode( const string& file, const VolIterator& begin,
- const VolIterator& end )
+Storage::printInfo(ostream& str) const
+{
+ ConstContPair p = contPair();
+ for (ConstContIterator i = p.begin(); i != p.end(); ++i)
{
- AsciiFile vd( file );
- for( VolIterator i=begin; i!=end; ++i )
+ i->print(str);
+ str << endl;
+
+ Container::ConstVolPair vp = i->volPair();
+ for (Container::ConstVolIterator j = vp.begin(); j != vp.end(); ++j)
{
- int pos = -1;
- if( (pos=vd.find( 0, "^"+i->device()+" " ))>=0 )
- {
- i->getTestmodeData( vd[pos] );
- }
- i->getFstabData( *fstab );
+ j->print(str);
+ str << endl;
}
}
+}
-void
-Storage::logVolumes( const string& Dir )
+
+ void
+ Storage::logContainersAndVolumes(const string& Dir) const
{
- string fname( Dir + "/volume_info.tmp" );
- ofstream file( fname.c_str() );
- classic(file);
- for( VolIterator i=vBegin(); i!=vEnd(); ++i )
+ if (max_log_num > 0)
{
- if( i->getFs()!=FSUNKNOWN )
- {
- i->logVolume( file );
- }
+ for (CCIter i = cont.begin(); i != cont.end(); ++i)
+ (*i)->logData(Dir);
+
+ logFreeInfo(Dir);
+ logArchInfo(Dir);
}
- file.close();
- handleLogFile( fname );
}
+
bool
-Storage::testFilesEqual( const string& n1, const string& n2 )
- {
+Storage::testFilesEqual(const string& n1, const string& n2)
+{
bool ret = false;
- if( access( n1.c_str(), R_OK )==0 && access( n2.c_str(), R_OK )==0 )
- {
- SystemCmd c("/usr/bin/md5sum " + quote(n1) + " " + quote(n2));
- if( c.retcode()==0 && c.numLines()>=2 )
- {
- ret = extractNthWord( 0, *c.getLine(0) )==
- extractNthWord( 0, *c.getLine(1) );
- }
- }
- y2mil("ret:" << ret << "n1:" << n1 << " n2:" << n2);
+ if (access(n1.c_str(), R_OK) == 0 && access(n2.c_str(), R_OK) == 0)
+ ret = AsciiFile(n1).lines() == AsciiFile(n2).lines();
+ y2deb("ret:" << ret << " n1:" << n1 << " n2:" << n2);
return ret;
- }
+}
+
void
-Storage::handleLogFile( const string& name )
+Storage::handleLogFile(const string& name) const
{
- string bname( name );
- string::size_type pos = bname.rfind( '.' );
- bname.erase( pos );
- y2milestone( "name:%s bname:%s", name.c_str(), bname.c_str() );
+ string bname(name, 0, name.rfind('.'));
+ y2mil("name:" << name << " bname:" << bname);
if( access( bname.c_str(), R_OK )==0 )
{
if( !testFilesEqual( bname, name ) )
@@ -1082,98 +956,210 @@
rename( name.c_str(), bname.c_str() );
}
-void Storage::setRecursiveRemoval( bool val )
- {
- y2milestone( "val:%d", val );
+
+void Storage::setRecursiveRemoval(bool val)
+{
+ y2mil("val:" << val);
recursiveRemove = val;
- }
+}
+
+
+int
+Storage::getRecursiveUsing(const string& device, list<string>& devices)
+{
+ y2mil("device:" << device);
+ assertInit();
+ devices.clear();
+ int ret = getRecursiveUsingHelper(device, devices);
+ y2mil("ret:" << ret << " devices:" << devices);
+ return ret;
+}
-void Storage::setZeroNewPartitions( bool val )
+
+int
+Storage::getRecursiveUsingHelper(const string& device, list<string>& devices)
{
- y2milestone( "val:%d", val );
- zeroNewPartitions = val;
+ int ret = 0;
+ ConstContIterator cont;
+ ConstVolIterator vol;
+
+ if (findContainer(device, cont))
+ {
+ Container::ConstVolPair p = cont->volPair(Volume::notDeleted);
+ for( Container::ConstVolIterator it = p.begin(); it != p.end(); ++it )
+ {
+ addIfNotThere( devices, it->device() );
+ getRecursiveUsingHelper(it->device(), devices);
+ }
+
+ if (cont->isUsedBy())
+ {
+ const list<UsedBy> usedBy = cont->getUsedBy();
+ for( list<UsedBy>::const_iterator it = usedBy.begin();
+ it != usedBy.end(); ++it)
+ {
+ addIfNotThere( devices, it->device() );
+ getRecursiveUsingHelper(it->device(), devices);
+ }
+ }
+ }
+ else if (findVolume(device, vol))
+ {
+ if (vol->isUsedBy())
+ {
+ const list<UsedBy> usedBy = vol->getUsedBy();
+ for( list<UsedBy>::const_iterator it = usedBy.begin();
+ it != usedBy.end(); ++it)
+ {
+ addIfNotThere( devices, it->device() );
+ getRecursiveUsingHelper(it->device(), devices);
+ }
+ }
+ CType typ = vol->cType();
+ list<string> dl;
+ switch( typ )
+ {
+ default:
+ break;
+ case DISK:
+ {
+ const Partition* p = dynamic_cast<const Partition*>(&(*vol));
+ if( p!=NULL && p->type()==EXTENDED )
+ {
+ const Disk* d = p->disk();
+ Disk::ConstPartPair pp = d->partPair(Partition::notDeleted);
+ for( Disk::ConstPartIter i=pp.begin(); i!=pp.end(); ++i )
+ {
+ if( i->type()==LOGICAL )
+ dl.push_back(i->device());
+ }
+ }
+ }
+ break;
+ case DMRAID:
+ case DMMULTIPATH:
+ {
+ const DmPart* dp = dynamic_cast<const DmPart*>(&(*vol));
+ const Partition* p = dp!=NULL ? dp->getPtr() : NULL;
+ if( p!=NULL && p->type()==EXTENDED )
+ {
+ const Container* co = vol->getContainer();
+ const DmPartCo* d = dynamic_cast<const DmPartCo *>(co);
+ if( d!=NULL )
+ {
+ DmPartCo::ConstDmPartPair pp = d->dmpartPair(DmPart::notDeleted);
+ for( DmPartCo::ConstDmPartIter i=pp.begin(); i!=pp.end(); ++i )
+ {
+ p = i->getPtr();
+ if( p!=NULL && p->type()==LOGICAL )
+ dl.push_back(i->device());
+ }
+ }
+ }
+ }
+ break;
+ case MDPART:
+ {
+ const MdPart* dp = dynamic_cast<const MdPart*>(&(*vol));
+ const Partition* p = dp!=NULL ? dp->getPtr() : NULL;
+ if( p!=NULL && p->type()==EXTENDED )
+ {
+ const Container* co = vol->getContainer();
+ const MdPartCo* d = dynamic_cast<const MdPartCo *>(co);
+ if( d!=NULL )
+ {
+ MdPartCo::ConstMdPartPair pp = d->mdpartPair(MdPart::notDeleted);
+ for( MdPartCo::ConstMdPartIter i=pp.begin(); i!=pp.end(); ++i )
+ {
+ p = i->getPtr();
+ if( p!=NULL && p->type()==LOGICAL )
+ dl.push_back(i->device());
+ }
+ }
+ }
+ }
+ break;
+ }
+ for( list<string>::const_iterator i = dl.begin(); i != dl.end(); ++i )
+ {
+ addIfNotThere( devices, *i );
+ getRecursiveUsingHelper(*i, devices);
+ }
+ }
+ else
+ {
+ ret = STORAGE_DEVICE_NOT_FOUND;
+ }
+ return ret;
}
-void Storage::setPartitionAlignment( PartAlign val )
- {
+
+void Storage::setZeroNewPartitions(bool val)
+{
y2mil("val:" << val);
- partAlignment = val;
- }
+ zeroNewPartitions = val;
+}
-void Storage::setDefaultMountBy( MountByType val )
+void Storage::setPartitionAlignment( PartAlign val )
{
- y2mil( "val:" << Volume::mbyTypeString(val) );
- defaultMountBy = val;
+ y2mil("val:" << toString(val));
+ partAlignment = val;
}
-
-void
-Storage::setEfiBoot(bool val)
+void Storage::setDefaultMountBy(MountByType val)
{
- assertInit();
- y2mil("val:" << val);
- efiboot = val;
+ y2mil("val:" << toString(val));
+ defaultMountBy = val;
}
-bool
-Storage::getEfiBoot()
+
+void Storage::setDefaultFs(FsType val)
{
- assertInit();
- return efiboot;
+ y2mil("val:" << toString(val));
+ defaultFs = val;
}
-void Storage::setRootPrefix( const string& root )
+ bool
+ Storage::getEfiBoot()
{
- y2milestone( "root:%s", root.c_str() );
- rootprefix = root;
+ assertInit();
+ return archinfo.is_efiboot;
}
-string Storage::prependRoot(const string& mp) const
-{
- string ret = mp;
- if (mp != "swap")
- ret.insert(0, rootprefix);
- return ret;
-}
-void Storage::setDetectMountedVolumes( bool val )
+ bool
+ Storage::hasIScsiDisks() const
{
- y2milestone( "val:%d", val );
- detectMounted = val;
+ ConstDiskPair dp = diskPair(Disk::isIScsi);
+ bool ret = !dp.empty();
+ y2mil("ret:" << ret);
+ return ret;
}
-string Storage::proc_arch;
-bool Storage::is_ppc_mac = false;
-bool Storage::is_ppc_pegasos = false;
-
-bool
-Storage::hasIScsiDisks() const
+void Storage::setRootPrefix(const string& root)
{
- bool ret = false;
+ y2mil("root:" << root);
+ rootprefix = root;
+}
- ConstDiskPair dp = diskPair();
- for (ConstDiskIterator i = dp.begin(); i != dp.end(); ++i)
- {
- if (i->isIScsi())
- {
- ret = true;
- break;
- }
- }
+string Storage::prependRoot(const string& mp) const
+{
+ if (mp == "swap")
+ return mp;
- y2mil("ret:" << ret);
- return ret;
+ if (rootprefix != "" && mp == "/")
+ return rootprefix;
+ else
+ return rootprefix + mp;
}
-
-namespace storage
+void Storage::setDetectMountedVolumes(bool val)
{
- void initDefaultLogger ()
- {
- Storage::initDefaultLogger ();
- }
+ y2mil("val:" << val);
+ detectMounted = val;
+}
StorageInterface* createStorageInterface(const Environment& env)
@@ -1198,7 +1184,6 @@
{
delete p;
}
-}
int
@@ -1208,9 +1193,8 @@
int ret = 0;
bool done = false;
assertInit();
- y2milestone( "disk:%s type:%d start:%ld size:%ld", disk.c_str(),
- type, start, size );
- if( readonly() )
+ y2mil("disk:" << disk << " type:" << toString(type) << " start:" << start << " size:" << size);
+ if (readonly())
{
ret = STORAGE_CHANGE_READONLY;
}
@@ -1220,7 +1204,7 @@
if( i != dEnd() )
{
done = true;
- if( i->getUsedByType() != UB_NONE )
+ if (i->isUsedBy())
ret = STORAGE_DISK_USED_BY;
else
{
@@ -1236,7 +1220,7 @@
if( i != dmpCoEnd() )
{
done = true;
- if( i->getUsedByType() != UB_NONE )
+ if (i->isUsedBy())
ret = STORAGE_DISK_USED_BY;
else
{
@@ -1252,11 +1236,13 @@
if( i != mdpCoEnd() )
{
done = true;
- if( i->getUsedByType() != UB_NONE )
+ if (i->isUsedBy())
ret = STORAGE_DISK_USED_BY;
else
{
ret = i->createPartition( type, start, size, device, true );
+ if( ret==0 )
+ checkPwdBuf( device );
}
}
}
@@ -1268,7 +1254,7 @@
{
ret = checkCache();
}
- y2milestone( "ret:%d device:%s", ret, ret?"":device.c_str() );
+ y2mil("ret:" << ret << " device:" << (ret?"":device));
return( ret );
}
@@ -1280,9 +1266,9 @@
int ret = 0;
bool done = false;
assertInit();
- y2milestone( "disk:%s type:%d start:%lld sizeK:%lld", disk.c_str(),
- type, start, sizeK );
- if( readonly() )
+ y2mil("disk:" << disk << " type:" << toString(type) << " start:" << start << " sizeK:" <<
+ sizeK);
+ if (readonly())
{
ret = STORAGE_CHANGE_READONLY;
}
@@ -1292,7 +1278,7 @@
if( i != dEnd() )
{
done = true;
- if( i->getUsedByType() != UB_NONE )
+ if (i->isUsedBy())
ret = STORAGE_DISK_USED_BY;
else
{
@@ -1313,7 +1299,7 @@
if( i != dmpCoEnd() )
{
done = true;
- if( i->getUsedByType() != UB_NONE )
+ if (i->isUsedBy())
ret = STORAGE_DISK_USED_BY;
else
{
@@ -1334,7 +1320,7 @@
if( i != mdpCoEnd() )
{
done = true;
- if( i->getUsedByType() != UB_NONE )
+ if (i->isUsedBy())
ret = STORAGE_DISK_USED_BY;
else
{
@@ -1353,7 +1339,7 @@
{
ret = STORAGE_DISK_NOT_FOUND;
}
- y2milestone( "ret:%d device:%s", ret, ret?"":device.c_str() );
+ y2mil("ret:" << ret << " device:" << (ret?"":device));
return( ret );
}
@@ -1364,8 +1350,8 @@
int ret = 0;
bool done = false;
assertInit();
- y2milestone( "disk:%s sizeK:%lld", disk.c_str(), sizeK );
- if( readonly() )
+ y2mil("disk:" << disk << " sizeK:" << sizeK);
+ if (readonly())
{
ret = STORAGE_CHANGE_READONLY;
}
@@ -1375,7 +1361,7 @@
if( i != dEnd() )
{
done = true;
- if( i->getUsedByType() != UB_NONE )
+ if (i->isUsedBy())
ret = STORAGE_DISK_USED_BY;
else
{
@@ -1390,7 +1376,7 @@
if( i != dmpCoEnd() )
{
done = true;
- if( i->getUsedByType() != UB_NONE )
+ if (i->isUsedBy())
ret = STORAGE_DISK_USED_BY;
else
{
@@ -1405,7 +1391,7 @@
if( i != mdpCoEnd() )
{
done = true;
- if( i->getUsedByType() != UB_NONE )
+ if (i->isUsedBy())
ret = STORAGE_DISK_USED_BY;
else
{
@@ -1418,7 +1404,7 @@
{
ret = STORAGE_DISK_NOT_FOUND;
}
- y2milestone( "ret:%d device:%s", ret, ret?"":device.c_str() );
+ y2mil("ret:" << ret << " device:" << (ret?"":device));
return( ret );
}
@@ -1429,8 +1415,8 @@
int ret = 0;
bool done = false;
assertInit();
- y2milestone( "disk:%s type:%u", disk.c_str(), type );
- DiskIterator i = findDisk( disk );
+ y2mil("disk:" << disk << " type:" << toString(type));
+ ConstDiskIterator i = findDisk( disk );
if( i != dEnd() )
{
done = true;
@@ -1438,7 +1424,7 @@
}
if( !done )
{
- DmPartCoIterator i = findDmPartCo( disk );
+ ConstDmPartCoIterator i = findDmPartCo( disk );
if( i != dmpCoEnd() )
{
done = true;
@@ -1447,7 +1433,7 @@
}
if( !done )
{
- MdPartCoIterator i = findMdPartCo( disk );
+ ConstMdPartCoIterator i = findMdPartCo( disk );
if( i != mdpCoEnd() )
{
done = true;
@@ -1458,7 +1444,7 @@
{
ret = STORAGE_DISK_NOT_FOUND;
}
- y2milestone( "ret:%d device:%s", ret, ret?"":device.c_str() );
+ y2mil("ret:" << ret << " device:" << (ret?"":device));
return( ret );
}
@@ -1469,9 +1455,9 @@
int ret = 0;
bool done = false;
assertInit();
- y2milestone( "disk:%s type:%u", disk.c_str(), type );
+ y2mil("disk:" << disk << " type:" << toString(type));
DiskIterator i = findDisk( disk );
- if( readonly() )
+ if (readonly())
{
ret = STORAGE_CHANGE_READONLY;
}
@@ -1481,7 +1467,7 @@
if( i != dEnd() )
{
done = true;
- if( i->getUsedByType() != UB_NONE )
+ if (i->isUsedBy())
ret = STORAGE_DISK_USED_BY;
else
{
@@ -1495,7 +1481,7 @@
if( i != dmpCoEnd() )
{
done = true;
- if( i->getUsedByType() != UB_NONE )
+ if (i->isUsedBy())
ret = STORAGE_DISK_USED_BY;
else
{
@@ -1509,7 +1495,7 @@
if( i != mdpCoEnd() )
{
done = true;
- if( i->getUsedByType() != UB_NONE )
+ if (i->isUsedBy())
ret = STORAGE_DISK_USED_BY;
else
{
@@ -1521,7 +1507,7 @@
{
ret = STORAGE_DISK_NOT_FOUND;
}
- y2milestone( "ret:%d device:%s", ret, ret?"":device.c_str() );
+ y2mil("ret:" << ret << " device:" << (ret?"":device));
return( ret );
}
@@ -1531,8 +1517,8 @@
unsigned long long ret = 0;
bool done = false;
assertInit();
- y2milestone( "disk:%s size:%ld", disk.c_str(), size );
- DiskIterator i = findDisk( disk );
+ y2mil("disk:" << disk << " size:" << size);
+ ConstDiskIterator i = findDisk( disk );
if( i != dEnd() )
{
done = true;
@@ -1540,7 +1526,7 @@
}
if( !done )
{
- DmPartCoIterator i = findDmPartCo( disk );
+ ConstDmPartCoIterator i = findDmPartCo( disk );
if( i != dmpCoEnd() )
{
done = true;
@@ -1548,15 +1534,15 @@
}
}
if( !done )
- {
- MdPartCoIterator i = findMdPartCo( disk );
+ {
+ ConstMdPartCoIterator i = findMdPartCo( disk );
if( i != mdpCoEnd() )
- {
+ {
done = true;
ret = i->cylinderToKb( size );
- }
- }
- y2milestone( "ret:%lld", ret );
+ }
+ }
+ y2mil("ret:" << ret);
return( ret );
}
@@ -1566,8 +1552,8 @@
unsigned long ret = 0;
bool done = false;
assertInit();
- y2milestone( "disk:%s sizeK:%lld", disk.c_str(), sizeK );
- DiskIterator i = findDisk( disk );
+ y2mil("disk:" << disk << " sizeK:" << sizeK);
+ ConstDiskIterator i = findDisk( disk );
if( i != dEnd() )
{
done = true;
@@ -1575,7 +1561,7 @@
}
if( !done )
{
- DmPartCoIterator i = findDmPartCo( disk );
+ ConstDmPartCoIterator i = findDmPartCo( disk );
if( i != dmpCoEnd() )
{
done = true;
@@ -1583,16 +1569,15 @@
}
}
if( !done )
- {
- MdPartCoIterator i = findMdPartCo( disk );
+ {
+ ConstMdPartCoIterator i = findMdPartCo( disk );
if( i != mdpCoEnd() )
- {
+ {
done = true;
ret = i->kbToCylinder( sizeK );
- }
- }
-
- y2milestone( "ret:%ld", ret );
+ }
+ }
+ y2mil("ret:" << ret);
return( ret );
}
@@ -1601,23 +1586,23 @@
{
int ret = 0;
assertInit();
- y2milestone( "partition:%s", partition.c_str() );
+ y2mil("partition:" << partition);
VolIterator vol;
ContIterator cont;
- if( readonly() )
+ if (readonly())
{
ret = STORAGE_CHANGE_READONLY;
}
- else if( findVolume( partition, cont, vol ) )
+ else if( findVolume( partition, cont, vol, true ) )
{
if( cont->type()==DISK )
{
Disk* disk = dynamic_cast<Disk *>(&(*cont));
if( disk!=NULL )
{
- if( vol->getUsedByType() == UB_NONE || recursiveRemove )
+ if( canRemove( *vol ) )
{
- if( vol->getUsedByType() != UB_NONE )
+ if (vol->isUsedBy())
ret = removeUsing( vol->device(), vol->getUsedBy() );
if( ret==0 )
ret = disk->removePartition( vol->nr() );
@@ -1635,9 +1620,9 @@
DmPartCo* disk = dynamic_cast<DmPartCo *>(&(*cont));
if( disk!=NULL )
{
- if( vol->getUsedByType() == UB_NONE || recursiveRemove )
+ if( canRemove( *vol ) )
{
- if( vol->getUsedByType() != UB_NONE )
+ if (vol->isUsedBy())
ret = removeUsing( vol->device(), vol->getUsedBy() );
if( ret==0 )
ret = disk->removePartition( vol->nr() );
@@ -1655,9 +1640,9 @@
MdPartCo* disk = dynamic_cast<MdPartCo *>(&(*cont));
if( disk != NULL)
{
- if( vol->getUsedByType() == UB_NONE || recursiveRemove )
+ if( canRemove( *vol ) )
{
- if( vol->getUsedByType() != UB_NONE )
+ if( vol->isUsedBy())
ret = removeUsing( vol->device(), vol->getUsedBy() );
if( ret==0 )
{
@@ -1695,11 +1680,10 @@
{
int ret = 0;
assertInit();
- y2milestone( "partition:%s start:%ld size:%ld", partition.c_str(),
- start, size );
+ y2mil("partition:" << partition << " start:" << start << " size:" << size);
VolIterator vol;
ContIterator cont;
- if( readonly() )
+ if (readonly())
{
ret = STORAGE_CHANGE_READONLY;
}
@@ -1710,7 +1694,7 @@
Disk* disk = dynamic_cast<Disk *>(&(*cont));
if( disk!=NULL )
{
- ret = disk->changePartitionArea( vol->nr(), start, size );
+ ret = disk->changePartitionArea(vol->nr(), Region(start, size));
}
else
{
@@ -1722,7 +1706,7 @@
DmPartCo* disk = dynamic_cast<DmPartCo *>(&(*cont));
if( disk!=NULL )
{
- ret = disk->changePartitionArea( vol->nr(), start, size );
+ ret = disk->changePartitionArea(vol->nr(), Region(start, size));
}
else
{
@@ -1734,7 +1718,7 @@
MdPartCo* disk = dynamic_cast<MdPartCo *>(&(*cont));
if( disk!=NULL )
{
- ret = disk->changePartitionArea( vol->nr(), start, size );
+ ret = disk->changePartitionArea(vol->nr(), Region(start, size));
}
else
{
@@ -1766,8 +1750,8 @@
int ret = 0;
assertInit();
y2mil("partition:" << partition);
- VolIterator vol;
- ContIterator cont;
+ ConstVolIterator vol;
+ ConstContIterator cont;
if( findVolume( partition, cont, vol ) )
{
if( cont->type()==DISK )
@@ -1828,10 +1812,10 @@
{
int ret = 0;
assertInit();
- y2milestone( "partition:%s id:%x", partition.c_str(), id );
+ y2mil("partition:" << partition << " id:" << hex << id);
VolIterator vol;
ContIterator cont;
- if( readonly() )
+ if (readonly())
{
ret = STORAGE_CHANGE_READONLY;
}
@@ -1908,11 +1892,10 @@
{
int ret = 0;
assertInit();
- y2milestone( "partition:%s newCyl:%lu ignoreFs:%d", partition.c_str(),
- sizeCyl, ignoreFs );
+ y2mil("partition:" << partition << " newCyl:" << sizeCyl << " ignoreFs:" << ignoreFs);
VolIterator vol;
ContIterator cont;
- if( readonly() )
+ if (readonly())
{
ret = STORAGE_CHANGE_READONLY;
}
@@ -1985,10 +1968,10 @@
{
int ret = 0;
assertInit();
- y2milestone( "partition:%s", partition.c_str() );
+ y2mil("partition:" << partition);
VolIterator vol;
ContIterator cont;
- if( readonly() )
+ if (readonly())
{
ret = STORAGE_CHANGE_READONLY;
}
@@ -2049,6 +2032,20 @@
}
+ string
+ Storage::getPartitionPrefix(const string& disk)
+ {
+ return Disk::partNaming(disk);
+ }
+
+
+ string
+ Storage::getPartitionName(const string& disk, int partition_no)
+ {
+ return disk + Disk::partNaming(disk) + decString(partition_no);
+ }
+
+
int
Storage::getUnusedPartitionSlots(const string& disk, list<PartitionSlotInfo>& slots)
{
@@ -2058,9 +2055,9 @@
// TODO: don't have code below twice
- DiskIterator i1 = findDisk( disk );
- DmPartCoIterator i2 = findDmPartCo( disk );
- MdPartCoIterator i3 = findMdPartCo( disk );
+ ConstDiskIterator i1 = findDisk( disk );
+ ConstDmPartCoIterator i2 = findDmPartCo( disk );
+ ConstMdPartCoIterator i3 = findMdPartCo( disk );
if (i1 != dEnd())
{
@@ -2200,9 +2197,9 @@
int ret = 0;
bool done = false;
assertInit();
- y2milestone( "disk:%s label:%s", disk.c_str(), label.c_str() );
+ y2mil("disk:" << disk << " label:" << label);
- if( readonly() )
+ if (readonly())
{
ret = STORAGE_CHANGE_READONLY;
}
@@ -2251,9 +2248,9 @@
int ret = 0;
bool done = false;
assertInit();
- y2milestone( "disk:%s value:%d", disk.c_str(), value );
+ y2mil("disk:" << disk << " value:" << value);
- if( readonly() )
+ if (readonly())
{
ret = STORAGE_CHANGE_READONLY;
}
@@ -2302,21 +2299,19 @@
{
assertInit();
- unsigned long long num_sectors = 0;
-
- DiskIterator i1 = findDisk(device);
+ ConstDiskIterator i1 = findDisk(device);
if (i1 != dEnd())
- num_sectors = i1->kbToSector(i1->size_k);
+ return i1->defaultLabel();
- DmPartCoIterator i2 = findDmPartCo(device);
+ ConstDmPartCoIterator i2 = findDmPartCo(device);
if (i2 != dmpCoEnd())
- num_sectors = i2->disk->kbToSector(i2->size_k);
+ return i2->disk->defaultLabel();
- MdPartCoIterator i3 = findMdPartCo(device);
+ ConstMdPartCoIterator i3 = findMdPartCo(device);
if (i3 != mdpCoEnd())
- num_sectors = i3->disk->kbToSector(i3->size_k);
+ return i3->disk->defaultLabel();
- return Disk::defaultLabel(efiBoot(), num_sectors);
+ return ""; // FIXME
}
@@ -2325,17 +2320,58 @@
{
int ret = 0;
assertInit();
- y2milestone( "device:%s format:%d type:%s", device.c_str(), format,
- Volume::fsTypeString(fs).c_str() );
+ y2mil("device:" << device << " format:" << format << " fs_type:" << toString(fs));
VolIterator vol;
- ContIterator cont;
- if( readonly() )
+ if (readonly())
{
ret = STORAGE_CHANGE_READONLY;
}
- else if( findVolume( device, cont, vol ) )
+ else if( findVolume( device, vol ) )
{
- ret = vol->setFormat( format, fs );
+ BtrfsCo *co = NULL;
+ FsType tmpfs = format?fs:vol->detectedFs();
+ y2mil( "tmpfs:" << tmpfs << " fs:" << fs << " det:" << vol->detectedFs() );
+ y2mil( "ctype:" << vol->cType() << " BTRFS:" << BTRFSC );
+
+ if( (tmpfs==BTRFS && vol->cType()==BTRFSC) ||
+ (tmpfs!=BTRFS && vol->cType()!=BTRFSC) )
+ ret = vol->setFormat( format, fs );
+ else if( tmpfs==BTRFS )
+ {
+ // put volume to format into BTRFS-Container and set used by on plain volume
+ bool have_co = haveBtrfs(co);
+ if( !have_co )
+ co = new BtrfsCo(this);
+ if( co==NULL )
+ ret = STORAGE_MEMORY_EXHAUSTED;
+ if( ret==0 )
+ {
+ ret = vol->setFormat( format, fs );
+ if( ret==0 )
+ {
+ co->addFromVolume( *vol );
+ vol->setUsedByUuid( UB_BTRFS, "12345" );
+ }
+ }
+ }
+ else if( tmpfs!=BTRFS )
+ {
+ // remove volume from BTRFS-Container and unset used by on plain volume
+ if(haveBtrfs(co))
+ {
+ string mp = vol->getMount();
+ co->eraseVolume( &(*vol) );
+ if( findVolume( device, vol ) && vol->cType()!=BTRFSC )
+ {
+ vol->updateFsData();
+ vol->changeMount( mp );
+ vol->clearUsedBy();
+ ret = vol->setFormat( format, fs );
+ }
+ else
+ y2war( "base volume for " << device << " not found" );
+ }
+ }
}
else
{
@@ -2354,10 +2390,10 @@
{
int ret = 0;
assertInit();
- y2milestone( "device:%s label:%s", device.c_str(), label.c_str() );
+ y2mil("device:" << device << " label:" << label);
VolIterator vol;
ContIterator cont;
- if( readonly() )
+ if (readonly())
{
ret = STORAGE_CHANGE_READONLY;
}
@@ -2382,10 +2418,10 @@
{
int ret = 0;
assertInit();
- y2milestone( "device:%s", device.c_str() );
+ y2mil("device:" << device);
VolIterator vol;
ContIterator cont;
- if( readonly() )
+ if (readonly())
{
ret = STORAGE_CHANGE_READONLY;
}
@@ -2402,48 +2438,14 @@
}
int
-Storage::verifyCryptFilePassword( const string& file, const string& pwd )
- {
- int ret = VOLUME_CRYPT_NOT_DETECTED;
- assertInit();
- y2mil("file:" << file << " l:" << pwd.length());
-#ifdef DEBUG_LOOP_CRYPT_PASSWORD
- y2mil("password:" << pwd);
-#endif
-
- VolIterator vol;
- if (readonly())
- {
- ret = STORAGE_CHANGE_READONLY;
- }
- else
- {
- ProcPart ppart;
- LoopCo* co = new LoopCo(this, false, ppart);
- if( co )
- {
- Loop* loop = new Loop( *co, file, true, 0, true );
- if( loop && loop->setCryptPwd( pwd )==0 &&
- loop->detectEncryption()!=ENC_UNKNOWN )
- ret = 0;
- if( loop )
- delete loop;
- delete co;
- }
- }
- y2mil("ret:" << ret);
- return( ret );
- }
-
-int
Storage::changeMkfsOptVolume( const string& device, const string& opts )
{
int ret = 0;
assertInit();
- y2milestone( "device:%s opts:%s", device.c_str(), opts.c_str() );
+ y2mil("device:" << device << " opts:" << opts);
VolIterator vol;
ContIterator cont;
- if( readonly() )
+ if (readonly())
{
ret = STORAGE_CHANGE_READONLY;
}
@@ -2468,10 +2470,10 @@
{
int ret = 0;
assertInit();
- y2milestone( "device:%s opts:%s", device.c_str(), opts.c_str() );
+ y2mil("device:" << device << " opts:" << opts);
VolIterator vol;
ContIterator cont;
- if( readonly() )
+ if (readonly())
{
ret = STORAGE_CHANGE_READONLY;
}
@@ -2496,10 +2498,10 @@
{
int ret = 0;
assertInit();
- y2milestone( "device:%s txt:%s", device.c_str(), txt.c_str() );
+ y2mil("device:" << device << " txt:" << txt);
VolIterator vol;
ContIterator cont;
- if( readonly() )
+ if (readonly())
{
ret = STORAGE_CHANGE_READONLY;
}
@@ -2524,10 +2526,10 @@
{
int ret = 0;
assertInit();
- y2milestone( "device:%s mount:%s", device.c_str(), mount.c_str() );
+ y2mil("device:" << device << " mount:" << mount);
VolIterator vol;
ContIterator cont;
- if( readonly() )
+ if (readonly())
{
ret = STORAGE_CHANGE_READONLY;
}
@@ -2552,9 +2554,9 @@
{
int ret = 0;
assertInit();
- y2milestone( "device:%s", device.c_str());
- VolIterator vol;
- ContIterator cont;
+ y2mil("device:" << device);
+ ConstVolIterator vol;
+ ConstContIterator cont;
if( findVolume( device, cont, vol ) )
{
mount = vol->getMount();
@@ -2572,11 +2574,10 @@
{
int ret = 0;
assertInit();
- y2milestone( "device:%s mby:%s", device.c_str(),
- Volume::mbyTypeString(mby).c_str() );
+ y2mil("device:" << device << " mby:" << toString(mby));
VolIterator vol;
ContIterator cont;
- if( readonly() )
+ if (readonly())
{
ret = STORAGE_CHANGE_READONLY;
}
@@ -2601,9 +2602,9 @@
{
int ret = 0;
assertInit();
- y2milestone( "device:%s", device.c_str());
- VolIterator vol;
- ContIterator cont;
+ y2mil("device:" << device);
+ ConstVolIterator vol;
+ ConstContIterator cont;
if( findVolume( device, cont, vol ) )
{
mby = vol->getMountBy();
@@ -2614,10 +2615,9 @@
pair<string,unsigned> dp = Disk::getDiskPartition(device);
y2mil( "dp:" << dp );
- DiskIterator i1 = findDisk(dp.first);
- DmPartCoIterator i2 = findDmPartCo(dp.first);
- MdPartCoIterator i3 = findMdPartCo(dp.first);
-
+ ConstDiskIterator i1 = findDisk(dp.first);
+ ConstDmPartCoIterator i2 = findDmPartCo(dp.first);
+ ConstMdPartCoIterator i3 = findMdPartCo(dp.first);
if (i1 != dEnd())
{
if ((mby == MOUNTBY_ID && i1->udevId().empty()) ||
@@ -2641,7 +2641,7 @@
ret = STORAGE_VOLUME_NOT_FOUND;
}
}
- y2milestone( "ret:%d mby:%s", ret, Volume::mbyTypeString(mby).c_str());
+ y2mil("ret:" << ret << " mby:" << toString(mby));
return( ret );
}
@@ -2650,10 +2650,10 @@
{
int ret = 0;
assertInit();
- y2milestone( "device:%s options:%s", device.c_str(), options.c_str() );
+ y2mil("device:" << device << " options:" << options);
VolIterator vol;
ContIterator cont;
- if( readonly() )
+ if (readonly())
{
ret = STORAGE_CHANGE_READONLY;
}
@@ -2678,9 +2678,9 @@
{
int ret = 0;
assertInit();
- y2milestone( "device:%s", device.c_str());
- VolIterator vol;
- ContIterator cont;
+ y2mil("device:" << device);
+ ConstVolIterator vol;
+ ConstContIterator cont;
if( findVolume( device, cont, vol ) )
{
options = vol->getFstabOption();
@@ -2689,7 +2689,7 @@
{
ret = STORAGE_VOLUME_NOT_FOUND;
}
- y2milestone( "ret:%d options:%s", ret, options.c_str() );
+ y2mil("ret:" << ret << " options:" << options);
return( ret );
}
@@ -2698,10 +2698,10 @@
{
int ret = 0;
assertInit();
- y2milestone( "device:%s options:%s", device.c_str(), options.c_str() );
+ y2mil("device:" << device << " options:" << options);
VolIterator vol;
ContIterator cont;
- if( readonly() )
+ if (readonly())
{
ret = STORAGE_CHANGE_READONLY;
}
@@ -2714,7 +2714,7 @@
if( find( opts.begin(), opts.end(), *i )==opts.end() )
opts.push_back( *i );
}
- ret = vol->changeFstabOptions( mergeString( opts, "," ) );
+ ret = vol->changeFstabOptions( boost::join( opts, "," ) );
}
else
{
@@ -2733,10 +2733,10 @@
{
int ret = 0;
assertInit();
- y2milestone( "device:%s options:%s", device.c_str(), options.c_str() );
+ y2mil("device:" << device << " options:" << options);
VolIterator vol;
ContIterator cont;
- if( readonly() )
+ if (readonly())
{
ret = STORAGE_CHANGE_READONLY;
}
@@ -2746,9 +2746,9 @@
list<string> opts = splitString( vol->getFstabOption(), "," );
for( list<string>::const_iterator i=l.begin(); i!=l.end(); i++ )
{
- opts.remove_if(match_regex(*i));
+ opts.remove_if(regex_matches(*i));
}
- ret = vol->changeFstabOptions( mergeString( opts, "," ) );
+ ret = vol->changeFstabOptions( boost::join( opts, "," ) );
}
else
{
@@ -2765,7 +2765,7 @@
int
Storage::setCrypt( const string& device, bool val )
{
- y2milestone( "device:%s val:%d", device.c_str(), val );
+ y2mil("device:" << device << " val:" << val);
return( setCryptType( device, val, ENC_LUKS ));
}
@@ -2774,10 +2774,10 @@
{
int ret = 0;
assertInit();
- y2milestone( "device:%s val:%d type:%d", device.c_str(), val, typ );
+ y2mil("device:" << device << " val:" << val << " enc_type:" << toString(typ));
VolIterator vol;
ContIterator cont;
- if( readonly() )
+ if (readonly())
{
ret = STORAGE_CHANGE_READONLY;
}
@@ -2804,9 +2804,9 @@
{
int ret = 0;
assertInit();
- y2milestone( "device:%s", device.c_str());
- VolIterator vol;
- ContIterator cont;
+ y2mil("device:" << device);
+ ConstVolIterator vol;
+ ConstContIterator cont;
if( findVolume( device, cont, vol ) )
{
val = vol->getEncryption();
@@ -2815,22 +2815,23 @@
{
ret = STORAGE_VOLUME_NOT_FOUND;
}
- y2milestone( "ret:%d val:%d", ret, val );
+ y2mil("ret:" << ret << " val:" << val);
return( ret );
}
int
-Storage::verifyCryptPassword( const string& device, const string& pwd )
+Storage::verifyCryptPassword( const string& device, const string& pwd,
+ bool erase )
{
int ret = 0;
assertInit();
- y2milestone( "device:%s l:%zu", device.c_str(), pwd.length() );
-#ifdef DEBUG_LOOP_CRYPT_PASSWORD
- y2milestone( "password:%s", pwd.c_str() );
+ y2mil("device:" << device << " l:" << pwd.length() << " erase:" << erase );
+#ifdef DEBUG_CRYPT_PASSWORD
+ y2mil("pwd:" << pwd);
#endif
VolIterator vol;
- if( readonly() )
+ if (readonly())
{
ret = STORAGE_CHANGE_READONLY;
}
@@ -2839,7 +2840,8 @@
ret = vol->setCryptPwd( pwd );
if( ret==0 && vol->detectEncryption()==ENC_UNKNOWN )
ret = VOLUME_CRYPT_NOT_DETECTED;
- vol->clearCryptPwd();
+ if( erase || ret != 0 )
+ vol->clearCryptPwd();
}
else
{
@@ -2850,13 +2852,45 @@
}
int
+Storage::verifyCryptFilePassword( const string& file, const string& pwd )
+ {
+ int ret = VOLUME_CRYPT_NOT_DETECTED;
+ assertInit();
+ y2mil("file:" << file << " l:" << pwd.length());
+#ifdef DEBUG_CRYPT_PASSWORD
+ y2mil("pwd:" << pwd);
+#endif
+
+ if (readonly())
+ {
+ ret = STORAGE_CHANGE_READONLY;
+ }
+ else
+ {
+ LoopCo* co = new LoopCo(this);
+ if( co )
+ {
+ Loop* loop = new Loop( *co, file, true, 0, true );
+ if( loop && loop->setCryptPwd( pwd )==0 &&
+ loop->detectEncryption()!=ENC_UNKNOWN )
+ ret = 0;
+ if( loop )
+ delete loop;
+ delete co;
+ }
+ }
+ y2mil("ret:" << ret);
+ return( ret );
+ }
+
+int
Storage::setCryptPassword( const string& device, const string& pwd )
{
int ret = 0;
assertInit();
y2mil("device:" << device << " l:" << pwd.length());
-#ifdef DEBUG_LOOP_CRYPT_PASSWORD
- y2mil("password:" << pwd);
+#ifdef DEBUG_CRYPT_PASSWORD
+ y2mil("pwd:" << pwd);
#endif
VolIterator vol;
@@ -2888,10 +2922,10 @@
{
int ret = 0;
assertInit();
- y2milestone( "device:%s", device.c_str() );
+ y2mil("device:" << device);
VolIterator vol;
- if( readonly() )
+ if (readonly())
{
ret = STORAGE_CHANGE_READONLY;
}
@@ -2919,7 +2953,7 @@
assertInit();
y2mil("device:" << device);
- VolIterator vol;
+ ConstVolIterator vol;
if( checkNormalFile(device) )
{
ConstLoopPair p = loopPair(Loop::notDeleted);
@@ -2950,10 +2984,10 @@
{
int ret = 0;
assertInit();
- y2milestone( "device:%s", device.c_str() );
+ y2mil("device:" << device);
pwd.clear();
- VolIterator vol;
+ ConstVolIterator vol;
if( findVolume( device, vol ) )
{
pwd = vol->getCryptPwd();
@@ -2966,8 +3000,8 @@
else
ret = STORAGE_VOLUME_NOT_FOUND;
}
-#ifdef DEBUG_LOOP_CRYPT_PASSWORD
- y2milestone( "password:%s", pwd.c_str() );
+#ifdef DEBUG_CRYPT_PASSWORD
+ y2mil("pwd:" << pwd);
#endif
y2mil("ret:" << ret);
return( ret );
@@ -2978,10 +3012,10 @@
{
int ret = 0;
assertInit();
- y2milestone( "device:%s val:%d", device.c_str(), val );
+ y2mil("device:" << device << " val:" << val);
VolIterator vol;
ContIterator cont;
- if( readonly() )
+ if (readonly())
{
ret = STORAGE_CHANGE_READONLY;
}
@@ -3006,9 +3040,9 @@
{
int ret = 0;
assertInit();
- y2milestone( "device:%s", device.c_str());
- VolIterator vol;
- ContIterator cont;
+ y2mil("device:" << device);
+ ConstVolIterator vol;
+ ConstContIterator cont;
if( findVolume( device, cont, vol ) )
{
val = vol->ignoreFstab();
@@ -3017,33 +3051,32 @@
{
ret = STORAGE_VOLUME_NOT_FOUND;
}
- y2milestone( "ret:%d val:%d", ret, val );
+ y2mil("ret:" << ret << " val:" << val);
return( ret );
}
int
-Storage::resizeVolume( const string& device, unsigned long long newSizeMb )
+Storage::resizeVolume(const string& device, unsigned long long newSizeK)
{
- return( resizeVolume( device, newSizeMb, false ));
+ return resizeVolume(device, newSizeK, false);
}
int
-Storage::resizeVolumeNoFs( const string& device, unsigned long long newSizeMb )
+Storage::resizeVolumeNoFs(const string& device, unsigned long long newSizeK)
{
- return( resizeVolume( device, newSizeMb, true ));
+ return resizeVolume(device, newSizeK, true);
}
int
-Storage::resizeVolume( const string& device, unsigned long long newSizeMb,
- bool ignoreFs )
+Storage::resizeVolume(const string& device, unsigned long long newSizeK,
+ bool ignoreFs)
{
int ret = 0;
assertInit();
- y2milestone( "device:%s newSizeMb:%llu ignoreFs:%d", device.c_str(),
- newSizeMb, ignoreFs );
+ y2mil("device:" << device << " newSizeK:" << newSizeK << " ignoreFs:" << ignoreFs);
VolIterator vol;
ContIterator cont;
- if( readonly() )
+ if (readonly())
{
ret = STORAGE_CHANGE_READONLY;
}
@@ -3052,8 +3085,8 @@
y2mil( "vol:" << *vol );
if( ignoreFs )
vol->setIgnoreFs();
- ret = cont->resizeVolume( &(*vol), newSizeMb*1024 );
- eraseFreeInfo( vol->device() );
+ ret = cont->resizeVolume(&(*vol), newSizeK);
+ eraseCachedFreeInfo(vol->device());
y2mil( "vol:" << *vol );
}
else
@@ -3073,10 +3106,10 @@
{
int ret = 0;
assertInit();
- y2milestone( "device:%s", device.c_str() );
+ y2mil("device:" << device);
VolIterator vol;
ContIterator cont;
- if( readonly() )
+ if (readonly())
{
ret = STORAGE_CHANGE_READONLY;
}
@@ -3101,20 +3134,20 @@
{
int ret = 0;
assertInit();
- y2milestone( "device:%s", device.c_str() );
+ y2mil("device:" << device);
VolIterator vol;
ContIterator cont;
- if( readonly() )
+ if (readonly())
{
ret = STORAGE_CHANGE_READONLY;
}
- else if( findVolume( device, cont, vol ) )
+ else if( findVolume( device, cont, vol, false ) )
{
- if( vol->getUsedByType() == UB_NONE || recursiveRemove )
+ if( canRemove( *vol ) )
{
string vdev = vol->device();
- if( vol->getUsedByType() != UB_NONE )
+ if (vol->isUsedBy())
ret = removeUsing( vdev, vol->getUsedBy() );
if( ret==0 )
ret = cont->removeVolume( &(*vol) );
@@ -3142,8 +3175,8 @@
assertInit();
y2mil( "name:" << name << " peSizeK:" << peSizeK << " lvm1:" << lvm1 <<
" devices:" << devs );
- LvmVgIterator i = findLvmVg( name );
- if( readonly() )
+ ConstLvmVgIterator i = findLvmVg( name );
+ if (readonly())
{
ret = STORAGE_CHANGE_READONLY;
}
@@ -3154,14 +3187,11 @@
}
else if( i == lvgEnd() )
{
- LvmVg *v = new LvmVg( this, name, lvm1 );
- v->setCreated();
+ LvmVg* v = new LvmVg(this, name, "/dev/" + name, lvm1);
ret = v->setPeSize( peSizeK );
if( ret==0 && !devs.empty() )
{
- list<string> d;
- back_insert_iterator<list<string> > inserter(d);
- copy( devs.begin(), devs.end(), inserter );
+ list<string> d(devs.begin(), devs.end());
ret = v->extendVg( d );
}
if( ret==0 )
@@ -3186,9 +3216,9 @@
{
int ret = 0;
assertInit();
- y2milestone( "name:%s", name.c_str() );
+ y2mil("name:" << name);
LvmVgIterator i = findLvmVg( name );
- if( readonly() )
+ if (readonly())
{
ret = STORAGE_CHANGE_READONLY;
}
@@ -3217,15 +3247,13 @@
assertInit();
y2mil( "name:" << name << " devices:" << devs );
LvmVgIterator i = findLvmVg( name );
- if( readonly() )
+ if (readonly())
{
ret = STORAGE_CHANGE_READONLY;
}
else if( i != lvgEnd() )
{
- list<string> d;
- back_insert_iterator<list<string> > inserter(d);
- copy( devs.begin(), devs.end(), inserter );
+ list<string> d(devs.begin(), devs.end());
ret = i->extendVg( d );
}
else
@@ -3247,15 +3275,13 @@
assertInit();
y2mil( "name:" << name << " devices:" << devs );
LvmVgIterator i = findLvmVg( name );
- if( readonly() )
+ if (readonly())
{
ret = STORAGE_CHANGE_READONLY;
}
else if( i != lvgEnd() )
{
- list<string> d;
- back_insert_iterator<list<string> > inserter(d);
- copy( devs.begin(), devs.end(), inserter );
+ list<string> d(devs.begin(), devs.end());
ret = i->reduceVg( d );
}
else
@@ -3271,22 +3297,21 @@
}
int
-Storage::createLvmLv( const string& vg, const string& name,
- unsigned long long sizeM, unsigned stripe,
- string& device )
+Storage::createLvmLv(const string& vg, const string& name,
+ unsigned long long sizeK, unsigned stripes,
+ string& device)
{
int ret = 0;
assertInit();
- y2milestone( "vg:%s name:%s sizeM:%llu stripe:%u", vg.c_str(),
- name.c_str(), sizeM, stripe );
+ y2mil("vg:" << vg << " name:" << name << " sizeK:" << sizeK << " stripes:" << stripes);
LvmVgIterator i = findLvmVg( vg );
- if( readonly() )
+ if (readonly())
{
ret = STORAGE_CHANGE_READONLY;
}
else if( i != lvgEnd() )
{
- ret = i->createLv( name, sizeM*1024, stripe, device );
+ ret = i->createLv(name, sizeK, stripes, device);
if( ret==0 )
checkPwdBuf( device );
}
@@ -3298,7 +3323,7 @@
{
ret = checkCache();
}
- y2milestone( "ret:%d device:%s", ret, ret?"":device.c_str() );
+ y2mil("ret:" << ret << " device:" << (ret?"":device));
return( ret );
}
@@ -3327,9 +3352,9 @@
{
int ret = 0;
assertInit();
- y2milestone( "vg:%s name:%s", vg.c_str(), name.c_str() );
+ y2mil("vg:" << vg << " name:" << name);
LvmVgIterator i = findLvmVg( vg );
- if( readonly() )
+ if (readonly())
{
ret = STORAGE_CHANGE_READONLY;
}
@@ -3355,10 +3380,9 @@
{
int ret = 0;
assertInit();
- y2milestone( "vg:%s name:%s stripe:%lu", vg.c_str(), name.c_str(),
- stripe );
+ y2mil("vg:" << vg << " name:" << name << " stripe:" << stripe);
LvmVgIterator i = findLvmVg( vg );
- if( readonly() )
+ if (readonly())
{
ret = STORAGE_CHANGE_READONLY;
}
@@ -3384,10 +3408,9 @@
{
int ret = 0;
assertInit();
- y2milestone( "vg:%s name:%s stripeSize:%llu", vg.c_str(), name.c_str(),
- stripeSize );
+ y2mil("vg:" << vg << " name:" << name << " stripeSize:" << stripeSize);
LvmVgIterator i = findLvmVg( vg );
- if( readonly() )
+ if (readonly())
{
ret = STORAGE_CHANGE_READONLY;
}
@@ -3489,102 +3512,71 @@
int
-Storage::nextFreeMd(int &nr, string &device)
+Storage::nextFreeMd(unsigned& nr, string &device)
{
int ret = 0;
assertInit();
MdCo *md = NULL;
- list<int> mdNums;
- list<int> mdPartNums;
- nr = -1;
- mdNums.clear();
- mdPartNums.clear();
+ list<unsigned> nums;
+
if (haveMd(md))
- (void)md->usedNumbers(mdNums);
+ nums = md->usedNumbers();
- getMdPartMdNums(mdPartNums);
+ nums.splice(nums.end(), getMdPartMdNums());
- mdPartNums.merge(mdNums);
- mdPartNums.sort();
- mdPartNums.unique();
+ bool found_free = false;
- if(mdPartNums.size() > 0 )
- {
- int found;
- //FIXME: magic number
- for(int i=0; i<1000; i++)
- {
- found=0;
- for(list<int>::iterator it=mdPartNums.begin();
- it!=mdPartNums.end(); it++)
- {
- if (i == *it )
- found = 1;
- }
- if(found == 0)
- {
- // Number not found on the list.
- nr = i;
- break;
- }
- }
- }
- else
- {
- nr = 0;
- }
- if( nr != -1 )
- {
- device = "/dev/md" + decString(nr);
- y2milestone("ret:%d nr:%d device:%s", ret, nr, device.c_str());
- }
+ //FIXME: magic number
+ for (unsigned i = 0; i < 1000; ++i)
+ {
+ if (find(nums.begin(), nums.end(), i) == nums.end())
+ {
+ found_free = true;
+ nr = i;
+ break;
+ }
+ }
+
+ if (found_free)
+ {
+ device = "/dev/md" + decString(nr);
+ y2mil("nr:" << nr << " device:" << device);
+ }
else
- ret = MD_UNKNOWN_NUMBER;
+ ret = MD_UNKNOWN_NUMBER;
+
+ y2mil("ret:" << ret);
return ret;
}
-bool Storage::checkMdNumber(int num)
+
+bool
+Storage::checkMdNumber(unsigned num)
{
- assertInit();
- MdCo *md = NULL;
- list<int> mdNums;
- list<int> mdPartNums;
-
- mdNums.clear();
- mdPartNums.clear();
- if (haveMd(md))
- (void)md->usedNumbers(mdNums);
-
- getMdPartMdNums(mdPartNums);
-
- mdPartNums.merge(mdNums);
- mdPartNums.sort();
- mdPartNums.unique();
+ assertInit();
+ MdCo *md = NULL;
- if(mdPartNums.size() == 0 )
- return false;
+ list<unsigned> nums;
- for(list<int>::iterator it=mdPartNums.begin();
- it!=mdPartNums.end();
- it++)
- {
- if (num == *it )
- return true;
- }
- return false;
+ if (haveMd(md))
+ nums = md->usedNumbers();
+
+ nums.splice(nums.end(), getMdPartMdNums());
+
+ return find(nums.begin(), nums.end(), num) == nums.end();
}
+
int
-Storage::createMd( const string& name, MdType rtype,
- const deque<string>& devs )
+Storage::createMd(const string& name, MdType rtype, const list<string>& devs,
+ const list<string>& spares)
{
int ret = 0;
assertInit();
- y2mil( "name:" << name << " MdType:" << Md::pName(rtype) <<
- " devices:" << devs );
+ y2mil("name:" << name << " MdType:" << toString(rtype) << " devices:" << devs << " spares:" << spares);
unsigned num = 0;
- if( readonly() )
+ if (readonly())
{
ret = STORAGE_CHANGE_READONLY;
}
@@ -3592,7 +3584,7 @@
{
ret = STORAGE_MD_INVALID_NAME;
}
- if( ret==0 && checkMdNumber(num)==true )
+ if( ret==0 && !checkMdNumber(num) )
{
ret = MD_DUPLICATE_NUMBER;
}
@@ -3602,13 +3594,11 @@
{
have_md = haveMd(md);
if( !have_md )
- md = new MdCo( this, false );
+ md = new MdCo(this);
}
if( ret==0 && md!=NULL )
{
- list<string> d;
- d.insert( d.end(), devs.begin(), devs.end() );
- ret = md->createMd( num, rtype, d );
+ ret = md->createMd(num, rtype, normalizeDevices(devs), normalizeDevices(spares));
if( ret==0 )
checkPwdBuf( Md::mdDevice(num) );
}
@@ -3627,40 +3617,34 @@
return( ret );
}
-int Storage::createMdAny( MdType rtype, const deque<string>& devs,
- string& device )
+int Storage::createMdAny(MdType rtype, const list<string>& devs, const list<string>& spares,
+ string& device)
{
int ret = 0;
assertInit();
- y2mil( "MdType:" << Md::pName(rtype) << " devices:" << devs );
- if( readonly() )
+ y2mil("MdType:" << toString(rtype) << " devices:" << devs << " spares:" << spares);
+ if (readonly())
{
ret = STORAGE_CHANGE_READONLY;
}
MdCo *md = NULL;
bool have_md = true;
- int mdNum=0;
unsigned num = 0;
- string tmpStr;
if( ret==0 )
{
have_md = haveMd(md);
if( !have_md )
- md = new MdCo( this, false );
+ md = new MdCo(this);
if( md==NULL )
ret = STORAGE_MEMORY_EXHAUSTED;
if( ret == 0 )
{
- ret = nextFreeMd(mdNum,tmpStr);
- if( ret == 0 )
- num = (unsigned)mdNum;
+ ret = nextFreeMd(num, device);
}
}
if( ret==0 )
{
- list<string> d;
- d.insert( d.end(), devs.begin(), devs.end() );
- ret = md->createMd( num, rtype, d );
+ ret = md->createMd(num, rtype, normalizeDevices(devs), normalizeDevices(spares));
if( ret==0 )
checkPwdBuf( Md::mdDevice(num) );
}
@@ -3675,13 +3659,9 @@
}
if( ret==0 )
{
- device = "/dev/md" + decString(num);
- }
- if( ret==0 )
- {
ret = checkCache();
}
- y2milestone( "ret:%d device:%s", ret, ret==0?device.c_str():"" );
+ y2mil("ret:" << ret << " device:" << (ret==0?device:""));
return( ret );
}
@@ -3689,8 +3669,8 @@
{
int ret = 0;
assertInit();
- y2milestone( "name:%s destroySb:%d", name.c_str(), destroySb );
- if( readonly() )
+ y2mil("name:" << name << " destroySb:" << destroySb);
+ if (readonly())
{
ret = STORAGE_CHANGE_READONLY;
}
@@ -3715,12 +3695,12 @@
return( ret );
}
-int Storage::extendMd( const string& name, const string& dev )
+int Storage::extendMd(const string& name, const list<string>& devs, const list<string>& spares)
{
int ret = 0;
assertInit();
- y2milestone( "name:%s dev:%s", name.c_str(), dev.c_str() );
- if( readonly() )
+ y2mil("name:" << name << " devs:" << devs << " spares:" << spares);
+ if (readonly())
{
ret = STORAGE_CHANGE_READONLY;
}
@@ -3733,7 +3713,7 @@
{
MdCo *md = NULL;
if( haveMd(md) )
- ret = md->extendMd( num, dev );
+ ret = md->extendMd(num, normalizeDevices(devs), normalizeDevices(spares));
else
ret = STORAGE_MD_NOT_FOUND;
}
@@ -3745,12 +3725,12 @@
return( ret );
}
-int Storage::shrinkMd( const string& name, const string& dev )
+int Storage::shrinkMd(const string& name, const list<string>& devs, const list<string>& spares)
{
int ret = 0;
assertInit();
- y2milestone( "name:%s dev:%s", name.c_str(), dev.c_str() );
- if( readonly() )
+ y2mil("name:" << name << " devs:" << devs << " spares:" << spares);
+ if (readonly())
{
ret = STORAGE_CHANGE_READONLY;
}
@@ -3763,7 +3743,7 @@
{
MdCo *md = NULL;
if( haveMd(md) )
- ret = md->shrinkMd( num, dev );
+ ret = md->shrinkMd(num, normalizeDevices(devs), normalizeDevices(spares));
else
ret = STORAGE_MD_NOT_FOUND;
}
@@ -3775,13 +3755,12 @@
return( ret );
}
-
int Storage::changeMdType( const string& name, MdType rtype )
{
int ret = 0;
assertInit();
- y2milestone( "name:%s rtype:%d", name.c_str(), rtype );
- if( readonly() )
+ y2mil("name:" << name << " rtype:" << toString(rtype));
+ if (readonly())
{
ret = STORAGE_CHANGE_READONLY;
}
@@ -3810,8 +3789,8 @@
{
int ret = 0;
assertInit();
- y2milestone( "name:%s dev:%lu", name.c_str(), chunk );
- if( readonly() )
+ y2mil("name:" << name << " chunk:" << chunk);
+ if (readonly())
{
ret = STORAGE_CHANGE_READONLY;
}
@@ -3840,8 +3819,8 @@
{
int ret = 0;
assertInit();
- y2milestone( "name:%s parity:%d", name.c_str(), ptype );
- if( readonly() )
+ y2mil("name:" << name << " parity:" << toString(ptype));
+ if (readonly())
{
ret = STORAGE_CHANGE_READONLY;
}
@@ -3870,7 +3849,7 @@
{
int ret = 0;
assertInit();
- y2milestone( "name:%s", name.c_str() );
+ y2mil("name:" << name);
unsigned num = 0;
MdCo *md = NULL;
if( Md::mdStringNum( name, num ) && haveMd(md) )
@@ -3886,7 +3865,7 @@
{
int ret = 0;
assertInit();
- y2milestone("name:%s", name.c_str());
+ y2mil("name:" << name);
unsigned num = 0;
if (ret == 0 && !Md::mdStringNum(name, num))
{
@@ -3900,40 +3879,40 @@
else
ret = STORAGE_MD_NOT_FOUND;
}
- y2milestone("ret:%d", ret);
+ y2mil("ret:" << ret);
return ret;
}
-// Find container 'name' and return its state.
-int Storage::getMdPartCoStateInfo(const string& name, MdPartCoStateInfo& info)
+
+int
+Storage::getMdPartCoStateInfo(const string& name, MdPartCoStateInfo& info)
{
- CPair p = cPair();
- ContIterator i = p.begin();
+ int ret = 0;
- for( i=p.begin(); i!=p.end(); i++)
+ ConstMdPartCoIterator i = findMdPartCo(name);
+ if (i != mdpCoEnd())
+ {
+ ret = i->getMdPartCoState(info);
+ }
+ else
{
- if( i->type()==MDPART )
- {
- MdPartCo* mdp = static_cast<MdPartCo*>(&(*i));
- if( mdp->matchMdName(name) )
- {
- mdp->getMdPartCoState(info);
- break;
- }
- }
+ ret = STORAGE_MDPART_CO_NOT_FOUND;
}
- return( i != p.end() );
+
+ return ret;
}
+
int
-Storage::computeMdSize(MdType md_type, list<string> devices, unsigned long long& sizeK)
+Storage::computeMdSize(MdType md_type, const list<string>& devices, const list<string>& spares,
+ unsigned long long& sizeK)
{
int ret = 0;
unsigned long long sumK = 0;
unsigned long long smallestK = 0;
- for (list<string>::const_iterator i = devices.begin(); i != devices.end(); i++)
+ for (list<string>::const_iterator i = devices.begin(); i != devices.end(); ++i)
{
const Volume* v = getVolume(*i);
if (!v)
@@ -3943,40 +3922,115 @@
}
sumK += v->sizeK();
- if (smallestK == 0)
+ if (i == devices.begin())
smallestK = v->sizeK();
else
smallestK = min(smallestK, v->sizeK());
}
- switch (md_type)
+ for (list<string>::const_iterator i = spares.begin(); i != spares.end(); ++i)
{
- case RAID0:
- sizeK = sumK;
- break;
- case RAID1:
- case MULTIPATH:
- sizeK = smallestK;
- break;
- case RAID5:
- sizeK = devices.size()<1 ? 0 : smallestK*(devices.size()-1);
- break;
- case RAID6:
- sizeK = devices.size()<2 ? 0 : smallestK*(devices.size()-2);
- break;
- case RAID10:
- sizeK = smallestK*devices.size()/2;
- break;
- default:
+ const Volume* v = getVolume(*i);
+ if (!v)
+ {
+ ret = STORAGE_VOLUME_NOT_FOUND;
break;
+ }
+
+ smallestK = min(smallestK, v->sizeK());
+ }
+
+ if (ret == 0)
+ {
+ switch (md_type)
+ {
+ case RAID0:
+ if (devices.size() < 2)
+ ret = MD_TOO_FEW_DEVICES;
+ else
+ sizeK = sumK;
+ break;
+
+ case RAID1:
+ case MULTIPATH:
+ if (devices.size() < 2)
+ ret = MD_TOO_FEW_DEVICES;
+ else
+ sizeK = smallestK;
+ break;
+
+ case RAID5:
+ if (devices.size() < 3)
+ ret = MD_TOO_FEW_DEVICES;
+ else
+ sizeK = smallestK*(devices.size()-1);
+ break;
+
+ case RAID6:
+ if (devices.size() < 4)
+ ret = MD_TOO_FEW_DEVICES;
+ else
+ sizeK = smallestK*(devices.size()-2);
+ break;
+
+ case RAID10:
+ if (devices.size() < 2)
+ ret = MD_TOO_FEW_DEVICES;
+ else
+ sizeK = smallestK*devices.size()/2;
+ break;
+
+ default:
+ break;
+ }
}
- y2milestone ("type:%d smallest:%llu sum:%llu size:%llu", md_type,
- smallestK, sumK, sizeK);
+ y2mil("type:" << toString(md_type) << " smallest:" << smallestK << " sum:" << sumK <<
+ " size:" << sizeK);
return ret;
}
+list<int>
+Storage::getMdAllowedParity( MdType md_type, unsigned devices )
+ {
+ list<int> ret;
+ if( md_type==RAID5 || md_type==RAID6 )
+ {
+ ret.push_back(PAR_DEFAULT);
+ ret.push_back(LEFT_ASYMMETRIC);
+ ret.push_back(LEFT_SYMMETRIC);
+ ret.push_back(RIGHT_ASYMMETRIC);
+ ret.push_back(RIGHT_SYMMETRIC);
+ ret.push_back(PAR_FIRST);
+ ret.push_back(PAR_LAST);
+ if( md_type==RAID6 )
+ {
+ ret.push_back(LEFT_ASYMMETRIC_6);
+ ret.push_back(LEFT_SYMMETRIC_6);
+ ret.push_back(RIGHT_ASYMMETRIC_6);
+ ret.push_back(RIGHT_SYMMETRIC_6);
+ ret.push_back(PAR_FIRST_6);
+ }
+ }
+ else if( md_type==RAID10 )
+ {
+ ret.push_back(PAR_DEFAULT);
+ ret.push_back(PAR_NEAR_2);
+ ret.push_back(PAR_OFFSET_2);
+ ret.push_back(PAR_FAR_2);
+ if( devices>2 )
+ {
+ ret.push_back(PAR_NEAR_3);
+ ret.push_back(PAR_OFFSET_3);
+ ret.push_back(PAR_FAR_3);
+ }
+ }
+
+ y2mil("type:" << toString(md_type) << " ret:" << ret );
+ return ret;
+ }
+
//
// Removes Software RAIDs that are not IMSM RAIDs.
//
@@ -3984,12 +4038,10 @@
{
y2mil("Called");
int ret;
- MdPartCoIterator mdp;
-
- mdp = findMdPartCo(devName);
+ MdPartCoIterator mdp = findMdPartCo(devName);
if( mdp == mdpCoEnd() )
{
- y2war("Not found device: " + devName);
+ y2war("Not found device: " << devName);
return MDPART_DEVICE_NOT_FOUND;
}
MdPartCoInfo mdpInfo;
@@ -4005,46 +4057,41 @@
{
ret = checkCache();
}
- y2mil("Done, ret=" << ret);
+ y2mil("ret:" << ret);
return ret;
}
+
bool Storage::haveMd( MdCo*& md )
{
md = NULL;
- CPair p = cPair();
+ CPair p = cPair(isMd);
ContIterator i = p.begin();
- while( i != p.end() && i->type()!=MD )
- ++i;
if( i != p.end() )
md = static_cast<MdCo*>(&(*i));
return( i != p.end() );
}
-int Storage::getMdPartMdNums(list<int>& mdPartNums)
+
+ list<unsigned>
+ Storage::getMdPartMdNums() const
{
- mdPartNums.clear();
- CPair p = cPair();
- ContIterator i;
- for(i=p.begin(); i!=p.end(); i++ )
- {
- if( i->type()==MDPART )
- {
- MdPartCo *mdpart = static_cast<MdPartCo*>(&(*i));
- mdPartNums.push_back(mdpart->nr());
- }
- }
- return 0;
+ list<unsigned> nums;
+
+ ConstMdPartCoPair p = mdpartCoPair(MdPartCo::notDeleted);
+ for (ConstMdPartCoIterator i = p.begin(); i != p.end(); ++i)
+ nums.push_back(i->nr());
+
+ return nums;
}
+
bool
Storage::haveDm(DmCo*& dm)
{
dm = NULL;
- CPair p = cPair();
+ CPair p = cPair(isDm);
ContIterator i = p.begin();
- while (i != p.end() && i->type() != DM)
- ++i;
if (i != p.end())
dm = static_cast<DmCo*>(&(*i));
return i != p.end();
@@ -4054,23 +4101,21 @@
bool Storage::haveNfs( NfsCo*& co )
{
co = NULL;
- CPair p = cPair();
+ CPair p = cPair(isNfs);
ContIterator i = p.begin();
- while( i != p.end() && i->type()!=NFSC )
- ++i;
if( i != p.end() )
co = static_cast<NfsCo*>(&(*i));
return( i != p.end() );
}
int
-Storage::addNfsDevice( const string& nfsDev, const string& opts,
- unsigned long long sizeK, const string& mp )
+Storage::addNfsDevice(const string& nfsDev, const string& opts, unsigned long long sizeK,
+ const string& mp, bool nfs4)
{
int ret = 0;
assertInit();
- y2mil( "name:" << nfsDev << " sizeK:" << sizeK << " mp:" << mp );
- if( readonly() )
+ y2mil("name:" << nfsDev << " sizeK:" << sizeK << " mp:" << mp << " nfs4:" << nfs4);
+ if (readonly())
{
ret = STORAGE_CHANGE_READONLY;
}
@@ -4085,8 +4130,8 @@
if( ret==0 && co!=NULL )
{
if( sizeK==0 )
- checkNfsDevice( nfsDev, opts, sizeK );
- ret = co->addNfs( nfsDev, sizeK, mp );
+ checkNfsDevice(nfsDev, opts, nfs4, sizeK);
+ ret = co->addNfs(nfsDev, sizeK, opts, mp, nfs4);
}
if( !have )
{
@@ -4103,20 +4148,16 @@
return( ret );
}
-int
-Storage::checkNfsDevice( const string& nfsDev, const string& opts,
- unsigned long long& sizeK )
+
+int
+Storage::checkNfsDevice(const string& nfsDev, const string& opts, bool nfs4, unsigned long long& sizeK)
{
int ret = 0;
assertInit();
NfsCo co( this );
- string mdir = tmpDir() + "/tmp_mp";
- unlink( mdir.c_str() );
- rmdir( mdir.c_str() );
- createPath( mdir );
- ret = co.addNfs( nfsDev, 0, "" );
- if( !opts.empty() )
- co.vBegin()->setFstabOption( opts );
+ string mdir = tmpDir() + "/tmp-nfs-mp";
+ mkdir(mdir.c_str(), 0777);
+ ret = co.addNfs(nfsDev, 0, opts, "", nfs4);
if( instsys() )
{
SystemCmd c;
@@ -4135,105 +4176,308 @@
}
if( ret==0 && (ret=co.vBegin()->mount( mdir ))==0 )
{
- sizeK = getDfSize( mdir );
+ StatVfs vfsbuf;
+ getStatVfs(mdir, vfsbuf);
+ sizeK = vfsbuf.sizeK;
ret = co.vBegin()->umount( mdir );
}
- y2mil( "name:" << nfsDev << " opts:" << opts << " ret:" << ret <<
+ rmdir(mdir.c_str());
+ y2mil( "name:" << nfsDev << " opts:" << opts << " nfs4:" << nfs4 << " ret:" << ret <<
" sizeK:" << sizeK );
+ return ret;
+ }
+
+int
+Storage::createFileLoop( const string& lname, bool reuseExisting,
+ unsigned long long sizeK, const string& mp,
+ const string& pwd, string& device )
+ {
+ int ret = 0;
+ assertInit();
+ y2mil("lname:" << lname << " reuseExisting:" << reuseExisting << " sizeK:" << sizeK << " mp:" << mp);
+#ifdef DEBUG_CRYPT_PASSWORD
+ y2mil("pwd:" << pwd);
+#endif
+ if (readonly())
+ {
+ ret = STORAGE_CHANGE_READONLY;
+ }
+ LoopCo *loop = NULL;
+ Volume *vol = NULL;
+ bool have_loop = true;
+ if( ret==0 )
+ {
+ have_loop = haveLoop(loop);
+ y2mil( "have_loop:" << have_loop );
+ if( !have_loop )
+ {
+ loop = new LoopCo(this);
+ }
+ if( loop==NULL )
+ ret = STORAGE_MEMORY_EXHAUSTED;
+ }
+ if( ret==0 )
+ {
+ ret = loop->createLoop( lname, reuseExisting, sizeK, true, device );
+ }
+ if( ret==0 && !loop->findVolume( device, vol ))
+ {
+ ret = STORAGE_CREATED_LOOP_NOT_FOUND;
+ }
+ if( ret==0 )
+ {
+ ret = vol->setCryptPwd( pwd );
+ }
+ if( ret==0 && (!reuseExisting || access( (root()+lname).c_str(), R_OK )!=0 ))
+ {
+ ret = vol->setFormat( true, EXT3 );
+ }
+ if( ret==0 )
+ {
+ ret = vol->setEncryption( true );
+ }
+ if( ret==0 && !mp.empty() )
+ {
+ ret = vol->changeMount( mp );
+ }
+ if( !have_loop )
+ {
+ if( ret==0 )
+ {
+ addToList( loop );
+ }
+ else if( loop!=NULL )
+ delete loop;
+ }
+ if( ret==0 )
+ {
+ ret = checkCache();
+ }
+ y2mil("ret:" << ret << " device:" << (ret==0?device:""));
+ return( ret );
+ }
+
+int
+Storage::modifyFileLoop( const string& device, const string& lname,
+ bool reuseExisting, unsigned long long sizeK )
+ {
+ int ret = 0;
+ assertInit();
+ y2mil("device:" << device << " lname:" << lname << " reuse:" << reuseExisting << " sizeK:" << sizeK);
+ if (readonly())
+ {
+ ret = STORAGE_CHANGE_READONLY;
+ }
+ if( ret==0 )
+ {
+ LoopCo *loop = NULL;
+ if( haveLoop(loop) )
+ ret = loop->updateLoop( device, lname, reuseExisting, sizeK );
+ else
+ ret = STORAGE_LOOP_NOT_FOUND;
+ }
+ if( ret==0 )
+ {
+ ret = checkCache();
+ }
+ y2mil("ret:" << ret);
+ return( ret );
+ }
+
+int
+Storage::removeFileLoop( const string& lname, bool removeFile )
+ {
+ int ret = 0;
+ assertInit();
+ y2mil("lname:" << lname << " removeFile:" << removeFile);
+ if (readonly())
+ {
+ ret = STORAGE_CHANGE_READONLY;
+ }
+ if( ret==0 )
+ {
+ LoopCo *loop = NULL;
+ if( haveLoop(loop) )
+ ret = loop->removeLoop( lname, removeFile );
+ else
+ ret = STORAGE_LOOP_NOT_FOUND;
+ }
+ if( ret==0 )
+ {
+ ret = checkCache();
+ }
+ y2mil("ret:" << ret);
+ return( ret );
+ }
+
+
+bool Storage::haveLoop( LoopCo*& loop )
+ {
+ loop = NULL;
+ CPair p = cPair(isLoop);
+ ContIterator i = p.begin();
+ if( i != p.end() )
+ loop = static_cast<LoopCo*>(&(*i));
+ return( i != p.end() );
+ }
+
+bool Storage::haveBtrfs( BtrfsCo*& co )
+ {
+ co = NULL;
+ CPair p = cPair(isBtrfs);
+ ContIterator i = p.begin();
+ if( i != p.end() )
+ co = static_cast<BtrfsCo*>(&(*i));
+ return( i != p.end() );
+ }
+
+bool Storage::haveTmpfs( TmpfsCo*& co )
+ {
+ co = NULL;
+ CPair p = cPair(isTmpfs);
+ ContIterator i = p.begin();
+ if( i != p.end() )
+ co = static_cast<TmpfsCo*>(&(*i));
+ return( i != p.end() );
+ }
+
+int Storage::removeDmraid( const string& name )
+ {
+ int ret = 0;
+ assertInit();
+ DmraidCoIterator i = findDmraidCo( name );
+ if (readonly())
+ {
+ ret = STORAGE_CHANGE_READONLY;
+ }
+ else if( i != dmrCoEnd() )
+ {
+ ret = i->removeDmPart();
+ }
+ else
+ ret = STORAGE_DMRAID_CO_NOT_FOUND;
+ return( ret );
+ }
+
+int Storage::createSubvolume( const string& device, const string& name )
+ {
+ int ret = 0;
+ assertInit();
+ y2mil("device:" << device << " name:" << name);
+ BtrfsCo* co;
+ if (readonly())
+ {
+ ret = STORAGE_CHANGE_READONLY;
+ }
+ else if( haveBtrfs(co) )
+ {
+ ret = co->createSubvolume( device, name );
+ }
+ else
+ {
+ ret = STORAGE_BTRFS_CO_NOT_FOUND;
+ }
+ if( ret==0 )
+ {
+ ret = checkCache();
+ }
+ y2mil("ret:" << ret);
return( ret );
}
-int
-Storage::createFileLoop( const string& lname, bool reuseExisting,
- unsigned long long sizeK, const string& mp,
- const string& pwd, string& device )
+int Storage::removeSubvolume( const string& device, const string& name )
{
int ret = 0;
assertInit();
- y2milestone( "lname:%s reuseExisting:%d sizeK:%llu mp:%s", lname.c_str(),
- reuseExisting, sizeK, mp.c_str() );
-#ifdef DEBUG_LOOP_CRYPT_PASSWORD
- y2milestone( "pwd:%s", pwd.c_str() );
-#endif
- if( readonly() )
+ y2mil("device:" << device << " name:" << name);
+ BtrfsCo* co;
+ if (readonly())
{
ret = STORAGE_CHANGE_READONLY;
}
- LoopCo *loop = NULL;
- Volume *vol = NULL;
- bool have_loop = true;
- if( ret==0 )
- {
- have_loop = haveLoop(loop);
- y2mil( "have_loop:" << have_loop );
- if( !have_loop )
- {
- ProcPart ppart;
- loop = new LoopCo( this, false, ppart );
- }
- if( loop==NULL )
- ret = STORAGE_MEMORY_EXHAUSTED;
- }
- if( ret==0 )
+ else if( haveBtrfs(co) )
{
- ret = loop->createLoop( lname, reuseExisting, sizeK, true, device );
+ ret = co->removeSubvolume( device, name );
}
- if( ret==0 && !loop->findVolume( device, vol ))
+ else
{
- ret = STORAGE_CREATED_LOOP_NOT_FOUND;
+ ret = STORAGE_BTRFS_CO_NOT_FOUND;
}
if( ret==0 )
{
- ret = vol->setCryptPwd( pwd );
+ ret = checkCache();
}
- if( ret==0 && (!reuseExisting || access( (root()+lname).c_str(), R_OK )!=0 ))
+ y2mil("ret:" << ret);
+ return( ret );
+ }
+
+int Storage::extendBtrfsVolume( const string& device, const string& dev )
+ {
+ deque<string> d;
+ d.push_back(dev);
+ return( extendBtrfsVolume(device,d));
+ }
+
+int Storage::extendBtrfsVolume( const string& device, const deque<string>& devs )
+ {
+ int ret = 0;
+ assertInit();
+ y2mil("device:" << device << "devices:" << devs );
+ BtrfsCo* co;
+ if (readonly())
{
- ret = vol->setFormat( true, EXT3 );
+ ret = STORAGE_CHANGE_READONLY;
}
- if( ret==0 )
+ else if( devs.empty() )
{
- ret = vol->setEncryption( true );
+ ret = BTRFS_LIST_EMPTY;
}
- if( ret==0 && !mp.empty() )
+ else if( haveBtrfs(co) )
{
- ret = vol->changeMount( mp );
+ list<string> d(devs.begin(), devs.end());
+ ret = co->extendVolume( device, d );
}
- if( !have_loop )
+ else
{
- if( ret==0 )
- {
- addToList( loop );
- }
- else if( loop!=NULL )
- delete loop;
+ ret = STORAGE_BTRFS_CO_NOT_FOUND;
}
if( ret==0 )
{
ret = checkCache();
}
- y2milestone( "ret:%d device:%s", ret, ret==0?device.c_str():"" );
+ y2mil("ret:" << ret);
return( ret );
}
-int
-Storage::modifyFileLoop( const string& device, const string& lname,
- bool reuseExisting, unsigned long long sizeK )
+int Storage::shrinkBtrfsVolume( const string& device, const string& dev )
+ {
+ deque<string> d;
+ d.push_back(dev);
+ return( shrinkBtrfsVolume(device,d));
+ }
+
+int Storage::shrinkBtrfsVolume( const string& device, const deque<string>& devs )
{
int ret = 0;
assertInit();
- y2milestone( "device:%s lname:%s reuse:%d sizeK:%lld", device.c_str(),
- lname.c_str(), reuseExisting, sizeK );
- if( readonly() )
+ y2mil("device:" << device << "devices:" << devs );
+ BtrfsCo* co;
+ if (readonly())
{
ret = STORAGE_CHANGE_READONLY;
}
- if( ret==0 )
+ else if( devs.empty() )
{
- LoopCo *loop = NULL;
- if( haveLoop(loop) )
- ret = loop->updateLoop( device, lname, reuseExisting, sizeK );
- else
- ret = STORAGE_LOOP_NOT_FOUND;
+ ret = BTRFS_LIST_EMPTY;
+ }
+ else if( haveBtrfs(co) )
+ {
+ list<string> d(devs.begin(), devs.end());
+ ret = co->shrinkVolume( device, d );
+ }
+ else
+ {
+ ret = STORAGE_BTRFS_CO_NOT_FOUND;
}
if( ret==0 )
{
@@ -4243,23 +4487,33 @@
return( ret );
}
-int
-Storage::removeFileLoop( const string& lname, bool removeFile )
+int Storage::addTmpfsMount( const string& mp, const string& opts )
{
int ret = 0;
assertInit();
- y2milestone( "lname:%s removeFile:%d", lname.c_str(), removeFile );
- if( readonly() )
+ y2mil("mount:" << mp << " opts:" << opts );
+ if (readonly())
{
ret = STORAGE_CHANGE_READONLY;
}
+ TmpfsCo *co = NULL;
+ bool have = true;
if( ret==0 )
{
- LoopCo *loop = NULL;
- if( haveLoop(loop) )
- ret = loop->removeLoop( lname, removeFile );
- else
- ret = STORAGE_LOOP_NOT_FOUND;
+ have = haveTmpfs(co);
+ if( !have )
+ co = new TmpfsCo( this );
+ }
+ if( ret==0 && co!=NULL )
+ {
+ ret = co->addTmpfs(mp, opts);
+ }
+ if( !have )
+ {
+ if( ret==0 )
+ addToList( co );
+ else if( co!=NULL )
+ delete co;
}
if( ret==0 )
{
@@ -4269,30 +4523,34 @@
return( ret );
}
-
-bool Storage::haveLoop( LoopCo*& loop )
- {
- loop = NULL;
- CPair p = cPair();
- ContIterator i = p.begin();
- while( i != p.end() && i->type()!=LOOP )
- ++i;
- if( i != p.end() )
- loop = static_cast<LoopCo*>(&(*i));
- return( i != p.end() );
- }
-
-int Storage::removeDmraid( const string& name )
+int Storage::removeTmpfsMount( const string& mp )
{
int ret = 0;
assertInit();
- DmraidCoIterator i = findDmraidCo( name );
- if( i != dmrCoEnd() )
+ y2mil("mount:" << mp );
+ if (readonly())
{
- ret = i->removeDmPart();
+ ret = STORAGE_CHANGE_READONLY;
}
- else
- ret = STORAGE_DMRAID_CO_NOT_FOUND;
+ TmpfsCo *co = NULL;
+ bool have = true;
+ if( ret==0 )
+ {
+ have = haveTmpfs(co);
+ }
+ if( ret==0 && co!=NULL )
+ {
+ ret = co->removeTmpfs(mp);
+ }
+ else if( ret==0 )
+ {
+ ret = STORAGE_TMPFS_CO_NOT_FOUND;
+ }
+ if( ret==0 )
+ {
+ ret = checkCache();
+ }
+ y2mil("ret:" << ret);
return( ret );
}
@@ -4305,55 +4563,59 @@
}
-deque<string>
-Storage::getCommitActions(bool mark_destructive) const
+list<commitAction>
+Storage::getCommitActions() const
{
- CommitInfo info;
- getCommitInfo(mark_destructive, info);
- return info.actions;
+ ConstContPair p = contPair();
+ list<commitAction> ca;
+ for (ConstContIterator it = p.begin(); it != p.end(); ++it)
+ {
+ list<commitAction> l;
+ it->getCommitActions(l);
+ ca.splice(ca.end(), l);
+ }
+ ca.sort();
+ return ca;
}
void
-Storage::getCommitInfo(bool mark_destructive, CommitInfo& info) const
+Storage::getCommitInfos(list<CommitInfo>& infos) const
{
- info.destructive = false;
- info.actions.clear();
-
- ConstContPair p = contPair();
- y2mil("empty:" << p.empty());
- if( !p.empty() )
- {
- list<commitAction*> ac;
- for( ConstContIterator i = p.begin(); i != p.end(); ++i )
+ static list<CommitInfo> s_infos; // workaround for broken ycp bindings
+ s_infos.clear();
+
+ const list<commitAction> ca = getCommitActions();
+ for (list<commitAction>::const_iterator i = ca.begin(); i != ca.end(); ++i)
{
- list<commitAction*> l;
- i->getCommitActions( l );
- ac.splice( ac.end(), l );
- }
- ac.sort( cont_less<commitAction>() );
- string txt;
- for( list<commitAction*>::const_iterator i=ac.begin(); i!=ac.end(); ++i )
- {
- if ((*i)->destructive)
- info.destructive = true;
- txt.erase();
- if( mark_destructive && (*i)->destructive )
- txt += "<font color=red>";
- txt += (*i)->descr;
- const Volume *v = (*i)->vol();
+ CommitInfo info;
+ info.destructive = i->destructive;
+ info.text = i->description.text;
+ const Volume* v = i->vol();
if( v && !v->getDescText().empty() )
{
- txt += ". ";
- txt += v->getDescText();
+ info.text += ". ";
+ info.text += v->getDescText();
}
- if( mark_destructive && (*i)->destructive )
- txt += "</font>";
- info.actions.push_back( txt );
- delete *i;
+ s_infos.push_back(info);
}
+
+ infos = s_infos;
+ y2mil("infos.size:" << infos.size());
+}
+
+
+void
+Storage::dumpCommitInfos() const
+{
+ const list<commitAction> ca = getCommitActions();
+ for (list<commitAction>::const_iterator it = ca.begin(); it != ca.end(); ++it)
+ {
+ string text = it->description.native;
+ if (it->destructive)
+ text += " [destructive]";
+ y2mil("ChangeText " << text);
}
- y2mil("destructive:" << info.destructive << " actions.size():" << info.actions.size());
}
@@ -4424,9 +4686,10 @@
return( rhs->getMount()<lhs->getMount() );
}
+
void
-Storage::sortCommitLists( CommitStage stage, list<Container*>& co,
- list<Volume*>& vl, list<commitAction*>& todo )
+Storage::sortCommitLists(CommitStage stage, list<const Container*>& co,
+ list<const Volume*>& vl, list<commitAction>& todo) const
{
co.sort( (stage==DECREASE)?sort_cont_up:sort_cont_down );
std::ostringstream b;
@@ -4442,28 +4705,28 @@
vl.sort( sort_vol_mount );
else
vl.sort( sort_vol_normal );
- for( list<Container*>::const_iterator i=co.begin(); i!=co.end(); ++i )
- todo.push_back( new commitAction( stage, (*i)->type(), *i ));
- for( list<Volume*>::const_iterator i=vl.begin(); i!=vl.end(); ++i )
- todo.push_back( new commitAction( stage, (*i)->cType(), *i ));
+ for( list<const Container*>::const_iterator i=co.begin(); i!=co.end(); ++i )
+ todo.push_back(commitAction(stage, (*i)->type(), *i));
+ for( list<const Volume*>::const_iterator i=vl.begin(); i!=vl.end(); ++i )
+ todo.push_back(commitAction(stage, (*i)->cType(), *i));
b.str("");
b << "unsorted actions <";
- for( list<commitAction*>::const_iterator i=todo.begin(); i!=todo.end(); ++i )
+ for (list<commitAction>::const_iterator i = todo.begin(); i != todo.end(); ++i)
{
if( i!=todo.begin() )
b << " ";
- if( (*i)->container )
- b << "C:" << (*i)->co()->device();
+ if( i->container )
+ b << "C:" << i->co()->device();
else
- b << "V:" << (*i)->vol()->device();
+ b << "V:" << i->vol()->device();
}
b << "> ";
y2mil(b.str());
b.str("");
- todo.sort( cont_less<commitAction>() );
- y2milestone( "stage %d", stage );
+ todo.sort();
+ y2mil("stage:" << stage);
b << "sorted co <";
- for( list<Container*>::const_iterator i=co.begin(); i!=co.end(); ++i )
+ for( list<const Container*>::const_iterator i=co.begin(); i!=co.end(); ++i )
{
if( i!=co.begin() )
b << " ";
@@ -4473,7 +4736,7 @@
y2mil(b.str());
b.str("");
b << "sorted vol <";
- for( list<Volume*>::const_iterator i=vl.begin(); i!=vl.end(); ++i )
+ for( list<const Volume*>::const_iterator i=vl.begin(); i!=vl.end(); ++i )
{
if( i!=vl.begin() )
b << " ";
@@ -4483,14 +4746,14 @@
y2mil(b.str());
b.str("");
b << "sorted actions <";
- for( list<commitAction*>::const_iterator i=todo.begin(); i!=todo.end(); ++i )
+ for (list<commitAction>::const_iterator i = todo.begin(); i != todo.end(); ++i)
{
if( i!=todo.begin() )
b << " ";
- if( (*i)->container )
- b << "C:" << (*i)->co()->device();
+ if( i->container )
+ b << "C:" << i->co()->device();
else
- b << "V:" << (*i)->vol()->device();
+ b << "V:" << i->vol()->device();
}
b << "> ";
y2mil(b.str());
@@ -4506,7 +4769,7 @@
SystemCmd c( "ps ax | grep -w /usr/sbin/hald | grep -v grep" );
if( c.numLines()>0 )
{
- extractNthWord( 0, *c.getLine(0) ) >> hald_pid;
+ extractNthWord( 0, c.getLine(0) ) >> hald_pid;
y2mil( "hald_pid:" << hald_pid );
}
if( hald_pid>0 )
@@ -4531,16 +4794,16 @@
assertInit();
lastAction.clear();
extendedError.clear();
- SystemCmd c;
+ dumpCommitInfos();
CPair p = cPair( notLoop );
int ret = 0;
- y2milestone( "empty:%d", p.empty() );
+ y2mil("empty:" << p.empty());
if( !p.empty() )
{
ret = commitPair( p, notLoop );
}
p = cPair( isLoop );
- y2milestone( "empty:%d", p.empty() );
+ y2mil("empty:" << p.empty());
if( ret==0 && !p.empty() )
{
ret = commitPair( p, isLoop );
@@ -4554,62 +4817,67 @@
return( ret );
}
-bool
-Storage::ignoreError( list<commitAction*>::iterator i,
- list<commitAction*>& al )
+
+string
+Storage::getErrorString(int error) const
+{
+ switch (error)
{
- bool ret = false;
- if( !(*i)->container && (*i)->type==DISK && (*i)->stage==DECREASE )
- {
- ++i;
- while( ret==false && i!=al.end() )
- {
- y2mil( "it:" << **i );
- ret = (*i)->container && (*i)->type==DISK && (*i)->stage==DECREASE;
- ++i;
- }
- }
- y2mil( "ret:" << ret );
- return( ret );
+ case VOLUME_UMOUNT_FAILED:
+ return _("Unmount failed.").text;
+
+ default:
+ return "";
}
+}
+
+
+bool
+Storage::ignoreError(int error, list<commitAction>::const_iterator ca) const
+{
+ bool ret = commitErrorPopupCb(error, lastAction, extendedError);
+
+ if (ret)
+ y2mil("user decided to continue after commit error");
+
+ return ret;
+}
+
int
Storage::commitPair( CPair& p, bool (* fnc)( const Container& ) )
{
int ret = 0;
- y2milestone( "p.length:%d", p.length() );
- CommitStage a[] = { DECREASE, INCREASE, FORMAT, MOUNT };
- CommitStage* pt = a;
- while( unsigned(pt-a) < lengthof(a) )
+ y2mil("p.length:" << p.length());
+
+ typedef array<CommitStage, 5> Stages;
+ const Stages stages = { { DECREASE, INCREASE, FORMAT, MOUNT, SUBVOL } };
+
+ for (Stages::const_iterator stage = stages.begin(); stage != stages.end(); ++stage)
+ {
+ list<const Container*> colist;
+ list<const Volume*> vlist;
+
+ if (ret == 0)
{
+ for (ContIterator i = p.begin(); i != p.end(); ++i)
+ i->getToCommit(*stage, colist, vlist);
+ }
+
bool new_pair = false;
- list<Container*> colist;
- list<Volume*> vlist;
- ContIterator i = p.begin();
- while( ret==0 && i != p.end() )
- {
- ret = i->getToCommit( *pt, colist, vlist );
- ++i;
- }
-#if 0
- if( *pt == FORMAT && instsys() )
- {
- activateHld( true );
- }
-#endif
- list<commitAction*> todo;
- sortCommitLists( *pt, colist, vlist, todo );
- list<commitAction*>::iterator ac = todo.begin();
+ list<commitAction> todo;
+ sortCommitLists(*stage, colist, vlist, todo);
+ list<commitAction>::iterator ac = todo.begin();
while( ret==0 && ac != todo.end() )
{
- bool cont = (*ac)->container;
- CType type = (*ac)->type;
- Container *co = cont ? const_cast<Container*>((*ac)->co()) :
- const_cast<Container*>((*ac)->vol()->getContainer());
+ bool cont = ac->container;
+ CType type = ac->type;
+ Container *co = cont ? const_cast<Container*>(ac->co()) :
+ const_cast<Container*>(ac->vol()->getContainer());
if( cont )
{
- bool cont_removed = co->deleted() && (type==LVM || type==MDPART);
- ret = co->commitChanges( *pt );
+ bool cont_removed = co->deleted() && (type == LVM || type == MDPART);
+ ret = co->commitChanges(*stage);
cont_removed = cont_removed && ret==0;
if( cont_removed )
{
@@ -4619,24 +4887,22 @@
}
else
{
- ret = co->commitChanges( *pt, const_cast<Volume*>((*ac)->vol()) );
+ ret = co->commitChanges(*stage, const_cast<Volume*>(ac->vol()));
}
if( ret!=0 )
{
- y2mil( "err at " << **ac );
- if( ignoreError( ac, todo ))
+ y2mil("err at " << *ac);
+ if (ignoreError(ret, ac))
ret = 0;
}
- delete( *ac );
++ac;
}
- y2milestone( "stage:%d new_pair:%d", *pt, new_pair );
+ y2mil("stage:" << *stage << " new_pair:" << new_pair);
if( new_pair )
{
p = cPair( fnc );
new_pair = false;
}
- pt++;
if( !todo.empty() )
{
SystemCmd c;
@@ -4680,10 +4946,10 @@
}
}
else
- y2warning( "not a Dm descendant %s", v->device().c_str() );
+ y2war("not a Dm descendant " << v->device());
}
- VolIterator v;
- DiskIterator d;
+ ConstVolIterator v;
+ ConstDiskIterator d;
if( findVolume( dev, v ))
{
v->triggerUdevUpdate();
@@ -4713,19 +4979,19 @@
}
}
else
- y2warning( "not a Dm descendant %s", v->device().c_str() );
+ y2war("not a Dm descendant " << v->device());
}
}
bool Storage::checkDmMapsTo( const string& dev )
{
bool ret = false;
- y2milestone( "dev:%s", dev.c_str() );
+ y2mil("dev:" << dev);
VPair vp = vPair( isDmContainer );
- VolIterator v=vp.begin();
+ ConstVolIterator v=vp.begin();
while( !ret && v!=vp.end() )
{
- Dm * dm = dynamic_cast<Dm *>(&(*v));
+ const Dm* dm = dynamic_cast<const Dm*>(&(*v));
if( dm!=NULL )
ret = ret && dm->mapsTo( dev );
++v;
@@ -4738,11 +5004,9 @@
{
y2mil( "old:" << old << " new:" << nw );
CPair p = cPair();
- ContIterator ci = p.begin();
- while( ci!=p.end() )
+ for (ContIterator ci = p.begin(); ci != p.end(); ++ci)
{
ci->changeDeviceName( old, nw );
- ++ci;
}
}
@@ -4752,24 +5016,20 @@
{
dl.clear();
DiskPair dp = dPair( CheckFnc );
- DiskIterator i = dp.begin();
- while( i!=dp.end() )
+ for (DiskIterator i = dp.begin(); i != dp.end(); ++i)
{
y2mil( "disk:" << i->device() );
dl.push_back( &(*i) );
- ++i;
}
}
-static bool showContainers( const Container& c )
- { return( !c.deleted()||c.type()==DISK ); }
void
Storage::getContainers( deque<ContainerInfo>& infos )
{
- infos.clear ();
+ infos.clear();
assertInit();
- ConstContPair p = contPair( showContainers );
+ ConstContPair p = contPair(Container::notDeleted);
for( ConstContIterator i = p.begin(); i != p.end(); ++i)
{
y2mil( "co:" << *i );
@@ -4791,152 +5051,42 @@
}
}
-int
-Storage::getContVolInfo( const string& device, ContVolInfo& info)
+int
+Storage::getContVolInfo(const string& device, ContVolInfo& info)
{
- int ret = 0;
- string dev = device;
- ContIterator c;
- VolIterator v;
- info.type = CUNKNOWN;
- assertInit();
- if( findVolume( dev, c, v ))
- {
- info.type = c->type();
- info.cname = c->device();
+ int ret = STORAGE_VOLUME_NOT_FOUND;
+ ConstContIterator c;
+ ConstVolIterator v;
+ info.ctype = CUNKNOWN;
+ assertInit();
+ if (findVolume(device, c, v))
+ {
+ ret = 0;
+ info.ctype = c->type();
+ info.cname = c->name();
+ info.cdevice = c->device();
info.vname = v->name();
- info.numeric = v->isNumeric();
- if( info.numeric )
- info.nr = v->nr();
- else
- info.nr = 0;
- }
- else
- {
- DiskIterator d;
- DmraidCoIterator r;
- DmmultipathCoIterator m;
- MdPartCoIterator md;
- std::pair<string,unsigned> p = Disk::getDiskPartition( dev );
- if( p.first=="/dev/md" )
- {
- info.cname = p.first;
- info.vname = undevDevice(device);
- info.type = MD;
- info.numeric = true;
- info.nr = p.second;
- }
- else if( p.first=="/dev/loop" )
- {
- info.cname = p.first;
- info.vname = undevDevice(device);
- info.type = LOOP;
- info.numeric = true;
- info.nr = p.second;
- }
- else if( p.first=="/dev/dm-" )
- {
- info.cname = p.first;
- info.vname = undevDevice(device);
- info.type = DM;
- info.numeric = true;
- info.nr = p.second;
- }
- else if( (d=findDisk(p.first))!=dEnd() )
- {
- info.cname = d->device();
- info.vname = dev.substr( dev.find_last_of('/')+1 );
- info.type = DISK;
- info.numeric = true;
- info.nr = p.second;
- }
- else if( (r=findDmraidCo(p.first))!=dmrCoEnd() )
- {
- info.cname = r->device();
- info.vname = dev.substr( dev.find_last_of('/')+1 );
- info.type = DMRAID;
- info.numeric = true;
- info.nr = p.second;
- }
- else if( (md=findMdPartCo(p.first))!=mdpCoEnd() )
- {
- info.cname = md->device();
- info.vname = dev.substr( dev.find_last_of('/')+1 );
- info.type = MDPART;
- info.numeric = true;
- info.nr = p.second;
- }
- else if( (m=findDmmultipathCo(p.first))!=dmmCoEnd() )
- {
- info.cname = m->device();
- info.vname = dev.substr( dev.find_last_of('/')+1 );
- info.type = DMMULTIPATH;
- info.numeric = true;
- info.nr = p.second;
- }
- else if( dev.find("/dev/disk/by-uuid/")==0 ||
- dev.find("/dev/disk/by-label/")==0 ||
- dev.find("UUID=")==0 || dev.find("LABEL=")==0 )
- {
- if( dev[0] == '/' )
- {
- bool uuid = dev.find( "/by-uuid/" )!=string::npos;
- dev.erase( 0, dev.find_last_of('/')+1 );
- dev = (uuid?"UUID=":"LABEL=")+dev;
- }
- if( findVolume(dev, v) )
- {
- info.type = v->cType();
- info.numeric = v->isNumeric();
- if( info.numeric )
- info.nr = v->nr();
- info.vname = v->name();
- info.cname = v->getContainer()->name();
- }
- }
- else if( (dev.find("/dev/disk/by-id/")==0 &&
- (d=findDiskId(p.first))!=dEnd()) ||
- (dev.find("/dev/disk/by-path/")==0 &&
- (d=findDiskPath(p.first))!=dEnd()) )
- {
- info.type = DISK;
- info.numeric = true;
- info.nr = p.second;
- info.cname = d->device();
- if( p.second>0 )
- info.vname = Disk::getPartName( d->name(), p.second );
- else
- info.vname = d->name();
- if( info.vname.find('/')!=string::npos )
- info.vname.erase( 0, info.vname.find_last_of('/')+1 );
- }
- else if( splitString( dev, "/" ).size()==3 && !Disk::needP( dev ) )
- {
- info.type = LVM;
- info.numeric = false;
- info.vname = dev.substr( dev.find_last_of('/')+1 );
- info.cname = dev.substr( 0, dev.find_last_of('/') );
- }
- else
- {
- info.cname = p.first;
- info.vname = dev.substr( dev.find_last_of('/')+1 );
- info.numeric = true;
- info.nr = p.second;
- }
+ info.vdevice = v->device();
}
- y2mil( "dev:" << dev << " ret:" << ret << " cn:" << info.cname <<
- " vn:" << info.vname );
- if( info.numeric )
- y2mil( "nr:" << info.nr );
- return( ret );
+ else if (findContainer(device, c))
+ {
+ ret = 0;
+ info.ctype = c->type();
+ info.cname = c->name();
+ info.cdevice = c->device();
+ info.vname = "";
+ info.vdevice = "";
+ }
+ y2mil("device:" << device << " ret:" << ret << " cname:" << info.cname <<
+ " vname:" << info.vname);
+ return ret;
}
int
Storage::getVolume( const string& device, VolumeInfo& info )
{
int ret = 0;
- VolIterator v;
+ ConstVolIterator v;
if( findVolume( device, v ))
{
v->getInfo( info );
@@ -4952,7 +5102,7 @@
{
int ret = 0;
assertInit();
- DiskIterator i = findDisk( disk );
+ ConstDiskIterator i = findDisk( disk );
if( i != dEnd() )
{
i->getInfo( info );
@@ -4967,10 +5117,10 @@
{
int ret = 0;
assertInit();
- DiskIterator i = findDisk( disk );
+ ConstDiskIterator i = findDisk( disk );
if( i != dEnd() )
{
- ((const Container*)&(*i))->getInfo( cinfo );
+ i->Container::getInfo(cinfo);
i->getInfo( info );
}
else
@@ -4978,46 +5128,36 @@
return( ret );
}
-
int Storage::getPartitionInfo( const string& disk,
deque<storage::PartitionInfo>& plist )
{
int ret = 0;
- bool done = false;
plist.clear();
assertInit();
- DiskIterator i = findDisk( disk );
- if( i != dEnd() )
+ ConstDiskIterator i = findDisk(disk);
+ if (i != dEnd())
+ {
+ // TODO: those partitions shouldn't be detected at all
+ if (!i->isUsedBy())
{
- Disk::PartPair p = i->partPair (Disk::notDeleted);
- for (Disk::PartIter i2 = p.begin(); i2 != p.end(); ++i2)
+ Disk::ConstPartPair p = i->partPair(Partition::notDeleted);
+ for (Disk::ConstPartIter i2 = p.begin(); i2 != p.end(); ++i2)
{
- plist.push_back( PartitionInfo() );
- i2->getInfo( plist.back() );
+ plist.push_back(PartitionInfo());
+ i2->getInfo(plist.back());
}
- done = true;
}
- if( done == false )
- {
- MdPartCoIterator i = findMdPartCo( disk );
- if( i != mdpCoEnd() )
- {
- ret = i->getPartitionInfo( plist );
- done = false;
- }
- }
- if( done == false)
- {
+ }
+ else
ret = STORAGE_DISK_NOT_FOUND;
- }
- return( ret );
+ return ret;
}
int Storage::getLvmVgInfo( const string& name, LvmVgInfo& info )
{
int ret = 0;
assertInit();
- LvmVgIterator i = findLvmVg( name );
+ ConstLvmVgIterator i = findLvmVg( name );
if( i != lvgEnd() )
{
i->getInfo( info );
@@ -5032,10 +5172,10 @@
{
int ret = 0;
assertInit();
- LvmVgIterator i = findLvmVg( name );
+ ConstLvmVgIterator i = findLvmVg( name );
if( i != lvgEnd() )
{
- ((const Container*)&(*i))->getInfo( cinfo );
+ i->Container::getInfo(cinfo);
i->getInfo( info );
}
else
@@ -5049,11 +5189,11 @@
int ret = 0;
plist.clear();
assertInit();
- LvmVgIterator i = findLvmVg( name );
+ ConstLvmVgIterator i = findLvmVg( name );
if( i != lvgEnd() )
{
- LvmVg::LvmLvPair p = i->lvmLvPair(LvmVg::lvNotDeleted);
- for( LvmVg::LvmLvIter i2 = p.begin(); i2 != p.end(); ++i2)
+ LvmVg::ConstLvmLvPair p = i->lvmLvPair(LvmLv::notDeleted);
+ for( LvmVg::ConstLvmLvIter i2 = p.begin(); i2 != p.end(); ++i2)
{
plist.push_back( LvmLvInfo() );
i2->getInfo( plist.back() );
@@ -5069,7 +5209,7 @@
{
int ret = 0;
assertInit();
- DmraidCoIterator i = findDmraidCo( name );
+ ConstDmraidCoIterator i = findDmraidCo( name );
if( i != dmrCoEnd() )
{
i->getInfo( info );
@@ -5084,10 +5224,10 @@
{
int ret = 0;
assertInit();
- DmraidCoIterator i = findDmraidCo( name );
+ ConstDmraidCoIterator i = findDmraidCo( name );
if( i != dmrCoEnd() )
{
- ((const Container*)&(*i))->getInfo( cinfo );
+ i->Container::getInfo(cinfo);
i->getInfo( info );
}
else
@@ -5101,7 +5241,7 @@
{
int ret = 0;
assertInit();
- DmmultipathCoIterator i = findDmmultipathCo( name );
+ ConstDmmultipathCoIterator i = findDmmultipathCo( name );
if( i != dmmCoEnd() )
{
i->getInfo( info );
@@ -5117,10 +5257,10 @@
{
int ret = 0;
assertInit();
- DmmultipathCoIterator i = findDmmultipathCo( name );
+ ConstDmmultipathCoIterator i = findDmmultipathCo( name );
if( i != dmmCoEnd() )
{
- ((const Container*)&(*i))->getInfo( cinfo );
+ i->Container::getInfo(cinfo);
i->getInfo( info );
}
else
@@ -5147,7 +5287,7 @@
{
int ret = 0;
assertInit();
- MdPartCoIterator i = findMdPartCo( name );
+ ConstMdPartCoIterator i = findMdPartCo( name );
if( i != mdpCoEnd() )
{
i->getInfo( info );
@@ -5162,10 +5302,10 @@
{
int ret = 0;
assertInit();
- MdPartCoIterator i = findMdPartCo( name );
+ ConstMdPartCoIterator i = findMdPartCo( name );
if( i != mdpCoEnd() )
{
- ((const Container*)&(*i))->getInfo( cinfo );
+ i->Container::getInfo(cinfo);
i->getInfo( info );
}
else
@@ -5249,7 +5389,7 @@
DmraidCoIterator i = findDmraidCo( name );
if( i != dmrCoEnd() )
{
- DmraidCo::DmraidPair p = i->dmraidPair(DmraidCo::raidNotDeleted);
+ DmraidCo::DmraidPair p = i->dmraidPair(Dmraid::notDeleted);
for( DmraidCo::DmraidIter i2 = p.begin(); i2 != p.end(); ++i2 )
{
plist.push_back( DmraidInfo() );
@@ -5269,11 +5409,11 @@
int ret = 0;
plist.clear();
assertInit();
- DmmultipathCoIterator i = findDmmultipathCo( name );
+ ConstDmmultipathCoIterator i = findDmmultipathCo( name );
if( i != dmmCoEnd() )
{
- DmmultipathCo::DmmultipathPair p = i->dmmultipathPair(DmmultipathCo::multipathNotDeleted);
- for( DmmultipathCo::DmmultipathIter i2 = p.begin(); i2 != p.end(); ++i2 )
+ DmmultipathCo::ConstDmmultipathPair p = i->dmmultipathPair(Dmmultipath::notDeleted);
+ for( DmmultipathCo::ConstDmmultipathIter i2 = p.begin(); i2 != p.end(); ++i2 )
{
plist.push_back( DmmultipathInfo() );
i2->getInfo( plist.back() );
@@ -5284,6 +5424,33 @@
return( ret );
}
+int Storage::getBtrfsInfo( deque<storage::BtrfsInfo>& plist )
+ {
+ int ret = 0;
+ plist.clear();
+ assertInit();
+ ConstBtrfsPair p = btrfsPair(Btrfs::notDeleted);
+ for( ConstBtrfsIterator i = p.begin(); i != p.end(); ++i )
+ {
+ plist.push_back( BtrfsInfo() );
+ i->getInfo( plist.back() );
+ }
+ return( ret );
+ }
+
+int Storage::getTmpfsInfo( deque<storage::TmpfsInfo>& plist )
+ {
+ int ret = 0;
+ plist.clear();
+ assertInit();
+ ConstTmpfsPair p = tmpfsPair(Tmpfs::notDeleted);
+ for( ConstTmpfsIterator i = p.begin(); i != p.end(); ++i )
+ {
+ plist.push_back( TmpfsInfo() );
+ i->getInfo( plist.back() );
+ }
+ return( ret );
+ }
list<string> Storage::getAllUsedFs() const
{
@@ -5298,7 +5465,7 @@
list<string> ret;
for( set<FsType>::const_iterator i=fs.begin(); i!=fs.end(); ++i )
{
- ret.push_back(Volume::fsTypeString(*i));
+ ret.push_back(toString(*i));
}
y2mil( "ret:" << ret );
return ret;
@@ -5338,6 +5505,12 @@
static FsCapabilitiesX ext3Caps (true, true, true, false, true, true,
true, 16, 10*1024);
+ static FsCapabilitiesX ext4Caps (true, true, true, false, true, true,
+ true, 16, 32*1024);
+
+ static FsCapabilitiesX btrfsCaps (false, false, false, false, true, false,
+ false, 0, 256*1024);
+
static FsCapabilitiesX xfsCaps (true, true, false, false, true, true,
false, 12, 40*1024);
@@ -5348,7 +5521,7 @@
false, 0, 16);
static FsCapabilitiesX swapCaps (true, false, true, false, true, true,
- true, 16, 64);
+ false, 16, 64);
static FsCapabilitiesX jfsCaps (false, false, false, false, true, true,
false, 16, 16*1024);
@@ -5376,6 +5549,14 @@
fscapabilities = ext3Caps;
return true;
+ case EXT4:
+ fscapabilities = ext4Caps;
+ return true;
+
+ case BTRFS:
+ fscapabilities = btrfsCaps;
+ return true;
+
case XFS:
fscapabilities = xfsCaps;
return true;
@@ -5413,12 +5594,27 @@
}
}
+
bool
Storage::getDlabelCapabilities(const string& dlabel, DlabelCapabilities& dlabelcapabilities) const
{
return Disk::getDlabelCapabilities(dlabel, dlabelcapabilities);
}
+void Storage::removeDmTableTo( unsigned long mjr, unsigned long mnr )
+ {
+ y2mil( "mjr:" << mjr << " mnr:" << mnr );
+ string cmd = DMSETUPBIN " table | grep -w ";
+ cmd += decString(mjr) + ":" + decString(mnr);
+ cmd += " | sed s/:.*// | uniq";
+ SystemCmd c( cmd );
+ unsigned line=0;
+ while( line<c.numLines() )
+ {
+ removeDmTable( c.getLine(line) );
+ line++;
+ }
+ }
void Storage::removeDmTableTo( const Volume& vol )
@@ -5433,17 +5629,8 @@
removeDmMapsTo( vol.getContainer()->device() );
if( vol.getContainer()->majorNr()>0 )
{
- string cmd = DMSETUPBIN " table | grep -w ";
- cmd += decString(vol.getContainer()->majorNr()) + ":" +
- decString(vol.getContainer()->minorNr());
- cmd += " | sed s/:.*// | uniq";
- SystemCmd c( cmd );
- unsigned line=0;
- while( line<c.numLines() )
- {
- removeDmTable( *c.getLine(line) );
- line++;
- }
+ removeDmTableTo( vol.getContainer()->majorNr(),
+ vol.getContainer()->minorNr() );
}
}
}
@@ -5476,17 +5663,6 @@
void
-Storage::logCo(const string& device)
-{
- ContIterator cc;
- if( findContainer( device, cc ))
- logCo( &(*cc) );
- else
- y2mil( "not found:" << device );
-}
-
-
-void
Storage::logCo(const Container* c) const
{
std::ostringstream b;
@@ -5502,25 +5678,41 @@
}
-void Storage::logProcData( const string& l )
+ void
+ Storage::logProcData(const string& str) const
{
- y2mil( "begin:" << l );
- ProcPart t;
- AsciiFile md( "/proc/mdstat" );
- for( unsigned i=0; i<md.numLines(); i++ )
- y2mil( "mdstat:" << i+1 << ". line:" << md[i] );
- AsciiFile mo( "/proc/mounts" );
- for( unsigned i=0; i<mo.numLines(); i++ )
- y2mil( "mounts:" << i+1 << ". line:" << mo[i] );
- y2mil( "end" << l );
+ y2mil("begin:" << str);
+
+ if (!testmode())
+ {
+ AsciiFile("/proc/partitions").logContent();
+ AsciiFile("/proc/mdstat").logContent();
+ AsciiFile("/proc/mounts").logContent();
+ AsciiFile("/proc/swaps").logContent();
+ }
+
+ y2mil("end" << str);
}
+bool Storage::findVolume( const string& device, ConstContIterator& c,
+ ConstVolIterator& v )
+ {
+ ContIterator ct;
+ VolIterator vt;
+ bool ret = findVolume( device, ct, vt );
+ if( ret )
+ {
+ c = ct;
+ v = vt;
+ }
+ return( ret );
+ }
bool Storage::findVolume( const string& device, ContIterator& c,
- VolIterator& v )
+ VolIterator& v, bool no_btrfs )
{
bool ret = false;
- if( findVolume( device, v ))
+ if( findVolume( device, v, false, no_btrfs ))
{
const Container *co = v->getContainer();
CPair cp = cPair();
@@ -5529,9 +5721,8 @@
++c;
ret = c!=cp.end();
}
- y2milestone( "device:%s ret:%d c->device:%s v->device:%s", device.c_str(),
- ret, ret?c->device().c_str():"nil",
- ret?v->device().c_str():"nil" );
+ y2mil("device:" << device << " ret:" << ret << " c->device:" << (ret?c->device():"NULL") <<
+ " v->device:" << (ret?v->device():"NULL"));
return( ret );
}
@@ -5587,23 +5778,58 @@
{
c->removeFromList( const_cast<Dm*>(dm) );
if( c->isEmpty() )
- removeContainer( &(*c), true );
+ removeContainer( &(*c) );
}
}
y2mil( "device:" << device << " ret:" << (dm!=0) );
return( dm!=0 );
}
+int Storage::unaccessDev( const string& device )
+ {
+ int ret = 0;
+ VolIterator v;
+ if( findVolume(device, v) )
+ {
+ v->setSilent(true);
+ ret = v->unaccessVol();
+ v->setSilent(false);
+ }
+ else
+ ret = STORAGE_VOLUME_NOT_FOUND;
+ y2mil( "device:" << device << " ret:" << ret );
+ return( ret );
+ }
+
+bool Storage::findContainer( const string& device, ConstContIterator& c )
+ {
+ ContIterator tmp;
+ bool ret = findContainer( device, tmp );
+ if( ret )
+ c = tmp;
+ return( ret );
+ }
+
bool Storage::findContainer( const string& device, ContIterator& c )
{
CPair cp = cPair();
c = cp.begin();
- while( c!=cp.end() && c->sameDevice(device))
+ while (c != cp.end() && !c->sameDevice(device))
++c;
return( c!=cp.end() );
}
-bool Storage::findVolume( const string& device, VolIterator& v, bool also_del )
+bool Storage::findVolume( const string& device, ConstVolIterator& v, bool also_del, bool no_btrfsc )
+ {
+ VolIterator tmp;
+ bool ret = findVolume( device, tmp, also_del, no_btrfsc );
+ if( ret )
+ v = tmp;
+ return( ret );
+ }
+
+bool Storage::findVolume( const string& device, VolIterator& v, bool also_del,
+ bool no_btrfsc )
{
assertInit();
string label;
@@ -5616,57 +5842,69 @@
else
d = normalizeDevice( device );
if( !label.empty() || !uuid.empty() )
- y2milestone( "label:%s uuid:%s", label.c_str(), uuid.c_str() );
- VPair p = vPair( also_del?NULL:Volume::notDeleted );
- v = p.begin();
- if( label.empty() && uuid.empty() )
- {
- while( v!=p.end() && v->device()!=d )
- {
- const list<string>& al( v->altNames() );
- if( find( al.begin(), al.end(), d )!=al.end() )
- break;
- ++v;
- }
- if( !p.empty() && v==p.end() && d.find("/dev/loop")==0 )
- {
- v = p.begin();
- while( v!=p.end() && v->loopDevice()!=d )
+ y2mil("label:" << label << " uuid:" << uuid);
+ bool found = false;
+ list<VPair> pl;
+ if( !no_btrfsc )
+ pl.push_back( vPair( also_del?NULL:Volume::notDeleted, isBtrfs ));
+ pl.push_back( vPair( also_del?NULL:Volume::notDeleted, isNotBtrfs ));
+ list<VPair>::iterator li = pl.begin();
+ while( li != pl.end() && !found )
+ {
+ v = li->begin();
+ if( label.empty() && uuid.empty() )
+ {
+ while( v!=li->end() && v->device()!=d )
+ {
+ const list<string>& al( v->altNames() );
+ if( find( al.begin(), al.end(), d )!=al.end() )
+ break;
++v;
+ }
+ if( !li->empty() && v==li->end() && d.find("/dev/loop")==0 )
+ {
+ v = li->begin();
+ while( v!=li->end() && v->loopDevice()!=d )
+ ++v;
+ }
+ if( !li->empty() && v==li->end() && d.find("/dev/mapper/cr_")==0 )
+ {
+ v = li->begin();
+ while( v!=li->end() && v->dmcryptDevice()!=d )
+ ++v;
+ }
+ if( !li->empty() && v==li->end() )
+ {
+ string tmp(d);
+ tmp.replace( 0, 5, "/dev/mapper/" );
+ v = li->begin();
+ while( v!=li->end() && v->device()!=tmp )
+ ++v;
+ }
}
- if( !p.empty() && v==p.end() && d.find("/dev/mapper/cr_")==0 )
+ else if( !label.empty() )
{
- v = p.begin();
- while( v!=p.end() && v->dmcryptDevice()!=d )
+ while( v!=li->end() && v->getLabel()!=label )
++v;
}
- if( !p.empty() && v==p.end() )
+ else if( !uuid.empty() )
{
- d.replace( 0, 5, "/dev/mapper/" );
- v = p.begin();
- while( v!=p.end() && v->device()!=d )
+ while( v!=li->end() && v->getUuid()!=uuid )
++v;
}
+ found = v!=li->end();
+ ++li;
}
- else if( !label.empty() )
- {
- while( v!=p.end() && v->getLabel()!=label )
- ++v;
- }
- else if( !uuid.empty() )
- {
- while( v!=p.end() && v->getUuid()!=uuid )
- ++v;
- }
- return( v!=p.end() );
+ return( found );
}
-bool Storage::findVolume( const string& device, Volume const * &vol )
+bool Storage::findVolume( const string& device, Volume const * &vol,
+ bool no_btrfsc )
{
bool ret = false;
vol = NULL;
- VolIterator v;
- if( findVolume( device, v ))
+ ConstVolIterator v;
+ if( findVolume( device, v, false, true ))
{
vol = &(*v);
ret = true;
@@ -5680,7 +5918,7 @@
string Storage::findNormalDevice( const string& device )
{
string ret;
- VolIterator v;
+ ConstVolIterator v;
if( findVolume( device, v ))
ret = v->device();
y2mil( "device:" << device << " ret:" << ret );
@@ -5688,121 +5926,285 @@
}
-bool Storage::clearUsedBy(const string& dev)
-{
- return setUsedBy(dev, UB_NONE, "");
-}
+bool
+Storage::findDevice( const string& dev, const Device* &vol,
+ bool search_by_minor )
+ {
+ vol = findDevice(dev);
+ unsigned long mj = 0, mi = 0;
+ if( vol==NULL && search_by_minor && getMajorMinor( dev, mj, mi ) && mi!=0 )
+ {
+ vol = deviceByNumber( mj, mi );
+ }
+ return( vol!=NULL );
+ }
+ Device*
+ Storage::findDevice(const string& dev, bool no_btrfsc)
+ {
+ VolIterator v;
+ if (findVolume(dev, v, false, no_btrfsc))
+ return &*v;
-bool Storage::setUsedBy(const string& dev, UsedByType ub_type, const string& ub_name)
-{
- bool ret=true;
- VolIterator v;
- if( !findVolume( dev, v ) )
+ ContIterator c;
+ if (findContainer(dev, c))
+ return &*c;
+
+ return NULL;
+ }
+
+
+ void
+ Storage::clearUsedBy(const string& dev)
{
- DiskIterator i = findDisk( dev );
- if( i != dEnd() )
+ Device* tmp = findDevice(dev,true);
+ if (tmp)
{
- i->setUsedBy(ub_type, ub_name);
+ tmp->clearUsedBy();
+ y2mil("dev:" << dev);
}
else
{
- ret = false;
- y2err("could not set ub_type:" << ub_type << " ub_name:" << ub_name <<
- "for dev: " << dev);
+ y2mil("dev:" << dev << " failed");
}
}
- else
+
+
+ void
+ Storage::clearUsedBy(const list<string>& devs)
{
- v->setUsedBy(ub_type, ub_name);
+ for (list<string>::const_iterator it = devs.begin(); it != devs.end(); ++it)
+ clearUsedBy(*it);
}
- y2mil("dev:" << dev << " ub_type:" << ub_type << " ub_name:" << ub_name << " ret:" << ret);
- return ret;
-}
-bool Storage::usedBy( const string& dev, storage::usedBy& ub )
+ void
+ Storage::setUsedBy(const string& dev, UsedByType type, const string& device)
{
- ub.clear();
- bool ret=false;
- VolIterator v;
- if( !findVolume( dev, v ) )
+ Device* tmp = findDevice(dev);
+ if (tmp)
{
- DiskIterator i = findDisk( dev );
- if( i != dEnd() )
- {
- ub = i->getUsedBy();
- ret = true;
- }
+ tmp->setUsedBy(type, device);
+ y2mil("dev:" << dev << " type:" << toString(type) << " device:" << device);
}
- else
+ else
{
- ub = v->getUsedBy();
- ret = true;
+ danglingUsedBy[dev].clear();
+ danglingUsedBy[dev].push_back(UsedBy(type, device));
+ y2mil("setting type:" << toString(type) << " device:" << device <<
+ " for dev:" << dev << " to dangling usedby");
+ }
+ }
+
+void
+Storage::setUsedByBtrfs(const string& dev, const string& uuid)
+ {
+ y2mil( "dev:" << dev << " uuid:" << uuid );
+ Device* tmp = findDevice(dev,true);
+ if (tmp)
+ {
+ tmp->setUsedBy(UB_BTRFS, uuid);
+ }
+ }
+
+bool
+Storage::canRemove( const Volume& vol ) const
+ {
+ return( recursiveRemove || !vol.isUsedBy() ||
+ isUsedBySingleBtrfs( vol ) );
+ }
+
+bool
+Storage::isUsedBySingleBtrfs( const Volume& vol ) const
+ {
+ const list<UsedBy>& ub = vol.getUsedBy();
+ bool ret = ub.size()==1 && ub.front().type()==UB_BTRFS;
+ if( ret )
+ {
+ ConstBtrfsPair p = btrfsPair(Btrfs::notDeleted);
+ ConstBtrfsIterator i = p.begin();
+ while( i!=p.end() && i->getUuid()!=ub.front().device() )
+ ++i;
+ ret = i!=p.end() && i->getDevices().size()<=1;
}
- y2mil( "dev:" << dev << " ret:" << ret << " ub:" << ub );
+ y2mil( "dev:" << vol.device() << " ret:" << ret );
return( ret );
}
-UsedByType Storage::usedBy( const string& dev )
+
+ void
+ Storage::setUsedBy(const list<string>& devs, UsedByType type, const string& device)
+ {
+ for (list<string>::const_iterator it = devs.begin(); it != devs.end(); ++it)
+ setUsedBy(*it, type, device);
+ }
+
+
+ void
+ Storage::addUsedBy(const string& dev, UsedByType type, const string& device)
+ {
+ Device* tmp = findDevice(dev);
+ if (tmp)
+ {
+ tmp->addUsedBy(type, device);
+ y2mil("dev:" << dev << " type:" << toString(type) << " device:" << device);
+ }
+ else
+ {
+ danglingUsedBy[dev].push_back(UsedBy(type, device));
+ y2mil("adding type:" << toString(type) << " device:" << device <<
+ " for dev:" << dev << " to dangling usedby");
+ }
+ }
+
+
+ void
+ Storage::addUsedBy(const list<string>& devs, UsedByType type, const string& device)
+ {
+ for (list<string>::const_iterator it = devs.begin(); it != devs.end(); ++it)
+ addUsedBy(*it, type, device);
+ }
+
+
+ void
+ Storage::removeUsedBy(const string& dev, UsedByType type, const string& device)
+ {
+ Device* tmp = findDevice(dev);
+ if (tmp)
+ {
+ tmp->removeUsedBy(type, device);
+ y2mil("dev:" << dev << " type:" << toString(type) << " device:" << device);
+ }
+ else
+ {
+ y2mil("dev:" << dev << " type:" << toString(type) << " device:" << device <<
+ " failed");
+ }
+ }
+
+
+ void
+ Storage::removeUsedBy(const list<string>& devs, UsedByType type, const string& device)
+ {
+ for (list<string>::const_iterator it = devs.begin(); it != devs.end(); ++it)
+ removeUsedBy(*it, type, device);
+ }
+
+
+ bool
+ Storage::isUsedBy(const string& dev)
+ {
+ bool ret = false;
+
+ Device* tmp = findDevice(dev);
+ if (tmp)
+ {
+ ret = tmp->isUsedBy();
+ }
+
+ y2mil("dev:" << dev << " ret:" << ret);
+ return ret;
+ }
+
+
+ bool
+ Storage::isUsedBy(const string& dev, UsedByType type)
+ {
+ bool ret = false;
+
+ Device* tmp = findDevice(dev);
+ if (tmp)
+ {
+ ret = tmp->isUsedBy(type);
+ }
+
+ y2mil("dev:" << dev << " type:" << toString(type) << " ret:" << ret);
+ return ret;
+ }
+
+
+ void
+ Storage::fetchDanglingUsedBy(const string& dev, list<UsedBy>& uby)
{
- storage::usedBy ub;
- usedBy( dev, ub );
- return( ub.type() );
+ map<string, list<UsedBy>>::iterator pos = danglingUsedBy.find(dev);
+ if (pos != danglingUsedBy.end())
+ {
+ uby.splice(uby.end(), pos->second);
+ danglingUsedBy.erase(pos);
+ y2mil("dev:" << dev << " usedby:" << uby);
+ }
+ else
+ {
+ y2mil("dev:" << dev << " not found");
+ }
}
void Storage::progressBarCb(const string& id, unsigned cur, unsigned max) const
{
- y2milestone( "id:%s cur:%d max:%d", id.c_str(), cur, max );
+ y2mil("PROGRESS BAR id:" << id << " cur:" << cur << " max:" << max);
CallbackProgressBar cb = getCallbackProgressBarTheOne();
if( cb )
(*cb)( id, cur, max );
}
-void Storage::showInfoCb(const string& info)
+void Storage::showInfoCb(const Text& info)
{
- y2milestone( "INSTALL INFO:%s", info.c_str() );
+ y2mil("INSTALL INFO info:" << info.native);
CallbackShowInstallInfo cb = getCallbackShowInstallInfoTheOne();
lastAction = info;
if( cb )
- (*cb)( info );
+ (*cb)( info.text );
}
-void Storage::infoPopupCb(const string& info) const
+void Storage::infoPopupCb(const Text& info) const
{
- y2milestone( "INFO POPUP:%s", info.c_str() );
+ y2mil("INFO POPUP info:" << info.native);
CallbackInfoPopup cb = getCallbackInfoPopupTheOne();
if( cb )
- (*cb)( info );
+ (*cb)( info.text );
}
-void Storage::addInfoPopupText(const string& disk, const string& txt)
+void Storage::addInfoPopupText(const string& disk, const Text& txt)
{
- y2mil( "d:" << disk << " txt:" << txt );
+ y2mil( "d:" << disk << " txt:" << txt.native );
infoPopupTxts.push_back( make_pair(disk,txt) );
}
-bool Storage::yesnoPopupCb(const string& info) const
+bool Storage::yesnoPopupCb(const Text& info) const
{
- y2milestone( "YESNO POPUP:%s", info.c_str() );
+ y2mil("YESNO POPUP info:" << info.native);
CallbackYesNoPopup cb = getCallbackYesNoPopupTheOne();
if( cb )
- return (*cb)( info );
+ return (*cb)( info.text );
else
- return( true );
+ return true;
}
-bool
-Storage::passwordPopupCb(const string& device, int attempts, string& password) const
-{
- y2mil("PASSWORD POPUP device:" << device << " attempts:" << attempts);
- CallbackPasswordPopup cb = getCallbackPasswordPopupTheOne();
- if (cb)
- return (*cb)(device, attempts, password);
- else
- return false;
-}
+
+ bool
+ Storage::commitErrorPopupCb(int error, const Text& last_action, const string& extended_message) const
+ {
+ y2mil("COMMIT ERROR POPUP error:" << error << " last_action:" << last_action.native <<
+ " extended_message:" << extended_message);
+ CallbackCommitErrorPopup cb = getCallbackCommitErrorPopupTheOne();
+ if (cb)
+ return (*cb)(error, last_action.text, extended_message);
+ else
+ return false;
+ }
+
+
+ bool
+ Storage::passwordPopupCb(const string& device, int attempts, string& password) const
+ {
+ y2mil("PASSWORD POPUP device:" << device << " attempts:" << attempts);
+ CallbackPasswordPopup cb = getCallbackPasswordPopupTheOne();
+ if (cb)
+ return (*cb)(device, attempts, password);
+ else
+ return false;
+ }
Storage::DiskIterator Storage::findDisk( const string& disk )
@@ -5907,12 +6309,12 @@
bool Storage::knownDevice( const string& dev, bool disks_allowed )
{
bool ret=true;
- VolIterator v;
+ ConstVolIterator v;
if( !findVolume( dev, v ) )
{
ret = disks_allowed && findDisk( dev )!=dEnd();
}
- y2milestone( "dev:%s ret:%d", dev.c_str(), ret );
+ y2mil("dev:" << dev << " ret:" << ret);
return( ret );
}
@@ -5920,8 +6322,7 @@
unsigned dmnum, unsigned long long siz,
storage::EncryptType typ )
{
- y2milestone( "dev:%s dm:%s dmn:%u sizeK:%llu", dev.c_str(), dm.c_str(),
- dmnum, siz );
+ y2mil("dev:" << dev << " dm:" << dm << " dmnum:" << dmnum << " sizeK:" << siz);
bool ret=false;
VolIterator v;
if( dm.find("/temporary-cryptsetup-")==string::npos &&
@@ -5936,16 +6337,19 @@
return( ret );
}
-bool Storage::deletedDevice( const string& dev )
- {
- VPair p = vPair( Volume::isDeleted );
- VolIterator v = p.begin();
+
+bool
+Storage::deletedDevice(const string& dev) const
+{
+ ConstVolPair p = volPair(Volume::isDeleted);
+ ConstVolIterator v = p.begin();
while( v!=p.end() && v->device()!=dev )
++v;
bool ret = v!=p.end();
- y2milestone( "dev:%s ret:%d", dev.c_str(), ret );
- return( ret );
- }
+ y2mil("dev:" << dev << " ret:" << ret);
+ return ret;
+}
+
bool Storage::isDisk( const string& dev )
{
@@ -5957,27 +6361,25 @@
Storage::getVolume( const string& dev )
{
const Volume* ret=NULL;
- VolIterator v;
+ ConstVolIterator v;
if( findVolume( dev, v ) )
{
ret = &(*v);
}
- y2milestone( "dev:%s ret:%s", dev.c_str(),
- ret?ret->device().c_str():"nil" );
+ y2mil("dev:" << dev << " ret:" << (ret?ret->device():"NULL"));
return( ret );
}
bool Storage::canUseDevice( const string& dev, bool disks_allowed )
{
bool ret=true;
- VolIterator v;
+ ConstVolIterator v;
if( !findVolume( dev, v ) )
{
if( disks_allowed )
{
DiskIterator i = findDisk( dev );
- ret = i!=dEnd() && i->getUsedByType()==UB_NONE &&
- i->numPartitions()==0;
+ ret = i != dEnd() && !i->isUsedBy() && i->numPartitions() == 0;
}
else
ret = false;
@@ -5986,11 +6388,37 @@
{
ret = v->canUseDevice();
}
- y2milestone( "dev:%s ret:%d", dev.c_str(), ret );
+ y2mil("dev:" << dev << " ret:" << ret);
return( ret );
}
-string Storage::deviceByNumber( const string& majmin )
+const Device*
+Storage::deviceByNumber( unsigned long maj, unsigned long min ) const
+ {
+ const Device* ret=NULL;
+ ConstVolPair p = volPair( Volume::notDeleted );
+ ConstVolIterator v = p.begin();
+ while( v!=p.end() && (maj!=v->majorNr() || min!=v->minorNr()))
+ {
+ ++v;
+ }
+ if( v!=p.end() )
+ ret = &*v;
+ if( !ret )
+ {
+ ConstContPair c = contPair(Container::DeviceUsable);
+ ConstContIterator ci = c.begin();
+ while( ci!=c.end() && (maj!=ci->majorNr() || min!=ci->minorNr()))
+ ++ci;
+ if( ci!=c.end() )
+ ret = &*ci;
+ }
+ y2mil( "maj:" << maj << " min:" << min << " ret:" << (ret?ret->device():"NULL") );
+ return ret;
+ }
+
+string
+Storage::deviceByNumber(const string& majmin) const
{
string ret="";
string::size_type pos = majmin.find( ":" );
@@ -5999,41 +6427,18 @@
unsigned ma, mi;
majmin.substr( 0, pos ) >> ma;
majmin.substr( pos+1 ) >> mi;
- ConstVolPair p = volPair( Volume::notDeleted );
- ConstVolIterator v = p.begin();
- while( v!=p.end() && (ma!=v->majorNr() || mi!=v->minorNr()))
- {
- ++v;
- }
- if( v!=p.end() )
- ret = v->device();
- if( ret.empty() )
- {
- ConstDiskPair d = diskPair();
- ConstDiskIterator di = d.begin();
- while( di!=d.end() && (ma!=di->majorNr() || mi!=di->minorNr()))
- ++di;
- if( di!=d.end() )
- ret = di->device();
- }
- if( ret.empty() && ma==Dm::dmMajor())
- {
- ConstDmraidCoPair d = dmraidCoPair();
- ConstDmraidCoIterator di = d.begin();
- while( di!=d.end() && mi!=di->minorNr() )
- ++di;
- if( di!=d.end() )
- ret = di->device();
- }
+ const Device* dev = deviceByNumber( ma, mi );
+ if( dev )
+ ret = dev->device();
}
- y2milestone( "majmin %s ret:%s", majmin.c_str(), ret.c_str() );
- return( ret );
+ y2mil("majmin:" << majmin << " ret:" << ret);
+ return ret;
}
unsigned long long Storage::deviceSize( const string& dev )
{
unsigned long long ret=0;
- VolIterator v;
+ ConstVolIterator v;
if( !findVolume( dev, v ) )
{
DiskIterator i = findDisk( dev );
@@ -6042,21 +6447,28 @@
}
else
ret = v->sizeK();
- y2milestone( "dev:%s ret:%llu", dev.c_str(), ret );
+ y2mil("dev:" << dev << " ret:" << ret);
return( ret );
}
-int Storage::removeContainer( Container* val, bool call_del )
+
+ void
+ Storage::addToList(Container* e)
+ {
+ pointerIntoSortedList<Container>(cont, e);
+ }
+
+
+int Storage::removeContainer( Container* val )
{
- y2milestone( "name:%s call_del:%d", val->name().c_str(), call_del );
+ y2mil("name:" << val->name());
int ret = 0;
CIter i=cont.begin();
while( i!=cont.end() && *i!=val )
++i;
if( i!=cont.end() )
{
- if( call_del )
- delete( *i );
+ delete *i;
cont.erase( i );
}
else
@@ -6068,50 +6480,62 @@
}
-int Storage::removeUsing(const string& device, const storage::usedBy& uby)
-{
- y2mil("device:" << device << " uby:" << uby);
- int ret=0;
- switch( uby.type() )
- {
- case UB_MD:
- ret = removeVolume(uby.device());
- break;
- case UB_DM:
- ret = removeVolume(uby.device());
- break;
- case UB_LVM:
- ret = removeLvmVg(uby.name());
- break;
- case UB_DMRAID:
- //ret = removeDmraidCo( name );
- break;
- case UB_MDPART:
- ret = removeMdPartCo( uby.device(), true );
- break;
- case UB_DMMULTIPATH:
- break;
- case UB_NONE:
- y2war(device << " used by none");
- break;
- default:
- ret = STORAGE_REMOVE_USING_UNKNOWN_TYPE;
- break;
+ int
+ Storage::removeUsing(const string& device, const list<UsedBy>& usedby)
+ {
+ y2mil("device:" << device << " usedby:" << usedby);
+
+ int ret = 0;
+
+ // iterators of usedby are invalidated during remove
+ const list<UsedBy> tmp(usedby);
+
+ for (list<UsedBy>::const_iterator it = tmp.begin(); it != tmp.end(); ++it)
+ {
+ switch (it->type())
+ {
+ case UB_MD:
+ ret = removeVolume(it->device());
+ break;
+ case UB_DM:
+ ret = removeVolume(it->device());
+ break;
+ case UB_LVM:
+ ret = removeLvmVg(it->device().substr(5));
+ break;
+ case UB_DMRAID:
+ break;
+ case UB_DMMULTIPATH:
+ break;
+ case UB_BTRFS:
+ {
+ BtrfsCo* co;
+ if( haveBtrfs(co) )
+ ret = co->removeUuid(it->device());
+ else
+ ret = STORAGE_BTRFS_CO_NOT_FOUND;
+ }
+ break;
+ case UB_MDPART:
+ ret = removeMdPartCo(it->device(), true);
+ break;
+ default:
+ ret = STORAGE_REMOVE_USING_UNKNOWN_TYPE;
+ break;
+ }
+
+ if (ret != 0)
+ break;
}
- y2mil("ret:" << ret);
- return ret;
-}
+ y2mil("ret:" << ret);
+ return ret;
+ }
-void Storage::rootMounted()
- {
- root_mounted = true;
- if( !root().empty() )
- {
- string d = root() + "/etc";
- if (!checkDir(d))
- createPath(d);
+ void
+ Storage::syncMdadm()
+ {
bool have_mds = false;
MdCo* md;
@@ -6124,15 +6548,28 @@
if (have_mds)
{
- delete raidtab;
- raidtab = new EtcRaidtab(this, root());
+ delete mdadm;
+ mdadm = new EtcMdadm(this, root());
if (haveMd(md))
- md->syncRaidtab();
+ md->syncMdadm(mdadm);
for (MdPartCoIterator it = p.begin(); it != p.end(); ++it)
- it->syncRaidtab();
+ it->syncMdadm(mdadm);
}
+ }
+
+
+void Storage::rootMounted()
+ {
+ root_mounted = true;
+ if( !root().empty() )
+ {
+ string d = root() + "/etc";
+ if (!checkDir(d))
+ createPath(d);
+
+ syncMdadm();
if( instsys() )
{
@@ -6141,45 +6578,47 @@
}
int ret = fstab->changeRootPrefix( root()+"/etc" );
if( ret!=0 )
- y2error( "changeRootPrefix returns %d", ret );
+ y2err("changeRootPrefix returns " << ret);
}
}
+
bool
-Storage::checkDeviceMounted( const string& device, string& mp )
+Storage::checkDeviceMounted(const string& device, list<string>& mps)
{
bool ret = false;
assertInit();
- y2milestone( "device:%s", device.c_str() );
- VolIterator vol;
- ProcMounts mountData( this );
+ y2mil("device:" << device);
+ ConstVolIterator vol;
+ ProcMounts mounts;
if( findVolume( device, vol ) )
{
- mp = mountData.getMount( vol->mountDevice() );
- if( mp.empty() )
- mp = mountData.getMount( vol->altNames() );
- ret = !mp.empty();
+ mps = mounts.getAllMounts(vol->mountDevice());
+ mps.splice(mps.end(), mounts.getAllMounts(vol->altNames()));
}
else
{
- mp = mountData.getMount( device );
+ mps = mounts.getAllMounts(device);
}
- y2milestone( "ret:%d mp:%s", ret, mp.c_str() );
- return( ret );
+ ret = !mps.empty();
+ y2mil("ret:" << ret << " mps:" << mps);
+ return ret;
}
+
bool
-Storage::umountDevice( const string& device )
+Storage::umountDev( const string& device, bool unsetup )
{
bool ret = false;
assertInit();
- y2milestone( "device:%s", device.c_str() );
+ y2mil("device:" << device << " unsetup:" << unsetup );
VolIterator vol;
if( !readonly() && findVolume( device, vol ) )
{
if( vol->umount()==0 )
{
- vol->crUnsetup();
+ if( unsetup )
+ vol->crUnsetup();
ret = true;
}
}
@@ -6193,8 +6632,7 @@
{
bool ret = true;
assertInit();
- y2milestone( "device:%s mp:%s ro:%d opts:%s", device.c_str(), mp.c_str(),
- ro, opts.c_str() );
+ y2mil("device:" << device << " mp:" << mp << " ro:" << ro << " opts:" << opts);
VolIterator vol;
if( !readonly() && findVolume( device, vol ) )
{
@@ -6218,191 +6656,181 @@
return( ret );
}
+int
+Storage::activateEncryption( const string& device, bool on )
+ {
+ int ret = 0;
+ assertInit();
+ y2mil("device:" << device << " on:" << on );
+ VolIterator vol;
+ if( !readonly() && findVolume( device, vol ) )
+ {
+ bool slnt = vol->isSilent();
+ vol->setSilent(true);
+ if( on && vol->needCrsetup() )
+ {
+ ret = vol->doCrsetup();
+ }
+ else if( !on )
+ {
+ ret = vol->crUnsetup(true);
+ }
+ vol->setSilent(slnt);
+ }
+ else
+ ret = STORAGE_VOLUME_NOT_FOUND;
+ y2mil("ret:" << ret);
+ return( ret );
+ }
+
+
bool
Storage::readFstab( const string& dir, deque<VolumeInfo>& infos )
- {
- static deque<VolumeInfo> vil;
+{
+ static deque<VolumeInfo> s_infos; // workaround for broken ycp bindings
static Regex disk_part( "^/dev/[sh]d[a-z]+[0-9]+$" );
- vil.clear();
+ s_infos.clear();
bool ret = false;
- VolIterator vol;
+ ConstVolIterator vol;
assertInit();
- y2milestone( "dir:%s", dir.c_str() );
- EtcFstab *fstab = new EtcFstab( dir, true );
- list<FstabEntry> le;
- fstab->getEntries( le );
+ y2mil("dir:" << dir);
+ EtcFstab fstab(dir, true);
+ const list<FstabEntry> le = fstab.getEntries();
for( list<FstabEntry>::const_iterator i=le.begin(); i!=le.end(); ++i )
- {
+ {
y2mil( "entry:" << *i );
- VolumeInfo* info = NULL;
if( disk_part.match( i->dentry ) )
- {
- info = new VolumeInfo;
- info->create = info->format = info->resize = false;
- info->sizeK = info->OrigSizeK = info->minor = info->major = 0;
- info->device = i->dentry;
- info->mount = i->mount;
- info->mount_by = MOUNTBY_DEVICE;
- info->fs = Volume::toFsType( i->fs );
- info->fstab_options = mergeString( i->opts, "," );
- vil.push_back( *info );
- }
- else if( findVolume( i->dentry, vol ) )
- {
- info = new VolumeInfo;
- vol->getInfo( *info );
- vol->mergeFstabInfo( *info, *i );
+ {
+ VolumeInfo info;
+ info.create = info.format = info.resize = false;
+ info.sizeK = info.origSizeK = 0;
+ info.minor = info.major = 0;
+ info.device = i->dentry;
+ info.mount = i->mount;
+ info.mount_by = MOUNTBY_DEVICE;
+ info.fs = toValueWithFallback(i->fs, FSUNKNOWN);
+ info.fstab_options = boost::join( i->opts, "," );
+ s_infos.push_back(info);
+ }
+ else if( findVolume( i->dentry, vol )||findVolume( i->device, vol ) )
+ {
+ VolumeInfo info;
+ vol->getInfo( info );
+ vol->mergeFstabInfo( info, *i );
y2mil( "volume:" << *vol );
- vil.push_back( *info );
- }
- if( info )
- {
- delete info;
- info = NULL;
- }
+ s_infos.push_back(info);
}
- delete fstab;
- infos = vil;
+ }
+ infos = s_infos;
ret = !infos.empty();
y2mil("ret:" << ret);
- return( ret );
- }
+ return ret;
+}
+
-unsigned long long
-Storage::getDfSize( const string& mp )
+bool Storage::mountTmp( const Volume* vol, string& mdir, bool ro )
{
- unsigned long long ret = 0;
- struct statvfs64 fsbuf;
- if( statvfs64( mp.c_str(), &fsbuf )==0 )
+ bool ret = false;
+ removeDmTableTo( *vol );
+ mdir = tmpDir() + "/tmp-" + (ro?"ro-mp":"mp") + "-XXXXXX";
+ if (mkdtemp(mdir))
+ {
+ y2mil( "mdir:" << mdir << " ro:" << ro );
+
+ string opts = vol->getFstabOption();
+ if( vol->getFs()==NTFS )
{
- ret = fsbuf.f_blocks;
- ret *= fsbuf.f_bsize;
- ret /= 1024;
- y2mil("blocks:" << fsbuf.f_blocks << " free:" << fsbuf.f_bfree <<
- " bsize:" << fsbuf.f_bsize);
+ if( !opts.empty() )
+ opts += ",";
+ opts += "show_sys_files";
}
- else
+
+ if( mountDev( vol->device(), mdir, ro, opts ) )
+ {
+ ret = true;
+ }
+ else
{
- y2war( "errno:" << errno << " " << strerror(errno));
+ rmdir(mdir.c_str());
+ mdir.erase();
}
- y2mil( "mp:" << mp << " ret:" << ret );
+ }
+
+ y2mil( "ret:" << ret << " mp:" << mdir );
return( ret );
}
bool
-Storage::getFreeInfo( const string& device, unsigned long long& resize_free,
- unsigned long long& df_free,
- unsigned long long& used, bool& win, bool& efi,
- bool use_cache )
+Storage::getFreeInfo(const string& device, bool get_resize, ResizeInfo& resize_info,
+ bool get_content, ContentInfo& content_info, bool use_cache)
{
bool ret = false;
assertInit();
- resize_free = df_free = used = 0;
- y2milestone( "device:%s use_cache:%d", device.c_str(), use_cache );
+
+ resize_info = ResizeInfo();
+ content_info = ContentInfo();
+
+ if (testmode())
+ use_cache = true;
+
+ y2mil("device:" << device << " use_cache:" << use_cache);
+
VolIterator vol;
if( findVolume( device, vol ) )
{
- if( use_cache && getFreeInf( vol->device(), df_free, resize_free,
- used, win, efi, ret ))
- {
- }
+ if (vol->getFs() == FSUNKNOWN || vol->getFs() == FSNONE || vol->getFs() == SWAP)
+ {
+ ret = false;
+ }
+ else if (vol->isUsedBy()&&!isUsedBySingleBtrfs(*vol))
+ {
+ ret = false;
+ }
+ else if (use_cache && getCachedFreeInfo(vol->device(), get_resize, resize_info,
+ get_content, content_info))
+ {
+ ret = true;
+ }
+ else if (testmode())
+ {
+ ret = false;
+ }
else
{
bool needUmount = false;
string mp;
- if( !vol->isMounted() )
- {
- removeDmTableTo( *vol );
- string mdir = tmpDir() + "/tmp_mp";
- unlink( mdir.c_str() );
- rmdir( mdir.c_str() );
- string save_opt;
- string cur_opt;
- if( vol->getFs()==NTFS )
- {
- save_opt = vol->getFstabOption();
- cur_opt = save_opt;
- if( !cur_opt.empty() )
- cur_opt += ",";
- cur_opt += "show_sys_files";
- vol->changeFstabOptions( cur_opt );
- }
- if( vol->getFs()!=FSUNKNOWN && mkdir( mdir.c_str(), 0700 )==0 &&
- mountDev( device, mdir ) )
- {
- needUmount = true;
- mp = mdir;
- }
- if( vol->getFs()==NTFS )
- vol->changeFstabOptions( save_opt );
- }
+ if( !vol->isMounted() && mountTmpRo( &(*vol), mp ) )
+ needUmount = true;
else
mp = vol->getMount();
+
if( !mp.empty() )
{
- struct statvfs64 fsbuf;
- ret = statvfs64( mp.c_str(), &fsbuf )==0;
- if( ret )
- {
- df_free = fsbuf.f_bfree;
- df_free *= fsbuf.f_bsize;
- df_free /= 1024;
- resize_free = df_free;
- used = fsbuf.f_blocks-fsbuf.f_bfree;
- used *= fsbuf.f_bsize;
- used /= 1024;
- y2mil("blocks:" << fsbuf.f_blocks << " free:" << fsbuf.f_bfree <<
- " bsize:" << fsbuf.f_bsize);
- y2mil("free:" << df_free << " used:" << used);
- }
- if( ret && vol->getFs()==NTFS )
- {
- SystemCmd c("/usr/sbin/ntfsresize -f -i " + quote(device));
- string fstr = " might resize at ";
- string::size_type pos;
- if( c.retcode()==0 &&
- (pos=c.getString()->find( fstr ))!=string::npos )
- {
- y2mil("pos:" << pos);
- pos = c.getString()->find_first_not_of( " \t\n", pos+fstr.size());
- y2mil("pos:" << pos);
- string number = c.getString()->substr( pos,
- c.getString()->find_first_not_of( "0123456789", pos ));
- y2mil("number:\"" << number << "\"");
- unsigned long long t;
- number >> t;
- y2mil("number:" << t);
- if( t-vol->sizeK()<resize_free )
- resize_free = t-vol->sizeK();
- y2mil("resize_free:" << t);
- }
- else
- ret = false;
- }
- win = false;
- const char * files[] = { "boot.ini", "msdos.sys", "io.sys",
- "config.sys", "MSDOS.SYS", "IO.SYS",
- "bootmgr", "$Boot" };
- unsigned i=0;
- while( !win && i<lengthof(files) )
+ ret = true;
+
+ bool resize_cached = false;
+ bool content_cached = false;
+
+ if (get_resize || vol->getFs() != NTFS)
{
- string f = mp + "/" + files[i];
- if (access(f.c_str(), R_OK) == 0)
- {
- y2mil("found windows file " << quote(f));
- win = true;
- }
- i++;
+ resize_cached = true;
+ resize_info = FreeInfo::detectResizeInfo(mp, *vol);
+ }
+
+ if (get_content || true)
+ {
+ content_cached = true;
+ content_info = FreeInfo::detectContentInfo(mp, *vol);
}
- efi = vol->getFs()==VFAT && checkDir( mp + "/efi" );
- if( efi )
- win = false;
+
+ setCachedFreeInfo(vol->device(), resize_cached, resize_info, content_cached,
+ content_info);
}
+
if( needUmount )
{
umountDevice( device );
rmdir( mp.c_str() );
- rmdir( tmpDir().c_str() );
}
if( vol->needCrsetup() && vol->doCrsetup() )
@@ -6411,82 +6839,173 @@
if( !ret )
vol->crUnsetup();
}
- setFreeInfo( vol->device(), df_free, resize_free, used, win, efi,
- ret );
}
}
- if( ret )
- y2milestone( "resize_free:%llu df_free:%llu used:%llu",
- resize_free, df_free, used );
- y2milestone( "ret:%d win:%d", ret, win );
- return( ret );
- }
-void Storage::setFreeInfo( const string& device, unsigned long long df_free,
- unsigned long long resize_free,
- unsigned long long used, bool win, bool efi,
- bool resize_ok )
- {
- y2milestone( "device:%s df_free:%llu resize_free:%llu used:%llu win:%d efi:%d",
- device.c_str(), df_free, resize_free, used, win, efi );
+ y2mil("device:" << device << " ret:" << ret);
+ if (ret && get_resize)
+ y2mil("resize_info " << resize_info);
+ if (ret && get_content)
+ y2mil("content_info " << content_info);
- FreeInfo inf( df_free, resize_free, used, win, efi, resize_ok );
- freeInfo[device] = inf;
+ return ret;
}
+
+void
+Storage::setCachedFreeInfo(const string& device, bool resize_cached, const ResizeInfo& resize_info,
+ bool content_cached, const ContentInfo& content_info)
+{
+ map<string, FreeInfo>::iterator it = free_infos.find(device);
+ if (it != free_infos.end())
+ it->second.update(resize_cached, resize_info, content_cached, content_info);
+ else
+ free_infos.insert(it, make_pair(device, FreeInfo(resize_cached, resize_info,
+ content_cached, content_info)));
+}
+
+
bool
-Storage::getFreeInf( const string& device, unsigned long long& df_free,
- unsigned long long& resize_free,
- unsigned long long& used, bool& win, bool& efi,
- bool& resize_ok )
+Storage::getCachedFreeInfo(const string& device, bool get_resize, ResizeInfo& resize_info,
+ bool get_content, ContentInfo& content_info) const
+{
+ bool ret = false;
+
+ map<string, FreeInfo>::const_iterator it = free_infos.find(device);
+ if (it != free_infos.end())
{
- map<string,FreeInfo>::iterator i = freeInfo.find( device );
- bool ret = i!=freeInfo.end();
- if( ret )
+ ret = true;
+
+ if (get_resize)
{
- df_free = i->second.df_free;
- resize_free = i->second.resize_free;
- used = i->second.used;
- win = i->second.win;
- efi = i->second.efi;
- resize_ok = i->second.rok;
+ if (it->second.resize_cached)
+ resize_info = it->second.resize_info;
+ else
+ ret = false;
+ }
+
+ if (get_content)
+ {
+ if (it->second.content_cached)
+ content_info = it->second.content_info;
+ else
+ ret = false;
}
- y2milestone( "device:%s ret:%d", device.c_str(), ret );
- if( ret )
- y2milestone( "df_free:%llu resize_free:%llu used:%llu win:%d efi:%d resize_ok:%d",
- df_free, resize_free, used, win, efi, resize_ok );
- return( ret );
}
+ y2mil("device:" << device << " ret:" << ret);
+ return ret;
+}
+
+
void
-Storage::eraseFreeInfo( const string& device )
+Storage::eraseCachedFreeInfo(const string& device)
+{
+ free_infos.erase(device);
+}
+
+
+void Storage::checkPwdBuf( const string& device )
+ {
+ map<string,string>::iterator i=pwdBuf.find(device);
+ if( i!=pwdBuf.end() )
+ {
+ VolIterator vol;
+ if( findVolume( device, vol ) )
+ vol->setCryptPwd( i->second );
+ pwdBuf.erase(i);
+ }
+ }
+
+
+ void
+ Storage::logFreeInfo(const string& Dir) const
+ {
+ string fname(Dir + "/free.info.tmp");
+
+ XmlFile xml;
+ xmlNode* node = xmlNewNode("free");
+ xml.setRootElement(node);
+
+ for (map<string, FreeInfo>::const_iterator it = free_infos.begin(); it != free_infos.end(); ++it)
+ {
+ xmlNode* tmp = xmlNewChild(node, "free");
+ setChildValue(tmp, "device", it->first);
+ it->second.saveData(tmp);
+ }
+
+ xml.save(fname);
+
+ handleLogFile(fname);
+ }
+
+
+ void
+ Storage::readFreeInfo(const string& fname)
+ {
+ XmlFile file(fname);
+ const xmlNode* root = file.getRootElement();
+ const xmlNode* free = getChildNode(root, "free");
+ if (free)
+ {
+ const list<const xmlNode*> frees = getChildNodes(free, "free");
+ for(list<const xmlNode*>::const_iterator it = frees.begin(); it != frees.end(); ++it)
+ {
+ string device;
+ getChildValue(*it, "device", device);
+ mapInsertOrReplace(free_infos, device, FreeInfo(*it));
+ }
+ }
+ }
+
+
+ void
+ Storage::logArchInfo(const string& Dir) const
{
- map<string,FreeInfo>::iterator i = freeInfo.find( device );
- if( i!=freeInfo.end() )
- freeInfo.erase(i);
+ string fname(Dir + "/arch.info.tmp");
+
+ XmlFile xml;
+ xmlNode* node = xmlNewNode("arch");
+ xml.setRootElement(node);
+ archinfo.saveData(node);
+ xml.save(fname);
+
+ handleLogFile(fname);
+ }
+
+
+ void
+ Storage::readArchInfo(const string& fname)
+ {
+ XmlFile file(fname);
+ const xmlNode* root = file.getRootElement();
+ const xmlNode* node = getChildNode(root, "arch");
+ if (node)
+ archinfo.readData(node);
}
+
int
Storage::createBackupState( const string& name )
{
int ret = readonly()?STORAGE_CHANGE_READONLY:0;
assertInit();
- y2milestone( "name:%s", name.c_str() );
+ y2mil("name:" << name);
+ if (ret == 0 && name.empty())
+ ret = STORAGE_INVALID_BACKUP_STATE_NAME;
if( ret==0 )
{
- if(checkBackupState(name))
- removeBackupState( name );
- CCIter i=cont.begin();
- while( i!=cont.end() )
- {
- backups[name].push_back( (*i)->getCopy() );
- ++i;
- }
+ if (checkBackupState(name))
+ removeBackupState(name);
+ CCont tmp;
+ for (CCIter i = cont.begin(); i != cont.end(); ++i)
+ tmp.push_back((*i)->getCopy());
+ backups.insert(make_pair(name, tmp));
}
y2mil( "states:" << backupStates() );
y2mil("ret:" << ret);
if( ret==0 )
- y2milestone( "comp:%d", equalBackupStates( name, "", true ));
+ y2mil("comp:" << equalBackupStates(name, "", true));
return( ret );
}
@@ -6495,7 +7014,7 @@
{
int ret = readonly()?STORAGE_CHANGE_READONLY:0;
assertInit();
- y2milestone( "name:%s", name.c_str() );
+ y2mil("name:" << name);
if( ret==0 )
{
if( !name.empty() )
@@ -6503,7 +7022,7 @@
map<string,CCont>::iterator i = backups.find( name );
if( i!=backups.end())
{
- deleteClist( i->second );
+ clearPointerList(i->second);
backups.erase(i);
}
else
@@ -6522,19 +7041,15 @@
{
int ret = readonly()?STORAGE_CHANGE_READONLY:0;
assertInit();
- y2milestone( "name:%s", name.c_str() );
+ y2mil("name:" << name);
if( ret==0 )
{
- map<string,CCont>::iterator b = backups.find( name );
+ map<string, CCont>::const_iterator b = backups.find(name);
if( b!=backups.end())
{
- cont.clear();
- CCIter i=b->second.begin();
- while( i!=b->second.end() )
- {
+ clearPointerList(cont);
+ for (CCIter i = b->second.begin(); i != b->second.end(); ++i)
cont.push_back( (*i)->getCopy() );
- ++i;
- }
}
else
ret = STORAGE_BACKUP_STATE_NOT_FOUND;
@@ -6544,38 +7059,26 @@
}
bool
-Storage::checkBackupState( const string& name )
+Storage::checkBackupState( const string& name ) const
{
- bool ret = false;
- assertInit();
- y2milestone( "name:%s", name.c_str() );
- map<string,CCont>::iterator i = backups.find( name );
- ret = i!=backups.end();
- y2mil("ret:" << ret);
- return( ret );
+ bool ret = backups.find(name) != backups.end();
+ y2mil("name:" << name << " ret:" << ret);
+ return ret;
}
-struct equal_co
- {
- equal_co( const Container* const co ) : c(co) {};
- bool operator()(const Container* co) { return( *co==*c ); }
- const Container* const c;
- };
-
bool
Storage::equalBackupStates(const string& lhs, const string& rhs,
bool verbose_log) const
{
y2mil("lhs:" << lhs << " rhs:" << rhs << " verbose:" << verbose_log);
- map<string,CCont>::const_iterator i;
const CCont* l = NULL;
const CCont* r = NULL;
if( lhs.empty() )
l = &cont;
else
{
- i = backups.find( lhs );
+ map<string, CCont>::const_iterator i = backups.find(lhs);
if( i!=backups.end() )
l = &i->second;
}
@@ -6583,7 +7086,7 @@
r = &cont;
else
{
- i = backups.find( rhs );
+ map<string, CCont>::const_iterator i = backups.find(rhs);
if( i!=backups.end() )
r = &i->second;
}
@@ -6594,9 +7097,9 @@
CCIter j;
while( (ret||verbose_log) && i!=l->end() )
{
- j = find_if( r->begin(), r->end(), equal_co( *i ) );
+ j = find_if(r->begin(), r->end(), bind2nd(deref_equal_to<Container>(), *i));
if( j!=r->end() )
- ret = (*i)->compareContainer( *j, verbose_log ) && ret;
+ ret = (*i)->compareContainer( **j, verbose_log ) && ret;
else
{
ret = false;
@@ -6608,7 +7111,7 @@
i=r->begin();
while( (ret||verbose_log) && i!=r->end() )
{
- j = find_if( l->begin(), l->end(), equal_co( *i ) );
+ j = find_if(l->begin(), l->end(), bind2nd(deref_equal_to<Container>(), *i));
if( j==l->end() )
{
ret = false;
@@ -6654,8 +7157,6 @@
Dm::activate(val);
MdPartCo::activate(val, tmpDir());
}
-
-
}
LvmVg::activate(val);
if (!val)
@@ -6680,9 +7181,8 @@
{
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(),
- freq, passno );
+ y2mil("device:" << device << " mount:" << mount << " vfs:" << vfs << " opts:" << options <<
+ " freq:" << freq << " passno:" << passno);
if( ret==0 && (device.empty()||mount.empty()||vfs.empty()))
{
ret = STORAGE_INVALID_FSTAB_VALUE;
@@ -6706,7 +7206,7 @@
fstab->addEntry( c );
if( isRootMounted() )
{
- string dir = root() + mount;
+ string dir = prependRoot(mount);
if( access( dir.c_str(), R_OK )!=0 )
createPath( dir );
ret = fstab->flush();
@@ -6722,74 +7222,40 @@
}
-int Storage::waitForDevice()
-{
- int ret = 0;
- 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());
- }
- y2mil("ret:" << ret);
- return ret;
+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 )
- {
+int
+Storage::waitForDevice(const string& device)
+{
int ret = 0;
waitForDevice();
- bool exist = access( device.c_str(), R_OK )==0;
- y2milestone( "device:%s exist:%d", device.c_str(), exist );
- if( !exist )
- {
- 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 );
+ bool exist = access(device.c_str(), R_OK)==0;
+ y2mil("device:" << device << " exist:" << exist);
+ if (!exist)
+ {
+ for (int count = 0; count < 500; count++)
+ {
+ 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 );
- }
-
-
-void Storage::checkDeviceExclusive( const string& device, unsigned secs )
-{
- const int delay = 50000;
- const unsigned count = secs * 1000000/delay;
- y2mil( "dev:" << device << " sec:" << secs << " count:" << count );
- for( unsigned i=0; i<count; i++ )
- {
- int fd = open( device.c_str(), O_RDONLY|O_EXCL );
- y2mil( "count:" << i << " fd:" << fd );
- if( fd>=0 )
- close(fd);
- usleep( delay );
- }
+ return ret;
}
-void Storage::checkPwdBuf( const string& device )
- {
- if( !pwdBuf.empty() )
- {
- map<string,string>::iterator i=pwdBuf.find(device);
- if( i!=pwdBuf.end() )
- {
- VolIterator vol;
- if( findVolume( device, vol ) )
- vol->setCryptPwd( i->second );
- pwdBuf.erase(i);
- }
- }
- }
int
Storage::zeroDevice(const string& device, unsigned long long sizeK, bool random,
@@ -6807,53 +7273,45 @@
SystemCmd c;
string cmd;
- startK = min(startK, sizeK);
- cmd = DDBIN " if=" + source + " of=" + quote(device) + " bs=1k count=" + decString(startK);
+ if( sizeK>0 )
+ startK = min(startK, sizeK);
+ cmd = DDBIN " if=" + source + " of=" + quote(device) + " bs=1k count=" + decString(startK) + " conv=nocreat";
if (c.execute(cmd) != 0)
ret = STORAGE_ZERO_DEVICE_FAILED;
- endK = min(endK, sizeK);
- cmd = DDBIN " if=" + source + " of=" + quote(device) + " seek=" + decString(sizeK - endK) +
- " bs=1k count=" + decString(endK);
- c.execute(cmd);
-
+ if( sizeK>0 )
+ {
+ endK = min(endK, sizeK);
+ cmd = DDBIN " if=" + source + " of=" + quote(device) + " seek=" + decString(sizeK - endK) +
+ " bs=1k count=" + decString(endK) + " conv=nocreat";
+ if (c.execute(cmd) != 0)
+ ret = STORAGE_ZERO_DEVICE_FAILED;
+ }
y2mil("ret:" << ret);
return ret;
}
-string Storage::byteToHumanString(unsigned long long size, bool classic, int precision,
- bool omit_zeroes) const
-{
- return storage::byteToHumanString(size, classic, precision, omit_zeroes);
-}
-
-
-bool Storage::humanStringToByte(const string& str, bool classic, unsigned long long& size) const
-{
- return storage::humanStringToByte(str, classic, size);
-}
-
-
-namespace storage
-{
-std::ostream& operator<< (std::ostream& s, Storage &v )
+std::ostream& operator<<(std::ostream& s, const Storage& v)
{
v.printInfo(s);
return(s);
}
-}
-
+std::ostream& operator<<(std::ostream& s, Storage& v)
+ {
+ v.assertInit();
+ v.printInfo(s);
+ return(s);
+ }
-Storage::SkipDeleted Storage::SkipDel;
-namespace storage
-{
// workaround for broken YCP bindings
CallbackProgressBar progress_bar_cb_ycp = NULL;
CallbackShowInstallInfo install_info_cb_ycp = NULL;
CallbackInfoPopup info_popup_cb_ycp = NULL;
CallbackYesNoPopup yesno_popup_cb_ycp = NULL;
+ CallbackCommitErrorPopup commit_error_popup_cb_ycp = NULL;
CallbackPasswordPopup password_popup_cb_ycp = NULL;
+
}
Modified: branches/SuSE-Code-11-SP2-Branch/storage/libstorage/src/Storage.h
URL: http://svn.opensuse.org/viewcvs/yast/branches/SuSE-Code-11-SP2-Branch/stora…
==============================================================================
--- branches/SuSE-Code-11-SP2-Branch/storage/libstorage/src/Storage.h (original)
+++ branches/SuSE-Code-11-SP2-Branch/storage/libstorage/src/Storage.h Tue May 17 13:39:44 2011
@@ -1,5 +1,5 @@
/*
- * Copyright (c) [2004-2009] Novell, Inc.
+ * Copyright (c) [2004-2010] Novell, Inc.
*
* All Rights Reserved.
*
@@ -23,37 +23,44 @@
#ifndef STORAGE_H
#define STORAGE_H
-#include <iostream>
+#include <ostream>
#include <list>
#include <map>
-#include "y2storage/StorageInterface.h"
-#include "y2storage/StorageTypes.h"
-#include "y2storage/StorageTmpl.h"
-#include "y2storage/Container.h"
-#include "y2storage/Volume.h"
-#include "y2storage/Disk.h"
-#include "y2storage/Partition.h"
-#include "y2storage/LvmVg.h"
-#include "y2storage/LvmLv.h"
-#include "y2storage/DmraidCo.h"
-#include "y2storage/Dmraid.h"
-#include "y2storage/DmmultipathCo.h"
-#include "y2storage/Dmmultipath.h"
-#include "y2storage/MdCo.h"
-#include "y2storage/Md.h"
-#include "y2storage/MdPartCo.h"
-#include "y2storage/MdPart.h"
-#include "y2storage/DmCo.h"
-#include "y2storage/LoopCo.h"
-#include "y2storage/Loop.h"
-#include "y2storage/NfsCo.h"
-#include "y2storage/Nfs.h"
-#include "y2storage/FilterIterator.h"
-#include "y2storage/DerefIterator.h"
-#include "y2storage/ListListIterator.h"
-#include "y2storage/IterPair.h"
-#include "y2storage/Lock.h"
+#include "storage/StorageInterface.h"
+#include "storage/StorageTypes.h"
+#include "storage/StorageTmpl.h"
+#include "storage/Container.h"
+#include "storage/Volume.h"
+#include "storage/Disk.h"
+#include "storage/Partition.h"
+#include "storage/LvmVg.h"
+#include "storage/LvmLv.h"
+#include "storage/DmraidCo.h"
+#include "storage/Dmraid.h"
+#include "storage/DmmultipathCo.h"
+#include "storage/Dmmultipath.h"
+#include "storage/MdCo.h"
+#include "storage/Md.h"
+#include "storage/MdPartCo.h"
+#include "storage/MdPart.h"
+#include "storage/DmCo.h"
+#include "storage/LoopCo.h"
+#include "storage/Loop.h"
+#include "storage/BtrfsCo.h"
+#include "storage/Btrfs.h"
+#include "storage/TmpfsCo.h"
+#include "storage/Tmpfs.h"
+#include "storage/NfsCo.h"
+#include "storage/Nfs.h"
+#include "storage/FilterIterator.h"
+#include "storage/DerefIterator.h"
+#include "storage/ListListIterator.h"
+#include "storage/IterPair.h"
+#include "storage/Lock.h"
+#include "storage/FreeInfo.h"
+#include "storage/ArchInfo.h"
+
namespace storage
{
@@ -62,9 +69,11 @@
extern CallbackShowInstallInfo install_info_cb_ycp;
extern CallbackInfoPopup info_popup_cb_ycp;
extern CallbackYesNoPopup yesno_popup_cb_ycp;
+ extern CallbackCommitErrorPopup commit_error_popup_cb_ycp;
extern CallbackPasswordPopup password_popup_cb_ycp;
-template <int Value>
+
+template <CType Value>
class CheckType
{
public:
@@ -74,9 +83,8 @@
}
};
-template< class Iter, int Value, class CastResult >
-class CastCheckIterator : public CheckType<Value>,
- public FilterIterator< CheckType<Value>, Iter >
+template< class Iter, CType Value, class CastResult >
+class CastCheckIterator : public FilterIterator< CheckType<Value>, Iter >
{
typedef FilterIterator<CheckType<Value>, Iter> _bclass;
public:
@@ -86,10 +94,12 @@
CastCheckIterator() : _bclass() {}
CastCheckIterator( const Iter& b, const Iter& e, bool atend=false) :
- _bclass( b, e, *this, atend ) {}
+ _bclass( b, e, CheckType<Value>(), atend ) {}
CastCheckIterator( const IterPair<Iter>& pair, bool atend=false) :
- _bclass( pair, *this, atend ) {}
- CastCheckIterator( const CastCheckIterator& i) { *this=i;}
+ _bclass( pair, CheckType<Value>(), atend ) {}
+ template< class It >
+ CastCheckIterator( const It& i) : _bclass( i.begin(), i.end(), CheckType<Value>() )
+ { this->m_cur=i.cur();}
CastResult operator*() const
{
return( static_cast<CastResult>(_bclass::operator*()) );
@@ -133,8 +143,7 @@
};
template< class Iter, bool (* FncP)( const Container& c ), class CastResult >
-class CastCheckFncIterator : public CheckByFnc<FncP>,
- public FilterIterator< CheckByFnc<FncP>, Iter >
+class CastCheckFncIterator : public FilterIterator< CheckByFnc<FncP>, Iter >
{
typedef FilterIterator<CheckByFnc<FncP>, Iter> _bclass;
public:
@@ -144,10 +153,12 @@
CastCheckFncIterator() : _bclass() {}
CastCheckFncIterator( const Iter& b, const Iter& e, bool atend=false) :
- _bclass( b, e, *this, atend ) {}
+ _bclass( b, e, CheckByFnc<FncP>(), atend ) {}
CastCheckFncIterator( const IterPair<Iter>& pair, bool atend=false) :
- _bclass( pair, *this, atend ) {}
- CastCheckFncIterator( const CastCheckFncIterator& i) { *this=i;}
+ _bclass( pair, CheckByFnc<FncP>(), atend ) {}
+ template< class It >
+ CastCheckFncIterator( const It& i) : _bclass( i.begin(), i.end(), i.pred() )
+ { this->m_cur=i.cur();}
CastResult operator*() const
{
return( static_cast<CastResult>(_bclass::operator*()) );
@@ -180,26 +191,26 @@
}
};
-/**
- * \brief Main class to access libstorage functionality.
- *
- * This is the main class with that one can get access to the
- * functionality provided by libstorage.
- * It contains a list of container objects.
- *
- * All modifying member functions of the storage library will
- * go through Storage class. This is the central place where
- * things like readonly access, locking, testmode, inst-sys etc.
- * are handled. It has the additional advantage the the complete
- * class hierarchy below Storage could be changed without affecting
- * the user interface of libstorage.
- */
class EtcFstab;
-class EtcRaidtab;
+ class EtcMdadm;
class DiskData;
-class Storage : public storage::StorageInterface
+
+ /**
+ * \brief Main class to access libstorage functionality.
+ *
+ * This is the main class with that one can get access to the
+ * functionality provided by libstorage. It contains a list of container
+ * objects.
+ *
+ * All modifying member functions of the storage library will go through
+ * Storage class. This is the central place where things like readonly
+ * access, locking, testmode, inst-sys etc. are handled. It has the
+ * additional advantage the the complete class hierarchy below Storage
+ * could be changed without affecting the user interface of libstorage.
+ */
+ class Storage : public storage::StorageInterface, boost::noncopyable
{
protected:
@@ -215,33 +226,19 @@
{ return( d.type()==storage::NFSC ); }
static bool isDm( const Container&d )
{ return( d.type()==storage::DM ); }
- struct FreeInfo
- {
- unsigned long long resize_free;
- unsigned long long df_free;
- unsigned long long used;
- bool win;
- bool efi;
- bool rok;
- FreeInfo() { resize_free=df_free=used=0; efi=win=rok=false; }
- FreeInfo( unsigned long long df,
- unsigned long long resize,
- unsigned long long usd, bool w=false, bool e=false,
- bool r=true )
- { resize_free=resize; df_free=df; used=usd; win=w;
- efi=e, rok=r; }
- };
-
- public:
- struct SkipDeleted { bool operator()(const Container&d) const {return( !d.deleted());}};
- static SkipDeleted SkipDel;
- static bool notDeleted( const Container&d ) { return( !d.deleted() ); };
+ static bool isBtrfs( const Container&d )
+ { return( d.type()==storage::BTRFSC ); }
+ static bool isNotBtrfs( const Container&d )
+ { return( d.type()!=storage::BTRFSC ); }
+ static bool isTmpfs( const Container&d )
+ { return( d.type()==storage::TMPFSC ); }
+
+ public:
+
static bool isDmPart( const Container&d )
{ return d.type() == storage::DMRAID || d.type() == storage::DMMULTIPATH; }
- static bool isMdPart( const Container&d )
- { return( d.type()==storage::MDPART ); }
-
- static void initDefaultLogger ();
+ static bool isMdPart( const Container&d )
+ { return d.type() == storage::MDPART; }
Storage(const Environment& env);
@@ -256,47 +253,65 @@
bool isCacheChanges() const { return( cache ); }
void assertInit() { if( !initialized ) initialize(); }
void rescanEverything();
+ bool rescanCryptedObjects();
int checkCache();
const string& root() const { return( rootprefix ); }
string prependRoot(const string& mp) const;
- const string& tmpDir() const;
- bool efiBoot() const { return efiboot; }
+ const string& tmpDir() const { return tempdir; }
bool hasIScsiDisks() const;
- static const string& arch() { return( proc_arch ); }
- static bool isPPCMac() { return( is_ppc_mac ); }
- static bool isPPCPegasos() { return( is_ppc_pegasos ); }
+ string bootMount() const;
+
+ const ArchInfo& getArchInfo() const { return archinfo; }
+
EtcFstab* getFstab() { return fstab; }
- EtcRaidtab* getRaidtab() { return raidtab; }
- void handleLogFile( const string& name );
+ EtcMdadm* getMdadm() { return mdadm; }
+ void handleLogFile(const string& name) const;
static bool testFilesEqual( const string& n1, const string& n2 );
- void printInfo( std::ostream& str ) { printInfo( str, "" ); }
- void printInfo( std::ostream& str, const string& name );
- void printInfoCo( std::ostream& str, const string& name ) { printInfo( str, name ); }
+ void printInfo(std::ostream& str) const;
void logCo(const Container* c) const;
- void logCo(const string& device);
- void logProcData( const string& l="" );
- storage::UsedByType usedBy( const string& dev );
- bool usedBy( const string& dev, storage::usedBy& ub );
- bool clearUsedBy(const string& dev);
- bool setUsedBy(const string& dev, storage::UsedByType ub_type,
- const string& ub_name);
+ void logProcData(const string& str = "") const;
+
+ void clearUsedBy(const string& dev);
+ void clearUsedBy(const list<string>& devs);
+ void setUsedBy(const string& dev, UsedByType type, const string& device);
+ void setUsedBy(const list<string>& devs, UsedByType type, const string& device);
+ void setUsedByBtrfs( const string& dev, const string& uuid );
+ void addUsedBy(const string& dev, UsedByType type, const string& device);
+ void addUsedBy(const list<string>& devs, UsedByType type, const string& device);
+ void removeUsedBy(const string& dev, UsedByType type, const string& device);
+ void removeUsedBy(const list<string>& devs, UsedByType type, const string& device);
+ bool isUsedBy(const string& dev);
+ bool isUsedBy(const string& dev, UsedByType type);
+ bool isUsedBySingleBtrfs( const Volume& vol ) const;
+ bool canRemove( const Volume& vol ) const;
+
+ void fetchDanglingUsedBy(const string& dev, list<UsedBy>& uby);
+
bool canUseDevice( const string& dev, bool disks_allowed=false );
bool knownDevice( const string& dev, bool disks_allowed=false );
bool setDmcryptData( const string& dev, const string& dm,
unsigned dmnum, unsigned long long siz,
storage::EncryptType typ );
- bool deletedDevice( const string& dev );
+ bool deletedDevice(const string& dev) const;
bool isDisk( const string& dev );
const Volume* getVolume( const string& dev );
unsigned long long deviceSize( const string& dev );
- string deviceByNumber( const string& majmin );
+ string deviceByNumber(const string& majmin) const;
+ const Device* deviceByNumber( unsigned long maj, unsigned long min ) const;
+
+ void syncMdadm();
void rootMounted();
bool isRootMounted() const { return( root_mounted ); }
+
string findNormalDevice( const string& device );
- bool findVolume( const string& device, Volume const* &vol );
+ bool findVolume( const string& device, Volume const* &vol,
+ bool no_btrfsc=false );
bool findDm( const string& device, const Dm*& dm );
bool findDmUsing( const string& device, const Dm*& dm );
+ bool findDevice( const string& dev, const Device* &vol,
+ bool search_by_minor=false );
bool removeDm( const string& device );
+ int unaccessDev( const string& device );
virtual ~Storage();
@@ -328,6 +343,8 @@
int getDmInfo( deque<storage::DmInfo>& plist );
int getNfsInfo( deque<storage::NfsInfo>& plist );
int getLoopInfo( deque<storage::LoopInfo>& plist );
+ int getBtrfsInfo( deque<storage::BtrfsInfo>& plist );
+ int getTmpfsInfo( deque<storage::TmpfsInfo>& plist );
int getDmraidInfo( const string& name,
deque<storage::DmraidInfo>& plist );
int getDmmultipathInfo( const string& name,
@@ -338,6 +355,7 @@
storage::FsCapabilities& fscapabilities) const;
bool getDlabelCapabilities(const string& dlabel,
storage::DlabelCapabilities& dlabelcapabilities) const;
+
list<string> getAllUsedFs() const;
void setExtError( const string& txt );
int createPartition( const string& disk, storage::PartitionType type,
@@ -363,6 +381,10 @@
int removePartition( const string& partition );
int changePartitionId( const string& partition, unsigned id );
int forgetChangePartitionId( const string& partition );
+
+ string getPartitionPrefix(const string& disk);
+ string getPartitionName(const string& disk, int partition_no);
+
int getUnusedPartitionSlots(const string& disk, list<PartitionSlotInfo>& slots);
int destroyPartitionTable( const string& disk, const string& label );
int initializeDisk( const string& disk, bool value );
@@ -384,7 +406,8 @@
int addFstabOptions( const string&, const string& options );
int removeFstabOptions( const string&, const string& options );
int setCryptPassword( const string& device, const string& pwd );
- int verifyCryptPassword( const string& device, const string& pwd );
+ int verifyCryptPassword( const string& device, const string& pwd,
+ bool erase );
int verifyCryptFilePassword( const string& file, const string& pwd );
bool needCryptPassword( const string& device );
int forgetCryptPassword( const string& device );
@@ -397,29 +420,38 @@
int addFstabEntry( const string& device, const string& mount,
const string& vfs, const string& options,
unsigned freq, unsigned passno );
- int resizeVolume( const string& device, unsigned long long newSizeMb );
- int resizeVolumeNoFs( const string& device, unsigned long long newSizeMb );
+ int resizeVolume(const string& device, unsigned long long newSizeK);
+ int resizeVolumeNoFs(const string& device, unsigned long long newSizeK);
int forgetResizeVolume( const string& device );
void setRecursiveRemoval( bool val=true );
bool getRecursiveRemoval() const { return recursiveRemove; }
+
+ int getRecursiveUsing(const string& device, list<string>& devices);
+ int getRecursiveUsingHelper(const string& device, list<string>& devices);
+
void setZeroNewPartitions( bool val=true );
bool getZeroNewPartitions() const { return zeroNewPartitions; }
void setPartitionAlignment( PartAlign val );
PartAlign getPartitionAlignment() const { return partAlignment; }
- void setDefaultMountBy (MountByType mby = MOUNTBY_DEVICE);
+ void setDefaultMountBy(MountByType mby);
MountByType getDefaultMountBy() const { return defaultMountBy; }
+
+ void setDefaultFs (FsType fs);
+ FsType getDefaultFs() const { return defaultFs; }
+
void setDetectMountedVolumes( bool val=true );
bool getDetectMountedVolumes() const { return detectMounted; }
- void setEfiBoot(bool val);
bool getEfiBoot();
void setRootPrefix( const string& root );
string getRootPrefix() const { return rootprefix; }
int removeVolume( const string& device );
- int removeUsing( const string& device, const storage::usedBy& uby );
- bool checkDeviceMounted( const string& device, string& mp );
- bool umountDevice( const string& device );
+ int removeUsing(const string& device, const list<UsedBy>& uby);
+ bool checkDeviceMounted(const string& device, list<string>& mps);
+ bool umountDevice( const string& device )
+ { return( umountDev( device, true )); }
+ bool umountDev( const string& device, bool dounsetup=false );
bool mountDev( const string& device, const string& mp, bool ro=true,
const string& opts="" );
bool mountDevice( const string& device, const string& mp )
@@ -430,16 +462,16 @@
bool mountDeviceRo( const string& device, const string& mp,
const string& opts )
{ return( mountDev( device, mp, true, opts )); }
+ int activateEncryption( const string& device, bool on );
bool readFstab( const string& dir, deque<storage::VolumeInfo>& infos);
- bool getFreeInfo( const string& device, unsigned long long& resize_free,
- unsigned long long& df_free,
- unsigned long long& used, bool& win, bool& efi,
- bool use_cache );
- unsigned long long getDfSize( const string& mp );
+
+ bool getFreeInfo(const string& device, bool get_resize, ResizeInfo& resize_info,
+ bool get_content, ContentInfo& content_info, bool use_cache);
+
int createBackupState( const string& name );
int removeBackupState( const string& name );
int restoreBackupState( const string& name );
- bool checkBackupState( const string& name );
+ bool checkBackupState( const string& name ) const;
bool equalBackupStates( const string& lhs, const string& rhs,
bool verbose_log ) const;
@@ -449,7 +481,7 @@
int extendLvmVg( const string& name, const deque<string>& devs );
int shrinkLvmVg( const string& name, const deque<string>& devs );
int createLvmLv( const string& vg, const string& name,
- unsigned long long sizeM, unsigned stripe,
+ unsigned long long sizeK, unsigned stripes,
string& device );
int removeLvmLvByDevice( const string& device );
int removeLvmLv( const string& vg, const string& name );
@@ -465,23 +497,23 @@
int getLvmLvSnapshotStateInfo(const string& vg, const string& name,
LvmLvSnapshotStateInfo& info);
- int nextFreeMd(int &nr, string &device);
- bool checkMdNumber(int num);
- int createMd( const string& name, storage::MdType rtype,
- const deque<string>& devs );
- int createMdAny( storage::MdType rtype, const deque<string>& devs,
- string& device );
+ int nextFreeMd(unsigned& nr, string &device);
+ bool checkMdNumber(unsigned num);
+ int createMd(const string& name, MdType rtype, const list<string>& devs,
+ const list<string>& spares);
+ int createMdAny(MdType rtype, const list<string>& devs, const list<string>& spares,
+ string& device);
int removeMd( const string& name, bool destroySb=true );
- int extendMd( const string& name, const string& dev );
- int shrinkMd( const string& name, const string& dev );
+ int extendMd(const string& name, const list<string>& devs, const list<string>& spares);
+ int shrinkMd(const string& name, const list<string>& devs, const list<string>& spares);
int changeMdType( const string& name, storage::MdType rtype );
int changeMdChunk( const string& name, unsigned long chunk );
int changeMdParity( const string& name, storage::MdParity ptype );
int checkMd( const string& name );
int getMdStateInfo(const string& name, MdStateInfo& info);
- int computeMdSize(MdType md_type, list<string> devices,
+ int computeMdSize(MdType md_type, const list<string>& devices, const list<string>& spares,
unsigned long long& sizeK);
-
+ list<int> getMdAllowedParity(MdType md_type, unsigned devices );
void setImsmDriver(ImsmDriver val) { imsm_driver = val; }
ImsmDriver getImsmDriver() const { return imsm_driver; }
@@ -491,10 +523,10 @@
int getMdPartCoStateInfo(const string& name, MdPartCoStateInfo& info);
int removeMdPartCo(const string& devName, bool destroySb);
- int addNfsDevice( const string& nfsDev, const string& opts,
- unsigned long long sizeK, const string& mp );
- int checkNfsDevice( const string& nfsDev, const string& opts,
- unsigned long long& sizeK );
+ int addNfsDevice(const string& nfsDev, const string& opts,
+ unsigned long long sizeK, const string& mp, bool nfs4);
+ int checkNfsDevice(const string& nfsDev, const string& opts, bool nfs4,
+ unsigned long long& sizeK);
int createFileLoop( const string& lname, bool reuseExisting,
unsigned long long sizeK, const string& mp,
@@ -505,66 +537,88 @@
int removeDmraid( const string& name );
- deque<string> getCommitActions( bool mark_destructive ) const;
- void getCommitInfo(bool mark_destructive, CommitInfo& info) const;
- const string& getLastAction() const { return lastAction; }
+ int createSubvolume( const string& device, const string& name );
+ int removeSubvolume( const string& device, const string& name );
+ int extendBtrfsVolume( const string& device, const string& dev );
+ int extendBtrfsVolume( const string& device, const deque<string>& devs );
+ int shrinkBtrfsVolume( const string& device, const string& dev );
+ int shrinkBtrfsVolume( const string& device, const deque<string>& devs );
+ int newBtrfs( const string& device );
+
+ int addTmpfsMount( const string& mp, const string& opts );
+ int removeTmpfsMount( const string& mp );
+
+ void getCommitInfos(list<CommitInfo>& infos) const;
+ const string& getLastAction() const { return lastAction.text; }
const string& getExtendedErrorMessage() const { return extendedError; }
- void eraseFreeInfo( const string& device );
+ void eraseCachedFreeInfo(const string& device);
+
+ static void waitForDevice();
+ static int waitForDevice(const string& device);
- static int waitForDevice();
- static int waitForDevice( const string& device );
- 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);
+ static 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<Disk*>& dl );
void changeDeviceName( const string& old, const string& nw );
int commit();
+
+ string getErrorString(int error) const;
+
void handleHald( bool stop );
- void activateHld( bool val=true );
- void activateMultipath( bool val=true );
+
+ void activateHld(bool val = true);
+ void activateMultipath(bool val = true);
+
void removeDmTableTo( const Volume& vol );
void removeDmTableTo( const string& device );
+ void removeDmTableTo( unsigned long mjr, unsigned long mnr );
bool removeDmTable( const string& table );
bool removeDmMapsTo( const string& dev );
bool checkDmMapsTo( const string& dev );
void updateDmEmptyPeMap();
void dumpObjectList();
-
- string byteToHumanString(unsigned long long size, bool classic, int precision, bool omit_zeroes) const;
- bool humanStringToByte(const string& str, bool classic, unsigned long long& size) const;
+ void dumpCommitInfos() const;
+ bool mountTmpRo( const Volume* vol, string& mp )
+ { return mountTmp( vol, mp, true ); }
+ bool mountTmp( const Volume* vol, string& mp, bool ro=false );
void setCallbackProgressBar(CallbackProgressBar pfnc) { progress_bar_cb = pfnc; }
- CallbackProgressBar getCallbackProgressBar() const { return progress_bar_cb; }
- void setCallbackShowInstallInfo(CallbackShowInstallInfo pfnc) { install_info_cb = pfnc; }
- CallbackShowInstallInfo getCallbackShowInstallInfo() const { return install_info_cb; }
- void setCallbackInfoPopup(CallbackInfoPopup pfnc) { info_popup_cb = pfnc; }
- CallbackInfoPopup getCallbackInfoPopup() const { return info_popup_cb; }
- void setCallbackYesNoPopup(CallbackYesNoPopup pfnc) { yesno_popup_cb = pfnc; }
- CallbackYesNoPopup getCallbackYesNoPopup() const { return yesno_popup_cb; }
- void setCallbackPasswordPopup(CallbackPasswordPopup pfnc) { password_popup_cb = pfnc; }
- CallbackPasswordPopup getCallbackPasswordPopup() const { return password_popup_cb; }
-
- void addInfoPopupText( const string& disk, const string& txt );
-
- CallbackProgressBar getCallbackProgressBarTheOne() const
- { return progress_bar_cb ? progress_bar_cb : progress_bar_cb_ycp; }
- CallbackShowInstallInfo getCallbackShowInstallInfoTheOne() const
- { return install_info_cb ? install_info_cb : install_info_cb_ycp; }
- CallbackInfoPopup getCallbackInfoPopupTheOne() const
- { return info_popup_cb ? info_popup_cb : info_popup_cb_ycp; }
- CallbackYesNoPopup getCallbackYesNoPopupTheOne() const
- { return yesno_popup_cb ? yesno_popup_cb : yesno_popup_cb_ycp; }
- CallbackPasswordPopup getCallbackPasswordPopupTheOne() const
- { return password_popup_cb ? password_popup_cb : password_popup_cb_ycp; }
-
- void progressBarCb(const string& id, unsigned cur, unsigned max) const;
- void showInfoCb(const string& info);
- void infoPopupCb(const string& info) const;
- bool yesnoPopupCb(const string& info) const;
- bool passwordPopupCb(const string& device, int attempts, string& password) const;
+ CallbackProgressBar getCallbackProgressBar() const { return progress_bar_cb; }
+ void setCallbackShowInstallInfo(CallbackShowInstallInfo pfnc) { install_info_cb = pfnc; }
+ CallbackShowInstallInfo getCallbackShowInstallInfo() const { return install_info_cb; }
+ void setCallbackInfoPopup(CallbackInfoPopup pfnc) { info_popup_cb = pfnc; }
+ CallbackInfoPopup getCallbackInfoPopup() const { return info_popup_cb; }
+ void setCallbackYesNoPopup(CallbackYesNoPopup pfnc) { yesno_popup_cb = pfnc; }
+ CallbackYesNoPopup getCallbackYesNoPopup() const { return yesno_popup_cb; }
+ void setCallbackCommitErrorPopup(CallbackCommitErrorPopup pfnc) { commit_error_popup_cb = pfnc; }
+ CallbackCommitErrorPopup getCallbackCommitErrorPopup() const { return commit_error_popup_cb; }
+ void setCallbackPasswordPopup(CallbackPasswordPopup pfnc) { password_popup_cb = pfnc; }
+ CallbackPasswordPopup getCallbackPasswordPopup() const { return password_popup_cb; }
+
+ void addInfoPopupText( const string& disk, const Text& txt );
+
+ CallbackProgressBar getCallbackProgressBarTheOne() const
+ { return progress_bar_cb ? progress_bar_cb : progress_bar_cb_ycp; }
+ CallbackShowInstallInfo getCallbackShowInstallInfoTheOne() const
+ { return install_info_cb ? install_info_cb : install_info_cb_ycp; }
+ CallbackInfoPopup getCallbackInfoPopupTheOne() const
+ { return info_popup_cb ? info_popup_cb : info_popup_cb_ycp; }
+ CallbackYesNoPopup getCallbackYesNoPopupTheOne() const
+ { return yesno_popup_cb ? yesno_popup_cb : yesno_popup_cb_ycp; }
+ CallbackCommitErrorPopup getCallbackCommitErrorPopupTheOne() const
+ { return commit_error_popup_cb ? commit_error_popup_cb : commit_error_popup_cb_ycp; }
+ CallbackPasswordPopup getCallbackPasswordPopupTheOne() const
+ { return password_popup_cb ? password_popup_cb : password_popup_cb_ycp; }
+
+ void progressBarCb(const string& id, unsigned cur, unsigned max) const;
+ void showInfoCb(const Text& info);
+ void infoPopupCb(const Text& info) const;
+ bool yesnoPopupCb(const Text& info) const;
+ bool commitErrorPopupCb(int error, const Text& last_action, const string& extended_message) const;
+ bool passwordPopupCb(const string& device, int attempts, string& password) const;
// iterators over container
protected:
@@ -1512,9 +1566,6 @@
}
-
-
-
// iterators over file based loop devices
protected:
// protected typedefs for iterators over file based loop devices
@@ -1575,6 +1626,126 @@
return( typename ConstLoopI<Pred>::type( typename ConstLoopPI<Pred>::type(pair, p, true )) );
}
+// iterators over btrfs volumes
+ protected:
+ // protected typedefs for iterators over btrfs volumes
+ typedef CastIterator<ConstVolInter, Btrfs *> ConstBtrfsInter;
+ template< class Pred >
+ struct ConstBtrfsPI { typedef ContainerIter<Pred,
+ ConstBtrfsInter> type; };
+ typedef CheckFnc<const Btrfs> CheckFncBtrfs;
+ typedef CheckerIterator< CheckFncBtrfs, ConstBtrfsPI<CheckFncBtrfs>::type,
+ ConstBtrfsInter, Btrfs > ConstBtrfsPIterator;
+ public:
+ // public typedefs for iterators over btrfs volumes
+ template< class Pred >
+ struct ConstBtrfsI
+ { typedef ContainerDerIter<Pred, typename ConstBtrfsPI<Pred>::type,
+ const Btrfs> type; };
+ template< class Pred >
+ struct BtrfsCondIPair
+ { typedef MakeCondIterPair<Pred, typename ConstBtrfsI<Pred>::type> type;};
+ typedef DerefIterator<ConstBtrfsPIterator, const Btrfs> ConstBtrfsIterator;
+ typedef IterPair<ConstBtrfsIterator> ConstBtrfsPair;
+
+ // public member functions for iterators over btrfs volumes
+ ConstBtrfsPair btrfsPair( bool (* CheckBtrfs)( const Btrfs& )=NULL ) const
+ {
+ return( ConstBtrfsPair( btrfsBegin( CheckBtrfs ), btrfsEnd( CheckBtrfs ) ));
+ }
+ ConstBtrfsIterator btrfsBegin( bool (* CheckBtrfs)( const Btrfs& )=NULL ) const
+ {
+ ConstVolInter b( contPair( isBtrfs ) );
+ ConstVolInter e( contPair( isBtrfs ), true );
+ IterPair<ConstBtrfsInter> p( (ConstBtrfsInter(b)), (ConstBtrfsInter(e)) );
+ return( ConstBtrfsIterator( ConstBtrfsPIterator(p, CheckBtrfs )));
+ }
+ ConstBtrfsIterator btrfsEnd( bool (* CheckBtrfs)( const Btrfs& )=NULL ) const
+ {
+ ConstVolInter b( contPair( isBtrfs ) );
+ ConstVolInter e( contPair( isBtrfs ), true );
+ IterPair<ConstBtrfsInter> p( (ConstBtrfsInter(b)), (ConstBtrfsInter(e)) );
+ return( ConstBtrfsIterator( ConstBtrfsPIterator(p, CheckBtrfs, true )));
+ }
+ template< class Pred > typename BtrfsCondIPair<Pred>::type btrfsCondPair( const Pred& p ) const
+ {
+ return( typename BtrfsCondIPair<Pred>::type( btrfsCondBegin( p ), btrfsCondEnd( p ) ) );
+ }
+ template< class Pred > typename ConstBtrfsI<Pred>::type btrfsCondBegin( const Pred& p ) const
+ {
+ ConstVolInter b( contPair( isBtrfs ) );
+ ConstVolInter e( contPair( isBtrfs ), true );
+ IterPair<ConstBtrfsInter> pair( (ConstBtrfsInter(b)), (ConstBtrfsInter(e)) );
+ return( typename ConstBtrfsI<Pred>::type( typename ConstBtrfsPI<Pred>::type(pair, p) ) );
+ }
+ template< class Pred > typename ConstBtrfsI<Pred>::type btrfsCondEnd( const Pred& p ) const
+ {
+ ConstVolInter b( contPair( isBtrfs ) );
+ ConstVolInter e( contPair( isBtrfs ), true );
+ IterPair<ConstBtrfsInter> pair( (ConstBtrfsInter(b)), (ConstBtrfsInter(e)) );
+ return( typename ConstBtrfsI<Pred>::type( typename ConstBtrfsPI<Pred>::type(pair, p, true )) );
+ }
+
+// iterators over tmpfs volumes
+ protected:
+ // protected typedefs for iterators over tmpfs volumes
+ typedef CastIterator<ConstVolInter, Tmpfs *> ConstTmpfsInter;
+ template< class Pred >
+ struct ConstTmpfsPI { typedef ContainerIter<Pred,
+ ConstTmpfsInter> type; };
+ typedef CheckFnc<const Tmpfs> CheckFncTmpfs;
+ typedef CheckerIterator< CheckFncTmpfs, ConstTmpfsPI<CheckFncTmpfs>::type,
+ ConstTmpfsInter, Tmpfs > ConstTmpfsPIterator;
+ public:
+ // public typedefs for iterators over tmpfs volumes
+ template< class Pred >
+ struct ConstTmpfsI
+ { typedef ContainerDerIter<Pred, typename ConstTmpfsPI<Pred>::type,
+ const Tmpfs> type; };
+ template< class Pred >
+ struct TmpfsCondIPair
+ { typedef MakeCondIterPair<Pred, typename ConstTmpfsI<Pred>::type> type;};
+ typedef DerefIterator<ConstTmpfsPIterator, const Tmpfs> ConstTmpfsIterator;
+ typedef IterPair<ConstTmpfsIterator> ConstTmpfsPair;
+
+ // public member functions for iterators over tmpfs volumes
+ ConstTmpfsPair tmpfsPair( bool (* CheckTmpfs)( const Tmpfs& )=NULL ) const
+ {
+ return( ConstTmpfsPair( tmpfsBegin( CheckTmpfs ), tmpfsEnd( CheckTmpfs ) ));
+ }
+ ConstTmpfsIterator tmpfsBegin( bool (* CheckTmpfs)( const Tmpfs& )=NULL ) const
+ {
+ ConstVolInter b( contPair( isTmpfs ) );
+ ConstVolInter e( contPair( isTmpfs ), true );
+ IterPair<ConstTmpfsInter> p( (ConstTmpfsInter(b)), (ConstTmpfsInter(e)) );
+ return( ConstTmpfsIterator( ConstTmpfsPIterator(p, CheckTmpfs )));
+ }
+ ConstTmpfsIterator tmpfsEnd( bool (* CheckTmpfs)( const Tmpfs& )=NULL ) const
+ {
+ ConstVolInter b( contPair( isTmpfs ) );
+ ConstVolInter e( contPair( isTmpfs ), true );
+ IterPair<ConstTmpfsInter> p( (ConstTmpfsInter(b)), (ConstTmpfsInter(e)) );
+ return( ConstTmpfsIterator( ConstTmpfsPIterator(p, CheckTmpfs, true )));
+ }
+ template< class Pred > typename TmpfsCondIPair<Pred>::type tmpfsCondPair( const Pred& p ) const
+ {
+ return( typename TmpfsCondIPair<Pred>::type( tmpfsCondBegin( p ), tmpfsCondEnd( p ) ) );
+ }
+ template< class Pred > typename ConstTmpfsI<Pred>::type tmpfsCondBegin( const Pred& p ) const
+ {
+ ConstVolInter b( contPair( isTmpfs ) );
+ ConstVolInter e( contPair( isTmpfs ), true );
+ IterPair<ConstTmpfsInter> pair( (ConstTmpfsInter(b)), (ConstTmpfsInter(e)) );
+ return( typename ConstTmpfsI<Pred>::type( typename ConstTmpfsPI<Pred>::type(pair, p) ) );
+ }
+ template< class Pred > typename ConstTmpfsI<Pred>::type tmpfsCondEnd( const Pred& p ) const
+ {
+ ConstVolInter b( contPair( isTmpfs ) );
+ ConstVolInter e( contPair( isTmpfs ), true );
+ IterPair<ConstTmpfsInter> pair( (ConstTmpfsInter(b)), (ConstTmpfsInter(e)) );
+ return( typename ConstTmpfsI<Pred>::type( typename ConstTmpfsPI<Pred>::type(pair, p, true )) );
+ }
+
// iterators over nfs devices
protected:
// protected typedefs for iterators over nfs devices
@@ -1845,33 +2016,26 @@
// protected internal member functions
void initialize();
void logSystemInfo() const;
- void detectDisks( ProcPart& ppart );
- void autodetectDisks( ProcPart& ppart );
- void detectMultipath();
- void detectMds();
- void detectMdParts(ProcPart& ppart);
- //Discovers that platfrom is IMSM and Partitionable RAID Volumes
- //can be on it
+ void detectDisks(SystemInfo& systeminfo);
+ void autodetectDisks(SystemInfo& systeminfo);
+ void detectMds(SystemInfo& systeminfo);
+ void detectBtrfs(SystemInfo& systeminfo);
+ void detectMdParts(SystemInfo& systeminfo);
bool discoverMdPVols();
- void detectLoops( ProcPart& ppart );
- void detectNfs( ProcMounts& mounts );
- void detectLvmVgs();
- void detectDmraid( ProcPart& ppart );
- void detectDmmultipath( ProcPart& ppart );
- void detectDm(ProcPart& ppart, bool only_crypt);
- void initDisk( list<DiskData>& dl, ProcPart& pp );
- void detectFsData( const VolIterator& begin, const VolIterator& end,
- ProcMounts& mounts );
- void detectFsDataTestMode( const string& file,
- const VolIterator& begin,
- const VolIterator& end );
- int resizeVolume( const string& device, unsigned long long newSizeMb,
- bool ignore_fs );
+ void detectLoops(SystemInfo& systeminfo);
+ void detectNfs(const EtcFstab& fstab, SystemInfo& systeminfo);
+ void detectTmpfs(const EtcFstab& fstab, SystemInfo& systeminfo);
+ void detectLvmVgs(SystemInfo& systeminfo);
+ void detectDmraid(SystemInfo& systeminfo);
+ void detectDmmultipath(SystemInfo& systeminfo);
+ void detectDm(SystemInfo& systeminfo, bool only_crypt);
+ void initDisk( list<DiskData>& dl, SystemInfo& systeminfo);
+ void detectFsData(const VolIterator& begin, const VolIterator& end, SystemInfo& systeminfo);
+ int resizeVolume(const string& device, unsigned long long newSizeK,
+ bool ignore_fs);
int resizePartition( const string& device, unsigned long sizeCyl,
bool ignore_fs );
- static void detectArch();
- void addToList( Container* e )
- { pointerIntoSortedList<Container>( cont, e ); }
+ void addToList(Container* e);
DiskIterator findDisk( const string& disk );
DiskIterator findDiskId( const string& id );
DiskIterator findDiskPath( const string& path );
@@ -1883,38 +2047,49 @@
MdPartCoIterator findMdPartCo( const string& name );
bool findVolume( const string& device, ContIterator& c,
- VolIterator& v );
+ VolIterator& v, bool no_btrfs=false );
+ bool findVolume( const string& device, ConstContIterator& c,
+ ConstVolIterator& v );
bool findVolume( const string& device, VolIterator& v,
- bool also_del=false );
+ bool also_del=false, bool no_btrfs=false );
+ bool findVolume( const string& device, ConstVolIterator& v,
+ bool also_del=false, bool no_btrfs=false );
bool findContainer( const string& device, ContIterator& c );
+ bool findContainer( const string& device, ConstContIterator& c );
+
+ Device* findDevice(const string& dev, bool no_btrfs=false);
void checkPwdBuf( const string& device );
+
bool haveMd( MdCo*& md );
- int getMdPartMdNums(list<int>& mdPartNums);
+ list<unsigned> getMdPartMdNums() const;
bool haveDm(DmCo*& dm);
bool haveNfs( NfsCo*& co );
bool haveLoop( LoopCo*& loop );
- int removeContainer( Container* val, bool call_del=true );
- void logVolumes( const string& Dir );
+ bool haveBtrfs( BtrfsCo*& co );
+ bool haveTmpfs( TmpfsCo*& co );
+ int removeContainer( Container* val );
+ void logContainersAndVolumes(const string& Dir) const;
+
int commitPair( CPair& p, bool (* fnc)( const Container& ) );
- void sortCommitLists( storage::CommitStage stage,
- std::list<Container*>& co,
- std::list<Volume*>& vl,
- std::list<storage::commitAction*>& todo );
- bool ignoreError( std::list<commitAction*>::iterator i,
- std::list<commitAction*>& al );
+ void sortCommitLists(storage::CommitStage stage, list<const Container*>& co,
+ list<const Volume*>& vl, list<commitAction>& todo) const;
+ bool ignoreError(int error, list<commitAction>::const_iterator ca) const;
string backupStates() const;
void detectObjects();
- void deleteClist( CCont& co );
void deleteBackups();
- void setFreeInfo( const string& device, unsigned long long df_free,
- unsigned long long resize_free,
- unsigned long long used, bool win, bool efi,
- bool resize_ok );
- bool getFreeInf( const string& device, unsigned long long& df_free,
- unsigned long long& resize_free,
- unsigned long long& used, bool& win, bool& efi,
- bool& resize_ok );
+
+ void setCachedFreeInfo(const string& device, bool resize_cached, const ResizeInfo& resize_info,
+ bool content_cached, const ContentInfo& content_info);
+ bool getCachedFreeInfo( const string& device, bool get_resize, ResizeInfo& resize_info,
+ bool get_content, ContentInfo& content_info) const;
+ void logFreeInfo(const string& Dir) const;
+ void readFreeInfo(const string& file);
+
+ void logArchInfo(const string& Dir) const;
+ void readArchInfo(const string& file);
+
+ list<commitAction> getCommitActions() const;
// protected internal member variables
const Environment env;
@@ -1925,51 +2100,40 @@
bool zeroNewPartitions;
PartAlign partAlignment;
MountByType defaultMountBy;
+ FsType defaultFs;
bool detectMounted;
bool root_mounted;
string tempdir;
string rootprefix;
unsigned hald_pid;
- bool efiboot;
- static string proc_arch;
- static bool is_ppc_mac;
- static bool is_ppc_pegasos;
+
+ ArchInfo archinfo;
+
CCont cont;
EtcFstab *fstab;
- EtcRaidtab *raidtab;
+ EtcMdadm* mdadm;
ImsmDriver imsm_driver;
CallbackProgressBar progress_bar_cb;
- CallbackShowInstallInfo install_info_cb;
- CallbackInfoPopup info_popup_cb;
- CallbackYesNoPopup yesno_popup_cb;
- CallbackPasswordPopup password_popup_cb;
+ CallbackShowInstallInfo install_info_cb;
+ CallbackInfoPopup info_popup_cb;
+ CallbackYesNoPopup yesno_popup_cb;
+ CallbackCommitErrorPopup commit_error_popup_cb;
+ CallbackPasswordPopup password_popup_cb;
+
+ friend std::ostream& operator<<(std::ostream& s, const Storage& v);
+ friend std::ostream& operator<<(std::ostream& s, Storage& v);
- friend std::ostream& operator<< (std::ostream& s, Storage &v );
+ map<string, list<UsedBy>> danglingUsedBy;
unsigned max_log_num;
- string lastAction;
+ Text lastAction;
string extendedError;
std::map<string,CCont> backups;
- std::map<string,FreeInfo> freeInfo;
+ map<string, FreeInfo> free_infos;
std::map<string,string> pwdBuf;
- std::list<std::pair<string,string> > infoPopupTxts;
- };
-
-inline std::ostream& operator<< (std::ostream& s, commitAction &a )
- {
- s << "stage:" << a.stage
- << " type:" << a.type
- << " cont:" << a.container
- << " dest:" << a.destructive;
- if( a.container && a.co() )
- s << " name:" << a.co()->name();
- else if( a.vol() )
- s << " name:" << a.vol()->name();
- if( !a.descr.empty() )
- s << " desc:" << a.descr;
- return( s );
+ std::list<std::pair<string, Text>> infoPopupTxts;
};
}
Modified: branches/SuSE-Code-11-SP2-Branch/storage/libstorage/src/StorageCallbacks.cc
URL: http://svn.opensuse.org/viewcvs/yast/branches/SuSE-Code-11-SP2-Branch/stora…
==============================================================================
--- branches/SuSE-Code-11-SP2-Branch/storage/libstorage/src/StorageCallbacks.cc (original)
+++ branches/SuSE-Code-11-SP2-Branch/storage/libstorage/src/StorageCallbacks.cc Tue May 17 13:39:44 2011
@@ -43,6 +43,8 @@
#define y2log_component "libstorage"
+#include <algorithm>
+
#include <ycp/y2log.h>
#include <ycp/YExpression.h>
#include <ycp/YBlock.h>
@@ -57,12 +59,7 @@
#include <y2/Y2Component.h>
#include <y2/Y2ComponentBroker.h>
-#undef y2milestone
-#undef y2error
-#undef y2warning
-#undef y2debug
-
-#include <Storage.h>
+#include <StorageInterface.h>
using namespace storage;
@@ -73,6 +70,7 @@
extern CallbackShowInstallInfo install_info_cb_ycp;
extern CallbackInfoPopup info_popup_cb_ycp;
extern CallbackYesNoPopup yesno_popup_cb_ycp;
+ extern CallbackCommitErrorPopup commit_error_popup_cb_ycp;
extern CallbackPasswordPopup password_popup_cb_ycp;
}
@@ -107,7 +105,7 @@
m_param3 ( YCPNull () ),
m_param4 ( YCPNull () )
{
-};
+}
bool Y2StorageCallbackFunction::attachParameter (const YCPValue& arg,
const int position)
@@ -124,6 +122,7 @@
return true;
}
+
constTypePtr Y2StorageCallbackFunction::wantedParameterType () const
{
y2internal ("wantedParameterType not implemented");
@@ -236,6 +235,7 @@
static Y2Function* show_install_info = NULL;
static Y2Function* info_popup = NULL;
static Y2Function* yesno_popup = NULL;
+static Y2Function* commit_error_popup = NULL;
static Y2Function* password_popup = NULL;
void progress_bar_callback( const string& id, unsigned cur, unsigned max )
@@ -291,6 +291,28 @@
return ret;
}
+
+bool commit_error_popup_callback(int error, const string& last_action, const string& extended_message)
+{
+ bool ret = false;
+
+ if (commit_error_popup)
+ {
+ commit_error_popup->reset();
+ commit_error_popup->appendParameter(YCPInteger(error));
+ commit_error_popup->appendParameter(YCPString(last_action));
+ commit_error_popup->appendParameter(YCPString(extended_message));
+ commit_error_popup->finishParameters();
+
+ YCPValue tmp = commit_error_popup->evaluateCall();
+ if (tmp->isBoolean())
+ ret = tmp->asBoolean()->value();
+ }
+
+ return ret;
+}
+
+
bool password_popup_callback(const string& device, int attempts, string& password)
{
bool ret = false;
@@ -499,6 +521,53 @@
}
+YCPValue
+StorageCallbacks::CommitErrorPopup(const YCPString& callback)
+{
+ string name_r = callback->value();
+
+ y2debug("Registering callback %s", name_r.c_str());
+ string::size_type colonpos = name_r.find("::");
+
+ if (colonpos == string::npos)
+ {
+ ycp2error ("Specify namespace and the fuction name for a callback");
+ return YCPVoid ();
+ }
+
+ string module = name_r.substr(0, colonpos);
+ string name = name_r.substr(colonpos + 2);
+
+ Y2Component* c = Y2ComponentBroker::getNamespaceComponent(module.c_str());
+ if (c == NULL)
+ {
+ ycp2error("No component can provide namespace %s for a callback of %s",
+ module.c_str(), name.c_str());
+ return YCPVoid();
+ }
+
+ Y2Namespace* ns = c->import(module.c_str());
+ if (ns == NULL)
+ {
+ y2error("No namespace %s for a callback of %s", module.c_str(),
+ name.c_str());
+ return YCPVoid();
+ }
+
+ commit_error_popup = ns->createFunctionCall(name, Type::Unspec);
+ if (commit_error_popup == NULL)
+ {
+ ycp2error("Cannot find function %s in module %s as a callback",
+ name.c_str(), module.c_str());
+ return YCPVoid();
+ }
+
+ storage::commit_error_popup_cb_ycp = commit_error_popup_callback;
+
+ return YCPVoid();
+}
+
+
YCPValue
StorageCallbacks::PasswordPopup (const YCPString & callback)
{
Modified: branches/SuSE-Code-11-SP2-Branch/storage/libstorage/src/StorageCallbacks.h
URL: http://svn.opensuse.org/viewcvs/yast/branches/SuSE-Code-11-SP2-Branch/stora…
==============================================================================
--- branches/SuSE-Code-11-SP2-Branch/storage/libstorage/src/StorageCallbacks.h (original)
+++ branches/SuSE-Code-11-SP2-Branch/storage/libstorage/src/StorageCallbacks.h Tue May 17 13:39:44 2011
@@ -80,6 +80,8 @@
/* TYPEINFO: void(string) */
YCPValue YesNoPopup (const YCPString& func);
/* TYPEINFO: void(string) */
+ YCPValue CommitErrorPopup (const YCPString& func);
+ /* TYPEINFO: void(string) */
YCPValue PasswordPopup (const YCPString& func);
/**
Modified: branches/SuSE-Code-11-SP2-Branch/storage/libstorage/src/StorageDefines.h
URL: http://svn.opensuse.org/viewcvs/yast/branches/SuSE-Code-11-SP2-Branch/stora…
==============================================================================
--- branches/SuSE-Code-11-SP2-Branch/storage/libstorage/src/StorageDefines.h (original)
+++ branches/SuSE-Code-11-SP2-Branch/storage/libstorage/src/StorageDefines.h Tue May 17 13:39:44 2011
@@ -26,14 +26,13 @@
#define SYSFSDIR "/sys/block"
+#define SYSCONFIGFILE "/etc/sysconfig/storage"
#define PARTEDBIN "/usr/sbin/parted"
#define PARTEDCMD PARTEDBIN " -s " // blank at end !!
#define ADDPARTBIN "/usr/sbin/addpart"
#define DELPARTBIN "/usr/sbin/delpart"
-#define FDISKBIN "/sbin/fdisk"
-
#define MDADMBIN "/sbin/mdadm"
#define PVCREATEBIN "/sbin/pvcreate"
@@ -49,6 +48,7 @@
#define VGEXTENDBIN "/sbin/vgextend"
#define VGREDUCEBIN "/sbin/vgreduce"
#define VGDISPLAYBIN "/sbin/vgdisplay"
+#define VGSBIN "/sbin/vgs"
#define VGSCANBIN "/sbin/vgscan"
#define VGCHANGEBIN "/sbin/vgchange"
@@ -57,8 +57,8 @@
#define MULTIPATHBIN "/sbin/multipath"
#define MULTIPATHDBIN "/sbin/multipathd"
#define DMSETUPBIN "/sbin/dmsetup"
-#define KPARTXBIN "/sbin/kpartx"
#define DMRAIDBIN "/sbin/dmraid"
+#define BTRFSBIN "/sbin/btrfs"
#define MOUNTBIN "/bin/mount"
#define UMOUNTBIN "/bin/umount"
@@ -67,6 +67,14 @@
#define DDBIN "/bin/dd"
+#define BLKIDBIN "/sbin/blkid"
+#define BLOCKDEVBIN "/sbin/blockdev"
+#define LSSCSIBIN "/usr/bin/lsscsi"
+
+#define LSBIN "/bin/ls"
+
+#define GREPBIN "/bin/grep"
+
#define DASDFMTBIN "/sbin/dasdfmt"
#define DASDVIEWBIN "/sbin/dasdview"
#define FDASDBIN "/sbin/fdasd"
@@ -75,9 +83,5 @@
#define MODPROBEBIN "/sbin/modprobe"
-#define BLKIDBIN "/sbin/blkid"
-
-#define LSBIN "/bin/ls"
-
#endif
Modified: branches/SuSE-Code-11-SP2-Branch/storage/libstorage/src/StorageInterface.h
URL: http://svn.opensuse.org/viewcvs/yast/branches/SuSE-Code-11-SP2-Branch/stora…
==============================================================================
--- branches/SuSE-Code-11-SP2-Branch/storage/libstorage/src/StorageInterface.h (original)
+++ branches/SuSE-Code-11-SP2-Branch/storage/libstorage/src/StorageInterface.h Tue May 17 13:39:44 2011
@@ -1,5 +1,5 @@
/*
- * Copyright (c) [2004-2009] Novell, Inc.
+ * Copyright (c) [2004-2010] Novell, Inc.
*
* All Rights Reserved.
*
@@ -27,7 +27,6 @@
#include <string>
#include <deque>
#include <list>
-#include <ostream>
using std::string;
using std::deque;
@@ -46,8 +45,8 @@
*
* \section Caching
*
- * All modifying functions of libstorage can either operate on an
- * internal cache or directly on the system.
+ * All modifying functions of libstorage can either operate on an internal
+ * cache or directly on the system.
*
* When the caching mode is enabled a call of e.g. \link
* storage::StorageInterface::createPartition() createPartition() \endlink
@@ -80,68 +79,86 @@
*
* Locking may also fail for other reasons, e.g. limited permissions.
*
+ * \section Configuration File
+ *
+ * During initialisation libstorage reads the default filesystem and default
+ * mount-by method from /etc/sysconfig/storage. Libstorage does not write that
+ * file.
+ *
+ * \section Nomenclature
+ *
+ * Sizes with postfix K are in kilobytes (1024 bytes).
+ *
+ * The only size in bytes instead of kilobytes is the cylinder size of disks.
+ *
* \section Example
*
* Here is a simple example to demonstrate the usage of libstorage:
*
* \code
*
- * #include <y2storage/StorageInterface.h>
+ * #include <storage/StorageInterface.h>
*
- * using namespace std;
* using namespace storage;
*
* int
- * main ()
+ * main()
* {
- * // First we must create a concrete StorageInterface object.
- * StorageInterface* s = createStorageInterface (false, false, true);
+ * // Environment for StorageInterface with read-write enabled.
+ * Environment env(false);
+ *
+ * // Create a concrete StorageInterface object.
+ * StorageInterface* s = createStorageInterface(env);
*
* int ret;
* string name;
*
- * // Create a primary partition on /dev/hda.
- * ret = s->createPartitionKb ("/dev/hda", PRIMARY, 0, 100000, name);
+ * // Create a primary partition on /dev/sdb.
+ * ret = s->createPartitionKb("/dev/sdb", PRIMARY, 0, 100000, name);
*
* // Commit the change to the system.
- * ret = s->commit ();
+ * ret = s->commit();
*
* // Finally destroy the StorageInterface object.
- * delete s;
+ * destroyStorageInterface(s);
* }
*
* \endcode
*
- * If you have installed the latest yast2-storage package you can find more
- * examples in the directory
- * /usr/share/doc/packages/yast2-storage/examples/liby2storage.
+ * If you have installed the latest libstorage-devel package you can find more
+ * examples in the directory /usr/share/doc/packages/libstorage/examples.
*/
namespace storage
{
- enum FsType { FSUNKNOWN, REISERFS, EXT2, EXT3, VFAT, XFS, JFS, HFS, NTFS, SWAP, HFSPLUS, NFS, FSNONE };
+ enum FsType { FSUNKNOWN, REISERFS, EXT2, EXT3, EXT4, BTRFS, VFAT, XFS, JFS, HFS, NTFS,
+ SWAP, HFSPLUS, NFS, NFS4, TMPFS, FSNONE };
enum PartitionType { PRIMARY, EXTENDED, LOGICAL, PTYPE_ANY };
enum MountByType { MOUNTBY_DEVICE, MOUNTBY_UUID, MOUNTBY_LABEL, MOUNTBY_ID, MOUNTBY_PATH };
enum EncryptType { ENC_NONE, ENC_TWOFISH, ENC_TWOFISH_OLD,
- ENC_TWOFISH256_OLD, ENC_LUKS, ENC_UNKNOWN };
+ ENC_TWOFISH256_OLD, ENC_LUKS, ENC_UNKNOWN };
enum MdType { RAID_UNK, RAID0, RAID1, RAID5, RAID6, RAID10, MULTIPATH };
- enum MdParity { PAR_NONE, LEFT_ASYMMETRIC, LEFT_SYMMETRIC,
- RIGHT_ASYMMETRIC, RIGHT_SYMMETRIC };
+ enum MdParity { PAR_DEFAULT, LEFT_ASYMMETRIC, LEFT_SYMMETRIC,
+ RIGHT_ASYMMETRIC, RIGHT_SYMMETRIC, PAR_FIRST, PAR_LAST,
+ LEFT_ASYMMETRIC_6, LEFT_SYMMETRIC_6, RIGHT_ASYMMETRIC_6,
+ RIGHT_SYMMETRIC_6, PAR_FIRST_6,
+ PAR_NEAR_2, PAR_OFFSET_2, PAR_FAR_2,
+ PAR_NEAR_3, PAR_OFFSET_3, PAR_FAR_3 };
enum MdArrayState { UNKNOWN, CLEAR, INACTIVE, SUSPENDED, READONLY, READ_AUTO,
CLEAN, ACTIVE, WRITE_PENDING, ACTIVE_IDLE };
- enum UsedByType { UB_NONE, UB_LVM, UB_MD, UB_DM, UB_DMRAID, UB_DMMULTIPATH,
- UB_MDPART };
+ enum UsedByType { UB_NONE, UB_LVM, UB_MD, UB_MDPART, UB_DM, UB_DMRAID, UB_DMMULTIPATH, UB_BTRFS };
- enum CType { CUNKNOWN, DISK, MD, LOOP, LVM, DM, DMRAID, NFSC, DMMULTIPATH,
- MDPART, COTYPE_LAST_ENTRY };
+ enum CType { CUNKNOWN, DISK, MD, LOOP, LVM, DM, DMRAID, NFSC, DMMULTIPATH, MDPART, BTRFSC, TMPFSC };
+
+ enum Transport { TUNKNOWN, SBP, ATA, FC, ISCSI, SAS, SATA, SPI, USB };
enum ImsmDriver { IMSM_UNDECIDED, IMSM_DMRAID, IMSM_MDADM };
@@ -149,19 +166,20 @@
/**
- * typedef for a pointer to a function that is called on progress bar events
+ * typedef for a pointer to a function that is called on progress bar
+ * events.
*/
typedef void (*CallbackProgressBar)(const string& id, unsigned cur, unsigned max);
/**
- * typedef for a pointer to a function that is called with strings
- * telling the user what is currently going on
+ * typedef for a pointer to a function that is called with strings telling
+ * the user what is currently going on.
*/
typedef void (*CallbackShowInstallInfo)(const string& id);
/**
- * typedef for a pointer to a function that displays a popup with
- * the given text and waits for user confirmation
+ * typedef for a pointer to a function that displays a popup with the
+ * given text and waits for user confirmation.
*/
typedef void (*CallbackInfoPopup)(const string& text);
@@ -174,7 +192,15 @@
typedef bool (*CallbackYesNoPopup)(const string& text);
/**
- * typedef for a pointer to a function that ask for the password of the
+ * typedef for a pointer to a function that asks whether to continue after
+ * an commit error. If true is returned the commit error is ignored and
+ * the commit continues.
+ */
+ typedef bool (*CallbackCommitErrorPopup)(int error, const string& last_action,
+ const string& extended_message);
+
+ /**
+ * typedef for a pointer to a function that asks for the password of the
* given device. If the user does not want to decrypt the device false is
* returned, true otherwise.
*/
@@ -186,7 +212,7 @@
*/
struct FsCapabilities
{
- FsCapabilities () {}
+ FsCapabilities() {}
bool isExtendable;
bool isExtendableWhileMounted;
bool isReduceable;
@@ -211,6 +237,40 @@
};
+ struct UsedByInfo
+ {
+ UsedByInfo(UsedByType type, const string& device) : type(type), device(device) {}
+ UsedByType type;
+ string device;
+ };
+
+
+ struct SubvolInfo
+ {
+ SubvolInfo(const string& path) : path(path) {}
+ string path;
+ };
+
+
+ struct ResizeInfo
+ {
+ ResizeInfo() : df_freeK(0), resize_freeK(0), usedK(0), resize_ok(false) {}
+ unsigned long long df_freeK;
+ unsigned long long resize_freeK;
+ unsigned long long usedK;
+ bool resize_ok;
+ };
+
+
+ struct ContentInfo
+ {
+ ContentInfo() : windows(false), efi(false), homes(0) {}
+ bool windows;
+ bool efi;
+ unsigned homes;
+ };
+
+
/**
* Contains info about a generic container.
*/
@@ -218,12 +278,13 @@
{
ContainerInfo() {}
CType type;
- unsigned volcnt;
string device;
string name;
- UsedByType usedByType;
- string usedByName; // deprecated
- string usedByDevice;
+ string udevPath;
+ string udevId;
+ list<UsedByInfo> usedBy;
+ UsedByType usedByType; // deprecated
+ string usedByDevice; // deprecated
bool readonly;
};
@@ -234,18 +295,18 @@
{
DiskInfo() {}
unsigned long long sizeK;
- unsigned long long cylSizeB;
+ unsigned long long cylSize;
unsigned long cyl;
unsigned long heads;
unsigned long sectors;
unsigned int sectorSize;
string disklabel;
- string udevPath;
- string udevId;
- unsigned maxLogical;
unsigned maxPrimary;
+ bool extendedPossible;
+ unsigned maxLogical;
bool initDisk;
- bool iscsi;
+ Transport transport;
+ bool iscsi; // deprecated
};
/**
@@ -255,7 +316,7 @@
{
LvmVgInfo() {}
unsigned long long sizeK;
- unsigned long long peSize;
+ unsigned long long peSizeK;
unsigned long peCount;
unsigned long peFree;
string uuid;
@@ -303,10 +364,14 @@
string name;
string device;
string mount;
+ string crypt_device;
MountByType mount_by;
- UsedByType usedByType;
- string usedByName; // deprecated
- string usedByDevice;
+ string udevPath;
+ string udevId;
+ list<UsedByInfo> usedBy;
+ UsedByType usedByType; // deprecated
+ string usedByDevice; // deprecated
+ bool ignore_fstab;
string fstab_options;
string uuid;
string label;
@@ -317,12 +382,13 @@
EncryptType encryption;
string crypt_pwd;
FsType fs;
+ FsType detected_fs;
bool format;
bool create;
bool is_mounted;
bool resize;
bool ignore_fs;
- unsigned long long OrigSizeK;
+ unsigned long long origSizeK;
};
struct PartitionAddInfo
@@ -334,8 +400,6 @@
PartitionType partitionType;
unsigned id;
bool boot;
- string udevPath;
- string udevId;
};
/**
@@ -352,8 +416,6 @@
PartitionType partitionType;
unsigned id;
bool boot;
- string udevPath;
- string udevId;
};
/**
@@ -363,8 +425,8 @@
{
LvmLvInfo() {}
VolumeInfo v;
- unsigned stripe;
- unsigned stripe_size;
+ unsigned stripes;
+ unsigned stripeSizeK;
string uuid;
string status;
string allocation;
@@ -396,8 +458,9 @@
unsigned parity;
string uuid;
string sb_ver;
- unsigned long chunk;
+ unsigned long chunkSizeK;
string devices;
+ string spares;
};
/**
@@ -406,9 +469,7 @@
struct MdStateInfo
{
MdStateInfo() {}
- bool active;
- bool degraded;
- enum MdArrayState state;
+ MdArrayState state;
};
/**
@@ -419,28 +480,22 @@
{
MdPartCoInfo() {}
DiskInfo d;
- string devices;
- string spares; // Spare disks
- unsigned long minor;
-
- unsigned level; // RAID level
+ unsigned type; // RAID level
unsigned nr; // MD device number
unsigned parity; // Parity (not for all RAID level)
string uuid; // MD Device UUID
string sb_ver; // Metadata version
- unsigned long chunk; // Chunksize (strip size)
- string md_name; // MD Device name (link in /dev/md/)
+ unsigned long chunkSizeK; // Chunksize (strip size)
+ string devices;
+ string spares;
};
struct MdPartCoStateInfo
{
MdPartCoStateInfo() {}
- bool active;
- bool degraded;
- enum MdArrayState state; // Few states at one?
+ MdArrayState state;
};
-
/**
* Contains info about a partition on SW RAID device.
*/
@@ -474,6 +529,28 @@
};
/**
+ * Contains info about btrfs volume.
+ */
+ struct BtrfsInfo
+ {
+ BtrfsInfo() {}
+ VolumeInfo v;
+ string devices;
+ string devices_add;
+ string devices_rem;
+ string subvol;
+ };
+
+ /**
+ * Contains info about tmpfs volume.
+ */
+ struct TmpfsInfo
+ {
+ TmpfsInfo() {}
+ VolumeInfo v;
+ };
+
+ /**
* Contains info about a DM volume.
*/
struct DmInfo
@@ -517,16 +594,16 @@
};
/**
- * Contains info about a DM volume.
+ * Contains info about container and volume.
*/
struct ContVolInfo
{
- ContVolInfo() { numeric=false; nr=0; type=CUNKNOWN; }
- CType type;
+ ContVolInfo() : ctype(CUNKNOWN) {}
+ CType ctype;
string cname;
+ string cdevice;
string vname;
- bool numeric;
- unsigned nr;
+ string vdevice;
};
/**
@@ -550,8 +627,9 @@
*/
struct CommitInfo
{
+ CommitInfo() {}
bool destructive;
- deque<string> actions;
+ string text;
};
@@ -560,6 +638,8 @@
*/
enum ErrorCodes
{
+ STORAGE_NO_ERROR = 0,
+
DISK_PARTITION_OVERLAPS_EXISTING = -1000,
DISK_PARTITION_EXCEEDS_DISK = -1001,
DISK_CREATE_PARTITION_EXT_ONLY_ONCE = -1002,
@@ -619,7 +699,11 @@
STORAGE_RESIZE_INVALID_CONTAINER = -2029,
STORAGE_DMMULTIPATH_CO_NOT_FOUND = -2030,
STORAGE_ZERO_DEVICE_FAILED = -2031,
- STORAGE_MDPART_CO_NOT_FOUND = -2032,
+ STORAGE_INVALID_BACKUP_STATE_NAME = -2032,
+ STORAGE_MDPART_CO_NOT_FOUND = -2033,
+ STORAGE_DEVICE_NOT_FOUND = -2034,
+ STORAGE_BTRFS_CO_NOT_FOUND = -2035,
+ STORAGE_TMPFS_CO_NOT_FOUND = -2036,
VOLUME_COMMIT_UNKNOWN_STAGE = -3000,
VOLUME_FSTAB_EMPTY_MOUNT = -3001,
@@ -657,10 +741,11 @@
VOLUME_CRYPTSETUP_FAILED = -3034,
VOLUME_CRYPTUNSETUP_FAILED = -3035,
VOLUME_FORMAT_NOT_IMPLEMENTED = -3036,
- VOLUME_FORMAT_NFS_IMPOSSIBLE = -3037,
+ VOLUME_FORMAT_IMPOSSIBLE = -3037,
VOLUME_CRYPT_NFS_IMPOSSIBLE = -3038,
VOLUME_REMOUNT_FAILED = -3039,
VOLUME_TUNEREISERFS_FAILED = -3040,
+ VOLUME_UMOUNT_NOT_MOUNTED = -3041,
LVM_CREATE_PV_FAILED = -4000,
LVM_PV_ALREADY_CONTAINED = -4001,
@@ -695,6 +780,7 @@
LVM_LV_NOT_SNAPSHOT = -4030,
LVM_LV_HAS_SNAPSHOTS = -4031,
LVM_LV_IS_SNAPSHOT = -4032,
+ LVM_LIST_EMPTY = -4033,
FSTAB_ENTRY_NOT_FOUND = -5000,
FSTAB_CHANGE_PREFIX_IMPOSSIBLE = -5001,
@@ -723,6 +809,9 @@
MD_NO_CREATE_UNKNOWN = -6018,
MD_STATE_NOT_ON_DISK = -6019,
MD_PARTITION_NOT_FOUND = -6020,
+ MD_INVALID_PARITY = -6021,
+ MD_TOO_MANY_SPARES = -6022,
+ MD_GET_STATE_FAILED = -6023,
MDPART_CHANGE_READONLY = -6100,
MDPART_INTERNAL_ERR = -6101,
@@ -781,6 +870,31 @@
NFS_REMOVE_VOLUME_LIST_ERASE = -14004,
NFS_REMOVE_INVALID_VOLUME = -14005,
+ BTRFS_COMMIT_INVALID_VOLUME = -15001,
+ BTRFS_CANNOT_TMP_MOUNT = -15002,
+ BTRFS_CANNOT_TMP_UMOUNT = -15003,
+ BTRFS_DELETE_SUBVOL_FAIL = -15004,
+ BTRFS_CREATE_SUBVOL_FAIL = -15005,
+ BTRFS_VOLUME_NOT_FOUND = -15006,
+ BTRFS_SUBVOL_EXISTS = -15007,
+ BTRFS_SUBVOL_NON_EXISTS = -15008,
+ BTRFS_REMOVE_NOT_FOUND = -15009,
+ BTRFS_REMOVE_NO_BTRFS = -15010,
+ BTRFS_REMOVE_INVALID_VOLUME = -15011,
+ BTRFS_CHANGE_READONLY = -15012,
+ BTRFS_DEV_ALREADY_CONTAINED = -15013,
+ BTRFS_DEVICE_UNKNOWN = -15014,
+ BTRFS_DEVICE_USED = -15015,
+ BTRFS_HAS_NONE_DEV = -15016,
+ BTRFS_DEV_NOT_FOUND = -15017,
+ BTRFS_EXTEND_FAIL = -15018,
+ BTRFS_REDUCE_FAIL = -15019,
+ BTRFS_LIST_EMPTY = -15020,
+
+ TMPFS_REMOVE_INVALID_VOLUME = -16001,
+ TMPFS_REMOVE_NO_TMPFS = -16002,
+ TMPFS_REMOVE_NOT_FOUND = -16003,
+
CONTAINER_INTERNAL_ERROR = -99000,
CONTAINER_INVALID_VIRTUAL_CALL = -99001,
@@ -996,6 +1110,22 @@
virtual int getDmInfo( deque<DmInfo>& plist ) = 0;
/**
+ * Query infos for btrfs devices in system
+ *
+ * @param plist list of records that get filled with btrfs specific info
+ * @return zero if all is ok, a negative number to indicate an error
+ */
+ virtual int getBtrfsInfo( deque<BtrfsInfo>& plist ) = 0;
+
+ /**
+ * Query infos for tmpfs devices in system
+ *
+ * @param plist list of records that get filled with tmpfs specific info
+ * @return zero if all is ok, a negative number to indicate an error
+ */
+ virtual int getTmpfsInfo( deque<TmpfsInfo>& plist ) = 0;
+
+ /**
* Query infos for dmraid devices in system
*
* @param plist list of records that get filled with dmraid specific info
@@ -1032,30 +1162,11 @@
virtual list<string> getAllUsedFs() const = 0;
/**
- * Print all detected entities to a stream.
- * Exact output format may change between releases.
- * Function mainly meant for debugging purposes.
- *
- * @param str stream to print data to
- */
- virtual void printInfo( std::ostream& str ) = 0;
-
- /**
- * Print names entities to a stream.
- * Exact output format may change between releases.
- * Function mainly meant for debugging purposes.
- *
- * @param str stream to print data to
- * @param name name of container to print
- */
- virtual void printInfoCo( std::ostream& str, const string& name ) = 0;
-
- /**
* Create a new partition. Units given in disk cylinders.
*
* @param disk device name of disk, e.g. /dev/hda
* @param type type of partition to create, e.g. primary or extended
- * @param start cylinder number of partition start (cylinders are numbered starting with 0)
+ * @param startCyl cylinder number of partition start (cylinders are numbered starting with 0)
* @param sizeCyl size of partition in disk cylinders
* @param device is set to the device name of the new partition
* The name is returned instead of the number since creating the name from the
@@ -1063,7 +1174,7 @@
* @return zero if all is ok, a negative number to indicate an error
*/
virtual int createPartition( const string& disk, PartitionType type,
- unsigned long start,
+ unsigned long startCyl,
unsigned long sizeCyl,
string& device ) = 0;
@@ -1095,12 +1206,12 @@
* committed.
*
* @param device device name of partition, e.g. /dev/hda1
- * @param start cylinder number of partition start (cylinders are numbered starting with 0)
+ * @param startCyl cylinder number of partition start (cylinders are numbered starting with 0)
* @param sizeCyl size of partition in disk cylinders
* @return zero if all is ok, a negative number to indicate an error
*/
virtual int updatePartitionArea( const string& device,
- unsigned long start,
+ unsigned long startCyl,
unsigned long sizeCyl ) = 0;
/**
@@ -1131,30 +1242,30 @@
*
* @param disk device name of disk, e.g. /dev/hda
* @param type type of partition to create, e.g. primary or extended
- * @param start offset in kilobytes from start of disk
- * @param size size of partition in kilobytes
+ * @param startK offset in kilobytes from start of disk
+ * @param sizeK size of partition in kilobytes
* @param device is set to the device name of the new partition
* The name is returned instead of the number since creating the name from the
* number is not straight-forward.
* @return zero if all is ok, a negative number to indicate an error
*/
virtual int createPartitionKb( const string& disk, PartitionType type,
- unsigned long long start,
- unsigned long long size,
+ unsigned long long startK,
+ unsigned long long sizeK,
string& device ) = 0;
/**
* Create a new partition of any type anywhere on the disk. Units given in Kilobytes.
*
* @param disk device name of disk, e.g. /dev/hda
- * @param size size of partition in kilobytes
+ * @param sizeK size of partition in kilobytes
* @param device is set to the device name of the new partition
* The name is returned instead of the number since creating the name from the
* number is not straight-forward.
* @return zero if all is ok, a negative number to indicate an error
*/
virtual int createPartitionAny( const string& disk,
- unsigned long long size,
+ unsigned long long sizeK,
string& device ) = 0;
/**
@@ -1174,21 +1285,21 @@
* Compute number of kilobytes of a given number of disk cylinders
*
* @param disk device name of disk, e.g. /dev/hda
- * @param size number of disk cylinders
+ * @param sizeCyl number of disk cylinders
* @return number of kilobytes of given cylinders
*/
virtual unsigned long long cylinderToKb( const string& disk,
- unsigned long size ) = 0;
+ unsigned long sizeCyl) = 0;
/**
* Compute number of disk cylinders needed for given space
*
* @param disk device name of disk, e.g. /dev/hda
- * @param size number of kilobytes
+ * @param sizeK number of kilobytes
* @return number of disk cylinders needed
*/
virtual unsigned long kbToCylinder( const string& disk,
- unsigned long long size ) = 0;
+ unsigned long long sizeK) = 0;
/**
* Remove a partition
@@ -1216,6 +1327,25 @@
virtual int forgetChangePartitionId (const string& partition ) = 0;
/**
+ * Return the prefix that is inserted between the disk name and the
+ * partition number.
+ *
+ * @param disk name of disk, e.g. /dev/sda
+ * @return prefix for partitions, e.g. "", "p" or "_part"
+ */
+ virtual string getPartitionPrefix(const string& disk) = 0;
+
+ /**
+ * Construct the device name for a partiton from the disk name and
+ * partiton number.
+ *
+ * @param disk name of disk, e.g. /dev/sda
+ * @param partition_no number of partition, e.g. 1
+ * @return device name of partition, e.g. /dev/sda1
+ */
+ virtual string getPartitionName(const string& disk, int partition_no) = 0;
+
+ /**
* Query unused slots on a disk suitable for creating partitions.
*
* @param disk name of disk, e.g. /dev/hda1
@@ -1246,7 +1376,7 @@
*/
virtual int initializeDisk( const string& disk, bool value ) = 0;
- /**
+ /**
* Query the default disk label of the architecture of the
* machine (e.g. msdos for ix86, gpt for ia64, ...) for a disk
*
@@ -1254,7 +1384,7 @@
*
* @return default disk label of the disk
*/
- virtual string defaultDiskLabel(const string& device) = 0;
+ virtual string defaultDiskLabel(const string& device) = 0;
/**
* Sets or unsets the format flag for the given volume.
@@ -1407,9 +1537,12 @@
*
* @param device name of volume, e.g. /dev/hda1
* @param pwd crypt password for this volume
+ * @param erase if true remove password even after successful verification
* @return zero if password is ok, a negative number to indicate an error
*/
- virtual int verifyCryptPassword( const string& device, const string& pwd ) = 0;
+ virtual int verifyCryptPassword( const string& device,
+ const string& pwd, bool erase ) = 0;
+
/**
* Check if crypt password is required
*
@@ -1476,8 +1609,8 @@
/**
* Sets the value of description text.
- * This text will be returned together with the text returned by
- * getCommitInfo().
+ * This text will be returned together with the text returned by
+ * getCommitInfos().
*
* @param device name of volume, e.g. /dev/hda1
* @param txt description text for this partition
@@ -1488,6 +1621,9 @@
/**
* Adds the specified entry to /etc/fstab
*
+ * This function does not cache the changes but writes them
+ * immediately.
+ *
* @param device name of volume, e.g. /dev/hda1
* @param mount mount point, e.g. /home
* @param vfs virtual filesystem type, e.g. reiserfs or ext3
@@ -1505,19 +1641,19 @@
* Resizes a volume while keeping the data on the filesystem
*
* @param device name of volume, e.g. /dev/hda1
- * @param newSizeMb new size desired volume in Megabyte
+ * @param newSizeK new size desired volume in kilobytes
* @return zero if all is ok, a negative number to indicate an error
*/
- virtual int resizeVolume( const string& device, unsigned long long newSizeMb ) = 0;
+ virtual int resizeVolume(const string& device, unsigned long long newSizeK) = 0;
/**
* Resizes a volume while ignoring the data on the filesystem
*
* @param device name of volume, e.g. /dev/hda1
- * @param newSizeMb new size desired volume in Megabyte
+ * @param newSizeK new size desired volume in kilobytes
* @return zero if all is ok, a negative number to indicate an error
*/
- virtual int resizeVolumeNoFs( const string& device, unsigned long long newSizeMb ) = 0;
+ virtual int resizeVolumeNoFs(const string& device, unsigned long long newSizeK) = 0;
/**
* Forget about possible resize of an volume.
@@ -1551,6 +1687,16 @@
virtual bool getRecursiveRemoval() const = 0;
/**
+ * Recursively get all devices using device. Volumes of containers are
+ * also considered as using the devices.
+ *
+ * @param device name of device, e.g. /dev/sda
+ * @param devices name of devices using device, e.g. /dev/sda1 /dev/sda2
+ * @return zero if all is ok, a negative number to indicate an error
+ */
+ virtual int getRecursiveUsing(const string& device, list<string>& devices) = 0;
+
+ /**
* Set handling of newly created partitions. With this flag
* once can make the library overwrite start and end of newly
* created partitions with zeroes. This prevents that obsolete
@@ -1600,20 +1746,25 @@
virtual void setDefaultMountBy( MountByType val ) = 0;
/**
- * Set default value for mount by.
+ * Get default value for mount by.
*
* @return default value for mount by
*/
virtual MountByType getDefaultMountBy() const = 0;
/**
- * Set value for EFI boot.
+ * Set default filesystem.
*
- * Currently this value affects the default disk label.
+ * @param val new default filesystem.
+ */
+ virtual void setDefaultFs(FsType val) = 0;
+
+ /**
+ * Get default filesystem.
*
- * @param val new efi boot value
+ * @return default filesystem.
*/
- virtual void setEfiBoot(bool val) = 0;
+ virtual FsType getDefaultFs() const = 0;
/**
* Get value for EFI boot.
@@ -1626,7 +1777,7 @@
* Set value for root prefix.
*
* This value is appended to all mount points of volumes, when
- * changes are commited. Config files fstab, cryptotab, raidtab and
+ * changes are commited. Config files fstab, crypttab and
* mdadm.conf are also created relative to this prefix.
* This variable must be set before first call to commit.
*
@@ -1712,14 +1863,14 @@
*
* @param vg name of volume group
* @param name of logical volume
- * @param sizeM size of logical volume in megabytes
- * @param stripe stripe count of logical volume (use 1 unless you know
+ * @param sizeK size of logical volume in kilobytes
+ * @param stripes stripe count of logical volume (use 1 unless you know
* exactly what you are doing)
* @param device is set to the device name of the new LV
* @return zero if all is ok, a negative number to indicate an error
*/
virtual int createLvmLv( const string& vg, const string& name,
- unsigned long long sizeM, unsigned stripe,
+ unsigned long long sizeK, unsigned stripes,
string& device ) = 0;
/**
@@ -1757,11 +1908,11 @@
*
* @param vg name of volume group
* @param name of logical volume
- * @param stripeSize new stripe size of logical volume
+ * @param stripeSizeK new stripe size of logical volume
* @return zero if all is ok, a negative number to indicate an error
*/
virtual int changeLvStripeSize( const string& vg, const string& name,
- unsigned long long stripeSize ) = 0;
+ unsigned long long stripeSizeK) = 0;
/**
* Create a LVM logical volume snapshot
@@ -1806,29 +1957,31 @@
* @param device is set to the device name of the next created software raid device
* @return zero if all is ok, a negative number to indicate an error
*/
- virtual int nextFreeMd(int &nr, string &device) = 0;
+ virtual int nextFreeMd(unsigned& nr, string &device) = 0;
/**
* Create a Software raid device by name
*
* @param name name of software raid device to create (e.g. /dev/md0)
- * @param rtype raid personality of the new software raid
- * @param devs list with physical devices for the new software raid
+ * @param md_type raid personality of the new software raid
+ * @param devices list with physical devices for the new software raid
+ * @param spares list with spare physical devices for the new software raid
* @return zero if all is ok, a negative number to indicate an error
*/
- virtual int createMd( const string& name, MdType rtype,
- const deque<string>& devs ) = 0;
+ virtual int createMd(const string& name, MdType md_type, const list<string>& devices,
+ const list<string>& spares) = 0;
/**
* Create a Software raid device. Name determined by library.
*
- * @param rtype raid personality of the new software raid
- * @param devs list with physical devices for the new software raid
+ * @param md_type raid personality of the new software raid
+ * @param devices list with physical devices for the new software raid
+ * @param spares list with spare physical devices for the new software raid
* @param device device name of created software raid device
* @return zero if all is ok, a negative number to indicate an error
*/
- virtual int createMdAny( MdType rtype, const deque<string>& devs,
- string& device ) = 0;
+ virtual int createMdAny(MdType md_type, const list<string>& devices,
+ const list<string>& spares, string& device) = 0;
/**
* Remove a Software raid device.
@@ -1845,43 +1998,47 @@
* This can only be done before the raid is created on disk.
*
* @param name name of software raid device (e.g. /dev/md0)
- * @param dev partition to add to that raid
+ * @param devices list with physical devices to add to the raid
+ * @param spares list with spare physical devices to add to the raid
* @return zero if all is ok, a negative number to indicate an error
*/
- virtual int extendMd( const string& name, const string& dev ) = 0;
+ virtual int extendMd(const string& name, const list<string>& devices,
+ const list<string>& spares) = 0;
/**
* Remove a partition from a raid device.
* This can only be done before the raid is created on disk.
*
* @param name name of software raid device (e.g. /dev/md0)
- * @param dev partition to remove from that raid
+ * @param devices list of physical devices to remove from the raid
+ * @param spares list of spare physical devices to remove from the raid
* @return zero if all is ok, a negative number to indicate an error
*/
- virtual int shrinkMd( const string& name, const string& dev ) = 0;
+ virtual int shrinkMd(const string& name, const list<string>& devices,
+ const list<string>& spares) = 0;
/**
* Change raid type of a raid device.
* This can only be done before the raid is created on disk.
*
* @param name name of software raid device (e.g. /dev/md0)
- * @param rtype new raid personality of the software raid
+ * @param md_type new raid personality of the software raid
* @return zero if all is ok, a negative number to indicate an error
*/
- virtual int changeMdType( const string& name, MdType rtype ) = 0;
+ virtual int changeMdType(const string& name, MdType md_type) = 0;
/**
* Change chunk size of a raid device.
* This can only be done before the raid is created on disk.
*
* @param name name of software raid device (e.g. /dev/md0)
- * @param chunk new chunk size of the software raid
+ * @param chunkSizeK new chunk size of the software raid
* @return zero if all is ok, a negative number to indicate an error
*/
- virtual int changeMdChunk( const string& name, unsigned long chunk ) = 0;
+ virtual int changeMdChunk(const string& name, unsigned long chunkSizeK) = 0;
/**
- * Change parity of a raid device with raid type raid5.
+ * Change parity of a raid device with raid type raid5, raid6 or raid10.
* This can only be done before the raid is created on disk.
*
* @param name name of software raid device (e.g. /dev/md0)
@@ -1929,11 +2086,21 @@
*
* @param md_type raid type of the software raid
* @param devices list with physical devices for the software raid
+ * @param spares list with spare physical devices for the software raid
* @param sizeK will contain the computed size in kilobytes
* @return zero if all is ok, a negative number to indicate an error
*/
- virtual int computeMdSize(MdType md_type, list<string> devices,
- unsigned long long& sizeK) = 0;
+ virtual int computeMdSize(MdType md_type, const list<string>& devices,
+ const list<string>& spares, unsigned long long& sizeK) = 0;
+
+ /**
+ * Determine allowed parity types for raid type.
+ *
+ * @param md_type raid type of the software raid
+ * @param devnr number of physical devices for the software raid
+ * @return list of allowed parity typed for this raid
+ */
+ virtual list<int> getMdAllowedParity(MdType md_type, unsigned devnr) = 0;
/**
* Remove a Partitionable Software raid device.
@@ -1954,22 +2121,24 @@
* @param sizeK size of the nfs device
* @param opts mount options for nfs mount
* @param mp mount point of the nfs device
+ * @param nfs4 use NFS4 for device
* @return zero if all is ok, a negative number to indicate an error
*/
- virtual int addNfsDevice( const string& nfsDev, const string& opts,
- unsigned long long sizeK,
- const string& mp ) = 0;
+ virtual int addNfsDevice(const string& nfsDev, const string& opts,
+ unsigned long long sizeK, const string& mp,
+ bool nfs4) = 0;
/**
* Check accessibility and size of nfs device.
*
* @param nfsDev name of nfs device
* @param opts mount options for nfs mount
+ * @param nfs4 use NFS4 for device
* @param sizeK size of the nfs device
* @return zero if all is ok, a negative number to indicate an error
*/
- virtual int checkNfsDevice( const string& nfsDev, const string& opts,
- unsigned long long& sizeK ) = 0;
+ virtual int checkNfsDevice(const string& nfsDev, const string& opts,
+ bool nfs4, unsigned long long& sizeK) = 0;
/**
* Create a file based loop device. Encryption is automatically
@@ -2032,25 +2201,68 @@
virtual int removeDmraid( const string& name ) = 0;
/**
- * Gets a list of string describing the actions to be executed
- * after next call to commit().
+ * Create a BTRFS subvolume
*
- * Deprecated, use getCommitInfo().
- *
- * @param mark_destructive if true use <red> around </red>
- * destructive actions (like e.g. deletion, formatting, ...)
- * @return list of strings presentable to the user
+ * @param device of the main BTRFS volume
+ * @param name of subvolume
+ * @return zero if all is ok, a negative number to indicate an error
+ */
+ virtual int createSubvolume( const string& device, const string& name ) = 0;
+
+ /**
+ * Remove a BTRFS subvolume
+ *
+ * @param device of the main BTRFS volume
+ * @param name of subvolume
+ * @return zero if all is ok, a negative number to indicate an error
+ */
+ virtual int removeSubvolume( const string& device, const string& name ) = 0;
+
+ /**
+ * Extend a BTRFS volume with additional devices
+ *
+ * @param name name of BTRFS volume (this can contain a device name
+ * or be specified as "UUID=<uuid>")
+ * @param devs list with devices to add to that BTRFS volume
+ * @return zero if all is ok, a negative number to indicate an error
+ */
+ virtual int extendBtrfsVolume( const string& name,
+ const deque<string>& devs ) = 0;
+
+ /**
+ * Shrink a BTRFS volume by some devices
+ *
+ * @param name name of BTRFS volume (this can contain a device name
+ * or be specified as "UUID=<uuid>")
+ * @param devs list with devices to remove from that BTRFS volume
+ * @return zero if all is ok, a negative number to indicate an error
+ */
+ virtual int shrinkBtrfsVolume( const string& name,
+ const deque<string>& devs ) = 0;
+
+ /**
+ * Add new tmpfs filesystem
+ *
+ * @param mp mount point for the tmpfs
+ * @param opts mount options for tmpfs mount
+ * @return zero if all is ok, a negative number to indicate an error
+ */
+ virtual int addTmpfsMount( const string& mp, const string& opts ) = 0;
+
+ /**
+ * Remove tmpfs filesystem
+ *
+ * @param mp mount point for the tmpfs
+ * @return zero if all is ok, a negative number to indicate an error
*/
- virtual deque<string> getCommitActions(bool mark_destructive) const = 0;
+ virtual int removeTmpfsMount( const string& mp ) = 0;
/**
* Gets info about actions to be executed after next call to commit().
*
- * @param mark_destructive if true use <red> around </red>
- * destructive actions (like e.g. deletion, formatting, ...)
- * @param info record that gets filled with data
+ * @param infos list of records that gets filled with infos
*/
- virtual void getCommitInfo(bool mark_destructive, CommitInfo& info) const = 0;
+ virtual void getCommitInfos(list<CommitInfo>& infos) const = 0;
/**
* Gets action performed last during previous call to commit()
@@ -2135,6 +2347,21 @@
/**
+ * Sets the callback function called for errors during commit.
+ *
+ * @param pfnc pointer to function
+ */
+ virtual void setCallbackCommitErrorPopup(CallbackCommitErrorPopup pfnc) = 0;
+
+ /**
+ * Query the callback function called for errors during commit.
+ *
+ * @return pointer to function currently called for progress bar events
+ */
+ virtual CallbackCommitErrorPopup getCallbackCommitErrorPopup() const = 0;
+
+
+ /**
* Sets the callback function called to query a password by the user.
*
* @param pfnc pointer to function.
@@ -2170,6 +2397,11 @@
virtual int commit() = 0;
/**
+ * Get a textual message for an error code. Can be empty.
+ */
+ virtual string getErrorString(int error) const = 0;
+
+ /**
* Create backup of current state of all containers
*
* @param name name under which the backup should be created
@@ -2189,9 +2421,9 @@
* Checks if a backup with a certain name already exists
*
* @param name name of the backup to check
- * @return boolean if the backup exists
+ * @return true if the backup exists
*/
- virtual bool checkBackupState( const string& name ) = 0;
+ virtual bool checkBackupState(const string& name) const = 0;
/**
* Compare two backup states
@@ -2201,9 +2433,8 @@
* @param verbose_log flag if differences should be logged in detail
* @return true if states are equal
*/
- virtual bool equalBackupStates( const string& lhs,
- const string& rhs,
- bool verbose_log ) const = 0;
+ virtual bool equalBackupStates(const string& lhs, const string& rhs,
+ bool verbose_log) const = 0;
/**
* Remove existing backup state
@@ -2218,14 +2449,15 @@
* Determine if the given device is known and mounted somewhere
*
* @param device device name to check (checks also all alias names)
- * @param mp set to current mount point if mounted
+ * @param mps set to current mount points if mounted
* @return bool that is true if device is mounted
*/
- virtual bool checkDeviceMounted( const string& device, string& mp ) = 0;
+ virtual bool checkDeviceMounted(const string& device, list<string>& mps) = 0;
/**
* Umount the given device and do what is necessary to remove
* underlying volume (e.g. do losetup -d if loop is set up)
+ *
* The function umounts at once, /etc/fstab is unaffected
*
* @param device device name to umount
@@ -2236,6 +2468,7 @@
/**
* Mount the given device and do what is necessary to access
* volume (e.g. do losetup if loop is set up)
+ *
* The function mounts at once, /etc/fstab is unaffected
*
* @param device device name to mount
@@ -2245,8 +2478,21 @@
virtual bool mountDevice( const string& device, const string& mp ) = 0;
/**
+ * Mount the given device and do what is necessary to access
+ * volume (e.g. do losetup if loop is set up)
+ *
+ * The function mounts at once, /etc/fstab is unaffected
+ *
+ * @param device device name
+ * @param on if true activate access to encrypted data, otherwise deactivate it
+ * @return zero if all is ok, a negative number to indicate an error
+ */
+ virtual int activateEncryption( const string& device, bool on ) = 0;
+
+ /**
* Mount the given device with given options and do what is necessary
* to access volume (e.g. do losetup if loop is set up)
+ *
* The function mounts at once, /etc/fstab is unaffected
*
* @param device device name to mount
@@ -2260,6 +2506,7 @@
/**
* Mount the given device readonly and do what is necessary to access
* volume (e.g. do losetup if loop is set up)
+ *
* The function mounts at once, /etc/fstab is unaffected
*
* @param device device name to mount
@@ -2289,18 +2536,15 @@
* Detect potentially available free space on a partition
*
* @param device device to check
- * @param resize_free free space in kilobytes available for resize
- * @param df_free free space in kilobytes available in filesystem
- * @param used used space in kilobytes for filesystem
- * @param win flag if partition contains a windows installation
+ * @param get_resize flag to indicate that resize_info should be queried
+ * @param resize_info struct that gets filled with resize info
+ * @param get_content flag to indicate that content_info should be queried
+ * @param content_info struct that gets filled with content info
* @param use_cache function should return cached data if available
* @return bool if values could be successfully determined
*/
- virtual bool getFreeInfo( const string& device,
- unsigned long long& resize_free,
- unsigned long long& df_free,
- unsigned long long& used,
- bool& win, bool& efi, bool use_cache ) = 0;
+ virtual bool getFreeInfo(const string& device, bool get_resize, ResizeInfo& resize_info,
+ bool get_content, ContentInfo& content_info, bool use_cache) = 0;
/**
* Read fstab and cryptotab, if existent, from a specified directory and
@@ -2314,7 +2558,8 @@
/**
* Activate or deactivate higher level devices as MD, LVM, DM
*
- * Multipath is not activate by this function.
+ * Multipath is not activate by this function. Only use in instsys
+ * mode.
*
* @param val flag if devices should be activated or deactivated
* @return bool if values could be successfully determined
@@ -2324,6 +2569,8 @@
/**
* Activate or deactivate multipath
*
+ * Only use in instsys mode.
+ *
* @param val flag if multipath should be activated or deactivated
* @return bool if values could be successfully determined
*/
@@ -2340,11 +2587,26 @@
virtual void rescanEverything() = 0;
/**
+ * Rescan after unlocked encrypted volume.
+ * Rescan for objects that might be newly found after at least one
+ * encrypted volume has been unlocked. Currently the only supported
+ * containers on an decrypted volume is a LVM Volume Group.
+ *
+ * @return true if at least on encrypted container has been found
+ */
+ virtual bool rescanCryptedObjects() = 0;
+
+ /**
* Dump list of all objects to log file.
*/
virtual void dumpObjectList() = 0;
/**
+ * Dump list of commit actions to log file.
+ */
+ virtual void dumpCommitInfos() const = 0;
+
+ /**
* Split volume device name up into container name and a volume
* name. For Containers where this is appropriate (e.g. disks,
* MD, loop) also a volume number is provided.
@@ -2353,34 +2615,8 @@
* @param info record that get filled with split data
* @return zero if all is ok, negative number to indicate an error
*/
- virtual int getContVolInfo( const string& dev, ContVolInfo& info) = 0;
+ virtual int getContVolInfo(const string& dev, ContVolInfo& info) = 0;
- /**
- * Return a pretty description of a size with required precision
- * and using B, kB, MB, GB, TB or PB as unit as appropriate.
- *
- * @param size size in bytes
- * @param classic use classic locale
- * @param precision number of fraction digits in output
- * @param omit_zeroes if true omit trailing zeroes for exact values
- * @return formatted string
- */
- virtual string byteToHumanString(unsigned long long size, bool classic, int precision,
- bool omit_zeroes) const = 0;
-
- /**
- * Converts a size description using B, kB, MB, GB, TB or PB into an integer.
- *
- * @param str size string
- * @param classic use classic locale
- * @param size size in bytes
- * @return true on successful conversion
- *
- * The conversion is always case-insensitive. With classic set to
- * false the conversion is also sloppy concerning omission of 'B'.
- */
- virtual bool humanStringToByte(const string& str, bool classic, unsigned long long&
- size) const = 0;
};
@@ -2396,7 +2632,7 @@
struct Environment
{
Environment(bool readonly) : readonly(readonly), testmode(false), autodetect(true),
- instsys(false), logdir("/var/log/YaST2"), testdir("") {}
+ instsys(false), logdir("/var/log/YaST2"), testdir("tmp") {}
bool readonly;
bool testmode;
Modified: branches/SuSE-Code-11-SP2-Branch/storage/libstorage/src/StorageTmpl.h
URL: http://svn.opensuse.org/viewcvs/yast/branches/SuSE-Code-11-SP2-Branch/stora…
==============================================================================
--- branches/SuSE-Code-11-SP2-Branch/storage/libstorage/src/StorageTmpl.h (original)
+++ branches/SuSE-Code-11-SP2-Branch/storage/libstorage/src/StorageTmpl.h Tue May 17 13:39:44 2011
@@ -30,11 +30,12 @@
#include <list>
#include <map>
#include <deque>
+#include <iostream>
-#include "y2storage/IterPair.h"
-#include "y2storage/FilterIterator.h"
-#include "y2storage/DerefIterator.h"
-#include "y2storage/AppUtil.h"
+#include "storage/IterPair.h"
+#include "storage/FilterIterator.h"
+#include "storage/DerefIterator.h"
+#include "storage/AppUtil.h"
namespace storage
{
@@ -62,7 +63,9 @@
ContainerIter( const IterPair<Iter>& pair, const Pred& p,
bool atend=false ) :
_bclass(pair, p, atend ) {}
- ContainerIter( const ContainerIter& i) { *this=i;}
+ template< class It >
+ ContainerIter( const It& i) : _bclass( i.begin(), i.end(), i.pred() )
+ { this->m_cur=i.cur(); }
};
template< class Pred, class Iter, class Value >
@@ -72,7 +75,9 @@
public:
ContainerDerIter() : _bclass() {}
ContainerDerIter( const _bclass& i ) : _bclass(i) {}
- ContainerDerIter( const ContainerDerIter& i) { *this=i;}
+ template< class It >
+ ContainerDerIter( const It& i) : _bclass( i )
+ { this->m_cur=i.cur(); }
};
template< class Iter, class CastResult >
@@ -85,7 +90,8 @@
CastIterator() : Iter() {}
CastIterator( const Iter& i ) : Iter( i ) {}
- CastIterator( const CastIterator& i ) { *this=i; }
+ template< class It >
+ CastIterator( const It& i ) : Iter( i ) {}
CastResult operator*() const
{
return( static_cast<CastResult>(Iter::operator*()) );
@@ -119,45 +125,29 @@
};
template < class Checker, class ContIter, class Iter, class Value >
-class CheckerIterator : public Checker, public ContIter
+class CheckerIterator : public ContIter
{
public:
CheckerIterator() {};
CheckerIterator( const Iter& b, const Iter& e,
bool (* CheckFnc)( const Value& )=NULL,
bool atend=false ) :
- Checker( CheckFnc ),
- ContIter( b, e, *this, atend ) {}
+ ContIter( b, e, Checker( CheckFnc ), atend ) {}
CheckerIterator( const IterPair<Iter>& p,
bool (* CheckFnc)( const Value& )=NULL,
bool atend=false ) :
- Checker( CheckFnc ),
- ContIter( p, *this, atend ) {}
- CheckerIterator( const CheckerIterator& i ) { *this=i; }
+ ContIter( p, Checker( CheckFnc ), atend ) {}
+ template<class It>
+ CheckerIterator( const It& i ) :
+ ContIter( i.begin(), i.end(), Checker(i.pred()), false )
+ { this->m_cur=i.cur(); }
};
-template < class C >
-void pointerIntoSortedList( std::list<C*>& l, C* e )
- {
- typename std::list<C*>::iterator i = l.begin();
- while( i!=l.end() && **i < *e )
- i++;
- l.insert( i, e );
- }
-
-template<typename Map, typename Key, typename Value>
-typename Map::iterator mapInsertOrReplace(Map& m, const Key& k, const Value& v)
- {
- typename Map::iterator pos = m.lower_bound(k);
- if (pos != m.end() && !typename Map::key_compare()(k, pos->first))
- pos->second = v;
- else
- pos = m.insert(pos, typename Map::value_type(k, v));
- return pos;
- }
template<class Num> string decString(Num number)
{
+ static_assert(std::is_integral<Num>::value, "not integral");
+
std::ostringstream num_str;
classic(num_str);
num_str << number;
@@ -166,6 +156,8 @@
template<class Num> string hexString(Num number)
{
+ static_assert(std::is_integral<Num>::value, "not integral");
+
std::ostringstream num_str;
classic(num_str);
num_str << std::hex << number;
@@ -224,36 +216,192 @@
return( s );
}
+
+ template <typename Type>
+ void logDiff(std::ostream& log, const char* text, const Type& lhs, const Type& rhs)
+ {
+ static_assert(!std::is_enum<Type>::value, "is enum");
+
+ if (lhs != rhs)
+ log << " " << text << ":" << lhs << "-->" << rhs;
+ }
+
+ template <typename Type>
+ void logDiffHex(std::ostream& log, const char* text, const Type& lhs, const Type& rhs)
+ {
+ static_assert(std::is_integral<Type>::value, "not integral");
+
+ if (lhs != rhs)
+ log << " " << text << ":" << std::hex << lhs << "-->" << rhs << std::dec;
+ }
+
+ template <typename Type>
+ void logDiffEnum(std::ostream& log, const char* text, const Type& lhs, const Type& rhs)
+ {
+ static_assert(std::is_enum<Type>::value, "not enum");
+
+ if (lhs != rhs)
+ log << " " << text << ":" << toString(lhs) << "-->" << toString(rhs);
+ }
+
+ inline
+ void logDiff(std::ostream& log, const char* text, bool lhs, bool rhs)
+ {
+ if (lhs != rhs)
+ {
+ if (rhs)
+ log << " -->" << text;
+ else
+ log << " " << text << "-->";
+ }
+ }
+
+
template<class Type>
bool
read_sysfs_property(const string& path, Type& value, bool log_error = true)
{
- std::ifstream file(path.c_str());
- classic(file);
- file >> value;
- file.close();
-
- if (file.fail())
- {
- y2err("reading " << path << " failed");
- if (log_error)
+ std::ifstream file(path.c_str());
+ classic(file);
+ file >> value;
+ file.close();
+
+ if (file.fail())
+ {
+ if (log_error)
y2err("reading " << path << " failed");
- return false;
- }
+ return false;
+ }
- return true;
+ return true;
}
-template< class Val >
-struct cont_less : public std::binary_function<Val*,Val*,bool>
+ template<class Type>
+ struct deref_less : public std::binary_function<const Type*, const Type*, bool>
{
- bool operator()(const Val* __x, const Val* __y) const { return *__x < *__y; }
+ bool operator()(const Type* x, const Type* y) const { return *x < *y; }
+ };
+
+
+ template<class Type>
+ struct deref_equal_to : public std::binary_function<const Type*, const Type*, bool>
+ {
+ bool operator()(const Type* x, const Type* y) const { return *x == *y; }
};
+
+ template <class Type>
+ void pointerIntoSortedList(list<Type*>& l, Type* e)
+ {
+ l.insert(lower_bound(l.begin(), l.end(), e, deref_less<Type>()), e);
+ }
+
+
+ template <class Type>
+ void clearPointerList(list<Type*>& l)
+ {
+ for (typename list<Type*>::iterator i = l.begin(); i != l.end(); ++i)
+ delete *i;
+ l.clear();
+ }
+
+
+ template <typename ListType, typename Type>
+ bool contains(const ListType& l, const Type& value)
+ {
+ return find(l.begin(), l.end(), value) != l.end();
+ }
+
+
+ template <typename ListType, typename Predicate>
+ bool contains_if(const ListType& l, Predicate pred)
+ {
+ return find_if(l.begin(), l.end(), pred) != l.end();
+ }
+
+
+ template<typename Map, typename Key, typename Value>
+ typename Map::iterator mapInsertOrReplace(Map& m, const Key& k, const Value& v)
+ {
+ typename Map::iterator pos = m.lower_bound(k);
+ if (pos != m.end() && !typename Map::key_compare()(k, pos->first))
+ pos->second = v;
+ else
+ pos = m.insert(pos, typename Map::value_type(k, v));
+ return pos;
+ }
+
+ template<typename List, typename Value>
+ typename List::const_iterator addIfNotThere(List& l, const Value& v)
+ {
+ typename List::const_iterator pos = find( l.begin(), l.end(), v );
+ if (pos == l.end() )
+ pos = l.insert(l.end(), v);
+ return pos;
+ }
+
+
+ template <class InputIterator1, class InputIterator2>
+ bool equalContent(InputIterator1 first1, InputIterator1 last1,
+ InputIterator2 first2, InputIterator2 last2)
+ {
+ while (first1 != last1 && first2 != last2)
+ {
+ if (!first1->equalContent(*first2))
+ return false;
+ ++first1;
+ ++first2;
+ }
+ return first1 == last1 && first2 == last2;
+ }
+
+
+ template <class InputIterator1, class InputIterator2>
+ void logVolumesDifference(std::ostream& log, InputIterator1 first1, InputIterator1 last1,
+ InputIterator2 first2, InputIterator2 last2)
+ {
+ for (InputIterator1 i = first1; i != last1; ++i)
+ {
+ InputIterator2 j = first2;
+ while (j != last2 && (i->device() != j->device() || i->created() != j->created()))
+ ++j;
+ if (j != last2)
+ {
+ if (!i->equalContent(*j))
+ {
+ i->logDifference(log, *j);
+ log << std::endl;
+ }
+ }
+ else
+ {
+ log << " -->" << *i << std::endl;
+ }
+ }
+
+ for (InputIterator2 i = first2; i != last2; ++i)
+ {
+ InputIterator1 j = first1;
+ while (j != last1 && (i->device() != j->device() || i->created() != j->created()))
+ ++j;
+ if (j == last1)
+ {
+ log << " <--" << *i << std::endl;
+ }
+ }
+ }
+
+
template <class T, unsigned int sz>
inline unsigned int lengthof (T (&)[sz]) { return sz; }
+template <class Type>
+void printtype(Type type)
+ {
+ std::cout << __PRETTY_FUNCTION__ << std::endl;
+ }
+
}
#endif
Modified: branches/SuSE-Code-11-SP2-Branch/storage/libstorage/src/StorageTypes.cc
URL: http://svn.opensuse.org/viewcvs/yast/branches/SuSE-Code-11-SP2-Branch/stora…
==============================================================================
--- branches/SuSE-Code-11-SP2-Branch/storage/libstorage/src/StorageTypes.cc (original)
+++ branches/SuSE-Code-11-SP2-Branch/storage/libstorage/src/StorageTypes.cc Tue May 17 13:39:44 2011
@@ -1,5 +1,5 @@
/*
- * Copyright (c) [2004-2009] Novell, Inc.
+ * Copyright (c) [2004-2010] Novell, Inc.
*
* All Rights Reserved.
*
@@ -19,8 +19,11 @@
* find current contact information at www.novell.com.
*/
-#include "y2storage/StorageTypes.h"
-#include "y2storage/Volume.h"
+
+#include "storage/Storage.h"
+#include "storage/StorageTypes.h"
+#include "storage/Volume.h"
+
namespace storage
{
@@ -73,69 +76,96 @@
}
- const string usedBy::device() const
+ std::ostream& operator<<(std::ostream& s, const commitAction& a)
{
- switch (ub_type)
- {
- case UB_NONE:
- return "";
+ s << "stage:" << a.stage
+ << " type:" << toString(a.type)
+ << " cont:" << a.container
+ << " dest:" << a.destructive;
+ if (a.co())
+ s << " name:" << a.co()->name();
+ if (a.vol())
+ s << " name:" << a.vol()->name();
+ if (!a.description.native.empty())
+ s << " desc:" << a.description.native;
+ return s;
+ };
+
+ std::ostream& operator<<(std::ostream& s, const UsedBy& usedby)
+ {
+ switch (usedby.type())
+ {
case UB_LVM:
+ s << "lvm[" << usedby.device() << "]";
+ break;
case UB_MD:
+ s << "md[" << usedby.device() << "]";
+ break;
case UB_MDPART:
- return "/dev/" + ub_name;
-
+ s << "mdpart[" << usedby.device() << "]";
+ break;
case UB_DM:
+ s << "dm[" << usedby.device() << "]";
+ break;
case UB_DMRAID:
+ s << "dmraid[" << usedby.device() << "]";
+ break;
case UB_DMMULTIPATH:
- return "/dev/mapper/" + ub_name;
+ s << "dmmultipath[" << usedby.device() << "]";
+ break;
+ case UB_BTRFS:
+ s << "btrfs[" << usedby.device() << "]";
+ break;
+ case UB_NONE:
+ break;
}
- }
+ return s;
+ }
- usedBy::operator string() const
+ void
+ setChildValue(xmlNode* node, const char* name, const UsedBy& value)
{
- string st;
- if (type() != storage::UB_NONE)
+ xmlNode* tmp = xmlNewChild(node, name);
+
+ switch (value.ub_type)
{
- switch (type())
- {
- case storage::UB_LVM:
- st = "lvm";
- break;
- case storage::UB_MD:
- st = "md";
- break;
- case storage::UB_MDPART:
- st = "mdpart";
- break;
- case storage::UB_DM:
- st = "dm";
- break;
- case storage::UB_DMRAID:
- st = "dmraid";
- break;
- case UB_DMMULTIPATH:
- st = "dmmultipath";
- break;
- default:
- st = "UNKNOWN";
- break;
- }
- st += "[" + name() + "]";
+ case UB_LVM: setChildValue(tmp, "type", "lvm"); break;
+ case UB_MD: setChildValue(tmp, "type", "md"); break;
+ case UB_MDPART: setChildValue(tmp, "type", "mdpart"); break;
+ case UB_DM: setChildValue(tmp, "type", "dm"); break;
+ case UB_DMRAID: setChildValue(tmp, "type", "dmraid"); break;
+ case UB_DMMULTIPATH: setChildValue(tmp, "type", "dmmultipath"); break;
+ case UB_BTRFS: setChildValue(tmp, "type", "btrfs"); break;
+ case UB_NONE: break;
}
- return st;
- }
+ setChildValue(tmp, "device", value.ub_device);
+ }
- std::ostream& operator<<(std::ostream& s, const usedBy& d)
+ std::ostream& operator<<(std::ostream& s, const Subvolume& sv)
{
- if (d.type() != storage::UB_NONE)
- {
- s << " UsedBy:" << string(d);
- }
+ s << sv.path();
return s;
}
+ void
+ setChildValue(xmlNode* node, const char* name, const Subvolume& v)
+ {
+ xmlNode* tmp = xmlNewChild(node, name);
+ setChildValue(tmp, "path", v.path());
+ }
+
+
+std::ostream& operator<<(std::ostream& s, const PartitionSlotInfo& a)
+ {
+ s << "start:" << a.cylStart
+ << " len:" << a.cylSize
+ << " primary:" << a.primarySlot << " poss:" << a.primaryPossible
+ << " extended:" << a.extendedSlot << " poss:" << a.extendedPossible
+ << " logical:" << a.logicalSlot << " poss:" << a.logicalPossible;
+ return s;
+ };
}
Modified: branches/SuSE-Code-11-SP2-Branch/storage/libstorage/src/StorageTypes.h
URL: http://svn.opensuse.org/viewcvs/yast/branches/SuSE-Code-11-SP2-Branch/stora…
==============================================================================
--- branches/SuSE-Code-11-SP2-Branch/storage/libstorage/src/StorageTypes.h (original)
+++ branches/SuSE-Code-11-SP2-Branch/storage/libstorage/src/StorageTypes.h Tue May 17 13:39:44 2011
@@ -1,5 +1,5 @@
/*
- * Copyright (c) [2004-2009] Novell, Inc.
+ * Copyright (c) [2004-2010] Novell, Inc.
*
* All Rights Reserved.
*
@@ -23,23 +23,28 @@
#ifndef STORAGE_TYPES_H
#define STORAGE_TYPES_H
-#include <vector>
+
#include <string>
-#include <iostream>
+#include <vector>
+#include <ostream>
#include <boost/algorithm/string.hpp>
-#include "y2storage/Regex.h"
-#include "y2storage/AppUtil.h"
-#include "y2storage/StorageInterface.h"
+#include "storage/Regex.h"
+#include "storage/AppUtil.h"
+#include "storage/StorageInterface.h"
+#include "storage/XmlFile.h"
+#include "storage/Enum.h"
+
namespace storage
{
using std::string;
using std::vector;
+
inline bool operator<(CType a, CType b)
{
- static const int order[COTYPE_LAST_ENTRY] = {
+ static const int order[] = {
0, // CUNKNOWN
1, // DISK
5, // MD
@@ -49,11 +54,13 @@
2, // DMRAID
9, // NFSC
3, // DMMULTIPATH
- 4 // MDPART
+ 4, // MDPART
+ 10, // BTRFSC
};
bool ret = order[a] < order[b];
- y2mil("a:" << a << " o(a):" << order[a] << " b:" << b << " o(b):" << order[b] << " ret:" << ret);
+ y2mil("a:" << toString(a) << " o(a):" << order[a] << " b:" << toString(b) << " o(b):" <<
+ order[b] << " ret:" << ret);
return ret;
}
@@ -84,136 +91,179 @@
unsigned order;
};
-typedef enum { DECREASE, INCREASE, FORMAT, MOUNT } CommitStage;
+std::ostream& operator<<(std::ostream& s, const PartitionSlotInfo& a);
+
+ enum CommitStage { DECREASE, INCREASE, FORMAT, MOUNT, SUBVOL };
-class Volume;
-class Container;
-struct commitAction
+ class Volume;
+ class Container;
+
+ struct commitAction
{
- commitAction( CommitStage s, CType t, const string& d, const Volume* v,
- bool destr=false )
- { stage=s; type=t; descr=d; destructive=destr; container=false;
- u.vol=v; }
- commitAction( CommitStage s, CType t, const string& d, const Container* co,
- bool destr=false )
- { stage=s; type=t; descr=d; destructive=destr; container=true;
- u.co=co; }
- commitAction( CommitStage s, CType t, const Volume* v )
- { stage=s; type=t; destructive=false; container=false; u.vol=v; }
- commitAction( CommitStage s, CType t, const Container* c )
- { stage=s; type=t; destructive=false; container=true; u.co=c; }
- CommitStage stage;
- CType type;
- string descr;
- bool destructive;
- bool container;
- union
+ commitAction(CommitStage s, CType t, const Text& d, const Volume* v,
+ bool destr = false)
+ : stage(s), type(t), description(d), destructive(destr), container(false), u(v)
{
- const Volume* vol;
- const Container* co;
- } u;
- const Container* co() const { return( container?u.co:NULL ); }
- const Volume* vol() const { return( container?NULL:u.vol ); }
- bool operator==( const commitAction& rhs ) const
- { return( stage==rhs.stage && type==rhs.type ); }
- bool operator<( const commitAction& rhs ) const;
- bool operator<=( const commitAction& rhs ) const
- { return( *this < rhs || *this == rhs ); }
- bool operator>=( const commitAction& rhs ) const
- { return( ! (*this < rhs) ); }
- bool operator>( const commitAction& rhs ) const
- { return( !(*this < rhs && *this == rhs) ); }
- };
-
+ }
-class usedBy
-{
- // TODO: save device instead of name?
+ commitAction(CommitStage s, CType t, const Text& d, const Container* c,
+ bool destr = false)
+ : stage(s), type(t), description(d), destructive(destr), container(true), u(c)
+ {
+ }
-public:
- usedBy() : ub_type(storage::UB_NONE) {}
- usedBy(storage::UsedByType type, const string& name) : ub_type(type), ub_name(name) {}
+ commitAction(CommitStage s, CType t, const Volume* v)
+ : stage(s), type(t), description(), destructive(false), container(false), u(v)
+ {
+ }
- void clear() { ub_type = storage::UB_NONE; ub_name.erase(); }
- void set(storage::UsedByType type, const string& name)
- { ub_type = type; (ub_type==storage::UB_NONE)?ub_name.erase():ub_name = name; }
+ commitAction(CommitStage s, CType t, const Container* c)
+ : stage(s), type(t), description(), destructive(false), container(true), u(c)
+ {
+ }
- bool operator==(const usedBy& rhs) const
- { return ub_type == rhs.ub_type && ub_name == rhs.ub_name; }
- bool operator!=(const usedBy& rhs) const
- { return !(*this == rhs); }
+ const CommitStage stage;
+ const CType type;
+ const Text description;
+ const bool destructive;
+ const bool container;
- operator string() const;
+ const union U
+ {
+ U(const Volume* v) : vol(v) {}
+ U(const Container* c) : co(c) {}
- storage::UsedByType type() const { return ub_type; }
- const string& name() const { return ub_name; }
- const string device() const;
+ const Volume* vol;
+ const Container* co;
+ } u;
- friend std::ostream& operator<<(std::ostream&, const usedBy&);
+ const Container* co() const { return container ? u.co : NULL; }
+ const Volume* vol() const { return container ? NULL : u.vol; }
-private:
- storage::UsedByType ub_type;
- string ub_name;
-};
+ bool operator==(const commitAction& rhs) const
+ { return stage == rhs.stage && type == rhs.type; }
+ bool operator<(const commitAction& rhs) const;
+ bool operator<=(const commitAction& rhs) const
+ { return *this < rhs || *this == rhs; }
+ bool operator>=(const commitAction& rhs) const
+ { return !(*this < rhs); }
+ bool operator>(const commitAction& rhs) const
+ { return !(*this < rhs && *this == rhs); }
- struct string_starts_with
- {
- string_starts_with(const string& t) : val(t) {}
- bool operator()(const string& s) const { return boost::starts_with(s, val); }
- const string& val;
+ friend std::ostream& operator<<(std::ostream& s, const commitAction& a);
};
- struct string_contains
+
+ struct stage_is
{
- string_contains(const string& t) : val(t) {}
- bool operator()(const string& s) const { return boost::contains(s, val); }
- const string& val;
+ stage_is(CommitStage t) : val(t) {}
+ bool operator()(const commitAction& t) const { return t.stage == val; }
+ const CommitStage val;
};
-template <class Pred>
-vector<string>::iterator
-find_if(vector<string>& lines, Pred pred)
+ class UsedBy
{
- return std::find_if(lines.begin(), lines.end(), pred);
- }
-template <class Pred>
-vector<string>::const_iterator
-find_if(const vector<string>& lines, Pred pred)
- {
- return std::find_if(lines.begin(), lines.end(), pred);
- }
+ public:
+
+ UsedBy(UsedByType type, const string& device) : ub_type(type), ub_device(device) {}
+
+ bool operator==(const UsedBy& rhs) const
+ { return ub_type == rhs.ub_type && ub_device == rhs.ub_device; }
+ bool operator!=(const UsedBy& rhs) const
+ { return !(*this == rhs); }
-struct match_string
+ UsedByType type() const { return ub_type; }
+ string device() const { return ub_device; }
+
+ friend std::ostream& operator<<(std::ostream&, const UsedBy&);
+
+ friend void setChildValue(xmlNode* node, const char* name, const UsedBy& value);
+
+ operator UsedByInfo() const { return UsedByInfo(ub_type, ub_device); }
+
+ private:
+
+ UsedByType ub_type;
+ string ub_device;
+
+ };
+
+ class Subvolume
{
- match_string(const string& t) : val(t) {}
- bool operator()(const string&s) { return s == val; }
- const string& val;
+
+ public:
+
+ Subvolume(const string& path) : p(path), del(false), create(false) {}
+ Subvolume(const xmlNode* node) : p()
+ {
+ getChildValue(node, "path", p);
+ }
+
+ bool operator==(const Subvolume& rhs) const
+ { return p == rhs.p && del == rhs.del; }
+ bool operator!=(const Subvolume& rhs) const
+ { return !(*this == rhs); }
+
+ string path() const { return p; }
+ bool deleted() const { return del; }
+ void setDeleted( bool val=true ) { del=val; }
+ bool created() const { return create; }
+ void setCreated( bool val=true ) { create=val; }
+
+ friend std::ostream& operator<<(std::ostream&, const Subvolume&);
+
+ friend void setChildValue(xmlNode* node, const char* name, const Subvolume& value);
+
+ operator SubvolInfo() const { return SubvolInfo(p); }
+
+ private:
+ string p;
+ bool del;
+ bool create;
+
};
-struct match_regex
+
+ struct regex_matches
{
- match_regex(const Regex& t) : r(t) {}
- bool operator()(const string&s) { return r.match(s); }
- const Regex& r;
+ regex_matches(const Regex& t) : val(t) {}
+ bool operator()(const string& s) const { return val.match(s); }
+ const Regex& val;
};
-struct find_begin
+ struct string_starts_with
{
- find_begin(const string& t) : val(t) {}
- bool operator()(const string&s) { return s.find(val) == 0; }
- const string& val;
+ string_starts_with(const string& t) : val(t) {}
+ bool operator()(const string& s) const { return boost::starts_with(s, val); }
+ const string& val;
};
-struct find_any
+ struct string_contains
{
- find_any(const string& t) : val(t) {}
- bool operator()(const string&s) { return s.find(val) != string::npos; }
- const string& val;
+ string_contains(const string& t) : val(t) {}
+ bool operator()(const string& s) const { return boost::contains(s, val); }
+ const string& val;
};
+
+ template <class Pred>
+ vector<string>::iterator
+ find_if(vector<string>& lines, Pred pred)
+ {
+ return std::find_if(lines.begin(), lines.end(), pred);
+ }
+
+ template <class Pred>
+ vector<string>::const_iterator
+ find_if(const vector<string>& lines, Pred pred)
+ {
+ return std::find_if(lines.begin(), lines.end(), pred);
+ }
+
}
+
#endif
Modified: branches/SuSE-Code-11-SP2-Branch/storage/libstorage/src/SystemCmd.cc
URL: http://svn.opensuse.org/viewcvs/yast/branches/SuSE-Code-11-SP2-Branch/stora…
==============================================================================
--- branches/SuSE-Code-11-SP2-Branch/storage/libstorage/src/SystemCmd.cc (original)
+++ branches/SuSE-Code-11-SP2-Branch/storage/libstorage/src/SystemCmd.cc Tue May 17 13:39:44 2011
@@ -19,60 +19,51 @@
* find current contact information at www.novell.com.
*/
-// Maintainer: fehr(a)suse.de
-/*
- Textdomain "storage"
-*/
#include <stdlib.h>
#include <unistd.h>
#include <errno.h>
#include <fcntl.h>
-#include <iostream>
+#include <ostream>
#include <fstream>
#include <sys/wait.h>
-
#include <string>
-#include <boost/algorithm/string/replace.hpp>
-
-#include "y2storage/AppUtil.h"
-#include "y2storage/SystemCmd.h"
-#include "y2storage/OutputProcessor.h"
+#include <boost/algorithm/string.hpp>
-using namespace std;
-using namespace storage;
+#include "storage/AppUtil.h"
+#include "storage/SystemCmd.h"
+#include "storage/OutputProcessor.h"
-SystemCmd::SystemCmd( const char* Command )
+namespace storage
{
- y2mil("constructor SystemCmd:\"" << Command << "\"");
- init();
- execute( Command );
-}
+ using namespace std;
+
SystemCmd::SystemCmd( const string& Command_Cv )
+ : Combine_b(false), output_proc(NULL)
{
y2mil("constructor SystemCmd:\"" << Command_Cv << "\"");
init();
execute( Command_Cv );
}
+
SystemCmd::SystemCmd()
+ : Combine_b(false), output_proc(NULL)
{
y2mil("constructor SystemCmd");
init();
}
+
void SystemCmd::init()
{
- Combine_b = false;
- OutputHandler_f = NULL;
- HandlerPar_p = NULL;
- output_proc = NULL;
File_aC[0] = File_aC[1] = NULL;
pfds[0].events = pfds[1].events = POLLIN;
}
+
SystemCmd::~SystemCmd()
{
if( File_aC[IDX_STDOUT] )
@@ -81,16 +72,9 @@
fclose( File_aC[IDX_STDERR] );
}
-void
-SystemCmd::setOutputHandler( void (*Handle_f)( void *, string, bool ),
- void * Par_p )
- {
- OutputHandler_f = Handle_f;
- HandlerPar_p = Par_p;
- }
void
-SystemCmd::closeOpenFds()
+SystemCmd::closeOpenFds() const
{
int max_fd = getdtablesize();
for( int fd = 3; fd < max_fd; fd++ )
@@ -101,7 +85,7 @@
int
-SystemCmd::execute( const string& Cmd_Cv )
+SystemCmd::execute(const string& Cmd_Cv)
{
y2mil("SystemCmd Executing:\"" << Cmd_Cv << "\"");
Background_b = false;
@@ -120,8 +104,7 @@
int
SystemCmd::executeRestricted( const string& Command_Cv,
- long unsigned MaxTimeSec,
- long unsigned MaxLineOut,
+ long unsigned MaxTimeSec, long unsigned MaxLineOut,
bool& ExceedTime, bool& ExceedLines )
{
y2mil("cmd:" << Command_Cv << " MaxTime:" << MaxTimeSec << " MaxLines:" << MaxLineOut);
@@ -186,7 +169,7 @@
#define ALTERNATE_SHELL "/bin/bash"
int
-SystemCmd::doExecute( string Cmd )
+SystemCmd::doExecute( const string& Cmd )
{
string Shell_Ci = PRIMARY_SHELL;
if( access( Shell_Ci.c_str(), X_OK ) != 0 )
@@ -201,6 +184,8 @@
}
y2deb("Cmd:" << Cmd);
+ StopWatch stopwatch;
+
File_aC[IDX_STDERR] = File_aC[IDX_STDOUT] = NULL;
invalidate();
int sout[2];
@@ -208,14 +193,12 @@
bool ok_bi = true;
if( !testmode && pipe(sout)<0 )
{
- y2error( "pipe stdout creation failed errno=%d (%s)", errno,
- strerror(errno));
+ y2err("pipe stdout creation failed errno:" << errno << " (" << strerror(errno) << ")");
ok_bi = false;
}
if( !testmode && !Combine_b && pipe(serr)<0 )
{
- y2error( "pipe stderr creation failed errno=%d (%s)", errno,
- strerror(errno));
+ y2err("pipe stderr creation failed errno:" << errno << " (" << strerror(errno) << ")");
ok_bi = false;
}
if( !testmode && ok_bi )
@@ -223,54 +206,46 @@
pfds[0].fd = sout[0];
if( fcntl( pfds[0].fd, F_SETFL, O_NONBLOCK )<0 )
{
- y2error( "fcntl O_NONBLOCK failed errno=%d (%s)", errno,
- strerror(errno));
+ y2err("fcntl O_NONBLOCK failed errno:" << errno << " (" << strerror(errno) << ")");
}
if( !Combine_b )
{
pfds[1].fd = serr[0];
if( fcntl( pfds[1].fd, F_SETFL, O_NONBLOCK )<0 )
{
- y2error( "fcntl O_NONBLOCK failed errno=%d (%s)", errno,
- strerror(errno));
+ y2err("fcntl O_NONBLOCK failed errno:" << errno << " (" << strerror(errno) << ")");
}
}
- y2debug( "sout:%d serr:%d", pfds[0].fd, Combine_b?-1:pfds[1].fd );
+ y2deb("sout:" << pfds[0].fd << " serr:" << (Combine_b?-1:pfds[1].fd));
switch( (Pid_i=fork()) )
{
case 0:
setenv( "LC_ALL", "C", 1 );
setenv( "LANGUAGE", "C", 1 );
- if( dup2( sout[1], 1 )<0 )
+ if( dup2( sout[1], STDOUT_FILENO )<0 )
{
- y2error( "dup2 stdout child failed errno=%d (%s)", errno,
- strerror(errno));
+ y2err("dup2 stdout child failed errno:" << errno << " (" << strerror(errno) << ")");
}
- if( !Combine_b && dup2( serr[1], 2 )<0 )
+ if( !Combine_b && dup2( serr[1], STDERR_FILENO )<0 )
{
- y2error( "dup2 stderr child failed errno=%d (%s)", errno,
- strerror(errno));
+ y2err("dup2 stderr child failed errno:" << errno << " (" << strerror(errno) << ")");
}
- if( Combine_b && dup2( 1, 2 )<0 )
+ if( Combine_b && dup2( STDOUT_FILENO, STDERR_FILENO )<0 )
{
- y2error( "dup2 stderr child failed errno=%d (%s)", errno,
- strerror(errno));
+ y2err("dup2 stderr child failed errno:" << errno << " (" << strerror(errno) << ")");
}
if( close( sout[0] )<0 )
{
- y2error( "close child failed errno=%d (%s)", errno,
- strerror(errno));
+ y2err("close child failed errno:" << errno << " (" << strerror(errno) << ")");
}
if( !Combine_b && close( serr[0] )<0 )
{
- y2error( "close child failed errno=%d (%s)", errno,
- strerror(errno));
+ y2err("close child failed errno:" << errno << " (" << strerror(errno) << ")");
}
closeOpenFds();
Ret_i = execl( Shell_Ci.c_str(), Shell_Ci.c_str(), "-c",
Cmd.c_str(), NULL );
- y2error( "SHOULD NOT HAPPEN \"%s\" Ret:%d", Shell_Ci.c_str(),
- Ret_i );
+ y2err("SHOULD NOT HAPPEN \"" << Shell_Ci << "\" Ret:" << Ret_i);
break;
case -1:
Ret_i = -1;
@@ -278,33 +253,30 @@
default:
if( close( sout[1] )<0 )
{
- y2error( "close parent failed errno=%d (%s)", errno,
- strerror(errno));
+ y2err("close parent failed errno:" << errno << " (" << strerror(errno) << ")");
}
if( !Combine_b && close( serr[1] )<0 )
{
- y2error( "close parent failed errno=%d (%s)", errno,
- strerror(errno));
+ y2err("close parent failed errno:" << errno << " (" << strerror(errno) << ")");
}
Ret_i = 0;
File_aC[IDX_STDOUT] = fdopen( sout[0], "r" );
if( File_aC[IDX_STDOUT] == NULL )
{
- y2error( "fdopen stdout failed errno=%d (%s)", errno,
- strerror(errno));
+ y2err("fdopen stdout failed errno:" << errno << " (" << strerror(errno) << ")");
}
if( !Combine_b )
{
File_aC[IDX_STDERR] = fdopen( serr[0], "r" );
if( File_aC[IDX_STDERR] == NULL )
{
- y2error( "fdopen stderr failed errno=%d (%s)", errno,
- strerror(errno));
+ y2err("fdopen stderr failed errno:" << errno << " (" << strerror(errno) << ")");
}
}
if( !Background_b )
{
doWait( true, Ret_i );
+ y2mil("stopwatch " << stopwatch << " for \"" << cmd() << "\"");
}
break;
}
@@ -336,26 +308,26 @@
{
int Wait_ii;
int Status_ii;
- int sel;
do
{
- y2debug( "[0] id:%d ev:%x [1] fs:%d ev:%x",
- pfds[0].fd, (unsigned)pfds[0].events,
- Combine_b?-1:pfds[1].fd, Combine_b?0:(unsigned)pfds[1].events );
- if( (sel=poll( pfds, Combine_b?1:2, 1000 ))<0 )
+ y2deb("[0] id:" << pfds[0].fd << " ev:" << hex << (unsigned)pfds[0].events << dec << " [1] fs:" <<
+ (Combine_b?-1:pfds[1].fd) << " ev:" << hex << (Combine_b?0:(unsigned)pfds[1].events));
+ int sel = poll( pfds, Combine_b?1:2, 1000 );
+ if (sel < 0)
{
- y2error( "poll failed errno=%d (%s)", errno, strerror(errno));
+ y2err("poll failed errno:" << errno << " (" << strerror(errno) << ")");
}
- y2debug( "poll ret:%d", sel );
+ y2deb("poll ret:" << sel);
if( sel>0 )
{
checkOutput();
}
Wait_ii = waitpid( Pid_i, &Status_ii, WNOHANG );
- y2debug( "Wait ret:%d", Wait_ii );
+ y2deb("Wait ret:" << Wait_ii);
}
while( Hang_bv && Wait_ii == 0 );
+
if( Wait_ii != 0 )
{
checkOutput();
@@ -366,56 +338,47 @@
fclose( File_aC[IDX_STDERR] );
File_aC[IDX_STDERR] = NULL;
}
- if( !WIFEXITED(Status_ii) )
- {
- Ret_ir = -127;
- }
- else
- {
+ if (WIFEXITED(Status_ii))
+ {
Ret_ir = WEXITSTATUS(Status_ii);
- }
+ if (Ret_ir == 126)
+ y2err("command \"" << lastCmd << "\" not executable");
+ else if (Ret_ir == 127)
+ y2err("command \"" << lastCmd << "\" not found");
+ }
+ else
+ {
+ Ret_ir = -127;
+ y2err("command \"" << lastCmd << "\" failed");
+ }
if( output_proc )
{
- output_proc->finished();
+ output_proc->finish();
}
}
- y2debug( "Wait:%d pid=%d stat=%d Hang:%d Ret:%d", Wait_ii, Pid_i,
- Status_ii, Hang_bv, Ret_ir );
+
+ y2deb("Wait:" << Wait_ii << " pid:" << Pid_i << " stat:" << Status_ii <<
+ " Hang:" << Hang_bv << " Ret:" << Ret_ir);
return Wait_ii != 0;
}
+
void
-SystemCmd::setCombine( const bool Comb_bv )
- {
- Combine_b = Comb_bv;
- }
+SystemCmd::setCombine(bool val)
+{
+ Combine_b = val;
+}
-const string *
-SystemCmd::getString( unsigned Idx_iv ) const
- {
- if( Idx_iv > 1 )
- {
- y2err("invalid index " << Idx_iv);
- }
- if( !Valid_ab[Idx_iv] )
- {
- unsigned int I_ii;
- Text_aC[Idx_iv] = "";
- I_ii=0;
- while( I_ii<Lines_aC[Idx_iv].size() )
- {
- Text_aC[Idx_iv] += Lines_aC[Idx_iv][I_ii];
- Text_aC[Idx_iv] += '\n';
- I_ii++;
- }
- Valid_ab[Idx_iv] = true;
- }
- return &Text_aC[Idx_iv];
- }
+void
+SystemCmd::setTestmode(bool val)
+{
+ testmode = val;
+}
+
unsigned
-SystemCmd::numLines( bool Sel_bv, unsigned Idx_iv ) const
+SystemCmd::numLines( bool Sel_bv, OutputStream Idx_iv ) const
{
unsigned Ret_ii;
@@ -435,10 +398,11 @@
return Ret_ii;
}
-const string *
-SystemCmd::getLine( unsigned Nr_iv, bool Sel_bv, unsigned Idx_iv ) const
+
+string
+SystemCmd::getLine( unsigned Nr_iv, bool Sel_bv, OutputStream Idx_iv ) const
{
- const string * Ret_pCi = NULL;
+ string ret;
if( Idx_iv > 1 )
{
@@ -448,90 +412,80 @@
{
if( Nr_iv < SelLines_aC[Idx_iv].capacity() )
{
- Ret_pCi = SelLines_aC[Idx_iv][Nr_iv];
+ ret = *SelLines_aC[Idx_iv][Nr_iv];
}
}
else
{
if( Nr_iv < Lines_aC[Idx_iv].size() )
{
- Ret_pCi = &Lines_aC[Idx_iv][Nr_iv];
+ ret = Lines_aC[Idx_iv][Nr_iv];
}
}
- return Ret_pCi;
+ return ret;
}
+
int
-SystemCmd::select( string Pat_Cv, bool Invert_bv, unsigned Idx_iv )
+SystemCmd::select( const string& Pat_Cv, OutputStream Idx_iv )
{
- int I_ii;
- int End_ii;
- int Size_ii;
- string::size_type Pos_ii;
- bool BeginOfLine_bi;
- string Search_Ci( Pat_Cv );
-
if( Idx_iv > 1 )
{
y2err("invalid index " << Idx_iv);
}
- BeginOfLine_bi = Search_Ci.length()>0 && Search_Ci[0]=='^';
+ string Search_Ci( Pat_Cv );
+ bool BeginOfLine_bi = Search_Ci.length()>0 && Search_Ci[0]=='^';
if( BeginOfLine_bi )
{
Search_Ci.erase( 0, 1 );
}
SelLines_aC[Idx_iv].resize(0);
- Size_ii = 0;
- End_ii = Lines_aC[Idx_iv].size();
- for( I_ii=0; I_ii<End_ii; I_ii++ )
+ int Size_ii = 0;
+ int End_ii = Lines_aC[Idx_iv].size();
+ for( int I_ii=0; I_ii<End_ii; I_ii++ )
{
- Pos_ii = Lines_aC[Idx_iv][I_ii].find( Search_Ci );
+ string::size_type Pos_ii = Lines_aC[Idx_iv][I_ii].find( Search_Ci );
if( Pos_ii>0 && BeginOfLine_bi )
{
Pos_ii = string::npos;
}
- if( (Pos_ii != string::npos) != Invert_bv )
+ if (Pos_ii != string::npos)
{
SelLines_aC[Idx_iv].resize( Size_ii+1 );
SelLines_aC[Idx_iv][Size_ii] = &Lines_aC[Idx_iv][I_ii];
- y2debug( "Select Added Line %d \"%s\"", Size_ii,
- SelLines_aC[Idx_iv][Size_ii]->c_str() );
+ y2deb("Select Added Line " << Size_ii << " \"" << *SelLines_aC[Idx_iv][Size_ii] << "\"");
Size_ii++;
}
}
- y2milestone( "Pid:%d Idx:%d Pattern:\"%s\" Invert:%d Lines %d", Pid_i,
- Idx_iv, Pat_Cv.c_str(), Invert_bv, Size_ii );
+
+ y2mil("Pid:" << Pid_i << " Idx:" << Idx_iv << " Pattern:\"" << Pat_Cv << "\" Lines:" << Size_ii);
return Size_ii;
}
+
void
SystemCmd::invalidate()
{
- int Idx_ii;
-
- for( Idx_ii=0; Idx_ii<2; Idx_ii++ )
+ for (int Idx_ii = 0; Idx_ii < 2; Idx_ii++)
{
- Valid_ab[Idx_ii] = false;
SelLines_aC[Idx_ii].resize(0);
Lines_aC[Idx_ii].clear();
NewLineSeen_ab[Idx_ii] = true;
}
}
+
void
SystemCmd::checkOutput()
- {
- y2debug( "NewLine out:%d err:%d", NewLineSeen_ab[IDX_STDOUT],
- NewLineSeen_ab[IDX_STDERR] );
- if( File_aC[IDX_STDOUT] )
- getUntilEOF( File_aC[IDX_STDOUT], Lines_aC[IDX_STDOUT],
- NewLineSeen_ab[IDX_STDOUT], false );
- if( File_aC[IDX_STDERR] )
- getUntilEOF( File_aC[IDX_STDERR], Lines_aC[IDX_STDERR],
- NewLineSeen_ab[IDX_STDERR], true );
- y2debug( "NewLine out:%d err:%d", NewLineSeen_ab[IDX_STDOUT],
- NewLineSeen_ab[IDX_STDERR] );
- }
+{
+ y2deb("NewLine out:" << NewLineSeen_ab[IDX_STDOUT] << " err:" << NewLineSeen_ab[IDX_STDERR]);
+ if (File_aC[IDX_STDOUT])
+ getUntilEOF(File_aC[IDX_STDOUT], Lines_aC[IDX_STDOUT], NewLineSeen_ab[IDX_STDOUT], false);
+ if (File_aC[IDX_STDERR])
+ getUntilEOF(File_aC[IDX_STDERR], Lines_aC[IDX_STDERR], NewLineSeen_ab[IDX_STDERR], true);
+ y2deb("NewLine out:" << NewLineSeen_ab[IDX_STDOUT] << " err:" << NewLineSeen_ab[IDX_STDERR]);
+}
+
#define BUF_LEN 256
@@ -560,11 +514,6 @@
{
output_proc->process( Buf_ti, Stderr_bv );
}
- if( OutputHandler_f )
- {
- y2deb("Calling Output-Handler Buf:\"" << Buf_ti << "\" Stderr:" << Stderr_bv);
- OutputHandler_f( HandlerPar_p, Buf_ti, Stderr_bv );
- }
}
Char_ii = EOF;
}
@@ -576,11 +525,6 @@
{
output_proc->process( Buf_ti, Stderr_bv );
}
- if( OutputHandler_f )
- {
- y2deb("Calling Output-Handler Buf:\"" << Buf_ti << "\" Stderr:" << Stderr_bv);
- OutputHandler_f( HandlerPar_p, Buf_ti, Stderr_bv );
- }
}
if( Text_Ci.length() > 0 )
{
@@ -605,9 +549,10 @@
}
}
+
void
-SystemCmd::extractNewline( const char* Buf_ti, int Cnt_iv, bool& NewLine_br,
- string& Text_Cr, vector<string>& Lines_Cr )
+SystemCmd::extractNewline(const string& Buf_ti, int Cnt_iv, bool& NewLine_br,
+ string& Text_Cr, vector<string>& Lines_Cr)
{
string::size_type Idx_ii;
@@ -625,14 +570,14 @@
Text_Cr.erase( 0, Idx_ii+1 );
NewLine_br = true;
}
- y2debug( "Text_Ci:%s NewLine:%d", Text_Cr.c_str(), NewLine_br );
+ y2deb("Text_Ci:" << Text_Cr << " NewLine:" << NewLine_br);
}
void
-SystemCmd::addLine(string Text_Cv, vector<string>& Lines_Cr)
+SystemCmd::addLine(const string& Text_Cv, vector<string>& Lines_Cr)
{
- if (Lines_Cr.size() < 100)
+ if (Lines_Cr.size() < line_limit)
{
y2mil("Adding Line " << Lines_Cr.size() + 1 << " \"" << Text_Cv << "\"");
}
@@ -648,58 +593,47 @@
void
SystemCmd::logOutput() const
{
- for (unsigned i = 0; i < numLines(false, IDX_STDERR); ++i)
- y2mil("stderr:" << *getLine(i, false, IDX_STDERR));
- for (unsigned i = 0; i < numLines(false, IDX_STDOUT); ++i)
- y2mil("stdout:" << *getLine(i, false, IDX_STDOUT));
-}
-
-
-///////////////////////////////////////////////////////////////////
-//
-// METHOD NAME : SystemCmd::PlaceOutput
-// METHOD TYPE : int
-//
-// INPUT :
-// OUTPUT :
-// DESCRIPTION : Place stdout/stderr linewise in Ret_Cr
-//
-int SystemCmd::placeOutput( unsigned Which_iv, vector<string> &Ret_Cr,
- const bool Append_bv ) const
-{
- if ( !Append_bv )
- Ret_Cr.clear();
-
- int Lines_ii = numLines( false, Which_iv );
-
- for ( int i_ii = 0; i_ii < Lines_ii; i_ii++ )
- Ret_Cr.push_back( *getLine( i_ii, false, Which_iv ) );
-
- return Lines_ii;
-}
-
-int SystemCmd::placeOutput( unsigned Which_iv, list<string> &Ret_Cr,
- const bool Append_bv ) const
-{
- if ( !Append_bv )
- Ret_Cr.clear();
-
- int Lines_ii = numLines( false, Which_iv );
-
- for ( int i_ii = 0; i_ii < Lines_ii; i_ii++ )
- Ret_Cr.push_back( *getLine( i_ii, false, Which_iv ) );
+ unsigned lines = numLines(false, IDX_STDERR);
+ if (lines <= line_limit)
+ {
+ for (unsigned i = 0; i < lines; ++i)
+ y2mil("stderr:" << getLine(i, false, IDX_STDERR));
+ }
+ else
+ {
+ for (unsigned i = 0; i < line_limit / 2; ++i)
+ y2mil("stderr:" << getLine(i, false, IDX_STDERR));
+ y2mil("stderr omitting lines");
+ for (unsigned i = lines - line_limit / 2; i < lines; ++i)
+ y2mil("stderr:" << getLine(i, false, IDX_STDERR));
+ }
- return Lines_ii;
+ lines = numLines(false, IDX_STDOUT);
+ if (lines <= line_limit)
+ {
+ for (unsigned i = 0; i < lines; ++i)
+ y2mil("stdout:" << getLine(i, false, IDX_STDOUT));
+ }
+ else
+ {
+ for (unsigned i = 0; i < line_limit / 2; ++i)
+ y2mil("stdout:" << getLine(i, false, IDX_STDOUT));
+ y2mil("stdout omitting lines");
+ for (unsigned i = lines - line_limit / 2; i < lines; ++i)
+ y2mil("stdout:" << getLine(i, false, IDX_STDOUT));
+ }
}
-string SystemCmd::quote(const string& str)
+string
+SystemCmd::quote(const string& str)
{
return "'" + boost::replace_all_copy(str, "'", "'\\''") + "'";
}
-string SystemCmd::quote(const list<string>& strs)
+string
+SystemCmd::quote(const list<string>& strs)
{
string ret;
for (std::list<string>::const_iterator it = strs.begin(); it != strs.end(); it++)
@@ -713,3 +647,5 @@
bool SystemCmd::testmode = false;
+
+}
Modified: branches/SuSE-Code-11-SP2-Branch/storage/libstorage/src/SystemCmd.h
URL: http://svn.opensuse.org/viewcvs/yast/branches/SuSE-Code-11-SP2-Branch/stora…
==============================================================================
--- branches/SuSE-Code-11-SP2-Branch/storage/libstorage/src/SystemCmd.h (original)
+++ branches/SuSE-Code-11-SP2-Branch/storage/libstorage/src/SystemCmd.h Tue May 17 13:39:44 2011
@@ -29,53 +29,48 @@
#include <string>
#include <vector>
#include <list>
+#include <boost/noncopyable.hpp>
-using std::string;
namespace storage
{
+ using std::string;
+ using std::vector;
class OutputProcessor;
-class SystemCmd
+class SystemCmd : boost::noncopyable
{
public:
+
enum OutputStream { IDX_STDOUT, IDX_STDERR };
- SystemCmd( const char* Command_Cv );
- SystemCmd( const string& Command_Cv );
+
+ SystemCmd(const string& Command_Cv);
SystemCmd();
+
virtual ~SystemCmd();
- int execute( const string& Command_Cv );
- int executeBackground( const string& Command_Cv );
- int executeRestricted( const string& Command_Cv,
- unsigned long MaxTimeSec,
- unsigned long MaxLineOut,
- bool& ExceedTime, bool& ExceedLines);
- void setOutputHandler( void (*Handle_f)( void *, string, bool ),
- void * Par_p );
- void logOutput() const;
- void setOutputProcessor( OutputProcessor * proc )
- { output_proc = proc; }
- int select( string Reg_Cv, bool Invert_bv=false,
- unsigned Idx_ii=IDX_STDOUT );
- const string& stderr() const { return( *getString(IDX_STDERR)); }
- const string& stdout() const { return( *getString(IDX_STDOUT)); }
- const string& cmd() const { return( lastCmd ); }
- const string* getString( unsigned Idx_ii=IDX_STDOUT ) const;
- const string* getLine( unsigned Num_iv, bool Selected_bv=false,
- unsigned Idx_ii=IDX_STDOUT ) const;
- unsigned numLines( bool Selected_bv=false, unsigned Idx_ii=IDX_STDOUT ) const;
- void setCombine( const bool Combine_b=true );
+
+ int execute(const string& Command_Cv);
+ int executeBackground(const string& Command_Cv);
+ int executeRestricted(const string& Command_Cv,
+ unsigned long MaxTimeSec, unsigned long MaxLineOut,
+ bool& ExceedTime, bool& ExceedLines);
+
+ void setOutputProcessor(OutputProcessor* proc) { output_proc = proc; }
+
+ const vector<string>& stdout() const { return Lines_aC[IDX_STDOUT]; }
+ const vector<string>& stderr() const { return Lines_aC[IDX_STDERR]; }
+
+ string cmd() const { return lastCmd; }
int retcode() const { return Ret_i; }
- int getStdout( std::vector<string> &Ret_Cr, const bool Append_bv = false ) const
- { return placeOutput( IDX_STDOUT, Ret_Cr, Append_bv); }
- int getStderr( std::vector<string> &Ret_Cr, const bool Append_bv = false ) const
- { return placeOutput( IDX_STDERR, Ret_Cr, Append_bv); }
- int getStdout( std::list<string> &Ret_Cr, const bool Append_bv = false ) const
- { return placeOutput( IDX_STDOUT, Ret_Cr, Append_bv); }
- int getStderr( std::list<string> &Ret_Cr, const bool Append_bv = false ) const
- { return placeOutput( IDX_STDERR, Ret_Cr, Append_bv); }
+ int select(const string& Reg_Cv, OutputStream Idx_ii = IDX_STDOUT);
+ unsigned numLines(bool Selected_bv = false, OutputStream Idx_ii = IDX_STDOUT) const;
+ string getLine(unsigned Num_iv, bool Selected_bv = false, OutputStream Idx_ii = IDX_STDOUT) const;
+
+ void setCombine(bool combine = true);
+
+ static void setTestmode(bool testmode = true);
/**
* Quotes and protects a single string for shell execution.
@@ -87,27 +82,22 @@
*/
static string quote(const std::list<string>& strs);
- static bool testmode;
-
protected:
- int placeOutput( unsigned Which_iv, std::vector<string> &Ret_Cr, const bool Append_bv ) const;
- int placeOutput( unsigned Which_iv, std::list<string> &Ret_Cr, const bool Append_bv ) const;
-
void invalidate();
- void closeOpenFds();
- int doExecute( string Cmd_Cv );
- bool doWait( bool Hang_bv, int& Ret_ir );
+ void closeOpenFds() const;
+ int doExecute(const string& Cmd_Cv);
+ bool doWait(bool Hang_bv, int& Ret_ir);
void checkOutput();
- void getUntilEOF( FILE* File_Cr, std::vector<string>& Lines_Cr,
- bool& NewLineSeen_br, bool Stderr_bv );
- void extractNewline( const char* Buf_ti, int Cnt_ii, bool& NewLineSeen_br,
- string& Text_Cr, std::vector<string>& Lines_Cr );
- void addLine( string Text_Cv, std::vector<string>& Lines_Cr );
+ void getUntilEOF(FILE* File_Cr, std::vector<string>& Lines_Cr,
+ bool& NewLineSeen_br, bool Stderr_bv);
+ void extractNewline(const string& Buf_ti, int Cnt_ii, bool& NewLineSeen_br,
+ string& Text_Cr, std::vector<string>& Lines_Cr);
+ void addLine(const string& Text_Cv, std::vector<string>& Lines_Cr);
void init();
- mutable string Text_aC[2];
- mutable bool Valid_ab[2];
+ void logOutput() const;
+
FILE* File_aC[2];
std::vector<string> Lines_aC[2];
std::vector<string*> SelLines_aC[2];
@@ -117,11 +107,12 @@
string lastCmd;
int Ret_i;
int Pid_i;
- void (* OutputHandler_f)( void*, string, bool );
- void *HandlerPar_p;
OutputProcessor* output_proc;
struct pollfd pfds[2];
+ static bool testmode;
+
+ static const unsigned line_limit = 50;
};
Added: branches/SuSE-Code-11-SP2-Branch/storage/libstorage/src/SystemInfo.cc
URL: http://svn.opensuse.org/viewcvs/yast/branches/SuSE-Code-11-SP2-Branch/stora…
==============================================================================
--- branches/SuSE-Code-11-SP2-Branch/storage/libstorage/src/SystemInfo.cc (added)
+++ branches/SuSE-Code-11-SP2-Branch/storage/libstorage/src/SystemInfo.cc Tue May 17 13:39:44 2011
@@ -0,0 +1,103 @@
+/*
+ * Copyright (c) [2004-2010] Novell, Inc.
+ *
+ * All Rights Reserved.
+ *
+ * This program is free software; you can redistribute it and/or modify it
+ * under the terms of version 2 of the GNU General Public License as published
+ * by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
+ * more details.
+ *
+ * You should have received a copy of the GNU General Public License along
+ * with this program; if not, contact Novell, Inc.
+ *
+ * To contact Novell about this file by physical or electronic mail, you may
+ * find current contact information at www.novell.com.
+ */
+
+
+#include "storage/StorageDefines.h"
+
+#include "storage/SystemCmd.h"
+
+#include "storage/SystemInfo.h"
+
+
+namespace storage
+{
+
+ SystemInfo::SystemInfo()
+ {
+ y2deb("constructed SystemInfo");
+ }
+
+
+ SystemInfo::~SystemInfo()
+ {
+ y2deb("destructed SystemInfo");
+ }
+
+CmdBtrfsShow::CmdBtrfsShow()
+ {
+ SystemCmd c(BTRFSBIN " filesystem show");
+ if (c.retcode() != 0 || c.numLines() == 0)
+ return;
+
+ const vector<string>& lines = c.stdout();
+ vector<string>::const_iterator it = lines.begin();
+
+ while( it!=lines.end() )
+ {
+ while( it != lines.end() && !boost::contains( *it, " uuid: " ))
+ ++it;
+ if( it!=lines.end() )
+ {
+ y2mil( "uuid line:" << *it );
+ string uuid = extractNthWord( 3, *it );
+ y2mil( "uuid:" << uuid );
+ Entry e;
+ ++it;
+ while( it!=lines.end() && !boost::contains( *it, " uuid: " ) &&
+ !boost::contains( *it, "devid " ) )
+ ++it;
+ while( it!=lines.end() && boost::contains( *it, "devid " ) )
+ {
+ y2mil( "devs line:" << *it );
+ e.devices.push_back( extractNthWord( 7, *it ));
+ ++it;
+ }
+ y2mil( "devs:" << e.devices );
+ fs[uuid] = e;
+ }
+ }
+ }
+
+bool
+CmdBtrfsShow::getEntry( const string& uuid, Entry& entry) const
+ {
+ const_iterator it = fs.find(uuid);
+ if( it!=fs.end() )
+ entry = it->second;
+ return( it!=fs.end() );
+ }
+
+list<string>
+CmdBtrfsShow::getUuids() const
+ {
+ list<string> ret;
+
+ const_iterator it = fs.begin();
+ while( it != fs.end() )
+ {
+ ret.push_back( it->first );
+ ++it;
+ }
+ y2mil( "ret:" << ret );
+ return( ret );
+ }
+
+}
Added: branches/SuSE-Code-11-SP2-Branch/storage/libstorage/src/SystemInfo.h
URL: http://svn.opensuse.org/viewcvs/yast/branches/SuSE-Code-11-SP2-Branch/stora…
==============================================================================
--- branches/SuSE-Code-11-SP2-Branch/storage/libstorage/src/SystemInfo.h (added)
+++ branches/SuSE-Code-11-SP2-Branch/storage/libstorage/src/SystemInfo.h Tue May 17 13:39:44 2011
@@ -0,0 +1,142 @@
+/*
+ * Copyright (c) [2004-2010] Novell, Inc.
+ *
+ * All Rights Reserved.
+ *
+ * This program is free software; you can redistribute it and/or modify it
+ * under the terms of version 2 of the GNU General Public License as published
+ * by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
+ * more details.
+ *
+ * You should have received a copy of the GNU General Public License along
+ * with this program; if not, contact Novell, Inc.
+ *
+ * To contact Novell about this file by physical or electronic mail, you may
+ * find current contact information at www.novell.com.
+ */
+
+
+#ifndef SYSTEM_INFO_H
+#define SYSTEM_INFO_H
+
+
+#include <boost/noncopyable.hpp>
+
+#include "storage/AppUtil.h"
+#include "storage/ProcParts.h"
+#include "storage/ProcMounts.h"
+#include "storage/ProcMdstat.h"
+#include "storage/Blkid.h"
+#include "storage/Lsscsi.h"
+#include "storage/Parted.h"
+#include "storage/Dasdview.h"
+#include "storage/DmCo.h"
+#include "storage/DmraidCo.h"
+#include "storage/DmmultipathCo.h"
+
+namespace storage
+{
+ using std::map;
+ using std::list;
+
+ class CmdBtrfsShow
+ {
+ public:
+ CmdBtrfsShow();
+ struct Entry
+ {
+ list<string> devices;
+ };
+ bool getEntry(const string& uuid, Entry& entry) const;
+ list<string> getUuids() const;
+
+ private:
+ typedef map<string, Entry>::const_iterator const_iterator;
+
+ map< string, Entry > fs;
+ };
+
+ class SystemInfo : boost::noncopyable
+ {
+
+ public:
+
+ SystemInfo();
+ ~SystemInfo();
+
+ const UdevMap& getUdevMap(const string& path) { return udevmaps.get(path); }
+ const ProcParts& getProcParts() { return *procparts; }
+ const ProcMounts& getProcMounts() { return *procmounts; }
+ const ProcMdstat& getProcMdstat() { return *procmdstat; }
+ const Blkid& getBlkid() { return *blkid; }
+ const Lsscsi& getLsscsi() { return *lsscsi; }
+ const Parted& getParted(const string& device) { return parteds.get(device); }
+ const Fdasd& getFdasd(const string& device) { return fdasds.get(device); }
+ const CmdDmsetup& getCmdDmsetup() { return *cmddmsetup; }
+ const CmdDmraid& getCmdDmraid() { return *cmddmraid; }
+ const CmdMultipath& getCmdMultipath() { return *cmdmultipath; }
+ const CmdBtrfsShow& getCmdBtrfsShow() { return *cmdbtrfsshow; }
+
+ private:
+
+ template <class Type>
+ class LazyObject : boost::noncopyable
+ {
+ public:
+
+ LazyObject() : ptr(NULL) {}
+ ~LazyObject() { delete ptr; }
+
+ const Type& operator*() { if (!ptr) ptr = new Type(); return *ptr; }
+
+ private:
+
+ Type* ptr;
+
+ };
+
+ template <class Type>
+ class LazyObjects : boost::noncopyable
+ {
+ public:
+
+ const Type& get(const string& s)
+ {
+ typename map<string, Type>::iterator pos = data.lower_bound(s);
+ if (pos == data.end() || typename map<string, Type>::key_compare()(s, pos->first))
+ {
+ Type tmp(s);
+ pos = data.insert(pos, typename map<string, Type>::value_type(s, tmp));
+ }
+ return pos->second;
+ }
+
+ private:
+
+ map<string, Type> data;
+
+ };
+
+ LazyObjects<UdevMap> udevmaps;
+ LazyObject<ProcParts> procparts;
+ LazyObject<ProcMounts> procmounts;
+ LazyObject<ProcMdstat> procmdstat;
+ LazyObject<Blkid> blkid;
+ LazyObject<Lsscsi> lsscsi;
+ LazyObjects<Parted> parteds;
+ LazyObjects<Fdasd> fdasds;
+ LazyObject<CmdDmsetup> cmddmsetup;
+ LazyObject<CmdDmraid> cmddmraid;
+ LazyObject<CmdMultipath> cmdmultipath;
+ LazyObject<CmdBtrfsShow> cmdbtrfsshow;
+
+ };
+
+}
+
+
+#endif
Added: branches/SuSE-Code-11-SP2-Branch/storage/libstorage/src/Tmpfs.cc
URL: http://svn.opensuse.org/viewcvs/yast/branches/SuSE-Code-11-SP2-Branch/stora…
==============================================================================
--- branches/SuSE-Code-11-SP2-Branch/storage/libstorage/src/Tmpfs.cc (added)
+++ branches/SuSE-Code-11-SP2-Branch/storage/libstorage/src/Tmpfs.cc Tue May 17 13:39:44 2011
@@ -0,0 +1,154 @@
+/*
+ * Copyright (c) [2004-2011] Novell, Inc.
+ *
+ * All Rights Reserved.
+ *
+ * This program is free software; you can redistribute it and/or modify it
+ * under the terms of version 2 of the GNU General Public License as published
+ * by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
+ * more details.
+ *
+ * You should have received a copy of the GNU General Public License along
+ * with this program; if not, contact Novell, Inc.
+ *
+ * To contact Novell about this file by physical or electronic mail, you may
+ * find current contact information at www.novell.com.
+ */
+
+
+#include <sys/stat.h>
+#include <sstream>
+
+#include "storage/Tmpfs.h"
+#include "storage/StorageTypes.h"
+#include "storage/Container.h"
+#include "storage/AppUtil.h"
+#include "storage/SystemInfo.h"
+#include "storage/Storage.h"
+#include "storage/SystemCmd.h"
+#include "storage/StorageDefines.h"
+
+
+namespace storage
+{
+using namespace std;
+
+Tmpfs::Tmpfs(const TmpfsCo& d, const string& m, bool mounted ) : Volume(d,"none","none")
+ {
+ y2mil("constructed tmpfs vol mount:" << m << " mounted:" << mounted );
+ if( mounted )
+ setMount(m);
+ else
+ mp = m;
+ setFs(TMPFS);
+ is_mounted = mounted;
+ }
+
+Tmpfs::Tmpfs(const TmpfsCo& d, const xmlNode* node ) : Volume(d, node)
+ {
+ }
+
+
+Tmpfs::Tmpfs(const TmpfsCo& c, const Tmpfs& v) : Volume(c, v)
+ {
+ y2deb("copy-constructed Tmpfs from " << v.mp);
+ }
+
+Tmpfs::~Tmpfs()
+ {
+ y2deb("destructed Tmpfs for mount:" << mp);
+ }
+
+Text Tmpfs::removeText(bool doing) const
+ {
+ Text txt;
+ if( doing )
+ {
+ // displayed text during action, %1$s is replaced by path name e.g /var/run
+ txt = sformat( _("Removing Tmpfs volume from mount point %1$s"), orig_mp.c_str() );
+ }
+ else
+ {
+ // displayed text before action, %1$s is replaced by path name e.g /var/run
+ txt = sformat( _("Remove Tmpfs volume from mount point %1$s"), orig_mp.c_str() );
+ }
+ return( txt );
+ }
+
+Text Tmpfs::mountText( bool doing ) const
+ {
+ Text txt;
+ if( doing )
+ {
+ if( !mp.empty() )
+ {
+ // displayed text during action, %1$s is replaced by mount point e.g. /home
+ txt = sformat(_("Mounting tmpfs to %1$s"), mp.c_str());
+ }
+ else
+ {
+ // displayed text during action
+ txt = _("Unmounting tmpfs");
+ }
+ }
+ else
+ {
+ if( !orig_mp.empty() && !mp.empty() &&
+ (!getStorage()->instsys()||mp!=orig_mp||mp!="swap") )
+ {
+ // displayed text before action, %1$s is replaced by mount point e.g. /home
+ txt = sformat(_("Change mount point of tmpfs to %1$s"), mp.c_str());
+ }
+ else if( !mp.empty() )
+ {
+ // displayed text before action, %1$s is replaced by mount point e.g. /home
+ txt = sformat(_("Set mount point of tmpfs to %1$s"), mp.c_str());
+ }
+ else if( !orig_mp.empty() )
+ {
+ string fn = "/etc/fstab";
+ if( inCrypttab() )
+ fn = "/etc/crypttab";
+ if( inCryptotab() )
+ fn = "/etc/cryptotab";
+ // displayed text before action, %1$s is replaced by pathname e.g. /etc/fstab
+ txt = sformat(_("Remove tmpfs from %1$s"), fn.c_str());
+ }
+ }
+ return( txt );
+ }
+
+void Tmpfs::getInfo( TmpfsInfo& tinfo ) const
+ {
+ Volume::getInfo(info.v);
+ tinfo = info;
+ }
+
+std::ostream& operator<< (std::ostream& s, const Tmpfs& v )
+ {
+ s << "Tmpfs " << dynamic_cast<const Volume&>(v);
+ return( s );
+ }
+
+
+bool Tmpfs::equalContent( const Tmpfs& rhs ) const
+ {
+ return( Volume::equalContent(rhs) );
+ }
+
+
+void Tmpfs::logDifference(std::ostream& log, const Tmpfs& rhs) const
+ {
+ Volume::logDifference(log, rhs);
+ }
+
+void Tmpfs::saveData(xmlNode* node) const
+ {
+ Volume::saveData(node);
+ }
+
+}
Added: branches/SuSE-Code-11-SP2-Branch/storage/libstorage/src/Tmpfs.h
URL: http://svn.opensuse.org/viewcvs/yast/branches/SuSE-Code-11-SP2-Branch/stora…
==============================================================================
--- branches/SuSE-Code-11-SP2-Branch/storage/libstorage/src/Tmpfs.h (added)
+++ branches/SuSE-Code-11-SP2-Branch/storage/libstorage/src/Tmpfs.h Tue May 17 13:39:44 2011
@@ -0,0 +1,67 @@
+/*
+ * Copyright (c) [2004-2011] Novell, Inc.
+ *
+ * All Rights Reserved.
+ *
+ * This program is free software; you can redistribute it and/or modify it
+ * under the terms of version 2 of the GNU General Public License as published
+ * by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
+ * more details.
+ *
+ * You should have received a copy of the GNU General Public License along
+ * with this program; if not, contact Novell, Inc.
+ *
+ * To contact Novell about this file by physical or electronic mail, you may
+ * find current contact information at www.novell.com.
+ */
+
+
+#ifndef TMPFS_H
+#define TMPFS_H
+
+#include "storage/Volume.h"
+
+namespace storage
+{
+class TmpfsCo;
+class SystemInfo;
+
+
+class Tmpfs : public Volume
+ {
+ public:
+
+ Tmpfs( const TmpfsCo& d, const string& mp, bool mounted );
+ Tmpfs( const TmpfsCo& d, const Tmpfs& v );
+ Tmpfs( const TmpfsCo& d, const xmlNode* node );
+ virtual ~Tmpfs();
+
+ Text removeText( bool doing ) const;
+ Text mountText( bool doing ) const;
+
+ void saveData(xmlNode* node) const;
+ friend std::ostream& operator<< (std::ostream& s, const Tmpfs& l );
+ virtual void print( std::ostream& s ) const { s << *this; }
+ void getInfo( storage::TmpfsInfo& info ) const;
+ bool equalContent( const Tmpfs& rhs ) const;
+ void logDifference(std::ostream& log, const Tmpfs& rhs) const;
+
+ static bool notDeleted( const Tmpfs& l ) { return( !l.deleted() ); }
+
+ protected:
+ mutable storage::TmpfsInfo info; // workaround for broken ycp bindings
+
+ private:
+
+ Tmpfs& operator=(const Tmpfs& v); // disallow
+ Tmpfs(const Tmpfs&); // disallow
+
+ };
+
+}
+
+#endif
Added: branches/SuSE-Code-11-SP2-Branch/storage/libstorage/src/TmpfsCo.cc
URL: http://svn.opensuse.org/viewcvs/yast/branches/SuSE-Code-11-SP2-Branch/stora…
==============================================================================
--- branches/SuSE-Code-11-SP2-Branch/storage/libstorage/src/TmpfsCo.cc (added)
+++ branches/SuSE-Code-11-SP2-Branch/storage/libstorage/src/TmpfsCo.cc Tue May 17 13:39:44 2011
@@ -0,0 +1,230 @@
+/*
+ * Copyright (c) [2004-2011] Novell, Inc.
+ *
+ * All Rights Reserved.
+ *
+ * This program is free software; you can redistribute it and/or modify it
+ * under the terms of version 2 of the GNU General Public License as published
+ * by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
+ * more details.
+ *
+ * You should have received a copy of the GNU General Public License along
+ * with this program; if not, contact Novell, Inc.
+ *
+ * To contact Novell about this file by physical or electronic mail, you may
+ * find current contact information at www.novell.com.
+ */
+
+
+#include <ostream>
+#include <sstream>
+
+#include "storage/TmpfsCo.h"
+#include "storage/Tmpfs.h"
+#include "storage/SystemCmd.h"
+#include "storage/Dm.h"
+#include "storage/SystemInfo.h"
+#include "storage/ProcMounts.h"
+#include "storage/AppUtil.h"
+#include "storage/Storage.h"
+#include "storage/EtcFstab.h"
+#include "storage/StorageDefines.h"
+
+
+namespace storage
+{
+ using namespace std;
+
+
+TmpfsCo::TmpfsCo(Storage* s) : Container(s, "tmpfs", "/dev/tmpfs", staticType())
+ {
+ y2deb("constructing TmpfsCo");
+ }
+
+TmpfsCo::TmpfsCo(Storage* s, const EtcFstab& fstab, SystemInfo& systeminfo)
+ : Container(s, "tmpfs", "/dev/tmpfs", staticType(), systeminfo)
+ {
+ y2deb("constructing TmpfsCo");
+ getTmpfsData(fstab, systeminfo);
+ }
+
+TmpfsCo::TmpfsCo(const TmpfsCo& c) : Container(c)
+ {
+ y2deb("copy-constructed TmpfsCo from " << c.dev);
+
+ ConstTmpfsPair p = c.tmpfsPair();
+ for (ConstTmpfsIter i = p.begin(); i != p.end(); ++i)
+ {
+ Tmpfs* p = new Tmpfs(*this, *i);
+ vols.push_back(p);
+ }
+ }
+
+TmpfsCo::~TmpfsCo()
+ {
+ y2deb("destructed TmpfsCo " << dev);
+ }
+
+int TmpfsCo::addTmpfs( const string& mp, const string &opts )
+ {
+ removeTmpfs( mp, true );
+ Tmpfs* t = new Tmpfs( *this, mp, false );
+ t->setFstabOption( opts );
+ addToList( t );
+ return( 0 );
+ }
+
+int TmpfsCo::removeTmpfs( const string& mp, bool silent )
+ {
+ int ret = 0;
+ TmpfsIter tmpfs;
+ if( findTmpfs( mp, tmpfs ))
+ {
+ if( silent )
+ tmpfs->setSilent();
+ tmpfs->changeMount( "" );
+ tmpfs->setDeleted();
+ }
+ else
+ ret = TMPFS_REMOVE_NOT_FOUND;
+ return( ret );
+ }
+
+void TmpfsCo::getTmpfsData(const EtcFstab& fstab, SystemInfo& systeminfo)
+ {
+ const list<FstabEntry> l = systeminfo.getProcMounts().getEntries();
+ for (list<FstabEntry>::const_iterator i = l.begin(); i != l.end(); ++i)
+ {
+ if( i->fs == "tmpfs" )
+ {
+ y2mil( "entry:" << *i );
+ TmpfsIter tmpfs;
+ if( !findTmpfs( i->mount, tmpfs ))
+ {
+ Tmpfs *t = new Tmpfs(*this, i->mount, true);
+ if( !fstab.findMount(i->mount) )
+ t->setIgnoreFstab();
+
+ StatVfs vfsbuf;
+ getStatVfs(i->mount, vfsbuf);
+ t->setSize(vfsbuf.sizeK);
+ addToList( t );
+ y2mil( "tmpfs:" << *t );
+ }
+ }
+ }
+ }
+
+int TmpfsCo::removeVolume( Volume* v, bool quiet )
+ {
+ int ret = 0;
+ y2mil("qiet:" << quiet);
+ y2mil("vol:" << *v);
+ v->setDeleted();
+ if( quiet )
+ v->setSilent();
+ y2mil("ret:" << ret);
+ return( ret );
+ }
+
+int TmpfsCo::removeVolume( Volume* v )
+ {
+ return( removeVolume( v, false ));
+ }
+
+int
+TmpfsCo::doRemove( Volume* v )
+ {
+ int ret = 0;
+ Tmpfs *b = dynamic_cast<Tmpfs *>(v);
+ if( b != NULL )
+ {
+ if( !silent )
+ {
+ getStorage()->showInfoCb( b->removeText(true) );
+ }
+ ret = v->prepareRemove();
+ if( ret==0 && !removeFromList(v) )
+ ret = TMPFS_REMOVE_NO_TMPFS;
+ }
+ else
+ ret = TMPFS_REMOVE_INVALID_VOLUME;
+ y2mil("ret:" << ret);
+ return( ret );
+ }
+
+bool TmpfsCo::findTmpfs( const string& mp, TmpfsIter& i )
+ {
+ TmpfsPair p=tmpfsPair(Tmpfs::notDeleted);
+ i=p.begin();
+ while( i!=p.end() && i->getMount()!=mp )
+ ++i;
+ y2mil( "mp:" << mp << " ret:" << (i!=p.end()) );
+ return( i!=p.end() );
+ }
+
+
+void
+TmpfsCo::logData(const string& Dir) const
+ {
+ string fname(Dir + "/tmpfs.info.tmp");
+
+ XmlFile xml;
+ xmlNode* node = xmlNewNode("tmpfs");
+ xml.setRootElement(node);
+ saveData(node);
+ xml.save(fname);
+
+ getStorage()->handleLogFile( fname );
+ }
+
+void
+TmpfsCo::saveData(xmlNode* node) const
+ {
+ Container::saveData(node);
+ ConstTmpfsPair vp = tmpfsPair();
+ for (ConstTmpfsIter v = vp.begin(); v != vp.end(); ++v)
+ v->saveData(xmlNewChild(node, "tmpfs"));
+ }
+
+
+std::ostream& operator<<(std::ostream& s, const TmpfsCo& d)
+ {
+ s << dynamic_cast<const Container&>(d);
+ return( s );
+ }
+
+
+void TmpfsCo::logDifferenceWithVolumes(std::ostream& log, const Container& rhs_c) const
+ {
+ const TmpfsCo& rhs = dynamic_cast<const TmpfsCo&>(rhs_c);
+
+ logDifference(log, rhs);
+ log << endl;
+
+ ConstTmpfsPair pp = tmpfsPair();
+ ConstTmpfsPair pc = rhs.tmpfsPair();
+ logVolumesDifference(log, pp.begin(), pp.end(), pc.begin(), pc.end());
+ }
+
+
+bool TmpfsCo::equalContent( const Container& rhs ) const
+ {
+ const TmpfsCo * p = NULL;
+ bool ret = Container::equalContent(rhs);
+ if( ret )
+ p = dynamic_cast<const TmpfsCo*>(&rhs);
+ if( ret && p )
+ {
+ ConstTmpfsPair pp = tmpfsPair();
+ ConstTmpfsPair pc = p->tmpfsPair();
+ ret = ret && storage::equalContent(pp.begin(), pp.end(), pc.begin(), pc.end());
+ }
+ return( ret );
+ }
+
+}
Added: branches/SuSE-Code-11-SP2-Branch/storage/libstorage/src/TmpfsCo.h
URL: http://svn.opensuse.org/viewcvs/yast/branches/SuSE-Code-11-SP2-Branch/stora…
==============================================================================
--- branches/SuSE-Code-11-SP2-Branch/storage/libstorage/src/TmpfsCo.h (added)
+++ branches/SuSE-Code-11-SP2-Branch/storage/libstorage/src/TmpfsCo.h Tue May 17 13:39:44 2011
@@ -0,0 +1,126 @@
+/*
+ * Copyright (c) [2004-2011] Novell, Inc.
+ *
+ * All Rights Reserved.
+ *
+ * This program is free software; you can redistribute it and/or modify it
+ * under the terms of version 2 of the GNU General Public License as published
+ * by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
+ * more details.
+ *
+ * You should have received a copy of the GNU General Public License along
+ * with this program; if not, contact Novell, Inc.
+ *
+ * To contact Novell about this file by physical or electronic mail, you may
+ * find current contact information at www.novell.com.
+ */
+
+
+#ifndef TMPFS_CO_H
+#define TMPFS_CO_H
+
+#include "storage/Container.h"
+#include "storage/Tmpfs.h"
+
+
+namespace storage
+{
+ class SystemInfo;
+
+
+class TmpfsCo : public Container
+ {
+ friend class Storage;
+
+ public:
+
+ TmpfsCo(Storage * const s);
+ TmpfsCo(Storage * const s, const EtcFstab& fstab, SystemInfo& systeminfo);
+ TmpfsCo(const TmpfsCo& c);
+ virtual ~TmpfsCo();
+
+ int addTmpfs( const string& mp, const string &opts );
+ int removeTmpfs( const string& mp, bool silent=false );
+
+ int doRemove( Volume* v );
+
+ static storage::CType staticType() { return storage::TMPFSC; }
+ friend std::ostream& operator<< (std::ostream&, const TmpfsCo& );
+
+ int removeVolume( Volume* v );
+ int removeVolume( Volume* v, bool quiet );
+ bool equalContent( const Container& rhs ) const;
+ void saveData(xmlNode* node) const;
+
+ virtual void logDifferenceWithVolumes(std::ostream& log, const Container& rhs) const;
+ virtual void logData(const string& Dir) const;
+
+
+ protected:
+ // iterators over TMPFS volumes
+ // protected typedefs for iterators over TMPFS volumes
+ typedef CastIterator<VIter, Tmpfs *> TmpfsInter;
+ typedef CastIterator<CVIter, const Tmpfs *> TmpfsCInter;
+ template< class Pred >
+ struct TmpfsPI { typedef ContainerIter<Pred, TmpfsInter> type; };
+ template< class Pred >
+ struct TmpfsCPI { typedef ContainerIter<Pred, TmpfsCInter> type; };
+ typedef CheckFnc<const Tmpfs> CheckFncTmpfs;
+ typedef CheckerIterator< CheckFncTmpfs, TmpfsPI<CheckFncTmpfs>::type,
+ TmpfsInter, Tmpfs > TmpfsPIterator;
+ typedef CheckerIterator< CheckFncTmpfs, TmpfsCPI<CheckFncTmpfs>::type,
+ TmpfsCInter, const Tmpfs > TmpfsCPIterator;
+ typedef DerefIterator<TmpfsPIterator,Tmpfs> TmpfsIter;
+ typedef DerefIterator<TmpfsCPIterator,const Tmpfs> ConstTmpfsIter;
+ typedef IterPair<TmpfsIter> TmpfsPair;
+ typedef IterPair<ConstTmpfsIter> ConstTmpfsPair;
+
+ TmpfsPair tmpfsPair( bool (* Check)( const Tmpfs& )=NULL)
+ {
+ return( TmpfsPair( tmpfsBegin( Check ), tmpfsEnd( Check ) ));
+ }
+ TmpfsIter tmpfsBegin( bool (* Check)( const Tmpfs& )=NULL)
+ {
+ IterPair<TmpfsInter> p( (TmpfsInter(begin())), (TmpfsInter(end())) );
+ return( TmpfsIter( TmpfsPIterator( p, Check )) );
+ }
+ TmpfsIter tmpfsEnd( bool (* Check)( const Tmpfs& )=NULL)
+ {
+ IterPair<TmpfsInter> p( (TmpfsInter(begin())), (TmpfsInter(end())) );
+ return( TmpfsIter( TmpfsPIterator( p, Check, true )) );
+ }
+
+ ConstTmpfsPair tmpfsPair( bool (* Check)( const Tmpfs& )=NULL) const
+ {
+ return( ConstTmpfsPair( tmpfsBegin( Check ), tmpfsEnd( Check ) ));
+ }
+ ConstTmpfsIter tmpfsBegin( bool (* Check)( const Tmpfs& )=NULL) const
+ {
+ IterPair<TmpfsCInter> p( (TmpfsCInter(begin())), (TmpfsCInter(end())) );
+ return( ConstTmpfsIter( TmpfsCPIterator( p, Check )) );
+ }
+ ConstTmpfsIter tmpfsEnd( bool (* Check)( const Tmpfs& )=NULL) const
+ {
+ IterPair<TmpfsCInter> p( (TmpfsCInter(begin())), (TmpfsCInter(end())) );
+ return( ConstTmpfsIter( TmpfsCPIterator( p, Check, true )) );
+ }
+
+ void getTmpfsData(const EtcFstab& fstab, SystemInfo& systeminfo);
+ bool findTmpfs( const string& mp, TmpfsIter& i );
+
+ virtual void print( std::ostream& s ) const { s << *this; }
+ virtual Container* getCopy() const { return( new TmpfsCo( *this ) ); }
+
+ private:
+
+ TmpfsCo& operator=(const TmpfsCo&); // disallow
+
+ };
+
+}
+
+#endif
Modified: branches/SuSE-Code-11-SP2-Branch/storage/libstorage/src/Volume.cc
URL: http://svn.opensuse.org/viewcvs/yast/branches/SuSE-Code-11-SP2-Branch/stora…
==============================================================================
--- branches/SuSE-Code-11-SP2-Branch/storage/libstorage/src/Volume.cc (original)
+++ branches/SuSE-Code-11-SP2-Branch/storage/libstorage/src/Volume.cc Tue May 17 13:39:44 2011
@@ -1,5 +1,5 @@
/*
- * Copyright (c) [2004-2009] Novell, Inc.
+ * Copyright (c) [2004-2010] Novell, Inc.
*
* All Rights Reserved.
*
@@ -19,66 +19,192 @@
* find current contact information at www.novell.com.
*/
-/*
- Textdomain "storage"
-*/
-
-#include <sstream>
#include <features.h>
#include <sys/stat.h>
+#include <sstream>
+#include <fstream>
+
+#include "storage/Volume.h"
+#include "storage/Disk.h"
+#include "storage/Storage.h"
+#include "storage/StorageTypes.h"
+#include "storage/Container.h"
+#include "storage/AppUtil.h"
+#include "storage/Blkid.h"
+#include "storage/SystemCmd.h"
+#include "storage/ProcMounts.h"
+#include "storage/ProcParts.h"
+#include "storage/OutputProcessor.h"
+#include "storage/EtcFstab.h"
+#include "storage/StorageDefines.h"
+
+
+namespace storage
+{
+ using namespace std;
+
+
+ Volume::Volume(const Container& c, unsigned PNr, unsigned long long SizeK)
+ : Device("", ""), cont(&c), numeric(true), num(PNr)
+ {
+ size_k = orig_size_k = SizeK;
+ init();
+ y2deb("constructed Volume " << ((num>0)?dev:"") << " on " << cont->device());
+ }
+
+
+ Volume::Volume(const Container& c, const string& name, const string& device)
+ : Device(name, device), cont(&c), numeric(false), format(false),
+ fstab_added(false), fs(FSUNKNOWN), detected_fs(FSUNKNOWN),
+ mount_by(MOUNTBY_DEVICE), orig_mount_by(MOUNTBY_DEVICE),
+ is_loop(false), is_mounted(false), ignore_fstab(false),
+ ignore_fs(false), loop_active(false), dmcrypt_active(false),
+ ronly(false), encryption(ENC_NONE), orig_encryption(ENC_NONE),
+ num(0), orig_size_k(0)
+ {
+ y2deb("constructed Volume " << dev << " on " << cont->device());
+
+ mount_by = orig_mount_by = defaultMountBy();
+
+ assert(!nm.empty() && !dev.empty());
+ }
+
+
+ Volume::Volume(const Container& c, const string& name, const string& device,
+ SystemInfo& systeminfo)
+ : Device(name, device, systeminfo), cont(&c), numeric(false),
+ format(false), fstab_added(false), fs(FSUNKNOWN),
+ detected_fs(FSUNKNOWN), mount_by(MOUNTBY_DEVICE),
+ orig_mount_by(MOUNTBY_DEVICE), is_loop(false), is_mounted(false),
+ ignore_fstab(false), ignore_fs(false), loop_active(false),
+ dmcrypt_active(false), ronly(false), encryption(ENC_NONE),
+ orig_encryption(ENC_NONE), num(0), orig_size_k(0)
+ {
+ y2deb("constructed Volume " << dev << " on " << cont->device());
+
+ mount_by = orig_mount_by = defaultMountBy();
+
+ assert(!nm.empty() && !dev.empty());
+ assert(!getStorage()->testmode());
+ }
+
+
+ /* This is our constructor for Volume used during fake detection in
+ testmode. This is recognisable by the fact that it has an parameter of
+ type xmlNode. */
+ Volume::Volume(const Container& c, const xmlNode* node)
+ : Device(node), cont(&c), numeric(false), format(false),
+ fstab_added(false), fs(FSUNKNOWN), detected_fs(FSUNKNOWN),
+ mount_by(MOUNTBY_DEVICE), orig_mount_by(MOUNTBY_DEVICE),
+ is_loop(false), is_mounted(false), ignore_fstab(false),
+ ignore_fs(false), loop_active(false), dmcrypt_active(false),
+ ronly(false), encryption(ENC_NONE), orig_encryption(ENC_NONE),
+ num(0), orig_size_k(0)
+ {
+ string tmp;
+
+ getChildValue(node, "numeric", numeric);
+ getChildValue(node, "number", num);
+
+ if (getChildValue(node, "fs_type", tmp))
+ fs = detected_fs = toValueWithFallback(tmp, FSUNKNOWN);
+ if (getChildValue(node, "fs_uuid", uuid))
+ orig_uuid = uuid;
+ if (getChildValue(node, "fs_label", label))
+ orig_label = label;
+ if (getChildValue(node, "mount", mp))
+ orig_mp = mp;
+ if (getChildValue(node, "mount_by", tmp))
+ mount_by = orig_mount_by = toValueWithFallback(tmp, MOUNTBY_DEVICE);
+ if (getChildValue(node, "fstopt", fstab_opt))
+ orig_fstab_opt = fstab_opt;
-#include "y2storage/Volume.h"
-#include "y2storage/Disk.h"
-#include "y2storage/LoopCo.h"
-#include "y2storage/Storage.h"
-#include "y2storage/StorageTypes.h"
-#include "y2storage/Container.h"
-#include "y2storage/AppUtil.h"
-#include "y2storage/SystemCmd.h"
-#include "y2storage/ProcMounts.h"
-#include "y2storage/ProcPart.h"
-#include "y2storage/OutputProcessor.h"
-#include "y2storage/EtcFstab.h"
-#include "y2storage/StorageDefines.h"
-
-using namespace std;
-using namespace storage;
-
-Volume::Volume( const Container& d, unsigned PNr, unsigned long long SizeK )
- : cont(&d)
- {
- numeric = true;
- num = PNr;
- size_k = orig_size_k = SizeK;
- init();
- y2debug( "constructed volume %s on disk %s", (num>0)?dev.c_str():"",
- cont->name().c_str() );
- }
-
-Volume::Volume( const Container& c, const string& Name, unsigned long long SizeK ) : cont(&c)
- {
- numeric = false;
- nm = Name;
- size_k = orig_size_k = SizeK;
- init();
- y2debug( "constructed volume \"%s\" on disk %s", dev.c_str(),
- cont->name().c_str() );
- }
-
-Volume::Volume( const Container& c ) : cont(&c)
- {
- numeric = false;
- size_k = orig_size_k = 0;
- init();
- y2deb("constructed late init volume");
+ if (getChildValue(node, "encryption", tmp))
+ encryption = orig_encryption = toValueWithFallback(tmp, ENC_UNKNOWN);
+ if (getChildValue(node, "password", crypt_pwd))
+ orig_crypt_pwd = crypt_pwd;
+
+ orig_size_k = size_k;
+
+ y2deb("constructed Volume " << dev);
+
+ assert(getStorage()->testmode());
+ }
+
+
+ /* This is our copy-constructor for Volumes. Every class derived from
+ Volume needs an equivalent one. It takes a Container as extra argument
+ since the newly created Volume can belong to a different Container than
+ the original Volume. */
+ Volume::Volume(const Container&c, const Volume&v)
+ : Device(v), cont(&c), numeric(v.numeric), format(v.format),
+ fstab_added(v.fstab_added), fs(v.fs), detected_fs(v.detected_fs),
+ mount_by(v.mount_by), orig_mount_by(v.orig_mount_by), uuid(v.uuid),
+ orig_uuid(v.orig_uuid),
+ label(v.label), orig_label(v.orig_label), mp(v.mp),
+ orig_mp(v.orig_mp), fstab_opt(v.fstab_opt),
+ orig_fstab_opt(v.orig_fstab_opt), mkfs_opt(v.mkfs_opt),
+ tunefs_opt(v.tunefs_opt), is_loop(v.is_loop),
+ is_mounted(v.is_mounted), ignore_fstab(v.ignore_fstab),
+ ignore_fs(v.ignore_fs), loop_active(v.loop_active),
+ dmcrypt_active(v.dmcrypt_active), ronly(v.ronly),
+ encryption(v.encryption), orig_encryption(v.orig_encryption),
+ loop_dev(v.loop_dev), dmcrypt_dev(v.dmcrypt_dev),
+ fstab_loop_dev(v.fstab_loop_dev),
+ crypt_pwd(v.crypt_pwd), orig_crypt_pwd(v.orig_crypt_pwd),
+ num(v.num), orig_size_k(v.orig_size_k), dtxt(v.dtxt)
+ {
+ y2deb("copy-constructed Volume " << dev);
+ }
+
+
+ Volume::~Volume()
+ {
+ y2deb("destructed Volume " << dev);
+ }
+
+
+ void
+ Volume::saveData(xmlNode* node) const
+ {
+ Device::saveData(node);
+
+ setChildValue(node, "numeric", numeric);
+ if (numeric)
+ setChildValue(node, "number", num);
+
+ if (fs != FSUNKNOWN)
+ {
+ setChildValue(node, "fs_type", toString(fs));
+ if (!uuid.empty())
+ setChildValue(node, "fs_uuid", uuid);
+ if (!label.empty())
+ setChildValue(node, "fs_label", label);
+ if (!mp.empty())
+ setChildValue(node, "mount", mp);
+ if (mount_by != MOUNTBY_DEVICE)
+ setChildValue(node, "mount_by", toString(mount_by));
+ if (!fstab_opt.empty())
+ setChildValue(node, "fstopt", fstab_opt);
+ }
+
+ if (encryption != ENC_NONE)
+ setChildValue(node, "encryption", toString(encryption));
+#ifdef DEBUG_CRYPT_PASSWORD
+ if (encryption != ENC_NONE && !crypt_pwd.empty())
+ setChildValue(node, "password", crypt_pwd);
+#endif
}
-Volume::~Volume()
+
+ Storage*
+ Volume::getStorage() const
{
- y2deb("destructed volume " << dev);
+ return cont->getStorage();
}
+
void Volume::setNameDev()
{
std::ostringstream Buf_Ci;
@@ -103,20 +229,13 @@
void Volume::setDmcryptDevEnc( const string& dm, storage::EncryptType typ, bool active )
{
- y2mil( "dev:" << dev << " dm:" << dm << " type:" << typ << " active:" << active );
+ y2mil("dev:" << dev << " dm:" << dm << " enc_type:" << toString(typ) << " active:" << active);
dmcrypt_dev = dm;
encryption = orig_encryption = typ;
dmcrypt_active = active;
y2mil( "this:" << *this );
}
-bool Volume::sameDevice( const string& device ) const
- {
- string d = normalizeDevice(device);
- return( d==dev ||
- find( alt_names.begin(), alt_names.end(), d )!=alt_names.end() );
- }
-
const string& Volume::mountDevice() const
{
if( dmcrypt() && !dmcrypt_dev.empty() )
@@ -126,64 +245,71 @@
}
-storage::MountByType
-Volume::defaultMountBy(const string& mp)
+MountByType
+Volume::defaultMountBy() const
{
- MountByType mb = cont->getStorage()->getDefaultMountBy();
- y2mil( "mby:" << mb_names[mb] << " type:" << cType() );
- if ((cType() != DISK && cType() != DMRAID && cType() != DMMULTIPATH && cType() != MDPART) &&
- (mb == MOUNTBY_ID || mb == MOUNTBY_PATH))
- mb = MOUNTBY_DEVICE;
- if (cType() == NFSC && mb != MOUNTBY_DEVICE)
- mb = MOUNTBY_DEVICE;
- y2mil( "path:" << udevPath() << " id:" << udevId() );
- if( (mb==MOUNTBY_PATH && udevPath().empty()) ||
- (mb==MOUNTBY_ID && udevId().empty()) )
- mb = MOUNTBY_DEVICE;
- if( encryption != ENC_NONE &&
- (mb==MOUNTBY_UUID || mb==MOUNTBY_LABEL) )
- mb = MOUNTBY_DEVICE;
- y2mil( "dev:" << dev << " mp:" << mp << " mby:" << mb_names[mb] );
- return mb;
+ MountByType mby = getStorage()->getDefaultMountBy();
+
+ if (!allowedMountBy(mby))
+ mby = MOUNTBY_DEVICE;
+
+ y2mil("dev:" << dev << " ctype:" << toString(cType()) << " ret:" << toString(mby));
+ return mby;
}
-// TODO: allowedMountBy is never used
bool
-Volume::allowedMountBy(storage::MountByType mby, const string& mp)
+Volume::allowedMountBy(MountByType mby) const
{
bool ret = true;
- if ((cType() != DISK && cType() != DMRAID && cType() != DMMULTIPATH && cType() != MDPART)
- && (mby == MOUNTBY_ID || mby == MOUNTBY_PATH))
- ret = false;
- if (cType() == NFSC && mby != MOUNTBY_DEVICE)
- ret = false;
- if( (mby==MOUNTBY_PATH && udevPath().empty()) ||
- (mby==MOUNTBY_ID && udevId().empty()) )
- ret = false;
- if( ret && encryption != ENC_NONE &&
- (mby==MOUNTBY_UUID || mby==MOUNTBY_LABEL) )
- ret = false;
- y2mil( "mby:" << mb_names[mby] << " mp:" << mp << " ret:" << ret );
+
+ switch (mby)
+ {
+ case MOUNTBY_PATH:
+ if (cType() != DISK)
+ ret = false;
+ if (udevPath().empty())
+ ret = false;
+ break;
+
+ case MOUNTBY_ID:
+ if (cType() != DISK && cType() != DMRAID && cType() != DMMULTIPATH && cType() != MD && cType() != MDPART)
+ ret = false;
+ if (udevId().empty() && cType() != MD)
+ ret = false;
+ break;
+
+ case MOUNTBY_UUID:
+ case MOUNTBY_LABEL:
+ if (cType() == NFSC)
+ ret = false;
+ if (encryption != ENC_NONE)
+ ret = false;
+ break;
+
+ case MOUNTBY_DEVICE:
+ break;
+ }
+
+ y2mil("dev:" << dev << " ctype:" << toString(cType()) << " mby:" << toString(mby) <<
+ " ret:" << ret);
return ret;
}
void Volume::init()
{
- del = create = format = is_loop = loop_active = silnt = false;
+ format = is_loop = loop_active = false;
is_mounted = ronly = fstab_added = ignore_fstab = ignore_fs = false;
dmcrypt_active = false;
detected_fs = fs = FSUNKNOWN;
encryption = orig_encryption = ENC_NONE;
- mjr = mnr = 0;
if( numeric||!nm.empty() )
{
setNameDev();
- getMajorMinor( dev, mjr, mnr );
+ if (!getStorage()->testmode() && cType()!=NFSC)
+ getMajorMinor();
}
- if( !numeric )
- num = 0;
mount_by = orig_mount_by = defaultMountBy();
}
@@ -214,26 +340,12 @@
return( !del );
}
-bool Volume::getMajorMinor( const string& device,
- unsigned long& Major, unsigned long& Minor )
- {
- bool ret = false;
- string dev = normalizeDevice( device );
- struct stat sbuf;
- if( stat( dev.c_str(), &sbuf )==0 )
- {
- Minor = gnu_dev_minor( sbuf.st_rdev );
- Major = gnu_dev_major( sbuf.st_rdev );
- ret = true;
- }
- return( ret );
- }
void Volume::getFsInfo( const Volume* source )
{
setFs( source->getFs() );
setFormat( source->getFormat(), source->getFs() );
- setUuid( source->getUuid() );
+ initUuid( source->getUuid() );
initLabel( source->getLabel() );
}
@@ -241,7 +353,7 @@
{
FstabEntry entry;
bool found = false;
- if( cont->type()==LOOP )
+ if( cType()==LOOP )
{
Loop* l = static_cast<Loop*>(this);
found = fstabData.findDevice( l->loopFile(), entry );
@@ -264,10 +376,15 @@
fstabData.setDevice( entry, device() );
}
}
+
if( !found && !mp.empty() )
{
found = fstabData.findMount( mp, entry );
}
+ if (!found && !mp.empty())
+ {
+ setIgnoreFstab(true);
+ }
if( found )
{
std::ostringstream b;
@@ -282,62 +399,51 @@
mount_by = orig_mount_by = entry.mount_by;
if( mount_by != MOUNTBY_DEVICE )
{
- b << " mountby:" << mb_names[mount_by];
+ b << " mountby:" << toString(mount_by);
}
- fstab_opt = orig_fstab_opt = mergeString( entry.opts, "," );
+ fstab_opt = orig_fstab_opt = boost::join( entry.opts, "," );
b << " fstopt:" << fstab_opt;
if( !is_loop && entry.loop )
{
is_loop = true;
orig_encryption = encryption = entry.encr;
loop_dev = fstab_loop_dev = entry.loop_dev;
- b << " loop_dev:" << loop_dev << " encr:" << enc_names[encryption];
+ b << " loop_dev:" << loop_dev << " encr:" << toString(encryption);
}
y2mil(b.str());
}
}
-void Volume::getStartData()
+void Volume::getMountData( const ProcMounts& mounts, bool swap_only )
{
- if( fs==FSUNKNOWN && encryption==ENC_NONE )
+ if( fs != TMPFS )
{
- char buf[10];
- ifstream file( dev.c_str() );
- classic(file);
- file.read( buf, sizeof(buf) );
- if( file.good() && strncmp( buf, "LUKS", 4 )==0 )
- initEncryption( ENC_LUKS );
- file.close();
- }
- }
-
-void Volume::getMountData( const ProcMounts& mountData, bool swap_only )
- {
- y2mil( "this:" << *this );
- y2mil( "swap_only:" << swap_only << " mountDevice:" << mountDevice() );
- mp = mountData.getMount( mountDevice() );
- if( mp.empty() )
- {
- mp = mountData.getMount( alt_names );
- }
- if( !mp.empty() )
- {
- is_mounted = true;
- if( swap_only && mp!="swap" )
+ y2mil( "this:" << *this );
+ y2mil( "swap_only:" << swap_only << " mountDevice:" << mountDevice() );
+ mp = mounts.getMount(mountDevice());
+ if( mp.empty() )
{
- is_mounted = false;
- mp.clear();
+ mp = mounts.getMount(alt_names);
}
- if( is_mounted )
- y2milestone( "%s mounted on %s", device().c_str(), mp.c_str() );
+ if( !mp.empty() )
+ {
+ is_mounted = true;
+ if( swap_only && mp!="swap" )
+ {
+ is_mounted = false;
+ mp.clear();
+ }
+ if( is_mounted )
+ y2mil(device() << " mounted on " << mp);
+ }
+ orig_mp = mp;
}
- orig_mp = mp;
}
void Volume::getLoopData( SystemCmd& loopData )
{
bool found = false;
- if( cont->type()==LOOP )
+ if( cType()==LOOP )
{
if( !dmcrypt() )
{
@@ -360,7 +466,7 @@
}
if( found )
{
- list<string> l = splitString( *loopData.getLine( 0, true ));
+ list<string> l = splitString( loopData.getLine( 0, true ));
std::ostringstream b;
classic(b);
b << "line[" << device() << "]=" << l;
@@ -393,156 +499,104 @@
orig_encryption = encryption = ENC_UNKNOWN;
}
}
- b << " encr:" << encryption;
+ b << " encr:" << toString(encryption);
y2mil(b.str());
}
}
}
-void Volume::getFsData( SystemCmd& blkidData )
+
+bool
+Volume::findBlkid( const Blkid& blkid, Blkid::Entry& entry )
{
- bool found = blkidData.select( "^" + mountDevice() + ":" )>0;
- if( !found && !is_loop )
+ bool found = blkid.getEntry(mountDevice(), entry);
+ if (!found && !is_loop)
{
list<string>::const_iterator an = alt_names.begin();
- while( !found && an!=alt_names.end() )
+ while (!found && an != alt_names.end())
{
- found = blkidData.select( "^" + *an + ":" )>0;
+ found = blkid.getEntry(*an, entry);
++an;
}
}
- if( found )
+ return( found );
+ }
+
+
+ void
+ Volume::getFsData(const Blkid& blkid, bool setUsedByLvm )
+ {
+ Blkid::Entry entry;
+
+ if( findBlkid( blkid, entry ))
{
- list<string> l = splitString( *blkidData.getLine( 0, true ), " \t\n",
- true, true, "\"" );
- std::ostringstream b;
- classic(b);
- b << "line[" << device() << "]=" << l;
- y2mil(b.str());
- if( !l.empty() )
+ y2mil("device:" << device() << " mountDevice:" << mountDevice() << " entry:" << entry);
+
+ if (entry.is_fs)
{
- l.pop_front();
- map<string,string> m = makeMap( l, "=", "\"" );
- map<string,string>::const_iterator i = m.find( "TYPE" );
- b.str("");
- if( i !=m.end() )
- {
- if( i->second == "reiserfs" )
- {
- fs = REISERFS;
- }
- else if( i->second == "swap" )
- {
- fs = SWAP;
- }
- else if( i->second == "ext2" )
- {
- fs = (m["SEC_TYPE"]=="ext3")?EXT3:EXT2;
- }
- else if( i->second == "ext3" )
- {
- fs = EXT3;
- }
- else if( i->second == "vfat" )
- {
- fs = VFAT;
- }
- else if( i->second == "ntfs" )
- {
- fs = NTFS;
- }
- else if( i->second == "jfs" )
- {
- fs = JFS;
- }
- else if( i->second == "hfs" )
- {
- fs = HFS;
- }
- else if( i->second == "hfsplus" )
- {
- fs = HFSPLUS;
- }
- else if( i->second == "xfs" )
- {
- fs = XFS;
- }
- else if( i->second == "(null)" )
- {
- fs = FSNONE;
- }
- detected_fs = fs;
- b << "fs:" << fs_names[fs];
- }
- i = m.find( "UUID" );
- if( i != m.end() )
+ detected_fs = fs = entry.fs_type;
+
+ if (!entry.fs_uuid.empty())
{
- uuid = i->second;
- b << " uuid:" << uuid;
- list<string>::iterator i = find_if( alt_names.begin(),
- alt_names.end(),
- find_any( "/by-uuid/" ) );
- if( i!=alt_names.end() )
- {
- alt_names.erase(i);
- }
- alt_names.push_back( "/dev/disk/by-uuid/" + uuid );
+ uuid = entry.fs_uuid;
+ alt_names.remove_if(string_contains("/by-uuid/"));
+ alt_names.push_back("/dev/disk/by-uuid/" + uuid);
}
- i = m.find( "LABEL" );
- if( i != m.end() )
+
+ if (!entry.fs_label.empty())
{
- // ignore label for hfs since we cannot set it (bnc #447782)
- if (fs != HFS)
- label = orig_label = i->second;
- b << " label:\"" << label << "\"";
- list<string>::iterator i = find_if( alt_names.begin(),
- alt_names.end(),
- find_any( "/by-label/" ) );
- if( i!=alt_names.end() )
- {
- alt_names.erase(i);
- }
- alt_names.push_back( "/dev/disk/by-label/" + label );
+ // ignore label for hfs since we cannot set it (bnc #447782)
+ if (entry.fs_type != HFS)
+ label = orig_label = entry.fs_label;
+ alt_names.remove_if(string_contains("/by-label/"));
+ if (!label.empty())
+ alt_names.push_back("/dev/disk/by-label/" + udevEncode(label));
}
- y2mil(b.str());
+ }
+ if (setUsedByLvm && entry.is_lvm)
+ {
+ setUsedBy(UB_LVM,"");
+
}
}
}
+
int Volume::setFormat( bool val, storage::FsType new_fs )
{
int ret = 0;
- y2milestone( "device:%s val:%d fs:%s", dev.c_str(), val,
- fs_names[new_fs].c_str() );
+ y2mil("device:" << dev << " val:" << val << " fs:" << toString(new_fs));
format = val;
if( !format )
{
fs = detected_fs;
mkfs_opt = "";
tunefs_opt = "";
+ if( label.empty() && !orig_label.empty() )
+ label = orig_label;
+ if( uuid.empty() && !orig_uuid.empty() )
+ uuid = orig_uuid;
}
else
{
FsCapabilities caps;
- if( uby.type() != UB_NONE )
+ if (isUsedBy())
{
ret = VOLUME_ALREADY_IN_USE;
}
- else if( cont->getStorage()->getFsCapabilities( new_fs, caps ) &&
- caps.minimalFsSizeK > size_k )
+ else if (getStorage()->getFsCapabilities(new_fs, caps) && caps.minimalFsSizeK > size_k)
{
ret = VOLUME_FORMAT_FS_TOO_SMALL;
}
- else if( new_fs == NFS )
+ else if( new_fs == NFS || new_fs == NFS4 || new_fs == TMPFS )
{
- ret = VOLUME_FORMAT_NFS_IMPOSSIBLE;
+ ret = VOLUME_FORMAT_IMPOSSIBLE;
}
else
{
fs = new_fs;
FsCapabilities caps;
- if( !cont->getStorage()->getFsCapabilities( fs, caps ) ||
- !caps.supportsLabel )
+ if (!getStorage()->getFsCapabilities(fs, caps) || !caps.supportsLabel)
{
eraseLabel();
}
@@ -568,7 +622,7 @@
{
ret = VOLUME_MOUNT_POINT_INVALID;
}
- else if( uby.type() != UB_NONE )
+ else if (isUsedBy())
{
ret = VOLUME_ALREADY_IN_USE;
}
@@ -578,7 +632,7 @@
if( m.empty() )
{
orig_fstab_opt = fstab_opt = "";
- orig_mount_by = mount_by = defaultMountBy(m);
+ orig_mount_by = mount_by = defaultMountBy();
}
/*
else
@@ -594,9 +648,9 @@
Volume::changeMountBy(MountByType mby)
{
int ret = 0;
- y2mil("device:" << dev << " mby:" << mbyTypeString(mby));
+ y2mil("device:" << dev << " mby:" << toString(mby));
y2mil( "vorher:" << *this );
- if( uby.type() != UB_NONE )
+ if (isUsedBy())
{
ret = VOLUME_ALREADY_IN_USE;
}
@@ -607,17 +661,15 @@
FsCapabilities caps;
if( encryption != ENC_NONE )
ret = VOLUME_MOUNTBY_NOT_ENCRYPTED;
- else if( !cont->getStorage()->getFsCapabilities( fs, caps ) ||
+ else if( !getStorage()->getFsCapabilities( fs, caps ) ||
(mby==MOUNTBY_LABEL && !caps.supportsLabel) ||
(mby==MOUNTBY_UUID && !caps.supportsUuid))
{
ret = VOLUME_MOUNTBY_UNSUPPORTED_BY_FS;
}
}
- else if( mby == MOUNTBY_ID || mby == MOUNTBY_PATH )
+ else if (!allowedMountBy(mby))
{
- // TODO: why not use allowedMountBy()?
- if (cType() != DISK && cType() != DMRAID && cType() != DMMULTIPATH && cType() != MDPART)
ret = VOLUME_MOUNTBY_UNSUPPORTED_BY_VOLUME;
}
if( ret==0 )
@@ -630,19 +682,19 @@
}
-void Volume::updateFstabOptions()
+ void
+ Volume::updateFstabOptions()
{
- list<string> l;
- getFstabOpts( l );
- fstab_opt = mergeString( l, "," );
+ list<string> l = getFstabOpts();
+ fstab_opt = boost::join(l, ",");
}
+
int Volume::changeFstabOptions( const string& options )
{
int ret = 0;
- y2milestone( "device:%s options:%s encr:%s", dev.c_str(), options.c_str(),
- encTypeString(encryption).c_str() );
- if( uby.type() != UB_NONE )
+ y2mil("device:" << dev << " options:" << options << " encr:" << toString(encryption));
+ if (isUsedBy())
{
ret = VOLUME_ALREADY_IN_USE;
}
@@ -655,17 +707,16 @@
return( ret );
}
-string Volume::formatText( bool doing ) const
+Text Volume::formatText( bool doing ) const
{
- string txt;
- string d = dev;
+ Text txt;
if( doing )
{
// displayed text during action, %1$s is replaced by device name e.g. /dev/hda1
// %2$s is replaced by size (e.g. 623.5 MB)
// %3$s is replaced by file system type (e.g. reiserfs)
- txt = sformat( _("Formatting device %1$s (%2$s) with %3$s "),
- d.c_str(), sizeString().c_str(), fsTypeString().c_str() );
+ txt = sformat(_("Formatting device %1$s (%2$s) with %3$s"), dev.c_str(),
+ sizeString().c_str(), fsTypeString().c_str());
}
else
{
@@ -677,9 +728,9 @@
// %2$s is replaced by size (e.g. 623.5 MB)
// %3$s is replaced by file system type (e.g. reiserfs)
// %4$s is replaced by mount point (e.g. /usr)
- txt = sformat( _("Format device %1$s (%2$s) for %4$s with %3$s"),
- d.c_str(), sizeString().c_str(), fsTypeString().c_str(),
- mp.c_str() );
+ txt = sformat(_("Format device %1$s (%2$s) for %4$s with %3$s"),
+ dev.c_str(), sizeString().c_str(), fsTypeString().c_str(),
+ mp.c_str());
}
else
{
@@ -687,9 +738,9 @@
// %2$s is replaced by size (e.g. 623.5 MB)
// %3$s is replaced by file system type (e.g. reiserfs)
// %4$s is replaced by mount point (e.g. /usr)
- txt = sformat( _("Format encrypted device %1$s (%2$s) for %4$s with %3$s"),
- d.c_str(), sizeString().c_str(), fsTypeString().c_str(),
- mp.c_str() );
+ txt = sformat(_("Format encrypted device %1$s (%2$s) for %4$s with %3$s"),
+ dev.c_str(), sizeString().c_str(), fsTypeString().c_str(),
+ mp.c_str());
}
}
else
@@ -697,24 +748,63 @@
// displayed text before action, %1$s is replaced by device name e.g. /dev/hda1
// %2$s is replaced by size (e.g. 623.5 MB)
// %3$s is replaced by file system type (e.g. reiserfs)
- txt = sformat( _("Format device %1$s (%2$s) with %3$s"),
- d.c_str(), sizeString().c_str(), fsTypeString().c_str() );
+ txt = sformat(_("Format device %1$s (%2$s) with %3$s"),
+ dev.c_str(), sizeString().c_str(), fsTypeString().c_str());
}
}
return( txt );
}
+static string handle_O_Features( const string& opts )
+ {
+ string ret = opts;
+ const string ofb = "-O ";
+ const string of = "-O";
+ string::size_type pos;
+ if( (pos=ret.find( ofb ))!=string::npos &&
+ ret.find( ofb, pos+ofb.size())!=string::npos )
+ {
+ list<string> ls = splitString( ret, " " );
+ list<string>::iterator li = find( ls.begin(), ls.end(), of );
+ if( li != ls.end() )
+ li++;
+ list<string>::iterator ofi = li;
+ while( li != ls.end() )
+ {
+ if( *li == of )
+ {
+ li = ls.erase( li );
+ if( li != ls.end() )
+ {
+ *ofi += ',';
+ *ofi += *li;
+ li = ls.erase( li );
+ }
+ }
+ else
+ ++li;
+ }
+ ret = boost::join( ls, " " );
+ }
+ if( ret!=opts )
+ {
+ y2mil( "org:" << opts );
+ y2mil( "ret:" << ret );
+ }
+ return( ret );
+ }
+
int Volume::doFormat()
{
static int fcount=1000;
int ret = 0;
bool needMount = false;
y2mil("device:" << dev);
- if( !silent() )
+ if( !silent )
{
- cont->getStorage()->showInfoCb( formatText(true) );
+ getStorage()->showInfoCb( formatText(true) );
}
- if( uby.type() != UB_NONE )
+ if (isUsedBy())
{
ret = VOLUME_ALREADY_IN_USE;
}
@@ -723,60 +813,62 @@
ret = umount( orig_mp );
needMount = ret==0;
}
- if( ret==0 && !cont->getStorage()->testmode() )
+ if( ret==0 && !getStorage()->testmode() )
{
ret = checkDevice();
}
if( ret==0 )
{
- cont->getStorage()->removeDmTableTo( *this );
+ getStorage()->removeDmTableTo( *this );
}
if( ret==0 && encryption!=ENC_NONE )
{
- ret = cont->getStorage()->zeroDevice(mountDevice(), size_k, true);
+ ret = Storage::zeroDevice(mountDevice(), size_k, true);
}
- if( ret==0 && mountDevice()!=dev && !cont->getStorage()->testmode() )
+ if( ret==0 && mountDevice()!=dev && !getStorage()->testmode() )
{
ret = checkDevice(mountDevice());
}
if( ret==0 && mountDevice().find( "/dev/md" )!=0 &&
mountDevice().find( "/dev/loop" )!=0 )
{
- SystemCmd c;
- c.execute(MDADMBIN " --zero-superblock " + quote(mountDevice()));
+ SystemCmd(MDADMBIN " --zero-superblock " + quote(mountDevice()));
}
if( ret==0 )
{
string cmd;
string params;
- ScrollBarHandler* p = NULL;
- CallbackProgressBar cb = cont->getStorage()->getCallbackProgressBarTheOne();
+ ProgressBar* progressbar = NULL;
+ CallbackProgressBar cb = getStorage()->getCallbackProgressBarTheOne();
switch( fs )
{
- case EXT2:
+ case EXT2:
+ cmd = "/sbin/mke2fs";
+ params = "-t ext2 -v";
+ progressbar = new Mke2fsProgressBar( cb );
+ break;
case EXT3:
cmd = "/sbin/mke2fs";
- params = (fs==EXT2) ? "-v" : "-j -v";
- p = new Mke2fsScrollbar( cb );
+ params = "-t ext3 -v";
+ progressbar = new Mke2fsProgressBar( cb );
+ break;
+ case EXT4:
+ cmd = "/sbin/mke2fs";
+ params = "-t ext4 -v";
+ progressbar = new Mke2fsProgressBar( cb );
+ break;
+ case BTRFS:
+ cmd = "/sbin/mkfs.btrfs";
break;
case REISERFS:
cmd = "/sbin/mkreiserfs";
params = "-f -f";
- p = new ReiserScrollbar( cb );
+ progressbar = new ReiserProgressBar( cb );
break;
case VFAT:
- {
cmd = "/sbin/mkdosfs";
- list<string> l=splitString( mkfs_opt );
- if( find_if( l.begin(), l.end(), find_begin( "-F" ) ) != l.end())
- params = "-F 32";
- else if( sizeK()>2*1024*1024 )
- {
- params += " -F 32";
- }
break;
- }
case JFS:
cmd = "/sbin/mkfs.jfs";
params = "-q";
@@ -793,6 +885,7 @@
break;
case SWAP:
cmd = "/sbin/mkswap";
+ params = "-f";
break;
default:
ret = VOLUME_FORMAT_UNKNOWN_FS;
@@ -803,15 +896,26 @@
cmd += " ";
if( !mkfs_opt.empty() )
{
- cmd += mkfs_opt + " ";
+ cmd += handle_O_Features(mkfs_opt) + " ";
}
if( !params.empty() )
{
cmd += params + " ";
}
- cmd += quote(mountDevice());
+ if( fs==BTRFS && cType()==BTRFSC && getEncryption()==ENC_NONE )
+ {
+ const Btrfs* l = static_cast<const Btrfs*>(this);
+ list<string> li = l->getDevices();
+ for( list<string>::const_iterator i=li.begin(); i!=li.end(); ++i )
+ {
+ cmd += ' ';
+ cmd += quote(*i );
+ }
+ }
+ else
+ cmd += quote(mountDevice());
SystemCmd c;
- c.setOutputProcessor( p );
+ c.setOutputProcessor(progressbar);
c.execute( cmd );
if( c.retcode()!=0 )
{
@@ -819,42 +923,58 @@
setExtError( c );
}
}
- delete p;
+ delete progressbar;
}
- if( ret==0 && fs==EXT3 )
+
+ if (ret == 0)
+ {
+ switch (fs)
{
- if (!tunefs_opt.empty())
+ case EXT3:
+ case EXT4:
{
- string cmd = "/sbin/tune2fs " + tunefs_opt + " " + quote(mountDevice());
- SystemCmd c( cmd );
- if( c.retcode()!=0 )
- ret = VOLUME_TUNE2FS_FAILED;
- }
- if( ret==0 && mp=="/" &&
- (fstab_opt.find( "data=writeback" )!=string::npos ||
- fstab_opt.find( "data=journal" )!=string::npos) )
- {
- string cmd = "/sbin/tune2fs -o ";
- if( fstab_opt.find( "data=writeback" )!=string::npos )
- cmd += "journal_data_writeback ";
- else
- cmd += "journal_data ";
- cmd += quote(mountDevice());
- SystemCmd c( cmd );
- if( c.retcode()!=0 )
- ret = VOLUME_TUNE2FS_FAILED;
+ if (!tunefs_opt.empty())
+ {
+ string cmd = "/sbin/tune2fs " + tunefs_opt + " " + quote(mountDevice());
+ SystemCmd c( cmd );
+ if( c.retcode()!=0 )
+ ret = VOLUME_TUNE2FS_FAILED;
+ }
+
+ if( ret==0 && mp=="/" &&
+ (fstab_opt.find( "data=writeback" )!=string::npos ||
+ fstab_opt.find( "data=journal" )!=string::npos) )
+ {
+ string cmd = "/sbin/tune2fs -o ";
+ if( fstab_opt.find( "data=writeback" )!=string::npos )
+ cmd += "journal_data_writeback ";
+ else
+ cmd += "journal_data ";
+ cmd += quote(mountDevice());
+ SystemCmd c( cmd );
+ if( c.retcode()!=0 )
+ ret = VOLUME_TUNE2FS_FAILED;
+ }
}
- }
- if( ret==0 && fs==REISERFS )
- {
- if (!tunefs_opt.empty())
+ break;
+
+ case REISERFS:
{
- string cmd = "/sbin/reiserfstune " + tunefs_opt + " " + quote(mountDevice());
- SystemCmd c( cmd );
- if( c.retcode()!=0 )
- ret = VOLUME_TUNEREISERFS_FAILED;
+ if (!tunefs_opt.empty())
+ {
+ string cmd = "/sbin/reiserfstune " + tunefs_opt + " " + quote(mountDevice());
+ SystemCmd c( cmd );
+ if( c.retcode()!=0 )
+ ret = VOLUME_TUNEREISERFS_FAILED;
+ }
}
+ break;
+
+ default:
+ break;
}
+ }
+
if( ret==0 )
{
triggerUdevUpdate();
@@ -867,12 +987,14 @@
{
format = false;
detected_fs = fs;
- if( !cont->getStorage()->testmode() )
+ if (!getStorage()->testmode())
{
FsType old=fs;
updateFsData();
if( fs != old )
ret = VOLUME_FORMAT_FS_UNDETECTED;
+ else if( fs==BTRFS )
+ getStorage()->setUsedByBtrfs( dev, uuid );
}
else
{
@@ -893,19 +1015,28 @@
return( ret );
}
-void Volume::updateFsData()
+
+ void
+ Volume::updateFsData( bool setUsedByLvm )
{
- SystemCmd Blkid("BLKID_SKIP_CHECK_MDRAID=1 /sbin/blkid -c /dev/null " + quote(mountDevice()));
- getFsData( Blkid );
+ Blkid blkid(mountDevice());
+ getFsData(blkid,setUsedByLvm);
+ if( getFs()==FSUNKNOWN && getEncryption()==ENC_NONE &&
+ orig_encryption==ENC_NONE )
+ {
+ Blkid::Entry e;
+ if( findBlkid( blkid, e ) && e.is_luks)
+ initEncryption(ENC_LUKS);
+ }
}
-string Volume::sysfsPath() const
+void Volume::setUsedByUuid( UsedByType ubt, const string& uuid )
{
- string ret = SYSFSDIR "/";
- string::size_type pos = dev.rfind( '/' ) + 1;
- ret += dev.substr( pos );
- y2mil( "ret:" << ret );
- return( ret );
+ eraseUuid();
+ eraseLabel();
+ setMount( "" );
+ formattingDone();
+ setUsedBy( ubt, uuid );
}
string Volume::getFilesysSysfsPath() const
@@ -935,7 +1066,7 @@
y2mil( "writing \"add\" to " << path );
file << "add" << endl;
file.close();
- cont->getStorage()->waitForDevice();
+ Storage::waitForDevice();
}
else
y2mil( "error opening " << path << " err:" <<
@@ -948,31 +1079,59 @@
int Volume::umount( const string& mp )
{
SystemCmd cmd;
- y2milestone( "device:%s mp:%s", dev.c_str(), mp.c_str() );
+ y2mil("device:" << dev << " mp:" << mp);
string d = mountDevice();
if( dmcrypt_active )
d = dmcrypt_dev;
else if( loop_active )
d = loop_dev;
string cmdline = ((detected_fs != SWAP)?UMOUNTBIN " ":SWAPOFFBIN " ") + quote(d);
- int ret = cmd.execute( cmdline );
- if( ret != 0 && mountDevice()!=dev )
+ int ret = -1;
+ if( fs!=TMPFS )
{
- cmdline = ((detected_fs != SWAP)?UMOUNTBIN " ":SWAPOFFBIN " ") + quote(dev);
- ret = cmd.execute( cmdline );
+ int ret = cmd.execute( cmdline );
+ if( ret != 0 && mountDevice()!=dev )
+ {
+ cmdline = ((detected_fs != SWAP)?UMOUNTBIN " ":SWAPOFFBIN " ") + quote(dev);
+ ret = cmd.execute( cmdline );
+ }
}
+ list<string> mps;
if( ret!=0 && !mp.empty() && mp!="swap" )
{
+ mps.push_back(mp);
cmdline = UMOUNTBIN " " + quote(mp);
ret = cmd.execute( cmdline );
}
if( ret!=0 && !orig_mp.empty() && orig_mp!="swap" )
{
+ mps.push_back(orig_mp);
cmdline = UMOUNTBIN " " + quote(orig_mp);
ret = cmd.execute( cmdline );
}
if( ret != 0 )
+ {
ret = VOLUME_UMOUNT_FAILED;
+ ProcMounts mounts;
+ list<string> devs;
+ devs.push_back( mountDevice() );
+ devs.push_back( dev );
+ if( mounts.getMount(devs).empty() )
+ {
+ ret = VOLUME_UMOUNT_NOT_MOUNTED;
+ if( !mps.empty() )
+ {
+ map<string, string> mp = mounts.allMounts();
+ for( list<string>::const_iterator i=mps.begin(); i!=mps.end(); ++i )
+ {
+ if( !mp[*i].empty() )
+ ret = VOLUME_UMOUNT_FAILED;
+ }
+ }
+ }
+ if( ret==VOLUME_UMOUNT_NOT_MOUNTED )
+ is_mounted = false;
+ }
else
is_mounted = false;
y2mil("ret:" << ret);
@@ -1004,8 +1163,7 @@
int Volume::cryptUnsetup( bool force )
{
int ret=0;
- y2mil( "force:" << force << " active:" << dmcrypt_active <<
- " table:" << dmcrypt_dev );
+ y2mil("force:" << force << " active:" << dmcrypt_active << " table:" << dmcrypt_dev);
if( dmcrypt_active || force )
{
string table = dmcrypt_dev;
@@ -1036,33 +1194,32 @@
return( ret );
}
-string Volume::mountText( bool doing ) const
+Text Volume::mountText( bool doing ) const
{
- string txt;
- string d = dev;
+ Text txt;
if( doing )
{
if( !mp.empty() )
{
// displayed text during action, %1$s is replaced by device name e.g. /dev/hda1
// %2$s is replaced by mount point e.g. /home
- txt = sformat( _("Mounting %1$s to %2$s"), d.c_str(), mp.c_str() );
+ txt = sformat(_("Mounting %1$s to %2$s"), dev.c_str(), mp.c_str());
}
else
{
// displayed text during action, %1$s is replaced by device name e.g. /dev/hda1
- txt = sformat( _("Unmounting %1$s"), d.c_str() );
+ txt = sformat(_("Unmounting %1$s"), dev.c_str());
}
}
else
{
if( !orig_mp.empty() && !mp.empty() &&
- (!cont->getStorage()->instsys()||mp!=orig_mp||mp!="swap") )
+ (!getStorage()->instsys()||mp!=orig_mp||mp!="swap") )
{
// displayed text before action, %1$s is replaced by device name e.g. /dev/hda1
// %2$s is replaced by mount point e.g. /home
- txt = sformat( _("Change mount point of %1$s to %2$s"), d.c_str(),
- mp.c_str() );
+ txt = sformat(_("Change mount point of %1$s to %2$s"), dev.c_str(),
+ mp.c_str());
}
else if( !mp.empty() )
{
@@ -1070,14 +1227,14 @@
{
// displayed text before action, %1$s is replaced by device name e.g. /dev/hda1
// %2$s is replaced by mount point e.g. /home
- txt = sformat( _("Set mount point of %1$s to %2$s"), d.c_str(),
- mp.c_str() );
+ txt = sformat(_("Set mount point of %1$s to %2$s"), dev.c_str(),
+ mp.c_str());
}
else
{
// displayed text before action, %1$s is replaced by device name e.g. /dev/hda1
// %2$s is replaced by "swap"
- txt = sformat( _("Use %1$s as %2$s"), d.c_str(), mp.c_str() );
+ txt = sformat(_("Use %1$s as %2$s"), dev.c_str(), mp.c_str());
}
}
else if( !orig_mp.empty() )
@@ -1089,37 +1246,19 @@
fn = "/etc/cryptotab";
// displayed text before action, %1$s is replaced by device name e.g. /dev/hda1
// %2$s is replaced by pathname e.g. /etc/fstab
- txt = sformat( _("Remove %1$s from %2$s"), d.c_str(), fn.c_str() );
+ txt = sformat(_("Remove %1$s from %2$s"), dev.c_str(), fn.c_str());
}
}
return( txt );
}
-void Volume::rename( const string& newName )
- {
- y2milestone( "rename old:%s new:%s", nm.c_str(), newName.c_str() );
- string::size_type pos;
- if( (pos=dev.rfind( nm ))!=string::npos )
- {
- dev.replace( pos, nm.size(), newName );
- }
- for( list<string>::iterator i=alt_names.begin(); i!=alt_names.end(); ++i )
- {
- if( (pos=i->rfind( nm ))!=string::npos )
- {
- i->replace( pos, nm.size(), newName );
- }
- }
- nm = newName;
- }
-
-int Volume::checkDevice()
+int Volume::checkDevice() const
{
return( checkDevice(dev));
}
-int Volume::checkDevice( const string& device )
+int Volume::checkDevice(const string& device) const
{
struct stat sbuf;
int ret = 0;
@@ -1127,51 +1266,57 @@
ret = VOLUME_DEVICE_NOT_PRESENT;
else if( !S_ISBLK(sbuf.st_mode) )
ret = VOLUME_DEVICE_NOT_BLOCK;
- y2milestone( "checkDevice:%s ret:%d", device.c_str(), ret );
+ y2mil("checkDevice:" << device << " ret:" << ret);
return( ret );
}
int Volume::doMount()
{
int ret = 0;
- string lmount;
- if( mp != "swap" )
- lmount += cont->getStorage()->root();
- if( mp!="/" )
- lmount += mp;
- y2milestone( "device:%s mp:%s old mp:%s", dev.c_str(), mp.c_str(),
- orig_mp.c_str() );
- if( !silent() )
+ y2mil("device:" << dev << " mp:" << mp << " orig_mp:" << orig_mp);
+ if( !silent )
{
- cont->getStorage()->showInfoCb( mountText(true) );
+ getStorage()->showInfoCb( mountText(true) );
}
if( ret==0 && !orig_mp.empty() && isMounted() )
{
- string um = orig_mp;
- if( um != "swap" )
- um = cont->getStorage()->root() + um;
- ret = umount( um );
+ ret = umount(getStorage()->prependRoot(orig_mp));
}
+ string lmount = getStorage()->prependRoot(mp);
if( ret==0 && lmount!="swap" && access( lmount.c_str(), R_OK )!=0 )
{
createPath( lmount );
}
- if( ret==0 && !mp.empty() && uby.type() != UB_NONE )
+ if (ret == 0 && !mp.empty() && isUsedBy())
{
ret = VOLUME_ALREADY_IN_USE;
}
- if( ret==0 && !mp.empty() && !cont->getStorage()->testmode() )
+ if( ret==0 && !mp.empty() && !getStorage()->testmode() )
{
- if( fs!=NFS )
+ bool do_chmod = isTmpCryptMp(mp) && mp!="swap";
+ mode_t mode, omode;
+
+ if( fs!=NFS && fs!=NFS4 && fs!=TMPFS )
{
- cont->getStorage()->removeDmTableTo( *this );
+ getStorage()->removeDmTableTo(*this);
ret = checkDevice(mountDevice());
}
+ if( ret==0 && do_chmod )
+ {
+ if( !getStatMode( lmount, mode ) )
+ do_chmod=false;
+ else
+ y2mil( "Mode of " << lmount << " is " << oct << mode << dec);
+ }
if( ret==0 )
{
ret = mount( lmount );
- if( ret!=0 && cont->getStorage()->instsys() && fs==NTFS )
- ret = mount( lmount, true );
+ }
+ if( ret==0 && do_chmod && getStatMode( lmount, omode ) && mode!=omode )
+ {
+ bool ok = setStatMode( lmount, mode );
+ y2mil( "setting mode for " << lmount << " from:" << oct << omode <<
+ " to:" << mode << dec << " ok:" << ok );
}
}
if( ret==0 )
@@ -1179,9 +1324,9 @@
ret = doFstabUpdate();
orig_mp = mp;
}
- if( ret==0 && mp=="/" && !cont->getStorage()->root().empty() )
+ if( ret==0 && mp=="/" && !getStorage()->root().empty() )
{
- cont->getStorage()->rootMounted();
+ getStorage()->rootMounted();
}
y2mil("ret:" << ret);
return( ret );
@@ -1190,8 +1335,8 @@
int Volume::canResize( unsigned long long newSizeK ) const
{
int ret=0;
- y2milestone( "val:%llu", newSizeK );
- if( uby.type() != UB_NONE )
+ y2mil("val:" << newSizeK);
+ if (isUsedBy() && !getStorage()->isUsedBySingleBtrfs(*this))
{
ret = VOLUME_ALREADY_IN_USE;
}
@@ -1199,7 +1344,7 @@
{
FsCapabilities caps;
if( !format && fs!=FSNONE && !ignore_fs &&
- (!cont->getStorage()->getFsCapabilities( fs, caps ) ||
+ (!getStorage()->getFsCapabilities( fs, caps ) ||
(newSizeK < size_k && !caps.isReduceable) ||
(newSizeK > size_k && !caps.isExtendable)) )
{
@@ -1267,6 +1412,7 @@
break;
case EXT2:
case EXT3:
+ case EXT4:
cmd = "/sbin/resize2fs -f " + quote(mountDevice());
if( needShrink() )
cmd += " " + decString(size_k) + "K";
@@ -1284,7 +1430,7 @@
string mpoint = orig_mp;
if( !isMounted() )
{
- mpoint = cont->getStorage()->tmpDir()+"/mp";
+ mpoint = getStorage()->tmpDir() + "/tmp-xfs-mp";
mkdir( mpoint.c_str(), 0700 );
ret = mount( mpoint );
needrmdir = true;
@@ -1309,7 +1455,6 @@
if( needrmdir )
{
rmdir( mpoint.c_str() );
- rmdir( cont->getStorage()->tmpDir().c_str() );
}
}
break;
@@ -1327,12 +1472,12 @@
}
- int
- Volume::setEncryption(bool val, EncryptType typ)
+int
+Volume::setEncryption(bool val, EncryptType typ )
{
int ret = 0;
- y2milestone( "val:%d typ:%d", val, typ );
- if( getUsedByType() != UB_NONE )
+ y2mil("val:" << val << " typ:" << toString(typ));
+ if (isUsedBy())
{
ret = VOLUME_ALREADY_IN_USE;
}
@@ -1363,16 +1508,16 @@
if (ret == 0 && (create || format || loop_active || mp.empty()))
{
encryption = typ;
- is_loop = cont->type()==LOOP;
+ is_loop = cType() == LOOP;
dmcrypt_dev = getDmcryptName();
}
- if (ret == 0 && !create && !format && !loop_active && !mp.empty())
+ if (ret == 0 && !create && !format && !loop_active && !mp.empty() )
{
if( detectEncryption()==ENC_UNKNOWN )
ret = VOLUME_CRYPT_NOT_DETECTED;
}
- }
}
+ }
if( ret==0 )
{
updateFstabOptions();
@@ -1381,36 +1526,34 @@
return( ret );
}
-string Volume::losetupText( bool doing ) const
+Text Volume::losetupText( bool doing ) const
{
- string txt;
- string d = dev;
+ Text txt;
if( doing )
{
// displayed text during action, %1$s is replaced by device name e.g. /dev/hda1
- txt = sformat( _("Setting up encrypted loop device on %1$s"), d.c_str() );
+ txt = sformat(_("Setting up encrypted loop device on %1$s"), dev.c_str());
}
else
{
// displayed text before action, %1$s is replaced by device name e.g. /dev/hda1
- txt = sformat( _("Set up encrypted loop device on %1$s"), d.c_str() );
+ txt = sformat(_("Set up encrypted loop device on %1$s"), dev.c_str());
}
return( txt );
}
-string Volume::crsetupText( bool doing ) const
+Text Volume::crsetupText( bool doing ) const
{
- string txt;
- string d = dev;
+ Text txt;
if( doing )
{
// displayed text during action, %1$s is replaced by device name e.g. /dev/hda1
- txt = sformat( _("Setting up encrypted dm device on %1$s"), d.c_str() );
+ txt = sformat(_("Setting up encrypted dm device on %1$s"), dev.c_str());
}
else
{
// displayed text before action, %1$s is replaced by device name e.g. /dev/hda1
- txt = sformat( _("Set up encrypted dm device on %1$s"), d.c_str() );
+ txt = sformat(_("Set up encrypted dm device on %1$s"), dev.c_str());
}
return( txt );
}
@@ -1430,7 +1573,7 @@
bool hasLoopDevice( const Volume& v ) { return( !v.loopDevice().empty() ); }
-bool Volume::loopInUse( Storage* sto, const string& loopdev )
+bool Volume::loopInUse(const Storage* sto, const string& loopdev)
{
bool ret = false;
@@ -1450,7 +1593,7 @@
y2mil( "ids:" << ids );
const int loop_instsys_offset = 2;
list<unsigned> lnum;
- Storage::ConstVolPair p = cont->getStorage()->volPair( hasLoopDevice );
+ Storage::ConstVolPair p = getStorage()->volPair( hasLoopDevice );
for( Storage::ConstVolIterator i=p.begin(); i!=p.end(); ++i )
{
y2mil( "lvol:" << *i );
@@ -1459,7 +1602,7 @@
lnum.push_back( num );
}
y2mil( "lnum:" << lnum );
- unsigned num = cont->getStorage()->instsys()?loop_instsys_offset:0;
+ unsigned num = getStorage()->instsys() ? loop_instsys_offset : 0;
bool found;
string ldev;
do
@@ -1477,13 +1620,12 @@
else
{
loop_dev = "/dev/loop" + decString(num);
- if( cont->getStorage()->instsys() )
+ if (getStorage()->instsys())
fstab_loop_dev = "/dev/loop" + decString(num-loop_instsys_offset);
else
fstab_loop_dev = loop_dev;
}
- y2milestone( "loop_dev:%s fstab_loop_dev:%s", loop_dev.c_str(),
- fstab_loop_dev.c_str() );
+ y2mil("loop_dev:" << loop_dev << " fstab_loop_dev:" << fstab_loop_dev);
return( ret );
}
@@ -1491,10 +1633,7 @@
{
int ret = 0;
if( loop_dev.empty() )
- {
- list<unsigned> ids;
- ret = getFreeLoop( loopData, ids );
- }
+ ret = getFreeLoop(loopData, list<unsigned>());
y2mil("ret:" << ret);
return( ret );
}
@@ -1516,7 +1655,7 @@
string cmd = LOSETUPBIN " " + quote(loop_dev) + " ";
const Loop* l = static_cast<const Loop*>(this);
cmd += quote(l->lfileRealPath());
- y2milestone( "cmd:%s", cmd.c_str() );
+ y2mil("cmd:" << cmd);
return( cmd );
}
@@ -1525,7 +1664,7 @@
bool format, bool empty_pwd ) const
{
string table = dmdev;
- y2mil( "enctype:" << e << " dmdev:" << dmdev << " mount:" << mount <<
+ y2mil( "enctype:" << toString(e) << " dmdev:" << dmdev << " mount:" << mount <<
" format:" << format << " pwempty:" << empty_pwd );
if( table.find( '/' )!=string::npos )
table.erase( 0, table.find_last_of( '/' )+1 );
@@ -1612,7 +1751,7 @@
}
}
- y2milestone( "cmd:%s", cmd.c_str() );
+ y2mil("cmd:" << cmd);
return( cmd );
}
@@ -1639,8 +1778,8 @@
int
Volume::setCryptPwd( const string& val )
{
-#ifdef DEBUG_LOOP_CRYPT_PASSWORD
- y2milestone( "password:%s", val.c_str() );
+#ifdef DEBUG_CRYPT_PASSWORD
+ y2mil("pwd:" << val << " orig_pwd:" << orig_crypt_pwd );
#endif
int ret = 0;
@@ -1653,6 +1792,9 @@
if( encryption==ENC_UNKNOWN )
detectEncryption();
}
+#ifdef DEBUG_CRYPT_PASSWORD
+ y2mil("pwd:" << crypt_pwd << " orig_pwd:" << orig_crypt_pwd );
+#endif
y2mil("ret:" << ret);
return( ret );
}
@@ -1672,12 +1814,12 @@
bool Volume::needLosetup( bool urgent ) const
{
bool ret = (is_loop!=loop_active) &&
- (encryption==ENC_NONE || !crypt_pwd.empty() ||
- (dmcrypt() && cType() == LOOP));
+ (encryption==ENC_NONE || !crypt_pwd.empty() ||
+ (dmcrypt() && cType() == LOOP));
if( !urgent && loop_dev.empty() )
ret = false;
if( is_loop && encryption!=ENC_NONE &&
- !crypt_pwd.empty() && crypt_pwd!=orig_crypt_pwd )
+ !crypt_pwd.empty() && crypt_pwd!=orig_crypt_pwd )
ret = true;
return( ret );
}
@@ -1686,12 +1828,12 @@
{
bool ret = (dmcrypt()!=dmcrypt_active) &&
(encryption==ENC_NONE || encryption!=orig_encryption ||
- !crypt_pwd.empty() || isTmpCryptMp(mp));
+ !crypt_pwd.empty() || isTmpCryptMp(mp) ||
+ (encryption==ENC_LUKS&&!isTmpCryptMp(mp)&&isUsedBy(UB_LVM)) );
if( dmcrypt() && encryption!=ENC_NONE &&
- !crypt_pwd.empty() && crypt_pwd!=orig_crypt_pwd )
+ ((!crypt_pwd.empty() && crypt_pwd!=orig_crypt_pwd) ||
+ (crypt_pwd.empty() && isTmpCryptMp(mp) && format)) )
ret = true;
- y2mil( "vol:" << *this );
- y2mil( "ret:" << ret );
return( ret );
}
@@ -1703,7 +1845,7 @@
bool Volume::needFstabUpdate() const
{
bool ret = !ignore_fstab && !(mp.empty() && orig_mp.empty()) &&
- ((cont->getStorage()->instsys()&&mp=="swap"&&mp==orig_mp) ||
+ ((getStorage()->instsys()&&mp=="swap"&&mp==orig_mp) ||
fstab_opt!=orig_fstab_opt || mount_by!=orig_mount_by ||
encryption!=orig_encryption);
return( ret );
@@ -1712,25 +1854,29 @@
EncryptType Volume::detectEncryption()
{
EncryptType ret = ENC_UNKNOWN;
+ EncryptType save_enc = encryption;
+ EncryptType save_orig = orig_encryption;
- if( getContainer()->getStorage()->testmode() )
+ if (getStorage()->testmode())
{
ret = encryption = orig_encryption = ENC_TWOFISH;
- y2milestone( "ret:%s", encTypeString(ret).c_str() );
+ y2mil("ret:" << toString(ret));
return( ret );
}
unsigned pos=0;
static EncryptType try_order[] = { ENC_LUKS, ENC_TWOFISH_OLD,
ENC_TWOFISH256_OLD, ENC_TWOFISH };
- string fname = cont->getStorage()->tmpDir()+"/pwdf";
- string mpname = cont->getStorage()->tmpDir()+"/mp";
+ string fname = getStorage()->tmpDir() + "/pwdf";
+ string mpname = getStorage()->tmpDir() + "/tmp-enc-mp";
SystemCmd c;
- y2milestone( "device:%s", dev.c_str() );
+ y2mil("device:" << dev);
mkdir( mpname.c_str(), 0700 );
- getFreeLoop();
+ if( is_loop )
+ getFreeLoop();
detected_fs = fs = FSUNKNOWN;
+ bool luks_ok = false;
do
{
ofstream pwdfile( fname.c_str() );
@@ -1738,7 +1884,7 @@
pwdfile << crypt_pwd;
pwdfile.close();
encryption = orig_encryption = try_order[pos];
- is_loop = cont->type()==LOOP;
+ is_loop = cType() == LOOP;
dmcrypt_dev = getDmcryptName();
crUnsetup( true );
if( is_loop )
@@ -1746,48 +1892,57 @@
string lfile;
if( getLoopFile( lfile ))
c.execute(LOSETUPBIN " " + quote(loop_dev) + " " +
- quote(cont->getStorage()->root() + lfile));
+ quote(getStorage()->root() + lfile));
}
string cmd = getCryptsetupCmd( try_order[pos], dmcrypt_dev, "", fname, false );
c.execute(MODPROBEBIN " dm-crypt");
c.execute( cmd );
string use_dev = dmcrypt_dev;
+ luks_ok = try_order[pos]==ENC_LUKS && c.retcode()==0;
if( c.retcode()==0 )
{
- cont->getStorage()->waitForDevice( use_dev );
+ Storage::waitForDevice(use_dev);
updateFsData();
- if( detected_fs!=FSUNKNOWN )
+ unsigned long mj = 0;
+ unsigned long mn;
+ if( storage::getMajorMinor( use_dev, mj, mn ) && mj>0 )
+ getStorage()->removeDmTableTo( mj, mn );
+ if( detected_fs!=FSUNKNOWN && !luks_ok )
{
string cmd;
switch( detected_fs )
{
case EXT2:
+ cmd = "/sbin/fsck.ext2 -n -f " + quote(use_dev);
+ break;
case EXT3:
- cmd = "fsck.ext2 -n -f " + use_dev;
+ cmd = "/sbin/fsck.ext3 -n -f " + quote(use_dev);
+ break;
+ case EXT4:
+ cmd = "/sbin/fsck.ext4 -n -f " + quote(use_dev);
break;
case REISERFS:
- cmd = "reiserfsck --yes --check -q " + use_dev;
+ cmd = "reiserfsck --yes --check -q " + quote(use_dev);
break;
case XFS:
- cmd = "xfs_check " + use_dev;
+ cmd = "xfs_check " + quote(use_dev);
break;
case JFS:
- cmd = "fsck.jfs -n " + use_dev;
+ cmd = "fsck.jfs -n " + quote(use_dev);
break;
default:
- cmd = "fsck -n -t " + fsTypeString(detected_fs) +
- " " + use_dev;
+ cmd = "fsck -n -t " + toString(detected_fs) + " " + quote(use_dev);
break;
}
bool excTime, excLines;
c.executeRestricted( cmd, 15, 500, excTime, excLines );
bool ok = c.retcode()==0 || (excTime && !excLines);
- y2milestone( "ok:%d retcode:%d excTime:%d excLines:%d",
- ok, c.retcode(), excTime, excLines );
+ y2mil("ok:" << ok << " retcode:" << c.retcode() << " excTime:" << excTime <<
+ " excLines:" << excLines);
if( ok )
{
- c.execute(MODPROBEBIN " " + fs_names[detected_fs]);
- c.execute(MOUNTBIN " -oro -t " + fsTypeString(detected_fs) + " " +
+ c.execute(MODPROBEBIN " " + toString(detected_fs));
+ c.execute(MOUNTBIN " -oro -t " + toString(detected_fs) + " " +
quote(use_dev) + " " + quote(mpname));
ok = c.retcode()==0;
c.execute(UMOUNTBIN " " + quote(mpname));
@@ -1796,18 +1951,19 @@
{
detected_fs = fs = FSUNKNOWN;
eraseLabel();
- uuid.erase();
+ eraseUuid();
}
}
}
- if( fs==FSUNKNOWN )
+ if( fs==FSUNKNOWN && !luks_ok )
pos++;
+ y2mil("pos:" << pos << " luks_ok:" << luks_ok << " fs:" << toString(fs));
}
- while( detected_fs==FSUNKNOWN && pos<lengthof(try_order) );
+ while( !luks_ok && detected_fs==FSUNKNOWN && pos<lengthof(try_order) );
crUnsetup( true );
- if( detected_fs!=FSUNKNOWN )
+ if( detected_fs!=FSUNKNOWN || luks_ok )
{
- is_loop = cont->type()==LOOP;
+ is_loop = cType() == LOOP;
ret = encryption = orig_encryption = try_order[pos];
orig_crypt_pwd = crypt_pwd;
}
@@ -1818,23 +1974,26 @@
loop_dev.erase();
crypt_pwd.erase();
orig_crypt_pwd.erase();
- ret = encryption = orig_encryption = ENC_UNKNOWN;
+ ret = ENC_UNKNOWN;
+ encryption = save_enc;
+ orig_encryption = save_orig;
}
unlink( fname.c_str() );
rmdir( mpname.c_str() );
- rmdir( cont->getStorage()->tmpDir().c_str() );
- y2milestone( "ret:%s", encTypeString(ret).c_str() );
+#ifdef DEBUG_CRYPT_PASSWORD
+ y2mil("pwd:" << crypt_pwd << " orig_pwd:" << orig_crypt_pwd );
+#endif
+ y2mil("ret:" << toString(ret));
return( ret );
}
int Volume::doLosetup()
{
int ret = 0;
- y2milestone( "device:%s mp:%s is_loop:%d loop_active:%d",
- dev.c_str(), mp.c_str(), is_loop, loop_active );
- if( !silent() && is_loop && !dmcrypt() )
+ y2mil("device:" << dev << " mp:" << mp << " is_loop:" << is_loop << " loop_active:" << loop_active);
+ if( !silent && is_loop && !dmcrypt() )
{
- cont->getStorage()->showInfoCb( losetupText(true) );
+ getStorage()->showInfoCb( losetupText(true) );
}
if( is_mounted )
{
@@ -1842,7 +2001,7 @@
}
if( is_loop )
{
- cont->getStorage()->removeDmTableTo( *this );
+ getStorage()->removeDmTableTo( *this );
if( ret==0 && loop_dev.empty() )
{
ret = getFreeLoop();
@@ -1852,7 +2011,7 @@
string fname;
if( !dmcrypt() )
{
- fname = cont->getStorage()->tmpDir()+"/pwdf";
+ fname = getStorage()->tmpDir() + "/pwdf";
ofstream pwdfile( fname.c_str() );
classic(pwdfile);
pwdfile << crypt_pwd << endl;
@@ -1866,9 +2025,8 @@
if( !fname.empty() )
{
unlink( fname.c_str() );
- rmdir( cont->getStorage()->tmpDir().c_str() );
}
- cont->getStorage()->waitForDevice( loop_dev );
+ Storage::waitForDevice(loop_dev);
}
if( ret==0 )
{
@@ -1878,16 +2036,16 @@
list<string> l = splitString( fstab_opt, "," );
list<string>::iterator i = find( l.begin(), l.end(), "loop" );
if( i == l.end() )
- i = find_if( l.begin(), l.end(), find_begin( "loop=" ) );
+ i = find_if( l.begin(), l.end(), string_starts_with( "loop=" ) );
if( i!=l.end() )
*i = "loop=" + fstab_loop_dev;
- fstab_opt = mergeString( l, "," );
+ fstab_opt = boost::join( l, "," );
}
}
}
else
{
- if( loop_dev.size()>0 )
+ if (!loop_dev.empty())
{
SystemCmd c(LOSETUPBIN " -d " + quote(loop_dev));
loop_dev.erase();
@@ -1899,10 +2057,10 @@
return( ret );
}
-string Volume::getDmcryptName()
+string Volume::getDmcryptName() const
{
string nm;
- if( cont->type()!=LOOP )
+ if( cType() != LOOP )
{
nm = dev;
}
@@ -1919,9 +2077,9 @@
void Volume::replaceAltName( const string& prefix, const string& newn )
{
- y2mil( "prefix:" << prefix << " new:" << newn );
+ y2mil("device:" << dev << " prefix:" << prefix << " new:" << newn);
list<string>::iterator i =
- find_if( alt_names.begin(), alt_names.end(), find_begin( prefix ) );
+ find_if( alt_names.begin(), alt_names.end(), string_starts_with( prefix ) );
if( i!=alt_names.end() )
{
if( !newn.empty() )
@@ -1939,9 +2097,9 @@
int ret = 0;
y2mil("device:" << dev << " mp:" << mp << " dmcrypt:" << dmcrypt() <<
" active:" << dmcrypt_active << " format:" << format );
- if( !silent() && dmcrypt() )
+ if( !silent && dmcrypt() )
{
- cont->getStorage()->showInfoCb( crsetupText(true) );
+ getStorage()->showInfoCb( crsetupText(true) );
}
if( is_mounted )
{
@@ -1949,7 +2107,7 @@
}
if( dmcrypt() )
{
- cont->getStorage()->removeDmTableTo( *this );
+ getStorage()->removeDmTableTo( *this );
if( ret==0 && dmcrypt_dev.empty() )
{
dmcrypt_dev = getDmcryptName();
@@ -1958,16 +2116,21 @@
{
ret = cryptUnsetup();
}
+ if( ret==0 && encryption==ENC_LUKS && !isTmpCryptMp(mp) &&
+ crypt_pwd.empty() )
+ {
+ ret = VOLUME_CRYPT_NO_PWD;
+ }
if( ret==0 )
{
- string fname = cont->getStorage()->tmpDir()+"/pwdf";
+ string fname = getStorage()->tmpDir() + "/pwdf";
ofstream pwdfile( fname.c_str() );
classic(pwdfile);
pwdfile << crypt_pwd;
pwdfile.close();
SystemCmd cmd;
if( format || (isTmpCryptMp(mp)&&crypt_pwd.empty()) ||
- (encryption!=ENC_NONE&&mp.empty()) )
+ (encryption!=ENC_NONE&&orig_crypt_pwd!=crypt_pwd) )
{
string cmdline = getCryptsetupCmd( encryption, dmcrypt_dev, mp, fname, true,
crypt_pwd.empty() );
@@ -1975,10 +2138,10 @@
{
cmd.execute( cmdline );
if( cmd.retcode()!=0 )
- ret = VOLUME_CRYPTFORMAT_FAILED;
- if( ret==0 && mp=="swap" )
- cmd.execute("/sbin/mkswap " + quote(dmcrypt_dev));
- }
+ ret = VOLUME_CRYPTFORMAT_FAILED;
+ if( ret==0 && mp=="swap" && crypt_pwd.empty() && !format )
+ cmd.execute("/sbin/mkswap " + quote(dmcrypt_dev));
+ }
}
if( ret==0 && (!isTmpCryptMp(mp)||!crypt_pwd.empty()) )
{
@@ -1987,34 +2150,33 @@
{
cmd.execute( cmdline );
if( cmd.retcode()!=0 )
- ret = VOLUME_CRYPTSETUP_FAILED;
- }
+ ret = VOLUME_CRYPTSETUP_FAILED;
+ }
}
if( ret==0 )
orig_crypt_pwd = crypt_pwd;
unlink( fname.c_str() );
- rmdir( cont->getStorage()->tmpDir().c_str() );
- cont->getStorage()->waitForDevice( dmcrypt_dev );
+ Storage::waitForDevice(dmcrypt_dev);
}
if( ret==0 )
{
dmcrypt_active = true;
unsigned long dummy, minor;
- if( cont->type()==LOOP )
+ if (cType() == LOOP)
{
- getMajorMinor( dev, mjr, mnr );
+ getMajorMinor();
minor = mnr;
replaceAltName( "/dev/dm-", Dm::dmDeviceName(mnr) );
}
else
- {
- getMajorMinor( dmcrypt_dev, dummy, minor );
+ {
+ storage::getMajorMinor( dmcrypt_dev, dummy, minor );
replaceAltName("/dev/dm-", Dm::dmDeviceName(minor));
- }
+ }
- ProcPart p;
+ ProcParts parts;
unsigned long long sz;
- if( p.getSize( Dm::dmDeviceName(minor), sz ))
+ if (parts.getSize( Dm::dmDeviceName(minor), sz))
setSize( sz );
}
}
@@ -2030,7 +2192,9 @@
int Volume::doCrsetup()
{
int ret = 0;
+ bool force_fstab_rewrite = false;
bool losetup_done = false;
+ bool did_cryptsetup = false;
if( needLosetup(true) )
{
ret = doLosetup();
@@ -2038,38 +2202,42 @@
}
if( ret==0 && needCryptsetup() )
{
+ force_fstab_rewrite =
+ encryption != ENC_NONE &&
+ ((!crypt_pwd.empty() && crypt_pwd!=orig_crypt_pwd) ||
+ (crypt_pwd.empty() && isTmpCryptMp(mp) && format));
ret = doCryptsetup();
if( ret!=0 && losetup_done )
loUnsetup();
+ did_cryptsetup = true;
}
if (ret == 0)
{
- updateFsData();
+ updateFsData(did_cryptsetup);
}
if (ret == 0 && encryption != ENC_NONE)
{
- doFstabUpdate();
+ doFstabUpdate(force_fstab_rewrite);
}
y2mil("ret:" << ret);
return ret;
}
-string Volume::labelText( bool doing ) const
+Text Volume::labelText( bool doing ) const
{
- string txt;
- string d = dev;
+ Text txt;
if( doing )
{
if( label.empty() )
{
// displayed text during action, %1$s is replaced by device name e.g. /dev/hda1
- txt = sformat( _("Clearing label on %1$s"), d.c_str() );
+ txt = sformat(_("Clearing label on %1$s"), dev.c_str());
}
else
{
// displayed text during action, %1$s is replaced by device name e.g. /dev/hda1
// %2$s is replaced by a name e.g. ROOT
- txt = sformat( _("Setting label on %1$s to %2$s"), d.c_str(), label.c_str() );
+ txt = sformat(_("Setting label on %1$s to %2$s"), dev.c_str(), label.c_str());
}
}
else
@@ -2077,13 +2245,13 @@
if( label.empty() )
{
// displayed text before action, %1$s is replaced by device name e.g. /dev/hda1
- txt = sformat( _("Clear label on %1$s"), d.c_str() );
+ txt = sformat(_("Clear label on %1$s"), dev.c_str());
}
else
{
// displayed text before action, %1$s is replaced by device name e.g. /dev/hda1
// %2$s is replaced by a name e.g. ROOT
- txt = sformat( _("Set label on %1$s to %2$s"), d.c_str(), label.c_str() );
+ txt = sformat(_("Set label on %1$s to %2$s"), dev.c_str(), label.c_str());
}
}
return( txt );
@@ -2095,22 +2263,21 @@
bool remount = false;
FsCapabilities caps;
y2mil("device:" << dev << " mp:" << mp << " label:" << label);
- if( !silent() )
+ if( !silent )
{
- cont->getStorage()->showInfoCb( labelText(true) );
+ getStorage()->showInfoCb( labelText(true) );
}
- if( !cont->getStorage()->getFsCapabilities( fs, caps ) ||
- !caps.supportsLabel )
+ if (!getStorage()->getFsCapabilities(fs, caps) || !caps.supportsLabel)
{
ret = VOLUME_LABEL_TOO_LONG;
}
- if( ret==0 && getUsedByType() != UB_NONE )
+ if (ret == 0 && isUsedBy())
{
ret = VOLUME_ALREADY_IN_USE;
}
if( ret==0 && is_mounted && !caps.labelWhileMounted )
{
- ret = umount( cont->getStorage()->root()+orig_mp );
+ ret = umount(getStorage()->prependRoot(orig_mp));
if( ret!=0 )
ret = VOLUME_LABEL_WHILE_MOUNTED;
else
@@ -2123,6 +2290,7 @@
{
case EXT2:
case EXT3:
+ case EXT4:
cmd = "/sbin/tune2fs -L " + quote(label) + " " + quote(mountDevice());
break;
case REISERFS:
@@ -2162,7 +2330,7 @@
}
if( remount )
{
- ret = mount( cont->getStorage()->root()+orig_mp );
+ ret = mount(getStorage()->prependRoot(orig_mp));
}
if( ret==0 )
{
@@ -2179,14 +2347,13 @@
int Volume::setLabel( const string& val )
{
int ret=0;
- y2milestone( "label:%s", val.c_str() );
+ y2mil("label:" << val);
FsCapabilities caps;
- if( cont->getStorage()->getFsCapabilities( fs, caps ) &&
- caps.supportsLabel )
+ if (getStorage()->getFsCapabilities(fs, caps) && caps.supportsLabel)
{
if( caps.labelLength < val.size() )
ret = VOLUME_LABEL_TOO_LONG;
- else if( getUsedByType() != UB_NONE )
+ else if (isUsedBy())
ret = VOLUME_ALREADY_IN_USE;
else
label = val;
@@ -2200,71 +2367,64 @@
int Volume::mount( const string& m, bool ro )
{
SystemCmd cmd;
- y2milestone( "device:%s mp:%s ro:%d", dev.c_str(), m.c_str(), ro );
+ y2mil("device:" << dev << " mp:" << m << " ro:" << ro);
string cmdline;
if( fs != SWAP )
{
string lmount = (!m.empty())?m:mp;
- y2milestone( "device:%s mp:%s", dev.c_str(), lmount.c_str() );
- string fsn = fs_names[fs];
+ y2mil("device:" << dev << " mp:" << lmount);
+ string fsn = toString(fs);
switch( fs )
{
case NTFS:
- if( !ro )
- fsn = "ntfs-3g";
+ fsn = "ntfs-3g";
break;
case FSUNKNOWN:
fsn = "auto";
break;
default:
- cmdline = MODPROBEBIN " " + fsn;
- cmd.execute( cmdline );
+ cmd.execute(MODPROBEBIN " " + fsn);
break;
}
if( fs == VFAT )
{
- cmdline = MODPROBEBIN " nls_cp437";
- cmd.execute( cmdline );
- cmdline = MODPROBEBIN " nls_iso8859-1";
- cmd.execute( cmdline );
+ cmd.execute(MODPROBEBIN " nls_cp437");
+ cmd.execute(MODPROBEBIN " nls_iso8859-1");
}
cmdline = MOUNTBIN " ";
if( ro )
cmdline += "-r ";
+ cmdline += "-t " + fsn + " ";
+
const char * ign_opt[] = { "defaults", "" };
const char * ign_beg[] = { "loop", "encryption=", "phash=",
"itercountk=", "" };
- if( cont->getStorage()->instsys() )
+ if (getStorage()->instsys())
ign_opt[lengthof(ign_opt)-1] = "ro";
if( fsn=="ntfs" )
ign_beg[lengthof(ign_beg)-1] = "locale=";
list<string> l = splitString( fstab_opt, "," );
y2mil( "l before:" << l );
for( unsigned i=0; i<lengthof(ign_opt) && *ign_opt[i]!=0; i++ )
- l.erase( remove(l.begin(), l.end(), ign_opt[i]), l.end() );
+ l.remove(ign_opt[i]);
for( unsigned i=0; i<lengthof(ign_beg) && *ign_beg[i]!=0; i++ )
- l.erase( remove_if(l.begin(), l.end(), find_begin(ign_beg[i])),
- l.end() );
+ l.remove_if(string_starts_with(ign_beg[i]));
y2mil( "l after:" << l );
- string opts = " ";
if( !l.empty() )
- {
- opts += "-o";
- opts += mergeString( l, "," );
- opts += " ";
- }
- cmdline += "-t " + fsn + opts + quote(mountDevice()) + " " + quote(lmount);
+ cmdline += "-o " + boost::join(l, ",") + " ";
+
+ cmdline += quote(mountDevice()) + " " + quote(lmount);
}
else
{
cmdline = SWAPONBIN " --fixpgsz " + quote(mountDevice());
- if( cont->getStorage()->instsys() )
+ if (getStorage()->instsys())
{
- ProcMounts mountData( cont->getStorage() );
- string m = mountData.getMount( mountDevice() );
+ ProcMounts mounts;
+ string m = mounts.getMount(mountDevice());
if( m.empty() )
{
- m = mountData.getMount( alt_names );
+ m = mounts.getMount(alt_names);
}
if( m == "swap" )
cmdline = "echo " + cmdline;
@@ -2282,10 +2442,9 @@
return( ret );
}
-int Volume::prepareRemove()
+int Volume::unaccessVol()
{
int ret = 0;
- y2milestone( "device:%s", dev.c_str() );
if( !orig_mp.empty() )
{
if( isMounted() )
@@ -2297,94 +2456,114 @@
ret = doFstabUpdate();
}
}
+ return( ret );
+ }
+
+int Volume::prepareRemove()
+ {
+ y2mil("device:" << dev);
+ int ret = unaccessVol();
if( loop_active || dmcrypt_active )
{
crUnsetup();
}
- cont->getStorage()->eraseFreeInfo(dev);
- cont->getStorage()->removeDmTableTo(*this);
+ getStorage()->eraseCachedFreeInfo(dev);
+ getStorage()->removeDmTableTo(*this);
y2mil("ret:" << ret);
return( ret );
}
-string Volume::getMountByString( MountByType mby, const string& dev,
- const string& uuid, const string& label ) const
+
+ string
+ Volume::getMountByString() const
{
string ret = dev;
- if( mby==MOUNTBY_UUID )
- {
- ret = "UUID=" + uuid;
- }
- else if( mby==MOUNTBY_LABEL )
- {
- ret = "LABEL=" + label;
- }
- else if( mby==MOUNTBY_ID )
- {
- if( !udevId().empty() )
- ret = udevId().front();
- }
- else if( mby==MOUNTBY_PATH )
+
+ switch (mount_by)
{
- ret = udevPath();
+ case MOUNTBY_UUID:
+ if (!uuid.empty())
+ ret = "UUID=" + uuid;
+ else
+ y2err("no uuid defined");
+ break;
+
+ case MOUNTBY_LABEL:
+ if (!label.empty())
+ ret = "LABEL=" + label;
+ else
+ y2err("no label defined");
+ break;
+
+ case MOUNTBY_ID:
+ if (!udevId().empty())
+ ret = "/dev/disk/by-id/" + udevId().front();
+ else
+ y2err("no udev-id defined");
+ break;
+
+ case MOUNTBY_PATH:
+ if (!udevPath().empty())
+ ret = "/dev/disk/by-path/" + udevPath();
+ else
+ y2err("no udev-path defined");
+ break;
+
+ case MOUNTBY_DEVICE:
+ break;
}
- return( ret );
+
+ return ret;
}
-void Volume::getCommitActions( list<commitAction*>& l ) const
+
+void
+Volume::getCommitActions(list<commitAction>& l) const
{
if( deleted() )
{
- l.push_back( new commitAction( DECREASE, cont->type(),
- removeText(false), this, true ));
+ l.push_back(commitAction(DECREASE, cType(), removeText(false), this, true));
}
- else if( needShrink() )
+ else if( needShrink() && !format )
{
- l.push_back( new commitAction( DECREASE, cont->type(),
- resizeText(false), this, true ));
+ l.push_back(commitAction(DECREASE, cType(), resizeText(false), this, true));
}
else if( created() )
{
- l.push_back( new commitAction( INCREASE, cont->type(),
- createText(false), this, false ));
+ l.push_back(commitAction(INCREASE, cType(), createText(false), this, false));
}
- else if( needExtend() )
+ else if( needExtend() && !format )
{
- l.push_back( new commitAction( INCREASE, cont->type(),
- resizeText(false), this, true ));
+ l.push_back(commitAction(INCREASE, cType(), resizeText(false), this, true));
}
else if( format )
{
- l.push_back( new commitAction( FORMAT, cont->type(),
- formatText(false), this, true ));
+ l.push_back(commitAction(FORMAT, cType(), formatText(false), this, true));
}
- else if ( needCrsetup(false) )
+ else if( needCrsetup(false) )
{
- l.push_back(new commitAction(mp.empty()?INCREASE:FORMAT, cont->type(),
- crsetupText(false), this, mp.empty()));
+ l.push_back(commitAction(mp.empty()?INCREASE:FORMAT, cType(),
+ crsetupText(false), this, mp.empty()));
}
- else if( mp != orig_mp ||
- (cont->getStorage()->instsys()&&mp=="swap") )
+ else if (mp != orig_mp || (getStorage()->instsys() && mp=="swap"))
{
- l.push_back( new commitAction( MOUNT, cont->type(),
- mountText(false), this, false ));
+ l.push_back(commitAction(MOUNT, cType(), mountText(false), this, false));
}
else if( label != orig_label )
{
- l.push_back( new commitAction( MOUNT, cont->type(),
- labelText(false), this, false ));
+ l.push_back(commitAction(MOUNT, cType(), labelText(false), this, false));
}
else if( needFstabUpdate() )
{
- l.push_back( new commitAction( MOUNT, cont->type(),
- fstabUpdateText(), this, false ));
+ l.push_back(commitAction(MOUNT, cType(), fstabUpdateText(), this, false));
}
}
-string Volume::fstabUpdateText() const
+
+Text Volume::fstabUpdateText() const
{
- string txt;
- EtcFstab* fstab = cont->getStorage()->getFstab();
+ Text txt;
+ const EtcFstab* fstab = getStorage()->getFstab();
if( !orig_mp.empty() && mp.empty() )
txt = fstab->removeText( false, inCryptotab(), orig_mp );
else
@@ -2392,66 +2571,69 @@
return( txt );
}
-string Volume::getFstabDevice()
+string Volume::getFstabDevice() const
{
string ret = dev;
- const Loop* l = NULL;
- if( cont->type()==LOOP )
- l = static_cast<const Loop*>(this);
- if( l && dmcrypt() && !optNoauto() )
- ret = l->loopFile();
+ if( cType() == TMPFSC )
+ ret = "tmpfs";
+ else if (cType() == LOOP)
+ {
+ const Loop* l = static_cast<const Loop*>(this);
+ if( l && dmcrypt() )
+ ret = l->loopFile();
+ }
y2mil( "ret:" << ret );
return( ret );
}
-string Volume::getFstabDentry()
+string Volume::getFstabDentry() const
{
string ret;
- const Loop* l = NULL;
- if( cont->type()==LOOP )
- l = static_cast<const Loop*>(this);
- if( cont->type()!=LOOP )
+ if (cType() != LOOP)
{
if( dmcrypt() )
- ret = (inCryptotab()||optNoauto())?dev:dmcrypt_dev;
+ ret = inCryptotab()?dev:dmcrypt_dev;
+ else if( cType() == TMPFSC )
+ ret = "tmpfs";
else
- ret = getMountByString( mount_by, dev, uuid, label );
+ ret = getMountByString();
}
else
{
- if( dmcrypt() && !optNoauto() )
+ const Loop* l = static_cast<const Loop*>(this);
+ if( dmcrypt() )
ret = dmcrypt_dev;
- else
+ else if( l )
ret = l->loopFile();
}
return( ret );
}
-void Volume::getFstabOpts( list<string>& l )
+
+list<string>
+Volume::getFstabOpts() const
{
+ list<string> l;
+
if( fstab_opt.empty() )
- {
- l.clear();
l.push_back( (is_loop&&!dmcrypt())?"noatime":"defaults" );
- }
else
l = splitString( fstab_opt, "," );
list<string>::iterator loop = find( l.begin(), l.end(), "loop" );
if( loop == l.end() )
- loop = find_if( l.begin(), l.end(), find_begin( "loop=" ) );
+ loop = find_if( l.begin(), l.end(), string_starts_with( "loop=" ) );
list<string>::iterator enc =
- find_if( l.begin(), l.end(), find_begin( "encryption=" ) );
+ find_if( l.begin(), l.end(), string_starts_with( "encryption=" ) );
string lstr;
- if( optNoauto() &&
- ((encryption!=ENC_NONE && !dmcrypt()) || cont->type()==LOOP ))
+ if( (encryption!=ENC_NONE && !dmcrypt()) || cType() == LOOP )
{
lstr = "loop";
if( !fstab_loop_dev.empty() && !dmcrypt() )
lstr += "="+fstab_loop_dev;
}
string estr;
- if( optNoauto() && encryption!=ENC_NONE && !dmcrypt() )
- estr = "encryption=" + Volume::encTypeString(encryption);
+ if( encryption!=ENC_NONE && !dmcrypt() )
+ estr = "encryption=" + toString(encryption);
if( loop!=l.end() )
l.erase( loop );
if( enc!=l.end() )
@@ -2462,12 +2644,15 @@
l.push_front( lstr );
if( l.size()>1 && (enc=find( l.begin(), l.end(), "defaults" ))!=l.end() )
l.erase(enc);
+
+ return l;
}
+
bool Volume::getLoopFile( string& fname ) const
{
const Loop* l = NULL;
- if( cont->type()==LOOP )
+ if (cType() == LOOP)
l = static_cast<const Loop*>(this);
if( l )
fname = l->loopFile();
@@ -2481,7 +2666,7 @@
list<string>::const_iterator i = opt.begin();
while( !ret && i!=opt.end() )
{
- ret = (*i=="usrquota") || (*i=="usrquota") ||
+ ret = (*i=="usrquota") || (*i=="grpquota") ||
i->find("usrjquota=")==0 || i->find("grpjquota=")==0;
++i;
}
@@ -2489,15 +2674,10 @@
return( ret );
}
-bool Volume::pvEncryption() const
- {
- return( encryption==ENC_LUKS && getUsedByType()==UB_LVM );
- }
-
bool Volume::noFreqPassno() const
{
- return( fs==SWAP || fs==NFS || fs==VFAT || fs==NTFS ||
- fs==FSUNKNOWN || is_loop || optNoauto() );
+ return( fs==SWAP || fs==NFS || fs==NFS4 || fs==VFAT || fs==NTFS ||
+ fs==FSUNKNOWN || fs==TMPFS || is_loop || optNoauto() );
}
unsigned Volume::fstabFreq() const
@@ -2511,36 +2691,41 @@
unsigned Volume::fstabPassno() const
{
unsigned ret = 2;
- if( noFreqPassno() || (encryption!=ENC_NONE&&dmcrypt()) )
+ if( noFreqPassno() || (encryption!=ENC_NONE) )
ret = 0;
else if( mp=="/" )
ret = 1;
return( ret );
}
-int Volume::doFstabUpdate()
+bool Volume::pvEncryption() const
+ {
+ return( encryption==ENC_LUKS && isUsedBy(UB_LVM) );
+ }
+
+int Volume::doFstabUpdate( bool force_rewrite )
{
int ret = 0;
bool changed = false;
- y2mil( "dev:" << *this );
+ y2mil( "force_rewrite:" << force_rewrite );
+ y2mil(*this);
if( !ignore_fstab )
{
- EtcFstab* fstab = cont->getStorage()->getFstab();
+ EtcFstab* fstab = getStorage()->getFstab();
FstabEntry entry;
- if ((!orig_mp.empty() || orig_encryption != ENC_NONE) &&
+ if( (!orig_mp.empty() || orig_encryption != ENC_NONE) &&
(deleted() || (mp.empty() && !pvEncryption())) &&
- (fstab->findDevice( dev, entry ) ||
- fstab->findDevice( alt_names, entry ) ||
- (cType()==LOOP && fstab->findMount( orig_mp, entry )) ||
- (cType()==LOOP && fstab->findMount( mp, entry )) ))
+ (fstab->findDevice( dev, entry ) ||
+ fstab->findDevice( alt_names, entry ) ||
+ ((cType()==LOOP||cType()==TMPFSC) && fstab->findMount( orig_mp, entry )) ||
+ ((cType()==LOOP||cType()==TMPFSC) && fstab->findMount( mp, entry ))) )
{
changed = true;
- if( !silent() )
+ if( !silent )
{
- cont->getStorage()->showInfoCb(
- fstab->removeText(true, entry.cryptotab, entry.mount));
+ getStorage()->showInfoCb(fstab->removeText(true, entry.cryptotab, entry.mount));
}
- y2milestone( "before removeEntry" );
+ y2mil("before removeEntry");
ret = fstab->removeEntry( entry );
}
else if ((!mp.empty() || pvEncryption()) && !deleted())
@@ -2548,10 +2733,13 @@
string fname;
if( fstab->findDevice( dev, entry ) ||
fstab->findDevice( alt_names, entry ) ||
- (cont->type()==LOOP && getLoopFile(fname) &&
- fstab->findDevice( fname, entry )))
+ (cType() == LOOP && getLoopFile(fname) &&
+ fstab->findDevice( fname, entry )) ||
+ (cType() == TMPFSC && !mp.empty() &&
+ fstab->findMount( mp, entry )))
{
y2mil( "changed:" << entry );
+ changed = force_rewrite;
FstabChange che( entry );
string de = getFstabDentry();
if( orig_mp!=mp )
@@ -2562,7 +2750,7 @@
if( fstab_opt!=orig_fstab_opt )
{
changed = true;
- getFstabOpts( che.opts );
+ che.opts = getFstabOpts();
if( encryption!=ENC_NONE )
che.dentry = de;
}
@@ -2573,10 +2761,10 @@
changed = true;
che.dentry = de;
}
- if( fs != detected_fs || che.fs!=fs_names[fs] )
+ if( fs != detected_fs || che.fs!=toString(fs) )
{
changed = true;
- che.fs = fs_names[fs];
+ che.fs = toString(fs);
che.freq = fstabFreq();
che.passno = fstabPassno();
}
@@ -2593,11 +2781,13 @@
che.freq = fstabFreq();
che.passno = fstabPassno();
}
+ che.tmpcrypt = dmcrypt() && isTmpCryptMp(mp) &&
+ crypt_pwd.empty();
if( changed )
{
- if( !silent() && !fstab_added )
+ if( !silent && !fstab_added )
{
- cont->getStorage()->showInfoCb(
+ getStorage()->showInfoCb(
fstab->updateText( true, inCryptotab(),
che.mount ));
}
@@ -2611,7 +2801,7 @@
FstabChange che;
che.device = getFstabDevice();
if( !udevId().empty() )
- che.device = udevId().front();
+ che.device = "/dev/disk/by-id/" + udevId().front();
che.dentry = getFstabDentry();
che.encr = encryption;
if( dmcrypt() && isTmpCryptMp(mp) && crypt_pwd.empty() )
@@ -2621,37 +2811,41 @@
getFreeLoop();
che.loop_dev = fstab_loop_dev;
}
- che.fs = fs_names[fs];
- getFstabOpts( che.opts );
+ che.fs = toString(fs);
+ che.opts = getFstabOpts();
che.mount = mp;
che.freq = fstabFreq();
che.passno = fstabPassno();
- if( !silent() )
+ if( !silent )
{
- cont->getStorage()->showInfoCb(
+ getStorage()->showInfoCb(
fstab->addText( true, inCryptotab(), che.mount ));
}
ret = fstab->addEntry( che );
fstab_added = true;
}
}
- if( changed && ret==0 && cont->getStorage()->isRootMounted() )
+ if( changed && ret==0 && getStorage()->isRootMounted() )
{
ret = fstab->flush();
}
}
- if( ret==0 && !format && !cont->getStorage()->instsys() &&
+ if( ret==0 && !format && !getStorage()->instsys() &&
fstab_opt!=orig_fstab_opt && !orig_fstab_opt.empty() &&
mp==orig_mp && mp!="swap" )
{
SystemCmd c;
y2mil( "fstab_opt:" << fstab_opt << " fstab_opt_orig:" << orig_fstab_opt );
y2mil( "remount:" << *this );
- int r = umount( mp );
- y2mil( "remount umount:" << r );
- if( r==0 )
+ int r = 0;
+ if( isMounted() )
+ {
+ r = umount( mp );
+ y2mil( "remount umount:" << r );
+ }
+ if( r==0 || r==VOLUME_UMOUNT_NOT_MOUNTED )
{
- ret = mount(cont->getStorage()->prependRoot(mp));
+ ret = mount(getStorage()->prependRoot(mp));
y2mil( "remount mount:" << ret );
}
else
@@ -2661,76 +2855,31 @@
if( c.retcode()!=0 )
ret = VOLUME_REMOUNT_FAILED;
}
- if( !cont->getStorage()->instsys() &&
+ if( !getStorage()->instsys() &&
haveQuota(fstab_opt)!=haveQuota(orig_fstab_opt) )
{
c.execute( "/etc/init.d/boot.quota restart" );
}
}
- y2milestone( "changed:%d ret:%d", changed, ret );
+ y2mil("changed:" << changed << " ret:" << ret);
return( ret );
}
void Volume::fstabUpdateDone()
{
- y2milestone( "begin" );
+ y2mil("begin");
orig_fstab_opt = fstab_opt;
orig_mount_by = mount_by;
orig_encryption = encryption;
}
-EncryptType Volume::toEncType( const string& val )
- {
- EncryptType ret = ENC_UNKNOWN;
- if( val=="none" || val.empty() )
- ret = ENC_NONE;
- else if( val=="twofish" )
- ret = ENC_TWOFISH_OLD;
- else if( val=="twofishSL92" )
- ret = ENC_TWOFISH256_OLD;
- else if( val=="twofish256" )
- ret = ENC_TWOFISH;
- return( ret );
- }
-
-FsType Volume::toFsType( const string& val )
- {
- enum FsType ret = FSNONE;
- while( ret!=FSUNKNOWN && val!=fs_names[ret] )
- {
- ret = FsType(ret-1);
- }
- return( ret );
- }
-
-MountByType Volume::toMountByType( const string& val )
- {
- enum MountByType ret = MOUNTBY_LABEL;
- while( ret!=MOUNTBY_DEVICE && val!=mb_names[ret] )
- {
- ret = MountByType(ret-1);
- }
- return( ret );
- }
-
-string Volume::sizeString() const
-{
- return byteToHumanString(1024 * size_k, false, 2, false);
-}
bool Volume::canUseDevice() const
{
- bool ret = getUsedByType()==UB_NONE && getMount().empty();
- return( ret );
+ bool ret = !isUsedBy() && getMount().empty();
+ return ret;
}
-string Volume::bootMount() const
- {
- if( Storage::arch()=="ia64" )
- return( "/boot/efi" );
- else
- return( "/boot" );
- }
bool Volume::needRemount() const
{
@@ -2753,65 +2902,128 @@
cont->setExtError( cmd, serr );
}
-string Volume::createText( bool doing ) const
+
+Text
+Volume::createText(bool doing) const
+{
+ Text txt;
+ if (doing)
{
- string txt;
- if( doing )
- {
- // displayed text during action, %1$s is replaced by device name e.g. /dev/hda1
- txt = sformat( _("Creating %1$s"), dev.c_str() );
- }
+ // displayed text during action, %1$s is replaced by device name e.g. /dev/hda1
+ txt = sformat(_("Creating volume %1$s"), dev.c_str());
+ }
else
- {
- // displayed text before action, %1$s is replaced by device name e.g. /dev/hda1
- txt = sformat( _("Create %1$s"), dev.c_str() );
- }
- return( txt );
+ {
+ if (mp == "swap")
+ {
+ // displayed text before action, %1$s is replaced by device name e.g. /dev/hda1
+ // %2$s is replaced by size (e.g. 623.5 MB)
+ txt = sformat(_("Create swap volume %1$s (%2$s)"), dev.c_str(),
+ sizeString().c_str());
+ }
+ else if (mp == "/")
+ {
+ // displayed text before action, %1$s is replaced by device name e.g. /dev/hda1
+ // %2$s is replaced by size (e.g. 623.5 MB)
+ // %3$s is replaced by file system type (e.g. reiserfs)
+ txt = sformat(_("Create root volume %1$s (%2$s) with %3$s"),
+ dev.c_str(), sizeString().c_str(), fsTypeString().c_str());
+ }
+ else if (mp == getStorage()->bootMount())
+ {
+ // displayed text before action, %1$s is replaced by device name e.g. /dev/hda1
+ // %2$s is replaced by size (e.g. 623.5 MB)
+ // %3$s is replaced by file system type (e.g. reiserfs)
+ txt = sformat(_("Create boot volume %1$s (%2$s) with %3$s"),
+ dev.c_str(), sizeString().c_str(), fsTypeString().c_str());
+ }
+ else if (!mp.empty())
+ {
+ if (encryption == ENC_NONE)
+ {
+ // displayed text before action, %1$s is replaced by device name e.g. /dev/hda1
+ // %2$s is replaced by size (e.g. 623.5 MB)
+ // %3$s is replaced by file system type (e.g. reiserfs)
+ // %4$s is replaced by mount point (e.g. /usr)
+ txt = sformat(_("Create volume %1$s (%2$s) for %4$s with %3$s"),
+ dev.c_str(), sizeString().c_str(), fsTypeString().c_str(),
+ mp.c_str());
+ }
+ else
+ {
+ // displayed text before action, %1$s is replaced by device name e.g. /dev/hda1
+ // %2$s is replaced by size (e.g. 623.5 MB)
+ // %3$s is replaced by file system type (e.g. reiserfs)
+ // %4$s is replaced by mount point (e.g. /usr)
+ txt = sformat(_("Create encrypted volume %1$s (%2$s) for %4$s with %3$s"),
+ dev.c_str(), sizeString().c_str(), fsTypeString().c_str(),
+ mp.c_str());
+ }
+ }
+ else
+ {
+ if (encryption == ENC_NONE)
+ {
+ // displayed text before action, %1$s is replaced by device name e.g. /dev/hda1
+ // %2$s is replaced by size (e.g. 623.5 MB)
+ txt = sformat(_("Create volume %1$s (%2$s)"), dev.c_str(), sizeString().c_str());
+ }
+ else
+ {
+ // displayed text before action, %1$s is replaced by device name e.g. /dev/hda1
+ // %2$s is replaced by size (e.g. 623.5 MB)
+ txt = sformat(_("Create encrypted volume %1$s (%2$s)"), dev.c_str(),
+ sizeString().c_str());
+ }
+ }
}
+ return txt;
+}
+
-string Volume::resizeText( bool doing ) const
+Text Volume::resizeText( bool doing ) const
{
- string txt;
- string d = dev;
+ Text txt;
if( doing )
{
if( needShrink() )
// displayed text during action, %1$s is replaced by device name e.g. /dev/hda1
// %2$s is replaced by size (e.g. 623.5 MB)
- txt = sformat( _("Shrinking %1$s to %2$s"), d.c_str(), sizeString().c_str() );
+ txt = sformat(_("Shrinking %1$s to %2$s"), dev.c_str(), sizeString().c_str());
else
// displayed text during action, %1$s is replaced by device name e.g. /dev/hda1
// %2$s is replaced by size (e.g. 623.5 MB)
- txt = sformat( _("Extending %1$s to %2$s"), d.c_str(), sizeString().c_str() );
+ txt = sformat(_("Extending %1$s to %2$s"), dev.c_str(), sizeString().c_str());
+ txt += Text(" ", " ");
// text displayed during action
- txt += string(" ") + _("(progress bar might not move)");
+ txt += _("(progress bar might not move)");
}
else
{
if( needShrink() )
// displayed text before action, %1$s is replaced by device name e.g. /dev/hda1
// %2$s is replaced by size (e.g. 623.5 MB)
- txt = sformat( _("Shrink %1$s to %2$s"), d.c_str(), sizeString().c_str() );
+ txt = sformat(_("Shrink %1$s to %2$s"), dev.c_str(), sizeString().c_str());
else
// displayed text before action, %1$s is replaced by device name e.g. /dev/hda1
// %2$s is replaced by size (e.g. 623.5 MB)
- txt = sformat( _("Extend %1$s to %2$s"), d.c_str(), sizeString().c_str() );
+ txt = sformat(_("Extend %1$s to %2$s"), dev.c_str(), sizeString().c_str());
}
- return( txt );
+ return txt;
}
-string Volume::removeText( bool doing ) const
+Text Volume::removeText( bool doing ) const
{
- string txt;
+ Text txt;
if( doing )
{
// displayed text during action, %1$s is replaced by device name e.g. /dev/hda1
- txt = sformat( _("Removing %1$s"), dev.c_str() );
+ txt = sformat( _("Removing volume %1$s"), dev.c_str() );
}
else
{
// displayed text before action, %1$s is replaced by device name e.g. /dev/hda1
- txt = sformat( _("Remove %1$s"), dev.c_str() );
+ txt = sformat( _("Remove volume %1$s"), dev.c_str() );
}
return( txt );
}
@@ -2823,17 +3035,35 @@
info.minor = mnr;
info.name = nm;
info.device = dev;
+ if( dmcrypt() )
+ info.crypt_device = dmcrypt_dev;
info.mount = mp;
info.mount_by = mount_by;
- info.usedByType = uby.type();
- info.usedByName = uby.name();
- info.usedByDevice = uby.device();
+
+ info.udevPath = udevPath();
+ info.udevId = boost::join(udevId(), " ");
+
+ info.usedBy = list<UsedByInfo>(uby.begin(), uby.end());
+
+ if (uby.empty())
+ {
+ info.usedByType = UB_NONE;
+ info.usedByDevice = "";
+ }
+ else
+ {
+ info.usedByType = uby.front().type();
+ info.usedByDevice = uby.front().device();
+ }
+
+ info.ignore_fstab = ignore_fstab;
info.fstab_options = fstab_opt;
info.uuid = uuid;
info.label = label;
info.encryption = encryption;
info.crypt_pwd = crypt_pwd;
info.fs = fs;
+ info.detected_fs = detected_fs;
info.format = format;
info.create = create;
info.mkfs_options = mkfs_opt;
@@ -2844,9 +3074,9 @@
info.ignore_fs = ignore_fs;
info.resize = size_k!=orig_size_k;
if( info.resize )
- info.OrigSizeK = orig_size_k;
+ info.origSizeK = orig_size_k;
else
- info.OrigSizeK = 0;
+ info.origSizeK = 0;
tinfo = info;
}
@@ -2854,171 +3084,86 @@
{
info.mount = fste.mount;
info.mount_by = fste.mount_by;
- info.fstab_options = mergeString( fste.opts, "," );
+ info.fstab_options = boost::join( fste.opts, "," );
info.encryption = fste.encr;
tinfo = info;
}
-ostream& Volume::logVolume( ostream& file ) const
- {
- file << dev << " fs=" << fs_names[fs];
- if( !uuid.empty() )
- file << " uuid=" << uuid;
- if( !label.empty() )
- file << " label=" << label;
- if( !mp.empty() )
- file << " mount=" << mp;
- if( !fstab_opt.empty() )
- file << " fstopt=" << fstab_opt;
- if( mount_by != MOUNTBY_DEVICE )
- file << " mountby=" << mb_names[mount_by];
- if( is_loop && !fstab_loop_dev.empty() )
- file << " loop=" << fstab_loop_dev;
- if( is_loop && encryption!=ENC_NONE )
- file << " encr=" << enc_names[encryption];
-#ifdef DEBUG_LOOP_CRYPT_PASSWORD
- if( is_loop && encryption!=ENC_NONE && !crypt_pwd.empty() )
- file << " pwd:" << crypt_pwd;
- if( is_loop && encryption!=ENC_NONE && !orig_crypt_pwd.empty() &&
- orig_crypt_pwd!=crypt_pwd )
- file << " orig_pwd:" << orig_crypt_pwd;
-#endif
- file << endl;
- return( file );
- }
-
-void Volume::getTestmodeData( const string& data )
- {
- list<string> l = splitString( data );
- if( l.begin()!=l.end() )
- l.erase( l.begin() );
- map<string,string> m = makeMap( l );
- map<string,string>::const_iterator i = m.find( "fs" );
- if( i!=m.end() )
- fs = detected_fs = toFsType(i->second);
- i = m.find( "uuid" );
- if( i!=m.end() )
- uuid = i->second;
- i = m.find( "label" );
- if( i!=m.end() )
- label = orig_label = i->second;
- i = m.find( "mount" );
- if( i!=m.end() )
- mp = orig_mp = i->second;
- i = m.find( "mountby" );
- if( i!=m.end() )
- mount_by = orig_mount_by = toMountByType(i->second);
- i = m.find( "fstopt" );
- if( i!=m.end() )
- fstab_opt = orig_fstab_opt = i->second;
- i = m.find( "loop" );
- if( i!=m.end() )
- {
- loop_dev = fstab_loop_dev = i->second;
- is_loop = true;
- loop_active = true;
- }
- i = m.find( "encr" );
- if( i!=m.end() )
- encryption = orig_encryption = toEncType(i->second);
- i = m.find( "pwd" );
- if( i!=m.end() )
- orig_crypt_pwd = crypt_pwd = i->second;
- }
-
-namespace storage
-{
std::ostream& operator<< (std::ostream& s, const Volume &v )
{
- s << "Device:" << v.dev;
- if( v.numeric )
- {
- if( v.num>0 )
- s << " Nr:" << v.num;
- }
- else if( v.nm!=v.dev )
- s << " Name:" << v.nm;
- s << " SizeK:" << v.size_k;
+ s << dynamic_cast<const Device&>(v);
+ s << " Nr:" << v.num;
if( v.size_k != v.orig_size_k )
s << " orig_SizeK:" << v.orig_size_k;
- if( v.mjr!=0 || v.mnr!=0 )
- s << " Node <" << v.mjr << ":" << v.mnr << ">";
if( v.ronly )
s << " readonly";
- if( v.del )
- s << " deleted";
- if( v.create )
- s << " created";
if( v.format )
s << " format";
- if( v.silnt )
- s << " silent";
if( v.ignore_fstab )
s << " ignoreFstab";
if( v.ignore_fs )
s << " ignoreFs";
- s << v.uby;
+ if (!v.uby.empty())
+ s << " usedby:" << v.uby;
if( v.fs != storage::FSUNKNOWN )
{
- s << " fs:" << Volume::fs_names[v.fs];
+ s << " fs:" << toString(v.fs);
if( v.fs != v.detected_fs && v.detected_fs!=storage::FSUNKNOWN )
- s << " det_fs:" << Volume::fs_names[v.detected_fs];
+ s << " det_fs:" << toString(v.detected_fs);
}
- if( v.mp.length()>0 )
+ if (!v.mp.empty())
{
s << " mount:" << v.mp;
- if( v.mp != v.orig_mp && v.orig_mp.length()>0 )
- s << " orig_mount:" << v.orig_mp;
if( !v.is_mounted )
s << " not_mounted";
}
+ if( v.mp != v.orig_mp && !v.orig_mp.empty() )
+ s << " orig_mount:" << v.orig_mp;
if( v.mount_by != storage::MOUNTBY_DEVICE )
{
- s << " mount_by:" << Volume::mb_names[v.mount_by];
+ s << " mount_by:" << toString(v.mount_by);
if( v.mount_by != v.orig_mount_by )
- s << " orig_mount_by:" << Volume::mb_names[v.orig_mount_by];
+ s << " orig_mount_by:" << toString(v.orig_mount_by);
}
- if( v.uuid.length()>0 )
+ if (!v.uuid.empty())
{
s << " uuid:" << v.uuid;
}
- if( v.label.length()>0 )
+ if (!v.label.empty())
{
s << " label:" << v.label;
}
- if( v.label != v.orig_label && v.orig_label.length()>0 )
+ if( v.label != v.orig_label && !v.orig_label.empty() )
s << " orig_label:" << v.orig_label;
- if( v.fstab_opt.length()>0 )
+ if( !v.fstab_opt.empty() )
{
s << " fstopt:" << v.fstab_opt;
- if( v.fstab_opt != v.orig_fstab_opt && v.orig_fstab_opt.length()>0 )
+ if( v.fstab_opt != v.orig_fstab_opt && !v.orig_fstab_opt.empty() )
s << " orig_fstopt:" << v.orig_fstab_opt;
}
- if( v.mkfs_opt.length()>0 )
+ if (!v.mkfs_opt.empty())
{
s << " mkfsopt:" << v.mkfs_opt;
}
- if( v.tunefs_opt.length()>0 )
+ if (!v.tunefs_opt.empty())
{
s << " tunefsopt:" << v.tunefs_opt;
}
- if( v.dtxt.length()>0 )
+ if (!v.dtxt.empty())
{
s << " dtxt:" << v.dtxt;
}
- if( v.alt_names.begin() != v.alt_names.end() )
- {
+ if (!v.alt_names.empty())
s << " alt_names:" << v.alt_names;
- }
if( v.encryption != storage::ENC_NONE ||
v.orig_encryption != storage::ENC_NONE )
{
- s << " encr:" << v.enc_names[v.encryption];
+ s << " encr:" << toString(v.encryption);
if( v.encryption != v.orig_encryption &&
v.orig_encryption!=storage::ENC_NONE )
- s << " orig_encr:" << v.enc_names[v.orig_encryption];
-#ifdef DEBUG_LOOP_CRYPT_PASSWORD
+ s << " orig_encr:" << toString(v.orig_encryption);
+#ifdef DEBUG_CRYPT_PASSWORD
s << " pwd:" << v.crypt_pwd;
if( v.orig_crypt_pwd.empty() && v.crypt_pwd!=v.orig_crypt_pwd )
s << " orig_pwd:" << v.orig_crypt_pwd;
@@ -3041,128 +3186,55 @@
return( s );
}
-}
-string
-Volume::logDifference( const Volume& rhs ) const
+ void
+ Volume::logDifference(std::ostream& log, const Volume& rhs) const
{
- string ret = "Device:" + dev;
- if( dev!=rhs.dev )
- ret += "-->"+rhs.dev;
- if( numeric && num!=rhs.num )
- ret += " Nr:" + decString(num) + "-->" + decString(rhs.num);
- if( !numeric && nm!=rhs.nm )
- ret += " Name:" + nm + "-->" + rhs.nm;
- if( size_k!=rhs.size_k )
- ret += " SizeK:" + decString(size_k) + "-->" + decString(rhs.size_k);
- if( orig_size_k!=rhs.orig_size_k )
- ret += " orig_SizeK:" + decString(orig_size_k) + "-->" + decString(rhs.size_k);
- if( mjr!=rhs.mjr )
- ret += " SizeK:" + decString(mjr) + "-->" + decString(rhs.mjr);
- if( mnr!=rhs.mnr )
- ret += " SizeK:" + decString(mnr) + "-->" + decString(rhs.mnr);
- if( del!=rhs.del )
- {
- if( rhs.del )
- ret += " -->deleted";
- else
- ret += " deleted-->";
- }
- if( create!=rhs.create )
- {
- if( rhs.create )
- ret += " -->created";
- else
- ret += " created-->";
- }
- if( ronly!=rhs.ronly )
- {
- if( rhs.ronly )
- ret += " -->readonly";
- else
- ret += " readonly-->";
- }
- if( format!=rhs.format )
- {
- if( rhs.format )
- ret += " -->format";
- else
- ret += " format-->";
- }
- if( uby!=rhs.uby )
- {
- std::ostringstream b;
- classic(b);
- b << uby << "-->" << string(rhs.uby);
- ret += b.str();
- }
- if( fs!=rhs.fs )
- ret += " fs:" + Volume::fs_names[fs] + "-->" + Volume::fs_names[rhs.fs];
- if( detected_fs!=rhs.detected_fs )
- ret += " det_fs:" + Volume::fs_names[detected_fs] + "-->" +
- Volume::fs_names[rhs.detected_fs];
- if( mp!=rhs.mp )
- ret += " mount:" + mp + "-->" + rhs.mp;
- if( orig_mp!=rhs.orig_mp )
- ret += " orig_mount:" + orig_mp + "-->" + rhs.orig_mp;
- if( is_mounted!=rhs.is_mounted )
- {
- if( rhs.is_mounted )
- ret += " -->mounted";
- else
- ret += " mounted-->";
- }
- if( mount_by!=rhs.mount_by )
- ret += " mount_by:" + Volume::mb_names[mount_by] + "-->" +
- Volume::mb_names[rhs.mount_by];
- if( orig_mount_by!=rhs.orig_mount_by )
- ret += " orig_mount_by:" + Volume::mb_names[orig_mount_by] + "-->" +
- Volume::mb_names[rhs.orig_mount_by];
- if( uuid!=rhs.uuid )
- ret += " uuid:" + uuid + "-->" + rhs.uuid;
- if( label!=rhs.label )
- ret += " label:" + label + "-->" + rhs.label;
- if( orig_label!=rhs.orig_label )
- ret += " orig_label:" + orig_label + "-->" + rhs.orig_label;
- if( fstab_opt!=rhs.fstab_opt )
- ret += " fstopt:" + fstab_opt + "-->" + rhs.fstab_opt;
- if( orig_fstab_opt!=rhs.orig_fstab_opt )
- ret += " orig_fstopt:" + orig_fstab_opt + "-->" + rhs.orig_fstab_opt;
- if( mkfs_opt!=rhs.mkfs_opt )
- ret += " mkfsopt:" + mkfs_opt + "-->" + rhs.mkfs_opt;
- if( tunefs_opt!=rhs.tunefs_opt )
- ret += " tunefsopt:" + tunefs_opt + "-->" + rhs.tunefs_opt;
- if( dtxt!=rhs.dtxt )
- ret += " dtxt:" + dtxt + "-->" + rhs.dtxt;
- if( is_loop!=rhs.is_loop )
- {
- if( rhs.is_loop )
- ret += " -->loop";
- else
- ret += " loop-->";
- }
- if( loop_active!=rhs.loop_active )
- {
- if( rhs.loop_active )
- ret += " -->loop_active";
- else
- ret += " loop_active-->";
- }
- if( loop_dev!=rhs.loop_dev )
- ret += " loop:" + loop_dev + "-->" + rhs.loop_dev;
- if( fstab_loop_dev!=rhs.fstab_loop_dev )
- ret += " fstab_loop:" + fstab_loop_dev + "-->" + rhs.fstab_loop_dev;
- if( encryption!=rhs.encryption )
- ret += " encr:" + Volume::enc_names[encryption] + "-->" +
- Volume::enc_names[rhs.encryption];
- if( orig_encryption!=rhs.orig_encryption )
- ret += " orig_encr:" + Volume::enc_names[orig_encryption] + "-->" +
- Volume::enc_names[rhs.orig_encryption];
-#ifdef DEBUG_LOOP_CRYPT_PASSWORD
- if( crypt_pwd!=rhs.crypt_pwd )
- ret += " pwd:" + crypt_pwd + "-->" + rhs.crypt_pwd;
+ Device::logDifference(log, rhs);
+
+ logDiff(log, "num", num, rhs.num);
+
+ logDiff(log, "size_k", size_k, rhs.size_k);
+ logDiff(log, "orig_size_k", orig_size_k, rhs.orig_size_k);
+
+ logDiff(log, "readonly", ronly, rhs.ronly);
+ logDiff(log, "format", format, rhs.format);
+
+ logDiff(log, "usedby", uby, rhs.uby);
+
+ logDiffEnum(log, "fs", fs, rhs.fs);
+ logDiffEnum(log, "det_fs", detected_fs, rhs.detected_fs);
+
+ logDiff(log, "mount", mp, rhs.mp);
+ logDiff(log, "orig_mount", orig_mp, rhs.orig_mp);
+
+ logDiff(log, "is_mounted", is_mounted, rhs.is_mounted);
+
+ logDiffEnum(log, "mount_by", mount_by, rhs.mount_by);
+ logDiffEnum(log, "orig_mount_by", orig_mount_by, rhs.orig_mount_by);
+
+ logDiff(log, "uuid", uuid, rhs.uuid);
+
+ logDiff(log, "label", label, rhs.label);
+ logDiff(log, "orig_label", orig_label, rhs.orig_label);
+
+ logDiff(log, "fstopt", fstab_opt, rhs.fstab_opt);
+ logDiff(log, "orig_fstopt", orig_fstab_opt, rhs.orig_fstab_opt);
+ logDiff(log, "mkfsopt", mkfs_opt, rhs.mkfs_opt);
+ logDiff(log, "tunefsopt", tunefs_opt, rhs.tunefs_opt);
+
+ logDiff(log, "dtxt", dtxt, rhs.dtxt);
+
+ logDiff(log, "is_loop", is_loop, rhs.is_loop);
+ logDiff(log, "loop_active", loop_active, rhs.loop_active);
+ logDiff(log, "loop_dev", loop_dev, rhs.loop_dev);
+ logDiff(log, "fstab_loop_dev", fstab_loop_dev, rhs.fstab_loop_dev);
+
+ logDiffEnum(log, "encr", encryption, rhs.encryption);
+ logDiffEnum(log, "orig_encr", orig_encryption, rhs.orig_encryption);
+#ifdef DEBUG_CRYPT_PASSWORD
+ logDiff(log, "pwd", crypt_pwd, rhs.crypt_pwd);
#endif
- return( ret );
}
@@ -3172,7 +3244,7 @@
((numeric&&num==rhs.num)||(!numeric&&nm==rhs.nm)) &&
size_k==rhs.size_k && mnr==rhs.mnr && mjr==rhs.mjr &&
ronly==rhs.ronly && create==rhs.create && del==rhs.del &&
- silnt==rhs.silnt && format==rhs.format &&
+ silent==rhs.silent && format==rhs.format &&
fstab_added==rhs.fstab_added &&
fs==rhs.fs && mount_by==rhs.mount_by &&
uuid==rhs.uuid && label==rhs.label && mp==rhs.mp &&
@@ -3184,76 +3256,17 @@
uby==rhs.uby );
}
-Volume& Volume::operator= ( const Volume& rhs )
- {
- y2deb("operator= from " << rhs.dev);
- dev = rhs.dev;
- numeric = rhs.numeric;
- num = rhs.num;
- nm = rhs.nm;
- size_k = rhs.size_k;
- orig_size_k = rhs.orig_size_k;
- mnr = rhs.mnr;
- mjr = rhs.mjr;
- ronly = rhs.ronly;
- create = rhs.create;
- del = rhs.del;
- silnt = rhs.silnt;
- format = rhs.format;
- fstab_added = rhs.fstab_added;
- fs = rhs.fs;
- detected_fs = rhs.detected_fs;
- mount_by = rhs.mount_by;
- orig_mount_by = rhs.orig_mount_by;
- uuid = rhs.uuid;
- label = rhs.label;
- orig_label = rhs.orig_label;
- mp = rhs.mp;
- orig_mp = rhs.orig_mp;
- fstab_opt = rhs.fstab_opt;
- orig_fstab_opt = rhs.orig_fstab_opt;
- mkfs_opt = rhs.mkfs_opt;
- tunefs_opt = rhs.tunefs_opt;
- dtxt = rhs.dtxt;
- is_loop = rhs.is_loop;
- loop_active = rhs.loop_active;
- is_mounted = rhs.is_mounted;
- encryption = rhs.encryption;
- orig_encryption = rhs.orig_encryption;
- loop_dev = rhs.loop_dev;
- fstab_loop_dev = rhs.fstab_loop_dev;
- crypt_pwd = rhs.crypt_pwd;
- orig_crypt_pwd = rhs.orig_crypt_pwd;
- uby = rhs.uby;
- alt_names = rhs.alt_names;
- return( *this );
- }
-
-Volume::Volume( const Volume& rhs ) : cont(rhs.cont)
- {
- y2deb("constructed vol by copy constructor from " << rhs.dev);
- *this = rhs;
- }
-
-bool Volume::isTmpCryptMp( const string& mp )
- {
- string *end = tmp_mount + lengthof(tmp_mount);
- y2mil( "lengthof(tmp_mount):" << lengthof(tmp_mount) );
- y2mil( "find mp:" << mp << " is:" << (find( tmp_mount, end, mp )!=end) );
- return( find( tmp_mount, end, mp )!=end );
- }
-
-string Volume::fs_names[] = { "unknown", "reiserfs", "ext2", "ext3", "vfat",
- "xfs", "jfs", "hfs", "ntfs", "swap", "hfsplus",
- "nfs", "none" };
-
-string Volume::mb_names[] = { "device", "uuid", "label", "id", "path" };
-string Volume::enc_names[] = { "none", "twofish256", "twofish",
- "twofishSL92", "luks", "unknown" };
+ bool
+ Volume::isTmpCryptMp(const string& mp)
+ {
+ const string* end = tmp_mount + lengthof(tmp_mount);
+ bool ret = find(tmp_mount, end, mp) != end;
+ y2mil("find mp:" << mp << " ret:" << ret);
+ return ret;
+ }
-string Volume::tmp_mount[] = { "swap", "/tmp", "/var/tmp" };
-const string Volume::empty_string;
-const list<string> Volume::empty_slist;
+ const string Volume::tmp_mount[] = { "swap", "/tmp", "/var/tmp" };
+}
Modified: branches/SuSE-Code-11-SP2-Branch/storage/libstorage/src/Volume.h
URL: http://svn.opensuse.org/viewcvs/yast/branches/SuSE-Code-11-SP2-Branch/stora…
==============================================================================
--- branches/SuSE-Code-11-SP2-Branch/storage/libstorage/src/Volume.h (original)
+++ branches/SuSE-Code-11-SP2-Branch/storage/libstorage/src/Volume.h Tue May 17 13:39:44 2011
@@ -1,5 +1,5 @@
/*
- * Copyright (c) [2004-2009] Novell, Inc.
+ * Copyright (c) [2004-2010] Novell, Inc.
*
* All Rights Reserved.
*
@@ -23,12 +23,18 @@
#ifndef VOLUME_H
#define VOLUME_H
-#include "y2storage/StorageInterface.h"
-#include "y2storage/StorageTypes.h"
-#include "y2storage/StorageTmpl.h"
+#include "storage/Blkid.h"
+#include "storage/StorageInterface.h"
+#include "storage/StorageTypes.h"
+#include "storage/StorageTmpl.h"
+#include "storage/Device.h"
+#include "storage/Enum.h"
+
namespace storage
{
+ using std::list;
+
class SystemCmd;
class ProcMounts;
@@ -36,55 +42,45 @@
class FstabEntry;
class Container;
class Storage;
+
-class Volume
+ class Volume : public Device
{
friend class Storage;
public:
- Volume( const Container& d, unsigned Pnr, unsigned long long SizeK );
- Volume( const Container& d, const string& PName, unsigned long long SizeK );
- Volume( const Container& d );
- Volume( const Volume& );
- Volume& operator=( const Volume& );
+ Volume(const Container& c, unsigned Pnr, unsigned long long SizeK);
+ Volume(const Container& c, const string& name, const string& device);
+ Volume(const Container& c, const string& name, const string& device,
+ SystemInfo& systeminfo);
+ Volume(const Container& c, const xmlNode* node);
+ Volume(const Container& c, const Volume& v);
virtual ~Volume();
- const string& device() const { return dev; }
+ void saveData(xmlNode* node) const;
+
const string& mountDevice() const;
const string& loopDevice() const { return( loop_dev ); }
const string& dmcryptDevice() const { return( dmcrypt_dev ); }
+
const Container* getContainer() const { return cont; }
+ Storage* getStorage() const;
+
storage::CType cType() const;
- bool deleted() const { return del; }
- bool created() const { return create; }
- bool silent() const { return silnt; }
- virtual const std::list<string> udevId() const { return empty_slist; }
- virtual const string& udevPath() const { return empty_string; }
- virtual string sysfsPath() const;
- void setDeleted( bool val=true ) { del=val; }
- void setCreated( bool val=true ) { create=val; }
void setReadonly( bool val=true ) { ronly=val; }
- void setSilent( bool val=true ) { silnt=val; }
bool ignoreFstab() const { return( ignore_fstab ); }
void setIgnoreFstab( bool val=true ) { ignore_fstab=val; }
bool ignoreFs() const { return( ignore_fs ); }
void setIgnoreFs( bool val=true ) { ignore_fs=val; }
void setFstabAdded( bool val=true ) { fstab_added=val; }
- bool sameDevice( const string& device ) const;
bool fstabAdded() const { return( fstab_added ); }
- void clearUsedBy() { uby.clear(); }
- void setUsedBy(storage::UsedByType ub_type, const string& ub_name) { uby.set(ub_type, ub_name); }
- const storage::usedBy& getUsedBy() const { return uby; }
- storage::UsedByType getUsedByType() const { return uby.type(); }
-
void getFsInfo( const Volume* source );
virtual int setFormat( bool format=true, storage::FsType fs=storage::REISERFS );
- void formattingDone() { format=false; detected_fs=fs; }
+ void formattingDone() { format=false; fs=detected_fs; }
bool getFormat() const { return format; }
- void rename( const string& newName );
int changeFstabOptions( const string& options );
int changeMountBy( storage::MountByType mby );
virtual int changeMount( const string& m );
@@ -97,6 +93,7 @@
const string& getLabel() const { return label; }
int setLabel( const string& val );
int eraseLabel() { label.erase(); orig_label.erase(); return 0; }
+ int eraseUuid() { uuid.erase(); orig_uuid.erase(); return 0; }
bool needLabel() const { return( label!=orig_label ); }
storage::EncryptType getEncryption() const { return encryption; }
void initEncryption( storage::EncryptType val=storage::ENC_LUKS )
@@ -109,12 +106,13 @@
const string& getMount() const { return mp; }
bool hasOrigMount() const { return !orig_mp.empty(); }
bool needRemount() const;
- bool needShrink() const { return(size_k<orig_size_k); }
- bool needExtend() const { return(size_k>orig_size_k); }
- long long extendSize() const { return(size_k-orig_size_k);}
+ bool needShrink() const { return !del && size_k<orig_size_k; }
+ bool needExtend() const { return !del && size_k>orig_size_k; }
+ long long extendSize() const { return size_k-orig_size_k; }
storage::FsType getFs() const { return fs; }
+ storage::FsType detectedFs() const { return detected_fs; }
void setFs( storage::FsType val ) { detected_fs=fs=val; }
- void setUuid( const string& id ) { uuid=id; }
+ void initUuid( const string& id ) { uuid=orig_uuid=id; }
void initLabel( const string& lbl ) { label=orig_label=lbl; }
storage::MountByType getMountBy() const { return mount_by; }
const string& getFstabOption() const { return fstab_opt; }
@@ -130,18 +128,12 @@
int setTunefsOption( const string& val ) { tunefs_opt=val; return 0; }
const string& getDescText() const { return dtxt; }
int setDescText( const string& val ) { dtxt=val; return 0; }
- const std::list<string>& altNames() const { return( alt_names ); }
unsigned nr() const { return num; }
- unsigned long long sizeK() const { return size_k; }
unsigned long long origSizeK() const { return orig_size_k; }
- const string& name() const { return nm; }
- unsigned long minorNr() const { return mnr; }
- unsigned long majorNr() const { return mjr; }
bool isNumeric() const { return numeric; }
- void setMajorMinor( unsigned long Major, unsigned long Minor )
- { mjr=Major; mnr=Minor; }
void setSize( unsigned long long SizeK ) { size_k=orig_size_k=SizeK; }
virtual void setResizedSize( unsigned long long SizeK ) { size_k=SizeK; }
+ void setUsedByUuid( UsedByType type, const string& uuid );
void setDmcryptDev( const string& dm, bool active );
void setDmcryptDevEnc( const string& dm, storage::EncryptType typ, bool active );
virtual void forgetResize() { size_k=orig_size_k; }
@@ -157,11 +149,15 @@
{ return( !(*this<rhs) ); }
bool operator> ( const Volume& rhs ) const
{ return( !(*this<=rhs) ); }
- bool equalContent( const Volume& rhs ) const;
- string logDifference( const Volume& c ) const;
+
+ bool equalContent(const Volume& rhs) const;
+
+ void logDifference(std::ostream& log, const Volume& rhs) const;
+
friend std::ostream& operator<< (std::ostream& s, const Volume &v );
int prepareRemove();
+ int unaccessVol();
int umount( const string& mp="" );
int crUnsetup( bool force=false );
int mount( const string& mp="", bool ro=false );
@@ -170,84 +166,65 @@
int doFormat();
int doCrsetup();
int doSetLabel();
- int doFstabUpdate();
+ int doFstabUpdate(bool force=false);
int resizeFs();
void fstabUpdateDone();
bool isMounted() const { return( is_mounted ); }
- virtual string removeText(bool doing=true) const;
- virtual string createText(bool doing=true) const;
- virtual string resizeText(bool doing=true) const;
- virtual string formatText(bool doing=true) const;
- virtual void getCommitActions( std::list<storage::commitAction*>& l ) const;
- string mountText( bool doing=true ) const;
- string labelText( bool doing=true ) const;
- string losetupText( bool doing=true ) const;
- string crsetupText( bool doing=true ) const;
- string fstabUpdateText() const;
- string sizeString() const;
- string bootMount() const;
+ virtual Text removeText(bool doing) const;
+ virtual Text createText(bool doing) const;
+ virtual Text resizeText(bool doing) const;
+ virtual Text formatText(bool doing) const;
+ virtual void getCommitActions(list<commitAction>& l) const;
+ virtual Text mountText(bool doing) const;
+ Text labelText(bool doing) const;
+ Text losetupText(bool doing) const;
+ Text crsetupText(bool doing) const;
+ Text fstabUpdateText() const;
bool optNoauto() const;
bool inCryptotab() const { return( encryption!=ENC_NONE &&
encryption!=ENC_LUKS &&
!optNoauto() ); }
+ bool inCrypttab() const { return( encryption==ENC_LUKS ); }
bool pvEncryption() const;
- bool inCrypttab() const { return( encryption==ENC_LUKS && !optNoauto() ); }
virtual void print( std::ostream& s ) const { s << *this; }
int getFreeLoop();
int getFreeLoop( SystemCmd& loopData );
int getFreeLoop( SystemCmd& loopData, const std::list<unsigned>& ids );
void getInfo( storage::VolumeInfo& info ) const;
void mergeFstabInfo( storage::VolumeInfo& tinfo, const FstabEntry& fste ) const;
- void updateFsData();
+ void updateFsData( bool setUsedByLvm=false );
void triggerUdevUpdate() const;
- static bool loopInUse( Storage* sto, const string& loopdev );
+ static bool loopInUse(const Storage* sto, const string& loopdev);
- struct SkipDeleted
- {
- bool operator()(const Volume&d) const { return( !d.deleted());}
- };
- static SkipDeleted SkipDel;
static bool notDeleted( const Volume&d ) { return( !d.deleted() ); }
static bool isDeleted( const Volume&d ) { return( d.deleted() ); }
- static bool getMajorMinor( const string& device,
- unsigned long& Major, unsigned long& Minor );
+
static bool loopStringNum( const string& name, unsigned& num );
- static storage::EncryptType toEncType( const string& val );
- static storage::FsType toFsType( const string& val );
- static storage::MountByType toMountByType( const string& val );
- const string& fsTypeString() const { return fs_names[fs]; }
- static const string& fsTypeString( const storage::FsType type )
- { return fs_names[type]; }
- static const string& encTypeString( const storage::EncryptType type )
- { return enc_names[type]; }
- static const string& mbyTypeString( const storage::MountByType type )
- { return mb_names[type]; }
- static bool isTmpCryptMp( const string& mp );
+ const string& fsTypeString() const { return toString(fs); }
+
+ static bool isTmpCryptMp( const string& mp );
protected:
void init();
void setNameDev();
- int checkDevice();
- int checkDevice( const string& device );
- storage::MountByType defaultMountBy( const string& mp="" );
- bool allowedMountBy( storage::MountByType mby, const string& mp="" );
- void getFsData( SystemCmd& blkidData );
+ int checkDevice() const;
+ int checkDevice(const string& device) const;
+ MountByType defaultMountBy() const;
+ bool allowedMountBy(MountByType mby) const;
+ bool findBlkid( const Blkid& blkid, Blkid::Entry& entry );
+ void getFsData(const Blkid& blkid, bool setUsedByLvm=false );
void getLoopData( SystemCmd& loopData );
- void getMountData( const ProcMounts& mountData, bool swap_only=false );
+ void getMountData(const ProcMounts& mounts, bool swap_only = false);
void getFstabData( EtcFstab& fstabData );
- void getStartData();
- void getTestmodeData( const string& data );
void replaceAltName( const string& prefix, const string& newn );
- string getMountByString( storage::MountByType mby, const string& dev,
- const string& uuid,
- const string& label ) const;
- string getFstabDevice();
- string getFstabDentry();
- void getFstabOpts( std::list<string>& ol );
+ string getMountByString() const;
+ string getFstabDevice() const;
+ string getFstabDentry() const;
+ list<string> getFstabOpts() const;
bool getLoopFile( string& fname ) const;
void setExtError( const SystemCmd& cmd, bool serr=true );
- string getDmcryptName();
+ string getDmcryptName() const;
bool needLosetup( bool urgent ) const;
bool needCryptsetup() const;
int doLosetup();
@@ -258,7 +235,6 @@
bool format ) const;
bool noFreqPassno() const;
- std::ostream& logVolume( std::ostream& file ) const;
string getLosetupCmd( storage::EncryptType, const string& pwdfile ) const;
string getCryptsetupCmd( storage::EncryptType e, const string& dmdev,
const string& mp, const string& pwdfile, bool format,
@@ -268,16 +244,14 @@
const Container* const cont;
bool numeric;
- bool create;
- bool del;
bool format;
- bool silnt;
bool fstab_added;
storage::FsType fs;
storage::FsType detected_fs;
storage::MountByType mount_by;
storage::MountByType orig_mount_by;
string uuid;
+ string orig_uuid;
string label;
string orig_label;
string mp;
@@ -300,26 +274,19 @@
string fstab_loop_dev;
string crypt_pwd;
string orig_crypt_pwd;
- string nm;
- std::list<string> alt_names;
unsigned num;
- unsigned long long size_k;
unsigned long long orig_size_k;
- string dev;
string dtxt;
- unsigned long mnr;
- unsigned long mjr;
- storage::usedBy uby;
-
- static string fs_names[storage::FSNONE+1];
- static string mb_names[storage::MOUNTBY_PATH+1];
- static string enc_names[storage::ENC_UNKNOWN+1];
- static string tmp_mount[3];
- static const string empty_string;
- static const std::list<string> empty_slist;
+ static const string tmp_mount[3];
+
+ mutable storage::VolumeInfo info; // workaround for broken ycp bindings
+
+ private:
+
+ Volume(const Volume&); // disallow
+ Volume& operator=(const Volume&); // disallow
- mutable storage::VolumeInfo info;
};
}
Added: branches/SuSE-Code-11-SP2-Branch/storage/libstorage/src/XmlFile.cc
URL: http://svn.opensuse.org/viewcvs/yast/branches/SuSE-Code-11-SP2-Branch/stora…
==============================================================================
--- branches/SuSE-Code-11-SP2-Branch/storage/libstorage/src/XmlFile.cc (added)
+++ branches/SuSE-Code-11-SP2-Branch/storage/libstorage/src/XmlFile.cc Tue May 17 13:39:44 2011
@@ -0,0 +1,149 @@
+/*
+ * Copyright (c) 2010 Novell, Inc.
+ *
+ * All Rights Reserved.
+ *
+ * This program is free software; you can redistribute it and/or modify it
+ * under the terms of version 2 of the GNU General Public License as published
+ * by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
+ * more details.
+ *
+ * You should have received a copy of the GNU General Public License along
+ * with this program; if not, contact Novell, Inc.
+ *
+ * To contact Novell about this file by physical or electronic mail, you may
+ * find current contact information at www.novell.com.
+ */
+
+
+#include <assert.h>
+#include <string.h>
+
+#include "storage/XmlFile.h"
+
+
+namespace storage
+{
+
+ XmlFile::XmlFile()
+ : doc(xmlNewDoc((const xmlChar*) "1.0"))
+ {
+ }
+
+
+ XmlFile::XmlFile(const string& filename)
+ : doc(xmlReadFile(filename.c_str(), NULL, XML_PARSE_NOBLANKS | XML_PARSE_NONET))
+ {
+ }
+
+
+ XmlFile::~XmlFile()
+ {
+ if (doc)
+ xmlFreeDoc(doc);
+ }
+
+
+ xmlNode*
+ xmlNewNode(const char* name)
+ {
+ return ::xmlNewNode(NULL, (const xmlChar*) name);
+ }
+
+
+ xmlNode*
+ xmlNewChild(xmlNode* node, const char* name)
+ {
+ return ::xmlNewChild(node, NULL, (const xmlChar*) name, NULL);
+ }
+
+
+ const xmlNode*
+ getChildNode(const xmlNode* node, const char* name)
+ {
+ for (const xmlNode* cur_node = node; cur_node; cur_node = cur_node->next)
+ {
+ if (strcmp(name, (const char*) cur_node->name) == 0)
+ {
+ if (cur_node->children)
+ return cur_node->children;
+ }
+ }
+
+ return NULL;
+ }
+
+
+ list<const xmlNode*>
+ getChildNodes(const xmlNode* node, const char* name)
+ {
+ list<const xmlNode*> ret;
+
+ for (const xmlNode* cur_node = node; cur_node; cur_node = cur_node->next)
+ {
+ if (cur_node->type == XML_ELEMENT_NODE &&
+ strcmp(name, (const char*) cur_node->name) == 0)
+ {
+ if (cur_node->children)
+ ret.push_back(cur_node->children);
+ }
+ }
+
+ return ret;
+ }
+
+
+ bool
+ getChildValue(const xmlNode* node, const char* name, string& value)
+ {
+ for (const xmlNode* cur_node = node; cur_node; cur_node = cur_node->next)
+ {
+ if (cur_node->type == XML_ELEMENT_NODE &&
+ strcmp(name, (const char*) cur_node->name) == 0)
+ {
+ value = (const char*) cur_node->children->content;
+ return true;
+ }
+ }
+
+ return false;
+ }
+
+
+ bool
+ getChildValue(const xmlNode* node, const char* name, bool& value)
+ {
+ string tmp;
+ if (!getChildValue(node, name, tmp))
+ return false;
+
+ value = tmp == "true";
+ return true;
+ }
+
+
+ void
+ setChildValue(xmlNode* node, const char* name, const char* value)
+ {
+ xmlNewTextChild(node, NULL, (const xmlChar*) name, (const xmlChar*) value);
+ }
+
+
+ void
+ setChildValue(xmlNode* node, const char* name, const string& value)
+ {
+ xmlNewTextChild(node, NULL, (const xmlChar*) name, (const xmlChar*) value.c_str());
+ }
+
+
+ void
+ setChildValue(xmlNode* node, const char* name, bool value)
+ {
+ xmlNewTextChild(node, NULL, (const xmlChar*) name, (const xmlChar*)(value ? "true" : "false"));
+ }
+
+}
Added: branches/SuSE-Code-11-SP2-Branch/storage/libstorage/src/XmlFile.h
URL: http://svn.opensuse.org/viewcvs/yast/branches/SuSE-Code-11-SP2-Branch/stora…
==============================================================================
--- branches/SuSE-Code-11-SP2-Branch/storage/libstorage/src/XmlFile.h (added)
+++ branches/SuSE-Code-11-SP2-Branch/storage/libstorage/src/XmlFile.h Tue May 17 13:39:44 2011
@@ -0,0 +1,114 @@
+/*
+ * Copyright (c) 2010 Novell, Inc.
+ *
+ * All Rights Reserved.
+ *
+ * This program is free software; you can redistribute it and/or modify it
+ * under the terms of version 2 of the GNU General Public License as published
+ * by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
+ * more details.
+ *
+ * You should have received a copy of the GNU General Public License along
+ * with this program; if not, contact Novell, Inc.
+ *
+ * To contact Novell about this file by physical or electronic mail, you may
+ * find current contact information at www.novell.com.
+ */
+
+
+#ifndef XML_FILE_H
+#define XML_FILE_H
+
+
+#include <libxml/tree.h>
+#include <string>
+#include <list>
+#include <boost/noncopyable.hpp>
+
+#include "storage/AppUtil.h"
+
+
+namespace storage
+{
+ using namespace std;
+
+
+ class XmlFile : boost::noncopyable
+ {
+
+ public:
+
+ XmlFile();
+ XmlFile(const string& filename);
+
+ ~XmlFile();
+
+ bool save(const string& filename)
+ { return xmlSaveFormatFile(filename.c_str(), doc, 1); }
+
+ void setRootElement(xmlNode* node)
+ { xmlDocSetRootElement(doc, node); }
+
+ const xmlNode* getRootElement() const
+ { return xmlDocGetRootElement(doc); }
+
+ private:
+
+ xmlDoc* doc;
+
+ };
+
+
+ xmlNode* xmlNewNode(const char* name);
+ xmlNode* xmlNewChild(xmlNode* node, const char* name);
+
+
+ const xmlNode* getChildNode(const xmlNode* node, const char* name);
+ list<const xmlNode*> getChildNodes(const xmlNode* node, const char* name);
+
+
+ bool getChildValue(const xmlNode* node, const char* name, string& value);
+ bool getChildValue(const xmlNode* node, const char* name, bool& value);
+
+ template<typename Type>
+ bool getChildValue(const xmlNode* node, const char* name, Type& value)
+ {
+ string tmp;
+ if (!getChildValue(node, name, tmp))
+ return false;
+
+ std::istringstream istr(tmp);
+ classic(istr);
+ istr >> value;
+ return true;
+ }
+
+
+ void setChildValue(xmlNode* node, const char* name, const char* value);
+ void setChildValue(xmlNode* node, const char* name, const string& value);
+ void setChildValue(xmlNode* node, const char* name, bool value);
+
+ template<typename Type>
+ void setChildValue(xmlNode* node, const char* name, const Type& value)
+ {
+ std::ostringstream ostr;
+ classic(ostr);
+ ostr << value;
+ setChildValue(node, name, ostr.str());
+ }
+
+ template<typename Type>
+ void setChildValue(xmlNode* node, const char* name, const list<Type>& values)
+ {
+ for (typename list<Type>::const_iterator it = values.begin(); it != values.end(); ++it)
+ setChildValue(node, name, *it);
+ }
+
+}
+
+
+#endif
Modified: branches/SuSE-Code-11-SP2-Branch/storage/libstorage/testsuite/Makefile.am
URL: http://svn.opensuse.org/viewcvs/yast/branches/SuSE-Code-11-SP2-Branch/stora…
==============================================================================
--- branches/SuSE-Code-11-SP2-Branch/storage/libstorage/testsuite/Makefile.am (original)
+++ branches/SuSE-Code-11-SP2-Branch/storage/libstorage/testsuite/Makefile.am Tue May 17 13:39:44 2011
@@ -9,30 +9,45 @@
AUTOMAKE_OPTIONS = dejagnu
INCLUDES = -I$(top_srcdir)/libstorage/src
-
+
LDADD = ../src/liby2storage.la
-noinst_PROGRAMS = partition1.single format1.single uuid1.single fstab1.single \
- lvm_create.single lvm_extend.single md_create.single \
- humanstring1.single humanstring2.single
-
-partition1_single_SOURCES = partition1.cc common.h
-
-format1_single_SOURCES = format1.cc common.h
-
-uuid1_single_SOURCES = uuid1.cc common.h
-
-fstab1_single_SOURCES = fstab1.cc common.h
-
-lvm_create_single_SOURCES = lvm_create.cc common.h
-
-lvm_extend_single_SOURCES = lvm_extend.cc common.h
-
-md_create_single_SOURCES = md_create.cc common.h
-
+noinst_PROGRAMS = backupstate1.single contvolinfo1.single disklabel1.single \
+ format1.single freeinfo1.single fstab1.single fstab2.single \
+ fstab3.single fstab4.single humanstring1.single humanstring2.single \
+ lvm_create.single lvm_create2.single lvm_extend.single \
+ md_create.single partition1.single partitionname.single \
+ partitionprefix.single recursive1.single recursive2.single \
+ renumber1.single renumber2.single renumber3.single udevdecode.single \
+ udevencode.single usedby1.single uuid1.single
+
+backupstate1_single_SOURCES = backupstate1.cc common.h common.cc
+contvolinfo1_single_SOURCES = contvolinfo1.cc common.h common.cc
+disklabel1_single_SOURCES = disklabel1.cc common.h common.cc
+format1_single_SOURCES = format1.cc common.h common.cc
+freeinfo1_single_SOURCES = freeinfo1.cc common.h common.cc
+fstab1_single_SOURCES = fstab1.cc common.h common.cc
+fstab2_single_SOURCES = fstab2.cc common.h common.cc
+fstab3_single_SOURCES = fstab3.cc common.h common.cc
+fstab4_single_SOURCES = fstab4.cc common.h common.cc
humanstring1_single_SOURCES = humanstring1.cc
-
humanstring2_single_SOURCES = humanstring2.cc
+lvm_create2_single_SOURCES = lvm_create2.cc common.h common.cc
+lvm_create_single_SOURCES = lvm_create.cc common.h common.cc
+lvm_extend_single_SOURCES = lvm_extend.cc common.h common.cc
+md_create_single_SOURCES = md_create.cc common.h common.cc
+partition1_single_SOURCES = partition1.cc common.h common.cc
+partitionname_single_SOURCES = partitionname.cc common.cc
+partitionprefix_single_SOURCES = partitionprefix.cc common.cc
+recursive1_single_SOURCES = recursive1.cc common.h common.cc
+recursive2_single_SOURCES = recursive2.cc common.h common.cc
+renumber1_single_SOURCES = renumber1.cc common.h common.cc
+renumber2_single_SOURCES = renumber2.cc common.h common.cc
+renumber3_single_SOURCES = renumber3.cc common.h common.cc
+udevdecode_single_SOURCES = udevdecode.cc
+udevencode_single_SOURCES = udevencode.cc
+usedby1_single_SOURCES = usedby1.cc common.h common.cc
+uuid1_single_SOURCES = uuid1.cc common.h common.cc
clean-local:
- rm -f tmp.err.* tmp.out.* site.exp site.bak
+ rm -f site.exp site.bak
Added: branches/SuSE-Code-11-SP2-Branch/storage/libstorage/testsuite/backupstate1.cc
URL: http://svn.opensuse.org/viewcvs/yast/branches/SuSE-Code-11-SP2-Branch/stora…
==============================================================================
--- branches/SuSE-Code-11-SP2-Branch/storage/libstorage/testsuite/backupstate1.cc (added)
+++ branches/SuSE-Code-11-SP2-Branch/storage/libstorage/testsuite/backupstate1.cc Tue May 17 13:39:44 2011
@@ -0,0 +1,43 @@
+
+#include <iostream>
+
+#include "common.h"
+
+
+using namespace storage;
+using namespace std;
+
+
+int
+main()
+{
+ cout.setf(std::ios::boolalpha);
+
+ setup_logger();
+
+ setup_system("thalassa");
+
+ StorageInterface* s = createStorageInterface(TestEnvironment());
+
+ s->createBackupState("test");
+ cout << s->checkBackupState("test") << " "
+ << s->equalBackupStates("test", "", true) << endl;
+
+ s->changeFormatVolume("/dev/sda1", true, EXT3);
+ cout << s->checkBackupState("test") << " "
+ << s->equalBackupStates("test", "", true) << endl;
+
+ s->changeFormatVolume("/dev/sda1", false, EXT3);
+ cout << s->checkBackupState("test") << " "
+ << s->equalBackupStates("test", "", true) << endl;
+
+ s->changeMountBy("/dev/system/abuild", MOUNTBY_DEVICE);
+ cout << s->checkBackupState("test") << " "
+ << s->equalBackupStates("test", "", true) << endl;
+
+ s->changeMountBy("/dev/system/abuild", MOUNTBY_UUID);
+ cout << s->checkBackupState("test") << " "
+ << s->equalBackupStates("test", "", true) << endl;
+
+ delete s;
+}
Added: branches/SuSE-Code-11-SP2-Branch/storage/libstorage/testsuite/common.cc
URL: http://svn.opensuse.org/viewcvs/yast/branches/SuSE-Code-11-SP2-Branch/stora…
==============================================================================
--- branches/SuSE-Code-11-SP2-Branch/storage/libstorage/testsuite/common.cc (added)
+++ branches/SuSE-Code-11-SP2-Branch/storage/libstorage/testsuite/common.cc Tue May 17 13:39:44 2011
@@ -0,0 +1,112 @@
+
+#include <stdlib.h>
+#include <iostream>
+#include <fstream>
+
+#include "common.h"
+
+#include "storage/AppUtil.h"
+
+
+extern char* program_invocation_short_name;
+
+
+namespace storage
+{
+ using namespace std;
+
+
+ void
+ setup_logger()
+ {
+ string name = program_invocation_short_name;
+ string::size_type pos = name.rfind(".");
+ if (pos != string::npos)
+ {
+ string path = name.substr(pos + 1) + ".out/out";
+ string file = name.substr(0, pos) + ".log";
+ system(string("rm -f " + path + "/" + file).c_str());
+ createLogger("default", path, file);
+ }
+ }
+
+
+ void
+ setup_system(const string& name)
+ {
+ system("mkdir -p tmp");
+ system("rm -rf tmp/*");
+ system(string("cp data/" + name + "/*.info tmp").c_str());
+ }
+
+
+ void
+ print_fstab()
+ {
+ ifstream fstab("tmp/etc/fstab");
+
+ cout << "begin of fstab" << endl;
+ string line;
+ while (getline(fstab, line))
+ cout << line << endl;
+ cout << "end of fstab" << endl;
+ }
+
+
+ void
+ print_crypttab()
+ {
+ ifstream fstab("tmp/etc/crypttab");
+
+ cout << "begin of crypttab" << endl;
+ string line;
+ while (getline(fstab, line))
+ cout << line << endl;
+ cout << "end of crypttab" << endl;
+ }
+
+
+ void
+ print_partitions(StorageInterface* s, const string& disk)
+ {
+ deque<PartitionInfo> partitioninfos;
+ s->getPartitionInfo(disk, partitioninfos);
+ for (deque<PartitionInfo>::iterator it = partitioninfos.begin();
+ it != partitioninfos.end(); ++it)
+ {
+ cout << it->v.name << ' ';
+ switch (it->partitionType)
+ {
+ case PRIMARY: cout << "PRIMARY "; break;
+ case EXTENDED: cout << "EXTENDED "; break;
+ case LOGICAL: cout << "LOGICAL "; break;
+ case PTYPE_ANY: cout << "ANY "; break;
+ }
+ cout << it->cylStart << ' ' << it->cylSize << ' ';
+ switch (it->v.fs)
+ {
+ case FSUNKNOWN: cout << "UNKNOWN"; break;
+ case REISERFS: cout << "REISERFS"; break;
+ case EXT2: cout << "EXT2"; break;
+ case EXT3: cout << "EXT3"; break;
+ case EXT4: cout << "EXT4"; break;
+ case BTRFS: cout << "BTRFS"; break;
+ case VFAT: cout << "VFAT"; break;
+ case XFS: cout << "XFS"; break;
+ case JFS: cout << "JFS"; break;
+ case HFS: cout << "HFS"; break;
+ case NTFS: cout << "NTFS"; break;
+ case HFSPLUS: cout << "HFSPLUS"; break;
+ case SWAP: cout << "SWAP"; break;
+ case NFS: cout << "NFS"; break;
+ case NFS4: cout << "NFS4"; break;
+ case TMPFS: cout << "TMPFS"; break;
+ case FSNONE: cout << "NONE"; break;
+ }
+ cout << endl;
+ }
+
+ cout << endl;
+ }
+
+}
Modified: branches/SuSE-Code-11-SP2-Branch/storage/libstorage/testsuite/common.h
URL: http://svn.opensuse.org/viewcvs/yast/branches/SuSE-Code-11-SP2-Branch/stora…
==============================================================================
--- branches/SuSE-Code-11-SP2-Branch/storage/libstorage/testsuite/common.h (original)
+++ branches/SuSE-Code-11-SP2-Branch/storage/libstorage/testsuite/common.h Tue May 17 13:39:44 2011
@@ -15,5 +15,14 @@
}
};
-}
+ void setup_logger();
+
+ void setup_system(const string& name);
+
+ void print_fstab();
+ void print_crypttab();
+
+ void print_partitions(StorageInterface* s, const string& disk);
+
+}
Added: branches/SuSE-Code-11-SP2-Branch/storage/libstorage/testsuite/contvolinfo1.cc
URL: http://svn.opensuse.org/viewcvs/yast/branches/SuSE-Code-11-SP2-Branch/stora…
==============================================================================
--- branches/SuSE-Code-11-SP2-Branch/storage/libstorage/testsuite/contvolinfo1.cc (added)
+++ branches/SuSE-Code-11-SP2-Branch/storage/libstorage/testsuite/contvolinfo1.cc Tue May 17 13:39:44 2011
@@ -0,0 +1,53 @@
+
+#include <iostream>
+
+#include "common.h"
+
+
+using namespace std;
+using namespace storage;
+
+
+StorageInterface* s = 0;
+
+
+void
+test(const string& device)
+{
+ cout << "device:" << device << endl;
+
+ ContVolInfo info;
+
+ int ret = s->getContVolInfo(device, info);
+ cout << "ret:" << ret << endl;
+
+ if (ret == 0)
+ {
+ cout << "ctype:" << info.ctype << endl;
+ cout << "cname:" << info.cname << endl;
+ cout << "vname:" << info.vname << endl;
+ }
+
+ cout << endl;
+}
+
+
+int
+main()
+{
+ setup_logger();
+
+ setup_system("thalassa");
+
+ s = createStorageInterface(TestEnvironment());
+
+ test("/dev/sda");
+ test("/dev/sda1");
+
+ test("/dev/system");
+ test("/dev/system/swap");
+
+ test("/dev/unknown");
+
+ delete s;
+}
Modified: branches/SuSE-Code-11-SP2-Branch/storage/libstorage/testsuite/data/Makefile.am
URL: http://svn.opensuse.org/viewcvs/yast/branches/SuSE-Code-11-SP2-Branch/stora…
==============================================================================
--- branches/SuSE-Code-11-SP2-Branch/storage/libstorage/testsuite/data/Makefile.am (original)
+++ branches/SuSE-Code-11-SP2-Branch/storage/libstorage/testsuite/data/Makefile.am Tue May 17 13:39:44 2011
@@ -2,4 +2,4 @@
# Makefile.am for libstorage/testsuite/data
#
-EXTRA_DIST = disk_hda disk_hdb disk_sda disk_sdb volume_info
+SUBDIRS = thalassa scandium empty
Added: branches/SuSE-Code-11-SP2-Branch/storage/libstorage/testsuite/data/empty/Makefile.am
URL: http://svn.opensuse.org/viewcvs/yast/branches/SuSE-Code-11-SP2-Branch/stora…
==============================================================================
--- branches/SuSE-Code-11-SP2-Branch/storage/libstorage/testsuite/data/empty/Makefile.am (added)
+++ branches/SuSE-Code-11-SP2-Branch/storage/libstorage/testsuite/data/empty/Makefile.am Tue May 17 13:39:44 2011
@@ -0,0 +1,6 @@
+#
+# Makefile.am for libstorage/testsuite/data/empty
+#
+
+EXTRA_DIST = disk_sda.info
+
Added: branches/SuSE-Code-11-SP2-Branch/storage/libstorage/testsuite/data/empty/disk_sda.info
URL: http://svn.opensuse.org/viewcvs/yast/branches/SuSE-Code-11-SP2-Branch/stora…
==============================================================================
--- branches/SuSE-Code-11-SP2-Branch/storage/libstorage/testsuite/data/empty/disk_sda.info (added)
+++ branches/SuSE-Code-11-SP2-Branch/storage/libstorage/testsuite/data/empty/disk_sda.info Tue May 17 13:39:44 2011
@@ -0,0 +1,21 @@
+<?xml version="1.0"?>
+<disk>
+ <name>sda</name>
+ <device>/dev/sda</device>
+ <size_k>976762584</size_k>
+ <major>8</major>
+ <minor>32</minor>
+ <range>256</range>
+ <geometry>
+ <cylinders>121601</cylinders>
+ <heads>255</heads>
+ <sectors>63</sectors>
+ </geometry>
+ <label>msdos</label>
+ <max_primary>4</max_primary>
+ <ext_possible>true</ext_possible>
+ <max_logical>255</max_logical>
+ <udev_path>pci-0000:00:1f.2-scsi-2:0:0:0</udev_path>
+ <udev_id>ata-WDC_WD10EADS-00M2B0_WD-WCAV52321683</udev_id>
+ <udev_id>scsi-SATA_WDC_WD10EADS-00_WD-WCAV52321683</udev_id>
+</disk>
Added: branches/SuSE-Code-11-SP2-Branch/storage/libstorage/testsuite/data/scandium/Makefile.am
URL: http://svn.opensuse.org/viewcvs/yast/branches/SuSE-Code-11-SP2-Branch/stora…
==============================================================================
--- branches/SuSE-Code-11-SP2-Branch/storage/libstorage/testsuite/data/scandium/Makefile.am (added)
+++ branches/SuSE-Code-11-SP2-Branch/storage/libstorage/testsuite/data/scandium/Makefile.am Tue May 17 13:39:44 2011
@@ -0,0 +1,6 @@
+#
+# Makefile.am for libstorage/testsuite/data/scandium
+#
+
+EXTRA_DIST = disk_sda.info arch.info
+
Added: branches/SuSE-Code-11-SP2-Branch/storage/libstorage/testsuite/data/scandium/arch.info
URL: http://svn.opensuse.org/viewcvs/yast/branches/SuSE-Code-11-SP2-Branch/stora…
==============================================================================
--- branches/SuSE-Code-11-SP2-Branch/storage/libstorage/testsuite/data/scandium/arch.info (added)
+++ branches/SuSE-Code-11-SP2-Branch/storage/libstorage/testsuite/data/scandium/arch.info Tue May 17 13:39:44 2011
@@ -0,0 +1,5 @@
+<?xml version="1.0"?>
+<arch>
+ <arch>ia64</arch>
+ <efiboot>true</efiboot>
+</arch>
Added: branches/SuSE-Code-11-SP2-Branch/storage/libstorage/testsuite/data/scandium/disk_sda.info
URL: http://svn.opensuse.org/viewcvs/yast/branches/SuSE-Code-11-SP2-Branch/stora…
==============================================================================
--- branches/SuSE-Code-11-SP2-Branch/storage/libstorage/testsuite/data/scandium/disk_sda.info (added)
+++ branches/SuSE-Code-11-SP2-Branch/storage/libstorage/testsuite/data/scandium/disk_sda.info Tue May 17 13:39:44 2011
@@ -0,0 +1,206 @@
+<?xml version="1.0"?>
+<disk>
+ <name>sda</name>
+ <device>/dev/sda</device>
+ <size_k>143374744</size_k>
+ <major>8</major>
+ <minor>0</minor>
+ <range>16</range>
+ <geometry>
+ <cylinders>17849</cylinders>
+ <heads>255</heads>
+ <sectors>63</sectors>
+ </geometry>
+ <label>gpt</label>
+ <max_primary>15</max_primary>
+ <udev_path>pci-0001:00:01.0-sas-phy0:1-0x5000c5000001ecdd:0-lun0</udev_path>
+ <udev_id>scsi-SSEAGATE_ST3146854SS_3KN0JH8600008609GTBW</udev_id>
+ <transport>SAS</transport>
+ <partition>
+ <name>sda1</name>
+ <device>/dev/sda1</device>
+ <size_k>208828</size_k>
+ <major>8</major>
+ <minor>1</minor>
+ <numeric>true</numeric>
+ <number>1</number>
+ <fs_type>vfat</fs_type>
+ <fs_uuid>4784-925A</fs_uuid>
+ <mount_by>id</mount_by>
+ <region>
+ <start>0</start>
+ <length>27</length>
+ </region>
+ <partition_type>primary</partition_type>
+ <partition_id>259</partition_id>
+ <boot_flag>true</boot_flag>
+ </partition>
+ <partition>
+ <name>sda2</name>
+ <device>/dev/sda2</device>
+ <size_k>23246055</size_k>
+ <major>8</major>
+ <minor>2</minor>
+ <numeric>true</numeric>
+ <number>2</number>
+ <fs_type>swap</fs_type>
+ <fs_uuid>d1434be1-818a-4476-8475-17e3238b27da</fs_uuid>
+ <mount>swap</mount>
+ <mount_by>id</mount_by>
+ <fstopt>defaults</fstopt>
+ <region>
+ <start>26</start>
+ <length>2895</length>
+ </region>
+ <partition_type>primary</partition_type>
+ <partition_id>130</partition_id>
+ </partition>
+ <partition>
+ <name>sda3</name>
+ <device>/dev/sda3</device>
+ <size_k>216877</size_k>
+ <major>8</major>
+ <minor>3</minor>
+ <numeric>true</numeric>
+ <number>3</number>
+ <fs_type>vfat</fs_type>
+ <fs_uuid>46A5-DDF8</fs_uuid>
+ <mount_by>id</mount_by>
+ <region>
+ <start>2920</start>
+ <length>27</length>
+ </region>
+ <partition_type>primary</partition_type>
+ <partition_id>259</partition_id>
+ <boot_flag>true</boot_flag>
+ </partition>
+ <partition>
+ <name>sda4</name>
+ <device>/dev/sda4</device>
+ <size_k>20980890</size_k>
+ <major>8</major>
+ <minor>4</minor>
+ <numeric>true</numeric>
+ <number>4</number>
+ <fs_type>ext3</fs_type>
+ <fs_uuid>9747e169-6937-4a53-ae6b-6cbb4d26b81c</fs_uuid>
+ <mount_by>id</mount_by>
+ <region>
+ <start>2947</start>
+ <length>2612</length>
+ </region>
+ <partition_type>primary</partition_type>
+ <partition_id>131</partition_id>
+ </partition>
+ <partition>
+ <name>sda5</name>
+ <device>/dev/sda5</device>
+ <size_k>208845</size_k>
+ <major>8</major>
+ <minor>5</minor>
+ <numeric>true</numeric>
+ <number>5</number>
+ <fs_type>vfat</fs_type>
+ <fs_uuid>486C-CA1D</fs_uuid>
+ <mount_by>id</mount_by>
+ <region>
+ <start>5559</start>
+ <length>26</length>
+ </region>
+ <partition_type>primary</partition_type>
+ <partition_id>259</partition_id>
+ <boot_flag>true</boot_flag>
+ </partition>
+ <partition>
+ <name>sda6</name>
+ <device>/dev/sda6</device>
+ <size_k>20980890</size_k>
+ <major>8</major>
+ <minor>6</minor>
+ <numeric>true</numeric>
+ <number>6</number>
+ <fs_type>xfs</fs_type>
+ <fs_uuid>59c5e268-88dd-467b-9284-e897dde490be</fs_uuid>
+ <mount_by>id</mount_by>
+ <region>
+ <start>5585</start>
+ <length>2612</length>
+ </region>
+ <partition_type>primary</partition_type>
+ <partition_id>131</partition_id>
+ </partition>
+ <partition>
+ <name>sda7</name>
+ <device>/dev/sda7</device>
+ <size_k>208845</size_k>
+ <major>8</major>
+ <minor>7</minor>
+ <numeric>true</numeric>
+ <number>7</number>
+ <fs_type>vfat</fs_type>
+ <fs_uuid>48B5-5083</fs_uuid>
+ <mount>/boot/efi</mount>
+ <mount_by>id</mount_by>
+ <fstopt>defaults</fstopt>
+ <region>
+ <start>8197</start>
+ <length>26</length>
+ </region>
+ <partition_type>primary</partition_type>
+ <partition_id>259</partition_id>
+ <boot_flag>true</boot_flag>
+ </partition>
+ <partition>
+ <name>sda8</name>
+ <device>/dev/sda8</device>
+ <size_k>20980890</size_k>
+ <major>8</major>
+ <minor>8</minor>
+ <numeric>true</numeric>
+ <number>8</number>
+ <fs_type>ext3</fs_type>
+ <fs_uuid>203ece22-0c71-45a0-a224-1ee575c2025d</fs_uuid>
+ <mount>/</mount>
+ <mount_by>id</mount_by>
+ <fstopt>defaults</fstopt>
+ <region>
+ <start>8223</start>
+ <length>2612</length>
+ </region>
+ <partition_type>primary</partition_type>
+ <partition_id>131</partition_id>
+ </partition>
+ <partition>
+ <name>sda9</name>
+ <device>/dev/sda9</device>
+ <size_k>208845</size_k>
+ <major>8</major>
+ <minor>9</minor>
+ <numeric>true</numeric>
+ <number>9</number>
+ <region>
+ <start>10835</start>
+ <length>26</length>
+ </region>
+ <partition_type>primary</partition_type>
+ <partition_id>131</partition_id>
+ </partition>
+ <partition>
+ <name>sda10</name>
+ <device>/dev/sda10</device>
+ <size_k>20980890</size_k>
+ <major>8</major>
+ <minor>10</minor>
+ <numeric>true</numeric>
+ <number>10</number>
+ <fs_type>ext3</fs_type>
+ <fs_uuid>203ece22-0c71-45a0-a224-1ee575c2025d</fs_uuid>
+ <mount_by>id</mount_by>
+ <region>
+ <start>10861</start>
+ <length>2612</length>
+ </region>
+ <partition_type>primary</partition_type>
+ <partition_id>131</partition_id>
+ </partition>
+</disk>
Added: branches/SuSE-Code-11-SP2-Branch/storage/libstorage/testsuite/data/thalassa/Makefile.am
URL: http://svn.opensuse.org/viewcvs/yast/branches/SuSE-Code-11-SP2-Branch/stora…
==============================================================================
--- branches/SuSE-Code-11-SP2-Branch/storage/libstorage/testsuite/data/thalassa/Makefile.am (added)
+++ branches/SuSE-Code-11-SP2-Branch/storage/libstorage/testsuite/data/thalassa/Makefile.am Tue May 17 13:39:44 2011
@@ -0,0 +1,6 @@
+#
+# Makefile.am for libstorage/testsuite/data/thalassa
+#
+
+EXTRA_DIST = disk_sda.info disk_sdb.info disk_sdc.info lvmvg_system.info free.info
+
Added: branches/SuSE-Code-11-SP2-Branch/storage/libstorage/testsuite/data/thalassa/disk_sda.info
URL: http://svn.opensuse.org/viewcvs/yast/branches/SuSE-Code-11-SP2-Branch/stora…
==============================================================================
--- branches/SuSE-Code-11-SP2-Branch/storage/libstorage/testsuite/data/thalassa/disk_sda.info (added)
+++ branches/SuSE-Code-11-SP2-Branch/storage/libstorage/testsuite/data/thalassa/disk_sda.info Tue May 17 13:39:44 2011
@@ -0,0 +1,59 @@
+<?xml version="1.0"?>
+<disk>
+ <name>sda</name>
+ <device>/dev/sda</device>
+ <size_k>312571224</size_k>
+ <major>8</major>
+ <minor>0</minor>
+ <range>256</range>
+ <geometry>
+ <cylinders>38913</cylinders>
+ <heads>255</heads>
+ <sectors>63</sectors>
+ </geometry>
+ <label>msdos</label>
+ <max_primary>4</max_primary>
+ <ext_possible>true</ext_possible>
+ <max_logical>63</max_logical>
+ <partition>
+ <name>sda1</name>
+ <device>/dev/sda1</device>
+ <size_k>1044225</size_k>
+ <major>8</major>
+ <minor>1</minor>
+ <numeric>true</numeric>
+ <number>1</number>
+ <fs_type>ext3</fs_type>
+ <fs_uuid>14875716-b8e3-4c83-ac86-48c20682b63a</fs_uuid>
+ <fs_label>BOOT</fs_label>
+ <mount>/boot</mount>
+ <mount_by>id</mount_by>
+ <fstopt>acl,user_xattr</fstopt>
+ <region>
+ <start>1</start>
+ <length>130</length>
+ </region>
+ <partition_type>primary</partition_type>
+ <partition_id>131</partition_id>
+ <boot_flag>true</boot_flag>
+ </partition>
+ <partition>
+ <name>sda2</name>
+ <device>/dev/sda2</device>
+ <size_k>157284382</size_k>
+ <major>8</major>
+ <minor>2</minor>
+ <used_by>
+ <type>lvm</type>
+ <device>/dev/system</device>
+ </used_by>
+ <numeric>true</numeric>
+ <number>2</number>
+ <region>
+ <start>131</start>
+ <length>19581</length>
+ </region>
+ <partition_type>primary</partition_type>
+ <partition_id>142</partition_id>
+ </partition>
+</disk>
Added: branches/SuSE-Code-11-SP2-Branch/storage/libstorage/testsuite/data/thalassa/disk_sdb.info
URL: http://svn.opensuse.org/viewcvs/yast/branches/SuSE-Code-11-SP2-Branch/stora…
==============================================================================
--- branches/SuSE-Code-11-SP2-Branch/storage/libstorage/testsuite/data/thalassa/disk_sdb.info (added)
+++ branches/SuSE-Code-11-SP2-Branch/storage/libstorage/testsuite/data/thalassa/disk_sdb.info Tue May 17 13:39:44 2011
@@ -0,0 +1,87 @@
+<?xml version="1.0"?>
+<disk>
+ <name>sdb</name>
+ <device>/dev/sdb</device>
+ <size_k>80418240</size_k>
+ <major>8</major>
+ <minor>16</minor>
+ <range>256</range>
+ <geometry>
+ <cylinders>10011</cylinders>
+ <heads>255</heads>
+ <sectors>63</sectors>
+ </geometry>
+ <label>msdos</label>
+ <max_primary>4</max_primary>
+ <ext_possible>true</ext_possible>
+ <max_logical>63</max_logical>
+ <partition>
+ <name>sdb1</name>
+ <device>/dev/sdb1</device>
+ <size_k>5253223</size_k>
+ <major>8</major>
+ <minor>17</minor>
+ <numeric>true</numeric>
+ <number>1</number>
+ <fs_type>ext3</fs_type>
+ <fs_uuid>69fc7099-4a05-436f-b55a-fa7fd30a1f7c</fs_uuid>
+ <mount_by>id</mount_by>
+ <region>
+ <start>0</start>
+ <length>654</length>
+ </region>
+ <partition_type>primary</partition_type>
+ <partition_id>131</partition_id>
+ </partition>
+ <partition>
+ <name>sdb2</name>
+ <device>/dev/sdb2</device>
+ <size_k>75160102</size_k>
+ <major>8</major>
+ <minor>18</minor>
+ <numeric>true</numeric>
+ <number>2</number>
+ <region>
+ <start>654</start>
+ <length>9357</length>
+ </region>
+ <partition_type>extended</partition_type>
+ <partition_id>15</partition_id>
+ </partition>
+ <partition>
+ <name>sdb5</name>
+ <device>/dev/sdb5</device>
+ <size_k>20972826</size_k>
+ <major>8</major>
+ <minor>21</minor>
+ <numeric>true</numeric>
+ <number>5</number>
+ <fs_type>ext3</fs_type>
+ <fs_uuid>686b8c9a-14ec-43ca-ad3e-7800a2581680</fs_uuid>
+ <mount_by>id</mount_by>
+ <region>
+ <start>654</start>
+ <length>2611</length>
+ </region>
+ <partition_type>logical</partition_type>
+ <partition_id>131</partition_id>
+ </partition>
+ <partition>
+ <name>sdb6</name>
+ <device>/dev/sdb6</device>
+ <size_k>20972826</size_k>
+ <major>8</major>
+ <minor>22</minor>
+ <numeric>true</numeric>
+ <number>6</number>
+ <fs_type>ext3</fs_type>
+ <fs_uuid>8c6da4fd-03d3-43cd-b4c7-bb15338c89ce</fs_uuid>
+ <mount_by>id</mount_by>
+ <region>
+ <start>3265</start>
+ <length>2611</length>
+ </region>
+ <partition_type>logical</partition_type>
+ <partition_id>131</partition_id>
+ </partition>
+</disk>
Added: branches/SuSE-Code-11-SP2-Branch/storage/libstorage/testsuite/data/thalassa/disk_sdc.info
URL: http://svn.opensuse.org/viewcvs/yast/branches/SuSE-Code-11-SP2-Branch/stora…
==============================================================================
--- branches/SuSE-Code-11-SP2-Branch/storage/libstorage/testsuite/data/thalassa/disk_sdc.info (added)
+++ branches/SuSE-Code-11-SP2-Branch/storage/libstorage/testsuite/data/thalassa/disk_sdc.info Tue May 17 13:39:44 2011
@@ -0,0 +1,123 @@
+<?xml version="1.0"?>
+<disk>
+ <name>sdc</name>
+ <device>/dev/sdc</device>
+ <size_k>78150744</size_k>
+ <major>8</major>
+ <minor>32</minor>
+ <range>256</range>
+ <geometry>
+ <cylinders>9729</cylinders>
+ <heads>255</heads>
+ <sectors>63</sectors>
+ </geometry>
+ <label>msdos</label>
+ <max_primary>4</max_primary>
+ <ext_possible>true</ext_possible>
+ <max_logical>63</max_logical>
+ <partition>
+ <name>sdc1</name>
+ <device>/dev/sdc1</device>
+ <size_k>5253223</size_k>
+ <major>8</major>
+ <minor>33</minor>
+ <numeric>true</numeric>
+ <number>1</number>
+ <fs_type>ext2</fs_type>
+ <fs_uuid>fa39d2fd-cd05-47f9-933e-1511e89879ab</fs_uuid>
+ <mount_by>id</mount_by>
+ <region>
+ <start>0</start>
+ <length>654</length>
+ </region>
+ <partition_type>primary</partition_type>
+ <partition_id>131</partition_id>
+ </partition>
+ <partition>
+ <name>sdc2</name>
+ <device>/dev/sdc2</device>
+ <size_k>10482412</size_k>
+ <major>8</major>
+ <minor>34</minor>
+ <numeric>true</numeric>
+ <number>2</number>
+ <fs_type>ext3</fs_type>
+ <fs_uuid>85b755d4-e980-49bb-9ebd-3f4416b54ff9</fs_uuid>
+ <mount_by>id</mount_by>
+ <region>
+ <start>654</start>
+ <length>1305</length>
+ </region>
+ <partition_type>primary</partition_type>
+ <partition_id>131</partition_id>
+ </partition>
+ <partition>
+ <name>sdc3</name>
+ <device>/dev/sdc3</device>
+ <size_k>15727635</size_k>
+ <major>8</major>
+ <minor>35</minor>
+ <numeric>true</numeric>
+ <number>3</number>
+ <fs_type>ext4</fs_type>
+ <fs_uuid>3c465f82-9f9e-45a3-b789-9831ffd2ade6</fs_uuid>
+ <mount_by>id</mount_by>
+ <region>
+ <start>1959</start>
+ <length>1958</length>
+ </region>
+ <partition_type>primary</partition_type>
+ <partition_id>131</partition_id>
+ </partition>
+ <partition>
+ <name>sdc4</name>
+ <device>/dev/sdc4</device>
+ <size_k>46684890</size_k>
+ <major>8</major>
+ <minor>36</minor>
+ <numeric>true</numeric>
+ <number>4</number>
+ <region>
+ <start>3917</start>
+ <length>5812</length>
+ </region>
+ <partition_type>extended</partition_type>
+ <partition_id>15</partition_id>
+ </partition>
+ <partition>
+ <name>sdc5</name>
+ <device>/dev/sdc5</device>
+ <size_k>20972826</size_k>
+ <major>8</major>
+ <minor>37</minor>
+ <numeric>true</numeric>
+ <number>5</number>
+ <fs_type>btrfs</fs_type>
+ <fs_uuid>92f5be30-e4f6-4512-954b-8c13af0cbc15</fs_uuid>
+ <mount_by>id</mount_by>
+ <region>
+ <start>3917</start>
+ <length>2611</length>
+ </region>
+ <partition_type>logical</partition_type>
+ <partition_id>131</partition_id>
+ </partition>
+ <partition>
+ <name>sdc6</name>
+ <device>/dev/sdc6</device>
+ <size_k>20972826</size_k>
+ <major>8</major>
+ <minor>38</minor>
+ <numeric>true</numeric>
+ <number>6</number>
+ <fs_type>btrfs</fs_type>
+ <fs_uuid>8a5e979d-fabe-432a-b588-c303c5ceba08</fs_uuid>
+ <mount_by>id</mount_by>
+ <region>
+ <start>6528</start>
+ <length>2611</length>
+ </region>
+ <partition_type>logical</partition_type>
+ <partition_id>131</partition_id>
+ </partition>
+</disk>
Added: branches/SuSE-Code-11-SP2-Branch/storage/libstorage/testsuite/data/thalassa/free.info
URL: http://svn.opensuse.org/viewcvs/yast/branches/SuSE-Code-11-SP2-Branch/stora…
==============================================================================
--- branches/SuSE-Code-11-SP2-Branch/storage/libstorage/testsuite/data/thalassa/free.info (added)
+++ branches/SuSE-Code-11-SP2-Branch/storage/libstorage/testsuite/data/thalassa/free.info Tue May 17 13:39:44 2011
@@ -0,0 +1,15 @@
+<?xml version="1.0"?>
+<free>
+ <free>
+ <device>/dev/system/arvin</device>
+ <resize_cached>true</resize_cached>
+ <df_free_k>23338740</df_free_k>
+ <resize_free_k>23338740</resize_free_k>
+ <used_k>26203196</used_k>
+ <resize_ok>true</resize_ok>
+ <content_cached>true</content_cached>
+ <windows>false</windows>
+ <efi>false</efi>
+ <homes>2</homes>
+ </free>
+</free>
Added: branches/SuSE-Code-11-SP2-Branch/storage/libstorage/testsuite/data/thalassa/lvmvg_system.info
URL: http://svn.opensuse.org/viewcvs/yast/branches/SuSE-Code-11-SP2-Branch/stora…
==============================================================================
--- branches/SuSE-Code-11-SP2-Branch/storage/libstorage/testsuite/data/thalassa/lvmvg_system.info (added)
+++ branches/SuSE-Code-11-SP2-Branch/storage/libstorage/testsuite/data/thalassa/lvmvg_system.info Tue May 17 13:39:44 2011
@@ -0,0 +1,90 @@
+<?xml version="1.0"?>
+<volume_group>
+ <name>system</name>
+ <device>/dev/system</device>
+ <size_k>157282304</size_k>
+ <major>0</major>
+ <minor>0</minor>
+ <pe_size_k>4096</pe_size_k>
+ <pe_count>38399</pe_count>
+ <pe_free>255</pe_free>
+ <physical_extent>
+ <device>/dev/sda2</device>
+ <pe_count>38399</pe_count>
+ <pe_free>255</pe_free>
+ </physical_extent>
+ <logical_volume>
+ <name>abuild</name>
+ <device>/dev/system/abuild</device>
+ <size_k>8388608</size_k>
+ <major>253</major>
+ <minor>0</minor>
+ <numeric>false</numeric>
+ <fs_type>btrfs</fs_type>
+ <fs_uuid>a25f1b5f-27d1-48c1-ba02-bb083cb4c862</fs_uuid>
+ <fs_label>ABUILD</fs_label>
+ <mount>/abuild</mount>
+ <mount_by>uuid</mount_by>
+ <fstopt>noatime,acl,user_xattr</fstopt>
+ <table_name>system-abuild</table_name>
+ <stripes>1</stripes>
+ </logical_volume>
+ <logical_volume>
+ <name>arvin</name>
+ <device>/dev/system/arvin</device>
+ <size_k>50331648</size_k>
+ <major>253</major>
+ <minor>1</minor>
+ <numeric>false</numeric>
+ <fs_type>ext3</fs_type>
+ <fs_uuid>d4c2b968-3d62-44d7-a0c2-d85d8562a25d</fs_uuid>
+ <mount>/ARVIN</mount>
+ <fstopt>noatime,acl,user_xattr</fstopt>
+ <table_name>system-arvin</table_name>
+ <stripes>1</stripes>
+ </logical_volume>
+ <logical_volume>
+ <name>root</name>
+ <device>/dev/system/root</device>
+ <size_k>16777216</size_k>
+ <major>253</major>
+ <minor>2</minor>
+ <numeric>false</numeric>
+ <fs_type>ext3</fs_type>
+ <fs_uuid>31e381c9-5b35-4045-8d01-9274a30e1298</fs_uuid>
+ <mount>/</mount>
+ <fstopt>noatime,acl,user_xattr</fstopt>
+ <table_name>system-root</table_name>
+ <stripes>1</stripes>
+ </logical_volume>
+ <logical_volume>
+ <name>swap</name>
+ <device>/dev/system/swap</device>
+ <size_k>2097152</size_k>
+ <major>253</major>
+ <minor>3</minor>
+ <numeric>false</numeric>
+ <fs_type>swap</fs_type>
+ <fs_uuid>fd39c3f9-2990-435d-8eed-e56b6dc2e592</fs_uuid>
+ <fs_label>SWAP</fs_label>
+ <mount>swap</mount>
+ <mount_by>label</mount_by>
+ <fstopt>defaults</fstopt>
+ <table_name>system-swap</table_name>
+ <stripes>1</stripes>
+ </logical_volume>
+ <logical_volume>
+ <name>virtualbox</name>
+ <device>/dev/system/virtualbox</device>
+ <size_k>78643200</size_k>
+ <major>253</major>
+ <minor>4</minor>
+ <numeric>false</numeric>
+ <fs_type>ext2</fs_type>
+ <fs_uuid>1f8091b0-ac6d-498e-8667-61efce3008e2</fs_uuid>
+ <mount>/ARVIN/virtualbox</mount>
+ <fstopt>noatime,acl,user_xattr</fstopt>
+ <table_name>system-virtualbox</table_name>
+ <stripes>1</stripes>
+ </logical_volume>
+</volume_group>
Added: branches/SuSE-Code-11-SP2-Branch/storage/libstorage/testsuite/disklabel1.cc
URL: http://svn.opensuse.org/viewcvs/yast/branches/SuSE-Code-11-SP2-Branch/stora…
==============================================================================
--- branches/SuSE-Code-11-SP2-Branch/storage/libstorage/testsuite/disklabel1.cc (added)
+++ branches/SuSE-Code-11-SP2-Branch/storage/libstorage/testsuite/disklabel1.cc Tue May 17 13:39:44 2011
@@ -0,0 +1,33 @@
+
+#include <iostream>
+
+#include "common.h"
+
+
+using namespace storage;
+using namespace std;
+
+
+void
+test(const string& name)
+{
+ setup_system(name);
+
+ StorageInterface* s = createStorageInterface(TestEnvironment());
+
+ cout << s->defaultDiskLabel("/dev/sda") << endl;
+
+ delete s;
+}
+
+
+int
+main()
+{
+ cout.setf(std::ios::boolalpha);
+
+ setup_logger();
+
+ test("thalassa");
+ test("scandium");
+}
Modified: branches/SuSE-Code-11-SP2-Branch/storage/libstorage/testsuite/format1.cc
URL: http://svn.opensuse.org/viewcvs/yast/branches/SuSE-Code-11-SP2-Branch/stora…
==============================================================================
--- branches/SuSE-Code-11-SP2-Branch/storage/libstorage/testsuite/format1.cc (original)
+++ branches/SuSE-Code-11-SP2-Branch/storage/libstorage/testsuite/format1.cc Tue May 17 13:39:44 2011
@@ -1,10 +1,5 @@
-#include <stdio.h>
-#include <stdlib.h>
#include <iostream>
-#include <iterator>
-
-#include <StorageInterface.h>
#include "common.h"
@@ -17,71 +12,31 @@
void
-print_partitions (const string& disk)
-{
- deque<PartitionInfo> partitioninfos;
- s->getPartitionInfo (disk, partitioninfos);
- for (deque<PartitionInfo>::iterator i = partitioninfos.begin ();
- i != partitioninfos.end(); i++)
- {
- cout << i->v.name << ' ';
- switch (i->partitionType)
- {
- case PRIMARY: cout << "PRIMARY "; break;
- case EXTENDED: cout << "EXTENDED "; break;
- case LOGICAL: cout << "LOGICAL "; break;
- case PTYPE_ANY: cout << "ANY "; break;
- }
- cout << i->cylStart << ' ' << i->cylSize << ' ';
- switch (i->v.fs)
- {
- case FSUNKNOWN: cout << "UNKNOWN"; break;
- case REISERFS: cout << "REISERFS"; break;
- case EXT2: cout << "EXT2"; break;
- case EXT3: cout << "EXT3"; break;
- case VFAT: cout << "VFAT"; break;
- case XFS: cout << "XFS"; break;
- case JFS: cout << "JFS"; break;
- case HFS: cout << "HFS"; break;
- case NTFS: cout << "NTFS"; break;
- case HFSPLUS: cout << "HFSPLUS"; break;
- case SWAP: cout << "SWAP"; break;
- case NFS: cout << "NFS"; break;
- case FSNONE: cout << "NONE"; break;
- }
- cout << '\n';
- }
-
- cout << '\n';
-}
-
-
-void
-test ()
+test()
{
- printf ("test\n");
+ cout << "test" << endl;
s = createStorageInterface(TestEnvironment());
- cout << s->changeFormatVolume ("/dev/hda1", true, REISERFS) << '\n';
- cout << s->changeFormatVolume ("/dev/hda2", true, EXT2) << '\n';
- cout << s->changeFormatVolume ("/dev/hda3", true, EXT3) << '\n';
- cout << s->changeFormatVolume ("/dev/hda4", true, REISERFS) << '\n'; // FAILS
- cout << s->changeFormatVolume ("/dev/hda5", true, EXT2) << '\n';
- cout << s->changeFormatVolume ("/dev/hda6", true, EXT3) << '\n';
+ cout << s->changeFormatVolume("/dev/sdc1", true, REISERFS) << endl;
+ cout << s->changeFormatVolume("/dev/sdc2", true, EXT2) << endl;
+ cout << s->changeFormatVolume("/dev/sdc3", true, EXT3) << endl;
+ cout << s->changeFormatVolume("/dev/sdc4", true, REISERFS) << endl; // FAILS
+ cout << s->changeFormatVolume("/dev/sdc5", true, EXT2) << endl;
+ cout << s->changeFormatVolume("/dev/sdc6", true, EXT3) << endl;
- print_partitions ("/dev/hda");
+ print_partitions(s, "/dev/sdc");
delete s;
}
int
-main ()
+main()
{
- system ("mkdir -p tmp");
+ setup_logger();
+
+ setup_system("thalassa");
- system ("cp data/disk_hda tmp/disk_hda");
- system ("rm -f tmp/volume_info");
- test ();
+ test();
}
Added: branches/SuSE-Code-11-SP2-Branch/storage/libstorage/testsuite/freeinfo1.cc
URL: http://svn.opensuse.org/viewcvs/yast/branches/SuSE-Code-11-SP2-Branch/stora…
==============================================================================
--- branches/SuSE-Code-11-SP2-Branch/storage/libstorage/testsuite/freeinfo1.cc (added)
+++ branches/SuSE-Code-11-SP2-Branch/storage/libstorage/testsuite/freeinfo1.cc Tue May 17 13:39:44 2011
@@ -0,0 +1,50 @@
+
+#include <iostream>
+
+#include "common.h"
+
+
+using namespace storage;
+using namespace std;
+
+
+StorageInterface* s = NULL;
+
+
+void
+test(const string& device)
+{
+ ResizeInfo resize_info;
+ ContentInfo content_info;
+
+ if (s->getFreeInfo(device, true, resize_info, true, content_info, true))
+ {
+ cout << device << " true" << endl;
+ cout << " " << resize_info.resize_freeK << " " << resize_info.df_freeK << " "
+ << resize_info.usedK << " " << resize_info.resize_ok << endl;
+ cout << " " << content_info.windows << " " << content_info.efi << " "
+ << content_info.homes << endl;
+ }
+ else
+ {
+ cout << device << " false" << endl;
+ }
+}
+
+
+int
+main()
+{
+ cout.setf(std::ios::boolalpha);
+
+ setup_logger();
+
+ setup_system("thalassa");
+
+ s = createStorageInterface(TestEnvironment());
+
+ test("/dev/system/arvin");
+ test("/dev/system/root");
+
+ delete s;
+}
Modified: branches/SuSE-Code-11-SP2-Branch/storage/libstorage/testsuite/fstab1.cc
URL: http://svn.opensuse.org/viewcvs/yast/branches/SuSE-Code-11-SP2-Branch/stora…
==============================================================================
--- branches/SuSE-Code-11-SP2-Branch/storage/libstorage/testsuite/fstab1.cc (original)
+++ branches/SuSE-Code-11-SP2-Branch/storage/libstorage/testsuite/fstab1.cc Tue May 17 13:39:44 2011
@@ -1,7 +1,6 @@
#include <stdlib.h>
#include <iostream>
-#include <iterator>
#include "common.h"
@@ -14,7 +13,7 @@
void
-mountpoint1 ()
+mountpoint1()
{
cout << "mountpoint1\n";
@@ -22,12 +21,12 @@
string mountpoint;
- cout << s->changeMountPoint ("/dev/hda1", "") << '\n';
- cout << s->getMountPoint ("/dev/hda1", mountpoint) << '\n';
+ cout << s->changeMountPoint("/dev/sda1", "") << '\n';
+ cout << s->getMountPoint("/dev/sda1", mountpoint) << '\n';
cout << mountpoint << '\n';
- cout << s->changeMountPoint ("/dev/hda1", "/mnt") << '\n';
- cout << s->getMountPoint ("/dev/hda1", mountpoint) << '\n';
+ cout << s->changeMountPoint("/dev/sda1", "/mnt") << '\n';
+ cout << s->getMountPoint("/dev/sda1", mountpoint) << '\n';
cout << mountpoint << '\n';
delete s;
@@ -35,7 +34,7 @@
void
-mountby1 ()
+mountby1()
{
cout << "mountby1\n";
@@ -43,16 +42,16 @@
MountByType mountby;
- cout << s->changeMountBy ("/dev/hda1", MOUNTBY_DEVICE) << '\n';
- cout << s->getMountBy ("/dev/hda1", mountby) << '\n';
+ cout << s->changeMountBy("/dev/sda1", MOUNTBY_DEVICE) << '\n';
+ cout << s->getMountBy("/dev/sda1", mountby) << '\n';
cout << mountby << '\n';
- cout << s->changeMountBy ("/dev/hda1", MOUNTBY_UUID) << '\n';
- cout << s->getMountBy ("/dev/hda1", mountby) << '\n';
+ cout << s->changeMountBy("/dev/sda1", MOUNTBY_UUID) << '\n';
+ cout << s->getMountBy("/dev/sda1", mountby) << '\n';
cout << mountby << '\n';
- cout << s->changeMountBy ("/dev/hda1", MOUNTBY_LABEL) << '\n';
- cout << s->getMountBy ("/dev/hda1", mountby) << '\n';
+ cout << s->changeMountBy("/dev/sda1", MOUNTBY_LABEL) << '\n';
+ cout << s->getMountBy("/dev/sda1", mountby) << '\n';
cout << mountby << '\n';
delete s;
@@ -60,7 +59,7 @@
void
-options1 ()
+options1()
{
cout << "options1\n";
@@ -68,28 +67,28 @@
string options;
- cout << s->changeFstabOptions ("/dev/hda1", "acl,user_xattr") << '\n';
- cout << s->getFstabOptions ("/dev/hda1", options) << '\n';
+ cout << s->changeFstabOptions("/dev/sda1", "acl,user_xattr") << '\n';
+ cout << s->getFstabOptions("/dev/sda1", options) << '\n';
cout << options << '\n';
- cout << s->removeFstabOptions ("/dev/hda1", "acl") << '\n';
- cout << s->getFstabOptions ("/dev/hda1", options) << '\n';
+ cout << s->removeFstabOptions("/dev/sda1", "acl") << '\n';
+ cout << s->getFstabOptions("/dev/sda1", options) << '\n';
cout << options << '\n';
- cout << s->addFstabOptions ("/dev/hda1", "noauto") << '\n';
- cout << s->getFstabOptions ("/dev/hda1", options) << '\n';
+ cout << s->addFstabOptions("/dev/sda1", "noauto") << '\n';
+ cout << s->getFstabOptions("/dev/sda1", options) << '\n';
cout << options << '\n';
- cout << s->addFstabOptions ("/dev/hda1", "iocharset=utf8") << '\n';
- cout << s->getFstabOptions ("/dev/hda1", options) << '\n';
+ cout << s->addFstabOptions("/dev/sda1", "iocharset=utf8") << '\n';
+ cout << s->getFstabOptions("/dev/sda1", options) << '\n';
cout << options << '\n';
- cout << s->removeFstabOptions ("/dev/hda1", "iocharset=*") << '\n';
- cout << s->getFstabOptions ("/dev/hda1", options) << '\n';
+ cout << s->removeFstabOptions("/dev/sda1", "iocharset=*") << '\n';
+ cout << s->getFstabOptions("/dev/sda1", options) << '\n';
cout << options << '\n';
- cout << s->removeFstabOptions ("/dev/hda1", "not_here") << '\n';
- cout << s->getFstabOptions ("/dev/hda1", options) << '\n';
+ cout << s->removeFstabOptions("/dev/sda1", "not_here") << '\n';
+ cout << s->getFstabOptions("/dev/sda1", options) << '\n';
cout << options << '\n';
delete s;
@@ -97,7 +96,7 @@
void
-crypt1 ()
+crypt1()
{
cout << "crypt1\n";
@@ -105,23 +104,23 @@
bool val = false;
- cout << s->changeFormatVolume("/dev/hda1", true, EXT3 ) << '\n';
- cout << s->setCryptPassword ("/dev/hda1", "test") << '\n'; // FAILS
- cout << s->setCrypt ("/dev/hda1", true) << '\n'; // FAILS
-
- cout << s->changeFormatVolume("/dev/hda1", false, EXT3 ) << '\n';
- cout << s->setCryptPassword("/dev/hda1", "test") << '\n';
- cout << s->setCrypt("/dev/hda1", true) << '\n';
+ cout << s->changeFormatVolume("/dev/sda1", true, EXT3 ) << '\n';
+ cout << s->setCryptPassword("/dev/sda1", "test") << '\n'; // FAILS
+ cout << s->setCrypt("/dev/sda1", true) << '\n'; // FAILS
+
+ cout << s->changeFormatVolume("/dev/sda1", false, EXT3 ) << '\n';
+ cout << s->setCryptPassword("/dev/sda1", "test") << '\n';
+ cout << s->setCrypt("/dev/sda1", true) << '\n';
- cout << s->changeFormatVolume("/dev/hda1", true, EXT3 ) << '\n';
- cout << s->setCryptPassword ("/dev/hda1", "hello-world") << '\n';
+ cout << s->changeFormatVolume("/dev/sda1", true, EXT3 ) << '\n';
+ cout << s->setCryptPassword("/dev/sda1", "hello-world") << '\n';
- cout << s->setCrypt ("/dev/hda1", true) << '\n';
- cout << s->getCrypt ("/dev/hda1", val) << '\n';
+ cout << s->setCrypt("/dev/sda1", true) << '\n';
+ cout << s->getCrypt("/dev/sda1", val) << '\n';
cout << val << '\n';
- cout << s->setCrypt ("/dev/hda1", false) << '\n';
- cout << s->getCrypt ("/dev/hda1", val) << '\n';
+ cout << s->setCrypt("/dev/sda1", false) << '\n';
+ cout << s->getCrypt("/dev/sda1", val) << '\n';
cout << val << '\n';
delete s;
@@ -129,7 +128,7 @@
void
-combined1 ()
+combined1()
{
cout << "combined1\n";
@@ -137,26 +136,26 @@
string mountpoint;
- cout << s->changeMountPoint ("/dev/hda1", "/mnt") << '\n';
- cout << s->changeMountBy ("/dev/hda1", MOUNTBY_DEVICE) << '\n';
+ cout << s->changeMountPoint("/dev/sda1", "/mnt") << '\n';
+ cout << s->changeMountBy("/dev/sda1", MOUNTBY_DEVICE) << '\n';
- cout << s->changeMountPoint ("/dev/hda1", "") << '\n';
- cout << s->changeMountBy ("/dev/hda1", MOUNTBY_DEVICE) << '\n'; // FAILS
+ cout << s->changeMountPoint("/dev/sda1", "") << '\n';
+ cout << s->changeMountBy("/dev/sda1", MOUNTBY_DEVICE) << '\n'; // FAILS
delete s;
}
int
-main ()
+main()
{
- system ("mkdir -p tmp");
+ setup_logger();
- system ("cp data/volume_info tmp");
- system ("cp data/disk_hda tmp");
- mountpoint1 ();
- mountby1 ();
- options1 ();
- crypt1 ();
- combined1 ();
+ setup_system("thalassa");
+
+ mountpoint1();
+ mountby1();
+ options1();
+ crypt1();
+ combined1();
}
Added: branches/SuSE-Code-11-SP2-Branch/storage/libstorage/testsuite/fstab2.cc
URL: http://svn.opensuse.org/viewcvs/yast/branches/SuSE-Code-11-SP2-Branch/stora…
==============================================================================
--- branches/SuSE-Code-11-SP2-Branch/storage/libstorage/testsuite/fstab2.cc (added)
+++ branches/SuSE-Code-11-SP2-Branch/storage/libstorage/testsuite/fstab2.cc Tue May 17 13:39:44 2011
@@ -0,0 +1,59 @@
+
+#include <stdlib.h>
+#include <iostream>
+#include <boost/algorithm/string.hpp>
+
+#include "common.h"
+
+
+using namespace std;
+using namespace storage;
+
+
+void
+run()
+{
+ // check order of entries in fstab (bnc #584553)
+
+ StorageInterface* s = createStorageInterface(TestEnvironment());
+
+ string disk = "/dev/sda";
+
+ s->destroyPartitionTable(disk, "msdos");
+
+ string name1;
+ cout << s->createPartitionKb(disk, PRIMARY, 0, 999999, name1) << endl;
+ cout << name1 << endl;
+
+ string name2;
+ cout << s->createPartitionKb(disk, PRIMARY, 1000000, 1999999, name2) << endl;
+ cout << name2 << endl;
+
+ cout << s->changeFormatVolume(name1, true, EXT4) << endl;
+ cout << s->changeMountPoint(name1, "/usr/local") << endl;
+ cout << s->changeLabelVolume(name1, "first") << endl;
+ cout << s->changeMountBy(name1, MOUNTBY_LABEL) << endl;
+
+ cout << s->changeFormatVolume(name2, true, EXT4) << endl;
+ cout << s->changeMountPoint(name2, "/usr") << endl;
+ cout << s->changeLabelVolume(name2, "second") << endl;
+ cout << s->changeMountBy(name2, MOUNTBY_LABEL) << endl;
+
+ cout << s->commit() << endl;
+
+ delete s;
+}
+
+
+int
+main()
+{
+ cout.setf(std::ios::boolalpha);
+
+ setup_logger();
+
+ setup_system("empty");
+
+ run();
+ print_fstab();
+}
Added: branches/SuSE-Code-11-SP2-Branch/storage/libstorage/testsuite/fstab3.cc
URL: http://svn.opensuse.org/viewcvs/yast/branches/SuSE-Code-11-SP2-Branch/stora…
==============================================================================
--- branches/SuSE-Code-11-SP2-Branch/storage/libstorage/testsuite/fstab3.cc (added)
+++ branches/SuSE-Code-11-SP2-Branch/storage/libstorage/testsuite/fstab3.cc Tue May 17 13:39:44 2011
@@ -0,0 +1,49 @@
+
+#include <stdlib.h>
+#include <iostream>
+#include <boost/algorithm/string.hpp>
+
+#include "common.h"
+
+
+using namespace std;
+using namespace storage;
+
+
+void
+run()
+{
+ StorageInterface* s = createStorageInterface(TestEnvironment());
+
+ string disk = "/dev/sda";
+
+ s->destroyPartitionTable(disk, "msdos");
+
+ string name;
+ cout << s->createPartitionKb(disk, PRIMARY, 0, 999999, name) << endl;
+ cout << name << endl;
+
+ cout << s->changeFormatVolume(name, true, EXT4) << endl;
+ cout << s->changeMountPoint(name, "/secret") << endl;
+ cout << s->setCryptPassword(name, "12345678") << endl;
+ cout << s->setCrypt(name, true) << endl;
+
+ cout << s->commit() << endl;
+
+ delete s;
+}
+
+
+int
+main()
+{
+ cout.setf(std::ios::boolalpha);
+
+ setup_logger();
+
+ setup_system("empty");
+
+ run();
+ print_fstab();
+ print_crypttab();
+}
Added: branches/SuSE-Code-11-SP2-Branch/storage/libstorage/testsuite/fstab4.cc
URL: http://svn.opensuse.org/viewcvs/yast/branches/SuSE-Code-11-SP2-Branch/stora…
==============================================================================
--- branches/SuSE-Code-11-SP2-Branch/storage/libstorage/testsuite/fstab4.cc (added)
+++ branches/SuSE-Code-11-SP2-Branch/storage/libstorage/testsuite/fstab4.cc Tue May 17 13:39:44 2011
@@ -0,0 +1,51 @@
+
+#include <stdlib.h>
+#include <iostream>
+#include <boost/algorithm/string.hpp>
+
+#include "common.h"
+
+
+using namespace std;
+using namespace storage;
+
+
+void
+run()
+{
+ StorageInterface* s = createStorageInterface(TestEnvironment());
+
+ string disk = "/dev/sda";
+
+ s->destroyPartitionTable(disk, "msdos");
+
+ string name;
+ cout << s->createPartitionKb(disk, PRIMARY, 0, 999999, name) << endl;
+ cout << name << endl;
+
+ cout << s->setCryptPassword(name, "12345678") << endl;
+ cout << s->setCrypt(name, true) << endl;
+
+ deque<string> pvs;
+ pvs.push_back(name);
+ cout << s->createLvmVg("test", 1024, false, pvs) << endl;
+
+ cout << s->commit() << endl; // TODO: fails, but acceptable for testcase
+
+ delete s;
+}
+
+
+int
+main()
+{
+ cout.setf(std::ios::boolalpha);
+
+ setup_logger();
+
+ setup_system("empty");
+
+ run();
+ print_fstab();
+ print_crypttab();
+}
Modified: branches/SuSE-Code-11-SP2-Branch/storage/libstorage/testsuite/humanstring1.cc
URL: http://svn.opensuse.org/viewcvs/yast/branches/SuSE-Code-11-SP2-Branch/stora…
==============================================================================
--- branches/SuSE-Code-11-SP2-Branch/storage/libstorage/testsuite/humanstring1.cc (original)
+++ branches/SuSE-Code-11-SP2-Branch/storage/libstorage/testsuite/humanstring1.cc Tue May 17 13:39:44 2011
@@ -3,47 +3,44 @@
#include <iostream>
#include <locale>
-#include <StorageInterface.h>
+#include <storage/HumanString.h>
-#include "common.h"
using namespace std;
using namespace storage;
-// Don't bother setting up locale for gettext since we don't have translations
-// during package build.
-
-
-StorageInterface* s = 0;
-
-
void
test(const char* loc, unsigned long long size, bool classic,
int precision, bool omit_zeroes)
{
locale::global(locale(loc));
- cout << s->byteToHumanString(size, classic, precision, omit_zeroes) << endl;
+ cout << byteToHumanString(size, classic, precision, omit_zeroes) << endl;
}
int
main()
{
- s = createStorageInterface(TestEnvironment());
-
+ const char* localedir = getenv("LOCALEDIR");
+ if (localedir)
+ bindtextdomain("libstorage", localedir);
+
+ cout << "-- 1 --" << endl;
+ test("en_GB.UTF-8", 0, false, 2, true);
+ test("en_GB.UTF-8", 0, false, 2, false);
test("en_GB.UTF-8", 1024, true, 2, true);
test("en_GB.UTF-8", 1024, true, 2, false);
+ cout << "-- 2 --" << endl;
test("de_DE.UTF-8", 123456789, true, 4, false);
test("de_DE.UTF-8", 123456789, false, 4, false);
+ cout << "-- 3 --" << endl;
test("fr_FR.UTF-8", 123456789, true, 4, false);
- test("fr_FR.UTF-8", 123456789, false, 4, false);
+ cout << "-- 4 --" << endl;
test("en_GB.UTF-8", 1000*1024, false, 2, false);
test("de_DE.UTF-8", 1000*1024, false, 2, false);
- test("fr_FR.UTF-8", 1000*1024, false, 2, false);
-
- delete s;
+ test("de_CH.UTF-8", 1000*1024, false, 2, false);
}
Modified: branches/SuSE-Code-11-SP2-Branch/storage/libstorage/testsuite/humanstring2.cc
URL: http://svn.opensuse.org/viewcvs/yast/branches/SuSE-Code-11-SP2-Branch/stora…
==============================================================================
--- branches/SuSE-Code-11-SP2-Branch/storage/libstorage/testsuite/humanstring2.cc (original)
+++ branches/SuSE-Code-11-SP2-Branch/storage/libstorage/testsuite/humanstring2.cc Tue May 17 13:39:44 2011
@@ -3,20 +3,12 @@
#include <iostream>
#include <locale>
-#include <StorageInterface.h>
+#include <storage/HumanString.h>
-#include "common.h"
using namespace std;
using namespace storage;
-
-// Don't bother setting up locale for gettext since we don't have translations
-// during package build.
-
-
-StorageInterface* s = 0;
-
void
test(const char* loc, const char* str, bool classic)
@@ -25,7 +17,7 @@
unsigned long long size = 0;
- if (s->humanStringToByte(str, classic, size))
+ if (humanStringToByte(str, classic, size))
cout << "parse ok " << size << endl;
else
cout << "parse error" << endl;
@@ -35,42 +27,60 @@
int
main()
{
- s = createStorageInterface(TestEnvironment());
+ const char* localedir = getenv("LOCALEDIR");
+ if (localedir)
+ bindtextdomain("libstorage", localedir);
+ cout << "-- 1 --" << endl;
test("en_GB.UTF-8", "42", true); // FAILS: classic=true needs a suffix
test("en_GB.UTF-8", "42B", true);
test("en_GB.UTF-8", "42 b", true);
+ cout << "-- 2 --" << endl;
test("en_GB.UTF-8", "42", false);
test("en_GB.UTF-8", "42b", false);
test("en_GB.UTF-8", "42 B", false);
+ cout << "-- 3 --" << endl;
test("en_GB.UTF-8", "12.4GB", true);
test("en_GB.UTF-8", "12.4 GB", true);
+ cout << "-- 4 --" << endl;
test("en_GB.UTF-8", "12.4GB", false);
test("en_GB.UTF-8", "12.4 gb", false);
test("en_GB.UTF-8", "12.4g", false);
test("en_GB.UTF-8", "12.4 G", false);
+ cout << "-- 5 --" << endl;
test("en_GB.UTF-8", "123,456 kB", false);
test("de_DE.UTF-8", "123.456 kB", false);
- test("fr_FR.UTF-8", "123 456 kB", false);
+ test("de_CH.UTF-8", "123'456 kB", false);
+ cout << "-- 6 --" << endl;
test("en_GB.UTF-8", "123,456.789kB", false);
test("de_DE.UTF-8", "123.456,789kB", false);
- test("fr_FR.UTF-8", "123 456,789kB", false);
+ test("de_CH.UTF-8", "123'456.789kB", false);
+ cout << "-- 7 --" << endl;
test("en_GB.UTF-8", "123,456.789 kB", false);
test("de_DE.UTF-8", "123.456,789 kB", false);
- test("fr_FR.UTF-8", "123 456,789 kB", false);
+ test("de_CH.UTF-8", "123'456.789 kB", false);
- test("fr_FR.UTF-8", "5GB", false);
- test("fr_FR.UTF-8", "5 GB", false);
+ cout << "-- 8 --" << endl;
+ cout << "-- 9 --" << endl;
test("en_US.UTF-8", "5 G B", false); // FAILS
test("de_DE.UTF-8", "12.34 kB", false); // FAILS
- test("fr_FR.UTF-8", "12 34 GB", false); // FAILS
+ test("de_DE.UTF-8", "12'34 kB", false); // FAILS
+ test("fr_FR.UTF-8", "12 34 Go", false); // FAILS
- delete s;
+ cout << "-- 10 --" << endl;
+ test("en_GB.UTF-8", "3.14 G", false);
+ test("en_GB.UTF-8", "3.14 GB", false);
+ test("en_GB.UTF-8", "3.14 GiB", false);
+
+ cout << "-- 11 --" << endl;
+ test("en_GB.UTF-8", "12345 GB", false);
+ test("de_DE.UTF-8", "12345 GB", false);
+ test("de_CH.UTF-8", "12345 GB", false);
}
Modified: branches/SuSE-Code-11-SP2-Branch/storage/libstorage/testsuite/lvm_create.cc
URL: http://svn.opensuse.org/viewcvs/yast/branches/SuSE-Code-11-SP2-Branch/stora…
==============================================================================
--- branches/SuSE-Code-11-SP2-Branch/storage/libstorage/testsuite/lvm_create.cc (original)
+++ branches/SuSE-Code-11-SP2-Branch/storage/libstorage/testsuite/lvm_create.cc Tue May 17 13:39:44 2011
@@ -1,8 +1,5 @@
-#include <stdio.h>
-#include <stdlib.h>
#include <iostream>
-#include <iterator>
#include <sstream>
#include "common.h"
@@ -12,68 +9,18 @@
using namespace std;
-StorageInterface *s = 0;
-
-
-void print_num_lvs(const string& disk, const string& vg)
-{
- deque<LvmLvInfo> plist;
- s->getLvmLvInfo( vg, plist );
-
- cout << plist.size() << endl;
-}
-
-/*
- * get all partitions on disks disks which could be added to a
- * logical volume group ( AFAIK --> PRIMARY, LOGICAL )
- */
-deque<string> getDevs( deque<string> disks )
-{
- StorageInterface *siface = createStorageInterface(TestEnvironment());
-
- deque<string> devs;
- deque<PartitionInfo> pInfos;
-
- for ( deque<string>::iterator i = disks.begin();
- i != disks.end(); i++)
- {
- cout << siface->getPartitionInfo( *i, pInfos ) << endl;
-
- for (deque<PartitionInfo>::iterator f = pInfos.begin ();
- f != pInfos.end(); f++)
- {
- switch (f->partitionType)
- {
- case PRIMARY:
- devs.push_back(f->v.name);
- break;
- case LOGICAL:
- devs.push_back(f->v.name);
- break;
- default:
- break;
- }
- }
-
- }
-
- delete siface;
-
- return devs;
-}
-
-void createLvs( const string& vg, int n, deque<string>& disks )
+void createLvs(const string& vg, int n, const deque<string>& pvs)
{
- printf("createLvs\n");
+ cout << "createLvs" << endl;
- s = createStorageInterface(TestEnvironment());
+ StorageInterface* s = createStorageInterface(TestEnvironment());
- /* create volume group with the above disks */
- cout << s->createLvmVg( vg, 4, false, getDevs(disks) ) << endl;
+ /* create volume group with the above pvs */
+ cout << s->createLvmVg( vg, 4, false, pvs ) << endl;
/* create n logical volumes */
int ret = 0;
- for ( int i = 0; i < n; i++ )
+ for ( int i = 0; i < n; i++ )
{
ostringstream name;
name << "volume";
@@ -83,28 +30,24 @@
ret = s->createLvmLv( vg, name.str(), 100, 1, dev );
}
cout << ret << endl;
-
-
- for ( deque<string>::iterator i = disks.begin();
- i != disks.end(); i++ )
- {
- print_num_lvs( *i, vg);
- print_num_lvs( *i, vg);
- }
+ deque<LvmLvInfo> plist;
+ s->getLvmLvInfo( vg, plist );
+ cout << plist.size() << endl;
+
delete s;
}
-void createExtendedLv( const string& vg, const string& dev )
+void createExtendedLv(const string& vg, const string& dev)
{
- printf("createExtendedLv\n");
+ cout << "createExtendedLv" << endl;
- s = createStorageInterface(TestEnvironment());
+ StorageInterface* s = createStorageInterface(TestEnvironment());
deque<string> devs;
devs.push_back(dev); // add extended partition
-
+
/* create volume group with the extended partition */
cout << s->createLvmVg( vg, 4, false, devs ) << endl; // FAILS
@@ -112,55 +55,29 @@
}
-int main( int argc_iv, char** argv_ppcv )
+int
+main()
{
- system ("mkdir -p tmp");
-
- system ("rm -rf tmp/*");
-
- deque<string> disks;
+ setup_logger();
/*
- * Check that we can create a volume group and 50 logical volumes on
- * ide disks.
+ * Check that we can create a volume group from primary and logical
+ * partitons and 50 logical volumes.
*/
- disks.push_back( "/dev/hda" );
- disks.push_back( "/dev/hdb" );
- system ("cp data/disk_hda tmp");
- system ("cp data/disk_hdb tmp");
- createLvs( "system", 50, disks );
- disks.clear();
+ setup_system("thalassa");
- /*
- * Check that we can create a volume group and 50 logical volumes on
- * scsi disks.
- */
- disks.push_back( "/dev/sda" );
- disks.push_back( "/dev/sdb" );
- system ("cp data/disk_sda tmp");
- system ("cp data/disk_sdb tmp");
- createLvs( "system", 50, disks );
- disks.clear();
+ deque<string> pvs;
+ pvs.push_back("/dev/sdc1");
+ pvs.push_back("/dev/sdc2");
+ pvs.push_back("/dev/sdc5");
+ pvs.push_back("/dev/sdc6");
+ createLvs("test", 50, pvs);
/*
- * Check that we can create a volume group and 100 logical volumes on
- * ide and scsi disks.
+ * Check that we cannot create a volume group out of an extended
+ * partition.
*/
- disks.push_back( "/dev/sda" );
- disks.push_back( "/dev/sdb" );
- disks.push_back( "/dev/hda" );
- disks.push_back( "/dev/hdb" );
- system ("cp data/disk_sda tmp");
- system ("cp data/disk_sdb tmp");
- system ("cp data/disk_hda tmp");
- system ("cp data/disk_hdb tmp");
- createLvs( "system", 50, disks );
- disks.clear();
+ setup_system("thalassa");
- /*
- * Check that we _cannot_ create a volume group out of an extended
- * partition
- */
- system ("cp data/disk_hda tmp");
- createExtendedLv("system", "/dev/hda4");
+ createExtendedLv("test", "/dev/sdc4");
}
Added: branches/SuSE-Code-11-SP2-Branch/storage/libstorage/testsuite/lvm_create2.cc
URL: http://svn.opensuse.org/viewcvs/yast/branches/SuSE-Code-11-SP2-Branch/stora…
==============================================================================
--- branches/SuSE-Code-11-SP2-Branch/storage/libstorage/testsuite/lvm_create2.cc (added)
+++ branches/SuSE-Code-11-SP2-Branch/storage/libstorage/testsuite/lvm_create2.cc Tue May 17 13:39:44 2011
@@ -0,0 +1,40 @@
+
+#include <iostream>
+
+#include "common.h"
+
+
+using namespace storage;
+using namespace std;
+
+
+int
+main()
+{
+ setup_logger();
+
+ setup_system("thalassa");
+
+ StorageInterface* s = createStorageInterface(TestEnvironment());
+
+ string device;
+ deque<string> devices;
+
+ /* create volume group "system" which does already exist */
+ devices.clear();
+ devices.push_back("/dev/sdb1");
+ cout << s->createLvmVg("system", 4, false, devices) << endl; // FAILS
+
+ /* create volume group "data" */
+ devices.clear();
+ devices.push_back("/dev/sdb1");
+ cout << s->createLvmVg("data", 4, false, devices) << endl;
+
+ /* create logical volume "swap" on "system" which does already exist */
+ cout << s->createLvmLv("system", "swap", 2000, 1, device) << endl; // FAILS
+
+ /* create logical volume "swap" on "data" */
+ cout << s->createLvmLv("data", "swap", 2000, 1, device) << endl;
+
+ delete s;
+}
Modified: branches/SuSE-Code-11-SP2-Branch/storage/libstorage/testsuite/lvm_extend.cc
URL: http://svn.opensuse.org/viewcvs/yast/branches/SuSE-Code-11-SP2-Branch/stora…
==============================================================================
--- branches/SuSE-Code-11-SP2-Branch/storage/libstorage/testsuite/lvm_extend.cc (original)
+++ branches/SuSE-Code-11-SP2-Branch/storage/libstorage/testsuite/lvm_extend.cc Tue May 17 13:39:44 2011
@@ -1,9 +1,5 @@
-#include <stdio.h>
-#include <stdlib.h>
#include <iostream>
-#include <iterator>
-#include <sstream>
#include "common.h"
@@ -12,93 +8,40 @@
using namespace std;
-StorageInterface *s = 0;
-
-void print_num_pvs( const string& vg)
+void
+extendVg(const string& vg, const deque<string>& pvs)
{
- deque<string> disks;
- disks.push_back( "/dev/hda" );
- disks.push_back( "/dev/hdb" );
- disks.push_back( "/dev/sda" );
- disks.push_back( "/dev/sdb" );
-
- int count = 0;
- for ( deque<string>::iterator i = disks.begin();
- i != disks.end(); i++ )
- {
- deque<PartitionInfo> pinfos;
- cout << s->getPartitionInfo( *i, pinfos )<< endl;
-
- for ( deque<PartitionInfo>::iterator p = pinfos.begin();
- p != pinfos.end(); p++ )
- {
- if ( p->v.usedByDevice == "/dev/" + vg )
- count++;
- }
- }
- cout << count << endl;
-}
+ cout << "extendVg" << endl;
+ StorageInterface* s = createStorageInterface(TestEnvironment());
-void extendVg( const string& vg, deque<string> devs_extend )
-{
- printf("extendVg\n");
+ LvmVgInfo info;
+ cout << s->getLvmVgInfo(vg, info) << endl;
+ cout << info.devices << endl;
- s = createStorageInterface(TestEnvironment());
+ /* extend it by devs_extend given pvs */
+ cout << s->extendLvmVg(vg, pvs) << endl;
- deque<string> devs;
- devs.push_back( "/dev/hda1" );
- /* create volume group with the above disk */
- cout << s->createLvmVg( vg, 4, false, devs ) << endl;
-
- print_num_pvs( vg );
-
- /* extend it by devs_extend given devs */
- cout << s->extendLvmVg( vg, devs_extend ) << endl;
-
- print_num_pvs( vg );
+ cout << s->getLvmVgInfo(vg, info) << endl;
+ cout << info.devices << endl;
+ cout << info.devices_add << endl;
delete s;
}
-int main( int argc_iv, char** argv_ppcv )
+int
+main()
{
- system ("mkdir -p tmp");
-
- system ("rm -rf tmp/*");
+ setup_logger();
- system ("cp data/disk_hda tmp");
- system ("cp data/disk_hdb tmp");
- system ("cp data/disk_sda tmp");
- system ("cp data/disk_sdb tmp");
+ setup_system("thalassa");
deque<string> devs;
/*
- * Check that we can extend a volume group ( consisting of one PV
- * /dev/hda1 ) by some partitions on the same ide disk
- */
- devs.push_back("/dev/hda2");
- devs.push_back("/dev/hda5");
- extendVg( "system", devs );
- devs.clear();
-
- /*
- * Check that we can extend a volume group ( consisting of one PV
- * /dev/hda1 ) by some partitions on the another ide disk
- */
- devs.push_back("/dev/hdb1");
- devs.push_back("/dev/hdb2");
- extendVg( "system", devs );
- devs.clear();
-
- /*
- * Check that we can extend a volume group ( consisting of one PV
- * /dev/hda1 ) by some partitions on the another scsi disk
+ * Check that we can extend a volume group.
*/
- devs.push_back("/dev/sda1");
devs.push_back("/dev/sdb1");
- extendVg( "system", devs );
- devs.clear();
+ extendVg("system", devs);
}
Modified: branches/SuSE-Code-11-SP2-Branch/storage/libstorage/testsuite/md_create.cc
URL: http://svn.opensuse.org/viewcvs/yast/branches/SuSE-Code-11-SP2-Branch/stora…
==============================================================================
--- branches/SuSE-Code-11-SP2-Branch/storage/libstorage/testsuite/md_create.cc (original)
+++ branches/SuSE-Code-11-SP2-Branch/storage/libstorage/testsuite/md_create.cc Tue May 17 13:39:44 2011
@@ -1,7 +1,6 @@
#include <stdlib.h>
#include <iostream>
-#include <iterator>
#include "common.h"
@@ -26,16 +25,15 @@
cout << p->v.device << ' ';
cout << p->nr << ' ';
cout << p->type << ' ';
- cout << p->chunk << ' ';
+ cout << p->chunkSizeK << ' ';
}
-
}
-void createMD( MdType type, deque<string> devs )
+void createMD(MdType type, list<string> devs)
{
s = createStorageInterface(TestEnvironment());
- int ret = s->createMd( "/dev/md0", type, devs );
+ int ret = s->createMd("/dev/md0", type, devs, list<string>());
if( ret==0 )
ret = s->checkMd( "/dev/md0" );
@@ -48,49 +46,46 @@
}
-int main( int argc_iv, char** argv_ppcv )
+int
+main()
{
- system ("mkdir -p tmp");
+ setup_logger();
- system ("rm -rf tmp/*");
+ setup_system("thalassa");
- deque<string> devs;
-
- system ("cp data/disk_hda tmp");
- system ("cp data/disk_hdb tmp");
- system ("cp data/disk_sda tmp");
+ list<string> devs;
/*
* Check that we _cannot_ create software raid devices with just one
* partition
*/
- devs.push_back( "/dev/hda1" );
+ devs.push_back("/dev/sdc1");
cout << "Devices: " << devs.size() << " ----------------------\n";
createMD(RAID0, devs); // fails, too few devices
createMD(RAID1, devs); // fails, too few devices
createMD(RAID5, devs); // fails, too few devices
createMD(RAID6, devs); // fails, too few devices
- createMD(RAID10,devs); // fails, too few devices
+ createMD(RAID10, devs); // fails, too few devices
createMD(MULTIPATH, devs); // fails, too few devices
createMD(RAID_UNK, devs); // RAID_UNK always fails
/*
* Check that this works for some raid levels with two devices
*/
- devs.push_back( "/dev/hda2" );
+ devs.push_back("/dev/sdc2");
cout << "Devices: " << devs.size() << " ----------------------\n";
createMD(RAID0, devs); // works now
createMD(RAID1, devs); // works now
createMD(RAID5, devs); // fails, too few devices
createMD(RAID6, devs); // fails, too few devices
- createMD(RAID10,devs); // works now
+ createMD(RAID10, devs); // works now
createMD(MULTIPATH, devs); // works now
createMD(RAID_UNK, devs); // RAID_UNK always fails
/*
* RAID6 still fails
*/
- devs.push_back( "/dev/hda3" );
+ devs.push_back("/dev/sdc3");
cout << "Devices: " << devs.size() << " ----------------------\n";
createMD(RAID5, devs); // works now
createMD(RAID6, devs); // fails, too few devices
@@ -98,7 +93,7 @@
/*
* Everything works now
*/
- devs.push_back( "/dev/hda3" );
+ devs.push_back("/dev/sdc5");
cout << "Devices: " << devs.size() << " ----------------------\n";
createMD(RAID6, devs); // works now
@@ -106,25 +101,12 @@
* Check that we can create a software raid device with partitions
* from different devices
*/
- devs.push_back( "/dev/hdb1" );
- cout << "Devices: " << devs.size() << " ----------------------\n";
- createMD(RAID0, devs);
- createMD(RAID1, devs);
- createMD(RAID5, devs);
- createMD(RAID6, devs);
- createMD(RAID10,devs);
- createMD(MULTIPATH, devs);
-
-
- /*
- * Check that we can create a software raid device with partitions from a scsi disk
- */
- devs.push_back( "/dev/sda1" );
+ devs.push_back("/dev/sdb1");
cout << "Devices: " << devs.size() << " ----------------------\n";
createMD(RAID0, devs);
createMD(RAID1, devs);
createMD(RAID5, devs);
createMD(RAID6, devs);
- createMD(RAID10,devs);
+ createMD(RAID10, devs);
createMD(MULTIPATH, devs);
}
Modified: branches/SuSE-Code-11-SP2-Branch/storage/libstorage/testsuite/partition1.cc
URL: http://svn.opensuse.org/viewcvs/yast/branches/SuSE-Code-11-SP2-Branch/stora…
==============================================================================
--- branches/SuSE-Code-11-SP2-Branch/storage/libstorage/testsuite/partition1.cc (original)
+++ branches/SuSE-Code-11-SP2-Branch/storage/libstorage/testsuite/partition1.cc Tue May 17 13:39:44 2011
@@ -1,10 +1,5 @@
-#include <stdio.h>
-#include <stdlib.h>
#include <iostream>
-#include <iterator>
-
-#include <StorageInterface.h>
#include "common.h"
@@ -17,52 +12,27 @@
void
-print_partitions (const string& disk)
-{
- deque<PartitionInfo> partitioninfos;
- s->getPartitionInfo (disk, partitioninfos);
- for (deque<PartitionInfo>::iterator i = partitioninfos.begin ();
- i != partitioninfos.end(); i++)
- {
- cout << i->v.name << ' ';
- switch (i->partitionType)
- {
- case PRIMARY: cout << "PRIMARY "; break;
- case EXTENDED: cout << "EXTENDED "; break;
- case LOGICAL: cout << "LOGICAL "; break;
- case PTYPE_ANY: cout << "ANY "; break;
- }
- cout << i->cylStart << ' ' << i->cylSize << '\n';
- }
-
- cout << '\n';
-}
-
-
-void
msdos (const string& disk, int n)
{
- printf ("msdos %s %d\n", disk.c_str(), n);
+ cout << "msdos " << disk << " " << n << endl;
s = createStorageInterface(TestEnvironment());
- s->destroyPartitionTable (disk, "msdos");
+ s->destroyPartitionTable(disk, "msdos");
long int S = 100000;
string name;
- cout << s->createPartitionKb (disk, PRIMARY, 0*S, S, name) << '\n';
- cout << s->createPartitionKb (disk, PRIMARY, 1*S, S, name) << '\n';
- cout << s->createPartitionKb (disk, PRIMARY, 2*S, S, name) << '\n';
-
- cout << s->createPartitionKb (disk, EXTENDED, 3*S, (n+1)*S, name) << '\n';
+ cout << s->createPartitionKb(disk, PRIMARY, 0*S, S, name) << endl;
+ cout << s->createPartitionKb(disk, PRIMARY, 1*S, S, name) << endl;
+ cout << s->createPartitionKb(disk, PRIMARY, 2*S, S, name) << endl;
- for (int i = 0; i < n; i++)
- cout << s->createPartitionKb (disk, LOGICAL, (3+i)*S, S, name) << '\n';
+ cout << s->createPartitionKb(disk, EXTENDED, 3*S, (n+1)*S, name) << endl;
- cout << s->createPartitionKb (disk, LOGICAL, (3+n)*S, S, name) << '\n'; // FAILS
+ for (int i = 0; i < n; ++i)
+ cout << s->createPartitionKb(disk, LOGICAL, (3+i)*S, S, name) << endl;
- print_partitions (disk);
+ print_partitions(s, disk);
delete s;
}
@@ -71,56 +41,40 @@
void
gpt (const string& disk, int n)
{
- printf ("gpt %s %d\n", disk.c_str(), n);
+ cout << "gpt " << disk << " " << n << endl;
s = createStorageInterface(TestEnvironment());
- s->destroyPartitionTable (disk, "gpt");
+ s->destroyPartitionTable(disk, "gpt");
long int S = 100000;
string name;
- for (int i = 0; i < n; i++)
- cout << s->createPartitionKb (disk, PRIMARY, i*S, S, name) << '\n';
+ for (int i = 0; i < n; ++i)
+ cout << s->createPartitionKb(disk, PRIMARY, i*S, S, name) << endl;
- cout << s->createPartitionKb (disk, PRIMARY, n*S, S, name) << '\n'; // FAILS
-
- print_partitions (disk);
+ print_partitions(s, disk);
delete s;
}
int
-main ()
+main()
{
- system ("mkdir -p tmp");
-
- /*
- * Check that we can create 3 primary, 1 extended and 59 logical partitions
- * on a ide disk with msdos partition table.
- */
- system ("cp data/disk_hda tmp/disk_hda");
- msdos ("/dev/hda", 59);
-
- /*
- * Check that we can create 3 primary, 1 extended and 11 logical partitions
- * on a scsi disk with msdos partition table.
- */
- system ("cp data/disk_sda tmp/disk_sda");
- msdos ("/dev/sda", 11);
+ setup_logger();
/*
- * Check that we can create 63 primary partitions on a ide disk with gpt
- * partition table.
+ * Check that we can create 3 primary, 1 extended and many logical
+ * partitions on a disk with msdos partition table and big range.
*/
- system ("cp data/disk_hda tmp/disk_hda");
- gpt ("/dev/hda", 63);
+ setup_system("thalassa");
+ msdos("/dev/sdc", 32);
/*
- * Check that we can create 15 primary partitions on a scsi disk with gpt
- * partition table.
+ * Check that we can create many primary partitions on a disk with gpt
+ * partition table and big range.
*/
- system ("cp data/disk_sda tmp/disk_sda");
- gpt ("/dev/sda", 15);
+ setup_system("thalassa");
+ gpt("/dev/sdc", 32);
}
Added: branches/SuSE-Code-11-SP2-Branch/storage/libstorage/testsuite/partitionname.cc
URL: http://svn.opensuse.org/viewcvs/yast/branches/SuSE-Code-11-SP2-Branch/stora…
==============================================================================
--- branches/SuSE-Code-11-SP2-Branch/storage/libstorage/testsuite/partitionname.cc (added)
+++ branches/SuSE-Code-11-SP2-Branch/storage/libstorage/testsuite/partitionname.cc Tue May 17 13:39:44 2011
@@ -0,0 +1,25 @@
+
+#include <iostream>
+
+#include "common.h"
+
+
+using namespace std;
+using namespace storage;
+
+
+int
+main()
+{
+ setup_logger();
+
+ StorageInterface* s = createStorageInterface(TestEnvironment());
+
+ cout << s->getPartitionName("/dev/sda", 1) << endl;
+ cout << s->getPartitionName("/dev/cciss/c0d1", 2) << endl;
+ cout << s->getPartitionName("/dev/mmcblk0", 3) << endl;
+ cout << s->getPartitionName("/dev/mapper/isw_cfcjajfdfh_test", 4) << endl;
+ cout << s->getPartitionName("/dev/md2", 5) << endl;
+
+ delete s;
+}
Added: branches/SuSE-Code-11-SP2-Branch/storage/libstorage/testsuite/partitionprefix.cc
URL: http://svn.opensuse.org/viewcvs/yast/branches/SuSE-Code-11-SP2-Branch/stora…
==============================================================================
--- branches/SuSE-Code-11-SP2-Branch/storage/libstorage/testsuite/partitionprefix.cc (added)
+++ branches/SuSE-Code-11-SP2-Branch/storage/libstorage/testsuite/partitionprefix.cc Tue May 17 13:39:44 2011
@@ -0,0 +1,28 @@
+
+#include <iostream>
+
+#include "common.h"
+
+
+using namespace std;
+using namespace storage;
+
+
+int
+main()
+{
+ setup_logger();
+
+ StorageInterface* s = createStorageInterface(TestEnvironment());
+
+ cout << s->getPartitionPrefix("/dev/sda") << endl;
+ cout << s->getPartitionPrefix("/dev/sda1") << endl;
+ cout << s->getPartitionPrefix("/dev/cciss/c0d1") << endl;
+ cout << s->getPartitionPrefix("/dev/cciss/c0d1p2") << endl;
+ cout << s->getPartitionPrefix("/dev/mmcblk0") << endl;
+ cout << s->getPartitionPrefix("/dev/mmcblk0p3") << endl;
+ cout << s->getPartitionPrefix("/dev/mapper/isw_cfcjajfdfh_test") << endl;
+ cout << s->getPartitionPrefix("/dev/mapper/isw_cfcjajfdfh_test_part4") << endl;
+
+ delete s;
+}
Added: branches/SuSE-Code-11-SP2-Branch/storage/libstorage/testsuite/recursive1.cc
URL: http://svn.opensuse.org/viewcvs/yast/branches/SuSE-Code-11-SP2-Branch/stora…
==============================================================================
--- branches/SuSE-Code-11-SP2-Branch/storage/libstorage/testsuite/recursive1.cc (added)
+++ branches/SuSE-Code-11-SP2-Branch/storage/libstorage/testsuite/recursive1.cc Tue May 17 13:39:44 2011
@@ -0,0 +1,30 @@
+
+#include <iostream>
+
+#include "common.h"
+
+
+using namespace storage;
+using namespace std;
+
+
+int
+main()
+{
+ cout.setf(std::ios::boolalpha);
+
+ setup_logger();
+
+ setup_system("thalassa");
+
+ StorageInterface* s = createStorageInterface(TestEnvironment());
+
+ /* try to remove partition used by lvm */
+ cout << s->removePartition("/dev/sda2") << endl; // FAILS
+
+ /* remove partition used by lvm with recursive removal on */
+ s->setRecursiveRemoval(true);
+ cout << s->removePartition("/dev/sda2") << endl;
+
+ delete s;
+}
Added: branches/SuSE-Code-11-SP2-Branch/storage/libstorage/testsuite/recursive2.cc
URL: http://svn.opensuse.org/viewcvs/yast/branches/SuSE-Code-11-SP2-Branch/stora…
==============================================================================
--- branches/SuSE-Code-11-SP2-Branch/storage/libstorage/testsuite/recursive2.cc (added)
+++ branches/SuSE-Code-11-SP2-Branch/storage/libstorage/testsuite/recursive2.cc Tue May 17 13:39:44 2011
@@ -0,0 +1,53 @@
+
+#include <iostream>
+#include <boost/algorithm/string.hpp>
+
+#include "common.h"
+
+
+using namespace storage;
+using namespace std;
+
+
+StorageInterface* s = NULL;
+
+
+void
+test(const string& device)
+{
+ list<string> devices;
+ int ret = s->getRecursiveUsing(device, devices);
+
+ cout << device << " ";
+ if (ret == 0)
+ cout << boost::join(devices, " ");
+ else
+ cout << ret;
+ cout << endl;
+}
+
+
+int
+main()
+{
+ cout.setf(std::ios::boolalpha);
+
+ setup_logger();
+
+ setup_system("thalassa");
+
+ s = createStorageInterface(TestEnvironment());
+
+ test("/dev/sda");
+ test("/dev/sda1");
+ test("/dev/sda2");
+ test("/dev/sdb");
+ test("/dev/sdb1");
+ test("/dev/sdb2");
+
+ test("/dev/system");
+
+ test("/dev/sdxyz");
+
+ delete s;
+}
Added: branches/SuSE-Code-11-SP2-Branch/storage/libstorage/testsuite/renumber1.cc
URL: http://svn.opensuse.org/viewcvs/yast/branches/SuSE-Code-11-SP2-Branch/stora…
==============================================================================
--- branches/SuSE-Code-11-SP2-Branch/storage/libstorage/testsuite/renumber1.cc (added)
+++ branches/SuSE-Code-11-SP2-Branch/storage/libstorage/testsuite/renumber1.cc Tue May 17 13:39:44 2011
@@ -0,0 +1,25 @@
+
+#include <iostream>
+
+#include "common.h"
+
+
+using namespace std;
+using namespace storage;
+
+
+int
+main()
+{
+ setup_logger();
+
+ setup_system("thalassa");
+
+ StorageInterface* s = createStorageInterface(TestEnvironment());
+
+ cout << s->removePartition("/dev/sdc5") << endl;
+
+ print_partitions(s, "/dev/sdc");
+
+ delete s;
+}
Added: branches/SuSE-Code-11-SP2-Branch/storage/libstorage/testsuite/renumber2.cc
URL: http://svn.opensuse.org/viewcvs/yast/branches/SuSE-Code-11-SP2-Branch/stora…
==============================================================================
--- branches/SuSE-Code-11-SP2-Branch/storage/libstorage/testsuite/renumber2.cc (added)
+++ branches/SuSE-Code-11-SP2-Branch/storage/libstorage/testsuite/renumber2.cc Tue May 17 13:39:44 2011
@@ -0,0 +1,39 @@
+
+#include <iostream>
+
+#include "common.h"
+
+
+using namespace std;
+using namespace storage;
+
+
+int
+main()
+{
+ setup_logger();
+
+ setup_system("empty");
+
+ StorageInterface* s = createStorageInterface(TestEnvironment());
+
+ string device;
+ cout << s->createPartition("/dev/sda", EXTENDED, 0, 1000, device) << endl;
+ cout << s->createPartition("/dev/sda", LOGICAL, 0, 200, device) << endl;
+ cout << s->createPartition("/dev/sda", LOGICAL, 200, 200, device) << endl;
+
+ deque<string> lvm_devices;
+ lvm_devices.push_back("/dev/sda6");
+ cout << s->createLvmVg("test", 1024, false, lvm_devices) << endl;
+
+ LvmVgInfo lvm_info;
+ cout << s->getLvmVgInfo("test", lvm_info) << endl;
+ cout << lvm_info.devices_add << endl;
+
+ cout << s->removePartition("/dev/sda5") << endl;
+
+ cout << s->getLvmVgInfo("test", lvm_info) << endl;
+ cout << lvm_info.devices_add << endl;
+
+ delete s;
+}
Added: branches/SuSE-Code-11-SP2-Branch/storage/libstorage/testsuite/renumber3.cc
URL: http://svn.opensuse.org/viewcvs/yast/branches/SuSE-Code-11-SP2-Branch/stora…
==============================================================================
--- branches/SuSE-Code-11-SP2-Branch/storage/libstorage/testsuite/renumber3.cc (added)
+++ branches/SuSE-Code-11-SP2-Branch/storage/libstorage/testsuite/renumber3.cc Tue May 17 13:39:44 2011
@@ -0,0 +1,46 @@
+
+#include <iostream>
+
+#include "common.h"
+
+
+using namespace std;
+using namespace storage;
+
+
+int
+main()
+{
+ setup_logger();
+
+ setup_system("empty");
+
+ StorageInterface* s = createStorageInterface(TestEnvironment());
+
+ string device;
+ cout << s->createPartition("/dev/sda", EXTENDED, 0, 1000, device) << endl;
+ cout << s->createPartition("/dev/sda", LOGICAL, 0, 200, device) << endl;
+ cout << s->createPartition("/dev/sda", LOGICAL, 200, 200, device) << endl;
+ cout << s->createPartition("/dev/sda", LOGICAL, 400, 200, device) << endl;
+ cout << s->createPartition("/dev/sda", LOGICAL, 600, 200, device) << endl;
+
+ list<string> md_devices;
+ md_devices.push_back("/dev/sda6");
+ md_devices.push_back("/dev/sda7");
+ list<string> md_spares;
+ md_spares.push_back("/dev/sda8");
+ cout << s->createMd("/dev/md0", RAID1, md_devices, md_spares) << endl;
+
+ deque<MdInfo> md_infos;
+ cout << s->getMdInfo(md_infos) << endl;
+ cout << md_infos[0].devices << endl;
+ cout << md_infos[0].spares << endl;
+
+ cout << s->removePartition("/dev/sda5") << endl;
+
+ cout << s->getMdInfo(md_infos) << endl;
+ cout << md_infos[0].devices << endl;
+ cout << md_infos[0].spares << endl;
+
+ delete s;
+}
Added: branches/SuSE-Code-11-SP2-Branch/storage/libstorage/testsuite/single.out/backupstate1.err
URL: http://svn.opensuse.org/viewcvs/yast/branches/SuSE-Code-11-SP2-Branch/stora…
==============================================================================
(empty)
Added: branches/SuSE-Code-11-SP2-Branch/storage/libstorage/testsuite/single.out/backupstate1.out
URL: http://svn.opensuse.org/viewcvs/yast/branches/SuSE-Code-11-SP2-Branch/stora…
==============================================================================
--- branches/SuSE-Code-11-SP2-Branch/storage/libstorage/testsuite/single.out/backupstate1.out (added)
+++ branches/SuSE-Code-11-SP2-Branch/storage/libstorage/testsuite/single.out/backupstate1.out Tue May 17 13:39:44 2011
@@ -0,0 +1,5 @@
+true true
+true false
+true true
+true false
+true true
Added: branches/SuSE-Code-11-SP2-Branch/storage/libstorage/testsuite/single.out/contvolinfo1.err
URL: http://svn.opensuse.org/viewcvs/yast/branches/SuSE-Code-11-SP2-Branch/stora…
==============================================================================
(empty)
Added: branches/SuSE-Code-11-SP2-Branch/storage/libstorage/testsuite/single.out/contvolinfo1.out
URL: http://svn.opensuse.org/viewcvs/yast/branches/SuSE-Code-11-SP2-Branch/stora…
==============================================================================
--- branches/SuSE-Code-11-SP2-Branch/storage/libstorage/testsuite/single.out/contvolinfo1.out (added)
+++ branches/SuSE-Code-11-SP2-Branch/storage/libstorage/testsuite/single.out/contvolinfo1.out Tue May 17 13:39:44 2011
@@ -0,0 +1,27 @@
+device:/dev/sda
+ret:0
+ctype:1
+cname:sda
+vname:
+
+device:/dev/sda1
+ret:0
+ctype:1
+cname:sda
+vname:sda1
+
+device:/dev/system
+ret:0
+ctype:4
+cname:system
+vname:
+
+device:/dev/system/swap
+ret:0
+ctype:4
+cname:system
+vname:swap
+
+device:/dev/unknown
+ret:-2001
+
Added: branches/SuSE-Code-11-SP2-Branch/storage/libstorage/testsuite/single.out/disklabel1.err
URL: http://svn.opensuse.org/viewcvs/yast/branches/SuSE-Code-11-SP2-Branch/stora…
==============================================================================
(empty)
Added: branches/SuSE-Code-11-SP2-Branch/storage/libstorage/testsuite/single.out/disklabel1.out
URL: http://svn.opensuse.org/viewcvs/yast/branches/SuSE-Code-11-SP2-Branch/stora…
==============================================================================
--- branches/SuSE-Code-11-SP2-Branch/storage/libstorage/testsuite/single.out/disklabel1.out (added)
+++ branches/SuSE-Code-11-SP2-Branch/storage/libstorage/testsuite/single.out/disklabel1.out Tue May 17 13:39:44 2011
@@ -0,0 +1,2 @@
+msdos
+gpt
Modified: branches/SuSE-Code-11-SP2-Branch/storage/libstorage/testsuite/single.out/format1.out
URL: http://svn.opensuse.org/viewcvs/yast/branches/SuSE-Code-11-SP2-Branch/stora…
==============================================================================
--- branches/SuSE-Code-11-SP2-Branch/storage/libstorage/testsuite/single.out/format1.out (original)
+++ branches/SuSE-Code-11-SP2-Branch/storage/libstorage/testsuite/single.out/format1.out Tue May 17 13:39:44 2011
@@ -5,10 +5,10 @@
-3017
0
0
-hda1 PRIMARY 1 10407 REISERFS
-hda2 PRIMARY 10408 10391 EXT2
-hda3 PRIMARY 20799 2088 EXT3
-hda4 EXTENDED 22887 54650 UNKNOWN
-hda5 LOGICAL 22887 31206 EXT2
-hda6 LOGICAL 54093 23444 EXT3
+sdc1 PRIMARY 0 654 REISERFS
+sdc2 PRIMARY 654 1305 EXT2
+sdc3 PRIMARY 1959 1958 EXT3
+sdc4 EXTENDED 3917 5812 UNKNOWN
+sdc5 LOGICAL 3917 2611 EXT2
+sdc6 LOGICAL 6528 2611 EXT3
Added: branches/SuSE-Code-11-SP2-Branch/storage/libstorage/testsuite/single.out/freeinfo1.err
URL: http://svn.opensuse.org/viewcvs/yast/branches/SuSE-Code-11-SP2-Branch/stora…
==============================================================================
(empty)
Added: branches/SuSE-Code-11-SP2-Branch/storage/libstorage/testsuite/single.out/freeinfo1.out
URL: http://svn.opensuse.org/viewcvs/yast/branches/SuSE-Code-11-SP2-Branch/stora…
==============================================================================
--- branches/SuSE-Code-11-SP2-Branch/storage/libstorage/testsuite/single.out/freeinfo1.out (added)
+++ branches/SuSE-Code-11-SP2-Branch/storage/libstorage/testsuite/single.out/freeinfo1.out Tue May 17 13:39:44 2011
@@ -0,0 +1,4 @@
+/dev/system/arvin true
+ 23338740 23338740 26203196 true
+ false false 2
+/dev/system/root false
Added: branches/SuSE-Code-11-SP2-Branch/storage/libstorage/testsuite/single.out/fstab2.err
URL: http://svn.opensuse.org/viewcvs/yast/branches/SuSE-Code-11-SP2-Branch/stora…
==============================================================================
(empty)
Added: branches/SuSE-Code-11-SP2-Branch/storage/libstorage/testsuite/single.out/fstab2.out
URL: http://svn.opensuse.org/viewcvs/yast/branches/SuSE-Code-11-SP2-Branch/stora…
==============================================================================
--- branches/SuSE-Code-11-SP2-Branch/storage/libstorage/testsuite/single.out/fstab2.out (added)
+++ branches/SuSE-Code-11-SP2-Branch/storage/libstorage/testsuite/single.out/fstab2.out Tue May 17 13:39:44 2011
@@ -0,0 +1,17 @@
+0
+/dev/sda1
+0
+/dev/sda2
+0
+0
+0
+0
+0
+0
+0
+0
+0
+begin of fstab
+LABEL=second /usr ext4 defaults 1 2
+LABEL=first /usr/local ext4 defaults 1 2
+end of fstab
Added: branches/SuSE-Code-11-SP2-Branch/storage/libstorage/testsuite/single.out/fstab3.err
URL: http://svn.opensuse.org/viewcvs/yast/branches/SuSE-Code-11-SP2-Branch/stora…
==============================================================================
(empty)
Added: branches/SuSE-Code-11-SP2-Branch/storage/libstorage/testsuite/single.out/fstab3.out
URL: http://svn.opensuse.org/viewcvs/yast/branches/SuSE-Code-11-SP2-Branch/stora…
==============================================================================
--- branches/SuSE-Code-11-SP2-Branch/storage/libstorage/testsuite/single.out/fstab3.out (added)
+++ branches/SuSE-Code-11-SP2-Branch/storage/libstorage/testsuite/single.out/fstab3.out Tue May 17 13:39:44 2011
@@ -0,0 +1,13 @@
+0
+/dev/sda1
+0
+0
+0
+0
+0
+begin of fstab
+/dev/mapper/cr_sda1 /secret ext4 nofail 0 0
+end of fstab
+begin of crypttab
+cr_sda1 /dev/sda1 none none
+end of crypttab
Added: branches/SuSE-Code-11-SP2-Branch/storage/libstorage/testsuite/single.out/fstab4.err
URL: http://svn.opensuse.org/viewcvs/yast/branches/SuSE-Code-11-SP2-Branch/stora…
==============================================================================
(empty)
Added: branches/SuSE-Code-11-SP2-Branch/storage/libstorage/testsuite/single.out/fstab4.out
URL: http://svn.opensuse.org/viewcvs/yast/branches/SuSE-Code-11-SP2-Branch/stora…
==============================================================================
--- branches/SuSE-Code-11-SP2-Branch/storage/libstorage/testsuite/single.out/fstab4.out (added)
+++ branches/SuSE-Code-11-SP2-Branch/storage/libstorage/testsuite/single.out/fstab4.out Tue May 17 13:39:44 2011
@@ -0,0 +1,11 @@
+0
+/dev/sda1
+0
+0
+0
+-4017
+begin of fstab
+end of fstab
+begin of crypttab
+cr_sda1 /dev/sda1 none none
+end of crypttab
Modified: branches/SuSE-Code-11-SP2-Branch/storage/libstorage/testsuite/single.out/humanstring1.out
URL: http://svn.opensuse.org/viewcvs/yast/branches/SuSE-Code-11-SP2-Branch/stora…
==============================================================================
--- branches/SuSE-Code-11-SP2-Branch/storage/libstorage/testsuite/single.out/humanstring1.out (original)
+++ branches/SuSE-Code-11-SP2-Branch/storage/libstorage/testsuite/single.out/humanstring1.out Tue May 17 13:39:44 2011
@@ -1,9 +1,14 @@
+-- 1 --
+0 B
+0 B
1 kB
1.00 kB
+-- 2 --
117.7376 MB
117,7376 MB
+-- 3 --
117.7376 MB
-117,7376 MB
+-- 4 --
1,000.00 kB
1.000,00 kB
-1 000,00 kB
+1'000.00 kB
Modified: branches/SuSE-Code-11-SP2-Branch/storage/libstorage/testsuite/single.out/humanstring2.out
URL: http://svn.opensuse.org/viewcvs/yast/branches/SuSE-Code-11-SP2-Branch/stora…
==============================================================================
--- branches/SuSE-Code-11-SP2-Branch/storage/libstorage/testsuite/single.out/humanstring2.out (original)
+++ branches/SuSE-Code-11-SP2-Branch/storage/libstorage/testsuite/single.out/humanstring2.out Tue May 17 13:39:44 2011
@@ -1,26 +1,42 @@
+-- 1 --
parse error
parse ok 42
parse ok 42
+-- 2 --
parse ok 42
parse ok 42
parse ok 42
+-- 3 --
parse ok 13314398617
parse ok 13314398617
+-- 4 --
parse ok 13314398617
parse ok 13314398617
parse ok 13314398617
parse ok 13314398617
+-- 5 --
parse ok 126418944
parse ok 126418944
parse ok 126418944
+-- 6 --
parse ok 126419751
parse ok 126419751
parse ok 126419751
+-- 7 --
parse ok 126419751
parse ok 126419751
parse ok 126419751
-parse ok 5368709120
-parse ok 5368709120
+-- 8 --
+-- 9 --
parse error
parse error
parse error
+parse error
+-- 10 --
+parse ok 3371549327
+parse ok 3371549327
+parse ok 3371549327
+-- 11 --
+parse ok 13255342817280
+parse ok 13255342817280
+parse ok 13255342817280
Modified: branches/SuSE-Code-11-SP2-Branch/storage/libstorage/testsuite/single.out/lvm_create.out
URL: http://svn.opensuse.org/viewcvs/yast/branches/SuSE-Code-11-SP2-Branch/stora…
==============================================================================
--- branches/SuSE-Code-11-SP2-Branch/storage/libstorage/testsuite/single.out/lvm_create.out (original)
+++ branches/SuSE-Code-11-SP2-Branch/storage/libstorage/testsuite/single.out/lvm_create.out Tue May 17 13:39:44 2011
@@ -1,35 +1,6 @@
createLvs
0
0
-0
-0
-50
-50
-50
-50
-createLvs
-0
-0
-0
-0
-50
-50
-50
-50
-createLvs
-0
-0
-0
-0
-0
-0
-50
-50
-50
-50
-50
-50
-50
50
createExtendedLv
-4003
Added: branches/SuSE-Code-11-SP2-Branch/storage/libstorage/testsuite/single.out/lvm_create2.err
URL: http://svn.opensuse.org/viewcvs/yast/branches/SuSE-Code-11-SP2-Branch/stora…
==============================================================================
(empty)
Added: branches/SuSE-Code-11-SP2-Branch/storage/libstorage/testsuite/single.out/lvm_create2.out
URL: http://svn.opensuse.org/viewcvs/yast/branches/SuSE-Code-11-SP2-Branch/stora…
==============================================================================
--- branches/SuSE-Code-11-SP2-Branch/storage/libstorage/testsuite/single.out/lvm_create2.out (added)
+++ branches/SuSE-Code-11-SP2-Branch/storage/libstorage/testsuite/single.out/lvm_create2.out Tue May 17 13:39:44 2011
@@ -0,0 +1,4 @@
+-2006
+0
+-4006
+0
Modified: branches/SuSE-Code-11-SP2-Branch/storage/libstorage/testsuite/single.out/lvm_extend.out
URL: http://svn.opensuse.org/viewcvs/yast/branches/SuSE-Code-11-SP2-Branch/stora…
==============================================================================
--- branches/SuSE-Code-11-SP2-Branch/storage/libstorage/testsuite/single.out/lvm_extend.out (original)
+++ branches/SuSE-Code-11-SP2-Branch/storage/libstorage/testsuite/single.out/lvm_extend.out Tue May 17 13:39:44 2011
@@ -1,39 +1,7 @@
extendVg
0
+/dev/sda2
0
0
-0
-0
-1
-0
-0
-0
-0
-0
-3
-extendVg
-0
-0
-0
-0
-0
-1
-0
-0
-0
-0
-0
-3
-extendVg
-0
-0
-0
-0
-0
-1
-0
-0
-0
-0
-0
-3
+/dev/sda2
+/dev/sdb1
Modified: branches/SuSE-Code-11-SP2-Branch/storage/libstorage/testsuite/single.out/md_create.out
URL: http://svn.opensuse.org/viewcvs/yast/branches/SuSE-Code-11-SP2-Branch/stora…
==============================================================================
--- branches/SuSE-Code-11-SP2-Branch/storage/libstorage/testsuite/single.out/md_create.out (original)
+++ branches/SuSE-Code-11-SP2-Branch/storage/libstorage/testsuite/single.out/md_create.out Tue May 17 13:39:44 2011
@@ -26,10 +26,3 @@
createMD: 0 md0 /dev/md0 0 4 0
createMD: 0 md0 /dev/md0 0 5 0
createMD: 0 md0 /dev/md0 0 6 0
-Devices: 6 ----------------------
-createMD: 0 md0 /dev/md0 0 1 0
-createMD: 0 md0 /dev/md0 0 2 0
-createMD: 0 md0 /dev/md0 0 3 0
-createMD: 0 md0 /dev/md0 0 4 0
-createMD: 0 md0 /dev/md0 0 5 0
-createMD: 0 md0 /dev/md0 0 6 0
Modified: branches/SuSE-Code-11-SP2-Branch/storage/libstorage/testsuite/single.out/partition1.out
URL: http://svn.opensuse.org/viewcvs/yast/branches/SuSE-Code-11-SP2-Branch/stora…
==============================================================================
--- branches/SuSE-Code-11-SP2-Branch/storage/libstorage/testsuite/single.out/partition1.out (original)
+++ branches/SuSE-Code-11-SP2-Branch/storage/libstorage/testsuite/single.out/partition1.out Tue May 17 13:39:44 2011
@@ -1,4 +1,4 @@
-msdos /dev/hda 59
+msdos /dev/sdc 32
0
0
0
@@ -35,134 +35,44 @@
0
0
0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
--1004
-hda1 PRIMARY 1 199
-hda2 PRIMARY 200 199
-hda3 PRIMARY 398 199
-hda4 EXTENDED 597 11905
-hda5 LOGICAL 597 199
-hda6 LOGICAL 795 199
-hda7 LOGICAL 994 199
-hda8 LOGICAL 1192 199
-hda9 LOGICAL 1390 199
-hda10 LOGICAL 1589 199
-hda11 LOGICAL 1787 199
-hda12 LOGICAL 1986 199
-hda13 LOGICAL 2184 199
-hda14 LOGICAL 2382 199
-hda15 LOGICAL 2581 199
-hda16 LOGICAL 2779 199
-hda17 LOGICAL 2978 199
-hda18 LOGICAL 3176 199
-hda19 LOGICAL 3375 199
-hda20 LOGICAL 3573 199
-hda21 LOGICAL 3771 199
-hda22 LOGICAL 3970 199
-hda23 LOGICAL 4168 199
-hda24 LOGICAL 4367 199
-hda25 LOGICAL 4565 199
-hda26 LOGICAL 4763 199
-hda27 LOGICAL 4962 199
-hda28 LOGICAL 5160 199
-hda29 LOGICAL 5359 199
-hda30 LOGICAL 5557 199
-hda31 LOGICAL 5755 199
-hda32 LOGICAL 5954 199
-hda33 LOGICAL 6152 199
-hda34 LOGICAL 6351 199
-hda35 LOGICAL 6549 199
-hda36 LOGICAL 6748 199
-hda37 LOGICAL 6946 199
-hda38 LOGICAL 7144 199
-hda39 LOGICAL 7343 199
-hda40 LOGICAL 7541 199
-hda41 LOGICAL 7740 199
-hda42 LOGICAL 7938 199
-hda43 LOGICAL 8136 199
-hda44 LOGICAL 8335 199
-hda45 LOGICAL 8533 199
-hda46 LOGICAL 8732 199
-hda47 LOGICAL 8930 199
-hda48 LOGICAL 9128 199
-hda49 LOGICAL 9327 199
-hda50 LOGICAL 9525 199
-hda51 LOGICAL 9724 199
-hda52 LOGICAL 9922 199
-hda53 LOGICAL 10121 199
-hda54 LOGICAL 10319 199
-hda55 LOGICAL 10517 199
-hda56 LOGICAL 10716 199
-hda57 LOGICAL 10914 199
-hda58 LOGICAL 11113 199
-hda59 LOGICAL 11311 199
-hda60 LOGICAL 11509 199
-hda61 LOGICAL 11708 199
-hda62 LOGICAL 11906 199
-hda63 LOGICAL 12105 199
-
-msdos /dev/sda 11
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
--1004
-sda1 PRIMARY 1 13
-sda2 PRIMARY 14 13
-sda3 PRIMARY 26 13
-sda4 EXTENDED 39 150
-sda5 LOGICAL 39 13
-sda6 LOGICAL 51 13
-sda7 LOGICAL 64 13
-sda8 LOGICAL 76 13
-sda9 LOGICAL 89 13
-sda10 LOGICAL 101 13
-sda11 LOGICAL 114 13
-sda12 LOGICAL 126 13
-sda13 LOGICAL 138 13
-sda14 LOGICAL 151 13
-sda15 LOGICAL 163 13
+sdc1 PRIMARY 1 13 UNKNOWN
+sdc2 PRIMARY 14 13 UNKNOWN
+sdc3 PRIMARY 26 13 UNKNOWN
+sdc4 EXTENDED 39 411 UNKNOWN
+sdc5 LOGICAL 39 13 UNKNOWN
+sdc6 LOGICAL 51 13 UNKNOWN
+sdc7 LOGICAL 64 13 UNKNOWN
+sdc8 LOGICAL 76 13 UNKNOWN
+sdc9 LOGICAL 89 13 UNKNOWN
+sdc10 LOGICAL 101 13 UNKNOWN
+sdc11 LOGICAL 114 13 UNKNOWN
+sdc12 LOGICAL 126 13 UNKNOWN
+sdc13 LOGICAL 138 13 UNKNOWN
+sdc14 LOGICAL 151 13 UNKNOWN
+sdc15 LOGICAL 163 13 UNKNOWN
+sdc16 LOGICAL 176 13 UNKNOWN
+sdc17 LOGICAL 188 13 UNKNOWN
+sdc18 LOGICAL 201 13 UNKNOWN
+sdc19 LOGICAL 213 13 UNKNOWN
+sdc20 LOGICAL 226 13 UNKNOWN
+sdc21 LOGICAL 238 13 UNKNOWN
+sdc22 LOGICAL 250 13 UNKNOWN
+sdc23 LOGICAL 263 13 UNKNOWN
+sdc24 LOGICAL 275 13 UNKNOWN
+sdc25 LOGICAL 288 13 UNKNOWN
+sdc26 LOGICAL 300 13 UNKNOWN
+sdc27 LOGICAL 313 13 UNKNOWN
+sdc28 LOGICAL 325 13 UNKNOWN
+sdc29 LOGICAL 338 13 UNKNOWN
+sdc30 LOGICAL 350 13 UNKNOWN
+sdc31 LOGICAL 363 13 UNKNOWN
+sdc32 LOGICAL 375 13 UNKNOWN
+sdc33 LOGICAL 387 13 UNKNOWN
+sdc34 LOGICAL 400 13 UNKNOWN
+sdc35 LOGICAL 412 13 UNKNOWN
+sdc36 LOGICAL 425 13 UNKNOWN
-gpt /dev/hda 63
-0
-0
+gpt /dev/sdc 32
0
0
0
@@ -195,130 +105,36 @@
0
0
0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
--1004
-hda1 PRIMARY 1 199
-hda2 PRIMARY 200 199
-hda3 PRIMARY 398 199
-hda4 PRIMARY 597 199
-hda5 PRIMARY 795 199
-hda6 PRIMARY 994 199
-hda7 PRIMARY 1192 199
-hda8 PRIMARY 1390 199
-hda9 PRIMARY 1589 199
-hda10 PRIMARY 1787 199
-hda11 PRIMARY 1986 199
-hda12 PRIMARY 2184 199
-hda13 PRIMARY 2382 199
-hda14 PRIMARY 2581 199
-hda15 PRIMARY 2779 199
-hda16 PRIMARY 2978 199
-hda17 PRIMARY 3176 199
-hda18 PRIMARY 3375 199
-hda19 PRIMARY 3573 199
-hda20 PRIMARY 3771 199
-hda21 PRIMARY 3970 199
-hda22 PRIMARY 4168 199
-hda23 PRIMARY 4367 199
-hda24 PRIMARY 4565 199
-hda25 PRIMARY 4763 199
-hda26 PRIMARY 4962 199
-hda27 PRIMARY 5160 199
-hda28 PRIMARY 5359 199
-hda29 PRIMARY 5557 199
-hda30 PRIMARY 5755 199
-hda31 PRIMARY 5954 199
-hda32 PRIMARY 6152 199
-hda33 PRIMARY 6351 199
-hda34 PRIMARY 6549 199
-hda35 PRIMARY 6748 199
-hda36 PRIMARY 6946 199
-hda37 PRIMARY 7144 199
-hda38 PRIMARY 7343 199
-hda39 PRIMARY 7541 199
-hda40 PRIMARY 7740 199
-hda41 PRIMARY 7938 199
-hda42 PRIMARY 8136 199
-hda43 PRIMARY 8335 199
-hda44 PRIMARY 8533 199
-hda45 PRIMARY 8732 199
-hda46 PRIMARY 8930 199
-hda47 PRIMARY 9128 199
-hda48 PRIMARY 9327 199
-hda49 PRIMARY 9525 199
-hda50 PRIMARY 9724 199
-hda51 PRIMARY 9922 199
-hda52 PRIMARY 10121 199
-hda53 PRIMARY 10319 199
-hda54 PRIMARY 10517 199
-hda55 PRIMARY 10716 199
-hda56 PRIMARY 10914 199
-hda57 PRIMARY 11113 199
-hda58 PRIMARY 11311 199
-hda59 PRIMARY 11509 199
-hda60 PRIMARY 11708 199
-hda61 PRIMARY 11906 199
-hda62 PRIMARY 12105 199
-hda63 PRIMARY 12303 199
-
-gpt /dev/sda 15
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
--1004
-sda1 PRIMARY 1 13
-sda2 PRIMARY 14 13
-sda3 PRIMARY 26 13
-sda4 PRIMARY 39 13
-sda5 PRIMARY 51 13
-sda6 PRIMARY 64 13
-sda7 PRIMARY 76 13
-sda8 PRIMARY 89 13
-sda9 PRIMARY 101 13
-sda10 PRIMARY 114 13
-sda11 PRIMARY 126 13
-sda12 PRIMARY 138 13
-sda13 PRIMARY 151 13
-sda14 PRIMARY 163 13
-sda15 PRIMARY 176 13
+sdc1 PRIMARY 1 13 UNKNOWN
+sdc2 PRIMARY 14 13 UNKNOWN
+sdc3 PRIMARY 26 13 UNKNOWN
+sdc4 PRIMARY 39 13 UNKNOWN
+sdc5 PRIMARY 51 13 UNKNOWN
+sdc6 PRIMARY 64 13 UNKNOWN
+sdc7 PRIMARY 76 13 UNKNOWN
+sdc8 PRIMARY 89 13 UNKNOWN
+sdc9 PRIMARY 101 13 UNKNOWN
+sdc10 PRIMARY 114 13 UNKNOWN
+sdc11 PRIMARY 126 13 UNKNOWN
+sdc12 PRIMARY 138 13 UNKNOWN
+sdc13 PRIMARY 151 13 UNKNOWN
+sdc14 PRIMARY 163 13 UNKNOWN
+sdc15 PRIMARY 176 13 UNKNOWN
+sdc16 PRIMARY 188 13 UNKNOWN
+sdc17 PRIMARY 201 13 UNKNOWN
+sdc18 PRIMARY 213 13 UNKNOWN
+sdc19 PRIMARY 226 13 UNKNOWN
+sdc20 PRIMARY 238 13 UNKNOWN
+sdc21 PRIMARY 250 13 UNKNOWN
+sdc22 PRIMARY 263 13 UNKNOWN
+sdc23 PRIMARY 275 13 UNKNOWN
+sdc24 PRIMARY 288 13 UNKNOWN
+sdc25 PRIMARY 300 13 UNKNOWN
+sdc26 PRIMARY 313 13 UNKNOWN
+sdc27 PRIMARY 325 13 UNKNOWN
+sdc28 PRIMARY 338 13 UNKNOWN
+sdc29 PRIMARY 350 13 UNKNOWN
+sdc30 PRIMARY 363 13 UNKNOWN
+sdc31 PRIMARY 375 13 UNKNOWN
+sdc32 PRIMARY 387 13 UNKNOWN
Added: branches/SuSE-Code-11-SP2-Branch/storage/libstorage/testsuite/single.out/partitionname.err
URL: http://svn.opensuse.org/viewcvs/yast/branches/SuSE-Code-11-SP2-Branch/stora…
==============================================================================
(empty)
Added: branches/SuSE-Code-11-SP2-Branch/storage/libstorage/testsuite/single.out/partitionname.out
URL: http://svn.opensuse.org/viewcvs/yast/branches/SuSE-Code-11-SP2-Branch/stora…
==============================================================================
--- branches/SuSE-Code-11-SP2-Branch/storage/libstorage/testsuite/single.out/partitionname.out (added)
+++ branches/SuSE-Code-11-SP2-Branch/storage/libstorage/testsuite/single.out/partitionname.out Tue May 17 13:39:44 2011
@@ -0,0 +1,5 @@
+/dev/sda1
+/dev/cciss/c0d1p2
+/dev/mmcblk0p3
+/dev/mapper/isw_cfcjajfdfh_test_part4
+/dev/md2p5
Added: branches/SuSE-Code-11-SP2-Branch/storage/libstorage/testsuite/single.out/partitionprefix.err
URL: http://svn.opensuse.org/viewcvs/yast/branches/SuSE-Code-11-SP2-Branch/stora…
==============================================================================
(empty)
Added: branches/SuSE-Code-11-SP2-Branch/storage/libstorage/testsuite/single.out/partitionprefix.out
URL: http://svn.opensuse.org/viewcvs/yast/branches/SuSE-Code-11-SP2-Branch/stora…
==============================================================================
--- branches/SuSE-Code-11-SP2-Branch/storage/libstorage/testsuite/single.out/partitionprefix.out (added)
+++ branches/SuSE-Code-11-SP2-Branch/storage/libstorage/testsuite/single.out/partitionprefix.out Tue May 17 13:39:44 2011
@@ -0,0 +1,8 @@
+
+
+p
+p
+p
+p
+_part
+_part
Added: branches/SuSE-Code-11-SP2-Branch/storage/libstorage/testsuite/single.out/recursive1.err
URL: http://svn.opensuse.org/viewcvs/yast/branches/SuSE-Code-11-SP2-Branch/stora…
==============================================================================
(empty)
Added: branches/SuSE-Code-11-SP2-Branch/storage/libstorage/testsuite/single.out/recursive1.out
URL: http://svn.opensuse.org/viewcvs/yast/branches/SuSE-Code-11-SP2-Branch/stora…
==============================================================================
--- branches/SuSE-Code-11-SP2-Branch/storage/libstorage/testsuite/single.out/recursive1.out (added)
+++ branches/SuSE-Code-11-SP2-Branch/storage/libstorage/testsuite/single.out/recursive1.out Tue May 17 13:39:44 2011
@@ -0,0 +1,2 @@
+-2011
+0
Added: branches/SuSE-Code-11-SP2-Branch/storage/libstorage/testsuite/single.out/recursive2.err
URL: http://svn.opensuse.org/viewcvs/yast/branches/SuSE-Code-11-SP2-Branch/stora…
==============================================================================
(empty)
Added: branches/SuSE-Code-11-SP2-Branch/storage/libstorage/testsuite/single.out/recursive2.out
URL: http://svn.opensuse.org/viewcvs/yast/branches/SuSE-Code-11-SP2-Branch/stora…
==============================================================================
--- branches/SuSE-Code-11-SP2-Branch/storage/libstorage/testsuite/single.out/recursive2.out (added)
+++ branches/SuSE-Code-11-SP2-Branch/storage/libstorage/testsuite/single.out/recursive2.out Tue May 17 13:39:44 2011
@@ -0,0 +1,8 @@
+/dev/sda /dev/sda1 /dev/sda2 /dev/system /dev/system/abuild /dev/system/arvin /dev/system/root /dev/system/swap /dev/system/virtualbox
+/dev/sda1
+/dev/sda2 /dev/system /dev/system/abuild /dev/system/arvin /dev/system/root /dev/system/swap /dev/system/virtualbox
+/dev/sdb /dev/sdb1 /dev/sdb2 /dev/sdb5 /dev/sdb6
+/dev/sdb1
+/dev/sdb2 /dev/sdb5 /dev/sdb6
+/dev/system /dev/system/abuild /dev/system/arvin /dev/system/root /dev/system/swap /dev/system/virtualbox
+/dev/sdxyz -2034
Added: branches/SuSE-Code-11-SP2-Branch/storage/libstorage/testsuite/single.out/renumber1.err
URL: http://svn.opensuse.org/viewcvs/yast/branches/SuSE-Code-11-SP2-Branch/stora…
==============================================================================
(empty)
Added: branches/SuSE-Code-11-SP2-Branch/storage/libstorage/testsuite/single.out/renumber1.out
URL: http://svn.opensuse.org/viewcvs/yast/branches/SuSE-Code-11-SP2-Branch/stora…
==============================================================================
--- branches/SuSE-Code-11-SP2-Branch/storage/libstorage/testsuite/single.out/renumber1.out (added)
+++ branches/SuSE-Code-11-SP2-Branch/storage/libstorage/testsuite/single.out/renumber1.out Tue May 17 13:39:44 2011
@@ -0,0 +1,7 @@
+0
+sdc1 PRIMARY 0 654 EXT2
+sdc2 PRIMARY 654 1305 EXT3
+sdc3 PRIMARY 1959 1958 EXT4
+sdc4 EXTENDED 3917 5812 UNKNOWN
+sdc5 LOGICAL 6528 2611 BTRFS
+
Added: branches/SuSE-Code-11-SP2-Branch/storage/libstorage/testsuite/single.out/renumber2.err
URL: http://svn.opensuse.org/viewcvs/yast/branches/SuSE-Code-11-SP2-Branch/stora…
==============================================================================
(empty)
Added: branches/SuSE-Code-11-SP2-Branch/storage/libstorage/testsuite/single.out/renumber2.out
URL: http://svn.opensuse.org/viewcvs/yast/branches/SuSE-Code-11-SP2-Branch/stora…
==============================================================================
--- branches/SuSE-Code-11-SP2-Branch/storage/libstorage/testsuite/single.out/renumber2.out (added)
+++ branches/SuSE-Code-11-SP2-Branch/storage/libstorage/testsuite/single.out/renumber2.out Tue May 17 13:39:44 2011
@@ -0,0 +1,9 @@
+0
+0
+0
+0
+0
+/dev/sda6
+0
+0
+/dev/sda5
Added: branches/SuSE-Code-11-SP2-Branch/storage/libstorage/testsuite/single.out/renumber3.err
URL: http://svn.opensuse.org/viewcvs/yast/branches/SuSE-Code-11-SP2-Branch/stora…
==============================================================================
(empty)
Added: branches/SuSE-Code-11-SP2-Branch/storage/libstorage/testsuite/single.out/renumber3.out
URL: http://svn.opensuse.org/viewcvs/yast/branches/SuSE-Code-11-SP2-Branch/stora…
==============================================================================
--- branches/SuSE-Code-11-SP2-Branch/storage/libstorage/testsuite/single.out/renumber3.out (added)
+++ branches/SuSE-Code-11-SP2-Branch/storage/libstorage/testsuite/single.out/renumber3.out Tue May 17 13:39:44 2011
@@ -0,0 +1,13 @@
+0
+0
+0
+0
+0
+0
+0
+/dev/sda6 /dev/sda7
+/dev/sda8
+0
+0
+/dev/sda5 /dev/sda6
+/dev/sda7
Added: branches/SuSE-Code-11-SP2-Branch/storage/libstorage/testsuite/single.out/udevdecode.err
URL: http://svn.opensuse.org/viewcvs/yast/branches/SuSE-Code-11-SP2-Branch/stora…
==============================================================================
(empty)
Added: branches/SuSE-Code-11-SP2-Branch/storage/libstorage/testsuite/single.out/udevdecode.out
URL: http://svn.opensuse.org/viewcvs/yast/branches/SuSE-Code-11-SP2-Branch/stora…
==============================================================================
--- branches/SuSE-Code-11-SP2-Branch/storage/libstorage/testsuite/single.out/udevdecode.out (added)
+++ branches/SuSE-Code-11-SP2-Branch/storage/libstorage/testsuite/single.out/udevdecode.out Tue May 17 13:39:44 2011
@@ -0,0 +1,6 @@
+nothing
+hello world
+hello world
+ beginning
+ending
+woody's
Added: branches/SuSE-Code-11-SP2-Branch/storage/libstorage/testsuite/single.out/udevencode.err
URL: http://svn.opensuse.org/viewcvs/yast/branches/SuSE-Code-11-SP2-Branch/stora…
==============================================================================
(empty)
Added: branches/SuSE-Code-11-SP2-Branch/storage/libstorage/testsuite/single.out/udevencode.out
URL: http://svn.opensuse.org/viewcvs/yast/branches/SuSE-Code-11-SP2-Branch/stora…
==============================================================================
--- branches/SuSE-Code-11-SP2-Branch/storage/libstorage/testsuite/single.out/udevencode.out (added)
+++ branches/SuSE-Code-11-SP2-Branch/storage/libstorage/testsuite/single.out/udevencode.out Tue May 17 13:39:44 2011
@@ -0,0 +1,6 @@
+nothing
+hello\x20world
+hello\x20\x20world
+\x20beginning
+ending\x20
+woody\x27s
Added: branches/SuSE-Code-11-SP2-Branch/storage/libstorage/testsuite/single.out/usedby1.err
URL: http://svn.opensuse.org/viewcvs/yast/branches/SuSE-Code-11-SP2-Branch/stora…
==============================================================================
(empty)
Added: branches/SuSE-Code-11-SP2-Branch/storage/libstorage/testsuite/single.out/usedby1.out
URL: http://svn.opensuse.org/viewcvs/yast/branches/SuSE-Code-11-SP2-Branch/stora…
==============================================================================
--- branches/SuSE-Code-11-SP2-Branch/storage/libstorage/testsuite/single.out/usedby1.out (added)
+++ branches/SuSE-Code-11-SP2-Branch/storage/libstorage/testsuite/single.out/usedby1.out Tue May 17 13:39:44 2011
@@ -0,0 +1 @@
+-3028
Modified: branches/SuSE-Code-11-SP2-Branch/storage/libstorage/testsuite/single.out/uuid1.out
URL: http://svn.opensuse.org/viewcvs/yast/branches/SuSE-Code-11-SP2-Branch/stora…
==============================================================================
--- branches/SuSE-Code-11-SP2-Branch/storage/libstorage/testsuite/single.out/uuid1.out (original)
+++ branches/SuSE-Code-11-SP2-Branch/storage/libstorage/testsuite/single.out/uuid1.out Tue May 17 13:39:44 2011
@@ -1,13 +1,17 @@
run1
0
-/dev/hdb1
+/dev/sda1
0
0
0
0
+begin of fstab
UUID=testmode-0123-4567-6666-987654321000 /tmp/mnt reiserfs defaults 1 2
+end of fstab
run2
-/dev/hdb1
+/dev/sda1
0
0
-/dev/hdb1 /tmp/mnt reiserfs defaults 1 2
+begin of fstab
+/dev/sda1 /tmp/mnt reiserfs defaults 1 2
+end of fstab
Added: branches/SuSE-Code-11-SP2-Branch/storage/libstorage/testsuite/udevdecode.cc
URL: http://svn.opensuse.org/viewcvs/yast/branches/SuSE-Code-11-SP2-Branch/stora…
==============================================================================
--- branches/SuSE-Code-11-SP2-Branch/storage/libstorage/testsuite/udevdecode.cc (added)
+++ branches/SuSE-Code-11-SP2-Branch/storage/libstorage/testsuite/udevdecode.cc Tue May 17 13:39:44 2011
@@ -0,0 +1,23 @@
+
+#include <iostream>
+
+#include <storage/AppUtil.h>
+
+
+using namespace std;
+using namespace storage;
+
+
+int
+main()
+{
+ cout << udevDecode("nothing") << endl;
+
+ cout << udevDecode("hello\\x20world") << endl;
+ cout << udevDecode("hello\\x20\\x20world") << endl;
+
+ cout << udevDecode("\\x20beginning") << endl;
+ cout << udevDecode("ending\\x20") << endl;
+
+ cout << udevDecode("woody\\x27s") << endl;
+}
Added: branches/SuSE-Code-11-SP2-Branch/storage/libstorage/testsuite/udevencode.cc
URL: http://svn.opensuse.org/viewcvs/yast/branches/SuSE-Code-11-SP2-Branch/stora…
==============================================================================
--- branches/SuSE-Code-11-SP2-Branch/storage/libstorage/testsuite/udevencode.cc (added)
+++ branches/SuSE-Code-11-SP2-Branch/storage/libstorage/testsuite/udevencode.cc Tue May 17 13:39:44 2011
@@ -0,0 +1,23 @@
+
+#include <iostream>
+
+#include <storage/AppUtil.h>
+
+
+using namespace std;
+using namespace storage;
+
+
+int
+main()
+{
+ cout << udevEncode("nothing") << endl;
+
+ cout << udevEncode("hello world") << endl;
+ cout << udevEncode("hello world") << endl;
+
+ cout << udevEncode(" beginning") << endl;
+ cout << udevEncode("ending ") << endl;
+
+ cout << udevEncode("woody's") << endl;
+}
Added: branches/SuSE-Code-11-SP2-Branch/storage/libstorage/testsuite/usedby1.cc
URL: http://svn.opensuse.org/viewcvs/yast/branches/SuSE-Code-11-SP2-Branch/stora…
==============================================================================
--- branches/SuSE-Code-11-SP2-Branch/storage/libstorage/testsuite/usedby1.cc (added)
+++ branches/SuSE-Code-11-SP2-Branch/storage/libstorage/testsuite/usedby1.cc Tue May 17 13:39:44 2011
@@ -0,0 +1,26 @@
+
+#include <iostream>
+
+#include "common.h"
+
+
+using namespace storage;
+using namespace std;
+
+
+int
+main()
+{
+ cout.setf(std::ios::boolalpha);
+
+ setup_logger();
+
+ setup_system("thalassa");
+
+ StorageInterface* s = createStorageInterface(TestEnvironment());
+
+ /* try to format partition used by lvm */
+ cout << s->changeFormatVolume("/dev/sda2", true, EXT3) << endl; // FAILS
+
+ delete s;
+}
Modified: branches/SuSE-Code-11-SP2-Branch/storage/libstorage/testsuite/uuid1.cc
URL: http://svn.opensuse.org/viewcvs/yast/branches/SuSE-Code-11-SP2-Branch/stora…
==============================================================================
--- branches/SuSE-Code-11-SP2-Branch/storage/libstorage/testsuite/uuid1.cc (original)
+++ branches/SuSE-Code-11-SP2-Branch/storage/libstorage/testsuite/uuid1.cc Tue May 17 13:39:44 2011
@@ -1,10 +1,7 @@
#include <stdlib.h>
#include <iostream>
-#include <fstream>
-#include <iterator>
-
-#include <StorageInterface.h>
+#include <boost/algorithm/string.hpp>
#include "common.h"
@@ -13,43 +10,29 @@
using namespace storage;
-StorageInterface* s = 0;
-
-
-void
-print_fstab ()
-{
- ifstream fstab ("tmp/fstab");
- string line;
-
- while (getline (fstab, line))
- cout << line << '\n';
-}
-
-
void
run1 ()
{
- cout << "run1\n";
+ cout << "run1" << endl;
- s = createStorageInterface(TestEnvironment());
+ StorageInterface* s = createStorageInterface(TestEnvironment());
- string disk = "/dev/hdb";
+ string disk = "/dev/sda";
s->destroyPartitionTable (disk, "msdos");
long int S = 4 * 1000000;
string name;
- cout << s->createPartitionKb (disk, PRIMARY, 0, S, name) << '\n';
+ cout << s->createPartitionKb(disk, PRIMARY, 0, S, name) << endl;
- cout << name << '\n';
+ cout << name << endl;
- cout << s->changeFormatVolume (name, true, REISERFS) << '\n';
- cout << s->changeMountPoint (name, "/tmp/mnt") << '\n';
- cout << s->changeMountBy (name, MOUNTBY_UUID) << '\n';
+ cout << s->changeFormatVolume(name, true, REISERFS) << endl;
+ cout << s->changeMountPoint(name, "/tmp/mnt") << endl;
+ cout << s->changeMountBy(name, MOUNTBY_UUID) << endl;
- cout << s->commit () << '\n';
+ cout << s->commit() << endl;
delete s;
}
@@ -58,29 +41,30 @@
void
run2 ()
{
- cout << "run2\n";
+ cout << "run2" << endl;
- s = createStorageInterface(TestEnvironment());
+ StorageInterface* s = createStorageInterface(TestEnvironment());
- string name = "/dev/hdb1";
+ string name = "/dev/sda1";
- cout << name << '\n';
+ cout << name << endl;
- cout << s->changeMountBy (name, MOUNTBY_DEVICE) << '\n';
+ cout << s->changeMountBy(name, MOUNTBY_DEVICE) << endl;
- cout << s->commit () << '\n';
+ cout << s->commit() << endl;
delete s;
}
int
-main (int argc, char* argv[])
+main()
{
- system ("mkdir -p tmp");
+ cout.setf(std::ios::boolalpha);
+
+ setup_logger();
- system ("rm -f tmp/fstab tmp/volume_info");
- system ("cp data/disk_hdb tmp/disk_hdb");
+ setup_system("empty");
run1 ();
print_fstab ();
Modified: branches/SuSE-Code-11-SP2-Branch/storage/package/yast2-storage.changes
URL: http://svn.opensuse.org/viewcvs/yast/branches/SuSE-Code-11-SP2-Branch/stora…
==============================================================================
--- branches/SuSE-Code-11-SP2-Branch/storage/package/yast2-storage.changes (original)
+++ branches/SuSE-Code-11-SP2-Branch/storage/package/yast2-storage.changes Tue May 17 13:39:44 2011
@@ -1,4 +1,12 @@
-------------------------------------------------------------------
+Tue May 17 13:35:53 CEST 2011 - fehr(a)suse.de
+
+- huge backport from svn and git head for lots of features
+ in SLES11 SP2 (e.g. fate#307741, fate#311015, fate#310223,
+ fate#303810, fate#306587l, fate#306960)
+- version 2.17.101
+
+-------------------------------------------------------------------
Tue Jan 18 14:49:17 CET 2011 - jsrain(a)suse.cz
- adaptations for unattended migration
Modified: branches/SuSE-Code-11-SP2-Branch/storage/storage/src/Makefile.am
URL: http://svn.opensuse.org/viewcvs/yast/branches/SuSE-Code-11-SP2-Branch/stora…
==============================================================================
--- branches/SuSE-Code-11-SP2-Branch/storage/storage/src/Makefile.am (original)
+++ branches/SuSE-Code-11-SP2-Branch/storage/storage/src/Makefile.am Tue May 17 13:39:44 2011
@@ -2,15 +2,15 @@
# Makefile.am for storage/storage/src
#
-SUBDIRS = include modules proposal
+SUBDIRS = include modules proposal testsuite
client_DATA = \
inst_custom_part.ycp \
inst_disk.ycp \
- inst_do_resize.ycp \
inst_disk_proposal.ycp \
inst_prepdisk.ycp \
inst_resize_ui.ycp \
+ inst_resize_dialog.ycp \
inst_target_part.ycp \
inst_target_selection.ycp \
storage_finish.ycp
Modified: branches/SuSE-Code-11-SP2-Branch/storage/storage/src/include/auto_part_create.ycp
URL: http://svn.opensuse.org/viewcvs/yast/branches/SuSE-Code-11-SP2-Branch/stora…
==============================================================================
--- branches/SuSE-Code-11-SP2-Branch/storage/storage/src/include/auto_part_create.ycp (original)
+++ branches/SuSE-Code-11-SP2-Branch/storage/storage/src/include/auto_part_create.ycp Tue May 17 13:39:44 2011
@@ -18,19 +18,17 @@
import "Storage";
import "Partitions";
- import "ProductFeatures";
-
-include "partitioning/do_proposal_flexible.ycp";
+ import "StorageProposal";
boolean create_partitions( map<string,map> tgmap, map disk, list<map> partitions )
{
y2milestone( "create_partitions disk:%1",
haskey(disk,"partitions")?remove(disk,"partitions"):disk );
y2milestone( "create_partitions partitions %1", partitions );
- flex_init_swapable( tgmap );
+ StorageProposal::flex_init_swapable( tgmap );
boolean ret = false;
- boolean has_flex = has_flex_proposal();
- string vm = Storage::ProposalVM();
+ boolean has_flex = StorageProposal::has_flex_proposal();
+ string vm = StorageProposal::GetProposalVM();
y2milestone( "create_partitions flex %1 vm %2", has_flex, vm );
disk["partitions"] = partitions;
map keep = find( map p, partitions,
@@ -39,7 +37,7 @@
{
if( has_flex )
{
- map flex = do_flexible_disk( disk );
+ map flex = StorageProposal::do_flexible_disk( disk );
if( flex["ok"]:false )
partitions = flex["disk","partitions"]:[];
}
@@ -51,7 +49,7 @@
integer num_del_free = size(filter(map p, partitions,
``(p["type"]:`unknown==`free&&
p["delete"]:false)));
- map r = can_swap_reuse( disk["device"]:"", partitions, tgmap );
+ map r = StorageProposal::can_swap_reuse( disk["device"]:"", partitions, tgmap );
if( haskey( r, "partitions" ))
partitions = r["partitions"]:[];
else if( haskey( r, "targets" ))
@@ -80,7 +78,7 @@
}
else
{
- partitions = get_proposal( size(r)>0, disk );
+ partitions = StorageProposal::get_proposal( size(r)>0, disk );
}
}
y2milestone( "create_partitions %1", partitions );
@@ -100,7 +98,7 @@
});
y2milestone( "create_partitions id_save %1", id_save );
y2milestone( "create_partitions ps %1", disk["partitions"]:[] );
- map r = get_proposal_vm( tgmap, vm, disk );
+ map r = StorageProposal::get_proposal_vm( tgmap, vm, disk );
ret = r["ok"]:false;
if( ret )
{
Modified: branches/SuSE-Code-11-SP2-Branch/storage/storage/src/include/auto_part_functions.ycp
URL: http://svn.opensuse.org/viewcvs/yast/branches/SuSE-Code-11-SP2-Branch/stora…
==============================================================================
--- branches/SuSE-Code-11-SP2-Branch/storage/storage/src/include/auto_part_functions.ycp (original)
+++ branches/SuSE-Code-11-SP2-Branch/storage/storage/src/include/auto_part_functions.ycp Tue May 17 13:39:44 2011
@@ -17,27 +17,20 @@
*
* defined functions:
global define size_of_region (list region) ``{
- global define size_to_units (integer bytes) ``{
global define start_of_region (list region) ``{
global define end_of_region (list region) ``{
global define num_primary (list partitions) ``{
- global define contiguous_selection (list selection) ``{
global define contains_extended (list partitions) ``{
global define extended_region (list partitions) ``{
- global define calculate_selected_region (list selection, any extended_region) ``{
global define can_create_logical (list partitions, integer first_logical,
integer max_logical ) ``{
global define can_resize( list partitions ) ``{
- global define renumber_logical_partitions (list partitions) ``{
global define unused_extended_region (list partitions) ``{
- global define unused_logical_region (list partitions) ``{
global define compute_max_partitions (map target) ``{
- global define compute_max_primary (map target)
*
*/
{
import "Arch";
- import "Partitions";
textdomain "storage";
@@ -51,13 +44,6 @@
return region[1]:0 * bytes_per_unit;
};
- // Return the number of units that holds at least BYTES
-
-define integer size_to_units( integer bytes,
- integer bytes_per_unit) ``{
- return (bytes + bytes_per_unit - 1) / bytes_per_unit;
- };
-
// Return the start of the region.
define integer start_of_region (list<integer> region) ``{
@@ -104,33 +90,6 @@
return( ret );
};
- // return the maximal number of primary partitions
-
-define integer compute_max_primary (map disk) ``{
- return disk["max_primary"]:4;
- };
-
- // Return whether the list of selected partitions is contiguous.
-
-define boolean contiguous_selection (list<map> selection) ``{
- boolean ret = true;
- list<integer> last_region = nil;
-
- foreach (map pentry, selection, ``{
- if (!pentry["create"]:false) {
- list<integer> region = pentry["region"]:[];
- symbol type = pentry["type"]:`unknown;
- if( last_region != nil &&
- (end_of_region(last_region) < start_of_region(region)))
- {
- ret = false;
- }
- last_region = region;
- }
- });
- return ret;
- }; // contiguous_selection
-
// Return true if an extended partition exists
@@ -164,39 +123,6 @@
};
- // Return the region for the selected partitions. If EXTENDED_REGION
- // is not nil it is used to clip the region so that it is contained
- // entirely within it.
-
-define list<integer> calculate_selected_region( list selection,
- list<integer> ext_region )
- ``{
- integer start = -1;
- integer end = 0;
- if( size(selection) > 0)
- {
- start = start_of_region( selection[0,"region"]:[] );
- end = end_of_region( selection[size(selection)-1,"region"]:[] );
- }
- if (start != -1)
- {
- if (size (ext_region)>0)
- {
- // Use only the part that is contained in the extended
- // partition
- if (start >= end_of_region (ext_region))
- return [ 0, 0 ];
- if (start < start_of_region (ext_region))
- start = start_of_region (ext_region);
- if (end > end_of_region (ext_region))
- end = end_of_region (ext_region);
- }
- return [ start, end - start ];
- }
- return [ 0, 0 ];
- }; // selected_region
-
-
// Check whether three logical partitions can be created without
// running past the kernel limit for the number of partitions
@@ -386,25 +312,6 @@
}; // End of check_win_nt_system()
- // --------------------------------------------------------------
- // Renumber the logical partitions if some of them are deleted
- // The returned list is sorted by partition number instead of region
-
-define list<map> renumber_logical_partitions (list<map> partitions) ``{
- partitions = sort (map a, map b, partitions, ``(a["nr"]:0 < b["nr"]:0));
- integer logicals_deleted = 0;
- return maplist (map pentry, partitions, ``{
- if (pentry["type"]:`unknown == `logical) {
- if (pentry["delete"]:false)
- logicals_deleted = logicals_deleted + 1;
- else
- pentry = add (pentry, "nr",
- pentry["nr"]:0 - logicals_deleted);
- }
- return pentry;
- });
- };
-
// Find unused space at the end of the extended partition
define list<integer> unused_extended_region (list<map> partitions) ``{
list<integer> extended = extended_region (partitions);
@@ -421,26 +328,4 @@
return [0, 0];
};
-
- // Find unused space at the start of the extended partition
-define list<integer> unused_logical_region (list<map> partitions) ``{
- list<integer> extended = extended_region (partitions);
- list logicals = filter (map pentry, partitions, ``(pentry["type"]:`unknown == `logical));
- integer start_of_logicals = 0;
-
- if (size (logicals) > 0)
- start_of_logicals = start_of_region (logicals[0,"region"]:[]);
- else
- start_of_logicals = start_of_region (extended);
-
- if (start_of_logicals > start_of_region (extended))
- return [ start_of_region(extended), start_of_region (extended) - start_of_logicals ];
- return [0, 0];
- };
-
-define integer calculate_needed_swap ()
- ``{
- return 1024*1024*Partitions::SwapSizeMb( 0 );
- };
-
}
Modified: branches/SuSE-Code-11-SP2-Branch/storage/storage/src/include/auto_part_prepare.ycp
URL: http://svn.opensuse.org/viewcvs/yast/branches/SuSE-Code-11-SP2-Branch/stora…
==============================================================================
--- branches/SuSE-Code-11-SP2-Branch/storage/storage/src/include/auto_part_prepare.ycp (original)
+++ branches/SuSE-Code-11-SP2-Branch/storage/storage/src/include/auto_part_prepare.ycp Tue May 17 13:39:44 2011
@@ -13,9 +13,8 @@
*/
{
textdomain "storage";
-import "Storage";
+
import "Partitions";
-import "Mode";
define list<map> prepare_partitions( map target, list<map> partitions )
``{
@@ -27,7 +26,8 @@
y2milestone( "prepare_partitions bytes_per_unit: %1 disk_size:%2",
bytes_per_unit, disk_size );
- size_of_boot = Partitions::MinimalNeededBootsize();
+ integer size_of_boot = Partitions::ProposedBootsize();
+ integer size_of_swap = 1024 * 1024 * Partitions::SwapSizeMb(0);
// The minimum size needed to install a default system
integer required_size = 1500 * 1024 * 1024 + size_of_boot + size_of_swap;
Modified: branches/SuSE-Code-11-SP2-Branch/storage/storage/src/include/auto_part_ui.ycp
URL: http://svn.opensuse.org/viewcvs/yast/branches/SuSE-Code-11-SP2-Branch/stora…
==============================================================================
--- branches/SuSE-Code-11-SP2-Branch/storage/storage/src/include/auto_part_ui.ycp (original)
+++ branches/SuSE-Code-11-SP2-Branch/storage/storage/src/include/auto_part_ui.ycp Tue May 17 13:39:44 2011
@@ -15,9 +15,7 @@
*
* defined functions
global define display_error_box (string reason) ``{
- global define warn_not_bootable () ``{
global define partition_text (integer nr, map pentry) ``{
- global define ask_free_space ()
global define construct_partition_dialog ()
global define open_auto_dialog (string targetname, term targetbox) ``{
global define create_resize_dialog (list partitions) ``{
@@ -27,9 +25,9 @@
import "Wizard";
import "Partitions";
- import "Report";
import "Popup";
import "Product";
+ import "StorageProposal";
// --------------------------------------------------------------
// warning and pop-ups
@@ -42,15 +40,6 @@
Popup::Message(text);
};
-define void warn_not_bootable () ``{
- // This is a warning message that pops up when the selection does not
- // include a bootable disk region (< 1024 cylinders).
- Report::Warning(sformat(_("With the current partitioning, your %2 installation
-cannot be booted directly, because your /boot partition
-is above cylinder %1.
-"), Partitions::BootCyl(), Product::name) );
- };
-
// Return a text that describes a partition
@@ -71,12 +60,6 @@
pentry["fstype"]:"", pentry["device"]:"", pentry["label"]:"" );
};
-define boolean ask_free_space () ``{
- // we found an unassigned partition which is large enough for a minimal installation
- return Popup::YesNo(sformat(_("There is free space on the selected disk.
-Use this for %1?
-"),Product::name));
- };
define map construct_partition_dialog( list<map> partitions, string ptype,
integer bps )
@@ -192,7 +175,7 @@
");
// Information what to do, background information
- Wizard::SetContents( _("Preparing Hard Disk -- Step 2"),
+ Wizard::SetContents( _("Preparing Hard Disk"),
`HCenter(
`HSquash(
`Frame(
@@ -241,7 +224,7 @@
");
// Information what to do, background information
- Wizard::SetContents( _("Preparing Hard Disk -- Step 2"),
+ Wizard::SetContents( _("Preparing Hard Disk"),
`HCenter(
`Frame(
// Frame title for installation target hard disk / partition(s)
@@ -268,7 +251,7 @@
term add_common_widgets( term vbox )
{
- map cfg = Storage::GetControlCfg();
+ map cfg = StorageProposal::GetControlCfg();
term vb = `VBox();
vb = add (vb,
`Left(`HBox(`HSpacing(3), `CheckBox( `id(`home),
Modified: branches/SuSE-Code-11-SP2-Branch/storage/storage/src/include/custom_part_check_generated.ycp
URL: http://svn.opensuse.org/viewcvs/yast/branches/SuSE-Code-11-SP2-Branch/stora…
==============================================================================
--- branches/SuSE-Code-11-SP2-Branch/storage/storage/src/include/custom_part_check_generated.ycp (original)
+++ branches/SuSE-Code-11-SP2-Branch/storage/storage/src/include/custom_part_check_generated.ycp Tue May 17 13:39:44 2011
@@ -23,12 +23,12 @@
import "Arch";
import "Storage";
import "Partitions";
- import "Package";
import "Label";
import "Product";
import "AutoinstData";
import "FileSystems";
import "Stage";
+ import "Region";
include "partitioning/custom_part_helptexts.ycp";
@@ -54,40 +54,34 @@
boolean diskless = true;
boolean partition_mounted_but_not_formated = false;
- boolean have_swap = false;
- symbol retval = `next;
- boolean sparc_first_is_swap = false;
- string sparc_first_dev = "";
boolean swap_found = false;
boolean boot_found = false;
boolean root_found = false;
- boolean gpt_warning = false;
boolean gpt_boot_ia64 = false;
integer boot_end = 0;
integer root_end = 0;
boolean root_raid = false;
+ boolean root_dmraid = false;
boolean boot_raid = false;
boolean root_lvm = false;
symbol root_fs = `unknown;
symbol boot_fs = `unknown;
integer boot_size_k = 0;
boolean boot_size_check = !(Arch::board_chrp() || Arch::board_prep() || Arch::board_iseries() || Arch::board_mac());
- integer root_cyl_for_gb = 0;
- integer boot_cyl_for_gb = 0;
boolean fat_system_mount = false;
boolean fat_system_boot = false;
- boolean dmraid_root = false;
string raid_type = "";
- foreach( string disk, map diskinfo, targetMap,
- ``{
+ foreach (string disk, map diskinfo, targetMap, {
+
list<map> part_info = diskinfo["partitions"]:[];
integer cyl_size = diskinfo["cyl_size"]:1000000;
if (contains([ `CT_DISK, `CT_DMRAID, `CT_DMMULTIPATH, `CT_MDPART ], diskinfo["type"]:`CT_UNKNOWN))
diskless = false;
- foreach( map part, part_info, ``{
+ foreach (map part, part_info, {
+
// All valid partitions ...
integer fsid = part["fsid"]:0;
string mountpoint = part["mount"]:"";
@@ -98,20 +92,15 @@
if( mountpoint == "/" )
{
- if( diskinfo["label"]:"" == "gpt" )
- {
- gpt_warning = true;
- }
root_found = true;
- dmraid_root = diskinfo["type"]:`CT_UNKNOWN == `CT_DMRAID;
- root_end = part["region",0]:0 + part["region",1]:1-1;
+ root_dmraid = diskinfo["type"]:`CT_UNKNOWN == `CT_DMRAID;
+ root_end = Region::End(part["region"]:[]);
if( !contains( [ `primary, `logical ], part["type"]:`unknown ))
{
// root_end does not have anything to do with physical cylinders
root_end = 0;
}
root_fs = part["used_fs"]:`unknown;
- root_cyl_for_gb = 1073741824 / diskinfo["cyl_size"]:1000000; // 1GB/cylinder size
if ( part["type"]:`unknown==`sw_raid ) root_raid = true;
if( !boot_raid ) raid_type = part["raid_type"]:"";
@@ -119,10 +108,6 @@
}
else if( mountpoint == Partitions::BootMount() )
{
- if( diskinfo["label"]:"" == "gpt" )
- {
- gpt_warning = true;
- }
if( (Partitions::EfiBoot() || Arch::ia64()) && diskinfo["label"]:"gpt" != "gpt" )
{
gpt_boot_ia64 = true;
@@ -130,14 +115,11 @@
boot_found = true;
if( diskinfo["type"]:`CT_UNKNOWN==`CT_DISK )
{
- boot_end = part["region",0]:0 + part["region",1]:1-1;
- // 1GB/cylinder size
- boot_cyl_for_gb = 1073741824 / diskinfo["cyl_size"]:1000000;
+ boot_end = Region::End(part["region"]:[]);
}
else
{
boot_end = 0;
- boot_cyl_for_gb = 0;
}
boot_fs = part["used_fs"]:`unknown;
boot_size_k = part["size_k"]:0;
@@ -151,17 +133,15 @@
(fsid == Partitions::fsid_prep_chrp_boot || fsid==6) )
{
boot_found = true;
- boot_end = part["region",0]:0 + part["region",1]:1-1;
+ boot_end = Region::End(part["region"]:[]);
boot_fs = part["used_fs"]:`unknown;
- boot_cyl_for_gb = 1073741824 / diskinfo["cyl_size"]:1000000;
boot_size_k = part["size_k"]:0;
}
else if( Arch::board_mac() && part["used_fs"]:`unknown==`hfs )
{
boot_found = true;
- boot_end = part["region",0]:0 + part["region",1]:1-1;
+ boot_end = Region::End(part["region"]:[]);
boot_fs = part["used_fs"]:`unknown;
- boot_cyl_for_gb = 1073741824 / diskinfo["cyl_size"]:1000000;
boot_size_k = part["size_k"]:0;
}
}
@@ -170,7 +150,6 @@
//////////////////////////////////////////////////////////////
// look for swap partition and check:
// - is there any
- // - on sparc: is first partition a swap partition
//
// check only "swap" not fsid cause for example on pdisk fsid = 0
//
@@ -178,16 +157,7 @@
if( mountpoint == "swap" )
{
- have_swap = true;
-
- // first partition of a sparc system shouldn't be a swap
- // parition
- if( Arch::sparc() && part["type"]:`unknown==`primary &&
- part["nr"]:0 == 1 )
- {
- sparc_first_is_swap = true;
- sparc_first_dev = disk;
- }
+ swap_found = true;
}
@@ -222,110 +192,115 @@
});
y2milestone("diskless:%1", diskless);
- y2milestone("root_found:%1 boot_found %2", root_found, boot_found);
- y2milestone("dmraid_root:%1 root_raid %2 boot_raid %3 raid_type:%4",
- dmraid_root, root_raid, boot_raid, raid_type);
-
- if ( ( !Arch::ia64 () && installation && gpt_warning) || show_all_popups )
- {
- // popup text %2 is a disk name e.g. /dev/hda %1 is a number
- boolean ret = Popup::YesNo( sformat(_("The disk label type on your system disk is GPT.
-Linux can handle a GPT partition table fine, but most BIOS
-versions cannot handle this disk label. To remove the GPT
-disk label from a disk, use the menu entry
-\"%1\" of the \"%2\" button.
-
-Change your partitioning?
-"),
- deletechars(_("Create New Partition Table"), "&"),
- deletechars(_("Expert.."), "&")));
-
- if (ret == true) retval = `again;
- }
+ y2milestone("root_found:%1 root_fs:%2", root_found, root_fs);
+ y2milestone("boot_found:%1 boot_fs:%2", boot_found, boot_fs);
+ y2milestone("root_dmraid:%1 root_raid:%2 boot_raid:%3 raid_type:%4",
+ root_dmraid, root_raid, boot_raid, raid_type);
+ boolean ok = true;
if (( !root_found && installation ) || show_all_popups )
{
// popup text
- Popup::Error(_("
-YaST2 needs a root partition to install.
-Assign the root mount point \"/\" to a partition.
-"));
-
- retval = `again;
- }
+ string message = _("You have not assigned a root partition for
+installation. This does not work. Assign the root mount point \"/\" to a
+partition.
+Really use this setup?
+");
+ if (!Popup::YesNo(message))
+ ok = false;
+ }
if( fat_system_mount || show_all_popups )
{
// popup text
- Popup::Error(_("You tried to mount a fat partition to
-one of the following mount points: / /usr /home /opt /var.
-Use a Linux file system, such as ext3 or reiserfs, for these mount points.
-"));
+ string message = _("You tried to mount a fat partition to one of
+the following mount points: / /usr /home /opt /var. This will very likely
+cause problems. Use a Linux file system, such as ext3 or ext4, for these mount
+points.
- retval = `again;
+Really use this setup?
+");
+
+ if (!Popup::YesNo(message))
+ ok = false;
}
if( fat_system_boot || show_all_popups )
{
// popup text
- Popup::Error(_("You tried to mount a fat partition to the mount point /boot.
-Use a Linux file system, such as ext2, ext3 or reiserfs, for this mount point.
-"));
+ string message = _("You tried to mount a fat partition to the
+mount point /boot. This will very likely cause problems. Use a Linux file
+system, such as ext3 or ext4, for this mount point.
- retval = `again;
+Really use this setup?
+");
+
+ if (!Popup::YesNo(message))
+ ok = false;
}
+ if ((boot_found && contains([ `btrfs ], boot_fs)) || show_all_popups)
+ {
+ // popup text
+ string message = _("You have mounted a partition with btrfs to the
+mount point /boot. This will very likely cause problems. Use a Linux file
+system, such as ext3 or ext4, for this mount point.
+
+Really use this setup?
+");
+
+ if (!Popup::YesNo(message))
+ ok = false;
+ }
+
+ if (!boot_found && contains([ `btrfs ], root_fs) || show_all_popups)
+ {
+ // popup text
+ string message = _("You have mounted a partition with btrfs to the
+mount point /. This will very likely cause problems. Use a Linux file system,
+such as ext3 or ext4, for this mount point or an extra partition for /boot.
+
+Really use this setup?
+");
+
+ if (!Popup::YesNo(message))
+ ok = false;
+ }
+
if( (boot_found) && installation || show_all_popups )
{
if( boot_end >= Partitions::BootCyl() || show_all_popups )
{
- // popup text %1 is a number
- boolean ret = Popup::YesNo(sformat(_("Warning:
+ // popup text, %1 is a number
+ string message = sformat(_("Warning:
Your boot partition ends above cylinder %1.
Your BIOS does not seem able to boot
partitions above cylinder %1.
With the current setup, your %2
installation might not be directly bootable.
-Change this?
-"),Partitions::BootCyl(),Product::name));
-
- if ( ret ) retval = `again;
- }
-
+Really use this setup?
+"), Partitions::BootCyl(), Product::name);
- // not substring sparc!
- if ( ( Arch::sparc32 () && boot_end >= boot_cyl_for_gb ) || show_all_popups )
- {
- // popup text
- boolean ret = Popup::YesNo(sformat(_("Warning:
-With the current setup, your %1
-installation might not be directly bootable.
-Some PROM versions have problems with a boot
-partition with an end cylinder above 1 GB.
-
-Change this?
-"),Product::name));
-
-
- if (ret == true) retval = `again;
+ if (!Popup::YesNo(message))
+ ok = false;
}
-
if ( (boot_size_k < 12*1024 && boot_size_check) || show_all_popups )
{
- // popup text
- boolean ret = Popup::YesNo(_("Warning:
-Your boot partition is less than 12MB.
+ // popup text, %1 is a size
+ string message = sformat(_("Warning:
+Your boot partition is smaller than %1.
It is recommended to increase the size of /boot.
-Do you want to do this?
-"));
+Really keep this size of boot partition?
+"), Storage::KByteToHumanStringOmitZeroes(12*1024));
- if (ret == true) retval = `again;
+ if (!Popup::YesNo(message))
+ ok = false;
}
}
@@ -333,7 +308,6 @@
if( (! boot_found && installation ) || show_all_popups )
{
-
// iSeries does not really need a boot partition
// a bootable binary will be written to a kernel slot in /proc
if ((Partitions::PrepBoot() && !Arch::board_iseries() && !diskless) || show_all_popups)
@@ -341,64 +315,35 @@
// popup text
// If the user chooses 'no' here, the system will not be able to
// boot from the hard drive!
- boolean ret = Popup::YesNo(_("Warning: There is no partition mounted as /boot.
+ string message = sformat(_("Warning: There is no partition mounted as /boot.
To boot from your hard disk, a small /boot partition
-(approx. 4MB) is required. Consider creating one.
+(approx. %1) is required. Consider creating one.
(Partitions assigned to /boot will automatically be changed to
type 0x41 PReP/CHRP).
-Do you want to change your setup?
-"));
-
- if (ret == true) retval = `again;
+Really use the setup without /boot partition?
+"), Storage::KByteToHumanStringOmitZeroes(4*1024));
+ if (!Popup::YesNo(message))
+ ok = false;
}
-
// no boot but root
if( (root_end >= Partitions::BootCyl() || show_all_popups) && AutoinstData::BootCylWarning )
{
// popup text
- boolean ret = Popup::YesNo(sformat(_("Warning: According to your setup, you intend to
+ string message = sformat(_("Warning: According to your setup, you intend to
boot your machine from the root partition (/), which, unfortunately,
has an end cylinder above %1. Your BIOS does not seem capable
of booting partitions beyond the %1 cylinder boundary,
which means your %2 installation will not be
directly bootable.
-Change this?
-"), Partitions::BootCyl(),Product::name));
-
- if (ret == true) retval = `again;
- }
-
- if ( (Arch::sparc32 () && root_end >= root_cyl_for_gb) || show_all_popups )
- {
- // popup text
- boolean ret = Popup::YesNo(sformat(_("Warning: With your current setup, your %1
-installation might not be directly bootable, because
-some PROM versions have problems with a boot partition
-ending above the 1 GB boundary.
-
-Change this?
-"),Product::name));
+Really use this setup?
+"), Partitions::BootCyl(), Product::name);
- if (ret == true) retval = `again;
- }
-
- if ( (Arch::sparc () && root_fs != `ext2) || show_all_popups )
- {
- // popup text
- boolean ret = Popup::YesNo(sformat(
-_("Warning: With your current setup, your %1
-installation might not be directly bootable, because
-some PROM versions have problems with a boot partition
-ending above the 1 GB boundary.
-
-Change this?
-"),Product::name));
-
- if (ret == true) retval = `again;
+ if (!Popup::YesNo(message))
+ ok = false;
}
}
@@ -409,46 +354,44 @@
AutoinstData::BootRaidWarning)
{
// popup text
- boolean ret = Popup::YesNo(sformat(
-_("Warning: With your current setup, your %1
+ string message = sformat(_("Warning: With your current setup, your %1
installation might not be directly bootable, because
your files below \"/boot\" are on a software RAID device.
The boot loader setup sometimes fails in this configuration.
-Change this?
-"),Product::name));
+Really use this setup?
+"), Product::name);
- if (ret == true) retval = `again;
+ if (!Popup::YesNo(message))
+ ok = false;
}
// iSeries has no problems with this configuration
// an initrd will be created and you can boot from a kernel slot
- if( installation && !Arch::board_iseries () &&
- ((root_lvm && !boot_found) || show_all_popups ) &&
+ if (installation && !Arch::board_iseries() && ((root_lvm && !boot_found) || show_all_popups) &&
AutoinstData::BootLVMWarning )
{
// popup text
- boolean ret = Popup::YesNo(sformat(_("Warning: With your current setup, your %1 installation
+ string message = sformat(_("Warning: With your current setup, your %1 installation
will encounter problems when booting, because you have no \"boot\"
partition and your \"root\" partition is an LVM logical volume.
This does not work.
-
If you do not know exactly what you are doing, use a normal
partition for your files below /boot.
-Change this?
-"),Product::name));
+Really use this setup?
+"), Product::name);
- if (ret == true) retval = `again;
+ if (!Popup::YesNo(message))
+ ok = false;
}
-
if( ((Partitions::EfiBoot() || Arch::ia64()) && installation && (!boot_found || boot_fs != `vfat)) ||
show_all_popups )
{
// popup text
- boolean ret = Popup::YesNo(sformat(_("Warning: With your current setup, your %2 installation
+ string message = sformat(_("Warning: With your current setup, your %2 installation
will encounter problems when booting, because you have no
FAT partition mounted onto %1.
@@ -457,73 +400,63 @@
If you do not know exactly what you are doing, use a normal
FAT partition for your files below %1.
-Change this?
-"), Partitions::BootMount(),Product::name));
+Really use this setup?
+"), Partitions::BootMount(), Product::name);
- if (ret == true) retval = `again;
+ if (!Popup::YesNo(message))
+ ok = false;
}
- if( (dmraid_root && !boot_found) || show_all_popups )
+ if( (root_dmraid && !boot_found) || show_all_popups )
{
// popup text
- boolean ret = Popup::YesNo(sformat(_("Warning: With your current setup, your installation will probably encounter problems
-when booting, because you have no separate %1
-partition on your RAID disk.
+ string message = sformat(_("Warning: With your current setup, your %2 installation will
+encounter problems when booting, because you have no
+separate %1 partition on your RAID disk.
This will give severe problems with the normal boot setup.
If you do not know exactly what you are doing, use a normal
partition for your files below %1.
-Change this?
-"), Partitions::BootMount()));
+Really use this setup?
+"), Partitions::BootMount(), Product::name);
- if (ret == true) retval = `again;
+ if (!Popup::YesNo(message))
+ ok = false;
}
if( ((Partitions::EfiBoot() || Arch::ia64()) && installation && boot_found && gpt_boot_ia64) ||
show_all_popups )
{
// popup text
- boolean ret = Popup::YesNo( ia64_gpt_text() + "\n\n" +
- _("Change this?") );
- if (ret == true) retval = `again;
+ string message = ia64_gpt_text() + "\n" + _("Really use this setup?");
+
+ if (!Popup::YesNo(message))
+ ok = false;
}
- if ( (!have_swap && Stage::initial() && root_fs!=`nfs) || show_all_popups )
+ if ( (!swap_found && Stage::initial() && root_fs!=`nfs) || show_all_popups )
{
// popup text
- boolean ret = Popup::YesNo(_("
+ string message = _("
You have not assigned a swap partition. There is nothing wrong with that, but
in most cases it is highly recommended to create and assign a swap partition.
Swap partitions on your system are listed in the main window with the
type \"Linux Swap\". An assigned swap partition has the mount point \"swap\".
You can assign more than one swap partition, if desired.
+Really use the setup without swap partition?
+");
-Do you want to change this?
-"));
-
- if (ret == true) retval = `again;
- }
-
- if( sparc_first_is_swap || show_all_popups )
- {
- // popup message
- Popup::Error( sformat(_("
-Your swap partition is the first partition of %1.
-It is strongly recommended to change this, because
-the disk label will be deleted.
-"), sparc_first_dev ));
- retval = `again;
+ if (!Popup::YesNo(message))
+ ok = false;
}
if( (partition_mounted_but_not_formated && installation) || show_all_popups )
{
// popup text
string message = _("
-WARNING:
-
You chose to install onto an existing partition that will not be
formatted. YaST2 cannot guarantee your installation will succeed,
particularly in any of the following cases:
@@ -542,23 +475,21 @@
// continued popup text
_("If you decide to format the partition, all data on it will be lost.
-Do you want to change your setup?
+Really keep the partition unformatted?
");
- boolean ret = Popup::YesNo( message);
-
- if (ret == true) retval = `again;
+ if (!Popup::YesNo(message))
+ ok = false;
}
- return retval == `next;
+ return ok;
}
-define symbol check_devices_used( list<map> partitions, boolean not_cr )
+symbol check_devices_used(list<map> partitions, boolean not_cr)
{
symbol ret = `UB_NONE;
- list<map> pl = filter( map p, partitions,
- ``( p["used_by_type"]:`UB_NONE!=`UB_NONE));
+ list<map> pl = filter( map p, partitions, ``(Storage::IsUsedBy(p)));
if( not_cr && size(pl)>0 )
{
map<string,map> tg = Storage::GetTargetMap();
@@ -568,20 +499,14 @@
if( p["used_by_type"]:`UB_NONE==`UB_MD ||
p["used_by_type"]:`UB_NONE==`UB_DM )
{
- string dev = p["used_by"]:"";
- if( p["used_by_type"]:`UB_NONE==`UB_MD &&
- search(dev,"/dev/")!=0 )
- dev = "/dev/" + dev;
- if( p["used_by_type"]:`UB_NONE==`UB_DM &&
- search(dev,"/dev/mapper/")!=0 )
- dev = "/dev/mapper/" + dev;
+ string dev = p["used_by_device"]:"";
map pa = Storage::GetPartition( tg, dev );
if( size(pa)==0 || !pa["create"]:false )
ppl = add( ppl, p );
}
else if( p["used_by_type"]:`UB_NONE==`UB_LVM )
{
- if( !tg["/dev/"+p["used_by"]:"","create"]:false )
+ if( !tg[p["used_by_device"]:"", "create"]:false )
ppl = add( ppl, p );
}
});
@@ -593,21 +518,8 @@
}
-
-define boolean check_device_edit( map curr_part, boolean bsd_label )
- ``{
- ///////////////////////////////////////////////////////
- // with a BSD-Disklabel partition 3 is always an additional entry
- // which describes the disk and should not be edited
-
- if( bsd_label && curr_part["type"]:`unknown==`primary &&
- curr_part["nr"]:0==3 )
- {
- // popup text
- Popup::Message(_("Partition 3 \"Entire Disk\" is not changeable"));
- return false;
- }
-
+boolean check_device_edit(map curr_part)
+ {
symbol used = check_devices_used( [ curr_part ], false );
if( used == `UB_MD)
@@ -615,7 +527,7 @@
// popup text %1 is replaced by a raid name e.g. md0
Popup::Message(sformat(_("The selected device belongs to the RAID (%1).
Remove it from the RAID before editing it.
-"),curr_part["used_by"]:""));
+"),curr_part["used_by_device"]:""));
return false;
}
else if( used == `UB_LVM )
@@ -623,14 +535,14 @@
// popup text %1 is replaced by a name e.g. system
Popup::Message(sformat(_("The selected device belongs to a volume group (%1).
Remove it from the volume group before editing it.
-"),curr_part["used_by"]:"" ));
+"),curr_part["used_by_device"]:"" ));
}
else if( used != `UB_NONE )
{
// popup text %1 is replaced by a name e.g. system
Popup::Message(sformat(_("The selected device is used by volume (%1).
Remove the volume before editing it.
-"), curr_part["used_by"]:"" ));
+"), curr_part["used_by_device"]:"" ));
}
boolean ret = used==`UB_NONE;
if( ret )
@@ -638,51 +550,36 @@
return( ret );
}
-define boolean check_device_delete( map curr_part, boolean bsd_label,
- boolean installation, map disk )
- ``{
- string part_name = curr_part["device"]:"";
-
- if( bsd_label )
- {
- ///////////////////////////////////////////////////////
- // with BSD-Disklabel partition 3 is always an additionl entry,
- // which describes the disk and should not be edited
- if( bsd_label && curr_part["type"]:`unknown==`primary &&
- curr_part["nr"]:0==3 )
- {
- // popup text
- Popup::Message(_("Partition 3 \"Entire Disk\" is not changeable"));
- return false;
- }
- }
+boolean check_device_delete(map curr_part, boolean installation, map disk)
+ {
+ string part_name = curr_part["device"]:"";
symbol used = check_devices_used( [ curr_part ], false );
if( used != `UB_NONE )
{
- if( used == `UB_LVM)
+ /*if( used == `UB_LVM)
{
// popup text %2 is a device name, %1 is the volume group name
Popup::Error(sformat(_("The device (%2) belongs to a volume group (%1).
Remove it from the volume group before deleting it.
-"),curr_part["used_by"]:"" , part_name) );
- }
+"),curr_part["used_by_device"]:"" , part_name) );
+ }*/
if( used == `UB_MD)
{
// popup text %2 is a device name, %1 is the raid name
Popup::Message(sformat(_("The device (%2) belongs to the RAID (%1).
Remove it from the RAID before deleting it.
-"), curr_part["used_by"]:"", part_name ));
+"), curr_part["used_by_device"]:"", part_name ));
}
else
{
// popup text, %1 and %2 are device names
Popup::Message(sformat(_("The device (%2) is used by %1.
Remove %1 before deleting it.
-"), curr_part["used_by"]:"", part_name ));
+"), curr_part["used_by_device"]:"", part_name ));
}
return false;
}
@@ -763,11 +660,11 @@
if( ret )
ret = Storage::CanDelete( curr_part, disk, true );
return ret;
- };
+ }
-define boolean check_extended_delete( map curr_disk, boolean installation )
- ``{
+boolean check_extended_delete( map curr_disk, boolean installation )
+ {
/////////////////////////////////////////////////
// filter delete partitions
list<map> partitions = curr_disk["partitions"]:[];
@@ -847,7 +744,7 @@
}
else if( used != `UB_NONE )
{
- // popup text, Do not translate RAID.
+ // popup text
Popup::Message(_("
The selected extended partition contains at least one partition
that is in use. Remove the used volume before
@@ -863,5 +760,5 @@
ret = Storage::CanDelete( extd, curr_disk, true );
}
return( ret );
- };
+ }
}
Modified: branches/SuSE-Code-11-SP2-Branch/storage/storage/src/include/custom_part_dialogs.ycp
URL: http://svn.opensuse.org/viewcvs/yast/branches/SuSE-Code-11-SP2-Branch/stora…
==============================================================================
--- branches/SuSE-Code-11-SP2-Branch/storage/storage/src/include/custom_part_dialogs.ycp (original)
+++ branches/SuSE-Code-11-SP2-Branch/storage/storage/src/include/custom_part_dialogs.ycp Tue May 17 13:39:44 2011
@@ -30,26 +30,26 @@
import "Arch";
import "Label";
import "Popup";
+ import "StorageProposal";
- include "partitioning/partition_defines.ycp";
include "partitioning/custom_part_helptexts.ycp";
- include "partitioning/custom_part_check_generated.ycp";
// TODO: cleanup
boolean check_unique_label( map<string,map> targetMap, map part );
boolean CheckFstabOptions( map part );
+ symbol check_devices_used( list<map> partitions, boolean not_cr );
-define string DlgCreateCryptFs( string device, integer minpwlen, boolean format,
+define string DlgPasswdCryptFs( string device, integer minpwlen, boolean format,
boolean tmpcrypt )
``{
string helptext = GetCreateCryptFsHelptext(minpwlen, format, tmpcrypt);
- y2milestone( "DlgCreateCryptFs device:%1 minpwlen:%2 format:%3 tmpcrypt:%4",
+ y2milestone( "DlgPasswdCryptFs device:%1 minpwlen:%2 format:%3 tmpcrypt:%4",
device, minpwlen, format, tmpcrypt );
// heading text
- string h = _("Enter your password for the encrypted file system.");
+ string h = _("Enter your Password for the Encrypted File System.");
string label = "";
if( format )
// label text
@@ -58,166 +58,15 @@
{
if( size(label)>0 )
label = label + " ";
- label = label + ("Empty password allowed.");
+ label = label + _("Empty password allowed.");
}
if( size(device)>0 )
// heading text, %1 is replaced by device name (e.g. /dev/hda1)
h = sformat( _("Password for Encrypted File System on %1"), device );
- UI::OpenDialog(
- `opt(`decorated ),
- `HBox(
- `HWeight(3, `RichText( helptext ) ),
- `HWeight(6, `VBox(
- `VSpacing(0.3),
- `HBox(
- `HSpacing(1),
- `Heading(h),
- `HSpacing(1)
- ),
- `VSpacing(4),
- `HBox(
- `HSpacing(4),
- `VBox(
- // label text
- `Label(label),
- `VSpacing(),
-
- `HBox(
- `Password(`id("pw1"),
- // Label: get password for user root
- // Please use newline if label is longer than 40 characters
- _("&Enter a password for your file system:"), ""),
- `HSpacing(15)),
-
- `VSpacing(0.5),
-
- `HBox(
- `Password(`id("pw2"),
- // Label: get same password again for verification
- // Please use newline if label is longer than 40 characters
- _("Reenter the password for &verification:"), ""),
- `HSpacing(15))
- ),
- `HSpacing(4)
- ),
- `VSpacing(3),
- `ButtonBox(
- `PushButton(`id("ok"), `opt(`default), Label::OKButton()),
- `PushButton(`id("cancel"), Label::CancelButton())
- ),
- `VSpacing(0.5)
- )
- )
- ));
-
- string password = "";
- symbol widget = nil;
-
- repeat
- {
- // Clear password fields on every round.
- UI::ChangeWidget(`id(`pw1), `Value, "");
- UI::ChangeWidget(`id(`pw2), `Value, "");
-
- UI::SetFocus(`id(`pw1));
-
- widget = (symbol) UI::UserInput();
-
- switch (widget)
- {
- case `ok:
-
- password = (string) UI::QueryWidget(`id(`pw1), `Value);
- string tmp = (string) UI::QueryWidget(`id(`pw2), `Value);
-
- if (!Storage::CheckEncryptionPasswords(password, tmp, minpwlen, tmpcrypt))
- widget = `again;
-
- break;
- }
-
- } until (widget == `cancel || widget == `ok);
-
- UI::CloseDialog();
-
- if (widget == `ok)
- {
- return password;
- }
- else
- {
- return "";
- }
- }
-
-
- boolean QueryProposalPassword()
- {
- if (size(Storage::ProposalPassword()) != 0)
- return true;
-
- UI::OpenDialog(`VBox(
- `Label(_("Enter your password for the proposal encryption.")),
- `MinWidth(40,
- `Password(`id(`pw1),
- // Label: get password for user root
- // Please use newline if label is longer than 40 characters
- _("Password:"), "")),
- `VSpacing(0.5),
- `MinWidth(40,
- `Password(`id(`pw2),
- // Label: get same password again for verification
- // Please use newline if label is longer than 40 characters
- _("Reenter the password for verification:"), "")),
- `Label(_("Don't forget what you enter here!")),
- `ButtonBox(
- `PushButton(`id(`ok), `opt(`default), Label::OKButton()),
- `PushButton(`id(`cancel), Label::CancelButton())
- )
- ));
-
- string password = "";
- symbol widget = nil;
-
- repeat
- {
- // Clear password fields on every round.
- UI::ChangeWidget(`id(`pw1), `Value, "");
- UI::ChangeWidget(`id(`pw2), `Value, "");
-
- UI::SetFocus(`id(`pw1));
-
- widget = (symbol) UI::UserInput();
-
- switch (widget)
- {
- case `ok:
-
- password = (string) UI::QueryWidget(`id(`pw1), `Value);
- string tmp = (string) UI::QueryWidget(`id(`pw2), `Value);
-
- if (!Storage::CheckEncryptionPasswords(password, tmp, 8, false))
- widget = `again;
-
- break;
- }
-
- } until (widget == `cancel || widget == `ok);
-
- UI::CloseDialog();
-
- if (widget == `ok)
- {
- Storage::SetProposalPassword(password);
- return true;
- }
- else
- {
- return false;
- }
-
+ string ret = Storage::PasswdPopup( helptext, h, label, format, minpwlen, tmpcrypt );
+ return( ret );
}
@@ -274,8 +123,7 @@
`HSpacing(4)
),
`VSpacing(2),
- `HBox(
- // Ok button
+ `ButtonBox(
`PushButton(`id("ok"), `opt(`default), Label::OKButton()),
// Cancel button
`PushButton(`id("cancel"), _("&Skip") )
@@ -350,6 +198,7 @@
``{
symbol ret = `ok;
list between = entry[`between]:[];
+ integer below = entry[`below]:0;
string valid_chars = entry[`valid_chars]:"";
integer str_length = entry[`str_length]:0;
@@ -363,7 +212,15 @@
ret = `error;
}
}
-
+ if( below != 0 && (size(query)>0 || !entry[`empty_allowed]:false))
+ {
+ y2milestone( "DoInputChecks entry:%1 query:\"%2\"", entry, query );
+ if( below < tofloat(query) )
+ {
+ Popup::Error(entry[`error_text]:"");
+ ret = `error;
+ }
+ }
if( valid_chars != "" && size(query)>0 && ret != `error )
{
if( nil != findfirstnotof( query, valid_chars ))
@@ -419,10 +276,10 @@
`HSpacing(1)),
`VSpacing(1),
`VStretch(),
- `HBox(
- `Left(`PushButton(`id(`help),`opt(`helpButton), Label::HelpButton())),
- `Right(`HBox(`PushButton(`id(`ok), `opt(`default), Label::OKButton()),
- `PushButton(`id(`cancel), Label::CancelButton())))
+ `ButtonBox(
+ `PushButton(`id(`help), `opt(`helpButton), Label::HelpButton()),
+ `PushButton(`id(`ok), `opt(`default), Label::OKButton()),
+ `PushButton(`id(`cancel), Label::CancelButton())
)
)
);
@@ -454,6 +311,11 @@
$[ "option_str" : entry[`option_str]:"",
"option_cmd" : entry[`option_cmd]:`mkfs,
"option_value" : query ];
+ if( is( query, boolean ) && query==false &&
+ haskey( entry, `option_false ) )
+ {
+ fs_option["option_str"] = entry[`option_false]:"";
+ }
y2milestone( "FileSystemOptions fs_option %1", fs_option );
if( entry[`option_blank]:false )
@@ -512,7 +374,7 @@
term contents = `VBox();
term emptyterm = `Empty();
- if( new["enc_type"]:`none==`none) // && new["mount"]:"" != "swap" )
+ if( new["enc_type"]:`none==`none && new["type"]:`unknown!=`tmpfs )
{
// help text, richtext format
helptext = helptext + _("<p><b>Mount in /etc/fstab By:</b>
@@ -672,11 +534,10 @@
`HSpacing(1)),
`VSpacing(1),
`VStretch(),
- `HBox(
- `Left(`PushButton(`id(`help),`opt(`helpButton), Label::HelpButton())),
- `Right(`HBox(`PushButton(`id(`ok), `opt(`default), Label::OKButton()),
- `PushButton(`id(`cancel), Label::CancelButton()))
- )
+ `ButtonBox(
+ `PushButton(`id(`help), `opt(`helpButton), Label::HelpButton()),
+ `PushButton(`id(`ok), `opt(`default), Label::OKButton()),
+ `PushButton(`id(`cancel), Label::CancelButton())
)
)
);
@@ -687,21 +548,27 @@
{
list no_mountby_type = [ `loop ];
list mountby_id_path_type = [ `primary, `logical ];
+ map enab = $[];
+ boolean tmp = !contains( no_mountby_type, new["type"]:`primary );
+ enab[`label] = tmp && FileSystems::MountLabel( new["used_fs"]:`unknown ) &&
+ new["enc_type"]:`none==`none;
+ enab[`uuid] = tmp && (new["format"]:false || size(new["uuid"]:"")>0) &&
+ FileSystems::MountUuid( new["used_fs"]:`unknown );
+ tmp = contains(mountby_id_path_type, new["type"]:`none);
+ enab[`id] = tmp && size(new["udev_id"]:[])>0;
+ enab[`path] = tmp && size(new["udev_path"]:"")>0;
+ y2milestone( "FstabOptions enab %1", enab );
+ UI::ChangeWidget( `id(`label), `Enabled, enab[`label]:false );
+ UI::ChangeWidget( `id(`uuid), `Enabled, enab[`uuid]:false );
+ UI::ChangeWidget( `id(`id), `Enabled, enab[`id]:false );
+ UI::ChangeWidget( `id(`path), `Enabled, enab[`path]:false );
symbol defmb = !Mode::config() ? Storage::GetMountBy( new["device"]:"" )
: `device;
y2milestone( "FstabOptions defmb %1", defmb );
+ if( haskey( enab, defmb ) && !enab[defmb]:false )
+ defmb = `device;
UI::ChangeWidget( `id(`mt_group), `CurrentButton,
new["mountby"]:defmb );
- UI::ChangeWidget( `id(`label), `Enabled,
- FileSystems::MountLabel( new["used_fs"]:`unknown ) &&
- new["enc_type"]:`none==`none &&
- !contains( no_mountby_type, new["type"]:`primary ) );
- UI::ChangeWidget( `id(`uuid), `Enabled,
- (new["format"]:false || size(new["uuid"]:"")>0) &&
- FileSystems::MountUuid( new["used_fs"]:`unknown ) &&
- !contains( no_mountby_type, new["type"]:`primary ) );
- UI::ChangeWidget( `id(`id), `Enabled, contains(mountby_id_path_type, new["type"]:`none) );
- UI::ChangeWidget( `id(`path), `Enabled, contains(mountby_id_path_type, new["type"]:`none) );
}
if( UI::WidgetExists( `id(`vol_label) ))
@@ -720,18 +587,18 @@
if( UI::WidgetExists( `id("opt_user") ))
{
UI::ChangeWidget( `id("opt_user"), `Enabled,
- new["enc_type"]:`none==`none || new["noauto"]:false );
- }
- if( UI::WidgetExists( `id("opt_noauto") ))
- {
- UI::ChangeWidget( `id("opt_noauto"), `Enabled,
- new["enc_type"]:`none==`none || new["noauto"]:false );
+ new["enc_type"]:`none==`none );
}
if( UI::WidgetExists( `id("opt_quota") ))
{
UI::ChangeWidget( `id("opt_quota"), `Enabled,
FileSystems::CanDoQuota(new) );
}
+ if( UI::WidgetExists( `id("opt_readonly") ))
+ {
+ UI::ChangeWidget( `id("opt_readonly"), `Enabled,
+ FileSystems::CanMountRo(new) );
+ }
foreach( any key, any value, old_state,
``{
UI::ChangeWidget( `id(key), `Value, value );
@@ -742,15 +609,6 @@
{
ret = UI::UserInput();
y2milestone( "FstabOptions ret %1", ret );
- if( ret == "opt_noauto" )
- {
- if( UI::WidgetExists( `id("opt_user") ))
- {
- boolean val = (boolean)UI::QueryWidget( `id("opt_noauto" ), `Value );
- UI::ChangeWidget( `id("opt_user"), `Enabled,
- new["enc_type"]:`none==`none || val );
- }
- }
if( ret == `ok )
{
if( UI::WidgetExists( `id(`mt_group) ))
@@ -1033,7 +891,6 @@
if( new_val["type"]:`primary != `lvm &&
new_val["type"]:`primary != `sw_raid &&
- new_val["type"]:`primary != `evms &&
new_val["type"]:`primary != `loop && !Partitions::no_fsid_menu )
{
fsid = `VBox(
@@ -1120,23 +977,6 @@
}
-
-
-define boolean UseChangedPartitionContinueCancelPopup()
- ``{
- // popup text
- if( Popup::ContinueCancel(_("You have changed the parameters of a partition currently
-mounted. In some cases, this can damage your Linux installation.
-
-Proceed only if you know what you are doing. If you are unsure,
-press Cancel.
-
-")))
- return true;
-
- return false;
- };
-
define boolean ModifyPartitionInSystemWarningPopup( string part, string mount )
``{
@@ -1169,12 +1009,12 @@
// Popup text
txt = _("
The file system on the partition cannot be shrunk by YaST2.
-Only fat, ext2, ext3, and reiser allow shrinking of a file system.");
+Only fat, ext2, ext3, ext4, and reiser allow shrinking of a file system.");
else
// Popup text
txt = _("
The file system on the logical volume cannot be shrunk by YaST2.
-Only fat, ext2, ext3, and reiser allow shrinking of a file system.");
+Only fat, ext2, ext3, ext4, and reiser allow shrinking of a file system.");
if( ask )
{
txt = txt + "\n";
@@ -1207,12 +1047,12 @@
// Popup text
txt = _("
The file system on the selected partition cannot be extended by YaST2.
-Only fat, ext2, ext3, xfs, and reiser allow extending a file system.");
+Only fat, ext2, ext3, ext4, xfs, and reiser allow extending a file system.");
else
// Popup text
txt = _("
The file system on the selected logical volume cannot be extended by YaST2.
-Only fat, ext2, ext3, xfs, and reiser allow extending a file system.");
+Only fat, ext2, ext3, ext4, xfs, and reiser allow extending a file system.");
if( ask )
{
txt = txt + "\n\n";
@@ -1263,119 +1103,6 @@
}
-/**
- * Scan exiting partitions for fstab files and if one found read the mountpoints
- * from the fstab file and build a new targetMap.
- * Ask the user if he like to use the new or old targetMap
- * (with or without found mountpoints)
- *------------------------------------
- * @parm targetMap all targets
- * @parm installation !!
- * @parm file_systems filesystems definition map
- * @return targetMap new or unmodified targetMap
- *---------------------------------------------------------------------
- */
-define integer FstabAddDialog( list table_input )
- ``{
- y2milestone( "FstabAddDialog start %1", table_input );
- if( table_input == [] || table_input == nil )
- {
- // popup text
- Popup::Message(_("No previous system with mount points was detected."));
- return -1;
- }
-
- // heading text
- term header = `header( _("Device "), _("Mount "));
-
- // help text, richtext format
- string help_text = _("<P><B><BIG>Attention:</BIG></B><BR>YaST2 has scanned your hard disks and found an old Linux system
-with mount points. On the right, see a list with the mount points found. </P>
-")+
- // help text, richtext format
-_("<P>To use these mount points, <BR>press <B>Yes</B>.</P>")+
- // help text, richtext format
-_("<P>To ignore these mount points, <BR> press <B>No</B>.</P>");
-
- UI::OpenDialog(
- `opt(`decorated ),
- `HBox(
- `VBox( `HSpacing(20), `RichText(help_text)),
- `VBox( `VSpacing(1),
- `ReplacePoint( `id(`heading), `Empty() ),
- `HBox(
- `HSpacing(3.0),
- `VSpacing(8),
- `VBox( `VSpacing(1),
- `Table(`id(`table), header, [] )
- ),
- `HSpacing(3.0)
- ),
-
- `VSpacing(1),
- // popup text
- `Heading(_("Would you like to use these mount points
-for your new installation?")),
- `VSpacing(1),
- `ReplacePoint( `id(`bbox), `Empty() )
- ))
- );
-
- symbol userinput = `none;
- integer idx = 0;
- repeat
- {
- // popup text %1 is replaced by a device name (e.g. /dev/hda1)
- string tmp = sformat(
-_("A previous system with the following mount points was detected:
-/etc/fstab found on %1"), table_input[idx,"root"]:"/dev/emil" );
- UI::ReplaceWidget( `id(`heading), `Heading( tmp ) );
-
- UI::ChangeWidget( `id(`table), `Items, table_input[idx,"tbl"]:[] );
-
- term bbox = `HBox( `PushButton( `id(`ok), `opt(`default),
- Label::YesButton() ),
- `PushButton(`id(`cancel), Label::NoButton())
- );
- if( size(table_input)>0 )
- {
- bbox = add( bbox, `HSpacing(5) );
- if( idx>0 )
- {
- bbox = add( bbox,
- `PushButton( `id(`show_p), _("Show &Previous") ));
- }
- if( idx<size(table_input)-1 )
- {
- bbox = add( bbox,
- `PushButton( `id(`show_n), _("Show &Next") ));
- }
- }
- y2milestone( "userinput UI::ReplaceWidget" );
- UI::ReplaceWidget( `id(`bbox), bbox );
- y2milestone( "after UI::ReplaceWidget" );
-
- userinput = (symbol)UI::UserInput();
- y2milestone( "userinput %1", userinput );
-
- if( userinput == `show_n )
- {
- idx = idx+1;
- }
- else if( userinput == `show_p )
- {
- idx = idx-1;
- }
- y2milestone( "idx %1", idx );
- }
- until( userinput == `ok || userinput == `cancel );
- UI::CloseDialog();
-
- integer ret = userinput == `ok ? idx : -1;
- y2milestone( "ret %1", ret );
- return ret;
- };
-
//FIXME: y2-repair uses this, need to find
//a better place for it
symbol ReallyInstPrepdisk()
@@ -1438,9 +1165,8 @@
* Check if at least on partition is mounted.
* @return map targetMap
*/
-define boolean deleteAllDevPartitions( map<string, any> disk,
- boolean installation, boolean bsd_label )
- ``{
+boolean deleteAllDevPartitions(map<string, any> disk, boolean installation)
+ {
boolean go_on = true;
string del_dev = disk["device"]:"";
y2milestone( "deleteAllDevPartitions disk:%1", remove( disk, "partitions" ));
@@ -1529,13 +1255,132 @@
y2milestone( "deleteAllDevPartitions dp:%1", dp );
foreach( map part, dp,
``{
- go_on = go_on &&
- Storage::DeleteDevice( del_dev, part["device"]:"" );
+ go_on = go_on && Storage::DeleteDevice(part["device"]:"");
});
}
}
y2milestone( "deleteAllDevPartitions ret:%1", go_on );
return(go_on);
+ }
+
+list<string> SubvolNames( map<string,any> data )
+ {
+ list<string> items = maplist( map p,
+ filter( map s, data["subvol"]:[], ``(!s["delete"]:false)),
+ {return p["name"]:"";});
+ y2milestone( "items:%1", items );
+ return( items );
+ }
+
+ /**
+ * Dialog: Subvolume handling
+ * @parm old map with original partition
+ * @parm new map with changes filled in
+ */
+define map<string,any> SubvolHandling( map<string,any> old, map<string,any> new )
+ ``{
+ // help text, richtext format
+ string helptext = _("<p>
+Here it is possible to create and remove subvolumes
+from an BTRFS filesystem.</p>");
+
+ list<map> old_subvol = new["subvol"]:[];
+
+ list<string> items = SubvolNames( new );
+
+ term contents = `VBox(
+ // label text
+ `MinHeight(10,`SelectionBox( `id(`subvol), _("Existing Subvolumes:"), items )),
+ `TextEntry( `id(`new_path), `opt(`hstretch),
+ // label text
+ _("New Subvolume")),
+ `HBox(
+ `PushButton( `id(`add),
+ // button text
+ _("Add new")),
+ `HSpacing(2),
+ `PushButton( `id(`remove),
+ // button text
+ _("Remove"))
+ )
+ );
+
+ UI::OpenDialog(`opt(`decorated),
+ `VBox(
+ `HSpacing(50),
+ // heading text
+ `Heading(_("Subvolume Handling")),
+ `VStretch(),
+ `VSpacing(1),
+ `HBox(`HStretch(),
+ `HSpacing(1),
+ contents,
+ `HStretch(),
+ `HSpacing(1)),
+ `VSpacing(1),
+ `VStretch(),
+ `ButtonBox(
+ `PushButton(`id(`help), `opt(`helpButton), Label::HelpButton()),
+ `PushButton(`id(`ok), `opt(`default), Label::OKButton()),
+ `PushButton(`id(`cancel), Label::CancelButton())
+ )
+ )
+ );
+
+ UI::ChangeWidget(`help, `HelpText, helptext);
+
+ any ret = `ok;
+ boolean changed = false;
+ repeat
+ {
+ ret = UI::UserInput();
+ y2milestone( "SubvolHandling ret %1", ret );
+ if( ret == `remove )
+ {
+ string pth = (string)UI::QueryWidget(`id(`subvol), `CurrentItem);
+ y2milestone( "SubvolHandling remove path:%1", pth );
+ new["subvol"] = maplist( map p, new["subvol"]:[],
+ {
+ if( p["name"]:""==pth )
+ p["delete"] = true;
+ return p;
+ });
+ items = SubvolNames( new );
+ changed = true;
+ UI::ChangeWidget( `id(`subvol), `Items, items );
+ }
+ if( ret == `add )
+ {
+ string pth = (string)UI::QueryWidget( `id(`new_path), `Value );
+ y2milestone( "SubvolHandling add path:%1", pth );
+ if( pth==nil || size(pth)==0 )
+ Popup::Message(_("Empty subvolume name noit allowed."));
+ else if( size(filter( map p, new["subvol"]:[], ``(p["name"]:""==pth)))>0 )
+ Popup::Message(sformat(_("Subvolume name %1 alread exists."),pth));
+ else
+ {
+ new["subvol"] = add( new["subvol"]:[], $[ "create" : true, "name" : pth ] );
+ changed = true;
+ }
+ items = SubvolNames( new );
+ UI::ChangeWidget( `id(`subvol), `Items, items );
+ UI::ChangeWidget( `id(`new_path), `Value, "" );
+ }
+ if( ret == `cancel )
+ {
+ if( changed )
+ {
+ if( Popup::YesNo( _("Modifications done so far in Dialog get lost!")) )
+ new["subvol"] = old_subvol;
+ else
+ ret = `again;
+ }
+ }
+ } until ( ret == `ok || ret == `cancel );
+
+ UI::CloseDialog();
+ y2milestone( "SubvolHandling subvol %1", new["subvol"]:[] );
+ return( new );
};
}
Modified: branches/SuSE-Code-11-SP2-Branch/storage/storage/src/include/custom_part_helptexts.ycp
URL: http://svn.opensuse.org/viewcvs/yast/branches/SuSE-Code-11-SP2-Branch/stora…
==============================================================================
--- branches/SuSE-Code-11-SP2-Branch/storage/storage/src/include/custom_part_helptexts.ycp (original)
+++ branches/SuSE-Code-11-SP2-Branch/storage/storage/src/include/custom_part_helptexts.ycp Tue May 17 13:39:44 2011
@@ -124,261 +124,6 @@
};
-define string getEditOrCreateHelptext(map new_val, boolean edit_format )
- ``{
-
- string helptextCR = "";
-
- if( edit_format )
- {
- // help text, richtext format
- helptextCR = _("<p>On already-existing partitions, you can change
-everything except the start and size of the partition.</p>");
- }
- else
- {
- // helptext for popup create partition line 1 of 6
- helptextCR = _("<p>First, choose the type of the partition and whether this partition should be formatted.</p>");
- // helptext for popup create partition line 2 of 6
- helptextCR = helptextCR + _("<p>Then, enter the mount point ( /, /boot, /usr, /var, etc.)</p>");
-
-
- if( !new_val["create"]:false )
- {
- // helptext line 3 of 3
- helptextCR = helptextCR + _("<p>To change the start or end cylinder, delete this partition then create a new one with the new parameters. All data on this partition will be lost.</p>");
- }
- else
- {
- // helptext for popup create partition line 3 of 6
- helptextCR = helptextCR + _("<p>Now, enter the location of the new partition on your hard disk. </p>");
- // helptext for popup create partition line 4 of 6
- helptextCR = helptextCR + _("<p>Please enter the starting cylinder number of the partition. </p>");
- // helptext for popup create partition line 5 of 6
- helptextCR = helptextCR + _("<p>After that, either specify an ending cylinder number or an offset from the first cylinder (e.g., +66).</p>");
- // helptext for popup create partition line 6 of 6
- helptextCR = helptextCR + _("<p>It is also possible to specify the size of the partition directly (e.g., +100M or +20000K).</p>");
- }
- }
- return( helptextCR );
- };
-
-
-define string getCreateEditExtendedHelptext() ``{
-
- // helptext for popup create extended partition line
- string helptextCR = _("<p>Enter the starting cylinder number of the partition.
-After that, either specify an ending cylinder number or an offset from the first cylinder (e.g., +66).
-It is also possible to specify the size of the partition directly (e.g., +2G, +100M, or +20000K).</p>
-");
- return( helptextCR );
- };
-
-
-define string getMainHelptext(boolean installation)
- ``{
- string help_text = "";
-
- // helptext expert partitioning. 1
- help_text = _("<p> Partition your hard disks... </p>");
-
- // helptext expert partitioning. 2
- help_text = help_text + _("<p>
-This is intended for <b>experts</b>.
-If you are not familiar with the concepts of hard disk <b>partitions</b>
-and how to use them, you might want to go back and select <b>automatic</b>
-partitioning.
-</p>");
- if( installation )
- {
- // helptext expert partitioning. 3
- help_text = help_text + _("<p>
-Please note that <b>nothing will be written to your hard disk</b>
-until you confirm the entire installation in the last installation dialog.
-Until that point, you can safely abort the installation.
-</p>");
- }
- else
- {
- // helptext expert partitioning. 3
- help_text = help_text + _("<p>
-<b>Nothing will be written to your hard disk</b>
-until you confirm all your changes with the \"Apply\" button.
-Until that point, you can safely abort.
-</p>
-");
- }
-
- // helptext expert partitioning
- help_text = help_text + _("<p>
-For LVM setup, using a non-LVM boot partition is necessary.
-Other than the boot partition, you should have partitions
-managed by LVM.</p>
-");
-
- // helptext expert partitioning. 4
- help_text = help_text + _("<p>
-The table to the right shows the current partitions on all your hard disks.
-</p>
-");
-
- // helptext expert partitioning. 5
- help_text = help_text + _("<p><b>Hard disks</b> are designated like this </p>") +
-// help text
-_("<tt>/dev/sda </tt>1st disk<br>
-<tt>/dev/sdb </tt>2nd disk<br>
-<tt>/dev/sdc </tt>3rd disk") +
-// help text
-_("<p>etc.</p>")+
-// help text
-_("<p>
-This notation always refers to the entire disk.
-</p>");
- // helptext expert partitioning. 7
- help_text = help_text + _("<p>
-<b>Partitions</b> are designated like this:
-</p>");
- // helptext expert partitioning. 8
- help_text = help_text + _("<p><tt>/dev/sda1 </tt>1st primary partition on the 1st disk.</p>")+
- // helptext expert partitioning
-_("<p><tt>/dev/sda2 </tt>2nd primary partition on the 1st disk.</p>") +
-"<p>...</p>" +
- // helptext expert partitioning
-_("<p><tt>/dev/sda5 </tt>1st logical partition within the extended partition on
-the first disk. <b>Note:</b> this is always #5, even if there are less than four
-primary partitions.</p>");
- // helptext expert partitioning. 9
- help_text = help_text + _("<p><tt>/dev/sda6 </tt>2nd logical partition</p>")+
-"<p>...</p>";
- // helptext expert partitioning. 10
- help_text = help_text + _("<p>
-On the i386 platform (i.e., normal PCs), there cannot be more than four
-<b>primary partitions</b> on any hard disk, because the respective table in the
-master boot record cannot contain more than four entries.
-</p>
-");
- // helptext expert partitioning. 11
- help_text = help_text + _("<p>
-Older PCs may have a <b>BIOS</b> limitation that restricts bootable
-partitions to cylinders below <b>1024</b>.
-</p>
-");
- // helptext expert partitioning. 12
- help_text = help_text + _("<p>
-If you have an older PC and want to boot from a partition, make sure it ends below this
-1024 cylinder boundary. Create a separate partition and mount it as
-<b>/boot</b>, if necessary. A partition consisting of one single cylinder
-(at least 64 MB) is usually sufficient for that.
-</p>
-");
- // helptext expert partitioning. 13
- help_text = help_text + _("<p>
-One of the four primary partitions may be an <b>extended partition</b>.
-This extended partition can contain one or more <b>logical partitions</b>.
-</p>");
- // helptext expert partitioning. 14
- help_text = help_text + _("<p>
-The extended partition itself cannot hold any data.
-To use its space, create logical partitions.
-These logical partitions may contain any kind of Linux partition (Linux
-file systems or Linux swap partition) or partitions for other
-operating systems.
-</p>
-");
- // helptext expert partitioning. 15
- help_text = help_text + _("<p>
-In connection with advanced boot managers such as <b>GRUB</b>, you can even
-boot your computer from a logical partition.
-</p>");
- // helptext expert partitioning. 16
- help_text = help_text + _("<p>
-The extended partition will <b>overlap</b> with the logical
-partitions: for an extended partition from cylinder 200 to 500, logical
-partitions could range from, for example, 200 to 250, 251 to 400, and 401 to 500.
-</p>
-");
- // helptext expert partitioning. 17
- help_text = help_text + _("<p>
-An asterisk (*) after the mount point indicates a file system that is
-currently not mounted (for example, because it has the <tt>noauto</tt> option set in <tt>/etc/fstab</tt>).
-</p>
-");
- // helptext expert partitioning. 18
- help_text = help_text + _("<p>
-The column labeled <b>F</b> contains flags. <tt>C</tt> means the partition is encrypted.
-<tt>F</tt> means the partition is selected to be formatted.
-</p>
-");
- // helptext expert partitioning. 19
- help_text = help_text + _("<p>
-<b>Used By</b> tells if a device is used by LVM or RAID. If you do not use such
-things, it is perfectly normal for this column to be empty.
-</p>
-");
- // helptext expert partitioning. 20
- help_text = help_text + _("<p>
-<b>Mount By</b> indicates how the file system is mounted: (K) by Kernel Name,
-(L) by Label, (U) by UUID, (I) by Device ID, and (P) by Device Path.
-</p>
-");
-
- //help_text = help_text + "<p>(.16)</p>";
-
- return( help_text );
- }
-
-define string getMainHelptextS390()
- ``{
- string help_text = "";
-
- // helptext S390 expert partitioning 1
- help_text = _("<p>
-For a root file system on SCSI disks, add a /boot
-partition on DASD to use for IPL.</p>
-");
-
- // helptext S390 expert partitioning 2
- help_text = help_text + _("<p>
-The table to the right shows the current partitions on all your hard disks.
-<b>Nothing will be written to your hard disk</b>
-until you confirm the entire installation in the last installation dialog.
-Until that point, you can safely abort the installation.</p>");
-
- // helptext S390 expert partitioning 3
- help_text = help_text + _("<p>
-<b>Hard disks</b> are designated like this: </p>
-<tt>/dev/dasda </tt>First DASD disk
-<tt>/dev/dasdb </tt>Second DASD disk
-<tt>/dev/dasdc </tt>Third DASD disk
-<p>- or - </p>
-<p><tt>/dev/sda </tt>First SCSI disk
-<tt>/dev/sdb </tt>Second SCSI disk
-<tt>/dev/sdc </tt>Third SCSI disk</p>");
-
- // helptext S390 expert partitioning 4
- help_text = help_text + _("<p>
-This notation always refers to the entire disk.</p>");
-
- // helptext S390 expert partitioning 5
- help_text = help_text + _("<p>
-If a DASD disk is selected for low level formatting
-with the dasdfmt command, an <tt>X</tt> appears
-in the third column of the line corresponding to the
-disk.</p>
-");
-
- // helptext S390 expert partitioning 6
- help_text = help_text + _("<p>
-<b>Partitions</b> are designated like this:</p>
-
-<p><tt>/dev/dasda1 </tt>First partition on the first DASD disk.</p>
-<p><tt>/dev/dasda2 </tt>Second partition on the first DASD disk.</p>
-<p><tt>/dev/dasda3 </tt>Third partition on the first DASD disk.</p>
-<p><tt>/dev/sda1</tt>, etc., for SCSI.</p>");
-
- return( help_text );
- }
-
define string ia64_gpt_text()
{
return( _("Warning: With your current setup, your installation
Modified: branches/SuSE-Code-11-SP2-Branch/storage/storage/src/include/custom_part_lib.ycp
URL: http://svn.opensuse.org/viewcvs/yast/branches/SuSE-Code-11-SP2-Branch/stora…
==============================================================================
--- branches/SuSE-Code-11-SP2-Branch/storage/storage/src/include/custom_part_lib.ycp (original)
+++ branches/SuSE-Code-11-SP2-Branch/storage/storage/src/include/custom_part_lib.ycp Tue May 17 13:39:44 2011
@@ -21,222 +21,30 @@
textdomain "storage";
import "Mode";
import "Arch";
- import "Installation";
import "Partitions";
import "Product";
import "FileSystems";
-
-define string mountVar( map var, map root, string rdev, string mp,
- map<string,map> targetMap )
- ``{
- string ret = "";
- boolean mount_success = false;
- y2milestone( "mountVar rdev:%1 mp:%2 var:%3 root:%4", rdev, mp, var, root );
- if( var["size_k"]:0>0 )
- {
- ret = var["device"]:"";
- }
- else
- {
- list<string> ds = maplist( string d, map disk, targetMap, ``(d));
- y2milestone( "mountVar ds:%1", ds );
- ds = filter( string d, ds, ``(targetMap[d,"type"]:`CT_UNKNOWN==`CT_DISK));
- y2milestone( "mountVar ds:%1", ds );
- map rootm = Storage::GetDiskPartition( rdev );
- map rootf = Storage::GetDiskPartition( root["device"]:"" );
- map varf = Storage::GetDiskPartition( var["device"]:"" );
- if( rootf["disk"]:""==varf["disk"]:"" )
- {
- ret = Storage::GetDeviceName( rootm["disk"]:"", varf["nr"]:(any)0 );
- }
- else if( size(ds)==1 )
- {
- ret = Storage::GetDeviceName( ds[0]:"", varf["nr"]:(any)0 );
- }
- else if( size(ds)>1 )
- {
- integer i = 0;
- while( i<size(ds) && size(ret)==0 )
- {
- ret = Storage::GetDeviceName( ds[i]:"", varf["nr"]:(any)0 );
- if( size(Storage::GetPartition( targetMap, ret ))>0 &&
- Storage::Mount( ret, mp ) )
- {
- map d = (map)SCR::Read( .target.stat, mp+"/lib/hardware" );
- y2milestone( "mountVar d:%1", d );
- if( !d["isdir"]:false )
- ret = "";
- Storage::Umount( ret );
- }
- else
- ret = "";
- i = i+1;
- }
- }
- }
- if( size(ret)>0 && !Storage::Mount( ret, mp ))
- ret = "";
- y2milestone( "mountVar ret:%1", ret );
- return( ret );
- }
+ include "partitioning/partition_defines.ycp";
/**
- * Find and read fstab by installation. Scan existing partitions.
- * @parm targetMap all targets
- * @parm search_point mount point where partitions can be mounted
- * @return list list with fstab data found
- */
-define list<list> findExistingFstab( map<string,map> targetMap, string search_point )
- ``{
- /////////////////////////////////////////////////////////////////
- // foreach partition on each target
- list<list> fstab = [];
- list skip_fs = [ `unknown, `swap, `vfat, `ntfs ];
-
- foreach( string dev, map disk, targetMap,
- ``{
- foreach( map part,
- filter( map p, disk["partitions"]:[],
- ``(!contains( skip_fs,
- p["detected_fs"]:`unknown) )),
- ``{
- /////////////////////////////////////////////////////
- // try to mount
- boolean mount_success = Storage::Mount( part["device"]:"",
- search_point );
-
- if( mount_success &&
- SCR::Read(.target.size, search_point+"/etc/fstab") > 0 )
- {
- list<map> tmp =
- (list<map>)Storage::ReadFstab( search_point+"/etc" );
- y2milestone( "findExistingFstab fstab %1", tmp );
- if( size(tmp)>0 )
- {
- if( find( map p, tmp, ``(p["size_k"]:0==0 ))!=nil )
- {
- string vardev = "";
- map var = find( map p, tmp, ``(p["mount"]:""=="/var"));
- map root = find( map p, tmp, ``(p["mount"]:""=="/"));
- y2milestone( "findExistingFstab var %1", var );
- if( var != nil )
- {
- vardev = mountVar( var, root, part["device"]:"",
- search_point+"/var", targetMap );
- y2milestone( "findExistingFstab vardev %1",
- vardev );
- }
- map dmap = Storage::BuildDiskmap( $[] );
- if( size(dmap)>0 )
- {
- y2milestone( "findExistingFstab dmap %1", dmap );
- y2milestone( "findExistingFstab tmp %1", tmp );
- tmp = maplist( map p, tmp,
- ``{
- if( p["size_k"]:0 == 0 )
- p["device"] = Storage::HdDiskMap( p["device"]:"", dmap );
- return( p );
- });
- y2milestone( "findExistingFstab tmp %1", tmp );
- }
- integer s = size(tmp);
- tmp = filter( map p, tmp, ``(Storage::CanEdit(p,false)));
- if( s!=size(tmp) )
- y2milestone( "findExistingFstab tmp %1", tmp );
- if( size(vardev)>0 )
- Storage::Umount( vardev );
- }
- fstab = add( fstab, tmp );
- }
- }
-
- /////////////////////////////////////////////////////
- // unmount
- if( mount_success )
- Storage::Umount( part["device"]:"" );
- });
- });
- y2milestone( "findExistingFstab count_fstab_found %1", size(fstab) );
- y2milestone( "findExistingFstab fstab %1", fstab );
- return fstab;
- };
-
-
-/**
- * Scan and Read and return fstab.
- * @parm targetMap all targets
- * @parm file_systems filesystem map
- * @return list list with fstab
- */
-define list<list> scanAndReadExistingFstab( map<string,map> targetMap )
- ``{
- string search_point = "/mnt";
-
- /////////////////////////////////////////////////////////////////
- // make search dir
-
- if( SCR::Execute(.target.bash, "/usr/bin/test -d " + search_point ) != 0)
- {
- SCR::Execute(.target.mkdir, search_point );
- }
-
- list<list> fstab = findExistingFstab( targetMap, search_point );
-
- return fstab;
- };
-
-
-
-
- /**
- * Only for check in installed system.
- * Please do not use this define by installation.
- * @parm part1 partition 1
- * @parm part2 partition 2
- * @return boolean
- */
-define boolean arePartitionsEqual( map part1, map part2 )
- ``{
- if( part1["create"]:false )
- return true;
-
- // -> not all keys
- if( part1["nr"]:0 == part2["nr"]:0 &&
- part1["fsid"]:0 == part2["fsid"]:0 &&
- part1["region"]:[] == part2["region"]:[] &&
- part1["create"]:false == part2["create"]:false &&
- part1["format"]:false == part2["format"]:false &&
- part1["used_fs"]:`unknown == part2["used_fs"]:`unknown &&
- part1["enc_type"]:`none == part2["enc_type"]:`none &&
- part1["fstab_mnt"]:`device == part2["fstab_mnt"]:`device &&
- part1["label"]:"" == part2["label"]:"" &&
- part1["mount"]:"" == part2["mount"]:"" )
- {
- return true;
- }
- return false;
- }
-
- /**
* Check lvm mount points
* @param mount mount point
* @return boolean
*/
-define boolean check_lvm_mount_points( string mount )
- ``{
- list not_allowed_lvm_mount_points = [ Partitions::BootMount() ];
- y2milestone( " check lvm mount");
- if( contains( not_allowed_lvm_mount_points, mount ))
+ boolean check_lvm_mount_points(string mount)
+ {
+ list<string> not_allowed_lvm_mount_points = [ Partitions::BootMount() ];
+ y2milestone("check lvm mount");
+ if (contains(not_allowed_lvm_mount_points, mount))
{
- // error popup text
- Popup::Error(sformat(_("You cannot use the mount point \"%1\" for LVM.\n"), Partitions::BootMount()));
-
+ // error popup text
+ Popup::Error(sformat(_("You cannot use the mount point \"%1\" for LVM.\n"), Partitions::BootMount()));
return false;
}
- return true;
- };
+ return true;
+ }
/**
@@ -244,25 +52,22 @@
* @param mount mount point
* @return boolean
**/
-define boolean check_raid_mount_points( string mount )
- ``{
- list not_allowed_raid_mount_points = [ ];
- if( Arch::ppc () || Arch::s390 () || Arch::sparc () )
- {
- not_allowed_raid_mount_points =
- add( not_allowed_raid_mount_points, Partitions::BootMount() );
- }
- y2milestone( " check raid mount");
- if( contains( not_allowed_raid_mount_points, mount ))
+ boolean check_raid_mount_points(string mount)
+ {
+ list<string> not_allowed_raid_mount_points = [];
+ if (Arch::ppc() || Arch::s390())
+ {
+ not_allowed_raid_mount_points = add(not_allowed_raid_mount_points, Partitions::BootMount());
+ }
+ y2milestone("check raid mount");
+ if (contains( not_allowed_raid_mount_points, mount))
{
- // error popup text
+ // error popup text
Popup::Error(sformat(_("You cannot use the mount point %1 for RAID."), Partitions::BootMount()));
-
return false;
}
return true;
- };
-
+ }
/**
@@ -366,19 +171,19 @@
* @param mount mount point
* @return boolean
**/
-define boolean check_mount_point( map<string,map> targetMap, string dev,
- map part )
-{
+ boolean check_mount_point(map<string,map> targetMap, string dev, map part)
+ {
string mount = part["mount"]:"";
symbol used_fs = part["used_fs"]:`unknown;
y2milestone( "check_mount_point part:%1", part );
boolean allowed = true;
- list not_allowed_system_mount_points =
- [ "/proc", "/dev", "/mnt", "/var/adm/mnt", "/lost+found", "/lib",
- "/bin", "/etc", "/sbin" ];
- if (mount == "")
+ list<string> not_allowed_system_mount_points = [ "/proc", "/sys",
+ "/dev", "/mnt", "/var/adm/mnt", "/lost+found", "/lib", "/lib64",
+ "/bin", "/etc", "/sbin" ];
+
+ if (isempty(mount))
{
Popup::Error(_("Mount point must not be empty."));
allowed = false;
@@ -395,7 +200,7 @@
// error popup
Popup::Error(_("Only swap devices may have swap as mount point."));
}
- else if (mount != "swap" || part["type"]:`unknown == `loop)
+ else if (mount != "swap") // || part["type"]:`unknown == `loop)
{
// check if the mount point is already in use
foreach( string disk, map diskinfo, targetMap, ``{
@@ -408,7 +213,7 @@
});
});
- if( allowed == false && mount!="swap" )
+ if (allowed == false) // && mount!="swap" )
{
// error popup text
Popup::Error(_("This mount point is already in use. Select a different one."));
@@ -436,7 +241,8 @@
allowed = false;
// error popup text
Popup::Error(_("You cannot use any of the following mount points:
-/proc, /dev, /lib, /bin, /etc, /sbin, /mnt, /var/adm/mnt, /lost+found
+/bin, /dev, /etc, /lib, /lib64, /lost+found, /mnt, /proc, /sbin, /sys,
+/var/adm/mnt
"));
}
else if ( substring( mount, 0, 1 ) != "/" )
@@ -448,17 +254,7 @@
}
else if( !part["format"]:false && part["detected_fs"]:`none != `swap )
{
- // error popup text
-string message = _("
-WARNING:
-
-You chose a swap partition but did not direct YaST2 to format it.
-This swap partition will probably not be usable.
-
-Change the setup?
-");
-
- allowed = !Popup::YesNo(message);
+ allowed = false;
}
if( allowed )
@@ -568,113 +364,17 @@
define boolean EmptyCryptPwdAllowed( map p )
{
boolean ret = p["format"]:false &&
- contains( union(FileSystems::tmp_m_mpoint,["swap"]),
- p["mount"]:"" );
+ contains(union(FileSystems::tmp_m_points, FileSystems::swap_m_points), p["mount"]:"");
ret = ret && Storage::IsPersistent( p );
y2milestone( "EmptyCryptPwdAllowed ret:%1", ret );
return( ret );
}
-define boolean AskCryptPwd( map p )
- {
- /* boolean ret = p["mount"]:""!="swap" || !EmptyCryptPwdAllowed(p); */
- boolean ret = true;
- y2milestone( "AskCryptPwd ret:%1", ret );
- return( true );
- }
-
-
-/**
- * Do all checks concerning handling of crypt fs
- * @param new partition map
- * @return map
- **/
-define map CheckCryptOk( map new )
- ``{
- map ret = $[ "ok" : true ];
- boolean crypt_fs = false;
- if( UI::WidgetExists( `id(`crypt_fs) ))
- {
- crypt_fs = (boolean)UI::QueryWidget(`id(`crypt_fs), `Value );
- }
- if( crypt_fs )
- new["enc_type"] = new["format"]:false?`luks:`twofish;
- else
- new["enc_type"] = `none;
- if( crypt_fs && AskCryptPwd( new ) &&
- size(Storage::GetCryptPwd( new["device"]:"" ))==0 )
- {
- boolean tmpc = EmptyCryptPwdAllowed( new );
- string fs_passwd = DlgCreateCryptFs( new["device"]:"",
- new["format"]:false?8:1,
- new["format"]:false, tmpc );
- // Ask the user for a password for cryptofs, else set crypto to nil??
- if( fs_passwd != nil && size(fs_passwd)>0 )
- {
- string dev = new["device"]:"";
- boolean popup = !new["format"]:false;
- y2milestone( "CheckCryptOk dev %1 popup %2", dev, popup );
- if( popup )
- UI::OpenDialog( `opt(`decorated),
- `VBox(
- `VSpacing(1),
- `HBox(`HSpacing(1),
- `Label(_("Detecting encryption type...")),
- `HSpacing(1)),
- `VSpacing(1)));
-
- ret["ok"] = Storage::SetCryptPwd( dev, fs_passwd ) &&
- (new["format"]:false ||
- Storage::SetCrypt( dev, true, new["format"]:false ));
- if( popup )
- UI::CloseDialog();
- }
- else
- {
- ret["ok"] = tmpc;
- }
- }
- ret["map"] = new;
- y2milestone( "CheckCryptOk ret:%1", ret );
- return( ret );
- };
-
-define map CheckFormatOk( map new )
- ``{
- map ret = $[ "ok" : true ];
- if( new["format"]:false )
- {
- symbol ufs = new["used_fs"]:`unknown;
- y2milestone( "GetSupportFormat %1", FileSystems::GetSupportFormat(ufs));
- if( !FileSystems::GetSupportFormat(ufs) )
- {
- // Popup text
- string txt = sformat( "The file system of type %1 cannot be created.",
- FileSystems::GetName( ufs, "" ));
- Popup::Error(txt);
- ret["ok"] = false;
- }
- }
- ret["map"] = new;
- y2milestone( "CheckFormatOk ret:%1", ret["ok"]:false );
- return( ret );
- };
-
-define map CheckDeviceFinalOk( map new )
- ``{
- y2milestone( "CheckDeviceFinalOk new:%1", new );
- map ret = CheckFormatOk( new );
- if( ret["ok"]:false )
- {
- ret = CheckCryptOk( ret["map"]:$[] );
- }
- y2milestone( "CheckDeviceFinalOk ret:%1", ret );
- return( ret );
- }
-
map pkg_for_fs = $[
`ext2 : [ "e2fsprogs" ],
`ext3 : [ "e2fsprogs" ],
+ `ext4 : [ "e2fsprogs" ],
+ `btrfs : [ "btrfsprogs" ],
`reiser : [ "reiserfs" ],
`vfat : [ "dosfstools" ],
`ntfs : [ "ntfsprogs" ],
@@ -684,7 +384,7 @@
define map<string,any> HandleFsChanged( boolean init, map<string,any> new,
symbol old_fs, map file_systems )
``{
- boolean undo_change = false;
+ boolean apply_change = true;
list<string> not_used_mp = [];
symbol used_fs = new["used_fs"]:`unknown;
map selected_fs = file_systems[used_fs]:$[];
@@ -706,12 +406,12 @@
in the system. Do not file bugs against the file system
itself if it does not work properly or at all.
-Undo the change of file system?
+Really use this file system?
"), Product::name );
- undo_change = Popup::YesNo(message);
+ apply_change = Popup::YesNo(message);
}
- if( !undo_change && !Stage::initial() )
+ if( apply_change && !Stage::initial() )
{
if( size(pkg_for_fs[used_fs]:[])>0 )
{
@@ -719,19 +419,21 @@
y2milestone( "HandleFsChanged install %1 ret:%2",
pkg_for_fs[used_fs]:[], r );
if( !r )
- undo_change = true;
+ apply_change = false;
}
}
- if( undo_change )
+ if( !apply_change )
{
new["used_fs"] = old_fs;
UI::ChangeWidget(`id(`fs), `Value, old_fs );
}
}
- if( !undo_change && UI::WidgetExists( `id(`crypt_fs) ))
+ if( apply_change && UI::WidgetExists( `id(`crypt_fs)) )
{
- boolean cr = selected_fs[`crypt]:true;
+ boolean cr = selected_fs[`crypt]:true &&
+ new["type"]:`primary!=`btrfs;
+ y2milestone( "HandleFsChanged cr:%1", cr );
UI::ChangeWidget( `id(`crypt_fs), `Enabled, cr );
if( !cr )
@@ -741,7 +443,7 @@
}
}
- if( !undo_change )
+ if( apply_change )
{
////////////////////////////////////////////////
// switch between swap and other mountpoints
@@ -772,7 +474,7 @@
{
not_used_mp =
filter( string mp, not_used_mp,
- ``(!contains( FileSystems::system_m_points, mp)));
+ ``(!contains(FileSystems::system_m_points(), mp)));
}
if(mount == "swap")
new["mount"] = "";
@@ -788,9 +490,9 @@
string fstopt = FileSystems::DefaultFstabOptions( new );
if( size(fstopt)>0 && size(new["fstopt"]:"")==0 )
new["fstopt"] = fstopt;
- new["fs_options"] = FileSystems::DefaultFormatOptions(new);
if( !init )
{
+ new["fs_options"] = FileSystems::DefaultFormatOptions(new);
new["fstopt"] = fstopt;
integer max_len = FileSystems::LabelLength( used_fs );
@@ -819,7 +521,7 @@
map file_systems,
map<string,any> old,
map<string,any> new )
- ``{
+ {
y2milestone( "HandlePartWidgetChanges init:%1 ret:%2 new:%3",
init, ret, new );
symbol used_fs = new["used_fs"]:`unknown;
@@ -837,7 +539,7 @@
UI::WidgetExists( `id(`fstab_options) ))
{
string mp = (string)UI::QueryWidget(`id(`mount_point), `Value);
- UI::ChangeWidget( `id(`fstab_options), `Enabled, size(mp)>0 );
+ UI::ChangeWidget( `id(`fstab_options), `Enabled, !isempty(mp) );
}
if( (init && UI::WidgetExists( `id(`format))) ||
ret == `do_format || ret == `do_not_format)
@@ -850,25 +552,6 @@
// format partition
new["format"] = format;
- if( UI::WidgetExists( `id(`fs) ))
- {
- UI::ChangeWidget( `id(`fs), `Enabled, format );
- }
- if( UI::WidgetExists( `id(`fs_options) ))
- {
- UI::ChangeWidget( `id(`fs_options), `Enabled,
- format && selected_fs[`options]:[] != [] );
- }
- if( UI::WidgetExists( `id(`crypt_fs) ))
- {
- UI::ChangeWidget( `id(`crypt_fs), `Enabled,
- selected_fs[`crypt]:true );
- }
- if( UI::WidgetExists( `id(`fsid_point) ))
- {
- UI::ChangeWidget( `id(`fsid_point), `Enabled, !format);
- }
-
if( old_format != format )
{
symbol dfs = `unknown;
@@ -1029,6 +712,10 @@
new["mount"] = UI::QueryWidget( `id(`mount_point), `Value );
new = FstabOptions( old, new );
}
+ if( ret == `subvol )
+ {
+ new = SubvolHandling( old, new );
+ }
if( ret == `crypt_fs )
{
boolean val = (boolean)UI::QueryWidget( `id(`crypt_fs), `Value );
@@ -1049,125 +736,17 @@
}
if( Mode::repair () )
{
- UI::ChangeWidget(`id(`mount_point), `Enabled, false);
+ UI::ChangeWidget(`id(`do_mount), `Enabled, false);
+ UI::ChangeWidget(`id(`do_not_mount), `Enabled, false);
+ UI::ChangeWidget(`id(`do_mount_attachment), `Enabled, false);
UI::ChangeWidget(`id(`fstab_options), `Enabled, false);
UI::ChangeWidget(`id(`crypt_fs) , `Enabled, false);
}
y2milestone( "HandlePartWidgetChanges old:%1", old );
y2milestone( "HandlePartWidgetChanges new:%1", new );
return( new );
- };
-
-/**
- * Merge readed list fstab with targetMap
- * @parm targetMap all targets
- * @parm fstab readed fstab list
- * @return return ( [ targetMap, table_input ]
- *
- */
-define list AddFstabToData( map<string,map> targetMap, list<map> fstab )
- ``{
- if( fstab == nil )
- return [targetMap] ;
-
- y2milestone( "AddFstabToData fstab = %1", fstab );
-
- map new_targetMap = targetMap;
- map table_input = $["tbl":[]];
-
- foreach( string dev, map disk, targetMap,
- ``{
- list new_partitions = [];
- map target = disk;
- foreach( map partition, disk["partitions"]:[],
- ``{
- map new_partition = partition;
-
- foreach( map fstab_entry, fstab,
- ``{
- string dev_fstab = fstab_entry["device"]:"";
- string mount_fstab = fstab_entry["mount"]:"";
- boolean found = false;
-
- if( dev_fstab == partition["device"]:"" )
- {
- found = true;
- }
- if( found )
- {
- new_partition["mount"] = mount_fstab;
- if( size(fstab_entry["fstopt"]:"")>0 &&
- fstab_entry["fstopt"]:"" != "default" )
- {
- new_partition["fstopt"] = fstab_entry["fstopt"]:"";
- }
- if( fstab_entry["mountby"]:`device != `device )
- new_partition["mountby"] = fstab_entry["mountby"]:`device;
- if( fstab_entry["enc_type"]:`none != `none )
- new_partition["enc_type"] = fstab_entry["enc_type"]:`none;
-
- /////////////////////////////////////////////
- // entries for table
- term a = `item(`id(dev_fstab));
- a = add( a, dev_fstab );
- a = add( a, mount_fstab );
- if( mount_fstab=="/" )
- {
- table_input["root"] = dev_fstab;
- }
- table_input["tbl"] = add( table_input["tbl"]:[], a );
- }
- });
- new_partitions = add( new_partitions, new_partition);
- });
- target["partitions"] = new_partitions;
- new_targetMap[dev] = target;
- });
-
- y2milestone( "AddFstabToData table_input %1", table_input );
- y2milestone( "AddFstabToData tbl %1", table_input["tbl"]:[] );
-
- if( size( table_input["tbl"]:[] )>1 )
- {
- table_input["tbl"] = sort( term a, term b, table_input["tbl"]:[],
- ``(a[2]:""<b[2]:""));
- }
- y2milestone( "AddFstabToData ret %1", [ new_targetMap, table_input ] );
-
- return [ new_targetMap, table_input ];
- };
-
-define boolean check_max_size( integer byte_size, integer max_size )
- ``{
- y2milestone( "icheck_lv_size byte_size=%1 max_size=%2", byte_size,
- max_size );
-
- if( byte_size == 0 )
- {
- if( max_size>0 )
- // error popup text
- Popup::Error(sformat(_("The size entered is invalid.
-Enter a size from 1M to %1. For example, 40M or 1G."),
- Storage::ByteToHumanString(max_size)) );
- else
- // error popup text
- Popup::Error(_("The size entered is invalid.
-Enter a valid size, such as 500k, 40M, or 1G.
-"));
- return( false );
- }
-
- if( max_size>0 && byte_size>max_size )
- {
- // error popup text
- Popup::Error(sformat(_("The size entered is too large.
-Enter a size from 1M to %1."),
- Storage::ByteToHumanString(max_size)) );
- return( false );
- }
+ }
- return( true );
- };
define boolean CheckResizePossible( boolean ask, boolean lvm, integer resize,
symbol fsys, string mount )
Modified: branches/SuSE-Code-11-SP2-Branch/storage/storage/src/include/ep-all.ycp
URL: http://svn.opensuse.org/viewcvs/yast/branches/SuSE-Code-11-SP2-Branch/stora…
==============================================================================
--- branches/SuSE-Code-11-SP2-Branch/storage/storage/src/include/ep-all.ycp (original)
+++ branches/SuSE-Code-11-SP2-Branch/storage/storage/src/include/ep-all.ycp Tue May 17 13:39:44 2011
@@ -3,13 +3,30 @@
* Package: yast2-storage
* Summary: Expert Partitioner
* Authors: Arvin Schnell <aschnell(a)suse.de>
+ *
+ * This file must only be included in other Expert Partitioner files ("ep-*.ycp").
*/
{
textdomain "storage";
+ import "PackageCallbacks";
+ import "PackageSystem";
+
void CreateAllPanel(any user_data)
{
+
+ boolean IsAvailable ( string client )
+ {
+ //in the installed system, we don't care if the client isn't there
+ //as the user will be prompted to install the pkg anyway (in CallConfig)
+ if ( !Stage::initial() )
+ return true;
+ //check if the client is in inst-sys
+ else
+ return WFM::ClientExists(client);
+ }
+
string short_hostname = Hostname::CurrentHostname();
list<symbol> fields = StorageSettings::FilterTable([ `device, `udev_path, `udev_id, `size, `format,
@@ -21,20 +38,53 @@
term table_header = StorageFields::TableHeader(fields);
list<term> table_contents = StorageFields::TableContents(fields, target_map, StorageFields::PredicateAll);
- term buttons = `HBox();
+ term buttons = `HBox(
+ // push button text
+ `PushButton(`id(`rescan), `opt(`key_F6), _("Rescan Devices"))
+ );
if (Mode::installation()) {
// push button text
buttons = add(buttons, `PushButton(`id(`import), _("Import Mount Points...")));
- buttons = add(buttons, `HStretch());
}
+ buttons = add(buttons, `HStretch());
+
+ list<term> configs = [];
+
+ if (IsAvailable("iscsi-client")) {
+ // menu entry text
+ configs = add(configs, `item(`id(`iscsi), `icon("yast-iscsi-client"), _("Configure &iSCSI...")));
+ }
+
+ if (true) {
+ // menu entry text
+ configs = add(configs, `item(`id(`multipath), `icon("yast-iscsi-server"), _("Configure &Multipath...")));
+ // menu entry text
+ configs = add(configs, `item(`id(`cryptpwd), `icon("yast-encrypted"), _("Provide Crypt &Passwords...")));
+ }
+
+ if (Arch::s390() && IsAvailable("s390")) {
+ // menu entry text
+ configs = add(configs, `item(`id(`dasd), `icon("yast-dasd"), _("Configure &DASD...")));
+ // menu entry text
+ configs = add(configs, `item(`id(`zfcp), `icon("yast-zfcp"), _("Configure &zFCP...")));
+ // menu entry text
+ configs = add(configs, `item(`id(`xpram), `icon("yast-xpram"), _("Configure &XPRAM...")));
+ }
+
+ if (!isempty(configs)) {
+ // menu button text
+ buttons = add(buttons, `MenuButton(`opt(`key_F7), _("Configure..."), configs));
+ }
+
+
UI::ReplaceWidget(`tree_panel,
Greasemonkey::Transform(
`VBox(
// dialog heading, %1 is replaced with hostname
- `IconAndHeading(sformat(_("Available Storage on %1"), short_hostname), all_icon),
- `Table(`id(`table), `opt(`keepSorting, `notify),
+ `IconAndHeading(sformat(_("Available Storage on %1"), short_hostname), StorageIcons::all_icon),
+ `Table(`id(`table), `opt(`keepSorting, `notify, `notifyContextMenu),
table_header, table_contents),
buttons
))
@@ -64,10 +114,57 @@
}
- void HandleAllPanel(any user_data, symbol widget)
+ void HandleAllPanel(any user_data, map event)
{
- switch (widget)
+
+ boolean CheckAndInstallPackages( list <string> pkgs )
+ {
+ if (Stage::initial())
+ return true;
+
+ boolean ret = false;
+ //switch off pkg-mgmt loading progress dialogs,
+ //because it just plain sucks
+ PackageCallbacks::RegisterEmptyProgressCallbacks();
+ ret = PackageSystem::CheckAndInstallPackages(pkgs);
+ PackageCallbacks::RestorePreviousProgressCallbacks();
+
+ return ret;
+ }
+
+ void CallConfig(string text, list<string> pkgs, string call)
+ {
+ boolean doit = true;
+
+ if (!Storage::EqualBackupStates("expert-partitioner", "", true))
+ {
+ doit = Popup::YesNo(text);
+ }
+
+ if (doit)
+ {
+ if (pkgs == nil || CheckAndInstallPackages(pkgs))
+ {
+ if (call != nil)
+ WFM::call(call);
+ RescanDisks();
+ Storage::CreateTargetBackup("expert-partitioner");
+
+ UpdateMainStatus();
+ UpdateNavigationTree(nil);
+ TreePanel::Create();
+ }
+ }
+ }
+
+ switch (Event::IsWidgetActivated(event))
{
+ case `rescan:
+ // popup text
+ CallConfig(_("Rescaning disks cancels all current changes.
+Really rescan disks?"), nil, nil);
+ break;
+
case `import:
ImportMountPoints();
@@ -76,5 +173,61 @@
TreePanel::Create();
break;
}
+
+ switch (Event::IsMenu(event))
+ {
+ case `iscsi:
+ // popup text
+ CallConfig(_("Calling iSCSI configuration cancels all current changes.
+Really call iSCSI configuration?"), ["yast2-iscsi-client"], "iscsi-client");
+ break;
+
+ case `multipath:
+ if ((ProductFeatures::GetBooleanFeature("partitioning", "use_separate_multipath_module") == true) ||
+ (Mode::normal() && WFM::ClientExists("multipath")))
+ // popup text
+ CallConfig(_("Calling Multipath configuration cancels all current changes.
+Really call Multipath configuration?"), ["yast2-multipath"], "multipath");
+ else
+ // popup text
+ CallConfig(_("Calling Multipath configuration cancels all current changes.
+Really call Multipath configuration?"), nil, "multipath-simple");
+ break;
+
+ case `cryptpwd:
+ map<string,map> tg = Storage::GetTargetMap();
+ tg = Storage::AskCryptPasswords( tg );
+ Storage::SetTargetMap(tg);
+ UpdateMainStatus();
+ UpdateNavigationTree(nil);
+ TreePanel::Create();
+ break;
+
+ case `dasd:
+ // popup text
+ CallConfig(_("Calling DASD configuration cancels all current changes.
+Really call DASD configuration?"), ["yast2-s390"], "dasd");
+ break;
+
+ case `zfcp:
+ // popup text
+ CallConfig(_("Calling zFCP configuration cancels all current changes.
+Really call zFCP configuration?"), ["yast2-s390"], "zfcp");
+ break;
+
+ case `xpram:
+ // popup text
+ CallConfig(_("Calling XPRAM configuration cancels all current changes.
+Really call XPRAM configuration?"), ["yast2-s390"], "xpram");
+ break;
+ }
+
+ switch (Event::IsWidgetContextMenuActivated(event))
+ {
+ case `table:
+ string device = (string) UI::QueryWidget(`id(`table), `CurrentItem);
+ EpContextMenuDevice(device);
+ break;
+ }
}
}
Added: branches/SuSE-Code-11-SP2-Branch/storage/storage/src/include/ep-btrfs-dialogs.ycp
URL: http://svn.opensuse.org/viewcvs/yast/branches/SuSE-Code-11-SP2-Branch/stora…
==============================================================================
--- branches/SuSE-Code-11-SP2-Branch/storage/storage/src/include/ep-btrfs-dialogs.ycp (added)
+++ branches/SuSE-Code-11-SP2-Branch/storage/storage/src/include/ep-btrfs-dialogs.ycp Tue May 17 13:39:44 2011
@@ -0,0 +1,212 @@
+/**
+ * File: ep-btrfs-dialogs.ycp
+ * Package: yast2-storage
+ * Summary: Expert Partitioner
+ * Authors: Thomas Fehr <fehr(a)suse.de>
+ *
+ * This file must only be included in other Expert Partitioner files ("ep-*.ycp").
+ */
+{
+ textdomain "storage";
+
+
+ boolean DlgEditBtrfsVolume(map<string, any> &data)
+ {
+ y2milestone( "DlgEditBtrfsVolume %1", data );
+ string device = data["device"]:"error";
+
+ map<string, any> aliases = $[
+ "FormatMount" : ``(MiniWorkflowStepFormatMount(data)),
+ "Password" : ``(MiniWorkflowStepPassword(data))
+ ];
+
+ map<string, any> sequence = $[
+ "FormatMount" : $[ `next : "Password",
+ `finish : `finish ],
+ "Password" : $[ `finish : `finish ]
+ ];
+
+ // dialog title
+ string title = sformat(_("Edit Btrfs %1"), data["uuid"]:"");
+
+ symbol widget = MiniWorkflow::Run(title, StorageIcons::lvm_lv_icon, aliases, sequence, "FormatMount");
+
+ return widget == `finish;
+ }
+
+ /////////////////////////////////////////////////////////////////
+ // Get all volumes, we can probably use as volumes in an BTRFS
+ // Add needed information: disksize
+ define list<map> GetPossibleVols( map<string,map> targetMap )
+ {
+ list<map> ret = [];
+
+ //////////////////////////////////////////////////////////////////////
+ // add the devicename i.e /dev/hda1 or /dev/system/usr to partition list
+
+ targetMap = mapmap( string dev, map devmap, targetMap,
+ {
+ list partitions = maplist( map part, devmap["partitions"]:[],
+ {
+ part["maindev"] = dev;
+ return( part );
+ });
+ return( $[ dev: add(devmap, "partitions", partitions) ] );
+ });
+
+ ////////////////////////////////////////////////////////////
+ // Look for all partitions:
+ // no mountpoint
+ // id 0x83
+
+ list types_no = [ `btrfs, `extended ];
+ list types_ok = [ `sw_raid, `dm, `lvm ];
+ list fsids = [ Partitions::fsid_native, Partitions::fsid_lvm, Partitions::fsid_raid ];
+ list allowed_enc_types = [ `none ];
+
+ foreach( string dev, map devmap, targetMap,
+ ``{
+ y2milestone( "GetPossibleVols parts:%1", devmap["partitions"]:[] );
+ list<map> parts =
+ filter( map part, devmap["partitions"]:[],
+ ``( size(part["mount"]:"")==0 &&
+ !contains( types_no, part["type"]:`primary ) &&
+ contains(allowed_enc_types, part["enc_type"]:`none) &&
+ (!Storage::IsUsedBy(part) || part["used_by_type"]:`UB_NONE==`UB_BTRFS) &&
+ (contains( types_ok, part["type"]:`primary ) ||
+ contains( fsids, part["fsid"]:0 ))));
+ y2milestone( "GetPossibleVols filter:%1", parts );
+ if( devmap["used_by_type"]:`UB_NONE!=`UB_NONE )
+ {
+ parts = [];
+ y2milestone( "GetPossibleVols no parts, disk used by %1 %2",
+ devmap["used_by_type"]:`UB_NONE, devmap["used_by_device"]:"" );
+ }
+ /* currently disallow usage of whole disk devices as parts of BTRFS volumes
+ if( size(devmap["partitions"]:[])==0 &&
+ Storage::IsPartType(devmap["type"]:`CT_UNKNOWN) &&
+ (!Storage::IsUsedBy(devmap) || devmap["used_by_type"]:`UB_NONE==`UB_LVM))
+ {
+ map p = $[ "device":dev, "maindev":dev,
+ "size_k":devmap["size_k"]:0 ];
+ if( devmap["used_by_type"]:`UB_NONE != `UB_NONE )
+ {
+ p["used_by_type"] = devmap["used_by_type"]:`UB_NONE;
+ p["used_by_device"] = devmap["used_by_device"]:"";
+ }
+ parts = [ p ];
+ }
+ */
+ ret = (list<map>)merge( ret, parts );
+ });
+ y2milestone( "GetPossibleVols ret %1", ret );
+ return( ret );
+ }
+
+ boolean CheckNumberOfDevicesForVolume(integer num)
+ {
+ if (num < 1)
+ {
+ // error popup
+ Popup::Error(sformat(_("Select at least one device.")));
+ UI::SetFocus(`id(`unselected));
+ return false;
+ }
+ else
+ {
+ return true;
+ }
+ }
+
+ string MiniWorkflowStepResizeVolumeHelptext()
+ {
+ // helptext
+ string helptext = _("<p>Change the devices that are used by the BTRFS volume.</p>");
+
+ return helptext;
+ }
+
+
+ symbol MiniWorkflowStepResizeVolume(map<string, any> &data)
+ {
+ y2milestone("MiniWorkflowStepResizeVolume data:%1", data);
+
+ string vgname = data["name"]:"error";
+ list<string> pvs_new = [];
+
+ list<symbol> fields = StorageSettings::FilterTable([ `device, `udev_path, `udev_id, `size, `encrypted, `type ]);
+
+ map<string, map> target_map = Storage::GetTargetMap();
+ list<map> unused_pvs = filter(map pv, GetPossibleVols(target_map), { return !Storage::IsUsedBy(pv); });
+ list<map> used_pvs = filter(map pv, GetPossibleVols(target_map), { return pv["used_by_device"]:"" == data["uuid"]:""; });
+
+ term contents = `VBox();
+
+ contents = add(contents, DevicesSelectionBox::Create(unused_pvs, used_pvs, fields, nil,
+ _("Unused Devices:"),
+ _("Selected Devices:")));
+
+ MiniWorkflow::SetContents(Greasemonkey::Transform(contents), MiniWorkflowStepResizeVolumeHelptext());
+ MiniWorkflow::SetLastStep(true);
+
+ symbol widget = nil;
+
+ repeat
+ {
+ widget = MiniWorkflow::UserInput();
+ DevicesSelectionBox::Handle(widget);
+
+ switch (widget)
+ {
+ case `next:
+ {
+ pvs_new = maplist(map pv, DevicesSelectionBox::GetSelectedDevices(), {
+ return pv["device"]:"";
+ });
+
+ if (!CheckNumberOfDevicesForVolume(size(pvs_new)))
+ widget = `again;
+
+ // TODO: overall size check
+ }
+ break;
+ }
+ }
+ until (widget == `abort || widget == `back || widget == `next);
+
+ if (widget == `next)
+ {
+ data["devices_new"] = pvs_new;
+
+ widget = `finish;
+ }
+
+ y2milestone("MiniWorkflowStepResizeVg data:%1 ret:%2", data, widget);
+
+ return widget;
+ }
+
+
+ boolean DlgResizeBtrfsVolume(map<string, any> &data, symbol() Commit)
+ {
+ map<string, any> aliases = $[
+ "TheOne" : ``(MiniWorkflowStepResizeVolume(data)),
+ "Commit" : ``(Commit())
+ ];
+
+ map<string, any> sequence = $[
+ "TheOne" : $[ `finish : "Commit" ],
+ "Commit" : $[ `finish : `finish ]
+ ];
+
+ y2milestone( "data:%1", data );
+
+ // dialog title
+ string title = sformat(_("Resize Btrfs Volume %1"), data["uuid"]:"error");
+
+ symbol widget = MiniWorkflow::Run(title, StorageIcons::lvm_icon, aliases, sequence, "TheOne");
+
+ return widget == `finish;
+ }
+
+}
Added: branches/SuSE-Code-11-SP2-Branch/storage/storage/src/include/ep-btrfs-lib.ycp
URL: http://svn.opensuse.org/viewcvs/yast/branches/SuSE-Code-11-SP2-Branch/stora…
==============================================================================
--- branches/SuSE-Code-11-SP2-Branch/storage/storage/src/include/ep-btrfs-lib.ycp (added)
+++ branches/SuSE-Code-11-SP2-Branch/storage/storage/src/include/ep-btrfs-lib.ycp Tue May 17 13:39:44 2011
@@ -0,0 +1,149 @@
+/**
+ * File: ep-btrfs-lib.ycp
+ * Package: yast2-storage
+ * Summary: Expert Partitioner
+ * Authors: Thomas Fehr <fehr(a)suse.de>
+ *
+ * This file must only be included in other Expert Partitioner files ("ep-*.ycp").
+ */
+{
+ textdomain "storage";
+
+
+void EpEditBtrfsDevice(string device)
+ {
+ if (device == nil)
+ {
+ // error popup
+ Popup::Error(_("No BTRFS device selected."));
+ return;
+ }
+
+ map<string, map> target_map = Storage::GetTargetMap();
+ map<string, any> data = Storage::GetPartition(target_map, device);
+ y2milestone( "EpEditBtrfsDevice device:%1 data:%2", device, data );
+
+ if (Storage::IsUsedBy(data))
+ {
+ // error popup
+ Popup::Error(sformat(_("The Btrfs %1 is in use. It cannot be
+edited. To edit %1, make sure it is not used."), data["uuid"]:""));
+ return;
+ }
+
+ if (DlgEditBtrfsVolume(data))
+ {
+ Storage::ChangeVolumeProperties(data);
+
+ UpdateMainStatus();
+ UpdateNavigationTree(nil);
+ TreePanel::Create();
+ UpdateTableFocus(device);
+ }
+ }
+
+void EpDeleteBtrfsDevice(string device)
+ {
+ if (device == nil)
+ {
+ // error popup
+ Popup::Error(_("No BTRFS device selected."));
+ return;
+ }
+
+ map<string, map> target_map = Storage::GetTargetMap();
+ map<string, any> data = Storage::GetPartition(target_map, device);
+ y2milestone( "EpDeletBtrfsDevice device:%1 data:%2", device, data );
+
+ if (!Storage::CanDelete(data, target_map["/dev/btrfs"]:$[], true))
+ return;
+
+ if (EpDeleteDevice(device))
+ {
+ any new_focus = nil;
+ if (UI::QueryWidget(`tree, `CurrentItem) == device)
+ new_focus = `md;
+ UpdateMainStatus();
+ UpdateNavigationTree(new_focus);
+ TreePanel::Create();
+ }
+ }
+
+boolean AddVols(string device, list<string> devs)
+ {
+ boolean ret = true;
+
+ foreach(string dev, devs, {
+ Storage::SetPartitionId(dev, Partitions::fsid_native);
+ Storage::SetPartitionFormat(dev, false, `none);
+ if (!Storage::ExtendBtrfsVolume(device, dev))
+ ret = false;
+ });
+ return ret;
+ }
+
+
+boolean RemoveVols(string device, list<string> devs)
+ {
+ boolean ret = true;
+
+ foreach(string dev, devs, {
+ Storage::UnchangePartitionId(dev);
+ if (!Storage::ReduceBtrfsVolume(device, dev))
+ ret = false;
+ });
+ return ret;
+ }
+
+void EpResizeBtrfsDevice(string device)
+ {
+ if (device == nil)
+ {
+ // error popup
+ Popup::Error(_("No BTRFS device selected."));
+ return;
+ }
+
+ map<string, map> target_map = Storage::GetTargetMap();
+ map<string, any> data = Storage::GetPartition(target_map, device);
+ y2milestone( "EpResizeBtrfsDevice device:%1 data:%2", device, data );
+
+ symbol Commit()
+ {
+ list<string> devices_old = MergeDevices(data);
+ list<string> devices_new = data["devices_new"]:[];
+
+ list<string> devices_added = AddedToList(devices_old, devices_new);
+ list<string> devices_removed = RemovedFromList(devices_old, devices_new);
+
+ if(size(devices_added)>0)
+ y2milestone("EpResizeBtrfsDevice device_added:%1", devices_added );
+ if(size(devices_removed)>0)
+ y2milestone("EpResizeBtrfsDevice device_removed:%1", devices_removed );
+
+ if( size(devices_added) > 0 || size(devices_removed) > 0)
+ {
+ AddVols(device, devices_added);
+
+ if (!RemoveVols(device, devices_removed))
+ {
+ // error popup
+ Popup::Error(_("Failed to remove some physical devices."));
+
+ // TODO: update data
+
+ return `back;
+ }
+ }
+
+ return `finish;
+ }
+
+ if( DlgResizeBtrfsVolume(data, Commit))
+ {
+ UpdateMainStatus();
+ UpdateNavigationTree(nil);
+ TreePanel::Create();
+ }
+ }
+}
Added: branches/SuSE-Code-11-SP2-Branch/storage/storage/src/include/ep-btrfs.ycp
URL: http://svn.opensuse.org/viewcvs/yast/branches/SuSE-Code-11-SP2-Branch/stora…
==============================================================================
--- branches/SuSE-Code-11-SP2-Branch/storage/storage/src/include/ep-btrfs.ycp (added)
+++ branches/SuSE-Code-11-SP2-Branch/storage/storage/src/include/ep-btrfs.ycp Tue May 17 13:39:44 2011
@@ -0,0 +1,233 @@
+/**
+ * File: ep-btrfs.ycp
+ * Package: yast2-storage
+ * Summary: Expert Partitioner
+ * Authors: Thomas Fehr <fehr(a)suse.de>
+ *
+ * This file must only be included in other Expert Partitioner files ("ep-*.ycp").
+ */
+{
+ textdomain "storage";
+
+ include "partitioning/ep-btrfs-dialogs.ycp";
+ include "partitioning/ep-btrfs-lib.ycp";
+
+
+ void EpContextMenuBtrfs(string device)
+ {
+ symbol widget = ContextMenu::Simple([ `item(`id(`edit), _("Edit")),
+ `item(`id(`delete), _("Delete")),
+ `item(`id(`resize), _("Resize"))]);
+
+ switch (widget)
+ {
+ case `edit:
+ EpEditBtrfsDevice(device);
+ break;
+ case `delete:
+ EpDeleteBtrfsDevice(device);
+ break;
+ case `resize:
+ EpResizeBtrfsDevice(device);
+ break;
+ }
+ }
+
+ void HandleBtrfsButtons( any user_data, string device, map event )
+ {
+ y2milestone( "HandleBtrfsButtons device:%1 user_data:%2 event:%3",
+ device, event, user_data );
+ string disk_device = "";
+
+ if (user_data == nil)
+ {
+ map disk = nil;
+ map part = nil;
+
+ map<string, map> target_map = Storage::GetTargetMap();
+ SplitDevice(target_map, device, disk, part);
+ disk_device = (string) disk["device"]:"";
+ }
+ else
+ {
+ disk_device = (string) user_data;
+ }
+
+ switch (Event::IsWidgetActivated(event))
+ {
+ case `edit:
+ EpEditBtrfsDevice(device);
+ break;
+
+ case `resize:
+ EpResizeBtrfsDevice(device);
+ break;
+ }
+ }
+
+ void CreateBtrfsMainPanel(any user_data)
+ {
+ list<symbol> fields = StorageSettings::FilterTable([ `device, `size, `format, `encrypted, `type,
+ `fs_type, `label, `mount_point, `mount_by ]);
+
+ map<string, map> target_map = Storage::GetTargetMap();
+ term table_header = StorageFields::TableHeader(fields);
+ list<term> table_contents = StorageFields::TableContents(fields, target_map, StorageFields::PredicateBtrfs);
+ UI::ReplaceWidget(`tree_panel,
+ Greasemonkey::Transform(
+ `VBox(
+ `HStretch(),
+ // heading
+ `IconAndHeading(_("Btrfs Volumes (BTRFS)"), StorageIcons::dm_icon ),
+ `Table(`id(`table), `opt(`keepSorting, `notify, `notifyContextMenu),
+ table_header, table_contents),
+ ArrangeButtons([ // push button text
+ `PushButton(`id(`edit),`opt(`key_F4), _("Edit...")),
+ // push button text
+ `PushButton(`id(`resize),`opt(`key_F8), _("Resize...")),
+ `HStretch() ])
+ )
+ ));
+
+ // helptext
+ string helptext = _("<p>This view shows all BTRFS volumes.</p>");
+
+ Wizard::RestoreHelp(helptext + StorageFields::TableHelptext(fields));
+ }
+
+ void HandleBtrfsMainPanel(any user_data, map event)
+ {
+ string device = (string) UI::QueryWidget(`id(`table), `CurrentItem);
+ HandleBtrfsButtons( user_data, device, event );
+ switch (Event::IsWidgetContextMenuActivated(event))
+ {
+ case `table:
+ EpContextMenuDevice(device);
+ break;
+ }
+ UI::SetFocus(`id(`table));
+ }
+
+
+ void CreateBtrfsOverviewTab(any user_data)
+ {
+ string device = (string) user_data;
+ y2milestone( "CreateBtrfsOverviewTab user_data:%1", user_data );
+
+ map<string, map> target_map = Storage::GetTargetMap();
+
+ list<symbol> fields = StorageSettings::FilterOverview([ `heading_device, `device, `size, `used_by,
+ `heading_filesystem, `fs_type, `mount_point,
+ `mount_by, `uuid, `label ]);
+
+ UI::ReplaceWidget(`tab_panel,
+ Greasemonkey::Transform(
+ `VBox(
+ StorageFields::Overview(fields, target_map, device),
+ `HBox(
+ // push button text
+ `PushButton(`id(`edit), _("Edit...")),
+ `HStretch()
+ )
+ )
+ )
+ );
+
+ // helptext
+ string helptext = _("<p>This view shows detailed information about the
+selected BTRFS volume.</p>");
+
+ Wizard::RestoreHelp(helptext + StorageFields::OverviewHelptext(fields));
+ }
+
+
+ void HandleBtrfsOverviewTab(any user_data, map event)
+ {
+ string device = (string) user_data;
+ y2milestone( "HandleBtrfsOverviewTab user_data:%1", user_data );
+
+ switch (Event::IsWidgetActivated(event))
+ {
+ case `edit:
+ EpEditBtrfsDevice(device);
+ break;
+ case `delete:
+ EpDeleteBtrfsDevice(device);
+ break;
+ case `resize:
+ EpResizeBtrfsDevice(device);
+ break;
+ }
+ }
+
+
+ void CreateBtrfsDevicesTab(any user_data)
+ {
+ string part_device = (string) user_data;
+ integer pos = search( part_device, "=" );
+ if( pos != nil )
+ part_device = substring( part_device, pos+1 );
+ y2milestone( "CreateBtrfsDevicesTab user_data:%1 part_device:%2", user_data, part_device );
+
+ symbol Predicate(map disk, map partition)
+ {
+ return StorageFields::PredicateUsedByDevice(disk, partition, [ part_device ]);
+ }
+
+ list<symbol> fields = StorageSettings::FilterTable([ `device, `udev_path, `udev_id, `size,
+ `format, `encrypted, `type ]);
+
+ map<string, map> target_map = Storage::GetTargetMap();
+
+ term table_header = StorageFields::TableHeader(fields);
+ list<term> table_contents = StorageFields::TableContents(fields, target_map, Predicate);
+
+ UI::ReplaceWidget(`tab_panel,
+ `VBox(
+ `Table(`id(`table), `opt(`keepSorting, `notify),
+ table_header, table_contents)
+ )
+ );
+
+ // helptext
+ string helptext = _("<p>This view shows all devices used by the
+selected BTRFS volume.</p>");
+
+ Wizard::RestoreHelp(helptext + StorageFields::TableHelptext(fields));
+ }
+
+
+ void CreateBtrfsPanel(any user_data)
+ {
+ string device = (string) user_data;
+ y2milestone( "CreateBtrfsPanel user_data:%1 device:%2", user_data, device );
+
+ map<symbol, map> data = $[ `overview : $[ `create : CreateBtrfsOverviewTab, `handle : HandleBtrfsOverviewTab, `user_data : user_data ],
+ `devices : $[ `create : CreateBtrfsDevicesTab, `user_data : user_data ] ];
+
+ UI::ReplaceWidget(`tree_panel,
+ Greasemonkey::Transform(
+ `VBox(
+ // heading
+ `IconAndHeading(sformat(_("Btrfs Device: %1"), device), StorageIcons::lvm_lv_icon),
+ `DumbTab(`id(`tab), [
+ // push button text
+ `item(`id(`overview), _("&Overview")),
+ // push button text
+ `item(`id(`devices), _("&Used Devices"))
+ ],
+ `ReplacePoint(`id(`tab_panel), TabPanel::empty_panel)
+ )
+ )
+ )
+ );
+
+ TabPanel::Init(data, `overview);
+ }
+
+
+ void HandleBtrfsPanel(any user_data, map event)
+ {
+ TabPanel::Handle(event);
+ }
+}
Modified: branches/SuSE-Code-11-SP2-Branch/storage/storage/src/include/ep-dialogs.ycp
URL: http://svn.opensuse.org/viewcvs/yast/branches/SuSE-Code-11-SP2-Branch/stora…
==============================================================================
--- branches/SuSE-Code-11-SP2-Branch/storage/storage/src/include/ep-dialogs.ycp (original)
+++ branches/SuSE-Code-11-SP2-Branch/storage/storage/src/include/ep-dialogs.ycp Tue May 17 13:39:44 2011
@@ -3,11 +3,15 @@
* Package: yast2-storage
* Summary: Expert Partitioner
* Authors: Arvin Schnell <aschnell(a)suse.de>
+ *
+ * This file must only be included in other Expert Partitioner files ("ep-*.ycp").
*/
{
+ textdomain "storage";
+
+
include "partitioning/custom_part_lib.ycp";
- textdomain "storage";
string MiniWorkflowStepFormatMountHelptext()
{
@@ -16,7 +20,8 @@
formatted and the desired file system type.</p>");
// helptext
- helptext = helptext + _("<p>Changing the encryption on an existing
+ helptext = helptext + _("<p>If you want to encrypt all data on the
+volume select <b>Encrypt device</b>. Changing the encryption on an existing
volume will delete all data on it.</p>");
// helptext
@@ -34,6 +39,21 @@
//retrieve all filesystems
map<symbol, map<symbol, any> > all_filesystems = FileSystems::GetAllFileSystems(true, true);
+ if( data["type"]:`primary==`btrfs )
+ {
+ // multi volume btrfs filesystem can only be formatted as btrfs
+ all_filesystems = (map<symbol, map<symbol, any> >)filter( symbol s, map p, all_filesystems, ``(s==`btrfs) );
+ }
+ if( data["type"]:`primary==`tmpfs )
+ {
+ all_filesystems[`tmpfs] = FileSystems::GetTmpfsFilesystem();
+ }
+
+ void ChangeWidgetIfExists( symbol wid, symbol property, any value)
+ {
+ if ( UI::WidgetExists(`id(wid)) )
+ UI::ChangeWidget(`id(wid), property, value);
+ }
list <string> ProposeMountpoints( symbol used_fs, string current_mp )
{
@@ -53,34 +73,41 @@
}
}
+ // disable Options p.b. if no fs options can be set
+ // disable Encrypt box if fs doesn't support encryption
+ void EnableDisableFsOpts( symbol used_fs )
+ {
+ map <symbol, any> fs_data = all_filesystems[used_fs]: $[];
+ ChangeWidgetIfExists(`fs_options, `Enabled, fs_data[`options]:[] != []);
+ ChangeWidgetIfExists(`crypt_fs, `Enabled,
+ fs_data[`crypt]:true&&data["type"]:`primary!=`btrfs);
+ }
boolean do_format = data["format"]:false;
symbol used_fs = data["used_fs"]:`unknown;
symbol default_crypt_fs = data["type"]:`unknown == `loop ? `luks : `none;
boolean crypt_fs = data["enc_type"]:default_crypt_fs != `none;
+ boolean orig_crypt_fs = crypt_fs;
string mount = data["mount"]:"";
boolean do_mount = mount != "";
-
-
- // returns true also when password can be omitted (e.g. encrypted swap)
- boolean NeedPassword()
- {
- return crypt_fs;
- }
+ if( data["type"]:`unknown == `loop || data["type"]:`unknown == `tmpfs)
+ do_mount = true;
boolean AskPassword()
{
- boolean ret = NeedPassword();
- if( ret && !do_format /*&& size(data["mount"]:"")>0*/ )
+ y2milestone( "AskPassword data:%1", data );
+ boolean ret = crypt_fs;
+ if( ret )
+ ret = do_format || orig_crypt_fs!=crypt_fs || do_mount;
+ if( ret && !do_format )
{
string key = (data["type"]:`unknown != `loop) ? (data["device"]:"error") : (data["fpath"]:"error");
ret = Storage::NeedCryptPwd(key);
}
- return ret;
+ return( ret );
}
-
/* MiniWorkflowStepPartitionSize data:
$["create":true,
"cyl_size":8225280,
@@ -115,7 +142,7 @@
mount = mount_point_proposal;
do_mount = mount != "";
- if (data["type"]:`unknown == `loop)
+ if (data["type"]:`unknown == `loop || data["type"]:`unknown == `tmpfs)
do_mount = true;
}
@@ -128,26 +155,44 @@
);
}
+ term fmt = `Empty();
+ if( data["type"]:`none != `tmpfs )
+ {
+ fmt = `FrameWithMarginBox( _("Formatting Options"),
+ `RadioButtonGroup(`id(`format),
+ `VBox(
+ `LeftRadioButtonWithAttachment(`id(`do_format), `opt(`notify),
+ _("Format partition"),
+ `VBox(`id(`do_format_attachment),
+ FileSystemsComboBox(data, all_filesystems)
+ )),
+ `VSpacing(0.45),
+ `LeftRadioButtonWithAttachment(`id(`do_not_format), `opt(`notify),
+ _("Do not format partition"), tmp1),
+ `VSpacing(0.45),
+ CryptButton(data)
+ )));
+ }
+
+ term notmnt = `Empty();
+ if( data["type"]:`none != `tmpfs )
+ {
+ notmnt = `LeftRadioButton(`id(`do_not_mount), `opt(`notify),
+ _("Do not mount partition"));
+ }
+
+ term subvol = `Empty();
+ if( data["used_fs"]:`unknown==`btrfs )
+ {
+ subvol = `FrameWithMarginBox("", `PushButton( `id(`subvol), `opt(`hstretch),
+ // button text
+ _("Subvolume Handling")));
+ }
+
list mountpoints = ProposeMountpoints( used_fs, mount );
term contents = `HVSquash(`VStackFrames(
- `FrameWithMarginBox(_("Formatting Options"),
- `RadioButtonGroup(`id(`format),
- `VBox(
- `LeftRadioButtonWithAttachment(`id(`do_format), `opt(`notify),
- _("Format partition"),
- `VBox(`id(`do_format_attachment),
- FileSystemsComboBox(data, all_filesystems)
- )),
- `VSpacing(0.45),
- `LeftRadioButtonWithAttachment(`id(`do_not_format), `opt(`notify),
- _("Do not format partition"),
- tmp1),
- `VSpacing(0.45),
- CryptButton(data)
- )
- )
- ),
+ fmt,
`FrameWithMarginBox(_("Mounting Options"),
`RadioButtonGroup(`id(`mount),
`VBox(
@@ -162,11 +207,10 @@
_("Fs&tab Options..."))
)),
`VSpacing(0.45),
- `LeftRadioButton(`id(`do_not_mount), `opt(`notify),
- _("Do not mount partition"))
- )
- )
- )
+ notmnt
+ ))
+ ),
+ subvol
)
);
@@ -174,10 +218,17 @@
MiniWorkflow::SetLastStep(!AskPassword());
- UI::ChangeWidget(`id(`format), `Value, do_format ? `do_format : `do_not_format);
- UI::ChangeWidget(`id(`do_format_attachment), `Enabled, do_format);
- UI::ChangeWidget(`id(`crypt_fs), `Value, crypt_fs);
- UI::ChangeWidget(`id(`do_not_format_attachment), `Enabled, !do_format);
+ ChangeWidgetIfExists( `format, `Value, do_format ? `do_format : `do_not_format);
+ ChangeWidgetIfExists( `do_format_attachment, `Enabled, do_format);
+ //not there in RAID/LVM/loop configuration (#483789)
+ ChangeWidgetIfExists( `do_not_format_attachment, `Enabled, !do_format );
+
+ if( do_format)
+ EnableDisableFsOpts(used_fs);
+
+ //not there on s390s
+ ChangeWidgetIfExists( `crypt_fs, `Value, crypt_fs );
+
UI::ChangeWidget(`id(`mount), `Value, do_mount ? `do_mount : `do_not_mount);
UI::ChangeWidget(`id(`do_mount_attachment), `Enabled, do_mount);
UI::ChangeWidget(`id(`mount_point), `Value, mount);
@@ -257,7 +308,8 @@
data["used_fs"] = (symbol) UI::QueryWidget(`id(`fs), `Value);
UI::ChangeWidget(`id(`do_format_attachment), `Enabled, true);
- UI::ChangeWidget(`id(`do_not_format_attachment), `Enabled, false);
+ ChangeWidgetIfExists(`do_not_format_attachment, `Enabled, false);
+ EnableDisableFsOpts( data["used_fs"]:`none);
UI::SetFocus(`id(`fs));
MiniWorkflow::SetLastStep(!AskPassword());
break;
@@ -265,7 +317,7 @@
case `do_not_format:
do_format = (boolean) UI::QueryWidget(`id(`do_format), `Value);
UI::ChangeWidget(`id(`do_format_attachment), `Enabled, false);
- UI::ChangeWidget(`id(`do_not_format_attachment), `Enabled, true);
+ ChangeWidgetIfExists(`do_not_format_attachment, `Enabled, true);
MiniWorkflow::SetLastStep(!AskPassword());
break;
@@ -279,16 +331,24 @@
UI::SetFocus(`id(`mount_point));
//propose mountpoints
//UI::ChangeWidget(`id(`mount_point), `Items, ProposeMountpoints( used_fs, mount ));
+ MiniWorkflow::SetLastStep(!AskPassword());
break;
case `do_not_mount:
do_mount = false;
UI::ChangeWidget(`id(`do_mount_attachment), `Enabled, false);
+ MiniWorkflow::SetLastStep(!AskPassword());
break;
case `next:
- do_format = (boolean) UI::QueryWidget(`id(`do_format), `Value);
- crypt_fs = (boolean) UI::QueryWidget(`id(`crypt_fs), `Value);
+ if( UI::WidgetExists(`id(`do_format)))
+ do_format = (boolean) UI::QueryWidget(`id(`do_format), `Value);
+ else
+ do_format = true;
+ if( UI::WidgetExists(`id(`crypt_fs)))
+ crypt_fs = (boolean) UI::QueryWidget(`id(`crypt_fs), `Value);
+ else
+ crypt_fs = false;
do_mount = (boolean) UI::QueryWidget(`id(`do_mount), `Value);
mount = (string) UI::QueryWidget(`id(`mount_point), `Value);
@@ -335,6 +395,22 @@
}
}
+ //tmpfs specific checks
+ if (data["type"]:`unknown == `tmpfs)
+ {
+ //enforce specifying mountpoint
+ if (!do_mount)
+ {
+ // error popup
+ Popup::Error(_("Tmpfs requires a mount point."));
+ UI::ChangeWidget(`id(`do_mount), `Value, true);
+ UI::ChangeWidget(`id(`do_mount_attachment), `Enabled, true);
+ UI::SetFocus(`id(`mount_point));
+ widget = `again;
+ continue;
+ }
+ }
+
if (do_mount)
{
map ret_mp = CheckOkMount(data["device"]:"error", orig_data, data);
@@ -363,7 +439,7 @@
if (widget == `next)
{
- if (NeedPassword())
+ if( crypt_fs )
data["enc_type"] = data["format"]:false ? `luks : `twofish;
else
data["enc_type"] = `none;
@@ -455,7 +531,7 @@
integer min_pw_len = data["format"]:false ? 8 : 1;
boolean empty_pw_allowed = EmptyCryptPwdAllowed(data);
- boolean two_pw = data["format"]:false || size(data["mount"]:"")==0;
+ boolean two_pw = data["format"]:false || isempty(data["mount"]:"");
string label = "";
@@ -472,7 +548,7 @@
term ad = `Empty();
if( two_pw )
ad = `Password( `id(`pw2), `opt(`hstretch),
- // Label: get same password again for verification
+ // Label: get same password again for verification
// Please use newline if label is longer than 40 characters
_("Reenter the password for &verification:"), "");
@@ -515,16 +591,16 @@
if (two_pw)
tmp = (string) UI::QueryWidget(`id(`pw2), `Value);
- boolean need_verify = !data["format"]:false && size(data["mount"]:"")>0;
+ boolean need_verify = !data["format"]:false && !isempty(data["mount"]:"");
if (!Storage::CheckEncryptionPasswords(password, tmp, min_pw_len, empty_pw_allowed) ||
- (need_verify && !Storage::CheckCryptOk(dev, password)) )
+ (need_verify && !Storage::CheckCryptOk(dev, password, false, false)) )
{
UI::SetFocus(`id(`pw1) );
widget = `again;
}
- }
- }
+ }
+ }
until (widget == `abort || widget == `back || widget == `next);
if (widget == `next)
@@ -541,10 +617,26 @@
boolean DlgResize(map <string, any> &data, map <string, any> disk)
{
+ /*
+ * This resize dialog is simple but avoids several problems faced
+ * before:
+ *
+ * - Stripped digits in a bargraph (bnc #445590)
+ *
+ * - Impossible to resize to maximal size (bnc #373744, #442318,
+ * #456816)
+ *
+ * - Changing dialog size (bnc #460382)
+ *
+ * If somebody wants fancy stuff like slider or bargraph it's a
+ * feature request.
+ */
+
+
map<string, map> target_map = Storage::GetTargetMap();
- map possible = Storage::IsResizable(data);
+ map<string, boolean> possible = Storage::IsResizable(data);
if (!data["format"]:false && !possible["shrink"]:false && !possible["extend"]:false)
{
// popup text
@@ -561,7 +653,6 @@
string device = data["device"]:"error";
symbol used_fs = data["used_fs"]:`none;
- boolean onLvm = ( data["type"]:`unknown == `lvm);
integer used_k = FileSystems::MinFsSizeK(used_fs);
@@ -569,8 +660,8 @@
{
if (used_fs != `swap)
{
- map free_data = Storage::GetFreeSpace(device, 0, used_fs, true);
- if (size(free_data) == 0 || !free_data["ok"]:false)
+ map free_data = Storage::GetFreeSpace(device, used_fs, true);
+ if (isempty(free_data) || !free_data["ok"]:false)
{
y2error("Failed to retrieve FreeSpace %1, filesystem %2", device, data["used_fs"]:`none);
//FIXME: Really?
@@ -583,69 +674,14 @@
}
integer min_free_k = 10*1024;
-
integer size_k = data["size_k"]:0;
// minimal and maximal size for volume
integer min_size_k = Integer::Min([ used_k + min_free_k, size_k ]);
integer max_size_k = 0;
-
- string unit = _("MB");
- integer factor = 1024;
-
- //Depending on size of the partition,
- //set correct division factor and units
- //and minimum required free space, too
- // TODO: get rid of this unit factor and unit altogether
- void AdjustUnits()
- {
- if (max_size_k > 20*1024*1024)
- {
- factor = factor * 1024;
- unit = _("GB");
- }
- }
-
-
string heading = "";
-
- list <string> BarGraphLabels( boolean newlines )
- {
- string used = "";
- string free = "";
- string available = "";
-
- switch (data["type"]:`unknown)
- {
- case `primary:
- case `logical:
- // Labels for bar graph/text field. Keep it short
- used = newlines ? _("Used\nSpace") : _("Used Space: ");
- if (used_fs == `swap)
- // Labels for bar graph/text field. Keep it short
- free = newlines? _("Swap\nSpace") : _("Swap Space: ");
- else
- // Labels for bar graph/text field. Keep it short
- free = newlines ? _("Free\nSpace") : _("Free Space: ");
- // Labels for bar graph. Keep it short
- available = newlines ? _("Unused\nDisk") : _("Unused Disk: ");
- break;
-
- case `lvm:
- // Labels for bar graph/text field. LV stands for 'Logical volume'. Keep it short
- used = newlines ? _("LV\nUsed") : _("LV Used: ");
- // Labels for bar graph/text field. LV stands for 'Logical volume'. Keep it short
- free = newlines ? _("LV\nFree") : _("LV Free: ");
- // Labels for bar graph/text field. VG stands for 'Volume group'. Keep it short
- available = newlines ? _("VG\nFree") : _("VG Free: ");
- break;
- }
-
- return [ used, free, available ];
- }
-
switch (data["type"]:`unknown)
{
case `primary:
@@ -655,7 +691,8 @@
heading = sformat(_("Resize Partition %1"), device);
cyl_size = disk["cyl_size"]:1;
- free_cyl_after = Storage::FreeCylindersAfterPartition(device);
+ integer free_cyl_before = 0;
+ Storage::FreeCylindersAroundPartition(device, free_cyl_before, free_cyl_after);
min_size_k = Integer::Max([ min_size_k, cyl_size / 1024 ]);
max_size_k = size_k + (cyl_size * free_cyl_after) / 1024;
@@ -673,85 +710,46 @@
break;
}
+ // size_k + min_size_k could be > max_size_k
+ min_size_k = Integer::Min([ min_size_k, max_size_k ]);
+
y2milestone("used_k:%1 size_k:%2", used_k, size_k);
y2milestone("min_size_k:%1 max_size_k:%2", min_size_k, max_size_k);
- AdjustUnits();
-
- integer slider_size_k = size_k / factor;
- integer slider_min_size_k = min_size_k / factor;
- integer slider_max_size_k = max_size_k / factor;
-
- term extra_content = `Empty();
- //Spinbox label - %1 will be substituted by unit (GB and alike)
- string newsz = onLvm ? _("New Logical Volume Size (in %1)") : _("New Partition Size (in %1)");
-
- if (UI::HasSpecialWidget(`BarGraph) && UI::HasSpecialWidget(`Slider))
- {
- extra_content = `VBox(
- `BarGraph(`id(`graph), `opt(`vstretch), [ slider_min_size_k, slider_size_k - slider_min_size_k,
- slider_max_size_k - slider_size_k ], BarGraphLabels( true ) ),
- `VSpacing(0.5),
- `Slider(`id(`new_size), `opt(`notify), sformat( newsz, unit),
- slider_min_size_k, slider_max_size_k, slider_size_k)
- );
- }
- else
- {
- extra_content = `IntField( `id(`new_size), `opt(`notify), sformat(newsz, unit ),
- slider_min_size_k, slider_max_size_k, slider_size_k );
- }
-
- //without newlines
- list <string> other_labels = BarGraphLabels( false );
+ term infos = `VBox(`Left(`Label(sformat(_("Current size: %1"), Storage::KByteToHumanString(size_k)))));
+ if (used_fs != `swap && !data["format"]:false)
+ infos = add(infos, `Left(`Label(sformat(_("Currently used: %1"), Storage::KByteToHumanString(used_k)))));
+
+
+ term contents = `HVSquash(
+ // frame heading
+ `FrameWithMarginBox(_("Size"),
+ `RadioButtonGroup(`id(`size),
+ `VBox(
+ `LeftRadioButton(`id(`max_size), `opt(`notify),
+ // radio button text, %1 is replaced by size
+ sformat(_("Maximum Size (%1)"), Storage::KByteToHumanString(max_size_k))),
+ `LeftRadioButton(`id(`min_size), `opt(`notify),
+ // radio button text, %1 is replaced by size
+ sformat(_("Minimum Size (%1)"), Storage::KByteToHumanString(min_size_k))),
+ // radio button text
+ `LeftRadioButtonWithAttachment(`id(`custom_size), `opt(`notify), _("Custom Size"),
+ `VBox(`id(`custom_size_attachment),
+ `MinWidth(15, `InputField(`id(`custom_size_input),
+ `opt(`shrinkable), _("Size")))
+ )),
+ `VSpacing(1),
+ infos
+ )
+ )
+ ));
UI::OpenDialog(
`VBox(
`Left(`Heading(heading)),
- `HSpacing(60),
- `VBox(
- //Frame label
- `Frame( onLvm ? _("Space on Logical Volume ") : _("Space on the Partition"),
- `MarginBox( 0.5, 0.5,
- `Left(`HBox(
- ( used_fs != `swap) ? (
- `HBox(
- `Label( other_labels[0]:""),
- `Label(`id(`used), `opt(`outputField), Storage::KByteToHumanString( min_size_k)),
- `HSpacing(0.5))
- ) : `Empty(),
-
- `Label( other_labels[1]:""),
- `ReplacePoint(`id(`r2),
- `Label(`id(`free),`opt(`outputField), Storage::KByteToHumanString(size_k - min_size_k))
- ),
- `HSpacing(0.5),
-
- `Label( other_labels[2]:""),
- `ReplacePoint(`id(`r3),
- `Label(`id(`unused),`opt(`outputField), Storage::KByteToHumanString( max_size_k - size_k))
- )
- ))
- )
- )
- ),
- extra_content,
+ Greasemonkey::Transform(contents),
`VSpacing(1.0),
- //Frame label
- `Frame ( onLvm ? _("LV Size Restrictions") : _("Partition Size Restrictions"),
- `MarginBox(0.5, 0.5,
- `Left(`HBox(
- //text field label
- `Label( onLvm ? _("Minimum LV Size") : _("Minimum Partition Size: ")),
- `Label(`opt(`outputField), Storage::KByteToHumanString(min_size_k)),
- `HSpacing(0.5),
- //text field label
- `Label( onLvm ? _("Maximum LV Size") : _("Maximum Partition Size: ")),
- `Label(`opt(`outputField), Storage::KByteToHumanString(max_size_k))
- ))
- )
- ),
`ButtonBox(
`PushButton(`id(`help), `opt(`helpButton), Label::HelpButton()),
`PushButton(`id(`cancel), `opt(`cancelButton), Label::CancelButton()),
@@ -761,11 +759,13 @@
);
// help text
- string help_text = _("<p>Choose the new size by dragging the slider or by entering a
-numeric value in either input field.</p>");
+ string help_text = _("<p>Choose new size.</p>");
UI::ChangeWidget(`help, `HelpText, help_text);
+ UI::ChangeWidget(`id(`size), `Value, `max_size);
+ UI::ChangeWidget(`id(`custom_size_attachment), `Enabled, false);
+ UI::ChangeWidget(`id(`custom_size_input), `Value, Storage::KByteToHumanString(size_k));
symbol widget = nil;
@@ -777,26 +777,57 @@
switch (widget)
{
- case `new_size:
+ case `max_size:
{
- slider_size_k = (integer) UI::QueryWidget(`id(`new_size), `Value);
- size_k = Integer::Clamp(slider_size_k * factor, min_size_k, max_size_k);
-
- UI::ChangeWidget(`id(`graph), `Values, [ slider_min_size_k, slider_size_k - slider_min_size_k,
- slider_max_size_k - slider_size_k ]);
-
+ UI::ChangeWidget(`id(`custom_size_attachment), `Enabled, false);
+ break;
+ }
- //Replacing widgets, rather than just changing value. It is clumsy, but UI sets value
- //of the label without adjusting its size. RecalcLayout makes ncurses flicker insanely.
- //ReplaceWidget does, too, but not so much
- UI::ReplaceWidget(`id(`r2), `Label(`opt(`outputField), Storage::KByteToHumanString( size_k - min_size_k )) );
- UI::ReplaceWidget(`id(`r3), `Label(`opt(`outputField), Storage::KByteToHumanString( max_size_k - size_k )) );
+ case `min_size:
+ {
+ UI::ChangeWidget(`id(`custom_size_attachment), `Enabled, false);
+ break;
+ }
+ case `custom_size:
+ {
+ UI::ChangeWidget(`id(`custom_size_attachment), `Enabled, true);
+ UI::SetFocus(`id(`custom_size_input));
break;
}
case `ok:
{
+ switch ((symbol) UI::QueryWidget(`id(`size), `Value))
+ {
+ case `max_size:
+ {
+ size_k = max_size_k;
+ break;
+ }
+
+ case `min_size:
+ {
+ size_k = min_size_k;
+ break;
+ }
+
+ case `custom_size:
+ {
+ string tmp = (string) UI::QueryWidget(`id(`custom_size_input), `Value);
+ if (!Storage::HumanStringToKByteWithRangeCheck(tmp, size_k, min_size_k, max_size_k))
+ {
+ // error popup, %1 and %2 are replaced by sizes
+ Popup::Error(sformat(_("The size entered is invalid. Enter a size between %1 and %2."),
+ Storage::KByteToHumanString(min_size_k),
+ Storage::KByteToHumanString(max_size_k)));
+ widget = `again;
+ continue;
+ }
+ break;
+ }
+ }
+
if (size_k != old_size_k)
{
string mountpoint = data["inactive"]:false ? "" : data["mount"]:"";
@@ -818,8 +849,9 @@
{
case `primary:
case `logical:
- data["region", 1] = Integer::Clamp(PartedSizeToCly((tofloat(size_k*1024)), cyl_size),
- 1, data["region", 1]:0 + free_cyl_after);
+ integer num_cyl = tointeger(1024.0 * size_k / cyl_size + 0.5);
+ num_cyl = Integer::Clamp(num_cyl, 1, data["region", 1]:0 + free_cyl_after);
+ data["region", 1] = num_cyl;
break;
case `lvm:
@@ -873,4 +905,42 @@
UI::CloseDialog();
}
+
+
+ boolean ConfirmRecursiveDelete(string device, list<string> devices, string headline, string text_before,
+ string text_after)
+ {
+ term button_box = `ButtonBox (
+ `PushButton(`id(`yes), `opt(`okButton), Label::DeleteButton() ),
+ `PushButton(`id(`no_button), `opt(`default, `cancelButton), Label::CancelButton())
+ );
+
+ map display_info = UI::GetDisplayInfo();
+ boolean has_image_support = display_info["HasImageSupport"]:false;
+
+ term layout =
+ `VBox (
+ `VSpacing (0.4),
+ `HBox (
+ has_image_support ? `Top (`Image(Icon::IconPath ("question"))) : `Empty(),
+ `HSpacing (1),
+ `VBox (
+ `Left (`Heading (headline)),
+ `VSpacing (0.2),
+ `Left( `Label( text_before ) ),
+ `VSpacing (0.2),
+ `Left(`RichText(HTML::List(sort(devices)))),
+ `VSpacing (0.2),
+ `Left(`Label( text_after)),
+ button_box
+ )
+ )
+ );
+
+ UI::OpenDialog(layout);
+ symbol ret = (symbol) UI::UserInput();
+ UI::CloseDialog();
+
+ return ret == `yes;
+ }
}
Modified: branches/SuSE-Code-11-SP2-Branch/storage/storage/src/include/ep-dm-dialogs.ycp
URL: http://svn.opensuse.org/viewcvs/yast/branches/SuSE-Code-11-SP2-Branch/stora…
==============================================================================
--- branches/SuSE-Code-11-SP2-Branch/storage/storage/src/include/ep-dm-dialogs.ycp (original)
+++ branches/SuSE-Code-11-SP2-Branch/storage/storage/src/include/ep-dm-dialogs.ycp Tue May 17 13:39:44 2011
@@ -3,6 +3,8 @@
* Package: yast2-storage
* Summary: Expert Partitioner
* Authors: Arvin Schnell <aschnell(a)suse.de>
+ *
+ * This file must only be included in other Expert Partitioner files ("ep-*.ycp").
*/
{
textdomain "storage";
@@ -11,7 +13,7 @@
boolean DlgEditDmVolume(map<string, any> &data)
{
string device = data["device"]:"error";
-
+
map<string, any> aliases = $[
"FormatMount" : ``(MiniWorkflowStepFormatMount(data)),
"Password" : ``(MiniWorkflowStepPassword(data))
@@ -26,7 +28,7 @@
// dialog title
string title = sformat(_("Edit DM %1"), device);
- symbol widget = MiniWorkflow::Run(title, dm_icon, aliases, sequence, "FormatMount");
+ symbol widget = MiniWorkflow::Run(title, StorageIcons::dm_icon, aliases, sequence, "FormatMount");
return widget == `finish;
}
Modified: branches/SuSE-Code-11-SP2-Branch/storage/storage/src/include/ep-dm-lib.ycp
URL: http://svn.opensuse.org/viewcvs/yast/branches/SuSE-Code-11-SP2-Branch/stora…
==============================================================================
--- branches/SuSE-Code-11-SP2-Branch/storage/storage/src/include/ep-dm-lib.ycp (original)
+++ branches/SuSE-Code-11-SP2-Branch/storage/storage/src/include/ep-dm-lib.ycp Tue May 17 13:39:44 2011
@@ -3,6 +3,8 @@
* Package: yast2-storage
* Summary: Expert Partitioner
* Authors: Arvin Schnell <aschnell(a)suse.de>
+ *
+ * This file must only be included in other Expert Partitioner files ("ep-*.ycp").
*/
{
textdomain "storage";
@@ -20,7 +22,7 @@
map<string, map> target_map = Storage::GetTargetMap();
map<string, any> data = Storage::GetPartition(target_map, device);
- if (data["used_by"]:"" != "")
+ if (Storage::IsUsedBy(data))
{
// error popup
Popup::Error(sformat(_("The DM %1 is in use. It cannot be
Modified: branches/SuSE-Code-11-SP2-Branch/storage/storage/src/include/ep-dm.ycp
URL: http://svn.opensuse.org/viewcvs/yast/branches/SuSE-Code-11-SP2-Branch/stora…
==============================================================================
--- branches/SuSE-Code-11-SP2-Branch/storage/storage/src/include/ep-dm.ycp (original)
+++ branches/SuSE-Code-11-SP2-Branch/storage/storage/src/include/ep-dm.ycp Tue May 17 13:39:44 2011
@@ -3,15 +3,29 @@
* Package: yast2-storage
* Summary: Expert Partitioner
* Authors: Arvin Schnell <aschnell(a)suse.de>
+ *
+ * This file must only be included in other Expert Partitioner files ("ep-*.ycp").
*/
{
textdomain "storage";
-
include "partitioning/ep-dm-dialogs.ycp";
include "partitioning/ep-dm-lib.ycp";
+ void EpContextMenuDm(string device)
+ {
+ symbol widget = ContextMenu::Simple([ `item(`id(`edit), _("Edit")) ]);
+
+ switch (widget)
+ {
+ case `edit:
+ EpEditDmDevice(device);
+ break;
+ }
+ }
+
+
void CreateDmMainPanel(any user_data)
{
symbol Predicate(map disk, map partition)
@@ -33,8 +47,8 @@
`VBox(
`HStretch(),
// heading
- `IconAndHeading(_("Device Mapper (DM)"), dm_icon),
- `Table(`id(`table), `opt(`keepSorting, `notify),
+ `IconAndHeading(_("Device Mapper (DM)"), StorageIcons::dm_icon),
+ `Table(`id(`table), `opt(`keepSorting, `notify, `notifyContextMenu),
table_header, table_contents)
)
)
@@ -49,6 +63,21 @@
}
+ void HandleDmMainPanel(any user_data, map event)
+ {
+ string device = (string) UI::QueryWidget(`id(`table), `CurrentItem);
+
+ switch (Event::IsWidgetContextMenuActivated(event))
+ {
+ case `table:
+ EpContextMenuDevice(device);
+ break;
+ }
+
+ UI::SetFocus(`id(`table));
+ }
+
+
void CreateDmOverviewTab(any user_data)
{
string dm_device = (string) user_data;
@@ -80,11 +109,11 @@
}
- void HandleDmOverviewTab(any user_data, symbol widget)
+ void HandleDmOverviewTab(any user_data, map event)
{
string dm_device = (string) user_data;
- switch (widget)
+ switch (Event::IsWidgetActivated(event))
{
case `edit:
EpEditDmDevice(dm_device);
@@ -136,7 +165,7 @@
Greasemonkey::Transform(
`VBox(
// heading
- `IconAndHeading(sformat(_("DM Device: %1"), device), dm_icon),
+ `IconAndHeading(sformat(_("DM Device: %1"), device), StorageIcons::dm_icon),
`DumbTab(`id(`tab), [
// push button text
`item(`id(`overview), _("&Overview")),
@@ -153,8 +182,8 @@
}
- void HandleDmPanel(any user_data, symbol widget)
+ void HandleDmPanel(any user_data, map event)
{
- TabPanel::Handle(widget);
+ TabPanel::Handle(event);
}
}
Added: branches/SuSE-Code-11-SP2-Branch/storage/storage/src/include/ep-graph.ycp
URL: http://svn.opensuse.org/viewcvs/yast/branches/SuSE-Code-11-SP2-Branch/stora…
==============================================================================
--- branches/SuSE-Code-11-SP2-Branch/storage/storage/src/include/ep-graph.ycp (added)
+++ branches/SuSE-Code-11-SP2-Branch/storage/storage/src/include/ep-graph.ycp Tue May 17 13:39:44 2011
@@ -0,0 +1,196 @@
+/**
+ * File: ep-graph.ycp
+ * Package: yast2-storage
+ * Summary: Expert Partitioner
+ * Authors: Arvin Schnell <aschnell(a)suse.de>
+ *
+ * This file must only be included in other Expert Partitioner files ("ep-*.ycp").
+ */
+{
+ textdomain "storage";
+
+
+ void EpContextMenuDeviceGraph()
+ {
+ symbol widget = ContextMenu::Simple([ `item(`id(`add_raid), `icon(StorageIcons::raid_icon), _("Add RAID")),
+ `item(`id(`add_lvmvg), `icon(StorageIcons::lvm_icon), _("Add Volume Group")) ]);
+
+ switch (widget)
+ {
+ case `add_raid:
+ EpCreateRaid();
+ break;
+
+ case `add_lvmvg:
+ EpCreateVolumeGroup();
+ break;
+ }
+ }
+
+
+ void CreateDeviceGraphPanel(any user_data)
+ {
+ string filename = Directory::tmpdir + "/device.gv";
+ Storage::SaveDeviceGraph(filename);
+
+ UI::ReplaceWidget(`tree_panel,
+ Greasemonkey::Transform(
+ `VBox(
+ // dialog heading, graph is the mathematic term for
+ // a set of notes connected with edges
+ `IconAndHeading(_("Device Graph"), StorageIcons::graph_icon),
+ `Graph(`id(`graph), `opt(`notify, `notifyContextMenu), filename, "dot"),
+ `HBox(
+ // button text
+ `PushButton(`id(`export), _("Export Device Graph...")),
+ `HStretch()
+ )
+ ))
+ );
+
+ SCR::Execute(.target.remove, filename);
+
+ // helptext
+ string helptext = _("<p>This view shows a graph of devices.</p>");
+
+ Wizard::RestoreHelp(helptext);
+ }
+
+
+ void RefreshDeviceGraphPanel(any user_data)
+ {
+ string filename = Directory::tmpdir + "/device.gv";
+ Storage::SaveDeviceGraph(filename);
+
+ UI::ChangeWidget(`id(`graph), `Filename, filename);
+ }
+
+
+ void HandleDeviceGraphPanel(any user_data, map event)
+ {
+ void GotoDevice(string device)
+ {
+ TreePanel::SwitchToNew(device);
+ UI::SetFocus(UI::WidgetExists(`id(`table)) ? `id(`table) : `id(`text));
+ }
+
+ switch (Event::IsWidgetContextMenuActivated(event))
+ {
+ case `graph:
+ {
+ string node = (string) UI::QueryWidget(`id(`graph), `Item);
+
+ if (isempty(node))
+ EpContextMenuDeviceGraph();
+ else if (String::StartsWith(node, "device:"))
+ EpContextMenuDevice(substring(node, 7));
+
+ // TODO: update graph
+ }
+ break;
+ }
+
+ switch (Event::IsWidgetActivated(event))
+ {
+ case `graph:
+ {
+ string node = (string) UI::QueryWidget(`id(`graph), `Item);
+
+ if (String::StartsWith(node, "device:"))
+ GotoDevice(substring(node, 7));
+ else if (String::StartsWith(node, "mountpoint:"))
+ GotoDevice(substring(node, 11));
+ }
+ break;
+
+ case `export:
+ {
+ string filename = UI::AskForSaveFileName("/tmp", "*.gv", "Save as...");
+ if (filename != nil)
+ {
+ if (!Storage::SaveDeviceGraph(filename))
+ {
+ // error popup
+ Popup::Error(_("Saving graph file failed."));
+ }
+ }
+ }
+ break;
+ }
+ }
+
+
+ void CreateMountGraphPanel(any user_data)
+ {
+ string filename = Directory::tmpdir + "/mount.gv";
+ Storage::SaveMountGraph(filename);
+
+ UI::ReplaceWidget(`tree_panel,
+ Greasemonkey::Transform(
+ `VBox(
+ // dialog heading, graph is the mathematic term for
+ // a set of notes connected with edges
+ `IconAndHeading(_("Mount Graph"), StorageIcons::graph_icon),
+ `Graph(`id(`graph), `opt(`notify, `notifyContextMenu), filename, "dot"),
+ `HBox(
+ // button text
+ `PushButton(`id(`export), _("Export Mount Graph...")),
+ `HStretch()
+ )
+ ))
+ );
+
+ SCR::Execute(.target.remove, filename);
+
+ // helptext
+ string helptext = _("<p>This view shows a graph of mount points.</p>");
+
+ Wizard::RestoreHelp(helptext);
+ }
+
+
+ void RefreshMountGraphPanel(any user_data)
+ {
+ string filename = Directory::tmpdir + "/mount.gv";
+ Storage::SaveMountGraph(filename);
+
+ UI::ChangeWidget(`id(`graph), `Filename, filename);
+ }
+
+
+ void HandleMountGraphPanel(any user_data, map event)
+ {
+ void GotoDevice(string device)
+ {
+ TreePanel::SwitchToNew(device);
+ UI::SetFocus(UI::WidgetExists(`id(`table)) ? `id(`table) : `id(`text));
+ }
+
+ switch (Event::IsWidgetActivated(event))
+ {
+ case `graph:
+ {
+ string node = (string) UI::QueryWidget(`id(`graph), `Item);
+
+ if (String::StartsWith(node, "mountpoint:"))
+ GotoDevice(substring(node, 11));
+ }
+ break;
+
+ case `export:
+ {
+ string filename = UI::AskForSaveFileName("/tmp", "*.gv", "Save as...");
+ if (filename != nil)
+ {
+ if (!Storage::SaveMountGraph(filename))
+ {
+ // error popup
+ Popup::Error(_("Saving graph file failed."));
+ }
+ }
+ }
+ break;
+ }
+ }
+
+}
Modified: branches/SuSE-Code-11-SP2-Branch/storage/storage/src/include/ep-hd-dialogs.ycp
URL: http://svn.opensuse.org/viewcvs/yast/branches/SuSE-Code-11-SP2-Branch/stora…
==============================================================================
--- branches/SuSE-Code-11-SP2-Branch/storage/storage/src/include/ep-hd-dialogs.ycp (original)
+++ branches/SuSE-Code-11-SP2-Branch/storage/storage/src/include/ep-hd-dialogs.ycp Tue May 17 13:39:44 2011
@@ -3,6 +3,8 @@
* Package: yast2-storage
* Summary: Expert Partitioner
* Authors: Arvin Schnell <aschnell(a)suse.de>
+ *
+ * This file must only be included in other Expert Partitioner files ("ep-*.ycp").
*/
{
textdomain "storage";
@@ -102,8 +104,11 @@
list<integer> region = data["region"]:slot;
integer size_k = (region[1]:0 * cyl_size) / 1024;
- integer min_size_k = tointeger(float::ceil(cyl_size / 1024.0));
- integer max_size_k = (slot[1]:0 * cyl_size) / 1024;
+ integer min_num_cyl = 1;
+ integer max_num_cyl = slot[1]:0;
+
+ integer min_size_k = tointeger(min_num_cyl * cyl_size / 1024.0);
+ integer max_size_k = tointeger(max_num_cyl * cyl_size / 1024.0);
symbol type = data["type"]:`unknown;
symbol what = `nothing; // ;-)
@@ -130,8 +135,8 @@
// radio button text
`LeftRadioButtonWithAttachment(`id(`manual_size), `opt(`notify), _("Custom Size"),
`VBox(`id(`manual_size_attachment),
- `MinWidth(15, `InputField(`id(`size_input), `opt(`shrinkable),
- _("Size (e.g. 9.0 MB or 9.0 GB)")))
+ `MinWidth(15, `InputField(`id(`size_input),
+ `opt(`shrinkable), _("Size")))
)),
// radio button text
`LeftRadioButtonWithAttachment(`id(`manual_region), `opt(`notify), _("Custom Region"),
@@ -149,7 +154,7 @@
MiniWorkflow::SetLastStep( type == `extended);
UI::ChangeWidget(`id(`size), `Value, what);
- UI::SetFocus(`id(what));
+ UI::SetFocus( (what == `extended) ? `id(`max_size) : ( what == `manual_size ? `id(`size_input) : `id(`manual_region)) );
UI::ChangeWidget(`id(`manual_size_attachment), `Enabled, what == `manual_size);
UI::ChangeWidget(`id(`size_input), `Value, Storage::KByteToHumanString(size_k));
UI::ChangeWidget(`id(`manual_region_attachment), `Enabled, what == `manual_region);
@@ -240,7 +245,8 @@
case `manual_size:
{
- integer num_cyl = size_k * 1024 / cyl_size;
+ integer num_cyl = tointeger(1024.0 * size_k / cyl_size + 0.5);
+ num_cyl = Integer::Clamp(num_cyl, min_num_cyl, max_num_cyl);
data["region"] = [ slot[0]:0, num_cyl ];
break;
}
@@ -304,7 +310,7 @@
// dialog title
string title = sformat(_("Add Partition on %1"), data["disk_device"]:"error");
- symbol widget = MiniWorkflow::Run(title, hd_part_icon, aliases, sequence, start);
+ symbol widget = MiniWorkflow::Run(title, StorageIcons::hd_part_icon, aliases, sequence, start);
return widget == `finish;
}
@@ -328,14 +334,112 @@
// dialog title
string title = sformat(_("Edit Partition %1"), device);
- symbol widget = MiniWorkflow::Run(title, hd_part_icon, aliases, sequence, "FormatMount");
+ symbol widget = MiniWorkflow::Run(title, StorageIcons::hd_part_icon, aliases, sequence, "FormatMount");
return widget == `finish;
}
+ boolean DlgMovePartition(map<string, any>& part)
+ {
+ string device = part["device"]:"error";
+
+ integer free_cyl_before = 0;
+ integer free_cyl_after = 0;
+
+ Storage::FreeCylindersAroundPartition(device, free_cyl_before, free_cyl_after);
+
+ if (free_cyl_before == 0 && free_cyl_after == 0)
+ {
+ // error popup text, %1 is replace with name of partition
+ Popup::Error(sformat(_("No space to moved partition %1."), device));
+ return false;
+ }
+
+ integer move = 0;
+
+ if (free_cyl_before > 0 && free_cyl_after == 0)
+ {
+ // popup text, %1 is replace with name of partition
+ if (!Popup::YesNo(sformat(_("Move partition %1 forward?"), device)))
+ return false;
+
+ move = -free_cyl_before;
+ }
+ else if (free_cyl_before == 0 && free_cyl_after > 0)
+ {
+ // popup text, %1 is replace with name of partition
+ if (!Popup::YesNo(sformat(_("Move partition %1 backward?"), device)))
+ return false;
+
+ move = free_cyl_after;
+ }
+ else if (free_cyl_before > 0 && free_cyl_after > 0)
+ {
+ UI::OpenDialog(`opt(`decorated),
+ Greasemonkey::Transform(
+ `VBox(
+ `MarginBox(2, 0.4,
+ `RadioButtonGroup(`id(`directions),
+ `VBox(
+ // popup text, %1 is replace with name of partition
+ `Label(sformat(_("Move partition %1?"), device)),
+ // radio button text
+ `LeftRadioButton(`id(`forward), _("Forward"), true),
+ // radio button text
+ `LeftRadioButton(`id(`backward), _("Backward"))
+ ))),
+ `ButtonBox(
+ `PushButton(`id(`cancel), `opt(`cancelButton), Label::CancelButton()),
+ `PushButton(`id(`ok), `opt(`default, `okButton), Label::OKButton())
+ )
+ )
+ )
+ );
+
+ symbol widget = (symbol) UI::UserInput();
+
+ symbol direction = (symbol) UI::QueryWidget(`id(`directions), `Value);
+
+ UI::CloseDialog();
+
+ if (widget != `ok)
+ return false;
+
+ switch (direction)
+ {
+ case `forward:
+ move = -free_cyl_before;
+ break;
+
+ case `backward:
+ move = free_cyl_after;
+ break;
+ }
+ }
+
+ if (move == 0)
+ return false;
+
+ part["region", 0] = part["region", 0]:0 + move;
+ y2milestone("part:%1", part);
+ return true;
+ }
+
+
boolean DlgResizePartition(map<string, any> &data, map <string, any> disk)
{
return DlgResize(data, disk);
}
+
+
+ boolean ConfirmPartitionsDelete( string disk, list<string> pnames )
+ {
+ return ConfirmRecursiveDelete( disk, pnames,
+ _("Confirm Deleting of All Partitions"),
+ sformat(_("The disk \"%1\" contains at least one partition.
+If you proceed, the following partitions will be deleted:"), disk),
+ sformat(_("Really delete all partitions on \"%1\"?"), disk)
+ );
+ }
}
Modified: branches/SuSE-Code-11-SP2-Branch/storage/storage/src/include/ep-hd-lib.ycp
URL: http://svn.opensuse.org/viewcvs/yast/branches/SuSE-Code-11-SP2-Branch/stora…
==============================================================================
--- branches/SuSE-Code-11-SP2-Branch/storage/storage/src/include/ep-hd-lib.ycp (original)
+++ branches/SuSE-Code-11-SP2-Branch/storage/storage/src/include/ep-hd-lib.ycp Tue May 17 13:39:44 2011
@@ -3,12 +3,12 @@
* Package: yast2-storage
* Summary: Expert Partitioner
* Authors: Arvin Schnell <aschnell(a)suse.de>
+ *
+ * This file must only be included in other Expert Partitioner files ("ep-*.ycp").
*/
{
textdomain "storage";
- import "Map";
- import "HTML";
void EpCreatePartitionTable(string disk_device)
{
@@ -22,7 +22,7 @@
map<string, map> target_map = Storage::GetTargetMap();
map disk = target_map[disk_device]:$[];
- if (disk["used_by_device"]:"" != "")
+ if (Storage::IsUsedBy(disk))
{
// error popup
Popup::Error(_("The disk is in use and cannot be modified."));
@@ -96,7 +96,7 @@
// popup text
if (Popup::YesNo(sformat(_("Really delete BIOS RAID %1?"), device)))
{
- if (deleteAllDevPartitions(disk, Stage::initial(), false))
+ if (deleteAllDevPartitions(disk, Stage::initial()))
Storage::DeleteDmraid(device);
UpdateMainStatus();
@@ -109,7 +109,7 @@
// popup text
if (Popup::YesNo(sformat(_("Really delete Partitioned RAID %1?"), device)))
{
- if (deleteAllDevPartitions(disk, Stage::initial(), false))
+ if (deleteAllDevPartitions(disk, Stage::initial()))
Storage::DeleteMdPartCo(device);
UpdateMainStatus();
@@ -119,8 +119,26 @@
}
else
{
- // error popup
- Popup::Error(_("The disk cannot be deleted."));
+ //partition names
+ list<string> pnames = Storage::GetAffectedDevices( device );
+ integer count = size(pnames);
+
+ if(count == 0)
+ {
+ // error ppup
+ Popup::Error(_("There are no partitions to delete on this disk."));
+ return;
+ }
+
+ else
+ {
+ if (ConfirmPartitionsDelete(device, pnames) && deleteAllDevPartitions(disk, Stage::initial()))
+ {
+ UpdateMainStatus();
+ UpdateNavigationTree(`hd);
+ TreePanel::Create();
+ }
+ }
}
}
@@ -154,7 +172,7 @@
if (size(ret) == 0)
{
// error popup
- Popup::Error(sformat(_("It is not possible to create a partition on %1."),
+ Popup::Error(sformat(_("It is not possible to create a partition on %1."),
disk_device));
}
@@ -178,7 +196,7 @@
map<string, map> target_map = Storage::GetTargetMap();
map disk = target_map[disk_device]:$[];
- if (disk["used_by_device"]:"" != "")
+ if (Storage::IsUsedBy(disk))
{
// error popup
Popup::Error(_("The disk is in use and cannot be modified."));
@@ -232,9 +250,12 @@
}
map<string, map> target_map = Storage::GetTargetMap();
- map<string, any> data = Storage::GetPartition(target_map, device);
+ map<string, any> part = Storage::GetPartition(target_map, device);
- if (data["used_by"]:"" != "")
+ if (!Storage::CanEdit(part, true))
+ return;
+
+ if (Storage::IsUsedBy(part))
{
// error popup, %1 is replace by partition device name e.g. /dev/sdb1
Popup::Error(sformat(_("The partition %1 is in use. It cannot be
@@ -242,16 +263,16 @@
return;
}
- if (data["type"]:`primary == `extended)
+ if (part["type"]:`primary == `extended)
{
// error popup text
Popup::Error(_("An extended partition cannot be edited."));
return;
}
- if (DlgEditPartition(data))
+ if (DlgEditPartition(part))
{
- Storage::ChangeVolumeProperties(data);
+ Storage::ChangeVolumeProperties(part);
UpdateMainStatus();
UpdateNavigationTree(nil);
@@ -261,7 +282,7 @@
}
- void EpResizePartition(string device)
+ void EpMovePartition(string device)
{
if (device == nil)
{
@@ -272,7 +293,7 @@
map<string, map> target_map = Storage::GetTargetMap();
map<string, any> disk = Storage::GetDisk(target_map, device);
- map<string, any> data = Storage::GetPartition(target_map, device);
+ map<string, any> part = Storage::GetPartition(target_map, device);
if (disk["readonly"]:false)
{
@@ -280,34 +301,34 @@
return;
}
- if (data["used_by"]:"" != "")
+ if (!part["create"]:false)
{
// error popup, %1 is replace by partition device name, e.g. /dev/sdb1
- Popup::Error(sformat(_("The partition %1 is in use. It cannot be
-resized. To resize %1, make sure it is not used."), device));
+ Popup::Error(sformat(_("The partition %1 is already created on disk
+and cannot be moved."), device));
return;
}
- if (data["type"]:`primary == `extended)
+ if (part["type"]:`primary == `extended)
{
// error popup text
- Popup::Error(_("An extended partition cannot be resized."));
+ Popup::Error(_("An extended partition cannot be moved."));
return;
}
- //Need to pass data on the whole disk, to determine free/available space
- if (DlgResizePartition(data, disk))
+ if (DlgMovePartition(part))
{
- Storage::ResizePartition(device, disk["device"]:"error", data["region", 1]:0);
-
- UpdateMainStatus();
- TreePanel::Create();
- UpdateTableFocus(device);
+ if (Storage::UpdatePartition(device, part["region", 0]:0, part["region", 1]:0))
+ {
+ UpdateMainStatus();
+ TreePanel::Create();
+ UpdateTableFocus(device);
+ }
}
}
- void EpDeletePartition(string device)
+ void EpResizePartition(string device)
{
if (device == nil)
{
@@ -316,52 +337,85 @@
return;
}
- string parent = ParentDevice(device);
+ map<string, map> target_map = Storage::GetTargetMap();
+ map<string, any> disk = Storage::GetDisk(target_map, device);
+ map<string, any> part = Storage::GetPartition(target_map, device);
- if (EpDeleteDevice(device))
+ if (disk["readonly"]:false)
+ {
+ Popup::Error(Partitions::RdonlyText(disk["device"]:"", true));
+ return;
+ }
+
+ if (Storage::IsUsedBy(part))
{
+ // error popup, %1 is replace by partition device name, e.g. /dev/sdb1
+ Popup::Error(sformat(_("The partition %1 is in use. It cannot be
+resized. To resize %1, make sure it is not used."), device));
+ return;
+ }
+
+ if (part["type"]:`primary == `extended)
+ {
+ // error popup text
+ Popup::Error(_("An extended partition cannot be resized."));
+ return;
+ }
+
+ // Need to pass data on the whole disk, to determine free/available space
+ if (DlgResizePartition(part, disk))
+ {
+ Storage::ResizePartition(device, disk["device"]:"error", part["region", 1]:0);
+
UpdateMainStatus();
- UpdateNavigationTree(parent);
TreePanel::Create();
+ UpdateTableFocus(device);
}
}
- void EpDasdfmtDisk(string device)
+ void EpDeletePartition(string device, symbol context)
{
+ if (device == nil)
+ {
+ // error popup
+ Popup::Error(_("No partition selected."));
+ return;
+ }
+
map<string, map> target_map = Storage::GetTargetMap();
+ map<string, any> disk = Storage::GetDisk(target_map, device);
+ map<string, any> part = Storage::GetPartition(target_map, device);
- map disk = target_map[device]:$[];
+ if (!Storage::CanDelete(part, disk, true))
+ return;
- if (!disk["dasdfmt"]:false)
+ string parent = ParentDevice(device);
+ string next = NextDeviceAfterDelete(device);
+
+ if (EpDeleteDevice(device))
{
- // popup text, %1 is replaced by a dasd name e.g. /dev/dasda
- boolean doit = Popup::YesNo(sformat(_("Running dasdfmt deletes all data on the disk.
-Really execute dasdfmt on disk %1?
-"), device));
+ UpdateMainStatus();
- if (doit)
+ switch (context)
{
- Storage::InitializeDisk(device, true);
+ case `table:
+ UpdateNavigationTree(nil);
+ TreePanel::Create();
+ if (!isempty(next))
+ UI::ChangeWidget(`id(`table), `CurrentItem, next);
+ break;
+
+ case `overview:
+ UpdateNavigationTree(parent);
+ TreePanel::Create();
+ break;
}
}
- else
- {
- // popup text
- Popup::Message(_("The disk is no longer marked for dasdfmt.
-
-Partitions currently present on this disk are again
-displayed.
-"));
- Storage::InitializeDisk(device, false);
- }
-
- UpdateMainStatus();
- UpdateNavigationTree(nil);
- TreePanel::Create();
}
- void EpCloneDisk( string device )
+
+ void EpCloneDisk(string device)
{
map<string, map> target_map = Storage::GetTargetMap();
@@ -370,42 +424,32 @@
list <map> myparts = target_map[ device, "partitions"]:[];
string mypart_table_type = target_map[device, "label"]:Storage::DefaultDiskLabel(device);
- string helptext = _("<p>Select one or more (if available) hard disks
-that will have the same partition layout as
-this disk.</p>
+ // helptext
+ string helptext = _("<p>Select one or more (if available) hard disks
+that will have the same partition layout as
+this disk.</p>
<p>Disks marked with '*' sign contain one or
-more partitions. After cloning, these
+more partitions. After cloning, these
partitions will be deleted.</p>");
- void HelpDialog() {
- UI::OpenDialog( `MinSize( 40,10,`VBox(
- `RichText(helptext),
- `VSpacing(1),
- `PushButton(`id(`ok), Label::CloseButton())
- )
- ));
-
- UI::UserInput();
- UI::CloseDialog();
- }
-
- list <string> AvailableTargetDisks() {
- list <string> items = [];
-
+ list <string> AvailableTargetDisks()
+ {
map <string, map> filtered_target_map =
filter( string dev, map props, target_map, {
- return ( dev != device &&
- Storage::IsDiskType( props["type"]:`CT_UNKNOWN ) &&
- props["used_by_device"]:"" == "" &&
- props["cyl_size"]:0 == mycyl_size );
+ return dev != device &&
+ Storage::IsDiskType( props["type"]:`CT_UNKNOWN ) &&
+ !Storage::IsUsedBy(props) &&
+ props["cyl_size"]:0 == mycyl_size;
});
y2milestone("Available, suitable and unused disks (other than %1): %2", device, Map::Keys(filtered_target_map));
+ list <string> items = [];
+
foreach( string dev, map props, filtered_target_map,{
if( props["size_k"]:0 >= mysize )
- items = add(items, dev);
- else
+ items = add(items, dev);
+ else
y2milestone("%1 is smaller than needed, skipping it", device);
});
@@ -432,8 +476,8 @@
return (ret == `ok);
}
- if (size(myparts) == 0) {
- Popup::Error(_("There are no partitions on this disk (a clonable
+ if (isempty(myparts)) {
+ Popup::Error(_("There are no partitions on this disk (a clonable
disk must have at least one partition).
Create some partitions before cloning the disk."));
return;
@@ -441,14 +485,14 @@
list <string> mydisks = AvailableTargetDisks();
- if( size( mydisks ) == 0 ) {
- Popup::Error(_("This disk cannot be cloned. There are no suitable
+ if (isempty(mydisks)) {
+ Popup::Error(_("This disk cannot be cloned. There are no suitable
disks that could have the same partitioning layout."));
return;
}
list<term> ui_items = maplist( string one_disk, mydisks, {
- boolean any_partitions = size( target_map[ one_disk, "partitions" ]:[]) > 0;
+ boolean any_partitions = !isempty(target_map[ one_disk, "partitions" ]:[]);
return `item(`id(one_disk), sformat("%1%2 (%3)",one_disk,
any_partitions ? "*" : "",
@@ -461,24 +505,25 @@
`MultiSelectionBox(`id(`tdisk), _("Available target disks:"), ui_items ),
`VSpacing(1),
`ButtonBox(
- `PushButton(`id(`help), Label::HelpButton()),
+ `PushButton(`id(`help), `opt(`helpButton), Label::HelpButton()),
`PushButton(`id(`ok), `opt(`default), Label::OKButton()),
`PushButton(`id(`cancel), Label::CancelButton())
)
)
));
+ UI::ChangeWidget(`help, `HelpText, helptext);
+
any ret = nil;
- boolean run_raid_setup = false;
- while(ret != `ok && ret != `cancel) {
+ while(ret != `ok && ret != `cancel)
+ {
ret = UI::UserInput();
if( ret == `ok) {
list <string> selected_disks = (list <string>) UI::QueryWidget(`id(`tdisk), `SelectedItems);
- boolean any_disk_selected = size(selected_disks) > 0;
- if (!any_disk_selected) {
+ if (isempty(selected_disks)) {
Popup::Error(_("Select some target disk for creating a clone"));
UI::SetFocus(`id(`tdisk));
ret = nil;
@@ -491,7 +536,7 @@
foreach (string this_disk, selected_disks, {
list <map> partitions = target_map[ this_disk, "partitions" ]:[];
- if ( size( partitions ) > 0 ) {
+ if (!isempty(partitions)) {
list <string> tmp = maplist( map one_part, partitions, {
return one_part["device"]:"";
});
@@ -500,7 +545,7 @@
});
//if there is anything to delete, ask user if s/he really wants to delete
- if ( size(partitions_to_delete) > 0 &&
+ if ( !isempty(partitions_to_delete) &&
!ConfirmDeletePartitions( partitions_to_delete )) {
ret = nil;
continue;
@@ -519,9 +564,9 @@
y2milestone("Deleting these partitions: %1", pnames);
- if( size(partitions) > 0) {
+ if (!isempty(partitions)) {
foreach( string one_partition, pnames,{
- Storage::DeleteDevice( disk_info["device"]:"", one_partition );
+ Storage::DeleteDevice(one_partition);
});
}
@@ -533,10 +578,10 @@
foreach( map one_partition, myparts, {
map next = Storage::NextPartition( this_disk, one_partition["type"]:`none);
- Storage::CreatePartition( this_disk, next["device"]:"error",
+ Storage::CreatePartition( this_disk, next["device"]:"error",
one_partition["type"]:`primary,
one_partition["fsid"]: Partitions::fsid_native,
- one_partition["region",0]:0, one_partition["region",1]:0,
+ one_partition["region",0]:0, one_partition["region",1]:0,
one_partition["mountby"]:Storage::GetMountBy(device) );
//FIXME: ChangeVolumeProperties too?
});
@@ -544,10 +589,6 @@
Storage::SetRecursiveRemoval( recursive );
}
- else if (ret == `help) {
- HelpDialog();
- continue;
- }
}
UI::CloseDialog();
@@ -558,4 +599,39 @@
TreePanel::Create();
}
}
+
+
+ void EpDasdfmtDisk(string device)
+ {
+ map<string, map> target_map = Storage::GetTargetMap();
+
+ map disk = target_map[device]:$[];
+
+ if (!disk["dasdfmt"]:false)
+ {
+ // popup text, %1 is replaced by a dasd name e.g. /dev/dasda
+ boolean doit = Popup::YesNo(sformat(_("Running dasdfmt deletes all data on the disk.
+Really execute dasdfmt on disk %1?
+"), device));
+
+ if (doit)
+ {
+ Storage::InitializeDisk(device, true);
+ }
+ }
+ else
+ {
+ // popup text
+ Popup::Message(_("The disk is no longer marked for dasdfmt.
+
+Partitions currently present on this disk are again
+displayed.
+"));
+ Storage::InitializeDisk(device, false);
+ }
+
+ UpdateMainStatus();
+ UpdateNavigationTree(nil);
+ TreePanel::Create();
+ }
}
Modified: branches/SuSE-Code-11-SP2-Branch/storage/storage/src/include/ep-hd.ycp
URL: http://svn.opensuse.org/viewcvs/yast/branches/SuSE-Code-11-SP2-Branch/stora…
==============================================================================
--- branches/SuSE-Code-11-SP2-Branch/storage/storage/src/include/ep-hd.ycp (original)
+++ branches/SuSE-Code-11-SP2-Branch/storage/storage/src/include/ep-hd.ycp Tue May 17 13:39:44 2011
@@ -3,91 +3,170 @@
* Package: yast2-storage
* Summary: Expert Partitioner
* Authors: Arvin Schnell <aschnell(a)suse.de>
+ *
+ * This file must only be included in other Expert Partitioner files ("ep-*.ycp").
*/
{
textdomain "storage";
- import "Arch";
- import "PackageCallbacks";
- import "PackageSystem";
- import "Mode";
- import "Stage";
-
include "partitioning/ep-hd-dialogs.ycp";
include "partitioning/ep-hd-lib.ycp";
- void CreateHdMainPanel(any user_data)
+ void EpContextMenuHdDisk(string device)
{
- symbol Predicate(map disk, map partition)
+ symbol widget = ContextMenu::Simple([ `item(`id(`add), `icon(StorageIcons::hd_part_icon), _("Add Partition")),
+ `item(`id(`delete), _("Delete")) ]);
+
+ switch (widget)
{
- return StorageFields::PredicateDiskType(disk, partition, [`CT_DMRAID, `CT_DMMULTIPATH,
- `CT_MDPART, `CT_DISK]);
+ case `add:
+ EpCreatePartition(device);
+ break;
+
+ case `delete:
+ EpDeleteDisk(device);
+ break;
}
+ }
+
+
+ void EpContextMenuHdPartition(string device)
+ {
+ symbol widget = ContextMenu::Simple([ `item(`id(`edit), _("Edit")),
+ `item(`id(`move), _("Move")),
+ `item(`id(`resize), _("Resize")),
+ `item(`id(`delete), _("Delete")) ]);
- boolean IsAvailable ( string client )
+ switch (widget)
{
- //in the installed system, we don't care if the client isn't there
- //as the user will be prompted to install the pkg anyway (in CallConfig)
- if ( !Stage::initial() )
- return true;
- //check if the client is in inst-sys
- else
- return WFM::ClientExists(client);
- }
+ case `edit:
+ EpEditPartition(device);
+ break;
- list<symbol> fields = StorageSettings::FilterTable([ `device, `udev_path, `udev_id, `size, `format,
- `encrypted, `type, `fs_type, `label, `mount_point,
- `mount_by, `start_cyl, `end_cyl, `used_by ]);
+ case `move:
+ EpMovePartition(device);
+ break;
- map<string, map> target_map = Storage::GetTargetMap();
+ case `resize:
+ EpResizePartition(device);
+ break;
+
+ case `delete:
+ EpDeletePartition(device, `table);
+ break;
+ }
+ }
- term table_header = StorageFields::TableHeader(fields);
- list<term> table_contents = StorageFields::TableContents(fields, target_map, Predicate);
- term buttons = `HBox(
+ list<term> HdButtons()
+ {
+ return [
+ // push button text
+ `PushButton(`id(`edit),`opt(`key_F4), _("Edit...")),
// push button text
- `PushButton(`id(`rescan), `opt(`key_F6), _("Rescan Disks"))
- );
+ `PushButton(`id(`move), `opt(`key_F7), _("Move...")),
+ // push button text
+ `PushButton(`id(`resize), `opt(`key_F6), _("Resize...")),
+ // push button text
+ `PushButton(`id(`delete), `opt(`key_F5), _("Delete..."))
+ ];
+ }
- buttons = add(buttons, `HStretch());
- list<term> configs = [];
+ void HandleHdButtons( any user_data, string device, map event )
+ {
+ string disk_device = "";
+ boolean is_disk = false;
- if (IsAvailable("iscsi-client")) {
- // menu entry text
- configs = add(configs, `item(`id(`iscsi), _("Configure &iSCSI...")));
- }
+ if (user_data == nil)
+ {
+ map disk = nil;
+ map part = nil;
- if (true) {
- // menu entry text
- configs = add(configs, `item(`id(`multipath), _("Configure &Multipath...")));
+ map<string, map> target_map = Storage::GetTargetMap();
+ SplitDevice(target_map, device, disk, part);
+ disk_device = (string) disk["device"]:"";
+ is_disk = part == nil;
+ }
+ else
+ {
+ disk_device = (string) user_data;
}
- if (Arch::s390() && IsAvailable("s390")) {
- // menu entry text
- configs = add(configs, `item(`id(`dasd), _("Configure &DASD...")));
- // menu entry text
- configs = add(configs, `item(`id(`zfcp), _("Configure &zFCP...")));
- // menu entry text
- configs = add(configs, `item(`id(`xpram), _("Configure &XPRAM...")));
+ switch (Event::IsWidgetActivated(event))
+ {
+ case `add:
+ EpCreatePartition(disk_device);
+ break;
+
+ case `edit:
+ if (is_disk)
+ TreePanel::SwitchToNew( disk_device );
+ else
+ EpEditPartition( device );
+ break;
+
+ case `move:
+ if (is_disk)
+ // error popup
+ Popup::Error(_("Hard disks, BIOS RAIDs and multipath
+devices cannot be moved."));
+ else
+ EpMovePartition(device);
+ break;
+
+ case `resize:
+ if (is_disk)
+ // error popup
+ Popup::Error(_("Hard disks, BIOS RAIDs and multipath
+devices cannot be resized."));
+ else
+ EpResizePartition ( device );
+ break;
+
+ case `delete:
+ if (is_disk)
+ EpDeleteDisk(disk_device);
+ else
+ EpDeletePartition ( device, UI::WidgetExists(`id(`table)) ? `table : `overview );
+ break;
}
+ }
- if (size(configs) > 0) {
- // menu button text
- buttons = add(buttons, `MenuButton(`opt(`key_F7), _("Configure..."), configs));
+
+ void CreateHdMainPanel(any user_data)
+ {
+ symbol Predicate(map disk, map partition)
+ {
+ return StorageFields::PredicateDiskType(disk, partition, [`CT_DMRAID, `CT_DMMULTIPATH,
+ `CT_MDPART, `CT_DISK]);
}
+ list<symbol> fields = StorageSettings::FilterTable([ `device, `udev_path, `udev_id, `size, `format,
+ `encrypted, `type, `fs_type, `label, `mount_point,
+ `mount_by, `start_cyl, `end_cyl, `used_by ]);
+
+ map<string, map> target_map = Storage::GetTargetMap();
+
+ term table_header = StorageFields::TableHeader(fields);
+ list<term> table_contents = StorageFields::TableContents(fields, target_map, Predicate);
+
UI::ReplaceWidget(`tree_panel,
Greasemonkey::Transform(
`VBox(
// heading
- `IconAndHeading(_("Hard Disks"), hd_icon),
- `Table(`id(`table), `opt(`keepSorting, `notify),
+ `IconAndHeading(_("Hard Disks"), StorageIcons::hd_icon),
+ `Table(`id(`table), `opt(`keepSorting, `notify, `notifyContextMenu),
table_header, table_contents),
- buttons
- )
+ ArrangeButtons(flatten([
+ [ // push button text
+ `PushButton(`id(`add),`opt(`key_F3), _("Add Partition...")) ],
+ HdButtons(),
+ [ `HStretch() ]
+ ]))
)
+ )
);
// helptext
@@ -98,90 +177,16 @@
}
- void HandleHdMainPanel(any user_data, symbol widget)
+ void HandleHdMainPanel(any user_data, map event)
{
- boolean CheckAndInstallPackages( list <string> pkgs )
- {
- if (Stage::initial())
- return true;
-
- boolean ret = false;
- //switch off pkg-mgmt loading progress dialogs,
- //because it just plain sucks
- PackageCallbacks::RegisterEmptyProgressCallbacks();
- ret = PackageSystem::CheckAndInstallPackages(pkgs);
- PackageCallbacks::RestorePreviousProgressCallbacks();
+ string device = (string) UI::QueryWidget(`id(`table), `CurrentItem);
- return ret;
- }
+ HandleHdButtons( user_data, device, event );
- void CallConfig(string text, list<string> pkgs, string call)
+ switch (Event::IsWidgetContextMenuActivated(event))
{
- boolean doit = true;
-
- if (!Storage::EqualBackupStates("expert-partitioner", "", true))
- {
- doit = Popup::YesNo(text);
- }
-
- if (doit)
- {
- if (pkgs == nil || CheckAndInstallPackages(pkgs))
- {
- if (call != nil)
- WFM::call(call);
- RescanDisks();
- Storage::CreateTargetBackup("expert-partitioner");
-
- UpdateMainStatus();
- UpdateNavigationTree(nil);
- TreePanel::Create();
- }
- }
- }
-
- switch (widget)
- {
- case `rescan:
- // popup text
- CallConfig(_("Rescaning disks cancels all current changes.
-Really rescan disks?"), nil, nil);
- break;
-
- case `iscsi:
- // popup text
- CallConfig(_("Calling iSCSI configuration cancels all current changes.
-Really call iSCSI configuration?"), ["yast2-iscsi-client"], "iscsi-client");
- break;
-
- case `multipath:
- if ((ProductFeatures::GetBooleanFeature("partitioning", "use_separate_multipath_module") == true) ||
- (Mode::normal() && WFM::ClientExists("multipath")))
- // popup text
- CallConfig(_("Calling Multipath configuration cancels all current changes.
-Really call Multipath configuration?"), ["yast2-multipath"], "multipath");
- else
- // popup text
- CallConfig(_("Calling Multipath configuration cancels all current changes.
-Really call Multipath configuration?"), nil, "multipath-simple");
- break;
-
- case `dasd:
- // popup text
- CallConfig(_("Calling DASD configuration cancels all current changes.
-Really call DASD configuration?"), ["yast2-s390"], "dasd");
- break;
-
- case `zfcp:
- // popup text
- CallConfig(_("Calling zFCP configuration cancels all current changes.
-Really call zFCP configuration?"), ["yast2-s390"], "zfcp");
- break;
-
- case `xpram:
- // popup text
- CallConfig(_("Calling XPRAM configuration cancels all current changes.
-Really call XPRAM configuration?"), ["yast2-s390"], "xpram");
+ case `table:
+ EpContextMenuDevice(device);
break;
}
}
@@ -197,23 +202,21 @@
list<symbol> fields = [ `heading_device, `device, `size, `udev_path, `udev_id, `used_by,
`heading_hd, `vendor, `model, `num_cyl, `cyl_size, `bus, `bios_id,
- `disk_label ];
+ `sector_size, `disk_label ];
if (contains([ `CT_MDPART ], ctype))
{
fields = (list<symbol>) merge(fields, [ `heading_md, `raid_type, `chunk_size, `parity_algorithm ]);
}
- if (contains([ `CT_DISK ], ctype))
+ if (contains([ `CT_DISK ], ctype) && target_map[device, "transport"]:`unknown == `fc)
{
fields = (list<symbol>) merge(fields, [`heading_fc, `fc_wwpn, `fc_port_id, `fc_fcp_lun ]);
}
- term buttons = `HBox(
- // push button text
- `PushButton(`id(`delete), _("Delete...")),
- `HStretch()
- );
+ fields = StorageSettings::FilterOverview(fields);
+
+ term buttons = `HBox();
if ((integer) SCR::Read(.target.size, "/usr/sbin/smartctl") > 0)
// push button text (do not translate 'SMART', it is the name of the tool)
@@ -222,12 +225,12 @@
if ((integer) SCR::Read(.target.size, "/sbin/hdparm") > 0)
// push button text (do not translate 'hdparm', it is the name of the tool)
buttons = add(buttons, `PushButton(`id(`hdparm), _("Properties (hdparm)...")));
-
+
UI::ReplaceWidget(`tab_panel,
`VBox(
`HStretch(),
- StorageFields::Overview(StorageSettings::FilterOverview(fields), target_map, device),
- buttons
+ StorageFields::Overview(fields, target_map, device),
+ add(buttons, `HStretch())
)
);
@@ -239,25 +242,19 @@
}
- void HandleHdDiskOverviewTab(any user_data, symbol widget)
+ void HandleHdDiskOverviewTab(any user_data, map event)
{
string disk_device = (string) user_data;
- switch (widget)
+ switch (Event::IsWidgetActivated(event))
{
- case `delete:
- {
- EpDeleteDisk(disk_device);
- break;
- }
-
case `smart:
{
map<string, map> target_map = Storage::GetTargetMap();
map disk = target_map[disk_device]:$[];
if (disk["type"]:`CT_UNKNOWN != `CT_DISK || substring(disk_device, 0, 9) == "/dev/dasd")
{
- Popup::Error(_("Smart is not available for this disk."));
+ Popup::Error(_("SMART is not available for this disk."));
break;
}
DisplayCommandOutput(sformat("/usr/sbin/smartctl --health '%1'", disk_device));
@@ -270,7 +267,7 @@
map disk = target_map[disk_device]:$[];
if (disk["type"]:`CT_UNKNOWN != `CT_DISK || substring(disk_device, 0, 9) == "/dev/dasd")
{
- Popup::Error(_("HD Parm is not available for this disk."));
+ Popup::Error(_("hdparm is not available for this disk."));
break;
}
DisplayCommandOutput(sformat("/sbin/hdparm -aAgr '%1'", disk_device));
@@ -298,16 +295,22 @@
term table_header = StorageFields::TableHeader(fields);
list<term> table_contents = StorageFields::TableContents(fields, target_map, Predicate);
- list<term> expert_cmds = [
- `item(`id(`create_partition_table),
- // menu entry text
- _("Create New Partition Table")),
- `item(`id(`clone_disk),
- // menu entry text
- _("Clone This Disk"))
- ];
+ list<term> expert_cmds = [];
+
+ if (!String::StartsWith(device, "/dev/dasd"))
+ {
+ expert_cmds = add(expert_cmds,
+ `item(`id(`create_partition_table),
+ // menu entry text
+ _("Create New Partition Table")));
+ }
+
+ expert_cmds = add(expert_cmds,
+ `item(`id(`clone_disk),
+ // menu entry text
+ _("Clone This Disk")));
- if (Arch::s390() && search(device, "/dev/dasd") == 0)
+ if (String::StartsWith(device, "/dev/dasd"))
{
expert_cmds = add(expert_cmds,
`item(`id(`dasdfmt),
@@ -318,21 +321,18 @@
UI::ReplaceWidget(`tab_panel,
`VBox(
- `Table(`id(`table), `opt(`keepSorting, `notify),
+ DiskBarGraph(device),
+ `Table(`id(`table), `opt(`keepSorting, `notify, `notifyContextMenu),
table_header, table_contents),
`HBox(
- // push button text
- `PushButton(`id(`add),`opt(`key_F3), _("Add...")),
- // push button text
- `PushButton(`id(`edit),`opt(`key_F4), _("Edit...")),
- // push button text
- `PushButton(`id(`resize), `opt(`key_F6), _("Resize...")),
- // push button text
- `PushButton(`id(`delete), `opt(`key_F5), _("Delete...")),
- `HStretch(),
- // menu button text
- `MenuButton(`opt(`key_F7), _("Expert..."), expert_cmds)
- )
+ ArrangeButtons(flatten([
+ [ // push button text
+ `PushButton(`id(`add),`opt(`key_F3), _("Add...")) ],
+ HdButtons(),
+ [ `HStretch(),
+ // menu button text
+ `MenuButton(`opt(`key_F7), _("Expert..."), expert_cmds)]
+ ])))
));
// helptext
@@ -344,29 +344,15 @@
}
- void HandleHdDiskPartitionsTab(any user_data, symbol widget)
+ void HandleHdDiskPartitionsTab(any user_data, map event)
{
string disk_device = (string) user_data;
string part_device = (string) UI::QueryWidget(`id(`table), `CurrentItem);
- switch (widget)
- {
- case `add:
- EpCreatePartition(disk_device);
- break;
-
- case `edit:
- EpEditPartition(part_device);
- break;
-
- case `resize:
- EpResizePartition(part_device);
- break;
-
- case `delete:
- EpDeletePartition(part_device);
- break;
+ HandleHdButtons( disk_device, part_device, event );
+ switch (Event::IsMenu(event))
+ {
case `create_partition_table:
EpCreatePartitionTable(disk_device);
break;
@@ -379,6 +365,14 @@
EpDasdfmtDisk(disk_device);
break;
}
+
+ switch (Event::IsWidgetContextMenuActivated(event))
+ {
+ case `table:
+ EpContextMenuDevice(part_device);
+ break;
+ }
+
UI::SetFocus(`id(`table));
}
@@ -409,8 +403,8 @@
// helptext
string helptext = _("<p>This view shows all devices used by the
-selected hard disk. The table is non-empty only for BIOS RAIDs and Multipath
-Disks.</p>");
+selected hard disk. The view is only available for BIOS RAIDs, partitioned
+software RAIDs and Multipath Disks.</p>");
Wizard::RestoreHelp(helptext + StorageFields::TableHelptext(fields));
}
@@ -431,19 +425,27 @@
`devices : $[ `create : CreateHdDiskDevicesTab,
`user_data : user_data ] ];
+ symbol ctype = target_map[device, "type"]:`CT_DISK;
+
+ list<term> tabs = [
+ // tab heading
+ `item(`id(`overview), _("&Overview")),
+ // tab heading
+ `item(`id(`partitions), _("&Partitions"))
+ ];
+
+ if (contains([ `CT_DMRAID, `CT_DMMULTIPATH, `CT_MDPART ], ctype))
+ {
+ // tab heading
+ tabs = add(tabs, `item(`id(`devices), _("&Used Devices")));
+ }
+
UI::ReplaceWidget(`tree_panel,
Greasemonkey::Transform(
`VBox(
// heading
- `IconAndHeading(sformat(_("Hard Disk: %1"), device), hd_icon),
- `DumbTab(`id(`tab), [
- // tab heading
- `item(`id(`overview), _("&Overview")),
- // tab heading
- `item(`id(`partitions), _("&Partitions")),
- // tab heading
- `item(`id(`devices), _("&Used Devices"))
- ],
+ `IconAndHeading(sformat(_("Hard Disk: %1"), device), StorageIcons::hd_icon),
+ `DumbTab(`id(`tab), tabs,
`ReplacePoint(`id(`tab_panel), TabPanel::empty_panel)
)
)
@@ -453,9 +455,9 @@
}
- void HandleHdDiskPanel(any user_data, symbol widget)
+ void HandleHdDiskPanel(any user_data, map event)
{
- TabPanel::Handle(widget);
+ TabPanel::Handle(event);
}
@@ -475,18 +477,13 @@
`VBox(
`HStretch(),
// heading
- `IconAndHeading(sformat(_("Partition: %1"), device), hd_part_icon),
+ `IconAndHeading(sformat(_("Partition: %1"), device), StorageIcons::hd_part_icon),
StorageFields::Overview(fields, target_map, device),
- `HBox(
- // push button text
- `PushButton(`id(`edit), `opt(`key_F4), _("Edit...")),
- // push button text
- `PushButton(`id(`resize), `opt(`key_F6), _("Resize...")),
- // push button text
- `PushButton(`id(`delete), `opt(`key_F5), _("Delete...")),
- `HStretch()
- )
- )
+ ArrangeButtons(flatten([
+ HdButtons(),
+ [ `HStretch() ]
+ ]))
+ )
)
);
@@ -498,24 +495,11 @@
}
- void HandleHdPartitionPanel(any user_data, symbol widget)
+ void HandleHdPartitionPanel(any user_data, map event)
{
string part_device = (string) user_data;
- switch (widget)
- {
- case `edit:
- EpEditPartition(part_device);
- break;
-
- case `resize:
- EpResizePartition(part_device);
- break;
-
- case `delete:
- EpDeletePartition(part_device);
- break;
- }
+ HandleHdButtons( nil, part_device, event);
UI::SetFocus(`id(`text));
}
}
Added: branches/SuSE-Code-11-SP2-Branch/storage/storage/src/include/ep-import.ycp
URL: http://svn.opensuse.org/viewcvs/yast/branches/SuSE-Code-11-SP2-Branch/stora…
==============================================================================
--- branches/SuSE-Code-11-SP2-Branch/storage/storage/src/include/ep-import.ycp (added)
+++ branches/SuSE-Code-11-SP2-Branch/storage/storage/src/include/ep-import.ycp Tue May 17 13:39:44 2011
@@ -0,0 +1,417 @@
+/**
+ * File: ep-import.ycp
+ * Package: yast2-storage
+ * Summary: Expert Partitioner
+ * Authors: Michael Hager <mike(a)suse.de>
+ * Johannes Buchhold <jbuch(a)suse.de>
+ * Arvin Schnell <aschnell(a)suse.de>
+ */
+{
+ textdomain "storage";
+
+
+ import "Directory";
+ import "FileSystems";
+ import "Label";
+ import "Popup";
+ import "Storage";
+ import "StorageFields";
+ import "StorageSettings";
+
+
+ string MountVar(map var, map root, string rdev, string mp, map<string, map> target_map)
+ {
+ string ret = "";
+ boolean mount_success = false;
+ y2milestone("MountVar rdev:%1 mp:%2 var:%3 root:%4", rdev, mp, var, root);
+ if( var["size_k"]:0>0 )
+ {
+ ret = var["device"]:"";
+ }
+ else
+ {
+ list<string> ds = maplist( string d, map disk, target_map, ``(d));
+ y2milestone("MountVar ds:%1", ds);
+ ds = filter( string d, ds, ``(target_map[d,"type"]:`CT_UNKNOWN==`CT_DISK));
+ y2milestone("MountVar ds:%1", ds);
+ map rootm = Storage::GetDiskPartition( rdev );
+ map rootf = Storage::GetDiskPartition( root["device"]:"" );
+ map varf = Storage::GetDiskPartition( var["device"]:"" );
+ if( rootf["disk"]:""==varf["disk"]:"" )
+ {
+ ret = Storage::GetDeviceName( rootm["disk"]:"", varf["nr"]:(any)0 );
+ }
+ else if( size(ds)==1 )
+ {
+ ret = Storage::GetDeviceName( ds[0]:"", varf["nr"]:(any)0 );
+ }
+ else if( size(ds)>1 )
+ {
+ integer i = 0;
+ while( i<size(ds) && isempty(ret) )
+ {
+ ret = Storage::GetDeviceName( ds[i]:"", varf["nr"]:(any)0 );
+ if( !isempty(Storage::GetPartition( target_map, ret )) &&
+ Storage::Mount( ret, mp ) )
+ {
+ map d = (map)SCR::Read( .target.stat, mp+"/lib/hardware" );
+ y2milestone("MountVar d:%1", d);
+ if( !d["isdir"]:false )
+ ret = "";
+ Storage::Umount( ret );
+ }
+ else
+ ret = "";
+ i = i+1;
+ }
+ }
+ }
+ if( !isempty(ret) && !Storage::Mount( ret, mp ))
+ ret = "";
+ y2milestone("MountVar ret:%1", ret);
+ return ret;
+ }
+
+
+ /**
+ * Find and read fstab by installation. Scan existing partitions.
+ * @parm target_map all targets
+ * @parm search_point mount point where partitions can be mounted
+ * @return map<string, list> map with device and fstab data found
+ */
+ map<string, list> FindExistingFstabs(map<string, map> target_map, string search_point)
+ {
+ map<string, list> fstabs = $[];
+
+ foreach( string disk_device, map disk, target_map, {
+
+ list<map> partitions = filter(map part, disk["partitions"]:[], {
+ return contains(FileSystems::possible_root_fs, part["detected_fs"]:`unknown);
+ });
+
+ foreach(map part, partitions, {
+
+ string part_device = part["device"]:"";
+
+ // try to mount
+ boolean mount_success = Storage::Mount(part_device, search_point);
+
+ if( mount_success &&
+ SCR::Read(.target.size, search_point+"/etc/fstab") > 0 )
+ {
+ list<map> fstab = Storage::ReadFstab( search_point+"/etc" );
+ y2milestone("FindExistingFstabs fstab:%1", fstab);
+ if (!isempty(fstab))
+ {
+ if( find( map p, fstab, ``(p["size_k"]:0==0 ))!=nil )
+ {
+ string vardev = "";
+ map var = find( map p, fstab, ``(p["mount"]:""=="/var"));
+ map root = find( map p, fstab, ``(p["mount"]:""=="/"));
+ y2milestone("FindExistingFstabs var:%1", var);
+ if( var != nil )
+ {
+ vardev = MountVar( var, root, part_device,
+ search_point+"/var", target_map );
+ y2milestone("FindExistingFstabs vardev:%1", vardev);
+ }
+ map dmap = Storage::BuildDiskmap( $[] );
+ if (!isempty(dmap))
+ {
+ y2milestone("FindExistingFstabs dmap:%1", dmap);
+ y2milestone("FindExistingFstabs fstab:%1", fstab);
+ fstab = maplist( map p, fstab, {
+ if( p["size_k"]:0 == 0 )
+ p["device"] = Storage::HdDiskMap( p["device"]:"", dmap );
+ return( p );
+ });
+ y2milestone("FindExistingFstabs fstab:%1", fstab);
+ }
+ integer s = size(fstab);
+ fstab = filter( map p, fstab, ``(Storage::CanEdit(p,false)));
+ if (s != size(fstab))
+ y2milestone("FindExistingFstabs fstab:%1", fstab);
+ if (!isempty(vardev))
+ Storage::Umount( vardev );
+ }
+
+ if (!isempty(fstab))
+ fstabs[part_device] = fstab;
+ }
+ }
+
+ // unmount
+ if( mount_success )
+ Storage::Umount(part_device);
+ });
+ });
+ y2milestone("FindExistingFstabs size(fstabs):%1", size(fstabs));
+ y2milestone("FindExistingFstabs fstabs:%1", fstabs);
+ return fstabs;
+ }
+
+
+ /**
+ * Scan and Read and return fstabs.
+ * @parm target_map all targets
+ * @return map<string, list> map with device and fstab data found
+ */
+ map<string, list> ScanAndReadExistingFstabs(map<string, map> target_map)
+ {
+ string search_point = Directory::tmpdir + "/tmp-mp";
+
+ if (!((map) SCR::Read(.target.stat, search_point))["isdir"]:false)
+ SCR::Execute(.target.mkdir, search_point);
+
+ map<string, list> fstabs = FindExistingFstabs(target_map, search_point);
+
+ return fstabs;
+ }
+
+
+ /**
+ * Merge fstab with target_map.
+ */
+ map<string, map> AddFstabToTargetMap(map<string, map> target_map, list<map> fstab, boolean format_sys)
+ {
+ y2milestone("AddFstabToTargetMap fstab:%1", fstab);
+
+ map<string, map> new_target_map = mapmap(string disk_device, map disk, target_map, {
+
+ disk["partitions"] = maplist(map partition, disk["partitions"]:[], {
+
+ string part_device = partition["device"]:"";
+
+ if (!Storage::IsInstallationSource(part_device))
+ {
+ foreach(map fstab_entry, fstab, {
+
+ string dev_fstab = fstab_entry["device"]:"";
+ string mount_fstab = fstab_entry["mount"]:"";
+
+ if (dev_fstab == part_device)
+ {
+ partition["mount"] = mount_fstab;
+ if (format_sys && FileSystems::IsSystemMp(mount_fstab, false))
+ partition["format"] = true;
+ if (!isempty(fstab_entry["fstopt"]:"") && fstab_entry["fstopt"]:"" != "default")
+ partition["fstopt"] = fstab_entry["fstopt"]:"";
+ if (fstab_entry["mountby"]:`device != `device)
+ partition["mountby"] = fstab_entry["mountby"]:`device;
+ if (fstab_entry["enc_type"]:`none != `none)
+ partition["enc_type"] = fstab_entry["enc_type"]:`none;
+ }
+ });
+ }
+
+ return partition;
+ });
+
+ return $[ disk_device : disk ];
+ });
+
+ y2milestone("AddFstabToTargetMap new_target_map:%1", new_target_map);
+
+ return new_target_map;
+ }
+
+
+ string FstabAddDialogHelptext()
+ {
+ // help text, richtext format
+ string helptext = _("<p>YaST2 has scanned your hard disks and found
+one or several existing Linux systems with mount points. The old mount points
+are shown in the table.</p>");
+
+ // help text, richtext format
+ helptext = helptext + _("<p>You can choose whether the existing system
+volumes, e.g. / and /usr, will be formatted during the
+installation. Non-system volumes, e.g. /home, will not be formatted.</p>");
+
+ return helptext;
+ }
+
+
+ /**
+ * Scan exiting partitions for fstab files and if one found read the mountpoints
+ * from the fstab file and build a new target_map.
+ * Ask the user if he like to use the new or old target_map
+ * (with or without found mountpoints)
+ */
+ string FstabAddDialog(map<string, map> target_map, map<string, list> fstabs, boolean& format_sys)
+ {
+ y2milestone("FstabAddDialog target_map:%1", target_map);
+ y2milestone("FstabAddDialog fstabs:%1", fstabs);
+
+ if (isempty(fstabs))
+ {
+ // popup text
+ Popup::Message(_("No previous system with mount points was detected."));
+ return "";
+ }
+
+ list<string> devices = maplist(string device, list fstab, fstabs, { return device; });
+
+ list<symbol> fields = StorageSettings::FilterTable([ `device, `size, `type, `fs_type,
+ `label, `mount_point ]);
+
+ term table_header = StorageFields::TableHeader(fields);
+
+ term navigate_buttons = `Empty();
+ if (size(fstabs) > 1)
+ {
+ navigate_buttons = `HBox(
+ `PushButton(`id(`show_prev), _("Show &Previous")),
+ `PushButton(`id(`show_next), _("Show &Next"))
+ );
+ }
+
+ UI::OpenDialog(
+ `opt(`decorated),
+ `VBox( `VSpacing(0.45),
+ // dialog heading
+ `Left(`Heading(_("Import Mount Points from existing System:"))),
+ `MarginBox(1, 0.5,
+ `VBox(
+ `Left(`ReplacePoint(`id(`device), `Empty())),
+ `MinSize(60, 8, `Table(`id(`table), `opt(`keepSorting), table_header, [])),
+ `VSpacing(0.45),
+ navigate_buttons,
+ `VSpacing(0.45),
+ // checkbox label
+ `Left(`CheckBox(`id(`format_sys), _("Format system volumes"), true))
+ )
+ ),
+ `ButtonBox(
+ `PushButton(`id(`help), `opt(`helpButton), Label::HelpButton()),
+ // pushbutton label
+ `PushButton(`id(`ok), `opt(`default), _("Import")),
+ `PushButton(`id(`cancel), Label::CancelButton())
+ )
+ )
+ );
+
+ UI::ChangeWidget(`help, `HelpText, FstabAddDialogHelptext());
+
+ symbol userinput = `none;
+ integer idx = 0;
+
+ repeat
+ {
+ string device = devices[idx]:"";
+
+ list<map> fstab = (list<map>) fstabs[device]:[];
+
+ map<string, map> new_target_map = AddFstabToTargetMap(target_map, fstab, format_sys);
+
+ // popup text %1 is replaced by a device name (e.g. /dev/hda1)
+ string str = sformat(_("/etc/fstab found on %1 contains:"), device);
+ UI::ReplaceWidget(`id(`device), `Label(str));
+
+ list<term> table_contents = StorageFields::TableContents(fields, new_target_map,
+ StorageFields::PredicateMountpoint);
+ UI::ChangeWidget(`id(`table), `Items, table_contents);
+ UI::ChangeWidget(`id(`table), `CurrentItem, nil);
+
+ if (size(fstabs) > 1)
+ {
+ UI::ChangeWidget(`id(`show_prev), `Enabled, idx > 0);
+ UI::ChangeWidget(`id(`show_next), `Enabled, idx < size(fstabs) - 1);
+ }
+
+ userinput = (symbol) UI::UserInput();
+
+ switch (userinput)
+ {
+ case `show_next:
+ idx = idx + 1;
+ break;
+
+ case `show_prev:
+ idx = idx - 1;
+ break;
+ }
+ y2milestone( "idx %1", idx );
+ }
+ until( userinput == `ok || userinput == `cancel );
+
+ format_sys = (boolean) UI::QueryWidget(`id(`format_sys), `Value);
+
+ UI::CloseDialog();
+
+ string device = userinput == `ok ? devices[idx]:"" : "";
+ y2milestone("FstabAddDialog device:%1", device);
+ return device;
+ }
+
+
+ void ImportMountPoints()
+ {
+ Storage::CreateTargetBackup("import");
+ Storage::ResetOndiskTarget();
+
+ map<string, map> target_map = Storage::GetOndiskTarget();
+
+ map<string, list> fstabs = ScanAndReadExistingFstabs(target_map);
+ y2milestone("ImportMountPoints fstabs:%1", fstabs);
+
+ boolean format_sys = true;
+ string device = FstabAddDialog(target_map, fstabs, format_sys);
+ map<string, map> new_target_map = $[];
+ boolean import_ok = false;
+ if (!isempty(device))
+ {
+ y2milestone("ImportMountPoints device:%1", device);
+ list<map> fstab = (list<map>) fstabs[device]:[];
+ import_ok = true;
+
+ new_target_map = AddFstabToTargetMap(target_map, fstab, format_sys);
+
+ foreach(string d, map disk, new_target_map, {
+ foreach(map p, disk["partitions"]:[], {
+ string key = (p["type"]:`unknown != `loop) ? (p["device"]:"error") : (p["fpath"]:"error");
+ if (!isempty(p["mount"]:"") && p["enc_type"]:`none!=`none &&
+ !p["tmpcrypt"]:false && Storage::NeedCryptPwd(key) )
+ {
+ boolean ok = false;
+ string dev = p["device"]:"";
+ string pwd = "";
+ do
+ {
+ ok = false;
+ pwd = DlgPasswdCryptFs( dev, 1, false, false );
+ if( pwd != nil && !isempty(pwd) )
+ {
+ if( Storage::CheckCryptOk( dev, pwd, true,
+ false ) )
+ {
+ ok = Storage::SetCryptPwd( dev, pwd ) &&
+ Storage::SetCrypt( dev, true, false );
+ }
+ else
+ {
+ Popup::Error(_("Wrong Password provided."));
+ }
+ }
+ else if( size(pwd)==0 )
+ {
+ ok = true;
+ import_ok = false;
+ }
+ }
+ while( !ok );
+
+ }
+ });
+ });
+
+ }
+ if( import_ok )
+ Storage::SetTargetMap(new_target_map);
+ else
+ Storage::RestoreTargetBackup("import");
+
+ Storage::DisposeTargetBackup("import");
+ }
+
+}
Modified: branches/SuSE-Code-11-SP2-Branch/storage/storage/src/include/ep-lib.ycp
URL: http://svn.opensuse.org/viewcvs/yast/branches/SuSE-Code-11-SP2-Branch/stora…
==============================================================================
--- branches/SuSE-Code-11-SP2-Branch/storage/storage/src/include/ep-lib.ycp (original)
+++ branches/SuSE-Code-11-SP2-Branch/storage/storage/src/include/ep-lib.ycp Tue May 17 13:39:44 2011
@@ -3,42 +3,141 @@
* Package: yast2-storage
* Summary: Expert Partitioner
* Authors: Arvin Schnell <aschnell(a)suse.de>
+ *
+ * This file must only be included in other Expert Partitioner files ("ep-*.ycp").
*/
{
textdomain "storage";
+ boolean EpDeleteVolumeGroup(string device);
+ boolean ConfirmRecursiveDelete(string device, list <string> partitions, string headline, string text_before, string text_after );
+
+
list<string> AddedToList(list<string> old, list<string> new)
{
- return filter(string tmp, new, { return !contains(old, tmp); });
+ return multiset::difference(sort(new), sort(old));
}
list<string> RemovedFromList(list<string> old, list<string> new)
{
- return filter(string tmp, old, { return !contains(new, tmp); });
+ return multiset::difference(sort(old), sort(new));
+ }
+
+
+ // Calculates the devices from the devices, devices_add and devices_rem entries
+ // in data.
+ list<string> MergeDevices(map<string, any> data)
+ {
+ list<string> devices = sort((list<string>) data["devices"]:[]);
+ list<string> devices_add = sort((list<string>) data["devices_add"]:[]);
+ list<string> devices_rem = sort((list<string>) data["devices_rem"]:[]);
+
+ devices = multiset::union(devices, devices_add);
+ devices = multiset::difference(devices, devices_rem);
+
+ return devices;
}
+ void SplitDevice(map<string, map> target_map, string device, map& disk, map& part)
+ {
+ map disk_tmp = target_map[device]:nil;
+ map part_tmp = nil;
+
+ if (disk_tmp == nil)
+ {
+ part_tmp = Storage::GetPartition( target_map, device );
+ disk_tmp = Storage::GetDisk( target_map, device );
+ }
+
+ disk = disk_tmp;
+ part = part_tmp;
+ }
+
+
+ /**
+ * Must be called before removing device.
+ */
string ParentDevice(string device)
{
map<string, map> target_map = Storage::GetTargetMap();
- map disk = target_map[device]:nil;
+ map disk = nil;
map part = nil;
- if (disk == nil)
+ SplitDevice(target_map, device, disk, part);
+
+ return disk["device"]:"";
+ }
+
+
+ boolean ConfirmDeletingUsedDevice( map tg, map <string, any> part, symbol used_by )
+ {
+ string device = part["device"]:"";
+ string used_by_device = part["used_by_device"]:"";
+
+ switch (used_by)
{
- foreach(string s, map d, target_map, {
- part = find(map p, d["partitions"]:[], { return p["device"]:"" == device; });
- if (part != nil) {
- disk = d;
- break;
- }
- });
+ case `UB_LVM:
+ {
+ list<string> volumes = Storage::GetAffectedDevices( device );
+ return ( ConfirmRecursiveDelete( device, volumes,
+ _("Confirm Deleting Partition Used by LVM"),
+ sformat(_("The selected partition is used by volume group \"%1\"
+To keep system in consistent state, the following volume group
+and its logical volumes will be deleted:"), used_by_device),
+ sformat( _("Delete partition \"%1\" and volume group \"%2\" now?"), device, used_by_device)
+ ));
+ break;
+ }
+ case `UB_MD:
+ {
+ list<string> volumes = Storage::GetAffectedDevices( device );
+ return ( ConfirmRecursiveDelete( device, volumes,
+ _("Confirm Deleting Partition Used by RAID"),
+ sformat(_("The selected partition belongs to RAID \"%1\"
+To keep system in consistent state, the following
+RAID device will be deleted:"), used_by_device),
+ sformat( _("Delete partition \"%1\" and RAID \"%2\" now?"), device, used_by_device)
+ ));
+
+ }
+ default:
+ break;
}
- return disk["device"]:"";
+ return false;
+ }
+
+ /**
+ * Must be called before removing device.
+ */
+ string NextDeviceAfterDelete(string device)
+ {
+ map<string, map> target_map = Storage::GetTargetMap();
+
+ string parent = ParentDevice(device);
+
+ list<string> partitions = maplist(map part, target_map[parent, "partitions"]:[], {
+ return part["device"]:"";
+ });
+
+ integer index = -1;
+ foreach(integer i, Integer::Range(size(partitions)), {
+ if (partitions[i]:"" == device)
+ index = i;
+ });
+
+ string ret = "";
+ if (index > 0)
+ ret = partitions[index - 1]:"";
+ else if (size(partitions) > 1)
+ ret = partitions[1]:"";
+
+ y2milestone("NextDeviceAfterDelete device:%1 ret:%2", device, ret);
+ return ret;
}
@@ -69,16 +168,11 @@
{
return false;
}
- else if( tg[id,"type"]:`CT_UNKNOWN == `CT_LVM )
- {
- string current_vg = substring( tg[id,"device"]:"", 5 );
- HandleRemoveVg( tg, current_vg );
- }
else if( tg[id,"type"]:`CT_UNKNOWN == `CT_DMRAID )
{
if( Popup::YesNo( sformat(_("Really delete BIOS RAID %1?"), id )))
{
- if( deleteAllDevPartitions( disk, Stage::initial(), false ))
+ if (deleteAllDevPartitions(disk, Stage::initial()))
Storage::DeleteDmraid( id );
return true;
}
@@ -86,20 +180,19 @@
// YesNo popup text %1 is replaced by a disk name e.g. /dev/hda
else if( Popup::YesNo( sformat(_("Really delete all partitions on %1?"), id )))
{
- deleteAllDevPartitions( disk, Stage::initial(), false );
+ deleteAllDevPartitions(disk, Stage::initial());
return true;
}
}
else if( part["type"]:`unknown==`lvm )
{
- if( !check_device_delete( part, false, Stage::initial(), $[] ))
+ if (!check_device_delete(part, Stage::initial(), $[]))
{
return false;
}
else
{
- HandleRemoveLv( tg, id );
- return true;
+ return HandleRemoveLv( tg, id );
}
}
else
@@ -120,11 +213,27 @@
{
return false;
}
- if( part["type"]:`primary != `extended &&
- !check_device_delete( part, false, Stage::initial(),
- disk ))
+
+ if( part["type"]:`primary != `extended )
{
- return false;
+ symbol used_by = check_devices_used( [ part ], false);
+
+ if ( used_by != `UB_NONE)
+ {
+ if (ConfirmDeletingUsedDevice( tg, part, used_by ))
+ {
+ boolean recursive = Storage::GetRecursiveRemoval();
+ Storage::SetRecursiveRemoval( true );
+ Storage::DeleteDevice(part["device"]:"");
+ Storage::SetRecursiveRemoval( recursive );
+ return true;
+ }
+ else
+ return false;
+ }
+
+ if (!check_device_delete(part, Stage::initial(), disk))
+ return false;
}
/////////////////////////////////////////////////////
@@ -145,15 +254,9 @@
Storage::DeleteLoop( disk["device"]:"",
part["fpath"]:"", true );
}
- if( part["type"]:`unknown == `nfs )
- {
- Storage::DeleteDevice( "/dev/nfs",
- part["device"]:"" );
- }
else
{
- Storage::DeleteDevice( disk["device"]:"",
- part["device"]:"" );
+ Storage::DeleteDevice(part["device"]:"");
}
return true;
}
@@ -163,57 +266,192 @@
}
- void ImportMountPoints()
+ term DiskBarGraph(string device)
{
- map<string,map> od = (map<string,map>)Storage::GetOndiskTarget();
- list<list> fstab = scanAndReadExistingFstab( od );
- y2milestone( "adapt_mp fstab %1", fstab );
- list ti = maplist( list e, fstab, ``(AddFstabToData( od, (list<map>)e)[1]:$[]));
- y2milestone( "adapt_mp ti %1", ti );
-
- integer idx = FstabAddDialog( ti );
- if( idx>=0 )
- {
- od = (map<string,map>)Storage::GetOndiskTarget();
- y2milestone( "adapt_mp use fstab idx %1", idx );
- ti = AddFstabToData( od, (list<map>)fstab[idx]:[] );
- Storage::ResetOndiskTarget();
- boolean import_ok = true;
- foreach( string d, map disk, ti[0]:$[],
- ``{
- foreach( map p, disk["partitions"]:[],
- ``{
- string key = (p["type"]:`unknown != `loop) ? (p["device"]:"error") : (p["fpath"]:"error");
- if( size(p["mount"]:"")>0 && p["enc_type"]:`none!=`none &&
- !p["tmpcrypt"]:false && Storage::NeedCryptPwd(key) )
- {
- boolean ok = false;
- string dev = p["device"]:"";
- string pwd = "";
- do
- {
- ok = false;
- pwd = DlgCreateCryptFs( dev, 1, false, false );
- if( pwd != nil && size(pwd)>0 )
- {
- if( Storage::CheckCryptOk( dev, pwd ) )
- {
- ok = Storage::SetCryptPwd( dev, pwd ) &&
- Storage::SetCrypt( dev, true, false );
- }
- }
- else if( size(pwd)==0 )
- {
- ok = true;
- import_ok = false;
- }
- }
- while( !ok );
- }
- });
- });
- if( import_ok )
- Storage::SetTargetMap(ti[0]:$[]);
+ if (!UI::HasSpecialWidget(`BarGraph))
+ return `Empty();
+
+ map<string, map> target_map = Storage::GetTargetMap();
+
+ map disk = nil;
+ map part = nil;
+ SplitDevice(target_map, device, disk, part);
+
+ if (Storage::IsUsedBy(disk))
+ return `Empty();
+
+ list <integer> bits = [];
+ list <string> labels = [];
+
+ void AddSegment(float bit, string label, integer size_k)
+ {
+ // Guarantee some minimal share (1%) of total graph width to the segment.
+ // Prevents small partitions e.g. swaps from disappearing completely.
+ bits = add(bits, Integer::Clamp(1000 * bit, 10, 1000));
+ labels = add(labels, label + "\n" + Storage::KByteToHumanString(size_k));
}
+
+ switch (disk["type"]:`CT_UNKNOWN)
+ {
+ case `CT_DISK:
+ case `CT_DMRAID:
+ case `CT_DMMULTIPATH:
+ case `CT_MDPART:
+ {
+ string emptyspace = _("Unpartitioned");
+
+ // Filter out extended partitions
+ list <map> partitions = (list <map>) filter ( map one_part, disk["partitions"]:[], {
+ return ( (one_part["type"]:`none == `primary) || (one_part["type"]:`none == `logical) );
+ });
+ // and sort the remaining ones by start cyl
+ partitions = (list <map> ) sort (map m, map n, partitions, {
+ return Region::Start( m["region"]:[] ) < Region::Start( n["region"]:[] );
+ });
+
+ // Clean disk (or 1 big extended partition)
+ if (isempty(partitions))
+ {
+ bits = [100];
+ labels = [ emptyspace + "\n" + Storage::KByteToHumanString(disk["size_k"]:0)];
+ }
+ else
+ {
+ integer i = 0;
+ integer part_count = size(partitions);
+ integer ccyl = 0;
+ integer endcyl = disk["cyl_count"]:1;
+
+ while (ccyl < endcyl)
+ {
+ map part = partitions[ i ]:$[];
+ list <integer> region = partitions[ i, "region" ]:[];
+ ccyl = Region::Start( region );
+ integer next_cyl = 0;
+
+ // this is the last partition in a row, look at the last cylinder of the disk
+ if ( (i+1) == part_count)
+ {
+ next_cyl = endcyl;
+ }
+ // somewhere in the middle, look where the next partition starts
+ else
+ {
+ next_cyl = Region::Start( partitions[ i+1, "region" ]:[] );
+ }
+
+ float tmp1 = (float) Region::Length(region) / (float) disk["cyl_count"]:1;
+ if (tmp1 >= 0.0)
+ AddSegment(tmp1, part["name"]:"", part["size_k"]:0);
+
+ // Now there is some xtra space between the end of this partition and the start of the next one
+ // or the end of the disk if
+ // 1. end +1th cyl is not the next one
+ // 2. end cyl is not the same as the next one (yeah, partitions may share a cylinder)
+ if ( ( Region::End( region ) != next_cyl ) &&
+ ( (Region::End( region) + 1) != next_cyl ) )
+ {
+ float tmp2 = (float) (next_cyl - Region::End(region)) / (float) disk["cyl_count"]:1;
+ if (tmp2 >= 0.0)
+ AddSegment(tmp2, emptyspace, ((next_cyl - Region::End(region)) * disk["cyl_size"]:1) / 1024);
+ }
+
+ ccyl = next_cyl;
+ i = i+1;
+ }
+ }
+ }
+ break;
+
+ case `CT_LVM:
+ {
+ string emptyspace = _("Unallocated");
+
+ list <map> partitions = disk["partitions"]:[];
+
+ integer disk_size_k = disk["size_k"]:1;
+ integer disk_free_k = disk_size_k;
+
+ foreach(map partition, partitions, {
+ integer size_k = partition["size_k"]:0;
+ disk_free_k = disk_free_k - size_k;
+ AddSegment((float) size_k / (float) disk_size_k, partition["name"]:"", size_k);
+ });
+
+ if (disk_free_k > 0)
+ AddSegment((float) disk_free_k / (float) disk_size_k, emptyspace, disk_free_k);
+ }
+ break;
+ }
+
+ return `BarGraph(bits, labels);
}
+
+
+ string CompleteSummary()
+ {
+ string part_summary = Storage::ChangeText();
+ if (isempty(part_summary))
+ part_summary = HTML::Heading(_("<p>No changes to partitioning.</p>"));
+ else
+ part_summary = HTML::Heading(_("<p>Changes to partitioning:</p>")) + part_summary;
+
+ string config_summary = HTML::Heading(_("<p>No changes to storage settings.</p>"));
+ if (StorageSettings::GetModified())
+ config_summary = HTML::Heading(_("<p>Storage settings:</p>")) + StorageSettings::Summary();
+
+ return part_summary + config_summary;
+ }
+
+
+ term ArrangeButtons(list<term> buttons)
+ {
+ // Unfortunately the UI does not provide functionality to rearrange
+ // buttons in two lines if the available space is limited. This
+ // implementation in YCP has several drawbacks, e.g. it does not know
+ // anything about the font size or the actually available space nor is
+ // it run when the dialog is resized.
+
+ map display_info = UI::GetDisplayInfo();
+ boolean textmode = display_info["TextMode"]:false;
+ integer width = display_info["DefaultWidth"]:1024;
+
+ integer max_buttons = 6;
+
+ if ((textmode && width <= 140) || (!textmode && Mode::installation() && width <= 800))
+ max_buttons = 3;
+
+ term ret = `VBox();
+
+ term line = `HBox();
+
+ integer i = 0;
+ integer j = 0;
+
+ foreach(term button, buttons, {
+
+ line = add(line, button);
+ i = i + 1;
+
+ if (contains([ `PushButton, `MenuButton ], symbolof(button)))
+ {
+ j = j + 1;
+
+ if (j == max_buttons)
+ {
+ if (i != size(buttons))
+ line = add(line, `HStretch());
+
+ ret = add(ret, line);
+ line = `HBox();
+ j = 0;
+ }
+ }
+ });
+
+ ret = add(ret, line);
+
+ return ret;
+ }
+
}
Modified: branches/SuSE-Code-11-SP2-Branch/storage/storage/src/include/ep-log.ycp
URL: http://svn.opensuse.org/viewcvs/yast/branches/SuSE-Code-11-SP2-Branch/stora…
==============================================================================
--- branches/SuSE-Code-11-SP2-Branch/storage/storage/src/include/ep-log.ycp (original)
+++ branches/SuSE-Code-11-SP2-Branch/storage/storage/src/include/ep-log.ycp Tue May 17 13:39:44 2011
@@ -3,11 +3,12 @@
* Package: yast2-storage
* Summary: Expert Partitioner
* Authors: Arvin Schnell <aschnell(a)suse.de>
+ *
+ * This file must only be included in other Expert Partitioner files ("ep-*.ycp").
*/
{
textdomain "storage";
-
import "LogViewCore";
@@ -19,7 +20,7 @@
Greasemonkey::Transform(
`VBox(
// heading
- `IconAndHeading(_("Log"), log_icon),
+ `IconAndHeading(_("Log"), StorageIcons::log_icon),
// label for log view
`LogView(`id(`log), sformat(_("Contents of %1:"), file), 10, 0),
// push button text
@@ -36,11 +37,20 @@
}
- void HandleLogPanel(any user_data, symbol widget)
+ void HandleLogPanel(any user_data, map event)
{
- if (widget == `update || widget == `timeout)
+ switch (Event::IsWidgetActivated(event))
+ {
+ case `update:
+ LogViewCore::Update(`id(`log));
+ break;
+ }
+
+ switch (Event::IsTimeout(event))
{
- LogViewCore::Update(`id(`log));
+ case `timeout:
+ LogViewCore::Update(`id(`log));
+ break;
}
}
Modified: branches/SuSE-Code-11-SP2-Branch/storage/storage/src/include/ep-loop-dialogs.ycp
URL: http://svn.opensuse.org/viewcvs/yast/branches/SuSE-Code-11-SP2-Branch/stora…
==============================================================================
--- branches/SuSE-Code-11-SP2-Branch/storage/storage/src/include/ep-loop-dialogs.ycp (original)
+++ branches/SuSE-Code-11-SP2-Branch/storage/storage/src/include/ep-loop-dialogs.ycp Tue May 17 13:39:44 2011
@@ -3,6 +3,8 @@
* Package: yast2-storage
* Summary: Expert Partitioner
* Authors: Arvin Schnell <aschnell(a)suse.de>
+ *
+ * This file must only be included in other Expert Partitioner files ("ep-*.ycp").
*/
{
textdomain "storage";
@@ -185,7 +187,7 @@
// dialog title
string title = _("Add Crypt File");
- symbol widget = MiniWorkflow::Run(title, lvm_lv_icon, aliases, sequence, "NameSize");
+ symbol widget = MiniWorkflow::Run(title, StorageIcons::loop_icon, aliases, sequence, "NameSize");
return widget == `finish;
}
@@ -209,7 +211,7 @@
// dialog title
string title = sformat(_("Edit Crypt File %1"), device);
- symbol widget = MiniWorkflow::Run(title, dm_icon, aliases, sequence, "FormatMount");
+ symbol widget = MiniWorkflow::Run(title, StorageIcons::loop_icon, aliases, sequence, "FormatMount");
return widget == `finish;
}
Modified: branches/SuSE-Code-11-SP2-Branch/storage/storage/src/include/ep-loop-lib.ycp
URL: http://svn.opensuse.org/viewcvs/yast/branches/SuSE-Code-11-SP2-Branch/stora…
==============================================================================
--- branches/SuSE-Code-11-SP2-Branch/storage/storage/src/include/ep-loop-lib.ycp (original)
+++ branches/SuSE-Code-11-SP2-Branch/storage/storage/src/include/ep-loop-lib.ycp Tue May 17 13:39:44 2011
@@ -3,6 +3,8 @@
* Package: yast2-storage
* Summary: Expert Partitioner
* Authors: Arvin Schnell <aschnell(a)suse.de>
+ *
+ * This file must only be included in other Expert Partitioner files ("ep-*.ycp").
*/
{
textdomain "storage";
@@ -43,7 +45,7 @@
map<string, map> target_map = Storage::GetTargetMap();
map<string, any> data = Storage::GetPartition(target_map, device);
- if (data["used_by"]:"" != "")
+ if (Storage::IsUsedBy(data))
{
// error popup, %1 is replaced by device name
Popup::Error(sformat(_("The Crypt File %1 is in use. It cannot be
Modified: branches/SuSE-Code-11-SP2-Branch/storage/storage/src/include/ep-loop.ycp
URL: http://svn.opensuse.org/viewcvs/yast/branches/SuSE-Code-11-SP2-Branch/stora…
==============================================================================
--- branches/SuSE-Code-11-SP2-Branch/storage/storage/src/include/ep-loop.ycp (original)
+++ branches/SuSE-Code-11-SP2-Branch/storage/storage/src/include/ep-loop.ycp Tue May 17 13:39:44 2011
@@ -4,15 +4,63 @@
* Summary: Expert Partitioner
* Authors: Arvin Schnell <aschnell(a)suse.de>
*
+ * This file must only be included in other Expert Partitioner files ("ep-*.ycp").
*/
{
textdomain "storage";
-
include "partitioning/ep-loop-dialogs.ycp";
include "partitioning/ep-loop-lib.ycp";
+ void EpContextMenuLoop(string device)
+ {
+ symbol widget = ContextMenu::Simple([ `item(`id(`edit), _("Edit")),
+ `item(`id(`delete), _("Delete")) ]);
+
+ switch (widget)
+ {
+ case `edit:
+ EpEditLoop(device);
+ break;
+
+ case `delete:
+ EpDeleteLoop(device);
+ break;
+ }
+ }
+
+
+ term LoopButtonBox()
+ {
+ return `HBox(
+ // push button text
+ `PushButton(`id(`edit), `opt(`key_F4), _("Edit...")),
+ // push button text
+ `PushButton(`id(`delete), `opt(`key_F5), _("Delete..."))
+ );
+ }
+
+
+ void HandleLoopButtons( string part_device, map event )
+ {
+ switch (Event::IsWidgetActivated(event))
+ {
+ case `add:
+ EpCreateLoop();
+ break;
+
+ case `edit:
+ EpEditLoop(part_device);
+ break;
+
+ case `delete:
+ EpDeleteLoop(part_device);
+ break;
+ }
+ }
+
+
void CreateLoopMainPanel(any user_data)
{
symbol Predicate(map disk, map partition)
@@ -32,12 +80,13 @@
`VBox(
`HStretch(),
// heading
- `IconAndHeading(_("Crypt Files"), loop_icon),
- `Table(`id(`table), `opt(`keepSorting, `notify),
+ `IconAndHeading(_("Crypt Files"), StorageIcons::loop_icon),
+ `Table(`id(`table), `opt(`keepSorting, `notify, `notifyContextMenu),
table_header, table_contents),
`HBox(
// push button text
- `Left(`PushButton(`id(`add), `opt(`key_F3), _("Add Crypt File..."))),
+ `PushButton(`id(`add), `opt(`key_F3), _("Add Crypt File...")),
+ LoopButtonBox(),
`HStretch()
)
)
@@ -51,14 +100,19 @@
}
- void HandleLoopMainPanel(any user_data, symbol widget)
+ void HandleLoopMainPanel(any user_data, map event)
{
- switch (widget)
+ string device = (string) UI::QueryWidget(`id(`table), `CurrentItem);
+
+ HandleLoopButtons(device, event);
+
+ switch (Event::IsWidgetContextMenuActivated(event))
{
- case `add:
- EpCreateLoop();
+ case `table:
+ EpContextMenuDevice(device);
break;
}
+
UI::SetFocus(`id(`table));
}
@@ -76,14 +130,11 @@
Greasemonkey::Transform(
`VBox(
// heading
- `IconAndHeading(sformat(_("Crypt File: %1"), part_device), loop_icon),
+ `IconAndHeading(sformat(_("Crypt File: %1"), part_device), StorageIcons::loop_icon),
`HStretch(),
StorageFields::Overview(fields, target_map, part_device),
`HBox(
- // push button text
- `PushButton(`id(`edit), `opt(`key_F4), _("Edit...")),
- // push button text
- `PushButton(`id(`delete), `opt(`key_F5), _("Delete...")),
+ LoopButtonBox(),
`HStretch()
)
))
@@ -97,20 +148,12 @@
}
- void HandleLoopPanel(any user_data, symbol widget)
+ void HandleLoopPanel(any user_data, map event)
{
string part_device = (string) user_data;
- switch (widget)
- {
- case `edit:
- EpEditLoop(part_device);
- break;
+ HandleLoopButtons( part_device, event );
- case `delete:
- EpDeleteLoop(part_device);
- break;
- }
UI::SetFocus(`id(`text));
}
}
Modified: branches/SuSE-Code-11-SP2-Branch/storage/storage/src/include/ep-lvm-dialogs.ycp
URL: http://svn.opensuse.org/viewcvs/yast/branches/SuSE-Code-11-SP2-Branch/stora…
==============================================================================
--- branches/SuSE-Code-11-SP2-Branch/storage/storage/src/include/ep-lvm-dialogs.ycp (original)
+++ branches/SuSE-Code-11-SP2-Branch/storage/storage/src/include/ep-lvm-dialogs.ycp Tue May 17 13:39:44 2011
@@ -3,6 +3,8 @@
* Package: yast2-storage
* Summary: Expert Partitioner
* Authors: Arvin Schnell <aschnell(a)suse.de>
+ *
+ * This file must only be included in other Expert Partitioner files ("ep-*.ycp").
*/
{
textdomain "storage";
@@ -43,7 +45,7 @@
ret = false;
}
if (!ret)
- UI::SetFocus(`id("vgname"));
+ UI::SetFocus(`id(`vgname));
return ret;
}
@@ -68,12 +70,28 @@
}
if (!ret)
- UI::SetFocus(`id("vgname"));
+ UI::SetFocus(`id(`vgname));
return ret;
}
+ boolean ConfirmVgDelete( string vgname, list <string> log_volumes )
+ {
+ return ConfirmRecursiveDelete( vgname, log_volumes,
+ //pop-up dialog title
+ _("Confirm Deleting of Volume Group"),
+ //pop-up dialog message part 1: %1 is vol.group name
+ sformat( _("The volume group \"%1\" contains at least one logical volume.
+If you proceed, the following volumes will be unmounted (if mounted)
+and deleted:"), vgname),
+ //pop-up dialog message part 2: %1 is vol.group name
+ sformat( _("Really delete volume group \"%1\" and all related logical volumes?"), vgname)
+ );
+
+ }
+
+
boolean CheckPeSize(integer pe_size)
{
if (!Integer::IsPowerOfTwo(pe_size) || pe_size < 1024)
@@ -81,10 +99,10 @@
// error popup, %1, %2 and %3 are replaced by sizes
Popup::Error(sformat(_("The data entered is invalid. Insert a physical extent size larger than %1
in powers of 2, for example, \"%2\" or \"%3\""),
- Storage::KByteToHumanStringWithPrecision(1, 1, true),
- Storage::KByteToHumanStringWithPrecision(4, 1, true),
- Storage::KByteToHumanStringWithPrecision(4*1024, 1, true)));
- UI::SetFocus(`id("pesize"));
+ Storage::KByteToHumanStringOmitZeroes(1),
+ Storage::KByteToHumanStringOmitZeroes(4),
+ Storage::KByteToHumanStringOmitZeroes(4*1024)));
+ UI::SetFocus(`id(`pesize));
return false;
}
else
@@ -187,17 +205,17 @@
list<symbol> fields = StorageSettings::FilterTable([ `device, `udev_path, `udev_id, `size, `encrypted, `type ]);
- list<map> unused_pvs = filter(map pv, get_possible_pvs(target_map), { return pv["used_by"]:"" == ""; });
+ list<map> unused_pvs = filter(map pv, get_possible_pvs(target_map), { return !Storage::IsUsedBy(pv); });
term contents = `VBox();
list<term> pesizes_list = maplist(integer i, Integer::RangeFrom(19, 26), {
- return `item(`id(2 << i), Storage::ByteToHumanStringWithPrecision(2 << i, 2, true));
+ return `item(`id(2 << i), Storage::ByteToHumanStringOmitZeroes(2 << i));
});
// label for input field
- contents = add(contents, `Left(`InputField(`id("vgname"), _("Volume Group Name"))));
- contents = add(contents, `Left(`ComboBoxSelected(`id("pesize"), `opt(`editable),
+ contents = add(contents, `Left(`InputField(`id(`vgname), _("Volume Group Name"))));
+ contents = add(contents, `Left(`ComboBoxSelected(`id(`pesize), `opt(`editable),
// label for combo box
_("&Physical Extent Size"), pesizes_list, `id(pesize))));
@@ -209,6 +227,7 @@
MiniWorkflow::SetContents(Greasemonkey::Transform(contents), MiniWorkflowStepVgHelptext());
MiniWorkflow::SetLastStep(true);
+ UI::SetFocus(`id(`vgname));
symbol widget = nil;
@@ -221,9 +240,9 @@
{
case `next:
{
- vgname = (string) UI::QueryWidget(`id("vgname"), `Value);
+ vgname = (string) UI::QueryWidget(`id(`vgname), `Value);
- any tmp = UI::QueryWidget(`id("pesize"), `Value);
+ any tmp = UI::QueryWidget(`id(`pesize), `Value);
if (is(tmp, integer))
pesize = (integer) tmp;
else if (!Storage::HumanStringToByte((string) tmp, pesize))
@@ -276,7 +295,7 @@
list<symbol> fields = StorageSettings::FilterTable([ `device, `udev_path, `udev_id, `size, `encrypted, `type ]);
map<string, map> target_map = Storage::GetTargetMap();
- list<map> unused_pvs = filter(map pv, get_possible_pvs(target_map), { return pv["used_by_device"]:"" == ""; });
+ list<map> unused_pvs = filter(map pv, get_possible_pvs(target_map), { return !Storage::IsUsedBy(pv); });
list<map> used_pvs = filter(map pv, get_possible_pvs(target_map), { return pv["used_by_device"]:"" == "/dev/" + vgname; });
term contents = `VBox();
@@ -339,7 +358,7 @@
// dialog title
string title = _("Add Volume Group");
- symbol widget = MiniWorkflow::Run(title, lvm_icon, aliases, sequence, "TheOne");
+ symbol widget = MiniWorkflow::Run(title, StorageIcons::lvm_icon, aliases, sequence, "TheOne");
return widget == `finish;
}
@@ -348,7 +367,9 @@
string MiniWorkflowStepLvSizeHelptext()
{
// helptext
- string helptext = _("<p>Enter the size and stripe number of the new logical volume.</p>");
+ string helptext = _("<p>Enter the size as well as the number and size
+of stripes for the new logical volume. The number of stripes cannot be higher
+than the number of physical volumes of the volume group.</p>");
return helptext;
}
@@ -363,7 +384,9 @@
integer size_k = data["size_k"]:max_size_k;
symbol what = (size_k == max_size_k) ? `max_size : `manual_size;
+ string name = data["name"]:"";
+ integer max_stripes = data["max_stripes"]:1;
integer stripes = data["stripes"]:1;
integer stripe_size = data["stripesize"]:64*1024;
@@ -375,20 +398,21 @@
`VBox(
`LeftRadioButton(`id(`max_size), `opt(`notify),
sformat(_("Maximum Size (%1)"), Storage::KByteToHumanString(max_size_k))),
- `LeftRadioButtonWithAttachment(`id(`manual_size), `opt(`notify), _("Manual Size"),
+ `LeftRadioButtonWithAttachment(`id(`manual_size), `opt(`notify), _("Custom Size"),
`VBox(`id(`manual_size_attachment),
- `MinWidth(15, `InputField(`id(`size_input), `opt(`shrinkable), _("Size")))
+ `MinWidth(15, `InputField(`id(`size_input),
+ `opt(`shrinkable), _("Size")))
)
)
)
)));
- list<term> stripes_list = maplist(integer i, Integer::RangeFrom(1, 9), {
+ list<term> stripes_list = maplist(integer i, Integer::RangeFrom(1, max_stripes + 1), {
return `item(`id(i), tostring(i));
});
list<term> stripe_sizes_list = maplist(integer i, Integer::RangeFrom(11, 20), {
- return `item(`id(2 << i), Storage::ByteToHumanStringWithPrecision(2 << i, 2, true));
+ return `item(`id(2 << i), Storage::ByteToHumanStringOmitZeroes(2 << i));
});
// heading for frame
@@ -404,6 +428,8 @@
term contents = `HVSquash(frames);
+ //A dialog title - %1 is a logical volume name, %2 is a volume group.
+ MiniWorkflow::SetTitle(sformat(_("Add Logical volume %1 on %2"), name, "/dev/" + data["vg_name"]:"error"));
MiniWorkflow::SetContents(Greasemonkey::Transform(contents), MiniWorkflowStepLvSizeHelptext());
MiniWorkflow::SetLastStep(false);
@@ -426,6 +452,7 @@
case `manual_size:
UI::ChangeWidget(`id(`manual_size_attachment), `Enabled, true);
+ UI::SetFocus(`id(`size_input));
break;
case `stripes:
@@ -442,8 +469,8 @@
if (!Storage::HumanStringToKByteWithRangeCheck(tmp, size_k, min_size_k, max_size_k))
{
Popup::Error(sformat(_("The size entered is invalid. Enter a size between %1 and %2."),
- Storage::KByteToHumanString(min_size_k),
- Storage::KByteToHumanString(max_size_k)));
+ Storage::KByteToHumanString(min_size_k),
+ Storage::KByteToHumanString(max_size_k)));
widget = `again;
}
}
@@ -493,7 +520,7 @@
// dialog title
string title = sformat(_("Resize Volume Group %1"), data["device"]:"error");
- symbol widget = MiniWorkflow::Run(title, lvm_icon, aliases, sequence, "TheOne");
+ symbol widget = MiniWorkflow::Run(title, StorageIcons::lvm_icon, aliases, sequence, "TheOne");
return widget == `finish;
}
@@ -528,6 +555,7 @@
MiniWorkflow::SetContents(Greasemonkey::Transform(contents), MiniWorkflowStepLvNameHelptext());
MiniWorkflow::SetLastStep(false);
+ UI::SetFocus(`id(`lvname));
symbol widget = nil;
@@ -582,10 +610,10 @@
"Commit" : $[ `finish : `finish ]
];
- // dialog title
+ // dialog title, %1 is a volume group
string title = sformat(_("Add Logical Volume on %1"), "/dev/" + data["vg_name"]:"error");
- symbol widget = MiniWorkflow::Run(title, lvm_lv_icon, aliases, sequence, "Name");
+ symbol widget = MiniWorkflow::Run(title, StorageIcons::lvm_lv_icon, aliases, sequence, "Name");
return widget == `finish;
}
@@ -606,10 +634,10 @@
"Password" : $[ `finish : `finish ]
];
- // dialog title
- string title = sformat(_("Edit Logical Volume %1"), device);
+ // dialog title - %1 is a logical volume name, %2 is a volume group
+ string title = sformat(_("Edit Logical Volume %1 on %2"), data["name"]:"", regexpsub( device, "^(.*)/[^/]*$", "\\1" ) );
- symbol widget = MiniWorkflow::Run(title, lvm_lv_icon, aliases, sequence, "FormatMount");
+ symbol widget = MiniWorkflow::Run(title, StorageIcons::lvm_lv_icon, aliases, sequence, "FormatMount");
return widget == `finish;
}
Modified: branches/SuSE-Code-11-SP2-Branch/storage/storage/src/include/ep-lvm-lib.ycp
URL: http://svn.opensuse.org/viewcvs/yast/branches/SuSE-Code-11-SP2-Branch/stora…
==============================================================================
--- branches/SuSE-Code-11-SP2-Branch/storage/storage/src/include/ep-lvm-lib.ycp (original)
+++ branches/SuSE-Code-11-SP2-Branch/storage/storage/src/include/ep-lvm-lib.ycp Tue May 17 13:39:44 2011
@@ -3,6 +3,8 @@
* Package: yast2-storage
* Summary: Expert Partitioner
* Authors: Arvin Schnell <aschnell(a)suse.de>
+ *
+ * This file must only be included in other Expert Partitioner files ("ep-*.ycp").
*/
{
textdomain "storage";
@@ -40,7 +42,7 @@
void EpCreateVolumeGroup()
{
map<string, map> target_map = Storage::GetTargetMap();
- list<map> unused_pvs = filter(map pv, get_possible_pvs(target_map), { return pv["used_by"]:"" == ""; });
+ list<map> unused_pvs = filter(map pv, get_possible_pvs(target_map), { return !Storage::IsUsedBy(pv); });
if (size(unused_pvs) < 1)
{
@@ -90,8 +92,7 @@
symbol Commit()
{
- list<string> devices_old = (list<string>) union(data["devices"]:[], data["devices_add"]:[]);
- devices_old = filter(string tmp, devices_old, { return !contains(data["devices_rem"]:[], tmp); });
+ list<string> devices_old = MergeDevices(data);
list<string> devices_new = data["devices_new"]:[];
list<string> devices_added = AddedToList(devices_old, devices_new);
@@ -125,41 +126,55 @@
}
- void EpDeleteVolumeGroup(string device)
+ boolean EpDeleteVolumeGroup(string device)
{
if (device == nil)
{
// error popup
Popup::Error(_("No volume group selected."));
- return;
+ return false;
}
string vgname = substring(device, 5);
+ //LV device names
+ list<string> log_volumes = Storage::GetAffectedDevices( device );
+ //how many of those we have?
+ integer count = size(log_volumes);
+
+ boolean ret = false;
+ boolean proceed = (count > 0) ?
+ //non-empty VG - make sure user wants to delete all LVs
+ ConfirmVgDelete(vgname, log_volumes) :
+ //empty VG - simple
+ Popup::YesNo(sformat(_("Really delete the volume group \"%1\"?"), vgname));
- map<string,map> tg = Storage::GetTargetMap();
- integer count = size(get_lv_names(tg, vgname));
-
- if (count > 0)
- {
- // message popup
- Popup::Message(sformat(_("The volume group \"%1\" contains at least one logical
-volume. It cannot be removed. Remove all logical volumes then
-remove the volume group.
-"), vgname));
- }
- else
+ if (proceed)
{
- // popup text
- if (Popup::YesNo(sformat(_("Really delete the volume group \"%1\"?"), vgname)))
+ boolean recursive = Storage::GetRecursiveRemoval();
+ Storage::SetRecursiveRemoval( true );
+
+ if (Storage::DeleteLvmVg(vgname))
{
- if (Storage::DeleteLvmVg(vgname))
- {
- UpdateMainStatus();
- UpdateNavigationTree(`lvm);
- TreePanel::Create();
- }
+ any new_focus = nil;
+ if (UI::QueryWidget(`tree, `CurrentItem) == device)
+ new_focus = `lvm;
+
+ UpdateMainStatus();
+ UpdateNavigationTree(new_focus);
+ TreePanel::Create();
+ ret = true;
+ }
+ else
+ {
+ Popup::Error( sformat(_("Deleting volume group \"%1\" failed."), vgname));
+ //FIXME: some rollback?
+ ret = false;
}
+
+ Storage::SetRecursiveRemoval( recursive );
}
+
+ return ret;
}
@@ -189,6 +204,7 @@
data["vg_name"] = vg_name;
data["pesize"] = target_map[device, "pesize"]:0;
data["max_size_k"] = (target_map[device, "pe_free"]:0 * target_map[device, "pesize"]:0) / 1024;
+ data["max_stripes"] = size(MergeDevices((map<string, any>) target_map[device]:$[]));
symbol Commit()
@@ -222,6 +238,14 @@
map<string, map> target_map = Storage::GetTargetMap();
map<string, any> data = Storage::GetPartition(target_map, device);
+ if (Storage::IsUsedBy(data))
+ {
+ // error popup, %1 is replace by partition device name e.g. /dev/sdb1
+ Popup::Error(sformat(_("The volume %1 is in use. It cannot be
+edited. To edit %1, make sure it is not used."), device));
+ return;
+ }
+
if (DlgEditLogicalVolume(data))
{
Storage::ChangeVolumeProperties(data);
@@ -258,7 +282,7 @@
}
- void EpDeleteLogicalVolume(string device)
+ void EpDeleteLogicalVolume(string device, symbol context)
{
if (device == nil)
{
@@ -268,12 +292,26 @@
}
string parent = ParentDevice(device);
+ string next = NextDeviceAfterDelete(device);
if (EpDeleteDevice(device))
{
UpdateMainStatus();
- UpdateNavigationTree(parent);
- TreePanel::Create();
+
+ switch (context)
+ {
+ case `table:
+ UpdateNavigationTree(nil);
+ TreePanel::Create();
+ if (!isempty(next))
+ UI::ChangeWidget(`id(`table), `CurrentItem, next);
+ break;
+
+ case `overview:
+ UpdateNavigationTree(parent);
+ TreePanel::Create();
+ break;
+ }
}
}
}
Modified: branches/SuSE-Code-11-SP2-Branch/storage/storage/src/include/ep-lvm.ycp
URL: http://svn.opensuse.org/viewcvs/yast/branches/SuSE-Code-11-SP2-Branch/stora…
==============================================================================
--- branches/SuSE-Code-11-SP2-Branch/storage/storage/src/include/ep-lvm.ycp (original)
+++ branches/SuSE-Code-11-SP2-Branch/storage/storage/src/include/ep-lvm.ycp Tue May 17 13:39:44 2011
@@ -3,15 +3,138 @@
* Package: yast2-storage
* Summary: Expert Partitioner
* Authors: Arvin Schnell <aschnell(a)suse.de>
+ *
+ * This file must only be included in other Expert Partitioner files ("ep-*.ycp").
*/
{
textdomain "storage";
-
include "partitioning/ep-lvm-dialogs.ycp";
include "partitioning/ep-lvm-lib.ycp";
+ void EpContextMenuLvmVg(string device)
+ {
+ symbol widget = ContextMenu::Simple([ `item(`id(`add), `icon(StorageIcons::lvm_lv_icon), _("Add Logical Volume")),
+ `item(`id(`resize), _("Resize")),
+ `item(`id(`delete), _("Delete")) ]);
+
+ switch (widget)
+ {
+ case `add:
+ EpCreateLogicalVolume(device);
+ break;
+
+ case `resize:
+ EpResizeVolumeGroup(device);
+ break;
+
+ case `delete:
+ EpDeleteVolumeGroup(device);
+ break;
+ }
+ }
+
+
+ void EpContextMenuLvmLv(string device)
+ {
+ symbol widget = ContextMenu::Simple([ `item(`id(`edit), _("Edit")),
+ `item(`id(`resize), _("Resize")),
+ `item(`id(`delete), _("Delete")) ]);
+
+ switch (widget)
+ {
+ case `edit:
+ EpEditLogicalVolume(device);
+ break;
+
+ case `resize:
+ EpResizeLogicalVolume(device);
+ break;
+
+ case `delete:
+ EpDeleteLogicalVolume(device, `table);
+ break;
+ }
+ }
+
+
+ term LvmButtonBox()
+ {
+ return `HBox(
+ // push button text
+ `PushButton(`id(`edit),`opt(`key_F4), _("Edit...")),
+ // push button text
+ `PushButton(`id(`resize), `opt(`key_F6), _("Resize...")),
+ // push button text
+ `PushButton(`id(`delete), `opt(`key_F5), _("Delete..."))
+ );
+ }
+
+
+ void HandleLvmButtons( any user_data, string device, map event )
+ {
+ string vg = "";
+ boolean is_vg = false;
+
+ if (user_data == nil)
+ {
+ map<string, map> target_map = Storage::GetTargetMap();
+
+ map disk = nil;
+ map part = nil;
+
+ SplitDevice(target_map, device, disk, part);
+
+ vg = disk["device"]:"";
+ is_vg = part == nil;
+ }
+ else
+ {
+ vg = (string) user_data;
+ }
+
+ switch (Event::IsWidgetActivated(event))
+ {
+ case `add:
+ EpCreateLogicalVolume( vg );
+ break;
+
+ case `edit:
+ if (is_vg)
+ TreePanel::SwitchToNew( vg );
+ else
+ EpEditLogicalVolume( device );
+ break;
+
+ case `resize:
+ if (is_vg)
+ EpResizeVolumeGroup( device);
+ else
+ EpResizeLogicalVolume ( device );
+ break;
+
+ case `delete:
+ if (is_vg)
+ EpDeleteVolumeGroup( device );
+ else
+ EpDeleteLogicalVolume ( device, UI::WidgetExists(`id(`table)) ? `table : `overview );
+ break;
+ }
+
+ switch (Event::IsMenu( event ))
+ {
+ case `group:
+ EpCreateVolumeGroup();
+ break;
+
+ case `volume:
+ EpCreateLogicalVolume( vg );
+ break;
+ }
+ }
+
+
void CreateLvmMainPanel(any user_data)
{
symbol Predicate(map disk, map partition)
@@ -27,17 +150,22 @@
term table_header = StorageFields::TableHeader(fields);
list<term> table_contents = StorageFields::TableContents(fields, target_map, Predicate);
+ list <term> mb_items = [ `item(`id(`group), _("Volume Group")) ];
+
+ if ( !isempty(table_contents) )
+ mb_items = add( mb_items, `item(`id(`volume), _("Logical Volume")) );
UI::ReplaceWidget(`tree_panel,
Greasemonkey::Transform(
`VBox(
// heading
- `IconAndHeading(_("Volume Management"), lvm_icon),
- `Table(`id(`table), `opt(`keepSorting, `notify),
+ `IconAndHeading(_("Volume Management"), StorageIcons::lvm_icon),
+ `Table(`id(`table), `opt(`keepSorting, `notify, `notifyContextMenu),
table_header, table_contents),
`HBox(
// push button text
- `PushButton(`id(`add), `opt(`key_F3), _("Add Volume Group...")),
+ `MenuButton(`id(`add), `opt(`key_F3), _("Add..."), mb_items),
+ LvmButtonBox(),
`HStretch()
)
)
@@ -52,14 +180,19 @@
}
- void HandleLvmMainPanel(any user_data, symbol widget)
+ void HandleLvmMainPanel(any user_data, map event)
{
- switch (widget)
+ string device = (string) UI::QueryWidget(`id(`table), `CurrentItem);
+
+ HandleLvmButtons( user_data, device, event );
+
+ switch (Event::IsWidgetContextMenuActivated(event))
{
- case `add:
- EpCreateVolumeGroup();
+ case `table:
+ EpContextMenuDevice(device);
break;
}
+
UI::SetFocus(`id(`table));
}
@@ -75,16 +208,8 @@
UI::ReplaceWidget(`tab_panel,
`VBox(
- `HStretch(),
- StorageFields::Overview(fields, target_map, device),
- `HBox(
- // push button text
- `PushButton(`id(`resize), _("Resize...")),
- // push button text
- `PushButton(`id(`delete), _("Delete...")),
- `HStretch()
- )
- )
+ StorageFields::Overview(fields, target_map, device)
+ )
);
// helptext
@@ -95,20 +220,11 @@
}
- void HandleLvmVgOverviewTab(any user_data, symbol widget)
+ void HandleLvmVgOverviewTab(any user_data, map event)
{
string device = (string) user_data;
- switch (widget)
- {
- case `resize:
- EpResizeVolumeGroup(device);
- break;
-
- case `delete:
- EpDeleteVolumeGroup(device);
- break;
- }
+ HandleLvmButtons( nil, device, event );
UI::SetFocus(`id(`text));
}
@@ -133,17 +249,13 @@
UI::ReplaceWidget(`tab_panel,
`VBox(
- `Table(`id(`table), `opt(`keepSorting, `notify),
+ DiskBarGraph(device),
+ `Table(`id(`table), `opt(`keepSorting, `notify, `notifyContextMenu),
table_header, table_contents),
`HBox(
// push button text
`PushButton(`id(`add), `opt(`key_F3), _("Add...")),
- // push button text
- `PushButton(`id(`edit), `opt(`key_F4), _("Edit...")),
- // push button text
- `PushButton(`id(`resize), `opt(`key_F6), _("Resize...")),
- // push button text
- `PushButton(`id(`delete), `opt(`key_F5), _("Delete...")),
+ LvmButtonBox(),
`HStretch()
)
)
@@ -157,29 +269,20 @@
}
- void HandleLvmVgLvsTab(any user_data, symbol widget)
+ void HandleLvmVgLvsTab(any user_data, map event)
{
string vg_device = (string) user_data;
string lv_device = (string) UI::QueryWidget(`id(`table), `CurrentItem);
- switch (widget)
- {
- case `add:
- EpCreateLogicalVolume(vg_device);
- break;
-
- case `edit:
- EpEditLogicalVolume(lv_device);
- break;
-
- case `resize:
- EpResizeLogicalVolume(lv_device);
- break;
+ HandleLvmButtons( vg_device, lv_device, event );
- case `delete:
- EpDeleteLogicalVolume(lv_device);
+ switch (Event::IsWidgetContextMenuActivated(event))
+ {
+ case `table:
+ EpContextMenuDevice(lv_device);
break;
}
+
UI::SetFocus(`id(`table));
}
@@ -228,7 +331,7 @@
Greasemonkey::Transform(
`VBox(
// heading
- `IconAndHeading(sformat(_("Volume Group: %1"), device), lvm_icon),
+ `IconAndHeading(sformat(_("Volume Group: %1"), device), StorageIcons::lvm_icon),
`DumbTab(`id(`tab), [
// push button text
`item(`id(`overview), _("&Overview")),
@@ -246,9 +349,9 @@
}
- void HandleLvmVgPanel(any user_data, symbol widget)
+ void HandleLvmVgPanel(any user_data, map event)
{
- TabPanel::Handle(widget);
+ TabPanel::Handle(event);
}
@@ -267,15 +370,10 @@
`VBox(
`HStretch(),
// heading
- `IconAndHeading(sformat(_("Logical Volume: %1"), device), lvm_lv_icon),
+ `IconAndHeading(sformat(_("Logical Volume: %1"), device), StorageIcons::lvm_lv_icon),
StorageFields::Overview(fields, target_map, device),
`HBox(
- // push button text
- `PushButton(`id(`edit), _("Edit...")),
- // push button text
- `PushButton(`id(`resize), _("Resize...")),
- // push button text
- `PushButton(`id(`delete), _("Delete...")),
+ LvmButtonBox(),
`HStretch()
)
)
@@ -290,23 +388,11 @@
}
- void HandleLvmLvPanel(any user_data, symbol widget)
+ void HandleLvmLvPanel(any user_data, map event)
{
string device = (string) user_data;
- switch (widget)
- {
- case `edit:
- EpEditLogicalVolume(device);
- break;
-
- case `resize:
- EpResizeLogicalVolume(device);
- break;
-
- case `delete:
- EpDeleteLogicalVolume(device);
- break;
- }
+ HandleLvmButtons( nil, device, event );
+ UI::SetFocus (`id(`text));
}
}
Modified: branches/SuSE-Code-11-SP2-Branch/storage/storage/src/include/ep-main.ycp
URL: http://svn.opensuse.org/viewcvs/yast/branches/SuSE-Code-11-SP2-Branch/stora…
==============================================================================
--- branches/SuSE-Code-11-SP2-Branch/storage/storage/src/include/ep-main.ycp (original)
+++ branches/SuSE-Code-11-SP2-Branch/storage/storage/src/include/ep-main.ycp Tue May 17 13:39:44 2011
@@ -7,16 +7,19 @@
{
textdomain "storage";
-
+ import "Arch";
import "Mode";
import "Stage";
import "Label";
import "Hostname";
+ import "Event";
+ import "ContextMenu";
import "TabPanel";
import "TreePanel";
import "Popup";
import "Storage";
import "StorageFields";
+ import "StorageIcons";
import "StorageSettings";
import "Wizard";
import "MiniWorkflow";
@@ -28,7 +31,10 @@
import "String";
import "Region";
import "ProductFeatures";
-
+ import "Directory";
+ import "HTML";
+ import "Map";
+ import "Icon";
include "partitioning/lvm_ui_dialogs.ycp";
include "partitioning/raid_lib.ycp";
@@ -52,13 +58,12 @@
}
- include "partitioning/icons.ycp";
+ void EpContextMenuDevice(string device);
+
include "partitioning/ep-lib.ycp";
include "partitioning/ep-dialogs.ycp";
-
- include "partitioning/ep-settings.ycp";
- include "partitioning/ep-log.ycp";
+ include "partitioning/ep-import.ycp";
include "partitioning/ep-all.ycp";
include "partitioning/ep-hd.ycp";
@@ -67,14 +72,21 @@
include "partitioning/ep-loop.ycp";
include "partitioning/ep-dm.ycp";
include "partitioning/ep-nfs.ycp";
+ include "partitioning/ep-btrfs.ycp";
+ include "partitioning/ep-tmpfs.ycp";
include "partitioning/ep-unused.ycp";
+ include "partitioning/ep-graph.ycp";
+ include "partitioning/ep-summary.ycp";
+ include "partitioning/ep-settings.ycp";
+ include "partitioning/ep-log.ycp";
+
void UpdateMainStatus()
{
if (Mode::normal())
{
- string next_label = Storage::EqualBackupStates("expert-partitioner", "", true) ?
+ string next_label = Storage::EqualBackupStates("expert-partitioner", "", true) ?
Label::FinishButton() : Label::NextButton();
Wizard::SetNextButton(`next, next_label);
@@ -91,9 +103,14 @@
`lvm : $[ `create : CreateLvmMainPanel, `handle : HandleLvmMainPanel ],
`md : $[ `create : CreateRaidMainPanel, `handle : HandleRaidMainPanel ],
`loop : $[ `create : CreateLoopMainPanel, `handle : HandleLoopMainPanel ],
- `dm : $[ `create : CreateDmMainPanel ],
+ `dm : $[ `create : CreateDmMainPanel, `handle : HandleDmMainPanel ],
`nfs : $[ `create : CreateNfsMainPanel, `handle : HandleNfsMainPanel ],
- `unused : $[ `create : CreateUnusedPanel, `handle: HandleUnusedPanel ],
+ `btrfs : $[ `create : CreateBtrfsMainPanel, `handle : HandleBtrfsMainPanel ],
+ `tmpfs : $[ `create : CreateTmpfsMainPanel, `handle : HandleTmpfsMainPanel ],
+ `unused : $[ `create : CreateUnusedPanel, `handle : HandleUnusedPanel ],
+ `devicegraph : $[ `create : CreateDeviceGraphPanel, `refresh : RefreshDeviceGraphPanel, `handle : HandleDeviceGraphPanel ],
+ `mountgraph : $[ `create : CreateMountGraphPanel, `refresh : RefreshDeviceGraphPanel, `handle : HandleMountGraphPanel ],
+ `summary : $[ `create : CreateSummaryPanel ],
`settings : $[ `create : CreateSettingsPanel, `handle : HandleSettingsPanel, `destroy : DestroySettingsPanel ],
`log : $[ `create : CreateLogPanel, `handle : HandleLogPanel, `destroy : DestroyLogPanel ] ];
@@ -167,6 +184,12 @@
case `CT_NFS:
huhu(disk, `nfs, $[ `create : CreateNfsPanel, `handle: HandleNfsMainPanel ], nil);
break;
+ case `CT_BTRFS:
+ huhu(disk, `btrfs, $[ `create : CreateBtrfsPanel, `handle: HandleBtrfsPanel ], nil);
+ break;
+ case `CT_TMPFS:
+ huhu(disk, `tmpfs, $[ `create : CreateTmpfsPanel, `handle: HandleTmpfsPanel ], nil);
+ break;
}
}
@@ -176,28 +199,46 @@
string short_hostname = Hostname::CurrentHostname();
// TODO: same ordering as with IterateTargetMap
- tree = [ `item(`id(`all), `icon(all_icon), short_hostname, open(`all), [
+ tree = [ `item(`id(`all), `icon(StorageIcons::all_icon), short_hostname, open(`all), [
+ // tree node label
+ `item(`id(`hd), `icon(StorageIcons::hd_icon), _("Hard Disks"), open(`hd), subtree[`hd]:[]),
+ // tree node label
+ `item(`id(`md), `icon(StorageIcons::raid_icon), _("RAID"), open(`md), subtree[`md]:[]),
// tree node label
- `item(`id(`hd), `icon(hd_icon), _("Hard Disks"), open(`hd), subtree[`hd]:[]),
+ `item(`id(`lvm), `icon(StorageIcons::lvm_icon), _("Volume Management"), open(`lvm), subtree[`lvm]:[]),
// tree node label
- `item(`id(`md), `icon(raid_icon), _("RAID"), open(`md), subtree[`md]:[]),
+ `item(`id(`loop), `icon(StorageIcons::loop_icon), _("Crypt Files"), open(`loop), subtree[`loop]:[]),
// tree node label
- `item(`id(`lvm), `icon(lvm_icon), _("Volume Management"), open(`lvm), subtree[`lvm]:[]),
+ `item(`id(`dm), `icon(StorageIcons::dm_icon), _("Device Mapper"), open(`dm), subtree[`dm]:[]),
// tree node label
- `item(`id(`loop), `icon(loop_icon), _("Crypt Files"), open(`loop), subtree[`loop]:[]),
+ `item(`id(`nfs), `icon(StorageIcons::nfs_icon), _("NFS"), open(`nfs)),
// tree node label
- `item(`id(`dm), `icon(dm_icon), _("Device Mapper"), open(`dm), subtree[`dm]:[]),
+ `item(`id(`btrfs), `icon(StorageIcons::nfs_icon), _("BTRFS"), open(`btrfs)),
// tree node label
- `item(`id(`nfs), `icon(nfs_icon), _("NFS"), open(`nfs)),
+ `item(`id(`tmpfs), `icon(StorageIcons::nfs_icon), _("TMPFS"), open(`tmpfs)),
// tree node label
- `item(`id(`unused), `icon(unused_icon), _("Unused Devices"), open(`unused))
- ]),
- // tree node label
- `item(`id(`settings), `icon(settings_icon), _("Settings"), open(`settings)) ];
+ `item(`id(`unused), `icon(StorageIcons::unused_icon), _("Unused Devices"), open(`unused))
+ ])
+ ];
+
+ if (UI::HasSpecialWidget(`Graph))
+ {
+ // tree node label
+ tree = add(tree, `item(`id(`devicegraph), `icon(StorageIcons::graph_icon), _("Device Graph"), open(`devicegraph)));
+ // tree node label
+ tree = add(tree, `item(`id(`mountgraph), `icon(StorageIcons::graph_icon), _("Mount Graph"), open(`mountgraph)));
+ }
+
+
+ // tree node label
+ tree = add(tree, `item(`id(`summary), `icon(StorageIcons::summary_icon), _("Installation Summary"), open(`summary)));
+
+ // tree node label
+ tree = add(tree, `item(`id(`settings), `icon(StorageIcons::settings_icon), _("Settings"), open(`settings)));
if (Mode::normal())
// tree node label
- tree = add(tree, `item(`id(`log), `icon(log_icon), _("Log"), open(`log)));
+ tree = add(tree, `item(`id(`log), `icon(StorageIcons::log_icon), _("Log"), open(`log)));
}
@@ -211,14 +252,73 @@
}
+ void EpContextMenuDevice(string device)
+ {
+ map<string, map> target_map = Storage::GetTargetMap();
+
+ map disk = nil;
+ map part = nil;
+
+ if( substring(device,0,5)=="tmpfs" )
+ disk = target_map["/dev/tmpfs"]:$[];
+ else
+ SplitDevice(target_map, device, disk, part);
+
+ switch (disk["type"]:`unknown)
+ {
+ case `CT_DISK:
+ case `CT_MDPART:
+ case `CT_DMRAID:
+ case `CT_DMMULTIPATH:
+ if (part == nil)
+ EpContextMenuHdDisk(device);
+ else
+ EpContextMenuHdPartition(device);
+ break;
+
+ case `CT_MD:
+ if (part != nil)
+ EpContextMenuRaid(device);
+ break;
+
+ case `CT_LOOP:
+ if (part != nil)
+ EpContextMenuLoop(device);
+ break;
+
+ case `CT_LVM:
+ if (part == nil)
+ EpContextMenuLvmVg(device);
+ else
+ EpContextMenuLvmLv(device);
+ break;
+
+ case `CT_DM:
+ if (part != nil)
+ EpContextMenuDm(device);
+ break;
+
+ case `CT_BTRFS:
+ if (part != nil)
+ EpContextMenuBtrfs(device);
+ break;
+
+ case `CT_TMPFS:
+ EpContextMenuTmpfs(device);
+ break;
+ }
+ }
+
+
/**
* Confirm leaving the module
*/
boolean ReallyQuit( string label )
{
// popup text, %1 will be replaces with button text
- string text = sformat(_("You have changed the partitioning. These changes will be lost
-if you exit the partitioner with %1. Really exit?"), deletechars(label, "&"));
+ string text = sformat(_("You have changed the partitioning or storage settings. These changes
+will be lost if you exit the partitioner with %1.
+Really exit?"), deletechars(label, "&"));
return Popup::YesNo(text);
}
@@ -231,7 +331,7 @@
return helptext;
}
-
+
/**
* Fullscreen summary of changes
@@ -239,24 +339,14 @@
symbol SummaryDialog()
{
symbol ret = `none;
- string doto = Storage::ChangeText();
- y2milestone("Summary of changes: %1", doto);
-
- /*if (size(doto) == 0)
- {
- // popup text
- Popup::Message(_("No unsaved changes exist."));
- return `back;
- }*/
Wizard::CreateDialog();
- Wizard::SetContentsButtons(caption + _(": Summary"),
- `VBox(`RichText( `id(`summary), _("Creating summary ..."))),
+ Wizard::SetContentsButtons(caption + _(": Summary"),
+ `VBox(`RichText(CompleteSummary())),
SummaryDialogHelptext(),
Label::BackButton(),
Label::FinishButton());
Wizard::SetDesktopIcon("disk");
- UI::ChangeWidget(`id(`summary), `Value, _("<h1>Changes in Partitioning</h1>") + doto);
while (true)
{
@@ -264,6 +354,7 @@
if (ret == `next || ret == `back)
break;
+
if( ret == `abort && ReallyQuit( Label::AbortButton() ))
{
ret =`abort;
@@ -343,9 +434,11 @@
repeat
{
- widget = (symbol) Wizard::UserInput();
+ map event = Wizard::WaitForEvent();
+
+ TreePanel::Handle(event);
- TreePanel::Handle(widget);
+ widget = event["ID"]:(symbol) nil;
switch (widget)
{
@@ -359,7 +452,7 @@
} break;
case `next: {
- if (!Storage::EqualBackupStates("expert-partitioner", "", true))
+ if (!Storage::EqualBackupStates("expert-partitioner", "", true) || StorageSettings::GetModified())
{
if (!check_created_partition_table(Storage::GetTargetMap(),
Stage::initial() && !Mode::repair()))
@@ -381,7 +474,10 @@
widget = `abort;
}
} break;
+ }
+ switch (Event::IsWidgetActivated(event))
+ {
case `table: {
any citem = UI::QueryWidget(`id(`table), `CurrentItem);
TreePanel::SwitchToNew(citem);
Modified: branches/SuSE-Code-11-SP2-Branch/storage/storage/src/include/ep-nfs.ycp
URL: http://svn.opensuse.org/viewcvs/yast/branches/SuSE-Code-11-SP2-Branch/stora…
==============================================================================
--- branches/SuSE-Code-11-SP2-Branch/storage/storage/src/include/ep-nfs.ycp (original)
+++ branches/SuSE-Code-11-SP2-Branch/storage/storage/src/include/ep-nfs.ycp Tue May 17 13:39:44 2011
@@ -3,14 +3,15 @@
* Package: yast2-storage
* Summary: Expert Partitioner
* Authors: Arvin Schnell <aschnell(a)suse.de>
+ *
+ * This file must only be included in other Expert Partitioner files ("ep-*.ycp").
*/
{
textdomain "storage";
- import "Directory";
import "PackageCallbacks";
import "PackageSystem";
- import "Wizard";
+
//boolean initialized = false;
map <string, map> target_map = $[];
@@ -24,7 +25,7 @@
return StorageFields::PredicateDiskType(disk, partition, [`CT_NFS]);
}
- term CreateContent()
+ term CreateContent()
{
boolean pkg_installed = false;
//fallback dialog content
@@ -63,7 +64,7 @@
return fallback_content;
}
- void Initialize()
+ void Initialize()
{
target_map = Storage::GetTargetMap();
@@ -90,7 +91,7 @@
`VBox(
`HStretch(),
// heading
- `IconAndHeading(_("Network File System (NFS)"), nfs_icon),
+ `IconAndHeading(_("Network File System (NFS)"), StorageIcons::nfs_icon),
CreateContent()
)
)
@@ -102,19 +103,23 @@
}
- void HandleNfsMainPanel(any user_data, symbol widget)
+ void HandleNfsMainPanel(any user_data, map event)
{
- void AddShare ( map <string, any> entry )
+ void AddShare ( map <string, any> entry )
{
- y2milestone("Adding NFS share: %1 mountpoint: %2 options: %3",
+ y2milestone("Adding NFS share: %1 mountpoint: %2 options: %3",
entry["device"]:"", entry["mount"]:"", entry["fstopt"]:"");
target_map = Storage::GetTargetMap();
list<map> nfs_list = target_map["/dev/nfs", "partitions"]:[];
- integer sizeK = Storage::CheckNfsVolume (entry["device"]:"", entry["fstopt"]:"");
+ string device = entry["device"]:"";
+ string mount = entry["mount"]:"";
+ string opts = entry["fstopt"]:"";
+ boolean nfs4 = entry["vfstype"]:"nfs" == "nfs4";
- if ( sizeK <= 0)
+ integer sizeK = Storage::CheckNfsVolume(device, opts, nfs4);
+ if (sizeK <= 0)
{
//rollback only if user does not want to save (#450060)
//the mount might fail later if the errors are not corrected, but the user has been warned
@@ -129,19 +134,19 @@
//real size - Perl then wants to die in addNfsVolume call
sizeK = 0;
}
- Storage::AddNfsVolume( entry["device"]:"", entry["fstopt"]:"", sizeK, entry["mount"]:"");
+ Storage::AddNfsVolume(device, opts, sizeK, mount, nfs4);
}
void EditShare( map <string, any> entry )
{
- y2milestone("Changing NFS share: %1 mountpoint: %2 options: %3",
+ y2milestone("Changing NFS share: %1 mountpoint: %2 options: %3",
entry["device"]:"", entry["mount"]:"", entry["fstopt"]:"");
//device got renamed -
- //delete the one with old name and create new
+ //delete the one with old name and create new
if (haskey(entry,"old_device"))
{
- Storage::DeleteDevice("/dev/nfs", entry["old_device"]:"");
+ Storage::DeleteDevice(entry["old_device"]:"");
AddShare(entry);
}
else
@@ -155,6 +160,7 @@
{
m["fstopt"] = entry["fstopt"]:"";
m["mount"] = entry["mount"]:"";
+ m["vfstype"] = entry["used_fs"]:`nfs == `nfs ? "nfs" : "nfs4";
}
return m;
});
@@ -165,19 +171,19 @@
void DeleteShare( map <string, any> entry )
{
- y2milestone("Deleting NFS share: %1 mountpoint: %2 options: %3",
+ y2milestone("Deleting NFS share: %1 mountpoint: %2 options: %3",
entry["device"]:"", entry["mount"]:"", entry["fstopt"]:"");
string dev = entry["device"]:"";
- Storage::DeleteDevice("/dev/nfs", dev );
+ Storage::DeleteDevice(dev);
}
- map <string, any> line = ( map <string, any> ) WFM::CallFunction("nfs-client4part", [ "HandleEvent", $[ "widget_id" : widget ] ]);
+ map <string, any> line = ( map <string, any> ) WFM::CallFunction("nfs-client4part", [ "HandleEvent", $[ "widget_id" : Event::IsWidgetActivated(event) ] ]);
//do something only if y2-nfs-client returns some reasonable data
if ( line != $[] && line != nil)
{
- switch (widget )
+ switch (Event::IsWidgetActivated(event))
{
case `newbut:
{
@@ -200,7 +206,7 @@
UI::SetFocus(`id(`fstable));
UpdateMainStatus();
}
- //FIXME: Take care that non-fstab settings of nfs-client
+ //FIXME: Take care that non-fstab settings of nfs-client
//(firewall, sysconfig, idmapd) get written on closing partitioner
}
@@ -209,8 +215,6 @@
//a hack - we don't have overviews for nfs dirs, so let's switch to the main panel ...
CreateNfsMainPanel( user_data );
UI::ChangeWidget(`tree, `CurrentItem, `nfs );
-
}
-
- }
+}
Modified: branches/SuSE-Code-11-SP2-Branch/storage/storage/src/include/ep-raid-dialogs.ycp
URL: http://svn.opensuse.org/viewcvs/yast/branches/SuSE-Code-11-SP2-Branch/stora…
==============================================================================
--- branches/SuSE-Code-11-SP2-Branch/storage/storage/src/include/ep-raid-dialogs.ycp (original)
+++ branches/SuSE-Code-11-SP2-Branch/storage/storage/src/include/ep-raid-dialogs.ycp Tue May 17 13:39:44 2011
@@ -3,6 +3,8 @@
* Package: yast2-storage
* Summary: Expert Partitioner
* Authors: Arvin Schnell <aschnell(a)suse.de>
+ *
+ * This file must only be included in other Expert Partitioner files ("ep-*.ycp").
*/
{
textdomain "storage";
@@ -27,6 +29,7 @@
// error popup, %1 is replaced by raid type e.g. "RAID1", %2 is replaced by integer
Popup::Error(sformat(_("For %1, select at least %2 device.", "For %1, select at least %2 devices.", min_num),
info[raid_type]:"error", min_num));
+ UI::SetFocus(`id(`unselected));
return false;
}
else
@@ -38,7 +41,7 @@
integer DefaultChunkSizeK(string raid_type)
{
- map<string, integer> info = $[ "raid0" : 32, "raid5" : 128 ];
+ map<string, integer> info = $[ "raid0" : 32, "raid5" : 128, "raid6" : 128, "raid10" : 32 ];
return info[raid_type]:4;
}
@@ -92,16 +95,16 @@
integer callback(list<map> devices)
{
integer sizeK = 0;
- Storage::ComputeMdSize(symbolof(toterm(raid_type)), maplist(map device, devices, { return device["device"]:""; }), sizeK);
+ Storage::ComputeMdSize(tosymbol(raid_type), maplist(map device, devices, { return device["device"]:""; }), sizeK);
return sizeK;
}
list<symbol> fields = StorageSettings::FilterTable([ `device, `udev_path, `udev_id, `size, `encrypted, `type ]);
map<string, map> target_map = Storage::GetTargetMap();
- list<map> unused_devices = filter(map dev, get_possible_rds(target_map), { return dev["used_by"]:"" == "" &&
+ list<map> unused_devices = filter(map dev, get_possible_rds(target_map), { return !Storage::IsUsedBy(dev) &&
!contains(devices, dev["device"]:""); });
- list<map> used_devices = filter(map dev, get_possible_rds(target_map), { return dev["used_by"]:"" == "" &&
+ list<map> used_devices = filter(map dev, get_possible_rds(target_map), { return !Storage::IsUsedBy(dev) &&
contains(devices, dev["device"]:""); });
term contents = `VBox(`Left(
@@ -183,7 +186,7 @@
data["devices"] = devices;
integer size_k = 0;
- Storage::ComputeMdSize(symbolof(toterm(raid_type)), devices, size_k);
+ Storage::ComputeMdSize(tosymbol(raid_type), devices, size_k);
data["size_k"] = size_k;
}
@@ -203,15 +206,23 @@
32 kB is a good starting point. For RAID 1, the chunk size does not affect the array very much.</p>
");
- if (raid_type == "raid5")
+ if (raid_type == "raid5" || raid_type == "raid6")
// helptext
- helptext = helptext + _("<p><b>Parity Algorithm:</b><br>The parity algorithm to use with RAID5.
+ helptext = helptext + _("<p><b>Parity Algorithm:</b><br>The parity algorithm to use with RAID5/6.
Left-symmetric is the one that offers maximum performance on typical disks with rotating platters.</p>
");
return helptext;
}
+ list<term> getParTerms( string mdtype, integer sz )
+ {
+ list<list> pars = Storage::AllowdParity( mdtype, sz );
+ return( maplist( list e, pars,
+ ``{
+ return( `item( `id(e[0]:`par_default), e[1]:"" ));
+ }));
+ }
symbol MiniWorkflowStepRaidOptions(map<string, any> &data)
{
@@ -219,10 +230,10 @@
string raid_type = data["raid_type"]:"error";
integer chunk_size = (data["chunk_size_k"]:DefaultChunkSizeK(raid_type))*1024;
- symbol parity_algorithm = data["parity_algorithm"]:`left_asymmetric;
+ symbol parity_algorithm = data["parity_algorithm"]:`par_default;
list<term> chunk_sizes_list = maplist(integer i, Integer::RangeFrom(11, 22), {
- return `item(`id(2 << i), Storage::ByteToHumanStringWithPrecision(2 << i, 2, true));
+ return `item(`id(2 << i), Storage::ByteToHumanStringOmitZeroes(2 << i));
});
term options = `VBox(
@@ -230,15 +241,14 @@
`id(chunk_size)))
);
- if (raid_type == "raid5")
+ list<term> par_list = getParTerms( raid_type, size(data["devices"]:[]));
+
+ if (size(par_list)>0)
options = add(options,
`Left(`ComboBoxSelected(`id(`parity_algorithm), `opt(`hstretch),
// combo box label
_("Parity &Algorithm"),
- [ `item(`id(`left_asymmetric), "left-asymmetric"),
- `item(`id(`left_symmetric), "left-symmetric"),
- `item(`id(`right_asymmetric), "right-asymmetric"),
- `item(`id(`right_symmetric), "right-symmetric") ],
+ par_list,
`id(parity_algorithm)))
);
@@ -293,7 +303,7 @@
integer callback(list<map> devices)
{
integer sizeK = 0;
- Storage::ComputeMdSize(symbolof(toterm(raid_type)), maplist(map device, devices, { return device["device"]:""; }), sizeK);
+ Storage::ComputeMdSize(tosymbol(raid_type), maplist(map device, devices, { return device["device"]:""; }), sizeK);
return sizeK;
}
@@ -368,7 +378,7 @@
// dialog title
string title = sformat(_("Add RAID %1"), data["device"]:"error");
- symbol widget = MiniWorkflow::Run(title, raid_icon, aliases, sequence, "TypeDevices");
+ symbol widget = MiniWorkflow::Run(title, StorageIcons::raid_icon, aliases, sequence, "TypeDevices");
return widget == `finish;
}
@@ -387,7 +397,7 @@
// dialog title
string title = sformat(_("Resize RAID %1"), data["device"]:"error");
- symbol widget = MiniWorkflow::Run(title, raid_icon, aliases, sequence, "TheOne");
+ symbol widget = MiniWorkflow::Run(title, StorageIcons::raid_icon, aliases, sequence, "TheOne");
return widget == `finish;
}
@@ -411,7 +421,7 @@
// dialog title
string title = sformat(_("Edit RAID %1"), device);
- symbol widget = MiniWorkflow::Run(title, raid_icon, aliases, sequence, "FormatMount");
+ symbol widget = MiniWorkflow::Run(title, StorageIcons::raid_icon, aliases, sequence, "FormatMount");
return widget == `finish;
}
Modified: branches/SuSE-Code-11-SP2-Branch/storage/storage/src/include/ep-raid-lib.ycp
URL: http://svn.opensuse.org/viewcvs/yast/branches/SuSE-Code-11-SP2-Branch/stora…
==============================================================================
--- branches/SuSE-Code-11-SP2-Branch/storage/storage/src/include/ep-raid-lib.ycp (original)
+++ branches/SuSE-Code-11-SP2-Branch/storage/storage/src/include/ep-raid-lib.ycp Tue May 17 13:39:44 2011
@@ -3,6 +3,8 @@
* Package: yast2-storage
* Summary: Expert Partitioner
* Authors: Arvin Schnell <aschnell(a)suse.de>
+ *
+ * This file must only be included in other Expert Partitioner files ("ep-*.ycp").
*/
{
textdomain "storage";
@@ -15,7 +17,7 @@
foreach(string dev, devs, {
Storage::SetPartitionId(dev, Partitions::fsid_raid);
Storage::SetPartitionFormat(dev, false, `none);
- if (!Storage::ExtendMd(raid_nr, dev))
+ if (!Storage::ExtendMd(raid_nr, [ dev ]))
ret = false;
});
@@ -29,7 +31,7 @@
foreach(string dev, devs, {
Storage::UnchangePartitionId(dev);
- if (!Storage::ShrinkMd(raid_nr, dev))
+ if (!Storage::ShrinkMd(raid_nr, [ dev ]))
ret = false;
});
@@ -40,7 +42,7 @@
void EpCreateRaid()
{
map<string, map> target_map = Storage::GetTargetMap();
- list<map> unused_devices = filter(map dev, get_possible_rds(target_map), { return dev["used_by"]:"" == ""; });
+ list<map> unused_devices = filter(map dev, get_possible_rds(target_map), { return !Storage::IsUsedBy(dev); });
if (size(unused_devices) < 2)
{
@@ -59,7 +61,7 @@
if (DlgCreateRaidNew(data))
{
integer nr = data["nr"]:0;
- symbol raid_type = symbolof(toterm(data["raid_type"]:"raid0"));
+ symbol raid_type = tosymbol(data["raid_type"]:"raid0");
if (Storage::CreateMdWithDevs(nr, raid_type, []))
{
@@ -69,10 +71,11 @@
integer chunk_size_k = data["chunk_size_k"]:4;
Storage::ChangeMdChunk(nr, chunk_size_k);
- if (raid_type == `raid5) {
- symbol parity_algorithm = data["parity_algorithm"]:`left_asymmetric;
+ if( haskey( data, "parity_algorithm" ))
+ {
+ symbol parity_algorithm = data["parity_algorithm"]:`par_default;
Storage::ChangeMdParitySymbol(nr, parity_algorithm);
- }
+ }
Storage::ChangeVolumeProperties(data);
@@ -97,7 +100,7 @@
map<string, map> target_map = Storage::GetTargetMap();
map<string, any> data = Storage::GetPartition(target_map, device);
- if (data["used_by"]:"" != "")
+ if (Storage::IsUsedBy(data))
{
// error popup, %1 is replaced by device name e.g. /dev/md1
Popup::Error(sformat(_("The RAID %1 is in use. It cannot be
@@ -137,7 +140,7 @@
return;
}
- if (data["used_by"]:"" != "")
+ if (Storage::IsUsedBy(data))
{
// error popup, %1 is replaced by device name e.g. /dev/md1
Popup::Error(sformat(_("The RAID %1 is in use. It cannot be
@@ -184,8 +187,12 @@
if (EpDeleteDevice(device))
{
+ any new_focus = nil;
+ if (UI::QueryWidget(`tree, `CurrentItem) == device)
+ new_focus = `md;
+
UpdateMainStatus();
- UpdateNavigationTree(`md);
+ UpdateNavigationTree(new_focus);
TreePanel::Create();
}
}
Modified: branches/SuSE-Code-11-SP2-Branch/storage/storage/src/include/ep-raid.ycp
URL: http://svn.opensuse.org/viewcvs/yast/branches/SuSE-Code-11-SP2-Branch/stora…
==============================================================================
--- branches/SuSE-Code-11-SP2-Branch/storage/storage/src/include/ep-raid.ycp (original)
+++ branches/SuSE-Code-11-SP2-Branch/storage/storage/src/include/ep-raid.ycp Tue May 17 13:39:44 2011
@@ -3,15 +3,73 @@
* Package: yast2-storage
* Summary: Expert Partitioner
* Authors: Arvin Schnell <aschnell(a)suse.de>
+ *
+ * This file must only be included in other Expert Partitioner files ("ep-*.ycp").
*/
{
textdomain "storage";
-
include "partitioning/ep-raid-dialogs.ycp";
include "partitioning/ep-raid-lib.ycp";
+ void EpContextMenuRaid(string device)
+ {
+ symbol widget = ContextMenu::Simple([ `item(`id(`edit), _("Edit")),
+ `item(`id(`resize), _("Resize")),
+ `item(`id(`delete), _("Delete")) ]);
+
+ switch (widget)
+ {
+ case `edit:
+ EpEditRaid(device);
+ break;
+
+ case `resize:
+ EpResizeRaid(device);
+ break;
+
+ case `delete:
+ EpDeleteRaid(device);
+ break;
+ }
+ }
+
+ term RaidButtonBox()
+ {
+ return `HBox(
+ // push button text
+ `PushButton(`id(`edit), `opt(`key_F4), _("Edit...")),
+ // push button text
+ `PushButton(`id(`resize), `opt(`key_F6), _("Resize...")),
+ // push button text
+ `PushButton(`id(`delete), `opt(`key_F5), _("Delete..."))
+ );
+ }
+
+ void HandleRaidButtons( string device, map event )
+ {
+
+ switch (Event::IsWidgetActivated(event))
+ {
+ case `add:
+ EpCreateRaid();
+ break;
+ case `edit:
+ EpEditRaid(device);
+ break;
+
+ case `resize:
+ EpResizeRaid(device);
+ break;
+
+ case `delete:
+ EpDeleteRaid(device);
+ break;
+ }
+
+ }
+
void CreateRaidMainPanel(any user_data)
{
symbol Predicate(map disk, map partition)
@@ -33,12 +91,13 @@
`VBox(
`HStretch(),
// heading
- `IconAndHeading(_("RAID"), raid_icon),
- `Table(`id(`table), `opt(`keepSorting, `notify),
+ `IconAndHeading(_("RAID"), StorageIcons::raid_icon),
+ `Table(`id(`table), `opt(`keepSorting, `notify, `notifyContextMenu),
table_header, table_contents),
`HBox(
// push button text
- `Left(`PushButton(`id(`add), `opt(`key_F3), _("Add RAID..."))),
+ `PushButton(`id(`add), `opt(`key_F3), _("Add RAID...")),
+ RaidButtonBox(),
`HStretch()
)
)
@@ -52,14 +111,19 @@
}
- void HandleRaidMainPanel(any user_data, symbol widget)
+ void HandleRaidMainPanel(any user_data, map event)
{
- switch (widget)
+ string device = (string) UI::QueryWidget(`id(`table), `CurrentItem);
+
+ HandleRaidButtons(device, event);
+
+ switch (Event::IsWidgetContextMenuActivated(event))
{
- case `add:
- EpCreateRaid();
+ case `table:
+ EpContextMenuDevice(device);
break;
}
+
UI::SetFocus(`id(`table));
}
@@ -70,7 +134,7 @@
map<string, map> target_map = Storage::GetTargetMap();
- list<symbol> fields = StorageSettings::FilterOverview([ `heading_device, `device, `size, `encrypted,
+ list<symbol> fields = StorageSettings::FilterOverview([ `heading_device, `device, `size, `encrypted, `udev_id,
`used_by, `heading_md, `raid_type, `chunk_size,
`parity_algorithm, `heading_filesystem,
`fs_type, `mount_point, `mount_by, `uuid,
@@ -80,15 +144,7 @@
`VBox(
`HStretch(),
StorageFields::Overview(fields, target_map, part_device),
- `HBox(
- // push button text
- `PushButton(`id(`edit), `opt(`key_F4), _("Edit...")),
- // push button text
- `PushButton(`id(`resize), `opt(`key_F6), _("Resize...")),
- // push button text
- `PushButton(`id(`delete), `opt(`key_F5), _("Delete...")),
- `HStretch()
- )
+ `Left( RaidButtonBox() )
)
);
@@ -100,24 +156,11 @@
}
- void HandleRaidOverviewTab(any user_data, symbol widget)
+ void HandleRaidOverviewTab(any user_data, map event)
{
- string device = (string) user_data;
-
- switch (widget)
- {
- case `edit:
- EpEditRaid(device);
- break;
- case `resize:
- EpResizeRaid(device);
- break;
+ HandleRaidButtons( (string) user_data, event);
- case `delete:
- EpDeleteRaid(device);
- break;
- }
UI::SetFocus(`id(`text));
}
@@ -165,7 +208,7 @@
Greasemonkey::Transform(
`VBox(
// heading
- `IconAndHeading(sformat(_("RAID: %1"), device), raid_icon),
+ `IconAndHeading(sformat(_("RAID: %1"), device), StorageIcons::raid_icon),
`DumbTab(`id(`tab), [
// push button text
`item(`id(`overview), _("&Overview")),
@@ -182,8 +225,8 @@
}
- void HandleRaidPanel(any user_data, symbol widget)
+ void HandleRaidPanel(any user_data, map event)
{
- TabPanel::Handle(widget);
+ TabPanel::Handle(event);
}
}
Modified: branches/SuSE-Code-11-SP2-Branch/storage/storage/src/include/ep-settings.ycp
URL: http://svn.opensuse.org/viewcvs/yast/branches/SuSE-Code-11-SP2-Branch/stora…
==============================================================================
--- branches/SuSE-Code-11-SP2-Branch/storage/storage/src/include/ep-settings.ycp (original)
+++ branches/SuSE-Code-11-SP2-Branch/storage/storage/src/include/ep-settings.ycp Tue May 17 13:39:44 2011
@@ -3,12 +3,16 @@
* Package: yast2-storage
* Summary: Expert Partitioner
* Authors: Arvin Schnell <aschnell(a)suse.de>
+ *
+ * This file must only be included in other Expert Partitioner files ("ep-*.ycp").
*/
{
textdomain "storage";
+
void DestroySettingsPanel(any user_data);
+
list< map<symbol, any> > visible_fields = [
// list entry
$[ `label : _("Label"), `fields : [ `label ] ],
@@ -28,65 +32,68 @@
$[ `label : _("Encryption"), `fields : [ `encrypted ] ]
];
-
- list<term> partalign_items = maplist(symbol pal, [ `align_optimal, `align_cylinder ], {
- return `item(`id(pal), substring( sformat( "%1", pal ), 7 ));
- });
+ map<symbol, string> mount_bys = $[
+ // combo box entry
+ `device : _("Device Name"),
+ // combo box entry
+ `label : _("Volume Label"),
+ // combo box entry
+ `uuid : _("UUID"),
+ // combo box entry
+ `id : _("Device ID"),
+ // combo box entry
+ `path : _("Device Path")
+ ];
void CreateSettingsPanel(any user_data)
{
list <term> PreselectVisibleFields()
{
- list <symbol> hidden_fields = StorageSettings::GetHiddenFields();
+ list<symbol> hidden_fields = StorageSettings::GetHiddenFields();
return maplist(integer i, Integer::Range(size(visible_fields)), {
string label = visible_fields[i, `label]:"";
list<symbol> fields = visible_fields[i, `fields]:[];
- boolean selected = list::reduce(boolean tmp, symbol field, true, fields, {
- return tmp && !setcontains(hidden_fields, field);
- });
+ boolean selected = !multiset::includes(hidden_fields, fields);
return `item(`id(i), label, selected);
});
}
+ list <term> mount_by_items = maplist( symbol item_id, string label, mount_bys, {
+ return `item(`id(item_id), label);
+ });
+
+ list<symbol> filesystems = filter(symbol fs, [ `ext2, `ext3, `ext4, `reiser, `xfs ], {
+ return FileSystems::IsSupported(fs) && !FileSystems::IsUnsupported(fs);
+ });
+
+ list<term> filesystem_items = maplist(symbol fs, filesystems, {
+ return `item(`id(fs), FileSystems::GetName(fs, "Error"));
+ });
+
+ list<term> partalign_items = maplist(symbol pal, [ `align_optimal, `align_cylinder ], {
+ return `item(`id(pal), substring( sformat( "%1", pal ), 7 ));
+ });
+
+
UI::ReplaceWidget(`tree_panel,
Greasemonkey::Transform(
`VBox(
// dialog heading
- `IconAndHeading(_("Settings"), settings_icon),
+ `IconAndHeading(_("Settings"), StorageIcons::settings_icon),
`VBox(
- `Left(`ComboBoxSelected(`id(`default_mountby),
+ `Left(`ComboBoxSelected(`id(`default_mountby),`opt(`notify),
// combo box label
_("Default Mount by"),
- [
- // combo box entry
- `item(`id(`device), _("Device Name")),
- // combo box entry
- `item(`id(`label), _("Volume Label")),
- // combo box entry
- `item(`id(`uuid), _("UUID")),
- // combo box entry
- `item(`id(`id), _("Device ID")),
- // combo box entry
- `item(`id(`path), _("Device Path"))
- ],
+ mount_by_items,
`id(Storage::GetDefaultMountBy()))),
- `Left(`ComboBoxSelected(`id(`default_fs),
+ `Left(`ComboBoxSelected(`id(`default_fs),`opt(`notify),
// combo box label
_("Default File System"),
- [
- // combo box entry
- `item(`id(`ext2), "Ext2"),
- // combo box entry
- `item(`id(`ext3), "Ext3"),
- // combo box entry
- `item(`id(`reiser), "Reiser"),
- // combo box entry
- `item(`id(`xfs), "XFS")
- ],
+ filesystem_items,
`id(Partitions::DefaultFs()))),
`Left(`ComboBoxSelected(`id(`part_align),`opt(`notify),
- // combo box label
+ // combo box label
_("Alignment of Newly Created Partitions"),
partalign_items,
`id(Storage::GetPartitionAlignment()))),
@@ -106,7 +113,7 @@
//This looks extremely ugly, but obviously there are few other means how
//to make MultiSelection widget smaller, yet still readable
`Left(`HBox(
- `MultiSelectionBox(`id(`visible_fields), `opt(`shrinkable),
+ `MultiSelectionBox(`id(`visible_fields), `opt(`shrinkable, `notify),
// multi selection box label
_("Visible Information On Storage Devices"),
PreselectVisibleFields()),
@@ -116,19 +123,30 @@
`VStretch()
)));
+
// helptext
string helptext = _("<p>This view shows general storage
settings:</p>");
// helptext
helptext = helptext + _("<p><b>Default Mount by</b> gives the mount by
-method for newly created file systems.</p>");
+method for newly created file systems. <i>Device Name</i> uses the kernel
+device name which is not persistent. <i>Device ID</i> and <i>Device Path</i>
+use names generated by udev from hardware information. These should be
+persistent but unfortunately this is not always true. Finally <i>UUID</i> and
+<i>Volume Label</i> use the file systems UUID and label.</p>");
// helptext
helptext = helptext + _("<p><b>Default File System</b> gives the file
system type for newly created file file systems.</p>");
// helptext
+ helptext = helptext + _("<p><b>Alignment of Newly Created Partitions</b>
+determines how created partitions are aligned. <b>cylinder</b> is the traditional alignment at cylinder boundaries of the disk. <b>optimal</b> aligns the
+partitions for best performance according to hints provided by linux kernel
+or tries to be compatible with Windows Vista and Win 7.</p>");
+
+ // helptext
helptext = helptext + _("<p><b>Show Storage Devices by</b> controls
the name displayed for hard disks in the navigation tree.</p>");
@@ -140,41 +158,47 @@
}
- void HandleSettingsPanel(any user_data, symbol widget)
+ void HandleSettingsPanel(any user_data, map event)
{
- if (widget == `display_name)
+ switch (Event::IsWidgetValueChanged(event))
{
- StorageSettings::SetDisplayName((symbol) UI::QueryWidget(`id(`display_name), `Value));
- UpdateNavigationTree(nil);
+ case `display_name:
+ StorageSettings::SetDisplayName((symbol) UI::QueryWidget(`id(`display_name), `Value));
+ UpdateNavigationTree(nil);
+ break;
}
- if (widget == `next)
+
+ switch (Event::IsWidgetActivated(event))
+ {
+ case `next:
+ DestroySettingsPanel(user_data);
+ break;
+ }
+
+ if (!StorageSettings::GetModified())
{
- DestroySettingsPanel(user_data);
+ StorageSettings::SetModified();
+ Wizard::SetNextButton(`next, Label::NextButton());
}
}
void DestroySettingsPanel(any user_data)
{
- list<symbol> InvertVisibleFields(list<symbol> hidden_fields)
- {
- list<integer> selected = (list<integer>) UI::QueryWidget(`id(`visible_fields), `SelectedItems);
+ list<integer> selected = (list<integer>) UI::QueryWidget(`id(`visible_fields), `SelectedItems);
+ list<string> selected_labels = [];
- foreach(integer i, Integer::Range(size(visible_fields)), {
- list<symbol> fields = visible_fields[i, `fields]:[];
- if (contains(selected, i))
- hidden_fields = filter(symbol hidden_field, hidden_fields, { return !setcontains(fields, hidden_field); });
- else
- hidden_fields = toset(flatten([ hidden_fields, fields ]));
- });
-
- return hidden_fields;
- }
+ foreach(integer i, selected, {
+ selected_labels= add(selected_labels, visible_fields[i, `label]:"");
+ });
- Storage::SetDefaultMountBy((symbol) UI::QueryWidget(`id(`default_mountby), `Value));
- Partitions::SetDefaultFs((symbol) UI::QueryWidget(`id(`default_fs), `Value));
+ symbol default_mount = (symbol) UI::QueryWidget(`id(`default_mountby), `Value);
+ symbol default_fs = (symbol) UI::QueryWidget(`id(`default_fs), `Value);
symbol part_align = (symbol) UI::QueryWidget(`id(`part_align), `Value);
+
+ Storage::SetDefaultMountBy( default_mount );
+ Partitions::SetDefaultFs( default_fs );
Storage::SetPartitionAlignment( part_align );
- StorageSettings::SetHiddenFields(InvertVisibleFields(StorageSettings::GetHiddenFields()));
+ StorageSettings::InvertVisibleFields(visible_fields, selected);
}
}
Added: branches/SuSE-Code-11-SP2-Branch/storage/storage/src/include/ep-summary.ycp
URL: http://svn.opensuse.org/viewcvs/yast/branches/SuSE-Code-11-SP2-Branch/stora…
==============================================================================
--- branches/SuSE-Code-11-SP2-Branch/storage/storage/src/include/ep-summary.ycp (added)
+++ branches/SuSE-Code-11-SP2-Branch/storage/storage/src/include/ep-summary.ycp Tue May 17 13:39:44 2011
@@ -0,0 +1,29 @@
+/**
+ * File: ep-summary.ycp
+ * Package: yast2-storage
+ * Summary: Expert Partitioner
+ * Authors: Arvin Schnell <aschnell(a)suse.de>
+ *
+ * This file must only be included in other Expert Partitioner files ("ep-*.ycp").
+ */
+{
+ textdomain "storage";
+
+
+ void CreateSummaryPanel(any user_data)
+ {
+ UI::ReplaceWidget(`tree_panel,
+ Greasemonkey::Transform(
+ `VBox(
+ // dialog heading
+ `IconAndHeading(_("Installation Summary"), StorageIcons::summary_icon),
+ `RichText(CompleteSummary())
+ ))
+ );
+
+ // helptext
+ string helptext = _("<p>This view show the installation summary.</p>");
+
+ Wizard::RestoreHelp(helptext);
+ }
+}
Added: branches/SuSE-Code-11-SP2-Branch/storage/storage/src/include/ep-tmpfs-dialogs.ycp
URL: http://svn.opensuse.org/viewcvs/yast/branches/SuSE-Code-11-SP2-Branch/stora…
==============================================================================
--- branches/SuSE-Code-11-SP2-Branch/storage/storage/src/include/ep-tmpfs-dialogs.ycp (added)
+++ branches/SuSE-Code-11-SP2-Branch/storage/storage/src/include/ep-tmpfs-dialogs.ycp Tue May 17 13:39:44 2011
@@ -0,0 +1,34 @@
+/**
+ * File: ep-tmpfs-dialogs.ycp
+ * Package: yast2-storage
+ * Summary: Expert Partitioner
+ * Authors: Thomas Fehr <fehr(a)suse.de>
+ *
+ * This file must only be included in other Expert Partitioner files ("ep-*.ycp").
+ */
+{
+ textdomain "storage";
+
+
+boolean DlgCreateTmpfs(map<string, any> &data)
+ {
+ map<string, any> aliases = $[
+ "FormatMount" : ``(MiniWorkflowStepFormatMount(data))
+ ];
+
+ map<string, any> sequence = $[
+ "FormatMount" : $[ `finish : `finish ],
+ ];
+
+ // dialog title
+ string title = _("Add Tmpfs Mount");
+
+ symbol widget = MiniWorkflow::Run(title, StorageIcons::dm_icon, aliases, sequence, "FormatMount");
+
+ return widget == `finish;
+ }
+
+
+
+
+}
Added: branches/SuSE-Code-11-SP2-Branch/storage/storage/src/include/ep-tmpfs-lib.ycp
URL: http://svn.opensuse.org/viewcvs/yast/branches/SuSE-Code-11-SP2-Branch/stora…
==============================================================================
--- branches/SuSE-Code-11-SP2-Branch/storage/storage/src/include/ep-tmpfs-lib.ycp (added)
+++ branches/SuSE-Code-11-SP2-Branch/storage/storage/src/include/ep-tmpfs-lib.ycp Tue May 17 13:39:44 2011
@@ -0,0 +1,51 @@
+/**
+ * File: ep-tmpfs-lib.ycp
+ * Package: yast2-storage
+ * Summary: Expert Partitioner
+ * Authors: Thomas Fehr <fehr(a)suse.de>
+ *
+ * This file must only be included in other Expert Partitioner files ("ep-*.ycp").
+ */
+{
+ textdomain "storage";
+
+
+void EpDeleteTmpfsDevice(string device)
+ {
+ if (device == nil)
+ {
+ // error popup
+ Popup::Error(_("No TMPFS device selected."));
+ return;
+ }
+
+ list<string> tmp = splitstring(device,":");
+ string mount = tmp[1]:"";
+ y2milestone( "EpDeleteTmpfsDevice device:%1 mount:%2", device, mount );
+ // YesNo popup. %1 is path to a file
+ if( Popup::YesNo( sformat(_("\nReally delete tmpfs mounted to %1"), mount )) &&
+ Storage::DelTmpfsVolume( mount ))
+ {
+ any new_focus = nil;
+ if (UI::QueryWidget(`tree, `CurrentItem) == device)
+ new_focus = `tmpfs;
+ UpdateMainStatus();
+ UpdateNavigationTree(new_focus);
+ TreePanel::Create();
+ }
+ }
+
+void EpAddTmpfsDevice()
+ {
+ map<string, any> data = $[ "device":"tmpfs", "fstype":"TMPFS", "format":true,
+ "type":`tmpfs, "detected_fs":`tmpfs, "used_fs":`tmpfs ];
+ if( DlgCreateTmpfs(data) )
+ {
+ y2milestone( "EpAddTmpfsDevice data:%1", data );
+ Storage::AddTmpfsVolume( data["mount"]:"", data["fstopt"]:"" );
+ UpdateMainStatus();
+ UpdateNavigationTree(nil);
+ TreePanel::Create();
+ }
+ }
+}
Added: branches/SuSE-Code-11-SP2-Branch/storage/storage/src/include/ep-tmpfs.ycp
URL: http://svn.opensuse.org/viewcvs/yast/branches/SuSE-Code-11-SP2-Branch/stora…
==============================================================================
--- branches/SuSE-Code-11-SP2-Branch/storage/storage/src/include/ep-tmpfs.ycp (added)
+++ branches/SuSE-Code-11-SP2-Branch/storage/storage/src/include/ep-tmpfs.ycp Tue May 17 13:39:44 2011
@@ -0,0 +1,184 @@
+/**
+ * File: ep-tmpfs.ycp
+ * Package: yast2-storage
+ * Summary: Expert Partitioner
+ * Authors: Thomas Fehr <fehr(a)suse.de>
+ *
+ * This file must only be included in other Expert Partitioner files ("ep-*.ycp").
+ */
+{
+ textdomain "storage";
+
+ include "partitioning/ep-tmpfs-dialogs.ycp";
+ include "partitioning/ep-tmpfs-lib.ycp";
+
+
+ void EpContextMenuTmpfs(string device)
+ {
+ symbol widget = ContextMenu::Simple([ `item(`id(`delete), _("Delete")) ]);
+
+ switch (widget)
+ {
+ case `delete:
+ EpDeleteTmpfsDevice(device);
+ break;
+ }
+ }
+
+ void HandleTmpfsButtons( any user_data, string device, map event )
+ {
+ y2milestone( "HandleTmpfsButtons device:%1 user_data:%2 event:%3",
+ device, event, user_data );
+ string disk_device = "";
+
+ if (user_data == nil)
+ {
+ map disk = nil;
+ map part = nil;
+
+ map<string, map> target_map = Storage::GetTargetMap();
+ SplitDevice(target_map, device, disk, part);
+ disk_device = (string) disk["device"]:"";
+ }
+ else
+ {
+ disk_device = (string) user_data;
+ }
+
+ switch (Event::IsWidgetActivated(event))
+ {
+ case `delete:
+ EpDeleteTmpfsDevice(device);
+ break;
+
+ case `add:
+ EpAddTmpfsDevice();
+ break;
+ }
+ }
+
+ void CreateTmpfsMainPanel(any user_data)
+ {
+ list<symbol> fields = StorageSettings::FilterTable([ `size, `type,
+ `fs_type, `mount_point ]);
+
+ map<string, map> target_map = Storage::GetTargetMap();
+ term table_header = StorageFields::TableHeader(fields);
+ list<term> table_contents = StorageFields::TableContents(fields, target_map, StorageFields::PredicateTmpfs);
+ UI::ReplaceWidget(`tree_panel,
+ Greasemonkey::Transform(
+ `VBox(
+ `HStretch(),
+ // heading
+ `IconAndHeading(_("Tmpfs Volumes (TMPFS)"), StorageIcons::dm_icon ),
+ `Table(`id(`table), `opt(`keepSorting, `notify, `notifyContextMenu),
+ table_header, table_contents),
+ ArrangeButtons([ // push button text
+ `PushButton(`id(`add),`opt(`key_F3), _("Add...")),
+ // push button text
+ `PushButton(`id(`delete),`opt(`key_F5), _("Delete...")),
+ `HStretch() ])
+ )
+ ));
+
+ // helptext
+ string helptext = _("<p>This view shows all TMPFS volumes.</p>");
+
+ Wizard::RestoreHelp(helptext + StorageFields::TableHelptext(fields));
+ }
+
+ void HandleTmpfsMainPanel(any user_data, map event)
+ {
+ string device = (string) UI::QueryWidget(`id(`table), `CurrentItem);
+ HandleTmpfsButtons( user_data, device, event );
+ switch (Event::IsWidgetContextMenuActivated(event))
+ {
+ case `table:
+ EpContextMenuDevice(device);
+ break;
+ }
+ UI::SetFocus(`id(`table));
+ }
+
+
+ void CreateTmpfsOverviewTab(any user_data)
+ {
+ string device = (string) user_data;
+ y2milestone( "CreateTmpfsOverviewTab user_data:%1", user_data );
+
+ map<string, map> target_map = Storage::GetTargetMap();
+
+ list<symbol> fields = StorageSettings::FilterOverview([ `heading_device, `device, `size, `used_by,
+ `heading_filesystem, `fs_type, `mount_point,
+ `mount_by ]);
+
+ UI::ReplaceWidget(`tab_panel,
+ Greasemonkey::Transform(
+ `VBox(
+ StorageFields::Overview(fields, target_map, device),
+ `HBox(
+ // push button text
+ `PushButton(`id(`delete), _("Delete...")),
+ `HStretch()
+ )
+ )
+ )
+ );
+
+ // helptext
+ string helptext = _("<p>This view shows detailed information about the
+selected TMPFS volume.</p>");
+
+ Wizard::RestoreHelp(helptext + StorageFields::OverviewHelptext(fields));
+ }
+
+
+ void HandleTmpfsOverviewTab(any user_data, map event)
+ {
+ string device = (string) user_data;
+ y2milestone( "HandleTmpfsOverviewTab user_data:%1", user_data );
+
+ switch (Event::IsWidgetActivated(event))
+ {
+ case `add:
+ EpAddTmpfsDevice();
+ break;
+ case `delete:
+ EpDeleteTmpfsDevice(device);
+ break;
+ }
+ }
+
+
+ void CreateTmpfsPanel(any user_data)
+ {
+ string device = (string) user_data;
+ y2milestone( "CreateTmpfsPanel user_data:%1 device:%2", user_data, device );
+
+ map<symbol, map> data = $[ `overview : $[ `create : CreateTmpfsOverviewTab, `handle : HandleTmpfsOverviewTab, `user_data : user_data ]
+ ];
+
+ UI::ReplaceWidget(`tree_panel,
+ Greasemonkey::Transform(
+ `VBox(
+ // heading
+ `IconAndHeading(sformat(_("Tmpfs mounted at %1"), device), StorageIcons::lvm_lv_icon),
+ `DumbTab(`id(`tab), [
+ // push button text
+ `item(`id(`overview), _("&Overview"))
+ ],
+ `ReplacePoint(`id(`tab_panel), TabPanel::empty_panel)
+ )
+ )
+ )
+ );
+
+ TabPanel::Init(data, `overview);
+ }
+
+
+ void HandleTmpfsPanel(any user_data, map event)
+ {
+ TabPanel::Handle(event);
+ }
+}
Modified: branches/SuSE-Code-11-SP2-Branch/storage/storage/src/include/ep-unused.ycp
URL: http://svn.opensuse.org/viewcvs/yast/branches/SuSE-Code-11-SP2-Branch/stora…
==============================================================================
--- branches/SuSE-Code-11-SP2-Branch/storage/storage/src/include/ep-unused.ycp (original)
+++ branches/SuSE-Code-11-SP2-Branch/storage/storage/src/include/ep-unused.ycp Tue May 17 13:39:44 2011
@@ -3,11 +3,15 @@
* Package: yast2-storage
* Summary: Expert Partitioner
* Authors: Arvin Schnell <aschnell(a)suse.de>
+ *
+ * This file must only be included in other Expert Partitioner files ("ep-*.ycp").
*/
{
textdomain "storage";
+
include "partitioning/ep-dialogs.ycp";
+
void CreateUnusedPanel(any user_data)
{
symbol Predicate(map disk, map partition)
@@ -16,8 +20,8 @@
if (partition == nil)
{
- if (disk["partitions"]:[] == [] &&
- disk["used_by_type"]:`UB_NONE == `UB_NONE)
+ if (isempty(disk["partitions"]:[]) &&
+ !Storage::IsUsedBy(disk))
{
return `show;
}
@@ -27,8 +31,8 @@
else
{
if (partition["type"]:`primary != `extended &&
- partition["mount"]:"" == "" &&
- partition["used_by_type"]:`UB_NONE == `UB_NONE)
+ isempty(partition["mount"]:"") &&
+ !Storage::IsUsedBy(partition))
{
return `show;
}
@@ -37,8 +41,8 @@
}
}
- list<symbol> fields = StorageSettings::FilterTable([ `device, `udev_path, `udev_id, `size, `type,
- `fs_type, `label ]);
+ list<symbol> fields = StorageSettings::FilterTable([ `device, `udev_path, `udev_id, `size, `format,
+ `encrypted, `type, `fs_type, `label ]);
map<string, map> target_map = Storage::GetTargetMap();
@@ -49,8 +53,8 @@
Greasemonkey::Transform(
`VBox(
// heading
- `IconAndHeading(_("Unused Devices"), unused_icon),
- `Table(`id(`table), `opt(`keepSorting, `notify),
+ `IconAndHeading(_("Unused Devices"), StorageIcons::unused_icon),
+ `Table(`id(`table), `opt(`keepSorting, `notify, `notifyContextMenu),
table_header, table_contents),
`HBox(
// push button text
@@ -69,9 +73,18 @@
}
- void HandleUnusedPanel(any user_data, symbol widget)
+ void HandleUnusedPanel(any user_data, map event)
{
- switch (widget)
+ string device = (string) UI::QueryWidget(`id(`table), `CurrentItem);
+
+ switch (Event::IsWidgetContextMenuActivated(event))
+ {
+ case `table:
+ EpContextMenuDevice(device);
+ break;
+ }
+
+ switch (Event::IsWidgetActivated(event))
{
case `rescan:
// popup message
Modified: branches/SuSE-Code-11-SP2-Branch/storage/storage/src/include/lvm_lib.ycp
URL: http://svn.opensuse.org/viewcvs/yast/branches/SuSE-Code-11-SP2-Branch/stora…
==============================================================================
--- branches/SuSE-Code-11-SP2-Branch/storage/storage/src/include/lvm_lib.ycp (original)
+++ branches/SuSE-Code-11-SP2-Branch/storage/storage/src/include/lvm_lib.ycp Tue May 17 13:39:44 2011
@@ -16,26 +16,8 @@
*/
{
- import "Integer";
-
-
- include "partitioning/partition_defines.ycp";
-
-
- // TODO: cleanup
- void new_vg_list( list vg_list );
-
-
textdomain "storage";
-define string lvmVg( string vg )
- {
- integer pos = search( vg, "/" );
- if( pos!=nil )
- return( substring( vg, pos+1 ));
- else
- return( vg );
- }
//////////////////////////////////////////////////////////////////////
// get a list of all volume groups in the targetMap
@@ -54,69 +36,4 @@
return( lvm_vg );
};
-//////////////////////////////////////////////////////////////////////
-// pesize to byte
-// in: <number>[kKmM][bB]
-//
-// return "0" if input is invalid
-//
-// pesize is valid 8kB to 512MB in power of 2
-// used by autoyast
-define integer pesize_str_to_byte(string input)
-{
- integer ret = kmgt_str_to_byte(input);
-
- if (!Integer::IsPowerOfTwo(ret))
- ret = 0;
- else if (ret < 8*1024 || ret > 512*1024*1024)
- ret = 0;
- return ret;
-};
-
-
-//////////////////////////////////////////////////////////////////////
-// Let the User create a new Volume group: open dialog ...
-// return: the changed targetMap and lvm_vgs and cancelled
-// used by autoyast
-define map addVolumeGroup( map vg, map<string,map> targetMap, list lvm_vgs )
- ``{
- boolean cancelled = true;
- string current_vg = "";
- integer pesize = 0;
-
-
- // has the user cancelled the dialog?
- if( size(vg)>0 )
- {
- // Now the user has created a new vg: make it the current vg
- current_vg = vg["vgname"]:"error";
- lvm_vgs = add( lvm_vgs, current_vg);
- pesize = vg["pesize"]:0;
-
- // Display current vg:
- if (UI::WidgetExists(`id(`rvg)) && UI::WidgetExists(`id(`vg)))
- {
- new_vg_list( lvm_vgs );
- UI::ChangeWidget( `id(`vg), `Value, current_vg);
- }
- cancelled = !Storage::CreateLvmVg( current_vg, pesize,
- vg["lvm2"]:true );
- }
- else
- {
- cancelled = true;
- }
-
- return( $[ "cancelled" : cancelled, "vg" : current_vg ]);
- };
-
-//////////////////////////////////////////////////////////////////////
-// Remove the specified volume group
-// return: boolean if removal was succesful
-
-define boolean removeVolumeGroup( string current_vg )
- ``{
- return( Storage::DeleteLvmVg( current_vg ));
- };
-
}
Modified: branches/SuSE-Code-11-SP2-Branch/storage/storage/src/include/lvm_lv_lib.ycp
URL: http://svn.opensuse.org/viewcvs/yast/branches/SuSE-Code-11-SP2-Branch/stora…
==============================================================================
--- branches/SuSE-Code-11-SP2-Branch/storage/storage/src/include/lvm_lv_lib.ycp (original)
+++ branches/SuSE-Code-11-SP2-Branch/storage/storage/src/include/lvm_lv_lib.ycp Tue May 17 13:39:44 2011
@@ -30,7 +30,7 @@
textdomain "storage";
import "Storage";
-import "Partitions";
+import "Popup";
include "partitioning/lvm_lib.ycp";
include "partitioning/lvm_pv_lib.ycp";
@@ -63,67 +63,7 @@
}
return( ret );
};
-
-/*
-define boolean editLogicalVolume( map Lv, string current_vg)
- ``{
- y2milestone( "editLogicalVolume Lv:%1", Lv );
- boolean ret = Storage::ChangeVolumeProperties( Lv );
- ret = Storage::ResizeVolume( Lv["device"]:"", "/dev/"+current_vg,
- Lv["size_k"]:0 ) && ret;
- if( Lv["create"]:false )
- {
- if( !Storage::ChangeLvStripeCount( current_vg, Lv["name"]:"",
- Lv["stripes"]:1 ))
- {
- popupText( Lv["stripes"]:1 );
- ret = false;
- }
- else if( Lv["stripes"]:1 > 1 )
- Storage::ChangeLvStripeSize( current_vg, Lv["name"]:"",
- Lv["stripesize"]:64 );
- }
- return( ret );
- };
-*/
-
-
-define boolean removeLogicalVolume( string disk, string device )
- ``{
- return( Storage::DeleteDevice( disk, device ));
- };
-
-
- //////////////////////////////////////////////////////////////////////
- //
- // !!!! input: partition_list: must be aready those lvs that belong to current_vg
- //
- // [ $["fsid":Partitions::fsid_lvm,
- // "fstype":"LVM",
- // "nr":"var",
- // "region":[255, 16],
- // "type":`primary],
- // $[
- // "fsid":131,
- // "fstype":"Linux native",
- // "nr":4, "region":[271, 844],
- // ...
- //
- // out: [ 10344343, 2223333 ] [ used, avail ]
-
-/*
-define list get_lv_size_info( map<string,map> targetMap, string current_vg )
- ``{
- list ret = [];
- integer sum_byte_vg = targetMap["/dev/"+current_vg,"size_k"]:0*1024;
- integer free_byte_vg = targetMap["/dev/"+current_vg,"pe_free"]:0*
- targetMap["/dev/"+current_vg,"cyl_size"]:0;
- ret = [ sum_byte_vg-free_byte_vg, free_byte_vg ];
- y2milestone( "get_lv_size_info vg=%1 ret=%2", current_vg, ret );
- return( ret );
- };
-*/
////////////////////////////////////////////////////////////////////////////////
// Get all existing lv names of a volume group
@@ -135,58 +75,5 @@
return ret;
};
- //////////////////////////////////////////////////////////////////////
- // partition list to widget table
- // in:
- // [ $["fsid":Partitions::fsid_lvm,
- // "fstype":"LVM",
- // "nr":"var",
- // "region":[255, 16],
- // "type":`primary],
- // $[
- // "fsid":131,
- // "fstype":"Linux native",
- // "nr":4, "region":[271, 844],
- // ...
- //
- // out:
- // [
- // `item(`id(1//dev/hda), "/dev/hda1 ", " /var ", "system", " 1G ", " LVM "),
- // `item(`id(2//dev/hda), "/dev/hda2 ", " /usr ", "system", " 2G ", " Linux ")
- // ];
-
-/*
-define list get_lv_widget_table( list<map> possPvList )
- ``{
- list ret = [];
-
- possPvList =
- sort( map x, map y, possPvList,
- ``{
- if( x["maindev"]:"" == y["maindev"]:"" )
- {
- return( x["nr"]:(any)"" < y["nr"]:(any)"" );
- }
- else
- {
- return( x["maindev"]:"" < y["maindev"]:"" );
- }
- });
-
-
- return( maplist( map partition, possPvList,
- ``{
- return(`item( `id(partition["device"]:"--"),
- partition["device"]:"--",
- partition["mount"]:"",
- partition["lvm_name"]:"",
- partition["size_str"]:"--",
- partition["fstype"]:"--"
- ));
- }
- ));
- };
-*/
-
-
+
}
Modified: branches/SuSE-Code-11-SP2-Branch/storage/storage/src/include/lvm_pv_lib.ycp
URL: http://svn.opensuse.org/viewcvs/yast/branches/SuSE-Code-11-SP2-Branch/stora…
==============================================================================
--- branches/SuSE-Code-11-SP2-Branch/storage/storage/src/include/lvm_pv_lib.ycp (original)
+++ branches/SuSE-Code-11-SP2-Branch/storage/storage/src/include/lvm_pv_lib.ycp Tue May 17 13:39:44 2011
@@ -20,7 +20,6 @@
textdomain "storage";
import "Storage";
import "Partitions";
- import "Package";
include "partitioning/lvm_lib.ycp";
include "partitioning/lvm_lv_lib.ycp";
@@ -56,111 +55,6 @@
};
-/*
-define boolean removePhysicalVolume( map<string,map> targetMap, string id,
- string current_vg )
- ``{
- map partition = Storage::GetPartition( targetMap, id );
-
- if( partition["fsid"]:0 == Partitions::fsid_lvm &&
- contains( [`primary, `logical], partition["type"]:`none ) )
- {
- Storage::UnchangePartitionId( id );
- }
- boolean ret = Storage::ReduceLvmVg( current_vg, id );
- if( !ret )
- {
- // message popup
- Popup::Error(_("If you remove the selected device from the volume group,
-there will not be enough space for all logical volumes in
-this group. To delete the volume group completely, remove
-its logical volumes first.
-"));
- }
- return( ret );
- };
-*/
-
-//////////////////////////////////////////////////////////////////////
-// belongs the the partition "id" already to a volume group
-//////////////////////////////////////////////////////////////////////
-
-/*
-define boolean isItemPv( map<string,map> tg, string id )
- ``{
- map part = $[];
- if( haskey( tg, id ))
- part = tg[id]:$[];
- else
- part = Storage::GetPartition( tg, id );
- return( part["used_by_type"]:`UB_NONE == `UB_LVM ||
- part["used_by_type"]:`UB_NONE == `UB_EVMS );
- };
-*/
-
-//////////////////////////////////////////////////////////////////////
-// belongs the the partition "id" already to a volume group
-// if YES: popup a proper Message and return(false)
-//////////////////////////////////////////////////////////////////////
-/*
-define boolean CheckItemIsNotPv( map<string,map> tg, string id )
- ``{
- if( !isItemPv(tg,id) )
- {
- //////////////
- return( true );
- //////////////
- }
-
- // error case:
- if( id != nil )
- {
- // message popup
- Popup::Message(sformat(_("The item %1 is already a physical volume.
-To add it to a different volume group,
-remove it from its current volume group
-then add it to the new group.
-"), id ));
- }
- else
- {
- // message popup
- Popup::Message(_("You have to select one device in the table"));
- }
- return( false );
- };
-
- //////////////////////////////////////////////////////////////////////
- // belongs the the partition "id" already to a volume group?
- // if NO: popup a proper Message and return(false)
- //////////////////////////////////////////////////////////////////////
-
-define boolean CheckItemIsPv( map<string,map> tg, string id )
- ``{
- if ( isItemPv(tg,id) )
- {
- //////////////
- return( true );
- //////////////
- }
-
- // error case:
- if ( id != nil )
- {
- // Message popup
- Popup::Message(sformat(_("The item %1 cannot be removed.
-It does not belong to a volume group.
-"), id ));
- }
- else
- {
- //Message popup
- Popup::Message(_("You have to select one device in the table"));
- }
- return( false );
- };
-*/
-
/////////////////////////////////////////////////////////////////
// Get all partitions, we can probably use as physical volumes
// Add needed information: disksize
@@ -189,10 +83,9 @@
// no mountpoint
// id 0x83 or 0x8e or 0xfe
- list types_no = [ `lvm, `evms, `extended ];
+ list types_no = [ `lvm, `extended ];
list fsids = [ Partitions::fsid_lvm, Partitions::fsid_raid,
Partitions::fsid_native ];
- list ubs = [ `UB_NONE, `UB_LVM, `UB_EVMS ];
list allowed_enc_types = [ `none, `luks ];
foreach( string dev, map devmap, targetMap,
@@ -203,7 +96,7 @@
``( size(part["mount"]:"")==0 &&
!contains( types_no, part["type"]:`primary ) &&
contains(allowed_enc_types, part["enc_type"]:`none) &&
- contains( ubs, part["used_by_type"]:`UB_NONE ) &&
+ (!Storage::IsUsedBy(part) || part["used_by_type"]:`UB_NONE==`UB_LVM) &&
(part["type"]:`primary==`sw_raid||
part["type"]:`primary==`dm||
contains( fsids, part["fsid"]:0 ))));
@@ -212,62 +105,28 @@
{
parts = [];
y2milestone( "get_possible_pvs no parts, disk used by %1 %2",
- devmap["used_by_type"]:`UB_NONE, devmap["used_by"]:"" );
+ devmap["used_by_type"]:`UB_NONE, devmap["used_by_device"]:"" );
}
if( size(devmap["partitions"]:[])==0 &&
Storage::IsPartType(devmap["type"]:`CT_UNKNOWN) &&
- contains( ubs, devmap["used_by_type"]:`UB_NONE ))
+ (!Storage::IsUsedBy(devmap) || devmap["used_by_type"]:`UB_NONE==`UB_LVM))
{
map p = $[ "device":dev, "maindev":dev,
"size_k":devmap["size_k"]:0 ];
if( devmap["used_by_type"]:`UB_NONE != `UB_NONE )
{
p["used_by_type"] = devmap["used_by_type"]:`UB_NONE;
- p["used_by"] = devmap["used_by"]:"";
+ p["used_by_device"] = devmap["used_by_device"]:"";
}
parts = [ p ];
}
ret = (list<map>)merge( ret, parts );
});
- ret = maplist( map p, ret,
- ``{
- p["used_by"] = lvmVg( p["used_by"]:"" );
- return( p );
- });
y2milestone( "get_possible_pvs ret %1", ret );
return( ret );
};
-/**
- * Check if the user can delete the partition.
- * -> Existing LVM partition with volume group
- * -> size of volume group to small for all logical partition
- */
-/*
-define boolean check_pv_delete( map<string,map> targetMap, string id,
- string current_vg )
- ``{
- boolean ret = true;
- y2milestone( "check_pv_delete id %1 current_vg: %2", id, current_vg );
- integer num_pvs = size( filter( map p, get_possible_pvs(targetMap),
- ``(p["used_by"]:""==current_vg)));
- y2milestone( "check_pv_delete num_pvs:%1", num_pvs );
- if( num_pvs<=1 )
- {
- // message popup
- Popup::Error(_("You cannot remove the last PV from a volume group.
-Delete the volume group completely instead.
-"));
- y2milestone( "check_pv_delete `nodelete" );
- ret = false;
- }
-
- y2milestone( "check_pv_delete ret:%1", ret );
- return( ret );
- }
-*/
-
boolean check_vgname_dev( string vgname )
{
boolean ret = true;
Modified: branches/SuSE-Code-11-SP2-Branch/storage/storage/src/include/lvm_ui_dialogs.ycp
URL: http://svn.opensuse.org/viewcvs/yast/branches/SuSE-Code-11-SP2-Branch/stora…
==============================================================================
--- branches/SuSE-Code-11-SP2-Branch/storage/storage/src/include/lvm_ui_dialogs.ycp (original)
+++ branches/SuSE-Code-11-SP2-Branch/storage/storage/src/include/lvm_ui_dialogs.ycp Tue May 17 13:39:44 2011
@@ -21,408 +21,14 @@
textdomain "storage";
-import "Mode";
-import "Partitions";
-import "FileSystems";
-import "Storage";
-import "Label";
+import "Storage";
import "Popup";
include "partitioning/custom_part_dialogs.ycp";
include "partitioning/custom_part_lib.ycp";
include "partitioning/lvm_lv_lib.ycp";
-/*
-define void handle_max( integer stripe, string max_text )
- ``{
- y2milestone( "stripe %1", stripe );
- UI::ChangeWidget(`id("max_size"), `Enabled, stripe==1 );
- UI::ChangeWidget(`id("max_text"), `Value, stripe==1?max_text:"" );
- }
-*/
-
-/*
-define map DlgCreateEditLogicaVolume( symbol create_or_edit, map<string,any> Lv,
- integer max_size, string vgname,
- list lvs, map<symbol,map> file_systems,
- string dev, integer pesize )
-
- ``{
- y2milestone( "DlgCreateEditLogicaVolume %4 dev=%1 pesize=%2 max_size=%3",
- dev, pesize, max_size, create_or_edit );
- y2milestone( "DlgCreateEditLogicaVolume lvs %1", lvs );
-
- integer new_size = Lv["size_k"]:0 * 1024;
- integer old_size = new_size;
- string curr_size = ByteToHumanStringWithZero(new_size);
- old_size = kmgt_str_to_byte(curr_size);
- string volume_name = Lv["name"]:"";
- integer stripes = Lv["stripes"]:1;
- integer stripesize = Lv["stripesize"]:64;
-
- list stripes_poss = [
- `item(`id(1), "1", stripes == 1 ),
- `item(`id(2), "2", stripes == 2 ),
- `item(`id(3), "3", stripes == 3 ),
- `item(`id(4), "4", stripes == 4 ),
- `item(`id(5), "5", stripes == 5 ),
- `item(`id(6), "6", stripes == 6 ),
- `item(`id(7), "7", stripes == 7 ),
- `item(`id(8), "8", stripes == 8 )
- ];
-
- list stripe_size = [
- `item(`id(4), "4", stripesize == 4 ),
- `item(`id(8), "8", stripesize == 8 ),
- `item(`id(16), "16", stripesize == 16 ),
- `item(`id(32), "32", stripesize == 32 ),
- `item(`id(64), "64", stripesize == 64 ),
- `item(`id(128), "128", stripesize == 128 ),
- `item(`id(256), "256", stripesize == 256 ),
- `item(`id(512), "512", stripesize == 512 ),
- ];
-
- string lv_size = "";
-
- string heading = "";
- boolean is_create_mode = false;
- boolean is_resize_mode = false;
- term ui_volume_name = `Dummy();
- any c_ret = `cancel;
-
- // header for input field size of Logical volume
- string size_txt = sformat(_("&Size: (e.g., %1 %2)"),
- ByteToHumanStringWithZero(4196*1024*1024),
- ByteToHumanStringWithZero(210*1024*1024));
- if( create_or_edit != `create )
- {
- max_size = max_size+new_size;
- y2milestone( "new max_size=%1", max_size );
- }
- y2milestone( "new_size %1", new_size );
- // header for input field maximum allowd size
- string max_text = sformat(_("max = %1 "),
- ByteToHumanStringWithZero(max_size));
-
-
- if( create_or_edit == `create )
- {
- // popup heading
- heading = _("Create Logical Volume");
- is_create_mode = true;
- ui_volume_name = `VBox( `TextEntry(`id("volume_name"),
- // label text
- _("Logical volume &name "),
- volume_name),
- // label text
- `Left(`Label(_("(e.g. var, opt)")))
- );
- }
- else if( create_or_edit == `edit )
- {
- // popup heading
- heading = _("Edit Logical Volume");
- is_create_mode = false;
- // display name of current volume group
- // display name of current volume group
- ui_volume_name = `VBox( `Label(""),
- // label text
- `HBox(`Label( _("Logical volume name: ")),
- `Heading(`opt(`outputField), volume_name ),
- `HStretch()
- ));
- }
- else if( create_or_edit == `resize )
- {
- // popup heading
- heading = _("Edit Logical Volume");
- is_create_mode = false;
- is_resize_mode = true;
- // display name of current volume group
- ui_volume_name = `VBox( `Label(""),
- // label text
- `HBox(`Label( _("Logical volume name: ")),
- `Heading(`opt(`outputField), volume_name ),
- `HStretch()
- )
- );
- }
- else
- {
- // internal error message
- heading = _("INTERNAL ERROR");
- }
-
- y2milestone( "is_create_mode %1 is_resize_mode %2", is_create_mode,
- is_resize_mode );
-
- UI::OpenDialog(
- `opt(`decorated ),
- `HBox(`HWeight(30,
- `HBox(
- `HSpacing(1),
- `HStretch(),
- `VBox(
- `Heading(heading),
- `VStretch(),
- `VSpacing(1),
- `HBox(
- FormatDlg( Lv, file_systems ),
- `HStretch(),
- `HSpacing(2),
- `VBox(
- `Top(`Left(ui_volume_name)),
- `Top(`VBox( `TextEntry(`id("size"), size_txt, curr_size),
- `HBox(
- // set size to maxsize
- `Left(`Label( `id("max_text"), max_text )),
- // button text
- `PushButton( `id("max_size"), _("ma&x")))
-
- )),
- `VStretch(),
- `Left(`ComboBox( `id("stripes"), `opt(`hstretch,`notify),
- // button text
- _("Stri&pes"), stripes_poss )),
- `VStretch(),
- `Left(`ComboBox( `id("stripesize"), `opt(`hstretch,`notify),
- // button text
- _("Stripe &Size"), stripe_size )),
- `VStretch(),
- `VSpacing(1),
- `ReplacePoint( `id(`mount_dlg_rp),
- MountDlg(Lv, []))
- )
- ),
- `VStretch(),
- `VSpacing(1),
- `HBox(
- // Ok button
- `PushButton(`id(`ok), `opt(`default), Label::OKButton() ),
- // Cancel button
- `PushButton(`id(`cancel), Label::CancelButton() )
- )
- ),
- `HStretch(),
- `HSpacing(1)
- )
- )));
-
-
- // configure main dialog for the first call
-
- if( is_create_mode )
- {
- UI::ChangeWidget( `id("volume_name"), `ValidChars,
- FileSystems::nchars + "-._:" );
- }
- UI::ChangeWidget( `id("stripes"), `Enabled, !is_resize_mode );
- UI::ChangeWidget( `id("stripesize"), `Enabled,
- !is_resize_mode && stripes>1 );
- handle_max( stripes, max_text );
-
- ////////////////////////////////////////////////////////////////////
- // User mainloop for dialog
- ////////////////////////////////////////////////////////////////////
-
- boolean input_is_ok = true;
- map<string,any> retval = eval(Lv);
-
- retval = HandlePartWidgetChanges( true, `ok, file_systems, Lv, retval );
-
- repeat
- {
- input_is_ok = true;
-
- c_ret = UI::UserInput();
-
- /////////////////////////////////////////////////////////
- if( c_ret == "stripes")
- {
- stripes = (integer)UI::QueryWidget(`id("stripes"), `Value);
- UI::ChangeWidget( `id("stripesize"), `Enabled,
- !is_resize_mode && stripes>1 );
- handle_max( stripes, max_text );
- c_ret = `again;
- continue;
- }
-
- /////////////////////////////////////////////////////////
- // stripes
- if( c_ret == "max_size")
- {
- UI::ChangeWidget(`id("size"), `Value, ByteToHumanStringWithZero(max_size));
- c_ret = `again;
- continue;
- }
-
- if( c_ret != `cancel )
- {
- retval = HandlePartWidgetChanges( false, c_ret, file_systems,
- Lv, retval );
- }
-
- if( is_create_mode )
- {
- volume_name = (string)UI::QueryWidget( `id("volume_name"),
- `Value );
- volume_name = deletechars( volume_name, " \t" );
- }
-
- stripes = (integer)UI::QueryWidget(`id("stripes"), `Value);
- stripesize = (integer)UI::QueryWidget(`id("stripesize"), `Value);
- lv_size = (string)UI::QueryWidget(`id("size"), `Value);
-
- y2debug("STRI ---- i%1i", stripes);
- if( c_ret==`ok )
- {
- new_size = kmgt_str_to_byte(lv_size);
-
- if( !check_max_size(new_size, max_size) )
- {
- input_is_ok = false;
- c_ret = `again;
- continue;
- }
- y2milestone( "new_size %1 old_size %2", new_size, old_size );
-
- if( !check_ok_fssize(new_size, retval) )
- {
- input_is_ok = false;
- c_ret = `again;
- continue;
- }
-
- if( is_resize_mode && !retval["format"]:false &&
- new_size!=old_size )
- {
- string mp = retval["inactive"]:false ? "" : retval["mount"]:"";
- if( !CheckResizePossible( true, true, new_size-old_size,
- retval["used_fs"]:`unknown, mp ))
- {
- UI::ChangeWidget(`id("size"), `Value, curr_size );
- c_ret = `again;
- continue;
- }
- }
-
- if( is_create_mode )
- {
- if( !icheck_volume_name(volume_name) )
- {
- input_is_ok = false;
- // error popup text
- // xgettext:no-c-format
- Popup::Error(_("Check your volume name.
-Use names like \"opt\" or \"var\" ...
-Do not use ;/\`',!\"%#"));
- UI::SetFocus(`id("volume_name"));
- c_ret = `again;
- continue;
- }
- else
- {
- if( contains( lvs, volume_name ) )
- {
- input_is_ok = false;
- // error popup text
- Popup::Error(sformat(_("A logical volume named \"%1\" already exists
-in volume group \"%2\". Choose another name
-or cancel this dialog.
-"), volume_name, vgname ));
- UI::SetFocus(`id("volume_name"));
- c_ret = `again;
- continue;
- }
- }
- }
-
- map ret_mp = CheckOkMount( dev, Lv, retval );
- retval = ret_mp["map"]:$[];
- if( !ret_mp["ok"]:false )
- {
- if( ret_mp["field"]:`none != `none )
- UI::SetFocus(`id( ret_mp["field"]:`none ));
- input_is_ok = false;
- c_ret = `again;
- continue;
- }
-
- retval["device"] = "/dev/"+vgname+"/"+volume_name;
- ret_mp = CheckDeviceFinalOk( retval );
- if( !ret_mp["ok"]:false )
- input_is_ok = false;
- else
- retval = ret_mp["map"]:$[];
- }
-
- /////////////////////////////////////////////////////////
- retval["stripes"] = stripes;
- if( stripes>1 )
- {
- retval["stripesize"] = stripesize;
- }
- retval["name"] = volume_name;
- if( new_size!=old_size )
- {
- retval["size_k"] = (new_size+1023)/1024;
- }
- } until ( (c_ret==`ok&&input_is_ok) || c_ret == `cancel );
-
- UI::CloseDialog();
-
- y2milestone( "retval=%1", retval );
-
- if( c_ret != `cancel && input_is_ok )
- {
- return( retval );
- }
- else
- {
- return( nil );
- }
- };
-*/
-
-
- //////////////////////////////////////////////////////////////////////////////
- // Dialog "Create a Volume Group
- //////////////////////////////////////////////////////////////////////////////
-/*
-define boolean HandleEditLv( map<string,map> targetMap, string device )
- ``{
- boolean ret = false;
- map disk = Storage::GetDisk( targetMap, device );
- integer pesize = disk["cyl_size"]:(4*1024*1024);
-
- map<symbol,map> fs = FileSystems::GetAllFileSystems(true, true);
- map<string,any> Lv = Storage::GetPartition( targetMap, device );
-
- // if Lv is a lvm partition
- if( size(Lv)>0 && Lv["type"]:`primary==`lvm )
- {
- string tmp_vg = disk["name"]:"";
- list size_list = get_lv_size_info( targetMap, tmp_vg );
- integer max_size = size_list[1]:0;
- symbol what = (Lv["create"]:false)?`edit:`resize;
- map createLv = DlgCreateEditLogicaVolume( what, Lv, max_size, tmp_vg,
- [], fs, device, pesize );
- // has an error occured
- if( size(createLv)>0 )
- {
- ret = editLogicalVolume( createLv, tmp_vg );
- }
- }
- else
- {
- // Popup text
- Popup::Error(_("You can only edit logical volumes."));
- }
- y2milestone( "ret %1", ret );
- return( ret );
- }
-*/
define boolean HandleRemoveLv( map<string,map> targetMap, string id )
``{
@@ -441,7 +47,7 @@
if( Popup::YesNo( message ))
{
- ret = removeLogicalVolume( disk["device"]:"", id );
+ ret = Storage::DeleteDevice(id);
}
}
y2milestone( "HandleRemoveLv ret:%1", ret );
@@ -449,135 +55,4 @@
}
-define boolean HandleRemoveVg( map<string,map> targetMap, string current_vg )
- ``{
- boolean ret = false;
- integer count = size(get_lv_names(targetMap, current_vg));
- if( count > 0 )
- {
- // Message popup
- Popup::Message(sformat(
-_("The volume group \"%1\" contains at least one logical
-volume. It cannot be removed. Remove all logical volumes then
-remove the volume group.
-"), current_vg));
- }
- else
- {
- // popup text
- if( Popup::ContinueCancel( sformat( _("Really remove the volume group \"%1\"?"), current_vg)))
- {
- ret = removeVolumeGroup( current_vg );
- }
- }
- return( ret );
- }
-
-/*
-define map DlgCreateVolumeGroup( list vgm_list )
- ``{
- string vgname = "";
- string pesize = "";
-
- UI::OpenDialog(
- `opt(`decorated ),
- `HBox(
- `HSpacing(2),
- `VBox(
- // popup header
- `Heading(_("Create a Volume Group")),
- // popup description
- `Label( _("Now we have to create a volume group.
-Typically you don't have to change anything,
-but if you are an expert, feel free to change
-our defaults:")),
- // label text
- `TextEntry( `id("vgname"), _("Volume Group &Name:"),
- size(vgm_list)==0?"system":""),
- // label text
- `TextEntry(`id("pesize"), _("&Physical Extent Size"), "4M"),
- `VSpacing(1),
- `HBox(
- // Ok button
- `PushButton(`id(`ok), `opt(`default),
- Label::OKButton() ),
- // Cancel button
- `PushButton(`id(`cancel), Label::CancelButton() )
- ),
- `VSpacing(0.5)
- ),
- `HSpacing(2)
- )
- );
-
- any ret = nil;
- boolean input_is_ok = false;
-
- repeat
- {
- ret = UI::UserInput();
-
- vgname = (string)UI::QueryWidget(`id("vgname"), `Value);
- vgname = deletechars( vgname, " \t" );
- pesize = (string)UI::QueryWidget(`id("pesize"), `Value);
-
- if( ret != `cancel )
- {
- input_is_ok = true;
-
- if( !icheck_pesize(pesize) )
- {
- // error popup text
- Popup::Error(_("The data entered is invalid.
-Insert a physical extent size from
-8KB to 512MB in powers of 2, for example, \"4M\" or \"512K\"
-"));
- input_is_ok = false;
- }
-
- if( !icheck_vgname(vgname) )
- {
- // error popup text
- Popup::Error(_("The data entered is invalid.
-Insert a group name like \"system\" or \"test\".
-Do not use ;/`, in your group name.
-"));
- input_is_ok = false;
- }
-
- if( contains( vgm_list, vgname ) )
- {
- // error popup text
- Popup::Error(sformat(_("The volume group \"%1\" already exists.
-Choose a different name
-or cancel this dialog.
-"), vgname ));
- input_is_ok = false;
- }
- if( !check_vgname_dev( vgname ) )
- {
- // error popup text
- Popup::Error(sformat(_("The volume group name \"%1\" conflicts
-with another entry in the /dev directory.\n"), vgname ));
- input_is_ok = false;
- }
- }
-
- } until( input_is_ok || ret == `cancel );
-
- UI::CloseDialog();
-
- if (ret == `ok )
- {
- map ret = $[ "vgname" : vgname, "pesize" : pesize_str_to_byte (pesize) ];
- ret["lvm2"] = true;
- return( ret );
- }
- else
- {
- return( $[] );
- }
- };
-*/
-
}
Modified: branches/SuSE-Code-11-SP2-Branch/storage/storage/src/include/partition_defines.ycp
URL: http://svn.opensuse.org/viewcvs/yast/branches/SuSE-Code-11-SP2-Branch/stora…
==============================================================================
--- branches/SuSE-Code-11-SP2-Branch/storage/storage/src/include/partition_defines.ycp (original)
+++ branches/SuSE-Code-11-SP2-Branch/storage/storage/src/include/partition_defines.ycp Tue May 17 13:39:44 2011
@@ -17,105 +17,12 @@
*/
{
- import "Arch";
- import "Installation";
- import "Wizard";
- import "Storage";
import "Mode";
- import "Stage";
- import "Partitions";
import "FileSystems";
- import "Report";
- import "String";
- import "Popup";
-
textdomain "storage";
-//////////////////////////////////////////////////////////////////////
-// size str to byte
-// in: <number>[kKmM][bB]
-//
-// return "0" if input is invalid
-//
-// 8 is 8k
-// 16K == 16k == 16KB == 16kb
-// TODO: remove
-define integer kmgt_str_to_byte( string input )
-{
- integer number = 0;
- integer pos = findfirstnotof( input, " +" );
-
- if( pos != nil && pos>0 )
- {
- input = substring( input, pos );
- }
-
- if( size(filterchars(input, "0123456789kKmMgGtTbBoO .")) != size(input))
- {
- return(0);
- }
-
- input = filterchars(input, "0123456789kKmMgGtTbBoO.");
-
- if( size(input)>0 && findfirstnotof( input, "0123456789.") != nil )
- {
- // check whether the last char is in "kKmM" or "bB"
- string last_char = substring( input, size(input)-1, 1);
-
- if( last_char == "b" || last_char == "B" ||
- last_char == "o" || last_char == "O" )
- {
- input = substring( input, 0, size(input)-1);
- // check whether the last char is in "kKmM"
- last_char = substring( input, size(input)-1, 1);
- }
-
- string number_str = substring(input, 0, size(input)-1);
-
- if( findfirstnotof( number_str, "0123456789.") == nil )
- {
- if( last_char == "k" || last_char == "K" )
- {
- number = tointeger(tofloat( number_str ) * 1024.0) ;
- }
- else if ( last_char == "m" || last_char == "M" )
- {
- number = tointeger(tofloat( number_str ) * 1024.0 * 1024.0);
- }
- else if ( last_char == "g" || last_char == "G" )
- {
- number = tointeger(tofloat( number_str ) *
- 1024.0 * 1024.0 * 1024.0);
- }
- else if ( last_char == "t" || last_char == "T" )
- {
- number = tointeger(tofloat( number_str ) *
- 1024.0 * 1024.0 * 1024.0 * 1024.0);
- }
- else
- {
- number = 0;
- }
- }
- else
- {
- number = 0;
- }
- }
- else if( size(input)==0 )
- {
- number = 0;
- }
- else
- {
- number = tointeger( input );
- }
- return( number );
- };
-
-
/*---------------------------------------------------------------------
* get a list of not used mountpoints
*------------------------------------
Modified: branches/SuSE-Code-11-SP2-Branch/storage/storage/src/include/raid_lib.ycp
URL: http://svn.opensuse.org/viewcvs/yast/branches/SuSE-Code-11-SP2-Branch/stora…
==============================================================================
--- branches/SuSE-Code-11-SP2-Branch/storage/storage/src/include/raid_lib.ycp (original)
+++ branches/SuSE-Code-11-SP2-Branch/storage/storage/src/include/raid_lib.ycp Tue May 17 13:39:44 2011
@@ -13,7 +13,6 @@
* $Id$
*/
{
- import "Storage";
import "Partitions";
textdomain "storage";
@@ -55,10 +54,9 @@
list<map> allret = [];
list<symbol> allowed_ctypes = [ `CT_DISK, `CT_DMRAID, `CT_DMMULTIPATH ];
- list types_no = [ `lvm, `sw_raid, `evms ];
+ list types_no = [ `lvm, `sw_raid ];
list fsids = [ Partitions::fsid_lvm, Partitions::fsid_raid,
Partitions::fsid_native ];
- list ubs = [ `UB_NONE, `UB_MD ];
list allowed_enc_types = [ `none ];
foreach (string dev, map devmap, targetMap, {
@@ -68,7 +66,7 @@
``( size(p["mount"]:"")==0 &&
!contains( types_no, p["type"]:`primary ) &&
contains(allowed_enc_types, p["enc_type"]:`none) &&
- contains( ubs, p["used_by_type"]:`UB_NONE ) &&
+ (!Storage::IsUsedBy(p) || p["used_by_type"]:`UB_NONE==`UB_MD) &&
(!haskey(p,"fsid")||contains( fsids, p["fsid"]:0 ))));
allret = (list<map>)merge(allret, ret );
}
Modified: branches/SuSE-Code-11-SP2-Branch/storage/storage/src/inst_custom_part.ycp
URL: http://svn.opensuse.org/viewcvs/yast/branches/SuSE-Code-11-SP2-Branch/stora…
==============================================================================
--- branches/SuSE-Code-11-SP2-Branch/storage/storage/src/inst_custom_part.ycp (original)
+++ branches/SuSE-Code-11-SP2-Branch/storage/storage/src/inst_custom_part.ycp Tue May 17 13:39:44 2011
@@ -13,526 +13,4 @@
return ExpertPartitioner();
-
-
-
-
- /**
- * Dialog: "Resize a partition Dialog"
- * @parm cur_val map that contains a partition
- * @parm device device name of the resized partition
- * @parm cyl_size size of a cylinder on the disk
- * @return map modified partition or nil by cancel
- */
-define map ResizePartDlg( map cur_val, string device, map disk, map possible )
- ``{
- integer cyl_size = disk["cyl_size"]:0;
- boolean test_simple_ui = false;
- boolean win = Partitions::IsDosWinNtPartition( cur_val["fsid"]:0 );
- boolean swap = !win && cur_val["fsid"]:0==Partitions::fsid_swap;
- boolean simple_ui = false;
- integer cyl_after = 0;
- if( possible["extend"]:false )
- {
- // cyl_after = Storage::FreeCylAfter( disk, cur_val );
- }
- integer av_space = cyl_after*cyl_size;
-
- y2milestone( "ResizePartDlg dev:%1 cyl:%2 map:%3 win:%4 swap:%5",
- device, cyl_size, cur_val, win, swap );
- y2milestone( "ResizePartDlg cyl_after:%1 av_space:%2",
- cyl_after, av_space );
-
- integer min_free = 0;
- integer new_size = 0;
- integer shrink_size = 0;
- integer new_min = 0;
-
- map df = $[];
-
- if( !swap && !cur_val["format"]:false )
- {
- df = Storage::GetFreeSpace( device, 0, cur_val["used_fs"]:`none, true );
- if( size(df)==0 || !df["ok"]:false )
- {
- y2error( "failed GetFreeSpace %1 fs:%2", device,
- cur_val["used_fs"]:`none );
- string tmp = sformat(
-_("Partition %1 cannot be resized
-because the file system seems to be inconsistent.
-"), device );
- Popup::Error( tmp );
- return( nil );
- }
- }
- else
- {
- df["used"] = 0;
- if( haskey( cur_val, "orig_size_k" ) && cur_val["resize"]:false )
- {
- df["df_free"] = cur_val["orig_size_k"]:0 * 1024;
- }
- else
- {
- df["df_free"] = cur_val["region",1]:0 * cyl_size;
- }
- df["free"] = df["df_free"]:0;
- }
-
- // label text
- string unit = _("MB");
- integer factor = 1024*1024;
-
- if( df["df_free"]:0 > 15*1024*factor )
- {
- factor = factor * 1024;
- unit = _("GB");
- }
- y2milestone( "ResizePartDlg factor:%1", factor );
-
- if( haskey( cur_val, "win_max_length" ) && cur_val["resize"]:false )
- {
- new_min = cur_val["orig_size_k"]:0*1024/cyl_size - cur_val["win_max_length"]:0;
- new_min = new_min*cyl_size / factor;
- }
-
- y2milestone( "ResizePartDlg min_lin:%1 df:%2", new_min, df );
-
- integer used = df["used"]:0 / factor;
- integer free = df["df_free"]:0 / factor;
- integer not_shrink_free = 0;
-
- // Labels for bar graph. "%1" will be replace with a numeric value.
- string bargraph_label_used = "";
- string bargraph_label_free = "";
- string bargraph_label_new = "";
- if( win )
- {
- // label text %1 is replaced by a number
- bargraph_label_used = _("Windows\nUsed\n%1 ") + unit;
- // label text %1 is replaced by a number
- bargraph_label_free = _("Windows\nFree\n%1 ") + unit;
- // label text %1 is replaced by a number
- bargraph_label_new = _("Linux\nSize\n%1 ") + unit;
- }
- else
- {
- // label text %1 is replaced by a number
- bargraph_label_used = _("Space\nUsed\n%1 ") + unit;
- if( swap )
- {
- // label text %1 is replaced by a number
- bargraph_label_free = _("Swap\nSpace\n%1 ") + unit;
- }
- else
- {
- // label text %1 is replaced by a number
- bargraph_label_free = _("Space\nFree\n%1 ") + unit;
- }
- // label text, %1 is replaced by a number
- bargraph_label_new = _("Unused\nDisk\n%1 ") + unit;
- }
-
- // Labels for input fields. "%1" will be replaced with the current unit (MB)
- string field_label_free = "";
- string field_label_new = "";
- if( win )
- {
- // label text, %1 is replaced by a unit value ("MB")
- field_label_free = sformat( _("Windows Free (%1)"), unit);
- // label text, %1 is replaced by a unit value ("MB")
- field_label_new = sformat( _("Linux Size (%1)"), unit);
- }
- else
- {
- // label text, %1 is replaced by a unit value ("MB")
- field_label_new = sformat( _("Unused Disk (%1)"), unit);
- if( swap )
- {
- // label text, %1 is replaced by a unit value ("MB")
- field_label_free = sformat( _("Swap Space (%1) "), unit);
- }
- else
- {
- // label text, %1 is replaced by a unit value ("MB")
- field_label_free = sformat( _("Space Free (%1)"), unit);
- }
- }
-
- if( win )
- {
- min_free = (factor==1024*1024)?200:1;
- if( df["df_free"]:0 != df["free"]:0 )
- {
- not_shrink_free = df["df_free"]:0 - df["free"]:0;
- not_shrink_free = (not_shrink_free + factor - 1) / factor;
- if( not_shrink_free > min_free )
- {
- min_free = not_shrink_free;
- }
- }
- }
- else
- {
- min_free = (factor==1024*1024)?5:1;
- }
-
- if( cur_val["used_fs"]:`none == `ntfs &&
- not_shrink_free > df["free"]:0/factor/5 )
- {
- //Message text. %1 and %2 are numbers. %3 is the unit.
- string ptext = sformat( _("Your NTFS file system has %1 %3 free space available. Due to limitations in
-the NTFS resizer, the file system can only be shrunk by up to %2 %3.
-To be able to shrink the file system more, boot your Windows
-system and run a disk defragmentation program under Windows to move
-the used blocks of the file system towards the start of the partition.
-"),
- free, df["free"]:0/factor, unit );
- Popup::Message( ptext );
- }
- if( haskey( cur_val, "orig_size_k" ) && cur_val["resize"]:false )
- {
- shrink_size = (df["used"]:0+df["df_free"]:0)/factor -
- cur_val["region",1]:0*cyl_size/factor;
- y2milestone( "ResizePartDlg new_size_k:%1 shrink_size:%2",
- cur_val["region,1"]:0*cyl_size/factor, shrink_size );
- if( shrink_size>df["free"]:0/factor )
- {
- shrink_size = df["free"]:0/factor;
- }
- y2milestone( "ResizePartDlg shrink_size:%1", shrink_size );
- }
- av_space = av_space/factor;
-
- y2milestone( "ResizePartDlg min_free:%1 free:%2 used:%3 shrink_size:%4 unit:%5",
- min_free, free, used, shrink_size, unit );
-
- string windows = "";
- if( win )
- {
- // label text
- windows = _("Windows");
- }
-
- // Help text for partition resizing -
- // common part for both graphical mode (with bar graphs)
- // and non-graphical mode (text only).
- // %1 is OS label, such as Windows
- string helptext = sformat( _("<p>
-Choose the new size for your %1 partition.
-</p>"), windows );
-
- // help text (common to both modes), continued
- // %1 is OS label, such as Windows
- helptext = helptext + sformat( _("
-<p>
-The actual resizing is performed only after you confirm all your
-settings in the last installation dialog. Until then, your %1
-partition will remain untouched.
-</p>"), windows );
-
- // help text (common to both modes), continued
- helptext = helptext + _("
-<p>
-If you decide not to resize your partition, press
-<b>Do Not Resize</b>. This resets the values to the original
-size of the partition.
-</p>
-");
-
- if( UI::HasSpecialWidget(`Slider ) &&
- UI::HasSpecialWidget(`BarGraph ) && !test_simple_ui )
- {
- // help text, continued - graphical mode only
- // this text will be appended to the help text common to both modes.
- helptext = helptext + _("
-<p>
-The upper bar graph displays the current situation.
-The lower bar graph displays the situation after the installation (after
-the partition resize).
-</p>");
- // help text (graphical mode), continued
- helptext = helptext + _("
-<p>
-Drag the slider or enter a numeric value in either
-input field to adjust the suggested value.
-</p>");
-
- ////////////////////////////////////////////////////////////////////////////////////////////
- // Open main dialog for resizing of partitions
- ////////////////////////////////////////////////////////////////////////////////////////////
- term graph = nil;
- if( win || cyl_after==0 )
- {
- graph = `BarGraph( [ used, free ],
- [ bargraph_label_used, bargraph_label_free ] );
- }
- else
- {
- graph = `BarGraph( [ used, free, av_space ],
- [ bargraph_label_used, bargraph_label_free,
- bargraph_label_new ] );
- }
- y2milestone( "ResizePartDlg graph=%1", graph );
-
- UI::OpenDialog( `opt(`decorated ),
- `HBox(
- `HWeight(30, `RichText( helptext )),
- `HStretch(),
- `HSpacing(1),
- `HWeight(70,`VBox(
- `HSpacing(50),
- `VStretch(),
- `VSpacing(1),
- // Headline above bar graph that displays current partition size
- `Left( `Label( _("Now")) ),
- graph,
- `VSpacing(1),
- `VStretch(),
- // Headline above bar graph that displays future partitions
- `Left( `Label( _("After Installation") ) ),
- `PartitionSplitter( `id(`linux_size),
- used, free+av_space,
- shrink_size+av_space, new_min, min_free,
- bargraph_label_used,
- bargraph_label_free,
- bargraph_label_new,
- field_label_free,
- field_label_new ),
- // Button text
- `HBox( `PushButton(`id(`rem_resize), _("&Do Not Resize") )),
- `VSpacing(1),
- `HBox(
- `PushButton(`id(`ok), `opt(`default), Label::OKButton() ),
- `PushButton(`id(`cancel), Label::CancelButton() ))
- ))));
- }
- else
- {
- simple_ui = true;
- // help text, continued - non-graphical mode only
- // this help text will be appended to the help text common to both modes.
- //%1 is OS label, such as Windows
- helptext = helptext + sformat( _("
-<p>Enter a value for the size to which to shrink the %1 partition.
-</p>"), windows );
-
- string used_label = "";
- if( win )
- {
- // Label text
- used_label = _("Windows Used");
- }
- else
- {
- // Label text
- used_label = _("Used");
- }
- // help text (non-graphical mode), continued
- //%1 is label text, such as Used. %2 is OS, such as Windows.
- helptext = helptext + sformat(_("
-<p>
-<b>%1<b> is the size of the used part of your %2 partition.
-</p>"), used_label, windows );
-
- // help text (non-graphical mode), continued
- helptext = helptext + _("
-<p><b>Free</b> indicates the current free space (before shrinking)
-of the partition.
-</p>");
-
- UI::OpenDialog( `opt(`decorated ),
- `HBox(
- `HWeight(30, `RichText( helptext )),
- `HStretch(),
- `HSpacing(1),
- `HWeight(70,
- `VBox(
- `HBox(
- // Label for used part of the partition in non-graphical mode
- `HWeight(3, `Right(`Label(used_label))),
- `HWeight(2, `Label(`opt(`outputField), sformat("%1", used ))),
- `HWeight(3, `Left(`Label( unit )))),
- `VSpacing(0.5),
- `HBox(
- // Label for free part of the partition in non-graphical mode
- `HWeight(3, `Right(`Label(_("Free")))),
- `HWeight(2, `Label(`opt(`outputField), sformat("%1", free ))),
- `HWeight(3, `Left(`Label( unit )))),
- `VSpacing(0.5),
- `HBox(
- // Edit field label for linux partition size in non-graphical mode
- `HWeight(3, `Right(`Bottom(`Label(_("New Size"))))),
- `HWeight(2, `IntField( `id(`linux_size), "",
- used+min_free, used+free+av_space,
- used+free-shrink_size)),
- `HWeight(3, `Left(`Bottom(`Label( unit ))))),
- // Button text
- `HBox( `PushButton( `id(`rem_resize),
- _("&Do Not Resize") )),
- `VSpacing(1),
- `HBox(
- `PushButton( `id(`ok), `opt(`default),
- Label::OKButton() ),
- `PushButton( `id(`cancel),
- Label::CancelButton() ))
- ))));
- }
-
- map retval = cur_val;
- any ret = `ok;
-
- repeat
- {
- /////////////////////////////////////////////////////////////
- // Check the User input
- ret = UI::UserInput();
-
- y2milestone( "ResizePartDlg ret=%1", ret );
-
- if( ret == `rem_resize )
- {
- if( simple_ui )
- UI::ChangeWidget( `id(`linux_size), `Value, used+free );
- else
- UI::ChangeWidget( `id(`linux_size), `Value, av_space );
- }
-
- if( ret == `ok )
- {
- // Get the value the user adjusted. If s/he entered a value
- // too big or too small this is automatically adjusted to the
- // biggest/smallest value possible (by Qt).
- shrink_size = (integer)UI::QueryWidget(`id(`linux_size), `Value);
- y2milestone( "ResizePartDlg shrink_size %1", shrink_size );
- if( simple_ui )
- {
- new_size = shrink_size;
- }
- else
- {
- new_size = used + free + av_space - shrink_size;
- }
- y2milestone( "ResizePartDlg Value:%1 New size:%2", shrink_size, new_size);
- }
- if( ret == `ok )
- {
- if( (!simple_ui && shrink_size != av_space) ||
- (simple_ui && shrink_size != used+free) )
- {
- retval["resize"] = true;
- list new_reg = [ retval["region",0]:0,
- PartedSizeToCly( (tofloat(new_size*factor)), cyl_size ) ];
- retval["region"] = new_reg;
- }
- else
- {
- retval["resize"] = false;
- }
- }
- if( ret == `ok && !cur_val["format"]:false && retval["resize"]:false )
- {
- integer diff = 0;
- if( haskey( retval, "orig_size_k" ))
- diff = retval["region",1]:0 - retval["orig_size_k"]:0*1024/cyl_size;
- else
- diff = retval["region",1]:0 - cur_val["region",1]:0;
- string mp = cur_val["inactive"]:false ? "" : cur_val["mount"]:"";
- y2milestone( "ResizePartDlg diff %1 mp %2", diff, mp );
- if( !CheckResizePossible( false, false, diff,
- cur_val["used_fs"]:`unknown, mp ))
- {
- ret = `again;
- }
- }
- y2milestone("ResizePartDlg ret = %1", retval );
- }
- until( ret == `ok || ret == `cancel );
-
- UI::CloseDialog();
-
- if( ret == `cancel )
- {
- return( nil );
- }
- else
- {
- return( retval );
- }
- }
-
-
-define string FormatCauseLine( symbol cause )
- ``{
- if( cause == `no_ext )
- // complete sentence, appended after other complete sentences.
- return( _("No extended partition exists."));
- if( cause == `dev_full )
- // complete sentence, appended after other complete sentences.
- return( _("There are already four primary and extended partitions."));
- if( cause == `no_extsp )
- // complete sentence, appended after other complete sentences.
- return( _("No space is left in the extended partition."));
- if( cause == `to_many )
- // complete sentence, appended after other complete sentences.
- return( _("Too many logical drives already exist."));
- if ( cause == `no_space )
- // complete sentence, appended after other complete sentences.
- return( _("No space remains."));
- if ( cause == `already )
- // complete sentence, appended after other complete sentences.
- return( _("An extended partition already exists."));
- return( "---" );
- };
-
-
- /*---------------------------------------------------------------------
- * Make a output string for "you can not create a partition, because: "
- *---------------------------------------------------------------------
- */
-
-define string FormatYouCannotCause( boolean primary_is_possible,
- boolean extended_is_possible,
- boolean logical_is_possible,
- symbol no_primary_cause,
- symbol no_extended_cause,
- symbol no_logical_cause )
- ``{
- string pri_line = "";
- string ext_line = "";
- string log_line = "";
-
- y2milestone( "prim:%1 ext:%2 log:%3 (%4 %5 %6)", primary_is_possible,
- extended_is_possible, logical_is_possible, no_primary_cause,
- no_extended_cause, no_logical_cause );
-
- if( primary_is_possible )
- // complete sentence. gets combined with other sentences.
- pri_line = _("A primary partition can be created.\n");
- else
- // complete sentence. gets combined with other sentences.
- pri_line = _("A primary partition cannot be created.") + " " +
- FormatCauseLine( no_primary_cause ) + "\n";
-
- if( logical_is_possible )
- // complete sentence. gets combined with other sentences.
- log_line = _("A logical partition can be created.\n");
- else
- if( no_logical_cause != `impossible )
- // complete sentence. gets combined with other sentences.
- log_line = _("A logical partition cannot be created.") + " " +
- FormatCauseLine( no_logical_cause ) +"\n" ;
-
- if ( extended_is_possible )
- // complete sentence. gets combined with other sentences.
- ext_line = _("An extended partition can be created.\n");
- else
- if( no_logical_cause != `impossible )
- // complete sentence. gets combined with other sentences.
- ext_line = _("An extended partition cannot be created.") + " " +
- FormatCauseLine( no_extended_cause ) +"\n";
-
- return ( pri_line + ext_line + log_line );
- };
-
}
Modified: branches/SuSE-Code-11-SP2-Branch/storage/storage/src/inst_disk_proposal.ycp
URL: http://svn.opensuse.org/viewcvs/yast/branches/SuSE-Code-11-SP2-Branch/stora…
==============================================================================
--- branches/SuSE-Code-11-SP2-Branch/storage/storage/src/inst_disk_proposal.ycp (original)
+++ branches/SuSE-Code-11-SP2-Branch/storage/storage/src/inst_disk_proposal.ycp Tue May 17 13:39:44 2011
@@ -23,20 +23,23 @@
{
textdomain "storage";
+
import "Arch";
import "Wizard";
import "Mode";
import "Popup";
import "Storage";
+ import "Sequencer";
+ import "StorageProposal";
+ import "Stage";
+
- include "wizard/sequencer.ycp";
- include "partitioning/custom_part_check_generated.ycp";
- include "partitioning/do_proposal_flexible.ycp";
- include "partitioning/custom_part_dialogs.ycp";
+ include "partitioning/custom_part_dialogs.ycp";
+ include "partitioning/ep-import.ycp";
-define boolean AskOverwriteChanges()
- ``{
+boolean AskOverwriteChanges()
+ {
boolean ret = true;
string target_is = Storage::GetPartMode();
y2milestone( "AskOverwriteChanges target_is %1", target_is );
@@ -51,9 +54,17 @@
return( ret );
}
-define void execSubscreens( boolean detailed )
- ``{
- y2milestone( "execSubscreens detailed %1", detailed );
+
+void execSubscreens(symbol mode)
+ {
+ y2milestone( "execSubscreens mode:%1", mode );
+
+ if (Mode::autoinst())
+ {
+ Storage::SetPartMode("PROP_MODIFY");
+ }
+ else
+ {
map aliases =
$[ "disk" :
``(WFM::CallFunction("inst_disk", [true, true])),
@@ -64,15 +75,15 @@
"resize_ui" :
``(WFM::CallFunction("inst_resize_ui", [true, true])),
];
+
map seq = $[];
seq["disk"] = $[ `abort : `abort, `cancel: `cancel, `next: `next ];
- if (Mode::autoinst())
- {
- Storage::SetPartMode("PROP_MODIFY");
- seq["ws_start"] = "disk";
- }
- else
- {
+
+ switch (mode)
+ {
+ case `modify:
+ case `detailed:
+ {
y2milestone( "ProposalActive %1 ProposalMode %2 PartMode %3",
Storage::GetPartProposalActive(),
Storage::GetPartProposalMode(), Storage::GetPartMode() );
@@ -88,7 +99,7 @@
}
seq["disk"] = $[ `abort : `abort, `cancel: `cancel, `next : `next ];
y2milestone( "execSubscreens GetPartMode %1", Storage::GetPartMode() );
- if( detailed && Storage::GetPartMode()!="CUSTOM" )
+ if( mode == `detailed && Storage::GetPartMode()!="CUSTOM" )
seq["ws_start"] = "target_sel";
else
seq["ws_start"] = "disk";
@@ -96,9 +107,19 @@
Storage::DisposeTargetBackup("disk");
y2milestone( "execSubscreens sequence %1", seq );
Wizard::OpenNextBackDialog();
- symbol result = WizardSequencer(aliases, seq);
+ symbol result = Sequencer::Run(aliases, seq);
Wizard::CloseDialog();
- Storage::HandleProposalPackages();
+ }
+ break;
+
+ case `import:
+ {
+ ImportMountPoints();
+ }
+ break;
+ }
+
+ Storage::HandleProposalPackages();
}
}
@@ -119,22 +140,17 @@
// Radiobutton for partition dialog
string detailed_str = _("&Create Partition Setup...");
// Radiobutton for partition dialog
-string part_str = _("&Partition Based");
-// Radiobutton for partition dialog
-string lvm_str = _("&LVM Based");
-// Checkbox for partition dialog
-string encrypt_str = _("Encrypt Volume Group");
+string import_str = _("&Import Partition Setup...");
string target_is = "";
string changes = "";
if( Storage::GetPartProposalFirst() )
{
- map prop = get_inst_prop( Storage::GetTargetMap() );
+ map prop = StorageProposal::get_inst_prop(Storage::GetTargetMap());
y2milestone( "prop ok:%1", prop["ok"]:false );
if( prop["ok"]:false )
{
- map save = targetMap;
Storage::SetTargetMap( prop["target"]:$[] );
targetMap = prop["target"]:$[];
Storage::SetPartProposalMode( "accept" );
@@ -163,43 +179,30 @@
y2milestone( "current proposal: %1", changes );
-map cfg = Storage::GetControlCfg();
-
-term rframe =
- `HBox(
- `HSpacing(3),
- `Top(`MinWidth(20,`Left( `RadioButton( `id(`part), `opt(`notify), part_str,
- !Storage::ProposalLvm() )))),
- `HSpacing(3),
- `Top(`MinWidth(20, `VBox(`Left(`RadioButton(`id(`lvm), `opt(`notify), lvm_str,
- Storage::ProposalLvm())),
- `HBox(`HSpacing(4), `CheckBox(`id(`encrypt), `opt(`notify), encrypt_str,
- Storage::ProposalEncrypt()))))),
- `HSpacing(3)
- );
+term rframe =
+ `HBox( `HSpacing(20),
+ StorageProposal::AddCommonWidgets(),
+ `HSpacing(3) );
term bframe =
- `HBox(
+ `VBox(
`PushButton( `id(`detailed), detailed_str ),
- `HSpacing(5),
- `PushButton( `id(`modify), modify_str ),
- `HSpacing(5)
+ `VSpacing(0.45),
+ `PushButton( `id(`import), import_str ),
+ `VSpacing(0.45),
+ `PushButton( `id(`modify), modify_str )
);
-// Frame description in suggested partition for mode accept modify ..
-//bframe = `HCenter( `Frame( _("Partitioning"), `HVSquash( bframe ) ));
-
term contents =
`VBox(
`VSpacing(0.5),
`HBox(
`HSpacing(2),
`VBox(
- `MinHeight( 7, `RichText( `id("richtext"), changes )),
- `VSpacing(1),
- `RadioButtonGroup( `id("prop_mode"), rframe ),
- `VSpacing(4),
+ `MinHeight(8, `RichText(`id(`richtext), changes)),
+ rframe,
+ `VSpacing(2),
bframe,
`VStretch()
),
@@ -223,6 +226,14 @@
"), deletechars(modify_str,"&"));
// help text continued
+// %1 is replaced by button text
+help_text = help_text + sformat(_("<p>
+To import the mount points from an existing Linux
+system choose <b>%1</b>. You can still make modification
+afterwards in the expert partitioner dialog.</p>
+"), deletechars(import_str, "&"));
+
+// help text continued
help_text = help_text + sformat(_("<p>
If the suggestion does not fit your needs, create
your own partition setup starting with the partitions as
@@ -252,14 +263,11 @@
if( Stage::initial () )
Wizard::SetTitleIcon( "yast-partitioning" );
- any r = nil;
-
- UI::ChangeWidget(`id(`encrypt), `Enabled, Storage::ProposalLvm());
+ UI::ChangeWidget(`id(`encrypt), `Enabled, StorageProposal::GetProposalLvm());
repeat
{
- symbol old_mode = (symbol) UI::QueryWidget(`id("prop_mode"), `CurrentButton);
- y2milestone( "old_mode %1", old_mode );
+ boolean val = false;
Wizard::SetFocusToNextButton();
ret = (symbol)Wizard::UserInput();
y2milestone( "USERINPUT %1", ret );
@@ -267,48 +275,16 @@
if( ret == `abort && Popup::ReallyAbort(true) )
return `abort;
- if( contains( [ `lvm, `part, `encrypt ], ret ) )
+ if( contains( [ `lvm, `home, `btrfs, `encrypt ], ret ) )
{
+ val = (boolean) UI::QueryWidget(`id(ret), `Value);
if( AskOverwriteChanges() )
{
target_is = "SUGGESTION";
-
- switch (ret)
- {
- case `part:
- Storage::SetProposalLvm(false);
- UI::ChangeWidget(`id(`encrypt), `Enabled, false);
- break;
-
- case `lvm:
- Storage::SetProposalLvm(true);
- UI::ChangeWidget(`id(`encrypt), `Enabled, true);
- break;
-
- case `encrypt:
-
- if ((boolean) UI::QueryWidget(`id(`encrypt), `Value))
- {
- if (QueryProposalPassword())
- {
- Storage::SetProposalEncrypt(true);
- }
- else
- {
- UI::ChangeWidget(`id(`encrypt), `Value, false);
- continue;
- }
- }
- else
- {
- Storage::SetProposalEncrypt(false);
- }
- break;
- }
-
+ StorageProposal::HandleCommonWidgets( ret );
Storage::ResetOndiskTarget();
Storage::AddMountPointsForWin(Storage::GetTargetMap());
- map prop = get_inst_prop( Storage::GetTargetMap());
+ map prop = StorageProposal::get_inst_prop(Storage::GetTargetMap());
if( !prop["ok"]:false )
{
Popup::Error( _("Impossible to create the requested proposal.") );
@@ -323,23 +299,26 @@
Storage::SetPartMode( target_is );
Storage::SetTargetMap( targetMap );
changes = Storage::ChangeText();
- UI::ChangeWidget( `id("richtext"), `Value, changes );
+ UI::ChangeWidget(`id(`richtext), `Value, changes);
}
else
- {
- UI::ChangeWidget( `id("prop_mode"), `CurrentButton, old_mode );
- }
+ UI::ChangeWidget(`id(ret), `Value, !val);
}
- else if( ret==`modify || ret==`detailed )
+ else if (contains([ `modify, `detailed, `import ], ret))
{
Storage::SetPartProposalFirst( false );
Storage::SetPartProposalActive( false );
- if( ret==`modify )
+
+ switch (ret)
+ {
+ case `modify:
{
target_is = "PROP_MODIFY";
Storage::SetPartProposalMode( "modify" );
}
- else
+ break;
+
+ case `detailed:
{
if( Storage::GetPartMode()!="CUSTOM" )
{
@@ -352,18 +331,31 @@
Storage::SetPartDisk( "" );
Storage::SetPartProposalMode( "detailed" );
}
- Storage::SetPartMode( target_is );
- execSubscreens( ret==`detailed );
- changes = Storage::ChangeText();
- UI::ChangeWidget( `id("richtext"), `Value, changes );
- if( ret==`detailed )
+ break;
+
+ case `import:
{
- UI::ChangeWidget(`id(`part), `Value, !Storage::ProposalLvm());
- UI::ChangeWidget(`id(`lvm), `Value, Storage::ProposalLvm());
- UI::ChangeWidget(`id(`encrypt), `Enabled, Storage::ProposalLvm());
- UI::ChangeWidget(`id(`encrypt), `Value, Storage::ProposalEncrypt());
+ target_is = "PROP_MODIFY";
+ Storage::SetPartProposalMode("modify");
}
+ break;
+ }
+
+ Storage::SetPartMode( target_is );
+ execSubscreens( ret );
+ changes = Storage::ChangeText();
+ UI::ChangeWidget(`id(`richtext), `Value, changes);
+ val = StorageProposal::GetProposalLvm();
+ UI::ChangeWidget(`id(`lvm), `Value, val );
+ UI::ChangeWidget(`id(`encrypt), `Enabled, val );
+ UI::ChangeWidget( `id(`encrypt), `Value,
+ val && StorageProposal::GetProposalEncrypt() );
+ UI::ChangeWidget(`id(`home), `Value,
+ StorageProposal::GetProposalHome() );
+ UI::ChangeWidget(`id(`btrfs), `Value,
+ StorageProposal::GetProposalBtrfs() );
}
+
} until ( ret == `next || ret == `back || ret == `cancel );
}
Storage::SaveExitKey( ret );
Modified: branches/SuSE-Code-11-SP2-Branch/storage/storage/src/inst_prepdisk.ycp
URL: http://svn.opensuse.org/viewcvs/yast/branches/SuSE-Code-11-SP2-Branch/stora…
==============================================================================
--- branches/SuSE-Code-11-SP2-Branch/storage/storage/src/inst_prepdisk.ycp (original)
+++ branches/SuSE-Code-11-SP2-Branch/storage/storage/src/inst_prepdisk.ycp Tue May 17 13:39:44 2011
@@ -13,82 +13,26 @@
* and mounted for the targets / and /boot.
*
*
- * SCR: Write(.disk + scrpath + .partitions, targetpartitions)
- * Execute (.target.mkdir, [ <mountpoint>, 0755] )
- * Execute (.target.mount, [<device>, <mountpoint>] )
- *
- *
* possible return values: `back, `abort `next
*/
{
textdomain "storage";
- import "Installation";
import "Mode";
import "Stage";
- import "Wizard";
import "Storage";
- import "Hotplug";
import "String";
import "SlideShow";
import "StorageClients";
- import "Popup";
if (Mode::update ())
return `auto;
- boolean test_mode = Mode::test();
- boolean this_is_for_real = !test_mode;
-
SCR::Write( .target.ycp, Storage::SaveDumpPath("targetMap_ps"),
Storage::GetTargetMap() );
-// Define macro that creates a dialog with progressbar
-define void MakefsDialog()
- ``{
- return;
-
- if (!Wizard::IsWizardDialog())
- return;
-
- // html-format
- // advise the user to wait for completion
- // part 1 of 2
- string helptext = _("<p>
-Please wait while your hard disk is prepared for installation...
-<br></p>");
- if( !Stage::initial () )
- {
- helptext = _("<p>
-Please wait while your hard disk is prepared...
-<br></p>");
- }
- // rich-text format help text part 2 of 2
- helptext = helptext + _("\
-<p>
-Depending on the size of your hard disk and your processor speed, this action
-might take some time. Several minutes are not unusual for really large disks.
-Often, the progress meter does not show a linear progress. Even if it looks
-slow near the end (\"95 %\"), please be patient. The formatting tool
-performs various checks. </p>");
-
- // The Wizard module sets a special protection mode for "Accept"
- // buttons to prevent sloppy calls to Wizard::SetContents()
- // from disabling it. This doesn't apply here, however -
- // switching protection mode off.
- UI::WizardCommand(`ProtectNextButton( false ) );
-
- // hard disk will be made ready for installing Linux
- Wizard::SetContents(_("Preparing Your Hard Disk"),
- `ProgressBar(`id(`progress), " ", 100),
- helptext, false, false);
- };
-
y2milestone( "BEGINNING of inst_prepdisk" );
- // check for ppc-PReP/CHRP system, they need a special boot partition
- // todo -> put this in a lib, we need it also in inst_custom_part ...
-
if( Mode::normal() )
{
// we need to open dialog and set up slideshow
@@ -109,7 +53,7 @@
// They are usually more than twice the reported value
// create, format, mount ...
- StorageClients::total_actions = Storage::ActionsCount() * 2.5;
+ StorageClients::total_actions = size(Storage::GetCommitInfos()) * 2.5;
y2milestone ("StorageClients::total_actions: %1", StorageClients::total_actions);
SlideShow::MoveToStage( "disk" );
@@ -120,25 +64,12 @@
integer ret = Storage::CommitChanges();
y2milestone( "CommitChanges ret:%1", ret );
if( ret!=0 )
- {
- string txt = sformat(_("Failure occurred during following action:
-%2
-
-System error code was: %1
-"), ret, Storage::LastAction() );
- string ext = Storage::ExtendedErrorMsg();
- if( size(ext)>0 )
- {
- txt = txt + "\n\n" + ext;
- }
- Popup::Error( txt );
ret_val = `abort;
- }
- //mount proc and usbfs during installation
if( Stage::initial() )
{
Storage::WriteFstab();
+
/*
* If a kernel without initrd is booted, then there is a small window
* between mounting the root filesystem until /etc/init.d/boot
@@ -153,16 +84,15 @@
y2milestone( "cmd %1", cmd );
map m = (map) SCR::Execute(.target.bash_output, cmd );
y2milestone( "ret %1", m );
- string destproc = Installation::scr_destdir+"/proc";
+ string destproc = Storage::PathToDestdir("/proc");
SCR::Execute (.target.mount, ["proc", destproc], "-t proc");
- destproc = Installation::scr_destdir+"/sys";
+ destproc = Storage::PathToDestdir("/sys");
SCR::Execute (.target.mount, ["sysfs", destproc], "-t sysfs");
}
else
{
Storage::FinishInstall();
}
- Storage::UpdateTargetMap();
// close progress on running system
if( Mode::normal() )
Added: branches/SuSE-Code-11-SP2-Branch/storage/storage/src/inst_resize_dialog.ycp
URL: http://svn.opensuse.org/viewcvs/yast/branches/SuSE-Code-11-SP2-Branch/stora…
==============================================================================
--- branches/SuSE-Code-11-SP2-Branch/storage/storage/src/inst_resize_dialog.ycp (added)
+++ branches/SuSE-Code-11-SP2-Branch/storage/storage/src/inst_resize_dialog.ycp Tue May 17 13:39:44 2011
@@ -0,0 +1,449 @@
+/**
+ * Module: inst_resize_dialog.ycp
+ *
+ * Authors: Thomas Roelz <tom(a)suse.de>
+ * Stefan Hundhammer <sh(a)suse.de>
+ * Jiri Srain
+ *
+ * Purpose: UI for setting how to split the disk between existing Windows and Linux
+ *
+ * FIXME: Get rid of code duplication between here and inst_resize_ui (resizing partition from a proposal)
+ *
+ *
+ * $Id: inst_resize_dialog.ycp 52739 2008-10-30 13:59:13Z aschnell $
+ */
+{
+ textdomain "storage";
+
+import "Mode";
+import "Storage";
+import "Popup";
+import "Partitions";
+import "Wizard";
+import "Installation";
+import "StorageProposal";
+
+include "partitioning/partition_defines.ycp";
+
+
+list<integer> DiskUsage (string win_device) {
+ integer win_used = -1;
+ integer win_free = -1;
+ boolean mount_result = (boolean)SCR::Execute( .target.mount,
+ [ win_device, Installation::scr_destdir,
+ Installation::mountlog ]);
+ if( !mount_result ) {
+ y2error( "Current Windows device <%1> could not be mounted. Canceled", win_device );
+ }
+ else
+ {
+ y2milestone( "Current Windows device <%1> mounted on %2.", win_device, Installation::scr_destdir );
+ }
+
+ // get usage information for the partition via df
+ list<map> df_result = (list<map>)SCR::Read(.run.df);
+ SCR::Execute(.target.umount, win_device);
+ y2debug( ".run.df: %1", df_result );
+
+ // filter out headline and other invalid entries
+ df_result = filter( map part, df_result,
+ ``( substring( part["spec"]:"", 0, 1 ) == "/" ));
+
+ foreach( map part, df_result, {
+ if( part["spec"]:"" == win_device ) // find right entry
+ {
+ // get the usage values
+ //
+ win_used = tointeger(part["used"]:"-1");
+ win_free = tointeger(part["free"]:"-1");
+
+ if( win_used != -1 && win_free != -1 ) {
+ win_used = win_used / 1024; // MB
+ win_free = win_free / 1024; // MB
+ y2milestone( ".run.df: win_used: <%1> win_free:<%2>", win_used, win_free );
+ }
+ }
+ });
+ return [ win_used, win_free ];
+}
+
+map _resize_result = nil;
+
+map ResizeResult() {
+ return _resize_result;
+}
+
+symbol ResizeDialog (string win_device, integer cyl_size, map win_partition) {
+
+ /////////////////////////////////////////////////////////////////////////
+ // START: Initialize
+ /////////////////////////////////////////////////////////////////////////
+
+ boolean test_mode = Mode::test ();
+ boolean demo_mode = Mode::test ();
+
+ // store
+ //
+
+ integer win_used = -1;
+ integer win_free = -1;
+ integer min_win_free = -1;
+ integer new_win_size = -1;
+ integer linux_size = -1;
+ integer linux_min = 400; // this is the base value for space calculations (minimum installation)
+
+ if ( test_mode ) // not just in demo mode! no HW probe in test mode!
+ {
+ win_used = 350;
+ win_free = 1500;
+ min_win_free = 50;
+ linux_size = 800;
+ linux_min = 400;
+ }
+
+ /////////////////////////////////////////////////////////////////////////
+ // END: Initialize
+ /////////////////////////////////////////////////////////////////////////
+
+
+ y2milestone( "Cylinder size of target: <%1>", cyl_size );
+ // Get region from win partition
+ //
+ list<integer> region = win_partition["region"]:[];
+
+ if( size( region ) != 2 ) {
+ y2error( "Invalid region <%1> in Windows partition data struct.", region );
+ return nil;
+ } else
+ y2milestone( "Old region <%1> OK in Windows partition data struct.", region );
+
+ // mount the partition to execute some checks
+ //
+ list<integer> usage = DiskUsage (win_device);
+ win_used = usage[0]:-1;
+ win_free = usage[1]:-1;
+ if( win_used == -1 || win_free == -1 ) {
+ y2error( "The sizes for device <%1> could not be examined.", win_device );
+ return nil;
+ } else {
+ // Apply some checks to determine if installing Linux is feasible at all.
+ //
+ boolean feasible = true;
+
+ // Set minimal free Windows size to 200 MB. Running Windows with
+ // less disk space is no fun.
+ //
+ if ( min_win_free < 200 ) min_win_free = 200;
+
+ // If this is more than the free space on the device Windows is already
+ // overcrowded and Linux shouldn't be installed.
+ //
+ if ( min_win_free > win_free ) return nil;
+
+ if( win_free - min_win_free < linux_min ) return nil;
+
+ // Try to reserve 1.5 GB for linux (default installation).
+ // Otherwise get as much as possible
+ //
+ if ( win_free - min_win_free > 1500 )
+ linux_size = 1500;
+ else
+ linux_size = win_free - min_win_free;
+ }
+
+ if (Storage::resize_partition != nil) // already resized
+ {
+ integer win_size = Storage::resize_partition_data["region",1]:-1;
+y2internal ("Win size read: %1", win_size);
+y2internal ("Part info: %1", Storage::resize_partition_data);
+y2internal ("Cyl size: %1", Storage::resize_cyl_size);
+ if (win_size != -1)
+ {
+ win_size = win_size * Storage::resize_cyl_size / (1024*1024);
+ linux_size = win_used + win_free - win_size;
+ }
+ }
+
+ /////////////////////////////////////////////////////////////////////////
+ // END: Preliminary action
+ /////////////////////////////////////////////////////////////////////////
+
+ /////////////////////////////////////////////////////////////////////////
+ // START: GUI
+ /////////////////////////////////////////////////////////////////////////
+
+ boolean test_simple_ui = false; // set to "true" to test non-graphical version
+
+ // Unit for parition resizing - currently Megabytes
+ string unit = _("MB");
+
+ // Labels for bar graph. "%1" will be replace with a numeric value.
+ string bargraph_label_win_used = _("Windows\nUsed\n%1 ") + unit;
+ // Labels for bar graph. "%1" will be replace with a numeric value.
+ string bargraph_label_win_free = _("Windows\nFree\n%1 ") + unit;
+ // Labels for bar graph. "%1" will be replace with a numeric value.
+ string bargraph_label_linux = _("Linux\n%1 ") + unit;
+
+ // Labels for input fields. "%1" will be replaced with the current unit (MB).
+ string field_label_win_free = sformat( _("Windows Free (%1)"), unit);
+ // Labels for input fields. "%1" will be replaced with the current unit (MB).
+ string field_label_linux = sformat( _("Linux (%1)"), unit);
+
+ term contents = `Empty();
+
+
+
+ // Help text for Windows partition resizing -
+ // common part for both graphical mode (with bar graphs)
+ // and non-graphical mode (text only).
+ string helptext = _("<p>
+Choose the new size for your Windows partition.
+</p>");
+
+ // help text (common to both modes), continued
+ helptext = helptext + _("
+<p>
+The actual resizing will be performed only after you confirm all your
+settings in the last installation dialog. Until then, your Windows
+partition will remain untouched.
+</p>");
+
+ // help text (common to both modes), continued
+ helptext = helptext + _("
+<p>
+To skip resizing your Windows partition, press
+<b>Back</b>.
+</p>
+");
+
+
+ if ( UI::HasSpecialWidget(`Slider ) &&
+ UI::HasSpecialWidget(`BarGraph ) &&
+ ! test_simple_ui )
+ {
+ contents = `VBox(
+ `VStretch(),
+ // Headline above bar graph that displays current windows partition size
+ `Left( `Label( _("Now")) ),
+ `BarGraph(
+ [ win_used, win_free ],
+ [
+ bargraph_label_win_used,
+ bargraph_label_win_free
+ ]
+ ),
+ `VStretch(),
+
+ // Headline above bar graph that displays future windows and linux partitions
+ `Left( `Label( _("After Installation") ) ),
+ `PartitionSplitter( `id(`linux_size),
+ win_used, win_free,
+ linux_size, linux_min, min_win_free,
+ bargraph_label_win_used,
+ bargraph_label_win_free,
+ bargraph_label_linux,
+ field_label_win_free,
+ field_label_linux
+ ),
+ `VStretch()
+ );
+
+
+ // help text, continued - graphical mode only
+ // this help text will be appended to the help text common to both modes.
+ helptext = helptext + _("
+<p>
+The upper bar graph displays the current situation.
+The lower bar graph displays the situation after the installation (after
+the partition resize).
+</p>
+");
+
+ // help text (graphical mode), continued
+ helptext = helptext + _("
+<p>
+Drag the slider or enter a numeric value in either
+input field to adjust the suggested value.
+</p>");
+
+ // help text (graphical mode), continued
+ helptext = helptext + _("
+<p>
+Within the space you reserve for Linux, partitions will automatically be
+created as necessary.
+</p>");
+ }
+ else // no special widgets -> simple fallback UI
+ {
+ contents = `HVSquash(
+ `VBox(
+ `HBox(
+ // Label for used part of the Windows partition in non-graphical mode
+ `HWeight(3, `Right(`Label(_("Windows Used")))),
+ `HWeight(2, `Label(`opt(`outputField), sformat("%1", win_used ))),
+ `HWeight(3, `Left(`Label( unit )))
+ ),
+ `VSpacing(0.5),
+ `HBox(
+ // Label for free part of the Windows partition in non-graphical mode
+ `HWeight(3, `Right(`Label(_("Free")))),
+ `HWeight(2, `Label(`opt(`outputField), sformat("%1", win_free ))),
+ `HWeight(3, `Left(`Label( unit )))
+ ),
+ `VSpacing(0.5),
+ `HBox(
+ // Edit field label for linux partition size in non-graphical mode
+ `HWeight(3, `Right(`Bottom(`Label(_("Linux"))))),
+ `HWeight(2, `IntField( `id(`linux_size),
+ "", // label (above)
+ linux_min, // min
+ win_free - min_win_free, // max
+ linux_size // initial
+ )
+ ),
+ `HWeight(3, `Left(`Bottom(`Label( unit ))))
+ )
+ )
+ );
+
+ // help text, continued - non-graphical mode only
+ // this help text will be appended to the help text common to both modes.
+ helptext = helptext + _("
+<p>Enter a value for the size of your <b>Linux</b> installation.
+The partitions will automatically be created within this range
+as required for &product;.
+</p>
+");
+
+ // help text (non-graphical mode), continued
+ helptext = helptext + _("
+<p>
+<b>Windows Used</b> is the size of the used part of your Windows partition.
+</p>");
+
+ // help text (non-graphical mode), continued
+ helptext = helptext + _("
+<p><b>Free</b> indicates the current free space (before the Linux
+installation) on the partition.
+</p>");
+ }
+
+
+y2internal ("Opening dialog");
+ Wizard::SetContents( // Set the dialog header
+ _("Resizing the Windows Partition"),
+ contents, helptext, true, true);
+
+
+ /////////////////////////////////////////////////////////////////////////
+ // END: GUI
+ /////////////////////////////////////////////////////////////////////////
+
+ /////////////////////////////////////////////////////////////////////////
+ // START: Main loop
+ /////////////////////////////////////////////////////////////////////////
+
+ symbol ret = nil;
+ repeat {
+ ret = (symbol)Wizard::UserInput();
+
+ if( ret == `abort && Popup::ReallyAbort(true) )
+ return `abort;
+
+ if( ret == `next )
+ {
+ // Get the value the user adjusted. If s/he entered a value
+ // too big or too small this is automatically adjusted to the
+ // biggest/smallest value possible (by Qt).
+ //
+ linux_size = (integer)UI::QueryWidget(`id(`linux_size), `Value);
+ new_win_size = win_used + win_free - linux_size;
+
+ y2milestone( "Linux size: <%1> - New Win size: <%2>",
+ linux_size, new_win_size);
+ }
+
+ if( ret == `back )
+ {
+ return `back;
+ }
+ } until ( ret == `next || ret == `back || ret == `cancel );
+
+ /////////////////////////////////////////////////////////////////////////
+ // END: Main loop
+ /////////////////////////////////////////////////////////////////////////
+
+ /////////////////////////////////////////////////////////////////////////
+ // START: Final action
+ /////////////////////////////////////////////////////////////////////////
+
+ // Now update the target map to the new situation
+ //
+ if( !test_mode ) {
+ // adjust the partition entry in the target map to reflect the new size
+
+ // add flag and new size to the windows partition
+ //
+ win_partition = add( win_partition, "resize", true );
+
+ // adjust the region list in the windows partition to reflect the new size
+ //
+ integer win_start = region[0]:0; // same as before resize
+y2internal ("Win size: %1", new_win_size);
+y2internal ("Cylinder: %1", cyl_size);
+ integer new_length_i = PartedSizeToCly( (tofloat(new_win_size) * 1024.0 * 1024.0), cyl_size );
+
+ region = [win_start, new_length_i];
+ win_partition = add( win_partition, "region", region);
+
+ y2milestone( "New region of Windows partition after resize: <%1>", region );
+ _resize_result = win_partition;
+ return `next;
+ }
+ /////////////////////////////////////////////////////////////////////////
+ // END: final action
+ /////////////////////////////////////////////////////////////////////////
+
+ return ret;
+}
+
+// main function
+if (Storage::resize_partition == nil) {
+ Storage::ResetOndiskTarget();
+ Storage::AddMountPointsForWin(Storage::GetTargetMap());
+ StorageProposal::get_inst_prop(Storage::GetTargetMap());
+ if (Storage::resize_partition == nil) // no resize
+ {
+ Storage::ResetOndiskTarget();
+ Storage::resize_partition = "";
+ return `auto;
+ }
+}
+if (Storage::resize_partition == "") {
+ return `auto;
+}
+symbol ret = ResizeDialog (Storage::resize_partition, Storage::resize_cyl_size, Storage::resize_partition_data);
+if (ret == `next)
+{
+ // store info about partition resize needed for the proposal
+ Storage::resize_partition_data = ResizeResult();
+ // reset proposal, recreate it
+ Storage::ResetOndiskTarget();
+ Storage::AddMountPointsForWin(Storage::GetTargetMap());
+ map prop = $[];
+ prop = StorageProposal::get_inst_prop(Storage::GetTargetMap());
+ y2milestone( "prop ok:%1", prop["ok"]:false );
+ if( prop["ok"]:false ) {
+ Storage::SetTargetMap( prop["target"]:$[] );
+ Storage::SetPartProposalMode( "accept" );
+ y2milestone( "PROPOSAL: %1", Storage::ChangeText());
+ } else {
+ Storage::SetPartProposalMode( "impossible" );
+ }
+ Storage::SetPartProposalFirst( false );
+ Storage::SetPartProposalActive( true );
+ y2milestone( "prop=%1", prop );
+ }
+return ret;
+
+}
Modified: branches/SuSE-Code-11-SP2-Branch/storage/storage/src/inst_resize_ui.ycp
URL: http://svn.opensuse.org/viewcvs/yast/branches/SuSE-Code-11-SP2-Branch/stora…
==============================================================================
--- branches/SuSE-Code-11-SP2-Branch/storage/storage/src/inst_resize_ui.ycp (original)
+++ branches/SuSE-Code-11-SP2-Branch/storage/storage/src/inst_resize_ui.ycp Tue May 17 13:39:44 2011
@@ -12,16 +12,15 @@
{
textdomain "storage";
- import "Arch";
- import "Mode";
import "Mode";
import "Storage";
import "Popup";
import "Partitions";
import "Wizard";
import "Product";
+ import "Installation";
- include "partitioning/do_proposal_flexible.ycp";
+ include "partitioning/partition_defines.ycp";
// Automatically return if resizing is not requested
//
@@ -556,7 +555,7 @@
boolean test_simple_ui = false; // set to "true" to test non-graphical version
// Unit for parition resizing - currently Megabytes
- string unit = _("MB");;
+ string unit = _("MB");
// Labels for bar graph. "%1" will be replace with a numeric value.
string bargraph_label_win_used = _("Windows\nUsed\n%1 ") + unit;
Modified: branches/SuSE-Code-11-SP2-Branch/storage/storage/src/inst_target_part.ycp
URL: http://svn.opensuse.org/viewcvs/yast/branches/SuSE-Code-11-SP2-Branch/stora…
==============================================================================
--- branches/SuSE-Code-11-SP2-Branch/storage/storage/src/inst_target_part.ycp (original)
+++ branches/SuSE-Code-11-SP2-Branch/storage/storage/src/inst_target_part.ycp Tue May 17 13:39:44 2011
@@ -17,10 +17,10 @@
import "Mode";
import "Popup";
import "Storage";
+ import "StorageProposal";
import "Partitions";
import "Product";
import "Label";
- import "Popup";
// flag for deleting a windows partition
integer win_partition_to_delete = -1;
@@ -44,8 +44,6 @@
// The partition number of the first logical partition
integer first_logical_nr = 5;
- integer size_of_swap = 0;
- integer size_of_boot = 0;
integer max_primary = 0;
// this will tell if automatic partitioning if feasible
boolean can_do_auto = false;
@@ -112,7 +110,7 @@
}
// user visible name of target
- string targetname = target["name"]:"";
+ string targetname = target["proposal_name"]:target["device"]:"?";
// The current list of partitions
list< map > partitions = target["partitions"]:[];
@@ -127,13 +125,6 @@
max_partitions = compute_max_partitions(target);
- // How much to allocate for swap
- size_of_swap = 1024*1024*Partitions::SwapSizeMb(0);
-
- // --------------------------------------------------------------
- // set size of /boot partition
- size_of_boot = Partitions::MinimalNeededBootsize();
-
// The number of possible primary partitions
max_primary = target["max_primary"]:4;
@@ -170,7 +161,7 @@
// this is the resize case
//
vbox = create_resize_dialog (partitions, target["cyl_size"]:1 );
- vbox = add_common_widgets( vbox );
+ vbox = add( vbox, StorageProposal::AddCommonWidgets());
y2milestone ("can resize !");
}
else
@@ -180,7 +171,7 @@
map tmp = construct_partition_dialog( partitions,
target["label"]:"",
target["cyl_size"]:1 );
- vbox = add_common_widgets( tmp["term"]:`Empty() );
+ vbox = add( tmp["term"]:`VBox(), StorageProposal::AddCommonWidgets());
}
}
@@ -189,7 +180,7 @@
else
{
vbox = create_whole_disk_dialog();
- vbox = add_common_widgets( vbox );
+ vbox = add( vbox, StorageProposal::AddCommonWidgets());
}
// Since resize case and normal case have different help texts we need
@@ -230,18 +221,10 @@
{
break;
}
- else if (ret == `lvm)
- {
- UI::ChangeWidget(`id(`encrypt), `Enabled, (boolean) UI::QueryWidget(`id(`lvm), `Value));
- }
- else if (ret == `encrypt)
- {
- if ((boolean) UI::QueryWidget(`id(`encrypt), `Value))
+ else if( contains( [ `lvm, `home, `btrfs, `encrypt ], ret ) )
{
- if (!QueryProposalPassword())
- UI::ChangeWidget(`id(`encrypt), `Value, false);
- }
- }
+ StorageProposal::HandleCommonWidgets(ret);
+ }
else if (ret == `full)
{
// Set all checkboxes
@@ -402,17 +385,11 @@
}
return( p );
});
- partitions = try_remove_sole_extended( partitions );
+ partitions = StorageProposal::try_remove_sole_extended( partitions );
y2milestone ("partitions '%1'", partitions);
- // Check selection for plausability
- Storage::SetProposalHome( (boolean)UI::QueryWidget( `id(`home), `Value ));
- Storage::SetProposalLvm((boolean) UI::QueryWidget(`id(`lvm), `Value));
- Storage::SetProposalEncrypt((boolean) UI::QueryWidget(`id(`encrypt), `Value));
-
ok = create_partitions( targetMap, target, partitions );
- Storage::SetProposalDefault(true);
if( !ok )
{
string reason = _("Too few partitions are marked for removal
Modified: branches/SuSE-Code-11-SP2-Branch/storage/storage/src/inst_target_selection.ycp
URL: http://svn.opensuse.org/viewcvs/yast/branches/SuSE-Code-11-SP2-Branch/stora…
==============================================================================
--- branches/SuSE-Code-11-SP2-Branch/storage/storage/src/inst_target_selection.ycp (original)
+++ branches/SuSE-Code-11-SP2-Branch/storage/storage/src/inst_target_selection.ycp Tue May 17 13:39:44 2011
@@ -56,43 +56,40 @@
boolean custom_val = (Storage::GetPartMode() == "CUSTOM");
y2milestone( "custom_val %1", custom_val );
- if( size(targetMap) > 0)
+ if (!isempty(targetMap))
{
// loop over targetMap and build radio buttons for selection
// dont use foreach here since we need a counter (as a shortcut)
// anyway
- term buttonbox = `VBox();
-
map<string, map> usable_target_map = filter(string d, map e, targetMap, {
return Storage::IsPartitionable(e) &&
!contains([ `UB_DMRAID, `UB_DMMULTIPATH, `UB_MDPART ], e["used_by_type"]:`UB_NONE);
});
integer dskcnt = size(usable_target_map);
- y2milestone( "dskcnt %1", dskcnt );
+ y2milestone("dskcnt:%1", dskcnt);
+
+ term buttonbox = `VBox();
- if (dskcnt > 10)
+ if (dskcnt >= 10)
{
- integer i = 1;
- list disklist = [];
+ list<term> disklist = [];
foreach(string tname, map tdata, usable_target_map, {
- disklist = add(disklist, `item(`id(tname), sformat("%1: %2", i, tname)));
- i = i + 1;
+ string tlinename = tdata["proposal_name"]:tdata["device"]:"?";
+ string tline = sformat("%1", tlinename);
+ disklist = add(disklist, `item(`id(tname), tline));
});
- buttonbox = add(buttonbox, `SelectionBox(`id(`disklist), `opt(`notify),
- _("Available &Disks"), disklist));
+ buttonbox = add(buttonbox, `MinWidth(40, `SelectionBox(`id(`disklist), `opt(`notify),
+ _("Available &Disks"), disklist)));
}
else
{
integer i = 1;
foreach(string tname, map tdata, usable_target_map, {
- string tlinename = tdata["name"]:"?";
- if( tdata["type"]:`CT_UNKNOWN==`CT_DMRAID )
- tlinename = "BIOS RAID " + tdata["name"]:"?";
- string tline = "&" + i + ": " + tlinename;
- boolean sel = Storage::GetPartDisk()==tname &&
- !custom_val;
+ string tlinename = tdata["proposal_name"]:tdata["device"]:"?";
+ string tline = sformat("&%1: %2", i, tlinename);
+ boolean sel = Storage::GetPartDisk() == tname && !custom_val;
buttonbox = add(buttonbox, `Left(`RadioButton(`id(tname), tline, sel)));
i = i + 1;
});
@@ -133,7 +130,7 @@
// There are several hard disks found. Linux is completely installed on
// one hard disk - this selection is done here
- // "Preparing Hard Disk - Step 1" is the description of the dialog what to
+ // "Preparing Hard Disk" is the description of the dialog what to
// do while the following locale is the help description
// help part 1 of 3
string helptext = _("<p>
@@ -157,7 +154,7 @@
// first step of hd prepare, select a single disk or "expert" partitioning
- Wizard::SetContents( _("Preparing Hard Disk: Step 1"),
+ Wizard::SetContents( _("Preparing Hard Disk"),
contents, helptext, (boolean)WFM::Args(0),
(boolean)WFM::Args(1));
if ( Stage::initial () )
Modified: branches/SuSE-Code-11-SP2-Branch/storage/storage/src/modules/FileSystems.ycp
URL: http://svn.opensuse.org/viewcvs/yast/branches/SuSE-Code-11-SP2-Branch/stora…
==============================================================================
--- branches/SuSE-Code-11-SP2-Branch/storage/storage/src/modules/FileSystems.ycp (original)
+++ branches/SuSE-Code-11-SP2-Branch/storage/storage/src/modules/FileSystems.ycp Tue May 17 13:39:44 2011
@@ -2,6 +2,7 @@
* Module: FileSystems.ycp
*
* Authors: Johannes Buchhold (jbuch(a)suse.de)
+ * Arvin Schnell <aschnell(a)suse.de>
*
* Purpose:
* These module contains the supported filesystems and their settings.
@@ -11,14 +12,13 @@
*/
{
module "FileSystems";
+
textdomain "storage";
+
import "Arch";
import "String";
import "Partitions";
- import "Popup";
import "Encoding";
-
- import "Mode";
import "Stage";
import "LibStorage";
@@ -32,7 +32,9 @@
"def_int" : LibStorage::FSUNKNOWN(),
"m" : $[ LibStorage::REISERFS() : `reiser,
LibStorage::EXT2() : `ext2,
- LibStorage::EXT3() : `ext3,
+ LibStorage::EXT3() : `ext3,
+ LibStorage::EXT4() : `ext4,
+ LibStorage::BTRFS() : `btrfs,
LibStorage::VFAT() : `vfat,
LibStorage::XFS() : `xfs,
LibStorage::JFS() : `jfs,
@@ -40,6 +42,8 @@
LibStorage::NTFS() : `ntfs,
LibStorage::SWAP() : `swap,
LibStorage::NFS() : `nfs,
+ LibStorage::NFS4() : `nfs4,
+ LibStorage::TMPFS() : `tmpfs,
LibStorage::FSNONE() : `none
]
];
@@ -55,12 +59,19 @@
return( ret );
}
- global list<string> system_m_points = [ "/", "/usr", "/var", "/opt",
- Partitions::BootMount() ];
- global list<string> crypt_m_points = [ "/", Partitions::BootMount(), "/usr" ];
- list<string> suggest_m_points = [];
- global list<string> swap_m_points = [ "swap" ];
- global list<string> tmp_m_mpoint = [ "/tmp", "/var/tmp" ];
+
+ // filesystems possible for root volume. used during scan for root volumes.
+ global const list<symbol> possible_root_fs = [ `ext2, `ext3, `ext4, `btrfs, `reiser, `xfs, `jfs ];
+
+
+ global list<string> system_m_points() { return [ "/", "/usr", "/var", "/opt", Partitions::BootMount() ]; }
+ global list<string> crypt_m_points() { return [ "/", Partitions::BootMount(), "/usr" ]; }
+ global const list<string> swap_m_points = [ "swap" ];
+ global const list<string> tmp_m_points = [ "/tmp", "/var/tmp" ];
+
+ list<string> suggest_m_points = [];
+ list<string> suggest_tmp_points = [];
+
global string nchars = "0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ";
@@ -70,17 +81,28 @@
{
suggest_m_points = [ "/home", "/srv", "/tmp", "/local" ];
if( Stage::initial() )
- suggest_m_points = (list<string>)union( system_m_points,
+ suggest_m_points = (list<string>)union( system_m_points(),
suggest_m_points );
y2milestone( "SuggestMPoints init:%1", suggest_m_points );
}
return( suggest_m_points );
}
- any lib_id = nil;
+global list<string> SuggesTmpfsMPoints()
+ {
+ if( size(suggest_tmp_points)==0 )
+ {
+ suggest_tmp_points = [ "/run", "/var/run", "/tmp", "/var/lock" ];
+ y2milestone( "SuggesTmpfsMPoints init:%1", suggest_tmp_points );
+ }
+ return( suggest_tmp_points );
+ }
+
+ any sint = nil;
+
-define list FstabOptionStrings =
- [ "defaults",
+ const list<string> FstabOptionStrings = [
+ "defaults",
"auto", "noauto",
"atime", "noatime",
"ro", "rw",
@@ -99,16 +121,19 @@
"usrquota", "grpquota"
];
-define list FstabOptionRegex = [ "pri=[0-9]\+", "iocharset=.\+", "utf8=\.*",
+ const list<string> FstabOptionRegex = [
+ "pri=[0-9]\+", "iocharset=.\+", "utf8=\.*",
"nls=.\+", "codepage=.\+",
"gid=[0-9]\+", "umask=[0-7]\+",
"loop=.\+", "encryption=.\+",
"pri=[0-9]\+",
"locale=\.\+", "fmask=[0-7]\+", "dmask=[0-7]\+",
- "usrjquota=.\+", "grpjquota=.\+", "jqfmt=.\+" ];
+ "usrjquota=.\+", "grpjquota=.\+", "jqfmt=.\+"
+ ];
-define map FstabDefaultMap =
- $[ "pts": $[ "spec":"devpts", "mount":"/dev/pts", "vfstype":"devpts",
+
+ const map<string, map> FstabDefaultMap = $[
+ "pts": $[ "spec":"devpts", "mount":"/dev/pts", "vfstype":"devpts",
"mntops":"mode=0620,gid=5", "freq":0, "passno":0 ],
"proc": $[ "spec":"proc", "mount":"/proc", "vfstype":"proc",
"mntops":"defaults", "freq":0, "passno":0 ],
@@ -144,6 +169,8 @@
`xfs : true,
`ext2 : true,
`ext3 : true,
+ `ext4 : true,
+ `btrfs : true,
`jfs : true,
`vfat : true,
`ntfs : true,
@@ -155,40 +182,8 @@
`lvm : true
];
- list<symbol> unsupportFs = [ `jfs ];
-
-
- map<symbol, map<string, any> > capabilities = $[
- `reiser : $[ ],
- `xfs : $[ ],
- `ext2 : $[ ],
- `ext3 : $[ ],
- `jfs : $[ ],
- `hfs : $[ ],
- `vfat : $[ ],
- `ntfs : $[ ],
- `swap : $[ ],
- `unknown : $[ ]
- ];
-
+ list<symbol> unsupportFs = [ `jfs, `btrfs ];
- /**
- * Return a map that contains the mount option for each used_fs (-t)
- * @return map
- */
- /*
- to mount_string
- global define used2typeMap()
- ``{
- return $[
- `ext2 : "ext2",
- `ext3 : "ext3",
- `reiser : "reiserfs",
- `xfs : "xfs",
- `jfs : "jfs",
- `vfat : "vfat" ];
- };
- */
global define list<map<symbol, any> > GetGeneralFstabOptions()
``{
@@ -335,6 +330,25 @@
return( opt );
};
+ list< map<symbol, any> > tmpfs_fst_options = [
+ $[ `widget : `TextEntry( `id("size"), `opt(`hstretch),
+ // label text
+ _("Tmpfs &Size"), "" ),
+ `query_key : "size",
+ `between : [ 1, 200 ],
+ `empty_allowed : true,
+ `valid_chars : "0123456789kKmMgG%",
+ // popup text
+ `error_text : _("Value must be larger than 0. Try again."),
+ `type : `text,
+ `str_opt : "size=%1",
+ `str_scan : "size=\(.*\)",
+ // help text, richtext format
+ `help_text : _("<p><b>Tmpfs Size:</b>
+Size may be either entered as a number followed by K,M,G for Kilo-, Mega- or Gigabyte or
+as a number followeb by a percent sign meaning percentage of memory.</p>")
+ ]];
+
define map<symbol, map<symbol, any> > GetNormalFilesystems()``{
list< map<symbol, any> > fat_fst_options =
@@ -373,7 +387,7 @@
[
$[
// label text
- `widget : `ComboBox(`id("opt_number_of_fats"), `opt(`hstretch), _("Number of &FATs"), ["auto" , "1", "2" ]),
+ `widget : `ComboBox(`id("opt_number_of_fats"), `opt(`hstretch), _("Number of &FATs"), [ "auto" , "1", "2" ]),
`query_key : "opt_number_of_fats",
`option_str : "-f",
// help text, richtext format
@@ -390,7 +404,7 @@
`option_str : "-F",
// help text, richtext format
`help_text : _("<p><b>FAT size:</b>
-Specifies the type of file allocation tables used (12, 16, or 32-bit). If auto is specified, YaST2 will automatically select the value most suitable for the file system size.</p>
+Specifies the type of file allocation tables used (12, 16, or 32-bit). If auto is specified, YaST2 will automatically select the value most suitable for the file system size.</p>
")
],
$[
@@ -567,14 +581,14 @@
`query_key : "opt_reserved_blocks",
`option_str : "-m",
//`default : 5,
- `between : [ 0 , 99 ], // -> -1 = infinite
- `str_length : 2,
- `valid_chars : "0123456789",
+ `below : 99,
+ `str_length : 6,
+ `valid_chars : "0123456789.",
// popup text
- `error_text : _("The \"Percentage of blocks reserved for root\" value is incorrect.\nPlease use a value between 0 and 99."),
+ `error_text : _("The \"Percentage of blocks reserved for root\" value is incorrect.\nAllowed are float numbers not larger than 99. (e.g. 0.5)"),
// xgettext: no-c-format
// help text, richtext format
- `help_text : _("<p><b>Percentage of blocks reserved for root:</b> Specify the percentage of blocks reserved for the super user. This value defaults to 5%.</p>")
+ `help_text : _("<p><b>Percentage of blocks reserved for root:</b> Specify the percentage of blocks reserved for the super user. The default is computed so that normally 1 Gig is reserved. Upper limit for reserved default is 5.0, lowest reserved default is 0.1.</p>")
],
$[
// checkbox text
@@ -605,18 +619,36 @@
`widget : `CheckBox(`id("opt_dir_index"), `opt(`hstretch), _("&Directory Index Feature")),
`query_key : "opt_dir_index",
`option_str : "-O dir_index",
+ `option_false : "-O ^dir_index",
`type : `boolean,
- `default : false,
// help text, richtext format
`help_text : _("<p><b>Directory Index:</b>
Enables use of hashed b-trees to speed up lookups in large directories.</p>\n")
]
];
+list< map<symbol, any> > ext4_only_options = [
+ $[
+ // label text
+ `widget : `CheckBox(`id("no_journal"), `opt(`hstretch), _("&No Journal")),
+ `query_key : "no_journal",
+ `option_str : "-O ^has_journal",
+ `type : `boolean,
+ `default : false,
+ // help text, richtext format
+ `help_text : _("<p><b>No Journal:</b>
+Suppressed use of journaling on filesystem. Only activate this when you really
+know what you are doing.</p>\n")
+ ]
+ ];
+
list< map<symbol, any> > ext3_options = (list< map<symbol, any> >)merge( ext2_options, ext3_only_options );
+ list< map<symbol, any> > ext4_options = (list< map<symbol, any> >)merge( ext2_options, ext3_only_options );
+ ext4_options = (list< map<symbol, any> >)merge( ext4_options, ext4_only_options );
- list< map<symbol, any> > ext3_fst_options = [ ];
list< map<symbol, any> > ext2_fst_options = [ ];
+ list< map<symbol, any> > ext3_fst_options = [ ];
+ list< map<symbol, any> > ext4_fst_options = [ ];
list< map<symbol, any> > reiser_fst_options = [ ];
@@ -632,7 +664,6 @@
`mountpoints : SuggestMPoints(),
`mount_option : "-t ext2",
`mount_string : "ext2",
- `makefstype : "ext2",
`fst_options : ext2_fst_options,
`options : ext2_options,
],
@@ -648,7 +679,6 @@
`mountpoints : SuggestMPoints() ,
`mount_option : "-t vfat",
`mount_string : "vfat",
- `makefstype : "fat32",
`needed_modules : [ "fat", "vfat" ],
`fst_options : fat_fst_options,
`options : vfat_options
@@ -666,7 +696,6 @@
`mount_option : "-t reiserfs",
`mount_string : "reiserfs",
`needed_modules : [ "reiserfs" ],
- `makefstype : "reiserfs",
`fst_options : reiser_fst_options,
`options : reiserfs_options
],
@@ -682,7 +711,6 @@
`mount_option : "-t xfs",
`mount_string : "xfs",
`needed_modules : [ "xfs" ],
- `makefstype : "xfs",
`options : xfs_options
],
`jfs : $[
@@ -697,7 +725,6 @@
`mount_string : "jfs",
`mount_option : "-t jfs",
`needed_modules : [ "jfs" ],
- `makefstype : "jfs",
`options : jfs_options
],
`ext3 : $[
@@ -711,10 +738,39 @@
`mountpoints : SuggestMPoints(),
`mount_string : "ext3",
`mount_option : "-t ext3",
- `needed_modules : [ "jbd", "ext3" ],
- `makefstype : "ext2", // format ext3 as ext2 !!!!!!!!!!!!!!!
+ `needed_modules : [ "jbd", "mbcache", "ext3" ],
`fst_options : ext3_fst_options,
`options : ext3_options
+ ],
+ `ext4 : $[
+ `name : "Ext4",
+ `fsid : Partitions::fsid_native,
+ `real_fs : true,
+ `supports_format : true ,
+ `fsid_item : "0x83 Linux " ,
+ `fstype : "Linux native" ,
+ `crypt : true,
+ `mountpoints : SuggestMPoints(),
+ `mount_string : "ext4",
+ `mount_option : "-t ext4",
+ `needed_modules : [ "jbd2", "mbcache", "ext4" ],
+ `fst_options : ext4_fst_options,
+ `options : ext4_options
+ ],
+ `btrfs : $[
+ `name : "BtrFS",
+ `fsid : Partitions::fsid_native,
+ `real_fs : true,
+ `supports_format : true ,
+ `fsid_item : "0x83 Linux " ,
+ `fstype : "Linux native" ,
+ `crypt : true,
+ `mountpoints : SuggestMPoints(),
+ `mount_string : "btrfs",
+ `mount_option : "-t btrfs",
+ `needed_modules : [ "btrfs" ],
+ `fst_options : [],
+ `options : []
],
`hfs : $[
`name : "MacHFS",
@@ -729,7 +785,6 @@
`mount_string : "hfs",
`mount_option : "-t hfs",
`needed_modules : [ "hfs" ],
- `makefstype : "hfs",
`fst_options : [],
`options : []
],
@@ -746,7 +801,6 @@
`mount_string : "hfsplus",
`mount_option : "-t hfsplus",
`needed_modules : [ "hfsplus" ],
- `makefstype : "",
`fst_options : [],
`options : []
],
@@ -763,9 +817,15 @@
`mount_string : "ntfs-3g",
`mount_option : "-t ntfs",
`needed_modules : [ "ntfs" ],
- `makefstype : "",
`fst_options : [],
`options : []
+ ],
+ `tmpfs : $[
+ `name : "TmpFS",
+ `mountpoints : SuggesTmpfsMPoints(),
+ `mount_string : "tmpfs",
+ `mount_option : "-t tmpfs",
+ `fst_options : tmpfs_fst_options,
]
];
@@ -867,38 +927,38 @@
return ret;
}
+global define map<symbol,any> GetTmpfsFilesystem()
+ {
+ return( GetNormalFilesystems()[`tmpfs]:$[] );
+ }
global define list< map<symbol, any> > GetFstabOptWidgets( symbol fsys )
``{
list< map<symbol, any> > ret = [];
- if( fsys != `swap )
+ if( fsys == `swap )
+ ret = swap_fst_options;
+ else if( fsys == `tmpfs )
+ ret = tmpfs_fst_options;
+ else
{
map<symbol, map<symbol, any> > fs = GetAllFileSystems( true, false );
ret = fs[fsys,`fst_options]:[];
- if( contains( [`ext3, `reiser], fsys ) )
+ if( contains( [`ext3, `ext4, `reiser], fsys ) )
{
ret = (list< map<symbol, any> >)union( ret, GetJournalFstabOptions() );
}
- if( contains( [`ext2, `ext3, `reiser], fsys ) )
+ if( contains( [`ext2, `ext3, `ext4, `reiser], fsys ) )
{
ret = (list< map<symbol, any> >)union( ret, GetAclFstabOptions() );
}
}
- else
- {
- ret = swap_fst_options;
- }
- y2milestone( "fsys %1", fsys );
- y2milestone( "ret %1", ret );
- return( ret );
+ y2milestone("fsys:%1 ret:%2", fsys, ret);
+ return ret;
};
-
-
- /* FileS build fss map with all supported filesystems ( list support ) */
-global define void FileSystems()
- ``{
+ global void FileSystems()
+ {
if( Arch::sparc64() || Arch::sparc32() )
{
support[`vfat] = false;
@@ -930,51 +990,10 @@
y2milestone( "support %1", support );
}
-global define void InitSlib( any sint )
+
+ global void InitSlib(any value)
{
- boolean bval = false;
- integer val = 0;
- lib_id = sint;
- foreach( symbol fs, map<string,any> cap, capabilities,
- ``{
- if( fs != `unknown )
- {
- integer id = fromSymbol( conv_fs, fs );
- any fsinfo = LibStorage::FsCapabilities::new("LibStorage::FsCapabilities");
- boolean ret = LibStorage::StorageInterface::getFsCapabilities( sint, id, fsinfo );
- if( !ret )
- y2error( "InitSlib fs:%1 id:%2 ret:%3", fs, id, ret );
- else
- {
- cap = $[];
- bval = LibStorage::FsCapabilities::swig_isExtendable_get(fsinfo);
- if( bval )
- cap["extend"] = true;
- bval = LibStorage::FsCapabilities::swig_isReduceable_get(fsinfo);
- if( bval )
- cap["shrink"] = true;
- bval = LibStorage::FsCapabilities::swig_isExtendableWhileMounted_get(fsinfo);
- if( bval )
- cap["mount_extend"] = true;
- bval = LibStorage::FsCapabilities::swig_isReduceableWhileMounted_get(fsinfo);
- if( bval )
- cap["mount_shrink"] = true;
- bval = LibStorage::FsCapabilities::swig_supportsUuid_get(fsinfo);
- if( bval )
- cap["uuid"] = true;
- bval = LibStorage::FsCapabilities::swig_supportsLabel_get(fsinfo);
- if( bval )
- cap["label"] = true;
- bval = LibStorage::FsCapabilities::swig_labelWhileMounted_get(fsinfo);
- if( bval )
- cap["set_label_mount"] = true;
- if( cap["label"]:false )
- cap["label_length"] = LibStorage::FsCapabilities::swig_labelLength_get(fsinfo);
- cap["min_fs_k"] = LibStorage::FsCapabilities::swig_minimalFsSizeK_get(fsinfo);
- capabilities[fs] = cap;
- }
- }
- });
+ sint = value;
}
@@ -1000,14 +1019,18 @@
}
}
- global define string GetName( symbol used_fs, string defaultv )``{
+
+ global string GetName( symbol used_fs, string defaultv )
+ {
map<symbol,any> fsmap = GetFsMap( used_fs);
string ret = fsmap[`name]:"";
if ( ret == "" && used_fs == `ntfs ) ret = "NTFS"; // obsolete? (included in RealFileSystems)
- if ( ret == "" && used_fs == `nfs ) ret = "NFS";
+ if ( ret == "" && used_fs == `nfs ) ret = "NFS";
+ if ( ret == "" && used_fs == `nfs4 ) ret = "NFS4";
if ( ret == "" ) ret = defaultv;
return ret;
- }
+ }
+
global define integer GetFsid( symbol used_fs )``{
map<symbol,any> fsmap = GetFsMap( used_fs);
@@ -1054,244 +1077,140 @@
* Return the mount option for each used_fs (-t)
* @return string
*/
- global define string GetMountString(symbol used_fs, string defaultv )``{
- map<symbol,any> fsmap = GetFsMap( used_fs);
- string ret = fsmap[`mount_string ]:"";
- if( size(ret)==0 )
- {
- if( used_fs == `vfat )
- {
- ret = "vfat";
- }
- else if( used_fs == `ntfs )
- {
- ret = "ntfs-3g";
- }
- }
- if( ret == "" ) ret = defaultv;
- y2milestone( "used_fs:%1 ret:%2", used_fs, ret );
- return ret;
- }
-
- global define list<string> GetNeededModules( symbol used_fs )``{
- list<string> ret = [];
- map<symbol,any> fsmap = GetFsMap( used_fs);
- if( used_fs==`ntfs && size(fsmap)==0 )
- {
- ret = ["ntfs"];
- }
- else
- {
- ret = fsmap[`needed_modules ]:[];
- }
- return ret;
- }
-
-
-/*
- global define string GetMakeFsType( symbol used_fs , string defaultv )``{
- map<symbol,any> fsmap = GetFsMap( used_fs);
- string ret = fsmap[`makefstype ]:"";
- if( ret == "" ) ret = defaultv;
- return ret;
- }
-*/
-
+ global string GetMountString(symbol used_fs, string defaultv)
+ {
+ map<symbol, any> fsmap = GetFsMap(used_fs);
+ string ret = fsmap[`mount_string ]:defaultv;
+ y2milestone("GetMountString used_fs:%1 ret:%2", used_fs, ret);
+ return ret;
+ }
- /**
- * Load the kernel module which is necessary to mount a partition with used_fs!
- * @param used_fs filesystem
- * @return boolean
- * old load_fs_module
- */
-/*
-global define boolean LoadModule( symbol used_fs )
- ``{
- list<string> all_needed_modules = GetNeededModules( used_fs );
- y2milestone("all needed modules for %1: %2", used_fs, all_needed_modules );
- boolean load_success = true;
-
- SCR::UnmountAgent (.proc.modules);
- map loaded_modules = (map) SCR::Read(.proc.modules);
- y2milestone( "loaded_modules %1", loaded_modules );
+ global list<string> GetNeededModules(symbol used_fs)
+ {
+ map<symbol, any> fsmap = GetFsMap(used_fs);
+ list<string> ret = fsmap[`needed_modules ]:[];
+ y2milestone("GetNeededModules used_fs:%1 ret:%2", used_fs, ret);
+ return ret;
+ }
- foreach( string modulename, all_needed_modules,
- ``{
- if( modulename != "" && size (loaded_modules[modulename]:$[])==0 )
- {
- if( load_success )
- load_success = (boolean) SCR::Execute(.target.modprobe, modulename , "" );
- y2milestone ("Loaded fs module %1 %2", modulename, load_success?"Ok":"Failed");
- }
- });
- return load_success;
- };
-*/
+ global integer MinFsSizeK(symbol fsys)
+ {
+ integer ret = 0;
+ integer id = fromSymbol(conv_fs, fsys);
+ any caps = LibStorage::FsCapabilities::new("LibStorage::FsCapabilities");
+ if (LibStorage::StorageInterface::getFsCapabilities(sint, id, caps))
+ ret = LibStorage::FsCapabilities::swig_minimalFsSizeK_get(caps);
+ y2milestone("MinFsSizeK fsys:%1 ret:%2", fsys, ret);
+ return ret;
+ }
-global define integer MinFsSizeK( symbol fsys )
- ``{
- map<string,any> cap = capabilities[`unknown]:$[];
- cap = capabilities[fsys]:cap;
- integer ret = cap["min_fs_k"]:0;
- y2milestone( "MinFsSizeK fsys:%1 ret:%2", fsys, ret );
- return( ret );
+ global boolean MountUuid(symbol fsys)
+ {
+ boolean ret = false;
+ integer id = fromSymbol(conv_fs, fsys);
+ any caps = LibStorage::FsCapabilities::new("LibStorage::FsCapabilities");
+ if (LibStorage::StorageInterface::getFsCapabilities(sint, id, caps))
+ ret = LibStorage::FsCapabilities::swig_supportsUuid_get(caps);
+ y2milestone("MountUuid fsys:%1 ret:%2", fsys, ret);
+ return ret;
}
-global define boolean MountUuid( symbol fsys )
- ``{
- map<string,any> cap = capabilities[`unknown]:$[];
- cap = capabilities[fsys]:cap;
- boolean ret = cap["uuid"]:false;
- y2milestone( "MountUuid fsys:%1 ret:%2", fsys, ret );
- return( ret );
- }
-global define boolean MountLabel( symbol fsys )
- ``{
- map<string,any> cap = capabilities[`unknown]:$[];
- cap = capabilities[fsys]:cap;
- boolean ret = cap["label"]:false;
- y2milestone( "MountLabel fsys:%1 ret:%2", fsys, ret );
- return( ret );
+ global boolean MountLabel(symbol fsys)
+ {
+ boolean ret = false;
+ integer id = fromSymbol(conv_fs, fsys);
+ any caps = LibStorage::FsCapabilities::new("LibStorage::FsCapabilities");
+ if (LibStorage::StorageInterface::getFsCapabilities(sint, id, caps))
+ ret = LibStorage::FsCapabilities::swig_supportsLabel_get(caps);
+ y2milestone("MountLabel fsys:%1 ret:%2", fsys, ret);
+ return ret;
}
-global define boolean ChangeLabelMounted( symbol fsys )
- ``{
- map<string,any> cap = capabilities[`unknown]:$[];
- cap = capabilities[fsys]:cap;
- boolean ret = cap["set_label_mount"]:false;
- y2milestone( "ChangeLabelMounted fsys:%1 ret:%2", fsys, ret );
- return( ret );
- }
-global define integer LabelLength( symbol fsys )
- ``{
- map<string,any> cap = capabilities[`unknown]:$[];
- cap = capabilities[fsys]:cap;
- integer ret = cap["label_length"]:16;
- y2milestone( "LabelLength fsys:%1 ret:%2", fsys, ret );
- return( ret );
+ global boolean ChangeLabelMounted(symbol fsys)
+ {
+ boolean ret = false;
+ integer id = fromSymbol(conv_fs, fsys);
+ any caps = LibStorage::FsCapabilities::new("LibStorage::FsCapabilities");
+ if (LibStorage::StorageInterface::getFsCapabilities(sint, id, caps))
+ ret = LibStorage::FsCapabilities::swig_labelWhileMounted_get(caps);
+ y2milestone("ChangeLabelMounted fsys:%1 ret:%2", fsys, ret);
+ return ret;
}
-global define map IsResizable( symbol fsys )
- ``{
- map<string,any> cap = capabilities[`unknown]:$[];
- cap = capabilities[fsys]:cap;
- map ret = $[];
- ret["extend"] = cap["extend"]:false;
- ret["shrink"] = cap["shrink"]:false;
- ret["mount_extend"] = cap["mount_extend"]:false;
- ret["mount_shrink"] = cap["mount_shrink"]:false;
- y2milestone( "IsResizable fsys:%1 ret:%2", fsys, ret );
- return( ret );
- };
-global define symbol FsToSymbol( string type )
- ``{
- symbol return_value = `none;
- if( type == "ext2" )
- {
- return_value = `ext2;
- }
- else if( type == "ext3" )
- {
- return_value = `ext3;
- }
- else if( regexpmatch( type, "reiser.*" ) )
- {
- return_value = `reiser;
- }
- else if( type == "jfs" )
- {
- return_value = `jfs;
- }
- else if( type == "xfs" )
- {
- return_value = `xfs;
- }
- else if( type == "vfat" || regexpmatch( type, "fat.*" ))
- {
- return_value = `vfat;
- }
- else if( type == "ntfs" )
- {
- return_value = `ntfs;
- }
- else if( type == "hfs" )
- {
- return_value = `hfs;
- }
- else if( type == "swap" )
- {
- return_value = `swap;
- }
- return( return_value );
+ global integer LabelLength(symbol fsys)
+ {
+ integer ret = 0;
+ integer id = fromSymbol(conv_fs, fsys);
+ any caps = LibStorage::FsCapabilities::new("LibStorage::FsCapabilities");
+ if (LibStorage::StorageInterface::getFsCapabilities(sint, id, caps))
+ ret = LibStorage::FsCapabilities::swig_labelLength_get(caps);
+ y2milestone("LabelLength fsys:%1 ret:%2", fsys, ret);
+ return ret;
}
-/*
-global define boolean SetVolumeLabel( string dev, map part )
- ``{
- boolean ret = false;
- string cmd = "";
- symbol fs = part["used_fs"]:`unknown;
- string label = part["label"]:"";
- y2milestone( "SetVolumeLabel dev:%1 fs:%2 label:%3", dev, fs, label );
- if( fs == `ext2 || fs == `ext3 )
- {
- cmd = sformat("/sbin/tune2fs -L \"%1\" %2", label, dev );
- }
- else if( fs == `xfs )
- {
- if( size(label)==0 )
- label = "--";
- cmd = sformat("/usr/sbin/xfs_admin -L %1 %2", label, dev );
- }
- else if( fs == `reiser )
- {
- cmd = sformat("/sbin/reiserfstune -l \"%1\" %2", label, dev );
- }
- if( size(cmd)>0 )
+ global map<string, boolean> IsResizable(symbol fsys)
+ {
+ map<string, boolean> ret = $[];
+ integer id = fromSymbol(conv_fs, fsys);
+ any caps = LibStorage::FsCapabilities::new("LibStorage::FsCapabilities");
+ if (LibStorage::StorageInterface::getFsCapabilities(sint, id, caps))
{
- y2milestone( "Excuting cmd:%1", cmd );
- ret = SCR::Execute(.target.bash, cmd ) == 0;
- // /sbin/reiserfstune always seems to return 1 even on success
- if( fs == `reiser )
- ret = true;
+ ret = $[
+ "extend" : LibStorage::FsCapabilities::swig_isExtendable_get(caps),
+ "shrink" : LibStorage::FsCapabilities::swig_isReduceable_get(caps),
+ "mount_extend" : LibStorage::FsCapabilities::swig_isExtendableWhileMounted_get(caps),
+ "mount_shrink" : LibStorage::FsCapabilities::swig_isReduceableWhileMounted_get(caps)
+ ];
}
- y2milestone( "SetVolumeLabel ret:%1", ret );
- return( ret );
- };
+ y2milestone("IsResizable fsys:%1 ret:%2", fsys, ret);
+ return ret;
+ }
-global define void DoChangedFsDefaults( map part )
- ``{
- string cmd = "";
- symbol fs = part["used_fs"]:`unknown;
- string dev = part["device"]:"";
- if( haskey( part, "loop_dev" ))
- {
- dev = part["loop_dev"]:"";
- }
- if( fs == `ext3 )
- {
- y2milestone( "dev:%1 fs:%2", dev, fs );
- cmd = sformat("/sbin/tune2fs -c %1 -i %2 %3", 500, "2m", dev );
- y2milestone( "Excuting cmd:%1", cmd );
- SCR::Execute(.target.bash, cmd );
- }
- };
-*/
+
+ global symbol FsToSymbol(string type)
+ {
+ symbol ret = `none;
+
+ if (type == "ext2")
+ ret = `ext2;
+ else if (type == "ext3")
+ ret = `ext3;
+ else if (type == "ext4")
+ ret = `ext4;
+ else if (type == "btrfs")
+ ret = `btrfs;
+ else if (regexpmatch(type, "reiser.*"))
+ ret = `reiser;
+ else if (type == "jfs")
+ ret = `jfs;
+ else if (type == "xfs" )
+ ret = `xfs;
+ else if (type == "vfat" || regexpmatch(type, "fat.*"))
+ ret = `vfat;
+ else if (type == "ntfs")
+ ret = `ntfs;
+ else if (type == "hfs")
+ ret = `hfs;
+ else if (type == "swap")
+ ret = `swap;
+
+ return ret;
+ }
global define boolean IsCryptMp( string mount, boolean prefix )
``{
- boolean ret = contains( crypt_m_points, mount );
+ boolean ret = contains( crypt_m_points(), mount );
if( !ret && prefix )
{
- list<string> mp = filter(string s, system_m_points, ``(s!="/") );
+ list<string> mp = filter(string s, system_m_points(), ``(s!="/") );
foreach(string s, mp,
``{
ret = ret || search( mount, s + "/" )==0;
@@ -1303,10 +1222,10 @@
global define boolean IsSystemMp( string mount, boolean prefix )
``{
- boolean ret = contains( system_m_points, mount );
+ boolean ret = contains( system_m_points(), mount );
if( !ret && prefix )
{
- list<string> mp = filter(string s, system_m_points, ``(s!="/") );
+ list<string> mp = filter(string s, system_m_points(), ``(s!="/") );
foreach(string s, mp,
``{
ret = ret || search( mount, s + "/" )==0;
@@ -1366,7 +1285,7 @@
``{
symbol fsys = part["used_fs"]:`none;
string fst_default = "";
- if( part["format"]:false && contains( [`ext2, `ext3, `reiser ], fsys ) )
+ if( part["format"]:false && contains( [`ext2, `ext3, `ext4, `reiser ], fsys ) )
{
fst_default = "acl,user_xattr";
}
@@ -1401,17 +1320,17 @@
fst_default = fst_default + ",codepage=" + code;
}
}
+
any dp = LibStorage::ContVolInfo::new("LibStorage::ContVolInfo");
string dev = part["device"]:"";
- LibStorage::StorageInterface::getContVolInfo( lib_id, dev, dp );
- integer t = LibStorage::ContVolInfo::swig_type_get(dp);
+ LibStorage::StorageInterface::getContVolInfo(sint, dev, dp);
+ integer t = LibStorage::ContVolInfo::swig_ctype_get(dp);
if( t == LibStorage::DISK() )
{
any infos = LibStorage::DiskInfo::new("LibStorage::DiskInfo");
- string disk = LibStorage::ContVolInfo::swig_cname_get(dp);
+ string disk = LibStorage::ContVolInfo::swig_cdevice_get(dp);
y2milestone( "DefaultFstabOptions disk:%1", disk );
- integer r = LibStorage::StorageInterface::getDiskInfo( lib_id, disk,
- infos );
+ integer r = LibStorage::StorageInterface::getDiskInfo(sint, disk, infos);
if( r==0 )
{
if(LibStorage::DiskInfo::swig_iscsi_get(infos))
@@ -1422,6 +1341,7 @@
}
}
}
+
y2milestone( "DefaultFstabOptions dev %3 fsys %1 is %2", fsys, fst_default, dev );
return( fst_default );
}
@@ -1433,7 +1353,7 @@
symbol fsys = part["used_fs"]:`none;
if( part["format"]:false )
{
- if( fsys==`ext3 )
+ if (contains([ `ext3, `ext4 ], fsys))
{
ret["opt_dir_index"] = $[ "option_str" : "-O dir_index",
"option_value" : true ];
@@ -1441,16 +1361,31 @@
"option_value" : true,
"option_cmd" : `tunefs ];
}
- if( Arch::board_pegasos() && contains( [`ext2, `ext3], fsys ) )
+ if( Arch::board_pegasos() && contains( [`ext2, `ext3, `ext4], fsys ) )
{
ret["opt_bytes_per_inode"] = $[ "option_str" : "-I",
"option_value" : "128" ];
}
- if( Arch::s390() && contains( [`ext2, `ext3], fsys ) )
+ if( Arch::s390() && contains( [`ext2, `ext3, `ext4], fsys ) )
{
ret["opt_blocksize"] = $[ "option_str" : "-b",
"option_value" : "4096" ];
}
+ if( contains( [`ext2, `ext3, `ext4], fsys ) )
+ {
+ if( Arch::s390() )
+ {
+ ret["opt_blocksize"] = $[ "option_str" : "-b",
+ "option_value" : "4096" ];
+ }
+ float f = (1048576.0 / (part["size_k"]:0)) * 100;
+ if( f > 5 )
+ f = 5;
+ if( f < 0.1 )
+ f = 0.1;
+ ret["opt_reserved_blocks"] = $[ "option_str" : "-m",
+ "option_value" : tostring( f, 1 ) ];
+ }
}
y2milestone( "DefaultFormatOptions fsys %1 fmt %2 is %3", fsys,
part["format"]:false, ret );
@@ -1509,65 +1444,60 @@
return( ret );
}
-global define map GetFstabDefaultMap( string key )
- ``{
- return( FstabDefaultMap[key]:$[] );
+
+ global map GetFstabDefaultMap(string key)
+ {
+ return FstabDefaultMap[key]:$[];
}
-global define string GetFstabDefaultMntops( string key )
- ``{
- map m = GetFstabDefaultMap( key );
- return( m["mntops"]:"" );
+ global list<string> GetFstabDefaultList(string key)
+ {
+ map m = GetFstabDefaultMap(key);
+ return [ m["spec"]:"", m["mount"]:"", m["vfstype"]:"", m["mntops"]:"",
+ tostring(m["freq"]:0), tostring(m["passno"]:0) ];
}
-global define list GetFstabDefaultList( string key )
- ``{
- map m = GetFstabDefaultMap( key );
- return( [ m["spec"]:"", m["mount"]:"", m["vfstype"]:"", m["mntops"]:"",
- tostring(m["freq"]:0), tostring(m["passno"]:0) ] );
+
+ global boolean CanMountRo(map part)
+ {
+ const list<symbol> no_fs = [ `tmpfs, `swap ];
+ return !contains(no_fs, part["used_fs"]:`unknown);
}
-global define boolean CanDoQuota( map part )
- ``{
- list quota_fs = [ `ext2, `ext3, `reiser, `xfs ];
- return( contains( quota_fs, part["used_fs"]:`unknown ));
+ global boolean CanDoQuota(map part)
+ {
+ const list<symbol> quota_fs = [ `ext2, `ext3, `ext4, `btrfs, `reiser, `xfs ];
+ return contains(quota_fs, part["used_fs"]:`unknown);
}
-global define boolean HasQuota( map part )
- ``{
- boolean ret = false;
- list<string> opts = splitstring( part["fstopt"]:"", "," );
- integer i=0;
- while( !ret && i<size(opts) )
- {
- ret = opts[i]:""=="usrquota" || opts[i]:""=="grpquota" ||
- search(opts[i]:"","usrjquota=")==0 ||
- search(opts[i]:"","grpjquota=")==0;
- i = i+1;
- }
- return( ret );
+ global boolean HasQuota(map part)
+ {
+ list<string> opts = splitstring(part["fstopt"]:"", ",");
+ return find(string opt, opts, {
+ return opt == "usrquota" || opt == "grpquota" || search(opt, "usrjquota=") == 0 ||
+ search(opt, "grpjquota=") == 0;
+ }) != nil;
}
-global define string RemoveQuotaOpts( string fst_opts )
+ global string RemoveQuotaOpts(string fst_opts)
{
- list<string> opts = splitstring( fst_opts, "," );
- opts = filter( string o, opts,
- ``( o!="usrquota" && o!="grpquota" &&
- search(o,"usrjquota=")!=0 && search(o,"grpjquota=")!=0 &&
- search(o,"jqfmt=")!=0 ));
- return( mergestring( opts, "," ));
- }
-
-global define string AddQuotaOpts( map part, string fst_opts )
- {
- string ret = RemoveQuotaOpts( fst_opts );
- list journal = [ `ext3, `reiser ];
- if( contains( journal, part["used_fs"]:`unknown ))
- ret = ret + ",usrjquota=aquota.user,grpjquota=aquota.group,jqfmt=vfsv0";
- else
- ret = ret + ",usrquota,grpquota";
- return( ret );
+ list<string> opts = splitstring(fst_opts, ",");
+ opts = filter(string opt, opts, {
+ return opt != "usrquota" && opt != "grpquota" && search(opt, "usrjquota=") != 0 &&
+ search(opt, "grpjquota=") != 0 && search(opt, "jqfmt=") != 0;
+ });
+ return mergestring(opts, ",");
}
+ global string AddQuotaOpts(map part, string fst_opts)
+ {
+ const list<symbol> journal = [ `ext3, `ext4, `btrfs, `reiser ];
+ string ret = RemoveQuotaOpts(fst_opts);
+ if (contains(journal, part["used_fs"]:`unknown))
+ ret = ret + ",usrjquota=aquota.user,grpjquota=aquota.group,jqfmt=vfsv0";
+ else
+ ret = ret + ",usrquota,grpquota";
+ return ret;
+ }
}
Modified: branches/SuSE-Code-11-SP2-Branch/storage/storage/src/modules/Makefile.am
URL: http://svn.opensuse.org/viewcvs/yast/branches/SuSE-Code-11-SP2-Branch/stora…
==============================================================================
--- branches/SuSE-Code-11-SP2-Branch/storage/storage/src/modules/Makefile.am (original)
+++ branches/SuSE-Code-11-SP2-Branch/storage/storage/src/modules/Makefile.am Tue May 17 13:39:44 2011
@@ -15,7 +15,10 @@
StorageControllers.ycp \
StorageDevices.ycp \
StorageFields.ycp \
+ StorageIcons.ycp \
+ StorageProposal.ycp \
StorageSettings.ycp \
+ StorageUpdate.ycp \
TreePanel.ycp \
TabPanel.ycp \
MiniWorkflow.ycp \
Modified: branches/SuSE-Code-11-SP2-Branch/storage/storage/src/modules/MiniWorkflow.ycp
URL: http://svn.opensuse.org/viewcvs/yast/branches/SuSE-Code-11-SP2-Branch/stora…
==============================================================================
--- branches/SuSE-Code-11-SP2-Branch/storage/storage/src/modules/MiniWorkflow.ycp (original)
+++ branches/SuSE-Code-11-SP2-Branch/storage/storage/src/modules/MiniWorkflow.ycp Tue May 17 13:39:44 2011
@@ -17,6 +17,10 @@
string title = "";
+ global void SetTitle(string newtitle)
+ {
+ title = newtitle; //a je to!
+ }
global void SetContents(term contents, string help_text)
{
Modified: branches/SuSE-Code-11-SP2-Branch/storage/storage/src/modules/Partitions.ycp
URL: http://svn.opensuse.org/viewcvs/yast/branches/SuSE-Code-11-SP2-Branch/stora…
==============================================================================
--- branches/SuSE-Code-11-SP2-Branch/storage/storage/src/modules/Partitions.ycp (original)
+++ branches/SuSE-Code-11-SP2-Branch/storage/storage/src/modules/Partitions.ycp Tue May 17 13:39:44 2011
@@ -60,6 +60,8 @@
global string dmraid_name = "DM RAID";
global string dmmultipath_name = "DM Multipath";
global string nfs_name = "NFS";
+ global string btrfs_name = "BTRFS";
+ global string tmpfs_name = "TMPFS";
// filesystems for /win
global const list<integer> fsid_wintypes = [ 6, 11, 12, 14 ]; /* FAT32, Win95-Fat32, Win95LBA, Win95-Fat16 */
@@ -83,58 +85,24 @@
global const list<integer> no_windows = [ 0x12, 0x82, 0xde, fsid_gpt_boot, fsid_gpt_service,
fsid_gpt_msftres ];
- global integer minimal_needed_disksize = 400 * 1024 * 1024; // for installation of a minimal system
- integer minimal_needed_bootsize = 0;
+ map<symbol, integer> boot_size_k = $[];
symbol default_fs = `unknown;
symbol default_boot_fs = `unknown;
+
any sint = nil;
+
global void InitSlib(any value)
{
sint = value;
}
- global list<string> not_shown_partitions =
- [
- "Apple_partition_map",
- "Apple_Patches",
- "Apple_Driver",
- "Apple_Loader",
- "Apple_Boot",
- "Apple_Bootstrap",
- "Apple_FWDriver",
- "Apple_ProDOS"
- ];
-
global boolean EfiBoot()
{
- // TODO: move to libstorage
-
- boolean ret = false;
-
- if (Arch::ia64())
- {
- ret = true;
- }
- else
- {
- if (Stage::initial())
- {
- string tmp = (string) SCR::Read(.etc.install_inf.EFI);
- if (tmp != nil && tmp == "1")
- ret = true;
- }
- else
- {
- string tmp = (string) SCR::Read(.sysconfig.bootloader.LOADER_TYPE);
- if (tmp != nil && tmp == "elilo")
- ret = true;
- }
- }
-
+ boolean ret = LibStorage::StorageInterface::getEfiBoot(sint);
y2milestone("EfiBoot ret:%1", ret);
return ret;
}
@@ -152,10 +120,10 @@
if (default_fs == `unknown)
{
string tmp = (string) SCR::Read(.sysconfig.storage.DEFAULT_FS);
- if (tmp == nil || !contains([ "ext2", "ext3", "reiser", "xfs" ], tolower(tmp)))
- tmp = "ext3";
+ if (tmp == nil || !contains([ "ext2", "ext3", "ext4", "reiser", "xfs" ], tolower(tmp)))
+ tmp = "ext4";
- default_fs = symbolof(toterm(tolower(tmp)));
+ default_fs = tosymbol(tolower(tmp));
}
return default_fs;
}
@@ -165,7 +133,11 @@
{
if (default_boot_fs == `unknown)
{
- default_boot_fs = DefaultFs();
+
+ if( DefaultFs()!=`btrfs )
+ default_boot_fs = DefaultFs();
+ else
+ default_boot_fs = `ext4;
if (EfiBoot())
{
default_boot_fs = `vfat;
@@ -193,48 +165,58 @@
}
-global define integer MinimalNeededBootsize()
- ``{
- if( minimal_needed_bootsize == 0 )
+map<symbol, integer> BootSizeK()
+{
+ if (isempty(boot_size_k))
+ {
+ boot_size_k = $[ `proposed : 150 * 1024,
+ `minimal : 64 * 1024,
+ `maximal : 750 * 1024 ];
+
+ if (Arch::ia64())
{
- minimal_needed_bootsize = 64 * 1024 * 1024;
- if( Arch::ia64() )
- {
- minimal_needed_bootsize = 200*1024*1024;
- }
- else if( Arch::board_chrp() )
- {
- minimal_needed_bootsize = 200*1024*1024;
- }
- else if( Arch::board_prep() )
- {
- minimal_needed_bootsize = 200*1024*1024;
- }
- else if( Arch::board_iseries() )
- {
- minimal_needed_bootsize = 200*1024*1024;
- }
- else if( Arch::board_mac() )
- {
- minimal_needed_bootsize = 32*1024*1024;
- }
+ boot_size_k[`proposed] = 200 * 1024;
+ boot_size_k[`minimal] = 180 * 1024;
+ }
+ else if (Arch::board_chrp() || Arch::board_prep() || Arch::board_iseries())
+ {
+ boot_size_k[`proposed] = 200 * 1024;
+ boot_size_k[`minimal] = 180 * 1024;
+ }
+ else if (Arch::board_mac())
+ {
+ boot_size_k[`proposed] = 32 * 1024;
+ boot_size_k[`minimal] = 800;
}
- return( minimal_needed_bootsize );
- }
-global define integer MinimalRequiredBootsize()
- ``{
- integer need = MinimalNeededBootsize();
- integer ret = need;
- if( Arch::ia64() )
- ret = ret / 10 * 9;
- else if( Arch::board_mac() )
- ret = 800 * 1024;
- if( ret!=need )
- y2milestone( "MinimalRequiredBootsize ret %1 Req:%2", ret, need );
- return( ret );
+ y2milestone("BootSizeK boot_size_k:%1", boot_size_k);
}
+ return boot_size_k;
+}
+
+
+global integer MinimalNeededBootsize()
+{
+ return 1024 * BootSizeK()[`proposed]:0;
+}
+
+global integer ProposedBootsize()
+{
+ return 1024 * BootSizeK()[`proposed]:0;
+}
+
+global integer MinimalBootsize()
+{
+ return 1024 * BootSizeK()[`minimal]:0;
+}
+
+global integer MaximalBootsize()
+{
+ return 1024 * BootSizeK()[`maximal]:0;
+}
+
+
global define integer BootCyl()
``{
if( boot_cyl == 0 )
@@ -319,7 +301,7 @@
{
ret = true;
}
- y2milestone( "NeedBoot ret %1", ret );
+ y2milestone( "NeedBoot ret:%1", ret );
return ret;
}
@@ -344,20 +326,14 @@
return( !IsDosWinNtPartition( fsid ) && fsid==fsid_swap );
}
-global define integer SwapSizeMb( integer slot_size )
- ``{
- integer swap_size = 0;
+global integer SwapSizeMb( integer slot_size )
+ {
+ map mem_info_map = (map) SCR::Read(.proc.meminfo);
+ integer mem = mem_info_map["memtotal"]:0 / 1024;
+ y2milestone("mem_info_map:%1 mem:%2", mem_info_map, mem);
// a good approach swap == mem x 2
- integer mem = 256;
- if( !Mode::test () )
- {
- map mem_info_map = (map) SCR::Read(.proc.meminfo);
- y2milestone( "mem_info_map %1", mem_info_map );
- mem = mem_info_map["memtotal"]:0;
- mem = mem / 1024;
- }
- if( mem == 0 || mem == nil ) mem = 64;
+ integer swap_size = 0;
if( slot_size==0 )
{
@@ -434,7 +410,7 @@
y2milestone( "SwapSizeMb mem %1 slot_size %2 swap_size %3", mem,
slot_size, swap_size );
return( swap_size );
- };
+ }
global define boolean IsResizable( integer fsid )
@@ -516,8 +492,8 @@
* Return a list with all mounted partition
* @return list<map>
*/
-global define list<map> CurMounted()
- ``{
+global list<map> CurMounted()
+{
SCR::UnmountAgent (.proc.mounts);
SCR::UnmountAgent (.proc.swaps);
SCR::UnmountAgent (.etc.mtab);
@@ -525,6 +501,12 @@
list<map> swaps = (list<map>) SCR::Read(.proc.swaps );
list<map> mtab = (list<map>) SCR::Read(.etc.mtab );
+ if (mounts == nil || swaps == nil || mtab == nil)
+ {
+ y2error("failed to read .proc.mounts or .proc.swaps or .etc.mtab");
+ return [];
+ }
+
foreach(map swap, swaps,
``{
map swap_entry = $[
@@ -591,7 +573,7 @@
});
y2milestone( "CurMounted all mounts %1", ret);
return ret;
- };
+};
global define map GetFstab( string pathname )
@@ -721,53 +703,47 @@
}
-map capabilities = $[ "msdos" : $[ "extended" : true,
- "max_primary" : 4 ],
- "gpt" : $[ "max_primary" : 16 ],
- "mac" : $[ "max_primary" : 16 ],
- "amiga" : $[ "max_primary" : 16 ],
- "sun" : $[ "max_primary" : 8 ],
- "bsd" : $[ "max_primary" : 8 ],
- "dasd" : $[ "max_primary" : 3 ]
- ];
-
-global define integer MaxPrimary( string label )
- ``{
- integer ret = capabilities[label,"max_primary"]:4;
- y2milestone( "MaxPrimary label:%1 ret:%2", label, ret );
- return( ret );
+ global integer MaxPrimary(string dlabel)
+ {
+ integer ret = 0;
+ any caps = LibStorage::DlabelCapabilities::new("LibStorage::DlabelCapabilities");
+ if (LibStorage::StorageInterface::getDlabelCapabilities(sint, dlabel, caps))
+ ret = LibStorage::DlabelCapabilities::swig_maxPrimary_get(caps);
+ y2milestone("MaxPrimary dlabel:%1 ret:%2", dlabel, ret);
+ return ret;
}
-global define integer MaxLogical( string device )
- ``{
- integer ret = 15;
- if( search( device, "/dev/hd" )==0 )
- {
- ret = 63;
- }
- else if( search( device, "/dev/rd/c" )==0 )
- {
- ret = 7;
- }
- y2milestone( "MaxLogical:%1 ret:%2", device, ret );
- return( ret );
+
+ global boolean HasExtended(string dlabel)
+ {
+ boolean ret = false;
+ any caps = LibStorage::DlabelCapabilities::new("LibStorage::DlabelCapabilities");
+ if (LibStorage::StorageInterface::getDlabelCapabilities(sint, dlabel, caps))
+ ret = LibStorage::DlabelCapabilities::swig_extendedPossible_get(caps);
+ y2milestone("HasExtended dlabel:%1 ret:%2", dlabel, ret);
+ return ret;
}
-global define boolean HasExtended( string label )
- ``{
- boolean ret = capabilities[label,"extended"]:false;
- y2milestone( "HasExtended label:%1 ret:%2", label, ret );
- return( ret );
+
+ global integer MaxLogical(string dlabel)
+ {
+ integer ret = 0;
+ any caps = LibStorage::DlabelCapabilities::new("LibStorage::DlabelCapabilities");
+ if (LibStorage::StorageInterface::getDlabelCapabilities(sint, dlabel, caps))
+ ret = LibStorage::DlabelCapabilities::swig_maxLogical_get(caps);
+ y2milestone("MaxLogical dlabel:%1 ret:%2", dlabel, ret);
+ return ret;
}
-global integer MaxSectors(string dlabel)
+
+ global integer MaxSectors(string dlabel)
{
- integer ret = 0;
- any caps = LibStorage::DlabelCapabilities::new("LibStorage::DlabelCapabilities");
- if (LibStorage::StorageInterface::getDlabelCapabilities(sint, dlabel, caps))
- ret = LibStorage::DlabelCapabilities::swig_maxSectors_get(caps);
- y2milestone("MaxSizeK dlabel:%1 ret:%2", dlabel, ret);
- return ret;
+ integer ret = 0;
+ any caps = LibStorage::DlabelCapabilities::new("LibStorage::DlabelCapabilities");
+ if (LibStorage::StorageInterface::getDlabelCapabilities(sint, dlabel, caps))
+ ret = LibStorage::DlabelCapabilities::swig_maxSectors_get(caps);
+ y2milestone("MaxSizeK dlabel:%1 ret:%2", dlabel, ret);
+ return ret;
}
Modified: branches/SuSE-Code-11-SP2-Branch/storage/storage/src/modules/Storage.ycp
URL: http://svn.opensuse.org/viewcvs/yast/branches/SuSE-Code-11-SP2-Branch/stora…
==============================================================================
--- branches/SuSE-Code-11-SP2-Branch/storage/storage/src/modules/Storage.ycp (original)
+++ branches/SuSE-Code-11-SP2-Branch/storage/storage/src/modules/Storage.ycp Tue May 17 13:39:44 2011
@@ -23,27 +23,26 @@
*/
{
module "Storage";
+
textdomain "storage";
import "Arch";
- import "AsciiFile";
- import "Encoding";
import "Directory";
import "FileSystems";
import "FileUtils";
import "Installation";
import "Label";
+ import "Icon";
import "Mode";
import "Partitions";
import "Popup";
+ import "Report";
import "Misc";
import "HTML";
import "StorageDevices";
import "StorageClients";
- import "ProductFeatures";
import "Stage";
import "String";
- import "Region";
import "Hotplug";
import "LibStorage";
@@ -67,11 +66,28 @@
import "LibStorage::DmPartCoInfo";
import "LibStorage::DmraidCoInfo";
import "LibStorage::DmmultipathCoInfo";
+ import "LibStorage::BtrfsInfo";
+ import "LibStorage::TmpfsInfo";
import "LibStorage::PartitionSlotInfo";
import "LibStorage::CommitInfo";
+ import "LibStorage::DlabelCapabilities";
+ import "LibStorage::ContVolInfo";
+ import "LibStorage::ResizeInfo";
+ import "LibStorage::ContentInfo";
import "LibStorage::Environment";
+// simple resize functionality - dialog to set size of Linux and Windows before proposal
+
+global string resize_partition = nil;
+
+global map resize_partition_data = nil;
+
+global integer resize_cyl_size = nil;
+
+// end of resizing functions
+
+
map<string,any> conv_ctype =
$[ "def_sym" : `CT_UNKNOWN,
"def_int" : LibStorage::CUNKNOWN(),
@@ -83,7 +99,9 @@
LibStorage::DMMULTIPATH() : `CT_DMMULTIPATH,
LibStorage::DM() : `CT_DM,
LibStorage::MDPART() : `CT_MDPART,
- LibStorage::NFSC() : `CT_NFS
+ LibStorage::NFSC() : `CT_NFS,
+ LibStorage::BTRFSC() : `CT_BTRFS,
+ LibStorage::TMPFSC() : `CT_TMPFS
]
];
@@ -95,7 +113,8 @@
LibStorage::UB_DMRAID() : `UB_DMRAID,
LibStorage::UB_DMMULTIPATH() : `UB_DMMULTIPATH,
LibStorage::UB_MDPART() : `UB_MDPART,
- LibStorage::UB_DM() : `UB_DM
+ LibStorage::UB_DM() : `UB_DM,
+ LibStorage::UB_BTRFS() : `UB_BTRFS
]
];
@@ -149,45 +168,51 @@
"multipath" : LibStorage::MULTIPATH() ];
map<string,any> conv_mdparity =
- $[ "def_sym" : `par_none,
- "def_int" : LibStorage::PAR_NONE(),
+ $[ "def_sym" : `par_default,
+ "def_int" : LibStorage::PAR_DEFAULT(),
"m" : $[ LibStorage::LEFT_ASYMMETRIC() : `left_asymmetric,
LibStorage::LEFT_SYMMETRIC() : `left_symmetric,
LibStorage::RIGHT_ASYMMETRIC() : `right_asymmetric,
- LibStorage::RIGHT_SYMMETRIC() : `right_symmetric
+ LibStorage::RIGHT_SYMMETRIC() : `right_symmetric,
+ LibStorage::PAR_FIRST() : `par_first,
+ LibStorage::PAR_LAST() : `par_last,
+ LibStorage::LEFT_ASYMMETRIC_6() : `left_asymmetric_6,
+ LibStorage::LEFT_SYMMETRIC_6() : `left_symmetric_6,
+ LibStorage::RIGHT_ASYMMETRIC_6() : `right_asymmetric_6,
+ LibStorage::RIGHT_SYMMETRIC_6() : `right_symmetric_6,
+ LibStorage::PAR_FIRST_6() : `par_first_6,
+ LibStorage::PAR_NEAR_2() : `par_near_2,
+ LibStorage::PAR_OFFSET_2() : `par_offset_2,
+ LibStorage::PAR_FAR_2() : `par_far_2,
+ LibStorage::PAR_NEAR_3() : `par_near_3,
+ LibStorage::PAR_OFFSET_3() : `par_offset_3,
+ LibStorage::PAR_FAR_3() : `par_far_3
]
];
map<string,integer> conv_parstring =
- $[ "left_asymmetric" : LibStorage::LEFT_ASYMMETRIC(),
+ $[ "default" : LibStorage::PAR_DEFAULT(),
+ "left_asymmetric" : LibStorage::LEFT_ASYMMETRIC(),
"left_symmetric" : LibStorage::LEFT_SYMMETRIC(),
"right_asymmetric" : LibStorage::RIGHT_ASYMMETRIC(),
- "right_symmetric" : LibStorage::RIGHT_SYMMETRIC() ];
-
-map<symbol, integer> conv_imsm_driver =
- $[ `IMSM_UNDECIDED : LibStorage::IMSM_UNDECIDED(),
- `IMSM_DMRAID : LibStorage::IMSM_DMRAID(),
- `IMSM_MDADM : LibStorage::IMSM_MDADM() ];
+ "right_symmetric" : LibStorage::RIGHT_SYMMETRIC(),
+ "parity_first" : LibStorage::PAR_FIRST(),
+ "parity_last" : LibStorage::PAR_LAST(),
+ "left_asymmetric_6" : LibStorage::LEFT_ASYMMETRIC_6(),
+ "left_symmetric_6" : LibStorage::LEFT_SYMMETRIC_6(),
+ "right_asymmetric_6" : LibStorage::RIGHT_ASYMMETRIC_6(),
+ "right_symmetric_6" : LibStorage::RIGHT_SYMMETRIC_6(),
+ "parity_first_6" : LibStorage::PAR_FIRST_6(),
+ "n2" : LibStorage::PAR_NEAR_2(),
+ "o2" : LibStorage::PAR_OFFSET_2(),
+ "f2" : LibStorage::PAR_FAR_2(),
+ "n3" : LibStorage::PAR_NEAR_3(),
+ "o3" : LibStorage::PAR_OFFSET_3(),
+ "f3" : LibStorage::PAR_FAR_3()
+ ];
-map DiskMapVersion = $[];
-map DiskMap = $[];
-map type_order = $[ `CT_DISK : 0, `CT_MD : 1, `CT_MDPART : 2, `CT_DMRAID : 3,
- `CT_DMMULTIPATH : 4, `CT_LOOP : 5, `CT_DM : 6, `CT_LVM : 7,
- `CT_NFS : 8 ];
-list<string> hw_packages = [];
-list<string> no_propose_disks = nil;
-
-boolean proposal_home = false;
-boolean proposal_lvm = false;
-boolean proposal_encrypt = false;
-string proposal_password = "";
-
-map<string, any> cfg_xml = $[];
-string part_insts = "";
-
-// bnc#477778 - Updating SLES 10 SP2 (GA+) to SLES 11 RC4 produces multiple identical grub boot menu entries
-// flag indicates calling StorageUpdate::Update()
-boolean called_update = false;
+map<integer,string> rev_conv_parstring =
+ mapmap( string s, integer i, conv_parstring, {return$[ i: s ];});
map<string,any> conv_partalign =
$[ "def_sym" : `align_optimal,
@@ -197,44 +222,33 @@
]
];
+map<string,any> conv_transport =
+ $[ "def_sym" : `unknown,
+ "def_int" : LibStorage::TUNKNOWN(),
+ "m" : $[ LibStorage::SBP() : `sbp,
+ LibStorage::ATA() : `ata,
+ LibStorage::FC() : `fc,
+ LibStorage::ISCSI() : `iscsi,
+ LibStorage::SAS() : `sas,
+ LibStorage::SATA() : `sata,
+ LibStorage::SPI() : `spi,
+ LibStorage::USB() : `usb
+ ]
+ ];
+
+
+map DiskMapVersion = $[];
+map DiskMap = $[];
+
+const map<symbol, integer> type_order = $[ `CT_DISK : 0, `CT_MD : 1, `CT_MDPART : 2,
+ `CT_DMRAID : 3, `CT_DMMULTIPATH : 4, `CT_LOOP : 5, `CT_DM : 6, `CT_LVM : 7,
+ `CT_BTRFS : 8, `CT_NFS : 9, `CT_TMPFS : 10 ];
+
+list<string> hw_packages = [];
- /**
- * Returns Device Name
- *
- * @param string Disk
- * @param any partition
- * @return string device name
- *
- * @example Storage::GetDeviceName ("/dev/md", 1)
- */
-global define string GetDeviceName( string disk, any partition )
- {
- string ret = disk;
-
- if( is( partition, integer ) )
- {
- if( search( disk, "/dev/cciss/" )==0 ||
- search( disk, "/dev/ida/" )==0 ||
- search( disk, "/dev/ataraid/" )==0 ||
- search( disk, "/dev/etherd/" )==0 ||
- (search(disk, "/dev/md") == 0 && disk != "/dev/md") ||
- search( disk, "/dev/rd/" )==0 )
- {
- ret = ret + "p";
- }
- else if( search( disk, "/dev/mapper/" )==0 )
- {
- ret = ret + "_part";
- }
- ret = ret + sformat( "%1", partition );
- }
- else if( size( (string)partition )>0 )
- {
- ret = ret + "/" + (string)partition;
- }
- return( ret );
- };
+string part_insts = nil;
+global map<string, map> ReReadTargetMap();
global boolean IsKernelDeviceName(string device)
{
@@ -243,27 +257,6 @@
substring(device, 0, 13) != "/dev/disk/by-";
}
-/**
- * Returns ...
- *
- * @param string dev
- * @return string EvmsDevDisk
- */
-/*
-global string EvmsDevDisk( string dev )
- {
- string ret = "/dev/" + substring( dev, 10 );
- integer pos = search( ret, "!" );
- y2milestone( "EvmsDevDisk pos:%1", pos );
- if( pos!=nil )
- ret = String::Replace( ret, "!", "/" );
- pos = search( ret, "|" );
- y2milestone( "EvmsDevDisk pos:%1", pos );
- if( pos!=nil )
- ret = String::Replace( ret, "|", "/" );
- return( ret );
- }
-*/
/* Storage = TargetMap
/* Storage = $[ "targets" : $[],
@@ -318,7 +311,7 @@
{
any env = LibStorage::Environment::new("LibStorage::Environment", readonly);
LibStorage::Environment::swig_testmode_set(env, Mode::test());
- LibStorage::Environment::swig_autodetect_set(env, true);
+ LibStorage::Environment::swig_autodetect_set(env, !Mode::test());
LibStorage::Environment::swig_instsys_set(env, Stage::initial() || Mode::repair());
integer locker_pid = 0;
@@ -356,14 +349,6 @@
}
-symbol imsm_driver = `IMSM_UNDECIDED;
-
-global void SetImsmDriver(symbol val)
-{
- imsm_driver = val;
-}
-
-
list<map> getContainers();
global boolean InitLibstorage(boolean readonly)
@@ -373,68 +358,88 @@
y2milestone("InitLibstorage");
sint = CreateInterface(readonly);
- if (sint == nil) {
+ if (sint == nil)
+ {
y2error("Storage::CreateInterface failed");
return false;
}
+ StorageClients::InstallCallbacks(sint);
+
if (Stage::initial())
{
LibStorage::StorageInterface::setDetectMountedVolumes(sint, false);
LibStorage::StorageInterface::setRootPrefix(sint, Installation::destdir);
}
- LibStorage::StorageInterface::setEfiBoot(sint, Partitions::EfiBoot());
-
- // LibStorage::StorageInterface::setImsmDriver(sint, conv_imsm_driver[imsm_driver]:LibStorage::IMSM_UNDECIDED());
-
conts = getContainers();
y2milestone("InitLibstorage conts:%1", conts);
FileSystems::InitSlib(sint);
+ Partitions::InitSlib(sint);
return true;
}
+global void FinishLibstorage()
+{
+ if (sint == nil)
+ return;
+
+ y2milestone("FinishLibstorage");
+ LibStorage::destroyStorageInterface(sint);
+ sint = nil;
+}
+
+
+global integer ClassicStringToByte(string str)
+{
+ integer bytes = 0;
+ if (!LibStorage::humanStringToByte(str, true, bytes))
+ y2error("cannot parse %1", str);
+ return bytes;
+}
+
+
global string ByteToHumanString(integer bytes)
{
- return LibStorage::StorageInterface::byteToHumanString(sint, bytes, false, 2, false);
+ return LibStorage::byteToHumanString(bytes, false, 2, false);
}
-global string KByteToHumanString(integer kbytes)
+global string KByteToHumanString(integer bytes_k)
{
- return LibStorage::StorageInterface::byteToHumanString(sint, kbytes * 1024, false, 2, false);
+ return LibStorage::byteToHumanString(bytes_k * 1024, false, 2, false);
}
-global string ByteToHumanStringWithPrecision(integer bytes, integer precision, boolean omit_zeroes)
+global string ByteToHumanStringOmitZeroes(integer bytes)
{
- return LibStorage::StorageInterface::byteToHumanString(sint, bytes, false, precision, omit_zeroes);
+ return LibStorage::byteToHumanString(bytes, false, 2, true);
}
-global string KByteToHumanStringWithPrecision(integer kbytes, integer precision, boolean omit_zeroes)
+global string KByteToHumanStringOmitZeroes(integer bytes_k)
{
- return LibStorage::StorageInterface::byteToHumanString(sint, kbytes * 1024, false, precision, omit_zeroes);
+ return LibStorage::byteToHumanString(bytes_k * 1024, false, 2, true);
}
global boolean HumanStringToByte(string str, integer& bytes)
{
integer i = 0; bytes = i; // bnc #408829 and #408891
- boolean ret = LibStorage::StorageInterface::humanStringToByte(sint, str, false, bytes);
+ boolean ret = LibStorage::humanStringToByte(str, false, bytes);
y2milestone("HumanStringToByte ret:%1 str:%2 bytes:%3", ret, str, bytes);
return ret;
}
-global boolean HumanStringToKByte(string str, integer& kbytes)
+global boolean HumanStringToKByte(string str, integer& bytes_k)
{
integer bytes = 0; // bnc #408829
- boolean ret = LibStorage::StorageInterface::humanStringToByte(sint, str, false, bytes);
- kbytes = bytes / 1024;
- y2milestone("HumanStringToKByte ret:%1 str:%2 kbytes:%3", ret, str, kbytes);
+ boolean ret = LibStorage::humanStringToByte(str, false, bytes);
+ bytes_k = bytes / 1024;
+ y2milestone("HumanStringToKByte ret:%1 str:%2 bytes_k:%3", ret, str, bytes_k);
return ret;
}
@@ -468,7 +473,47 @@
}
+ /**
+ * Returns Device Name
+ *
+ * @param string Disk
+ * @param any partition
+ * @return string device name
+ *
+ * @example Storage::GetDeviceName("/dev/md", 1)
+ * @example Storage::GetDeviceName("/dev/system", "root")
+ */
+ global string GetDeviceName(string disk, any partition)
+ {
+ string ret = disk;
+ if (is(partition, integer))
+ {
+ ret = LibStorage::StorageInterface::getPartitionName(sint, disk, (integer) partition);
+ }
+ else if (size((string) partition ) > 0)
+ {
+ ret = ret + "/" + (string) partition;
+ }
+ return ret;
+ }
+
+
+ global boolean SetIgnoreFstab(string device, boolean val)
+ {
+ return LibStorage::StorageInterface::setIgnoreFstab(sint, device, val) == 0;
+ }
+
+
+ global boolean GetIgnoreFstab(string device, boolean& val)
+ {
+ return LibStorage::StorageInterface::getIgnoreFstab(sint, device, val) == 0;
+ }
+
+
global define map<string,map> GetTargetMap();
+global define void SetTargetMap( map<string,map> target );
+global define map<string,map> SetPartitionData( map<string,map> target, string device,
+ string key, any value );
define list<map> GetDiskPartitionTg( string device, map<string,map> tg )
@@ -605,21 +650,11 @@
}
else if( search( device, "/dev/md" )==0 && size(ls)==2 )
{
- integer pos = find(device, "p");
- y2milestone("device:%1 pos:%2", device, pos);
- if (pos == -1)
- dlen = 7;
- else
+ integer pos = search(device, "p");
+ if (pos != nil)
dlen = pos;
- }
- else if( search( device, "/dev/mmcblk" )==0 && size(ls)==2 )
- {
- integer pos = find(device, "p");
- y2milestone("device:%1 pos:%2", device, pos);
- if (pos == -1)
- dlen = size(device);
else
- dlen = pos;
+ dlen = 7;
}
else if( search( device, "/dev/loop" )==0 )
{
@@ -629,11 +664,7 @@
{
dlen = 12;
}
- else if( search( device, "/dev/rd/" )==0 ||
- search( device, "/dev/cciss/" )==0 ||
- search( device, "/dev/ataraid/" )==0 ||
- search( device, "/dev/etherd/" )==0 ||
- search( device, "/dev/ida/" )==0 )
+ else if(LibStorage::StorageInterface::getPartitionPrefix(sint, device) == "p")
{
integer pos = findlastof( device, "p" );
dlen = size(device);
@@ -712,12 +743,6 @@
{
ret = [ $[ "disk" : "/dev/nfs", "nr" : device ]];
}
- if( size(ret)>1 )
- {
- list<map> a = filter( map m, ret, ``(search(m["disk"]:"","/dev/evms")!=0));
- list<map> b = filter( map m, ret, ``(search(m["disk"]:"","/dev/evms")==0));
- ret = (list<map>)merge( a, b );
- }
y2debug( "GetDiskPartitionTg device:%1 ret:%2", device, ret );
return( ret );
};
@@ -763,7 +788,7 @@
list<map> part = filter( map p, tg[disk,"partitions"]:[],
``(p["device"]:""==device ));
part = filter( map p, part, ``(!p["delete"]:false));
- if( size(part)==0 )
+ if( size(part)==0 && is( m["nr"]:(any)0, integer ))
{
part = filter( map p, tg[disk,"partitions"]:[],
``(p["nr"]:-1==m["nr"]:0 ));
@@ -821,78 +846,10 @@
/**
- * Sets partition 'part' into the 'tg' map and returns changed 'tg' map
- *
- * @param map <string,map> tg
- * @param map part
- * @return map <string,map> changed tg
- */
-/*
-global define map<string,map> SetPartition( map<string,map> tg, map part )
- ``{
- y2milestone( "SetPartition part=%1", part );
- map tmp = GetDiskPartitionTg( part["device"]:"", tg )[0]:$[];
- y2milestone( "SetPartition tmp=%1", tmp );
- string disk = tmp["disk"]:"";
- if( search(part["device"]:"", "/dev/evms")==0 && !haskey( tg, disk ) )
- {
- disk = "/dev/evms";
- }
- list r_part = filter(map p, tg[disk,"partitions"]:[],
- ``(p["device"]:"" != part["device"]:""));
- r_part = add( r_part, part );
- tg[disk,"partitions"] = r_part;
- return( tg );
- }
-*/
-
-/**
- * Find next free loop device.
- *
- * @param integer start (start with /dev/loop$number)
- * @return string loop_dev ( e.g.: /dev/loop1 )
- */
-/*
-global define string GetLoopDev( integer start )
- ``{
- if( Mode::test () )
- return "/dev/loop2";
-
- integer max_loop_dev= 15;
- integer loop_dev_nb = start;
- boolean found_free = false;
- string loop_dev = "";
-
- while( !found_free && loop_dev_nb <= max_loop_dev )
- {
- loop_dev = sformat("/dev/loop%1", loop_dev_nb );
- loop_dev_nb = loop_dev_nb + 1;
-
- // Test loop dev
- if( SCR::Execute(.target.bash , "/sbin/losetup 2>/dev/null " + loop_dev ) != 0 )
- found_free = true;
- }
-
- if( !found_free )
- {
- loop_dev = "";
- // internal error popup
- Popup::Error( _("Too many loop devices (cryptofs ...)") );
- y2error( "Too many loop devices");
- }
-
- y2milestone("ret \"%1\"",loop_dev);
-
- return( loop_dev );
- };
-*/
-
-
-/**
* Get List of swap partitions
* @return list List of swap partitions
*/
-global list SwappingPartitions()
+global list<string> SwappingPartitions()
{
SCR::UnmountAgent(.proc.swaps);
list<map> swaps = (list<map>) SCR::Read(.proc.swaps);
@@ -902,49 +859,51 @@
swaps = [];
}
swaps = filter(map e, swaps, ``(e["type"]:""=="partition"));
- list ret = maplist(map e, swaps, ``(Partitions::TranslateMapperName(e["file"]:"")));
+ list<string> ret = maplist(map e, swaps, ``(Partitions::TranslateMapperName(e["file"]:"")));
y2milestone("SwappingPartitions %1", ret);
return ret;
}
-global define list GetDestroyedLvmVgs( map<string,map> target )
- ``{
- list vgs = [];
- foreach(string diskdev, map disk, target,
- ``{
- foreach( map p, disk["partitions"]:[],
- ``{
- if( p["used_by_type"]:`UB_NONE==`UB_LVM && p["format"]:false )
- {
- vgs = union( vgs, [ p["used_by"]:"" ] );
- }
- });
- });
- vgs = sort( vgs );
- y2milestone( "GetDestroyedLvmVgs %1", vgs );
- return( vgs );
- }
-global define map<string,map> DeleteDestroyedLvmVgs( map<string,map> target )
- ``{
- list<string> vgs = maplist( string s, (list<string>)GetDestroyedLvmVgs( target ),
- ``("/dev/"+s));
- y2milestone( "DeleteDestroyedLvmVgs %1", vgs );
- foreach( string dev, vgs,
- ``{
- if( haskey( target, dev ))
- target[dev,"delete"] = true;
- target[dev,"partitions"] = maplist( map p, target[dev,"partitions"]:[],
- ``{
- if( haskey( p, "mount" ))
- p = remove( p, "mount" );
- return( p );
- });
- y2milestone( "DeleteDestroyedLvmVgs %1: %2", dev, target[dev]:$[] );
- });
- return( target );
+global boolean GetFreeInfo(string device, boolean get_resize, map<symbol, any>& resize_info,
+ boolean get_content, map<symbol, any>& content_info, boolean use_cache)
+{
+ resize_info = $[];
+ content_info = $[];
+
+ any tmp1 = LibStorage::ResizeInfo::new("LibStorage::ResizeInfo");
+ any tmp2 = LibStorage::ContentInfo::new("LibStorage::ContentInfo");
+
+ boolean ret = LibStorage::StorageInterface::getFreeInfo(sint, device, get_resize, tmp1,
+ get_content, tmp2, use_cache);
+
+ if (ret)
+ {
+ if (get_resize)
+ {
+ resize_info = $[
+ `df_free_k : LibStorage::ResizeInfo::swig_df_freeK_get(tmp1),
+ `resize_free_k : LibStorage::ResizeInfo::swig_resize_freeK_get(tmp1),
+ `used_k : LibStorage::ResizeInfo::swig_usedK_get(tmp1),
+ `resize_ok : LibStorage::ResizeInfo::swig_resize_ok_get(tmp1)
+ ];
+ }
+
+ if (get_content)
+ {
+ content_info = $[
+ `windows : LibStorage::ContentInfo::swig_windows_get(tmp2),
+ `efi : LibStorage::ContentInfo::swig_efi_get(tmp2),
+ `homes : LibStorage::ContentInfo::swig_homes_get(tmp2)
+ ];
+ }
}
+ y2milestone("GetFreeInfo device:%1 ret:%2", device, ret);
+ return ret;
+}
+
+
/**
* Returns map of free space per partition
*
@@ -953,34 +912,22 @@
* @param symbol used_fs
* @param boolean verbose
*/
-global define map GetFreeSpace( string device, integer testsize,
- symbol used_fs, boolean verbose )
- ``{
- if( Mode::test() )
- {
- integer wf = tointeger(tofloat(testsize) * 0.6);
- integer wu = tointeger(tofloat(testsize) * 0.4);
- integer ls = tointeger(tofloat(testsize) * 0.5);
- return( $[ "free" : wf, "used" : wu,
- "linux_size" : ls, "new_size": (wu + wf - ls) ] );
- }
-
- integer used = 0;
- integer resize_free = 0;
- integer df_free = 0;
- boolean win_disk = false;
- boolean efi = false;
-
- boolean r = false;
- r = LibStorage::StorageInterface::getFreeInfo( sint, device, resize_free,
- df_free, used, win_disk,
- efi, used_fs==`ntfs );
-
- resize_free = resize_free * 1024; // Byte
- df_free = df_free * 1024; // Byte
- used = used * 1024; // Byte
+global map GetFreeSpace(string device, symbol used_fs, boolean verbose)
+{
+ map<symbol, any> resize_info = $[];
+ map<symbol, any> content_info = $[];
+
+ boolean r = GetFreeInfo(device, true, resize_info, true, content_info, used_fs == `ntfs);
- if( used_fs == `ntfs && !r && verbose )
+ integer used = 1024 * resize_info[`used_k]:0;
+ integer resize_free = 1024 * resize_info[`resize_free_k]:0;
+ integer df_free = 1024 * resize_info[`df_free_k]:0;
+ boolean resize_ok = resize_info[`resize_ok]:false;
+
+ boolean win_disk = content_info[`windows]:false;
+ boolean efi = content_info[`efi]:false;
+
+ if( used_fs == `ntfs && (!r || !resize_ok) && verbose )
{
string cmd = sformat("/usr/sbin/ntfsresize -f -i '%1'", device);
y2milestone( "GetFreeSpace Executing cmd:%1", cmd );
@@ -1064,8 +1011,8 @@
"new_size":new_size ];
ret["ok"] = r;
y2milestone( "GetFreeSpace %1 ret %2", device, ret );
- return( ret );
- };
+ return ret;
+}
global integer GetUnusedPartitionSlots(string device, list<map> &slots)
@@ -1091,199 +1038,12 @@
}
-/**
- * Adds ... and returns the changed map
- *
- * @param map <string,map> targets
- * @return map <string,map> targets
- */
-global define map<string,map> AddWinInfo( map<string,map> targets )
- ``{
- y2milestone( "AddWinInfo called" );
- foreach(string disk, map data, targets,
- ``{
- targets[disk,"partitions"] =
- maplist(map p, data["partitions"]:[],
- ``{
- if( Partitions::IsDosWinNtPartition(p["fsid"]:0) &&
- contains( [ `ntfs, `vfat ], p["used_fs"]:`none ))
- {
- p["winfo"] = GetFreeSpace( p["device"]:"", 0,
- p["used_fs"]:`none, false );
- y2milestone( "AddWinInfo %1", p );
- }
- return( p );
- });
- });
- return( targets );
- };
-
-global define string SaveDumpPath( string name )``{
- string ret = Directory::tmpdir + "/" + name;
- y2debug( "name=%1 path=%2", name, ret );
- return ret;
- }
-
-// add mount point for all mounted partitions
-/**
- * Adds mountpoint info to the target map and returns the changed map
- *
- * @param map <string,map> target
- * @return map <string,map> target
- */
-global define map<string,map> AddMountPointInfo( map<string,map> target )
- ``{
- list<map> mounts = Partitions::CurMounted();
- foreach(string diskdev, map disk, target,
- ``{
- // variable renamed due to some interpreter problems
- list<map> tmp2 = disk["partitions"]:[];
- tmp2 = maplist(map part, tmp2,
- ``{
- map mt = find(map mp, mounts, ``(mp["spec"]:" "==part["device"]:"" ||
- mp["loop_on"]:" "==part["device"]:""));
- if( mt != nil )
- {
- part["mount"] = mt["file"]:"";
- if( part["noauto"]:false )
- {
- part["active"] = true;
- }
- }
- return( part );
- });
- disk["partitions"] = tmp2;
- target[diskdev] = disk;
- });
- return( target );
+ global string SaveDumpPath(string name)
+ {
+ string ret = Directory::tmpdir + "/" + name;
+ return ret;
}
-/*
-global define list FindFstabLines( map fstab, string mount, string device,
- string uuid, string label )
- ``{
- list<integer> lines = [];
- if( size(mount)>0 && mount != "swap" )
- {
- lines = AsciiFile::FindLineField( fstab, 1, mount );
- }
- if( size(lines)==0 )
- {
- lines = AsciiFile::FindLineField( fstab, 0, device );
- }
- if( size(lines)>1 )
- {
- uuid = "UUID=" + uuid;
- label = "LABEL=" + label;
- map<integer,map> tlines = AsciiFile::GetLines( fstab, lines );
- map<integer,map> nlist = filter(integer num, map line, tlines,
- ``( line["fields",0]:"" == device ||
- line["fields",0]:"" == uuid ||
- line["fields",0]:"" == label ));
- if( size(nlist)>0 )
- {
- lines = maplist( integer num, map line, nlist, ``(num));
- }
- }
- y2milestone( "lines %1", lines );
- return( lines );
- };
-*/
-
-// add info gotten from /etc/fstab to targetMap
-/*
-global define map<string,map> AddFstabInfo( map<string,map> target, boolean lineno )
- ``{
- y2milestone( "lineno=%1", lineno );
- map fstab = Partitions::GetFstab( "/etc/fstab" );
- map crtab = Partitions::GetCrypto( "/etc/cryptotab" );
- foreach(string diskdev, map disk, target,
- ``{
- list new_part = [];
- foreach(map part, disk["partitions"]:[],
- ``{
- list<string> rem = [];
- if( lineno )
- {
- rem = [ "fstabline", "crtabline" ];
- }
- else
- {
- rem = [ "mountby", "fstopt" ];
- }
- part = (map<string,any>)filter(string key, any val, (map<string,any>)part, ``(!contains( rem, key )));
- string mp = part["mount"]:"";
- if( size(part["ori_mount"]:"")>0 )
- {
- mp = part["ori_mount"]:"";
- }
- list lines = [];
- lines = FindFstabLines( fstab, mp, part["device"]:"",
- part["uuid"]:"", part["label"]:"" );
- if( size(lines)>0 )
- {
- if( lineno )
- {
- part["fstabline"] = lines[0]:-1;
- }
- else
- {
- map entry = AsciiFile::GetLine( fstab, lines[0]:-1 );
- if( entry["fields",3]:"defaults" != "defaults" )
- {
- part["fstopt"] = entry["fields",3]:"";
- }
- if( search(entry["fields",0]:"", "UUID=") != nil )
- {
- part["mountby"] = `uuid;
- }
- else if( search(entry["fields",0]:"", "LABEL=") != nil )
- {
- part["mountby"] = `label;
- }
- else if( search(entry["fields",0]:"", "/dev/disk/by-id/") != nil )
- {
- part["mountby"] = `id;
- }
- else if( search(entry["fields",0]:"", "/dev/disk/by-path/") != nil )
- {
- part["mountby"] = `path;
- }
- }
- }
- lines = AsciiFile::FindLineField( crtab, 2, mp );
- if( size(lines)==0 && diskdev!="/dev/loop" )
- {
- lines = AsciiFile::FindLineField( crtab, 1, part["device"]:"" );
- }
- if( size(lines)==0 && diskdev=="/dev/loop" )
- {
- lines = AsciiFile::FindLineField( crtab, 0, part["device"]:"" );
- }
- if( size(lines)>0 )
- {
- if( lineno )
- {
- part["crtabline"] = lines[0]:-1;
- }
- else
- {
- map entry = AsciiFile::GetLine( crtab, lines[0]:-1 );
- if( entry["fields",5]:"defaults" != "defaults" )
- {
- part["fstopt"] = entry["fields",5]:"";
- }
- }
- }
- y2milestone( "part=%1", part );
- new_part = add( new_part, part );
- });
- target[diskdev] = disk;
- target[diskdev,"partitions"] = new_part;
- });
- return( target );
- }
-*/
string convertFsOptionMapToString( map<any, map> fsopt, symbol cmd )
{
@@ -1319,7 +1079,7 @@
}
else if( is(option_value, boolean) && option_value != nil )
{
- if( (boolean) option_value )
+ if( size(option_str)>0 )
{
if( size(ret)>0 )
ret = ret + " ";
@@ -1361,17 +1121,30 @@
``{
map m = $[];
string os = o[`option_str]:"";
- if( !found && size(os)>0 && search( opts, os )==0 )
+ string nos = o[`option_false]:"";
+ boolean se_ok = false;
+ boolean found_os = false;
+ if( size(os)>0 && search( opts, os )==0 )
+ {
+ found_os = true;
+ se_ok = true;
+ }
+ else if( size(nos)>0 && search( opts, nos )==0)
+ {
+ found_os = false;
+ se_ok = true;
+ }
+ if( !found && se_ok )
{
found = true;
- m["option_str"] = os;
+ m["option_str"] = found_os?os:nos;
m["option_cmd"] = o[`option_cmd]:`mkfs;
if( o[`type]:`text==`boolean )
{
- m["option_value"] = true;
+ m["option_value"] = found_os;
ret[o[`query_key]:""] = m;
}
- opts = substring( opts, size(os) );
+ opts = substring( opts, found_os?size(os):size(nos) );
pos = findfirstnotof( opts, " \t" );
if( pos>0 )
opts = substring( opts, pos );
@@ -1441,12 +1214,16 @@
map diskMap( any dinfo, map d )
{
d["size_k"] = LibStorage::DiskInfo::swig_sizeK_get(dinfo);
- d["cyl_size"] = LibStorage::DiskInfo::swig_cylSizeB_get(dinfo);
+ d["cyl_size"] = LibStorage::DiskInfo::swig_cylSize_get(dinfo);
d["cyl_count"] = LibStorage::DiskInfo::swig_cyl_get(dinfo);
d["sector_size"] = LibStorage::DiskInfo::swig_sectorSize_get(dinfo);
d["label"] = LibStorage::DiskInfo::swig_disklabel_get(dinfo);
d["max_logical"] = LibStorage::DiskInfo::swig_maxLogical_get(dinfo);
d["max_primary"] = LibStorage::DiskInfo::swig_maxPrimary_get(dinfo);
+
+ integer t = LibStorage::DiskInfo::swig_transport_get(dinfo);
+ d["transport"] = toSymbol(conv_transport, t);
+
boolean bt = LibStorage::DiskInfo::swig_iscsi_get(dinfo);
if( bt )
d["iscsi"] = true;
@@ -1457,16 +1234,6 @@
d["dasdfmt"] = true;
else if( haskey( d, "dasdfmt" ))
d = remove( d, "dasdfmt" );
- string tmp = LibStorage::DiskInfo::swig_udevId_get(dinfo);
- if( size(tmp)>0 )
- d["udev_id"] = splitstring( tmp, " " );
- else if( haskey( d, "udev_id" ))
- d = remove( d, "udev_id" );
- tmp = LibStorage::DiskInfo::swig_udevPath_get(dinfo);
- if( size(tmp)>0 )
- d["udev_path"] = tmp;
- else if( haskey( d, "udev_path" ))
- d = remove( d, "udev_path" );
y2milestone( "diskMap ret:%1", d );
return( d );
}
@@ -1487,20 +1254,25 @@
map volumeMap( any vinfo, map p )
{
p["device"] = LibStorage::VolumeInfo::swig_device_get(vinfo);
+ string tmp = LibStorage::VolumeInfo::swig_crypt_device_get(vinfo);
+ if( size(tmp)>0 )
+ p["crypt_device"] = tmp;
p["size_k"] = LibStorage::VolumeInfo::swig_sizeK_get(vinfo);
p["name"] = LibStorage::VolumeInfo::swig_name_get(vinfo);
integer t = LibStorage::VolumeInfo::swig_fs_get(vinfo);
symbol fs = toSymbol( FileSystems::conv_fs, t );
- p["detected_fs"] = fs;
- if( fs != `unknown )
+ if( fs!=`unknown )
p["used_fs"] = fs;
+ t = LibStorage::VolumeInfo::swig_detected_fs_get(vinfo);
+ fs = toSymbol( FileSystems::conv_fs, t );
+ p["detected_fs"] = fs;
boolean tbool = LibStorage::VolumeInfo::swig_format_get(vinfo);
if( tbool )
p["format"] = true;
tbool = LibStorage::VolumeInfo::swig_create_get(vinfo);
if( tbool )
p["create"] = true;
- string tmp = LibStorage::VolumeInfo::swig_mount_get(vinfo);
+ tmp = LibStorage::VolumeInfo::swig_mount_get(vinfo);
if( size(tmp)>0 )
{
p["mount"] = tmp;
@@ -1514,8 +1286,9 @@
if( t!=LibStorage::UB_NONE() )
{
p["used_by_type"] = toSymbol( conv_usedby, t );
- p["used_by"] = LibStorage::VolumeInfo::swig_usedByName_get(vinfo);
p["used_by_device"] = LibStorage::VolumeInfo::swig_usedByDevice_get(vinfo);
+ p["used_by"] = [ $[ "type" : p["used_by_type"]:`UB_NONE,
+ "device" : p["used_by_device"]:"" ] ];
}
tmp = LibStorage::VolumeInfo::swig_fstab_options_get(vinfo);
if( size(tmp)>0 )
@@ -1529,7 +1302,7 @@
{
p["mkfs_opt"] = tmp;
p["fs_options"] =
- convertStringToFsOptionMap( tmp, p["detected_fs"]:`unknown, `mkfs );
+ convertStringToFsOptionMap( tmp, p["used_fs"]:`unknown, `mkfs );
}
else
{
@@ -1541,7 +1314,7 @@
{
p["tunefs_opt"] = tmp;
p["fs_options"] = union(p["fs_options"]:$[],
- convertStringToFsOptionMap( tmp, p["detected_fs"]:`unknown, `tunefs ));
+ convertStringToFsOptionMap( tmp, p["used_fs"]:`unknown, `tunefs ));
}
tmp = LibStorage::VolumeInfo::swig_dtxt_get(vinfo);
if( size(tmp)>0 )
@@ -1561,7 +1334,7 @@
if( tbool )
{
p["resize"] = true;
- p["orig_size_k"] = LibStorage::VolumeInfo::swig_OrigSizeK_get(vinfo);
+ p["orig_size_k"] = LibStorage::VolumeInfo::swig_origSizeK_get(vinfo);
}
tbool = LibStorage::VolumeInfo::swig_ignore_fs_get(vinfo);
if( tbool )
@@ -1569,6 +1342,14 @@
tmp = LibStorage::VolumeInfo::swig_loop_get(vinfo);
if( size(tmp)>0 )
p["loop"] = tmp;
+
+ tmp = LibStorage::VolumeInfo::swig_udevPath_get(vinfo);
+ if (!isempty(tmp))
+ p["udev_path"] = tmp;
+ tmp = LibStorage::VolumeInfo::swig_udevId_get(vinfo);
+ if (!isempty(tmp))
+ p["udev_id"] = splitstring(tmp, " ");
+
return( p );
}
@@ -1584,12 +1365,6 @@
boolean boot = LibStorage::PartitionAddInfo::swig_boot_get(info);
if( boot )
p["boot"] = true;
- string tmp = LibStorage::PartitionAddInfo::swig_udevId_get(info);
- if( size(tmp)>0 )
- p["udev_id"] = splitstring( tmp, " " );
- tmp = LibStorage::PartitionAddInfo::swig_udevPath_get(info);
- if( size(tmp)>0 )
- p["udev_path"] = tmp;
y2milestone( "partAddMap ret:%1", p );
return( p );
}
@@ -1624,6 +1399,11 @@
return p;
}
+global boolean HasRaidParity( string rt )
+ {
+ return( contains( [ "raid5", "raid6", "raid10" ], rt ));
+ }
+
map getContainerInfo( map c )
{
y2milestone( "getContainerInfo %1", c );
@@ -1660,12 +1440,6 @@
boolean boot = LibStorage::PartitionInfo::swig_boot_get(info);
if( boot )
p["boot"] = true;
- tmp = LibStorage::PartitionInfo::swig_udevId_get(info);
- if( size(tmp)>0 )
- p["udev_id"] = splitstring( tmp, " " );
- tmp = LibStorage::PartitionInfo::swig_udevPath_get(info);
- if( size(tmp)>0 )
- p["udev_path"] = tmp;
c["partitions"] = add( c["partitions"]:[], p );
});
}
@@ -1734,19 +1508,22 @@
y2warning( "disk \"%1\" ret:%2", c["device"]:"", ret );
list<string> ls = splitstring(LibStorage::MdPartCoInfo::swig_devices_get(infos), " ");
- y2milestone( "ls=%1", ls );
c["devices"] = ls;
- integer t = LibStorage::MdPartCoInfo::swig_level_get(infos);
+ ls = splitstring(LibStorage::MdPartCoInfo::swig_spares_get(infos), " ");
+ if (!isempty(ls))
+ c["spares"] = ls;
+
+ integer t = LibStorage::MdPartCoInfo::swig_type_get(infos);
c["raid_type"] = substring(sformat("%1", toSymbol(conv_mdtype, t)), 1);
- if (c["raid_type"]:"" == "raid5")
- {
+ if( HasRaidParity( c["raid_type"]:"" ))
+ {
t = LibStorage::MdPartCoInfo::swig_parity_get(infos);
symbol pt = toSymbol(conv_mdparity, t);
- if (pt != `par_none)
- c["parity_algorithm"] = substring(sformat("%1", pt), 1);
- }
- t = LibStorage::MdPartCoInfo::swig_chunk_get(infos);
+ if( pt != `par_default )
+ c["parity_algorithm"] = rev_conv_parstring[t]:"";
+ }
+ t = LibStorage::MdPartCoInfo::swig_chunkSizeK_get(infos);
if (t > 0)
{
c["chunk_size"] = t;
@@ -1773,8 +1550,8 @@
{
c["create"] = LibStorage::LvmVgInfo::swig_create_get(infos);
c["size_k"] = LibStorage::LvmVgInfo::swig_sizeK_get(infos);
- c["cyl_size"] = 1024*LibStorage::LvmVgInfo::swig_peSize_get(infos);
- c["pesize"] = 1024*LibStorage::LvmVgInfo::swig_peSize_get(infos);
+ c["cyl_size"] = 1024*LibStorage::LvmVgInfo::swig_peSizeK_get(infos);
+ c["pesize"] = 1024*LibStorage::LvmVgInfo::swig_peSizeK_get(infos);
c["cyl_count"] = LibStorage::LvmVgInfo::swig_peCount_get(infos);
c["pe_free"] = LibStorage::LvmVgInfo::swig_peFree_get(infos);
c["lvm2"] = LibStorage::LvmVgInfo::swig_lvm2_get(infos);
@@ -1796,8 +1573,8 @@
map p = $[];
vinfo = LibStorage::LvmLvInfo::swig_v_get(info);
p = volumeMap( vinfo, p );
- p["stripes"] = LibStorage::LvmLvInfo::swig_stripe_get(info);
- t = LibStorage::LvmLvInfo::swig_stripe_size_get(info);
+ p["stripes"] = LibStorage::LvmLvInfo::swig_stripes_get(info);
+ t = LibStorage::LvmLvInfo::swig_stripeSizeK_get(info);
if( t>0 )
p["stripesize"] = t;
p["type"] = `lvm;
@@ -1819,25 +1596,31 @@
p["nr"] = LibStorage::MdInfo::swig_nr_get(info);
integer t = LibStorage::MdInfo::swig_type_get(info);
p["raid_type"] = substring( sformat( "%1", toSymbol( conv_mdtype, t )), 1 );
- if( p["raid_type"]:""=="raid5" )
+ if( HasRaidParity( p["raid_type"]:"" ))
{
t = LibStorage::MdInfo::swig_parity_get(info);
symbol pt = toSymbol( conv_mdparity, t );
- if( pt != `par_none )
- p["parity_algorithm"] = substring( sformat( "%1", pt), 1 );
+ if( pt != `par_default )
+ p["parity_algorithm"] = rev_conv_parstring[t]:"";
}
p["type"] = `sw_raid;
p["fstype"] = Partitions::raid_name;
- t = LibStorage::MdInfo::swig_chunk_get(info);
+ t = LibStorage::MdInfo::swig_chunkSizeK_get(info);
if( t>0 )
{
p["chunk_size"] = t;
}
string d = LibStorage::MdInfo::swig_sb_ver_get(info);
p["sb_ver"] = d;
- list<string> ls = splitstring( LibStorage::MdInfo::swig_devices_get(info), " " );
+
+ list<string> ls = splitstring(LibStorage::MdInfo::swig_devices_get(info), " ");
p["devices"] = ls;
- c["partitions"] = add( c["partitions"]:[], p );
+
+ ls = splitstring(LibStorage::MdInfo::swig_spares_get(info), " ");
+ if (!isempty(ls))
+ p["spares"] = ls;
+
+ c["partitions"] = add( c["partitions"]:[], p );
});
}
else if( c["type"]:`CT_UNKNOWN == `CT_LOOP )
@@ -1856,7 +1639,7 @@
p["fstype"] = Partitions::loop_name;
p["fpath"] = LibStorage::LoopInfo::swig_file_get(info);
p["create_file"] = !LibStorage::LoopInfo::swig_reuseFile_get(info);
- if( p["enc_type"]:`unknown != `luks )
+ if( p["enc_type"]:`unknown != `luks && size(p["loop"]:"")>0 )
p["device"] = p["loop"]:"";
c["partitions"] = add( c["partitions"]:[], p );
});
@@ -1896,6 +1679,56 @@
c["partitions"] = add( c["partitions"]:[], p );
});
}
+ else if( c["type"]:`CT_UNKNOWN == `CT_BTRFS )
+ {
+ list<any> pinfos = [];
+ y2milestone( "before getBtrfsInfo" );
+ ret = LibStorage::StorageInterface::getBtrfsInfo( sint, pinfos );
+ y2milestone( "after getBtrfsInfo" );
+ if( ret<0 )
+ y2warning( "getBtrfsInfo ret:%1", ret );
+ foreach( any info, pinfos,
+ ``{
+ map p = $[];
+ vinfo = LibStorage::BtrfsInfo::swig_v_get(info);
+ p = volumeMap( vinfo, p );
+ p["type"] = `btrfs;
+ p["fstype"] = Partitions::btrfs_name;
+ list<string> ls = splitstring(LibStorage::BtrfsInfo::swig_devices_get(info), "\n");
+ p["devices"] = ls;
+ ls = splitstring( LibStorage::BtrfsInfo::swig_devices_add_get(info), "\n" );
+ if( size(ls)>0 )
+ c["devices_add"] = ls;
+ ls = splitstring( LibStorage::BtrfsInfo::swig_devices_rem_get(info), "\n" );
+ if( size(ls)>0 )
+ c["devices_rem"] = ls;
+ ls = splitstring(LibStorage::BtrfsInfo::swig_subvol_get(info), "\n");
+ if( !isempty(ls) )
+ p["subvol"] = maplist( string s, ls, ``{ map m = $[ "name" : s ]; return( m ); });
+ if( size(p["devices"]:[])+size(p["devices_add"]:[])>1 )
+ p["device"] = "UUID=" + p["uuid"]:"";
+ c["partitions"] = add( c["partitions"]:[], p );
+ });
+ }
+ else if( c["type"]:`CT_UNKNOWN == `CT_TMPFS )
+ {
+ list<any> pinfos = [];
+ y2milestone( "before getTmpfsInfo" );
+ ret = LibStorage::StorageInterface::getTmpfsInfo( sint, pinfos );
+ y2milestone( "after getTmpfsInfo" );
+ if( ret<0 )
+ y2warning( "getTmpfsInfo ret:%1", ret );
+ foreach( any info, pinfos,
+ ``{
+ map p = $[];
+ vinfo = LibStorage::TmpfsInfo::swig_v_get(info);
+ p = volumeMap( vinfo, p );
+ p["type"] = `tmpfs;
+ p["fstype"] = Partitions::tmpfs_name;
+ p["device"] = "tmpfs";
+ c["partitions"] = add( c["partitions"]:[], p );
+ });
+ }
//y2milestone ("getContainerInfo container %1", remove( c, "partitions" ) );
y2milestone ("getContainerInfo container %1", c );
return( c );
@@ -1903,9 +1736,9 @@
map toDiskMap( map disk, map cinfo )
{
- list<string> l = [ "size_k", "cyl_size", "cyl_count", "sector_size", "label",
- "max_logical", "max_primary", "type", "readonly",
- "used_by_type", "used_by", "used_by_device", "partitions", "dasdfmt",
+ list<string> l = [ "size_k", "cyl_size", "cyl_count", "sector_size", "label", "name", "device",
+ "max_logical", "max_primary", "type", "readonly", "transport", "iscsi",
+ "used_by", "used_by_type", "used_by_device", "partitions", "dasdfmt",
"udev_id", "udev_path" ];
foreach( string s, l,
``{
@@ -1933,12 +1766,21 @@
if( t!=LibStorage::UB_NONE() )
{
c["used_by_type"] = toSymbol( conv_usedby, t );
- c["used_by"] = LibStorage::ContainerInfo::swig_usedByName_get(info);
c["used_by_device"] = LibStorage::ContainerInfo::swig_usedByDevice_get(info);
+ c["used_by"] = [ $[ "type" : c["used_by_type"]:`UB_NONE,
+ "device" : c["used_by_device"]:"" ] ];
}
boolean b = LibStorage::ContainerInfo::swig_readonly_get(info);
if( b )
c["readonly"] = true;
+
+ string tmp = LibStorage::ContainerInfo::swig_udevPath_get(info);
+ if (!isempty(tmp))
+ c["udev_path"] = tmp;
+ tmp = LibStorage::ContainerInfo::swig_udevId_get(info);
+ if (!isempty(tmp))
+ c["udev_id"] = splitstring(tmp, " ");
+
ret = add( ret, c );
});
y2milestone( "getContainers ret:%1", ret );
@@ -1952,12 +1794,31 @@
return contains([ `CT_DISK, `CT_DMRAID, `CT_DMMULTIPATH, `CT_MDPART ], t);
}
+map<string,map> HandleBtrfsSimpleVolumes( map<string,map> tg )
+ {
+ if( haskey( tg, "/dev/btrfs" ))
+ {
+ list<map> simple = filter( map p, tg["/dev/btrfs","partitions"]:[],
+ ``(size(p["devices"]:[])<=1));
+ tg["/dev/btrfs","partitions"] =
+ filter( map p, tg["/dev/btrfs","partitions"]:[],
+ ``(size(p["devices"]:[])>1));
+ y2milestone( "simple %1", simple );
+ foreach( map p, simple,
+ {
+ tg = SetPartitionData( tg, p["device"]:"", "subvol", p["subvol"]:[] );
+ tg = SetPartitionData( tg, p["device"]:"", "uuid", p["uuid"]:"" );
+ });
+ }
+ return( tg );
+ }
+
/**
* Updates target map
*
* @see GetTargetMap()
*/
-global void UpdateTargetMap()
+void UpdateTargetMap()
{
conts = getContainers();
list<string> rem_keys = [];
@@ -1979,6 +1840,20 @@
}
y2milestone( "UpdateTargetMap dev:%1 is:%2", dev, tg[dev]:$[] );
});
+ tg = HandleBtrfsSimpleVolumes( tg );
+ if( haskey( tg, "/dev/btrfs" ))
+ {
+ list<map> simple = filter( map p, tg["/dev/btrfs","partitions"]:[],
+ ``(size(p["devices"]:[])<=1));
+ tg["/dev/btrfs","partitions"] =
+ filter( map p, tg["/dev/btrfs","partitions"]:[],
+ ``(size(p["devices"]:[])>1));
+ y2milestone( "simple %1", simple );
+ foreach( map p, simple,
+ {
+ tg = SetPartitionData( tg, p["device"]:"", "subvol", p["subvol"]:[] );
+ });
+ }
y2milestone( "UpdateTargetMap rem_keys:%1", rem_keys );
foreach( string dev, rem_keys, ``{tg=remove(tg,dev);});
foreach( map c, conts,
@@ -2077,7 +1952,7 @@
* @param map disk
* @return map disk info
*/
-global define map getDiskInfo( string device, map disk )
+ map getDiskInfo(string device, map disk)
{
map c = $[];
c = find( map p, conts, ``(p["device"]:""==device ));
@@ -2114,60 +1989,13 @@
/**
- * Finds and returns fstab entry
- *
- * @param map fstab
- * @param string mount
- * @param string device
- * @param string uuid
- * @param string label
- * @return map fstab entry
- *
- * @example
- * FindFstabEntry ($[], "", "", "", "")
- *
- * @struct
- * $[
- * "spec" : "...",
- * "file" : "...",
- * "vfstype" : "...",
- * "mntops" : "...",
- * "freq" : ...,
- * "passno" : ...,
- * ]
- */
-/*
-global define map FindFstabEntry( map fstab, string mount, string device,
- string uuid, string label )
- {
- map ret = $[];
- list lines = [];
- lines = FindFstabLines( fstab, mount, device, uuid, label );
- y2milestone( "mount=%1 device=%2 uuid=%3 label=%4", mount, device, uuid,
- label );
- if( size(lines)>0 )
- {
- map entry = AsciiFile::GetLine( fstab, lines[0]:-1 );
- ret = $[ "spec" : entry["fields",0]:"",
- "file" : entry["fields",1]:"",
- "vfstype" : entry["fields",2]:"",
- "mntops" : entry["fields",3]:"",
- "freq" : entry["fields",4]:0,
- "passno" : entry["fields",5]:0 ];
- }
- y2milestone( "ret:%1", ret );
- return( ret );
- }
-*/
-
-/**
* Returns map describing the disk target
*
* @return map <string, map>
*/
-global define map< string, map > GetOndiskTarget()
+ global map<string, map> GetOndiskTarget()
{
- list keys = [ "mount", "enc_type", "mountby", "fstopt", "used_fs", "format" ];
+ list<string> keys = [ "mount", "enc_type", "mountby", "fstopt", "used_fs", "format" ];
map<string,map> ret = GetTargetMap();
foreach( string d, map disk, ret,
``{
@@ -2182,9 +2010,10 @@
}));
ret[d,"partitions"] = pl;
});
- return( ret );
+ return ret;
}
+
global define void CreateTargetBackup(string who)
{
string t = "targetMap_s_" + who + "_" + sformat("%1",count);
@@ -2319,17 +2148,9 @@
}
-global define void InstallCallbacks()
+ // Storage Constructor
+ global void Storage()
{
- StorageClients::InstallCallbacks();
- }
-
-
-// Constructor
-global define void Storage()
- ``{
- map m = (map)SCR::Execute(.target.bash_output, "date +%s.%N" );
- y2milestone( "constructor Storage() time:%1", m["stdout"]:"" );
if( Mode::normal() )
{
Storage::SetPartMode( "CUSTOM" );
@@ -2337,19 +2158,52 @@
}
if( Stage::initial() )
{
- string inst = (string) SCR::Read( .etc.install_inf.Partition );
- if( inst!=nil && size(inst)>0 )
- {
- part_insts = "/dev/" + inst;
- y2milestone( "Storage .etc.install_inf.Partition \"%1\" part_insts:%2",
- inst, part_insts );
- }
Storage::SetPartMode( "CUSTOM" );
Storage::SetPartProposalActive( false );
}
- InstallCallbacks();
- m = (map)SCR::Execute(.target.bash_output, "date +%s.%N" );
- y2milestone( "constructor Storage() end time:%1", m["stdout"]:"" );
+ }
+
+
+ global boolean GetContVolInfo(string device, map<string, any>& info)
+ {
+ any tmp = LibStorage::ContVolInfo::new("LibStorage::ContVolInfo");
+ if (LibStorage::StorageInterface::getContVolInfo(sint, device, tmp) != 0)
+ return false;
+
+ info = $[ "ctype" : toSymbol(conv_ctype, LibStorage::ContVolInfo::swig_ctype_get(tmp)),
+ "cname" : LibStorage::ContVolInfo::swig_cname_get(tmp),
+ "cdevice" : LibStorage::ContVolInfo::swig_cdevice_get(tmp),
+ "vname" : LibStorage::ContVolInfo::swig_vname_get(tmp),
+ "vdevice" : LibStorage::ContVolInfo::swig_vdevice_get(tmp) ];
+
+ y2milestone("GetContVolInfo device:%1 info:%2", device, info);
+ return true;
+ }
+
+
+ global boolean IsInstallationSource(string device)
+ {
+ if (part_insts == nil)
+ {
+ part_insts = "";
+
+ if (Stage::initial())
+ {
+ string tmp = (string) SCR::Read(.etc.install_inf.Partition);
+ if (tmp != nil && !isempty(tmp))
+ {
+ y2milestone("IsInstallationSource .etc.install_inf.Partition:\"%1\"", tmp);
+
+ map<string, any> info = $[];
+ if (GetContVolInfo("/dev/" + tmp, info))
+ part_insts = info["vdevice"]:"";
+ }
+ }
+
+ y2milestone("IsInstallationSource part_insts:\"%1\"", part_insts);
+ }
+
+ return !isempty(part_insts) && device == part_insts;
}
@@ -2382,6 +2236,7 @@
return ret;
}
+
global integer MaxCylLabel( map disk, integer start_cyl )
{
integer ret = Partitions::MaxSectors(disk["label"]:"") * disk["sector_size"]:512 / 1024;
@@ -2435,6 +2290,7 @@
return( ret==0 );
}
+
global boolean UpdatePartition( string device, integer start, integer len )
{
y2milestone( "UpdatePartition device:%1 start:%2 len:%3",
@@ -2535,7 +2391,7 @@
* @param string device name
* @param string disk
* @param integer new_cyls (in cylinders)
- * @return boolean if successfull
+ * @return boolean if successful
*/
global boolean ResizePartition(string device, string disk, integer new_cyls)
{
@@ -2555,13 +2411,13 @@
* @param string device name
* @param string disk
* @param integer new_size (in kBytes)
- * @return boolean if successfull
+ * @return boolean if successful
*/
global boolean ResizeVolume(string device, string disk, integer new_size_k)
{
y2milestone("ResizeVolume device:%1 disk:%2 new_size_k:%3", device, disk, new_size_k);
integer ret = 0;
- ret = LibStorage::StorageInterface::resizeVolume(sint, device, (new_size_k+1023)/1024);
+ ret = LibStorage::StorageInterface::resizeVolume(sint, device, new_size_k);
if (ret < 0)
y2error("ResizeVolume sint ret:%1", ret);
UpdateTargetMapDisk(disk);
@@ -2745,6 +2601,40 @@
else
y2milestone( "ChangeVolumeProperties sint ret:%1", ret );
}
+ if( ret==0 && size(part["subvol"]:[])>0 )
+ {
+ string d = part["device"]:"";
+ list<map> rem = filter( map p, part["subvol"]:[], ``(p["delete"]:false));
+ list<map> cre = filter( map p, part["subvol"]:[], ``(p["create"]:false));
+ y2milestone( "ChangeVolumeProperties rem:%1", rem );
+ y2milestone( "ChangeVolumeProperties cre:%1", cre );
+ while( ret==0 && size(rem)>0 )
+ {
+ changed = true;
+ string pth = rem[0,"name"]:"";
+ ret = LibStorage::StorageInterface::removeSubvolume( sint, d, pth );
+ if( ret<0 )
+ y2error( "ChangeVolumeProperties sint ret:%1", ret );
+ else
+ {
+ y2milestone( "ChangeVolumeProperties sint ret:%1", ret );
+ rem = remove( rem, 0 );
+ }
+ }
+ while( ret==0 && size(cre)>0 )
+ {
+ changed = true;
+ string pth = cre[0,"name"]:"";
+ ret = LibStorage::StorageInterface::createSubvolume( sint, d, pth );
+ if( ret<0 )
+ y2error( "ChangeVolumeProperties sint ret:%1", ret );
+ else
+ {
+ y2milestone( "ChangeVolumeProperties sint ret:%1", ret );
+ cre = remove( cre, 0 );
+ }
+ }
+ }
if( ret==0 )
{
y2debug( "ChangeVolumeProperties changed:%1 part:%2", changed, part );
@@ -2754,9 +2644,9 @@
return( ret==0 );
}
-global boolean DeleteDevice( string disk, string device )
+global boolean DeleteDevice(string device)
{
- y2milestone( "DeleteDevice disk:%1 device:%2", disk, device );
+ y2milestone( "DeleteDevice device:%1", device );
integer ret = LibStorage::StorageInterface::removeVolume( sint, device );
if( ret<0 )
y2error( "DeleteDevice sint ret:%1", ret );
@@ -2844,14 +2734,14 @@
}
global boolean CreateLvmLv( string vgname, string lvname, integer sizeK,
- integer stripe )
+ integer stripes )
{
- y2milestone( "CreateLvmLv vg:%1 name:%2 sizeK:%3 stripe:%4", vgname,
- lvname, sizeK, stripe );
+ y2milestone("CreateLvmLv vg:%1 name:%2 sizeK:%3 stripes:%4", vgname,
+ lvname, sizeK, stripes);
integer ret = 0;
string dummy = "";
ret = LibStorage::StorageInterface::createLvmLv( sint, vgname, lvname,
- (sizeK+1023)/1024, stripe,
+ sizeK, stripes,
dummy );
if( ret<0 )
y2error( "CreateLvmLv sint ret:%1", ret );
@@ -2891,27 +2781,49 @@
return( ret==0 );
}
-global boolean AddNfsVolume( string nfsdev, string opts, integer sz, string mp )
+global boolean ExtendBtrfsVolume( string uuid, string device )
+ {
+ y2milestone( "ExtendBtrfsVolume uuid:%1 device:%2", uuid, device );
+ integer ret = 0;
+ list<string> devs = [ device ];
+ ret = LibStorage::StorageInterface::extendBtrfsVolume( sint, uuid, devs );
+ if( ret<0 )
+ y2error( "ExtendBtrfsVolume sint ret:%1", ret );
+ UpdateTargetMap();
+ return( ret==0 );
+ }
+
+global boolean ReduceBtrfsVolume( string uuid, string device )
+ {
+ y2milestone( "ReduceBtrfsVolume uuid:%1 device:%2", uuid, device );
+ integer ret = 0;
+ list<string> devs = [ device ];
+ ret = LibStorage::StorageInterface::shrinkBtrfsVolume( sint, uuid, devs );
+ if( ret<0 )
+ y2error( "ReduceBtrfsVolume sint ret:%1", ret );
+ UpdateTargetMap();
+ return( ret==0 );
+ }
+
+global boolean AddNfsVolume( string nfsdev, string opts, integer sz, string mp, boolean nfs4 )
{
- y2milestone( "AddNfsVolume dev:%1 opts:%2 size:%3 mp:%4", nfsdev, opts,
- sz, mp );
+ y2milestone("AddNfsVolume dev:%1 opts:%2 size:%3 mp:%4 nfs4:%5", nfsdev, opts, sz, mp, nfs4);
integer ret = 0;
string dummy = "";
- ret = LibStorage::StorageInterface::addNfsDevice( sint, nfsdev, opts, sz, mp );
+ ret = LibStorage::StorageInterface::addNfsDevice(sint, nfsdev, opts, sz, mp, nfs4);
if( ret<0 )
y2error( "AddNfsVolume sint ret:%1", ret );
UpdateTargetMapDisk( "/dev/nfs" );
return( ret==0 );
}
-global integer CheckNfsVolume( string nfsdev, string opts )
+global integer CheckNfsVolume(string nfsdev, string opts, boolean nfs4)
{
- y2milestone( "CheckNfsVolume dev:%1 opts:%2", nfsdev, opts );
+ y2milestone("CheckNfsVolume dev:%1 opts:%2 nfs4:%3", nfsdev, opts, nfs4);
integer ret = 0;
integer sz = 0;
string dummy = "";
- ret = LibStorage::StorageInterface::checkNfsDevice( sint, nfsdev, opts,
- sz );
+ ret = LibStorage::StorageInterface::checkNfsDevice(sint, nfsdev, opts, nfs4, sz);
if( ret<0 )
y2error( "CheckNfsVolume sint ret:%1", ret );
else
@@ -2920,6 +2832,30 @@
return( ret );
}
+global boolean AddTmpfsVolume( string mount, string opts )
+ {
+ y2milestone("AddTmpfsVolume mount:%1 opts:%2", mount, opts );
+ integer ret = 0;
+ string dummy = "";
+ ret = LibStorage::StorageInterface::addTmpfsMount(sint, mount, opts );
+ if( ret<0 )
+ y2error( "AddTmpfsVolume sint ret:%1", ret );
+ UpdateTargetMapDisk( "/dev/tmpfs" );
+ return( ret==0 );
+ }
+
+global boolean DelTmpfsVolume( string mount )
+ {
+ y2milestone("DelTmpfsVolume mount:%1", mount );
+ integer ret = 0;
+ string dummy = "";
+ ret = LibStorage::StorageInterface::removeTmpfsMount(sint, mount);
+ if( ret<0 )
+ y2error( "DelTmpfsVolume sint ret:%1", ret );
+ UpdateTargetMapDisk( "/dev/tmpfs" );
+ return( ret==0 );
+ }
+
global boolean CreateMd( integer nr, string type )
{
y2milestone( "CreateMd nr:%1 type:%2", nr, type );
@@ -2927,7 +2863,7 @@
integer tmp = conv_mdstring[type]:0;
list<string> dummy = [];
string rd = sformat("/dev/md%1", nr );
- ret = LibStorage::StorageInterface::createMd( sint, rd, tmp, dummy );
+ ret = LibStorage::StorageInterface::createMd(sint, rd, tmp, dummy, dummy);
if( ret<0 )
y2error( "CreateMd sint ret:%1", ret );
UpdateTargetMapDisk( "/dev/md" );
@@ -2944,33 +2880,36 @@
if (v == type)
tmp = k;
});
-
+
+ list<string> dummy = [];
string rd = sformat("/dev/md%1", nr );
- ret = LibStorage::StorageInterface::createMd(sint, rd, tmp, devices);
+ ret = LibStorage::StorageInterface::createMd(sint, rd, tmp, devices, dummy);
if( ret<0 )
y2error( "CreateMdWithDevs sint ret:%1", ret );
UpdateTargetMap();
return ret==0;
}
-global boolean ExtendMd( integer nr, string dev )
+global boolean ExtendMd( integer nr, list<string> devs )
{
- y2milestone( "ExtendMd nr:%1 dev:%2", nr, dev );
+ y2milestone( "ExtendMd nr:%1 devs:%2", nr, devs );
integer ret = 0;
+ list<string> dummy = [];
string rd = sformat("/dev/md%1", nr );
- ret = LibStorage::StorageInterface::extendMd( sint, rd, dev );
+ ret = LibStorage::StorageInterface::extendMd( sint, rd, devs, dummy );
if( ret<0 )
y2error( "ExtendMd sint ret:%1", ret );
UpdateTargetMap();
return( ret==0 );
}
-global boolean ShrinkMd( integer nr, string dev )
+global boolean ShrinkMd( integer nr, list<string> devs )
{
- y2milestone( "ShrinkMd nr:%1 dev:%2", nr, dev );
+ y2milestone( "ShrinkMd nr:%1 devs:%2", nr, devs );
integer ret = 0;
+ list<string> dummy = [];
string rd = sformat("/dev/md%1", nr );
- ret = LibStorage::StorageInterface::shrinkMd( sint, rd, dev );
+ ret = LibStorage::StorageInterface::shrinkMd( sint, rd, devs, dummy );
if( ret<0 )
y2error( "ShrinkMd sint ret:%1", ret );
UpdateTargetMap();
@@ -3049,7 +2988,8 @@
tmp = k;
});
- ret = LibStorage::StorageInterface::computeMdSize(sint, tmp, devices, sizeK);
+ list<string> dummy = [];
+ ret = LibStorage::StorageInterface::computeMdSize(sint, tmp, devices, dummy, sizeK);
if( ret!=0 )
y2milestone( "ComputeMdSize sint ret:%1", ret );
return ret;
@@ -3060,11 +3000,12 @@
string pwd="";
y2milestone( "GetCryptPwd device:%1", device );
integer ret = 0;
- ret = LibStorage::StorageInterface::getCryptPassword( sint, device, pwd );
+ ret = LibStorage::StorageInterface::getCryptPassword( sint, device,
+ pwd );
if( ret<0 )
- y2error( "GetCryptPwd sint ret:%1", ret );
+ y2error( "GetCryptPwd sint ret:%1", ret );
else
- y2milestone( "GetCryptPwd empty:%1", size(pwd)==0 );
+ y2milestone( "GetCryptPwd empty:%1", size(pwd)==0 );
return( pwd );
}
@@ -3072,11 +3013,24 @@
{
y2milestone( "SetCryptPwd device:%1", device );
integer ret = 0;
- ret = LibStorage::StorageInterface::setCryptPassword( sint, device, pwd );
+ ret = LibStorage::StorageInterface::setCryptPassword( sint, device,
+ pwd );
+ if( ret<0 )
+ y2error( "SetCryptPwd sint ret:%1", ret );
+ else
+ y2milestone( "SetCryptPwd sint ret:%1", ret );
+ return( ret==0 );
+ }
+
+global boolean ActivateCrypt( string device, boolean on )
+ {
+ y2milestone( "ActivateCrypt device:%1 on:%2", device, on );
+ integer ret = 0;
+ ret = LibStorage::StorageInterface::activateEncryption( sint, device, on );
if( ret<0 )
- y2error( "SetCryptPwd sint ret:%1", ret );
+ y2error( "ActivateCrypt ret:%1", ret );
else
- y2milestone( "SetCryptPwd sint ret:%1", ret );
+ y2milestone( "ActivateCrypt ret:%1", ret );
return( ret==0 );
}
@@ -3088,6 +3042,7 @@
return( ret );
}
+
global string CreateLoop( string file, boolean create, integer sizeK,
string mp )
{
@@ -3097,7 +3052,7 @@
integer ret = 0;
string pwd = GetCryptPwd( file );
ret = LibStorage::StorageInterface::createFileLoop( sint, file, !create,
- sizeK, mp, pwd, dev );
+ sizeK, mp, pwd, dev );
if( ret<0 )
y2error( "CreateLoop sint ret:%1", ret );
LibStorage::StorageInterface::forgetCryptPassword( sint, file );
@@ -3106,32 +3061,6 @@
return( dev );
}
-/*
-integer loop_count = 0;
-
-global string GetLoopDevice()
- {
- y2milestone( "GetLoopDevice" );
- string file = Directory::tmpdir + sformat("/dfile_%1", loop_count);
- string mp = Directory::tmpdir + sformat("/loopmp_%1", loop_count);
- loop_count = loop_count + 1;
- string dev = "";
- string pwd = "emilemil";
- integer ret = LibStorage::StorageInterface::createFileLoop( sint, file,
- true, 50*1024,
- mp, pwd, dev );
- if( ret<0 )
- y2error( "GetLoopDevice sint ret:%1", ret );
- LibStorage::StorageInterface::forgetCryptPassword( sint, dev );
- y2milestone( "GetLoopDevice dev:%1", dev );
- return( dev );
- }
-*/
-
-global void UpdateClassified( string key, string pwd )
- {
- LibStorage::StorageInterface::setCryptPassword( sint, key, pwd );
- }
define void HandleModulesOnBoot( map<string,map> targetMap );
@@ -3162,6 +3091,7 @@
return( ret==0 );
}
+
global string DefaultDiskLabel(string disk)
{
string label = LibStorage::StorageInterface::defaultDiskLabel(sint, disk);
@@ -3175,10 +3105,11 @@
* @param string the disk to deleted the partition table from
* @return boolean
*/
-global boolean DeletePartitionTable(string disk)
+global boolean DeletePartitionTable(string disk, string label)
{
- y2milestone("DeletePartitionTable disk:%1", disk);
- string label = DefaultDiskLabel(disk);
+ y2milestone("DeletePartitionTable disk:%1 label:%2", disk, label);
+ if( size(label)==0 )
+ label = DefaultDiskLabel(disk);
integer ret = LibStorage::StorageInterface::destroyPartitionTable(sint, disk, label);
if( ret<0 )
y2error( "DeletePartitionTable sint ret:%1", ret );
@@ -3254,12 +3185,10 @@
ret = Storage::CreateMd( p["nr"]:0, p["raid_type"]:"raid1" );
if( ret && haskey( p, "chunk_size" ))
Storage::ChangeMdChunk( p["nr"]:0, p["chunk_size"]:4 );
- if( ret && p["raid_type"]:""=="raid5" &&
- haskey( p, "parity_algorithm" ))
- Storage::ChangeMdParity( p["nr"]:0,
- p["parity_algorithm"]:"" );
- foreach( string d, p["devices"]:[],
- ``{ret=Storage::ExtendMd( p["nr"]:0, d )&&ret;});
+ if( ret && HasRaidParity( p["raid_type"]:"" ) && haskey( p, "parity_algorithm" ))
+ Storage::ChangeMdParity(p["nr"]:0, p["parity_algorithm"]:"");
+ if (ret)
+ ret = Storage::ExtendMd(p["nr"]:0, p["devices"]:[]);
}
else if( ctype == `CT_LOOP )
{
@@ -3282,21 +3211,31 @@
}
else if( ctype == `CT_NFS )
{
- ret = Storage::AddNfsVolume( p["device"]:"", p["fstopt"]:"",
- p["size_k"]:0, p["mount"]:"" );
+ ret = Storage::AddNfsVolume( p["device"]:"", p["fstopt"]:"", p["size_k"]:0,
+ p["mount"]:"", p["used_fs"]:`nfs == `nfs4 );
}
y2milestone( "CreateAny ret:%1", ret );
return( ret );
}
-define boolean IsEfiPartition( map p )
+
+boolean IsEfiPartition(map p)
{
- map m = GetFreeSpace( p["device"]:"", 0, p["used_fs"]:`none, false );
- boolean ret = m["efi"]:false;
- y2milestone( "IsEfiPartition ret:%1", ret );
- return( ret );
+ boolean ret = false;
+
+ map<symbol, any> resize_info = $[];
+ map<symbol, any> content_info = $[];
+ if (GetFreeInfo(p["device"]:"", false, resize_info, true, content_info, true) &&
+ content_info[`efi]:false)
+ {
+ ret = true;
+ }
+
+ y2milestone("IsEfiPartition ret:%1", ret);
+ return ret;
}
+
/**
* Search in the list partitions for windows partitions and add the key
* "mount" to the found windows partitions.
@@ -3304,16 +3243,14 @@
* @parm primary handle primary or logical partitions
* @return list new partitions with windows mountpoints
*/
-define void AddMountPointsForWinParts( list<map> partitions, boolean primary,
- integer max_prim, integer& foreign_nr )
- ``{
+void AddMountPointsForWinParts( list<map> partitions, boolean primary,
+ integer max_prim, integer& foreign_nr )
+ {
if( !Arch::i386 () && !Arch::ia64 () && !Arch::x86_64 () )
return;
string foreign_ids = "CDEFGHIJKLMNOPQRSTUVW";
- list<map> new_partitions = [];
-
foreach(map partition, partitions,
``{
map new_partition = partition;
@@ -3353,8 +3290,9 @@
});
};
-global define void AddMountPointsForWin( map<string,map> targets )
- ``{
+
+global void AddMountPointsForWin( map<string, map> targets )
+ {
y2milestone( "AddMountPointsForWin called" );
integer foreign_nr = 0;
@@ -3374,6 +3312,7 @@
});
}
+
/**
* Removes ... maps to ...
*
@@ -3387,8 +3326,11 @@
LibStorage::StorageInterface::removeDmTableTo( sint, device );
}
-global define boolean CheckSwapable( string dev )
+global boolean CheckSwapable( string dev )
{
+ if (Mode::test())
+ return true;
+
string cmd = "/sbin/swapon --fixpgsz " + dev;
boolean ok = (integer)SCR::Execute(.target.bash, cmd )==0;
if( ok )
@@ -3405,9 +3347,9 @@
* @param target Disk map
* @return map<string,map> modified target
*/
-global define map<string,map> AddSwapMp( map<string,map> target )
- ``{
- list swaps = SwappingPartitions();
+map<string, map> AddSwapMp( map<string, map> target )
+ {
+ list<string> swaps = SwappingPartitions();
y2milestone( "AddSwapMp swaps %1", swaps );
foreach(string diskdev, map disk, target,
``{
@@ -3420,10 +3362,14 @@
search( diskdev, "/dev/evms" )!=0 ) ||
(contains( swaps, part["device"]:"" )))
{
+ y2milestone( "AddSwapMp %1", part );
boolean ok = true;
if( !contains( swaps, part["device"]:"" ))
{
- ok = CheckSwapable( part["device"]:"" );
+ string dev = part["device"]:"";
+ if( !isempty(part["crypt_device"]:""))
+ dev = part["crypt_device"]:"";
+ ok = CheckSwapable( dev );
y2milestone( "AddSwapMp initial ok:%1", ok );
}
if( ok )
@@ -3437,92 +3383,478 @@
});
target[diskdev] = disk;
});
- return( target );
+ return target;
}
+global boolean CheckCryptOk( string dev, string fs_passwd, boolean silent,
+ boolean erase )
+ {
+ integer i = LibStorage::StorageInterface::verifyCryptPassword( sint, dev, fs_passwd, erase );
+ if( i!=0 && !silent )
+ Popup::Error( sformat(_("Could not set encryption.
+System error code is %1.
-/**
- * Returns a system target map.
- *
- * @return map <string,map> target map
- *
- * @struct
- * $[
- * ... ?
- * ]
- */
-global map<string, map> GetTargetMap()
-{
- if (!InitLibstorage(false))
- return nil;
+The crypt password provided could be incorrect.
+"), i ));
+ y2milestone( "CheckCryptOk dev:%1 pwlen:%2 ret:%3",
+ dev, size(fs_passwd), i==0 );
+ return( i==0 );
+ }
- map<string,map> tmp = $[];
- boolean changed = false;
- if( !probe_done && !Mode::config() )
+global boolean RescanCrypted()
+ {
+ boolean ret = LibStorage::StorageInterface::rescanCryptedObjects( sint );
+ y2milestone( "RescanCrypted ret:%1", ret );
+ return( ret );
+ }
+
+global boolean CheckEncryptionPasswords( string pw1, string pw2,
+ integer min_length,
+ boolean empty_allowed)
+ {
+ if (pw1 != pw2)
{
- map<string,string> bios_id_raid = $[];
- y2milestone ("probing StorageDevices" );
- map<string,string> rename = $[];
- tmp = (map<string,map>)StorageDevices::Probe(true);
- foreach( string dev, map disk, tmp,
- ``{
- map dtmp = Storage::GetDiskPartitionTg( dev, $[] )[0]:$[];
- y2milestone( "probing dev %1 disk %2", dev, dtmp );
- if( search( dev, "/dev/dm-" )==0 || search( dev, "/dev/md" )==0 )
- {
- if( size(disk["bios_id"]:"")>0 )
- bios_id_raid[dev] = disk["bios_id"]:"";
- }
- else if( size(dtmp["disk"]:"")>0 && dev != dtmp["disk"]:"" )
- {
- rename[dev] = dtmp["disk"]:"";
- y2milestone( "probing rename %1", rename );
- }
- });
- tmp = filter( string dev, map disk, tmp,
- ``(search( dev, "/dev/dm-" )!=0));
- tmp = filter( string dev, map disk, tmp,
- ``(search( dev, "/dev/md" )!=0));
- if( size(rename)>0 )
+ // popup text
+ Popup::Message(_("The first and the second version
+of the password do not match.
+Try again."));
+ return false;
+ }
+
+ if (isempty(pw1))
+ {
+ if (!empty_allowed)
{
- foreach( string old, string new, rename,
- ``{
- if( haskey( tmp, old ))
- {
- tmp[new] = tmp[old]:$[];
- tmp = remove( tmp, old );
- tmp[new,"device"] = new;
- y2milestone( "probing old:%1 new:%2", old, tmp[new]:$[] );
- }
- });
+ // popup text
+ Popup::Message(_("You did not enter a password.
+Try again.
+"));
+ return false;
}
- y2milestone ("probing done" );
- if( size(tmp)>0 )
- {
+ }
+ else
+ {
+ if (size(pw1) < min_length)
+ {
+ // popup text
+ Popup::Message(sformat(_("The password must have at least %1 characters.
+Try again.
+"), min_length));
+ return false;
+ }
+
+ string allowed_chars = "0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ#* ,.;:._-+!$%&/|\?{[()]}@^\\<>";
+ if (findfirstnotof(pw1, allowed_chars) != nil)
+ {
+ // popup text
+ Popup::Message(_("The password may only contain the following characters:
+0..9, a..z, A..Z, and any of \"@#* ,.;:._-+!$%&/|\?{[()]}^\\<>\".
+Try again."));
+ return false;
+ }
+ }
+
+ return true;
+ }
+
+global string PasswdPopup( string helptxt, string header, string label,
+ boolean pw2, integer minpwlen, boolean tmpcrypt )
+ {
+ term ad = `Empty();
+ if( pw2 )
+ ad = `VBox(
+ `VSpacing(0.5),
+ `HBox(
+ `Password(`id(`pw2), `opt(`hstretch),
+ // Label: get same password again for verification
+ // Please use newline if label is longer than 40 characters
+ _("Reenter the password for &verification:"), ""),
+ `HSpacing(13))
+ );
+ UI::OpenDialog(
+ `opt(`decorated ),
+ `HBox(
+ `HWeight(3, `RichText( helptxt ) ),
+ `HWeight(6, `VBox(
+ `VSpacing(0.3),
+ `HBox(
+ `HSpacing(1),
+ `Heading(header),
+ `HSpacing(1)
+ ),
+ `VSpacing(1),
+ `HBox(
+ `HSpacing(4),
+ `VBox(
+ // label text
+ `Label(label),
+ `VSpacing(),
+ `HBox(
+ `Password(`id(`pw1), `opt(`hstretch),
+ // Label: get password for encrypted volume
+ // Please use newline if label is longer than 40 characters
+ _("&Enter encryption password:"), ""),
+ `HSpacing(13)),
+ ad),
+ `HSpacing(4)
+ ),
+ `VSpacing(2),
+ `ButtonBox(
+ `PushButton(`id(`ok), `opt(`default), Label::OKButton()),
+ `PushButton(`id(`cancel), Label::CancelButton())
+ ),
+ `VSpacing(0.5)
+ )
+ )
+ ));
+
+ string ret = "";
+ string password = "";
+ symbol widget = nil;
+
+ repeat
+ {
+ // Clear password fields on every round.
+ UI::ChangeWidget(`id(`pw1), `Value, "");
+ if( pw2 )
+ UI::ChangeWidget(`id(`pw2), `Value, "");
+
+ UI::SetFocus(`id(`pw1));
+
+ widget = (symbol) UI::UserInput();
+
+ switch (widget)
+ {
+ case `ok:
+ password = (string) UI::QueryWidget(`id(`pw1), `Value);
+ string tmp = password;
+ if( pw2 )
+ tmp = (string) UI::QueryWidget(`id(`pw2), `Value);
+
+ if (!Storage::CheckEncryptionPasswords( password, tmp,
+ minpwlen, tmpcrypt))
+ widget = `again;
+ else
+ ret = password;
+ break;
+ }
+ } until (widget == `cancel || widget == `ok);
+
+ UI::CloseDialog();
+ if( widget == `ok )
+ ret = password;
+ return( ret );
+ }
+
+
+boolean CryptVolPopup( list<string> dev1, list<string> dev2 )
+ {
+ term button_box = `ButtonBox(
+ `PushButton( `id(`yes), `opt(`okButton), _("Provide Password")),
+ `PushButton( `id(`no_button), `opt(`default, `cancelButton), Label::CancelButton())
+ );
+
+ map display_info = UI::GetDisplayInfo();
+ boolean has_image_support = display_info["HasImageSupport"]:false;
+
+ term ad = `Empty();
+ if( size(dev2)>0 )
+ ad = `VBox(
+ `Left( `Label( _(
+"The following encrypted volumes are already available."))),
+ `Left(`RichText(HTML::List(sort(dev2)))),
+ `VSpacing(0.2)
+ );
+
+ term icon = has_image_support ? `Top (`Image(Icon::IconPath ("question")))
+ : `Empty();
+
+ term layout =
+ `VBox (
+ `VSpacing (0.4),
+ `HBox (
+ icon,
+ `HSpacing (1),
+ `VBox (
+ `Left (`Heading (_("Encrypted Volume Activation"))),
+ `VSpacing(0.2),
+ `Left( `Label( _(
+"The following volumes contain an encryption signature but the
+passwords are not yet known.
+The passwords need to be known if the volumes are needed either
+during an update or if they contain an encrypted LVM physical volume."))),
+ `VSpacing(0.2),
+ `Left(`RichText(HTML::List(sort(dev1)))),
+ `VSpacing(0.2),
+ ad,
+ `Left(`Label( _("Do you want to provide crypt passwords?"))),
+ button_box
+ )
+ )
+ );
+
+ UI::OpenDialog(layout);
+ symbol ret = (symbol) UI::UserInput();
+ UI::CloseDialog();
+ y2milestone( "symbol:%1", ret );
+ return ret == `yes;
+ }
+
+map GetCryptLists( map<string, map> target )
+ {
+ list<map> ac_cr = [];
+ list<map> in_cr = [];
+ foreach( string k, map m, target,
+ ``{
+ list<map> tmp = filter( map p, m["partitions"]:[],
+ ``(p["enc_type"]:`none==`luks ));
+ in_cr = (list<map>)merge( in_cr,
+ filter( map p, tmp,
+ ``(isempty(p["crypt_device"]:""))));
+ ac_cr = (list<map>)merge( ac_cr,
+ filter( map p, tmp,
+ ``(!isempty(p["crypt_device"]:""))));
+ });
+ y2milestone( "GetCryptLists inactive:%1", in_cr );
+ y2milestone( "GetCryptLists active:%1", ac_cr );
+ map ret = $[];
+ ret["active"] = maplist( map p, ac_cr, ``(p["device"]:""));
+ ret["inactive"] = maplist( map p, in_cr, ``(p["device"]:""));
+ y2milestone( "ret:%1", ret );
+ return( ret );
+ }
+
+global map<string, map> AskCryptPasswords( map<string, map> target )
+ {
+ map crvol = GetCryptLists( target );
+ boolean ret = true;
+ boolean rescan_done = false;
+ // text in help field
+ string helptext = _(
+"Enter encryption password for any of the
+devices in the locked devices list.
+Password will be tried for all devices.");
+ // header text
+ string header = _("Enter Encryption Password");
+
+ if( Mode::normal() && size(crvol["inactive"]:[])==0 )
+ Popup::Error( _("There are no encrypted volume to unlock."));
+ while( size(crvol["inactive"]:[])>0 && ret )
+ {
+ ret = CryptVolPopup( crvol["inactive"]:[], crvol["active"]:[] );
+ y2milestone( "ret:%1", ret );
+ if( ret )
+ {
+ // label text, multiple device names follow
+ string label = _("Please provide password for any of the following devices:");
+ if( size(crvol["inactive"]:[])==1 )
+ // label text, one device name follows
+ label = _("Please provide password for the following device:");
+ foreach( string s, crvol["inactive"]:[],
+ ``{
+ label = label + sformat("\n%1", s );
+ });
+ string pw = PasswdPopup( helptext, header, label, false, 1, false );
+ if( size(pw)>0 )
+ {
+ UI::OpenDialog( `opt(`decorated),
+ `VBox(
+ `VSpacing(1),
+ `HBox(`HSpacing(1),
+ `Label(_("Trying to unlock encrypted volumes...")),
+ `HSpacing(1)),
+ `VSpacing(1)));
+ boolean unlock = false;
+ list<string> rl = [];
+ foreach( string d, crvol["inactive"]:[],
+ ``{
+ if( CheckCryptOk( d, pw, true, false ) &&
+ SetCryptPwd( d, pw ) &&
+ SetCrypt( d, true, false ) &&
+ ActivateCrypt( d, true ) )
+ {
+ y2milestone( "AskCryptPasswords activated %1", d );
+ unlock = true;
+ crvol["active"] = add( crvol["active"]:[], d );
+ rl = add( rl, d );
+ }
+ });
+ UI::CloseDialog();
+ if( !unlock )
+ {
+ Popup::Error( _("Password did not unlock any volume."));
+ }
+ else
+ {
+ crvol["inactive"] = filter( string s, crvol["inactive"]:[],
+ ``(!contains(rl,s)));
+ RescanCrypted();
+ rescan_done = true;
+ }
+ }
+ }
+ }
+ if( rescan_done )
+ {
+ StorageMap[targets_key] = target;
+ UpdateTargetMap();
+ target = StorageMap[targets_key]:$[];
+ }
+ return( target );
+ }
+
+map<string, map> AddProposalName(map<string, map> target_map)
+{
+ integer ide_disk_count = 0;
+ integer scsi_disk_count = 0;
+ integer generic_disk_count = 0;
+ integer dm_raid_count = 0;
+ integer md_raid_count = 0;
+
+ return mapmap(string device, map disk, target_map, {
+
+ string s = Storage::KByteToHumanString(disk["size_k"]:0);
+
+ switch (disk["type"]:`CT_UNKNOWN)
+ {
+ case `CT_DISK:
+ {
+ string proposal_name = "";
+
+ string bus = disk["bus"]:"";
+ if (bus == "IDE") {
+ ide_disk_count = ide_disk_count + 1;
+ proposal_name = sformat("%1. ", ide_disk_count) + _("IDE Disk");
+ } else if (bus == "SCSI") {
+ scsi_disk_count = scsi_disk_count + 1;
+ proposal_name = sformat("%1. ", scsi_disk_count) + _("SCSI Disk");
+ } else {
+ generic_disk_count = generic_disk_count + 1;
+ proposal_name = sformat("%1. ", generic_disk_count) + _("Disk");
+ }
+
+ proposal_name = proposal_name + ", " + s + ", " + device + ", ";
+
+ if (!isempty(disk["vendor"]:""))
+ proposal_name = proposal_name + disk["vendor"]:"" + "-";
+ proposal_name = proposal_name + disk["model"]:"";
+
+ disk["proposal_name"] = proposal_name;
+ }
+ break;
+
+ case `CT_DMRAID:
+ {
+ dm_raid_count = dm_raid_count + 1;
+ string proposal_name = sformat("%1. ", dm_raid_count) + _("DM RAID");
+
+ proposal_name = proposal_name + ", " + s + ", " + device;
+
+ disk["proposal_name"] = proposal_name;
+ }
+ break;
+
+ case `CT_MDPART:
+ {
+ md_raid_count = md_raid_count + 1;
+ string proposal_name = sformat("%1. ", md_raid_count) + _("MD RAID");
+
+ proposal_name = proposal_name + ", " + s + ", " + device;
+
+ disk["proposal_name"] = proposal_name;
+ }
+ break;
+ }
+
+ return $[ device : disk ];
+ });
+}
+
+
+/**
+ * Returns a system target map.
+ *
+ * @return map <string,map> target map
+ *
+ * @struct
+ * $[
+ * ... ?
+ * ]
+ */
+global map<string, map> GetTargetMap()
+{
+ if (!InitLibstorage(false))
+ return nil;
+
+ map<string,map> tmp = $[];
+ boolean changed = false;
+
+ if (Mode::test())
+ {
+ foreach(map c, conts, {
+ tmp[c["device"]:""] = getContainerInfo(c);
+ });
+ StorageMap[targets_key] = tmp;
+ if (!probe_done)
+ {
probe_done = true;
changed = true;
- foreach( string dev, map disk, tmp,
+ }
+ }
+ else if( !probe_done && !Mode::config() )
+ {
+ map<string,string> bios_id_raid = $[];
+ y2milestone ("probing StorageDevices" );
+ map<string,string> rename = $[];
+ tmp = StorageDevices::Probe(true);
+ foreach( string dev, map disk, tmp,
+ ``{
+ map dtmp = Storage::GetDiskPartitionTg( dev, $[] )[0]:$[];
+ y2milestone( "probing dev %1 disk %2", dev, dtmp );
+ if( search( dev, "/dev/dm-" )==0 || search( dev, "/dev/md" )==0 )
+ {
+ if( size(disk["bios_id"]:"")>0 )
+ bios_id_raid[dev] = disk["bios_id"]:"";
+ }
+ else if( size(dtmp["disk"]:"")>0 && dev != dtmp["disk"]:"" )
+ {
+ rename[dev] = dtmp["disk"]:"";
+ y2milestone( "probing rename %1", rename );
+ }
+ });
+ tmp = filter( string dev, map disk, tmp,
+ ``(search( dev, "/dev/dm-" )!=0));
+ tmp = filter( string dev, map disk, tmp,
+ ``(search( dev, "/dev/md" )!=0));
+ if( size(rename)>0 )
+ {
+ foreach( string old, string new, rename,
``{
- disk = getDiskInfo( dev, disk );
- integer s = disk["size_k"]:0 * 1024;
- disk["name"] = disk["dname"]:"" +
- Storage::ByteToHumanString( s ) + ", " +
- disk["device"]:"" + ", ";
- if( size( disk["vendor"]:"")>0 )
- disk["name"] = disk["name"]:"" + disk["vendor"]:"" + "-";
- disk["name"] = disk["name"]:"" + disk["model"]:"";
- if( haskey( disk, "dname" ))
- disk = remove( disk, "dname" );
- tmp[dev] = disk;
+ if( haskey( tmp, old ))
+ {
+ tmp[new] = tmp[old]:$[];
+ tmp = remove( tmp, old );
+ tmp[new,"device"] = new;
+ y2milestone( "probing old:%1 new:%2", old, tmp[new]:$[] );
+ }
+ });
+ }
+ y2milestone ("probing done" );
+ if( size(tmp)>0 )
+ {
+ probe_done = true;
+ changed = true;
+ foreach (string dev, map disk, tmp, {
+ tmp[dev] = getDiskInfo(dev, disk);
if( disk["dasdfmt"]:false )
Storage::InitializeDisk( dev, true );
});
- foreach( map c, conts,
- ``{
+ foreach (map c, conts, {
if( c["type"]:`CT_UNKNOWN!=`CT_DISK )
tmp[c["device"]:""] = getContainerInfo( c );
});
- if( size(bios_id_raid)>0 )
+ tmp = HandleBtrfsSimpleVolumes( tmp );
+ if (!isempty(bios_id_raid))
{
y2milestone( "bios_id_raid:%1", bios_id_raid );
foreach( string dm, string bios, bios_id_raid, {
@@ -3543,6 +3875,11 @@
});
});
}
+ if (Stage::initial())
+ {
+ tmp = AddProposalName(tmp);
+ tmp = AskCryptPasswords( tmp );
+ }
StorageMap[targets_key] = tmp;
}
}
@@ -3550,8 +3887,11 @@
{
tmp = StorageMap[targets_key]:$[];
SCR::Write(.target.ycp, Storage::SaveDumpPath("targetMap_i"), tmp );
- y2milestone ("AddSwapMp" );
- tmp = AddSwapMp( tmp );
+ if( !Mode::autoinst() )
+ {
+ y2milestone ("AddSwapMp" );
+ tmp = AddSwapMp( tmp );
+ }
CreateTargetBackup( "initial" );
if( (Stage::initial() || Mode::repair()) && !Mode::autoinst() )
{
@@ -3563,14 +3903,29 @@
}
map<string, map> ret = StorageMap[targets_key]:$[];
- if (changed)
- y2milestone("GetTargetMap changed:%1 ret:%2", changed, ret);
+ if( changed )
+ y2milestone("GetTargetMap changed:%1", changed );
else
- y2debug("GetTargetMap changed:%1 ret:%2", changed, ret);
+ y2debug("GetTargetMap changed:%1", changed );
+ foreach( string k, map m, ret,
+ ``{
+ if (changed)
+ y2milestone("GetTargetMap %1:%2", k, m);
+ else
+ y2debug("GetTargetMap %1:%2", k, m);
+ });
return ret;
}
+global list<string> GetAffectedDevices( string dev )
+ {
+ list<string> r = [];
+ integer ret = LibStorage::StorageInterface::getRecursiveUsing(sint,dev,r);
+ y2milestone( "GetAffectedDevices dev:%1 ret:%2 r:%3", dev, ret, r );
+ return( r );
+ }
+
global void SetRecursiveRemoval( boolean val )
{
y2milestone( "SetRecursiveRemoval val:%1", val );
@@ -3640,7 +3995,7 @@
dps = sort( map a, map b, dps, ``(a["nr"]:0>b["nr"]:0));
y2milestone( "SetTargetMap dps:%1", dps );
}
- foreach( map p, dps, ``{DeleteDevice( k, p["device"]:"" );});
+ foreach( map p, dps, ``{DeleteDevice( p["device"]:"" );});
if( tg[k,"create"]:false )
{
if( tg[k,"type"]:`CT_UNKNOWN==`CT_LVM )
@@ -3674,21 +4029,21 @@
``{
if( size(p["dtxt"]:"")>0 )
ChangeDescText( p["device"]:"", p["dtxt"]:"" );
- DeleteDevice( k, p["device"]:"" );
+ DeleteDevice( p["device"]:"" );
});
if( target[k,"delete"]:false )
{
if( target[k,"type"]:`CT_UNKNOWN==`CT_LVM )
DeleteLvmVg( target[k,"name"]:"" );
else if( target[k,"type"]:`CT_UNKNOWN==`CT_DISK )
- DeletePartitionTable( k );
+ DeletePartitionTable( k, target[k,"disklabel"]:"" );
else if( target[k,"type"]:`CT_UNKNOWN==`CT_DMRAID )
DeleteDmraid( k );
}
if( target[k,"del_ptable"]:false &&
IsPartType( target[k,"type"]:`CT_UNKNOWN ) )
{
- DeletePartitionTable( k );
+ DeletePartitionTable( k, target[k,"disklabel"]:"" );
}
});
keys = maplist( string k, any e, target, ``(k));
@@ -3773,16 +4128,24 @@
integer ret = LibStorage::StorageInterface::commit( sint );
if( ret<0 )
y2error( "CommitChanges sint ret:%1", ret );
+ Storage::UpdateTargetMap();
+
+ string env = getenv("YAST2_STORAGE_SLEEP_AFTER_COMMIT");
+ if (env != nil)
+ {
+ SCR::Execute(.target.bash, "sleep " + env);
+ }
+
return( ret );
}
global string DeviceMounted( string dev )
{
- string ret = "";
+ list<string> ret = [];
LibStorage::StorageInterface::checkDeviceMounted( sint, dev, ret );
- if( size(ret)>0 )
- y2milestone( "DeviceMounted %1 at %2", dev, ret );
- return( ret );
+ if (!isempty(ret))
+ y2milestone("DeviceMounted %1 at %2", dev, ret[0]:"");
+ return ret[0]:"";
}
/**
@@ -3832,57 +4195,30 @@
return( MountOpt( dev, mp, "" ) );
}
-global define map DetectHomeFs( map p )
+
+boolean DetectHomeFs( map p )
{
y2milestone( "DetectHomeFs p:%1", p );
- map ret = $[];
- boolean home = false;
- list poss_fs = [ `ext2, `ext3, `reiser, `xfs, `jfs ];
- if( !p["created"]:false && contains( poss_fs, p["detected_fs"]:`unknown ) &&
- size(p["device"]:"")>0 )
- {
- boolean mount_ok = false;
- string tmpdir = (string)SCR::Read(.target.tmpdir) + "/hmp";
- SCR::Execute(.target.mkdir, tmpdir );
- string fsto = FileSystems::DefaultFstabOptions( p );
- mount_ok = Storage::MountOpt( p["device"]:"", tmpdir, fsto );
- if( !mount_ok )
- mount_ok = Storage::Mount( p["device"]:"", tmpdir );
- else
- ret["fstopt"] = fsto;
- if( mount_ok )
- {
- list skip = [ ".", "..", "root" ];
- list tfile = [ ".profile", ".ssh", ".bashrc", ".kde2", ".gnome2", ".kde", ".gnome" ];
- list<string> files = (list<string>)SCR::Read (.target.dir, tmpdir);
- y2milestone( "DetectHomeFs files:%1", files );
- integer count=0;
-
- while( !home && count<size(files) )
- {
- string td = tmpdir + "/" + files[count]:"";
- if( !contains( skip, files[count]:"" ) &&
- FileUtils::IsDirectory( td ) )
- {
- integer i=0;
- while( !home && i<size(tfile) )
- {
- string tname = td + "/" + tfile[i]:"";
- home = FileUtils::GetSize( tname )>0;
- i = i+1;
- }
- }
- count = count+1;
- }
- Storage::Umount( p["device"]:"" );
- }
- SCR::Execute( .target.bash, "rmdir " + tmpdir );
+ boolean ret = false;
+ list<symbol> poss_fs = [ `ext2, `ext3, `ext4, `btrfs, `reiser, `xfs, `jfs ];
+ string device = p["device"]:"";
+ if( !p["create"]:false && contains( poss_fs, p["detected_fs"]:`unknown ) &&
+ !isempty(device) )
+ {
+ map<symbol, any> resize_info = $[];
+ map<symbol, any> content_info = $[];
+
+ if (GetFreeInfo(device, false, resize_info, true, content_info, true) &&
+ content_info[`homes]:0 > 0)
+ {
+ ret = true;
}
- ret["ishome"] = home;
- y2milestone( "DetectHomeFs ret:%1", ret );
- return( ret );
+ }
+ y2milestone("DetectHomeFs device:%1 ret:%2", device, ret);
+ return ret;
}
+
global define map SetVolOptions( map p, string mnt, symbol fs, string fs_opts,
string fstab_opts, string label )
{
@@ -3902,7 +4238,9 @@
ret["used_fs"] = Partitions::DefaultFs();
}
if( ret["used_fs"]:`unknown == `unknown ||
- ret["used_fs"]:`unknown == `none )
+ ret["used_fs"]:`unknown == `none ||
+ ret["used_fs"]:`unknown == `hfs ||
+ ret["used_fs"]:`unknown == `hfsplus )
ret["format"] = false;
else
ret["format"] = true;
@@ -3910,14 +4248,15 @@
ret["detected_fs"]:`unknown != `unknown && mnt=="/home" )
{
boolean lvm = p["type"]:`primary == `lvm;
- map h = DetectHomeFs( ret );
if( ( lvm && ret["name"]:""=="home") ||
- (!lvm && h["ishome"]:false ) )
+ (!lvm && DetectHomeFs(ret)))
{
ret["format"] = false;
- ret["used_fs"] = ret["detected_fs"]:`unknown;
- if( size(fstab_opts)==0 )
- fstab_opts = h["fstopt"]:"";
+ if( ret["used_fs"]:`unknown!=ret["detected_fs"]:`unknown )
+ {
+ ret["used_fs"] = ret["detected_fs"]:`unknown;
+ fstab_opts = FileSystems::DefaultFstabOptions(ret);
+ }
}
}
if( ret["format"]:false && !ret["create"]:false &&
@@ -3926,6 +4265,12 @@
ret["format"] = false;
ret["used_fs"] = `swap;
}
+ if( ret["format"]:false && ret["used_fs"]:`unknown==`btrfs && mnt=="/" )
+ {
+ list<string> def_subvol = [ "tmp", "var/tmp", "var/run" ];
+ ret["subvol"] = maplist( string s, def_subvol,
+ { return $[ "create" :true, "name" :s ]; });
+ }
if( size(fstab_opts)>0 )
ret["fstopt"] = fstab_opts;
else
@@ -3946,12 +4291,34 @@
return( ret );
}
+map FindBtrfsUuid( string uuid )
+ {
+ map btrfs = GetTargetMap()["/dev/btrfs"]:$[];
+ map ret = filter( map p, btrfs["partitions"]:[], ``(p["uuid"]:""==uuid ))[0]:$[];
+ y2milestone( "FindBtrfsUuid uuid:%1 ret:%2", uuid, ret );
+ return( ret );
+ }
+
+global boolean IsUsedBy( map p )
+ {
+ boolean ret = !isempty(p["used_by"]:[]);
+ if( ret && p["used_by",0,"type"]:`UB_NONE==`UB_BTRFS )
+ {
+ map b = FindBtrfsUuid( p["used_by",0,"device"]:"" );
+ if( size(b["devices"]:[])<=1 )
+ ret=false;
+ }
+ y2milestone( "IsUsedBy %1 by %2 ret:%3", p["device"]:"",
+ p["used_by"]:[], ret );
+ return( ret );
+ }
+
global boolean CanEdit( map p, boolean verbose )
{
boolean ret = true;
if( Stage::initial() )
{
- if( !p["created"]:false && !p["inactive"]:false &&
+ if( !p["create"]:false && !p["inactive"]:false &&
p["mount"]:""=="swap" )
{
ret = false;
@@ -3965,10 +4332,9 @@
Popup::Message( txt );
}
}
- if( size(part_insts)>0 && p["device"]:""==part_insts )
+ if (IsInstallationSource(p["device"]:""))
{
ret = false;
- y2milestone( "CanEdit part_insts:%1 p:%2", part_insts, p );
if( verbose )
{
string txt = sformat( _("
@@ -4046,7 +4412,7 @@
{
if (find(map partition, disk["partitions"]:[], {
return partition["device"]:"" != p["device"]:"" &&
- partition["used_by_type"]:`UB_NONE != `UB_NONE; }) != nil)
+ IsUsedBy(partition); }) != nil)
{
txt = sformat(_("
Partition %1 cannot be removed since other partitions on the
@@ -4064,19 +4430,23 @@
/**
* Reads and returns fstab from directory
*
+ * FIXME: please, add description of the list that is returned by this function.
+ *
+ * @struct [...unknown...]
+ *
* @param string directory
+ * @return list fstab?
*/
-global list ReadFstab( string dir )
+global list<map> ReadFstab(string dir)
{
- list ret = [];
+ list<map> ret = [];
list<any> vinfos = [];
boolean r = LibStorage::StorageInterface::readFstab( sint, dir, vinfos );
if( !r )
y2error( "ReadFstab sint dir %1 ret %2", dir, r );
else
{
- foreach( any info, vinfos,
- ``{
+ foreach( any info, vinfos, {
map p = $[];
p = volumeMap( info, p );
ret = add( ret, p );
@@ -4095,15 +4465,17 @@
}
-global map<symbol, any> GetCommitInfo()
+/**
+ * FIXME: please, add description of the list that is returned by this function.
+ */
+global list<map> GetCommitInfos()
{
- any info = LibStorage::CommitInfo::new("LibStorage::CommitInfo");
- LibStorage::StorageInterface::getCommitInfo(sint, true, info);
-
- map<symbol, any> ret = $[
- `destructive : LibStorage::CommitInfo::swig_destructive_get(info)
- ];
-
+ list<any> infos = [];
+ LibStorage::StorageInterface::getCommitInfos(sint, infos);
+ list<map> ret = maplist(any info, infos, {
+ return $[ `destructive : LibStorage::CommitInfo::swig_destructive_get(info),
+ `text : LibStorage::CommitInfo::swig_text_get(info) ];
+ });
return ret;
}
@@ -4111,22 +4483,25 @@
string save_chtxt = "";
global string ChangeText()
+{
+ list<string> texts = maplist(map info, GetCommitInfos(), {
+ string text = String::EscapeTags(info[`text]:"");
+ if (info[`destructive]:false)
+ text = "<font color=red>" + text + "</font>";
+ return text;
+ });
+
+ string ret = isempty(texts) ? "" : HTML::List(texts);
+
+ if (ret != save_chtxt)
{
- list<string> l = LibStorage::StorageInterface::getCommitActions( sint, true );
- string ret = "";
- if( size(l)>0 )
- ret = HTML::List( l );
- if( ret != save_chtxt )
- {
- foreach( string s, l,
- ``{
- y2milestone( "ChangeText %1", s );
- });
- save_chtxt = ret;
- }
- return( ret );
+ LibStorage::StorageInterface::dumpCommitInfos(sint);
}
+ return ret;
+}
+
+
global string LastAction()
{
string ret = LibStorage::StorageInterface::getLastAction( sint );
@@ -4163,6 +4538,7 @@
/**
* GetMountPoints()
* collect mountpoint:device as map to get a sorted list
+ *
* @returns: map of lists, the map key is the mount point,
* usually starting with a "/". Exception is "swap"
* For directory mount points (key starting with /) the value
@@ -4170,6 +4546,10 @@
* For swap mount points, the value is a list of lists:
* [[partitionName, fsid, targetdevice, raid_type], ...]
*
+ * FIXME: please, add more detailed description of the 'map of lists'
+ * with examples if possible.
+ *
+ * @struct $[ [...], [...], ... ]
*/
global define map GetMountPoints()
``{
@@ -4234,26 +4614,6 @@
return mountPoints;
}
-global define string
-GetIdSmaller( string disk, integer delim )
- ``{
- string ret = disk;
- map<string,map> tg = GetTargetMap();
- if( haskey( tg[disk,"partitions",0]:$[], "nr" ))
- {
- list<map> ps = filter( map p, tg[disk,"partitions"]:[], ``(p["nr"]:0<delim));
- if( size(ps)>1 )
- ps = sort( map a, map b, ps, ``(a["nr"]:0>b["nr"]:0));
- if( size(ps)>0 )
- ret = ps[0,"device"]:"";
- }
- else
- ret = tg[disk,"partitions",0,"device"]:disk;
- y2milestone( "GetIdSmaller disk:%1 delim:%2 ret:%3",
- disk, delim, ret );
- return( ret );
- }
-
/**
* Set <key> in partition <device> to the given <value> and return changed map <tg>
@@ -4273,19 +4633,13 @@
map tmp = GetDiskPartitionTg( device, tg )[0]:$[];
string disk = tmp["disk"]:"";
string dev = GetDeviceName( tmp["disk"]:"", tmp["nr"]:(any)0 );
- list r_part = filter(map part, tg[disk,"partitions"]:[],
- ``(part["device"]:"" != dev ));
- if( size(r_part)!=size(tg[disk,"partitions"]:[]) )
- {
- map p = filter( map part, tg[disk,"partitions"]:[],
- ``(part["device"]:"" == dev ))[0]:$[];
- if( size(p)>0 )
- {
- p[key] = value;
- r_part = add( r_part, p );
- tg[disk,"partitions"] = r_part;
- }
- }
+ tg[disk,"partitions"] =
+ maplist( map p, tg[disk,"partitions"]:[],
+ {
+ if( p["device"]:"" == dev )
+ p[key] = value;
+ return p;
+ });
return( tg );
}
@@ -4297,19 +4651,13 @@
map tmp = GetDiskPartitionTg( device, tg )[0]:$[];
string disk = tmp["disk"]:"";
string dev = GetDeviceName( tmp["disk"]:"", tmp["nr"]:(any)0 );
- list r_part = filter(map part, tg[disk,"partitions"]:[],
- ``(part["device"]:"" != dev ));
- if( size(r_part)!=size(tg[disk,"partitions"]:[]) )
- {
- map p = filter( map part, tg[disk,"partitions"]:[],
- ``(part["device"]:"" == dev ))[0]:$[];
- if( size(p)>0 )
- {
- p = filter(string k, any e, (map<string,any>)p, ``(k != key) );
- r_part = add( r_part, p );
- tg[disk,"partitions"] = r_part;
- }
- }
+ tg[disk,"partitions"] =
+ maplist( map p, tg[disk,"partitions"]:[],
+ {
+ if( p["device"]:"" == dev )
+ p = filter(string k, any e, (map<string,any>)p, ``(k != key) );
+ return p;
+ });
return( tg );
}
@@ -4396,31 +4744,12 @@
return( ret );
};
+
/**
- * Get list of all Partitions on all real disks
+ * Get list of all Linux Partitions on all real disks
* @return list Partition list
*/
-/*
-global define list GetPartitionList()``{
- list ret = [];
- foreach ( string dev, map disk, GetTargetMap(), ``{
- if( IsPartitionable( disk ) )
- {
- list<map> l = disk["partitions"]:[];
- ret = union( ret, maplist( map p, l, ``(p["device"]:"")));
- }
- });
- ret = sort( ret );
- y2debug( "GetPartitionList ret=%1", ret );
- return( ret );
- }
-*/
-
-/**
- * Get list of all Linux Partitions on all real disks
- * @return list Partition list
- */
-global define list GetOtherLinuxPartitions()``{
+global define list GetOtherLinuxPartitions()``{
list ret = [];
foreach ( string dev, map disk, GetTargetMap(), ``{
if( IsPartitionable( disk ) )
@@ -4428,7 +4757,7 @@
list<map> l = (list<map>) filter( map p, disk["partitions"]:[],
``(!p["format"]:false &&
Partitions::IsLinuxPartition(p["fsid"]:0)) );
- l = filter(map p, l, ``(contains( [`xfs, `ext2, `ext3, `jfs, `reiser],
+ l = filter(map p, l, ``(contains( [`xfs, `ext2, `ext3, `ext4, `btrfs, `jfs, `reiser],
p["used_fs"]:`unknown)));
l = filter(map p, l,
``(!FileSystems::IsSystemMp( p["mount"]:"", false )));
@@ -4442,25 +4771,20 @@
return( ret );
}
+
/**
* Check if swap paritition is availbe on a disk
* @param disk Disk to be checked
* @return boolean true if swap available.
*/
-global define boolean CheckSwapOn( string disk )``{
- boolean ret = false;
- list swaps = SwappingPartitions();
- while( size(swaps)>0 && !ret )
- {
- if( search( swaps[0]:"", disk )==0)
- {
- ret = true;
- }
- swaps = remove( swaps, 0 );
- }
- y2milestone( "CheckSwapOn %1 ret %2", disk, ret );
- return( ret );
- }
+global boolean CheckSwapOn(string disk)
+{
+ list<string> swaps = SwappingPartitions();
+ boolean ret = contains(SwappingPartitions(), disk);
+ y2milestone("CheckSwapOn disk:%1 ret:%2", disk, ret);
+ return ret;
+}
+
/**
* Returns list of primary partitions found
@@ -4469,12 +4793,9 @@
* @param boolean foreign_os
* @return list of primary partitions
*/
-global define list GetPrimPartitions( map<string,map> targets,
- boolean foreign_os )
- ``{
+list<map> GetPrimPartitions(map<string, map> targets, boolean foreign_os)
+ {
list<map> ret = [];
- map entry = $[];
- string text = "";
integer num_dos = 0;
integer num_win = 0;
integer num_os2 = 0;
@@ -4489,14 +4810,18 @@
foreach(map part, data["partitions"]:[],
``{
string device = part["device"]:"";
- if( part["type"]:`unknown == `primary &&
- SCR::Execute (.target.bash,
- "/usr/lib/YaST2/bin/check.boot "+device) == 0)
+ if (part["type"]:`unknown == `primary && !part["create"]:false &&
+ SCR::Execute(.target.bash, "/usr/lib/YaST2/bin/check.boot " + device) == 0)
{
- text = "";
+ string text = "";
if( Partitions::IsDosWinNtPartition( part["fsid"]:0 ) &&
- data["used_by_type"]:`UB_NONE==`UB_NONE &&
- GetFreeSpace( device, 0, part["used_fs"]:`none, false )["win_disk"]:false )
+ !IsUsedBy(data) )
+ {
+ map<symbol, any> resize_info = $[];
+ map<symbol, any> content_info = $[];
+
+ if (GetFreeInfo(device, false, resize_info, true, content_info, true) &&
+ content_info[`windows]:false)
{
if( contains( Partitions::fsid_dostypes, part["fsid"]:0 ) )
{
@@ -4509,6 +4834,7 @@
text = win_text;
}
}
+ }
else if( part["fsid"]:0 == 0x12 && !foreign_os )
{
text = "Vendor diagnostic";
@@ -4524,18 +4850,18 @@
text = linux_text;
num_linux = num_linux+1;
}
- if( size(text)>0 )
+ if (!isempty(text))
{
- entry["device"] = device;
- entry["string"] = text;
- ret = add( ret, eval(entry) );
- y2milestone( "new entry %1", entry );
+ map entry = $[ "device" : device, "string" : text ];
+ y2milestone( "new entry %1", entry );
+ ret = add(ret, entry);
}
}
});
});
y2milestone( "GetPrimPartitions foreign_os:%5 num_linux %1 num_win %2 num_dos %3 num_os2 %4",
num_linux, num_win, num_dos, num_os2, foreign_os );
+
integer num = 1;
if( num_linux>1 )
{
@@ -4592,9 +4918,10 @@
return( ret );
}
-global define list GetWinPrimPartitions( map<string,map> targets )
- ``{
- list ret = GetPrimPartitions( targets, true );
+
+global list<map> GetWinPrimPartitions(map<string, map> targets)
+ {
+ list<map> ret = GetPrimPartitions( targets, true );
y2milestone( "GetWinPrimPartitions ret %1", ret );
return( ret );
}
@@ -4623,27 +4950,26 @@
{
list<string> pl = hw_packages;
- map<string,map> tg = GetTargetMap();
+ map<string, map> target_map = GetTargetMap();
boolean need_lvm = false;
boolean need_nfs = false;
boolean need_quota = false;
boolean need_crypt = false;
- foreach( string k, map e, tg, {
+ foreach (string k, map e, target_map, {
if (e["type"]:`CT_UNKNOWN == `CT_LVM)
need_lvm = true;
if (e["type"]:`CT_UNKNOWN == `CT_NFS)
need_nfs = true;
- if( size(filter( map p, e["partitions"]:[],
- ``(FileSystems::HasQuota(p))))>0 )
+ if (find(map part, e["partitions"]:[], { return FileSystems::HasQuota(part); }) != nil)
need_quota = true;
- if( size(filter( map p, e["partitions"]:[],
- ``(p["enc_type"]:`none != `none)))>0 )
+ if (find(map part, e["partitions"]:[], { return part["enc_type"]:`none != `none; }) != nil)
need_crypt = true;
});
- y2milestone("AddPackageList need lvm:%1 need nfs: %2 quota:%3 crypt:%4", need_lvm, need_nfs, need_quota, need_crypt);
+ y2milestone("AddPackageList need_lvm:%1 need_nfs:%2 need_quota:%3 need_crypt:%4",
+ need_lvm, need_nfs, need_quota, need_crypt);
if (need_lvm)
{
@@ -4689,7 +5015,11 @@
//Set rather than Add, there might be some packs left over
//from previous 'MakeProposal' we don't need now
//This also covers the case when AddPackagesList returns [] or nil
- PackagesProposal::SetResolvables( proposal_ID, `package, pkgs );
+ if (!PackagesProposal::SetResolvables(proposal_ID, `package, pkgs))
+ {
+ y2error("PackagesProposal::SetResolvables() for %1 failed", pkgs);
+ Report::Error(sformat(_("Add the following resolvables failed: %1"), pkgs));
+ }
if( Stage::initial() )
{
@@ -4698,13 +5028,13 @@
}
-global define list GetForeignPrimary()
- ``{
- list ret = [];
+
+global list<string> GetForeignPrimary()
+ {
+ list<string> ret = [];
if( Arch::i386 () || Arch::ia64 () || Arch::x86_64 () )
{
- foreach(map e, (list<map>)GetPrimPartitions( GetTargetMap(), false ),
- ``{
+ foreach(map e, GetPrimPartitions( GetTargetMap(), false ), {
ret = add( ret, sformat( "%1 %2", e["device"]:"", e["string"]:"" ));
});
}
@@ -4712,15 +5042,16 @@
return( ret );
}
+
/**
* Returns whether a partition is resizable
*
* @param map partition
* @return map resizable ?
*/
-global define map IsResizable( map part )
- ``{
- map ret = FileSystems::IsResizable(`unknown);
+global map<string, boolean> IsResizable(map<string, any> part)
+ {
+ map<string, boolean> ret = FileSystems::IsResizable(`unknown);
if ((!Arch::s390() && Partitions::IsResizable(part["fsid"]:0)) ||
part["type"]:`none == `lvm)
{
@@ -4730,7 +5061,8 @@
}
else
{
- ret = FileSystems::IsResizable(part["used_fs"]:`unknown);
+ if (!(part["type"]:`none == `lvm && part["used_fs"]:`unknown == `vfat))
+ ret = FileSystems::IsResizable(part["used_fs"]:`unknown);
}
}
y2milestone( "IsResizable part:%1 ret:%2", part, ret );
@@ -4738,46 +5070,19 @@
}
-global integer FreeCylindersAfterPartition(string device)
+global boolean FreeCylindersAroundPartition(string device, integer& free_before, integer& free_after)
{
- integer free_before = 0;
- integer free_after = 0;
- integer ret = LibStorage::StorageInterface::freeCylindersAroundPartition(sint, device, free_before, free_after);
- if( ret >= 0 )
- {
- ret = free_after;
- y2milestone("FreeCylindersAfterPartition after:%1 before:%2", free_after, free_before );
- }
- else
- {
- y2milestone("FreeCylindersAfterPartition ret:%1", ret);
- ret = 0;
- }
+ boolean ret = LibStorage::StorageInterface::freeCylindersAroundPartition(sint, device, free_before, free_after) == 0;
+ y2milestone("FreeCylindersAfterPartition ret:%1 free_before:%2 free_after:%3", ret, free_before, free_after);
return ret;
}
-global define boolean CheckNextCreated( map disk, list region )
- ``{
- boolean ret = false;
- integer cylinder = region[0]:0 + region[1]:0;
- foreach(map part, disk["partitions"]:[], ``{
- if( part["region",0]:0 == cylinder && part["create"]:false )
- {
- ret = true;
- }
- });
- y2milestone( "CheckNextCreated region:%1 ret:%2", region, ret );
- return( ret );
- }
-
-global define string PathToDestdir( string pt )
- ``{
- if( Installation::scr_destdir != "/" )
- {
- pt = Installation::scr_destdir + pt;
- }
- return( pt );
+ global string PathToDestdir(string p)
+ {
+ if (Installation::scr_destdir != "/")
+ p = Installation::scr_destdir + p;
+ return p;
}
@@ -4833,7 +5138,7 @@
* @param map entry
* @return integer (0 and higher == OK, otherwise error)
*/
-global define integer AddFstabEntry( map e )
+integer AddFstabEntry( map e )
{
y2milestone( "AddFstabEntry entry:%1", e );
integer ret = 0;
@@ -5028,70 +5333,6 @@
}
-/*
-global define boolean DiskmapNeeded()
- ``{
- boolean ret = false;
- map<string,map> real_disks = filter( string k, map e, GetTargetMap(), ``(IsRealDisk( e )) );
- list<string> disks = (list<string>) maplist( string k, map e, real_disks, ``(k));
- y2milestone( "disks %1", disks );
- boolean scsi_disk = false;
- boolean ide_disk = false;
- foreach( string k, disks,
- ``{
- if( search( k, "/dev/sd" )==0 )
- {
- scsi_disk = true;
- }
- else if( search( k, "/dev/hd" )==0 )
- {
- ide_disk = true;
- }
- else
- {
- ret = true;
- }
- });
- ret = ret || (scsi_disk && ide_disk);
- if( !ret && ide_disk )
- {
- string abc = "abcdefghijklmnopqrstuvwxyz";
- integer idx = 0;
- foreach( string k, disks,
- ``{
- y2milestone( "dev %1 abc %2", substring(k, 7, 1),
- substring(abc, idx, 1));
- if( substring(k, 7, 1) != substring(abc, idx, 1) )
- {
- ret = true;
- }
- idx = idx+1;
- });
- }
- y2milestone( "ret %1 disks %2 ide %3 scsi %4", ret, size(disks), ide_disk,
- scsi_disk );
- return( ret );
- };
-*/
-
-
-/*
-global define list<string> GetDirPatterns( string dir, list patterns )
- ``{
- list<string> ret = [];
- string cmd = sformat( "cd %1 && (ls %2 2>/dev/null)", dir,
- mergestring( (list<string>)patterns, " "));
- map out = (map) SCR::Execute( .target.bash_output, cmd );
- ret = splitstring( out["stdout"]:"", "\n" );
- ret = filter( string e, ret, ``(size(e)>0) );
- ret = maplist( string e, ret, ``(dir+"/"+e));
- y2milestone( "dir %1 pat %2", dir, patterns );
- y2milestone( "ret %1", ret );
- return( ret );
- }
-*/
-
-
global define map GetBootPartition( string disk )
``{
map ret = $[];
@@ -5101,87 +5342,6 @@
return( ret );
}
-global define void UpdateFstabSubfs()
- ``{
- y2milestone( "UpdateFstabSubfs removing fstab entries for cdrom and floppy" );
- string tabpath = PathToDestdir( "/etc/fstab" );
- map fstab = Partitions::GetFstab( tabpath );
- integer line = 0;
- list<integer> rem_lines = [];
- while( line<=AsciiFile::NumLines( fstab ) )
- {
- map l = AsciiFile::GetLine( fstab, line );
- if( search( l["fields",1]:"", "/media/floppy" )==0 )
- {
- rem_lines = add( rem_lines, line );
- }
- else if( search( l["fields",1]:"", "/media/cdrom" )==0 ||
- search( l["fields",1]:"", "/media/dvd" )==0 ||
- search( l["fields",1]:"", "/media/cdrecorder" )==0 ||
- search( l["fields",1]:"", "/media/dvdrecorder" )==0 ||
- search( l["fields",1]:"", "/cdrom" )==0 ||
- search( l["fields",1]:"", "/dvd" )==0 ||
- search( l["fields",1]:"", "/cdrecorder" )==0 ||
- search( l["fields",1]:"", "/dvdrecorder" )==0 )
- {
- rem_lines = add( rem_lines, line );
- }
- line = line+1;
- }
- y2milestone( "UpdateFstabSubfs %1", rem_lines );
- if( size(rem_lines)>0 )
- {
- rem_lines = sort(rem_lines);
- AsciiFile::RemoveLines( fstab, rem_lines );
- }
- AsciiFile::RewriteFile( fstab, tabpath );
- }
-
-global define void UpdateFstabSysfs()
- ``{
- y2milestone( "UpdateFstabSysfs called" );
- string tabpath = PathToDestdir( "/etc/fstab" );
- map fstab = Partitions::GetFstab( tabpath );
- integer line = 0;
- boolean have_sysfs = false;
- while( !have_sysfs && line<=AsciiFile::NumLines( fstab ) )
- {
- map l = AsciiFile::GetLine( fstab, line );
- have_sysfs = l["fields",1]:"" == "/sys";
- line = line+1;
- }
- if( !have_sysfs )
- {
- map entry = FileSystems::GetFstabDefaultMap( "sys" );
- list fstlist = [ entry["spec"]:"", entry["mount"]:"",
- entry["vfstype"]:"", entry["mntops"]:"",
- sformat("%1",entry["freq"]:0),
- sformat("%1",entry["passno"]:0) ];
- y2milestone( "UpdateFstabSysfs entry %1", entry );
- y2milestone( "UpdateFstabSysfs fstlist %1", fstlist );
- AsciiFile::AppendLine( fstab, fstlist );
- AsciiFile::RewriteFile( fstab, tabpath );
- }
- }
-
-global define void UpdateFstabOptions() {
- y2milestone( "UpdateFstabOptions" );
- string tabpath = PathToDestdir( "/etc/fstab" );
- map fstab = Partitions::GetFstab( tabpath );
- integer line = 0;
- string n = "";
- while( line<=AsciiFile::NumLines( fstab ) )
- {
- map l = AsciiFile::GetLine( fstab, line );
- string options = l["fields", 3]:"";
- if (regexpmatch (options, "^\(.*,\)\?hotplug\(,.*\)\?$")) {
- options = regexpsub (options, "^\(.*,\)\?hotplug\(,.*\)\?$", "\\1nofail\\2");
- AsciiFile::ChangeLineField( fstab, line, 3, options );
- }
- line = line+1;
- }
- AsciiFile::RewriteFile( fstab, tabpath );
-}
global string HdToIseries( string input )
``{
@@ -5260,221 +5420,6 @@
return( ret );
}
-global define void UpdateFstabIseriesVd()
- ``{
- y2milestone( "UpdateFstabIseriesVd updating hdx to iseries/vdx" );
- string tabpath = PathToDestdir( "/etc/fstab" );
- map fstab = Partitions::GetFstab( tabpath );
- integer line = 0;
- string n = "";
- while( line<=AsciiFile::NumLines( fstab ) )
- {
- map l = AsciiFile::GetLine( fstab, line );
- n = HdToIseries( l["fields",0]:"" );
- if( n != l["fields",0]:"" )
- {
- AsciiFile::ChangeLineField( fstab, line, 0, n );
- }
- line = line+1;
- }
- AsciiFile::RewriteFile( fstab, tabpath );
- tabpath = PathToDestdir( "/etc/cryptotab" );
- map crtab = Partitions::GetCrypto( tabpath );
- line = 0;
- while( line<=AsciiFile::NumLines( crtab ) )
- {
- map l = AsciiFile::GetLine( crtab, line );
- n = HdToIseries( l["fields",1]:"" );
- if( n != l["fields",1]:"" )
- {
- AsciiFile::ChangeLineField( crtab, line, 1, n );
- }
- line = line+1;
- }
- AsciiFile::RewriteFile( crtab, tabpath );
- }
-
-global define void UpdateCdromLinks( map diskmap )
- ``{
- y2milestone( "UpdateCdromLinks map %1", diskmap );
- foreach( string link, StorageDevices::TypeNames,
- ``{
- string dev = "/dev/" + link;
- string cont = (string)SCR::Read( .target.symlink, dev );
- if( cont!=nil && search( cont, "/dev/") != 0 )
- cont = "/dev/" + cont;
- y2milestone( "UpdateCdromLinks dev %1 cont %2", dev, cont );
- if( cont!=nil && haskey( diskmap, cont ) && size(diskmap[cont]:"")>0 )
- {
- y2milestone( "Change symlink %1 from %2 -> %3", dev, cont,
- diskmap[cont]:"" );
- SCR::Execute( .target.remove, dev );
- SCR::Execute( .target.symlink, substring(diskmap[cont]:"",5), dev );
- }
- });
- }
-
-global define void UpdateFstabPersistentNames()
- ``{
- y2milestone( "UpdateFstabPersistentDevNames updating to SLES10 names" );
- string tabpath = PathToDestdir( "/etc/fstab" );
- map fstab = Partitions::GetFstab( tabpath );
- integer line = 0;
- string n = "";
- while( line<=AsciiFile::NumLines( fstab ) )
- {
- map l = AsciiFile::GetLine( fstab, line );
- n = SLES9PersistentDevNames( l["fields",0]:"" );
- if( n != l["fields",0]:"" )
- {
- AsciiFile::ChangeLineField( fstab, line, 0, n );
- }
- line = line+1;
- }
- AsciiFile::RewriteFile( fstab, tabpath );
- }
-
-global void UpdateFstabEvms2Lvm() {
- y2milestone( "UpdateFstabEvms2Lvm migrating EVMS to LVM" );
- string tabpath = PathToDestdir( "/etc/fstab" );
- map fstab = Partitions::GetFstab( tabpath );
- integer line = 0;
- string n = "";
- while( line<=AsciiFile::NumLines( fstab ) ) {
- map l = AsciiFile::GetLine( fstab, line );
- n = l["fields",0]:"";
- if (substring (n, 0, 15) == "/dev/evms/lvm2/")
- {
- n = "/dev/" + substring (n, 15);
- AsciiFile::ChangeLineField( fstab, line, 0, n );
- }
- line = line+1;
- }
- AsciiFile::RewriteFile( fstab, tabpath );
-}
-
-global define void UpdateFstabDiskmap( map diskmap )
- ``{
- y2milestone( "UpdateFstabDiskmap map %1", diskmap );
- string tabpath = PathToDestdir( "/etc/fstab" );
- map fstab = Partitions::GetFstab( tabpath );
- integer line = 0;
- string n = "";
- while( line<=AsciiFile::NumLines( fstab ) )
- {
- map l = AsciiFile::GetLine( fstab, line );
- n = HdDiskMap( l["fields",0]:"", diskmap );
- if( n != l["fields",0]:"" )
- {
- AsciiFile::ChangeLineField( fstab, line, 0, n );
- }
- line = line+1;
- }
- AsciiFile::RewriteFile( fstab, tabpath );
- tabpath = PathToDestdir( "/etc/cryptotab" );
- map crtab = Partitions::GetCrypto( tabpath );
- line = 0;
- while( line<=AsciiFile::NumLines( crtab ) )
- {
- map l = AsciiFile::GetLine( crtab, line );
- n = HdDiskMap( l["fields",1]:"", diskmap );
- if( n != l["fields",1]:"" )
- {
- AsciiFile::ChangeLineField( crtab, line, 1, n );
- }
- line = line+1;
- }
- AsciiFile::RewriteFile( crtab, tabpath );
- }
-
-global define void UpdateMdadm()
- ``{
- y2milestone( "UpdateMdadm" );
- string cpath = PathToDestdir( "/etc/mdadm.conf" );
- map file = $[];
- AsciiFile::SetComment( file, "^[ \t]*#" );
- AsciiFile::ReadFile( file, cpath );
- integer line = 0;
- boolean changed = false;
- while( line<=AsciiFile::NumLines( file ) )
- {
- if( search( file["l",line,"line"]:"", "DEVICE" )!=nil &&
- search( file["l",line,"line"]:"", "/dev/" )!=nil )
- {
- changed = true;
- file["l",line,"line"] = "DEVICE partitions";
- y2milestone( "UpdateMdadm %1", file["l",line]:$[] );
- }
- line = line+1;
- }
- if( changed )
- AsciiFile::RewriteFile( file, cpath );
- }
-
-global define void UpdateCryptoType()
- ``{
- y2milestone( "UpdateCryptoType" );
- string tabpath = PathToDestdir( "/etc/fstab" );
- map fstab = Partitions::GetFstab( tabpath );
- integer line = 0;
- integer pos = 0;
- string searchstr = "encryption=twofish256";
- while( line<=AsciiFile::NumLines( fstab ) )
- {
- map l = AsciiFile::GetLine( fstab, line );
- pos = search( l["fields",3]:"", searchstr );
- if( pos != nil )
- {
- string new = substring( l["fields",3]:"", 0, pos );
- new = new + "encryption=twofishSL92";
- new = new + substring( l["fields",3]:"", pos+size(searchstr) );
- y2milestone( "new options line in %1 is %2", l, new );
- AsciiFile::ChangeLineField( fstab, line, 3, new );
- }
- line = line+1;
- }
- AsciiFile::RewriteFile( fstab, tabpath );
- tabpath = PathToDestdir( "/etc/cryptotab" );
- map crtab = Partitions::GetCrypto( tabpath );
- line = 0;
- while( line<=AsciiFile::NumLines( crtab ) )
- {
- map l = AsciiFile::GetLine( crtab, line );
- if( l["fields",4]:"" == "twofish256" )
- {
- y2milestone( "set twofishSL92 in line %1", l );
- AsciiFile::ChangeLineField( crtab, line, 4, "twofishSL92" );
- }
- line = line+1;
- }
- AsciiFile::RewriteFile( crtab, tabpath );
- }
-
-global define void UpdateFstabUsbdevfs()
- ``{
- y2milestone( "UpdateFstabUsbdevfs updating usbdevfs to usbfs" );
- boolean changed = false;
- string tabpath = PathToDestdir( "/etc/fstab" );
- map fstab = Partitions::GetFstab( tabpath );
- integer line = 0;
- while( line<=AsciiFile::NumLines( fstab ) )
- {
- map l = AsciiFile::GetLine( fstab, line );
- if( l["fields",2]:"" == "usbdevfs" )
- {
- AsciiFile::ChangeLineField( fstab, line, 2, "usbfs" );
- AsciiFile::ChangeLineField( fstab, line, 0, "usbfs" );
- changed = true;
- }
- line = line+1;
- }
- if( changed )
- {
- y2milestone( "UpdateFstabUsbdevfs changed" );
- AsciiFile::RewriteFile( fstab, tabpath );
- }
- }
-
global define map BuildDiskmap( map oldv )
``{
@@ -5520,119 +5465,6 @@
return( DiskMap );
}
-/**
- * Updates fstab on disk
- *
- * @param map old version
- * @param map new version
- *
- * @struct version $[
- * // This means version 9.1
- * "major" : 9,
- * "minor" : 1,
- * ]
- */
-global define void Update( map oldv, map newv )
- ``{
- // bnc#477778 - Updating SLES 10 SP2 (GA+) to SLES 11 RC4 produces multiple identical grub boot menu entries
- // called_update is flag which indicates if Update() was already called
- if (!called_update)
- {
- y2milestone( "Update old:%1 new:%2", oldv, newv );
-
- // Enterprise products do not have minor release number
- // map enterprise releases to corresponding code bases of SL
- map sles_major_to_minor = $[ 8 : 2, 9 : 1, 10 : 1 ];
- if( haskey( oldv, "major" ) && !haskey( oldv, "minor" ) )
- {
- oldv["minor"] = sles_major_to_minor[oldv["major"]:0]:0;
- y2milestone( "Update old:%1", oldv );
- }
- if( haskey( newv, "major" ) && !haskey( newv, "minor" ) )
- {
- newv["minor"] = sles_major_to_minor[newv["major"]:0]:0;
- y2milestone( "Update new:%1", newv );
- }
- if( !haskey( oldv, "major" ) || !haskey( newv, "major" ) )
- y2error( "Missing key major or minor" );
-
- if( oldv["major"]:0<=9 )
- {
- UpdateFstabSysfs();
- }
- if( oldv["major"]:0<9 )
- {
- UpdateFstabUsbdevfs();
- }
- if( oldv["major"]:0==9 )
- {
- UpdateFstabPersistentNames();
- }
-
-
- // FIXME: proper fix
- UpdateFstabOptions();
-
- // remove EVMS
- // FIXME add appropriate condition if needed (does not seem so)
- UpdateFstabEvms2Lvm();
-
- map dm = BuildDiskmap( oldv );
- if( size(dm)>0 )
- {
- UpdateFstabDiskmap( dm );
- UpdateMdadm();
- }
- if( oldv["major"]:0<9 || (oldv["major"]:0==9 && oldv["minor"]:0<=2))
- {
- Storage::UpdateCryptoType();
- }
- if( oldv["major"]:0<10 || (oldv["major"]:0==10 && oldv["minor"]:0==0) )
- {
- string of = "/etc/udev/rules.d/20-cdrom.rules";
- y2milestone( "removing obsolete %1", of );
- SCR::Execute( .target.remove, of );
- of = "/etc/udev/rules.d/55-cdrom.rules";
- y2milestone( "removing obsolete %1", of );
- SCR::Execute( .target.remove, of );
- }
- if( oldv["major"]:0<10 || (oldv["major"]:0==10 && oldv["minor"]:0<=2) )
- {
- string of = "/etc/udev/rules.d/65-cdrom.rules";
- y2milestone( "removing obsolete %1", of );
- SCR::Execute( .target.remove, of );
- }
- if( oldv["major"]:0<10 || (oldv["major"]:0==10 && oldv["minor"]:0==0))
- UpdateFstabSubfs();
- if( oldv["major"]:0<9 || (oldv["major"]:0==9 && oldv["minor"]:0==0))
- {
- if( Arch::board_iseries () )
- {
- UpdateFstabIseriesVd();
- }
- string cmd = "cd / && /sbin/insserv -r /etc/init.d/boot.evms";
- y2milestone( "Update cmd %1", cmd );
- map bo = (map)SCR::Execute (.target.bash_output, cmd );
- y2milestone( "Update bo %1", bo );
- }
- if( oldv["major"]:0<10 || (oldv["major"]:0==10 && oldv["minor"]:0<=2))
- {
- string cmd = "cd / && /sbin/insserv /etc/init.d/boot.crypto";
- map bo = (map)SCR::Execute (.target.bash_output, cmd );
- y2milestone( "Update bo %1", bo );
-
- cmd = "cd / && /sbin/insserv /etc/init.d/boot.crypto-early";
- bo = (map)SCR::Execute (.target.bash_output, cmd );
- y2milestone( "Update bo %1", bo );
- }
- // set flag -> it indicates that Update was already called
- called_update = true;
- }
- else
- {
- y2milestone("Skip calling Update() -> It was already called");
- }
- }
global define list<string> GetTranslatedDevices( map oldv, map newv,
list<string> names )
@@ -5666,199 +5498,6 @@
return( ret );
}
-/*
-global define list GetUsedLvmGroups( map<string,map> tg )
- ``{
- list groups = [];
- foreach( string disk, map data, tg,
- ``{
- if( data["type"]:`CT_UNKNOWN==`CT_LVM &&
- size( filter( map p, data["partitions"]:[],
- ``(size(p["mount"]:"")>0 ) )) > 0 )
- {
- y2milestone( "GetUsedLvmGroups %1",
- filter( map p, data["partitions"]:[],
- ``(size(p["mount"]:"")>0 ) ) );
- groups = add( groups, substring( disk, 5 ) );
- }
- });
- y2milestone( "GetUsedLvmGroups ret %1", groups );
- return( groups );
- };
-*/
-
-/**
- * Get used real disks
- *
- * @param map <string,map> tg Target map
- * @param boolean ignore boot
- * @return list <string> disks List of disks
- */
-/*
-global define list<string> GetUsedRealDisksNew( map<string,map> tg,
- boolean ignore_boot )
- ``{
- list<string> disks = [];
- list lvmgr = GetUsedLvmGroups( tg );
- list mdlist = [];
- foreach( map p, tg["/dev/md","partitions"]:[],
- ``{
- if( size(p["mount"]:"")>0 ||
- contains( lvmgr, p["used_by"]:"" ) )
- {
- mdlist = add( mdlist, p["device"]:"" );
- }
- });
- foreach( string disk, map data, tg,
- ``{
- if( IsRealDisk( data ) &&
- size( filter( map p, data["partitions"]:[],
- ``( (size(p["mount"]:"")>0 &&
- (!ignore_boot ||
- p["mount"]:""!=Partitions::BootMount())) ||
- contains( mdlist, p["used_by"]:"" ) ||
- contains( lvmgr, p["used_by"]:"" ) ) )) > 0 )
- {
- disks = add( disks, disk );
- }
- });
- y2milestone( "GetUsedRealDisksNew ignore_boot %1 ret %2",
- ignore_boot, disks );
- return( disks );
- };
-*/
-
-/*
-global define list<string> GetUsedRealDisks( map<string,map> tg )
- {
- return( GetUsedRealDisksNew( tg, false ));
- };
-*/
-
-/*
-global define list<string> GetEvmsRealDisk( map<string,map> tg, map p )
- ``{
- list<string> rdisk = [];
- string name = "";
- string namel = "";
- if( size(p["device"]:"")>10 )
- name = substring( p["device"]:"", 10 );
- if( search( name, "lvm/" ) == 0 || search( name, "lvm2/" ) == 0)
- {
- name = substring( name, 0, findlastof( name, "/" ));
- }
- namel = name;
- integer pos = search( namel, "/" );
- if( pos != nil )
- {
- namel = substring( namel, pos+1 );
- }
- y2milestone( "GetEvmsRealDisk name is %1 namel is %2", name, namel );
- foreach( string disk, map data, tg,
- ``{
- if( size(name)>0 &&
- (IsRealDisk( data ) || disk=="/dev/md") &&
- ((size( filter( map p, data["partitions"]:[],
- ``(p["used_by_type"]:`UB_NONE==`UB_EVMS &&
- p["used_by"]:""==name)))>0) ||
- (size( filter( map p, data["partitions"]:[],
- ``(p["used_by_type"]:`UB_NONE==`UB_LVM &&
- p["used_by"]:""==namel)))>0) ))
- {
- list<string> dl = [ disk ];
- if( disk=="/dev/md" )
- {
- list<map> tl = [];
- tl = filter( map p, data["partitions"]:[],
- ``((p["used_by_type"]:`UB_NONE==`UB_EVMS &&
- p["used_by"]:""==name)||
- (p["used_by_type"]:`UB_NONE==`UB_LVM &&
- p["used_by"]:""==namel)));
- dl = maplist( map p, tl, ``(p["device"]:""));
- dl = (list<string>)sort( dl );
- dl = (list<string>)toset( dl );
- y2milestone( "GetEvmsRealDisk dl %1", dl );
- }
- rdisk = (list<string>)union( rdisk, dl );
- }
- });
- if( size(rdisk)==0 && !p["evms_native"]:false )
- {
- map d = GetDiskPartitionTg( EvmsDevDisk( p["device"]:"" ), tg )[0]:$[];
- if( haskey( tg, d["disk"]:"" ))
- {
- rdisk = [ d["disk"]:"" ];
- }
- }
- y2milestone( "GetEvmsRealDisk %1 is %2", p["device"]:"", rdisk );
- return( rdisk );
- }
-*/
-
-/*
-global define list<string> GetUsedEvmsDisks( map<string,map> tg )
- ``{
- list<string> disks = [];
- list mdlist = [];
- foreach( string disk, map data, tg,
- ``{
- if( search( disk, "/dev/evms" )==0 )
- {
- foreach( map p, data["partitions"]:[],
- ``{
- if( size(p["mount"]:"")>0 )
- {
- list<string> dl = GetEvmsRealDisk( tg, p );
- foreach( string d, dl,
- ``{
- y2milestone( "GetUsedEvmsDisks d %1", d );
- if( search( d, "/dev/md" ) == 0 )
- {
- list<string> ndl = [];
- foreach( string dd, map pp, tg,
- ``{
- map pu = find( map p, pp["partitions"]:[],
- ``(p["used_by"]:""==substring(d,5)) );
- y2milestone( "GetUsedEvmsDisks disk:%1 used:%2", dd, pu );
- if( pu!=nil && size(pu)>0 )
- {
- ndl = add( ndl, dd );
- }
- });
- disks = (list<string>)union( disks, ndl );
- }
- else
- {
- disks = (list<string>)union( disks, [d] );
- }
- });
- }
- });
- }
- });
- disks = sort( disks );
- y2milestone( "GetUsedEvmsDisks ret %1", disks );
- return( disks );
- };
-*/
-
-/*
-global list<map> GetPrepBoot( map<string,map> tg )
- {
- list<map> ret = [];
- list cl = [ 0x06, 0x41 ];
- foreach( string s, map e, tg,
- ``{
- if( IsRealDisk( e ) && Partitions::PrepBoot() )
- ret = (list<map>)merge( ret, filter( map p, e["partitions"]:[],
- ``( size(p["mount"]:"")==0 &&
- contains( cl, p["fsid"]:0 ) &&
- !p["delete"]:false )));
- });
- y2milestone( "GetPrepBoot ret:%1", ret );
- return( ret );
- }
-*/
void CallInsserv( boolean on, string name )
{
@@ -5876,68 +5515,16 @@
}
}
+
global void FinishInstall()
{
y2milestone("FinishInstall initial:%1", Stage::initial());
- map<string,map> tg = GetTargetMap();
+ map<string, map> target_map = GetTargetMap();
if( Stage::initial() )
{
- HandleModulesOnBoot( tg );
-/*
- list evms = GetUsedEvmsDisks( tg );
- y2milestone( "FinishInstall evms %1", evms );
- if( size(evms)>0 )
- CallInsserv( true, "evms" );
- list<string> nonevms = GetUsedRealDisks( tg );
- nonevms = filter( string d, nonevms, ``(!contains( evms, d )));
- nonevms = maplist( string d, nonevms, ``(substring(d,5)));
- y2milestone( "FinishInstall nonevms %1", nonevms );
- nonevms = (list<string>)merge( nonevms, maplist( map p, GetPrepBoot(tg),
- ``(substring(p["device"]:"",5))));
- y2milestone( "FinishInstall nonevms %1", nonevms );
- if( size(nonevms)>0 && SCR::Read( .target.size, "/etc/evms.conf" )>=0 )
- {
- map evmsconf = $[];
- AsciiFile::ReadFile( evmsconf, "/etc/evms.conf" );
- boolean found = false;
- integer i = 1;
- string regex1 = "^[ \t]*activate[ \t]*\\{";
- string regex2 = "^[ \t]*exclude[ \t]*=";
- string regex3 = "^[ \t]*\\}";
- while( i<=AsciiFile::NumLines(evmsconf) && !found )
- {
- found = regexpmatch( evmsconf["l",i,"line"]:"", regex1 );
- i = i+1;
- }
- found = false;
- boolean found2 = false;
- while( i<=AsciiFile::NumLines(evmsconf) && !found && !found2)
- {
- found = regexpmatch( evmsconf["l",i,"line"]:"", regex2 );
- found2 = regexpmatch( evmsconf["l",i,"line"]:"", regex3 );
- if( found )
- {
- string co = evmsconf["l",i,"line"]:"";
- integer pos = search( co, "[" );
- if( pos!=nil )
- co = substring( co, pos+1 );
- pos = search( co, "]" );
- if( pos!=nil )
- co = substring( co, 0, pos );
- y2milestone( "FinishInstall co = \"%1\"", co );
- string li = "\texclude = [ " + co +
- mergestring( nonevms, " " ) + " ]";
- y2milestone( "FinishInstall li = %1", li );
- evmsconf["l",i,"line"] = li;
- evmsconf["l",i,"buildline"] = false;
- AsciiFile::RewriteFile( evmsconf, "/etc/evms.conf" );
- }
- i = i+1;
- }
- }
-*/
+ HandleModulesOnBoot(target_map);
}
boolean need_crypt = false;
@@ -5946,11 +5533,10 @@
boolean need_dmraid = false;
boolean need_dmmultipath = false;
- foreach( string k, map e, tg, {
- if( size(filter( map p, e["partitions"]:[],
- ``(p["enc_type"]:`none != `none)))>0 )
+ foreach (string k, map e, target_map, {
+ if (find(map part, e["partitions"]:[], { return part["enc_type"]:`none != `none; }) != nil)
need_crypt = true;
- if( e["type"]:`CT_UNKNOWN==`CT_MD && size(e["partitions"]:[])>0 )
+ if (e["type"]:`CT_UNKNOWN == `CT_MD && !isempty(e["partitions"]:[]))
need_md = true;
if( e["type"]:`CT_UNKNOWN==`CT_MDPART )
need_md = true;
@@ -5980,22 +5566,20 @@
y2milestone("FinishInstall done");
}
-global define map GetEntryForMountpoint( string mp )
- ``{
- list<map> all_partitions = [];
- foreach( string dev, map disk, GetTargetMap(),
- ``{
- all_partitions = (list<map>)union( all_partitions,
- disk["partitions"]:[] );
+
+ global map GetEntryForMountpoint(string mp)
+ {
+ list<map> partitions = [];
+
+ foreach(string dev, map disk, GetTargetMap(), {
+ list<map> tmp = filter(map part, disk["partitions"]:[], { return part["mount"]:"" == mp; });
+ partitions = (list<map>) union(partitions, tmp);
});
- map partition = find( map part, all_partitions, ``(part["mount"]:""==mp) );
- if( partition==nil || partition["mount"]:"" != mp )
- {
- partition = $[];
- }
- return partition;
+
+ return partitions[0]:$[];
}
+
global define list GetRootInitrdModules()
``{
map partition = GetEntryForMountpoint( "/" );
@@ -6027,36 +5611,11 @@
}
if( partition["type"]:`unknown == `lvm )
{
- string vgname = substring( partition["device"]:"", 5 );
- vgname = substring( vgname, 0, findfirstof( vgname, "/" ));
- list<string> mod =
- (list<string>) maplist(map k, filter(map e, tg["/dev/md","partitions"]:[],
- ``(e["used_by"]:""==vgname) ),
- ``(k["raid_type"]:""));
- y2milestone( "GetRootInitrdModules mod %1", mod );
- foreach(string e, mod,
- ``{
- if( size(e)>0 && !contains( initrdmodules, e ) )
- {
- initrdmodules = add( initrdmodules, e );
- }
- });
- if( !contains( initrdmodules, "dm_mod" ) )
- {
- initrdmodules = add( initrdmodules, "dm_mod" );
- }
- }
- if( partition["type"]:`unknown == `evms )
- {
- string evmsco = partition["device"]:"";
- evmsco = substring( evmsco, 0, findlastof( evmsco, "/" ));
- y2milestone( "GetRootInitrdModules evmsco %1", evmsco );
- y2milestone( "GetRootInitrdModules evms %1", tg[evmsco]:$[] );
- list<string> md = filter( string s, tg[evmsco,"devices"]:[], ``(search(s,"/dev/md")==0));
- y2milestone( "GetRootInitrdModules mddev %1", md );
+ string vgdevice = substring( partition["device"]:"", 5 );
+ vgdevice = "/dev/" + substring( vgdevice, 0, findfirstof( vgdevice, "/" ));
list<string> mod =
(list<string>) maplist(map k, filter(map e, tg["/dev/md","partitions"]:[],
- ``(contains(md,e["device"]:""))),
+ ``(e["used_by_device"]:""==vgdevice) ),
``(k["raid_type"]:""));
y2milestone( "GetRootInitrdModules mod %1", mod );
foreach(string e, mod,
@@ -6100,153 +5659,22 @@
return initrdmodules;
};
-/**
- * CheckForLvmRootFs
- *---------------------------------------------------------------------
- * check if the root filesystem is a lvm logical volume
- *
- **/
-global define boolean CheckForLvmRootFs()
- ``{
- map part = GetEntryForMountpoint( "/" );
- y2milestone( "CheckForLvmRootFs root=%1", part );
- boolean ret = part["type"]:`primary==`lvm;
- y2milestone( "CheckForLvmRootFs ret=%1", ret );
- return ret;
- };
+ global boolean CheckForLvmRootFs()
+ {
+ map part = GetEntryForMountpoint("/");
+ boolean ret = part["type"]:`primary == `lvm;
+ y2milestone("CheckForLvmRootFs root:%1 ret:%2", part, ret);
+ return ret;
+ }
- /*---------------------------------------------------------------------
- * checkForMdRootFs
- *---------------------------------------------------------------------
- * check if the root filesystem is a md device
- *---------------------------------------------------------------------
- */
-global define boolean CheckForMdRootFs()
- ``{
- map part = GetEntryForMountpoint( "/" );
- boolean ret = part["type"]:`primary==`sw_raid;
- y2milestone( "CheckForMdRootFs root=%1", part );
- y2milestone( "CheckForMdRootFs ret=%1", ret );
- return ret;
- };
-global define void AdaptResize( string maindev, list region, integer schange )
- ``{
- map<string,map> tg = GetTargetMap();
- list<map> partitions = tg[maindev,"partitions"]:[];
- integer cylinder = region[0]:0 + region[1]:0;
- boolean found = false;
- integer index = -1;
- integer e_idx = -1;
- list<integer> idx_list = [];
- map part = (map) find(map p, partitions,
- ``(p["region",0]:0 == cylinder && p["create"]:false));
- y2milestone( "AdaptResize %1 reg %2 change %3", maindev, region, schange );
- if( part != nil )
- {
- found = false;
- index = 0;
- foreach(map p, partitions,
- ``{
- if( p["region",0]:0 == cylinder && p["create"]:false )
- {
- found = true;
- }
- else if( !found )
- {
- index = index + 1;
- }
- });
- if( partitions[index,"type"]:`primary == `extended )
- {
- e_idx = index;
- found = false;
- index = 0;
- foreach(map p, partitions,
- ``{
- if( p["region",0]:0 == cylinder && p["create"]:false &&
- p["type"]:`primary != `extended )
- {
- found = true;
- part = p;
- }
- else if( !found )
- {
- index = index + 1;
- }
- });
- }
- cylinder = part["region",0]:0 + part["region",1]:0;
- y2milestone( "AdaptResize part:%1", part );
- y2milestone( "AdaptResize index:%1 e_idx:%2 cylinder:%3", index, e_idx,
- cylinder );
- map pnew = (map) find( map p, partitions,
- ``( p["region",0]:0 == cylinder &&
- p["create"]:false ));
- y2milestone( "AdaptResize pnew:%1", pnew );
- while( pnew != nil &&
- (part["mount"]:"" == Partitions::BootMount() ||
- part["fsid"]:0==Partitions::fsid_swap ||
- part["region",1]:0 < (schange<0?(-1*schange):schange)) )
- {
- y2milestone( "AdaptResize pnew:%1", pnew );
- part = pnew;
- idx_list = add( idx_list, index );
- y2milestone( "AdaptResize index:%1 idx_list:%2", index, idx_list );
- found = false;
- index = 0;
- foreach(map p, partitions, ``{
- y2milestone( "found:%1 index:%2 p=%3", found, index, p );
- if( p["nr"]:0 == pnew["nr"]:0 )
- {
- found = true;
- }
- else if( !found )
- {
- index = index + 1;
- }
- });
- cylinder = part["region",0]:0 + part["region",1]:0;
- pnew = (map) find( map p, partitions,
- ``( p["region",0]:0 == cylinder &&
- p["create"]:false ));
- }
- y2milestone( "AdaptResize idx:%1 list:%2", index, idx_list );
-
- foreach(integer num, idx_list, ``{
- partitions[num,"region",0] = partitions[num,"region",0]:0 - schange;
- UpdatePartition( partitions[num,"device"]:"", partitions[num,"region",0]:0,
- partitions[num,"region",1]:1 );
- });
- partitions[index,"region",0] = partitions[index,"region",0]:0 - schange;
- partitions[index,"region",1] = partitions[index,"region",1]:0 + schange;
- if( partitions[index,"region",1]:0 <= 0 )
- {
- partitions[index,"region",1] = 1;
- }
- y2milestone( "AdaptResize increase p:%1", partitions[index]:$[] );
- UpdatePartition( partitions[index,"device"]:"", partitions[index,"region",0]:0,
- partitions[index,"region",1]:1 );
- if( e_idx>=0 )
- {
- partitions[e_idx,"region",0] = partitions[e_idx,"region",0]:0 - schange;
- partitions[e_idx,"region",1] = partitions[e_idx,"region",1]:0 + schange;
- if( partitions[e_idx,"region",1]:0 <= 0 )
- {
- partitions[e_idx,"region",1] = 1;
- }
- UpdatePartition( partitions[e_idx,"device"]:"", partitions[e_idx,"region",0]:0,
- partitions[e_idx,"region",1]:1 );
- }
- }
- else
- {
- y2error( "AdaptResize this should not happen %1", partitions );
- }
- y2milestone( "AdaptResize partitions:%1", partitions );
- y2milestone( "AdaptResize maindev:%1 region:%2 change:%3", maindev,
- region, schange );
+ global boolean CheckForMdRootFs()
+ {
+ map part = GetEntryForMountpoint("/");
+ boolean ret = part["type"]:`primary == `sw_raid;
+ y2milestone("CheckForMdRootFs root:%1 ret:%2", part, ret);
+ return ret;
}
@@ -6275,7 +5703,7 @@
(contains( [ `lvm, `sw_raid, `evms ], part["type"]:`unknown ) &&
size(part["mount"]:"")==0) ||
(part["enc_type"]:`none!=`none && !part["noauto"]:false) ||
- part["used_by_type"]:`UB_NONE != `UB_NONE ||
+ !IsUsedBy(part) ||
(contains( [ Partitions::fsid_prep_chrp_boot, Partitions::fsid_lvm,
Partitions::fsid_raid ], part["fsid"]:0 ) &&
size(part["mount"]:"")==0))
@@ -6307,9 +5735,9 @@
if( mount_point == "swap" )
{
vfstype = "swap";
- if( size(mntops) == 0 )
+ if (isempty(mntops))
{
- mntops = FileSystems::GetFstabDefaultMntops( "swap" );
+ mntops = FileSystems::GetFstabDefaultMap("swap")["mntops"]:"";
}
passno = 0;
}
@@ -6355,10 +5783,7 @@
string lower_point = tolower( mount_point );
if( lower_point != "" && mount_point != lower_point)
{
- if( Installation::scr_destdir != "/" )
- {
- lower_point = Installation::scr_destdir + lower_point;
- }
+ lower_point = PathToDestdir(lower_point);
y2milestone( "symlink %1 -> %2",
substring(mount_point,(findlastof(mount_point,"/")+1)),
lower_point );
@@ -6400,160 +5825,6 @@
};
-global boolean ProposalHome()
-{
- return( proposal_home );
-}
-
-global void SetProposalHome(boolean val)
-{
- proposal_home = val;
- y2milestone( "SetProposalHome val:%1", proposal_home );
-}
-
-global boolean ProposalLvm()
-{
- return proposal_lvm;
-}
-
-global void SetProposalLvm(boolean val)
-{
- proposal_lvm = val;
- y2milestone("SetProposalLvm val:%1", proposal_lvm);
-}
-
-global boolean ProposalEncrypt()
-{
- return proposal_encrypt;
-}
-
-global void SetProposalEncrypt(boolean val)
-{
- proposal_encrypt = val;
- y2milestone("SetProposalEncrypt val:%1", val);
-}
-
-global string ProposalPassword()
-{
- return proposal_password;
-}
-
-global void SetProposalPassword(string val)
-{
- proposal_password = val;
- y2milestone("SetProposalPassword");
-}
-
-
-global boolean ProposalEvms()
- {
- return false;
- }
-
-
-global void SetProposalDefault( boolean home_only )
- {
- SetProposalHome( cfg_xml["home"]:false );
- if( !home_only )
- {
- if( cfg_xml["prop_lvm"]:false )
- {
- SetProposalLvm(true);
- SetProposalEncrypt(false);
- SetProposalPassword("");
- }
- else
- {
- SetProposalLvm(false);
- }
- }
- y2milestone("SetProposalDefault home:%1 lvm:%2 encypt:%3 home_only:%4", proposal_home,
- proposal_lvm, proposal_encrypt, home_only);
- }
-
-
-global map<string, any> GetControlCfg()
-{
- integer StrToByte(string str)
- {
- integer bytes = 0;
- if (!LibStorage::StorageInterface::humanStringToByte(sint, str, true, bytes))
- y2error("cannot parse %1", str);
- return bytes;
- }
-
- if (size(cfg_xml) == 0)
- {
- boolean bt = ProductFeatures::GetBooleanFeature( "partitioning",
- "try_separate_home" );
- cfg_xml["home"] = bt?true:false;
-
- cfg_xml["root_percent"] =
- tointeger(ProductFeatures::GetStringFeature( "partitioning",
- "root_space_percent"));
- if( cfg_xml["root_percent"]:0 == nil || cfg_xml["root_percent"]:0 <= 0 )
- cfg_xml["root_percent"] = 40;
-
- string tmp = ProductFeatures::GetStringFeature( "partitioning",
- "limit_try_home");
- cfg_xml["home_limit"] = StrToByte(tmp) / (1024*1024);
- if( cfg_xml["home_limit"]:0 <= 0 )
- cfg_xml["home_limit"] = 5*1024;
-
- tmp = ProductFeatures::GetStringFeature( "partitioning",
- "root_base_size");
- cfg_xml["root_base"] = StrToByte(tmp) / (1024*1024);
- if( cfg_xml["root_base"]:0 <= 0 )
- cfg_xml["root_base"] = 3*1024;
-
- tmp = ProductFeatures::GetStringFeature( "partitioning",
- "root_max_size");
- cfg_xml["root_max"] = StrToByte(tmp) / (1024*1024);
- if( cfg_xml["root_max"]:0 <= 0 )
- cfg_xml["root_max"] = 10*1024;
-
- tmp = ProductFeatures::GetStringFeature( "partitioning",
- "vm_desired_size");
- cfg_xml["vm_want"] = StrToByte(tmp) / (1024*1024);
- if( cfg_xml["vm_want"]:0 <= 0 )
- cfg_xml["vm_want"] = 15*1024;
-
- tmp = ProductFeatures::GetStringFeature( "partitioning",
- "vm_home_max_size");
- cfg_xml["home_max"] = StrToByte(tmp) / (1024*1024);
- if( cfg_xml["home_max"]:0 <= 0 )
- cfg_xml["home_max"] = 25*1024;
-
- bt = ProductFeatures::GetBooleanFeature( "partitioning",
- "proposal_lvm" );
- cfg_xml["prop_lvm"] = bt?true:false;
-
- SetProposalDefault(false);
- y2milestone("GetControlCfg cfg_xml:%1", cfg_xml);
- }
-
- return cfg_xml;
-}
-
-
-global boolean BootEvms()
- {
- return false;
- }
-
-global string ProposalVM()
- {
- string ret = "";
- map xml = GetControlCfg();
- if (proposal_lvm)
- {
- ret = "system";
- }
- y2milestone("ProposalVM lvm:%1 ret:%2", proposal_lvm, ret);
- return ret;
- }
-
-
global void AddHwPackage( string name )
{
y2milestone( "AddHwPackage name %1 list:%2", name, hw_packages );
@@ -6569,7 +5840,7 @@
if (!on)
{
- SCR::Execute(.dbus.method,
+ SCR::Execute(.dbus.system.method,
$[ `destination : "org.freedesktop.Hal",
`path : "/org/freedesktop/Hal/Manager",
`interface : "org.freedesktop.Hal.Manager",
@@ -6579,7 +5850,7 @@
}
else
{
- SCR::Execute(.dbus.method,
+ SCR::Execute(.dbus.system.method,
$[ `destination : "org.freedesktop.Hal",
`path : "/org/freedesktop/Hal/Manager",
`interface : "org.freedesktop.Hal.Manager",
@@ -6599,49 +5870,6 @@
LibStorage::StorageInterface::dumpObjectList(sint);
}
-global define list<string> NoProposeDisks()
- {
- if( no_propose_disks == nil )
- {
- no_propose_disks = [];
- if( Stage::initial() && SCR::Read( .target.size, "/etc/install.inf" )>0 )
- {
- string inst = (string) SCR::Read( .etc.install_inf.Partition );
- y2milestone( "NoProposeDisks .etc.install_inf.Partition \"%1\"",
- inst );
- if( inst!=nil && size(inst)>0 )
- {
- if( search( inst, "/dev/" )!=0 )
- inst = "/dev/" + inst;
- map d = GetDiskPartition( inst );
- y2milestone( "NoProposeDisks inst:%1 disk:%2", inst, d );
- if( size(d["disk"]:"")>0 )
- no_propose_disks = add( no_propose_disks, d["disk"]:"" );
- }
- inst = (string) SCR::Read( .etc.install_inf.Cdrom );
- y2milestone( "NoProposeDisks .etc.install_inf.Cdrom \"%1\"", inst );
- if( inst!=nil && size(inst)>0 )
- {
- if( search( inst, "/dev/" )!=0 )
- inst = "/dev/" + inst;
- map d = GetDiskPartition( inst );
- y2milestone( "NoProposeDisks inst:%1 disk:%2", inst, d );
- if( size(d["disk"]:"")>0 )
- no_propose_disks = add( no_propose_disks, d["disk"]:"" );
- }
- }
- if( Stage::initial() )
- {
- map ret = (map)SCR::Execute( .target.bash_output, "echo $YAST2_STORAGE_NO_PROPOSE_DISKS" );
- y2milestone( "NoProposeDisks ret \"%1\"", ret["stdout"]:"" );
- list ls = filter( string e, splitstring( ret["stdout"]:"", " \t\n" ), ``(size(e)>0) );
- no_propose_disks = (list<string>)merge( no_propose_disks, ls );
- }
- y2milestone( "NoProposeDisks \"%1\"", no_propose_disks );
- }
- return( no_propose_disks );
- }
-
global void SetDefaultMountBy(symbol mby)
{
@@ -6667,6 +5895,22 @@
}
+global boolean SaveDeviceGraph(string filename)
+{
+ boolean ret = LibStorage::saveDeviceGraph(sint, filename);
+ y2milestone("SaveDeviceGraph filename:%1 ret:%2", filename, ret);
+ return ret;
+}
+
+
+global boolean SaveMountGraph(string filename)
+{
+ boolean ret = LibStorage::saveMountGraph(sint, filename);
+ y2milestone("SaveMountGraph filename:%1 ret:%2", filename, ret);
+ return ret;
+}
+
+
global boolean DeviceMatchFstab( string device, string fstab_spec )
{
boolean ret = false;
@@ -6688,85 +5932,28 @@
global boolean IsPersistent( map p )
- {
+{
boolean ret = contains( [ `lvm, `sw_raid, `dm ], p["type"]:`unknown );
- if( !ret && contains( [ `evms, `primary, `logical, `extended ],
- p["type"]:`unknown ))
- {
+ if( !ret && contains( [ `primary, `logical, `extended ], p["type"]:`unknown ))
+ {
map d = GetDisk( GetTargetMap(), p["device"]:"" );
- if( p["type"]:`unknown==`evms )
- ret = d["is_container"]:false || p["evms_native"]:false;
- else
- ret = d["type"]:`CT_UNKNONW==`CT_DMRAID || d["type"]:`CT_UNKNONW==`CT_DMMULTIPATH ||
- size(d["udev_id"]:[])>0;
- }
- y2milestone( "IsPersistent device:%1 ret:%2", p["device"]:"", ret );
- return( ret );
+ ret = d["type"]:`CT_UNKNONW==`CT_DMRAID || d["type"]:`CT_UNKNONW==`CT_DMMULTIPATH ||
+ size(d["udev_id"]:[])>0;
}
-
-global integer ActionsCount()
- {
- return size(LibStorage::StorageInterface::getCommitActions( sint, true ));
- }
-
- global boolean CheckEncryptionPasswords(string pw1, string pw2, integer min_length, boolean empty_allowed)
- {
- if (pw1 != pw2)
- {
- // popup text
- Popup::Message(_("The first and the second version\nof the password do not match.
-Try again."));
- return false;
+ y2milestone("IsPersistent device:%1 ret:%2", p["device"]:"", ret);
+ return ret;
}
- if (size(pw1) == 0 && !empty_allowed)
- {
- // popup text
- Popup::Message(_("You did not enter a password.
-Try again.
-"));
- return false;
- }
-
- if (size(pw1) < min_length && !empty_allowed)
- {
- // popup text
- Popup::Message(sformat(_("The password must have at least %1 characters.
-Try again.
-"), min_length));
- return false;
- }
-
- if (size(pw1) >= min_length || empty_allowed)
- {
- any tmp = findfirstnotof( pw1, "0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ#* ,.;:._-+!$%&/|\?{[()]}@^\\<>" );
- if (tmp != nil && size(pw1) > 0)
- {
- // popup text
- Popup::Message(_("The password may only contain the following characters:
- 0..9, a..z, A..Z, and any of \"@#* ,.;:._-+!$%&/|\?{[()]}^\\<>\".
-Try again."));
- return false;
- }
- }
-
- return true;
- }
-
-global boolean CheckCryptOk( string dev, string fs_passwd )
+global list<list> AllowdParity( string mdtype, integer sz )
{
- integer i = LibStorage::StorageInterface::verifyCryptPassword( sint, dev, fs_passwd );
- if( i!=0 )
- Popup::Error( sformat(_("Could not set encryption.
-System error code is %1.
-
-The crypt password provided could be incorrect.
-"), i ));
- y2milestone( "CheckCryptOk dev:%1 pwlen:%2 ret:%3",
- dev, size(fs_passwd), i==0 );
- return( i==0 );
+ integer mdt = conv_mdstring[mdtype]:0;
+ list<integer> pars =
+ LibStorage::StorageInterface::getMdAllowedParity(sint, mdt, sz );
+ list<list> ret = maplist( integer i, pars,
+ {return( [ toSymbol(conv_mdparity, i),
+ rev_conv_parstring[i]:"" ] );});
+ y2milestone( "ret:%1", ret );
+ return( ret );
}
}
-
-
Modified: branches/SuSE-Code-11-SP2-Branch/storage/storage/src/modules/StorageClients.ycp
URL: http://svn.opensuse.org/viewcvs/yast/branches/SuSE-Code-11-SP2-Branch/stora…
==============================================================================
--- branches/SuSE-Code-11-SP2-Branch/storage/storage/src/modules/StorageClients.ycp (original)
+++ branches/SuSE-Code-11-SP2-Branch/storage/storage/src/modules/StorageClients.ycp Tue May 17 13:39:44 2011
@@ -5,10 +5,7 @@
* Arvin Schnell <arvin(a)suse.de>
*
* Purpose: Define callbacks for libstorage.
- *
- * $Id$
*/
-
{
module "StorageClients";
@@ -18,8 +15,15 @@
import "SlideShow";
import "StorageCallbacks";
+ import "LibStorage";
+ import "LibStorage::StorageInterface";
+
textdomain "storage";
+
+ any sint = nil;
+
+
boolean enable_popup = false;
list<string> texts = [];
@@ -53,9 +57,9 @@
{
SlideShow::SubProgressStart( text );
SlideShow::AppendMessageToInstLog(text);
-
+
current_action = current_action + 1;
-
+
// hack: assume every text change means another action
y2milestone( "Current action: %1, total stage progress: %2", current_action, current_action * 100 / total_actions );
SlideShow::StageProgress( current_action * 100 / total_actions, nil );
@@ -74,56 +78,84 @@
global boolean YesNoPopup (string text)
{
y2milestone( "YesNoPopup txt:%1", text );
- return Report::AnyQuestion( Popup::NoHeadline(), text,
+ return Report::AnyQuestion( Popup::NoHeadline(), text,
Label::YesButton(), Label::NoButton(),
`yes );
}
-global list<any> PasswordPopup(string device, integer attempts, string password)
-{
- y2milestone("PasswordPopup device:%1 attempts:%2", device, attempts);
+ global boolean CommitErrorPopup(integer error, string last_action, string extended_message)
+ {
+ y2milestone("CommitErrorPopup error%1 last_action%2 extended_message:%3", error,
+ last_action, extended_message);
+
+ string text = _("Failure occurred during following action:") + "\n" + last_action + "\n\n";
+
+ string tmp = LibStorage::StorageInterface::getErrorString(sint, error);
+ if (!isempty(tmp))
+ {
+ text = text + tmp + "\n\n";
+ }
+
+ text = text + sformat(_("System error code was: %1"), error) + "\n\n";
- password = "";
+ if (!isempty(extended_message))
+ {
+ text = text + extended_message + "\n\n";
+ }
+
+ text = text + _("Continue despite the error?");
+
+ return Report::ErrorAnyQuestion(Popup::NoHeadline(), text, Label::ContinueButton(),
+ Label::AbortButton(), `focus_no);
+ }
+
+
+ global list<any> PasswordPopup(string device, integer attempts, string password)
+ {
+ y2milestone("PasswordPopup device:%1 attempts:%2", device, attempts);
- UI::OpenDialog(
- `opt(`decorated),
- `VBox(
- `Password(`id(`password),
- // Label: get password for device
- // Please use newline if label is longer than 40 characters
- sformat(_("&Enter password for device %1:"), device), password),
- `ButtonBox(
- // Ok button
- `PushButton(`id(`ok), `opt(`default), Label::OKButton()),
- // Cancel button
- `PushButton(`id(`cancel), Label::CancelButton())
+ password = "";
+
+ UI::OpenDialog(
+ `opt(`decorated),
+ `VBox(
+ `Password(`id(`password),
+ // Label: get password for device
+ // Please use newline if label is longer than 40 characters
+ sformat(_("&Enter password for device %1:"), device), password),
+ `ButtonBox(
+ `PushButton(`id(`ok), `opt(`default), Label::OKButton()),
+ `PushButton(`id(`cancel), Label::CancelButton())
+ )
)
- )
- );
+ );
- UI::SetFocus(`id(`password));
+ UI::SetFocus(`id(`password));
- symbol ret = (symbol) UI::UserInput();
+ symbol ret = (symbol) UI::UserInput();
- if (ret == `ok)
- password = (string) UI::QueryWidget(`id(`password), `Value);
+ if (ret == `ok)
+ password = (string) UI::QueryWidget(`id(`password), `Value);
- UI::CloseDialog();
+ UI::CloseDialog();
- return [ ret == `ok, password ];
-}
+ return [ ret == `ok, password ];
+ }
-global define void InstallCallbacks()
+global void InstallCallbacks(any value)
{
y2milestone( "InstallCallbacks" );
- StorageCallbacks::ProgressBar ("StorageClients::ProgressBar");
- StorageCallbacks::ShowInstallInfo ("StorageClients::ShowInstallInfo");
- StorageCallbacks::InfoPopup ("StorageClients::InfoPopup");
- StorageCallbacks::YesNoPopup ("StorageClients::YesNoPopup");
+
+ sint = value;
+
+ StorageCallbacks::ProgressBar("StorageClients::ProgressBar");
+ StorageCallbacks::ShowInstallInfo("StorageClients::ShowInstallInfo");
+ StorageCallbacks::InfoPopup("StorageClients::InfoPopup");
+ StorageCallbacks::YesNoPopup("StorageClients::YesNoPopup");
+ StorageCallbacks::CommitErrorPopup("StorageClients::CommitErrorPopup");
StorageCallbacks::PasswordPopup("StorageClients::PasswordPopup");
}
-} // module StorageClients
-
+}
Modified: branches/SuSE-Code-11-SP2-Branch/storage/storage/src/modules/StorageControllers.ycp
URL: http://svn.opensuse.org/viewcvs/yast/branches/SuSE-Code-11-SP2-Branch/stora…
==============================================================================
--- branches/SuSE-Code-11-SP2-Branch/storage/storage/src/modules/StorageControllers.ycp (original)
+++ branches/SuSE-Code-11-SP2-Branch/storage/storage/src/modules/StorageControllers.ycp Tue May 17 13:39:44 2011
@@ -15,17 +15,12 @@
module "StorageControllers";
import "Arch";
- import "Mode";
- import "ModulesConf";
import "ModuleLoading";
import "HwStatus";
import "Initrd";
- import "Kernel";
import "Storage";
import "StorageDevices";
import "StorageClients";
- import "Label";
- import "Popup";
import "Linuxrc";
textdomain "storage";
@@ -35,171 +30,14 @@
// must be kept in order (-> no map !)
// must be searchable (-> separate lists for names and args)
- global list moduleNames = [];
- global list moduleArgs = [];
- global list moduleIDs = []; //unique_id from probing
+ list<string> moduleNames = [];
+ list<string> moduleArgs = [];
list<list> ModToInitrdLx = [];
list<list> ModToInitrd = [];
- global string dasdParam = "";
+ list<map> controllers = []; // set by "Probe"
- // --------------------------------------------------------------
- // local values
-
- list controllers = []; // set by "Probe"
-
- // remember postinstall modules (like imm and ppa)
- // which must be installed *last*
-
- list postinstall_names = [ "imm", "ppa" ];
-
- // postinstall modules information
- // list of [ boolean modprobe,
- // string module_name,
- // string module_arg,
- // string vendor,
- // string device]
-
- list<list> postinstall_info = [];
-
- // --------------------------------------------------------------
-
-
-define list GetDasdList()
- ``{
- list ret = [];
- list<map> dasd = (list<map>) SCR::Read(.proc.dasddev);
- y2milestone( "dasd=%1", dasd );
- foreach( map entry, dasd,
- ``{
- term a = `item( `id(entry["name"]:"") );
- a = add( a, entry["name"]:"" );
- a = add( a, entry["address"]:"" );
- a = add( a, entry["state"]:"" );
- ret = add( ret, a );
- });
- return( ret );
- }
-
-define string S390DasdParams()
- ``{
- SCR::UnmountAgent (.proc.modules);
- map mod = (map)SCR::Read(.proc.modules);
- boolean mod_loaded = haskey(mod, "dasd_mod");
- y2milestone( "mod %1", mod );
- string param = (string)SCR::Read(.etc.install_inf.DASD_Parameter);
- if( param==nil )
- {
- param = "";
- }
- y2milestone( "param %1 size:%2", param, size(param) );
- boolean do_load = !mod_loaded || size(param)==0;
- if( do_load )
- {
- string okb = Label::AcceptButton();
- // button text
- string loadb = _("&Load Module");
- // popup text
- string text = sformat(
-_("Here, enter the parameters with which to load
-the dasd module, such as dasd=FD00-FD0F,FD40.
-Press \"%1\" to load the
-module.
-If the table shows the correct DASDs available,
-press \"%2\".
-"), deletechars(loadb,"&"), deletechars(okb,"&") );
-
- list cont = GetDasdList();
- UI::OpenDialog(
- `opt(`decorated),
- `HBox(
- `HSpacing(1),
- `VBox(
- `VSpacing(0.5),
- // heading text
- `Left(`Heading(_("DASD Module Parameter Setting"))),
- `VSpacing(0.2),
- `Left(`Label(text)),
- `VSpacing(0.2),
- `HBox(
- // label text
- `Left(`TextEntry(`id(`param), _("&DASD Parameter"),
- param )),
- `VSpacing(1),
- `Bottom(`PushButton(`id(`load), loadb ))
- ),
- `VSpacing(1),
- `HBox(
- `Table( `id(`dd_table),
- // heading text
- `header( _("DASD Name"),
- // heading text
- _("DASD Address"),
- // heading text
- _("Status") ),
- cont ),
- `VSpacing(10)
- ),
- `VSpacing(1),
- `HBox(
- `HStretch(),
- `PushButton(`id(`abort), Label::AbortButton() ),
- `HStretch(),
- `PushButton(`id(`accept), Label::AcceptButton() ),
- `HStretch()
- ),
- `VSpacing(0.5)
- ),
- `HSpacing(1)
- ));
- UI::SetFocus(`id(`param));
- symbol ret = `none;
- do
- {
- ret = (symbol)UI::UserInput();
- y2milestone( "ret = %1", ret );
- if( ret == `load )
- {
- if( mod_loaded )
- {
- SCR::Execute( .target.bash,
- "/sbin/rmmod dasd_eckd_mod dasd_fba_mod dasd_mod" );
- }
- param = (string)UI::QueryWidget( `id(`param), `Value );
- y2milestone( "param %1", param );
- boolean ret = (boolean)SCR::Execute(.target.modprobe, "dasd_mod", param );
- mod_loaded = true;
- y2milestone( "ret=%1", ret );
- if( !ret )
- {
- // popup text
- Popup::Error( sformat(_("Error loading module dasd with
-parameter: %1"), param ));
- }
- SCR::Execute(.target.modprobe, "dasd_eckd_mod", "" );
- SCR::Execute(.target.modprobe, "dasd_fba_mod", "" );
- cont = GetDasdList();
- UI::ChangeWidget( `id(`dd_table), `Items, cont );
- }
- else if( ret == `accept && size(cont)==0 )
- {
- ret = `continue;
- }
- if( (ret == `accept||ret == `abort) && size(cont)==0 )
- {
- // popup text
- Popup::Error( _("There are no DASD devices active.
-It is not possible to install without
-active DASD devices."));
- }
- }
- while( ret != `accept && ret != `abort );
- UI::CloseDialog();
- }
- y2milestone( "ret %1", param );
- return( param );
- }
/**
* Probe storage controllers
@@ -207,8 +45,8 @@
*
* @returns integer number of controllers, 0 = none found
*/
-global define integer Probe ()
- ``{
+global integer Probe()
+{
y2milestone( "StorageControllers::Probe()" );
// probe 'storage' list
@@ -220,77 +58,19 @@
y2milestone("no controllers");
}
return size (controllers);
- }
-
-
-
-// --------------------------------------------------------------
-
-// parportInitialize
-
-define void parportInitialize ()
- ``{
- // post-load parport module
- if ((size (postinstall_info) == 0) || Mode::test ())
- {
- return;
- }
-
- boolean parport_loaded = false;
- boolean parport_pc_loaded = false;
-
- foreach (list postlist, postinstall_info,
- ``{
- boolean post_modprobe = postlist[0]:false;
- string post_name = postlist[1]:"";
- string post_arg = postlist[2]:"";
- string post_vendor = postlist[3]:"";
- string post_device = postlist[4]:"";
- if (!parport_loaded)
- {
- if( `ok == ModuleLoading::Load( "parport", "", post_vendor,
- post_device, Linuxrc::manual (), true ))
- {
- ModulesConf::ModuleArgs ("parport", "");
- parport_loaded = true;
- }
- }
- if( !parport_pc_loaded)
- {
- if( `ok == ModuleLoading::Load( "parport_pc", "", post_vendor,
- post_device, Linuxrc::manual (), true ))
- {
- ModulesConf::ModuleArgs ("parport_pc", "");
- parport_pc_loaded = true;
- }
- }
-
- if( `ok == ModuleLoading::Load( post_name, post_arg, post_vendor,
- post_device, Linuxrc::manual (), post_modprobe))
- {
- ModulesConf::ModuleArgs (post_name, post_arg);
- Kernel::AddModuleToLoad(post_name);
+}
- moduleNames = add( moduleNames, post_name );
- moduleArgs = add( moduleArgs, post_arg );
- y2milestone( "moduleNames %1", moduleNames );
- y2milestone( "moduleArgs %1", moduleArgs );
- }
- });
- return;
- }
// start a controller (by loading its module)
// return true if all necessary modules were actually loaded
// return false if loading failed or was not necessary at all
-define boolean startController (map controller)
- ``{
+boolean StartController(map controller)
+{
// check module information
// skip controller if no module info available
list<map> module_drivers = controller["drivers"]:[];
- string module_id = controller["unique_key"]:"";
if (size (module_drivers) == 0)
return false;
@@ -349,23 +129,6 @@
string module_name = module_entry[0]:"";
string module_args = module_entry[1]:"";
- // remember postinstall modules
-
- if( contains( postinstall_names, module_name) )
- {
- y2milestone("startController name: %1 args: %2", module_name, module_args);
-
- list vendor_device =
- ModuleLoading::prepareVendorDeviceInfo(controller);
-
- // save data for parportInitialize
- postinstall_info =
- add( postinstall_info,
- [module_modprobe, module_name, module_args,
- vendor_device[0]:"", vendor_device[1]:""]);
- }
- else
- {
// load module if not yet loaded
if( !contains (moduleNames, module_name) )
{
@@ -402,18 +165,15 @@
// save data for modules.conf writing
moduleNames = add (moduleNames, module_name);
moduleArgs = add (moduleArgs, module_args);
- moduleIDs = add (moduleIDs, module_id);
y2milestone( "startController moduleNames %1", moduleNames );
y2milestone( "startController moduleArgs %1", moduleArgs );
- y2milestone( "startController moduleIDs %1", moduleIDs );
ModToInitrd = add( ModToInitrd, [ module_name,
module_args ] );
y2milestone( "startController ModToInitrd %1", ModToInitrd );
y2milestone( "startController ModToInitrdLx %1", ModToInitrdLx );
}
} // not yet loaded
- } // not postinstall
// break out of module load loop if one module failed
@@ -437,15 +197,15 @@
HwStatus::Set (unique_key, one_module_failed?`no:`yes);
- return (!one_module_failed);
- }
+ return !one_module_failed;
+}
// local function to go through list of resources (list of maps)
// checking if '"active":true' is set.
-define boolean anyActive (list<map> resources)
-``{
+boolean AnyActive(list<map> resources)
+{
boolean active = size(resources)==0;
foreach (map res, resources,
@@ -461,8 +221,8 @@
* Start storage related USB and FireWire stuff
*
*/
-global define void StartHotplugStorage ()
- ``{
+global void StartHotplugStorage()
+{
import "Hotplug";
// If USB capable, there might be an usb storage device (i.e. ZIP)
@@ -486,8 +246,6 @@
// load sbp2
ModuleLoading::Load ("sbp2", "", "", "SBP2 Protocol", Linuxrc::manual (), true);
}
-
- return;
}
/**
@@ -498,13 +256,11 @@
// O: list of [ loaded modules, module argument ]
*/
-global define void Initialize()
- ``{
+global void Initialize()
+{
moduleNames = [];
moduleArgs = [];
- map controller = $[];
integer cindex = 0;
- list ioresources = [];
boolean module_loaded = false;
ModToInitrd = [];
@@ -517,7 +273,7 @@
// use while(), continue not allowed in foreach()
while( !Arch::s390() && cindex < size(controllers) )
{
- controller = controllers[cindex]:$[];
+ map controller = controllers[cindex]:$[];
y2milestone( "Initialize controller %1", controller );
if( size(controller["requires"]:[])>0 )
@@ -537,8 +293,8 @@
// the controller is disabled in BIOS
// this is done by checking for an active IO or memory resource
- if( !(anyActive (controller["resource", "io"]:[])
- || anyActive (controller["resource", "mem"]:[])))
+ if( !(AnyActive (controller["resource", "io"]:[])
+ || AnyActive (controller["resource", "mem"]:[])))
{
y2milestone( "Initialize controller %1 disabled in BIOS",
controller["device"]:"" );
@@ -548,7 +304,7 @@
}
}
- module_loaded = startController(controller) || module_loaded;
+ module_loaded = StartController(controller) || module_loaded;
} // while (controller)
y2milestone( "Initialize module_loaded %1", module_loaded );
@@ -593,29 +349,23 @@
Initrd::AddModule( s[0]:"", s[1]:"" );
});
- y2milestone( "Initialize postinstall_info %1", postinstall_info );
-
- parportInitialize ();
-
// load all raid personalities
SCR::Execute(.target.modprobe, "raid0", "" );
SCR::Execute(.target.modprobe, "raid1", "" );
- SCR::Execute(.target.modprobe, "raid5", "" );
- SCR::Execute(.target.modprobe, "raid6", "" );
+ SCR::Execute(.target.modprobe, "raid5", "");
+ SCR::Execute(.target.modprobe, "raid6", "");
+ SCR::Execute(.target.modprobe, "raid10", "");
SCR::Execute(.target.modprobe, "multipath", "" );
StartHotplugStorage();
- y2milestone("Initialize all controllers initialized module_loaded:%1",
- module_loaded );
+ y2milestone("Initialize all controllers initialized module_loaded:%1", module_loaded);
+
StorageDevices::InitDone();
if( module_loaded )
Storage::ReReadTargetMap();
y2milestone( "Initialize calling EnablePopup()" );
StorageClients::EnablePopup();
-
- return;
-
-}; // Initialize ()
+};
}
Modified: branches/SuSE-Code-11-SP2-Branch/storage/storage/src/modules/StorageDevices.ycp
URL: http://svn.opensuse.org/viewcvs/yast/branches/SuSE-Code-11-SP2-Branch/stora…
==============================================================================
--- branches/SuSE-Code-11-SP2-Branch/storage/storage/src/modules/StorageDevices.ycp (original)
+++ branches/SuSE-Code-11-SP2-Branch/storage/storage/src/modules/StorageDevices.ycp Tue May 17 13:39:44 2011
@@ -24,22 +24,13 @@
import "Mode";
import "Stage";
- import "String";
import "HwStatus";
- import "Partitions";
- import "Installation";
- import "Kernel";
- import "AsciiFile";
-
- import "Arch";
- import "Report";
textdomain "storage";
-
boolean disks_valid = false;
- boolean raid_shown = false;
+
/**
* @return map of $["device": $[..target..], ...] for each ZIP drive
@@ -73,21 +64,12 @@
*/
list<map> cd_drives = nil;
- global list<string> TypeNames = [ "cdrom", "dvd", "cdrecorder", "dvdrecorder",
- "dvdram" ];
-
// storage for localProbe, see Probe()
integer targetMapSize = 0;
//---------------------------------------------------------------
-//---------------------------------------------------------------
-// CD Recorders and CD-ROM links
-list idecdrws = []; // list of IDE CD-RW drivers for ide-scsi
-list scsicds = []; // list of SCSI CDs
-
-
list<map> AddNormalLinknames( list<map> cddrives )
``{
map linknum = $[ "cdrom" : 0,
@@ -221,20 +203,6 @@
}
}
- // sort out idecdrws and scsicds
- foreach (map e, cd_drives,
- ``{
- if( (e["cdr"]:false || e["cdrw"]:false || e["dvdr"]:false ) &&
- e["bus"]:"" == "IDE" )
- {
- y2milestone ("IDE CD-RW %1", idecdrws );
- }
- if( e["bus"]:"" == "SCSI" )
- {
- scsicds = add (scsicds, e["dev_name"]:"");
- }
- });
-
string boot_device = (string) SCR::Read (.etc.install_inf.Cdrom);
if (boot_device == nil) boot_device = "";
@@ -383,19 +351,20 @@
* @return map TargetMap
*/
-global define map fakeProbe ()
- ``{
+map<string, map> fakeProbe()
+ {
string fake_map_file = ( Mode::test () ? "demo_target_map.ycp" : "test_target_map.ycp" );
y2milestone( "%1 mode - using fake target map from %2",
Mode::test () ? "Demo" : "Test", fake_map_file );
- map target_map = (map) SCR::Read( .target.yast2, fake_map_file );
+ map<string, map> target_map = (map<string, map>) SCR::Read( .target.yast2, fake_map_file );
y2debug( "Fake target map: %1", target_map );
return target_map;
- } // fakeProbe()
+ }
+
global boolean FloppyPresent()
{
@@ -425,9 +394,9 @@
* @return map TargetMap
*/
-define map localProbe()
- ``{
- map targets = $[];
+map<string, map> localProbe()
+ {
+ map<string, map> targets = $[];
if( Mode::test () )
{
return fakeProbe();
@@ -447,19 +416,14 @@
// loop over all_disks, constructing targets map
- integer ide_count = 0;
- integer scsi_count = 0;
- integer raid_count = 0;
- integer other_count = 0;
- string fake_raid = "";
- map target = $[];
zip_drives = $[];
- foreach (map disk, filter(map e,all_disks,``(size(e["dev_name"]:"")>0)),
- ``{
- target = $[];
+ foreach (map disk, filter(map e, all_disks, ``(!isempty(e["dev_name"]:""))), {
+
y2milestone( "localProbe: disk %1", disk );
+ map<string, any> target = $[];
+
boolean no_disk = false;
boolean notready = disk["notready"]:false &&
disk["device"]:"" != "DASD";
@@ -472,15 +436,7 @@
if( disk["hotpluggable"]:false )
target["hotpluggable"] = true;
if( disk["softraiddisk"]:false )
- {
target["softraiddisk"] = true;
- if( size(fake_raid)>0 )
- {
- fake_raid = fake_raid + " ";
- }
- fake_raid = fake_raid + disk["dev_name"]:"";
- y2milestone( "localProbe: fake_raid %1", fake_raid );
- }
map<string, any> res_fc = disk["resource", "fc", 0]:$[];
if (res_fc != $[])
@@ -492,69 +448,22 @@
if( no_disk )
continue;
- string bus = disk["bus"]:"?";
- string dname = "";
- integer i = 0;
-
// write out data for hardware status check
HwStatus::Set (disk["unique_key"]:"", `yes);
target["unique"] = disk["unique_key"]:"";
- // ------------------------------------------------------
- // check bus, count disks per bus
-
- if (bus == "IDE")
- {
- ide_count = ide_count + 1;
- i = ide_count;
- }
- else if (bus == "SCSI")
- {
- scsi_count = scsi_count + 1;
- i = scsi_count;
- }
- else if (bus == "RAID")
- {
- raid_count = raid_count + 1;
- i = raid_count;
- }
- else
- {
- other_count = other_count + 1;
- i = other_count;
- }
-
- target["bus"] = bus;
-
- // ------------------------------------------------------
- // construct disk name for user
-
- dname = ""+i+". ";
- if( bus != "None" )
- {
- dname = dname + bus;
- }
- else
- {
- dname = dname + "Disk";
- }
- dname = dname + ", ";
- target["dname"] = dname;
+ target["bus"] = disk["bus"]:"?";
// needed also later as key
string ddevice = disk["dev_name"]:"";
target["device"] = ddevice;
if( size(disk["bios_id"]:"")>0 )
- {
target["bios_id"] = disk["bios_id"]:"";
- }
y2milestone("localProbe: disk: %1", ddevice );
- // call fdisk agent to get size information
-
// ------------------------------------------------------
// construct full target name
@@ -612,8 +521,6 @@
targets[ddevice]:$[] );
}); // foreach (disk)
- SCR::UnmountAgent(.disk);
-
zip_drives = (map<string,map>)union( zip_drives, findZIPs() );
foreach(string k, any e, zip_drives,
@@ -634,16 +541,16 @@
* @param boolean force_reset
*/
-global define map Probe(boolean force_reset)
- ``{
- map target = $[];
+global map<string, map> Probe(boolean force_reset)
+ {
+ map<string, map> target = $[];
y2milestone( "Probe force_reset:%1 disks_valid:%2", force_reset, disks_valid );
if( force_reset )
targetMapSize = 0;
if( targetMapSize==0 && disks_valid )
{
- target = localProbe();
+ target = (map<string, map>) localProbe();
targetMapSize = size(target);
ProbeCDROMs();
}
@@ -677,6 +584,5 @@
{
disks_valid = true;
}
- return;
}
}
Modified: branches/SuSE-Code-11-SP2-Branch/storage/storage/src/modules/StorageFields.ycp
URL: http://svn.opensuse.org/viewcvs/yast/branches/SuSE-Code-11-SP2-Branch/stora…
==============================================================================
--- branches/SuSE-Code-11-SP2-Branch/storage/storage/src/modules/StorageFields.ycp (original)
+++ branches/SuSE-Code-11-SP2-Branch/storage/storage/src/modules/StorageFields.ycp Tue May 17 13:39:44 2011
@@ -12,12 +12,15 @@
import "Storage";
+ import "StorageIcons";
import "FileSystems";
import "Partitions";
+ import "Directory";
import "Mode";
import "HTML";
import "Integer";
import "String";
+ import "Region";
/**
@@ -26,12 +29,13 @@
global void IterateTargetMap(map<string, map> target_map, void(map<string, map>, map) callback)
{
const map disk_order = $[ `CT_DMRAID : 0, `CT_DMMULTIPATH : 1, `CT_MDPART : 2, `CT_DISK : 3,
- `CT_MD : 4, `CT_LOOP : 5, `CT_LVM : 6, `CT_DM : 7, `CT_NFS : 8 ];
+ `CT_MD : 4, `CT_LOOP : 5, `CT_LVM : 6, `CT_DM : 7, `CT_NFS : 8,
+ `CT_BTRFS : 9, `CT_TMPFS : 10 ];
list<string> keys = maplist(string dev, map disk, target_map, { return dev; });
keys = sort(string a, string b, keys, {
- integer oa = disk_order[target_map[a, "type"]:`CT_UNKNOWN]:9;
- integer ob = disk_order[target_map[b, "type"]:`CT_UNKNOWN]:9;
+ integer oa = disk_order[target_map[a, "type"]:`CT_UNKNOWN]:10;
+ integer ob = disk_order[target_map[b, "type"]:`CT_UNKNOWN]:10;
return (oa==ob) ? (a<b) : (oa<ob);
});
@@ -53,23 +57,28 @@
}
- string UsedByString(symbol used_by_type, string used_by)
+ string UsedByString(map<string, any> used_by)
{
- switch (used_by_type)
+ symbol type = used_by["type"]:`UB_NONE;
+ string device = used_by["device"]:"";
+
+ switch (type)
{
case `UB_LVM:
- return "LVM " + used_by;
+ return "LVM " + device;
case `UB_DM:
- return "DM " + used_by;
+ return "DM " + device;
case `UB_DMRAID:
- return "DM RAID " + used_by;
+ return "DM RAID " + device;
case `UB_DMMULTIPATH:
- return "DM Multipath " + used_by;
+ return "DM Multipath " + device;
case `UB_MD:
case `UB_MDPART:
- return "RAID " + used_by;
+ return "MD RAID " + device;
+ case `UB_BTRFS:
+ return "BTRFS " + device;
default:
- return used_by;
+ return device;
}
}
@@ -187,6 +196,11 @@
header = add(header, _("Stripes"));
break;
+ case `raid_version:
+ // Column header
+ header = add(header, _("RAID Version"));
+ break;
+
case `raid_type:
// Column header
header = add(header, _("RAID Type"));
@@ -336,13 +350,19 @@
ret = ret + _("<b>Mount By</b> indicates how the file system
is mounted: (Kernel) by Kernel Name, (Label) by File System Label, (UUID) by
File System UUID, (ID) by Device ID, and (Path) by Device Path.");
+ if (Mode::normal())
+ // helptext for table column and overview entry
+ ret = ret + " " + _("A question mark (?) indicates that
+the file system is not listed in <tt>/etc/fstab</tt>. It is either mounted
+manually or by some automount system. When changing setting of this volume
+YaST will not update <tt>/etc/fstab</tt>.");
break;
case `mount_point:
// helptext for table column and overview entry
ret = ret + _("<b>Mount Point</b> shows where the file system
is mounted.");
- if (Mode::normal() || true)
+ if (Mode::normal())
// helptext for table column and overview entry
ret = ret + " " + _("An asterisk (*) after the mount point
indicates a file system that is currently not mounted (for example, because it
@@ -358,15 +378,20 @@
case `parity_algorithm:
// helptext for table column and overview entry
ret = ret + _("<b>Parity Algorithm</b> shows the parity
-algorithm for RAID devices with RAID type 5.");
+algorithm for RAID devices with RAID type 5, 6 or 10.");
break;
case `pe_size:
// helptext for table column and overview entry
- ret = ret + _("<b>PE Size</b> shows the physical extend size
+ ret = ret + _("<b>PE Size</b> shows the physical extent size
for LVM volume groups.");
break;
+ case `raid_version:
+ // helptext for table column and overview entry
+ ret = ret + _("<b>RAID Version</b> shows the RAID version.");
+ break;
+
case `raid_type:
// helptext for table column and overview entry
ret = ret + _("<b>RAID Type</b> shows the RAID type, also
@@ -438,15 +463,18 @@
}
- string MakeSubInfo(map disk, map part, symbol field, symbol style)
+ any MakeSubInfo(map disk, map part, symbol field, symbol style)
{
map data = (part == nil ? disk : part);
+ symbol type = ( part == nil ? disk["type"]:`primary : part["type"]:`CT_DISK );
+
+ string device = data["device"]:"";
switch (field)
{
case `device:
{
- string value = data["device"]:"";
+ string value = device;
if (style == `table)
return value;
else
@@ -485,21 +513,21 @@
{
value = "RAID " + disk_device;
}
- else if(disk["type"]:`CT_UNKNOWN==`CT_LVM)
+ else if (disk["type"]:`CT_UNKNOWN == `CT_LVM)
{
value = "LVM" + (disk["lvm2"]:false ? "2 " : " ") + disk["name"]:"";
}
- else if(disk["type"]:`CT_UNKNOWN==`CT_DMRAID)
+ else if (disk["type"]:`CT_UNKNOWN == `CT_DMRAID)
{
value = "DM RAID " + disk["name"]:"";
}
- else if(disk["type"]:`CT_UNKNOWN==`CT_DMMULTIPATH)
+ else if (disk["type"]:`CT_UNKNOWN == `CT_DMMULTIPATH)
{
value = "DM Multipath " + disk["name"]:"";
}
- else if(disk["type"]:`CT_UNKNOWN==`CT_MDPART)
+ else if (disk["type"]:`CT_UNKNOWN == `CT_MDPART)
{
- value = "MD " + disk["name"]:"";
+ value = "MD RAID " + disk["name"]:"";
}
else
{
@@ -513,7 +541,7 @@
value = part["fstype"]:"";
}
if (style == `table)
- return value;
+ return `cell(`icon(Directory::icondir + "22x22/apps/" + StorageIcons::IconMap(type)), value);
else
// row label
return sformat(_("Type: %1"), String::EscapeTags(value));
@@ -540,10 +568,13 @@
{
boolean value = data["enc_type"]:`none != `none;
if (style == `table)
- {
+ {
if (value)
{
- return "E";
+ if (UI::GetDisplayInfo()["HasIconSupport"]:false)
+ return `cell(`icon(Directory::icondir + "22x22/apps/" + StorageIcons::encrypted_icon), "");
+ else
+ return "E";
}
else
return "";
@@ -568,8 +599,13 @@
case `mount_point:
{
string value = data["mount"]:"";
- if (Mode::normal() && data["inactive"]:false )
- value = value + " *";
+
+ if (Mode::normal())
+ {
+ if (data["inactive"]:false )
+ value = value + " *";
+ }
+
if (style == `table)
return value;
else
@@ -580,11 +616,20 @@
case `mount_by:
{
string value = "";
+
if (data["mount"]:"" != "") {
map tmp = $[ `device : "Kernel", `uuid : "UUID", `label : "Label", `id : "ID", `path : "Path" ];
symbol mount_by = data["mountby"]:`device;
value = tmp[mount_by]:"";
}
+
+ if (Mode::normal())
+ {
+ boolean tmp = false;
+ if (Storage::GetIgnoreFstab(device, tmp) && tmp)
+ value = "?";
+ }
+
if (style == `table)
return value;
else
@@ -594,12 +639,16 @@
case `used_by:
{
- string value = UsedByString(data["used_by_type"]:`UB_NONE, data["used_by_device"]:"");
if (style == `table)
- return value;
+ return UsedByString(data["used_by", 0]:$[]);
else
- // row label, %1 is replace by used by device name e.g. /dev/system
- return sformat(_("Used By: %1"), String::EscapeTags(value));
+ {
+ integer n = size(data["used_by"]:[]);
+ return mergestring(maplist(integer i, Integer::Range(n == 0 ? 1 : n), {
+ // row label, %1 is replaced by number, %2 is replace by device name e.g. /dev/system
+ return sformat(_("Used By %1: %2"), i+1, String::EscapeTags(UsedByString(data["used_by", i]:$[])));
+ }), HTML::Newline());
+ }
}
case `uuid:
@@ -687,7 +736,10 @@
case `bus:
{
- string value = data["bus"]:"";
+ map<symbol, string> names = $[ `sbp : "Firewire", `ata : "ATA",
+ `fc : "Fibre Channel", `iscsi : "iSCSI", `sas : "SAS",
+ `sata : "SATA", `spi : "SCSI", `usb : "USB" ];
+ string value = names[data["transport"]:`unknown]:"";
if (style == `table)
return value;
else
@@ -711,7 +763,7 @@
{
string value = "";
if (disk["type"]:`CT_UNKNOWN == `CT_LVM && part == nil)
- value = Storage::ByteToHumanStringWithPrecision(disk["pesize"]:0, 2, true);
+ value = Storage::ByteToHumanStringOmitZeroes(disk["pesize"]:0);
if (style == `table)
return value;
else
@@ -729,7 +781,7 @@
if (stripes == 1)
value = sformat("%1", stripes);
else
- value = sformat("%1 (%2)", stripes, Storage::KByteToHumanStringWithPrecision(stripesize, 2, true));
+ value = sformat("%1 (%2)", stripes, Storage::KByteToHumanStringOmitZeroes(stripesize));
}
if (style == `table)
return value;
@@ -738,6 +790,16 @@
return sformat(_("Stripes: %1"), value);
}
+ case `raid_version:
+ {
+ string value = data["sb_ver"]:"";
+ if (style == `table)
+ return value;
+ else
+ // row label, %1 is replace by raid version e.g. "1.00"
+ return sformat(_("RAID Version: %1"), value);
+ }
+
case `raid_type:
{
string value = toupper(data["raid_type"]:"");
@@ -751,9 +813,10 @@
case `chunk_size:
{
string value = "";
- if (contains(["raid0", "raid5"], data["raid_type"]:"")) {
+ if (data["raid_type"]:""=="raid0" ||
+ Storage::HasRaidParity(data["raid_type"]:"")) {
integer chunksize = data["chunk_size"]:0;
- value = Storage::KByteToHumanStringWithPrecision(chunksize, 2, true);
+ value = Storage::KByteToHumanStringOmitZeroes(chunksize);
}
if (style == `table)
return value;
@@ -765,7 +828,7 @@
case `parity_algorithm:
{
string value = "";
- if (contains(["raid5"], data["raid_type"]:"")) {
+ if (Storage::HasRaidParity(data["raid_type"]:"")) {
value = data["parity_algorithm"]:"";
value = mergestring(splitstring(value, "_"), "-");
}
@@ -807,7 +870,7 @@
if (part == nil)
value = tostring(0);
else
- value = tostring(part["region", 0]:0);
+ value = tostring(Region::Start(part["region"]:[]));
}
if (style == `table)
return value;
@@ -823,7 +886,7 @@
if (part == nil)
value = tostring(disk["cyl_count"]:0 - 1);
else
- value = tostring(part["region", 0]:0 + part["region", 1]:0 - 1);
+ value = tostring(Region::End(part["region"]:[]));
}
if (style == `table)
return value;
@@ -836,7 +899,7 @@
{
string value = "";
if (part == nil && Storage::IsPartitionable(disk))
- value = Storage::ByteToHumanString(disk["sector_size"]:0);
+ value = Storage::ByteToHumanStringOmitZeroes(disk["sector_size"]:0);
if (style == `table)
return value;
else
@@ -913,6 +976,8 @@
term TableRow(list<symbol> fields, map disk, map part)
{
string device = (part == nil) ? disk["device"]:"" : part["device"]:"";
+ if( disk["type"]:`CT_UNKNOWN == `CT_TMPFS )
+ device = "tmpfs:"+part["mount"]:"";
term row = list::reduce(term tmp, symbol field, `item(`id(device)), fields, {
return add(tmp, MakeSubInfo(disk, part, field, `table));
@@ -942,9 +1007,6 @@
if (partition["fsid"]:0 == Partitions::fsid_mac_hidden)
return true;
- if (contains([ `UB_DMRAID, `UB_DMMULTIPATH, `UB_MDPART ], disk["used_by_type"]:`UB_NONE))
- return true;
-
return false;
}
@@ -1025,14 +1087,75 @@
{
if (partition == nil)
{
- if (contains(devices, disk["used_by_device"]:""))
+ if (find(map used_by, disk["used_by"]:[], { return contains(devices, used_by["device"]:""); }) != nil)
+ return `showandfollow;
+ else
+ return `follow;
+ }
+ else
+ {
+ if (find(map used_by, partition["used_by"]:[], { return contains(devices, used_by["device"]:""); }) != nil)
+ return `show;
+ else
+ return `ignore;
+ }
+ }
+
+
+ /**
+ * Predicate function for Table and TableContents.
+ */
+ global symbol PredicateMountpoint(map disk, map partition)
+ {
+ if (partition == nil)
+ {
+ if (!isempty(disk["mount"]:""))
return `showandfollow;
else
return `follow;
}
else
{
- if (contains(devices, partition["used_by_device"]:""))
+ if (!isempty(partition["mount"]:""))
+ return `show;
+ else
+ return `ignore;
+ }
+ }
+
+ /**
+ * Predicate function for Table and TableContents.
+ */
+ global symbol PredicateBtrfs(map disk, map partition)
+ {
+ if (partition == nil)
+ {
+ return `follow;
+ }
+ else
+ {
+ if (partition["used_fs"]:`unknown==`btrfs &&
+ !Storage::IsUsedBy(partition) &&
+ (partition["used_by",0,"type"]:`UB_NONE==`UB_BTRFS ||
+ search( partition["device"]:"", "UUID=" ) == 0))
+ return `show;
+ else
+ return `ignore;
+ }
+ }
+
+ /**
+ * Predicate function for Table and TableContents.
+ */
+ global symbol PredicateTmpfs(map disk, map partition)
+ {
+ if (partition == nil)
+ {
+ return `follow;
+ }
+ else
+ {
+ if (partition["used_fs"]:`unknown==`tmpfs)
return `show;
else
return `ignore;
@@ -1040,6 +1163,7 @@
}
+
/**
* The predicate function determines whether the disk/partition is
* included. The predicate function takes two arguments, disk and
@@ -1183,7 +1307,8 @@
list<string> List(list<symbol> fields)
{
return maplist(symbol field, fields, {
- return MakeSubInfo(disk, part, field, `overview);
+ // cast to string - overviews expect textual summary
+ return ( string ) MakeSubInfo(disk, part, field, `overview);
});
};
Added: branches/SuSE-Code-11-SP2-Branch/storage/storage/src/modules/StorageIcons.ycp
URL: http://svn.opensuse.org/viewcvs/yast/branches/SuSE-Code-11-SP2-Branch/stora…
==============================================================================
--- branches/SuSE-Code-11-SP2-Branch/storage/storage/src/modules/StorageIcons.ycp (added)
+++ branches/SuSE-Code-11-SP2-Branch/storage/storage/src/modules/StorageIcons.ycp Tue May 17 13:39:44 2011
@@ -0,0 +1,84 @@
+/**
+ * File: StorageIcons.ycp
+ * Package: yast2-storage
+ * Summary: Expert Partitioner
+ * Authors: Arvin Schnell <aschnell(a)suse.de>
+ */
+{
+ module "StorageIcons";
+
+
+ global const string all_icon = "yast-disk.png";
+
+
+ global const string hd_icon = "yast-disk.png";
+ global const string hd_part_icon = "yast-partitioning.png";
+
+ global const string lvm_icon = "yast-lvm_config.png";
+ global const string lvm_lv_icon = "yast-partitioning.png";
+
+ global const string raid_icon = "yast-raid.png";
+
+ global const string loop_icon = "yast-encrypted.png";
+
+ global const string dm_icon = "yast-device-mapper.png";
+
+ global const string nfs_icon = "yast-nfs.png";
+
+ global const string unused_icon = "yast-unused-device.png";
+
+ global const string graph_icon = "yast-device-tree.png";
+
+ global const string summary_icon = "yast-disk.png";
+
+ global const string settings_icon = "yast-spanner.png";
+
+ global const string log_icon = "yast-messages.png";
+
+
+ global const string encrypted_icon = "yast-encrypted.png";
+
+
+ global string IconMap(symbol type)
+ {
+ switch (type)
+ {
+ case `CT_DMRAID:
+ case `CT_MD:
+ case `CT_MDPART:
+ case `sw_raid:
+ return raid_icon;
+
+ case `CT_DMMULTIPATH:
+ case `CT_DM:
+ case `dm:
+ return dm_icon;
+
+ case `CT_DISK:
+ return hd_icon;
+
+ case `CT_LOOP:
+ case `loop:
+ return loop_icon;
+
+ case `CT_LVM:
+ return lvm_icon;
+
+ case `lvm:
+ return lvm_lv_icon;
+
+ case `CT_NFS:
+ case `nfs:
+ return nfs_icon;
+
+ case `primary:
+ case `logical:
+ case `extended:
+ return hd_part_icon;
+
+ default:
+ return "yast-hdd-controller-kernel-module.png";
+ }
+ }
+
+}
Added: branches/SuSE-Code-11-SP2-Branch/storage/storage/src/modules/StorageProposal.ycp
URL: http://svn.opensuse.org/viewcvs/yast/branches/SuSE-Code-11-SP2-Branch/stora…
==============================================================================
--- branches/SuSE-Code-11-SP2-Branch/storage/storage/src/modules/StorageProposal.ycp (added)
+++ branches/SuSE-Code-11-SP2-Branch/storage/storage/src/modules/StorageProposal.ycp Tue May 17 13:39:44 2011
@@ -0,0 +1,4177 @@
+/*
+ *************************************************************
+ *
+ * YaST2 SuSE Labs -o)
+ * -------------------- /\\
+ * _\_v
+ * www.suse.de / www.suse.com
+ * ----------------------------------------------------------
+ *
+ * Author: Thomas Fehr <fehr(a)suse.de>
+ *
+ * Description: Make a proposal for partitioning
+ *
+ *************************************************************/
+{
+ module "StorageProposal";
+
+ textdomain "storage";
+
+ import "FileSystems";
+ import "Partitions";
+ import "Label";
+ import "Storage";
+ import "ProductFeatures";
+ import "Arch";
+ import "Stage";
+
+
+map read_partition_config( string fpath );
+map read_partition_xml_config();
+map get_gap_info( map disk, boolean add_exist_linux );
+map add_cylinder_info( map conf, map gap );
+map get_perfect_list( list ps, map g );
+map process_partition_data( string dev, map solution, string vgname );
+map find_matching_disk( list<string> disks, map target, map conf );
+map try_resize_windows( map disk );
+map remove_possible_partitions( map disk, map conf );
+map distribute_space( integer rest, list weights, list added, list ps );
+void add_part_recursive( list ps, map g );
+map normalize_gaps( list ps, map g );
+integer do_weighting( list ps, map g );
+
+symbol cur_mode = `free;
+integer cur_weight = -10000;
+map cur_gap = $[];
+integer big_cyl = 4 * 1024 * 1024 * 1024;
+
+ list<string> no_propose_disks = nil;
+
+ boolean proposal_home = false;
+ boolean proposal_lvm = false;
+ boolean proposal_encrypt = false;
+ boolean proposal_btrfs = false;
+ string proposal_password = "";
+
+ map<string, any> cfg_xml = $[];
+
+
+ global boolean GetProposalHome()
+ {
+ return proposal_home;
+ }
+
+ global void SetProposalHome(boolean val)
+ {
+ proposal_home = val;
+ y2milestone("SetProposalHome val:%1", proposal_home);
+ }
+
+ global boolean GetProposalLvm()
+ {
+ return proposal_lvm;
+ }
+
+ global void SetProposalLvm(boolean val)
+ {
+ proposal_lvm = val;
+ y2milestone("SetProposalLvm val:%1", val);
+ }
+
+ global boolean GetProposalEncrypt()
+ {
+ return proposal_encrypt;
+ }
+
+ global void SetProposalEncrypt(boolean val)
+ {
+ proposal_encrypt = val;
+ y2milestone("SetProposalEncrypt val:%1", val);
+ }
+
+ global boolean GetProposalBtrfs()
+ {
+ return proposal_btrfs;
+ }
+
+ global void SetProposalBtrfs(boolean val)
+ {
+ proposal_btrfs = val;
+ y2milestone("SetProposalBtrfs val:%1", val);
+ }
+
+ global string GetProposalPassword()
+ {
+ return proposal_password;
+ }
+
+ global void SetProposalPassword(string val)
+ {
+ proposal_password = val;
+ y2milestone("SetProposalPassword");
+ }
+
+ global void SetProposalDefault(boolean home_only)
+ {
+ SetProposalHome(cfg_xml["home"]:false);
+ if (!home_only)
+ {
+ SetProposalLvm(cfg_xml["prop_lvm"]:false);
+ SetProposalEncrypt(false);
+ SetProposalPassword("");
+ }
+ SetProposalBtrfs(cfg_xml["btrfs"]:false);
+ y2milestone("SetProposalDefault home:%1 lvm:%2 encypt:%3 home_only:%4 btrfs:%5",
+ proposal_home, proposal_lvm, proposal_encrypt, home_only,
+ proposal_btrfs);
+ }
+
+
+ global map<string, any> GetControlCfg()
+ {
+ if (isempty(cfg_xml))
+ {
+ boolean btmp = ProductFeatures::GetBooleanFeature("partitioning", "try_separate_home");
+ cfg_xml["home"] = btmp;
+
+ integer itmp = ProductFeatures::GetIntegerFeature("partitioning", "root_space_percent");
+ cfg_xml["root_percent"] = itmp;
+ if (cfg_xml["root_percent"]:0 == nil || cfg_xml["root_percent"]:0 <= 0)
+ cfg_xml["root_percent"] = 40;
+
+ string stmp = ProductFeatures::GetStringFeature("partitioning", "limit_try_home");
+ cfg_xml["home_limit"] = Storage::ClassicStringToByte(stmp) / (1024*1024);
+ if (cfg_xml["home_limit"]:0 <= 0)
+ cfg_xml["home_limit"] = 5*1024;
+
+ stmp = ProductFeatures::GetStringFeature("partitioning", "root_base_size");
+ cfg_xml["root_base"] = Storage::ClassicStringToByte(stmp) / (1024*1024);
+ if (cfg_xml["root_base"]:0 <= 0)
+ cfg_xml["root_base"] = 3*1024;
+
+ stmp = ProductFeatures::GetStringFeature("partitioning", "root_max_size");
+ cfg_xml["root_max"] = Storage::ClassicStringToByte(stmp) / (1024*1024);
+ if (cfg_xml["root_max"]:0 <= 0)
+ cfg_xml["root_max"] = 10*1024;
+
+ btmp = ProductFeatures::GetBooleanFeature("partitioning", "vm_keep_unpartitioned_region");
+ cfg_xml["vm_keep_unpartitioned_region"] = btmp;
+
+ stmp = ProductFeatures::GetStringFeature("partitioning", "vm_desired_size");
+ cfg_xml["vm_want"] = Storage::ClassicStringToByte(stmp) / (1024*1024);
+ if (cfg_xml["vm_want"]:0 <= 0)
+ cfg_xml["vm_want"] = 15*1024;
+
+ stmp = ProductFeatures::GetStringFeature("partitioning", "vm_home_max_size");
+ cfg_xml["home_max"] = Storage::ClassicStringToByte(stmp) / (1024*1024);
+ if (cfg_xml["home_max"]:0 <= 0)
+ cfg_xml["home_max"] = 25*1024;
+
+ btmp = ProductFeatures::GetBooleanFeature("partitioning", "proposal_lvm");
+ cfg_xml["prop_lvm"] = btmp ? true : false;
+
+ SetProposalDefault(false);
+ y2milestone("GetControlCfg cfg_xml:%1", cfg_xml);
+ }
+
+ return cfg_xml;
+ }
+
+ global string GetProposalVM()
+ {
+ string ret = "";
+ if (proposal_lvm)
+ {
+ ret = "system";
+ }
+ y2milestone("ProposalVM lvm:%1 ret:%2", proposal_lvm, ret);
+ return ret;
+ }
+
+symbol PropDefaultFs()
+ {
+ symbol ret = Partitions::DefaultFs();
+ if( GetProposalBtrfs() )
+ ret = `btrfs;
+ return( ret );
+ }
+
+
+ map<string, map> EncryptDevices(map<string, map> target, string vg)
+ {
+ if (!GetProposalLvm() || !GetProposalEncrypt())
+ return target;
+
+ list<string> devices = target[vg, "devices_add"]:[];
+
+ y2milestone("vg:%1 devices:%2", vg, devices);
+
+ // go through target map and set enc_type and password for all devices used by
+ // our volume group
+ target = mapmap(string disk_device, map data, target, {
+ list<map> partitions = data["partitions"]:[];
+ partitions = maplist(map partition, partitions, {
+ string part_device = partition["device"]:"";
+ if (contains(devices, part_device))
+ {
+ y2debug("setting encryption for %1", part_device);
+ partition["enc_type"] = `luks;
+ Storage::SetCryptPwd(part_device, proposal_password);
+ }
+ return partition;
+ });
+ data["partitions"] = partitions;
+ return $[ disk_device : data ];
+ });
+
+ y2milestone("target:%1", target);
+
+ return target;
+ }
+
+
+ list<string> GetDestroyedLvmVgs(map<string, map> target)
+ {
+ list<string> vgs = [];
+ foreach(string diskdev, map disk, target, {
+ foreach( map p, disk["partitions"]:[], {
+ if( p["used_by_type"]:`UB_NONE==`UB_LVM && p["format"]:false )
+ {
+ vgs = add(vgs, p["used_by_device"]:"");
+ }
+ });
+ });
+ vgs = toset(vgs);
+ y2milestone( "GetDestroyedLvmVgs %1", vgs );
+ return vgs;
+ }
+
+
+ map<string, map> DeleteDestroyedLvmVgs(map<string, map> target)
+ {
+ list<string> vgs = GetDestroyedLvmVgs(target);
+ y2milestone( "DeleteDestroyedLvmVgs %1", vgs );
+ foreach(string dev, vgs, {
+ if( haskey( target, dev ))
+ target[dev,"delete"] = true;
+ target[dev,"partitions"] = maplist( map p, target[dev,"partitions"]:[],
+ ``{
+ if( haskey( p, "mount" ))
+ p = remove( p, "mount" );
+ return( p );
+ });
+ y2milestone( "DeleteDestroyedLvmVgs %1: %2", dev, target[dev]:$[] );
+ });
+ return target;
+ }
+
+
+ list<string> NoProposeDisks()
+ {
+ if (no_propose_disks == nil)
+ {
+ no_propose_disks = [];
+ if( Stage::initial() && SCR::Read( .target.size, "/etc/install.inf" )>0 )
+ {
+ string inst = (string) SCR::Read( .etc.install_inf.Partition );
+ y2milestone( "NoProposeDisks .etc.install_inf.Partition \"%1\"",
+ inst );
+ if( inst!=nil && size(inst)>0 )
+ {
+ if( search( inst, "/dev/" )!=0 )
+ inst = "/dev/" + inst;
+ map d = Storage::GetDiskPartition( inst );
+ y2milestone( "NoProposeDisks inst:%1 disk:%2", inst, d );
+ if( size(d["disk"]:"")>0 )
+ no_propose_disks = add( no_propose_disks, d["disk"]:"" );
+ }
+ inst = (string) SCR::Read( .etc.install_inf.Cdrom );
+ y2milestone( "NoProposeDisks .etc.install_inf.Cdrom \"%1\"", inst );
+ if( inst!=nil && size(inst)>0 )
+ {
+ if( search( inst, "/dev/" )!=0 )
+ inst = "/dev/" + inst;
+ map d = Storage::GetDiskPartition( inst );
+ y2milestone( "NoProposeDisks inst:%1 disk:%2", inst, d );
+ if( size(d["disk"]:"")>0 )
+ no_propose_disks = add( no_propose_disks, d["disk"]:"" );
+ }
+ }
+ if( Stage::initial() )
+ {
+ string env = getenv("YAST2_STORAGE_NO_PROPOSE_DISKS");
+ y2milestone( "NoProposeDisks env:\"%1\"", env );
+ if (env != nil)
+ {
+ list<string> ls = filter( string e, splitstring( env, " \t\n" ), ``(size(e)>0) );
+ no_propose_disks = (list<string>)merge( no_propose_disks, ls );
+ }
+ }
+ no_propose_disks = toset(sort(no_propose_disks));
+ y2milestone( "NoProposeDisks \"%1\"", no_propose_disks );
+ }
+ return no_propose_disks;
+ }
+
+
+ boolean ignore_disk(string dev, map entry, boolean soft)
+ {
+ boolean ret = !Storage::IsPartitionable(entry) || entry["readonly"]:false;
+ // GPT is not required for uEFI on x86_64
+ if( !ret && Arch::ia64() && entry["label"]:"gpt"!="gpt" )
+ {
+ ret = true;
+ }
+ if( !ret && soft && Arch::board_iseries () && search( dev, "/dev/sd" )==0 )
+ {
+ ret = true;
+ }
+ if( !ret && soft && (entry["softraiddisk"]:false||entry["hotpluggable"]:false) )
+ {
+ ret = true;
+ }
+ if( !ret && soft && contains( NoProposeDisks(), dev ))
+ {
+ ret = true;
+ }
+ if( !ret && soft )
+ {
+ ret = Storage::IsUsedBy(entry);
+ }
+ if( ret )
+ {
+ y2milestone( "ignoring disk %1 soft:%2", dev, soft );
+ }
+ return( ret );
+ }
+
+
+ map<string, map> AddWinInfo(map<string, map> targets)
+ {
+ y2milestone("AddWinInfo called");
+ foreach(string disk, map data, targets, {
+ targets[disk, "partitions"] =
+ maplist(map p, data["partitions"]:[], {
+ if (Partitions::IsDosWinNtPartition(p["fsid"]:0) &&
+ contains([ `ntfs, `vfat ], p["used_fs"]:`none))
+ {
+ p["winfo"] = Storage::GetFreeSpace(p["device"]:"",
+ p["used_fs"]:`none, false);
+ y2milestone("AddWinInfo %1", p);
+ }
+ return p;
+ });
+ });
+ return targets;
+ }
+
+
+map<string, boolean> swapable = $[];
+
+
+ global void flex_init_swapable(map<string, map> tg)
+ {
+ swapable = $[];
+ list<string> swaps = Storage::SwappingPartitions();
+ foreach(string dev, map disk, tg, {
+ if (!Storage::IsUsedBy(disk))
+ {
+ list<map> sw = filter(map p, disk["partitions"]:[],
+ ``(p["type"]:`unknown!=`extended &&
+ !p["delete"]:false &&
+ p["detected_fs"]:`unknown==`swap));
+ sw = filter(map p, sw, ``(contains(swaps, p["device"]:"") ||
+ Storage::CheckSwapable(p["device"]:"")));
+ foreach(map p, sw, {
+ swapable[p["device"]:""] = true;
+ });
+ }
+ });
+ y2milestone("flex_init_swapable %1", swapable);
+ }
+
+
+ boolean check_swapable(string dev)
+ {
+ return swapable[dev]:false;
+ }
+
+
+ string pinfo_name()
+ {
+ return "/part.info";
+ }
+
+
+global boolean has_flex_proposal()
+ {
+ boolean ret = (integer)SCR::Read( .target.size, pinfo_name() )>0;
+ if( !ret )
+ {
+ any t = ProductFeatures::GetBooleanFeature( "partitioning",
+ "use_flexible_partitioning");
+ y2milestone( "ProductFeatures::GetBooleanFeature %1", t );
+ if( is( t, boolean ) && (boolean)t )
+ ret = true;
+ }
+ y2milestone( "has_flex_proposal ret:%1", ret );
+ return( ret );
+ }
+
+
+boolean need_boot( map disk )
+ {
+ y2milestone( "need_boot NeedBoot:%1 GetProposalBtrfs:%2 type:%3",
+ Partitions::NeedBoot(), GetProposalBtrfs(),
+ disk["type"]:`CT_UNKNOWN );
+ return( Partitions::NeedBoot() || GetProposalBtrfs() ||
+ disk["type"]:`CT_UNKNOWN == `CT_DMRAID );
+ }
+
+
+map try_add_boot( map conf, map disk, boolean force )
+ {
+ boolean boot =
+ size(filter( map e, conf["partitions"]:[],
+ ``(e["mount"]:""==Partitions::BootMount()))) > 0;
+ boolean root = size(filter( map e, conf["partitions"]:[],
+ ``(e["mount"]:""=="/"))) > 0;
+ map tc = conf;
+ y2milestone( "try_add_boot conf %1", conf );
+ y2milestone( "try_add_boot boot %1 root %2 force %3 need_boot:%4",
+ boot, root, force, need_boot(disk) );
+ if( !boot && (root||force) &&
+ (disk["cyl_count"]:0>Partitions::BootCyl() || need_boot(disk)) )
+ {
+ map pb = $[];
+ pb["mount"] = Partitions::BootMount();
+ pb["size"] = Partitions::ProposedBootsize();
+ pb["fsys"] = Partitions::DefaultBootFs();
+ pb["id"] = Partitions::FsidBoot();
+ pb["auto_added"] = true;
+ pb["max_cyl"] = Partitions::BootCyl();
+ pb["primary"] = Partitions::BootPrimary();
+ pb["maxsize"] = Partitions::MaximalBootsize();
+ tc["partitions"] = add( tc["partitions"]:[], pb );
+ y2milestone( "try_add_boot disk_cyl %1 boot_cyl %2 need_boot %3 typ %4",
+ disk["cyl_count"]:0, Partitions::BootCyl(),
+ Partitions::NeedBoot(), disk["type"]:`CT_UNKNOWN );
+ y2milestone( "try_add_boot boot added automagically pb %1", pb );
+ }
+ return( tc );
+ }
+
+
+global map<string, any> do_flexible_disk(map disk)
+ {
+ string dev = disk["device"]:"";
+ y2milestone( "do_flexible_disk dev %1", dev );
+ y2milestone( "do_flexible_disk parts %1", disk["partitions"]:[] );
+ map<string, any> ret = $[];
+ ret["ok"] = false;
+ map conf = read_partition_config( pinfo_name() );
+ map solutions = $[];
+
+ if( size(conf)>0 && Storage::IsPartitionable( disk ))
+ {
+ y2milestone( "do_flexible_disk processing disk %1", dev );
+ map tc = try_add_boot( conf, disk, false );
+ cur_mode = `free;
+ cur_gap = $[];
+ map gap = get_gap_info( disk, false );
+ tc = add_cylinder_info( tc, gap );
+ map sol = get_perfect_list( tc["partitions"]:[], gap );
+ if( size(sol)>0 )
+ {
+ sol["disk"] = eval(disk);
+ ret["ok"] = true;
+ ret["disk"] = process_partition_data( dev, sol, "" );
+ ret["weight"] = sol["weight"]:-1;
+ }
+ }
+ y2milestone( "do_flexible_disk ret %1", ret["ok"]:false );
+ if( ret["ok"]:false )
+ {
+ y2milestone( "do_flexible_disk weight %1", ret["weight"]:-2 );
+ y2milestone( "do_flexible_disk disk %1", ret["disk"]:$[] );
+ }
+ return( ret );
+ }
+
+
+map do_flexible_disk_conf( map disk, map co, boolean ignore_boot,
+ boolean reuse )
+ {
+ string dev = disk["device"]:"";
+ y2milestone( "do_flexible_disk_conf dev %1 ignore_boot %2 reuse %3",
+ dev, ignore_boot, reuse );
+ map conf = co;
+ if( !ignore_boot )
+ conf = try_add_boot( conf, disk, true );
+ y2milestone( "do_flexible_disk_conf parts %1", disk["partitions"]:[] );
+ y2milestone( "do_flexible_disk_conf conf %1", conf );
+ map ret = $[];
+ ret["ok"] = false;
+ map solutions = $[];
+
+ if( size(conf)>0 && size(conf["partitions"]:[])>0 &&
+ Storage::IsPartitionable( disk ))
+ {
+ y2milestone( "do_flexible_disk_conf processing disk %1", dev );
+ cur_mode = reuse?`reuse:`free;
+ cur_gap = $[];
+ map gap = get_gap_info( disk, reuse );
+ map tc = add_cylinder_info( conf, gap );
+ map sol = get_perfect_list( tc["partitions"]:[], gap );
+ if( size(sol)>0 )
+ {
+ sol["disk"] = eval(disk);
+ ret["ok"] = true;
+ ret["disk"] = process_partition_data( dev, sol, "" );
+ ret["weight"] = sol["weight"]:-1;
+ }
+ }
+ else if( Storage::IsPartitionable( disk ) )
+ {
+ ret["ok"] = true;
+ ret["disk"] = disk;
+ }
+ y2milestone( "do_flexible_disk_conf ret %1", ret["ok"]:false );
+ if( ret["ok"]:false && size(conf)>0 )
+ {
+ y2milestone( "do_flexible_disk_conf weight %1", ret["weight"]:-2 );
+ y2milestone( "do_flexible_disk_conf parts %1", ret["disk","partitions"]:[] );
+ }
+ return( ret );
+ }
+
+
+map do_vm_disk_conf( map disk, map boot, string vmkey, string key )
+ {
+ string dev = disk["device"]:"";
+ y2milestone( "do_vm_disk_conf dev %1 vmkey %2 key %3 boot %4",
+ dev, vmkey, key, boot );
+ y2milestone( "do_vm_disk_conf parts %1", disk["partitions"]:[] );
+ map conf = $[ "partitions" : [ $[ "id" : 0x8E ] ] ];
+ if( size(boot)>0 )
+ conf["partitions"] = add( conf["partitions"]:[], boot );
+ map ret = $[];
+ ret["ok"] = false;
+
+ integer fsid = conf["partitions",0,"id"]:0;
+ if( Storage::IsPartitionable( disk ))
+ {
+ y2milestone( "do_vm_disk_conf processing disk %1", dev );
+ cur_mode = `free;
+ cur_gap = $[];
+ map gap = get_gap_info( disk, true );
+ y2milestone( "do_vm_disk_conf gap %1", gap );
+ y2milestone( "do_vm_disk_conf conf %1", conf );
+ map tc = add_cylinder_info( conf, gap );
+ y2milestone( "do_vm_disk_conf tc %1", tc );
+ y2milestone( "do_vm_disk_conf gap %1", gap["gap"]:[] );
+ if( size(gap["gap"]:[])>1 )
+ {
+ gap["gap"] = sort( map a, map b, gap["gap"]:[],
+ ``{
+ if( a["extended"]:false==b["extended"]:false )
+ return( a["start"]:0<b["start"]:0 );
+ else
+ return( !a["extended"]:false );
+ });
+ y2milestone( "do_vm_disk_conf gap %1", gap["gap"]:[] );
+ }
+ boolean ok = size(boot)==0;
+ if( !ok )
+ {
+ integer gstart = -1;
+ map bo = find( map p, (list<map>)tc["partitions"]:[],
+ ``(p["mount"]:""==boot["mount"]:"") );
+ y2milestone( "do_vm_disk_conf boot %1", bo );
+ integer cyl_num = bo["cylinders"]:1;
+ y2milestone( "do_vm_disk_conf boot cyl %1", cyl_num );
+ gap["gap"] = maplist( map g, gap["gap"]:[],
+ ``{
+ if( !g["exists"]:false && !ok && g["cylinders"]:0>=cyl_num &&
+ ((g["extended"]:false && size(gap["ext_pnr"]:[])>1)||
+ (!g["extended"]:false && size(gap["free_pnr"]:[])>1)))
+ {
+ ok = true;
+ gstart = g["start"]:-1;
+ string key = g["extended"]:false ? "ext_pnr" : "free_pnr";
+ g["added"] = [ [ 1, gap[key,0]:0, cyl_num ] ];
+ g["cylinders"] = g["cylinders"]:0-cyl_num;
+ gap[key] = remove( gap[key]:[], 0 );
+ if( g["cylinders"]:0 > 1 )
+ {
+ integer vg_size = GetControlCfg()["vm_want"]:(15*1024);
+ // get only limited amount of the gap so that there is free
+ // space left (fate #303594)
+ y2milestone ("do_vm_disk_conf maximum volume group size from control file: %1", vg_size);
+ integer add_cylinders = g["cylinders"]:0; // whole partition as default
+ if (vg_size != nil && vg_size > 0 && GetControlCfg()["vm_keep_unpartitioned_region"]:false)
+ {
+ integer cyl_size = g["size"]:0 / g["cylinders"]:0;
+ add_cylinders = (vg_size * 1024 * 1024) / cyl_size;
+ if (add_cylinders > g["cylinders"]:0)
+ add_cylinders = g["cylinders"]:0;
+ }
+ g["added"] = add( g["added"]:[],
+ [ 0, gap[key,0]:0, add_cylinders ] );
+ y2milestone ("do_vm_disk_conf added new partition: %1", g);
+ g["cylinders"] = 0; // do not use the rest of the gap, if not set to zero, it is used, don't know why
+ gap[key] = remove( gap[key]:[], 0 );
+ }
+ }
+ return( g );
+ });
+ if( !ok )
+ {
+ gap["gap"] = maplist( map g, gap["gap"]:[],
+ ``{
+ if( !g["exists"]:false && !ok && g["cylinders"]:0>=cyl_num &&
+ ((g["extended"]:false && size(gap["ext_pnr"]:[])>0)||
+ (!g["extended"]:false && size(gap["free_pnr"]:[])>0)))
+ {
+ ok = true;
+ gstart = g["start"]:-1;
+ string key = g["extended"]:false ? "ext_pnr" : "free_pnr";
+ g["added"] = [ [ 1, gap[key,0]:0, cyl_num ] ];
+ g["cylinders"] = g["cylinders"]:0-cyl_num;
+ gap[key] = remove( gap[key]:[], 0 );
+ }
+ return( g );
+ });
+ }
+ if( ok && size(vmkey)>0 )
+ {
+ gap["gap"] = filter( map g, gap["gap"]:[],
+ ``(g["start"]:0==gstart));
+ }
+ y2milestone( "do_vm_disk_conf gap %1", gap["gap"]:[] );
+ }
+ else if( size(vmkey)>0 )
+ gap = $[];
+ map sol = $[];
+ sol["solution"] = gap;
+ sol["partitions"] = conf["partitions"]:[];
+ sol["disk"] = disk;
+ ret["ok"] = ok;
+ ret["weight"] = 0;
+ if( ok && size(vmkey)==0 )
+ {
+ if( size(gap["ext_reg"]:[])>0 )
+ {
+ integer ext_end = gap["ext_reg",0]:0 + gap["ext_reg",1]:0 - 1;
+ map aext = find( map g, gap["gap"]:[],
+ ``(size(g["added"]:[])==0 &&
+ !g["exists"]:false &&
+ g["start"]:0>=ext_end &&
+ g["start"]:0-ext_end<=1));
+ y2milestone( "do_vm_disk_conf ee:%1 ae:%2", ext_end, aext );
+ if( aext!=nil )
+ {
+ gap["resize_ext"] = aext["end"]:0;
+ gap["gap"] = filter( map g, gap["gap"]:[],
+ ``(g["start"]:0!=aext["start"]:0));
+ aext = find( map g, gap["gap"]:[],
+ ``(!g["exists"]:false && g["extended"]:false &&
+ g["end"]:0==ext_end));
+ y2milestone( "do_vm_disk_conf aext %1", aext );
+ if( aext != nil )
+ {
+ gap["gap"] = maplist( map g, gap["gap"]:[],
+ ``{
+ if( g["end"]:0==aext["end"]:0 )
+ {
+ g["cylinders"] = g["cylinders"]:0 +
+ gap["resize_ext"]:0 -
+ g["end"]:0;
+ g["end"] = gap["resize_ext"]:0;
+ }
+ return( g );
+ });
+ }
+ else
+ {
+ map a = $[ "extended" : true,
+ "start" : gap["ext_reg",0]:0+gap["ext_reg",1]:0,
+ "end" : gap["resize_ext"]:0 ];
+ a["cylinders"] = a["end"]:0 - a["start"]:0 + 1;
+ y2milestone("do_vm_disk_conf add gap %1", a );
+ y2milestone("do_vm_disk_conf add gap %1", gap["gap"]:[] );
+ gap["gap"] = add( gap["gap"]:[], a );
+ y2milestone("do_vm_disk_conf add gap %1", gap["gap"]:[] );
+ }
+ }
+ y2milestone( "do_vm_disk_conf aext gap %1", gap );
+ }
+ gap["gap"] = maplist( map g, gap["gap"]:[],
+ ``{
+ if( g["exists"]:false )
+ {
+ map acur = find( map gg, gap["gap"]:[],
+ ``(size(gg["added"]:[])==0 &&
+ !gg["exists"]:false &&
+ gg["extended"]:false==g["extended"]:false &&
+ gg["start"]:0>=g["end"]:0 &&
+ gg["start"]:0-g["end"]:0<=1));
+ y2milestone( "do_vm_disk_conf ee:%1 ae:%2",
+ g["end"]:0, acur );
+ if( acur!=nil )
+ {
+ g["resize"] = acur["end"]:0;
+ g["fsid"] = fsid;
+ }
+ }
+ return( g );
+ });
+ list<integer> sl = maplist( map g, gap["gap"]:[],
+ ``(g["resize"]:-1));
+ y2milestone( "do_vm_disk_conf sl %1", sl );
+ gap["gap"] = filter( map g, gap["gap"]:[],
+ ``(!contains(sl,g["end"]:0)));
+ gap["gap"] = sort( map a, map b, gap["gap"]:[],
+ ``{
+ return( a["cylinders"]:0>b["cylinders"]:0 );
+ });
+ y2milestone( "do_vm_disk_conf sorted gap %1", gap["gap"]:[] );
+ gap["gap"] = maplist( map g, gap["gap"]:[],
+ ``{
+ if( !g["exists"]:false && g["cylinders"]:0>0 &&
+ ((g["extended"]:false && size(gap["ext_pnr"]:[])>0)||
+ (!g["extended"]:false && size(gap["free_pnr"]:[])>0)))
+ {
+ string key = g["extended"]:false ? "ext_pnr" : "free_pnr";
+ // get only limited amount of the gap so that there is free
+ // space left (fate #303594)
+ integer vg_size = GetControlCfg()["vm_want"]:(15*1024);
+ y2milestone ("do_vm_disk_conf maximum volume group size from control file: %1", vg_size);
+ integer add_cylinders = g["cylinders"]:0; // whole partition as default
+ if (vg_size != nil && vg_size > 0 && GetControlCfg()["vm_keep_unpartitioned_region"]:false)
+ {
+ integer cyl_size = g["size"]:0 / g["cylinders"]:0;
+ add_cylinders = (vg_size * 1024 * 1024) / cyl_size;
+ if (add_cylinders > g["cylinders"]:0)
+ add_cylinders = g["cylinders"]:0;
+ }
+ g["added"] = add( g["added"]:[],
+ [ 0, gap[key,0]:0, add_cylinders ]);
+ y2milestone ("do_vm_disk_conf added new partition: %1", g);
+ g["cylinders"] = 0; // otherwise it get another chunk - don't know why :-(
+ gap[key] = remove( gap[key]:[], 0 );
+ }
+ return( g );
+ });
+ gap["gap"] = maplist( map g, gap["gap"]:[],
+ ``{
+ if( g["exists"]:false && fsid!=0 && g["fsid"]:0!=fsid )
+ {
+ g["fsid"] = fsid;
+ }
+ return( g );
+ });
+ y2milestone( "do_vm_disk_conf end gap %1", gap["gap"]:[] );
+ sol["solution"] = gap;
+ }
+ ret["disk"] = process_partition_data( dev, sol, key );
+ }
+ y2milestone( "do_vm_disk_conf ret %1", ret["ok"]:false );
+ if( ret["ok"]:false )
+ {
+ y2milestone( "do_vm_disk_conf weight %1", ret["weight"]:-2 );
+ y2milestone( "do_vm_disk_conf parts %1", ret["disk","partitions"]:[] );
+ }
+ return( ret );
+ }
+
+
+list<string> restrict_disk_names(list<string> disks)
+{
+ void helper(string s)
+ {
+ integer count = 0;
+ disks = filter(string dist, disks, {
+ if (search(dist, s) != 0)
+ return true;
+ count = count + 1;
+ return count <= 16;
+ });
+ }
+
+ helper("/dev/sd");
+ helper("/dev/hd");
+ helper("/dev/cciss/");
+ helper("/dev/dasd");
+
+ y2milestone("restrict_disk_names: ret %1", disks);
+ return disks;
+}
+
+
+ map<string, any> do_pflex(map<string, map> target, map conf)
+ {
+ map<string, any> ret = $[];
+ ret["ok"] = false;
+ list<map> solutions = [];
+ cur_mode = `free;
+ if( size(conf)>0 )
+ {
+ list<string> ddev = maplist( string k, map e,
+ filter( string l, map f, target,
+ ``(!ignore_disk(l,f,false))), ``(k));
+ ddev = sort( ddev );
+ y2milestone( "do_pflex ddev %1", ddev );
+ map tc = $[];
+ map<integer,any> dtmp = $[];
+ foreach( map p, conf["partitions"]:[],
+ ``{
+ integer dprio = p["disk"]:0;
+ if( haskey( dtmp, dprio ))
+ {
+ dtmp[dprio] = add( dtmp[dprio]:[], p );
+ }
+ else
+ {
+ dtmp[dprio] = [ p ];
+ }
+ });
+ y2milestone( "do_pflex dlist %1", dtmp );
+ list dlist = maplist( integer k, any e, dtmp, ``(e) );
+ y2milestone( "do_pflex dlist %1", dlist );
+ if( size(dlist)>size(ddev) )
+ {
+ integer idx = size(ddev);
+ while( idx<size(dlist) )
+ {
+ dlist[size(ddev)-1] = union( dlist[size(ddev)-1]:[],
+ dlist[idx]:[] );
+ idx = idx+1;
+ }
+ while( size(dlist)>size(ddev) )
+ {
+ dlist = remove( dlist, size(ddev) );
+ }
+ y2milestone( "do_pflex dlist %1", dlist );
+ }
+ list save_dlist = (list) eval(dlist);
+ repeat
+ {
+ integer count = 0;
+ repeat
+ {
+ list<string> td = eval(ddev);
+ integer idx = 0;
+ y2milestone( "do_pflex start while count %1", count );
+ while( idx<size(dlist) && count<size(dlist) )
+ {
+ y2milestone( "do_pflex in while idx %1", idx );
+ tc = (map) eval(conf);
+ tc["partitions"] = eval( dlist[idx]:[] );
+ map md = find_matching_disk( td, target, tc );
+ y2milestone( "do_pflex size(md) %1", size(md) );
+ if( size(md)>0 )
+ {
+ solutions = add( solutions, md );
+ td = filter( string e, td, ``(e!=md["device"]:""));
+ y2milestone( "do_pflex new td %1", td );
+ idx = idx+1;
+ }
+ else
+ {
+ y2milestone( "do_pflex no solution" );
+ idx = size(dlist);
+ td = eval(ddev);
+ solutions = [];
+ count = count + 1;
+ if( size(dlist)>1 )
+ {
+ list tfi = dlist[0]:[];
+ dlist = remove( dlist, 0 );
+ dlist = add( dlist, tfi );
+ y2milestone( "do_pflex new rot dlist %1", dlist );
+ }
+ }
+ }
+ }
+ until( size(solutions)>0 || count>=size(dlist) );
+ if( size(solutions)==0 && size(dlist)>1 )
+ {
+ dlist = (list) eval(save_dlist);
+ dlist[size(dlist)-2] = union( dlist[size(dlist)-2]:[],
+ dlist[size(dlist)-1]:[] );
+ dlist = remove( dlist, size(dlist)-1 );
+ y2milestone( "do_pflex new truncated dlist %1",
+ dlist );
+ save_dlist = (list)eval(dlist);
+ }
+ }
+ until( size(solutions)>0 || size(dlist)<=1 );
+ if( size(solutions)==0 &&
+ (size(conf["keep_partition_fsys"]:[])>0 ||
+ size(conf["keep_partition_id"]:[])>0 ||
+ size(conf["keep_partition_num"]:[])>0 ||
+ !conf["prefer_remove"]:false))
+ {
+ y2milestone( "do_pflex desperate mode" );
+ tc = (map) eval(conf);
+ cur_mode = `desparate;
+ tc["keep_partition_fsys"] = [];
+ tc["keep_partition_id"] = [];
+ tc["keep_partition_num"] = [];
+ tc["prefer_remove"] = true;
+ map md = find_matching_disk( ddev, target, tc );
+ if( size(md)>0 )
+ {
+ solutions = add( solutions, md );
+ }
+ }
+ if( size(solutions)>0 )
+ {
+ foreach( map e, solutions,
+ ``{
+ string disk = e["device"]:"";
+ target[disk] = process_partition_data( disk, e, "" );
+ y2milestone( "do_pflex solution disk %1 %2",
+ disk, target[disk]:$[] );
+ });
+ ret["ok"] = true;
+ target = Storage::SpecialBootHandling( target );
+ ret["target"] = DeleteDestroyedLvmVgs(target);
+ }
+ }
+ return( ret );
+ }
+
+
+ map<string, any> do_proposal_flexible(map<string, map> target)
+ {
+ map conf = $[];
+ if( ProductFeatures::GetBooleanFeature( "partitioning",
+ "use_flexible_partitioning"))
+ conf = read_partition_xml_config();
+ else
+ conf = read_partition_config( pinfo_name() );
+ y2milestone( "conf:%1", conf );
+ return( do_pflex( target, conf ) );
+ }
+
+
+map find_matching_disk( list<string> disks, map target, map conf )
+ {
+ map<string,map> solutions = $[];
+
+ cur_weight = -100000;
+ cur_gap = $[];
+ foreach( string k, disks,
+ ``{
+ map e = target[k]:$[];
+ y2milestone( "find_matching_disk processing disk %1", k );
+ y2milestone( "find_matching_disk parts %1", conf["partitions"]:[] );
+ map tc = try_add_boot( conf, e, false );
+ if( cur_mode != `desparate )
+ cur_mode = `free;
+ if( !tc["prefer_remove"]:false )
+ {
+ map gap = get_gap_info( e, false );
+ tc = add_cylinder_info( tc, gap );
+ map l = get_perfect_list( tc["partitions"]:[], gap );
+ if( size(l)>0 )
+ {
+ solutions[k] = eval(l);
+ solutions[k,"disk"] = eval(e);
+ }
+ cur_mode = `reuse;
+ map egap = get_gap_info( e, true );
+ if( size(egap["gap"]:[]) > size(gap["gap"]:[]) )
+ {
+ tc = add_cylinder_info( tc, egap );
+ l = get_perfect_list( tc["partitions"]:[], egap );
+ if( size(l)>0 &&
+ (!haskey(solutions,k) ||
+ (haskey( l, "weight" ) &&
+ l["weigth"]:0 > solutions[k,"weigth"]:0 )))
+ {
+ y2milestone( "find_matching_disk solution reuse existing" );
+ solutions[k] = eval(l);
+ solutions[k,"disk"] = eval(e);
+ }
+ }
+ cur_mode = `resize;
+ map rw = try_resize_windows( e );
+ if( find( map p, rw["partitions"]:[], ``(p["resize"]:false))!=nil )
+ {
+ egap = get_gap_info( rw, true );
+ tc = add_cylinder_info( tc, egap );
+ l = get_perfect_list( tc["partitions"]:[], egap );
+ if( size(l)>0 &&
+ (!haskey(solutions,k) ||
+ (haskey( l, "weight" ) &&
+ l["weigth"]:0 > solutions[k,"weigth"]:0 )))
+ {
+ y2milestone( "find_matching_disk solution resizing windows" );
+ solutions[k] = eval(l);
+ solutions[k,"disk"] = eval(rw);
+ }
+ }
+ }
+ else
+ {
+ map rp = remove_possible_partitions( e, tc );
+ map gap = get_gap_info( rp, false );
+ tc = add_cylinder_info( tc, gap );
+ map l = get_perfect_list( tc["partitions"]:[], gap );
+ if( size(l)>0 )
+ {
+ solutions[k] = eval(l);
+ solutions[k,"disk"] = eval(rp);
+ }
+ }
+ });
+ map ret = $[];
+ if( size(solutions)>0 )
+ {
+ foreach( string k, map e, solutions,
+ ``{
+ y2milestone( "find_matching_disk disk %1 weight %2",
+ k, e["weight"]:0 );
+ });
+ list<string> disks = maplist( string k, map e, solutions, ``(k) );
+ disks = sort( string a, string b, disks,
+ ``(solutions[a,"weight"]:0>solutions[b,"weight"]:0));
+ y2milestone( "find_matching_disk sorted disks %1", disks );
+ ret = solutions[disks[0]:""]:$[];
+ ret["device"] = disks[0]:"";
+ }
+ return( ret );
+ }
+
+
+map process_partition_data( string dev, map solution, string vgname )
+ {
+ map disk = solution["disk"]:$[];
+ list<map> partitions = [];
+ string value = "";
+ boolean remove_boot = false;
+ if( size( filter( map e, solution["partitions"]:[],
+ ``(e["mount"]:""==Partitions::BootMount() &&
+ e["auto_added"]:false)))>0 )
+ {
+ foreach( map e, solution["solution","gap"]:[],
+ ``{
+ foreach( list a, e["added"]:[],
+ ``{
+ integer pindex = a[0]:0;
+ if( solution["partitions",pindex,"mount"]:"" == "/" &&
+ disk["cyl_count"]:0 > Partitions::BootCyl() &&
+ e["end"]:0 <= Partitions::BootCyl() && !need_boot(disk) )
+ {
+ remove_boot = true;
+ }
+ });
+ });
+ }
+ integer index = 0;
+ if( remove_boot )
+ {
+ foreach( map e, solution["solution","gap"]:[],
+ ``{
+ list nlist = [];
+ foreach( list a, e["added"]:[],
+ ``{
+ integer pindex = a[0]:0;
+ if( solution["partitions",pindex,"mount"]:"" ==
+ Partitions::BootMount() )
+ {
+ integer rest = a[2]:0;
+ y2milestone( "process_partition_data remove unneeded %3 %1 cyl %2",
+ e["added"]:[], rest, Partitions::BootMount() );
+ list<list> nlist = filter( list l, e["added"]:[], ``(l[0]:0!=pindex));
+ if( size(nlist)>0 && !e["exists"]:false )
+ {
+ list weight = maplist( list l, nlist, ``(l[2]:0) );
+ map r = $[];
+ r = distribute_space( rest, weight, nlist,
+ solution["partitions"]:[] );
+ nlist = eval(r["added"]:[]);
+ solution["solution","gap",index,"cylinders"] =
+ e["cylinders"]:0 - r["diff"]:0;
+ }
+ solution["solution","gap",index,"added"] = eval(nlist);
+ }
+ pindex = pindex+1;
+ });
+ index = index + 1;
+ });
+ }
+ if( solution["solution","resize_ext"]:0>0 )
+ {
+ disk["partitions"] = maplist( map p, disk["partitions"]:[],
+ ``{
+ if( p["type"]:`unknown==`extended )
+ {
+ p["resize"] = true;
+ p["ignore_fs"] = true;
+ p["region",1] = solution["solution","resize_ext"]:0 -
+ p["region",0]:0 + 1;
+ p["size_k"] = p["region",1]:0 * disk["cyl_size"]:0 / 1024;
+ y2milestone( "process_partition_data resize ext %1", p );
+ }
+ return( p );
+ });
+ }
+ foreach( map e, solution["solution","gap"]:[],
+ ``{
+ y2milestone( "process_partition_data e %1", e );
+ if( e["exists"]:false )
+ {
+ integer index = 0;
+ integer pindex = e["added",0,0]:0;
+ string mount = solution["partitions",pindex,"mount"]:"";
+ integer fsid = Partitions::fsid_native;
+ if( mount == "swap" )
+ {
+ fsid = Partitions::fsid_swap;
+ }
+ if( solution["partitions",pindex,"id"]:0 != 0 )
+ {
+ fsid = solution["partitions",pindex,"id"]:0;
+ }
+ foreach( map p, disk["partitions"]:[],
+ ``{
+ if( p["nr"]:0 == e["added",0,1]:0 )
+ {
+ y2milestone( "process_partition_data reuse part %1", p );
+ if( p["mount"]:"" != mount )
+ p["inactive"] = true;
+ p = Storage::SetVolOptions( p, mount,
+ solution["partitions",pindex,"fsys"]:`unknown,
+ solution["partitions",pindex,"fopt"]:"",
+ solution["partitions",pindex,"fstopt"]:"",
+ solution["partitions",pindex,"label"]:"" );
+ if( p["fsid"]:0 != fsid )
+ {
+ p["change_fsid"] = true;
+ p["ori_fsid"] = p["fsid"]:0;
+ p["fsid"] = fsid;
+ }
+ if( size(mount)==0 && size(vgname)>0 &&
+ p["type"]:`unknown!=`extended )
+ p["vg"] = vgname;
+ disk["partitions",index] = p;
+ y2milestone( "process_partition_data reuse auto part %1", p );
+ }
+ else if( (size(vgname)>0||e["resize"]:0>0) &&
+ p["nr"]:0 == e["nr"]:0 )
+ {
+ if( e["fsid"]:0!=0 && e["fsid"]:0!=p["fsid"]:0 )
+ {
+ p["change_fsid"] = true;
+ p["ori_fsid"] = p["fsid"]:0;
+ p["fsid"] = e["fsid"]:0;
+ }
+ if( e["resize"]:0>0 )
+ {
+ p["resize"] = true;
+ p["ignore_fs"] = true;
+ p["region",1] = e["resize"]:0 - p["region",0]:0 + 1;
+ p["size_k"] = p["region",1]:0 *
+ disk["cyl_size"]:0 / 1024;
+ }
+ if( size(vgname)>0 )
+ p["vg"] = vgname;
+ disk["partitions",index] = p;
+ y2milestone( "process_partition_data resize part %1", p );
+ }
+ index = index + 1;
+ });
+ }
+ else
+ {
+ list region = [ e["start"]:0, e["end"]:0-e["start"]:0+1 ];
+ map part = $[];
+ if( e["extended"]:false && e["created"]:0 > 0 )
+ {
+ while( e["added",0,1]:(disk["max_primary"]:4+1) <=
+ disk["max_primary"]:4 )
+ {
+ integer pindex = e["added",0,0]:0;
+ string mount = solution["partitions",pindex,"mount"]:"";
+ integer fsid = Partitions::fsid_native;
+ if( mount == "swap" )
+ {
+ fsid = Partitions::fsid_swap;
+ }
+ part["create"] = true;
+ part["nr"] = e["created"]:0;
+ part["device"] = Storage::GetDeviceName( dev, part["nr"]:-1 );
+ part["region"] = region;
+ part["region",1] = e["added",0,2]:0;
+ region[0] = region[0]:0 + part["region",1]:0;
+ region[1] = region[1]:0 - part["region",1]:0;
+ part["type"] = `primary;
+ part["inactive"] = true;
+ part = Storage::SetVolOptions( part, mount,
+ solution["partitions",pindex,"fsys"]:`unknown,
+ solution["partitions",pindex,"fopt"]:"",
+ solution["partitions",pindex,"fstopt"]:"",
+ solution["partitions",pindex,"label"]:"" );
+ if( solution["partitions",pindex,"id"]:0 != 0 )
+ {
+ fsid = solution["partitions",pindex,"id"]:0;
+ if( !haskey( solution["partitions",pindex]:$[], "fsys" ))
+ {
+ part["format"] = false;
+ }
+ }
+ part["size_k"] = part["region",1]:0 * disk["cyl_size"]:0 / 1024;
+ part["fsid"] = fsid;
+ part["fstype"] = Partitions::FsIdToString( fsid );
+ if( size(mount)==0 && size(vgname)>0 )
+ part["vg"] = vgname;
+ y2milestone( "process_partition_data auto partition %1", part );
+ partitions = add( partitions, part );
+ e["created"] = e["added",0,1]:0;
+ e["added"] = remove( e["added"]:[], 0 );
+ part = $[];
+ }
+ part["create"] = true;
+ part["nr"] = e["created"]:0;
+ part["device"] = Storage::GetDeviceName( dev, part["nr"]:-1 );
+ part["region"] = eval(region);
+ part["type"] = `extended;
+ part["fsid"] = Partitions::fsid_extended_win;
+ part["fstype"] = Partitions::FsIdToString( part["fsid"]:0 );
+ part["size_k"] = region[1]:0 * disk["cyl_size"]:0 / 1024;
+ y2milestone( "process_partition_data extended auto partition %1", part );
+ partitions = add( partitions, eval(part));
+ }
+ foreach( list a, e["added"]:[],
+ ``{
+ part = $[];
+ integer pindex = a[0]:0;
+ string mount = solution["partitions",pindex,"mount"]:"";
+ integer fsid = Partitions::fsid_native;
+ if( mount == "swap" )
+ {
+ fsid = Partitions::fsid_swap;
+ }
+ part["create"] = true;
+ part["nr"] = a[1]:0;
+ part["device"] = Storage::GetDeviceName( dev, part["nr"]:0 );
+ region[1] = a[2]:0;
+ part["region"] = eval(region);
+ region[0] = region[0]:0 + region[1]:0;
+ part["size_k"] = region[1]:0 * disk["cyl_size"]:0 / 1024;
+ part["type"] = `primary;
+ if( e["extended"]:false )
+ {
+ part["type"] = `logical;
+ }
+ part["inactive"] = true;
+ part = Storage::SetVolOptions( part, mount,
+ solution["partitions",pindex,"fsys"]:`unknown,
+ solution["partitions",pindex,"fopt"]:"",
+ solution["partitions",pindex,"fstopt"]:"",
+ solution["partitions",pindex,"label"]:"" );
+ if( solution["partitions",pindex,"id"]:0 != 0 )
+ {
+ fsid = solution["partitions",pindex,"id"]:0;
+ if( !haskey( solution["partitions",pindex]:$[], "fsys" ))
+ {
+ part["format"] = false;
+ }
+ y2milestone( "process_partition_data partition id %1 format %2 part %3",
+ fsid, part["format"]:false,
+ solution["partitions",pindex]:$[] );
+ }
+ part["fsid"] = fsid;
+ part["fstype"] = Partitions::FsIdToString( fsid );
+ if( size(mount)==0 && size(vgname)>0 )
+ part["vg"] = vgname;
+ y2milestone( "process_partition_data auto partition %1", part );
+ partitions = add( partitions, eval(part));
+ });
+ partitions = sort( map a, map b, partitions, ``(a["nr"]:0<b["nr"]:0));
+ }
+ });
+ disk["partitions"] = union( disk["partitions"]:[], partitions );
+ y2milestone( "process_partition_data disk %1", disk );
+ return( disk );
+ }
+
+
+map add_cylinder_info( map conf, map gap )
+ {
+ integer cyl_size = gap["cyl_size"]:1;
+ conf["partitions"] =
+ sort( map a, map b, conf["partitions"]:[],
+ ``({
+ if( a["primary"]:false != b["primary"]:false )
+ return( true );
+ else if( a["max_cyl"]:big_cyl != b["max_cyl"]:big_cyl )
+ return( a["max_cyl"]:big_cyl < b["max_cyl"]:big_cyl );
+ else
+ return( a["size"]:0 < b["size"]:0 );
+ }));
+ y2milestone( "add_cylinder_info parts %1", conf["partitions"]:[] );
+ integer sum = 0;
+ conf["partitions"] = maplist( map p, conf["partitions"]:[],
+ ``{
+ sum = sum + p["pct"]:0;
+ p["cylinders"] = (p["size"]:0+cyl_size-1)/cyl_size;
+ if( p["cylinders"]:0 == 0 )
+ {
+ p["cylinders"] = 1;
+ }
+ return( p );
+ });
+ y2milestone( "add_cylinder_info sum %1", sum );
+ y2milestone( "add_cylinder_info parts %1", conf["partitions"]:[] );
+ if( sum>100 )
+ {
+ integer rest = sum - 100;
+ conf["partitions"] = maplist( map p, conf["partitions"]:[],
+ ``{
+ if( haskey( p, "pct" ) )
+ {
+ integer pct = p["pct"]:0;
+ integer diff = ((rest * pct) + sum/2) / sum;
+ sum = sum - pct;
+ rest = rest - diff;
+ p["pct"] = pct - diff;
+ }
+ return( p );
+ });
+ }
+ conf["partitions"] = maplist( map p, conf["partitions"]:[],
+ ``{
+ if( haskey( p, "pct" ) )
+ {
+ integer cyl = gap["sum"]:0 / 100 * p["pct"]:0;
+ cyl = (cyl+cyl_size/2) / cyl_size;
+ if( cyl == 0 )
+ {
+ cyl = 1;
+ }
+ p["want_cyl"] = cyl;
+ }
+ if( p["maxsize"]:0 > 0 )
+ {
+ integer cyl = (p["maxsize"]:0+cyl_size-1) / cyl_size;
+ p["size_max_cyl"] = cyl;
+ if( p["want_cyl"]:0 > cyl )
+ {
+ p["want_cyl"] = cyl;
+ }
+ }
+ return( p );
+ });
+ y2milestone( "add_cylinder_info parts %1", conf["partitions"]:[] );
+ return( conf );
+ }
+
+
+map get_perfect_list( list ps, map g )
+ {
+ y2milestone( "get_perfect_list ps %1", ps );
+ y2milestone( "get_perfect_list gap %1", g );
+ if( size(g["gap"]:[])>0 &&
+ ((g["extended_possible"]:false &&
+ size(g["free_pnr"]:[])>0 &&
+ size(ps)+1 <= size(g["ext_pnr"]:[])+size(g["free_pnr"]:[])) ||
+ (!g["extended_possible"]:false &&
+ size(ps) <= size(g["ext_pnr"]:[])+size(g["free_pnr"]:[]))) )
+ {
+ map lg = (map) eval(g);
+ lg["gap"] = maplist( map e, lg["gap"]:[],
+ ``{
+ e["orig_cyl"] = e["cylinders"]:0;
+ e["added"] = [];
+ return( e );
+ });
+ lg["procpart"] = 0;
+ list lp = (list) eval(ps);
+ if( g["extended_possible"]:false && size(ps)+1>size(g["free_pnr"]:[]))
+ {
+ y2milestone( "get_perfect_list creating extended" );
+ integer index = 0;
+ foreach( map e, lg["gap"]:[],
+ ``{
+ if( !e["exists"]:false )
+ {
+ map gap = (map) eval(lg);
+ gap["gap",index,"created"] = gap["free_pnr",0]:1;
+ gap["free_pnr"] = remove( gap["free_pnr"]:[1], 0 );
+ gap["gap",index,"extended"] = true;
+ add_part_recursive( ps, gap );
+ }
+ index = index+1;
+ });
+ }
+ else
+ {
+ y2milestone( "get_perfect_list not creating extended" );
+ add_part_recursive( ps, lg );
+ }
+ }
+ map ret = $[];
+ if( size(cur_gap)>0 )
+ {
+ ret["weight"] = cur_weight;
+ ret["solution"] = eval(cur_gap);
+ ret["partitions"] = eval(ps);
+ }
+ y2milestone( "get_perfect_list ret weight %1", ret["weight"]:-1000000 );
+ y2milestone( "get_perfect_list ret solution %1", ret["solution","gap"]:[] );
+ return( ret );
+ }
+
+
+void add_part_recursive( list ps, map g )
+ {
+ y2milestone( "add_part_recursive pindex %1", g["procpart"]:0 );
+ y2milestone( "add_part_recursive ps %1", ps );
+ y2milestone( "add_part_recursive gap %1", g );
+ map lg = (map) eval(g);
+ integer gindex = 0;
+ integer pindex = lg["procpart"]:0;
+ map part = ps[pindex]:$[];
+ lg["procpart"] = pindex + 1;
+ y2milestone( "add_part_recursive p %1", part );
+ foreach( map e, lg["gap"]:[],
+ ``{
+ y2milestone( "add_part_recursive e %1", e );
+ boolean max_cyl_ok = !haskey( part, "max_cyl" ) ||
+ part["max_cyl"]:0 >= e["end"]:0;
+ if( !max_cyl_ok )
+ {
+ integer cyl = 0;
+ foreach( list a, lg["gap",gindex,"added"]:[],
+ ``{
+ cyl = cyl + ps[a[0]:0,"cylinders"]:0;
+ });
+ cyl = cyl + part["cylinders"]:0;
+ y2milestone( "max_cyl_ok cyl %1", cyl );
+ max_cyl_ok = (e["start"]:0 + cyl) <= part["max_cyl"]:0;
+ }
+ y2milestone( "add_part_recursive max_cyl_ok %1", max_cyl_ok );
+ if( max_cyl_ok && part["cylinders"]:0 <= e["cylinders"]:0 &&
+ ((!e["extended"]:false && size(lg["free_pnr"]:[])>0) ||
+ (part["primary"]:false && e["created"]:0>0 && e["extended"]:false && size(lg["free_pnr"]:[])>0) ||
+ (!part["primary"]:false && e["extended"]:false && size(lg["ext_pnr"]:[])>0)))
+ {
+ map llg = (map) eval(lg);
+ if( e["exists"]:false )
+ {
+ llg["gap",gindex,"cylinders"] = 0;
+ }
+ else
+ {
+ llg["gap",gindex,"cylinders"] =
+ llg["gap",gindex,"cylinders"]:0 - part["cylinders"]:0;
+ }
+ list addl = [ pindex ];
+ if( e["extended"]:false && !part["primary"]:false )
+ {
+ addl = add( addl, llg["ext_pnr",0]:5 );
+ llg["ext_pnr"] = remove( llg["ext_pnr"]:[0], 0 );
+ }
+ else if( !e["exists"]:false )
+ {
+ addl = add( addl, llg["free_pnr",0]:1 );
+ llg["free_pnr"] = remove( llg["free_pnr"]:[0], 0 );
+ }
+ else
+ {
+ addl = add( addl, e["nr"]:0 );
+ }
+ llg["gap",gindex,"added"] =
+ add( llg["gap",gindex,"added"]:[], addl );
+ if( pindex+1 < size(ps) )
+ {
+ add_part_recursive( ps, llg );
+ }
+ else
+ {
+ map ng = normalize_gaps(ps, llg);
+ integer val = do_weighting( ps, ng );
+ y2milestone( "add_part_recursive val %1 cur_weight %2 size %3",
+ val, cur_weight, size(cur_gap));
+ if( val > cur_weight || size(cur_gap)==0 )
+ {
+ cur_weight = val;
+ cur_gap = (map)eval(ng);
+ }
+ }
+ }
+ gindex = gindex+1;
+ });
+ };
+
+
+map normalize_gaps( list ps, map g )
+ {
+ y2milestone( "normalize_gaps gap %1", g );
+ integer gindex = 0;
+ integer pindex = 0;
+ foreach( map e, g["gap"]:[],
+ ``{
+ y2milestone( "normalize_gaps e %1", e );
+ if( e["exists"]:false )
+ {
+ if( size(e["added"]:[])>0 && size(e["added",0]:[])==2 )
+ {
+ g["gap",gindex,"added",0] =
+ add( e["added",0]:[], e["orig_cyl"]:1 );
+ }
+ }
+ else
+ {
+ integer rest = e["cylinders"]:0;
+ integer needed = 0;
+ integer tidx = 0;
+ foreach( list p, e["added"]:[],
+ ``{
+ tidx = p[0]:0;
+ if( ps[tidx,"want_cyl"]:0 > ps[tidx,"cylinders"]:0 )
+ {
+ needed = needed + ps[tidx,"want_cyl"]:0 -
+ ps[tidx,"cylinders"]:0;
+ }
+ });
+ y2milestone( "normalize_gaps needed %1 rest %2", needed, rest );
+ if( needed > rest )
+ {
+ list tr = [];
+ list weight =
+ maplist( list l, e["added"]:[],
+ ``({
+ integer idx = l[0]:0;
+ integer d = ps[idx,"want_cyl"]:0 -
+ ps[idx,"cylinders"]:0;
+ if( d>0 )
+ {
+ l = add( l, ps[idx,"cylinders"]:0 );
+ }
+ tr = add( tr, l );
+ return( d>0 ? d : 0 );
+ }));
+ y2milestone( "normalize_gaps tr %1", tr );
+ map r = $[];
+ r = distribute_space( rest, weight, tr, ps );
+ g["gap",gindex,"added"] = eval(r["added"]:[]);
+ g["gap",gindex,"cylinders"] = e["cylinders"]:0 - r["diff"]:0;
+ y2milestone( "normalize_gaps partly satisfy %1 cyl %2",
+ g["gap",gindex,"added"]:[],
+ g["gap",gindex,"cylinders"]:0 );
+ }
+ else
+ {
+ g["gap",gindex,"cylinders"] = e["cylinders"]:0 - needed;
+ }
+
+ pindex = 0;
+ foreach( list p, g["gap",gindex,"added"]:[],
+ ``{
+ if( size(p)<3 )
+ {
+ tidx = p[0]:0;
+ if( ps[tidx,"want_cyl"]:0 > ps[tidx,"cylinders"]:0 )
+ {
+ p = add( p, ps[tidx,"want_cyl"]:0 );
+ }
+ else
+ {
+ p = add( p, ps[tidx,"cylinders"]:0 );
+ }
+ g["gap",gindex,"added",pindex] = p;
+ y2milestone( "normalize_gaps satisfy p %1 cyl %2", p,
+ e["cylinders"]:0 );
+ }
+ pindex = pindex+1;
+ });
+ y2milestone( "normalize_gaps added %1",
+ g["gap",gindex,"added"]:[] );
+ }
+ gindex = gindex + 1;
+ });
+ gindex = 0;
+ foreach( map e, g["gap"]:[],
+ ``{
+ if( !e["exists"]:false && e["cylinders"]:0>0 )
+ {
+ list<integer> weight = maplist( list l, e["added"]:[],
+ ``(ps[l[0]:0,"size"]:0==0 ? 1 : 0) );
+ if( find( integer l, weight, ``(l>0) ) != nil )
+ {
+ map r = $[];
+ r = distribute_space( e["cylinders"]:0, weight, e["added"]:[],
+ ps );
+ g["gap",gindex,"added"] = eval(r["added"]:[]);
+ g["gap",gindex,"cylinders"] = e["cylinders"]:0 - r["diff"]:0;
+ y2milestone( "normalize_gaps increase max p %1 cyl %2",
+ g["gap",gindex,"added"]:[],
+ g["gap",gindex,"cylinders"]:0 );
+ }
+ }
+ gindex = gindex + 1;
+ });
+ gindex = 0;
+ foreach( map e, g["gap"]:[],
+ ``{
+ if( !e["exists"]:false && e["cylinders"]:0>0 &&
+ e["cylinders"]:0 < g["disk_cyl"]:0/20 )
+ {
+ list weight = maplist( list l, e["added"]:[], ``(l[2]:0) );
+ map r = $[];
+ r = distribute_space( e["cylinders"]:0, weight, e["added"]:[], ps );
+ g["gap",gindex,"added"] = eval(r["added"]:[]);
+ g["gap",gindex,"cylinders"] = e["cylinders"]:0 - r["diff"]:0;
+ y2milestone( "normalize_gaps close small gap p %1 cyl %2",
+ g["gap",gindex,"added"]:[],
+ g["gap",gindex,"cylinders"]:0 );
+ }
+ gindex = gindex + 1;
+ });
+ gindex = 0;
+ foreach( map e, g["gap"]:[],
+ ``{
+ if( !e["exists"]:false && e["cylinders"]:0>0 )
+ {
+ list<integer> weight = [];
+ weight =
+ maplist( list l, e["added"]:[],
+ ``((ps[l[0]:0,"increasable"]:false) ? 1 : 0));
+ y2milestone( "normalize_gaps w %1", weight );
+ if( find( integer l, weight, ``(l>0) ) != nil )
+ {
+ map r = $[];
+ r = distribute_space( e["cylinders"]:0, weight, e["added"]:[],
+ ps );
+ g["gap",gindex,"added"] = eval(r["added"]:[]);
+ g["gap",gindex,"cylinders"] = e["cylinders"]:0 - r["diff"]:0;
+ e["cylinders"] = g["gap",gindex,"cylinders"]:0;
+ y2milestone( "normalize_gaps increase increasable p %1 cyl %2",
+ g["gap",gindex,"added"]:[],
+ g["gap",gindex,"cylinders"]:0 );
+ }
+ }
+ gindex = gindex + 1;
+ });
+ gindex = 0;
+ foreach( map e, g["gap"]:[],
+ ``{
+ if( !e["exists"]:false && e["extended"]:false && e["created"]:0 > 0 &&
+ size(e["added"]:[])==1 && e["cylinders"]:0==0 )
+ {
+ g["gap",gindex,"extended"] = false;
+ g["gap",gindex,"added",0,1] = e["created"]:0;
+ y2milestone( "normalize_gaps changed extended %1",
+ g["gap",gindex]:$[] );
+ }
+ gindex = gindex + 1;
+ });
+ gindex = 0;
+ map sort_map = $[ "/boot" : 0, "/boot/efi" : 0, "swap" : 1,
+ "/" : 5, "/home" :6 ];
+ foreach( map e, g["gap"]:[],
+ ``{
+ if( !e["exists"]:false && size(e["added"]:[])>1 )
+ {
+ y2milestone( "normalize_gaps old added %1", e["added"]:[] );
+ list nums = maplist( list l, e["added"]:[], ``(l[1]:-1));
+ y2milestone( "normalize_gaps old nums %1", nums );
+ list sdd = sort( list a, list b, e["added"]:[],
+ ``({
+ integer ai = a[0]:0;
+ integer bi = b[0]:0;
+ if( ps[ai,"primary"]:false != ps[bi,"primary"]:false )
+ return( ps[ai,"primary"]:false );
+ else if( ps[ai,"max_cyl"]:big_cyl != ps[bi,"max_cyl"]:big_cyl )
+ return( ps[ai,"max_cyl"]:big_cyl < ps[bi,"max_cyl"]:big_cyl );
+ else
+ return( sort_map[ps[ai,"mount"]:""]:3 < sort_map[ps[bi,"mount"]:""]:3);
+ }));
+ integer idx = 0;
+ foreach( list e, (list<list>)sdd,
+ ``{
+ sdd[idx,1] = nums[idx]:0;
+ idx = idx+1;
+ });
+ g["gap",gindex,"added"] = sdd;
+ y2milestone( "normalize_gaps sort added %1",
+ g["gap",gindex,"added"]:[] );
+ }
+ gindex = gindex + 1;
+ });
+ y2milestone( "normalize_gaps gap %1", g );
+ return( g );
+ };
+
+
+map distribute_space( integer rest, list weights, list added, list ps )
+ {
+ integer diff_sum = 0;
+ integer sum = 0;
+ integer index = 0;
+ integer pindex = 0;
+ integer scount = 0;
+ y2milestone( "distribute_space rest %1 weights %2 added %3", rest,
+ weights, added );
+ integer loopcount=0;
+ do
+ {
+ loopcount = loopcount+1;
+ index = 0;
+ sum = 0;
+ scount = 0;
+ foreach( list p, (list<list>)added,
+ ``{
+ pindex = p[0]:0;
+ if( ps[pindex,"size_max_cyl"]:0==0 ||
+ ps[pindex,"size_max_cyl"]:0 > p[2]:0)
+ {
+ sum = sum + weights[index]:0;
+ y2milestone( "sum %1 weight %2 pindex %3", sum,
+ weights[index]:0, pindex );
+ scount = scount+1;
+ }
+ index = index+1;
+ });
+ index = 0;
+ y2milestone( "distribute_space sum %1 rest %2 scount %3 added %4 lc %5",
+ sum, rest, scount, added, loopcount );
+ foreach( list p, (list<list>)added,
+ ``{
+ pindex = p[0]:0;
+ if( size(p)==3 && sum>0 &&
+ (ps[pindex,"size_max_cyl"]:0==0 ||
+ ps[pindex,"size_max_cyl"]:0 > p[2]:0) )
+ {
+ integer diff = ((rest*weights[index]:0) + sum/2) / sum;
+ if( ps[pindex,"size_max_cyl"]:0>0 &&
+ diff > ps[pindex,"size_max_cyl"]:0-p[2]:0 )
+ {
+ diff = ps[pindex,"size_max_cyl"]:0-p[2]:0;
+ }
+ sum = sum - weights[index]:0;
+ rest = rest - diff;
+ added[index,2] = added[index,2]:0 + diff;
+ diff_sum = diff_sum + diff;
+ y2milestone( "distribute_space sum %1 rest %2 diff %3 added %4",
+ sum, rest, diff, added[index]:[] );
+ }
+ index = index+1;
+ });
+ }
+ while( rest>0 && scount>0 && loopcount<3 );
+ map ret = $[ "added":added, "diff" : diff_sum ];
+ y2milestone( "distribute_space ret %1", ret );
+ return( ret );
+ }
+
+
+integer do_weighting( list ps, map g )
+ {
+ y2milestone( "do_weighting gap %1", g["gap"]:[] );
+ integer ret = 0;
+ integer index = 0;
+ integer diff = 0;
+ if( cur_mode == `reuse )
+ {
+ ret = ret - 100;
+ }
+ else if( cur_mode == `resize )
+ {
+ ret = ret - 1000;
+ }
+ else if( cur_mode == `desparate )
+ {
+ ret = ret - 1000000;
+ }
+ y2milestone( "do_weighting after mode ret %1", ret );
+ foreach( map e, g["gap"]:[],
+ ``{
+ y2milestone( "do_weighting e %1", e );
+ if( !e["exists"]:false && e["cylinders"]:0 > 0 )
+ {
+ diff = -5;
+ if( e["cylinders"]:0 < g["disk_cyl"]:0/20 )
+ {
+ diff = diff - 10;
+ }
+ ret = ret + diff;
+ y2milestone( "do_weighting after gaps diff %1 ret %2", diff, ret );
+ }
+ foreach( list p, e["added"]:[],
+ ``{
+ index = p[0]:0;
+ if( e["exists"]:false && ps[index,"mount"]:""=="swap" &&
+ e["swap"]:false )
+ {
+ diff = 100;
+ ret = ret + diff;
+ y2milestone( "do_weighting after swap reuse diff %1 ret %2",
+ diff, ret );
+ }
+ if( ps[index,"want_cyl"]:0>0 )
+ {
+ diff = ps[index,"want_cyl"]:0 - p[2]:0;
+ integer normdiff = diff * 100 / p[2]:0;
+ if( diff < 0 )
+ {
+ normdiff = -normdiff;
+ }
+ else if( diff > 0 )
+ {
+ normdiff = normdiff / 10;
+ }
+ diff = ps[index,"want_cyl"]:0*g["cyl_size"]:1 / (100*1024*1024) -
+ normdiff;
+ ret = ret + diff;
+ y2milestone( "do_weighting after pct parts diff %1 ret %2",
+ diff, ret );
+ }
+ if( ps[index,"size"]:0==0 )
+ {
+ diff = p[2]:0 * g["cyl_size"]:1 / (50 * 1024 * 1024);
+ ret = ret + diff;
+ y2milestone( "do_weighting after maximizes parts diff %1 ret %2",
+ diff, ret );
+ }
+ if( ps[index,"size_max_cyl"]:0 > 0 &&
+ ps[index,"size_max_cyl"]:0 < p[2]:0 )
+ {
+ diff = p[2]:0 - ps[index,"size_max_cyl"]:0;
+ integer normdiff = diff * 100 / ps[index,"size_max_cyl"]:0;
+ ret = ret - normdiff;
+ y2milestone( "do_weighting after maximal size diff %1 ret %2",
+ -normdiff, ret );
+ }
+ });
+ if( size(e["added"]:[])>0 && e["cylinders"]:0 > 0 )
+ {
+ integer diff = (e["cylinders"]:0 * g["cyl_size"]:1) / (1024*1024*1024);
+ ret = ret - diff;
+ y2milestone( "do_weighting after gap size diff %1 ret %2", -diff, ret );
+ }
+ if( e["extended"]:false )
+ ret = ret-1;
+ y2milestone( "do_weighting %1", ret );
+ });
+ y2milestone( "do_weighting ret %1", ret );
+ return( ret );
+ }
+
+
+global list<map> try_remove_sole_extended( list<map> parts )
+ {
+ list<map> ret = parts;
+ if( find( map p, ret,
+ ``(p["type"]:`unknown==`extended &&
+ !p["delete"]:false))!=nil &&
+ find( map p, ret,
+ ``(p["type"]:`unknown==`logical &&
+ !p["delete"]:false))==nil )
+ {
+ ret = maplist( map p, ret,
+ ``{
+ if( p["type"]:`unknown == `extended )
+ p["delete"] = true;
+ return( p );
+ });
+ y2milestone( "try_remove_sole_extended delete extended p:%1", ret );
+ }
+ return( ret );
+ }
+
+
+map remove_possible_partitions( map disk, map conf )
+ {
+ map ret = (map)eval(disk);
+ ret["partitions"] = maplist( map p, ret["partitions"]:[],
+ ``{
+ integer fsid = p["fsid"]:0;
+ if( (conf["remove_special_partitions"]:false ||
+ !contains( Partitions::do_not_delete, fsid ) ) &&
+ p["type"]:`primary != `extended &&
+ !contains( conf["keep_partition_num"]:[], p["nr"]:0 ) &&
+ !contains( conf["keep_partition_id"]:[], fsid ) &&
+ !contains( conf["keep_partition_fsys"]:[], p["used_fs"]:`none ) &&
+ Storage::CanDelete( p, disk, false ))
+ {
+ p["delete"] = true;
+ }
+ return( p );
+ });
+ ret["partitions"] = try_remove_sole_extended( ret["partitions"]:[] );
+ return( ret );
+ }
+
+
+map try_resize_windows( map disk )
+ {
+ integer cyl_size = disk["cyl_size"]:1;
+ map win = $[];
+ map ret = (map)eval(disk);
+
+ ret["partitions"] = maplist( map p, ret["partitions"]:[],
+ ``{
+ integer fsid = p["fsid"]:0;
+ if( Partitions::IsDosWinNtPartition( fsid ) )
+ {
+ win = p["winfo"]:$[];
+ y2milestone( "try_resize_windows win=%1", win );
+ if( win != nil && win["ok"]:false && p["size_k"]:0 > 1024*1024 &&
+ !win["efi"]:false )
+ {
+ p["winfo"] = win;
+ p["resize"] = true;
+ p["region",1] = (win["new_size"]:0 + cyl_size - 1) / cyl_size;
+ p["win_max_length"] =
+ (win["max_win_size"]:0 + cyl_size - 1) / cyl_size;
+ y2milestone( "try_resize_windows win part %1", p );
+ }
+ }
+ return( p );
+ });
+ return( ret );
+ }
+
+
+list<map> get_gaps( integer start, integer end, list<map> part,
+ boolean add_exist_linux )
+ {
+ y2milestone( "get_gaps start %1 end %2 add_exist %3", start, end,
+ add_exist_linux );
+ list<map> ret = [];
+ map entry = $[];
+ foreach( map p, part,
+ ``{
+ integer s = p["region",0]:0;
+ integer e = s + p["region",1]:1 - 1;
+ entry = $[];
+ if( start < s )
+ {
+ entry["start"] = start;
+ entry["end"] = s-1;
+ ret = add( ret, eval(entry) );
+ }
+ if( add_exist_linux && size(p["mount"]:"")==0 &&
+ (p["fsid"]:0==Partitions::fsid_native ||
+ p["fsid"]:0==Partitions::fsid_swap) )
+ {
+ entry["swap"] = p["fsid"]:0==Partitions::fsid_swap;
+ entry["start"] = s;
+ entry["end"] = e;
+ entry["exists"] = true;
+ entry["nr"] = p["nr"]:0;
+ ret = add( ret, entry );
+ }
+ start = e+1;
+ });
+ if( start < end )
+ {
+ entry = $[];
+ entry["start"] = start;
+ entry["end"] = end;
+ ret = add( ret, entry );
+ }
+ y2milestone( "get_gaps ret %1", ret );
+ return( ret );
+ }
+
+
+map get_gap_info( map disk, boolean add_exist_linux )
+ {
+ map ret = $[];
+ list<map> gap = [];
+ list<map> plist = filter( map p, disk["partitions"]:[],
+ ``(!p["delete"]:false) );
+ plist = sort( map a, map b, plist, ``(a["region",0]:0<b["region",0]:0) );
+ list<integer> exist_pnr = sort( maplist( map e, plist, ``(e["nr"]:0) ));
+ if( disk["label"]:""=="mac" && !contains( exist_pnr, 1 ) )
+ {
+ exist_pnr = add( exist_pnr, 1 );
+ }
+ integer max_prim = Partitions::MaxPrimary(disk["label"]:"msdos");
+ boolean has_ext = Partitions::HasExtended( disk["label"]:"msdos" );
+ integer max_pos_cyl = Storage::MaxCylLabel( disk, 0 );
+ integer end = 0;
+ if( has_ext )
+ {
+ map ext = filter( map p, plist,
+ ``(p["type"]:`primary == `extended))[0]:$[];
+ ret["extended_possible"] = size(ext)==0;
+ ret["ext_reg"] = ext["region"]:[];
+ if( size(ext)>0 )
+ {
+ end = ext["region",0]:0 + ext["region",1]:1-1;
+ if( end > ext["region",0]:0 + max_pos_cyl )
+ end = ext["region",0]:0 + max_pos_cyl;
+ gap = get_gaps( ext["region",0]:0, end,
+ filter( map p, plist, ``(p["nr"]:0>max_prim)),
+ add_exist_linux );
+ gap = maplist( map e, gap,
+ ``{
+ e["extended"]=true;
+ return e;
+ });
+ plist = filter( map p, plist, ``(p["nr"]:0<=max_prim));
+ }
+ }
+ else
+ {
+ ret["extended_possible"] = false;
+ }
+ end = disk["cyl_count"]:1-1;
+ if( end > max_pos_cyl )
+ end = max_pos_cyl;
+ integer start = 0;
+ if( disk["label"]:"" == "sun" )
+ start = 1;
+ gap = (list<map>)union( gap, get_gaps( start, end, plist, add_exist_linux ));
+ integer av_size = 0;
+ gap = maplist( map e, gap,
+ ``{
+ e["cylinders"] = e["end"]:0 - e["start"]:0 + 1;
+ e["size"] = e["cylinders"]:0 * disk["cyl_size"]:1;
+ av_size = av_size + e["size"]:0;
+ return( e );
+ });
+ gap = maplist( map e, gap,
+ ``{
+ e["sizepct"] = (e["size"]:0 * 201 / 2) / av_size;
+ if( e["sizepct"]:0 == 0 )
+ {
+ e["sizepct"] = 1;
+ }
+ return( e );
+ });
+ ret["cyl_size"] = disk["cyl_size"]:1;
+ ret["disk_cyl"] = disk["cyl_count"]:1;
+ ret["sum"] = av_size;
+ integer max_pnr = max_prim;
+ integer pnr = 1;
+ list free_pnr = [];
+ y2milestone( "get_gap_info exist_pnr %1", exist_pnr );
+ while( pnr<=max_pnr )
+ {
+ if( !contains( exist_pnr, pnr ) )
+ {
+ free_pnr = add( free_pnr, pnr );
+ }
+ pnr = pnr + 1;
+ }
+ ret["free_pnr"] = free_pnr;
+ list<integer> ext_pnr = [ 5, 6, 7, 8, 9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,
+ 25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,
+ 45,46,47,48,49,50,51,52,53,54,55,56,57,58,59,60,61,62,63];
+ integer max_logical = disk["max_logical"]:15;
+ if( max_logical<63 )
+ {
+ ext_pnr = filter( integer i, ext_pnr, ``(i<=max_logical));
+ }
+ if( !has_ext )
+ {
+ ext_pnr = [];
+ }
+ else
+ {
+ integer maxlog = size(filter( integer i, exist_pnr, ``(i>max_pnr))) + 4;
+ ext_pnr = filter( integer i, ext_pnr, ``(i>maxlog));
+ }
+ ret["ext_pnr"] = ext_pnr;
+ ret["gap"] = gap;
+ y2milestone( "get_gap_info ret %1", ret );
+ return( ret );
+ }
+
+
+/**
+ * Read partition data from XML control file
+ * @return map flexible proposal map
+ */
+map read_partition_xml_config()
+ {
+ map xmlflex = (map)ProductFeatures::GetFeature ("partitioning", "flexible_partitioning");
+ y2milestone("xml input: %1", xmlflex );
+
+ map conf = $[];
+ conf["prefer_remove"] = xmlflex["prefer_remove"]:true;
+ conf["remove_special_partitions"] =
+ xmlflex["remove_special_partitions"]:false;
+ conf["keep_partition_id"] = [];
+ conf["keep_partition_num"] = [];
+ conf["keep_partition_fsys"] = [];
+
+ foreach( string key, [ "keep_partition_id", "keep_partition_num"],
+ ``{
+ list num = [];
+ list<string> nlist = splitstring(xmlflex[key]:"", ",");
+ foreach( string n, nlist, ``{ num = union( num, [tointeger(n)] );});
+ conf[key] = num;
+ });
+
+ list fsys = [];
+ list<string> nlist = splitstring( xmlflex["keep_partition_fsys"]:"" , "," );
+ foreach( string n, nlist,
+ ``{
+ symbol fs = FileSystems::FsToSymbol(n);
+ if( fs != `none )
+ {
+ fsys = union( fsys, [ fs ] );
+ }
+ });
+ conf["keep_partition_fsys"] = fsys;
+ list partitions = [];
+ foreach(map p, xmlflex["partitions"]:[],
+ ``{
+ map partition = $[];
+
+ if (p["disk"]:0 != 0)
+ {
+ partition["disk"] = p["disk"]:0;
+ }
+ if (p["id"]:0 != 0)
+ {
+ partition["id"] = p["id"]:0;
+ }
+
+ if (p["fstopt"]:"" != "")
+ {
+ partition["fstopt"] = p["fstopt"]:"";
+ }
+
+ if (p["formatopt"]:"" != "")
+ {
+ partition["fopt"] = p["formatopt"]:"";
+ }
+
+ partition["increasable"] = p["increasable"]:false;
+
+ if (p["mount"]:"" != "")
+ {
+ partition["mount"] = p["mount"]:"";
+ }
+
+ if (p["percent"]:-1 != -1)
+ {
+ partition["pct"] = p["percent"]:100;
+ }
+
+ if (p["label"]:"" != "")
+ {
+ partition["label"] = p["label"]:"";
+ }
+
+ if (p["maxsize"]:"" != "")
+ {
+ partition["maxsize"] = Storage::ClassicStringToByte(p["maxsize"]:"");
+ }
+
+ if (p["fsys"]:"" != "")
+ {
+ symbol fs = FileSystems::FsToSymbol(p["fsys"]:"");
+ if( fs != `none )
+ {
+ partition["fsys"] = fs;
+ }
+ }
+
+ if (p["size"]:"" != "")
+ {
+ string s = p["size"]:"";
+ if( tolower(s) == "auto" )
+ {
+ partition["size"] = -1;
+ }
+ else if( tolower(s) == "max" )
+ {
+ partition["size"] = 0;
+ }
+ else
+ {
+ partition["size"] = Storage::ClassicStringToByte(s);
+ }
+ }
+
+ if( partition["size"]:0 == -1 && partition["mount"]:"" == "swap" )
+ {
+ partition["size"] = 1024*1024*Partitions::SwapSizeMb(0);
+ }
+ if( partition["mount"]:"" == Partitions::BootMount() )
+ {
+ if( partition["size"]:0 == -1 )
+ {
+ partition["size"] = Partitions::ProposedBootsize();
+ }
+ if( partition["fsys"]:`none == `none )
+ {
+ partition["fsys"] = Partitions::DefaultBootFs();
+ }
+ if( partition["id"]:0 == 0 )
+ {
+ partition["id"] = Partitions::FsidBoot();
+ }
+ partition["max_cyl"] = Partitions::BootCyl();
+ }
+ if( partition["size"]:0 == -1 )
+ {
+ partition["size"] = 0;
+ }
+
+ y2milestone("partition: %1", partition);
+ if( size(partition["mount"]:"")>0 || partition["id"]:0 > 0 )
+ {
+ partitions = add( partitions, partition );
+ }
+ });
+ conf["partitions"] = partitions;
+ if( size(partitions)==0 )
+ {
+ conf = $[];
+ }
+ else
+ {
+ conf["partitions"] = partitions;
+ }
+ y2milestone( "conf %1", conf );
+ return( conf );
+ }
+
+
+map read_partition_config( string fpath )
+ {
+ integer pos = 0;
+ string line = "";
+ string rex = "";
+ map conf = $[];
+
+ conf["prefer_remove"] = true;
+ conf["remove_special_partitions"] = false;
+ conf["keep_partition_id"] = [];
+ conf["keep_partition_num"] = [];
+ conf["keep_partition_fsys"] = [];
+
+ string cstring = (string) SCR::Read( .target.string, fpath );
+ list<string> lines = filter( string e, splitstring( cstring, "\n" ), ``(size(e)>0) );
+ rex = "[ \t]*#.*";
+ y2milestone( "lines %1", lines );
+ lines = filter( string e, lines, ``(!regexpmatch( e, "[ \t]*#.*" )));
+ y2milestone( "lines %1", lines );
+ list fnd = [];
+ foreach( string key, [ "PREFER_REMOVE", "REMOVE_SPECIAL_PARTITIONS" ],
+ ``{
+ rex = "[ \t]*" + key + "[ \t]*=";
+ fnd = filter( string e, lines, ``(regexpmatch( e, rex )));
+ y2milestone( "rex %1 fnd %2", rex, fnd );
+ if( size(fnd)>0 )
+ {
+ line = deletechars( fnd[size(fnd)-1]:"", "\t " );
+ pos = findlastof( line, "=" );
+ if( pos > 0 )
+ {
+ conf[tolower(key)] = tointeger( substring( line, pos+1 ))>0;
+ }
+ }
+ });
+ foreach( string key, [ "KEEP_PARTITION_ID", "KEEP_PARTITION_NUM" ],
+ ``{
+ rex = "[ \t]*" + key + "[ \t]*=";
+ y2milestone( "rex %1", rex );
+ foreach( string l, filter( string e, lines, ``(regexpmatch( e, rex ))),
+ ``{
+ y2milestone( "line %1", l );
+ line = deletechars( l, "\t " );
+ pos = findlastof( line, "=" );
+ if( pos > 0 )
+ {
+ list num = [];
+ list<string> nlist = splitstring( substring( line, pos+1 ), "," );
+ foreach( string n, nlist, ``{ num = union( num, [tointeger(n)] );});
+ conf[tolower(key)] = union( conf[tolower(key)]:[], num );
+ }
+ });
+ });
+ list fsys = [];
+ rex = "[ \t]*" + "KEEP_PARTITION_FSYS" + "[ \t]*=";
+ foreach( string l, filter( string e, lines, ``(regexpmatch( e, rex ))),
+ ``{
+ y2milestone( "line %1", l );
+ line = deletechars( l, "\t " );
+ pos = findlastof( line, "=" );
+ if( pos > 0 )
+ {
+ list<string> nlist = splitstring( substring( line, pos+1 ), "," );
+ foreach( string n, nlist,
+ ``{
+ symbol fs = FileSystems::FsToSymbol(n);
+ if( fs != `none )
+ {
+ fsys = union( fsys, [ fs ] );
+ }
+ });
+ }
+ });
+ conf["keep_partition_fsys"] = fsys;
+ list partitions = [];
+ map part = $[];
+ rex = "[ \t]*" + "PARTITION" + "[ \t][ \t]*";
+ foreach( string l, filter( string e, lines, ``(regexpmatch( e, rex ))),
+ ``{
+ y2milestone( "line %1", l );
+ string par = "";
+ string key = "";
+ integer pos = search( l, "PARTITION" );
+ line = substring( l, pos+10 );
+ y2milestone( "line %1", line );
+ pos = search( line, "=" );
+ part = $[];
+ while( pos!=nil )
+ {
+ key = deletechars( substring( line, 0, pos ), " \t" );
+ line = substring( line, pos+1 );
+ if( substring( line, 0, 1 ) == "\"" )
+ {
+ line = substring( line, 1 );
+ pos = search( line, "\"" );
+ par = substring( line, 0, pos );
+ line = substring( line, pos+1 );
+ }
+ else
+ {
+ pos = findfirstof( line, " \t" );
+ if( pos==nil )
+ {
+ par = line;
+ }
+ else
+ {
+ par = substring( line, 0, pos );
+ line = substring( line, pos+1 );
+ }
+ }
+ y2debug( "key %1 par \"%2\"", key, par );
+ if( key == "id" )
+ {
+ part[key] = tointeger(par);
+ }
+ else if( key == "mount" )
+ {
+ part[key] = par;
+ }
+ else if( key == "increasable" )
+ {
+ part["increasable"] = tointeger(par)>0 ? true : false;
+ }
+ else if( key == "size" )
+ {
+ if( tolower(par) == "auto" )
+ {
+ part["size"] = -1;
+ }
+ else if( tolower(par) == "max" )
+ {
+ part["size"] = 0;
+ }
+ else
+ {
+ part["size"] = Storage::ClassicStringToByte(par);
+ }
+ }
+ else if( key == "label" )
+ {
+ part[key] = par;
+ }
+ else if( key == "maxsize" )
+ {
+ part[key] = Storage::ClassicStringToByte(par);
+ }
+ else if( key == "sizepct" )
+ {
+ part["pct"] = tointeger(par);
+ }
+ else if( key == "disk" )
+ {
+ part[key] = tointeger(par);
+ }
+ else if( key == "fsys" )
+ {
+ symbol fs = FileSystems::FsToSymbol(par);
+ if( fs != `none )
+ {
+ part[key] = fs;
+ }
+ }
+ else if( key == "fstopt" )
+ {
+ part[key] = par;
+ }
+ else if( key == "formatopt" )
+ {
+ part["fopt"] = par;
+ }
+ pos = search( line, "=" );
+ }
+ y2milestone( "part %1", part );
+ if( part["size"]:0 == -1 && part["mount"]:"" == "swap" )
+ {
+ part["size"] = 1024*1024*Partitions::SwapSizeMb(0);
+ }
+ if( part["mount"]:"" == Partitions::BootMount() )
+ {
+ if( part["size"]:0 == -1 )
+ {
+ part["size"] = Partitions::ProposedBootsize();
+ }
+ if( part["fsys"]:`none == `none )
+ {
+ part["fsys"] = Partitions::DefaultBootFs();
+ }
+ if( part["id"]:0 == 0 )
+ {
+ part["id"] = Partitions::FsidBoot();
+ }
+ part["max_cyl"] = Partitions::BootCyl();
+ }
+ if( part["size"]:0 == -1 )
+ {
+ part["size"] = 0;
+ }
+ if( size(part["mount"]:"")>0 || part["id"]:0 > 0 )
+ {
+ partitions = add( partitions, part );
+ }
+ });
+ conf["partitions"] = partitions;
+ if( size(partitions)==0 )
+ {
+ conf = $[];
+ }
+ else
+ {
+ conf["partitions"] = partitions;
+ }
+ y2milestone( "conf %1", conf );
+ return( conf );
+ }
+
+
+global map can_swap_reuse( string disk, list<map> partitions, map<string,map> tgmap )
+ {
+ map ret = $[];
+ y2milestone( "can_swap_reuse disk %1 partitions %2", disk, partitions );
+ list<map> swaps = filter( map p, partitions,
+ ``(p["type"]:`unknown!=`free &&
+ !p["delete"]:false &&
+ p["detected_fs"]:`unknown==`swap));
+ swaps = filter( map p, swaps, ``(check_swapable(p["device"]:"")));
+ swaps = sort( map a, map b, swaps, ``(a["size_k"]:0>b["size_k"]:0));
+ y2milestone( "can_swap_reuse swaps %1", swaps );
+ if( swaps[0,"size_k"]:0 >= 128*1024 )
+ {
+ ret["partitions"] =
+ maplist( map p, partitions,
+ ``{
+ if( !p["delete"]:false &&
+ p["device"]:""==swaps[0,"device"]:"" )
+ {
+ if( p["mount"]:"" != "swap" )
+ p["inactive"] = true;
+ p["mount"] = "swap";
+ if( haskey( p, "vg" ))
+ {
+ p = remove( p, "vg" );
+ if( p["change_fsid"]:false )
+ p["fsid"] = p["ori_fsid"]:Partitions::fsid_swap;
+ }
+ }
+ return( p );
+ });
+ }
+ else
+ {
+ swaps = [];
+ map<string,map> tg = filter( string k, map d, tgmap,
+ ``(Storage::IsPartitionable(d)));
+ if( haskey( tg, disk ))
+ tg = remove( tg, disk );
+ y2milestone( "can_swap_reuse tg wo %1", tg );
+ foreach( string dev, map disk, tg,
+ ``{
+ list<map> sw = filter( map p, disk["partitions"]:[],
+ ``(p["type"]:`unknown!=`extended &&
+ !p["delete"]:false &&
+ p["detected_fs"]:`unknown==`swap));
+ sw = filter( map p, sw, ``(check_swapable(p["device"]:"")));
+ y2milestone( "can_swap_reuse disk %1 sw %2", dev, sw );
+ swaps = (list<map>)union( swaps, sw );
+ });
+ swaps = sort( map a, map b, swaps, ``(a["size_k"]:0>b["size_k"]:0));
+ y2milestone( "can_swap_reuse swaps %1", swaps );
+ if( swaps[0,"size_k"]:0 >= 256*1024 )
+ {
+ ret["targets"] = Storage::SetPartitionData( tgmap,
+ swaps[0,"device"]:"",
+ "mount", "swap" );
+ ret["targets"] = Storage::DelPartitionData( ret["targets"]:$[],
+ swaps[0,"device"]:"",
+ "vg" );
+ }
+ }
+ y2milestone( "can_swap_reuse ret %1", ret );
+ return( ret );
+ }
+
+
+list<map> can_boot_reuse( string disk, string label, boolean boot,
+ integer max_prim, list<map> partitions )
+ {
+ list<map> ret = [];
+ y2milestone( "can_boot_reuse boot:%1", boot );
+ if( boot && !Partitions::PrepBoot() )
+ {
+ y2milestone( "can_boot_reuse disk:%1 max_prim:%2 label:%3 part:%4",
+ disk, max_prim, label, partitions );
+ list<map> pl = [];
+ pl = filter( map p, partitions,
+ ``(!p["delete"]:false &&
+ p["size_k"]:0*1024 >=
+ Partitions::MinimalBootsize()));
+ map boot = find( map p, pl,
+ ``((p["fsid"]:0 == Partitions::fsid_gpt_boot) ||
+ (p["fsid"]:0 == Partitions::FsidBoot() &&
+ p["size_k"]:0*1024 <= Partitions::MaximalBootsize()) ||
+ (p["detected_fs"]:`unknown==`hfs &&
+ p["boot"]:false && label=="mac") ||
+ (p["fsid"]:0 == Partitions::fsid_prep_chrp_boot &&
+ p["nr"]:0 <= max_prim &&
+ Partitions::PrepBoot())));
+ if( boot != nil )
+ {
+ ret = maplist( map p, partitions,
+ ``{
+ if( !p["delete"]:false &&
+ p["device"]:""==boot["device"]:"" &&
+ Storage::CanEdit(p,false) )
+ {
+ p = Storage::SetVolOptions( p, Partitions::BootMount(),
+ Partitions::DefaultBootFs(),
+ "", "", "" );
+ }
+ return( p );
+ });
+ }
+ y2milestone( "can_boot_reuse ret:%1", ret );
+ }
+ return( ret );
+ }
+
+list<map> can_mp_reuse( string mp, integer min, integer max,
+ list<map> partitions )
+ {
+ list<map> ret = [];
+ if( max>0 )
+ max = max + max/10;
+ y2milestone( "can_mp_reuse mp %1 min %2 max %3", mp, min, max );
+ list<map> pl = [];
+ pl = filter( map p, partitions,
+ ``(!p["delete"]:false &&
+ p["fsid"]:Partitions::fsid_native ==
+ Partitions::fsid_native &&
+ !Storage::IsUsedBy(p) &&
+ size(p["mount"]:"")==0 &&
+ p["size_k"]:0/1024 >= min &&
+ (max==0 || p["size_k"]:0/1024 <= max) &&
+ Storage::CanEdit( p, false )));
+ y2milestone( "can_mp_reuse normal %1", pl );
+ if( size(pl)>0 )
+ {
+ pl = sort( map a, map b, pl, ``(a["size_k"]:0>b["size_k"]:0));
+ y2milestone( "can_mp_reuse sorted %1", pl );
+ ret = maplist( map p, partitions,
+ ``{
+ if( !p["delete"]:false &&
+ p["device"]:""==pl[0,"device"]:"" )
+ {
+ p = Storage::SetVolOptions( p, mp, PropDefaultFs(),
+ "", "", "" );
+ }
+ return( p );
+ });
+ }
+ y2milestone( "can_mp_reuse ret %1", ret );
+ return( ret );
+ }
+
+
+integer get_avail_size_mb( list<map> parts )
+ {
+ integer ret = 0;
+ foreach( map pp, filter( map p, parts, ``(p["delete"]:false &&
+ p["type"]:`unknown!=`extended)),
+ ``{
+ ret = ret + pp["size_k"]:0/1024;
+ });
+ y2milestone( "get_avail_size_mb ret %1", ret );
+ return( ret );
+ }
+
+
+ list<integer> get_swap_sizes(integer space)
+ {
+ list<integer> l = [ Partitions::SwapSizeMb(0), Partitions::SwapSizeMb(space) ];
+ y2milestone("get_swap_sizes space %1 ret %2", space, l);
+ return l;
+ }
+
+
+global list<map> get_proposal( boolean have_swap, map disk )
+ {
+ list<map> ret = [];
+ y2milestone( "get_proposal have_swap:%1 disk %2", have_swap, disk );
+ map root = $[ "mount" : "/", "increasable" : true,
+ "fsys" : PropDefaultFs(), "size" : 0 ];
+ map opts = GetControlCfg();
+ map conf = $[ "partitions" : [] ];
+ list<integer> swap_sizes = [];
+ integer avail_size = get_avail_size_mb(disk["partitions"]:[]);
+ if( !have_swap )
+ {
+ swap_sizes = get_swap_sizes( avail_size );
+ map swap = $[ "mount" : "swap", "increasable" : true, "fsys" : `swap,
+ "maxsize" : 2*1024*1024*1024,
+ "size" : swap_sizes[0]:256*1024*1024 ];
+ conf["partitions"] = add( conf["partitions"]:[], swap );
+ }
+ conf["partitions"] = add( conf["partitions"]:[], root );
+ map old_root = $[];
+ if( GetProposalHome() && opts["home_limit"]:0 < avail_size )
+ {
+ map home = $[ "mount" : "/home", "increasable" : true,
+ "fsys" : PropDefaultFs(), "size" : 512*1024*1024,
+ "pct" : 100-opts["root_percent"]:40 ];
+ conf["partitions"] = maplist( map p, conf["partitions"]:[],
+ ``{
+ if( p["mount"]:""=="/" )
+ {
+ old_root = p;
+ p["pct"] = opts["root_percent"]:40;
+ p["maxsize"] = opts["root_max"]:0*1024*1024;
+ p["size"] = opts["root_base"]:0*1024*1024;
+ }
+ return( p );
+ });
+ conf["partitions"] = add( conf["partitions"]:[], home );
+ }
+ map ps1 = do_flexible_disk_conf( disk, conf, false, false );
+ if( size(old_root)>0 && !ps1["ok"]:false )
+ {
+ conf["partitions"] =
+ filter( map p, conf["partitions"]:[],
+ ``(p["mount"]:""!="/home" && p["mount"]:""!="/"));
+ conf["partitions"] = add( conf["partitions"]:[], old_root );
+ ps1 = do_flexible_disk_conf( disk, conf, false, false );
+ }
+ if( !have_swap )
+ {
+ integer diff = swap_sizes[0]:256 - swap_sizes[1]:256;
+ if( diff<0 )
+ diff = -diff;
+ y2milestone( "get_proposal diff:%1 ps1 ok:%2", diff, ps1["ok"]:false );
+ if( (!ps1["ok"]:false && diff>0) || diff>100 )
+ {
+ conf["partitions",0,"size"] = swap_sizes[1]:256*1024*1024;
+ map ps2 = do_flexible_disk_conf( disk, conf, false, false );
+ y2milestone( "get_proposal ps2 ok:%1", ps2["ok"]:false );
+ if( ps2["ok"]:false )
+ {
+ map rp1 = find( map p, ps1["disk","partitions"]:[],
+ ``(!p["delete"]:false && p["mount"]:""=="/"));
+ map rp2 = find( map p, ps2["disk","partitions"]:[],
+ ``(!p["delete"]:false && p["mount"]:""=="/"));
+ y2milestone( "get_proposal rp1:%1", rp1 );
+ y2milestone( "get_proposal rp2:%1", rp2 );
+ if( rp1==nil || (rp2!=nil && rp2["size_k"]:0>rp1["size_k"]:0 ))
+ ps1 = ps2;
+ }
+ }
+ }
+ if( ps1["ok"]:false )
+ ret = ps1["disk","partitions"]:[];
+ y2milestone("get_proposal ret:%1", ret);
+ return ret;
+ }
+
+
+integer get_usable_size_mb( map disk, boolean reuse_linux )
+ {
+ integer ret = 0;
+ integer cyl_size = disk["cyl_size"]:0;
+ integer disk_cyl = disk["cyl_count"]:0;
+ list<map> partitions = filter( map p, disk["partitions"]:[],
+ ``(!p["create"]:false));
+ partitions = sort( map p1, map p2, partitions,
+ ``(p1["region",0]:0 < p2["region",0]:0));
+ integer last_end = 0;
+ foreach( map p, partitions,
+ ``{
+ if( p["region",0]:0>last_end )
+ ret = ret + (p["region",0]:0-last_end) * cyl_size;
+ if( p["type"]:`unknown!=`extended &&
+ (p["delete"]:false || (reuse_linux && p["linux"]:false)))
+ ret = ret + p["size_k"]:0 * 1024;
+ last_end = p["region",0]:0;
+ if( p["type"]:`unknown != `extended )
+ last_end = last_end + p["region",1]:0;
+ });
+ if( last_end < disk_cyl )
+ ret = ret + (disk_cyl-last_end) * cyl_size;
+ ret = ret / (1024*1024);
+ return( ret );
+ }
+
+
+integer get_mb_sol( map sol, string mp )
+ {
+ map pa = find( map p, sol["disk","partitions"]:[], ``(p["mount"]:""==mp));
+ y2milestone( "get_mb_sol pa %1", pa );
+ integer ret = pa!=nil ? pa["size_k"]:0/1024 : 0;
+ y2milestone( "get_mb_sol ret %1", ret );
+ return( ret );
+ }
+
+
+integer get_vm_sol( map sol )
+ {
+ integer ret = 0;
+ foreach( map p, sol["disk","partitions"]:[],
+ ``{
+ if( !p["delete"]:false && (size(p["mount"]:"")>0 || size(p["vg"]:"")>0))
+ ret = ret + p["size_k"]:0/1024;
+ });
+ y2milestone( "get_vm_sol ret %1", ret );
+ return( ret );
+ }
+
+
+list<map> special_boot_proposal_prepare( list<map> partitions )
+ {
+ list<map> ret = partitions;
+ if( Partitions::PrepBoot() )
+ {
+ ret = maplist( map p, partitions,
+ ``{
+ if( size(p["mount"]:"")==0 &&
+ (p["fsid"]:0 == 0x06 || p["fsid"]:0 == 0x41) )
+ p["delete"] = true;
+ return( p );
+ });
+ y2milestone( "special_boot_proposal_prepare part:%1", partitions );
+ y2milestone( "special_boot_proposal_prepare ret:%1", ret );
+ }
+ return( ret );
+ }
+
+
+map<string,map> prepare_part_lists( list<string> ddev, map<string,map> tg )
+ {
+ list linux_pid = [ Partitions::fsid_native, Partitions::fsid_swap,
+ Partitions::fsid_lvm, Partitions::fsid_raid ];
+ foreach( string s, ddev,
+ ``{
+ tg[s,"partitions"] =
+ maplist( map p, tg[s,"partitions"]:[],
+ ``{
+ if( contains( linux_pid, p["fsid"]:0 ) ||
+ (p["fsid"]:0 == Partitions::fsid_gpt_boot) ||
+ (p["fsid"]:0 == Partitions::FsidBoot() &&
+ p["size_k"]:0*1024 <= Partitions::MaximalBootsize()) ||
+ (Partitions::PrepBoot() &&
+ (p["fsid"]:0 == Partitions::fsid_prep_chrp_boot||
+ p["fsid"]:0 == 0x06)))
+ p["linux"] = true;
+ else
+ p["linux"] = false;
+ return( p );
+ });
+ });
+ return( tg );
+ }
+
+
+list<string> get_disk_try_list( map<string,map> tg, boolean soft )
+ {
+ list<string> ret = [];
+ ret = maplist( string k, map e,
+ filter( string l, map f, tg,
+ ``(!ignore_disk(l,f,soft))), ``(k));
+ ret = sort( ret );
+ if( size(ret)>4 )
+ {
+ ret = restrict_disk_names( ret );
+ }
+ y2milestone( "get_disk_try_list soft:%1 ret:%2", soft, ret );
+ return( ret );
+ }
+
+
+boolean usable_for_win_resize( map p, boolean assert_cons_fs )
+ {
+ boolean ret = Partitions::IsDosWinNtPartition( p["fsid"]:0 ) &&
+ p["size_k"]:0 > 1024*1024 &&
+ !p["resize"]:false && !p["delete"]:false;
+ if( ret )
+ {
+ if( assert_cons_fs )
+ ret = p["winfo","ok"]:false && !p["winfo","efi"]:false;
+ else
+ ret = size(p["winfo"]:$[])>0;
+ }
+ return( ret );
+ }
+
+
+list<map> remove_p_settings( list<map> parts, list<string> mp )
+ {
+ list<string> rems = [ "resize", "used_fs", "win_max_length", "mount",
+ "format", "ignore_fs", "vg" ];
+ parts =
+ maplist( map p, parts,
+ ``{
+ if( (size(mp)==0 || contains( mp, p["mount"]:"")) &&
+ !(p["mount"]:""=="swap" && !p["inactive"]:false) )
+ {
+ foreach( string s, rems,
+ ``{
+ if( haskey( p, s ) )
+ p = remove( p, s );
+ });
+ }
+ return( p );
+ });
+ return( parts );
+ }
+
+
+list<map> remove_one_partition( map disk )
+ {
+ list<map> partitions = disk["partitions"]:[];
+ list<map> pl = filter( map p, partitions,
+ ``( p["linux"]:false && size(p["mount"]:"")==0 &&
+ !p["delete"]:false &&
+ Storage::CanDelete( p, disk, false )));
+ if( size(pl)>0 )
+ {
+ pl = sort( map a, map b, pl,
+ ``(a["size_k"]:0>b["size_k"]:0));
+ pl = (list<map>) union(
+ filter( map p, pl, ``(!Storage::IsUsedBy(p)) ),
+ filter( map p, pl, ``(Storage::IsUsedBy(p)) ));
+
+ partitions =
+ maplist( map p, partitions,
+ ``{
+ if( p["linux"]:false && !p["delete"]:false &&
+ size(p["mount"]:"")==0 &&
+ p["device"]:""==pl[0,"device"]:"" &&
+ Storage::CanDelete( p, disk, false ))
+ {
+ p["delete"] = true;
+ y2milestone( "remove_one_partition p %1", p );
+ }
+ return( p );
+ });
+ partitions = try_remove_sole_extended( partitions );
+ }
+ return( partitions );
+ }
+
+
+list<map> remove_one_partition_vm( map disk )
+ {
+ list<map> partitions = disk["partitions"]:[];
+ list<map> pl = filter( map p, partitions,
+ ``( p["linux"]:false && size(p["mount"]:"")==0 &&
+ !p["delete"]:false &&
+ Storage::CanDelete( p, disk, false )));
+ if( size(pl)>0 )
+ {
+ pl = sort( map a, map b, pl,
+ ``(a["size_k"]:0<b["size_k"]:0));
+ pl = (list<map>) union(
+ filter( map p, pl, ``(p["type"]:`primary==`logical) ),
+ filter( map p, pl, ``(p["type"]:`primary!=`logical) ));
+ pl = (list<map>) union(
+ filter( map p, pl, ``(!Storage::IsUsedBy(p)) ),
+ filter( map p, pl, ``(Storage::IsUsedBy(p)) ));
+ y2milestone( "remove_one_partition_vm pl %1", pl );
+
+ integer nr = 0;
+
+ partitions =
+ maplist( map p, partitions,
+ ``{
+ if( p["linux"]:false && !p["delete"]:false &&
+ size(p["mount"]:"")==0 &&
+ p["device"]:""==pl[0,"device"]:"" &&
+ Storage::CanDelete( p, disk, false ))
+ {
+ p["delete"] = true;
+ nr = p["nr"]:0;
+ y2milestone( "remove_one_partition_vm p %1", p );
+ }
+ return( p );
+ });
+ if( nr>disk["max_primary"]:4 )
+ {
+ partitions =
+ maplist( map p, partitions,
+ ``{
+ if( !p["delete"]:false && p["nr"]:0>nr )
+ {
+ p["nr"] = p["nr"]:0-1;
+ p["device"] = Storage::GetDeviceName( disk["device"]:"",
+ p["nr"]:0 );
+ y2milestone( "remove_one_partition_vm ren %1", p );
+ }
+ return( p );
+ });
+ }
+ partitions = try_remove_sole_extended( partitions );
+ }
+ return( partitions );
+ }
+
+
+map remove_used_by( map tg, string disk )
+ {
+ string uby = tg[disk,"used_by_device"]:"";
+ y2milestone( "remove_used_by disk %1 uby %2", disk, uby );
+ if( size(uby)>0 )
+ {
+ if( haskey( tg, uby ))
+ {
+ tg[uby, "delete"] = true;
+ y2milestone( "remove_used_by uby %1", tg[uby]:$[] );
+ }
+ }
+ return( tg );
+ }
+
+
+ map<string, any> get_inst_proposal(map<string, map> target)
+ {
+ y2milestone( "get_inst_proposal start" );
+ flex_init_swapable( target );
+ map<string, any> ret = $[];
+ target = AddWinInfo(target);
+ ret["target"] = target;
+ map root = $[ "mount" : "/", "increasable" : true,
+ "fsys" : PropDefaultFs(), "size" : 0 ];
+ map opts = GetControlCfg();
+ list<string> ddev = get_disk_try_list( target, true );
+ string sol_disk = "";
+ list modes = [ `free, `reuse, `remove, `resize, `desparate ];
+ map<string,boolean> valid = $[];
+ map<string,list> size_mb = listmap( string s, ddev, ``($[s:[]]));
+ map solution = listmap( string s, ddev, ``($[s:[]]));
+ target = prepare_part_lists( ddev, target );
+ symbol mode = `free;
+ while( mode != `end && size(sol_disk)==0 )
+ {
+ if( mode == `free || mode == `desparate )
+ {
+ valid = listmap( string s, ddev, ``($[s:true]));
+ if( mode == `desparate )
+ {
+ ddev = get_disk_try_list( target, false );
+ valid = listmap( string s, ddev, ``($[s:true]));
+ target = prepare_part_lists( ddev, target );
+ foreach( string s, ddev,
+ ``{
+ target[s,"partitions"] =
+ remove_p_settings( target[s,"partitions"]:[], [] );
+ target[s,"partitions"] =
+ maplist( map p, target[s,"partitions"]:[],
+ ``{
+ if( !contains( Partitions::do_not_delete,
+ p["fsid"]:0 ) &&
+ Storage::CanDelete( p, target[s]:$[], false))
+ {
+ if( usable_for_win_resize(p,false) )
+ p["dtxt"] = _("Resize impossible due to inconsistent fs. Try checking fs under Windows.");
+ p["delete"] = true;
+ }
+ return( p );
+ });
+ });
+ }
+ }
+ else if( mode == `reuse )
+ {
+ valid = listmap( string s, ddev,
+ ``{
+ if( find( map p, target[s,"partitions"]:[],
+ ``(p["linux"]:false && size(p["mount"]:"")==0 &&
+ !p["delete"]:false &&
+ Storage::CanEdit(p,false))) != nil )
+ return( $[s:true] );
+ else
+ return( $[s:false] );
+ });
+ }
+ else if( mode == `remove )
+ {
+ valid = listmap( string s, ddev,
+ ``{
+ if( find( map p, target[s,"partitions"]:[],
+ ``(p["linux"]:false && size(p["mount"]:"")==0 &&
+ !p["delete"]:false &&
+ Storage::CanDelete(p,target[s]:$[],false))) != nil )
+ return( $[s:true] );
+ else
+ return( $[s:false] );
+ });
+ foreach( string s, ddev,
+ ``{
+ target[s,"partitions"] =
+ remove_p_settings( target[s,"partitions"]:[],
+ ["/", "/home"] );
+ });
+ foreach( string s, filter( string d, ddev, ``(valid[d]:false)),
+ ``{
+ target[s,"partitions"] =
+ remove_one_partition( target[s]:$[] );
+ });
+ }
+ else if( mode == `resize )
+ {
+ valid = listmap( string s, ddev,
+ ``{
+ if( find( map p, target[s,"partitions"]:[],
+ ``(usable_for_win_resize(p,true))) != nil )
+ return( $[s:true] );
+ else
+ return( $[s:false] );
+ });
+ foreach( string s, filter( string d, ddev, ``(valid[d]:false)),
+ ``{
+ list<map> pl = filter( map p, target[s,"partitions"]:[],
+ ``(usable_for_win_resize(p,true)));
+ if( size(pl)>0 )
+ {
+ pl = sort( map a, map b, pl,
+ ``(a["size_k"]:0>b["size_k"]:0));
+ target[s,"partitions"] =
+ maplist( map p, target[s,"partitions"]:[],
+ ``{
+ if( usable_for_win_resize(p,true) &&
+ p["device"]:""==pl[0,"device"]:"" )
+ {
+ integer cs = target[s,"cyl_size"]:1;
+ p["resize"] = true;
+ p["region",1] =
+ (p["winfo","new_size"]:0+cs-1) / cs ;
+ p["win_max_length"] =
+ (p["winfo","max_win_size"]:0+cs-1) / cs;
+ // nil means partition to be defined
+ if (Storage::resize_partition == nil)
+ {
+ Storage::resize_partition = p["device"]:"";
+ Storage::resize_partition_data = p;
+ Storage::resize_cyl_size = cs;
+ }
+ // if partitions match, override proposal with stored data
+ else if (Storage::resize_partition == p["device"]:"" && Storage::resize_partition != "")
+ {
+ p = Storage::resize_partition_data;
+ }
+ }
+ return( p );
+ });
+ y2milestone( "get_inst_proposal res parts %1",
+ target[s,"partitions"]:[] );
+ }
+ });
+ }
+ y2milestone( "get_inst_proposal mode %1 valid %2", mode, valid );
+ foreach( string s, filter( string d, ddev, ``(valid[d]:false)),
+ ``{
+ map conf = $[ "partitions" : [] ];
+ map disk = target[s]:$[];
+ list<map> p = can_boot_reuse( s, disk["label"]:"msdos",
+ need_boot(disk),
+ disk["max_primary"]:4,
+ disk["partitions"]:[] );
+ disk["partitions"] =
+ special_boot_proposal_prepare( disk["partitions"]:[] );
+ boolean have_home = false;
+ boolean have_root = false;
+ boolean have_boot = (!(Partitions::EfiBoot() || Arch::ia64()) || mode!=`free) && size(p)>0;
+ if( have_boot )
+ disk["partitions"] = p;
+ map r = can_swap_reuse( s, disk["partitions"]:[], target );
+ boolean have_swap = size(r)>0;
+ y2milestone( "get_inst_proposal have_boot %1 have_swap %2",
+ have_boot, have_swap );
+ if( haskey( r, "partitions" ))
+ disk["partitions"] = r["partitions"]:[];
+ else if( haskey( r, "targets" ))
+ target = r["targets"]:$[];
+ list<integer> swap_sizes = [];
+ integer avail_size = get_usable_size_mb(disk,mode==`reuse);
+ y2milestone( "get_inst_proposal disk %1 mode %2 avail %3",
+ s, mode, avail_size );
+ if( avail_size>0 )
+ {
+ if( mode == `reuse )
+ {
+ list<map> parts = disk["partitions"]:[];
+ if( GetProposalHome() )
+ {
+ if( avail_size > opts["home_limit"]:0 )
+ parts = can_mp_reuse( "/home", 4*1024, 0, parts );
+ else
+ parts = can_mp_reuse( "/", opts["root_base"]:0, 0,
+ parts );
+ }
+ if( size(parts)>0 && avail_size > opts["home_limit"]:0 )
+ {
+ integer mx = 0;
+ if( GetProposalHome() )
+ mx = opts["root_max"]:0;
+ parts = can_mp_reuse( "/", opts["root_base"]:0,
+ mx, parts );
+ }
+ if( size(parts)>0 )
+ {
+ have_home = avail_size > opts["home_limit"]:0;
+ have_root = true;
+ disk["partitions"] = parts;
+ }
+ y2milestone( "get_inst_proposal reuse have_home %1 have_root %2",
+ have_home, have_root );
+ if( have_home && have_root )
+ y2milestone( "get_inst_proposal reuse parts %1",
+ disk["partitions"]:[] );
+ }
+ if( !have_swap )
+ {
+ swap_sizes = get_swap_sizes( avail_size );
+ map swap = $[ "mount" : "swap", "increasable" : true,
+ "fsys" : `swap, "maxsize" : 2*1024*1024*1024,
+ "size" : swap_sizes[0]:256*1024*1024 ];
+ conf["partitions"] = add( conf["partitions"]:[], swap );
+ }
+ if( !have_root )
+ conf["partitions"] = add( conf["partitions"]:[], root );
+ map old_root = $[];
+ if( !have_home && GetProposalHome() &&
+ opts["home_limit"]:0 < avail_size )
+ {
+ map home = $[ "mount" : "/home", "increasable" : true,
+ "fsys" : PropDefaultFs(),
+ "size" : 512*1024*1024,
+ "pct" : 100-opts["root_percent"]:40 ];
+ conf["partitions"] =
+ maplist( map p, conf["partitions"]:[],
+ ``{
+ if( p["mount"]:""=="/" )
+ {
+ old_root = p;
+ p["pct"] = opts["root_percent"]:40;
+ p["maxsize"] = opts["root_max"]:0*1024*1024;
+ p["size"] = opts["root_base"]:0*1024*1024;
+ }
+ return( p );
+ });
+ conf["partitions"] = add( conf["partitions"]:[], home );
+ }
+ map ps1 = do_flexible_disk_conf( disk, conf, have_boot,
+ mode==`reuse );
+ if( size(old_root)>0 && !ps1["ok"]:false )
+ {
+ conf["partitions"] =
+ filter( map p, conf["partitions"]:[],
+ ``(p["mount"]:""!="/home" &&
+ p["mount"]:""!="/"));
+ conf["partitions"] = add( conf["partitions"]:[], old_root );
+ ps1 = do_flexible_disk_conf( disk, conf, have_boot,
+ mode==`reuse );
+ }
+ if( !have_swap )
+ {
+ integer diff = swap_sizes[0]:256 - swap_sizes[1]:256;
+ if( diff<0 )
+ diff = -diff;
+ y2milestone( "get_inst_proposal diff:%1 ps1 ok:%2",
+ diff, ps1["ok"]:false );
+ if( (!ps1["ok"]:false && diff>0) || diff>100 )
+ {
+ conf["partitions",0,"size"] =
+ swap_sizes[1]:256*1024*1024;
+ map ps2 = do_flexible_disk_conf( disk, conf, have_boot,
+ mode==`reuse );
+ y2milestone( "get_inst_proposal ps2 ok:%1",
+ ps2["ok"]:false );
+ if( ps2["ok"]:false )
+ {
+ map rp1 = find( map p, ps1["disk","partitions"]:[],
+ ``(!p["delete"]:false &&
+ p["mount"]:""=="/"));
+ map rp2 = find( map p, ps2["disk","partitions"]:[],
+ ``(!p["delete"]:false &&
+ p["mount"]:""=="/"));
+ y2milestone( "get_inst_proposal rp1:%1", rp1 );
+ y2milestone( "get_inst_proposal rp2:%1", rp2 );
+ if( rp1==nil ||
+ (rp2!=nil && rp2["size_k"]:0>rp1["size_k"]:0 ))
+ ps1 = ps2;
+ }
+ }
+ }
+ if( ps1["ok"]:false )
+ {
+ list mb = [ get_mb_sol( ps1, "/" )];
+ if( GetProposalHome() )
+ mb = add( mb, get_mb_sol( ps1, "/home" ));
+ if( mb[0]:0+mb[1]:0 > size_mb[s,0]:0 + size_mb[s,1]:0 )
+ {
+ solution[s] = ps1["disk"]:$[];
+ size_mb[s] = mb;
+ y2milestone( "get_inst_proposal sol %1 mb %2",
+ s, size_mb[s]:[] );
+ }
+ }
+ }
+ });
+ integer max_mb = 0;
+ string max_disk = "";
+ foreach( string s, list mb, size_mb,
+ ``{
+ if( (!GetProposalHome() || mb[1]:0>0 || mode==`resize ) &&
+ mb[1]:0+mb[0]:0 > max_mb )
+ {
+ max_mb = mb[1]:0+mb[0]:0;
+ max_disk = s;
+ }
+ });
+ y2milestone( "get_inst_proposal max_mb %1 size_mb %2", max_mb, size_mb );
+ if( max_mb>0 && size_mb[max_disk,0]:0 > 2*1024 &&
+ ( !GetProposalHome() || size_mb[max_disk,1]:0 > 1*1024 ))
+ {
+ sol_disk = max_disk;
+ }
+ y2milestone( "get_inst_proposal mode %1 size_mb %2", mode, size_mb );
+ if( size(sol_disk)==0 )
+ {
+ list<boolean> lb = maplist(string s, boolean e, valid, ``(e));
+ if( mode == `free )
+ mode = `reuse;
+ else if( mode == `reuse )
+ mode = `remove;
+ else if( mode == `remove && find( boolean v, lb, ``(v)) == nil )
+ mode = `resize;
+ else if( mode == `resize && find( boolean v, lb, ``(v)) == nil )
+ mode = `desparate;
+ else if( mode == `desparate )
+ mode = `end;
+ if( mode == `desparate && size(sol_disk)==0 )
+ {
+ max_mb = 0;
+ foreach( string s, list mb, size_mb,
+ ``{
+ if( mb[1]:0+mb[0]:0 > max_mb && mb[0]:0 > 2*1024 )
+ {
+ max_mb = mb[1]:0+mb[0]:0;
+ sol_disk = s;
+ }
+ });
+ y2milestone( "get_inst_proposal mode %1 sol_disk %2",
+ mode, sol_disk );
+ }
+ }
+ }
+ y2milestone( "get_inst_proposal sol_disk %1", sol_disk );
+ if( size(sol_disk)==0 )
+ {
+ integer max_mb = 0;
+ foreach( string s, list mb, size_mb,
+ ``{
+ if( mb[1]:0+mb[0]:0>max_mb && mb[0]:0 > 512 )
+ {
+ max_mb = mb[1]:0+mb[0]:0;
+ sol_disk = s;
+ }
+ });
+ y2milestone( "get_inst_proposal sol_disk %1", sol_disk );
+ }
+ ret["ok"] = size(sol_disk)>0;
+ if( ret["ok"]:false )
+ {
+ ret["target"] = remove_used_by( ret["target"]:$[], sol_disk );
+ ret["target",sol_disk] = solution[sol_disk]:$[];
+ ret["target"] = Storage::SpecialBootHandling( ret["target"]:$[] );
+ y2milestone( "get_inst_proposal sol:%1", ret["target",sol_disk]:$[] );
+ }
+ y2milestone( "get_inst_proposal ret[ok]:%1", ret["ok"]:false );
+ return( ret );
+ }
+
+
+list<map> remove_keys( list<map> pl, list<string> keys )
+ {
+ pl = maplist( map p, pl,
+ ``{
+ foreach( string k, keys,
+ ``{
+ if( haskey(p,k) )
+ p = remove( p, k );
+ });
+ return( p );
+ });
+ return( pl );
+ }
+
+
+map<string,map> remove_mount_points( map<string,map> target )
+ {
+ foreach( string s, map disk, target,
+ ``{
+ target[s,"partitions"] =
+ maplist( map p, target[s,"partitions"]:[],
+ ``{
+ if( haskey( p, "mount" ) &&
+ search( p["mount"]:"", "/windows/" )!=0 &&
+ search( p["mount"]:"", "/dos/" )!=0 )
+ p = remove( p, "mount" );
+ return( p );
+ });
+ remove_keys( target[s,"partitions"]:[],
+ [ "mount" ] );
+ });
+ return( target );
+ }
+
+
+map<string,map> remove_vm( map<string,map> tg, string ky )
+ {
+ y2milestone( "remove_vm key:%1", ky );
+ string key = "/dev/" + ky;
+ if( haskey( tg, key ))
+ {
+ tg[key,"delete"] = true;
+ tg[key,"partitions"] =
+ maplist( map p, tg[key,"partitions"]:[],
+ ``{
+ p["delete"] = true;
+ return(p);
+ });
+ y2milestone( "remove_vm removed:%1", tg[key]:$[] );
+ list<string> dl = tg[key,"devices"]:[];
+ foreach( string d, dl, {
+ tg = Storage::DelPartitionData( tg, d, "used_by_type" );
+ tg = Storage::DelPartitionData( tg, d, "used_by_device" );
+ });
+ }
+ return( tg );
+ }
+
+
+string find_vm( map<string,map> target, string ky, integer min_size )
+ {
+ string ret = "";
+ string key = "/dev/" + ky;
+ if( GetProposalLvm() && target[key,"lvm2"]:false &&
+ target[key,"size_k"]:0 >= min_size )
+ ret = key;
+ y2milestone( "find_vm key:%1 min_size:%2 ret:%3", ky, min_size, ret );
+ return( ret );
+ }
+
+
+boolean did_remove_vg( list<map> partitions, string vg )
+ {
+ boolean ret=false;
+ list<string> ele = [ "/dev/" + vg, "/dev/lvm/" + vg, "/dev/lvm2/" + vg ];
+ foreach( map p, partitions,
+ ``{
+ if( !ret && p["delete"]:false && contains( ele, p["used_by_device"]:"" ))
+ ret = true;
+ });
+ y2milestone( "did_remove_vg vg:%1 ret:%2", vg, ret );
+ return( ret );
+ }
+
+
+integer sizek_to_pe( integer pek, integer pebyte, boolean pvcreate )
+ {
+ integer ret = (pek-(pvcreate?500:0)) / (pebyte/1024);
+ y2milestone( "sizek_to_pe pek %1 pebyte %2 pvcreate %3 ret %4",
+ pek, pebyte, pvcreate, ret );
+ return( ret );
+ }
+
+
+integer pe_to_sizek( integer pe, integer pebyte )
+ {
+ integer ret = pe * (pebyte/1024);
+ y2milestone( "pe_to_sizek pe %1 pebyte %2 ret %3", pe, pebyte, ret );
+ return( ret );
+ }
+
+
+map extend_vm( map vg, string key, map disk )
+ {
+ y2milestone( "extend_vm key %1 vg %2", key, vg );
+ y2milestone( "extend_vm disk %1", disk );
+ list devs = [];
+ integer num_pe = vg["pe_free"]:0;
+ foreach( map p, disk["partitions"]:[],
+ ``{
+ if( p["vg"]:""==key )
+ {
+ devs = add( devs, p["device"]:"" );
+ num_pe = num_pe +
+ sizek_to_pe( p["size_k"]:0, vg["pesize"]:1024, true );
+ };
+ });
+ y2milestone( "extend_vm num_pe %1 devs %2", num_pe, devs );
+ vg["devices_add"] = devs;
+ vg["pe_free"] = num_pe;
+ vg["size_k"] = pe_to_sizek( num_pe, vg["pesize"]:0 );
+ y2milestone( "extend_vm ret %1", vg );
+ return( vg );
+ }
+
+
+map create_vm( string key, map disk )
+ {
+ y2milestone("create_vm key:%1 disk:%2", key, disk);
+ map ret = $[ "type" : `CT_LVM,
+ "name" : key,
+ "device" : "/dev/" + key,
+ "lvm2" : true,
+ "create" : true,
+ "partitions" : [],
+ "pesize" : 4*1024*1024 ];
+ list devs = [];
+ integer num_pe = 0;
+ foreach( map p, disk["partitions"]:[],
+ ``{
+ if( p["vg"]:""==key && !p["delete"]:false )
+ {
+ devs = add( devs, p["device"]:"" );
+ num_pe = num_pe +
+ sizek_to_pe( p["size_k"]:0, ret["pesize"]:1024, true );
+ };
+ });
+ y2milestone( "create_vm num_pe %1 devs %2", num_pe, devs );
+ ret["devices_add"] = devs;
+ ret["pe_free"] = num_pe;
+ ret["size_k"] = pe_to_sizek( num_pe, ret["pesize"]:0 );
+ y2milestone( "create_vm ret %1", ret );
+ return( ret );
+ }
+
+
+map modify_vm( map vm, map opts, boolean need_swap )
+ {
+ y2milestone( "modify_vm swap %1 start %2", need_swap, vm );
+ y2milestone( "modify_vm opts %1", opts );
+ map ret = vm;
+ integer free = ret["pe_free"]:0;
+ integer pe = ret["pesize"]:1024;
+ integer swsize = 0;
+ list<integer> swlist = [];
+ if( need_swap )
+ {
+ swlist = get_swap_sizes( free );
+ swsize = (swlist[1]:0>swlist[0]:0) ? swlist[1]:0 : swlist[0]:0;
+ }
+ y2milestone( "modify_vm swsize %1", swsize );
+ map swap = find( map p, ret["partitions"]:[], ``(p["name"]:""=="swap"));
+ map root = find( map p, ret["partitions"]:[], ``(p["name"]:""=="root"));
+ map home = find( map p, ret["partitions"]:[], ``(p["name"]:""=="home"));
+ y2milestone( "modify_vm swap %1 root %2 home %3", swap, root, home );
+ if( root!=nil && root["size_k"]:0<1024*1024 )
+ {
+ ret["partitions"] = maplist( map p, ret["partitions"]:[],
+ ``{
+ if( p["name"]:"" == "root" )
+ {
+ p["delete"] = true;
+ free = free + sizek_to_pe( p["size_k"]:0, pe, false );
+ y2milestone( "modify_vm remove root %1", p );
+ }
+ return(p);
+ });
+ y2milestone( "modify_vm pe free %1", free );
+ root = nil;
+ }
+ ret["partitions"] = sort( map a, map b, ret["partitions"]:[],
+ ``(a["size_k"]:0>b["size_k"]:0));
+ list keep = [ "root", "home", "swap" ];
+ integer root_pe = sizek_to_pe( opts["root_base"]:0*1024, pe, false );
+ y2milestone( "modify_vm pe free %1 root %2", free, root_pe );
+ map m = find( map p, ret["partitions"]:[],
+ ``(!p["delete"]:false && !contains(keep,p["name"]:"")));
+ while( root==nil && free<root_pe && m!=nil )
+ {
+ ret["partitions"] = maplist( map p, ret["partitions"]:[],
+ ``{
+ if( p["name"]:"" == m["name"]:"" )
+ {
+ p["delete"] = true;
+ free = free + sizek_to_pe( p["size_k"]:0, pe, false );
+ }
+ return(p);
+ });
+ y2milestone( "modify_vm pe free %1 root %2 del %3", free, root_pe, m );
+ m = find( map p, ret["partitions"]:[],
+ ``(!p["delete"]:false && !contains(keep,p["name"]:"")));
+ }
+ if( root==nil && free<root_pe && swap!=nil && swsize==0 )
+ {
+ ret["partitions"] = maplist( map p, ret["partitions"]:[],
+ ``{
+ if( p["name"]:"" == "swap" )
+ {
+ p["delete"] = true;
+ free = free + sizek_to_pe( p["size_k"]:0, pe, false );
+ }
+ return(p);
+ });
+ swap = nil;
+ y2milestone( "modify_vm pe free %1 root %2", free, root_pe );
+ }
+ if( root==nil && free<root_pe && swsize>0 )
+ {
+ swsize = (swlist[1]:0<swlist[0]:0) ? swlist[1]:0 : swlist[0]:0;
+ y2milestone( "modify_vm new swsize %1", swsize );
+ }
+ if( root==nil && free<root_pe && swap!=nil && swsize<swap["size_k"]:0/1024 )
+ {
+ ret["partitions"] = maplist( map p, ret["partitions"]:[],
+ ``{
+ if( p["name"]:"" == "swap" )
+ {
+ p["delete"] = true;
+ free = free + sizek_to_pe( p["size_k"]:0, pe, false );
+ }
+ return(p);
+ });
+ swap = nil;
+ y2milestone( "modify_vm pe free %1 root %2", free, root_pe );
+ }
+ integer swap_pe = 0;
+ integer home_pe = 0;
+ if( swap==nil && swsize>0 )
+ swap_pe = sizek_to_pe( swsize*1024, pe, false );
+ if( free<root_pe+swap_pe )
+ {
+ y2milestone( "modify_vm pe free %1 root %2 swap %3",
+ free, root_pe, swap_pe );
+ if( root==nil && swap_pe>free )
+ {
+ swap_pe = free;
+ free = 0;
+ }
+ else if( swap_pe==0 )
+ {
+ root_pe = free;
+ free = 0;
+ }
+ else
+ {
+ swap_pe = swap_pe*free/(root_pe+swap_pe);
+ root_pe = free-swap_pe;
+ free = 0;
+ }
+ y2milestone( "modify_vm pe free %1 root %2 swap %3",
+ free, root_pe, swap_pe );
+ }
+ else
+ {
+ free = free-swap_pe;
+ y2milestone( "modify_vm pe free %1 root %2 swap %3",
+ free, root_pe, swap_pe );
+ if( home==nil && GetProposalHome() &&
+ free>sizek_to_pe( opts["home_limit"]:0*1024, pe, false ) )
+ {
+ integer tmp = free * opts["root_percent"]:40 / 100;
+ if( tmp>root_pe )
+ root_pe=tmp;
+ tmp = sizek_to_pe( opts["root_max"]:0*1024, pe, false );
+ if( root_pe>tmp )
+ root_pe=tmp;
+ free = free-root_pe;
+ home_pe = free;
+ tmp = sizek_to_pe( opts["home_max"]:0*1024, pe, false );
+ if( home_pe>tmp )
+ home_pe = tmp;
+ free = free-home_pe;
+ y2milestone( "modify_vm pe free %1 root %2 home %3",
+ free, root_pe, home_pe );
+ }
+ else
+ {
+ integer tmp = sizek_to_pe( opts["root_max"]:0*1024, pe, false );
+ root_pe = free;
+ if( root_pe>tmp )
+ root_pe=tmp;
+ free = free-root_pe;
+ }
+ }
+ y2milestone( "modify_vm pe free %1 root %2 swap %3 home %4",
+ free, root_pe, swap_pe, home_pe );
+ if( root==nil && root_pe>0 )
+ {
+ map p = $[ "create":true, "name" : "root",
+ "device" : ret["device"]:"" + "/root",
+ "size_k" : pe_to_sizek(root_pe,pe) ];
+ p = Storage::SetVolOptions( p, "/", PropDefaultFs(), "", "", "" );
+ y2milestone( "modify_vm created %1", p );
+ ret["partitions"] = add( ret["partitions"]:[], p );
+ }
+ else if( root!=nil )
+ {
+ ret["partitions"] = maplist( map p, ret["partitions"]:[],
+ ``{
+ if( p["name"]:"" == "root" )
+ {
+ p = Storage::SetVolOptions( p, "/", PropDefaultFs(),
+ "", "", "" );
+ y2milestone( "modify_vm reuse %1", p );
+ }
+ return(p);
+ });
+ }
+ if( swap==nil && swap_pe>0 )
+ {
+ map p = $[ "create":true, "name" : "swap",
+ "device" : ret["device"]:"" + "/swap",
+ "size_k" : pe_to_sizek(swap_pe,pe) ];
+ p = Storage::SetVolOptions( p, "swap", `swap,
+ "", "", "" );
+ y2milestone( "modify_vm created %1", p );
+ ret["partitions"] = add( ret["partitions"]:[], p );
+ }
+ else if( swap!=nil )
+ {
+ ret["partitions"] = maplist( map p, ret["partitions"]:[],
+ ``{
+ if( p["name"]:"" == "swap" )
+ {
+ p = Storage::SetVolOptions( p, "swap", `swap,
+ "", "", "" );
+ y2milestone( "modify_vm reuse %1", p );
+ }
+ return(p);
+ });
+ }
+ if( home==nil && home_pe>0 )
+ {
+ map p = $[ "create":true, "name" : "home",
+ "device" : ret["device"]:"" + "/home",
+ "size_k" : pe_to_sizek(home_pe,pe) ];
+ p = Storage::SetVolOptions( p, "/home", PropDefaultFs(), "", "", "" );
+ y2milestone( "modify_vm created %1", p );
+ ret["partitions"] = add( ret["partitions"]:[], p );
+ }
+ else if( home!=nil )
+ {
+ ret["partitions"] = maplist( map p, ret["partitions"]:[],
+ ``{
+ if( p["name"]:"" == "home" )
+ {
+ p = Storage::SetVolOptions( p, "/home", PropDefaultFs(),
+ "", "", "" );
+ y2milestone( "modify_vm reuse %1", p );
+ }
+ return(p);
+ });
+ }
+ y2milestone( "modify_vm ret %1", ret );
+ return( ret );
+ }
+
+
+ map<string, any> get_inst_prop_vm(map<string, map> target, string key)
+ {
+ y2milestone( "get_inst_prop_vm start key %1", key );
+ map<string, any> ret = $[];
+ map opts = GetControlCfg();
+ string vg_key = find_vm( target, key, opts["root_base"]:0*1024 );
+ target = remove_mount_points(target);
+ if( size(vg_key)==0 )
+ target = remove_vm(target,key);
+ target = AddWinInfo(target);
+ ret["target"] = target;
+ map boot = $[ "mount" : Partitions::BootMount(),
+ "size" : Partitions::ProposedBootsize(),
+ "fsys" : Partitions::DefaultBootFs(),
+ "id" : Partitions::FsidBoot(),
+ "max_cyl" : Partitions::BootCyl() ];
+ if( Partitions::BootPrimary() )
+ {
+ boot["primary"] = true;
+ }
+ list<string> ddev = get_disk_try_list( target, true );
+ string sol_disk = "";
+ list modes = [ `free, `remove, `resize, `desparate ];
+ map<string,boolean> valid = $[];
+ map<string,integer> size_mb = listmap( string s, ddev, ``($[s:0]));
+ map<string,boolean> keep_vg = $[];
+ map solution = listmap( string s, ddev, ``($[s:[]]));
+ target = prepare_part_lists( ddev, target );
+ symbol mode = `free;
+ while( mode != `end && size(sol_disk)==0 )
+ {
+ if( mode == `free || mode == `desparate )
+ {
+ valid = listmap( string s, ddev, ``($[s:true]));
+ if( mode == `desparate )
+ {
+ ddev = get_disk_try_list( target, false );
+ valid = listmap( string s, ddev, ``($[s:true]));
+ target = prepare_part_lists( ddev, target );
+ foreach( string s, ddev,
+ ``{
+ target[s,"partitions"] =
+ remove_p_settings( target[s,"partitions"]:[], [] );
+ target[s,"partitions"] =
+ maplist( map p, target[s,"partitions"]:[],
+ ``{
+ if( !contains( Partitions::do_not_delete,
+ p["fsid"]:0 ) &&
+ Storage::CanDelete( p, target[s]:$[], false))
+ {
+ if( usable_for_win_resize(p,false) )
+ p["dtxt"] = _("Resize impossible due to inconsistent fs. Try checking fs under Windows.");
+ p["delete"] = true;
+ }
+ return( p );
+ });
+ });
+ }
+ }
+ else if( mode == `remove )
+ {
+ valid = listmap( string s, ddev,
+ ``{
+ if( find( map p, target[s,"partitions"]:[],
+ ``(p["linux"]:false && size(p["mount"]:"")==0 &&
+ !p["delete"]:false &&
+ Storage::CanDelete(p,target[s]:$[],false))) != nil )
+ return( $[s:true] );
+ else
+ return( $[s:false] );
+ });
+ foreach( string s, filter( string d, ddev, ``(valid[d]:false)),
+ ``{
+ target[s,"partitions"] =
+ remove_one_partition_vm( target[s]:$[] );
+ });
+ }
+ else if( mode == `resize )
+ {
+ valid = listmap( string s, ddev,
+ ``{
+ if( find( map p, target[s,"partitions"]:[],
+ ``(usable_for_win_resize(p,true))) != nil )
+ return( $[s:true] );
+ else
+ return( $[s:false] );
+ });
+ foreach( string s, filter( string d, ddev, ``(valid[d]:false)),
+ ``{
+ list<map> pl = filter( map p, target[s,"partitions"]:[],
+ ``(usable_for_win_resize(p,true)));
+ if( size(pl)>0 )
+ {
+ pl = sort( map a, map b, pl,
+ ``(a["size_k"]:0>b["size_k"]:0));
+ target[s,"partitions"] =
+ maplist( map p, target[s,"partitions"]:[], ``{
+ if( usable_for_win_resize(p,true) &&
+ p["device"]:""==pl[0,"device"]:"" )
+ {
+ integer cs = target[s,"cyl_size"]:1;
+ p["resize"] = true;
+ p["region",1] =
+ (p["winfo","new_size"]:0+cs-1) / cs ;
+ p["win_max_length"] =
+ (p["winfo","max_win_size"]:0+cs-1) / cs;
+ // nil means partition to be defined
+ if (Storage::resize_partition == nil)
+ {
+ Storage::resize_partition = p["device"]:"";
+ Storage::resize_partition_data = p;
+ Storage::resize_cyl_size = cs;
+ }
+ // if partitions match, override proposal with stored data
+ else if (Storage::resize_partition == p["device"]:"" && Storage::resize_partition != "")
+ {
+ p = Storage::resize_partition_data;
+ }
+ }
+ return( p );
+ });
+ y2milestone( "get_inst_prop_vm res parts %1",
+ target[s,"partitions"]:[] );
+ }
+ });
+ }
+ y2milestone( "get_inst_prop_vm mode %1 valid %2", mode, valid );
+ foreach( string s, filter( string d, ddev, ``(valid[d]:false)),
+ ``{
+ map disk = target[s]:$[];
+ map conf = $[ "partitions" : [] ];
+ list<map> p = can_boot_reuse( s, disk["label"]:"msdos", true,
+ disk["max_primary"]:4,
+ disk["partitions"]:[] );
+ disk["partitions"] =
+ special_boot_proposal_prepare( disk["partitions"]:[] );
+ boolean have_boot = size(p)>0;
+ if( have_boot )
+ disk["partitions"] = p;
+ string vg = vg_key;
+ if( size(vg)>0 && did_remove_vg( disk["partitions"]:[], key ))
+ vg = "";
+ map ps = do_vm_disk_conf( disk, have_boot?($[]):boot, vg, key );
+ if( ps["ok"]:false )
+ {
+ integer mb = get_vm_sol( ps );
+ if( mb-size_mb[s]:0>size_mb[s]:0/40 )
+ {
+ y2milestone( "get_inst_prop_vm new sol %1 old %2 new %3",
+ s, size_mb[s]:0, mb );
+ solution[s] = ps["disk"]:$[];
+ size_mb[s] = mb;
+ }
+ if( size(vg)>0 && !keep_vg[s]:false )
+ keep_vg[s] = true;
+ }
+ });
+ y2milestone( "get_inst_prop_vm size_mb %1 keep_vg %2",
+ size_mb, keep_vg );
+ integer max_mb = 0;
+ string max_disk = "";
+ string keep_disk = "";
+ foreach( string s, integer mb, size_mb,
+ ``{
+ if( mb > max_mb )
+ {
+ max_mb = mb;
+ max_disk = s;
+ }
+ });
+ foreach( string s, boolean keep, keep_vg,
+ ``{
+ if( size(keep_disk)==0 && keep )
+ {
+ keep_disk = s;
+ }
+ });
+ if( size(keep_disk)>0 )
+ {
+ sol_disk = keep_disk;
+ }
+ else if( max_mb>0 && size_mb[max_disk]:0 > opts["vm_want"]:(20*1024) )
+ {
+ sol_disk = max_disk;
+ vg_key = "";
+ }
+ y2milestone( "get_inst_prop_vm mode %1 sol_disk %2", mode, sol_disk );
+ if( size(sol_disk)==0 )
+ {
+ list<boolean> lb = maplist(string s, boolean e, valid, ``(e));
+ if( mode == `free )
+ mode = `remove;
+ else if( mode == `remove && find( boolean v, lb, ``(v)) == nil )
+ mode = `resize;
+ else if( mode == `resize && find( boolean v, lb, ``(v)) == nil )
+ mode = `desparate;
+ else if( mode == `desparate )
+ mode = `end;
+ }
+ }
+ y2milestone( "get_inst_prop_vm sol_disk %1", sol_disk );
+ if( size(sol_disk)==0 )
+ {
+ integer max_mb = 0;
+ foreach( string s, integer mb, size_mb,
+ ``{
+ if( mb>max_mb )
+ {
+ max_mb = mb;
+ sol_disk = s;
+ }
+ });
+ y2milestone( "get_inst_prop_vm sol_disk %1", sol_disk );
+ }
+ ret["ok"] = size(sol_disk)>0;
+ if( ret["ok"]:false )
+ {
+ map r = can_swap_reuse( sol_disk, solution[sol_disk,"partitions"]:[],
+ ret["target"]:$[] );
+ if( haskey( r, "partitions" ))
+ solution[sol_disk,"partitions"] = r["partitions"]:[];
+ else if( haskey( r, "targets" ))
+ ret["target"] = r["targets"]:$[];
+ ret["target"] = remove_used_by( ret["target"]:$[], sol_disk );
+ if( size(vg_key)==0 )
+ {
+ vg_key = "/dev/" + key;
+ map vg = ret["target",vg_key]:$[];
+ vg = union( vg, create_vm( key, solution[sol_disk]:$[] ));
+ if( size(vg["devices"]:[])>0 )
+ {
+ vg = remove( vg, "devices" );
+ }
+ y2milestone( "get_inst_prop_vm vkey %1", vg );
+ ret["target",vg_key] = vg;
+ }
+ else
+ {
+ map vg = ret["target",vg_key]:$[];
+ vg = extend_vm( vg, key, solution[sol_disk]:$[] );
+ ret["target",vg_key] = vg;
+ }
+ ret["target",vg_key] = modify_vm( ret["target",vg_key]:$[], opts,
+ size(r)==0 );
+ ret["target",sol_disk] = solution[sol_disk]:$[];
+ ret["target"] = Storage::SpecialBootHandling( ret["target"]:$[] );
+ y2milestone( "get_inst_prop_vm sol:%1", ret["target",sol_disk]:$[] );
+ }
+ y2milestone( "get_inst_prop_vm ret[ok]:%1", ret["ok"]:false );
+ return( ret );
+ }
+
+
+ global map<string, any> get_proposal_vm(map<string, map> target, string key, map disk)
+ {
+ string ddev = disk["device"]:"";
+ y2milestone("get_proposal_vm ddev:%1 vg:%2 home:%3 lvm:%4 encrypt:%5", ddev,
+ key, GetProposalHome(), GetProposalLvm(), GetProposalEncrypt());
+ map<string, any> ret = $[];
+ map opts = GetControlCfg();
+ target = remove_mount_points(target);
+ target = remove_vm(target,key);
+ ret["target"] = target;
+ map boot = $[ "mount" : Partitions::BootMount(),
+ "size" : Partitions::ProposedBootsize(),
+ "fsys" : Partitions::DefaultBootFs(),
+ "id" : Partitions::FsidBoot(),
+ "max_cyl" : Partitions::BootCyl() ];
+ if( Partitions::BootPrimary() )
+ {
+ boot["primary"] = true;
+ }
+ map conf = $[ "partitions" : [] ];
+ list<map> p = can_boot_reuse( ddev, disk["label"]:"msdos", true,
+ disk["max_primary"]:4,
+ disk["partitions"]:[] );
+ disk["partitions"] = special_boot_proposal_prepare( disk["partitions"]:[] );
+ boolean have_boot = size(p)>0;
+ if( have_boot )
+ disk["partitions"] = p;
+ map ps = do_vm_disk_conf( disk, have_boot?($[]):boot, "", key );
+ ret["ok"] = ps["ok"]:false;
+ if( ret["ok"]:false )
+ {
+ disk = ps["disk"]:$[];
+ map r = can_swap_reuse( ddev, disk["partitions"]:[],
+ ret["target"]:$[] );
+ if( haskey( r, "partitions" ))
+ disk["partitions"] = r["partitions"]:[];
+ else if( haskey( r, "targets" ))
+ ret["target"] = r["targets"]:$[];
+ ret["target"] = remove_used_by( ret["target"]:$[], ddev );
+ string vg_key = "/dev/" + key;
+ map vg = ret["target",vg_key]:$[];
+ vg = union( vg, create_vm( key, disk ));
+ if( size(vg["devices"]:[])>0 )
+ {
+ vg = remove( vg, "devices" );
+ }
+ y2milestone( "get_proposal_vm vkey %1", vg );
+ ret["target",vg_key] = modify_vm( vg, opts, size(r)==0 );
+ ret["target",ddev] = disk;
+ ret["target"] = EncryptDevices(ret["target"]:$[], vg_key);
+ ret["target"] = Storage::SpecialBootHandling( ret["target"]:$[] );
+ y2milestone( "get_proposal_vm sol:%1", disk );
+ }
+ y2milestone("get_proposal_vm ret:%1", ret);
+ return ret;
+ }
+
+
+ global map<string, any> get_inst_prop(map<string, map> target)
+ {
+ map<string, any> ret = $[];
+ string vg = GetProposalVM();
+ y2milestone("get_inst_prop vg:%1 home:%2 lvm:%3 encypt:%4", vg,
+ GetProposalHome(), GetProposalLvm(), GetProposalEncrypt());
+ if (isempty(vg))
+ {
+ if( has_flex_proposal() )
+ ret = do_proposal_flexible( target );
+ else
+ ret = get_inst_proposal( target );
+ }
+ else
+ {
+ y2milestone( "target:%1", target );
+ ret = get_inst_prop_vm( target, vg );
+ ret["target"] = EncryptDevices(ret["target"]:$[], "/dev/" + vg);
+ }
+ y2milestone("get_inst_prop ret:%1", ret);
+ return ret;
+ }
+
+global term AddCommonWidgets()
+ {
+ term vb = `VBox();
+ vb = add( vb,
+ `Left(`HBox(`HSpacing(3), `CheckBox(`id(`lvm), `opt(`notify),
+ // Label text
+ _("Create &LVM Based Proposal"), GetProposalLvm() ))));
+ vb = add( vb,
+ `Left(`HBox(`HSpacing(7), `CheckBox(`id(`encrypt), `opt(`notify),
+ // Label text
+ _("Encr&ypt Volume Group"), GetProposalEncrypt()))));
+ vb = add( vb, `VSpacing(0.5) );
+ vb = add( vb,
+ `Left(`HBox(`HSpacing(3), `CheckBox( `id(`home), `opt(`notify),
+ // Label text
+ _("Propose Separate &Home Partition"),
+ GetProposalHome() ))));
+ vb = add( vb, `VSpacing(0.5) );
+ vb = add( vb,
+ `Left(`HBox(`HSpacing(3), `CheckBox(`id(`btrfs), `opt(`notify),
+ // Label text
+ _("Use &Btrfs as default Filesystem"),
+ GetProposalBtrfs() ))));
+ term frame = `VBox( `VSpacing(1.5),
+ `HVCenter( `VBox( `Left(`Label( `opt(`boldFont), _("Proposal settings"))), `VSpacing(0.3), `HVCenter(vb)) ));
+ //`HVCenter(`Frame( _("Proposal settings"), `HVCenter(vb) )));
+ y2milestone( "AddCommonWidgets Home:%1 Btrfs:%2", GetProposalHome(),
+ GetProposalBtrfs() );
+ return( frame );
+ }
+
+boolean QueryProposalPassword()
+ {
+ if (!isempty(StorageProposal::GetProposalPassword()))
+ return true;
+
+ UI::OpenDialog(`VBox(
+ `Label(_("Enter your password for the proposal encryption.")),
+ `MinWidth(40,
+ `Password(`id(`pw1),
+ // Label: get password for user root
+ // Please use newline if label is longer than 40 characters
+ _("Password:"), "")),
+ `VSpacing(0.5),
+ `MinWidth(40,
+ `Password(`id(`pw2),
+ // Label: get same password again for verification
+ // Please use newline if label is longer than 40 characters
+ _("Reenter the password for verification:"), "")),
+ `Label(_("Don't forget what you enter here!")),
+ `ButtonBox(
+ `PushButton(`id(`ok), `opt(`default), Label::OKButton()),
+ `PushButton(`id(`cancel), Label::CancelButton())
+ )
+ ));
+
+ string password = "";
+ symbol widget = nil;
+
+ repeat
+ {
+ // Clear password fields on every round.
+ UI::ChangeWidget(`id(`pw1), `Value, "");
+ UI::ChangeWidget(`id(`pw2), `Value, "");
+
+ UI::SetFocus(`id(`pw1));
+
+ widget = (symbol) UI::UserInput();
+
+ switch (widget)
+ {
+ case `ok:
+
+ password = (string) UI::QueryWidget(`id(`pw1), `Value);
+ string tmp = (string) UI::QueryWidget(`id(`pw2), `Value);
+
+ if (!Storage::CheckEncryptionPasswords(password, tmp, 8, false))
+ widget = `again;
+
+ break;
+ }
+ } until (widget == `cancel || widget == `ok);
+
+ UI::CloseDialog();
+
+ if (widget == `ok)
+ {
+ StorageProposal::SetProposalPassword(password);
+ return true;
+ }
+ else
+ {
+ return false;
+ }
+ }
+
+global boolean HandleCommonWidgets( symbol id )
+ {
+ boolean ret = false;
+ boolean val = (boolean) UI::QueryWidget(`id(id), `Value);
+ y2milestone( "id:%1 val:%2", ret, val );
+ switch( id )
+ {
+ case `lvm:
+ StorageProposal::SetProposalLvm(val);
+ UI::ChangeWidget(`id(`encrypt), `Enabled, val);
+ ret = true;
+ break;
+
+ case `encrypt:
+ if( val )
+ {
+ if (QueryProposalPassword())
+ {
+ StorageProposal::SetProposalEncrypt(true);
+ }
+ else
+ {
+ UI::ChangeWidget(`id(`encrypt), `Value, false);
+ }
+ }
+ else
+ {
+ StorageProposal::SetProposalEncrypt(false);
+ }
+ ret = true;
+ break;
+
+ case `btrfs:
+ StorageProposal::SetProposalBtrfs(val);
+ ret = true;
+ break;
+
+ case `home:
+ StorageProposal::SetProposalHome(val);
+ ret = true;
+ break;
+ }
+ return( ret );
+ }
+}
Modified: branches/SuSE-Code-11-SP2-Branch/storage/storage/src/modules/StorageSettings.ycp
URL: http://svn.opensuse.org/viewcvs/yast/branches/SuSE-Code-11-SP2-Branch/stora…
==============================================================================
--- branches/SuSE-Code-11-SP2-Branch/storage/storage/src/modules/StorageSettings.ycp (original)
+++ branches/SuSE-Code-11-SP2-Branch/storage/storage/src/modules/StorageSettings.ycp Tue May 17 13:39:44 2011
@@ -13,11 +13,27 @@
import "Storage";
import "Partitions";
+ import "Integer";
+ import "HTML";
symbol display_name = nil;
list<symbol> hidden_fields = nil;
+ list <string> visible_fields = [];
+
+ boolean modified = false;
+
+
+ global boolean GetModified()
+ {
+ return modified;
+ }
+
+ global void SetModified( )
+ {
+ modified = true;
+ }
global void SetDisplayName(symbol new_display_name)
@@ -33,7 +49,7 @@
if (tmp == nil || !contains([ "device", "id", "path" ], tolower(tmp)))
tmp = "device";
- display_name = symbolof(toterm(tolower(tmp)));
+ display_name = tosymbol(tolower(tmp));
}
return display_name;
@@ -54,12 +70,8 @@
break;
}
- if (ret == "")
- ret = data["device"]:"";
-
- integer pos = findlastof(ret, "/");
- if (pos != nil)
- ret = substring(ret, pos + 1);
+ if (isempty(ret))
+ ret = data["name"]:"";
return ret;
}
@@ -80,7 +92,7 @@
tmp = "";
hidden_fields = toset(maplist(string field, splitstring(tmp, " \t"), {
- return symbolof(toterm(tolower(field)));
+ return tosymbol(tolower(field));
}));
}
@@ -93,14 +105,14 @@
list<symbol> hidden = GetHiddenFields();
if (GetDisplayName() != `path)
- hidden = toset(add(hidden, `udev_path));
+ hidden = multiset::union(hidden, [ `udev_path ]);
else
- hidden = filter(symbol field, hidden, { return field != `udev_path; });
+ hidden = multiset::difference(hidden, [ `udev_path ]);
if (GetDisplayName() != `id)
- hidden = toset(add(hidden, `udev_id));
+ hidden = multiset::union(hidden, [ `udev_id ]);
else
- hidden = filter(symbol field, hidden, { return field != `udev_id; });
+ hidden = multiset::difference(hidden, [ `udev_id ]);
return filter(symbol field, fields, { return !setcontains(hidden, field); });
}
@@ -113,6 +125,38 @@
return filter(symbol field, fields, { return !setcontains(hidden, field); });
}
+ global void InvertVisibleFields(list < map <symbol, any> >all_fields, list <integer> selected)
+ {
+ foreach(integer i, Integer::Range(size(all_fields)), {
+ list<symbol> fields = all_fields[i, `fields]:[];
+ string label = all_fields[i, `label]:"";
+ if (contains(selected, i))
+ {
+ hidden_fields = multiset::difference(hidden_fields, fields);
+ visible_fields = multiset::union(visible_fields, [label]);
+ }
+ else
+ {
+ hidden_fields = multiset::union(hidden_fields, fields);
+ visible_fields = multiset::difference(visible_fields, [label]);
+ }
+ });
+
+ }
+
+ global string Summary()
+ {
+ list<string> tmp = [
+ _("Default Mount-by:") + " " + substring(tostring(Storage::GetDefaultMountBy()), 1),
+ _("Default Filesystem:") + " " + substring(tostring(Partitions::DefaultFs()), 1),
+ _("Show Storage Devices by:") + " " + substring(tostring(display_name), 1),
+ _("Partition Alignment:") + " " + substring(tostring(Storage::GetPartitionAlignment()), 7),
+ _("Visible Information on Storage Devices:") + " " + HTML::List(visible_fields)
+ ];
+
+ return HTML::List(tmp);
+ }
+
global void Save()
{
Added: branches/SuSE-Code-11-SP2-Branch/storage/storage/src/modules/StorageUpdate.ycp
URL: http://svn.opensuse.org/viewcvs/yast/branches/SuSE-Code-11-SP2-Branch/stora…
==============================================================================
--- branches/SuSE-Code-11-SP2-Branch/storage/storage/src/modules/StorageUpdate.ycp (added)
+++ branches/SuSE-Code-11-SP2-Branch/storage/storage/src/modules/StorageUpdate.ycp Tue May 17 13:39:44 2011
@@ -0,0 +1,456 @@
+/**
+ * Module: StorageUpdate.ycp
+ *
+ * Authors: Thomas Fehr <fehr(a)suse.de>
+ * Arvin Schnell <aschnell(a)suse.de>
+ */
+{
+ module "StorageUpdate";
+
+ textdomain "storage";
+
+
+ import "Arch";
+ import "AsciiFile";
+ import "FileSystems";
+ import "Partitions";
+ import "Storage";
+
+
+ // flag indicates calling StorageUpdate::Update()
+ boolean called_update = false;
+
+
+ void UpdateFstabSubfs()
+ {
+ y2milestone( "UpdateFstabSubfs removing fstab entries for cdrom and floppy" );
+ string tabpath = Storage::PathToDestdir( "/etc/fstab" );
+ map fstab = Partitions::GetFstab( tabpath );
+ integer line = 0;
+ list<integer> rem_lines = [];
+ while( line<=AsciiFile::NumLines( fstab ) )
+ {
+ map l = AsciiFile::GetLine( fstab, line );
+ if( search( l["fields",1]:"", "/media/floppy" )==0 )
+ {
+ rem_lines = add( rem_lines, line );
+ }
+ else if( search( l["fields",1]:"", "/media/cdrom" )==0 ||
+ search( l["fields",1]:"", "/media/dvd" )==0 ||
+ search( l["fields",1]:"", "/media/cdrecorder" )==0 ||
+ search( l["fields",1]:"", "/media/dvdrecorder" )==0 ||
+ search( l["fields",1]:"", "/cdrom" )==0 ||
+ search( l["fields",1]:"", "/dvd" )==0 ||
+ search( l["fields",1]:"", "/cdrecorder" )==0 ||
+ search( l["fields",1]:"", "/dvdrecorder" )==0 )
+ {
+ rem_lines = add( rem_lines, line );
+ }
+ line = line+1;
+ }
+ y2milestone( "UpdateFstabSubfs %1", rem_lines );
+ if( size(rem_lines)>0 )
+ {
+ rem_lines = sort(rem_lines);
+ AsciiFile::RemoveLines( fstab, rem_lines );
+ }
+ AsciiFile::RewriteFile( fstab, tabpath );
+ }
+
+
+ void UpdateFstabSysfs()
+ {
+ y2milestone( "UpdateFstabSysfs called" );
+ string tabpath = Storage::PathToDestdir( "/etc/fstab" );
+ map fstab = Partitions::GetFstab( tabpath );
+ integer line = 0;
+ boolean have_sysfs = false;
+ while( !have_sysfs && line<=AsciiFile::NumLines( fstab ) )
+ {
+ map l = AsciiFile::GetLine( fstab, line );
+ have_sysfs = l["fields",1]:"" == "/sys";
+ line = line+1;
+ }
+ if( !have_sysfs )
+ {
+ map entry = FileSystems::GetFstabDefaultMap( "sys" );
+ list fstlist = [ entry["spec"]:"", entry["mount"]:"",
+ entry["vfstype"]:"", entry["mntops"]:"",
+ sformat("%1",entry["freq"]:0),
+ sformat("%1",entry["passno"]:0) ];
+ y2milestone( "UpdateFstabSysfs entry %1", entry );
+ y2milestone( "UpdateFstabSysfs fstlist %1", fstlist );
+ AsciiFile::AppendLine( fstab, fstlist );
+ AsciiFile::RewriteFile( fstab, tabpath );
+ }
+ }
+
+
+global define void UpdateFstabHotplugOption()
+ {
+ y2milestone( "UpdateFstabHotplugOption" );
+ string tabpath = Storage::PathToDestdir( "/etc/fstab" );
+ map fstab = Partitions::GetFstab( tabpath );
+ integer line = 0;
+ string n = "";
+ while( line<=AsciiFile::NumLines( fstab ) )
+ {
+ map l = AsciiFile::GetLine( fstab, line );
+ string options = l["fields", 3]:"";
+ if (regexpmatch (options, "^\(.*,\)\?hotplug\(,.*\)\?$")) {
+ options = regexpsub (options, "^\(.*,\)\?hotplug\(,.*\)\?$", "\\1nofail\\2");
+ AsciiFile::ChangeLineField( fstab, line, 3, options );
+ }
+ line = line+1;
+ }
+ AsciiFile::RewriteFile( fstab, tabpath );
+ }
+
+
+ void UpdateFstabPersistentNames()
+ {
+ y2milestone( "UpdateFstabPersistentDevNames updating to SLES10 names" );
+ string tabpath = Storage::PathToDestdir( "/etc/fstab" );
+ map fstab = Partitions::GetFstab( tabpath );
+ integer line = 0;
+ string n = "";
+ while( line<=AsciiFile::NumLines( fstab ) )
+ {
+ map l = AsciiFile::GetLine( fstab, line );
+ n = Storage::SLES9PersistentDevNames( l["fields",0]:"" );
+ if( n != l["fields",0]:"" )
+ {
+ AsciiFile::ChangeLineField( fstab, line, 0, n );
+ }
+ line = line+1;
+ }
+ AsciiFile::RewriteFile( fstab, tabpath );
+ }
+
+
+ void UpdateFstabEvms2Lvm()
+ {
+ y2milestone( "UpdateFstabEvms2Lvm migrating EVMS to LVM" );
+ string tabpath = Storage::PathToDestdir( "/etc/fstab" );
+ map fstab = Partitions::GetFstab( tabpath );
+ integer line = 0;
+ string n = "";
+ while( line<=AsciiFile::NumLines( fstab ) ) {
+ map l = AsciiFile::GetLine( fstab, line );
+ n = l["fields",0]:"";
+ if (substring (n, 0, 15) == "/dev/evms/lvm2/")
+ {
+ n = "/dev/" + substring (n, 15);
+ AsciiFile::ChangeLineField( fstab, line, 0, n );
+ }
+ line = line+1;
+ }
+ AsciiFile::RewriteFile( fstab, tabpath );
+ }
+
+
+ void UpdateMdadm()
+ {
+ y2milestone( "UpdateMdadm" );
+ string cpath = Storage::PathToDestdir( "/etc/mdadm.conf" );
+ map file = $[];
+ AsciiFile::SetComment( file, "^[ \t]*#" );
+ AsciiFile::ReadFile( file, cpath );
+ integer line = 0;
+ boolean changed = false;
+ while( line<=AsciiFile::NumLines( file ) )
+ {
+ if( search( file["l",line,"line"]:"", "DEVICE" )!=nil &&
+ search( file["l",line,"line"]:"", "/dev/" )!=nil )
+ {
+ changed = true;
+ file["l",line,"line"] = "DEVICE partitions";
+ y2milestone( "UpdateMdadm %1", file["l",line]:$[] );
+ }
+ line = line+1;
+ }
+ if( changed )
+ AsciiFile::RewriteFile( file, cpath );
+ }
+
+
+ void UpdateFstabDiskmap(map diskmap)
+ {
+ y2milestone( "UpdateFstabDiskmap map %1", diskmap );
+ string tabpath = Storage::PathToDestdir( "/etc/fstab" );
+ map fstab = Partitions::GetFstab( tabpath );
+ integer line = 0;
+ string n = "";
+ while( line<=AsciiFile::NumLines( fstab ) )
+ {
+ map l = AsciiFile::GetLine( fstab, line );
+ n = Storage::HdDiskMap( l["fields",0]:"", diskmap );
+ if( n != l["fields",0]:"" )
+ {
+ AsciiFile::ChangeLineField( fstab, line, 0, n );
+ }
+ line = line+1;
+ }
+ AsciiFile::RewriteFile( fstab, tabpath );
+ tabpath = Storage::PathToDestdir( "/etc/cryptotab" );
+ map crtab = Partitions::GetCrypto( tabpath );
+ line = 0;
+ while( line<=AsciiFile::NumLines( crtab ) )
+ {
+ map l = AsciiFile::GetLine( crtab, line );
+ n = Storage::HdDiskMap( l["fields",1]:"", diskmap );
+ if( n != l["fields",1]:"" )
+ {
+ AsciiFile::ChangeLineField( crtab, line, 1, n );
+ }
+ line = line+1;
+ }
+ AsciiFile::RewriteFile( crtab, tabpath );
+ }
+
+
+ void UpdateFstabUsbdevfs()
+ {
+ y2milestone( "UpdateFstabUsbdevfs updating usbdevfs to usbfs" );
+ boolean changed = false;
+ string tabpath = Storage::PathToDestdir( "/etc/fstab" );
+ map fstab = Partitions::GetFstab( tabpath );
+ integer line = 0;
+ while( line<=AsciiFile::NumLines( fstab ) )
+ {
+ map l = AsciiFile::GetLine( fstab, line );
+ if( l["fields",2]:"" == "usbdevfs" )
+ {
+ AsciiFile::ChangeLineField( fstab, line, 2, "usbfs" );
+ AsciiFile::ChangeLineField( fstab, line, 0, "usbfs" );
+ changed = true;
+ }
+ line = line+1;
+ }
+ if( changed )
+ {
+ y2milestone( "UpdateFstabUsbdevfs changed" );
+ AsciiFile::RewriteFile( fstab, tabpath );
+ }
+ }
+
+
+ void UpdateFstabIseriesVd()
+ {
+ y2milestone( "UpdateFstabIseriesVd updating hdx to iseries/vdx" );
+ string tabpath = Storage::PathToDestdir( "/etc/fstab" );
+ map fstab = Partitions::GetFstab( tabpath );
+ integer line = 0;
+ string n = "";
+ while( line<=AsciiFile::NumLines( fstab ) )
+ {
+ map l = AsciiFile::GetLine( fstab, line );
+ n = Storage::HdToIseries( l["fields",0]:"" );
+ if( n != l["fields",0]:"" )
+ {
+ AsciiFile::ChangeLineField( fstab, line, 0, n );
+ }
+ line = line+1;
+ }
+ AsciiFile::RewriteFile( fstab, tabpath );
+ tabpath = Storage::PathToDestdir( "/etc/cryptotab" );
+ map crtab = Partitions::GetCrypto( tabpath );
+ line = 0;
+ while( line<=AsciiFile::NumLines( crtab ) )
+ {
+ map l = AsciiFile::GetLine( crtab, line );
+ n = Storage::HdToIseries( l["fields",1]:"" );
+ if( n != l["fields",1]:"" )
+ {
+ AsciiFile::ChangeLineField( crtab, line, 1, n );
+ }
+ line = line+1;
+ }
+ AsciiFile::RewriteFile( crtab, tabpath );
+ }
+
+
+ void UpdateCryptoType()
+ {
+ y2milestone( "UpdateCryptoType" );
+ string tabpath = Storage::PathToDestdir( "/etc/fstab" );
+ map fstab = Partitions::GetFstab( tabpath );
+ integer line = 0;
+ integer pos = 0;
+ string searchstr = "encryption=twofish256";
+ while( line<=AsciiFile::NumLines( fstab ) )
+ {
+ map l = AsciiFile::GetLine( fstab, line );
+ pos = search( l["fields",3]:"", searchstr );
+ if( pos != nil )
+ {
+ string new = substring( l["fields",3]:"", 0, pos );
+ new = new + "encryption=twofishSL92";
+ new = new + substring( l["fields",3]:"", pos+size(searchstr) );
+ y2milestone( "new options line in %1 is %2", l, new );
+ AsciiFile::ChangeLineField( fstab, line, 3, new );
+ }
+ line = line+1;
+ }
+ AsciiFile::RewriteFile( fstab, tabpath );
+ tabpath = Storage::PathToDestdir( "/etc/cryptotab" );
+ map crtab = Partitions::GetCrypto( tabpath );
+ line = 0;
+ while( line<=AsciiFile::NumLines( crtab ) )
+ {
+ map l = AsciiFile::GetLine( crtab, line );
+ if( l["fields",4]:"" == "twofish256" )
+ {
+ y2milestone( "set twofishSL92 in line %1", l );
+ AsciiFile::ChangeLineField( crtab, line, 4, "twofishSL92" );
+ }
+ line = line+1;
+ }
+ AsciiFile::RewriteFile( crtab, tabpath );
+ }
+
+void UpdateFstabCryptNofail()
+ {
+ y2milestone( "UpdateFstabCryptNofail called" );
+ string tabpath = Storage::PathToDestdir( "/etc/fstab" );
+ map fstab = Partitions::GetFstab( tabpath );
+ integer line = 0;
+ boolean update = false;
+ while( line<=AsciiFile::NumLines( fstab ) )
+ {
+ map l = AsciiFile::GetLine( fstab, line );
+ if( search( l["fields",0]:"", "/dev/mapper/cr_" )==0 )
+ {
+ list<string> ls = splitstring( l["fields",3]:"", "," );
+ ls = filter( string s, ls, ``(s!="noauto"));
+ if( size(filter( string s, ls, ``(s=="nofail")))==0 )
+ {
+ ls = add( ls, "nofail" );
+ AsciiFile::ChangeLineField( fstab, line, 3,
+ mergestring( ls, "," ));
+ update = true;
+ }
+ }
+ line = line+1;
+ }
+ if( update )
+ {
+ AsciiFile::RewriteFile( fstab, tabpath );
+ }
+ }
+
+ /**
+ * Updates fstab on disk
+ *
+ * @param map old version
+ * @param map new version
+ *
+ * @struct version $[
+ * // This means version 9.1
+ * "major" : 9,
+ * "minor" : 1,
+ * ]
+ */
+ global void Update(map oldv, map newv)
+ {
+ if (!called_update)
+ {
+ y2milestone( "Update old:%1 new:%2", oldv, newv );
+
+ // Enterprise products do not have minor release number
+ // map enterprise releases to corresponding code bases of SL
+ map sles_major_to_minor = $[ 8 : 2, 9 : 1, 10 : 1 ];
+ if( haskey( oldv, "major" ) && !haskey( oldv, "minor" ) )
+ {
+ oldv["minor"] = sles_major_to_minor[oldv["major"]:0]:0;
+ y2milestone( "Update old:%1", oldv );
+ }
+ if( haskey( newv, "major" ) && !haskey( newv, "minor" ) )
+ {
+ newv["minor"] = sles_major_to_minor[newv["major"]:0]:0;
+ y2milestone( "Update new:%1", newv );
+ }
+ if( !haskey( oldv, "major" ) || !haskey( newv, "major" ) )
+ y2error( "Missing key major or minor" );
+
+ if( oldv["major"]:0<=9 )
+ {
+ UpdateFstabSysfs();
+ }
+ if( oldv["major"]:0<9 )
+ {
+ UpdateFstabUsbdevfs();
+ }
+ if( oldv["major"]:0==9 )
+ {
+ UpdateFstabPersistentNames();
+ }
+
+ if( oldv["major"]:0<=10 )
+ {
+ UpdateFstabHotplugOption();
+ }
+
+ // remove EVMS
+ // FIXME add appropriate condition if needed (does not seem so)
+ UpdateFstabEvms2Lvm();
+
+ map dm = Storage::BuildDiskmap( oldv );
+ if( size(dm)>0 )
+ {
+ UpdateFstabDiskmap( dm );
+ UpdateMdadm();
+ }
+ if( oldv["major"]:0<9 || (oldv["major"]:0==9 && oldv["minor"]:0<=2))
+ {
+ UpdateCryptoType();
+ }
+ if( oldv["major"]:0<10 || (oldv["major"]:0==10 && oldv["minor"]:0==0) )
+ {
+ string of = "/etc/udev/rules.d/20-cdrom.rules";
+ y2milestone( "removing obsolete %1", of );
+ SCR::Execute( .target.remove, of );
+ of = "/etc/udev/rules.d/55-cdrom.rules";
+ y2milestone( "removing obsolete %1", of );
+ SCR::Execute( .target.remove, of );
+ }
+ if( oldv["major"]:0<10 || (oldv["major"]:0==10 && oldv["minor"]:0<=2) )
+ {
+ string of = "/etc/udev/rules.d/65-cdrom.rules";
+ y2milestone( "removing obsolete %1", of );
+ SCR::Execute( .target.remove, of );
+ }
+ if( oldv["major"]:0<10 || (oldv["major"]:0==10 && oldv["minor"]:0==0))
+ UpdateFstabSubfs();
+ if( oldv["major"]:0<9 || (oldv["major"]:0==9 && oldv["minor"]:0==0))
+ {
+ if( Arch::board_iseries () )
+ {
+ UpdateFstabIseriesVd();
+ }
+ string cmd = "cd / && /sbin/insserv -r /etc/init.d/boot.evms";
+ y2milestone( "Update cmd %1", cmd );
+ map bo = (map)SCR::Execute (.target.bash_output, cmd );
+ y2milestone( "Update bo %1", bo );
+ }
+ if( oldv["major"]:0<10 || (oldv["major"]:0==10 && oldv["minor"]:0<=2))
+ {
+ string cmd = "cd / && /sbin/insserv /etc/init.d/boot.crypto";
+ map bo = (map)SCR::Execute (.target.bash_output, cmd );
+ y2milestone( "Update bo %1", bo );
+
+ cmd = "cd / && /sbin/insserv /etc/init.d/boot.crypto-early";
+ bo = (map)SCR::Execute (.target.bash_output, cmd );
+ y2milestone( "Update bo %1", bo );
+ }
+ if( oldv["major"]:0<11 || (oldv["major"]:0==11 && oldv["minor"]:0<=2))
+ UpdateFstabCryptNofail();
+ // set flag -> it indicates that Update was already called
+ called_update = true;
+ }
+ else
+ {
+ y2milestone("Skip calling Update() -> It was already called");
+ }
+ }
+}
Modified: branches/SuSE-Code-11-SP2-Branch/storage/storage/src/modules/TabPanel.ycp
URL: http://svn.opensuse.org/viewcvs/yast/branches/SuSE-Code-11-SP2-Branch/stora…
==============================================================================
--- branches/SuSE-Code-11-SP2-Branch/storage/storage/src/modules/TabPanel.ycp (original)
+++ branches/SuSE-Code-11-SP2-Branch/storage/storage/src/modules/TabPanel.ycp Tue May 17 13:39:44 2011
@@ -11,6 +11,9 @@
module "TabPanel";
+ import "Event";
+
+
map<symbol, map> data = nil;
symbol current_item = nil;
@@ -32,14 +35,25 @@
}
}
- void CallHandle(symbol widget)
+ void CallRefresh()
{
map tmp = data[current_item]:nil;
- void(any, symbol) handle_func = (void(any, symbol)) tmp[`handle]:nil;
+ void(any) refresh_func = (void(any)) tmp[`refresh]:nil;
+ if (refresh_func != nil)
+ {
+ any user_data = tmp[`user_data]:nil;
+ refresh_func(user_data);
+ }
+ }
+
+ void CallHandle(map event)
+ {
+ map tmp = data[current_item]:nil;
+ void(any, map) handle_func = (void(any, map)) tmp[`handle]:nil;
if (handle_func != nil)
{
any user_data = tmp[`user_data]:nil;
- handle_func(user_data, widget);
+ handle_func(user_data, event);
}
}
@@ -91,9 +105,16 @@
CallCreate();
}
- global void Handle(symbol widget)
+ global void Refresh()
+ {
+ CallRefresh();
+ }
+
+ global void Handle(map event)
{
- if (haskey(data, widget))
+ symbol widget = Event::IsMenu(event);
+
+ if (widget != nil && haskey(data, widget))
{
if (widget != current_item)
{
@@ -105,7 +126,7 @@
}
else
{
- CallHandle(widget);
+ CallHandle(event);
}
}
Modified: branches/SuSE-Code-11-SP2-Branch/storage/storage/src/modules/TreePanel.ycp
URL: http://svn.opensuse.org/viewcvs/yast/branches/SuSE-Code-11-SP2-Branch/stora…
==============================================================================
--- branches/SuSE-Code-11-SP2-Branch/storage/storage/src/modules/TreePanel.ycp (original)
+++ branches/SuSE-Code-11-SP2-Branch/storage/storage/src/modules/TreePanel.ycp Tue May 17 13:39:44 2011
@@ -9,6 +9,9 @@
*/
{
module "TreePanel";
+
+
+ import "Event";
map<any, map> data = nil;
@@ -30,14 +33,25 @@
}
}
- void CallHandle(symbol widget)
+ void CallRefresh()
+ {
+ map tmp = data[current_item]:nil;
+ void(any) refresh_func = (void(any)) tmp[`refresh]:nil;
+ if (refresh_func != nil)
+ {
+ any user_data = tmp[`user_data]:nil;
+ refresh_func(user_data);
+ }
+ }
+
+ void CallHandle(map event)
{
map tmp = data[current_item]:nil;
- void(any, symbol) handle_func = (void(any, symbol)) tmp[`handle]:nil;
+ void(any, map) handle_func = (void(any, map)) tmp[`handle]:nil;
if (handle_func != nil)
{
any user_data = tmp[`user_data]:nil;
- handle_func(user_data, widget);
+ handle_func(user_data, event);
}
}
@@ -101,12 +115,19 @@
CallCreate();
}
+ global void Refresh()
+ {
+ CallRefresh();
+ }
+
/**
* Handle user input by either switching the panel or delegating the input
* to the selected panel.
*/
- global void Handle(symbol widget)
+ global void Handle(map event)
{
+ symbol widget = Event::IsWidgetActivatedOrSelectionChanged(event);
+
if (widget == `tree)
{
any new_current_item = UI::QueryWidget(`tree, `CurrentItem);
@@ -119,7 +140,7 @@
}
else
{
- CallHandle(widget);
+ CallHandle(event);
}
}
Modified: branches/SuSE-Code-11-SP2-Branch/storage/storage/src/proposal/partitions_proposal.ycp
URL: http://svn.opensuse.org/viewcvs/yast/branches/SuSE-Code-11-SP2-Branch/stora…
==============================================================================
--- branches/SuSE-Code-11-SP2-Branch/storage/storage/src/proposal/partitions_proposal.ycp (original)
+++ branches/SuSE-Code-11-SP2-Branch/storage/storage/src/proposal/partitions_proposal.ycp Tue May 17 13:39:44 2011
@@ -1,4 +1,4 @@
- /**
+/**
* Module: proposal_partitions.ycp
*
* $Id$
@@ -13,10 +13,12 @@
textdomain "storage";
import "Arch";
- import "PackagesProposal";
+ import "Wizard";
+ import "Mode";
+ import "Sequencer";
+ import "Storage";
+ import "StorageProposal";
- include "wizard/sequencer.ycp";
- include "partitioning/do_proposal_flexible.ycp";
string func = (string) WFM::Args(0);
map param = (map) WFM::Args(1);
@@ -24,25 +26,38 @@
y2milestone( "func:%1 param:%2", func, param );
+
// check if /home partition keeps unformatted in order to warn for
- // possible incorrectly set file ownership (fate#306325)
- boolean home_not_formatted() {
- map<string,map> tm = Storage::GetTargetMap();
- boolean ret = false;
- foreach (string disk, map info, tm, {
- list<map> partitions = info["partitions"]:[];
- foreach (map p, partitions, {
- if (p["mount"]:"" == "/home" && ! p["format"]:false)
- {
- y2milestone ("The /home partition will not be formatted.");
- ret = true;
- break;
- }
- });
- });
- return ret;
+ // possible incorrectly set file ownership (fate #306325)
+ boolean unformatted_home_warning()
+ {
+ map part = Storage::GetEntryForMountpoint("/home");
+ if (!isempty(part) && !part["format"]:false)
+ {
+ y2milestone("/home partition will not be formatted");
+
+ import "UsersSimple";
+ if (UsersSimple::AfterAuth() != "users")
+ {
+ y2milestone("non-local user authentication");
+ return true;
+ }
+
+ string device = part["device"]:"";
+ map<symbol, any> resize_info = $[];
+ map<symbol, any> content_info = $[];
+ if (Storage::GetFreeInfo(device, false, resize_info, true, content_info, true) &&
+ content_info[`homes]:0 > 1)
+ {
+ y2milestone("multiple home directories");
+ return true;
+ }
+ }
+
+ return false;
}
+
if( func == "MakeProposal" && Mode::autoinst() )
{
ret["preformatted_proposal"] = Storage::ChangeText();
@@ -62,7 +77,7 @@
Storage::AddMountPointsForWin(Storage::GetTargetMap());
}
map prop = $[];
- prop = get_inst_prop( Storage::GetTargetMap());
+ prop = StorageProposal::get_inst_prop( Storage::GetTargetMap());
y2milestone( "prop ok:%1", prop["ok"]:false );
if( prop["ok"]:false )
{
@@ -83,17 +98,13 @@
!Storage::GetPartProposalActive() )
{
ret["preformatted_proposal"] = Storage::ChangeText();
- // detect non-formated /home together with remote authentication - Fate#306325
- if (home_not_formatted())
- {
- import "UsersSimple";
- if (UsersSimple::AfterAuth() != "users")
- {
- ret["warning"] = _("The /home partition will not be formatted. After installation,
-ensure that the permissions to home directories are set properly.");
- ret["warning_level"] = `warning;
- }
- }
+
+ if (unformatted_home_warning())
+ {
+ ret["warning"] = _("The /home partition will not be formatted. After installation,
+ensure that ownerships of home directories are set properly.");
+ ret["warning_level"] = `warning;
+ }
}
else
{
@@ -183,7 +194,7 @@
y2milestone( "proposal sequence %1", seq );
Wizard::OpenNextBackDialog();
- symbol result = WizardSequencer(aliases, seq);
+ symbol result = Sequencer::Run(aliases, seq);
Wizard::CloseDialog();
y2milestone( "AskUser Mode:%1 ProActive:%2", Storage::GetPartMode(),
Modified: branches/SuSE-Code-11-SP2-Branch/storage/storage/src/storage_finish.ycp
URL: http://svn.opensuse.org/viewcvs/yast/branches/SuSE-Code-11-SP2-Branch/stora…
==============================================================================
--- branches/SuSE-Code-11-SP2-Branch/storage/storage/src/storage_finish.ycp (original)
+++ branches/SuSE-Code-11-SP2-Branch/storage/storage/src/storage_finish.ycp Tue May 17 13:39:44 2011
@@ -18,6 +18,7 @@
import "Storage";
import "StorageSettings";
+import "StorageUpdate";
import "Mode";
import "Installation";
import "Initrd";
@@ -49,10 +50,12 @@
}
else if (func == "Write")
{
+/*
list<string> storage_initrdm = (list<string>)Storage::GetRootInitrdModules();
foreach(string m, storage_initrdm, {
Initrd::AddModule (m, "");
});
+*/
if( !Mode::update () )
{
SCR::Execute (.target.mkdir, Installation::sourcedir);
@@ -60,7 +63,7 @@
}
else
{
- Storage::Update (Installation::installedVersion, Installation::updateVersion);
+ StorageUpdate::Update(Installation::installedVersion, Installation::updateVersion);
}
if (Storage::CheckForLvmRootFs() )
{
Added: branches/SuSE-Code-11-SP2-Branch/storage/storage/src/testsuite/Makefile.am
URL: http://svn.opensuse.org/viewcvs/yast/branches/SuSE-Code-11-SP2-Branch/stora…
==============================================================================
--- branches/SuSE-Code-11-SP2-Branch/storage/storage/src/testsuite/Makefile.am (added)
+++ branches/SuSE-Code-11-SP2-Branch/storage/storage/src/testsuite/Makefile.am Tue May 17 13:39:44 2011
@@ -0,0 +1,31 @@
+#
+# Makefile.am for .../testsuite
+#
+# Do not edit this file (Makefile.am) as it will be overwritten!
+#
+
+SUBDIRS = data
+
+AUTOMAKE_OPTIONS = dejagnu
+EXTRA_DIST = $(wildcard tests/*.out) $(wildcard tests/*.err) $(wildcard tests/*.ycp) $(wildcard tests/*.yh)
+
+Y2BASEFLAGS = -M $(top_builddir)/libstorage/bindings/ycp
+export Y2BASEFLAGS
+
+Y2BASE_LD_LIBRARY_PATH = $(top_builddir)/libstorage/src/.libs
+Y2BASE_Y2DIR = $(top_builddir)/storage/src:$(top_builddir)/libstorage/src/.libs
+export Y2BASE_LD_LIBRARY_PATH
+export Y2BASE_Y2DIR
+
+testsuite_prepare = @ydatadir@/testsuite/Makefile.testsuite
+
+all-local: $(testsuite_prepare)
+ make -f $(testsuite_prepare) RPMNAME=$(RPMNAME) srcdir=$(srcdir)
+
+clean-local: $(testsuite_prepare)
+ make -f $(testsuite_prepare) RPMNAME=$(RPMNAME) srcdir=$(srcdir) clean
+
+check-local: $(testsuite_prepare)
+ make -f $(testsuite_prepare) RPMNAME=$(RPMNAME) srcdir=$(srcdir) check
+
+# EOF
Added: branches/SuSE-Code-11-SP2-Branch/storage/storage/src/testsuite/README
URL: http://svn.opensuse.org/viewcvs/yast/branches/SuSE-Code-11-SP2-Branch/stora…
==============================================================================
--- branches/SuSE-Code-11-SP2-Branch/storage/storage/src/testsuite/README (added)
+++ branches/SuSE-Code-11-SP2-Branch/storage/storage/src/testsuite/README Tue May 17 13:39:44 2011
@@ -0,0 +1,5 @@
+
+To run a test-script manually:
+
+ /usr/lib/YaST2/bin/y2base ./tests/<name>.ycp UI
+
Modified: branches/SuSE-Code-11-SP2-Branch/storage/storage/src/testsuite/config/unix.exp
URL: http://svn.opensuse.org/viewcvs/yast/branches/SuSE-Code-11-SP2-Branch/stora…
==============================================================================
--- branches/SuSE-Code-11-SP2-Branch/storage/storage/src/testsuite/config/unix.exp (original)
+++ branches/SuSE-Code-11-SP2-Branch/storage/storage/src/testsuite/config/unix.exp Tue May 17 13:39:44 2011
@@ -1,5 +1,114 @@
-load_lib "partitioning_init.exp"
+# YaST2: modules testsuite
+#
+# Description:
+# Main config file
+#
+# Author:
+# Michal Svec <msvec(a)suse.cz>
+#
+# $Id$
-proc partitioning_exit {} {}
-proc partitioning_version {} {}
+proc testsuite_exit {} {}
+proc testsuite_version {} {}
+# Run one test
+
+proc testsuite-run { src } {
+
+ set path [split $src "/"]
+ set filename [lindex $path [expr [llength $path]-1]]
+
+ # extract basename and check extension
+
+ set fname [split $filename "."]
+
+ if {[llength $fname] < 2} {
+ fail "Bad filename syntax '$src'"
+ return -1
+ }
+ if {[lindex $fname [expr [llength $fname]-1]] != "ycp"} {
+ fail "Not .ycp extension '$src'"
+ return -1
+ }
+
+ # setup filenames
+
+ # $src is the name of the original testfile with absolute path
+ # tests/$filename is the name of the original testfile with relative path,
+ # relative to the testsuite directory
+ set test_input "tests/$filename"
+
+ set base_name [lindex $fname 0]
+
+ set stdout_name "tests/$base_name.out"
+ set stderr_name "tests/$base_name.err"
+ set log_name "tests/$base_name.log"
+ set tmpout_name "tmp.out.$base_name"
+ set tmperr_name "tmp.err.$base_name"
+ set tmplog_name "tmp.log.$base_name"
+
+ # fate#2306: enable make check *gasp* before make install
+ # by searching in the source directory
+ set options ""
+ # first hack: look for the usual suspects
+ # (next steps: use YCPCFLAGS)
+ set sourcedir "../src"
+ if {[file isdirectory $sourcedir]} {
+ set options "-I $sourcedir -M $sourcedir"
+ }
+
+ puts "Running $base_name ..."
+
+ # run the test
+
+ set result ""
+ set oops [catch { set result [exec "run/runtest.sh" $options "$test_input" "$tmpout_name" "$tmperr_name" ] } catched]
+
+ if {$oops != 0} {
+ fail "Test case failed for $base_name: $catched"
+ return -1
+ }
+
+ # check return code from runycp
+
+ if {$result != ""} {
+ warning "Compilation of $base_name results in '$result'"
+ return -1
+ }
+
+ # check stderr
+
+ if {[diff $stderr_name "tmp.err.$base_name"] != 1} {
+ fail "Wrong stderr for $base_name"
+ set oops [catch { set result [exec test -f $stderr_name] } catched ]
+ if {$oops == 0} {
+ puts "\nThe diff follows...\n"
+ puts [exec sh -c "diff -u $stderr_name tmp.err.$base_name || true"]
+ puts ""
+ fail "Wrong stderr for $base_name"
+ puts "See the diff above."
+ }
+ return -1
+ }
+
+ # check stdout
+
+ if {[diff $stdout_name "tmp.out.$base_name"] != 1} {
+ fail "Wrong stdout for $base_name"
+ set oops [catch { set result [exec test -f $stdout_name] } catched ]
+ if {$oops == 0} {
+ puts "\nThe diff follows...\n"
+ puts [exec sh -c "diff -u $stdout_name tmp.out.$base_name || true"]
+ puts ""
+ fail "Wrong stdout for $base_name"
+ puts "See the diff above."
+ }
+ return -1
+ }
+
+ # ok, all is fine
+
+ pass $base_name
+
+ return 0
+}
Added: branches/SuSE-Code-11-SP2-Branch/storage/storage/src/testsuite/data/Makefile.am
URL: http://svn.opensuse.org/viewcvs/yast/branches/SuSE-Code-11-SP2-Branch/stora…
==============================================================================
--- branches/SuSE-Code-11-SP2-Branch/storage/storage/src/testsuite/data/Makefile.am (added)
+++ branches/SuSE-Code-11-SP2-Branch/storage/storage/src/testsuite/data/Makefile.am Tue May 17 13:39:44 2011
@@ -0,0 +1,6 @@
+#
+# Makefile.am for storage/storage/src/testsuite/data
+#
+
+SUBDIRS = empty empty-efi half-empty reuse-home windows windows-only
+
Added: branches/SuSE-Code-11-SP2-Branch/storage/storage/src/testsuite/data/empty-efi/Makefile.am
URL: http://svn.opensuse.org/viewcvs/yast/branches/SuSE-Code-11-SP2-Branch/stora…
==============================================================================
--- branches/SuSE-Code-11-SP2-Branch/storage/storage/src/testsuite/data/empty-efi/Makefile.am (added)
+++ branches/SuSE-Code-11-SP2-Branch/storage/storage/src/testsuite/data/empty-efi/Makefile.am Tue May 17 13:39:44 2011
@@ -0,0 +1,6 @@
+#
+# Makefile.am for storage/storage/src/testsuite/data/empty-efi
+#
+
+EXTRA_DIST = disk_sda.info arch.info
+
Added: branches/SuSE-Code-11-SP2-Branch/storage/storage/src/testsuite/data/empty-efi/arch.info
URL: http://svn.opensuse.org/viewcvs/yast/branches/SuSE-Code-11-SP2-Branch/stora…
==============================================================================
--- branches/SuSE-Code-11-SP2-Branch/storage/storage/src/testsuite/data/empty-efi/arch.info (added)
+++ branches/SuSE-Code-11-SP2-Branch/storage/storage/src/testsuite/data/empty-efi/arch.info Tue May 17 13:39:44 2011
@@ -0,0 +1,5 @@
+<?xml version="1.0"?>
+<arch>
+ <arch>x86_64</arch>
+ <efiboot>true</efiboot>
+</arch>
Added: branches/SuSE-Code-11-SP2-Branch/storage/storage/src/testsuite/data/empty-efi/disk_sda.info
URL: http://svn.opensuse.org/viewcvs/yast/branches/SuSE-Code-11-SP2-Branch/stora…
==============================================================================
--- branches/SuSE-Code-11-SP2-Branch/storage/storage/src/testsuite/data/empty-efi/disk_sda.info (added)
+++ branches/SuSE-Code-11-SP2-Branch/storage/storage/src/testsuite/data/empty-efi/disk_sda.info Tue May 17 13:39:44 2011
@@ -0,0 +1,16 @@
+<?xml version="1.0"?>
+<disk>
+ <name>sda</name>
+ <device>/dev/sda</device>
+ <size_k>312571224</size_k>
+ <major>8</major>
+ <minor>64</minor>
+ <range>256</range>
+ <geometry>
+ <cylinders>38913</cylinders>
+ <heads>255</heads>
+ <sectors>63</sectors>
+ </geometry>
+ <label>gpt</label>
+ <max_primary>128</max_primary>
+</disk>
Added: branches/SuSE-Code-11-SP2-Branch/storage/storage/src/testsuite/data/empty/Makefile.am
URL: http://svn.opensuse.org/viewcvs/yast/branches/SuSE-Code-11-SP2-Branch/stora…
==============================================================================
--- branches/SuSE-Code-11-SP2-Branch/storage/storage/src/testsuite/data/empty/Makefile.am (added)
+++ branches/SuSE-Code-11-SP2-Branch/storage/storage/src/testsuite/data/empty/Makefile.am Tue May 17 13:39:44 2011
@@ -0,0 +1,6 @@
+#
+# Makefile.am for storage/storage/src/testsuite/data/empty
+#
+
+EXTRA_DIST = disk_sda.info
+
Added: branches/SuSE-Code-11-SP2-Branch/storage/storage/src/testsuite/data/empty/disk_sda.info
URL: http://svn.opensuse.org/viewcvs/yast/branches/SuSE-Code-11-SP2-Branch/stora…
==============================================================================
--- branches/SuSE-Code-11-SP2-Branch/storage/storage/src/testsuite/data/empty/disk_sda.info (added)
+++ branches/SuSE-Code-11-SP2-Branch/storage/storage/src/testsuite/data/empty/disk_sda.info Tue May 17 13:39:44 2011
@@ -0,0 +1,18 @@
+<?xml version="1.0"?>
+<disk>
+ <name>sda</name>
+ <device>/dev/sda</device>
+ <size_k>312571224</size_k>
+ <major>8</major>
+ <minor>0</minor>
+ <range>256</range>
+ <geometry>
+ <cylinders>38913</cylinders>
+ <heads>255</heads>
+ <sectors>63</sectors>
+ </geometry>
+ <label>msdos</label>
+ <max_primary>4</max_primary>
+ <ext_possible>true</ext_possible>
+ <max_logical>63</max_logical>
+</disk>
Added: branches/SuSE-Code-11-SP2-Branch/storage/storage/src/testsuite/data/half-empty/Makefile.am
URL: http://svn.opensuse.org/viewcvs/yast/branches/SuSE-Code-11-SP2-Branch/stora…
==============================================================================
--- branches/SuSE-Code-11-SP2-Branch/storage/storage/src/testsuite/data/half-empty/Makefile.am (added)
+++ branches/SuSE-Code-11-SP2-Branch/storage/storage/src/testsuite/data/half-empty/Makefile.am Tue May 17 13:39:44 2011
@@ -0,0 +1,6 @@
+#
+# Makefile.am for storage/storage/src/testsuite/data/half-empty
+#
+
+EXTRA_DIST = disk_sda.info
+
Added: branches/SuSE-Code-11-SP2-Branch/storage/storage/src/testsuite/data/half-empty/disk_sda.info
URL: http://svn.opensuse.org/viewcvs/yast/branches/SuSE-Code-11-SP2-Branch/stora…
==============================================================================
--- branches/SuSE-Code-11-SP2-Branch/storage/storage/src/testsuite/data/half-empty/disk_sda.info (added)
+++ branches/SuSE-Code-11-SP2-Branch/storage/storage/src/testsuite/data/half-empty/disk_sda.info Tue May 17 13:39:44 2011
@@ -0,0 +1,49 @@
+<?xml version="1.0"?>
+<disk>
+ <name>sda</name>
+ <device>/dev/sda</device>
+ <size_k>312571224</size_k>
+ <major>8</major>
+ <minor>0</minor>
+ <range>256</range>
+ <geometry>
+ <cylinders>38913</cylinders>
+ <heads>255</heads>
+ <sectors>63</sectors>
+ </geometry>
+ <label>msdos</label>
+ <max_primary>4</max_primary>
+ <ext_possible>true</ext_possible>
+ <max_logical>63</max_logical>
+ <partition>
+ <name>sda1</name>
+ <device>/dev/sda1</device>
+ <size_k>1044225</size_k>
+ <major>8</major>
+ <minor>1</minor>
+ <numeric>true</numeric>
+ <number>1</number>
+ <region>
+ <start>1</start>
+ <length>130</length>
+ </region>
+ <partition_type>primary</partition_type>
+ <partition_id>131</partition_id>
+ <boot_flag>true</boot_flag>
+ </partition>
+ <partition>
+ <name>sda2</name>
+ <device>/dev/sda2</device>
+ <size_k>157284382</size_k>
+ <major>8</major>
+ <minor>2</minor>
+ <numeric>true</numeric>
+ <number>2</number>
+ <region>
+ <start>131</start>
+ <length>19581</length>
+ </region>
+ <partition_type>primary</partition_type>
+ <partition_id>142</partition_id>
+ </partition>
+</disk>
Added: branches/SuSE-Code-11-SP2-Branch/storage/storage/src/testsuite/data/reuse-home/Makefile.am
URL: http://svn.opensuse.org/viewcvs/yast/branches/SuSE-Code-11-SP2-Branch/stora…
==============================================================================
--- branches/SuSE-Code-11-SP2-Branch/storage/storage/src/testsuite/data/reuse-home/Makefile.am (added)
+++ branches/SuSE-Code-11-SP2-Branch/storage/storage/src/testsuite/data/reuse-home/Makefile.am Tue May 17 13:39:44 2011
@@ -0,0 +1,6 @@
+#
+# Makefile.am for storage/storage/src/testsuite/data/reuse-home
+#
+
+EXTRA_DIST = disk_sda.info free.info
+
Added: branches/SuSE-Code-11-SP2-Branch/storage/storage/src/testsuite/data/reuse-home/disk_sda.info
URL: http://svn.opensuse.org/viewcvs/yast/branches/SuSE-Code-11-SP2-Branch/stora…
==============================================================================
--- branches/SuSE-Code-11-SP2-Branch/storage/storage/src/testsuite/data/reuse-home/disk_sda.info (added)
+++ branches/SuSE-Code-11-SP2-Branch/storage/storage/src/testsuite/data/reuse-home/disk_sda.info Tue May 17 13:39:44 2011
@@ -0,0 +1,66 @@
+<?xml version="1.0"?>
+<disk>
+ <name>sda</name>
+ <device>/dev/sda</device>
+ <size_k>312571224</size_k>
+ <major>8</major>
+ <minor>0</minor>
+ <range>256</range>
+ <geometry>
+ <cylinders>38913</cylinders>
+ <heads>255</heads>
+ <sectors>63</sectors>
+ </geometry>
+ <label>msdos</label>
+ <max_primary>4</max_primary>
+ <ext_possible>true</ext_possible>
+ <max_logical>63</max_logical>
+ <partition>
+ <name>sda1</name>
+ <device>/dev/sda1</device>
+ <size_k>2104515</size_k>
+ <major>0</major>
+ <minor>0</minor>
+ <numeric>true</numeric>
+ <number>1</number>
+ <fs_type>swap</fs_type>
+ <region>
+ <start>0</start>
+ <length>262</length>
+ </region>
+ <partition_type>primary</partition_type>
+ <partition_id>130</partition_id>
+ </partition>
+ <partition>
+ <name>sda2</name>
+ <device>/dev/sda2</device>
+ <size_k>15735667</size_k>
+ <major>0</major>
+ <minor>0</minor>
+ <numeric>true</numeric>
+ <number>2</number>
+ <fs_type>ext4</fs_type>
+ <region>
+ <start>262</start>
+ <length>1959</length>
+ </region>
+ <partition_type>primary</partition_type>
+ <partition_id>131</partition_id>
+ </partition>
+ <partition>
+ <name>sda3</name>
+ <device>/dev/sda3</device>
+ <size_k>294728490</size_k>
+ <major>0</major>
+ <minor>0</minor>
+ <numeric>true</numeric>
+ <number>3</number>
+ <fs_type>ext4</fs_type>
+ <region>
+ <start>2221</start>
+ <length>36692</length>
+ </region>
+ <partition_type>primary</partition_type>
+ <partition_id>131</partition_id>
+ </partition>
+</disk>
Added: branches/SuSE-Code-11-SP2-Branch/storage/storage/src/testsuite/data/reuse-home/free.info
URL: http://svn.opensuse.org/viewcvs/yast/branches/SuSE-Code-11-SP2-Branch/stora…
==============================================================================
--- branches/SuSE-Code-11-SP2-Branch/storage/storage/src/testsuite/data/reuse-home/free.info (added)
+++ branches/SuSE-Code-11-SP2-Branch/storage/storage/src/testsuite/data/reuse-home/free.info Tue May 17 13:39:44 2011
@@ -0,0 +1,15 @@
+<?xml version="1.0"?>
+<free>
+ <free>
+ <device>/dev/sda3</device>
+ <resize_cached>true</resize_cached>
+ <df_free_k>23338740</df_free_k>
+ <resize_free_k>23338740</resize_free_k>
+ <used_k>26203196</used_k>
+ <resize_ok>true</resize_ok>
+ <content_cached>true</content_cached>
+ <windows>false</windows>
+ <efi>false</efi>
+ <homes>2</homes>
+ </free>
+</free>
Added: branches/SuSE-Code-11-SP2-Branch/storage/storage/src/testsuite/data/windows-only/Makefile.am
URL: http://svn.opensuse.org/viewcvs/yast/branches/SuSE-Code-11-SP2-Branch/stora…
==============================================================================
--- branches/SuSE-Code-11-SP2-Branch/storage/storage/src/testsuite/data/windows-only/Makefile.am (added)
+++ branches/SuSE-Code-11-SP2-Branch/storage/storage/src/testsuite/data/windows-only/Makefile.am Tue May 17 13:39:44 2011
@@ -0,0 +1,6 @@
+#
+# Makefile.am for storage/storage/src/testsuite/data/windows-only
+#
+
+EXTRA_DIST = disk_sda.info free.info
+
Added: branches/SuSE-Code-11-SP2-Branch/storage/storage/src/testsuite/data/windows-only/disk_sda.info
URL: http://svn.opensuse.org/viewcvs/yast/branches/SuSE-Code-11-SP2-Branch/stora…
==============================================================================
--- branches/SuSE-Code-11-SP2-Branch/storage/storage/src/testsuite/data/windows-only/disk_sda.info (added)
+++ branches/SuSE-Code-11-SP2-Branch/storage/storage/src/testsuite/data/windows-only/disk_sda.info Tue May 17 13:39:44 2011
@@ -0,0 +1,35 @@
+<?xml version="1.0"?>
+<disk>
+ <name>sda</name>
+ <device>/dev/sda</device>
+ <size_k>78150744</size_k>
+ <major>8</major>
+ <minor>16</minor>
+ <range>256</range>
+ <geometry>
+ <cylinders>9729</cylinders>
+ <heads>255</heads>
+ <sectors>63</sectors>
+ </geometry>
+ <label>msdos</label>
+ <max_primary>4</max_primary>
+ <ext_possible>true</ext_possible>
+ <max_logical>63</max_logical>
+ <partition>
+ <name>sda1</name>
+ <device>/dev/sda1</device>
+ <size_k>78148161</size_k>
+ <major>8</major>
+ <minor>17</minor>
+ <numeric>true</numeric>
+ <number>1</number>
+ <fs_type>ntfs-3g</fs_type>
+ <fs_uuid>33458CDC339D406E</fs_uuid>
+ <region>
+ <start>0</start>
+ <length>9729</length>
+ </region>
+ <partition_type>primary</partition_type>
+ <partition_id>7</partition_id>
+ </partition>
+</disk>
Added: branches/SuSE-Code-11-SP2-Branch/storage/storage/src/testsuite/data/windows-only/free.info
URL: http://svn.opensuse.org/viewcvs/yast/branches/SuSE-Code-11-SP2-Branch/stora…
==============================================================================
--- branches/SuSE-Code-11-SP2-Branch/storage/storage/src/testsuite/data/windows-only/free.info (added)
+++ branches/SuSE-Code-11-SP2-Branch/storage/storage/src/testsuite/data/windows-only/free.info Tue May 17 13:39:44 2011
@@ -0,0 +1,15 @@
+<?xml version="1.0"?>
+<free>
+ <free>
+ <device>/dev/sda1</device>
+ <resize_cached>true</resize_cached>
+ <df_free_k>64991212</df_free_k>
+ <resize_free_k>64991212</resize_free_k>
+ <used_k>13156948</used_k>
+ <resize_ok>true</resize_ok>
+ <content_cached>true</content_cached>
+ <windows>true</windows>
+ <efi>false</efi>
+ <home>false</home>
+ </free>
+</free>
Added: branches/SuSE-Code-11-SP2-Branch/storage/storage/src/testsuite/data/windows/Makefile.am
URL: http://svn.opensuse.org/viewcvs/yast/branches/SuSE-Code-11-SP2-Branch/stora…
==============================================================================
--- branches/SuSE-Code-11-SP2-Branch/storage/storage/src/testsuite/data/windows/Makefile.am (added)
+++ branches/SuSE-Code-11-SP2-Branch/storage/storage/src/testsuite/data/windows/Makefile.am Tue May 17 13:39:44 2011
@@ -0,0 +1,6 @@
+#
+# Makefile.am for storage/storage/src/testsuite/data/windows
+#
+
+EXTRA_DIST = disk_sda.info free.info
+
Added: branches/SuSE-Code-11-SP2-Branch/storage/storage/src/testsuite/data/windows/disk_sda.info
URL: http://svn.opensuse.org/viewcvs/yast/branches/SuSE-Code-11-SP2-Branch/stora…
==============================================================================
--- branches/SuSE-Code-11-SP2-Branch/storage/storage/src/testsuite/data/windows/disk_sda.info (added)
+++ branches/SuSE-Code-11-SP2-Branch/storage/storage/src/testsuite/data/windows/disk_sda.info Tue May 17 13:39:44 2011
@@ -0,0 +1,35 @@
+<?xml version="1.0"?>
+<disk>
+ <name>sda</name>
+ <device>/dev/sda</device>
+ <size_k>78150744</size_k>
+ <major>8</major>
+ <minor>16</minor>
+ <range>256</range>
+ <geometry>
+ <cylinders>9729</cylinders>
+ <heads>255</heads>
+ <sectors>63</sectors>
+ </geometry>
+ <label>msdos</label>
+ <max_primary>4</max_primary>
+ <ext_possible>true</ext_possible>
+ <max_logical>63</max_logical>
+ <partition>
+ <name>sda1</name>
+ <device>/dev/sda1</device>
+ <size_k>41945715</size_k>
+ <major>8</major>
+ <minor>17</minor>
+ <numeric>true</numeric>
+ <number>1</number>
+ <fs_type>ntfs-3g</fs_type>
+ <fs_uuid>33458CDC339D406E</fs_uuid>
+ <region>
+ <start>0</start>
+ <length>5223</length>
+ </region>
+ <partition_type>primary</partition_type>
+ <partition_id>7</partition_id>
+ </partition>
+</disk>
Added: branches/SuSE-Code-11-SP2-Branch/storage/storage/src/testsuite/data/windows/free.info
URL: http://svn.opensuse.org/viewcvs/yast/branches/SuSE-Code-11-SP2-Branch/stora…
==============================================================================
--- branches/SuSE-Code-11-SP2-Branch/storage/storage/src/testsuite/data/windows/free.info (added)
+++ branches/SuSE-Code-11-SP2-Branch/storage/storage/src/testsuite/data/windows/free.info Tue May 17 13:39:44 2011
@@ -0,0 +1,15 @@
+<?xml version="1.0"?>
+<free>
+ <free>
+ <device>/dev/sda1</device>
+ <resize_cached>true</resize_cached>
+ <df_free_k>27806796</df_free_k>
+ <resize_free_k>27806796</resize_free_k>
+ <used_k>13155812</used_k>
+ <resize_ok>true</resize_ok>
+ <content_cached>true</content_cached>
+ <windows>true</windows>
+ <efi>false</efi>
+ <home>false</home>
+ </free>
+</free>
Added: branches/SuSE-Code-11-SP2-Branch/storage/storage/src/testsuite/lib/test.exp
URL: http://svn.opensuse.org/viewcvs/yast/branches/SuSE-Code-11-SP2-Branch/stora…
==============================================================================
--- branches/SuSE-Code-11-SP2-Branch/storage/storage/src/testsuite/lib/test.exp (added)
+++ branches/SuSE-Code-11-SP2-Branch/storage/storage/src/testsuite/lib/test.exp Tue May 17 13:39:44 2011
@@ -0,0 +1 @@
+# anyagent.exp -- empty
Added: branches/SuSE-Code-11-SP2-Branch/storage/storage/src/testsuite/lib/test_init.exp
URL: http://svn.opensuse.org/viewcvs/yast/branches/SuSE-Code-11-SP2-Branch/stora…
==============================================================================
--- branches/SuSE-Code-11-SP2-Branch/storage/storage/src/testsuite/lib/test_init.exp (added)
+++ branches/SuSE-Code-11-SP2-Branch/storage/storage/src/testsuite/lib/test_init.exp Tue May 17 13:39:44 2011
@@ -0,0 +1,68 @@
+#
+# run a anyagent file
+#
+proc anyagent-run { src } {
+
+ set path [split $src "/"]
+ set filename [lindex $path [expr [llength $path]-1]]
+
+ # extract basename and check extension
+
+ set fname [split $filename "."]
+
+ if {[llength $fname] < 2} {
+ fail "Bad filename syntax '$src'"
+ return
+ }
+ if {[lindex $fname [expr [llength $fname]-1]] != "anyagent"} {
+ fail "Not .anyagent extension '$src'"
+ return
+ }
+
+ # setup filenames
+
+ set base_name [lindex $fname 0]
+
+ set stdout_name "tests/$base_name.out"
+ set stderr_name "tests/$base_name.err"
+ set tmpout_name "tmp.out.$base_name"
+ set tmperr_name "tmp.err.$base_name"
+ # run the test
+
+ puts "Running $base_name..."
+
+ set result ""
+ set oops [catch { set result [exec "../anyagent" "stdio" "anyagent" "<$src" ">$tmpout_name" "2>$tmperr_name"] } catched]
+
+ if {$oops != 0} {
+ fail "y2anyagent failed: $catched"
+ return
+ }
+
+ # check return code from y2anyagent
+
+ if {$result != ""} {
+ warning "Compilation of $base_name results in '$result'"
+ return
+ }
+
+ # check stdout
+
+ if {[diff $stdout_name $tmpout_name] != 1} {
+ fail "Wrong stdout for $base_name"
+ return
+ }
+
+ # check stderr
+# D I S A B L E D
+# if {[diff $stderr_name $tmperr_name] != 1} {
+# fail "Wrong stderr for $base_name"
+# return
+# }
+#
+ # ok, all is fine
+
+ pass $base_name
+
+ return
+}
Added: branches/SuSE-Code-11-SP2-Branch/storage/storage/src/testsuite/tests/empty-efi1.err
URL: http://svn.opensuse.org/viewcvs/yast/branches/SuSE-Code-11-SP2-Branch/stora…
==============================================================================
(empty)
Added: branches/SuSE-Code-11-SP2-Branch/storage/storage/src/testsuite/tests/empty-efi1.out
URL: http://svn.opensuse.org/viewcvs/yast/branches/SuSE-Code-11-SP2-Branch/stora…
==============================================================================
--- branches/SuSE-Code-11-SP2-Branch/storage/storage/src/testsuite/tests/empty-efi1.out (added)
+++ branches/SuSE-Code-11-SP2-Branch/storage/storage/src/testsuite/tests/empty-efi1.out Tue May 17 13:39:44 2011
@@ -0,0 +1,4 @@
+Dump Proposal:
+Dump Create boot volume /dev/sda1 (156.88 MB) with vfat
+Dump Create swap volume /dev/sda2 (517.72 MB)
+Dump Create root volume /dev/sda3 (297.43 GB) with ext4
Added: branches/SuSE-Code-11-SP2-Branch/storage/storage/src/testsuite/tests/empty-efi1.ycp
URL: http://svn.opensuse.org/viewcvs/yast/branches/SuSE-Code-11-SP2-Branch/stora…
==============================================================================
--- branches/SuSE-Code-11-SP2-Branch/storage/storage/src/testsuite/tests/empty-efi1.ycp (added)
+++ branches/SuSE-Code-11-SP2-Branch/storage/storage/src/testsuite/tests/empty-efi1.ycp Tue May 17 13:39:44 2011
@@ -0,0 +1,17 @@
+// testedfiles: helper1b.yh
+{
+ include "./tests/setup-system.yh";
+
+ setup_system("empty-efi");
+
+ include "./tests/helper1a.yh";
+
+ import "ProductFeatures";
+
+ ProductFeatures::SetBooleanFeature("partitioning", "try_separate_home", false);
+ ProductFeatures::SetBooleanFeature("partitioning", "proposal_lvm", false);
+ ProductFeatures::SetStringFeature("partitioning", "vm_desired_size", "30 GB");
+ ProductFeatures::SetStringFeature("partitioning", "root_base_size", "20 GB");
+
+ include "./tests/helper1b.yh";
+}
Added: branches/SuSE-Code-11-SP2-Branch/storage/storage/src/testsuite/tests/empty-efi2.err
URL: http://svn.opensuse.org/viewcvs/yast/branches/SuSE-Code-11-SP2-Branch/stora…
==============================================================================
(empty)
Added: branches/SuSE-Code-11-SP2-Branch/storage/storage/src/testsuite/tests/empty-efi2.out
URL: http://svn.opensuse.org/viewcvs/yast/branches/SuSE-Code-11-SP2-Branch/stora…
==============================================================================
--- branches/SuSE-Code-11-SP2-Branch/storage/storage/src/testsuite/tests/empty-efi2.out (added)
+++ branches/SuSE-Code-11-SP2-Branch/storage/storage/src/testsuite/tests/empty-efi2.out Tue May 17 13:39:44 2011
@@ -0,0 +1,5 @@
+Dump Proposal:
+Dump Create boot volume /dev/sda1 (156.88 MB) with vfat
+Dump Create swap volume /dev/sda2 (2.01 GB)
+Dump Create root volume /dev/sda3 (20.00 GB) with ext4
+Dump Create volume /dev/sda4 (275.93 GB) for /home with ext4
Added: branches/SuSE-Code-11-SP2-Branch/storage/storage/src/testsuite/tests/empty-efi2.ycp
URL: http://svn.opensuse.org/viewcvs/yast/branches/SuSE-Code-11-SP2-Branch/stora…
==============================================================================
--- branches/SuSE-Code-11-SP2-Branch/storage/storage/src/testsuite/tests/empty-efi2.ycp (added)
+++ branches/SuSE-Code-11-SP2-Branch/storage/storage/src/testsuite/tests/empty-efi2.ycp Tue May 17 13:39:44 2011
@@ -0,0 +1,17 @@
+// testedfiles: helper1b.yh
+{
+ include "./tests/setup-system.yh";
+
+ setup_system("empty-efi");
+
+ include "./tests/helper1a.yh";
+
+ import "ProductFeatures";
+
+ ProductFeatures::SetBooleanFeature("partitioning", "try_separate_home", true);
+ ProductFeatures::SetBooleanFeature("partitioning", "proposal_lvm", false);
+ ProductFeatures::SetStringFeature("partitioning", "vm_desired_size", "30 GB");
+ ProductFeatures::SetStringFeature("partitioning", "root_base_size", "20 GB");
+
+ include "./tests/helper1b.yh";
+}
Added: branches/SuSE-Code-11-SP2-Branch/storage/storage/src/testsuite/tests/empty1.err
URL: http://svn.opensuse.org/viewcvs/yast/branches/SuSE-Code-11-SP2-Branch/stora…
==============================================================================
(empty)
Added: branches/SuSE-Code-11-SP2-Branch/storage/storage/src/testsuite/tests/empty1.out
URL: http://svn.opensuse.org/viewcvs/yast/branches/SuSE-Code-11-SP2-Branch/stora…
==============================================================================
--- branches/SuSE-Code-11-SP2-Branch/storage/storage/src/testsuite/tests/empty1.out (added)
+++ branches/SuSE-Code-11-SP2-Branch/storage/storage/src/testsuite/tests/empty1.out Tue May 17 13:39:44 2011
@@ -0,0 +1,3 @@
+Dump Proposal:
+Dump Create swap volume /dev/sda1 (517.72 MB)
+Dump Create root volume /dev/sda2 (297.58 GB) with ext4
Added: branches/SuSE-Code-11-SP2-Branch/storage/storage/src/testsuite/tests/empty1.ycp
URL: http://svn.opensuse.org/viewcvs/yast/branches/SuSE-Code-11-SP2-Branch/stora…
==============================================================================
--- branches/SuSE-Code-11-SP2-Branch/storage/storage/src/testsuite/tests/empty1.ycp (added)
+++ branches/SuSE-Code-11-SP2-Branch/storage/storage/src/testsuite/tests/empty1.ycp Tue May 17 13:39:44 2011
@@ -0,0 +1,17 @@
+// testedfiles: helper1b.yh
+{
+ include "./tests/setup-system.yh";
+
+ setup_system("empty");
+
+ include "./tests/helper1a.yh";
+
+ import "ProductFeatures";
+
+ ProductFeatures::SetBooleanFeature("partitioning", "try_separate_home", false);
+ ProductFeatures::SetBooleanFeature("partitioning", "proposal_lvm", false);
+ ProductFeatures::SetStringFeature("partitioning", "vm_desired_size", "30 GB");
+ ProductFeatures::SetStringFeature("partitioning", "root_base_size", "20 GB");
+
+ include "./tests/helper1b.yh";
+}
Added: branches/SuSE-Code-11-SP2-Branch/storage/storage/src/testsuite/tests/empty2.err
URL: http://svn.opensuse.org/viewcvs/yast/branches/SuSE-Code-11-SP2-Branch/stora…
==============================================================================
(empty)
Added: branches/SuSE-Code-11-SP2-Branch/storage/storage/src/testsuite/tests/empty2.out
URL: http://svn.opensuse.org/viewcvs/yast/branches/SuSE-Code-11-SP2-Branch/stora…
==============================================================================
--- branches/SuSE-Code-11-SP2-Branch/storage/storage/src/testsuite/tests/empty2.out (added)
+++ branches/SuSE-Code-11-SP2-Branch/storage/storage/src/testsuite/tests/empty2.out Tue May 17 13:39:44 2011
@@ -0,0 +1,4 @@
+Dump Proposal:
+Dump Create swap volume /dev/sda1 (2.01 GB)
+Dump Create root volume /dev/sda2 (20.00 GB) with ext4
+Dump Create volume /dev/sda3 (276.08 GB) for /home with ext4
Added: branches/SuSE-Code-11-SP2-Branch/storage/storage/src/testsuite/tests/empty2.ycp
URL: http://svn.opensuse.org/viewcvs/yast/branches/SuSE-Code-11-SP2-Branch/stora…
==============================================================================
--- branches/SuSE-Code-11-SP2-Branch/storage/storage/src/testsuite/tests/empty2.ycp (added)
+++ branches/SuSE-Code-11-SP2-Branch/storage/storage/src/testsuite/tests/empty2.ycp Tue May 17 13:39:44 2011
@@ -0,0 +1,17 @@
+// testedfiles: helper1b.yh
+{
+ include "./tests/setup-system.yh";
+
+ setup_system("empty");
+
+ include "./tests/helper1a.yh";
+
+ import "ProductFeatures";
+
+ ProductFeatures::SetBooleanFeature("partitioning", "try_separate_home", true);
+ ProductFeatures::SetBooleanFeature("partitioning", "proposal_lvm", false);
+ ProductFeatures::SetStringFeature("partitioning", "vm_desired_size", "30 GB");
+ ProductFeatures::SetStringFeature("partitioning", "root_base_size", "20 GB");
+
+ include "./tests/helper1b.yh";
+}
Added: branches/SuSE-Code-11-SP2-Branch/storage/storage/src/testsuite/tests/empty3.err
URL: http://svn.opensuse.org/viewcvs/yast/branches/SuSE-Code-11-SP2-Branch/stora…
==============================================================================
(empty)
Added: branches/SuSE-Code-11-SP2-Branch/storage/storage/src/testsuite/tests/empty3.out
URL: http://svn.opensuse.org/viewcvs/yast/branches/SuSE-Code-11-SP2-Branch/stora…
==============================================================================
--- branches/SuSE-Code-11-SP2-Branch/storage/storage/src/testsuite/tests/empty3.out (added)
+++ branches/SuSE-Code-11-SP2-Branch/storage/storage/src/testsuite/tests/empty3.out Tue May 17 13:39:44 2011
@@ -0,0 +1,6 @@
+Dump Proposal:
+Dump Create boot volume /dev/sda1 (156.88 MB) with ext4
+Dump Create volume /dev/sda2 (29.98 GB)
+Dump Create volume group system (29.98 GB) from /dev/sda2 [destructive]
+Dump Create logical volume /dev/system/root (10.00 GB) for / with ext4
+Dump Create swap logical volume /dev/system/swap (512.00 MB)
Added: branches/SuSE-Code-11-SP2-Branch/storage/storage/src/testsuite/tests/empty3.ycp
URL: http://svn.opensuse.org/viewcvs/yast/branches/SuSE-Code-11-SP2-Branch/stora…
==============================================================================
--- branches/SuSE-Code-11-SP2-Branch/storage/storage/src/testsuite/tests/empty3.ycp (added)
+++ branches/SuSE-Code-11-SP2-Branch/storage/storage/src/testsuite/tests/empty3.ycp Tue May 17 13:39:44 2011
@@ -0,0 +1,18 @@
+// testedfiles: helper1b.yh
+{
+ include "./tests/setup-system.yh";
+
+ setup_system("empty");
+
+ include "./tests/helper1a.yh";
+
+ import "ProductFeatures";
+
+ ProductFeatures::SetBooleanFeature("partitioning", "try_separate_home", false);
+ ProductFeatures::SetBooleanFeature("partitioning", "proposal_lvm", true);
+ ProductFeatures::SetBooleanFeature("partitioning", "vm_keep_unpartitioned_region", true);
+ ProductFeatures::SetStringFeature("partitioning", "vm_desired_size", "30 GB");
+ ProductFeatures::SetStringFeature("partitioning", "root_base_size", "20 GB");
+
+ include "./tests/helper1b.yh";
+}
Added: branches/SuSE-Code-11-SP2-Branch/storage/storage/src/testsuite/tests/empty4.err
URL: http://svn.opensuse.org/viewcvs/yast/branches/SuSE-Code-11-SP2-Branch/stora…
==============================================================================
(empty)
Added: branches/SuSE-Code-11-SP2-Branch/storage/storage/src/testsuite/tests/empty4.out
URL: http://svn.opensuse.org/viewcvs/yast/branches/SuSE-Code-11-SP2-Branch/stora…
==============================================================================
--- branches/SuSE-Code-11-SP2-Branch/storage/storage/src/testsuite/tests/empty4.out (added)
+++ branches/SuSE-Code-11-SP2-Branch/storage/storage/src/testsuite/tests/empty4.out Tue May 17 13:39:44 2011
@@ -0,0 +1,7 @@
+Dump Proposal:
+Dump Create boot volume /dev/sda1 (156.88 MB) with ext4
+Dump Create volume /dev/sda2 (29.98 GB)
+Dump Create volume group system (29.98 GB) from /dev/sda2 [destructive]
+Dump Create logical volume /dev/system/home (19.48 GB) for /home with ext4
+Dump Create logical volume /dev/system/root (10.00 GB) for / with ext4
+Dump Create swap logical volume /dev/system/swap (512.00 MB)
Added: branches/SuSE-Code-11-SP2-Branch/storage/storage/src/testsuite/tests/empty4.ycp
URL: http://svn.opensuse.org/viewcvs/yast/branches/SuSE-Code-11-SP2-Branch/stora…
==============================================================================
--- branches/SuSE-Code-11-SP2-Branch/storage/storage/src/testsuite/tests/empty4.ycp (added)
+++ branches/SuSE-Code-11-SP2-Branch/storage/storage/src/testsuite/tests/empty4.ycp Tue May 17 13:39:44 2011
@@ -0,0 +1,18 @@
+// testedfiles: helper1b.yh
+{
+ include "./tests/setup-system.yh";
+
+ setup_system("empty");
+
+ include "./tests/helper1a.yh";
+
+ import "ProductFeatures";
+
+ ProductFeatures::SetBooleanFeature("partitioning", "try_separate_home", true);
+ ProductFeatures::SetBooleanFeature("partitioning", "proposal_lvm", true);
+ ProductFeatures::SetBooleanFeature("partitioning", "vm_keep_unpartitioned_region", true);
+ ProductFeatures::SetStringFeature("partitioning", "vm_desired_size", "30 GB");
+ ProductFeatures::SetStringFeature("partitioning", "root_base_size", "20 GB");
+
+ include "./tests/helper1b.yh";
+}
Added: branches/SuSE-Code-11-SP2-Branch/storage/storage/src/testsuite/tests/empty5.err
URL: http://svn.opensuse.org/viewcvs/yast/branches/SuSE-Code-11-SP2-Branch/stora…
==============================================================================
(empty)
Added: branches/SuSE-Code-11-SP2-Branch/storage/storage/src/testsuite/tests/empty5.out
URL: http://svn.opensuse.org/viewcvs/yast/branches/SuSE-Code-11-SP2-Branch/stora…
==============================================================================
--- branches/SuSE-Code-11-SP2-Branch/storage/storage/src/testsuite/tests/empty5.out (added)
+++ branches/SuSE-Code-11-SP2-Branch/storage/storage/src/testsuite/tests/empty5.out Tue May 17 13:39:44 2011
@@ -0,0 +1,6 @@
+Dump Proposal:
+Dump Create boot volume /dev/sda1 (156.88 MB) with ext4
+Dump Create volume /dev/sda2 (297.94 GB)
+Dump Create volume group system (297.93 GB) from /dev/sda2 [destructive]
+Dump Create logical volume /dev/system/root (10.00 GB) for / with ext4
+Dump Create swap logical volume /dev/system/swap (768.00 MB)
Added: branches/SuSE-Code-11-SP2-Branch/storage/storage/src/testsuite/tests/empty5.ycp
URL: http://svn.opensuse.org/viewcvs/yast/branches/SuSE-Code-11-SP2-Branch/stora…
==============================================================================
--- branches/SuSE-Code-11-SP2-Branch/storage/storage/src/testsuite/tests/empty5.ycp (added)
+++ branches/SuSE-Code-11-SP2-Branch/storage/storage/src/testsuite/tests/empty5.ycp Tue May 17 13:39:44 2011
@@ -0,0 +1,17 @@
+// testedfiles: helper1b.yh
+{
+ include "./tests/setup-system.yh";
+
+ setup_system("empty");
+
+ include "./tests/helper1a.yh";
+
+ import "ProductFeatures";
+
+ ProductFeatures::SetBooleanFeature("partitioning", "try_separate_home", false);
+ ProductFeatures::SetBooleanFeature("partitioning", "proposal_lvm", true);
+ ProductFeatures::SetStringFeature("partitioning", "vm_desired_size", "30 GB");
+ ProductFeatures::SetStringFeature("partitioning", "root_base_size", "20 GB");
+
+ include "./tests/helper1b.yh";
+}
Added: branches/SuSE-Code-11-SP2-Branch/storage/storage/src/testsuite/tests/empty6.err
URL: http://svn.opensuse.org/viewcvs/yast/branches/SuSE-Code-11-SP2-Branch/stora…
==============================================================================
(empty)
Added: branches/SuSE-Code-11-SP2-Branch/storage/storage/src/testsuite/tests/empty6.out
URL: http://svn.opensuse.org/viewcvs/yast/branches/SuSE-Code-11-SP2-Branch/stora…
==============================================================================
--- branches/SuSE-Code-11-SP2-Branch/storage/storage/src/testsuite/tests/empty6.out (added)
+++ branches/SuSE-Code-11-SP2-Branch/storage/storage/src/testsuite/tests/empty6.out Tue May 17 13:39:44 2011
@@ -0,0 +1,7 @@
+Dump Proposal:
+Dump Create boot volume /dev/sda1 (156.88 MB) with ext4
+Dump Create volume /dev/sda2 (297.94 GB)
+Dump Create volume group system (297.93 GB) from /dev/sda2 [destructive]
+Dump Create logical volume /dev/system/home (25.00 GB) for /home with ext4
+Dump Create logical volume /dev/system/root (10.00 GB) for / with ext4
+Dump Create swap logical volume /dev/system/swap (768.00 MB)
Added: branches/SuSE-Code-11-SP2-Branch/storage/storage/src/testsuite/tests/empty6.ycp
URL: http://svn.opensuse.org/viewcvs/yast/branches/SuSE-Code-11-SP2-Branch/stora…
==============================================================================
--- branches/SuSE-Code-11-SP2-Branch/storage/storage/src/testsuite/tests/empty6.ycp (added)
+++ branches/SuSE-Code-11-SP2-Branch/storage/storage/src/testsuite/tests/empty6.ycp Tue May 17 13:39:44 2011
@@ -0,0 +1,17 @@
+// testedfiles: helper1b.yh
+{
+ include "./tests/setup-system.yh";
+
+ setup_system("empty");
+
+ include "./tests/helper1a.yh";
+
+ import "ProductFeatures";
+
+ ProductFeatures::SetBooleanFeature("partitioning", "try_separate_home", true);
+ ProductFeatures::SetBooleanFeature("partitioning", "proposal_lvm", true);
+ ProductFeatures::SetStringFeature("partitioning", "vm_desired_size", "30 GB");
+ ProductFeatures::SetStringFeature("partitioning", "root_base_size", "20 GB");
+
+ include "./tests/helper1b.yh";
+}
Added: branches/SuSE-Code-11-SP2-Branch/storage/storage/src/testsuite/tests/half-empty1.err
URL: http://svn.opensuse.org/viewcvs/yast/branches/SuSE-Code-11-SP2-Branch/stora…
==============================================================================
(empty)
Added: branches/SuSE-Code-11-SP2-Branch/storage/storage/src/testsuite/tests/half-empty1.out
URL: http://svn.opensuse.org/viewcvs/yast/branches/SuSE-Code-11-SP2-Branch/stora…
==============================================================================
--- branches/SuSE-Code-11-SP2-Branch/storage/storage/src/testsuite/tests/half-empty1.out (added)
+++ branches/SuSE-Code-11-SP2-Branch/storage/storage/src/testsuite/tests/half-empty1.out Tue May 17 13:39:44 2011
@@ -0,0 +1,5 @@
+Dump Proposal:
+Dump Create extended partition /dev/sda3 (147.09 GB)
+Dump Create swap volume /dev/sda5 (2.01 GB)
+Dump Create root volume /dev/sda6 (20.00 GB) with ext4
+Dump Create volume /dev/sda7 (125.08 GB) for /home with ext4
Added: branches/SuSE-Code-11-SP2-Branch/storage/storage/src/testsuite/tests/half-empty1.ycp
URL: http://svn.opensuse.org/viewcvs/yast/branches/SuSE-Code-11-SP2-Branch/stora…
==============================================================================
--- branches/SuSE-Code-11-SP2-Branch/storage/storage/src/testsuite/tests/half-empty1.ycp (added)
+++ branches/SuSE-Code-11-SP2-Branch/storage/storage/src/testsuite/tests/half-empty1.ycp Tue May 17 13:39:44 2011
@@ -0,0 +1,16 @@
+// testedfiles: helper1b.yh
+{
+ include "./tests/setup-system.yh";
+
+ setup_system("half-empty");
+
+ include "./tests/helper1a.yh";
+
+ import "ProductFeatures";
+
+ ProductFeatures::SetBooleanFeature("partitioning", "try_separate_home", true);
+ ProductFeatures::SetBooleanFeature("partitioning", "proposal_lvm", false);
+ ProductFeatures::SetStringFeature("partitioning", "root_base_size", "20 GB");
+
+ include "./tests/helper1b.yh";
+}
Added: branches/SuSE-Code-11-SP2-Branch/storage/storage/src/testsuite/tests/helper1a.yh
URL: http://svn.opensuse.org/viewcvs/yast/branches/SuSE-Code-11-SP2-Branch/stora…
==============================================================================
--- branches/SuSE-Code-11-SP2-Branch/storage/storage/src/testsuite/tests/helper1a.yh (added)
+++ branches/SuSE-Code-11-SP2-Branch/storage/storage/src/testsuite/tests/helper1a.yh Tue May 17 13:39:44 2011
@@ -0,0 +1,39 @@
+{
+ import "Testsuite";
+
+ map READ = $[
+ "probe" : $[
+ "architecture" : "i386",
+ "bios" : [ $[ "lba_support" : true ] ],
+ "cdrom" : []
+ ],
+ "proc" : $[
+ "swaps" : [],
+ "meminfo" : $[ "memtotal" : 256 * 1024 ]
+ ],
+ "sysconfig" : $[
+ "storage" : $[
+ "DEFAULT_FS" : "ext4"
+ ],
+ "bootloader" : $[
+ "LOADER_TYPE" : "grub"
+ ],
+ "language" : $[
+ "RC_LANG" : "en_US.UTF-8",
+ "RC_LC_MESSAGES" : "",
+ ],
+ ],
+ "target" : $[
+ "size" : 0,
+ "bash_output" : $[],
+ "yast2" : $[],
+ "dir" : [],
+ ],
+ ];
+
+ Testsuite::Init([READ, $[], READ], nil);
+
+ import "Stage";
+
+ Stage::Set("initial");
+}
Added: branches/SuSE-Code-11-SP2-Branch/storage/storage/src/testsuite/tests/helper1b.yh
URL: http://svn.opensuse.org/viewcvs/yast/branches/SuSE-Code-11-SP2-Branch/stora…
==============================================================================
--- branches/SuSE-Code-11-SP2-Branch/storage/storage/src/testsuite/tests/helper1b.yh (added)
+++ branches/SuSE-Code-11-SP2-Branch/storage/storage/src/testsuite/tests/helper1b.yh Tue May 17 13:39:44 2011
@@ -0,0 +1,32 @@
+{
+ import "Storage";
+ import "StorageProposal";
+
+ Storage::InitLibstorage(false);
+
+ StorageProposal::GetControlCfg();
+
+ map<string, map> target_map = Storage::GetTargetMap();
+ map<string, any> prop = StorageProposal::get_inst_prop(target_map);
+
+ if (prop["ok"]:false)
+ {
+ Storage::SetTargetMap(prop["target"]:$[]);
+
+ list<map> infos = Storage::GetCommitInfos();
+
+ Testsuite::Dump("Proposal:");
+ foreach(map info, infos, {
+ string text = info[`text]:"";
+ if (info[`destructive]:false)
+ text = text + " [destructive]";
+ Testsuite::Dump(text);
+ });
+ }
+ else
+ {
+ Testsuite::Dump("No proposal.");
+ }
+
+ Storage::FinishLibstorage();
+}
Added: branches/SuSE-Code-11-SP2-Branch/storage/storage/src/testsuite/tests/reuse-home1.err
URL: http://svn.opensuse.org/viewcvs/yast/branches/SuSE-Code-11-SP2-Branch/stora…
==============================================================================
(empty)
Added: branches/SuSE-Code-11-SP2-Branch/storage/storage/src/testsuite/tests/reuse-home1.out
URL: http://svn.opensuse.org/viewcvs/yast/branches/SuSE-Code-11-SP2-Branch/stora…
==============================================================================
--- branches/SuSE-Code-11-SP2-Branch/storage/storage/src/testsuite/tests/reuse-home1.out (added)
+++ branches/SuSE-Code-11-SP2-Branch/storage/storage/src/testsuite/tests/reuse-home1.out Tue May 17 13:39:44 2011
@@ -0,0 +1,4 @@
+Dump Proposal:
+Dump Format partition /dev/sda2 (15.01 GB) for / with ext4 [destructive]
+Dump Use /dev/sda1 as swap
+Dump Set mount point of /dev/sda3 to /home
Added: branches/SuSE-Code-11-SP2-Branch/storage/storage/src/testsuite/tests/reuse-home1.ycp
URL: http://svn.opensuse.org/viewcvs/yast/branches/SuSE-Code-11-SP2-Branch/stora…
==============================================================================
--- branches/SuSE-Code-11-SP2-Branch/storage/storage/src/testsuite/tests/reuse-home1.ycp (added)
+++ branches/SuSE-Code-11-SP2-Branch/storage/storage/src/testsuite/tests/reuse-home1.ycp Tue May 17 13:39:44 2011
@@ -0,0 +1,17 @@
+// testedfiles: helper1b.yh
+{
+ include "./tests/setup-system.yh";
+
+ setup_system("reuse-home");
+
+ include "./tests/helper1a.yh";
+
+ import "ProductFeatures";
+
+ ProductFeatures::SetBooleanFeature("partitioning", "try_separate_home", true);
+ ProductFeatures::SetBooleanFeature("partitioning", "proposal_lvm", false);
+ ProductFeatures::SetStringFeature("partitioning", "root_max_size", "20 GB");
+ ProductFeatures::SetStringFeature("partitioning", "root_base_size", "15 GB");
+
+ include "./tests/helper1b.yh";
+}
Added: branches/SuSE-Code-11-SP2-Branch/storage/storage/src/testsuite/tests/setup-system.yh
URL: http://svn.opensuse.org/viewcvs/yast/branches/SuSE-Code-11-SP2-Branch/stora…
==============================================================================
--- branches/SuSE-Code-11-SP2-Branch/storage/storage/src/testsuite/tests/setup-system.yh (added)
+++ branches/SuSE-Code-11-SP2-Branch/storage/storage/src/testsuite/tests/setup-system.yh Tue May 17 13:39:44 2011
@@ -0,0 +1,9 @@
+{
+ void setup_system(string name)
+ {
+ SCR::Execute(.target.bash, "mkdir -p tmp");
+ SCR::Execute(.target.bash, "rm -rf tmp/*");
+
+ SCR::Execute(.target.bash, sformat("cp data/%1/*.info tmp", name));
+ }
+}
Added: branches/SuSE-Code-11-SP2-Branch/storage/storage/src/testsuite/tests/windows-only1.err
URL: http://svn.opensuse.org/viewcvs/yast/branches/SuSE-Code-11-SP2-Branch/stora…
==============================================================================
(empty)
Added: branches/SuSE-Code-11-SP2-Branch/storage/storage/src/testsuite/tests/windows-only1.out
URL: http://svn.opensuse.org/viewcvs/yast/branches/SuSE-Code-11-SP2-Branch/stora…
==============================================================================
--- branches/SuSE-Code-11-SP2-Branch/storage/storage/src/testsuite/tests/windows-only1.out (added)
+++ branches/SuSE-Code-11-SP2-Branch/storage/storage/src/testsuite/tests/windows-only1.out Tue May 17 13:39:44 2011
@@ -0,0 +1,6 @@
+Dump Proposal:
+Dump Shrink Windows partition /dev/sda1 to 33.21 GB [destructive]
+Dump Create extended partition /dev/sda2 (41.32 GB)
+Dump Create swap volume /dev/sda5 (517.72 MB)
+Dump Create root volume /dev/sda6 (16.50 GB) with ext4
+Dump Create volume /dev/sda7 (24.31 GB) for /home with ext4
Added: branches/SuSE-Code-11-SP2-Branch/storage/storage/src/testsuite/tests/windows-only1.ycp
URL: http://svn.opensuse.org/viewcvs/yast/branches/SuSE-Code-11-SP2-Branch/stora…
==============================================================================
--- branches/SuSE-Code-11-SP2-Branch/storage/storage/src/testsuite/tests/windows-only1.ycp (added)
+++ branches/SuSE-Code-11-SP2-Branch/storage/storage/src/testsuite/tests/windows-only1.ycp Tue May 17 13:39:44 2011
@@ -0,0 +1,17 @@
+// testedfiles: helper1b.yh
+{
+ include "./tests/setup-system.yh";
+
+ setup_system("windows-only");
+
+ include "./tests/helper1a.yh";
+
+ import "ProductFeatures";
+
+ ProductFeatures::SetBooleanFeature("partitioning", "try_separate_home", true);
+ ProductFeatures::SetBooleanFeature("partitioning", "proposal_lvm", false);
+ ProductFeatures::SetStringFeature("partitioning", "root_max_size", "20 GB");
+ ProductFeatures::SetStringFeature("partitioning", "root_base_size", "15 GB");
+
+ include "./tests/helper1b.yh";
+}
Added: branches/SuSE-Code-11-SP2-Branch/storage/storage/src/testsuite/tests/windows1.err
URL: http://svn.opensuse.org/viewcvs/yast/branches/SuSE-Code-11-SP2-Branch/stora…
==============================================================================
(empty)
Added: branches/SuSE-Code-11-SP2-Branch/storage/storage/src/testsuite/tests/windows1.out
URL: http://svn.opensuse.org/viewcvs/yast/branches/SuSE-Code-11-SP2-Branch/stora…
==============================================================================
--- branches/SuSE-Code-11-SP2-Branch/storage/storage/src/testsuite/tests/windows1.out (added)
+++ branches/SuSE-Code-11-SP2-Branch/storage/storage/src/testsuite/tests/windows1.out Tue May 17 13:39:44 2011
@@ -0,0 +1,6 @@
+Dump Proposal:
+Dump Create extended partition /dev/sda2 (34.52 GB)
+Dump Create swap volume /dev/sda5 (517.72 MB)
+Dump Create root volume /dev/sda6 (15.01 GB) with ext4
+Dump Create volume /dev/sda7 (19.01 GB) for /home with ext4
+Dump Set mount point of /dev/sda1 to /windows/C
Added: branches/SuSE-Code-11-SP2-Branch/storage/storage/src/testsuite/tests/windows1.ycp
URL: http://svn.opensuse.org/viewcvs/yast/branches/SuSE-Code-11-SP2-Branch/stora…
==============================================================================
--- branches/SuSE-Code-11-SP2-Branch/storage/storage/src/testsuite/tests/windows1.ycp (added)
+++ branches/SuSE-Code-11-SP2-Branch/storage/storage/src/testsuite/tests/windows1.ycp Tue May 17 13:39:44 2011
@@ -0,0 +1,17 @@
+// testedfiles: helper1b.yh
+{
+ include "./tests/setup-system.yh";
+
+ setup_system("windows");
+
+ include "./tests/helper1a.yh";
+
+ import "ProductFeatures";
+
+ ProductFeatures::SetBooleanFeature("partitioning", "try_separate_home", true);
+ ProductFeatures::SetBooleanFeature("partitioning", "proposal_lvm", false);
+ ProductFeatures::SetStringFeature("partitioning", "root_max_size", "20 GB");
+ ProductFeatures::SetStringFeature("partitioning", "root_base_size", "15 GB");
+
+ include "./tests/helper1b.yh";
+}
Modified: branches/SuSE-Code-11-SP2-Branch/storage/yast2-storage.spec.in
URL: http://svn.opensuse.org/viewcvs/yast/branches/SuSE-Code-11-SP2-Branch/stora…
==============================================================================
--- branches/SuSE-Code-11-SP2-Branch/storage/yast2-storage.spec.in (original)
+++ branches/SuSE-Code-11-SP2-Branch/storage/yast2-storage.spec.in Tue May 17 13:39:44 2011
@@ -2,11 +2,12 @@
@HEADER@
-BuildRequires: blocxx-devel boost-devel gcc-c++ libxcrypt-devel openssl-devel sablot swig docbook-xsl-stylesheets doxygen libxslt perl-XML-Writer sgml-skel update-desktop-files yast2 yast2-core-devel yast2-devtools yast2-testsuite yast2-perl-bindings
+BuildRequires: blocxx-devel boost-devel gcc-c++ libxcrypt-devel openssl-devel sablot swig docbook-xsl-stylesheets doxygen libxslt perl-XML-Writer sgml-skel update-desktop-files yast2 yast2-core-devel yast2-devtools yast2-testsuite yast2-perl-bindings libxml2-devel
Requires: yast2-storage-lib = %version yast2-perl-bindings mdadm lvm2 dmraid multipath-tools
Requires: kpartx cryptsetup util-linux >= 2.16
-Requires: yast2-core >= 2.17.28
-Requires: yast2 >= 2.17.45
+Requires: yast2-testsuite >= 2.17.0
+Requires: yast2-core >= 2.17.38
+Requires: yast2 >= 2.17.94
Requires: yast2-libyui >= 2.17.5
Requires: yast2-dbus-client
Requires: parted >= 2.2
@@ -54,9 +55,9 @@
@yncludedir@/partitioning/*.ycp
@clientdir@/inst_custom_part.ycp
@clientdir@/inst_resize_ui.ycp
+@clientdir@/inst_resize_dialog.ycp
@clientdir@/inst_disk.ycp
@clientdir@/inst_target_part.ycp
-@clientdir@/inst_do_resize.ycp
@clientdir@/inst_disk_proposal.ycp
@clientdir@/inst_target_selection.ycp
@clientdir@/inst_prepdisk.ycp
--
To unsubscribe, e-mail: yast-commit+unsubscribe(a)opensuse.org
For additional commands, e-mail: yast-commit+help(a)opensuse.org
1
0