Package: parted;
Reported by: Phillip Susi <psusi <at> ubuntu.com>
Date: Mon, 23 Dec 2013 20:54:02 UTC
Severity: normal
Tags: patch
Done: Phillip Susi <psusi <at> ubuntu.com>
Bug is archived. No further changes may be made.
View this message in rfc822 format
From: help-debbugs <at> gnu.org (GNU bug Tracking System) To: Phillip Susi <psusi <at> ubuntu.com> Cc: tracker <at> debbugs.gnu.org Subject: bug#16231: closed ([PATCH] Fix loop labels) Date: Fri, 23 May 2014 00:07:02 +0000
[Message part 1 (text/plain, inline)]
Your message dated Thu, 22 May 2014 20:06:20 -0400 with message-id <537E90FC.3020308 <at> ubuntu.com> and subject line Re: bug#16231: [PATCH 0/9] Refactored loop fixes has caused the debbugs.gnu.org bug report #16231, regarding [PATCH] Fix loop labels to be marked as done. (If you believe you have received this mail in error, please contact help-debbugs <at> gnu.org.) -- 16231: http://debbugs.gnu.org/cgi/bugreport.cgi?bug=16231 GNU Bug Tracking System Contact help-debbugs <at> gnu.org with problems
[Message part 2 (message/rfc822, inline)]
From: Phillip Susi <psusi <at> ubuntu.com> To: bug-parted <at> gnu.org Subject: [PATCH] Fix loop labels Date: Mon, 23 Dec 2013 15:17:26 -0500Loop labels were incorrectly identifying the device for the fictional partition as $dev1 instead of just $dev. This caused other programs like gparted to be confused, and caused parted to fail to identify the partition as busy due to the fact that it was looking for the wrong device. Parted also actually created the partition device so your raw fs on $dev gained an alias as $dev1. --- NEWS | 2 + include/parted/device.in.h | 1 + libparted/arch/linux.c | 17 ++++++-- libparted/disk.c | 2 + libparted/labels/loop.c | 4 +- partprobe/partprobe.c | 4 +- tests/Makefile.am | 1 + tests/t1102-loop-label.sh | 96 ++++++++++++++++++++++++++++++++++++++++++++++ 8 files changed, 120 insertions(+), 7 deletions(-) create mode 100644 tests/t1102-loop-label.sh diff --git a/NEWS b/NEWS index 935fa33..816fb57 100644 --- a/NEWS +++ b/NEWS @@ -12,6 +12,8 @@ GNU parted NEWS -*- outline -*- boot partition type. ** Bug Fixes + Fix several bugs with loop labels ( whole disk filesystems ) + Fix gpt to correctly handle non ASCII charcters in partition names If a drive was 100 times an even multiple of two, sizes specified as diff --git a/include/parted/device.in.h b/include/parted/device.in.h index 7c06a66..1c1765a 100644 --- a/include/parted/device.in.h +++ b/include/parted/device.in.h @@ -86,6 +86,7 @@ struct _PedDevice { int external_mode; int dirty; int boot_dirty; + int loop; /* using "loop" partition table */ PedCHSGeometry hw_geom; PedCHSGeometry bios_geom; diff --git a/libparted/arch/linux.c b/libparted/arch/linux.c index f43eae1..8a09763 100644 --- a/libparted/arch/linux.c +++ b/libparted/arch/linux.c @@ -48,6 +48,7 @@ #include "../architecture.h" #include "dirname.h" #include "xstrtol.h" +#include "xalloc.h" #if ENABLE_NLS # include <libintl.h> @@ -2315,10 +2316,14 @@ _device_get_part_path (PedDevice const *dev, int num) ? dm_canonical_path (dev) : dev->path); size_t path_len = strlen (devpath); char *result; + + /* bare device, no partitions */ + if (dev->loop) + result = xstrdup(devpath); /* Check for devfs-style /disc => /partN transformation unconditionally; the system might be using udev with devfs rules, and if not the test is harmless. */ - if (5 < path_len && !strcmp (devpath + path_len - 5, "/disc")) { + else if (5 < path_len && !strcmp (devpath + path_len - 5, "/disc")) { /* replace /disc with /part%d */ result = zasprintf ("%.*s/part%d", (int) (path_len - 5), devpath, num); @@ -2814,7 +2819,10 @@ _disk_sync_part_table (PedDisk* disk) int i; /* remove old partitions first */ for (i = 1; i <= lpn; i++) { - PedPartition *part = ped_disk_get_partition (disk, i); + PedPartition *part; + if (disk->dev->loop) + part = 0; + else part = ped_disk_get_partition (disk, i); if (part) { unsigned long long length; unsigned long long start; @@ -2830,7 +2838,10 @@ _disk_sync_part_table (PedDisk* disk) } } for (i = 1; i <= lpn; i++) { - PedPartition *part = ped_disk_get_partition (disk, i); + PedPartition *part; + if (disk->dev->loop) + part = 0; + else part = ped_disk_get_partition (disk, i); if (part) { unsigned long long length; unsigned long long start; diff --git a/libparted/disk.c b/libparted/disk.c index ce71bfc..0eecd63 100644 --- a/libparted/disk.c +++ b/libparted/disk.c @@ -197,6 +197,7 @@ ped_disk_new (PedDevice* dev) disk = ped_disk_new_fresh (dev, type); if (!disk) goto error_close_dev; + dev->loop = 0; if (!type->ops->read (disk)) goto error_destroy_disk; disk->needs_clobber = 0; @@ -497,6 +498,7 @@ ped_disk_commit_to_dev (PedDisk* disk) goto error_close_dev; disk->needs_clobber = 0; } + disk->dev->loop = 0; if (!disk->type->ops->write (disk)) goto error_close_dev; ped_device_close (disk->dev); diff --git a/libparted/labels/loop.c b/libparted/labels/loop.c index ea8f007..b237c1e 100644 --- a/libparted/labels/loop.c +++ b/libparted/labels/loop.c @@ -121,6 +121,7 @@ loop_read (PedDisk* disk) if (found_sig) { ped_constraint_destroy (constraint_any); + dev->loop = 1; return 1; } @@ -142,6 +143,7 @@ loop_read (PedDisk* disk) if (!ped_disk_add_partition (disk, part, constraint_any)) goto error; ped_constraint_destroy (constraint_any); + dev->loop = 1; return 1; error_free_geom: @@ -159,7 +161,7 @@ loop_write (const PedDisk* disk) char *buf = ped_malloc (buflen); if (buf == NULL) return 0; - + disk->dev->loop = 1; if (ped_disk_get_partition (disk, 1)) { if (!ped_device_read (disk->dev, buf, 0, 1)) { free (buf); diff --git a/partprobe/partprobe.c b/partprobe/partprobe.c index 4da4fb7..8b744b5 100644 --- a/partprobe/partprobe.c +++ b/partprobe/partprobe.c @@ -106,9 +106,7 @@ process_dev (PedDevice* dev) PedDisk* disk; disk_type = ped_disk_probe (dev); - if (disk_type && !strcmp (disk_type->name, "loop")) - return 1; - else if (!disk_type) { + if (!disk_type) { /* Partition table not found, so create dummy, empty one */ disk_type = ped_disk_type_get("msdos"); diff --git a/tests/Makefile.am b/tests/Makefile.am index 7a6fe8f..fc0b5ec 100644 --- a/tests/Makefile.am +++ b/tests/Makefile.am @@ -40,6 +40,7 @@ TESTS = \ t0501-duplicate.sh \ t1100-busy-label.sh \ t1101-busy-partition.sh \ + t1102-loop-label.sh \ t1700-probe-fs.sh \ t2200-dos-label-recog.sh \ t2201-pc98-label-recog.sh \ diff --git a/tests/t1102-loop-label.sh b/tests/t1102-loop-label.sh new file mode 100644 index 0000000..b26addd --- /dev/null +++ b/tests/t1102-loop-label.sh @@ -0,0 +1,96 @@ +#!/bin/sh +# make sure that loop labels do busy detection and don't +# create an actual partition + +# Copyright (C) 2013 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 +path_prepend_ ../partprobe +require_root_ +require_scsi_debug_module_ +ss=$sector_size_ + +scsi_debug_setup_ sector_size=$ss dev_size_mb=90 > dev-name || + skip_ 'failed to create scsi_debug device' +dev=$(cat dev-name) + +mke2fs -F $dev +parted -s "$dev" print > out 2>&1 || fail=1 +cat <<EOF > exp +Model: Linux scsi_debug (scsi) +Disk DEVICE: 94.4MB +Sector size (logical/physical): 512B/512B +Partition Table: loop +Disk Flags: + +Number Start End Size File system Flags + 1 0.00B 94.4MB 94.4MB ext2 + +EOF +mv out o2 && sed -e "s,$dev,DEVICE,;" o2 > out + +compare exp out || fail=1 +parted -s $dev rm 1 mkpart ext2 0% 100% || fail=1 +if [ -e ${dev}1 ]; then + echo "Partition should not exist on loop device" + fail=1 +fi +partprobe $dev || fail=1 +if [ -e ${dev}1 ]; then + echo "Partition should not exist on loop device" + fail=1 +fi + +mount_point="`pwd`/mnt" + +# Be sure to unmount upon interrupt, failure, etc. +cleanup_fn_() { umount "$mount_point" > /dev/null 2>&1; } + +# create mount point dir. and mount the just-created partition on it +mkdir $mount_point || fail=1 +mount -t ext2 "${dev}" $mount_point || fail=1 + +# now that a partition is mounted, mklabel attempt must fail +parted -s "$dev" mklabel msdos > out 2>&1; test $? = 1 || fail=1 + +# create expected output file +echo "Error: Partition(s) on $dev are being used." > exp +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/sde is being used. You must unmount it before you modify \ +it with Parted." > exp +compare exp out || fail=1 + +umount "$mount_point" + +# make sure partprobe cleans up stale partition devices +parted -s $dev mklabel msdos mkpart primary ext2 0% 100% +if [ ! -e ${dev}1 ]; then + echo "Partition doesn't exist on loop device" + fail=1 +fi + +mke2fs -F $dev +partprobe $dev +if [ -e ${dev}1 ]; then + echo "Partition should not exist on loop device" + fail=1 +fi + +Exit $fail -- 1.8.3.2
[Message part 3 (message/rfc822, inline)]
From: Phillip Susi <psusi <at> ubuntu.com> Cc: 16231-done <at> debbugs.gnu.org Subject: Re: bug#16231: [PATCH 0/9] Refactored loop fixes Date: Thu, 22 May 2014 20:06:20 -0400-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA512 On 05/22/2014 03:01 PM, Brian C. Lane wrote: > Sure enough, I was missing that one. Looks good, and passes all > tests on all arches. Patches pushed. -----BEGIN PGP SIGNATURE----- Version: GnuPG v1 Comment: Using GnuPG with Thunderbird - http://www.enigmail.net/ iQEcBAEBCgAGBQJTfpD8AAoJEI5FoCIzSKrwyYcH/A8ofwpaDKB+9sL4h/eV+Ako lNBT4qRMwS3DecOkUrhvr9xbs+qYQztqHPkyAeB/6jdbGpNZY1TgarqmOu42zU8d nq0cHZFFfnbRm7yL7Sr3aw4rl/dtFMPiCqU6TjsGEFLOWg0nIapoHUhVhLGCpTCY b5ShqxdRaTrMjj00BvyKDwPwGdsMfEXkwMfcKx8W/eG2VJnOOXHBOZVV8edJF7Ew T+LSbzMxqlRt7GCcgrZTl5Ooya5jRfp6bsqKS3ihYwfLzp9w9TMw6ozxNZEkffgV 79PVmHJMUeXKeKvwGHjhhKFUSim4oAy/HYDgO4/I12++eRJZjEe7O7k5DruPbTU= =cN6b -----END PGP SIGNATURE-----
GNU bug tracking system
Copyright (C) 1999 Darren O. Benham,
1997,2003 nCipher Corporation Ltd,
1994-97 Ian Jackson.