[parted-devel] [PATCH 1/2] libparted: use ext_range to find out largest possible partition

Petr Uzel petr.uzel at suse.cz
Sat Nov 26 14:45:08 UTC 2011


Parted uses /sys/block/DEV/range file to find out how many partitions
can the blockdevice hold and uses this number in its algorithm
for informing the kernel about modified partitions. This works
fine for most devices, however, it fails on partitionable MD arrays,
because these have 1 in range file. Using ext_range should be safer
and work for all devices.

* libparted/arch/linux.c (_device_get_partition_range): Use
/sys/block/DEV/ext_range instead of range sysfs file
* NEWS: Mention the change.

Addresses: http://bugzilla.novell.com/567652
Signed-off-by: Petr Uzel <petr.uzel at suse.cz>
---
 NEWS                   |    4 ++++
 libparted/arch/linux.c |    4 ++--
 2 files changed, 6 insertions(+), 2 deletions(-)

diff --git a/NEWS b/NEWS
index 566484c..7797e4f 100644
--- a/NEWS
+++ b/NEWS
@@ -38,6 +38,10 @@ GNU parted NEWS                                    -*- outline -*-
   with an HFS or HFS+ signature, but with invalid ->total_blocks and/or
   ->block_size values.
 
+  parted now uses ext_range device sysfs attribute to determine maximum number
+  of partitions the device can hold. With this change, parted now now correctly
+  informs kernel about new partitions on partitionable MD RAID devices.
+
 ** Changes in behavior
 
   parted: mkpart command has changed semantics with regard to specifying end
diff --git a/libparted/arch/linux.c b/libparted/arch/linux.c
index ab3d904..1da3343 100644
--- a/libparted/arch/linux.c
+++ b/libparted/arch/linux.c
@@ -2484,7 +2484,7 @@ _loop_get_partition_range(PedDevice const* dev)
 
 /*
  * The number of partitions that a device can have depends on the kernel.
- * If we don't find this value in /sys/block/DEV/range, we will use our own
+ * If we don't find this value in /sys/block/DEV/ext_range, we will use our own
  * value.
  */
 static unsigned int
@@ -2495,7 +2495,7 @@ _device_get_partition_range(PedDevice const* dev)
                 return _loop_get_partition_range(dev);
 
         int range;
-        bool ok = _sysfs_int_entry_from_dev(dev, "range", &range);
+        bool ok = _sysfs_int_entry_from_dev(dev, "ext_range", &range);
 
         return ok && range > 0 ? range : MAX_NUM_PARTS;
 }
-- 
1.7.7




More information about the parted-devel mailing list