]> err.no Git - util-linux/commitdiff
fdisk: add support for udev persistent device names
authorMatthias Koenig <mkoenig@suse.de>
Tue, 17 Jul 2007 16:07:11 +0000 (18:07 +0200)
committerKarel Zak <kzak@redhat.com>
Mon, 23 Jul 2007 21:47:33 +0000 (23:47 +0200)
udev names partitions with the extension "-partN" (where N is a
partition number).

Signed-off-by: Matthias Koenig <mkoenig@suse.de>
fdisk/common.h
fdisk/partname.c

index 71eecc4e773b018373ca5604d754a9889bee890f..cc5a04cdc617fb8968331d643b241090f5ce5057 100644 (file)
@@ -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>
index e4bc42bcde52d5497768388ccc1addbce48cc777..0ae058f95d276830da4a61dfa78f90c57d2d1f30 100644 (file)
@@ -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) {