Hello community, here is the log from the commit of package libstorage for openSUSE:Factory checked in at Fri Jun 10 09:29:47 CEST 2011.
-------- --- libstorage/libstorage.changes 2011-05-30 11:41:32.000000000 +0200 +++ /mounts/work_src_done/STABLE/libstorage/libstorage.changes 2011-06-09 15:56:25.000000000 +0200 @@ -1,0 +2,7 @@ +Thu Jun 9 14:56:02 CEST 2011 - f...@suse.de + +- add functionality to have everything in a default btrfs subvol + (additions to fate#306587) +- version 2.21.3 + +------------------------------------------------------------------- calling whatdependson for head-i586 Old: ---- libstorage-2.21.2.tar.bz2 New: ---- libstorage-2.21.3.tar.bz2 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Other differences: ------------------ ++++++ libstorage.spec ++++++ --- /var/tmp/diff_new_pack.Hbjzvt/_old 2011-06-10 09:29:20.000000000 +0200 +++ /var/tmp/diff_new_pack.Hbjzvt/_new 2011-06-10 09:29:20.000000000 +0200 @@ -19,8 +19,8 @@ Name: libstorage -Version: 2.21.2 -Release: 2 +Version: 2.21.3 +Release: 1 License: GPL Group: System/Libraries BuildRoot: %{_tmppath}/%{name}-%{version}-build ++++++ libstorage-2.21.2.tar.bz2 -> libstorage-2.21.3.tar.bz2 ++++++ diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/libstorage-2.21.2/VERSION new/libstorage-2.21.3/VERSION --- old/libstorage-2.21.2/VERSION 2011-05-26 11:52:50.000000000 +0200 +++ new/libstorage-2.21.3/VERSION 2011-06-09 15:04:27.000000000 +0200 @@ -1 +1 @@ -2.21.2 +2.21.3 diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/libstorage-2.21.2/bindings/python/libstorage.py new/libstorage-2.21.3/bindings/python/libstorage.py --- old/libstorage-2.21.2/bindings/python/libstorage.py 2011-04-27 10:07:44.000000000 +0200 +++ new/libstorage-2.21.3/bindings/python/libstorage.py 2011-06-09 15:35:39.000000000 +0200 @@ -1330,6 +1330,11 @@ VOLUME_REMOUNT_FAILED = _libstorage.VOLUME_REMOUNT_FAILED VOLUME_TUNEREISERFS_FAILED = _libstorage.VOLUME_TUNEREISERFS_FAILED VOLUME_UMOUNT_NOT_MOUNTED = _libstorage.VOLUME_UMOUNT_NOT_MOUNTED +VOLUME_BTRFS_ADD_FAILED = _libstorage.VOLUME_BTRFS_ADD_FAILED +VOLUME_CANNOT_TMP_MOUNT = _libstorage.VOLUME_CANNOT_TMP_MOUNT +VOLUME_CANNOT_TMP_UMOUNT = _libstorage.VOLUME_CANNOT_TMP_UMOUNT +VOLUME_BTRFS_SUBVOL_INIT_FAILED = _libstorage.VOLUME_BTRFS_SUBVOL_INIT_FAILED +VOLUME_BTRFS_SUBVOL_DETDEFAULT = _libstorage.VOLUME_BTRFS_SUBVOL_DETDEFAULT LVM_CREATE_PV_FAILED = _libstorage.LVM_CREATE_PV_FAILED LVM_PV_ALREADY_CONTAINED = _libstorage.LVM_PV_ALREADY_CONTAINED LVM_PV_DEVICE_UNKNOWN = _libstorage.LVM_PV_DEVICE_UNKNOWN @@ -1563,6 +1568,8 @@ def getDefaultMountBy(self): return _libstorage.StorageInterface_getDefaultMountBy(self) def setDefaultFs(self, *args): return _libstorage.StorageInterface_setDefaultFs(self, *args) def getDefaultFs(self): return _libstorage.StorageInterface_getDefaultFs(self) + def setDefaultSubvolName(self, *args): return _libstorage.StorageInterface_setDefaultSubvolName(self, *args) + def getDefaultSubvolName(self): return _libstorage.StorageInterface_getDefaultSubvolName(self) def getEfiBoot(self): return _libstorage.StorageInterface_getEfiBoot(self) def setRootPrefix(self, *args): return _libstorage.StorageInterface_setRootPrefix(self, *args) def getRootPrefix(self): return _libstorage.StorageInterface_getRootPrefix(self) diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/libstorage-2.21.2/storage/Btrfs.cc new/libstorage-2.21.3/storage/Btrfs.cc --- old/libstorage-2.21.2/storage/Btrfs.cc 2011-05-26 16:28:26.000000000 +0200 +++ new/libstorage-2.21.3/storage/Btrfs.cc 2011-06-09 15:04:12.000000000 +0200 @@ -117,7 +117,7 @@ list<Subvolume>::iterator i=subvol.begin(); while( i!=subvol.end() && !i->deleted() && i->path()!=name ) ++i; - if( i==subvol.end() ) + if( i==subvol.end() || getFormat() ) { Subvolume v( name ); v.setCreated(); @@ -263,18 +263,9 @@ 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; - } + bool needUmount; + string m; + int ret = prepareTmpMount( m, needUmount ); list<string> devs = dev_add; list<string>::const_iterator d = devs.begin(); SystemCmd c; @@ -294,12 +285,7 @@ ++d; } if( needUmount ) - { - if( !st->umountDev( device() ) && ret==0 ) - { - ret = BTRFS_CANNOT_TMP_UMOUNT; - } - } + ret = umountTmpMount( m, ret ); y2mil( "this:" << *this ); y2mil("ret:" << ret); return( ret ); @@ -308,18 +294,9 @@ 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; - } + bool needUmount; + string m; + int ret = prepareTmpMount( m, needUmount ); list<string> devs = dev_rem; list<string>::const_iterator d = devs.begin(); SystemCmd c; @@ -339,12 +316,7 @@ ++d; } if( needUmount ) - { - if( !st->umountDev( device() ) && ret==0 ) - { - ret = BTRFS_CANNOT_TMP_UMOUNT; - } - } + ret = umountTmpMount( m, ret ); y2mil( "this:" << *this ); y2mil("ret:" << ret); return( ret ); @@ -352,18 +324,9 @@ 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; - } + bool needUmount; + string m; + int ret = prepareTmpMount( m, needUmount, false, "subvolid=0" ); if( ret==0 ) { SystemCmd c; @@ -383,30 +346,16 @@ } } if( needUmount ) - { - if( !st->umountDev( device() ) && ret==0 ) - { - ret = BTRFS_CANNOT_TMP_UMOUNT; - } - } + ret = umountTmpMount( m, ret ); y2mil( "ret:" << ret ); return( ret ); } int Btrfs::doCreateSubvol() { - int ret = 0; - bool needUmount = false; - Storage* st = NULL; - string m = getStorage()->prependRoot(getMount()); - if( !isMounted() ) - { - st = getContainer()->getStorage(); - if( st->mountTmp( this, m ) ) - needUmount = true; - else - ret = BTRFS_CANNOT_TMP_MOUNT; - } + bool needUmount; + string m; + int ret = prepareTmpMount( m, needUmount, false, "subvolid=0" ); if( ret==0 ) { SystemCmd c; @@ -435,12 +384,7 @@ } } if( needUmount ) - { - if( !st->umountDev( device() ) && ret==0 ) - { - ret = BTRFS_CANNOT_TMP_UMOUNT; - } - } + ret = umountTmpMount( m, ret ); y2mil( "ret:" << ret ); return( ret ); } @@ -536,15 +480,52 @@ return( txt ); } + +string Btrfs::udevPath() const + { + Volume const *v = findRealVolume(); + if( v ) + return( v->udevPath() ); + else + return( Device::udevPath() ); + } + +list<string> Btrfs::udevId() const + { + Volume const *v = findRealVolume(); + if( v ) + return( v->udevId() ); + else + return( Device::udevId() ); + } + +string Btrfs::sysfsPath() const + { + string ret; + Volume const *v = findRealVolume(); + if( v ) + ret = v->sysfsPath(); + return( ret ); + } + +Volume const * Btrfs::findRealVolume() const + { + Volume const *v = NULL; + if( !getStorage()->findVolume( devices.front(), v, true )) + v = NULL; + return( v ); + } + Text Btrfs::formatText(bool doing) const { Text txt; bool done = false; if( devices.size()+dev_add.size()==1 ) { - Volume const *v = NULL; - if( getStorage()->findVolume( devices.front(), v, true )) + Volume const *v = findRealVolume(); + if( v!=NULL ) { + y2mil( "this: " << *this ); y2mil( "found:" << *v ); txt = v->formatText(doing); done = true; diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/libstorage-2.21.2/storage/Btrfs.h new/libstorage-2.21.3/storage/Btrfs.h --- old/libstorage-2.21.2/storage/Btrfs.h 2011-05-26 16:28:26.000000000 +0200 +++ new/libstorage-2.21.3/storage/Btrfs.h 2011-06-09 15:04:12.000000000 +0200 @@ -67,6 +67,10 @@ Text removeText( bool doing ) const; Text formatText( bool doing ) const; + virtual string udevPath() const; + virtual list<string> udevId() const; + virtual string sysfsPath() const; + void countSubvolAddDel( unsigned& add, unsigned& rem ) const; list<string> getSubvolAddDel( bool ) const; @@ -92,6 +96,7 @@ list<string> dev_add; list<string> dev_rem; list<Subvolume> subvol; + Volume const * findRealVolume() const; mutable storage::BtrfsInfo info; // workaround for broken ycp bindings diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/libstorage-2.21.2/storage/Lock.cc new/libstorage-2.21.3/storage/Lock.cc --- old/libstorage-2.21.2/storage/Lock.cc 2011-01-03 14:59:33.000000000 +0100 +++ new/libstorage-2.21.3/storage/Lock.cc 2011-06-07 11:15:41.000000000 +0200 @@ -25,6 +25,7 @@ #include <fcntl.h> #include <string.h> #include <errno.h> +#include <sys/stat.h> #include <sys/types.h> #include <stdlib.h> diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/libstorage-2.21.2/storage/Storage.cc new/libstorage-2.21.3/storage/Storage.cc --- old/libstorage-2.21.2/storage/Storage.cc 2011-05-26 16:28:26.000000000 +0200 +++ new/libstorage-2.21.3/storage/Storage.cc 2011-06-09 15:04:12.000000000 +0200 @@ -103,8 +103,9 @@ : 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) + defaultFs(EXT4), defaultSubvolName(""), detectMounted(true), + root_mounted(!instsys()), rootprefix(), fstab(NULL), mdadm(NULL), + imsm_driver(IMSM_UNDECIDED) { y2mil("constructed Storage with " << env); y2mil("libstorage version " VERSION); @@ -1119,6 +1120,12 @@ defaultFs = val; } +void Storage::setDefaultSubvolName( const string& val ) +{ + y2mil("old:\"" << defaultSubvolName << "\" val:\"" << val << "\"" ); + defaultSubvolName = val; +} + bool Storage::getEfiBoot() @@ -1146,10 +1153,10 @@ string Storage::prependRoot(const string& mp) const { - if (mp == "swap") + if (mp == "swap" || rootprefix.empty() ) return mp; - if (rootprefix != "" && mp == "/") + if (mp == "/") return rootprefix; else return rootprefix + mp; @@ -1456,7 +1463,6 @@ bool done = false; assertInit(); y2mil("disk:" << disk << " type:" << toString(type)); - DiskIterator i = findDisk( disk ); if (readonly()) { ret = STORAGE_CHANGE_READONLY; @@ -2353,7 +2359,9 @@ { string uuid; co->addFromVolume( *vol, uuid ); + y2mil( "vol before:" << *vol ); vol->setUsedByUuid( UB_BTRFS, uuid ); + y2mil( "vol after :" << *vol ); } } } @@ -4536,10 +4544,9 @@ ret = STORAGE_CHANGE_READONLY; } TmpfsCo *co = NULL; - bool have = true; if( ret==0 ) { - have = haveTmpfs(co); + haveTmpfs(co); } if( ret==0 && co!=NULL ) { @@ -6730,17 +6737,39 @@ return ret; } +bool Storage::mountTmpRo( const Volume* vol, string& mp, const string& opts ) + { + string opt(opts); + if( opt.empty() ) + opt="ro"; + else + opt += ",ro"; + return( mountTmp( vol, mp, opt )); + } -bool Storage::mountTmp( const Volume* vol, string& mdir, bool ro ) +bool Storage::mountTmp( const Volume* vol, string& mdir, const string& opt ) { + y2mil( "device:" << vol->device() << " opts:" << opt ); bool ret = false; removeDmTableTo( *vol ); - mdir = tmpDir() + "/tmp-" + (ro?"ro-mp":"mp") + "-XXXXXX"; + mdir = tmpDir() + "/tmp-mp-XXXXXX"; if (mkdtemp(mdir)) { - y2mil( "mdir:" << mdir << " ro:" << ro ); - - string opts = vol->getFstabOption(); + string opts = opt; + list<string> ls = splitString( vol->getFstabOption(), "," ); + y2mil( "ls=" << ls ); + y2mil( "format:" << vol->getFormat() ); + if( opt.find( "subvolid=0" )!=string::npos || vol->getFormat() ) + { + ls.remove_if( string_starts_with("subvol=") ); + y2mil( "ls=" << ls ); + } + if( !ls.empty() ) + { + if( !opts.empty() ) + opts += ","; + opts += boost::join(ls, ","); + } if( vol->getFs()==NTFS ) { if( !opts.empty() ) @@ -6748,7 +6777,7 @@ opts += "show_sys_files"; } - if( mountDev( vol->device(), mdir, ro, opts ) ) + if( mountDev( vol->device(), mdir, false, opts ) ) { ret = true; } diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/libstorage-2.21.2/storage/Storage.h new/libstorage-2.21.3/storage/Storage.h --- old/libstorage-2.21.2/storage/Storage.h 2011-05-25 10:02:56.000000000 +0200 +++ new/libstorage-2.21.3/storage/Storage.h 2011-06-09 15:04:12.000000000 +0200 @@ -441,6 +441,9 @@ void setDefaultFs (FsType fs); FsType getDefaultFs() const { return defaultFs; } + void setDefaultSubvolName( const string& val); + string getDefaultSubvolName() const { return defaultSubvolName; } + void setDetectMountedVolumes( bool val=true ); bool getDetectMountedVolumes() const { return detectMounted; } bool getEfiBoot(); @@ -579,9 +582,8 @@ void updateDmEmptyPeMap(); void dumpObjectList(); 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 ); + bool mountTmpRo( const Volume* vol, string& mp, const string& opts="" ); + bool mountTmp( const Volume* vol, string& mp, const string& opts="" ); void setCallbackProgressBar(CallbackProgressBar pfnc) { progress_bar_cb = pfnc; } CallbackProgressBar getCallbackProgressBar() const { return progress_bar_cb; } @@ -2099,6 +2101,7 @@ PartAlign partAlignment; MountByType defaultMountBy; FsType defaultFs; + string defaultSubvolName; bool detectMounted; bool root_mounted; string tempdir; diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/libstorage-2.21.2/storage/StorageInterface.h new/libstorage-2.21.3/storage/StorageInterface.h --- old/libstorage-2.21.2/storage/StorageInterface.h 2011-04-21 15:28:29.000000000 +0200 +++ new/libstorage-2.21.3/storage/StorageInterface.h 2011-06-09 15:04:12.000000000 +0200 @@ -746,6 +746,11 @@ VOLUME_REMOUNT_FAILED = -3039, VOLUME_TUNEREISERFS_FAILED = -3040, VOLUME_UMOUNT_NOT_MOUNTED = -3041, + VOLUME_BTRFS_ADD_FAILED = -3042, + VOLUME_CANNOT_TMP_MOUNT = -3043, + VOLUME_CANNOT_TMP_UMOUNT = -3044, + VOLUME_BTRFS_SUBVOL_INIT_FAILED = -3045, + VOLUME_BTRFS_SUBVOL_DETDEFAULT = -3046, LVM_CREATE_PV_FAILED = -4000, LVM_PV_ALREADY_CONTAINED = -4001, @@ -1767,6 +1772,20 @@ virtual FsType getDefaultFs() const = 0; /** + * Set default subvolume name. + * + * @param val new default subvolume name. + */ + virtual void setDefaultSubvolName( const string& val) = 0; + + /** + * Get default filesystem. + * + * @return default filesystem. + */ + virtual string getDefaultSubvolName() const = 0; + + /** * Get value for EFI boot. * * @return value for efi boot diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/libstorage-2.21.2/storage/SystemCmd.cc new/libstorage-2.21.3/storage/SystemCmd.cc --- old/libstorage-2.21.2/storage/SystemCmd.cc 2011-01-03 14:59:33.000000000 +0100 +++ new/libstorage-2.21.3/storage/SystemCmd.cc 2011-06-09 15:04:12.000000000 +0200 @@ -435,10 +435,15 @@ } string Search_Ci( Pat_Cv ); bool BeginOfLine_bi = Search_Ci.length()>0 && Search_Ci[0]=='^'; + bool EndOfLine_bi = Search_Ci.length()>0 && Search_Ci[Search_Ci.length()-1]=='$'; if( BeginOfLine_bi ) { Search_Ci.erase( 0, 1 ); } + if( EndOfLine_bi ) + { + Search_Ci.erase( Search_Ci.length()-1, 1 ); + } SelLines_aC[Idx_iv].resize(0); int Size_ii = 0; int End_ii = Lines_aC[Idx_iv].size(); @@ -449,6 +454,11 @@ { Pos_ii = string::npos; } + if( EndOfLine_bi && + Pos_ii!=(Lines_aC[Idx_iv][I_ii].length()-Search_Ci.length()) ) + { + Pos_ii = string::npos; + } if (Pos_ii != string::npos) { SelLines_aC[Idx_iv].resize( Size_ii+1 ); diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/libstorage-2.21.2/storage/Volume.cc new/libstorage-2.21.3/storage/Volume.cc --- old/libstorage-2.21.2/storage/Volume.cc 2011-05-26 16:28:26.000000000 +0200 +++ new/libstorage-2.21.3/storage/Volume.cc 2011-06-09 15:04:12.000000000 +0200 @@ -707,6 +707,34 @@ return( ret ); } +int Volume::prepareTmpMount( string& m, bool& needUmount, bool useMounted, const string& options ) + { + y2mil( "useMounted:" << useMounted << " opts:" << options ); + int ret = 0; + needUmount=false; + m = getStorage()->prependRoot(getMount()); + if( !isMounted() || !useMounted ) + { + m.clear(); + if( getStorage()->mountTmp( this, m, options ) ) + needUmount = true; + else + ret = VOLUME_CANNOT_TMP_MOUNT; + } + y2mil( "ret:" << " mp:" << m << " needUmount:" << needUmount ); + return( ret ); + } + +int Volume::umountTmpMount( const string& m, int ret ) + { + int r = ret; + if( !getStorage()->umountDev( mountDevice() ) && r==0 ) + r = VOLUME_CANNOT_TMP_UMOUNT; + if( m.substr( 0, 16 )== "/tmp/libstorage-" ) + rmdir( m.c_str() ); + return( r ); + } + Text Volume::formatText( bool doing ) const { Text txt; @@ -794,6 +822,95 @@ return( ret ); } +int Volume::doFormatBtrfs() + { + int ret = 0; + SystemCmd c; + string defvol = getStorage()->getDefaultSubvolName(); + string cmd = "/sbin/mkfs.btrfs " + quote(mountDevice()); + c.execute( cmd ); + if( c.retcode()!=0 ) + { + ret = VOLUME_FORMAT_FAILED; + setExtError( c ); + } + bool needUmount; + string m; + if( ret==0 && cType()==BTRFSC && getEncryption()==ENC_NONE ) + { + const Btrfs* l = static_cast<const Btrfs*>(this); + list<string> li = l->getDevices(); + y2mil( "devices:" << li ); + if( li.size()>1 ) + { + cmd = BTRFSBIN " device add "; + ret = prepareTmpMount( m, needUmount ); + if( ret==0 ) + { + for( list<string>::const_iterator i=li.begin(); i!=li.end(); ++i ) + { + if( *i!=device() && *i!=mountDevice() ) + { + c.execute( cmd + quote(*i) + " " + m ); + if( c.retcode()!=0 ) + { + ret = VOLUME_BTRFS_ADD_FAILED; + setExtError( c ); + } + } + } + } + if( needUmount ) + ret = umountTmpMount( m, ret ); + } + } + if( ret==0 && !defvol.empty() ) + { + ret = prepareTmpMount( m, needUmount, false, "subvolid=0" ); + cmd = BTRFSBIN " subvolume create " + m + "/" + defvol; + c.execute( cmd ); + if( ret==0 && c.retcode()!=0 ) + { + ret = VOLUME_BTRFS_SUBVOL_INIT_FAILED; + setExtError( c ); + } + if( ret==0 ) + { + cmd = BTRFSBIN " subvolume list " + m; + c.execute( cmd ); + int id = -1; + if( c.retcode()==0 ) + { + c.select( " path "+defvol+"$" ); + list<string> sl = splitString(c.getLine( 0, true )," "); + y2mil( "sl:" << sl ); + list<string>::const_iterator i = sl.begin(); + if( i!=sl.end() ) + ++i; + if( i!=sl.end() ) + { + *i >> id; + y2mil( "val:" << *i << " id:" << id ); + } + if( id>=0 ) + { + cmd = BTRFSBIN " subvolume set-default " + decString(id) + " " + m; + c.execute( cmd ); + if( c.retcode()!=0 ) + { + ret = VOLUME_BTRFS_SUBVOL_DETDEFAULT; + setExtError( c ); + } + } + } + } + if( needUmount ) + ret = umountTmpMount( m, ret ); + } + y2mil( "ret:" << ret ); + return( ret ); + } + int Volume::doFormat() { static int fcount=1000; @@ -858,9 +975,6 @@ params = "-t ext4 -v"; progressbar = new Mke2fsProgressBar( cb ); break; - case BTRFS: - cmd = "/sbin/mkfs.btrfs"; - break; case REISERFS: cmd = "/sbin/mkreiserfs"; params = "-f -f"; @@ -891,7 +1005,9 @@ ret = VOLUME_FORMAT_UNKNOWN_FS; break; } - if( ret==0 ) + if( ret==VOLUME_FORMAT_UNKNOWN_FS && fs==BTRFS ) + ret = doFormatBtrfs(); + if( ret==0 && fs!=BTRFS ) { cmd += " "; if( !mkfs_opt.empty() ) @@ -902,18 +1018,7 @@ { cmd += params + " "; } - 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()); + cmd += quote(mountDevice()); SystemCmd c; c.setOutputProcessor(progressbar); c.execute( cmd ); @@ -1035,7 +1140,8 @@ eraseUuid(); eraseLabel(); setMount( "" ); - formattingDone(); + format = false; + detected_fs = fs; setUsedBy( ubt, uuid ); } @@ -2396,19 +2502,22 @@ cmdline += "-r "; cmdline += "-t " + fsn + " "; - const char * ign_opt[] = { "defaults", "" }; - const char * ign_beg[] = { "loop", "encryption=", "phash=", - "itercountk=", "" }; + list<string> ign_opt( ignore_opt, ignore_opt+lengthof(ignore_opt)); + list<string> ign_beg( ignore_beg, ignore_beg+lengthof(ignore_beg)); + if (getStorage()->instsys()) - ign_opt[lengthof(ign_opt)-1] = "ro"; + ign_opt.push_back("ro"); if( fsn=="ntfs" ) - ign_beg[lengthof(ign_beg)-1] = "locale="; + ign_beg.push_back("locale="); + if( fs==BTRFS ) + ign_opt.push_back("subvol="+getStorage()->getDefaultSubvolName()); list<string> l = splitString( fstab_opt, "," ); y2mil( "l before:" << l ); - for( unsigned i=0; i<lengthof(ign_opt) && *ign_opt[i]!=0; i++ ) - l.remove(ign_opt[i]); - for( unsigned i=0; i<lengthof(ign_beg) && *ign_beg[i]!=0; i++ ) - l.remove_if(string_starts_with(ign_beg[i])); + list<string>::const_iterator i; + for( i=ign_opt.begin(); i!=ign_opt.end(); i++ ) + l.remove(*i); + for( i=ign_beg.begin(); i!=ign_beg.end(); i++ ) + l.remove_if(string_starts_with(*i)); y2mil( "l after:" << l ); if( !l.empty() ) cmdline += "-o " + boost::join(l, ",") + " "; @@ -3280,5 +3389,7 @@ const string Volume::tmp_mount[] = { "swap", "/tmp", "/var/tmp" }; + const string Volume::ignore_opt[] = { "defaults" }; + const string Volume::ignore_beg[] = { "loop", "encryption=", "phash=", "itercountk=" }; } diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/libstorage-2.21.2/storage/Volume.h new/libstorage-2.21.3/storage/Volume.h --- old/libstorage-2.21.2/storage/Volume.h 2011-05-16 09:08:13.000000000 +0200 +++ new/libstorage-2.21.3/storage/Volume.h 2011-06-09 15:04:12.000000000 +0200 @@ -234,6 +234,10 @@ bool pwdLengthOk( storage::EncryptType typ, const string& val, bool format ) const; bool noFreqPassno() const; + int prepareTmpMount( string& m, bool& needUmount, bool useMounted=true, + const string& options="" ); + int umountTmpMount( const string& m, int ret ); + int doFormatBtrfs(); string getLosetupCmd( storage::EncryptType, const string& pwdfile ) const; string getCryptsetupCmd( storage::EncryptType e, const string& dmdev, @@ -279,6 +283,8 @@ string dtxt; static const string tmp_mount[3]; + static const string ignore_opt[1]; + static const string ignore_beg[4]; mutable storage::VolumeInfo info; // workaround for broken ycp bindings ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Remember to have fun... -- To unsubscribe, e-mail: opensuse-commit+unsubscr...@opensuse.org For additional commands, e-mail: opensuse-commit+h...@opensuse.org