[parted-devel] [PATCH 1/2] libparted: don't canonicalize /dev/md/ paths

Brian C. Lane bcl at redhat.com
Wed Jan 9 00:02:37 UTC 2013


From: "Brian C. Lane" <bcl at redhat.com>

This is the same issue we have with /dev/mapper/ paths that was fixed in
commit c1eb485b9fd8919e18f192d678bc52b0488e6ee0. When libparted
is used to setup the device the symlink should be used to reference it,
not the backing device name which could change.

This is related to bug
https://bugzilla.redhat.com/show_bug.cgi?id=872361

* NEWS (Bug fixes): Mention it.
* libparted/device.c (ped_device_get): Don't canonicalize names
  that start with "/dev/md/".
---
 NEWS               | 3 +++
 libparted/device.c | 7 +++++--
 2 files changed, 8 insertions(+), 2 deletions(-)

diff --git a/NEWS b/NEWS
index 98f7c6e..f557b8e 100644
--- a/NEWS
+++ b/NEWS
@@ -4,6 +4,9 @@ GNU parted NEWS                                    -*- outline -*-
 
 ** Bug Fixes
 
+  libparted: Don't dereference symlinks in /dev/md/, the backing device
+  may change so it is better to reference the device via the symlink.
+
   libparted: Don't fail to manipulate partitions on dmraid disks that
   have other partitions in use.
 
diff --git a/libparted/device.c b/libparted/device.c
index 738b320..cdcc117 100644
--- a/libparted/device.c
+++ b/libparted/device.c
@@ -152,8 +152,11 @@ ped_device_get (const char* path)
 	char*		normal_path = NULL;
 
 	PED_ASSERT (path != NULL);
-	/* Don't canonicalize /dev/mapper paths, see tests/symlink.c */
-	if (strncmp (path, "/dev/mapper/", 12))
+	/* Don't canonicalize /dev/mapper or /dev/md/ paths, see
+	   tests/symlink.c
+	*/
+	if (strncmp (path, "/dev/mapper/", 12) &&
+	    strncmp (path, "/dev/md/", 8))
 		normal_path = canonicalize_file_name (path);
 	if (!normal_path)
 		/* Well, maybe it is just that the file does not exist.
-- 
1.8.0.2




More information about the parted-devel mailing list