From mboxrd@z Thu Jan 1 00:00:00 1970 Return-path: From: Ahmad Fatoum Date: Thu, 24 Oct 2019 16:24:50 +0200 Message-Id: <20191024142451.15777-2-a.fatoum@pengutronix.de> In-Reply-To: <20191024142451.15777-1-a.fatoum@pengutronix.de> References: <20191024142451.15777-1-a.fatoum@pengutronix.de> MIME-Version: 1.0 Subject: [OSS-Tools] [PATCH v5 1/2] libdt: support upper-case hexadecimals in value of partuuid property List-Id: Pengutronix Public Open-Source-Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Errors-To: oss-tools-bounces@pengutronix.de Sender: "OSS-Tools" To: oss-tools@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 --- 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