[parted] - Rebase on parted master commit 081ed98 - libparted: Add support for partition resize - parted: add
Brian C. Lane
bcl at fedoraproject.org
Mon Jul 14 23:50:32 UTC 2014
commit 13386670d031a92365c5ae975a527750c0aa0029
Author: Brian C. Lane <bcl at redhat.com>
Date: Mon Jul 14 14:44:27 2014 -0700
- Rebase on parted master commit 081ed98
- libparted: Add support for partition resize
- parted: add resizepart command
0123-libparted-Fix-part-dupe-with-empty-name.patch | 6 +-
0124-tests-check-name-when-duplicating.patch | 6 +-
...-Fix-python-test-scripts-for-distribution.patch | 6 +-
0126-parted-add-resizepart-command.patch | 146 +++++++++
0127-tests-excersise-resize-command.patch | 122 +++++++
...ibparted-Add-support-for-partition-resize.patch | 331 ++++++++++++++++++++
...-_partition_warn_busy-actually-a-warning-.patch | 105 ++++++
0130-parted-Allow-undocumented-commands.patch | 28 ++
...stub-resize-command-for-backward-compatib.patch | 50 +++
0132-Document-resizepart-command.patch | 62 ++++
0133-tests-fix-t9020-alignment.sh.patch | 28 ++
0134-maint-correct-a-POT-file-updating-rule.patch | 26 ++
parted.spec | 16 +-
13 files changed, 922 insertions(+), 10 deletions(-)
---
diff --git a/0123-libparted-Fix-part-dupe-with-empty-name.patch b/0123-libparted-Fix-part-dupe-with-empty-name.patch
index cf34bfe..5174042 100644
--- a/0123-libparted-Fix-part-dupe-with-empty-name.patch
+++ b/0123-libparted-Fix-part-dupe-with-empty-name.patch
@@ -1,7 +1,7 @@
-From f688c5a7910e1e5f81e8bd0e48a9ed64ec6b2a47 Mon Sep 17 00:00:00 2001
+From 06241515a818dcf62e7c5728a8328cf165e3a793 Mon Sep 17 00:00:00 2001
From: "Brian C. Lane" <bcl at redhat.com>
-Date: Wed, 16 Apr 2014 18:18:38 -0700
-Subject: [PATCH 123/125] libparted: Fix part dupe with empty name
+Date: Wed, 11 Jun 2014 12:13:48 -0700
+Subject: [PATCH 123/134] libparted: Fix part dupe with empty name
It was setting the original translated_name to 0, not the new copy.
diff --git a/0124-tests-check-name-when-duplicating.patch b/0124-tests-check-name-when-duplicating.patch
index d66da4e..084241d 100644
--- a/0124-tests-check-name-when-duplicating.patch
+++ b/0124-tests-check-name-when-duplicating.patch
@@ -1,7 +1,7 @@
-From d285d03becdcd96bdc6062224273e297fb12707e Mon Sep 17 00:00:00 2001
+From 8d2c819b9ec89ca7c29c061eb2fd438c3876d6f8 Mon Sep 17 00:00:00 2001
From: "Brian C. Lane" <bcl at redhat.com>
-Date: Wed, 16 Apr 2014 16:51:18 -0700
-Subject: [PATCH 124/125] tests: check name when duplicating
+Date: Wed, 11 Jun 2014 12:13:49 -0700
+Subject: [PATCH 124/134] tests: check name when duplicating
Create a second partition with a name when supported by the disk label.
Check to make sure that the duplicate has copied over the name. The goal
diff --git a/0125-Fix-python-test-scripts-for-distribution.patch b/0125-Fix-python-test-scripts-for-distribution.patch
index db285ff..0370535 100644
--- a/0125-Fix-python-test-scripts-for-distribution.patch
+++ b/0125-Fix-python-test-scripts-for-distribution.patch
@@ -1,7 +1,7 @@
-From 78ba2fe96dc7f39e585c508bfbc3549cc50aefff Mon Sep 17 00:00:00 2001
+From e8078b3a7b7652aa5f9ee6e09f3c6b21d2810b07 Mon Sep 17 00:00:00 2001
From: "Brian C. Lane" <bcl at redhat.com>
-Date: Wed, 11 Jun 2014 11:00:39 -0700
-Subject: [PATCH 125/125] Fix python test scripts for distribution
+Date: Wed, 11 Jun 2014 12:13:50 -0700
+Subject: [PATCH 125/134] Fix python test scripts for distribution
make distcheck was failing because these scripts were not being
included.
diff --git a/0126-parted-add-resizepart-command.patch b/0126-parted-add-resizepart-command.patch
new file mode 100644
index 0000000..150441e
--- /dev/null
+++ b/0126-parted-add-resizepart-command.patch
@@ -0,0 +1,146 @@
+From 21c58e17c473ea8ef31a18d03348eb2381c0f36c Mon Sep 17 00:00:00 2001
+From: Petr Uzel <petr.uzel at suse.cz>
+Date: Mon, 26 Sep 2011 17:21:01 +0200
+Subject: [PATCH 126/134] parted: add resizepart command
+
+Add resizepart command to resize ( change the end position ) an existing
+partition. Note that it does nothing to a filesystem in the partition.
+---
+ NEWS | 2 ++
+ parted/parted.c | 86 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+ 2 files changed, 88 insertions(+)
+
+diff --git a/NEWS b/NEWS
+index 3de5dde..7069020 100644
+--- a/NEWS
++++ b/NEWS
+@@ -4,6 +4,8 @@ GNU parted NEWS -*- outline -*-
+
+ ** New Features
+
++ Add resizepart command to resize a partition
++
+ Add support for EAV DASD partitions, which are ECKD's with more than
+ 65520 cylinders.
+
+diff --git a/parted/parted.c b/parted/parted.c
+index 3bf03ea..a36ca28 100644
+--- a/parted/parted.c
++++ b/parted/parted.c
+@@ -153,6 +153,9 @@ static const char* fs_type_msg_start = N_("FS-TYPE is one of: ");
+ 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");
+@@ -437,6 +440,21 @@ constraint_from_start_end (PedDevice* dev, PedGeometry* range_start,
+ 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)
+ {
+@@ -1484,6 +1502,66 @@ error:
+ }
+
+ static int
++do_resizepart (PedDevice** dev, PedDisk** diskp)
++{
++ PedDisk *disk = *diskp;
++ PedPartition *part = NULL;
++ PedSector start, end, oldend;
++ PedGeometry *range_end = NULL;
++ PedConstraint* constraint;
++ int rc = 0;
++
++ if (!disk) {
++ disk = ped_disk_new (*dev);
++ *diskp = disk;
++ }
++ 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);
++
++ if ((*dev)->type != PED_DEVICE_FILE)
++ disk_is_modified = 1;
++
++ rc = 1;
++
++error_destroy_constraint:
++ ped_constraint_destroy (constraint);
++error:
++ if (range_end != NULL)
++ ped_geometry_destroy (range_end);
++ return rc;
++}
++
++
++static int
+ do_rm (PedDevice** dev, PedDisk** diskp)
+ {
+ PedPartition* part = NULL;
+@@ -1906,6 +1984,14 @@ NULL),
+ str_list_create (_(start_end_msg), NULL), 1));
+
+ command_register (commands, command_create (
++ str_list_create_unique ("resizepart", _("resizepart"), NULL),
++ do_resizepart,
++ str_list_create (
++_("resizepart NUMBER END resize 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 (
+--
+1.9.3
+
diff --git a/0127-tests-excersise-resize-command.patch b/0127-tests-excersise-resize-command.patch
new file mode 100644
index 0000000..1cee9aa
--- /dev/null
+++ b/0127-tests-excersise-resize-command.patch
@@ -0,0 +1,122 @@
+From 33fd692cb14045fdc13306cd57cfe2040328daa8 Mon Sep 17 00:00:00 2001
+From: Petr Uzel <petr.uzel at suse.cz>
+Date: Tue, 27 Sep 2011 09:11:29 +0200
+Subject: [PATCH 127/134] tests: excersise resize command
+
+a lot of TODOs
+---
+ tests/Makefile.am | 1 +
+ tests/t3200-resize-partition.sh | 89 +++++++++++++++++++++++++++++++++++++++++
+ 2 files changed, 90 insertions(+)
+ create mode 100755 tests/t3200-resize-partition.sh
+
+diff --git a/tests/Makefile.am b/tests/Makefile.am
+index 0b5b1b6..b726366 100644
+--- a/tests/Makefile.am
++++ b/tests/Makefile.am
+@@ -50,6 +50,7 @@ TESTS = \
+ t2400-dos-hfs-partition-type.sh \
+ t2500-probe-corrupt-hfs.sh \
+ t3000-resize-fs.sh \
++ t3200-resize-partition.sh \
+ t3200-type-change.sh \
+ t3300-palo-prep.sh \
+ t3310-flags.sh \
+diff --git a/tests/t3200-resize-partition.sh b/tests/t3200-resize-partition.sh
+new file mode 100755
+index 0000000..251b545
+--- /dev/null
++++ b/tests/t3200-resize-partition.sh
+@@ -0,0 +1,89 @@
++#!/bin/sh
++# exercise the resize sub-command
++# based on t3000-resize-fs.sh test
++
++# Copyright (C) 2009-2011 Free Software Foundation, Inc.
++
++# This program is free software; you can redistribute it and/or modify
++# it under the terms of the GNU General Public License as published by
++# the Free Software Foundation; either version 3 of the License, or
++# (at your option) any later version.
++
++# This program is distributed in the hope that it will be useful,
++# but WITHOUT ANY WARRANTY; without even the implied warranty of
++# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
++# GNU General Public License for more details.
++
++# You should have received a copy of the GNU General Public License
++# along with this program. If not, see <http://www.gnu.org/licenses/>.
++
++. "${srcdir=.}/init.sh"; path_prepend_ ../parted
++
++require_root_
++require_scsi_debug_module_
++
++ss=$sector_size_
++
++default_start=1024s
++default_end=2048s
++
++# create memory-backed device
++scsi_debug_setup_ dev_size_mb=5 > dev-name ||
++ skip_ 'failed to create scsi_debug device'
++dev=$(cat dev-name)
++
++# TODO test simple shrink
++# TODO test expand past end of the disk
++# TODO test expand past begin of next partition
++# TODO test shrink before start
++# TODO test everything with GPT
++# TODO more tests with extended/logical partitions
++
++parted -s $dev mklabel msdos > out 2> err || fail=1
++# expect no output
++compare /dev/null out || fail=1
++compare /dev/null err || fail=1
++
++# ensure that the disk is large enough
++dev_n_sectors=$(parted -s $dev u s p|sed -n '2s/.* \([0-9]*\)s$/\1/p')
++device_sectors_required=$(echo $default_end | sed 's/s$//')
++# Ensure that $dev is large enough for this test
++test $device_sectors_required -le $dev_n_sectors || fail=1
++
++# create an empty partition
++parted -a minimal -s $dev mkpart primary $default_start $default_end > out 2>&1 || fail=1
++compare /dev/null out || fail=1
++
++# print partition table
++parted -m -s $dev u s p > out 2>&1 || fail=1
++
++# FIXME: check expected output
++
++# wait for new partition device to appear
++wait_for_dev_to_appear_ ${dev}1 || { warn_ "${dev}1 did not appear" fail=1; }
++sleep 1
++
++
++# extend the filesystem to end on sector 4096
++new_end=4096s
++parted -s $dev resizepart 1 $new_end > out 2> err || fail=1
++# expect no output
++compare /dev/null out || fail=1
++compare /dev/null err || fail=1
++
++# print partition table
++parted -m -s $dev u s p > out 2>&1 || fail=1
++
++sed -n 3p out > k && mv k out || fail=1
++printf "1:$default_start:$new_end:3073s:::$ms;\n" > exp || fail=1
++compare exp out || fail=1
++
++# Remove the partition explicitly, so that mklabel doesn't evoke a warning.
++parted -s $dev rm 1 || fail=1
++
++# Create a clean partition table for the next iteration.
++parted -s $dev mklabel msdos > out 2>&1 || fail=1
++# expect no output
++compare /dev/null out || fail=1
++
++Exit $fail
+--
+1.9.3
+
diff --git a/0128-libparted-Add-support-for-partition-resize.patch b/0128-libparted-Add-support-for-partition-resize.patch
new file mode 100644
index 0000000..6de3159
--- /dev/null
+++ b/0128-libparted-Add-support-for-partition-resize.patch
@@ -0,0 +1,331 @@
+From f09ca967a0bc443b869a6fad5b5ffe8e95c3fe9a Mon Sep 17 00:00:00 2001
+From: Phillip Susi <psusi at ubuntu.com>
+Date: Tue, 29 Nov 2011 14:05:48 -0500
+Subject: [PATCH 128/134] libparted: Add support for partition resize
+
+When resizing a partition ( same partition number, same
+start sector, different end sector ), try to use the
+new BLKPG_RES_PARTITION request to update the kernel
+partition table with the new size. Also handle resizing
+devmapper targets.
+---
+ NEWS | 3 +-
+ libparted/arch/linux.c | 207 +++++++++++++++++++++++++++++++++++++++++--------
+ 2 files changed, 177 insertions(+), 33 deletions(-)
+
+diff --git a/NEWS b/NEWS
+index 7069020..ad2fea1 100644
+--- a/NEWS
++++ b/NEWS
+@@ -4,7 +4,8 @@ GNU parted NEWS -*- outline -*-
+
+ ** New Features
+
+- Add resizepart command to resize a partition
++ Add resizepart command to resize a partition. This works even on
++ mounted partitions.
+
+ Add support for EAV DASD partitions, which are ECKD's with more than
+ 65520 cylinders.
+diff --git a/libparted/arch/linux.c b/libparted/arch/linux.c
+index cdb8a26..0f18904 100644
+--- a/libparted/arch/linux.c
++++ b/libparted/arch/linux.c
+@@ -2493,8 +2493,9 @@ _blkpg_add_partition (PedDisk* disk, const PedPartition *part)
+ }
+ linux_part.length *= disk->dev->sector_size;
+ }
+- else
++ else {
+ linux_part.length = part->geom.length * disk->dev->sector_size;
++ }
+ linux_part.pno = part->num;
+ strncpy (linux_part.devname, dev_name, BLKPG_DEVNAMELTH);
+ if (vol_name)
+@@ -2521,6 +2522,60 @@ _blkpg_remove_partition (PedDisk* disk, int n)
+ BLKPG_DEL_PARTITION);
+ }
+
++#ifdef BLKPG_RESIZE_PARTITION
++static int _blkpg_resize_partition (PedDisk* disk, const PedPartition *part)
++{
++ struct blkpg_partition linux_part;
++ char* dev_name;
++
++ PED_ASSERT(disk != NULL);
++ PED_ASSERT(disk->dev->sector_size % PED_SECTOR_SIZE_DEFAULT == 0);
++
++ dev_name = _device_get_part_path (disk->dev, part->num);
++ if (!dev_name)
++ return 0;
++ memset (&linux_part, 0, sizeof (linux_part));
++ linux_part.start = part->geom.start * disk->dev->sector_size;
++ /* see fs/partitions/msdos.c:msdos_partition(): "leave room for LILO" */
++ if (part->type & PED_PARTITION_EXTENDED) {
++ if (disk->dev->sector_size == 512) {
++ linux_part.length = 2;
++ PedPartition *walk;
++ /* if the second sector is claimed by a logical partition,
++ then there's just no room for lilo, so don't try to use it */
++ for (walk = part->part_list; walk; walk = walk->next) {
++ if (walk->geom.start == part->geom.start+1)
++ linux_part.length = 1;
++ }
++ } else linux_part.length = 1;
++ }
++ else
++ linux_part.length = part->geom.length * disk->dev->sector_size;
++ linux_part.pno = part->num;
++ strncpy (linux_part.devname, dev_name, BLKPG_DEVNAMELTH);
++
++ free (dev_name);
++
++ if (!_blkpg_part_command (disk->dev, &linux_part,
++ BLKPG_RESIZE_PARTITION)) {
++ return ped_exception_throw (
++ PED_EXCEPTION_ERROR,
++ PED_EXCEPTION_IGNORE_CANCEL,
++ _("Error informing the kernel about modifications to "
++ "partition %s -- %s. This means Linux won't know "
++ "about any changes you made to %s until you reboot "
++ "-- so you shouldn't mount it or use it in any way "
++ "before rebooting."),
++ linux_part.devname,
++ strerror (errno),
++ linux_part.devname)
++ == PED_EXCEPTION_IGNORE;
++ }
++
++ return 1;
++}
++#endif
++
+ /* Read the integer from /sys/block/DEV_BASE/ENTRY and set *VAL
+ to that value, where DEV_BASE is the last component of DEV->path.
+ Upon success, return true. Otherwise, return false. */
+@@ -2789,6 +2844,76 @@ err:
+ free (vol_name);
+ return 0;
+ }
++
++static int
++_dm_resize_partition (PedDisk* disk, const PedPartition* part)
++{
++ LinuxSpecific* arch_specific = LINUX_SPECIFIC (disk->dev);
++ char* params = NULL;
++ char* vol_name = NULL;
++ const char* dev_name = NULL;
++ uint32_t cookie = 0;
++
++ /* Get map name from devicemapper */
++ struct dm_task *task = dm_task_create (DM_DEVICE_INFO);
++ if (!task)
++ goto err;
++
++ if (!dm_task_set_major_minor (task, arch_specific->major,
++ arch_specific->minor, 0))
++ goto err;
++
++ if (!dm_task_run(task))
++ goto err;
++
++ dev_name = dm_task_get_name (task);
++ size_t name_len = strlen (dev_name);
++ vol_name = zasprintf ("%s%s%d",
++ dev_name,
++ isdigit (dev_name[name_len - 1]) ? "p" : "",
++ part->num);
++ if (vol_name == NULL)
++ goto err;
++
++ /* Caution: dm_task_destroy frees dev_name. */
++ dm_task_destroy (task);
++ task = NULL;
++ if ( ! (params = zasprintf ("%d:%d %lld", arch_specific->major,
++ arch_specific->minor, part->geom.start)))
++ goto err;
++
++ task = dm_task_create (DM_DEVICE_RELOAD);
++ if (!task)
++ goto err;
++
++ dm_task_set_name (task, vol_name);
++ dm_task_add_target (task, 0, part->geom.length,
++ "linear", params);
++ if (!dm_task_set_cookie (task, &cookie, 0))
++ goto err;
++ if (dm_task_run (task)) {
++ dm_task_destroy (task);
++ task = dm_task_create (DM_DEVICE_RESUME);
++ if (!task)
++ goto err;
++ dm_task_set_name (task, vol_name);
++ if (!dm_task_set_cookie (task, &cookie, 0))
++ goto err;
++ if (dm_task_run (task)) {
++ free (params);
++ free (vol_name);
++ return 1;
++ }
++ }
++err:
++ dm_task_update_nodes();
++ if (task)
++ dm_task_destroy (task);
++ free (params);
++ free (vol_name);
++ return 0;
++}
++
+ #endif
+
+ /*
+@@ -2810,9 +2935,10 @@ _disk_sync_part_table (PedDisk* disk)
+ {
+ PED_ASSERT(disk != NULL);
+ PED_ASSERT(disk->dev != NULL);
+- int lpn;
++ int lpn, lpn2;
+ unsigned int part_range = _device_get_partition_range(disk->dev);
+ int (*add_partition)(PedDisk* disk, const PedPartition *part);
++ int (*resize_partition)(PedDisk* disk, const PedPartition *part);
+ int (*remove_partition)(PedDisk* disk, int partno);
+ bool (*get_partition_start_and_length)(PedPartition const *part,
+ unsigned long long *start,
+@@ -2822,10 +2948,16 @@ _disk_sync_part_table (PedDisk* disk)
+ if (disk->dev->type == PED_DEVICE_DM) {
+ add_partition = _dm_add_partition;
+ remove_partition = _dm_remove_partition;
++ resize_partition = _dm_resize_partition;
+ get_partition_start_and_length = _dm_get_partition_start_and_length;
+ } else {
+ add_partition = _blkpg_add_partition;
+ remove_partition = _blkpg_remove_partition;
++#ifdef BLKPG_RESIZE_PARTITION
++ resize_partition = _blkpg_resize_partition;
++#else
++ resize_partition = NULL;
++#endif
+ get_partition_start_and_length = _kernel_get_partition_start_and_length;
+ }
+
+@@ -2835,7 +2967,11 @@ _disk_sync_part_table (PedDisk* disk)
+ lpn = PED_MAX(lpn, part_range);
+ else
+ lpn = part_range;
+-
++ /* for add pass, use lesser of device or label limit */
++ if (ped_disk_get_max_supported_partition_count(disk, &lpn2))
++ lpn2 = PED_MIN(lpn2, part_range);
++ else
++ lpn2 = part_range;
+ /* Its not possible to support largest_partnum < 0.
+ * largest_partnum == 0 would mean does not support partitions.
+ * */
+@@ -2860,9 +2996,10 @@ _disk_sync_part_table (PedDisk* disk)
+ if (get_partition_start_and_length(part,
+ &start, &length)
+ && start == part->geom.start
+- && length == part->geom.length)
++ && (length == part->geom.length
++ || (resize_partition && part->num < lpn2)))
+ {
+- /* partition is unchanged, so nothing to do */
++ /* partition is unchanged, or will be resized so nothing to do */
+ ok[i - 1] = 1;
+ continue;
+ }
+@@ -2882,13 +3019,8 @@ _disk_sync_part_table (PedDisk* disk)
+ } while (n_sleep--);
+ if (!ok[i - 1] && errnums[i - 1] == ENXIO)
+ ok[i - 1] = 1; /* it already doesn't exist */
+- }
+- /* lpn = largest partition number.
+- * for add pass, use lesser of device or label limit */
+- if (ped_disk_get_max_supported_partition_count(disk, &lpn))
+- lpn = PED_MIN(lpn, part_range);
+- else
+- lpn = part_range;
++ }
++ lpn = lpn2;
+ /* don't actually add partitions for loop */
+ if (strcmp (disk->type->name, "loop") == 0)
+ lpn = 0;
+@@ -2901,11 +3033,22 @@ _disk_sync_part_table (PedDisk* disk)
+ /* get start and length of existing partition */
+ if (get_partition_start_and_length(part,
+ &start, &length)
+- && start == part->geom.start
+- && length == part->geom.length) {
+- ok[i - 1] = 1;
+- /* partition is unchanged, so nothing to do */
+- continue;
++ && start == part->geom.start)
++ {
++ if (length == part->geom.length) {
++ ok[i - 1] = 1;
++ /* partition is unchanged, so nothing to do */
++ continue;
++ }
++ if (resize_partition
++ && start == part->geom.start)
++ {
++ /* try to resize */
++ if (resize_partition (disk, part)) {
++ ok[i - 1] = 1;
++ continue;
++ }
++ }
+ }
+ /* add the (possibly modified or new) partition */
+ if (!add_partition (disk, part)) {
+@@ -2917,31 +3060,31 @@ _disk_sync_part_table (PedDisk* disk)
+ char *bad_part_list = NULL;
+ /* now warn about any errors */
+ for (i = 1; i <= lpn; i++) {
+- if (ok[i - 1] || errnums[i - 1] == ENXIO)
+- continue;
+- if (bad_part_list == NULL) {
+- bad_part_list = malloc (lpn * 5);
+- if (!bad_part_list)
+- goto cleanup;
+- bad_part_list[0] = 0;
+- }
+- sprintf (bad_part_list + strlen (bad_part_list), "%d, ", i);
+- }
++ if (ok[i - 1] || errnums[i - 1] == ENXIO)
++ continue;
++ if (bad_part_list == NULL) {
++ bad_part_list = malloc (lpn * 5);
++ if (!bad_part_list)
++ goto cleanup;
++ bad_part_list[0] = 0;
++ }
++ sprintf (bad_part_list + strlen (bad_part_list), "%d, ", i);
++ }
+ if (bad_part_list == NULL)
+- ret = 1;
+- else {
++ ret = 1;
++ else {
+ bad_part_list[strlen (bad_part_list) - 2] = 0;
+ if (ped_exception_throw (
+ PED_EXCEPTION_ERROR,
+ PED_EXCEPTION_IGNORE_CANCEL,
+ _("Partition(s) %s on %s have been written, but we have "
+- "been unable to inform the kernel of the change, "
+- "probably because it/they are in use. As a result, "
++ "been unable to inform the kernel of the change, "
++ "probably because it/they are in use. As a result, "
+ "the old partition(s) will remain in use. You "
+ "should reboot now before making further changes."),
+ bad_part_list, disk->dev->path) == PED_EXCEPTION_IGNORE)
+ ret = 1;
+- free (bad_part_list);
++ free (bad_part_list);
+ }
+ cleanup:
+ free (errnums);
+--
+1.9.3
+
diff --git a/0129-parted-make-_partition_warn_busy-actually-a-warning-.patch b/0129-parted-make-_partition_warn_busy-actually-a-warning-.patch
new file mode 100644
index 0000000..63d2de6
--- /dev/null
+++ b/0129-parted-make-_partition_warn_busy-actually-a-warning-.patch
@@ -0,0 +1,105 @@
+From f46146a15bf45478569c1d364661d3d54f8e3a1a Mon Sep 17 00:00:00 2001
+From: Phillip Susi <psusi at ubuntu.com>
+Date: Wed, 30 Nov 2011 13:13:58 -0500
+Subject: [PATCH 129/134] parted: make _partition_warn_busy actually a warning
+ instead of an error
+
+This function was throwing a PED_EXCEPTION_ERROR with only the
+PED_EXCEPTION_CANCEL option. Converted to a PED_EXCEPTION_WARNING
+with the option to continue anyhow.
+---
+ NEWS | 3 +++
+ parted/parted.c | 17 ++++++++++-------
+ tests/t1101-busy-partition.sh | 2 +-
+ tests/t1102-loop-label.sh | 3 +--
+ tests/t9041-undetected-in-use-16th-partition.sh | 4 ++--
+ 5 files changed, 17 insertions(+), 12 deletions(-)
+
+diff --git a/NEWS b/NEWS
+index ad2fea1..118f459 100644
+--- a/NEWS
++++ b/NEWS
+@@ -134,6 +134,9 @@ GNU parted NEWS -*- outline -*-
+
+ ** Changes in behavior
+
++ When attempting to manipulate a mounted partition, parted now issues
++ a warning that you can choose to ignore, instead of an error.
++
+ When creating a loop label, it automatically comes with a partition
+ using the whole disk.
+
+diff --git a/parted/parted.c b/parted/parted.c
+index a36ca28..ec9e04e 100644
+--- a/parted/parted.c
++++ b/parted/parted.c
+@@ -224,14 +224,17 @@ _partition_warn_busy (PedPartition* part)
+
+ if (ped_partition_is_busy (part)) {
+ path = ped_partition_get_path (part);
+- ped_exception_throw (
+- PED_EXCEPTION_ERROR,
+- PED_EXCEPTION_CANCEL,
+- _("Partition %s is being used. You must unmount it "
+- "before you modify it with Parted."),
+- path);
++ if (ped_exception_throw (
++ PED_EXCEPTION_WARNING,
++ PED_EXCEPTION_YES_NO,
++ _("Partition %s is being used. Are you sure you " \
++ "want to continue?"),
++ path) != PED_EXCEPTION_YES)
++ {
++ free (path);
++ return 0;
++ }
+ free (path);
+- return 0;
+ }
+ return 1;
+ }
+diff --git a/tests/t1101-busy-partition.sh b/tests/t1101-busy-partition.sh
+index eb3fac6..ad091f7 100755
+--- a/tests/t1101-busy-partition.sh
++++ b/tests/t1101-busy-partition.sh
+@@ -29,7 +29,7 @@ scsi_debug_setup_ dev_size_mb=80 > dev-name ||
+ dev=$(cat dev-name)
+
+ cat <<EOF > exp-error || framework_failure
+-Error: Partition ${dev}2 is being used. You must unmount it before you modify it with Parted.
++Warning: Partition ${dev}2 is being used. Are you sure you want to continue?
+ EOF
+
+ parted -s "$dev" mklabel msdos > out 2>&1 || fail=1
+diff --git a/tests/t1102-loop-label.sh b/tests/t1102-loop-label.sh
+index c6574c2..9752002 100644
+--- a/tests/t1102-loop-label.sh
++++ b/tests/t1102-loop-label.sh
+@@ -73,8 +73,7 @@ compare exp out || fail=1
+ # make sure partition busy check works ( mklabel checks whole disk )
+ parted -s "$dev" rm 1 > out 2>&1; test $? = 1 || fail=1
+ # create expected output file
+-echo "Error: Partition $dev is being used. You must unmount it before you modify \
+-it with Parted." > exp
++echo "Warning: Partition ${dev} is being used. Are you sure you want to continue?" > exp
+ compare exp out || fail=1
+
+ umount "$mount_point"
+diff --git a/tests/t9041-undetected-in-use-16th-partition.sh b/tests/t9041-undetected-in-use-16th-partition.sh
+index b763e91..edaae1b 100644
+--- a/tests/t9041-undetected-in-use-16th-partition.sh
++++ b/tests/t9041-undetected-in-use-16th-partition.sh
+@@ -87,8 +87,8 @@ for part_dev in $partitions; do
+ # Removal of mounted partition must fail.
+ parted -s $scsi_dev rm $n > out 2>&1 && fail=1
+
+- echo "Error: Partition $part_dev is being used." \
+- 'You must unmount it before you modify it with Parted.' \
++ echo "Warning: Partition $part_dev is being used." \
++ 'Are you sure you want to continue?' \
+ > exp-error || framework_failure_
+
+ # expect error
+--
+1.9.3
+
diff --git a/0130-parted-Allow-undocumented-commands.patch b/0130-parted-Allow-undocumented-commands.patch
new file mode 100644
index 0000000..990c064
--- /dev/null
+++ b/0130-parted-Allow-undocumented-commands.patch
@@ -0,0 +1,28 @@
+From 360d6277d674c6f92135c8b6bf274c48675ef168 Mon Sep 17 00:00:00 2001
+From: Phillip Susi <psusi at ubuntu.com>
+Date: Mon, 5 Dec 2011 19:24:39 -0500
+Subject: [PATCH 130/134] parted: Allow undocumented commands
+
+Have command_print_summary print nothing if the command summary is NULL.
+This allows for a command to be registered, but not documented in the
+output of help.
+---
+ parted/command.c | 2 ++
+ 1 file changed, 2 insertions(+)
+
+diff --git a/parted/command.c b/parted/command.c
+index e8fa64e..bc70e8a 100644
+--- a/parted/command.c
++++ b/parted/command.c
+@@ -118,6 +118,8 @@ command_get_names (Command** list)
+ void
+ command_print_summary (Command* cmd)
+ {
++ if (cmd->summary == NULL)
++ return;
+ fputs (" ", stdout);
+ str_list_print_wrap (cmd->summary, screen_width(), 2, 8, stdout);
+ putchar ('\n');
+--
+1.9.3
+
diff --git a/0131-parted-Add-stub-resize-command-for-backward-compatib.patch b/0131-parted-Add-stub-resize-command-for-backward-compatib.patch
new file mode 100644
index 0000000..7fb28da
--- /dev/null
+++ b/0131-parted-Add-stub-resize-command-for-backward-compatib.patch
@@ -0,0 +1,50 @@
+From 56bfbe21ecca0cb6466c78baed192dc2e5401676 Mon Sep 17 00:00:00 2001
+From: Phillip Susi <psusi at ubuntu.com>
+Date: Tue, 8 Jan 2013 19:40:35 -0500
+Subject: [PATCH 131/134] parted: Add stub resize command for backward
+ compatibility
+
+To make sure that older scripts trying to use the resize command do not
+accidentally run the new resizepart command by mistake, this undocumented
+stub command will throw an error if called.
+---
+ parted/parted.c | 16 ++++++++++++++++
+ 1 file changed, 16 insertions(+)
+
+diff --git a/parted/parted.c b/parted/parted.c
+index ec9e04e..f27a035 100644
+--- a/parted/parted.c
++++ b/parted/parted.c
+@@ -1505,6 +1505,16 @@ error:
+ }
+
+ static int
++do_resize (PedDevice **dev, PedDisk** diskp)
++{
++ ped_exception_throw (
++ PED_EXCEPTION_ERROR,
++ PED_EXCEPTION_CANCEL,
++ _("The resize command has been removed in parted 3.0"));
++ return 0;
++}
++
++static int
+ do_resizepart (PedDevice** dev, PedDisk** diskp)
+ {
+ PedDisk *disk = *diskp;
+@@ -1987,6 +1997,12 @@ NULL),
+ str_list_create (_(start_end_msg), NULL), 1));
+
+ command_register (commands, command_create (
++ str_list_create_unique ("resize", _("resize"), NULL),
++ do_resize,
++ NULL,
++ str_list_create (_(N_("The resize command was removed in parted 3.0\n")), NULL), 1));
++
++command_register (commands, command_create (
+ str_list_create_unique ("resizepart", _("resizepart"), NULL),
+ do_resizepart,
+ str_list_create (
+--
+1.9.3
+
diff --git a/0132-Document-resizepart-command.patch b/0132-Document-resizepart-command.patch
new file mode 100644
index 0000000..acaef53
--- /dev/null
+++ b/0132-Document-resizepart-command.patch
@@ -0,0 +1,62 @@
+From 5c793853fe5cb0718d895c3394fb909c73c6fa1e Mon Sep 17 00:00:00 2001
+From: Phillip Susi <psusi at ubuntu.com>
+Date: Sun, 25 May 2014 14:43:39 -0400
+Subject: [PATCH 132/134] Document resizepart command
+
+---
+ doc/C/parted.8 | 4 ++++
+ doc/parted.texi | 16 ++++++++++++++++
+ 2 files changed, 20 insertions(+)
+
+diff --git a/doc/C/parted.8 b/doc/C/parted.8
+index f8e6a3d..689011c 100644
+--- a/doc/C/parted.8
++++ b/doc/C/parted.8
+@@ -93,6 +93,10 @@ Rescue a lost partition that was located somewhere between \fIstart\fP and
+ \fIend\fP. If a partition is found, \fBparted\fP will ask if you want to
+ create an entry for it in the partition table.
+ .TP
++.B resizepart \fIpartition\fP \fIend\fP
++Change the \fIend\fP position of \fIpartition\fP. Note that this does not
++modify any filesystem present in the partition.
++.TP
+ .B rm \fIpartition\fP
+ Delete \fIpartition\fP.
+ .TP
+diff --git a/doc/parted.texi b/doc/parted.texi
+index 2b6f7f8..07aa702 100644
+--- a/doc/parted.texi
++++ b/doc/parted.texi
+@@ -423,6 +423,7 @@ GNU Parted provides the following commands:
+ * print::
+ * quit::
+ * rescue::
++* resizepart::
+ * rm::
+ * select::
+ * set::
+@@ -744,6 +745,21 @@ It's back! :)
+
+ @end deffn
+
++ at node resizepart
++ at subsection resizepart
++ at cindex resizepart, command description
++ at cindex command description, resizepart
++
++ at deffn Command resizepart @var{number} @var{end}
++
++Moves the @var{end} position of partition @var{number}. Note that this
++does not modify any filesystem present in the partition. If you wish to
++do this, you will need to use external tools, such as @command{resize2fs}.
++
++When growing a partition you will want to grow the filesystem afterwards,
++but when shrinking, you need to shrink the filesystem before the partition.
++ at end deffn
++
+ @node rm
+ @subsection rm
+ @cindex rm, command description
+--
+1.9.3
+
diff --git a/0133-tests-fix-t9020-alignment.sh.patch b/0133-tests-fix-t9020-alignment.sh.patch
new file mode 100644
index 0000000..d0c3165
--- /dev/null
+++ b/0133-tests-fix-t9020-alignment.sh.patch
@@ -0,0 +1,28 @@
+From ae37d7c4586664e18f42e25a7f210f392e1f0100 Mon Sep 17 00:00:00 2001
+From: Phillip Susi <psusi at ubuntu.com>
+Date: Sun, 15 Jun 2014 18:20:07 -0400
+Subject: [PATCH 133/134] tests: fix t9020-alignment.sh
+
+This test was refering to print-alignment by absolute path, which
+broke building with a different object directory, causing
+make distcheck to fail.
+---
+ tests/t9020-alignment.sh | 2 +-
+ 1 file changed, 1 insertion(+), 1 deletion(-)
+
+diff --git a/tests/t9020-alignment.sh b/tests/t9020-alignment.sh
+index f27b59b..9ea6eb0 100755
+--- a/tests/t9020-alignment.sh
++++ b/tests/t9020-alignment.sh
+@@ -36,7 +36,7 @@ scsi_debug_setup_ physblk_exp=3 lowest_aligned=7 num_parts=4 > dev-name ||
+ scsi_dev=$(cat dev-name)
+
+ # print alignment info
+-"$abs_srcdir/print-align" $scsi_dev > out 2>&1 || fail=1
++../print-align $scsi_dev > out 2>&1 || fail=1
+
+ compare exp out || fail=1
+
+--
+1.9.3
+
diff --git a/0134-maint-correct-a-POT-file-updating-rule.patch b/0134-maint-correct-a-POT-file-updating-rule.patch
new file mode 100644
index 0000000..8c9bc5f
--- /dev/null
+++ b/0134-maint-correct-a-POT-file-updating-rule.patch
@@ -0,0 +1,26 @@
+From 081ed98dabfd1d857139c71fd6a74f8898dd9dcb Mon Sep 17 00:00:00 2001
+From: Jim Meyering <meyering at fb.com>
+Date: Mon, 23 Jun 2014 07:20:27 -0700
+Subject: [PATCH 134/134] maint: correct a POT-file updating rule
+
+* doc/C/Makefile.am (updatepo): If there is no po/$name.pot,
+create an empty one. Reported by Philip Susi.
+---
+ doc/C/Makefile.am | 1 +
+ 1 file changed, 1 insertion(+)
+
+diff --git a/doc/C/Makefile.am b/doc/C/Makefile.am
+index 42b3cb1..c3595f5 100644
+--- a/doc/C/Makefile.am
++++ b/doc/C/Makefile.am
+@@ -13,6 +13,7 @@ updatepo:
+ test -w . || exit 0; \
+ for name in $(dist_man8_MANS); do \
+ echo $$name; \
++ test -f po/$$name.pot || touch po/$$name.pot; \
+ cp po/$$name.pot po/$$name.new.pot; \
+ po4a-updatepo -f man -m $$name -p po/$$name.new.pot; \
+ diff -I '^\"POT-Creation-Date: ' po/$$name.pot po/$$name.new.pot 2>&1 > /dev/null; \
+--
+1.9.3
+
diff --git a/parted.spec b/parted.spec
index b2c023d..cc9118f 100644
--- a/parted.spec
+++ b/parted.spec
@@ -4,7 +4,7 @@
Summary: The GNU disk partition manipulation program
Name: parted
Version: 3.1
-Release: 28%{?dist}
+Release: 29%{?dist}
License: GPLv3+
Group: Applications/System
URL: http://www.gnu.org/software/parted
@@ -150,6 +150,15 @@ Patch0122: 0122-tests-use-test-s-operator-not.patch
Patch0123: 0123-libparted-Fix-part-dupe-with-empty-name.patch
Patch0124: 0124-tests-check-name-when-duplicating.patch
Patch0125: 0125-Fix-python-test-scripts-for-distribution.patch
+Patch0126: 0126-parted-add-resizepart-command.patch
+Patch0127: 0127-tests-excersise-resize-command.patch
+Patch0128: 0128-libparted-Add-support-for-partition-resize.patch
+Patch0129: 0129-parted-make-_partition_warn_busy-actually-a-warning-.patch
+Patch0130: 0130-parted-Allow-undocumented-commands.patch
+Patch0131: 0131-parted-Add-stub-resize-command-for-backward-compatib.patch
+Patch0132: 0132-Document-resizepart-command.patch
+Patch0133: 0133-tests-fix-t9020-alignment.sh.patch
+Patch0134: 0134-maint-correct-a-POT-file-updating-rule.patch
Buildroot: %{_tmppath}/%{name}-%{version}-%{release}-root-%(%{__id_u} -n)
BuildRequires: e2fsprogs-devel
@@ -289,6 +298,11 @@ fi
%changelog
+* Mon Jul 14 2014 Brian C. Lane <bcl at redhat.com> 3.1-29
+- Rebase on parted master commit 081ed98
+- libparted: Add support for partition resize
+- parted: add resizepart command
+
* Wed Jun 11 2014 Brian C. Lane <bcl at redhat.com> 3.1-28
- Rebase on parted master commit 1da239e2ebd2
- libparted: Fix bug with dupe and empty name
More information about the scm-commits
mailing list