From: Matthias Koenig Date: Tue, 17 Jul 2007 16:07:11 +0000 (+0200) Subject: fdisk: add support for udev persistent device names X-Git-Url: https://err.no/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=4fd4e8d35753f9d145b902985d8bd75e54efca63;p=util-linux fdisk: add support for udev persistent device names udev names partitions with the extension "-partN" (where N is a partition number). Signed-off-by: Matthias Koenig --- diff --git a/fdisk/common.h b/fdisk/common.h index 71eecc4e..cc5a04cd 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 fails */ #include #include diff --git a/fdisk/partname.c b/fdisk/partname.c index e4bc42bc..0ae058f9 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) {