Author: fehr
Date: Thu Jun 9 15:01:31 2011
New Revision: 64278
URL: http://svn.opensuse.org/viewcvs/yast?rev=64278&view=rev
Log:
- add functionality to have everything in a default btrfs subvol (additions to fate#306587)
- add /tmp, /var/run and /var/tmp to default subvol list
- version 2.17.105
Modified:
branches/SuSE-Code-11-SP2-Branch/storage/VERSION
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/Storage.cc
branches/SuSE-Code-11-SP2-Branch/storage/libstorage/src/Storage.h
branches/SuSE-Code-11-SP2-Branch/storage/libstorage/src/StorageInterface.h
branches/SuSE-Code-11-SP2-Branch/storage/libstorage/src/SystemCmd.cc
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/package/yast2-storage.changes
branches/SuSE-Code-11-SP2-Branch/storage/storage/src/modules/FileSystems.ycp
branches/SuSE-Code-11-SP2-Branch/storage/storage/src/modules/Storage.ycp
Modified: branches/SuSE-Code-11-SP2-Branch/storage/VERSION
URL: http://svn.opensuse.org/viewcvs/yast/branches/SuSE-Code-11-SP2-Branch/storage/VERSION?rev=64278&r1=64277&r2=64278&view=diff
==============================================================================
--- branches/SuSE-Code-11-SP2-Branch/storage/VERSION (original)
+++ branches/SuSE-Code-11-SP2-Branch/storage/VERSION Thu Jun 9 15:01:31 2011
@@ -1 +1 @@
-2.17.104
+2.17.105
Modified: branches/SuSE-Code-11-SP2-Branch/storage/libstorage/src/Btrfs.cc
URL: http://svn.opensuse.org/viewcvs/yast/branches/SuSE-Code-11-SP2-Branch/storage/libstorage/src/Btrfs.cc?rev=64278&r1=64277&r2=64278&view=diff
==============================================================================
--- branches/SuSE-Code-11-SP2-Branch/storage/libstorage/src/Btrfs.cc (original)
+++ branches/SuSE-Code-11-SP2-Branch/storage/libstorage/src/Btrfs.cc Thu Jun 9 15:01:31 2011
@@ -326,7 +326,7 @@
{
bool needUmount;
string m;
- int ret = prepareTmpMount( m, needUmount );
+ int ret = prepareTmpMount( m, needUmount, false, "subvolid=0" );
if( ret==0 )
{
SystemCmd c;
@@ -355,7 +355,7 @@
{
bool needUmount;
string m;
- int ret = prepareTmpMount( m, needUmount );
+ int ret = prepareTmpMount( m, needUmount, false, "subvolid=0" );
if( ret==0 )
{
SystemCmd c;
@@ -480,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;
Modified: branches/SuSE-Code-11-SP2-Branch/storage/libstorage/src/Btrfs.h
URL: http://svn.opensuse.org/viewcvs/yast/branches/SuSE-Code-11-SP2-Branch/storage/libstorage/src/Btrfs.h?rev=64278&r1=64277&r2=64278&view=diff
==============================================================================
--- branches/SuSE-Code-11-SP2-Branch/storage/libstorage/src/Btrfs.h (original)
+++ branches/SuSE-Code-11-SP2-Branch/storage/libstorage/src/Btrfs.h Thu Jun 9 15:01:31 2011
@@ -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
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/storage/libstorage/src/Storage.cc?rev=64278&r1=64277&r2=64278&view=diff
==============================================================================
--- branches/SuSE-Code-11-SP2-Branch/storage/libstorage/src/Storage.cc (original)
+++ branches/SuSE-Code-11-SP2-Branch/storage/libstorage/src/Storage.cc Thu Jun 9 15:01:31 2011
@@ -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()
@@ -2352,7 +2359,9 @@
{
string uuid;
co->addFromVolume( *vol, uuid );
+ y2mil( "vol before:" << *vol );
vol->setUsedByUuid( UB_BTRFS, uuid );
+ y2mil( "vol after :" << *vol );
}
}
}
@@ -6728,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() )
@@ -6746,7 +6777,7 @@
opts += "show_sys_files";
}
- if( mountDev( vol->device(), mdir, ro, opts ) )
+ if( mountDev( vol->device(), mdir, false, opts ) )
{
ret = true;
}
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/storage/libstorage/src/Storage.h?rev=64278&r1=64277&r2=64278&view=diff
==============================================================================
--- branches/SuSE-Code-11-SP2-Branch/storage/libstorage/src/Storage.h (original)
+++ branches/SuSE-Code-11-SP2-Branch/storage/libstorage/src/Storage.h Thu Jun 9 15:01:31 2011
@@ -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;
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/storage/libstorage/src/StorageInterface.h?rev=64278&r1=64277&r2=64278&view=diff
==============================================================================
--- branches/SuSE-Code-11-SP2-Branch/storage/libstorage/src/StorageInterface.h (original)
+++ branches/SuSE-Code-11-SP2-Branch/storage/libstorage/src/StorageInterface.h Thu Jun 9 15:01:31 2011
@@ -749,6 +749,8 @@
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,
@@ -1770,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
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/storage/libstorage/src/SystemCmd.cc?rev=64278&r1=64277&r2=64278&view=diff
==============================================================================
--- branches/SuSE-Code-11-SP2-Branch/storage/libstorage/src/SystemCmd.cc (original)
+++ branches/SuSE-Code-11-SP2-Branch/storage/libstorage/src/SystemCmd.cc Thu Jun 9 15:01:31 2011
@@ -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 );
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/storage/libstorage/src/Volume.cc?rev=64278&r1=64277&r2=64278&view=diff
==============================================================================
--- branches/SuSE-Code-11-SP2-Branch/storage/libstorage/src/Volume.cc (original)
+++ branches/SuSE-Code-11-SP2-Branch/storage/libstorage/src/Volume.cc Thu Jun 9 15:01:31 2011
@@ -707,14 +707,16 @@
return( ret );
}
-int Volume::prepareTmpMount( string& m, bool& needUmount )
+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() )
+ if( !isMounted() || !useMounted )
{
- if( getStorage()->mountTmp( this, m ) )
+ m.clear();
+ if( getStorage()->mountTmp( this, m, options ) )
needUmount = true;
else
ret = VOLUME_CANNOT_TMP_MOUNT;
@@ -824,6 +826,7 @@
{
int ret = 0;
SystemCmd c;
+ string defvol = getStorage()->getDefaultSubvolName();
string cmd = "/sbin/mkfs.btrfs " + quote(mountDevice());
c.execute( cmd );
if( c.retcode()!=0 )
@@ -831,6 +834,8 @@
ret = VOLUME_FORMAT_FAILED;
setExtError( c );
}
+ bool needUmount;
+ string m;
if( ret==0 && cType()==BTRFSC && getEncryption()==ENC_NONE )
{
const Btrfs* l = static_cast