git: d687c9fc7efe - main - stand: Accept any device name in disk_parsedev()

From: Olivier Cochard <olivier_at_FreeBSD.org>
Date: Thu, 12 Nov 2026 09:19:52 UTC
The branch main has been updated by olivier:

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

commit d687c9fc7efe55d1ba7bc7bea056352ce0437588
Author:     Olivier Cochard <olivier@FreeBSD.org>
AuthorDate: 2026-11-08 21:34:05 +0000
Commit:     Olivier Cochard <olivier@FreeBSD.org>
CommitDate: 2026-11-12 09:13:24 +0000

    stand: Accept any device name in disk_parsedev()
    
    disk_parsedev() only accepted names starting with "disk" or "vdisk", so other
    DEVT_DISK devices using disk_fmtdev() could print a name they could not parse
    back, e.g. "md0s2a:".
    Skip any alphabetic prefix instead; devparse() has already matched it to the
    devsw.
    
    Reviewed by:    imp
    Approved by:    imp
    Sponsored by:   Netflix
    Differential Revision:  https://ron-dev.freebsd.org/FreeBSD/src/pulls/97
---
 stand/common/disk.c | 16 ++++++++--------
 1 file changed, 8 insertions(+), 8 deletions(-)

diff --git a/stand/common/disk.c b/stand/common/disk.c
index 47f882d5a532..42981c4c6090 100644
--- a/stand/common/disk.c
+++ b/stand/common/disk.c
@@ -419,15 +419,15 @@ disk_parsedev(struct devdesc **idev, const char *devspec, const char **path)
 
 	/*
 	 * disk names look approximately like:
-	 *	v?disk([0-9]+(p[0-9]+|s[a-z])?)?:
-	 * so skip over the initial bit. We don't have access to the devsw
-	 * to check the name.
+	 *	<name>([0-9]+(p[0-9]+|s[a-z])?)?:
+	 * so skip over the leading name. We don't have access to the devsw
+	 * to check it, and any device using disk_fmtdev() can land here, so
+	 * take whatever alphabetic prefix it wrote rather than a fixed list.
 	 */
-	if (strncmp(devspec, "disk", 4) == 0)
-		np = devspec + 4;
-	else if (strncmp(devspec, "vdisk", 5) == 0)
-		np = devspec + 5;
-	else
+	np = devspec;
+	while (isalpha(*np))
+		np++;
+	if (np == devspec)
 		return (EINVAL);
 	unit = -1;
 	/*