ref: c523f72d4adb2eef8017388b96af71846b77e257
parent: 108d4b529e42d0d9a0975c492dcf3bcabe59f937
author: Richard Stephens <richard@richst.dev>
date: Wed Jul 5 11:56:40 CDT 2023
support specifying root device by partuuid
--- a/nlplug-findfs/nlplug-findfs.c
+++ b/nlplug-findfs/nlplug-findfs.c
@@ -972,7 +972,7 @@
static int searchdev(struct uevent *ev, const char *searchdev, int scanbootmedia)
{
struct ueventconf *conf = ev->conf;
- char *type = NULL, *label = NULL, *uuid = NULL;
+ char *type = NULL, *label = NULL, *uuid = NULL, *partuuid = NULL;
int rc = 0;
if (searchdev == NULL && !scanbootmedia)
@@ -989,6 +989,7 @@
type = blkid_get_tag_value(conf->blkid_cache, "TYPE", ev->devnode);
uuid = blkid_get_tag_value(conf->blkid_cache, "UUID", ev->devnode);
+ partuuid = blkid_get_tag_value(conf->blkid_cache, "PARTUUID", ev->devnode);
label = blkid_get_tag_value(conf->blkid_cache, "LABEL", ev->devnode);
if (searchdev != NULL) {
@@ -998,11 +999,14 @@
} else if (strncmp("UUID=", searchdev, 5) == 0) {
if (uuid && strcmp(uuid, searchdev+5) == 0)
rc = FOUND_DEVICE;
+ } else if (strncmp("PARTUUID=", searchdev, 9) == 0) {
+ if (partuuid && strcmp(partuuid, searchdev+9) == 0)
+ rc = FOUND_DEVICE;
}
}
- dbg("searchdev: dev='%s' type='%s' label='%s' uuid='%s'",
- ev->devnode, type, label, uuid);
+ dbg("searchdev: dev='%s' type='%s' label='%s' uuid='%s' partuuid='%s'",
+ ev->devnode, type, label, uuid, partuuid);
if (!rc && type) {
if (strcmp("linux_raid_member", type) == 0) {
@@ -1026,6 +1030,8 @@
free(label);
if (uuid)
free(uuid);
+ if (partuuid)
+ free(partuuid);
return rc;
}