summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAhmad Fatoum <a.fatoum@pengutronix.de>2019-10-24 16:24:50 +0200
committerRoland Hieber <rhi@pengutronix.de>2021-03-16 15:17:43 +0100
commit9f3915824bc700a36511cfc1f8982d9e32616f2c (patch)
tree804bf017b6868ffeee6e430629b180dc1aa4e4e0
parent8874600851ac3b498cd32746ae683d09ff89d596 (diff)
downloaddt-utils-9f3915824bc700a36511cfc1f8982d9e32616f2c.tar.gz
dt-utils-9f3915824bc700a36511cfc1f8982d9e32616f2c.tar.xz
libdt: support upper-case hexadecimals in value of partuuid property
barebox/next now has a commit[1] to support the hexadecimal numbers in the partition UUID to be upper case as well. This aligns its behavior with the Linux kernel, where the PARTUUID kernel argument flag also supports[2] lower and upper case UUIDs. The UUIDs used in the /dev/disk/by-partuuid/* symlinks created by udev come from libblkid, which formats the UUID hexadecimals as lower case[3], so we only need to lower case the property value inside dt-utils to have it support upper case part UUIDs as well. [1]: "fs: devfs-core: do a case-insensitive compare of partuuids", https://www.spinics.net/lists/u-boot-v2/msg39590.html [2]: v5.4-rc4, init/do_mounts.c: match_dev_by_uuid() [3]: util-linux v2.34, $(egrep -r '%[^\s"]+X' libblkid/) Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de> Message-Id: <20191024142451.15777-2-a.fatoum@pengutronix.de> Signed-off-by: Roland Hieber <rhi@pengutronix.de>
-rw-r--r--src/libdt.c12
1 files changed, 11 insertions, 1 deletions
diff --git a/src/libdt.c b/src/libdt.c
index bdfd409..01f0a69 100644
--- a/src/libdt.c
+++ b/src/libdt.c
@@ -2423,7 +2423,17 @@ int of_get_devicepath(struct device_node *partition_node, char **devpath, off_t
/* when partuuid is specified short-circuit the search for the cdev */
ret = of_property_read_string(partition_node, "partuuid", &uuid);
if (!ret) {
- *devpath = basprintf("/dev/disk/by-partuuid/%s", uuid);
+ const char prefix[] = "/dev/disk/by-partuuid/";
+ size_t prefix_len = sizeof(prefix) - 1;
+ char *lc_uuid, *s;
+
+ lc_uuid = xzalloc(prefix_len + strlen(uuid) + 1);
+ s = memcpy(lc_uuid, prefix, prefix_len) + prefix_len;
+
+ while (*uuid)
+ *s++ = tolower(*uuid++);
+
+ *devpath = lc_uuid;
return 0;
}