git: 70cf7c62ee14 - main - ubldr: Pass the whole loaderdev name to disk_parsedev()

From: Olivier Cochard <olivier_at_FreeBSD.org>
Date: Sun, 15 Nov 2026 13:45:40 UTC
The branch main has been updated by olivier:

URL: https://cgit.FreeBSD.org/src/commit/?id=70cf7c62ee14f54c5c0a4d3aea8be35e36166d58

commit 70cf7c62ee14f54c5c0a4d3aea8be35e36166d58
Author:     Olivier Cochard <olivier@FreeBSD.org>
AuthorDate: 2026-11-12 10:54:22 +0000
Commit:     Olivier Cochard <olivier@FreeBSD.org>
CommitDate: 2026-11-15 13:37:33 +0000

    ubldr: Pass the whole loaderdev name to disk_parsedev()
    
    p - 4 is one byte before the string for 3-letter types, so whether
    loaderdev=mmc0p2 parsed depended on that byte. disk_parsedev() now skips any
    name prefix itself.
    
    Reported by:    llm-postcr
    Reviewed by:    imp
    Approved by:    imp
    Fixes:          d18ed8e19c3c ("stand: Try to parse vdisk correctly")
    Sponsored by:   Netfix
    Differential Revision:  https://ron-dev.freebsd.org/FreeBSD/src/pulls/105
---
 stand/uboot/main.c | 14 ++++----------
 1 file changed, 4 insertions(+), 10 deletions(-)

diff --git a/stand/uboot/main.c b/stand/uboot/main.c
index 6f53c83543ba..15c8e008a223 100644
--- a/stand/uboot/main.c
+++ b/stand/uboot/main.c
@@ -229,20 +229,14 @@ get_load_device(int *type, int *unit, int *slice, int *partition)
 	 * of the string contains spaces, dots, or a colon in any location other
 	 * than the last char, it's legacy format.  Otherwise it might be
 	 * standard loader(8) format (e.g., disk0s2a or mmc1p12), so try to
-	 * parse the remainder of the string as such, and if it works, return
-	 * those results. Otherwise we'll fall through to the code that parses
-	 * the legacy format.
-	 *
-	 * disk_parsedev now assumes that it points to the start of the device
-	 * name, but since it doesn't know about uboot's usage, just subtract 4
-	 * since it always adds 4. This is the least-bad solution since it makes
-	 * all the other loader code easier (might be better to create a fake
-	 * 'disk...' string, but that's more work than uboot is worth).
+	 * parse the string as such, and if it works, return those results.
+	 * Otherwise we'll fall through to the code that parses the legacy
+	 * format.
 	 */
 	if (*type & DEV_TYP_STOR) {
 		size_t len = strlen(p);
 		if (strcspn(p, " .") == len && strcspn(p, ":") >= len - 1 &&
-		    disk_parsedev((struct devdesc **)&dev, p - 4, NULL) == 0) { /* Hack */
+		    disk_parsedev((struct devdesc **)&dev, devstr, NULL) == 0) {
 			*unit = dev->dd.d_unit;
 			*slice = dev->d_slice;
 			*partition = dev->d_partition;