From: Karel Zak Date: Wed, 3 Jun 2020 14:53:00 +0000 (+0200) Subject: libmount: add support for ID= X-Git-Tag: v2.36-rc1~26 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=b3391f3ac790b52ec14d763c0ff5cde808309d76;p=thirdparty%2Futil-linux.git libmount: add support for ID= This patch add support for a new tag. The tag is based on udev block device ID (see /dev/disk/by-id). The usual use-case is to use WWN for this purpose, for example # mount ID=wwn-0x50026b724b09a1ff /mnt Note that ID is not strictly defined and udevd generates various IDs also for HW where WWN is undefined. This is reason why introduce ID= seems better and more generic than more restrictive WWN=. Addresses: https://github.com/karelzak/util-linux/issues/1008 Signed-off-by: Karel Zak --- diff --git a/libblkid/src/evaluate.c b/libblkid/src/evaluate.c index 8ba8bd5f37..710eac9566 100644 --- a/libblkid/src/evaluate.c +++ b/libblkid/src/evaluate.c @@ -59,6 +59,9 @@ static int verify_tag(const char *devname, const char *name, const char *value) const char *data; int errsv = 0; + if (strcmp(token, "ID") == 0) + return 0; /* non-content tag */ + pr = blkid_new_probe(); if (!pr) return -1; @@ -149,6 +152,8 @@ static char *evaluate_by_udev(const char *token, const char *value, int uevent) strcpy(dev, _PATH_DEV_BYPARTLABEL "/"); else if (!strcmp(token, "PARTUUID")) strcpy(dev, _PATH_DEV_BYPARTUUID "/"); + else if (!strcmp(token, "ID")) + strcpy(dev, _PATH_DEV_BYID "/"); else { DBG(EVALUATE, ul_debug("unsupported token %s", token)); return NULL; /* unsupported tag */ diff --git a/libmount/src/utils.c b/libmount/src/utils.c index 6be7a72c0a..92829ebb01 100644 --- a/libmount/src/utils.c +++ b/libmount/src/utils.c @@ -72,6 +72,7 @@ int is_file_empty(const char *name) int mnt_valid_tagname(const char *tagname) { if (tagname && *tagname && ( + strcmp("ID", tagname) == 0 || strcmp("UUID", tagname) == 0 || strcmp("LABEL", tagname) == 0 || strcmp("PARTUUID", tagname) == 0 || diff --git a/sys-utils/mount.8 b/sys-utils/mount.8 index f1d114cb33..082fa1719e 100644 --- a/sys-utils/mount.8 +++ b/sys-utils/mount.8 @@ -177,6 +177,14 @@ PARTUUID=\fIuuid\fR Partition universally unique identifier. This identifier is independent on filesystem and does not change by mkfs or mkswap operations It's supported for example for GUID Partition Tables (GPT). +.TP +ID=\fIid\fR +Hardware block device ID as generated by udevd. This identifier is usually +based on WWN (unique storage identifier) and assigned by the hardware +manufacturer. See \fBls /dev/disk/by-id\fR for more details, this directory +and running udevd is required. This identifier is not recommended for generic +use as the identifier is not strictly defined and it depends on udev, udev rules +and hardware. .RE .sp The command \fBlsblk \-\-fs\fR provides an overview of filesystems, LABELs and UUIDs @@ -189,7 +197,7 @@ unique, especially if you move, share or copy the device. Use to verify that the UUIDs are really unique in your system. The recommended setup is to use tags (e.g.\& \fBUUID=\fIuuid\fR) rather than -.I /dev/disk/by-{label,uuid,partuuid,partlabel} +.I /dev/disk/by-{label,uuid,id,partuuid,partlabel} udev symlinks in the .I /etc/fstab file. Tags are @@ -301,7 +309,7 @@ program does not read the .I /etc/fstab file if both .I device -(or LABEL, UUID, PARTUUID or PARTLABEL) and +(or LABEL, UUID, ID, PARTUUID or PARTLABEL) and .I dir are specified. For example, to mount device .BR foo " at " /dir : diff --git a/sys-utils/mount.c b/sys-utils/mount.c index 49d3beb0d5..a87833eee3 100644 --- a/sys-utils/mount.c +++ b/sys-utils/mount.c @@ -493,7 +493,8 @@ static void __attribute__((__noreturn__)) usage(void) " LABEL=