[PATCH] fdisk: add support for udev persistent device names

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



udev names partitions with the extension "-partN" (where N is a
partition number).

Signed-off-by: Matthias Koenig <mkoenig@xxxxxxx>
---
 fdisk/common.h   |    4 ++++
 fdisk/partname.c |    7 +++++++
 2 files changed, 11 insertions(+), 0 deletions(-)

diff --git a/fdisk/common.h b/fdisk/common.h
index 71eecc4..cc5a04c 100644
--- a/fdisk/common.h
+++ b/fdisk/common.h
@@ -3,6 +3,10 @@
 
 /* common stuff for fdisk, cfdisk, sfdisk */
 
+/* udev paths */
+#define PATH_DEV_BYID   "/dev/disk/by-id"
+#define PATH_DEV_BYPATH "/dev/disk/by-path"
+
 /* including <linux/fs.h> fails */
 #include <sys/types.h>
 #include <sys/ioctl.h>
diff --git a/fdisk/partname.c b/fdisk/partname.c
index e4bc42b..60b491c 100644
--- a/fdisk/partname.c
+++ b/fdisk/partname.c
@@ -30,6 +30,13 @@ partnamebf(char *dev, int pno, int lth, int bufsiz, char *bufp) {
 		p = "part";
 	}
 
+	/* udev names partitions by appending -partN
+	   e.g. ata-SAMSUNG_SV8004H_0357J1FT712448-part1 */
+	if ((strncmp(dev, PATH_DEV_BYID, strlen(PATH_DEV_BYID)) == 0) ||
+	     strncmp(dev, PATH_DEV_BYPATH, strlen(PATH_DEV_BYPATH)) == 0) {
+	       p = "-part";	
+	}
+
 	wp = strlen(p);
 		
 	if (lth) {
-- 
1.5.0.4.GIT

-
To unsubscribe from this list: send the line "unsubscribe util-linux-ng" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html

[Index of Archives]     [Netdev]     [Ethernet Bridging]     [Linux Wireless]     [Kernel Newbies]     [Security]     [Linux for Hams]     [Netfilter]     [Bugtraq]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux RAID]     [Linux Admin]     [Samba]

  Powered by Linux