Hans de Goede wrote: > We cannot do partition related ioctl's on loopback devices, so > treat them as files. > > * libparted/arch/linux.c(LOOP_MAJOR): New define. > * libparted/arch/linux.c(_device_probe_type): Treat loopback > devices as files. > --- > libparted/arch/linux.c | 3 +++ > 1 files changed, 3 insertions(+), 0 deletions(-) > > diff --git a/libparted/arch/linux.c b/libparted/arch/linux.c > index 94cbae9..9d15bf2 100644 > --- a/libparted/arch/linux.c > +++ b/libparted/arch/linux.c > @@ -254,6 +254,7 @@ struct blkdev_ioctl_param { > #define SX8_MAJOR2 161 > #define XVD_MAJOR 202 > #define SDMMC_MAJOR 179 > +#define LOOP_MAJOR 7 > > #define SCSI_BLK_MAJOR(M) ( \ > (M) == SCSI_DISK0_MAJOR \ > @@ -569,6 +570,8 @@ _device_probe_type (PedDevice* dev) > dev->type = PED_DEVICE_SDMMC; > } else if (_is_virtblk_major(dev_major)) { > dev->type = PED_DEVICE_VIRTBLK; > + } else if (dev_major == LOOP_MAJOR) { > + dev->type = PED_DEVICE_FILE; > } else { > dev->type = PED_DEVICE_UNKNOWN; > }
Thank you! I've adjusted the log message, added a NEWS entry and fixed the tests/t8000-loop.sh test to pass with this new behavior: >From 1983b7b517604aade6a317e8384bd5a58f8e20f5 Mon Sep 17 00:00:00 2001 From: Hans de Goede <hdego...@redhat.com> Date: Fri, 11 Dec 2009 11:24:52 +0100 Subject: [PATCH 1/2] linux: treat loopback devices as files We cannot do partition related ioctl's on loopback devices, so treat them as files. * libparted/arch/linux.c (LOOP_MAJOR): Define. * libparted/arch/linux.c (_device_probe_type): Treat loopback devices as files. Reported by Josef Bacik in http://bugzilla.redhat.com/546622 --- libparted/arch/linux.c | 3 +++ 1 files changed, 3 insertions(+), 0 deletions(-) diff --git a/libparted/arch/linux.c b/libparted/arch/linux.c index 94cbae9..9d15bf2 100644 --- a/libparted/arch/linux.c +++ b/libparted/arch/linux.c @@ -254,6 +254,7 @@ struct blkdev_ioctl_param { #define SX8_MAJOR2 161 #define XVD_MAJOR 202 #define SDMMC_MAJOR 179 +#define LOOP_MAJOR 7 #define SCSI_BLK_MAJOR(M) ( \ (M) == SCSI_DISK0_MAJOR \ @@ -569,6 +570,8 @@ _device_probe_type (PedDevice* dev) dev->type = PED_DEVICE_SDMMC; } else if (_is_virtblk_major(dev_major)) { dev->type = PED_DEVICE_VIRTBLK; + } else if (dev_major == LOOP_MAJOR) { + dev->type = PED_DEVICE_FILE; } else { dev->type = PED_DEVICE_UNKNOWN; } -- 1.6.6.rc1.319.g9b57d >From 6792f263d47f9550869fde3a751aaf7349b91c0a Mon Sep 17 00:00:00 2001 From: Jim Meyering <meyer...@redhat.com> Date: Fri, 11 Dec 2009 16:56:45 +0100 Subject: [PATCH 2/2] tests: ensure that parted can partition a loop device * tests/t8000-loop.sh: Reverse sense of tests, now that partitioning a loop device succeeds again. * NEWS (Bug fixes): Mention it. --- NEWS | 4 ++++ tests/t8000-loop.sh | 28 ++++++++-------------------- 2 files changed, 12 insertions(+), 20 deletions(-) diff --git a/NEWS b/NEWS index cd67678..b3d69bc 100644 --- a/NEWS +++ b/NEWS @@ -56,6 +56,10 @@ GNU parted NEWS -*- outline -*- ** Bug fixes + parted can once again create partition tables on loop devices. + Before, "parted -s /dev/loop0 mklabel gpt" would fail. + [bug introduced in parted-1.9.0] + improved >512-byte sector support: for example, printing a table on a 4k-sector disk would show "Sector size (logical/physical): 4096B/512B", when the sizes should have been "4096B/4096B". diff --git a/tests/t8000-loop.sh b/tests/t8000-loop.sh index de4378a..e8c27fe 100755 --- a/tests/t8000-loop.sh +++ b/tests/t8000-loop.sh @@ -25,37 +25,25 @@ fi . $srcdir/t-lib.sh require_root_ -lvm_init_root_dir_ -d1= +d1= f1= cleanup_() { test -n "$d1" && losetup -d "$d1" - rm -f "$f1"; + rm -f "$f1" } f1=$(pwd)/1; d1=$(loop_setup_ "$f1") \ || skip_test_ "is this partition mounted with 'nodev'?" -printf '%s\n' \ - 'Warning: WARNING: the kernel failed to re-read the partition table on' \ - > exp || framework_failure - fail=0 -# Expect this to exit with status of 1. -parted -s $d1 mklabel msdos > err 2>&1 -test $? = 1 || fail=1 -sed 's/^\(Warn.*table on\).*/\1/' err > k && mv k err || fail=1 - -compare exp err || fail=1 - -# Create a partition; expect to exit 1 -parted -s $d1 mkpart primary 1 10 > err 2>&1 -test $? = 1 || fail=1 -sed 's/^\(Warn.*table on\).*/\1/' err > k && mv k err || fail=1 +# Expect this to succeed. +parted -s $d1 mklabel msdos > err 2>&1 || fail=1 +compare err /dev/null || fail=1 # expect no output -# check for expected output -compare exp err || fail=1 +# Create a partition +parted -s $d1 mkpart primary 1 10 > err 2>&1 || fail=1 +compare err /dev/null || fail=1 # expect no output Exit $fail -- 1.6.6.rc1.319.g9b57d _______________________________________________ bug-parted mailing list bug-parted@gnu.org http://lists.gnu.org/mailman/listinfo/bug-parted