From nobody Wed Nov 30 22:31:19 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 4NMv7W4G8Cz4jCSF; Wed, 30 Nov 2022 22:31:19 +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 4NMv7W3ZQTz44Fp; Wed, 30 Nov 2022 22:31:19 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1669847479; 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=Q5jesECZR4wXSd2SCkyBDNhzsTinlaRS6R55KG59b4Y=; b=nN8v5ookjQZH46jDsqYnyiIhc6uJFzg7c26T4ANyzjHWmNr1NuWY6ZgKZrrSZdAYMZ6yfC ZX4YaKJZjRqmsvrWyHe8EffTu7v8STG7gZV9DogBevNpdB6xnC9hKnmqIzYZWmSjnFhMHa BW8FYC5ecf9+LBS485114tYgxmzmYdxQy6pxd75txmBB6mEWp5WPzHBUyLvXvskRaR3wjP emtrz+sIURfN4QrApDOG5SPBIxmDn0DOZkxJp9nFId3XLjXFdaiimIoYPIyNeGq3kuCLi+ rs8jhSQ2R2bAzhIRoWzE+K6BAeh8q8zVDuh14xq7lW3ooeoCvgyVgZ3v2p6tDQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1669847479; 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=Q5jesECZR4wXSd2SCkyBDNhzsTinlaRS6R55KG59b4Y=; b=crRUoyvflqItDPVqhB4yCRwRPI91DYr0ZtVear8C9aVlpyV0ZQSSmhTGPOe2RDqKpxohXv sQztpneUQuxPP+1s3sFTnKwQyWaYPEZeW9838EMqtVVSgdcuJ5YalMUCUv0pjePaADML9e 8bJEI5Bb6YR4kpSWVkZuqRQVCt8wM8pRojMaebIBBldsQEHhreElNyWdvHMpyGmxCQsrz1 /et7Hpd0475b8M47F7VkOkeNr+hnKg8Ci0hHL730UjfM0nJw+yybps6+TrjODxmeVwG9Ez ofPjBUZH5bzrr5QPl8a/BTQmhRJVPDZsPpkz3VnDeUnVE4V3RuEo9cPBH1+LEA== ARC-Authentication-Results: i=1; mx1.freebsd.org; none ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1669847479; a=rsa-sha256; cv=none; b=tcwJoo+UQSGQ8/wLInEhRbJPv6iB5RSBh9ByT/7Suk5BO+RMs+ZFpMV8uO+IvQlb2Zv53f 7XVNPKRotWgOu1IqT01+jutgocCHqTaT8kqUa8i1CqmwfqWdhHyuWdKikwY0liiD4j+bRQ e+qFbfk0HL3bR3nDrcwtrDhQMFSCiosuf/2PmwtEhlOd39HwJw/gPqixw6hmC9meBpGG+g feuRo6ry5E7J+oLGHTrNlcImA/yfJrI1F8w86BNwbTcZe90Qcbcns1Hh0PpMekl2g7Pn0T paxn8pC+OrhA82lZZGUp1F0oCOU8xK/fLB2GwemqJSGmk9nOt8I5zUqbBtyaYw== 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 4NMv7W2FhRz1Cfd; Wed, 30 Nov 2022 22:31:19 +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 2AUMVJDX023456; Wed, 30 Nov 2022 22:31:19 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 2AUMVJcY023455; Wed, 30 Nov 2022 22:31:19 GMT (envelope-from git) Date: Wed, 30 Nov 2022 22:31:19 GMT Message-Id: <202211302231.2AUMVJcY023455@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: 910de60a7e43 - main - stand/userboot: Move to using common devparse() 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: 910de60a7e43c593b5126b2f1ee468c089c8116e Auto-Submitted: auto-generated X-ThisMailContainsUnwantedMimeParts: N The branch main has been updated by imp: URL: https://cgit.FreeBSD.org/src/commit/?id=910de60a7e43c593b5126b2f1ee468c089c8116e commit 910de60a7e43c593b5126b2f1ee468c089c8116e Author: Warner Losh AuthorDate: 2022-11-30 22:09:05 +0000 Commit: Warner Losh CommitDate: 2022-11-30 22:30:32 +0000 stand/userboot: Move to using common devparse() We no longer need to have to hand-code this for each boot loader since devparse() handles them all with dv_parsedev(). Sponsored by: Netflix Differential Revision: https://reviews.freebsd.org/D37342 --- stand/userboot/userboot/devicename.c | 119 +---------------------------------- 1 file changed, 3 insertions(+), 116 deletions(-) diff --git a/stand/userboot/userboot/devicename.c b/stand/userboot/userboot/devicename.c index c8b46e7f590c..e6d7e9706c18 100644 --- a/stand/userboot/userboot/devicename.c +++ b/stand/userboot/userboot/devicename.c @@ -34,13 +34,6 @@ __FBSDID("$FreeBSD$"); #include "disk.h" #include "libuserboot.h" -#if defined(USERBOOT_ZFS_SUPPORT) -#include "libzfs.h" -#endif - -static int userboot_parsedev(struct devdesc **dev, const char *devspec, - const char **path); - /* * Point (dev) at an allocated device specifier for the device matching the * path in (devspec). If it contains an explicit device specification, @@ -60,7 +53,7 @@ userboot_getdev(void **vdev, const char *devspec, const char **path) (devspec[0] == '/') || (strchr(devspec, ':') == NULL)) { - rv = userboot_parsedev(dev, getenv("currdev"), NULL); + rv = devparse(dev, getenv("currdev"), NULL); if (rv == 0 && path != NULL) *path = devspec; return (rv); @@ -69,115 +62,9 @@ userboot_getdev(void **vdev, const char *devspec, const char **path) /* * Try to parse the device name off the beginning of the devspec */ - return (userboot_parsedev(dev, devspec, path)); + return (devparse(dev, devspec, path)); } -/* - * Point (dev) at an allocated device specifier matching the string version - * at the beginning of (devspec). Return a pointer to the remaining - * text in (path). - * - * In all cases, the beginning of (devspec) is compared to the names - * of known devices in the device switch, and then any following text - * is parsed according to the rules applied to the device type. - * - * For disk-type devices, the syntax is: - * - * disk[s][]: - * - */ -static int -userboot_parsedev(struct devdesc **dev, const char *devspec, - const char **path) -{ - struct devdesc *idev; - struct devsw *dv; - int i, unit, err; - const char *cp; - const char *np; - - /* minimum length check */ - if (strlen(devspec) < 2) - return (EINVAL); - - /* look for a device that matches */ - for (i = 0, dv = NULL; devsw[i] != NULL; i++) { - if (strncmp(devspec, devsw[i]->dv_name, - strlen(devsw[i]->dv_name)) == 0) { - dv = devsw[i]; - break; - } - } - if (dv == NULL) - return (ENOENT); - idev = malloc(sizeof(struct disk_devdesc)); - err = 0; - np = (devspec + strlen(dv->dv_name)); - - switch (dv->dv_type) { - case DEVT_NONE: /* XXX what to do here? Do we care? */ - break; - - case DEVT_DISK: - free(idev); - err = disk_parsedev(&idev, np, path); - if (err != 0) - goto fail; - break; - - case DEVT_CD: - case DEVT_NET: - unit = 0; - - if (*np && (*np != ':')) { - /* get unit number if present */ - unit = strtol(np, (char **)&cp, 0); - if (cp == np) { - err = EUNIT; - goto fail; - } - } else { - cp = np; - } - if (*cp && (*cp != ':')) { - err = EINVAL; - goto fail; - } - - idev->d_unit = unit; - if (path != NULL) - *path = (*cp == 0) ? cp : cp + 1; - break; - - case DEVT_ZFS: -#if defined(USERBOOT_ZFS_SUPPORT) - free(idev); - err = zfs_parsedev(&idev, np, path); - if (err != 0) - goto fail; - break; -#else - /* FALLTHROUGH */ -#endif - - default: - err = EINVAL; - goto fail; - } - idev->d_dev = dv; - if (dev == NULL) { - free(idev); - } else { - *dev = idev; - } - return (0); - -fail: - free(idev); - return (err); -} - - /* * Set currdev to suit the value being supplied in (value) */ @@ -187,7 +74,7 @@ userboot_setcurrdev(struct env_var *ev, int flags, const void *value) struct devdesc *ncurr; int rv; - if ((rv = userboot_parsedev(&ncurr, value, NULL)) != 0) + if ((rv = devparse(&ncurr, value, NULL)) != 0) return (rv); free(ncurr);