From nobody Wed Nov 30 22:31:26 2022 X-Original-To: dev-commits-src-all@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id 4NMv7f2Sg9z4jC3h; Wed, 30 Nov 2022 22:31:26 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4NMv7f1wjCz44WW; Wed, 30 Nov 2022 22:31:26 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1669847486; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=wY1qYq4lohBxiIQ3OkoQsoLBDhqagnWo7/4t5gOtFh0=; b=JhHsmCaxgY3W1g2rTaQbYseZvwmuP/eK5U3TBtt6tu5/00BXy1bEOgjT6mpE0SJdXWZaRp I0oSto7FG2+8SVm+BHC3m18T1Yke07UVTRms+ESXw9OW7F4yNkluDjdSVk731auVx4mgcs 5zAVhYvfXztjgQrmGknQXieohlQpzy42MoQg7XVqn07+1gGawpvjj7x2GefGqCp6omdLdk jcbUcudZMQGxM/pOORRyrrMqByQGCmb3Onn+kIc/Ld4ZQujngYZI3eGliOXAlJlyKUT3rD cnNynD8NKEP+B4Hf/lgpMJfC6Eqbn9ORzUI5SmBbTJO/Yu6leHbKdeB9B/zlyg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1669847486; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=wY1qYq4lohBxiIQ3OkoQsoLBDhqagnWo7/4t5gOtFh0=; b=KJHIzhhKvCfevoCKtQvMAi7wg6fkJm2TccaFT2PPrx8mQPhQygr4C1Uej8/4fc+O3VVjSC N2jGFeUu1WxzkTPRmhXpuv7nI5LjA5+AOSBMXGl97uCpfxkqXMSY36QM0ChPiLLaFtb9KL L4n03lutCn1R+7PtdDZr9Mq1QJ98Xz/3hxEaZR4lCNsGnMe/gfAIes0V1IL81508zldnuo dOO7gJUZA3uv8rFo5CLXxzCketfgrBwHZQ+lT0L8cySgut+nEASTIze9tHxp2/1fyr46Hf afRHjRE2Z6fabPgjrHoEL43nq3e1OrZ/5GBkPSrrsfgHOiU8vtXTNXqhqj3RgA== ARC-Authentication-Results: i=1; mx1.freebsd.org; none ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1669847486; a=rsa-sha256; cv=none; b=wpfnCL0QgprqtVxzdfV/5YCD/qROndVusrEmZP576O3JxC1irT/ie3lcgA8ZKtPUJVRQaW ucznaZMXMNhspZ/KiwFp+kN9k79CJjun0wP+GpWMDS3IUThwdWS9Vqm+d5GkQzIwvnHmYK 6XkfYrXHOV0Nh+JDnvS//0zx89rVxJTXpyVlFlCSXEkzOmFmggc6WH2f0vsssydsYAkCED Nqri1tYmZ+i29KZMhDRV9/6zJSx+ee/FiMw0KRVesphVpv1ZraGtbS/jWDLaanomMiUasM 3IZGndGEG7keEkV2azMSwrE5yB4/rbXDCQvONR4QTrhCIpmTCQ8bJl6V/u6skQ== Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 4NMv7f0zq5z1Cr1; Wed, 30 Nov 2022 22:31:26 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.16.1/8.16.1) with ESMTP id 2AUMVQBO023607; Wed, 30 Nov 2022 22:31:26 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 2AUMVQmA023606; Wed, 30 Nov 2022 22:31:26 GMT (envelope-from git) Date: Wed, 30 Nov 2022 22:31:26 GMT Message-Id: <202211302231.2AUMVQmA023606@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Warner Losh Subject: git: 33bbe5ddcbbc - main - stand: parsedev API change: devspec now points to start of full device name List-Id: Commit messages for all branches of the src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-all List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-dev-commits-src-all@freebsd.org X-BeenThere: dev-commits-src-all@freebsd.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: imp X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: 33bbe5ddcbbce03b6395a4948927643107b55c06 Auto-Submitted: auto-generated X-ThisMailContainsUnwantedMimeParts: N The branch main has been updated by imp: URL: https://cgit.FreeBSD.org/src/commit/?id=33bbe5ddcbbce03b6395a4948927643107b55c06 commit 33bbe5ddcbbce03b6395a4948927643107b55c06 Author: Warner Losh AuthorDate: 2022-11-30 22:09:36 +0000 Commit: Warner Losh CommitDate: 2022-11-30 22:30:33 +0000 stand: parsedev API change: devspec now points to start of full device name To support more flexible device matching, we now pass in the full devspec to the parsedev routines. For everything execpt uboot, this is just a drop in (since everything except uboot and openfirmware always uses disk...: and/or zfs:, but openfirmware isn't really affected). uboot we kludge around it by subtracting 4 from where the rest of the device name starts. This is unforunate, and can compute the address one before the string. But we never dereference that address. uboot needs more work, and this is an acceptable UB until that other work happens. OFW doesn't really use the parsedev routines these days (since none of the supported device uses this... yet). It too needs more work, but it needs device matching support first. Sponsored by: Netflix Reviewed by: delphij Differential Revision: https://reviews.freebsd.org/D37553 --- stand/common/disk.c | 2 +- stand/i386/zfsboot/zfsboot.c | 2 +- stand/libofw/devicename.c | 2 +- stand/libsa/dev.c | 2 +- stand/libsa/zfs/zfs.c | 4 ++-- stand/uboot/devicename.c | 2 +- stand/uboot/main.c | 8 +++++++- 7 files changed, 14 insertions(+), 8 deletions(-) diff --git a/stand/common/disk.c b/stand/common/disk.c index 653f971d46b8..eecf519c52aa 100644 --- a/stand/common/disk.c +++ b/stand/common/disk.c @@ -420,7 +420,7 @@ disk_parsedev(struct devdesc **idev, const char *devspec, const char **path) char *cp; struct disk_devdesc *dev; - np = devspec; + np = devspec + 4; /* Skip the leading 'disk' */ unit = -1; /* * If there is path/file info after the device info, then any missing diff --git a/stand/i386/zfsboot/zfsboot.c b/stand/i386/zfsboot/zfsboot.c index 1d64ace063e0..c6305b41493e 100644 --- a/stand/i386/zfsboot/zfsboot.c +++ b/stand/i386/zfsboot/zfsboot.c @@ -214,7 +214,7 @@ main(void) devinit(); /* XXX assumes this will be a disk, but it looks likely give above */ - disk_parsedev((struct devdesc **)&devdesc, boot_devname + 4, NULL); + disk_parsedev((struct devdesc **)&devdesc, boot_devname, NULL); bootdev = MAKEBOOTDEV(dev_maj[DEVT_DISK], devdesc->d_slice + 1, devdesc->dd.d_unit, diff --git a/stand/libofw/devicename.c b/stand/libofw/devicename.c index f03703e3872f..ecf966506194 100644 --- a/stand/libofw/devicename.c +++ b/stand/libofw/devicename.c @@ -112,7 +112,7 @@ found: if (dv->dv_parsedev != NULL) { p = devspec + strlen(dv->dv_name); free(idev); - err = dv->dv_parsedev((struct devdesc **)&idev, p, path); + err = dv->dv_parsedev((struct devdesc **)&idev, devspec, path); if (err != 0) { return (err); } diff --git a/stand/libsa/dev.c b/stand/libsa/dev.c index 158b4d69381b..b16637181059 100644 --- a/stand/libsa/dev.c +++ b/stand/libsa/dev.c @@ -134,7 +134,7 @@ devparse(struct devdesc **dev, const char *devspec, const char **path) idev = NULL; err = 0; if (dv->dv_parsedev) { - err = dv->dv_parsedev(&idev, np, path); + err = dv->dv_parsedev(&idev, devspec, path); } else { np = devspec + strlen(dv->dv_name); err = default_parsedev(&idev, np, path); diff --git a/stand/libsa/zfs/zfs.c b/stand/libsa/zfs/zfs.c index db4bed7f7697..d7aecc71ab5c 100644 --- a/stand/libsa/zfs/zfs.c +++ b/stand/libsa/zfs/zfs.c @@ -385,7 +385,7 @@ zfs_mount(const char *dev, const char *path, void **data) int rv; errno = 0; - rv = zfs_parsedev((struct devdesc **)&zfsdev, dev + 3, NULL); + rv = zfs_parsedev((struct devdesc **)&zfsdev, dev, NULL); if (rv != 0) { return (rv); } @@ -1644,7 +1644,7 @@ zfs_parsedev(struct devdesc **idev, const char *devspec, const char **path) int rv; struct zfs_devdesc *dev; - np = devspec; + np = devspec + 3; /* Skip the leading 'zfs' */ if (*np != ':') return (EINVAL); np++; diff --git a/stand/uboot/devicename.c b/stand/uboot/devicename.c index 8f867406e6fa..075880baa59f 100644 --- a/stand/uboot/devicename.c +++ b/stand/uboot/devicename.c @@ -116,7 +116,7 @@ uboot_parsedev(struct uboot_devdesc **dev, const char *devspec, #ifdef LOADER_DISK_SUPPORT case DEVT_DISK: free(idev); - err = disk_parsedev((struct devdesc **)&idev, np, path); + err = disk_parsedev((struct devdesc **)&idev, devspec, path); if (err != 0) goto fail; break; diff --git a/stand/uboot/main.c b/stand/uboot/main.c index cf41917d6ee5..58de335edf7f 100644 --- a/stand/uboot/main.c +++ b/stand/uboot/main.c @@ -233,11 +233,17 @@ get_load_device(int *type, int *unit, int *slice, int *partition) * 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). */ if (*type & DEV_TYP_STOR) { size_t len = strlen(p); if (strcspn(p, " .") == len && strcspn(p, ":") >= len - 1 && - disk_parsedev((struct devdesc **)&dev, p, NULL) == 0) { + disk_parsedev((struct devdesc **)&dev, p - 4, NULL) == 0) { /* Hack */ *unit = dev->dd.d_unit; *slice = dev->d_slice; *partition = dev->d_partition;