OSDN Git Service

libparted: use ext_range to find out largest possible partition
authorPetr Uzel <petr.uzel@suse.cz>
Sat, 26 Nov 2011 14:45:08 +0000 (15:45 +0100)
committerJim Meyering <meyering@redhat.com>
Sat, 26 Nov 2011 21:13:30 +0000 (22:13 +0100)
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

NEWS
libparted/arch/linux.c

diff --git a/NEWS b/NEWS
index 566484c..5d8df35 100644 (file)
--- 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 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
index ab3d904..1da3343 100644 (file)
@@ -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;
 }