Merge lp:~psusi/ubuntu/raring/parted/resize into lp:ubuntu/raring/parted

Proposed by Phillip Susi
Status: Needs review
Proposed branch: lp:~psusi/ubuntu/raring/parted/resize
Merge into: lp:ubuntu/raring/parted
Diff against target: 308 lines (+278/-0)
5 files modified
debian/changelog (+8/-0)
debian/patches/0001-parted-resizepart-command.patch (+134/-0)
debian/patches/0003-libparted-Add-support-for-BLKPG-ioctl-partition-resi.patch (+88/-0)
debian/patches/0004-parted-make-_partition_warn_busy-actually-a-warning-.patch (+45/-0)
debian/patches/series (+3/-0)
To merge this branch: bzr merge lp:~psusi/ubuntu/raring/parted/resize
Reviewer Review Type Date Requested Status
Scott Moser Pending
Review via email: mp+151401@code.launchpad.net
To post a comment you must log in.

Unmerged revisions

118. By Phillip Susi

Backport online resize patches: 0001-parted-resizepart-command.patch,
0003-libparted-Add-support-for-BLKPG-ioctl-partition-resi.patch,
and 0004-parted-make-_partition_warn_busy-actually-a-warning.patch

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'debian/changelog'
2--- debian/changelog 2012-10-23 11:50:25 +0000
3+++ debian/changelog 2013-03-03 23:38:21 +0000
4@@ -1,3 +1,11 @@
5+parted (2.3-11ubuntu2) raring; urgency=low
6+
7+ * Backport online resize patches: 0001-parted-resizepart-command.patch,
8+ 0003-libparted-Add-support-for-BLKPG-ioctl-partition-resi.patch,
9+ and 0004-parted-make-_partition_warn_busy-actually-a-warning.patch
10+
11+ -- Phillip Susi <psusi@ubuntu.com> Sun, 24 Feb 2013 12:25:51 -0500
12+
13 parted (2.3-11ubuntu1) raring; urgency=low
14
15 * Resynchronise with Debian. Remaining changes:
16
17=== added file 'debian/patches/0001-parted-resizepart-command.patch'
18--- debian/patches/0001-parted-resizepart-command.patch 1970-01-01 00:00:00 +0000
19+++ debian/patches/0001-parted-resizepart-command.patch 2013-03-03 23:38:21 +0000
20@@ -0,0 +1,134 @@
21+From be7c4b8da40aca5296f96d09ae73fbb7f5250b99 Mon Sep 17 00:00:00 2001
22+From: Petr Uzel <petr.uzel@suse.cz>
23+Date: Mon, 26 Sep 2011 17:21:01 +0200
24+Subject: [PATCH 1/6] parted: resizepart command
25+
26+TODO
27+---
28+ parted/parted.c | 89 +++++++++++++++++++++++++++++++++++++++++++++++++++++++
29+ 1 file changed, 89 insertions(+)
30+
31+Index: b/parted/parted.c
32+===================================================================
33+--- a/parted/parted.c
34++++ b/parted/parted.c
35+@@ -150,6 +150,9 @@
36+ static const char* start_end_msg = N_("START and END are disk locations, such as "
37+ "4GB or 10%. Negative values count from the end of the disk. "
38+ "For example, -1s specifies exactly the last sector.\n");
39++static const char* end_msg = N_("END is disk location, such as "
40++ "4GB or 10%. Negative value counts from the end of the disk. "
41++ "For example, -1s specifies exactly the last sector.\n");
42+ static const char* state_msg = N_("STATE is one of: on, off\n");
43+ static const char* device_msg = N_("DEVICE is usually /dev/hda or /dev/sda\n");
44+ static const char* name_msg = N_("NAME is any word you want\n");
45+@@ -466,6 +469,21 @@
46+ return result;
47+ }
48+
49++
50++static PedConstraint*
51++constraint_from_start_end_fixed_start (PedDevice* dev, PedSector start_sector,
52++ PedGeometry* range_end)
53++{
54++ PedGeometry range_start;
55++ range_start.dev = dev;
56++ range_start.start = start_sector;
57++ range_start.end = start_sector;
58++ range_start.length = 1;
59++
60++ return ped_constraint_new (ped_alignment_any, ped_alignment_any,
61++ &range_start, range_end, 1, dev->length);
62++}
63++
64+ void
65+ help_on (char* topic)
66+ {
67+@@ -2004,11 +2022,69 @@
68+ }
69+
70+ static int
71++do_resizepart (PedDevice** dev)
72++{
73++ PedDisk *disk;
74++ PedPartition *part = NULL;
75++ PedSector start, end, oldend;
76++ PedGeometry *range_end = NULL;
77++ PedConstraint* constraint;
78++
79++ disk = ped_disk_new (*dev);
80++ if (!disk)
81++ goto error;
82++
83++ if (ped_disk_is_flag_available(disk, PED_DISK_CYLINDER_ALIGNMENT))
84++ if (!ped_disk_set_flag(disk, PED_DISK_CYLINDER_ALIGNMENT,
85++ alignment == ALIGNMENT_CYLINDER))
86++ goto error;
87++
88++ if (!command_line_get_partition (_("Partition number?"), disk, &part))
89++ goto error;
90++ if (!_partition_warn_busy (part))
91++ goto error;
92++
93++ start = part->geom.start;
94++ end = oldend = part->geom.end;
95++ if (!command_line_get_sector (_("End?"), *dev, &end, &range_end))
96++ goto error;
97++ /* Do not move start of the partition */
98++ constraint = constraint_from_start_end_fixed_start (*dev, start, range_end);
99++ if (!ped_disk_set_partition_geom (disk, part, constraint,
100++ start, end))
101++ goto error_destroy_constraint;
102++ /* warn when shrinking partition - might lose data */
103++ if (part->geom.end < oldend)
104++ if (ped_exception_throw (
105++ PED_EXCEPTION_WARNING,
106++ PED_EXCEPTION_YES_NO,
107++ _("Shrinking a partition can cause data loss, " \
108++ "are you sure you want to continue?")) != PED_EXCEPTION_YES)
109++ goto error_destroy_constraint;
110++ ped_disk_commit (disk);
111++ ped_constraint_destroy (constraint);
112++ if (range_end != NULL)
113++ ped_geometry_destroy (range_end);
114++
115++ if ((*dev)->type != PED_DEVICE_FILE)
116++ disk_is_modified = 1;
117++
118++ return 1;
119++
120++error_destroy_constraint:
121++ ped_constraint_destroy (constraint);
122++error:
123++ if (range_end != NULL)
124++ ped_geometry_destroy (range_end);
125++ return 0;
126++}
127++
128++
129++static int
130+ do_rm (PedDevice** dev)
131+ {
132+- PedDisk* disk;
133++ PedDisk* disk;
134+ PedPartition* part = NULL;
135+-
136+ disk = ped_disk_new (*dev);
137+ if (!disk)
138+ goto error;
139+@@ -2423,6 +2499,15 @@
140+ NULL),
141+ str_list_create (_(part_type_msg), _(start_end_msg), NULL), 1));
142+
143++//XXX: mention that this command does never move start of the partition
144++command_register (commands, command_create (
145++ str_list_create_unique ("resizepart", _("resizepart"), NULL),
146++ do_resizepart,
147++ str_list_create (
148++_("resizepart NUMBER END resize partition NUMBER"),
149++NULL),
150++ str_list_create (_(number_msg), _(end_msg), NULL), 1));
151++
152+ command_register (commands, command_create (
153+ str_list_create_unique ("move", _("move"), NULL),
154+ do_move,
155
156=== added file 'debian/patches/0003-libparted-Add-support-for-BLKPG-ioctl-partition-resi.patch'
157--- debian/patches/0003-libparted-Add-support-for-BLKPG-ioctl-partition-resi.patch 1970-01-01 00:00:00 +0000
158+++ debian/patches/0003-libparted-Add-support-for-BLKPG-ioctl-partition-resi.patch 2013-03-03 23:38:21 +0000
159@@ -0,0 +1,88 @@
160+From 6ca0769fcc25f1e4fc7b40769eabd05804670b30 Mon Sep 17 00:00:00 2001
161+From: Phillip Susi <psusi@ubuntu.com>
162+Date: Tue, 29 Nov 2011 14:05:48 -0500
163+Subject: [PATCH 3/6] libparted: Add support for BLKPG ioctl partition resize
164+
165+When resizing a partition ( same partition number, same
166+start sector, different end sector ), if removing the old
167+partition fails because it is in use, try to use the
168+new BLKPG_RES_PARTITION request to update the kernel
169+partition table with the new size.
170+---
171+ libparted/arch/linux.c | 56 ++++++++++++++++++++++++++++++++++++++++++++++++
172+ 1 file changed, 56 insertions(+)
173+
174+Index: b/libparted/arch/linux.c
175+===================================================================
176+--- a/libparted/arch/linux.c
177++++ b/libparted/arch/linux.c
178+@@ -2481,6 +2481,53 @@
179+ BLKPG_DEL_PARTITION);
180+ }
181+
182++#ifdef BLKPG_RESIZE_PARTITION
183++static int _blkpg_resize_partition (PedDisk* disk, const PedPartition *part)
184++{
185++ struct blkpg_partition linux_part;
186++ const char* vol_name;
187++ char* dev_name;
188++
189++ PED_ASSERT(disk != NULL, return 0);
190++ PED_ASSERT(disk->dev->sector_size % PED_SECTOR_SIZE_DEFAULT == 0, return 0);
191++
192++ dev_name = _device_get_part_path (disk->dev, part->num);
193++ if (!dev_name)
194++ return 0;
195++ memset (&linux_part, 0, sizeof (linux_part));
196++ linux_part.start = part->geom.start * disk->dev->sector_size;
197++ /* see fs/partitions/msdos.c:msdos_partition(): "leave room for LILO" */
198++ if (part->type & PED_PARTITION_EXTENDED)
199++ linux_part.length = part->geom.length == 1 ? 512 : 1024;
200++ else
201++ linux_part.length = part->geom.length * disk->dev->sector_size;
202++ linux_part.pno = part->num;
203++ strncpy (linux_part.devname, dev_name, BLKPG_DEVNAMELTH);
204++ if (vol_name)
205++ strncpy (linux_part.volname, vol_name, BLKPG_VOLNAMELTH);
206++
207++ free (dev_name);
208++
209++ if (!_blkpg_part_command (disk->dev, &linux_part,
210++ BLKPG_RESIZE_PARTITION)) {
211++ return ped_exception_throw (
212++ PED_EXCEPTION_ERROR,
213++ PED_EXCEPTION_IGNORE_CANCEL,
214++ _("Error informing the kernel about modifications to "
215++ "partition %s -- %s. This means Linux won't know "
216++ "about any changes you made to %s until you reboot "
217++ "-- so you shouldn't mount it or use it in any way "
218++ "before rebooting."),
219++ linux_part.devname,
220++ strerror (errno),
221++ linux_part.devname)
222++ == PED_EXCEPTION_IGNORE;
223++ }
224++
225++ return 1;
226++}
227++#endif
228++
229+ /* Read the unsigned long long from /sys/block/DEV_BASE/PART_BASE/ENTRY
230+ and set *VAL to that value, where DEV_BASE is the last component of path to
231+ block device corresponding to PART and PART_BASE is the sysfs name of PART.
232+@@ -2695,6 +2742,15 @@
233+ if (start == part->geom.start
234+ && length == part->geom.length)
235+ ok[i - 1] = 1;
236++#ifdef BLKPG_RESIZE_PARTITION
237++ if (start == part->geom.start
238++ && length != part->geom.length)
239++ {
240++ /* try to resize */
241++ if (_blkpg_resize_partition (disk, part))
242++ ok[i - 1] = 1;
243++ }
244++#endif
245+ /* If the new partition is unchanged and the
246+ existing one was not removed because it was
247+ in use, then reset the error flag and do not
248
249=== added file 'debian/patches/0004-parted-make-_partition_warn_busy-actually-a-warning-.patch'
250--- debian/patches/0004-parted-make-_partition_warn_busy-actually-a-warning-.patch 1970-01-01 00:00:00 +0000
251+++ debian/patches/0004-parted-make-_partition_warn_busy-actually-a-warning-.patch 2013-03-03 23:38:21 +0000
252@@ -0,0 +1,45 @@
253+From 7ef73999b35294a8fd30f5af4eb6221a0ce62802 Mon Sep 17 00:00:00 2001
254+From: Phillip Susi <psusi@ubuntu.com>
255+Date: Wed, 30 Nov 2011 13:13:58 -0500
256+Subject: [PATCH 4/6] parted: make _partition_warn_busy actually a warning
257+ instead of an error
258+
259+This function was throwing a PED_EXCEPTION_ERROR with only the
260+PED_EXCEPTION_CANCEL option. Converted to a PED_EXCEPTION_WARNING
261+with the option to continue anyhow.
262+---
263+ parted/parted.c | 19 +++++++++++--------
264+ tests/t1101-busy-partition.sh | 2 +-
265+ tests/t9041-undetected-in-use-16th-partition.sh | 4 ++--
266+ 3 files changed, 14 insertions(+), 11 deletions(-)
267+
268+Index: b/parted/parted.c
269+===================================================================
270+--- a/parted/parted.c
271++++ b/parted/parted.c
272+@@ -224,14 +224,17 @@
273+
274+ if (ped_partition_is_busy (part)) {
275+ path = ped_partition_get_path (part);
276+- ped_exception_throw (
277+- PED_EXCEPTION_ERROR,
278+- PED_EXCEPTION_CANCEL,
279+- _("Partition %s is being used. You must unmount it "
280+- "before you modify it with Parted."),
281+- path);
282+- free (path);
283+- return 0;
284++ if (ped_exception_throw (
285++ PED_EXCEPTION_WARNING,
286++ PED_EXCEPTION_YES_NO,
287++ _("Partition %s is being used. Are you sure you " \
288++ "want to continue?"),
289++ path) != PED_EXCEPTION_YES)
290++ {
291++ free (path);
292++ return 0;
293++ }
294++ free (path);
295+ }
296+ return 1;
297+ }
298
299=== modified file 'debian/patches/series'
300--- debian/patches/series 2012-10-23 11:50:25 +0000
301+++ debian/patches/series 2013-03-03 23:38:21 +0000
302@@ -44,3 +44,6 @@
303
304 # Ubuntu FTBFS eglibc-2.16
305 gnulib-gets.patch
306+0001-parted-resizepart-command.patch
307+0003-libparted-Add-support-for-BLKPG-ioctl-partition-resi.patch
308+0004-parted-make-_partition_warn_busy-actually-a-warning-.patch

Subscribers

People subscribed via source and target branches

to all changes: