- changes in parted-3.1: * Changes in behavior - Floppy drives are no longer scanned on linux: they cannot be partitioned anyhow, and some users have a misconfigured BIOS that claims to have a floppy when they don't, and scanning gets hung up. - parted: the mkpart command has changed semantics with regard to specifying the end of the partition. If the end is specified using units of MiB, GiB, etc., parted subtracts one sector from the specified value. With this change, it is now possible to create partitions like 1MiB-2MiB, 2MiB-3MiB and so on. * Many bugfixes (see changelog) - changes in parted-3.0: * Changes in behavior - Remove all FS-related (file system-related) sub-commands; these commands are no longer recognized because they were all dependent on parted "knowing" too much about file system: mkpartfs, mkfs, cp, move, check. - 'resize' command changed semantics: it no longer resizes the filesystem, but only moves end sector of the partition - libparted-devel contains libparted-fs-resize library - add ability to change size of the partition (ignoring contained filesystem) with 'resize' command; this command has different semantics than the former 'resize' command which upstream decided to drop - parted-resize-command.patch (fate#316110) - when using syncmbr on POWER, make the first partition type 0x41 OBS-URL: https://build.opensuse.org/package/show/Base:System/parted?expand=0&rev=79
123 lines
4.5 KiB
Diff
123 lines
4.5 KiB
Diff
---
|
|
parted/parted.c | 86 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++
|
|
1 file changed, 86 insertions(+)
|
|
|
|
Index: parted-3.1/parted/parted.c
|
|
===================================================================
|
|
--- parted-3.1.orig/parted/parted.c
|
|
+++ parted-3.1/parted/parted.c
|
|
@@ -152,6 +152,9 @@ static const char* fs_type_msg_start = N
|
|
static const char* start_end_msg = N_("START and END are disk locations, such as "
|
|
"4GB or 10%. Negative values count from the end of the disk. "
|
|
"For example, -1s specifies exactly the last sector.\n");
|
|
+static const char* end_msg = N_("END is disk location, such as "
|
|
+ "4GB or 10%. Negative value counts from the end of the disk. "
|
|
+ "For example, -1s specifies exactly the last sector.\n");
|
|
static const char* state_msg = N_("STATE is one of: on, off\n");
|
|
static const char* device_msg = N_("DEVICE is usually /dev/hda or /dev/sda\n");
|
|
static const char* name_msg = N_("NAME is any word you want\n");
|
|
@@ -461,6 +464,21 @@ constraint_from_start_end (PedDevice* de
|
|
range_start, range_end, 1, dev->length);
|
|
}
|
|
|
|
+static PedConstraint*
|
|
+constraint_from_start_end_fixed_start (PedDevice* dev, PedSector start_sector,
|
|
+ PedGeometry* range_end)
|
|
+{
|
|
+ PedGeometry range_start;
|
|
+ range_start.dev = dev;
|
|
+ range_start.start = start_sector;
|
|
+ range_start.end = start_sector;
|
|
+ range_start.length = 1;
|
|
+
|
|
+ return ped_constraint_new (ped_alignment_any, ped_alignment_any,
|
|
+ &range_start, range_end, 1, dev->length);
|
|
+}
|
|
+
|
|
+
|
|
void
|
|
help_on (char* topic)
|
|
{
|
|
@@ -1527,6 +1545,66 @@ error:
|
|
return 0;
|
|
}
|
|
|
|
+
|
|
+static int
|
|
+do_resize (PedDevice** dev)
|
|
+{
|
|
+ PedDisk *disk;
|
|
+ PedPartition *part = NULL;
|
|
+ PedSector start, end, oldend;
|
|
+ PedGeometry *range_end = NULL;
|
|
+ PedConstraint* constraint;
|
|
+
|
|
+ disk = ped_disk_new (*dev);
|
|
+ if (!disk)
|
|
+ goto error;
|
|
+
|
|
+ if (ped_disk_is_flag_available(disk, PED_DISK_CYLINDER_ALIGNMENT))
|
|
+ if (!ped_disk_set_flag(disk, PED_DISK_CYLINDER_ALIGNMENT,
|
|
+ alignment == ALIGNMENT_CYLINDER))
|
|
+ goto error;
|
|
+
|
|
+ if (!command_line_get_partition (_("Partition number?"), disk, &part))
|
|
+ goto error;
|
|
+ if (!_partition_warn_busy (part))
|
|
+ goto error;
|
|
+
|
|
+ start = part->geom.start;
|
|
+ end = oldend = part->geom.end;
|
|
+ if (!command_line_get_sector (_("End?"), *dev, &end, &range_end, NULL))
|
|
+ goto error;
|
|
+ /* Do not move start of the partition */
|
|
+ constraint = constraint_from_start_end_fixed_start (*dev, start, range_end);
|
|
+ if (!ped_disk_set_partition_geom (disk, part, constraint,
|
|
+ start, end))
|
|
+ goto error_destroy_constraint;
|
|
+ /* warn when shrinking partition - might lose data */
|
|
+ if (part->geom.end < oldend)
|
|
+ if (ped_exception_throw (
|
|
+ PED_EXCEPTION_WARNING,
|
|
+ PED_EXCEPTION_YES_NO,
|
|
+ _("Shrinking a partition can cause data loss, " \
|
|
+ "are you sure you want to continue?")) != PED_EXCEPTION_YES)
|
|
+ goto error_destroy_constraint;
|
|
+ ped_disk_commit (disk);
|
|
+ ped_constraint_destroy (constraint);
|
|
+ if (range_end != NULL)
|
|
+ ped_geometry_destroy (range_end);
|
|
+
|
|
+ if ((*dev)->type != PED_DEVICE_FILE)
|
|
+ disk_is_modified = 1;
|
|
+
|
|
+ return 1;
|
|
+
|
|
+error_destroy_constraint:
|
|
+ ped_constraint_destroy (constraint);
|
|
+error:
|
|
+ if (range_end != NULL)
|
|
+ ped_geometry_destroy (range_end);
|
|
+ return 0;
|
|
+}
|
|
+
|
|
+
|
|
static int
|
|
do_rm (PedDevice** dev)
|
|
{
|
|
@@ -1899,6 +1977,14 @@ NULL),
|
|
str_list_create (_(start_end_msg), NULL), 1));
|
|
|
|
command_register (commands, command_create (
|
|
+ str_list_create_unique ("resize", _("resize"), NULL),
|
|
+ do_resize,
|
|
+ str_list_create (
|
|
+_("resize NUMBER END change end sector of partition NUMBER"),
|
|
+NULL),
|
|
+ str_list_create (_(number_msg), _(end_msg), NULL), 1));
|
|
+
|
|
+command_register (commands, command_create (
|
|
str_list_create_unique ("rm", _("rm"), NULL),
|
|
do_rm,
|
|
str_list_create (
|