Author: fehr
Date: Thu Apr 21 11:17:08 2011
New Revision: 63848
URL: http://svn.opensuse.org/viewcvs/yast?rev=63848&view=rev
Log:
add suport for tmpfs (fate#303810)
Modified:
trunk/storage/bindings/ycp/LibStorage.i
trunk/storage/package/yast2-storage.changes
trunk/storage/storage/src/include/custom_part_dialogs.ycp
trunk/storage/storage/src/include/ep-dialogs.ycp
trunk/storage/storage/src/include/ep-main.ycp
trunk/storage/storage/src/modules/FileSystems.ycp
trunk/storage/storage/src/modules/Partitions.ycp
trunk/storage/storage/src/modules/Storage.ycp
trunk/storage/storage/src/modules/StorageFields.ycp
Modified: trunk/storage/bindings/ycp/LibStorage.i
URL: http://svn.opensuse.org/viewcvs/yast/trunk/storage/bindings/ycp/LibStorage.i?rev=63848&r1=63847&r2=63848&view=diff
==============================================================================
--- trunk/storage/bindings/ycp/LibStorage.i (original)
+++ trunk/storage/bindings/ycp/LibStorage.i Thu Apr 21 11:17:08 2011
@@ -43,6 +43,7 @@
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)
Modified: trunk/storage/package/yast2-storage.changes
URL: http://svn.opensuse.org/viewcvs/yast/trunk/storage/package/yast2-storage.changes?rev=63848&r1=63847&r2=63848&view=diff
==============================================================================
--- trunk/storage/package/yast2-storage.changes (original)
+++ trunk/storage/package/yast2-storage.changes Thu Apr 21 11:17:08 2011
@@ -1,4 +1,9 @@
-------------------------------------------------------------------
+Thu Apr 21 11:16:43 CEST 2011 - fehr@suse.de
+
+- add suport for tmpfs (fate#303810)
+
+-------------------------------------------------------------------
Thu Mar 24 17:27:26 CET 2011 - fehr@suse.de
- add code to add/remove volumes to/from BTRFS volume
Modified: trunk/storage/storage/src/include/custom_part_dialogs.ycp
URL: http://svn.opensuse.org/viewcvs/yast/trunk/storage/storage/src/include/custom_part_dialogs.ycp?rev=63848&r1=63847&r2=63848&view=diff
==============================================================================
--- trunk/storage/storage/src/include/custom_part_dialogs.ycp (original)
+++ trunk/storage/storage/src/include/custom_part_dialogs.ycp Thu Apr 21 11:17:08 2011
@@ -374,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>
@@ -594,6 +594,11 @@
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 );
Modified: trunk/storage/storage/src/include/ep-dialogs.ycp
URL: http://svn.opensuse.org/viewcvs/yast/trunk/storage/storage/src/include/ep-dialogs.ycp?rev=63848&r1=63847&r2=63848&view=diff
==============================================================================
--- trunk/storage/storage/src/include/ep-dialogs.ycp (original)
+++ trunk/storage/storage/src/include/ep-dialogs.ycp Thu Apr 21 11:17:08 2011
@@ -44,6 +44,10 @@
// multi volume btrfs filesystem can only be formatted as btrfs
all_filesystems = (map >)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)
{
@@ -74,7 +78,7 @@
void EnableDisableFsOpts( symbol used_fs )
{
map fs_data = all_filesystems[used_fs]: $[];
- UI::ChangeWidget(`id(`fs_options), `Enabled, fs_data[`options]:[] != []);
+ ChangeWidgetIfExists(`fs_options, `Enabled, fs_data[`options]:[] != []);
ChangeWidgetIfExists(`crypt_fs, `Enabled,
fs_data[`crypt]:true&&data["type"]:`primary!=`btrfs);
}
@@ -86,6 +90,8 @@
boolean orig_crypt_fs = crypt_fs;
string mount = data["mount"]:"";
boolean do_mount = mount != "";
+ if( data["type"]:`unknown == `loop || data["type"]:`unknown == `tmpfs)
+ do_mount = true;
boolean AskPassword()
@@ -136,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;
}
@@ -149,6 +155,32 @@
);
}
+ 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 )
{
@@ -160,23 +192,7 @@
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(
@@ -191,10 +207,8 @@
_("Fs&tab Options..."))
)),
`VSpacing(0.45),
- `LeftRadioButton(`id(`do_not_mount), `opt(`notify),
- _("Do not mount partition"))
- )
- )
+ notmnt
+ ))
),
subvol
)
@@ -204,8 +218,8 @@
MiniWorkflow::SetLastStep(!AskPassword());
- UI::ChangeWidget(`id(`format), `Value, do_format ? `do_format : `do_not_format);
- UI::ChangeWidget(`id(`do_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 );
@@ -327,8 +341,14 @@
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);
@@ -370,6 +390,22 @@
UI::ChangeWidget(`id(`do_mount), `Value, true);
UI::ChangeWidget(`id(`do_mount_attachment), `Enabled, true);
UI::SetFocus(`id(`mount_point));
+ widget = `again;
+ continue;
+ }
+ }
+
+ //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;
}
Modified: trunk/storage/storage/src/include/ep-main.ycp
URL: http://svn.opensuse.org/viewcvs/yast/trunk/storage/storage/src/include/ep-main.ycp?rev=63848&r1=63847&r2=63848&view=diff
==============================================================================
--- trunk/storage/storage/src/include/ep-main.ycp (original)
+++ trunk/storage/storage/src/include/ep-main.ycp Thu Apr 21 11:17:08 2011
@@ -73,6 +73,7 @@
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";
@@ -105,6 +106,7 @@
`dm : $[ `create : CreateDmMainPanel, `handle : HandleDmMainPanel ],
`nfs : $[ `create : CreateNfsMainPanel, `handle : HandleNfsMainPanel ],
`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 ],
@@ -185,6 +187,9 @@
case `CT_BTRFS:
huhu(disk, `btrfs, $[ `create : CreateBtrfsPanel, `handle: HandleBtrfsPanel ], nil);
break;
+ case `CT_TMPFS:
+ huhu(disk, `tmpfs, $[ `create : CreateTmpfsPanel, `handle: HandleTmpfsPanel ], nil);
+ break;
}
}
@@ -210,6 +215,8 @@
// tree node label
`item(`id(`btrfs), `icon(StorageIcons::nfs_icon), _("BTRFS"), open(`btrfs)),
// tree node label
+ `item(`id(`tmpfs), `icon(StorageIcons::nfs_icon), _("TMPFS"), open(`tmpfs)),
+ // tree node label
`item(`id(`unused), `icon(StorageIcons::unused_icon), _("Unused Devices"), open(`unused))
])
];
@@ -252,7 +259,10 @@
map disk = nil;
map part = nil;
- SplitDevice(target_map, device, disk, part);
+ if( substring(device,0,5)=="tmpfs" )
+ disk = target_map["/dev/tmpfs"]:$[];
+ else
+ SplitDevice(target_map, device, disk, part);
switch (disk["type"]:`unknown)
{
@@ -292,6 +302,10 @@
if (part != nil)
EpContextMenuBtrfs(device);
break;
+
+ case `CT_TMPFS:
+ EpContextMenuTmpfs(device);
+ break;
}
}
Modified: trunk/storage/storage/src/modules/FileSystems.ycp
URL: http://svn.opensuse.org/viewcvs/yast/trunk/storage/storage/src/modules/FileSystems.ycp?rev=63848&r1=63847&r2=63848&view=diff
==============================================================================
--- trunk/storage/storage/src/modules/FileSystems.ycp (original)
+++ trunk/storage/storage/src/modules/FileSystems.ycp Thu Apr 21 11:17:08 2011
@@ -43,6 +43,7 @@
LibStorage::SWAP() : `swap,
LibStorage::NFS() : `nfs,
LibStorage::NFS4() : `nfs4,
+ LibStorage::TMPFS() : `tmpfs,
LibStorage::FSNONE() : `none
]
];
@@ -69,6 +70,7 @@
global const list<string> tmp_m_points = [ "/tmp", "/var/tmp" ];
list<string> suggest_m_points = [];
+ list<string> suggest_tmp_points = [];
global string nchars = "0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ";
@@ -86,6 +88,16 @@
return( suggest_m_points );
}
+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;
@@ -318,6 +330,25 @@
return( opt );
};
+ list< map > 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 > GetNormalFilesystems()``{
list< map > fat_fst_options =
@@ -788,6 +819,13 @@
`needed_modules : [ "ntfs" ],
`fst_options : [],
`options : []
+ ],
+ `tmpfs : $[
+ `name : "TmpFS",
+ `mountpoints : SuggesTmpfsMPoints(),
+ `mount_string : "tmpfs",
+ `mount_option : "-t tmpfs",
+ `fst_options : tmpfs_fst_options,
]
];
@@ -889,11 +927,19 @@
return ret;
}
+global define map GetTmpfsFilesystem()
+ {
+ return( GetNormalFilesystems()[`tmpfs]:$[] );
+ }
global define list< map > GetFstabOptWidgets( symbol fsys )
``{
list< map > ret = [];
- if( fsys != `swap )
+ if( fsys == `swap )
+ ret = swap_fst_options;
+ else if( fsys == `tmpfs )
+ ret = tmpfs_fst_options;
+ else
{
map > fs = GetAllFileSystems( true, false );
ret = fs[fsys,`fst_options]:[];
@@ -906,10 +952,6 @@
ret = (list< map >)union( ret, GetAclFstabOptions() );
}
}
- else
- {
- ret = swap_fst_options;
- }
y2milestone("fsys:%1 ret:%2", fsys, ret);
return ret;
};
@@ -1416,6 +1458,12 @@
}
+ global boolean CanMountRo(map part)
+ {
+ const list<symbol> no_fs = [ `tmpfs, `swap ];
+ return !contains(no_fs, part["used_fs"]:`unknown);
+ }
+
global boolean CanDoQuota(map part)
{
const list<symbol> quota_fs = [ `ext2, `ext3, `ext4, `btrfs, `reiser, `xfs ];
Modified: trunk/storage/storage/src/modules/Partitions.ycp
URL: http://svn.opensuse.org/viewcvs/yast/trunk/storage/storage/src/modules/Partitions.ycp?rev=63848&r1=63847&r2=63848&view=diff
==============================================================================
--- trunk/storage/storage/src/modules/Partitions.ycp (original)
+++ trunk/storage/storage/src/modules/Partitions.ycp Thu Apr 21 11:17:08 2011
@@ -61,6 +61,7 @@
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 */
Modified: trunk/storage/storage/src/modules/Storage.ycp
URL: http://svn.opensuse.org/viewcvs/yast/trunk/storage/storage/src/modules/Storage.ycp?rev=63848&r1=63847&r2=63848&view=diff
==============================================================================
--- trunk/storage/storage/src/modules/Storage.ycp (original)
+++ trunk/storage/storage/src/modules/Storage.ycp Thu Apr 21 11:17:08 2011
@@ -67,6 +67,7 @@
import "LibStorage::DmraidCoInfo";
import "LibStorage::DmmultipathCoInfo";
import "LibStorage::BtrfsInfo";
+ import "LibStorage::TmpfsInfo";
import "LibStorage::PartitionSlotInfo";
import "LibStorage::CommitInfo";
import "LibStorage::DlabelCapabilities";
@@ -99,7 +100,8 @@
LibStorage::DM() : `CT_DM,
LibStorage::MDPART() : `CT_MDPART,
LibStorage::NFSC() : `CT_NFS,
- LibStorage::BTRFSC() : `CT_BTRFS
+ LibStorage::BTRFSC() : `CT_BTRFS,
+ LibStorage::TMPFSC() : `CT_TMPFS
]
];
@@ -240,7 +242,7 @@
const 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_BTRFS : 8, `CT_NFS : 9 ];
+ `CT_BTRFS : 8, `CT_NFS : 9, `CT_TMPFS : 10 ];
list<string> hw_packages = [];
@@ -786,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 && is( m["nr"]:0, integer ))
+ if( size(part)==0 && is( m["nr"]:(any)0, integer ))
{
part = filter( map p, tg[disk,"partitions"]:[],
``(p["nr"]:-1==m["nr"]:0 ));
@@ -1708,6 +1710,25 @@
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 );
@@ -2811,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 );
Modified: trunk/storage/storage/src/modules/StorageFields.ycp
URL: http://svn.opensuse.org/viewcvs/yast/trunk/storage/storage/src/modules/StorageFields.ycp?rev=63848&r1=63847&r2=63848&view=diff
==============================================================================
--- trunk/storage/storage/src/modules/StorageFields.ycp (original)
+++ trunk/storage/storage/src/modules/StorageFields.ycp Thu Apr 21 11:17:08 2011
@@ -30,7 +30,7 @@
{
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_BTRFS : 9 ];
+ `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, {
@@ -976,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));
@@ -1139,6 +1141,24 @@
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;
}
}
--
To unsubscribe, e-mail: yast-commit+unsubscribe@opensuse.org
For additional commands, e-mail: yast-commit+help@opensuse.org