[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [PATCH 1/5] Remove loop_get_partition_range
From: |
Jim Meyering |
Subject: |
Re: [PATCH 1/5] Remove loop_get_partition_range |
Date: |
Wed, 21 Dec 2011 18:18:34 +0100 |
Phillip Susi wrote:
> Commit 1eb0cc30 added support for loop devices to be partitioned,
> but it only enabled that support if the kernel parameter max_part
> was non zero. This parameter just reserves minor numbers for
> partitions in the traditional sequence that hard disks used.
> When it is zero, it is still possible to add partitions, they
> just will get minor numbers from another pool. Removing this
> check allows partitions to be used on loop devices even when the
> loop module was not loaded with the max_part argument.
Thank you for the patch. So far, this looks fine.
Nits I've corrected:
- it failed a "make syntax-check" test due to trailing blanks
- the function name in the commit log lacked the leading "_"
- I made the indentation of _device_get_partition_range consistent.
It was using a mix of spaces and TABs.
>From 2ba5f5fdc307429cfd369ea8155cd5dcd8829181 Mon Sep 17 00:00:00 2001
From: Phillip Susi <address@hidden>
Date: Fri, 16 Dec 2011 22:40:04 -0500
Subject: [PATCH] libparted: remove _loop_get_partition_range
Commit 1eb0cc30 added support for loop devices to be partitioned,
but it only enabled that support if the kernel parameter max_part
was non zero. This parameter just reserves minor numbers for
partitions in the traditional sequence that hard disks used.
When it is zero, it is still possible to add partitions, they
just will get minor numbers from another pool. Removing this
check allows partitions to be used on loop devices even when the
loop module was not loaded with the max_part argument.
* libparted/arch/linux.c (_loop_get_partition_range): Remove function
and all uses.
---
libparted/arch/linux.c | 41 ++++-------------------------------------
1 files changed, 4 insertions(+), 37 deletions(-)
diff --git a/libparted/arch/linux.c b/libparted/arch/linux.c
index e7166a8..2c8902d 100644
--- a/libparted/arch/linux.c
+++ b/libparted/arch/linux.c
@@ -2449,38 +2449,6 @@ _sysfs_int_entry_from_dev(PedDevice const* dev, const
char *entry, int *val)
return ok;
}
-/* Return the maximum number of partitions that the loopback device can hold.
- First, check the loop-module-exported max_part parameter (since linux-3.0).
- If that is not available, fall back to checking ext_range, which seems to
- have (for some reason) different semantics compared to other devices;
- specifically, ext_range <= 1 means that the loopback device does
- not support partitions. */
-static unsigned int
-_loop_get_partition_range(PedDevice const* dev)
-{
- int max_part;
- bool ok = false;
-
- /* max_part module param is exported since kernel 3.0 */
- FILE *fp = fopen("/sys/module/loop/parameters/max_part", "r");
- if (fp) {
- ok = fscanf(fp, "%d", &max_part) == 1;
- fclose(fp);
- }
-
- if (ok)
- return max_part > 0 ? max_part : 0;
-
- /*
- * max_part is not exported - check ext_range;
- * device supports partitions if ext_range > 1
- */
- int range;
- ok = _sysfs_int_entry_from_dev(dev, "range", &range);
-
- return ok && range > 1 ? range : 0;
-}
-
/*
* The number of partitions that a device can have depends on the kernel.
* If we don't find this value in /sys/block/DEV/ext_range, we will use our own
@@ -2489,14 +2457,13 @@ _loop_get_partition_range(PedDevice const* dev)
static unsigned int
_device_get_partition_range(PedDevice const* dev)
{
- /* loop handling is special */
- if (dev->type == PED_DEVICE_LOOP)
- return _loop_get_partition_range(dev);
-
int range;
bool ok = _sysfs_int_entry_from_dev(dev, "ext_range", &range);
- return ok && range > 0 ? range : MAX_NUM_PARTS;
+ if (!ok)
+ return MAX_NUM_PARTS;
+ /* both 0 and 1 mean no partitions */
+ return range > 1 ? range : 0;
}
/*
--
1.7.8.354.g4f48c
- [PATCH 4/5] Fix loop test, (continued)
- [PATCH 4/5] Fix loop test, Phillip Susi, 2011/12/16
- Re: [PATCH 4/5] Fix loop test, Jim Meyering, 2011/12/21
- Re: [PATCH 4/5] Fix loop test, Phillip Susi, 2011/12/21
- Re: [PATCH 4/5] Fix loop test, Jim Meyering, 2011/12/21
- Re: [PATCH 4/5] Fix loop test, Phillip Susi, 2011/12/21
- Re: [PATCH 4/5] Fix loop test, Keshav P R, 2011/12/21
- Re: [PATCH 4/5] Fix loop test, Jim Meyering, 2011/12/22
- Re: [PATCH 4/5] Fix loop test, Phillip Susi, 2011/12/22
- Re: [PATCH 4/5] Fix loop test, Jim Meyering, 2011/12/23
[PATCH 2/5] Remove has_partitions check to allow loopback partitions, Phillip Susi, 2011/12/16
Re: [PATCH 1/5] Remove loop_get_partition_range,
Jim Meyering <=