mailarchive of the pengutronix oss-tools mailing list
 help / color / mirror / Atom feed
From: Ahmad Fatoum <a.fatoum@pengutronix.de>
To: oss-tools@pengutronix.de
Subject: [OSS-Tools] [PATCH v5 1/2] libdt: support upper-case hexadecimals in value of partuuid property
Date: Thu, 24 Oct 2019 16:24:50 +0200	[thread overview]
Message-ID: <20191024142451.15777-2-a.fatoum@pengutronix.de> (raw)
In-Reply-To: <20191024142451.15777-1-a.fatoum@pengutronix.de>

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>
---
 src/libdt.c | 12 +++++++++++-
 1 file changed, 11 insertions(+), 1 deletion(-)

diff --git a/src/libdt.c b/src/libdt.c
index bdfd409b1aab..01f0a6941aa2 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;
 		}
-- 
2.23.0


_______________________________________________
OSS-Tools mailing list
OSS-Tools@pengutronix.de

  reply	other threads:[~2019-10-24 14:24 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-10-24 14:24 [OSS-Tools] [PATCH dt-utils v5 0/2] barebox-state: get devicetree from file Ahmad Fatoum
2019-10-24 14:24 ` Ahmad Fatoum [this message]
2019-10-24 14:24 ` [OSS-Tools] [PATCH v5 2/2] " Ahmad Fatoum
2020-07-09 13:20 ` [OSS-Tools] [PATCH dt-utils v5 0/2] " Ahmad Fatoum
2020-07-09 13:37   ` Roland Hieber
2021-03-16 14:18 ` Roland Hieber

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20191024142451.15777-2-a.fatoum@pengutronix.de \
    --to=a.fatoum@pengutronix.de \
    --cc=oss-tools@pengutronix.de \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox