From 4fd4e8d35753f9d145b902985d8bd75e54efca63 Mon Sep 17 00:00:00 2001 From: Matthias Koenig Date: Tue, 17 Jul 2007 18:07:11 +0200 Subject: [PATCH] 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 --- fdisk/common.h | 4 ++++ fdisk/partname.c | 7 +++++++ 2 files changed, 11 insertions(+) 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) { -- 2.39.5