From nobody Wed Nov 30 22:31:18 2022 X-Original-To: dev-commits-src-main@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 4NMv7V3Fw1z4jCGF; Wed, 30 Nov 2022 22:31:18 +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 4NMv7V2mkDz44CN; Wed, 30 Nov 2022 22:31:18 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1669847478; 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=Y+tSXRnPyzu0g1zSr6VjMMU2PtywEIbV98ZutrSS/sA=; b=QJDsu1ZG45zjrPZ0M/AE3ozRuXP/xyB4Juvf7kfu8DoZKaUsK5SgrjOGdsYlGAllUcy4Qj 7SkFzKSOeAe5CGZbbA4DpOkvWkEyg7UPaA397HUt9TuI5O+MbuBbxrvIlXSALvgVLpQ0xT haaxdio7i1D3Du2FsOyb8CFIxqzy6/hDoPQInViS+Y0/Rz2d03XislG82+FqvKG4oDZGS8 u7sDpLPetq6bz1HXb76xaQmzfNfL/MkwtTwDwvb07zK/mbA35EZBgpkEU491XUV/af9Eiu WHLH+Vq0rHZAQ+agZ2hQSGtiBEk+TucRR2gvYSSinDrzm2r/O1X4id3wKxrjlw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1669847478; 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=Y+tSXRnPyzu0g1zSr6VjMMU2PtywEIbV98ZutrSS/sA=; b=CrpZYFuITC2JcKCTD0hSmhGKdwivdxB0CBMdXUWPUDOvfreqoCKN/xuImQL11RuaAFlGUF 2jaoa5XfFIvT71DQOm2LkCZgBVftipWhWHClZt2/Oipl02z+RGATs9QrmtrLUpna10nQ81 1QysUwWipwbkbhTdWhudyDH16AFwTLaRxh0zihg7czeGcLG4zJYXGfjb63Y+CFuMlpjkFA yF96eHK3+y5/dvRkMVbQmxn1CZL0L/UuM6lgZ4ai5daDyAzOxMdMsX//LlqqwFrr8Sn5P5 DtdSpw/r+vcv1fs7XfFY1Oofqi7TBP/Yn1reh/1zDsLq/Da4rydNsCKptRBUDg== ARC-Authentication-Results: i=1; mx1.freebsd.org; none ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1669847478; a=rsa-sha256; cv=none; b=GHtEnVz0TouP+/k5alxriLssAbMYNCmlmJ+lMjU8SxIC/R59gvMv5jGqPmS9dTcjR6udRn shIa7E2yzdnaztVaBEqIoqQgfToEA77jyVQwCb1Qe7MdtGmconG/CKN/h/enM0XKuc4C5T vgh6jxeSxF4X1G8KhlUg0zUi1OwoKW4rYKWG8eVlRTNHaP5uyRDQhB6i0wVJ3MF/FLmWuJ SE+DI8cJOD/SjIKJwgroYg0ZRUe1Ypd+mLH8wS4B5rErsv5RsDNgDKsoIxT803Axn+z1vM M3S6dfnZJhPArjj/Vt/MEhBFEpUhuh1lODQXwYFiPeAmA2IctGbPEK/U/Xth7Q== 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 4NMv7V1d7RzDdT; Wed, 30 Nov 2022 22:31:18 +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 2AUMVIhk023428; Wed, 30 Nov 2022 22:31:18 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 2AUMVIep023427; Wed, 30 Nov 2022 22:31:18 GMT (envelope-from git) Date: Wed, 30 Nov 2022 22:31:18 GMT Message-Id: <202211302231.2AUMVIep023427@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: 641a0617e8d0 - main - stand/i386: Move to using common devparse() List-Id: Commit messages for the main branch of the src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-main List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-dev-commits-src-main@freebsd.org X-BeenThere: dev-commits-src-main@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: 641a0617e8d060c3c5fb997cee9e2b7fb40d9306 Auto-Submitted: auto-generated X-ThisMailContainsUnwantedMimeParts: N The branch main has been updated by imp: URL: https://cgit.FreeBSD.org/src/commit/?id=641a0617e8d060c3c5fb997cee9e2b7fb40d9306 commit 641a0617e8d060c3c5fb997cee9e2b7fb40d9306 Author: Warner Losh AuthorDate: 2022-11-30 22:09:00 +0000 Commit: Warner Losh CommitDate: 2022-11-30 22:30:32 +0000 stand/i386: 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/D37341 --- stand/i386/libi386/devicename.c | 109 ++-------------------------------------- 1 file changed, 5 insertions(+), 104 deletions(-) diff --git a/stand/i386/libi386/devicename.c b/stand/i386/libi386/devicename.c index 1d7e4c7d3fa3..99d3aa7920bc 100644 --- a/stand/i386/libi386/devicename.c +++ b/stand/i386/libi386/devicename.c @@ -32,9 +32,6 @@ __FBSDID("$FreeBSD$"); #include "bootstrap.h" #include "disk.h" #include "libi386.h" -#include "libzfs.h" - -static int i386_parsedev(struct i386_devdesc **dev, const char *devspec, const char **path); /* * Point (dev) at an allocated device specifier for the device matching the @@ -44,7 +41,7 @@ static int i386_parsedev(struct i386_devdesc **dev, const char *devspec, const c int i386_getdev(void **vdev, const char *devspec, const char **path) { - struct i386_devdesc **dev = (struct i386_devdesc **)vdev; + struct devdesc **dev = (struct devdesc **)vdev; int rv; /* @@ -55,7 +52,7 @@ i386_getdev(void **vdev, const char *devspec, const char **path) (devspec[0] == '/') || (strchr(devspec, ':') == NULL)) { - if (((rv = i386_parsedev(dev, getenv("currdev"), NULL)) == 0) && + if (((rv = devparse(dev, getenv("currdev"), NULL)) == 0) && (path != NULL)) *path = devspec; return(rv); @@ -64,103 +61,7 @@ i386_getdev(void **vdev, const char *devspec, const char **path) /* * Try to parse the device name off the beginning of the devspec */ - return(i386_parsedev(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 -i386_parsedev(struct i386_devdesc **dev, const char *devspec, const char **path) -{ - struct i386_devdesc *idev = NULL; - struct devsw *dv; - int i, unit, err; - 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))) { - dv = devsw[i]; - break; - } - } - if (dv == NULL) - return(ENOENT); - - np = (devspec + strlen(dv->dv_name)); - idev = NULL; - err = 0; - - switch(dv->dv_type) { - case DEVT_NONE: - break; - - case DEVT_DISK: - err = disk_parsedev((struct devdesc **)&idev, np, path); - if (err != 0) - goto fail; - break; - - case DEVT_ZFS: - err = zfs_parsedev((struct devdesc **)&idev, np, path); - if (err != 0) - goto fail; - break; - - default: - idev = malloc(sizeof (struct devdesc)); - if (idev == NULL) - return (ENOMEM); - - unit = 0; - cp = (char *)np; - - if (*np && (*np != ':')) { - unit = strtol(np, &cp, 0); /* get unit number if present */ - if (cp == np) { - err = EUNIT; - goto fail; - } - } - - if (*cp && (*cp != ':')) { - err = EINVAL; - goto fail; - } - - idev->dd.d_unit = unit; - if (path != NULL) - *path = (*cp == 0) ? cp : cp + 1; - break; - } - idev->dd.d_dev = dv; - if (dev != NULL) - *dev = idev; - else - free(idev); - - return(0); - - fail: - free(idev); - return(err); + return(devparse(dev, devspec, path)); } /* @@ -169,10 +70,10 @@ i386_parsedev(struct i386_devdesc **dev, const char *devspec, const char **path) int i386_setcurrdev(struct env_var *ev, int flags, const void *value) { - struct i386_devdesc *ncurr; + struct devdesc *ncurr; int rv; - if ((rv = i386_parsedev(&ncurr, value, NULL)) != 0) + if ((rv = devparse(&ncurr, value, NULL)) != 0) return (rv); free(ncurr);