Mailinglist Archive: yast-commit (195 mails)

< Previous Next >
[yast-commit] r63507 - in /trunk/storage: bindings/ycp/ package/ storage/src/include/ storage/src/modules/
Author: fehr
Date: Thu Mar 3 18:06:29 2011
New Revision: 63507

URL: http://svn.opensuse.org/viewcvs/yast?rev=63507&view=rev
Log:
- integrate handling of BTRFS volumes
- add handling of subvolumes in BTRFS volumes

Modified:
trunk/storage/bindings/ycp/LibStorage.i
trunk/storage/package/yast2-storage.changes
trunk/storage/storage/src/include/custom_part_check_generated.ycp
trunk/storage/storage/src/include/custom_part_dialogs.ycp
trunk/storage/storage/src/include/custom_part_lib.ycp
trunk/storage/storage/src/include/ep-dialogs.ycp
trunk/storage/storage/src/include/ep-dm-lib.ycp
trunk/storage/storage/src/include/ep-hd-lib.ycp
trunk/storage/storage/src/include/ep-lib.ycp
trunk/storage/storage/src/include/ep-loop-lib.ycp
trunk/storage/storage/src/include/ep-lvm-dialogs.ycp
trunk/storage/storage/src/include/ep-lvm-lib.ycp
trunk/storage/storage/src/include/ep-main.ycp
trunk/storage/storage/src/include/ep-raid-dialogs.ycp
trunk/storage/storage/src/include/ep-raid-lib.ycp
trunk/storage/storage/src/include/ep-unused.ycp
trunk/storage/storage/src/include/lvm_pv_lib.ycp
trunk/storage/storage/src/include/raid_lib.ycp
trunk/storage/storage/src/modules/Partitions.ycp
trunk/storage/storage/src/modules/Storage.ycp
trunk/storage/storage/src/modules/StorageFields.ycp
trunk/storage/storage/src/modules/StorageProposal.ycp

Modified: trunk/storage/bindings/ycp/LibStorage.i
URL:
http://svn.opensuse.org/viewcvs/yast/trunk/storage/bindings/ycp/LibStorage.i?rev=63507&r1=63506&r2=63507&view=diff
==============================================================================
--- trunk/storage/bindings/ycp/LibStorage.i (original)
+++ trunk/storage/bindings/ycp/LibStorage.i Thu Mar 3 18:06:29 2011
@@ -42,6 +42,7 @@
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::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=63507&r1=63506&r2=63507&view=diff
==============================================================================
--- trunk/storage/package/yast2-storage.changes (original)
+++ trunk/storage/package/yast2-storage.changes Thu Mar 3 18:06:29 2011
@@ -1,7 +1,13 @@
-------------------------------------------------------------------
+Thu Mar 3 18:05:04 CET 2011 - fehr@xxxxxxx
+
+- integrate handling of BTRFS volumes
+- add handling of subvolumes in BTRFS volumes
+
+-------------------------------------------------------------------
Thu Feb 17 15:47:57 CET 2011 - fehr@xxxxxxx

-- add option to demand and proposal using btrfs as default
+- add option to demand a proposal using btrfs as default
filesystem

-------------------------------------------------------------------

Modified: trunk/storage/storage/src/include/custom_part_check_generated.ycp
URL:
http://svn.opensuse.org/viewcvs/yast/trunk/storage/storage/src/include/custom_part_check_generated.ycp?rev=63507&r1=63506&r2=63507&view=diff
==============================================================================
--- trunk/storage/storage/src/include/custom_part_check_generated.ycp (original)
+++ trunk/storage/storage/src/include/custom_part_check_generated.ycp Thu Mar
3 18:06:29 2011
@@ -489,8 +489,7 @@
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();

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=63507&r1=63506&r2=63507&view=diff
==============================================================================
--- trunk/storage/storage/src/include/custom_part_dialogs.ycp (original)
+++ trunk/storage/storage/src/include/custom_part_dialogs.ycp Thu Mar 3
18:06:29 2011
@@ -1258,4 +1258,124 @@
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: trunk/storage/storage/src/include/custom_part_lib.ycp
URL:
http://svn.opensuse.org/viewcvs/yast/trunk/storage/storage/src/include/custom_part_lib.ycp?rev=63507&r1=63506&r2=63507&view=diff
==============================================================================
--- trunk/storage/storage/src/include/custom_part_lib.ycp (original)
+++ trunk/storage/storage/src/include/custom_part_lib.ycp Thu Mar 3 18:06:29
2011
@@ -429,9 +429,11 @@
}
}

- if( apply_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 )
@@ -710,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 );

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=63507&r1=63506&r2=63507&view=diff
==============================================================================
--- trunk/storage/storage/src/include/ep-dialogs.ycp (original)
+++ trunk/storage/storage/src/include/ep-dialogs.ycp Thu Mar 3 18:06:29 2011
@@ -39,6 +39,11 @@

//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) );
+ }

void ChangeWidgetIfExists( symbol wid, symbol property, any value)
{
@@ -70,7 +75,8 @@
{
map <symbol, any> fs_data = all_filesystems[used_fs]: $[];
UI::ChangeWidget(`id(`fs_options), `Enabled, fs_data[`options]:[]
!= []);
- ChangeWidgetIfExists(`crypt_fs, `Enabled, fs_data[`crypt]:true);
+ ChangeWidgetIfExists(`crypt_fs, `Enabled,
+
fs_data[`crypt]:true&&data["type"]:`primary!=`btrfs);
}

boolean do_format = data["format"]:false;
@@ -143,6 +149,14 @@
);
}

+ 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(
@@ -181,7 +195,8 @@

_("Do not mount partition"))
)
)
- )
+ ),
+ subvol
)
);


Modified: trunk/storage/storage/src/include/ep-dm-lib.ycp
URL:
http://svn.opensuse.org/viewcvs/yast/trunk/storage/storage/src/include/ep-dm-lib.ycp?rev=63507&r1=63506&r2=63507&view=diff
==============================================================================
--- trunk/storage/storage/src/include/ep-dm-lib.ycp (original)
+++ trunk/storage/storage/src/include/ep-dm-lib.ycp Thu Mar 3 18:06:29 2011
@@ -22,7 +22,7 @@
map<string, map> target_map = Storage::GetTargetMap();
map<string, any> data = Storage::GetPartition(target_map, device);

- if (!isempty(data["used_by"]:[]))
+ if (Storage::IsUsedBy(data))
{
// error popup
Popup::Error(sformat(_("The DM %1 is in use. It cannot be

Modified: trunk/storage/storage/src/include/ep-hd-lib.ycp
URL:
http://svn.opensuse.org/viewcvs/yast/trunk/storage/storage/src/include/ep-hd-lib.ycp?rev=63507&r1=63506&r2=63507&view=diff
==============================================================================
--- trunk/storage/storage/src/include/ep-hd-lib.ycp (original)
+++ trunk/storage/storage/src/include/ep-hd-lib.ycp Thu Mar 3 18:06:29 2011
@@ -22,7 +22,7 @@
map<string, map> target_map = Storage::GetTargetMap();
map disk = target_map[disk_device]:$[];

- if (!isempty(disk["used_by"]:[]))
+ if (Storage::IsUsedBy(disk))
{
// error popup
Popup::Error(_("The disk is in use and cannot be modified."));
@@ -196,7 +196,7 @@
map<string, map> target_map = Storage::GetTargetMap();
map disk = target_map[disk_device]:$[];

- if (!isempty(disk["used_by"]:[]))
+ if (Storage::IsUsedBy(disk))
{
// error popup
Popup::Error(_("The disk is in use and cannot be modified."));
@@ -255,7 +255,7 @@
if (!Storage::CanEdit(part, true))
return;

- if (!isempty(part["used_by"]:[]))
+ 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
@@ -347,7 +347,7 @@
return;
}

- if (!isempty(part["used_by"]:[]))
+ 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
@@ -438,7 +438,7 @@
filter( string dev, map props, target_map, {
return dev != device &&
Storage::IsDiskType( props["type"]:`CT_UNKNOWN ) &&
- isempty(props["used_by"]:[]) &&
+ !Storage::IsUsedBy(props) &&
props["cyl_size"]:0 == mycyl_size;
});


Modified: trunk/storage/storage/src/include/ep-lib.ycp
URL:
http://svn.opensuse.org/viewcvs/yast/trunk/storage/storage/src/include/ep-lib.ycp?rev=63507&r1=63506&r2=63507&view=diff
==============================================================================
--- trunk/storage/storage/src/include/ep-lib.ycp (original)
+++ trunk/storage/storage/src/include/ep-lib.ycp Thu Mar 3 18:06:29 2011
@@ -48,13 +48,8 @@

if (disk_tmp == nil)
{
- foreach(string s, map d, target_map, {
- part_tmp = find(map p, d["partitions"]:[], { return
p["device"]:"" == device; });
- if (part_tmp != nil) {
- disk_tmp = d;
- break;
- }
- });
+ part_tmp = Storage::GetPartition( target_map, device );
+ disk_tmp = Storage::GetDisk( target_map, device );
}

disk = disk_tmp;
@@ -282,7 +277,7 @@
map part = nil;
SplitDevice(target_map, device, disk, part);

- if (!isempty(disk["used_by"]:[]))
+ if (Storage::IsUsedBy(disk))
return `Empty();

list <integer> bits = [];

Modified: trunk/storage/storage/src/include/ep-loop-lib.ycp
URL:
http://svn.opensuse.org/viewcvs/yast/trunk/storage/storage/src/include/ep-loop-lib.ycp?rev=63507&r1=63506&r2=63507&view=diff
==============================================================================
--- trunk/storage/storage/src/include/ep-loop-lib.ycp (original)
+++ trunk/storage/storage/src/include/ep-loop-lib.ycp Thu Mar 3 18:06:29 2011
@@ -45,7 +45,7 @@
map<string, map> target_map = Storage::GetTargetMap();
map<string, any> data = Storage::GetPartition(target_map, device);

- if (!isempty(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: trunk/storage/storage/src/include/ep-lvm-dialogs.ycp
URL:
http://svn.opensuse.org/viewcvs/yast/trunk/storage/storage/src/include/ep-lvm-dialogs.ycp?rev=63507&r1=63506&r2=63507&view=diff
==============================================================================
--- trunk/storage/storage/src/include/ep-lvm-dialogs.ycp (original)
+++ trunk/storage/storage/src/include/ep-lvm-dialogs.ycp Thu Mar 3 18:06:29
2011
@@ -205,7 +205,7 @@

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 isempty(pv["used_by_device"]:""); });
+ list<map> unused_pvs = filter(map pv, get_possible_pvs(target_map), {
return !Storage::IsUsedBy(pv); });

term contents = `VBox();

@@ -295,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();

Modified: trunk/storage/storage/src/include/ep-lvm-lib.ycp
URL:
http://svn.opensuse.org/viewcvs/yast/trunk/storage/storage/src/include/ep-lvm-lib.ycp?rev=63507&r1=63506&r2=63507&view=diff
==============================================================================
--- trunk/storage/storage/src/include/ep-lvm-lib.ycp (original)
+++ trunk/storage/storage/src/include/ep-lvm-lib.ycp Thu Mar 3 18:06:29 2011
@@ -42,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 isempty(pv["used_by"]:[]); });
+ list<map> unused_pvs = filter(map pv, get_possible_pvs(target_map), {
return !Storage::IsUsedBy(pv); });

if (size(unused_pvs) < 1)
{
@@ -238,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);

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=63507&r1=63506&r2=63507&view=diff
==============================================================================
--- trunk/storage/storage/src/include/ep-main.ycp (original)
+++ trunk/storage/storage/src/include/ep-main.ycp Thu Mar 3 18:06:29 2011
@@ -72,6 +72,7 @@
include "partitioning/ep-loop.ycp";
include "partitioning/ep-dm.ycp";
include "partitioning/ep-nfs.ycp";
+ include "partitioning/ep-btrfs.ycp";
include "partitioning/ep-unused.ycp";

include "partitioning/ep-graph.ycp";
@@ -103,6 +104,7 @@
`loop : $[ `create : CreateLoopMainPanel, `handle :
HandleLoopMainPanel ],
`dm : $[ `create : CreateDmMainPanel, `handle :
HandleDmMainPanel ],
`nfs : $[ `create : CreateNfsMainPanel, `handle :
HandleNfsMainPanel ],
+ `btrfs : $[ `create : CreateBtrfsMainPanel, `handle :
HandleBtrfsMainPanel ],
`unused : $[ `create : CreateUnusedPanel, `handle :
HandleUnusedPanel ],
`devicegraph : $[ `create : CreateDeviceGraphPanel, `refresh
: RefreshDeviceGraphPanel, `handle : HandleDeviceGraphPanel ],
`mountgraph : $[ `create : CreateMountGraphPanel, `refresh :
RefreshDeviceGraphPanel, `handle : HandleMountGraphPanel ],
@@ -180,6 +182,9 @@
case `CT_NFS:
huhu(disk, `nfs, $[ `create : CreateNfsPanel, `handle:
HandleNfsMainPanel ], nil);
break;
+ case `CT_BTRFS:
+ huhu(disk, `btrfs, $[ `create : CreateBtrfsPanel, `handle:
HandleBtrfsPanel ], nil);
+ break;
}
}

@@ -203,6 +208,8 @@
// tree node label
`item(`id(`nfs), `icon(StorageIcons::nfs_icon),
_("NFS"), open(`nfs)),
// tree node label
+ `item(`id(`btrfs), `icon(StorageIcons::nfs_icon),
_("BTRFS"), open(`btrfs)),
+ // tree node label
`item(`id(`unused),
`icon(StorageIcons::unused_icon), _("Unused Devices"), open(`unused))
])
];
@@ -280,6 +287,11 @@
if (part != nil)
EpContextMenuDm(device);
break;
+
+ case `CT_BTRFS:
+ if (part != nil)
+ EpContextMenuBtrfs(device);
+ break;
}
}


Modified: trunk/storage/storage/src/include/ep-raid-dialogs.ycp
URL:
http://svn.opensuse.org/viewcvs/yast/trunk/storage/storage/src/include/ep-raid-dialogs.ycp?rev=63507&r1=63506&r2=63507&view=diff
==============================================================================
--- trunk/storage/storage/src/include/ep-raid-dialogs.ycp (original)
+++ trunk/storage/storage/src/include/ep-raid-dialogs.ycp Thu Mar 3 18:06:29
2011
@@ -102,9 +102,9 @@
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 isempty(dev["used_by_device"]:"") &&
+ 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 isempty(dev["used_by_device"]:"") &&
+ list<map> used_devices = filter(map dev, get_possible_rds(target_map),
{ return !Storage::IsUsedBy(dev) &&
contains(devices, dev["device"]:""); });

term contents = `VBox(`Left(

Modified: trunk/storage/storage/src/include/ep-raid-lib.ycp
URL:
http://svn.opensuse.org/viewcvs/yast/trunk/storage/storage/src/include/ep-raid-lib.ycp?rev=63507&r1=63506&r2=63507&view=diff
==============================================================================
--- trunk/storage/storage/src/include/ep-raid-lib.ycp (original)
+++ trunk/storage/storage/src/include/ep-raid-lib.ycp Thu Mar 3 18:06:29 2011
@@ -42,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 isempty(dev["used_by"]:[]); });
+ list<map> unused_devices = filter(map dev,
get_possible_rds(target_map), { return !Storage::IsUsedBy(dev); });

if (size(unused_devices) < 2)
{
@@ -100,7 +100,7 @@
map<string, map> target_map = Storage::GetTargetMap();
map<string, any> data = Storage::GetPartition(target_map, device);

- if (!isempty(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
@@ -140,7 +140,7 @@
return;
}

- if (!isempty(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

Modified: trunk/storage/storage/src/include/ep-unused.ycp
URL:
http://svn.opensuse.org/viewcvs/yast/trunk/storage/storage/src/include/ep-unused.ycp?rev=63507&r1=63506&r2=63507&view=diff
==============================================================================
--- trunk/storage/storage/src/include/ep-unused.ycp (original)
+++ trunk/storage/storage/src/include/ep-unused.ycp Thu Mar 3 18:06:29 2011
@@ -21,7 +21,7 @@
if (partition == nil)
{
if (isempty(disk["partitions"]:[]) &&
- isempty(disk["used_by"]:[]))
+ !Storage::IsUsedBy(disk))
{
return `show;
}
@@ -32,7 +32,7 @@
{
if (partition["type"]:`primary != `extended &&
isempty(partition["mount"]:"") &&
- isempty(partition["used_by"]:[]))
+ !Storage::IsUsedBy(partition))
{
return `show;
}

Modified: trunk/storage/storage/src/include/lvm_pv_lib.ycp
URL:
http://svn.opensuse.org/viewcvs/yast/trunk/storage/storage/src/include/lvm_pv_lib.ycp?rev=63507&r1=63506&r2=63507&view=diff
==============================================================================
--- trunk/storage/storage/src/include/lvm_pv_lib.ycp (original)
+++ trunk/storage/storage/src/include/lvm_pv_lib.ycp Thu Mar 3 18:06:29 2011
@@ -86,7 +86,6 @@
list types_no = [ `lvm, `extended ];
list fsids = [ Partitions::fsid_lvm, Partitions::fsid_raid,
Partitions::fsid_native ];
- list ubs = [ `UB_NONE, `UB_LVM ];
list allowed_enc_types = [ `none, `luks ];

foreach( string dev, map devmap, targetMap,
@@ -97,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 ))));
@@ -110,7 +109,7 @@
}
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 ];

Modified: trunk/storage/storage/src/include/raid_lib.ycp
URL:
http://svn.opensuse.org/viewcvs/yast/trunk/storage/storage/src/include/raid_lib.ycp?rev=63507&r1=63506&r2=63507&view=diff
==============================================================================
--- trunk/storage/storage/src/include/raid_lib.ycp (original)
+++ trunk/storage/storage/src/include/raid_lib.ycp Thu Mar 3 18:06:29 2011
@@ -57,7 +57,6 @@
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, {
@@ -67,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: trunk/storage/storage/src/modules/Partitions.ycp
URL:
http://svn.opensuse.org/viewcvs/yast/trunk/storage/storage/src/modules/Partitions.ycp?rev=63507&r1=63506&r2=63507&view=diff
==============================================================================
--- trunk/storage/storage/src/modules/Partitions.ycp (original)
+++ trunk/storage/storage/src/modules/Partitions.ycp Thu Mar 3 18:06:29 2011
@@ -60,6 +60,7 @@
global string dmraid_name = "DM RAID";
global string dmmultipath_name = "DM Multipath";
global string nfs_name = "NFS";
+ global string btrfs_name = "BTRFS";

// 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=63507&r1=63506&r2=63507&view=diff
==============================================================================
--- trunk/storage/storage/src/modules/Storage.ycp (original)
+++ trunk/storage/storage/src/modules/Storage.ycp Thu Mar 3 18:06:29 2011
@@ -66,6 +66,7 @@
import "LibStorage::DmPartCoInfo";
import "LibStorage::DmraidCoInfo";
import "LibStorage::DmmultipathCoInfo";
+ import "LibStorage::BtrfsInfo";
import "LibStorage::PartitionSlotInfo";
import "LibStorage::CommitInfo";
import "LibStorage::DlabelCapabilities";
@@ -97,7 +98,8 @@
LibStorage::DMMULTIPATH() : `CT_DMMULTIPATH,
LibStorage::DM() : `CT_DM,
LibStorage::MDPART() : `CT_MDPART,
- LibStorage::NFSC() : `CT_NFS
+ LibStorage::NFSC() : `CT_NFS,
+ LibStorage::BTRFSC() : `CT_BTRFS
]
];

@@ -237,8 +239,8 @@
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_NFS : 8 ];
+ `CT_DMRAID : 3, `CT_DMMULTIPATH : 4, `CT_LOOP : 5, `CT_DM : 6, `CT_LVM :
7,
+ `CT_BTRFS : 8, `CT_NFS : 9 ];

list<string> hw_packages = [];

@@ -507,6 +509,9 @@


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 )
@@ -781,7 +786,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"]:0, integer ))
{
part = filter( map p, tg[disk,"partitions"]:[],
``(p["nr"]:-1==m["nr"]:0 ));
@@ -1672,6 +1677,31 @@
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_subvol_get(info),
"\n");
+ if( !isempty(ls) )
+ p["subvol"] = maplist( string s, ls, ``{ map m = $[ "name" : s
]; return( m ); });
+ if( size(p["devices"]:[])>1 )
+ p["device"] = "UUID=" + p["uuid"]:"";
+ c["partitions"] = add( c["partitions"]:[], p );
+ });
+ }
//y2milestone ("getContainerInfo container %1", remove( c, "partitions" )
);
y2milestone ("getContainerInfo container %1", c );
return( c );
@@ -1737,6 +1767,24 @@
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"]:[]
);
+ });
+ }
+ return( tg );
+ }
+
/**
* Updates target map
*
@@ -1764,6 +1812,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,
@@ -2511,6 +2573,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 );
@@ -3680,6 +3776,7 @@
if( c["type"]:`CT_UNKNOWN!=`CT_DISK )
tmp[c["device"]:""] = getContainerInfo( c );
});
+ tmp = HandleBtrfsSimpleVolumes( tmp );
if (!isempty(bios_id_raid))
{
y2milestone( "bios_id_raid:%1", bios_id_raid );
@@ -4091,6 +4188,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
@@ -4111,6 +4214,28 @@
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;
@@ -4210,7 +4335,7 @@
{
if (find(map partition, disk["partitions"]:[], {
return partition["device"]:"" != p["device"]:"" &&
- !isempty(partition["used_by"]:[]); }) != nil)
+ IsUsedBy(partition); }) != nil)
{
txt = sformat(_("
Partition %1 cannot be removed since other partitions on the
@@ -4431,19 +4556,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 );
}

@@ -4455,19 +4574,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 );
}

@@ -4625,7 +4738,7 @@
{
string text = "";
if( Partitions::IsDosWinNtPartition( part["fsid"]:0 ) &&
- data["used_by_type"]:`UB_NONE==`UB_NONE )
+ !IsUsedBy(data) )
{
map<symbol, any> resize_info = $[];
map<symbol, any> content_info = $[];
@@ -5513,7 +5626,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))

Modified: trunk/storage/storage/src/modules/StorageFields.ycp
URL:
http://svn.opensuse.org/viewcvs/yast/trunk/storage/storage/src/modules/StorageFields.ycp?rev=63507&r1=63506&r2=63507&view=diff
==============================================================================
--- trunk/storage/storage/src/modules/StorageFields.ycp (original)
+++ trunk/storage/storage/src/modules/StorageFields.ycp Thu Mar 3 18:06:29 2011
@@ -29,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 ];

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);
});

@@ -1120,6 +1121,26 @@
}
}

+ /**
+ * 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))
+ return `show;
+ else
+ return `ignore;
+ }
+ }
+
+

/**
* The predicate function determines whether the disk/partition is

Modified: trunk/storage/storage/src/modules/StorageProposal.ycp
URL:
http://svn.opensuse.org/viewcvs/yast/trunk/storage/storage/src/modules/StorageProposal.ycp?rev=63507&r1=63506&r2=63507&view=diff
==============================================================================
--- trunk/storage/storage/src/modules/StorageProposal.ycp (original)
+++ trunk/storage/storage/src/modules/StorageProposal.ycp Thu Mar 3 18:06:29
2011
@@ -336,7 +336,7 @@
}
if( !ret && soft )
{
- ret = entry["used_by_type"]:`UB_NONE != `UB_NONE;
+ ret = Storage::IsUsedBy(entry);
}
if( ret )
{
@@ -374,7 +374,7 @@
swapable = $[];
list<string> swaps = Storage::SwappingPartitions();
foreach(string dev, map disk, tg, {
- if (disk["used_by_type"]:`UB_NONE == `UB_NONE)
+ if (!Storage::IsUsedBy(disk))
{
list<map> sw = filter(map p, disk["partitions"]:[],
``(p["type"]:`unknown!=`extended &&
@@ -2581,7 +2581,7 @@
``(!p["delete"]:false &&
p["fsid"]:Partitions::fsid_native ==
Partitions::fsid_native &&
- p["used_by_type"]:`UB_NONE == `UB_NONE &&
+ !Storage::IsUsedBy(p) &&
size(p["mount"]:"")==0 &&
p["size_k"]:0/1024 >= min &&
(max==0 || p["size_k"]:0/1024 <= max) &&
@@ -2868,8 +2868,8 @@
pl = sort( map a, map b, pl,
``(a["size_k"]:0>b["size_k"]:0));
pl = (list<map>) union(
- filter( map p, pl, ``(p["used_by_type"]:`UB_NONE==`UB_NONE) ),
- filter( map p, pl, ``(p["used_by_type"]:`UB_NONE!=`UB_NONE) ));
+ filter( map p, pl, ``(!Storage::IsUsedBy(p)) ),
+ filter( map p, pl, ``(Storage::IsUsedBy(p)) ));

partitions =
maplist( map p, partitions,
@@ -2905,8 +2905,8 @@
filter( map p, pl, ``(p["type"]:`primary==`logical) ),
filter( map p, pl, ``(p["type"]:`primary!=`logical) ));
pl = (list<map>) union(
- filter( map p, pl, ``(p["used_by_type"]:`UB_NONE==`UB_NONE) ),
- filter( map p, pl, ``(p["used_by_type"]:`UB_NONE!=`UB_NONE) ));
+ 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;

--
To unsubscribe, e-mail: yast-commit+unsubscribe@xxxxxxxxxxxx
For additional commands, e-mail: yast-commit+help@xxxxxxxxxxxx

< Previous Next >
This Thread
  • No further messages