Author: fehr
Date: Tue Dec 18 19:26:53 2007
New Revision: 43174
URL: http://svn.opensuse.org/viewcvs/yast?rev=43174&view=rev
Log:
- do not propose to format partition for /home if it already contains a valid home filesystem (#249380)
Added:
trunk/storage/libstorage/src/StorageTypes.cc
Modified:
trunk/storage/libstorage/src/Makefile.am
trunk/storage/libstorage/src/Storage.cc
trunk/storage/libstorage/src/Storage.h
trunk/storage/libstorage/src/StorageInterface.h
trunk/storage/libstorage/src/StorageTypes.h
trunk/storage/package/yast2-storage.changes
trunk/storage/storage/src/include/auto_part_create.ycp
trunk/storage/storage/src/include/do_proposal_flexible.ycp
trunk/storage/storage/src/modules/Storage.ycp
Modified: trunk/storage/libstorage/src/Makefile.am
URL: http://svn.opensuse.org/viewcvs/yast/trunk/storage/libstorage/src/Makefile.am?rev=43174&r1=43173&r2=43174&view=diff
==============================================================================
--- trunk/storage/libstorage/src/Makefile.am (original)
+++ trunk/storage/libstorage/src/Makefile.am Tue Dec 18 19:26:53 2007
@@ -55,10 +55,10 @@
ProcMounts.cc ProcMounts.h \
EtcFstab.cc EtcFstab.h \
AppUtil.cc AppUtil.h \
+ StorageTypes.cc StorageTypes.h \
FilterIterator.h ListListIterator.h \
DerefIterator.h IterPair.h \
- Region.h StorageTypes.h \
- StorageTmpl.h
+ Region.h StorageTmpl.h
liby2storage_la_LDFLAGS = -version-info 2:0
liby2storage_la_LIBADD = -lblocxx
Modified: trunk/storage/libstorage/src/Storage.cc
URL: http://svn.opensuse.org/viewcvs/yast/trunk/storage/libstorage/src/Storage.cc?rev=43174&r1=43173&r2=43174&view=diff
==============================================================================
--- trunk/storage/libstorage/src/Storage.cc (original)
+++ trunk/storage/libstorage/src/Storage.cc Tue Dec 18 19:26:53 2007
@@ -3852,9 +3852,9 @@
static bool sort_vol_mount( const Volume* rhs, const Volume* lhs )
{
if( rhs->getMount()=="swap" )
- return( true );
- else if( lhs->getMount()=="swap" )
return( false );
+ else if( lhs->getMount()=="swap" )
+ return( true );
else if( lhs->hasOrigMount() != rhs->hasOrigMount() )
return( rhs->hasOrigMount() );
else
@@ -5727,11 +5727,13 @@
}
bool
-Storage::mountDev( const string& device, const string& mp, bool ro )
+Storage::mountDev( const string& device, const string& mp, bool ro,
+ const string& opts )
{
bool ret = true;
assertInit();
- y2milestone( "device:%s mp:%s ro:%d", device.c_str(), mp.c_str(), ro );
+ y2milestone( "device:%s mp:%s ro:%d opts:%s", device.c_str(), mp.c_str(),
+ ro, opts.c_str() );
VolIterator vol;
if( !readonly && findVolume( device, vol ) )
{
@@ -5741,7 +5743,10 @@
}
if( ret )
{
+ string save = vol->getFstabOption();
+ vol->setFstabOption( opts );
ret = vol->mount( mp, ro )==0;
+ vol->setFstabOption( save );
}
if( !ret )
vol->crUnsetup();
Modified: trunk/storage/libstorage/src/Storage.h
URL: http://svn.opensuse.org/viewcvs/yast/trunk/storage/libstorage/src/Storage.h?rev=43174&r1=43173&r2=43174&view=diff
==============================================================================
--- trunk/storage/libstorage/src/Storage.h (original)
+++ trunk/storage/libstorage/src/Storage.h Tue Dec 18 19:26:53 2007
@@ -360,11 +360,16 @@
int removeUsing( const string& device, const storage::usedBy& uby );
bool checkDeviceMounted( const string& device, string& mp );
bool umountDevice( const string& device );
- bool mountDev( const string& device, const string& mp, bool ro=true );
+ bool mountDev( const string& device, const string& mp, bool ro=true,
+ const string& opts="" );
bool mountDevice( const string& device, const string& mp )
{ return( mountDev( device, mp, false )); }
- bool mountDeviceRo( const string& device, const string& mp )
- { return( mountDev( device, mp, true )); }
+ bool mountDeviceOpts( const string& device, const string& mp,
+ const string& opts )
+ { return( mountDev( device, mp, false, opts )); }
+ bool mountDeviceRo( const string& device, const string& mp,
+ const string& opts )
+ { return( mountDev( device, mp, true, opts )); }
bool readFstab( const string& dir, dequestorage::VolumeInfo& infos);
bool getFreeInfo( const string& device, unsigned long long& resize_free,
unsigned long long& df_free,
Modified: trunk/storage/libstorage/src/StorageInterface.h
URL: http://svn.opensuse.org/viewcvs/yast/trunk/storage/libstorage/src/StorageInterface.h?rev=43174&r1=43173&r2=43174&view=diff
==============================================================================
--- trunk/storage/libstorage/src/StorageInterface.h (original)
+++ trunk/storage/libstorage/src/StorageInterface.h Tue Dec 18 19:26:53 2007
@@ -2000,15 +2000,30 @@
virtual bool mountDevice( const string& device, const string& mp ) = 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
+ * @param mp mount point to mount to
+ * @param opts options to use for mount
+ * @return bool if mount succeeded
+ */
+ virtual bool mountDeviceOpts( const string& device, const string& mp,
+ const string& opts ) = 0;
+
+ /**
* 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
* @param mp mount point to mount to
+ * @param opts options to use for mount
* @return bool if mount succeeded
*/
- virtual bool mountDeviceRo( const string& device, const string& mp ) = 0;
+ virtual bool mountDeviceRo( const string& device, const string& mp,
+ const string& opts ) = 0;
/**
* Check if there are dm maps to a given device
Added: trunk/storage/libstorage/src/StorageTypes.cc
URL: http://svn.opensuse.org/viewcvs/yast/trunk/storage/libstorage/src/StorageTypes.cc?rev=43174&view=auto
==============================================================================
--- trunk/storage/libstorage/src/StorageTypes.cc (added)
+++ trunk/storage/libstorage/src/StorageTypes.cc Tue Dec 18 19:26:53 2007
@@ -0,0 +1,55 @@
+#include "y2storage/StorageTypes.h"
+#include "y2storage/Volume.h"
+
+namespace storage
+{
+
+bool commitAction::operator<( const commitAction& rhs ) const
+ {
+ contOrder l(type);
+ contOrder r(rhs.type);
+
+ if( stage==rhs.stage && stage==MOUNT )
+ {
+ if( vol()==NULL || rhs.vol()==NULL )
+ return( false );
+ else
+ {
+ if( rhs.vol()->getMount()=="swap" )
+ return( false );
+ else if( vol()->getMount()=="swap" )
+ return( true );
+ else if( vol()->hasOrigMount() != rhs.vol()->hasOrigMount() )
+ return( rhs.vol()->hasOrigMount() );
+ else
+ return( vol()->getMount()getMount() );
+ }
+ }
+ else if( unsigned(r)==unsigned(l) )
+ {
+ if( stage==rhs.stage )
+ {
+ if( stage==DECREASE )
+ {
+ if( type!=rhs.type )
+ return( type>rhs.type );
+ else
+ return( containerrhs.container );
+ }
+ }
+ else
+ return( stagehttp://svn.opensuse.org/viewcvs/yast/trunk/storage/libstorage/src/StorageTypes.h?rev=43174&r1=43173&r2=43174&view=diff
==============================================================================
--- trunk/storage/libstorage/src/StorageTypes.h (original)
+++ trunk/storage/libstorage/src/StorageTypes.h Tue Dec 18 19:26:53 2007
@@ -79,38 +79,7 @@
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
- {
- contOrder l(type);
- contOrder r(rhs.type);
-
- if( stage==rhs.stage && stage==MOUNT )
- return( false );
- else if( unsigned(r)==unsigned(l) )
- {
- if( stage==rhs.stage )
- {
- if( stage==DECREASE )
- {
- if( type!=rhs.type )
- return( type>rhs.type );
- else
- return( containerrhs.container );
- }
- }
- else
- return( stage=( const commitAction& rhs ) const
Modified: trunk/storage/package/yast2-storage.changes
URL: http://svn.opensuse.org/viewcvs/yast/trunk/storage/package/yast2-storage.changes?rev=43174&r1=43173&r2=43174&view=diff
==============================================================================
--- trunk/storage/package/yast2-storage.changes (original)
+++ trunk/storage/package/yast2-storage.changes Tue Dec 18 19:26:53 2007
@@ -1,4 +1,10 @@
-------------------------------------------------------------------
+Tue Dec 18 19:17:41 CET 2007 - fehr@suse.de
+
+- do not propose to format partition for /home if it already
+ contains a valid home filesystem (#249380)
+
+-------------------------------------------------------------------
Fri Dec 14 16:00:31 CET 2007 - locilka@suse.cz
- Added a draft of documentation to Storage.ycp
Modified: trunk/storage/storage/src/include/auto_part_create.ycp
URL: http://svn.opensuse.org/viewcvs/yast/trunk/storage/storage/src/include/auto_part_create.ycp?rev=43174&r1=43173&r2=43174&view=diff
==============================================================================
--- trunk/storage/storage/src/include/auto_part_create.ycp (original)
+++ trunk/storage/storage/src/include/auto_part_create.ycp Tue Dec 18 19:26:53 2007
@@ -70,9 +70,9 @@
{
p = remove( p, "delete" );
first = false;
- p["format"] = true;
- p["used_fs"] = Partitions::DefaultFs();
- p["mount"] = "/";
+ p = Storage::SetVolOptions( p, "/",
+ Partitions::DefaultFs(),
+ "", "", "" );
y2milestone( "create_partitions single p %1", p );
}
return( p );
@@ -122,14 +122,6 @@
Storage::SetWholeDisk( keep == nil );
if( size(vm)==0 )
{
- partitions = maplist( map p, partitions,
- ``{
- if( size(p["mount"]:"")>0 && !p["delete"]:false )
- p["fstopt"] = FileSystems::DefaultFstabOptions( p );
- if( p["format"]:false && !p["delete"]:false )
- p["fs_options"] = FileSystems::DefaultFormatOptions( p );
- return( p );
- });
ret = size(partitions)>0;
if( ret )
{
Modified: trunk/storage/storage/src/include/do_proposal_flexible.ycp
URL: http://svn.opensuse.org/viewcvs/yast/trunk/storage/storage/src/include/do_proposal_flexible.ycp?rev=43174&r1=43173&r2=43174&view=diff
==============================================================================
--- trunk/storage/storage/src/include/do_proposal_flexible.ycp (original)
+++ trunk/storage/storage/src/include/do_proposal_flexible.ycp Tue Dec 18 19:26:53 2007
@@ -822,36 +822,13 @@
if( p["nr"]:0 == e["added",0,1]:0 )
{
y2milestone( "process_partition_data reuse part %1", p );
- p["format"] = true;
if( p["mount"]:"" != mount )
p["inactive"] = true;
- p["mount"] = mount;
- p["used_fs"] =
- solution["partitions",pindex,"fsys"]:Partitions::DefaultFs();
- value = solution["partitions",pindex,"fstopt"]:"";
- if( size(value)>0 )
- {
- p["fstopt"] = value;
- }
- else
- {
- p["fstopt"] = FileSystems::DefaultFstabOptions( p );
- }
- p["fs_options"] = FileSystems::DefaultFormatOptions( p );
- value = solution["partitions",pindex,"fopt"]:"";
- if( size(value)>0 )
- {
- p["format_opt"] = value;
- }
- value = solution["partitions",pindex,"label"]:"";
- if( size(value)>0 )
- {
- p["label"] = value;
- }
- else if( size(p["label"]:"")>0 )
- {
- p["label"] = "";
- }
+ 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;
@@ -901,7 +878,6 @@
integer pindex = e["added",0,0]:0;
string mount = solution["partitions",pindex,"mount"]:"";
integer fsid = Partitions::fsid_native;
- part["format"] = true;
if( mount == "swap" )
{
fsid = Partitions::fsid_swap;
@@ -914,6 +890,12 @@
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;
@@ -923,34 +905,6 @@
}
}
part["size_k"] = part["region",1]:0 * disk["cyl_size"]:0 / 1024;
- part["mount"] = mount;
- part["inactive"] = true;
- part["used_fs"] =
- solution["partitions",pindex,"fsys"]:Partitions::DefaultFs();
- value = solution["partitions",pindex,"fstopt"]:"";
- if( size(value)>0 )
- {
- part["fstopt"] = value;
- }
- else
- {
- part["fstopt"] = FileSystems::DefaultFstabOptions( part );
- }
- part["fs_options"] = FileSystems::DefaultFormatOptions( part );
- value = solution["partitions",pindex,"fopt"]:"";
- if( size(value)>0 )
- {
- part["format_opt"] = value;
- }
- value = solution["partitions",pindex,"label"]:"";
- if( size(value)>0 )
- {
- part["label"] = value;
- }
- else if( size(part["label"]:"")>0 )
- {
- part["label"] = "";
- }
part["fsid"] = fsid;
part["fstype"] = Partitions::FsIdToString( fsid );
if( size(mount)==0 && size(vgname)>0 )
@@ -978,22 +932,10 @@
integer pindex = a[0]:0;
string mount = solution["partitions",pindex,"mount"]:"";
integer fsid = Partitions::fsid_native;
- part["format"] = true;
if( mount == "swap" )
{
fsid = Partitions::fsid_swap;
}
- 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["create"] = true;
part["nr"] = a[1]:0;
part["device"] = Storage::GetDeviceName( dev, part["nr"]:0 );
@@ -1006,33 +948,22 @@
{
part["type"] = `logical;
}
- part["mount"] = mount;
part["inactive"] = true;
- part["used_fs"] =
- solution["partitions",pindex,"fsys"]:Partitions::DefaultFs();
- value = solution["partitions",pindex,"fstopt"]:"";
- if( size(value)>0 )
- {
- part["fstopt"] = value;
- }
- else
- {
- part["fstopt"] = FileSystems::DefaultFstabOptions( part );
- }
- part["fs_options"] = FileSystems::DefaultFormatOptions( part );
- value = solution["partitions",pindex,"fopt"]:"";
- if( size(value)>0 )
- {
- part["format_opt"] = value;
- }
- value = solution["partitions",pindex,"label"]:"";
- if( size(value)>0 )
- {
- part["label"] = value;
- }
- else if( size(part["label"]:"")>0 )
+ 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 )
{
- part["label"] = "";
+ 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 );
@@ -2292,15 +2223,9 @@
p["device"]:""==boot["device"]:"" &&
Storage::CanEdit(p,false) )
{
- p["mount"] = Partitions::BootMount();
- p["used_fs"] = Partitions::DefaultBootFs();
- p["format"] = true;
- if( size(p["label"]:"")>0 )
- p["label"] = "";
- p["fstopt"] =
- FileSystems::DefaultFstabOptions( p );
- p["fs_options"] =
- FileSystems::DefaultFormatOptions( p );
+ p = Storage::SetVolOptions( p, Partitions::BootMount(),
+ Partitions::DefaultBootFs(),
+ "", "", "" );
}
return( p );
});
@@ -2314,6 +2239,8 @@
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,
@@ -2335,14 +2262,9 @@
if( !p["delete"]:false &&
p["device"]:""==pl[0,"device"]:"" )
{
- p["mount"] = mp;
- p["used_fs"] = Partitions::DefaultFs();
- p["format"] = true;
- if( size(p["label"]:"")>0 )
- p["label"] = "";
- p["fstopt"] = FileSystems::DefaultFstabOptions( p );
- p["fs_options"] =
- FileSystems::DefaultFormatOptions( p );
+ p = Storage::SetVolOptions( p, mp,
+ Partitions::DefaultFs(),
+ "", "", "" );
}
return( p );
});
@@ -3384,12 +3306,10 @@
if( root==nil && root_pe>0 )
{
map p = $[ "create":true, "name" : "root",
- "format":true, "used_fs" : Partitions::DefaultFs(),
"device" : ret["device"]:"" + "/root",
- "mount" : "/",
"size_k" : pe_to_sizek(root_pe,pe) ];
- p["fstopt"] = FileSystems::DefaultFstabOptions( p );
- p["fs_options"] = FileSystems::DefaultFormatOptions( p );
+ p = Storage::SetVolOptions( p, "/", Partitions::DefaultFs(),
+ "", "", "" );
y2milestone( "modify_vm created %1", p );
ret["partitions"] = add( ret["partitions"]:[], p );
}
@@ -3399,14 +3319,8 @@
``{
if( p["name"]:"" == "root" )
{
- p["mount"] = "/";
- p["format"] = true;
- if( p["detected_fs"]:`unknown==`unknown )
- {
- p["used_fs"] = Partitions::DefaultFs();
- }
- p["fstopt"] = FileSystems::DefaultFstabOptions( p );
- p["fs_options"] = FileSystems::DefaultFormatOptions( p );
+ p = Storage::SetVolOptions( p, "/", Partitions::DefaultFs(),
+ "", "", "" );
y2milestone( "modify_vm reuse %1", p );
}
return(p);
@@ -3415,12 +3329,10 @@
if( swap==nil && swap_pe>0 )
{
map p = $[ "create":true, "name" : "swap",
- "format":true, "used_fs" : `swap,
"device" : ret["device"]:"" + "/swap",
- "mount" : "swap",
"size_k" : pe_to_sizek(swap_pe,pe) ];
- p["fstopt"] = FileSystems::DefaultFstabOptions( p );
- p["fs_options"] = FileSystems::DefaultFormatOptions( p );
+ p = Storage::SetVolOptions( p, "swap", `swap,
+ "", "", "" );
y2milestone( "modify_vm created %1", p );
ret["partitions"] = add( ret["partitions"]:[], p );
}
@@ -3430,14 +3342,8 @@
``{
if( p["name"]:"" == "swap" )
{
- p["mount"] = "swap";
- if( p["detected_fs"]:`unknown!=`swap )
- {
- p["format"] = true;
- p["used_fs"] = `swap;
- p["fs_options"] = FileSystems::DefaultFormatOptions( p );
- }
- p["fstopt"] = FileSystems::DefaultFstabOptions( p );
+ p = Storage::SetVolOptions( p, "swap", `swap,
+ "", "", "" );
y2milestone( "modify_vm reuse %1", p );
}
return(p);
@@ -3446,12 +3352,10 @@
if( home==nil && home_pe>0 )
{
map p = $[ "create":true, "name" : "home",
- "format":true, "used_fs" : Partitions::DefaultFs(),
"device" : ret["device"]:"" + "/home",
- "mount" : "/home",
"size_k" : pe_to_sizek(home_pe,pe) ];
- p["fstopt"] = FileSystems::DefaultFstabOptions( p );
- p["fs_options"] = FileSystems::DefaultFormatOptions( p );
+ p = Storage::SetVolOptions( p, "/home", Partitions::DefaultFs(),
+ "", "", "" );
y2milestone( "modify_vm created %1", p );
ret["partitions"] = add( ret["partitions"]:[], p );
}
@@ -3461,14 +3365,8 @@
``{
if( p["name"]:"" == "home" )
{
- p["mount"] = "/home";
- if( p["detected_fs"]:`unknown==`unknown )
- {
- p["format"] = true;
- p["used_fs"] = Partitions::DefaultFs();
- p["fs_options"] = FileSystems::DefaultFormatOptions( p );
- }
- p["fstopt"] = FileSystems::DefaultFstabOptions( p );
+ p = Storage::SetVolOptions( p, "/home", Partitions::DefaultFs(),
+ "", "", "" );
y2milestone( "modify_vm reuse %1", p );
}
return(p);
Modified: trunk/storage/storage/src/modules/Storage.ycp
URL: http://svn.opensuse.org/viewcvs/yast/trunk/storage/storage/src/modules/Storage.ycp?rev=43174&r1=43173&r2=43174&view=diff
==============================================================================
--- trunk/storage/storage/src/modules/Storage.ycp (original)
+++ trunk/storage/storage/src/modules/Storage.ycp Tue Dec 18 19:26:53 2007
@@ -31,6 +31,7 @@
import "Encoding";
import "Directory";
import "FileSystems";
+ import "FileUtils";
import "Installation";
import "Label";
import "Mode";
@@ -3875,14 +3876,144 @@
*
* @param string device name
* @param string mount point
+ * @param fstopt mount options
+ * @return boolean if successful
+ *
+ * @see Umount()
+ */
+global boolean MountOpt( string dev, string mp, string fstopt )
+ {
+ boolean ret = LibStorage::StorageInterface::mountDeviceRo( sint, dev, mp,
+ fstopt );
+ y2milestone( "MountOpt %1 to %2 with %3 ret %4", dev, mp, fstopt, ret );
+ return( ret );
+ }
+
+/**
+ * Mounts a device
+ *
+ * @param string device name
+ * @param string mount point
* @return boolean if successful
*
* @see Umount()
*/
global boolean Mount( string dev, string mp )
{
- boolean ret = LibStorage::StorageInterface::mountDeviceRo( sint, dev, mp );
- y2milestone( "Mount %1 to %2 ret %3", dev, mp, ret );
+ return( MountOpt( dev, mp, "" ) );
+ }
+
+global define map 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 && count0;
+ i = i+1;
+ }
+ }
+ count = count+1;
+ }
+ Storage::Umount( p["device"]:"" );
+ }
+ SCR::Execute( .target.bash, "rmdir " + tmpdir );
+ }
+ ret["ishome"] = home;
+ y2milestone( "DetectHomeFs ret:%1", ret );
+ return( ret );
+ }
+
+global define map SetVolOptions( map p, string mnt, symbol fs, string fs_opts,
+ string fstab_opts, string label )
+ {
+ y2milestone( "SetVolOptions p:%1", p );
+ y2milestone( "SetVolOptions mount:%1 fs:%2 fs_opt:%3 fst_opt:%4 label:%5",
+ mnt, fs, fs_opts, fstab_opts, label );
+ map ret = p;
+ if( size(mnt)>0 )
+ ret["mount"] = mnt;
+ if( fs!=nil && fs!=`unknown )
+ ret["used_fs"] = fs;
+ else
+ {
+ if( mnt==Partitions::BootMount() )
+ ret["used_fs"] = Partitions::DefaultBootFs();
+ else
+ ret["used_fs"] = Partitions::DefaultFs();
+ }
+ if( ret["used_fs"]:`unknown == `unknown ||
+ ret["used_fs"]:`unknown == `none )
+ ret["format"] = false;
+ else
+ ret["format"] = true;
+ if( ret["format"]:false && !ret["create"]:false &&
+ 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 ) )
+ {
+ ret["format"] = false;
+ ret["used_fs"] = ret["detected_fs"]:`unknown;
+ if( size(fstab_opts)==0 )
+ fstab_opts = h["fstopt"]:"";
+ }
+ }
+ if( ret["format"]:false && !ret["create"]:false &&
+ ret["detected_fs"]:`unknown == `swap && mnt=="swap" )
+ {
+ ret["format"] = false;
+ ret["used_fs"] = `swap;
+ }
+ if( size(fstab_opts)>0 )
+ ret["fstopt"] = fstab_opts;
+ else
+ ret["fstopt"] = FileSystems::DefaultFstabOptions( ret );
+
+ if( size(fs_opts)>0 )
+ ret["fs_options"] =
+ convertStringToFsOptionMap( fs_opts, ret["used_fs"]:`unknown );
+ else
+ ret["fs_options"] = FileSystems::DefaultFormatOptions( ret );
+
+ if( size(label)>0 )
+ ret["label"] = label;
+ else if( size(ret["label"]:"")>0 && ret["format"]:false )
+ ret["label"] = "";
+
+ y2milestone( "SetVolOptions ret:%1", ret );
return( ret );
}
--
To unsubscribe, e-mail: yast-commit+unsubscribe@opensuse.org
For additional commands, e-mail: yast-commit+help@opensuse.org