Author: aschnell
Date: Thu Jan 21 17:32:04 2010
New Revision: 60473
URL: http://svn.opensuse.org/viewcvs/yast?rev=60473&view=rev
Log:
- implemented moving of newly created partitions (see bnc #541034)
Modified:
trunk/storage/package/yast2-storage.changes
trunk/storage/storage/src/include/ep-dialogs.ycp
trunk/storage/storage/src/include/ep-hd-dialogs.ycp
trunk/storage/storage/src/include/ep-hd-lib.ycp
trunk/storage/storage/src/include/ep-hd.ycp
trunk/storage/storage/src/modules/Storage.ycp
Modified: trunk/storage/package/yast2-storage.changes
URL: http://svn.opensuse.org/viewcvs/yast/trunk/storage/package/yast2-storage.changes?rev=60473&r1=60472&r2=60473&view=diff
==============================================================================
--- trunk/storage/package/yast2-storage.changes (original)
+++ trunk/storage/package/yast2-storage.changes Thu Jan 21 17:32:04 2010
@@ -1,4 +1,9 @@
-------------------------------------------------------------------
+Thu Jan 21 17:28:48 CET 2010 - aschnell@suse.de
+
+- implemented moving of newly created partitions (see bnc #541034)
+
+-------------------------------------------------------------------
Tue Jan 19 14:14:26 CET 2010 - fehr@suse.de
- allow to use cylinder 0 for partition (bnc #571749)
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=60473&r1=60472&r2=60473&view=diff
==============================================================================
--- trunk/storage/storage/src/include/ep-dialogs.ycp (original)
+++ trunk/storage/storage/src/include/ep-dialogs.ycp Thu Jan 21 17:32:04 2010
@@ -622,7 +622,8 @@
heading = sformat(_("Resize Partition %1"), device);
cyl_size = disk["cyl_size"]:1;
- free_cyl_after = Storage::FreeCylindersAfterPartition(device);
+ integer free_cyl_before = 0;
+ Storage::FreeCylindersAroundPartition(device, free_cyl_before, free_cyl_after);
min_size_k = Integer::Max([ min_size_k, cyl_size / 1024 ]);
max_size_k = size_k + (cyl_size * free_cyl_after) / 1024;
Modified: trunk/storage/storage/src/include/ep-hd-dialogs.ycp
URL: http://svn.opensuse.org/viewcvs/yast/trunk/storage/storage/src/include/ep-hd-dialogs.ycp?rev=60473&r1=60472&r2=60473&view=diff
==============================================================================
--- trunk/storage/storage/src/include/ep-hd-dialogs.ycp (original)
+++ trunk/storage/storage/src/include/ep-hd-dialogs.ycp Thu Jan 21 17:32:04 2010
@@ -340,11 +340,99 @@
}
+ boolean DlgMovePartition(map& part)
+ {
+ string device = part["device"]:"error";
+
+ integer free_cyl_before = 0;
+ integer free_cyl_after = 0;
+
+ Storage::FreeCylindersAroundPartition(device, free_cyl_before, free_cyl_after);
+
+ if (free_cyl_before == 0 && free_cyl_after == 0)
+ {
+ // error popup text, %1 is replace with name of partition
+ Popup::Error(sformat(_("No space to moved partition %1."), device));
+ return false;
+ }
+
+ integer move = 0;
+
+ if (free_cyl_before > 0 && free_cyl_after == 0)
+ {
+ // popup text, %1 is replace with name of partition
+ if (!Popup::YesNo(sformat(_("Move partition %1 forward?"), device)))
+ return false;
+
+ move = -free_cyl_before;
+ }
+ else if (free_cyl_before == 0 && free_cyl_after > 0)
+ {
+ // popup text, %1 is replace with name of partition
+ if (!Popup::YesNo(sformat(_("Move partition %1 backward?"), device)))
+ return false;
+
+ move = free_cyl_after;
+ }
+ else if (free_cyl_before > 0 && free_cyl_after > 0)
+ {
+ UI::OpenDialog(`opt(`decorated),
+ Greasemonkey::Transform(
+ `VBox(
+ `MarginBox(2, 0.4,
+ `RadioButtonGroup(`id(`directions),
+ `VBox(
+ // popup text, %1 is replace with name of partition
+ `Label(sformat(_("Move partition %1?"), device)),
+ // radio button text
+ `LeftRadioButton(`id(`forward), _("Forward"), true),
+ // radio button text
+ `LeftRadioButton(`id(`backward), _("Backward"))
+ ))),
+ `ButtonBox(
+ `PushButton(`id(`cancel), `opt(`cancelButton), Label::CancelButton()),
+ `PushButton(`id(`ok), `opt(`default, `okButton), Label::OKButton())
+ )
+ )
+ )
+ );
+
+ symbol widget = (symbol) UI::UserInput();
+
+ symbol direction = (symbol) UI::QueryWidget(`id(`directions), `Value);
+
+ UI::CloseDialog();
+
+ if (widget != `ok)
+ return false;
+
+ switch (direction)
+ {
+ case `forward:
+ move = -free_cyl_before;
+ break;
+
+ case `backward:
+ move = free_cyl_after;
+ break;
+ }
+ }
+
+ if (move == 0)
+ return false;
+
+ part["region", 0] = part["region", 0]:0 + move;
+ y2milestone("part:%1", part);
+ return true;
+ }
+
+
boolean DlgResizePartition(map &data, map disk)
{
return DlgResize(data, disk);
}
+
boolean ConfirmPartitionsDelete( string disk, list<string> pnames )
{
return ConfirmRecursiveDelete( disk, pnames,
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=60473&r1=60472&r2=60473&view=diff
==============================================================================
--- trunk/storage/storage/src/include/ep-hd-lib.ycp (original)
+++ trunk/storage/storage/src/include/ep-hd-lib.ycp Thu Jan 21 17:32:04 2010
@@ -269,6 +269,52 @@
}
+ void EpMovePartition(string device)
+ {
+ if (device == nil)
+ {
+ // error popup
+ Popup::Error(_("No partition selected."));
+ return;
+ }
+
+ map target_map = Storage::GetTargetMap();
+ map disk = Storage::GetDisk(target_map, device);
+ map part = Storage::GetPartition(target_map, device);
+
+ if (disk["readonly"]:false)
+ {
+ Popup::Error(Partitions::RdonlyText(disk["device"]:"", true));
+ return;
+ }
+
+ if (!part["create"]:false)
+ {
+ // error popup, %1 is replace by partition device name, e.g. /dev/sdb1
+ Popup::Error(sformat(_("The partition %1 is already created on disk
+and cannot be moved."), device));
+ return;
+ }
+
+ if (part["type"]:`primary == `extended)
+ {
+ // error popup text
+ Popup::Error(_("An extended partition cannot be moved."));
+ return;
+ }
+
+ if (DlgMovePartition(part))
+ {
+ if (Storage::UpdatePartition(device, part["region", 0]:0, part["region", 1]:0))
+ {
+ UpdateMainStatus();
+ TreePanel::Create();
+ UpdateTableFocus(device);
+ }
+ }
+ }
+
+
void EpResizePartition(string device)
{
if (device == nil)
@@ -366,11 +412,11 @@
string mypart_table_type = target_map[ device, "label" ]:Storage::DefaultDiskLabel( mysize );
// helptext
- string helptext = _("<p>Select one or more (if available) hard disks
-that will have the same partition layout as
-this disk.</p>
+ string helptext = _("<p>Select one or more (if available) hard disks
+that will have the same partition layout as
+this disk.</p>
<p>Disks marked with '*' sign contain one or
-more partitions. After cloning, these
+more partitions. After cloning, these
partitions will be deleted.</p>");
list <string> AvailableTargetDisks()
@@ -379,7 +425,7 @@
filter( string dev, map props, target_map, {
return dev != device &&
Storage::IsDiskType( props["type"]:`CT_UNKNOWN ) &&
- isempty(props["used_by"]:[]) &&
+ isempty(props["used_by"]:[]) &&
props["cyl_size"]:0 == mycyl_size;
});
@@ -389,8 +435,8 @@
foreach( string dev, map props, filtered_target_map,{
if( props["size_k"]:0 >= mysize )
- items = add(items, dev);
- else
+ items = add(items, dev);
+ else
y2milestone("%1 is smaller than needed, skipping it", device);
});
@@ -418,7 +464,7 @@
}
if (isempty(myparts)) {
- Popup::Error(_("There are no partitions on this disk (a clonable
+ Popup::Error(_("There are no partitions on this disk (a clonable
disk must have at least one partition).
Create some partitions before cloning the disk."));
return;
@@ -427,7 +473,7 @@
list <string> mydisks = AvailableTargetDisks();
if (isempty(mydisks)) {
- Popup::Error("This disk cannot be cloned. There are no suitable
+ Popup::Error("This disk cannot be cloned. There are no suitable
disks that could have the same partitioning layout.");
return;
}
@@ -486,7 +532,7 @@
});
//if there is anything to delete, ask user if s/he really wants to delete
- if ( !isempty(partitions_to_delete) &&
+ if ( !isempty(partitions_to_delete) &&
!ConfirmDeletePartitions( partitions_to_delete )) {
ret = nil;
continue;
@@ -519,10 +565,10 @@
foreach( map one_partition, myparts, {
map next = Storage::NextPartition( this_disk, one_partition["type"]:`none);
- Storage::CreatePartition( this_disk, next["device"]:"error",
+ Storage::CreatePartition( this_disk, next["device"]:"error",
one_partition["type"]:`primary,
one_partition["fsid"]: Partitions::fsid_native,
- one_partition["region",0]:0, one_partition["region",1]:0,
+ one_partition["region",0]:0, one_partition["region",1]:0,
one_partition["mountby"]:Storage::GetMountBy(device) );
//FIXME: ChangeVolumeProperties too?
});
Modified: trunk/storage/storage/src/include/ep-hd.ycp
URL: http://svn.opensuse.org/viewcvs/yast/trunk/storage/storage/src/include/ep-hd.ycp?rev=60473&r1=60472&r2=60473&view=diff
==============================================================================
--- trunk/storage/storage/src/include/ep-hd.ycp (original)
+++ trunk/storage/storage/src/include/ep-hd.ycp Thu Jan 21 17:32:04 2010
@@ -34,6 +34,7 @@
void EpContextMenuHdPartition(string device)
{
symbol widget = ContextMenu::Simple([ `item(`id(`edit), _("Edit")),
+ `item(`id(`move), _("Move")),
`item(`id(`resize), _("Resize")),
`item(`id(`delete), _("Delete")) ]);
@@ -43,6 +44,10 @@
EpEditPartition(device);
break;
+ case `move:
+ EpMovePartition(device);
+ break;
+
case `resize:
EpResizePartition(device);
break;
@@ -60,6 +65,8 @@
// push button text
`PushButton(`id(`edit),`opt(`key_F4), _("Edit...")),
// push button text
+ `PushButton(`id(`move), `opt(`key_F7), _("Move...")),
+ // push button text
`PushButton(`id(`resize), `opt(`key_F6), _("Resize...")),
// push button text
`PushButton(`id(`delete), `opt(`key_F5), _("Delete..."))
@@ -100,6 +107,15 @@
EpEditPartition( device );
break;
+ case `move:
+ if (is_disk)
+ // error popup
+ Popup::Error(_("Hard disks, BIOS RAIDs and multipath
+devices cannot be moved."));
+ else
+ EpMovePartition(device);
+ break;
+
case `resize:
if (is_disk)
// error popup
Modified: trunk/storage/storage/src/modules/Storage.ycp
URL: http://svn.opensuse.org/viewcvs/yast/trunk/storage/storage/src/modules/Storage.ycp?rev=60473&r1=60472&r2=60473&view=diff
==============================================================================
--- trunk/storage/storage/src/modules/Storage.ycp (original)
+++ trunk/storage/storage/src/modules/Storage.ycp Thu Jan 21 17:32:04 2010
@@ -2153,6 +2153,7 @@
return( ret==0 );
}
+
global boolean UpdatePartition( string device, integer start, integer len )
{
y2milestone( "UpdatePartition device:%1 start:%2 len:%3",
@@ -4388,31 +4389,14 @@
}
-global integer FreeCylindersAfterPartition(string device)
+global boolean FreeCylindersAroundPartition(string device, integer& free_before, integer& free_after)
{
- integer ret = 0;
- if (LibStorage::StorageInterface::freeCylindersAfterPartition(sint, device, ret) != 0)
- ret = 0;
- y2milestone("FreeCylindersAfterPartition ret:%1", ret);
+ boolean ret = LibStorage::StorageInterface::freeCylindersAroundPartition(sint, device, free_before, free_after) == 0;
+ y2milestone("FreeCylindersAfterPartition ret:%1 free_before:%2 free_after:%3", ret, free_before, free_after);
return ret;
}
-global define boolean CheckNextCreated( map disk, list region )
- ``{
- boolean ret = false;
- integer cylinder = region[0]:0 + region[1]:0;
- foreach(map part, disk["partitions"]:[], ``{
- if( part["region",0]:0 == cylinder && part["create"]:false )
- {
- ret = true;
- }
- });
- y2milestone( "CheckNextCreated region:%1 ret:%2", region, ret );
- return( ret );
- }
-
-
global string PathToDestdir(string p)
{
if (Installation::scr_destdir != "/")
@@ -5013,125 +4997,6 @@
}
-global define void AdaptResize( string maindev, list region, integer schange )
- ``{
- map tg = GetTargetMap();
- list<map> partitions = tg[maindev,"partitions"]:[];
- integer cylinder = region[0]:0 + region[1]:0;
- boolean found = false;
- integer index = -1;
- integer e_idx = -1;
- list<integer> idx_list = [];
- map part = (map) find(map p, partitions,
- ``(p["region",0]:0 == cylinder && p["create"]:false));
- y2milestone( "AdaptResize %1 reg %2 change %3", maindev, region, schange );
- if( part != nil )
- {
- found = false;
- index = 0;
- foreach(map p, partitions,
- ``{
- if( p["region",0]:0 == cylinder && p["create"]:false )
- {
- found = true;
- }
- else if( !found )
- {
- index = index + 1;
- }
- });
- if( partitions[index,"type"]:`primary == `extended )
- {
- e_idx = index;
- found = false;
- index = 0;
- foreach(map p, partitions,
- ``{
- if( p["region",0]:0 == cylinder && p["create"]:false &&
- p["type"]:`primary != `extended )
- {
- found = true;
- part = p;
- }
- else if( !found )
- {
- index = index + 1;
- }
- });
- }
- cylinder = part["region",0]:0 + part["region",1]:0;
- y2milestone( "AdaptResize part:%1", part );
- y2milestone( "AdaptResize index:%1 e_idx:%2 cylinder:%3", index, e_idx,
- cylinder );
- map pnew = (map) find( map p, partitions,
- ``( p["region",0]:0 == cylinder &&
- p["create"]:false ));
- y2milestone( "AdaptResize pnew:%1", pnew );
- while( pnew != nil &&
- (part["mount"]:"" == Partitions::BootMount() ||
- part["fsid"]:0==Partitions::fsid_swap ||
- part["region",1]:0 < (schange<0?(-1*schange):schange)) )
- {
- y2milestone( "AdaptResize pnew:%1", pnew );
- part = pnew;
- idx_list = add( idx_list, index );
- y2milestone( "AdaptResize index:%1 idx_list:%2", index, idx_list );
- found = false;
- index = 0;
- foreach(map p, partitions, ``{
- y2milestone( "found:%1 index:%2 p=%3", found, index, p );
- if( p["nr"]:0 == pnew["nr"]:0 )
- {
- found = true;
- }
- else if( !found )
- {
- index = index + 1;
- }
- });
- cylinder = part["region",0]:0 + part["region",1]:0;
- pnew = (map) find( map p, partitions,
- ``( p["region",0]:0 == cylinder &&
- p["create"]:false ));
- }
- y2milestone( "AdaptResize idx:%1 list:%2", index, idx_list );
-
- foreach(integer num, idx_list, ``{
- partitions[num,"region",0] = partitions[num,"region",0]:0 - schange;
- UpdatePartition( partitions[num,"device"]:"", partitions[num,"region",0]:0,
- partitions[num,"region",1]:1 );
- });
- partitions[index,"region",0] = partitions[index,"region",0]:0 - schange;
- partitions[index,"region",1] = partitions[index,"region",1]:0 + schange;
- if( partitions[index,"region",1]:0 <= 0 )
- {
- partitions[index,"region",1] = 1;
- }
- y2milestone( "AdaptResize increase p:%1", partitions[index]:$[] );
- UpdatePartition( partitions[index,"device"]:"", partitions[index,"region",0]:0,
- partitions[index,"region",1]:1 );
- if( e_idx>=0 )
- {
- partitions[e_idx,"region",0] = partitions[e_idx,"region",0]:0 - schange;
- partitions[e_idx,"region",1] = partitions[e_idx,"region",1]:0 + schange;
- if( partitions[e_idx,"region",1]:0 <= 0 )
- {
- partitions[e_idx,"region",1] = 1;
- }
- UpdatePartition( partitions[e_idx,"device"]:"", partitions[e_idx,"region",0]:0,
- partitions[e_idx,"region",1]:1 );
- }
- }
- else
- {
- y2error( "AdaptResize this should not happen %1", partitions );
- }
- y2milestone( "AdaptResize partitions:%1", partitions );
- y2milestone( "AdaptResize maindev:%1 region:%2 change:%3", maindev,
- region, schange );
- }
-
-
global define integer NumLoopDevices()
{
map bo = (map)WFM::Execute (.local.bash_output, "losetup -a" );
--
To unsubscribe, e-mail: yast-commit+unsubscribe@opensuse.org
For additional commands, e-mail: yast-commit+help@opensuse.org