From: Karel Zak Date: Thu, 19 Apr 2012 12:33:49 +0000 (+0200) Subject: libblkid: add support for PARTUUID= and PARTLABEL= X-Git-Tag: v2.22-rc1~517 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=fc387ee14c6b8672761ae5e67ff639b5cae8f27c;p=thirdparty%2Futil-linux.git libblkid: add support for PARTUUID= and PARTLABEL= Signed-off-by: Karel Zak --- diff --git a/include/pathnames.h b/include/pathnames.h index 1757044f5a..88bec08dfc 100644 --- a/include/pathnames.h +++ b/include/pathnames.h @@ -124,6 +124,8 @@ #define _PATH_DEV_BYUUID "/dev/disk/by-uuid" #define _PATH_DEV_BYID "/dev/disk/by-id" #define _PATH_DEV_BYPATH "/dev/disk/by-path" +#define _PATH_DEV_BYPARTLABEL "/dev/disk/by-partlabel" +#define _PATH_DEV_BYPARTUUID "/dev/disk/by-partuuid" /* hwclock paths */ #define _PATH_ADJPATH "/etc/adjtime" diff --git a/libblkid/src/evaluate.c b/libblkid/src/evaluate.c index d20b922f61..fbd8a96fd6 100644 --- a/libblkid/src/evaluate.c +++ b/libblkid/src/evaluate.c @@ -65,6 +65,9 @@ static int verify_tag(const char *devname, const char *name, const char *value) blkid_probe_set_superblocks_flags(pr, BLKID_SUBLKS_LABEL | BLKID_SUBLKS_UUID); + blkid_probe_enable_partitions(pr, TRUE); + blkid_probe_set_partitions_flags(pr, BLKID_PARTS_ENTRY_DETAILS); + fd = open(devname, O_RDONLY); if (fd < 0) { errsv = errno; @@ -139,6 +142,10 @@ static char *evaluate_by_udev(const char *token, const char *value, int uevent) strcpy(dev, _PATH_DEV_BYUUID "/"); else if (!strcmp(token, "LABEL")) strcpy(dev, _PATH_DEV_BYLABEL "/"); + else if (!strcmp(token, "PARTLABEL")) + strcpy(dev, _PATH_DEV_BYPARTLABEL "/"); + else if (!strcmp(token, "PARTUUID")) + strcpy(dev, _PATH_DEV_BYPARTUUID "/"); else { DBG(DEBUG_EVALUATE, printf("unsupported token %s\n", token)); diff --git a/libblkid/src/verify.c b/libblkid/src/verify.c index 49cc6f1738..cbb409607a 100644 --- a/libblkid/src/verify.c +++ b/libblkid/src/verify.c @@ -31,8 +31,17 @@ static void blkid_probe_to_tags(blkid_probe pr, blkid_dev dev) nvals = blkid_probe_numof_values(pr); for (n = 0; n < nvals; n++) { - if (blkid_probe_get_value(pr, n, &name, &data, &len) == 0) + if (blkid_probe_get_value(pr, n, &name, &data, &len) != 0) + continue; + if (strncmp(name, "PART_ENTRY_", 11) == 0) { + if (strcmp(name, "PART_ENTRY_UUID") == 0) + blkid_set_tag(dev, "PARTUUID", data, len); + else if (strcmp(name, "PART_ENTRY_NAME") == 0) + blkid_set_tag(dev, "PARTLABEL", data, len); + } else { + /* superblock UUID, LABEL, ... */ blkid_set_tag(dev, name, data, len); + } } } @@ -132,6 +141,9 @@ blkid_dev blkid_verify(blkid_cache cache, blkid_dev dev) BLKID_SUBLKS_LABEL | BLKID_SUBLKS_UUID | BLKID_SUBLKS_TYPE | BLKID_SUBLKS_SECTYPE); + blkid_probe_enable_partitions(cache->probe, TRUE); + blkid_probe_set_partitions_flags(cache->probe, BLKID_PARTS_ENTRY_DETAILS); + /* * If we already know the type, then try that first. */