From nobody Tue Jan 24 22:13:15 2023 X-Original-To: dev-commits-src-branches@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 4P1h7J0jBhz3bgTj; Tue, 24 Jan 2023 22:13:16 +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 4P1h7H5Hkgz3G6w; Tue, 24 Jan 2023 22:13:15 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1674598395; 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=yj3AbB7dGTHyVbGEw+N4Z8L4TD0AhWga68ttUyMzfio=; b=xmzSsYdMevL0HMEHRveBud93aFvrDf7n+YSPce2I059rJa5Qr94rHRhz+TNn9eVjbgGgJZ 2CrPsIGAM/j87AlNpLmN1mDYJ9q2haFxjvSD0z+CW8FcgfzCtItw2jabYBlkn2U3jpWnhY bycnSJUMx+zBVsm0mu8YX5trhMOCpFIhvyThs4PQrGbG9jI5vdRz2PXOfmJ+71pFdymhE4 CuJCf81Z0KIjB7LMQ7XVfwRlYQxbCSj6e/5gup2P6sPL3HfQdibk6/Sdrr/H8FDqDWXUNE 5uoYAUML7uJxInoq0Mi2hQRfCaMh/EpIKqqHFNY/ICiuOdh/oXSI1B/hS1qNkQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1674598395; 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=yj3AbB7dGTHyVbGEw+N4Z8L4TD0AhWga68ttUyMzfio=; b=mbwn7pnwyVuBc5S+UiSQ6XGDjzovE2mHgtitE2JTYLH6tss2NMQzKTGmv3UdUwyeWE+9MI ure9C5z14PCu+S/F9IF4txTEV5d2EZjAKZyMRIehXVGMAURu4FDgtwwIz4NAEov1i25Rda 201oHPqrupl2YgeIFkHcjOTFRmCfSLMdPe/Kou0sjI7nzcw9MQRDOwZfII5CjPkFTKm40S 8yd+42s7nt8hkqPjj8ACNL33ATga8Iv9J2+zqD4zn1/GgwZ+prqCMsdq9jP/aoQdPvqZcw ZOMdkinI+iq8KUqTyfftJ9+cpOlt07zGGNiU25LcOhNA8C8MbnXGY5QBjOhmzA== ARC-Authentication-Results: i=1; mx1.freebsd.org; none ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1674598395; a=rsa-sha256; cv=none; b=WWjXIsDA3A856BvyoiIxfosK5mE+8tvBatLakzv8Qwo8cBAl6cYaBECwpE3txeEoRkAozw Dr++gzNS2WyXfcNm/YgZpXS3eE7kYluOozcfz0lJAiaRQkfaiJX+xGfU1X7pNyn23iIqvK 2Wll2NbMZRJWk1+muOvNGHOS0kL84P3HuBNEO82ZX87uVmeG6rRtQYQMJi7FOtIfBIqVh9 Vw9FV9J8JnqKVo1scdscRIDQvX7iD9mXsLGTWjQLKd0ljSTIm7/PZjR/735xmOt1RHEUJq 02QFbHHT0L73LfDt5mtJdR0BboHJjxW8ElC2x36bM3ZuL2vMhvGQOkD0ZmcVmA== 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 4P1h7H47HNzQVp; Tue, 24 Jan 2023 22:13:15 +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 30OMDFTa088168; Tue, 24 Jan 2023 22:13:15 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 30OMDF79088167; Tue, 24 Jan 2023 22:13:15 GMT (envelope-from git) Date: Tue, 24 Jan 2023 22:13:15 GMT Message-Id: <202301242213.30OMDF79088167@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Warner Losh Subject: git: ed6e58152124 - stable/13 - stand/efi: Move to using common devparse() List-Id: Commits to the stable branches of the FreeBSD src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-branches List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-dev-commits-src-branches@freebsd.org X-BeenThere: dev-commits-src-branches@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/stable/13 X-Git-Reftype: branch X-Git-Commit: ed6e58152124fae4d577c148921234ae87625587 Auto-Submitted: auto-generated X-ThisMailContainsUnwantedMimeParts: N The branch stable/13 has been updated by imp: URL: https://cgit.FreeBSD.org/src/commit/?id=ed6e58152124fae4d577c148921234ae87625587 commit ed6e58152124fae4d577c148921234ae87625587 Author: Warner Losh AuthorDate: 2022-11-30 22:08:55 +0000 Commit: Warner Losh CommitDate: 2023-01-24 21:49:38 +0000 stand/efi: 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/D37340 (cherry picked from commit 77378d79f165b59296a0133eb910af55c8b2b600) --- stand/efi/libefi/devicename.c | 105 ++---------------------------------------- 1 file changed, 3 insertions(+), 102 deletions(-) diff --git a/stand/efi/libefi/devicename.c b/stand/efi/libefi/devicename.c index 73b1d783c01f..83f4e6e99201 100644 --- a/stand/efi/libefi/devicename.c +++ b/stand/efi/libefi/devicename.c @@ -39,8 +39,6 @@ __FBSDID("$FreeBSD$"); #include #include -static int efi_parsedev(struct devdesc **, const char *, const char **); - /* * Point (dev) at an allocated device specifier for the device matching the * path in (devspec). If it contains an explicit device specification, @@ -57,110 +55,13 @@ efi_getdev(void **vdev, const char *devspec, const char **path) * use the current device instead. */ if (devspec == NULL || *devspec == '/' || !strchr(devspec, ':')) { - rv = efi_parsedev(dev, getenv("currdev"), NULL); + rv = devparse(dev, getenv("currdev"), NULL); if (rv == 0 && path != NULL) *path = devspec; return (rv); } - /* Parse the device name off the beginning of the devspec. */ - return (efi_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: - * - * fs: - */ -static int -efi_parsedev(struct devdesc **dev, const char *devspec, const char **path) -{ - struct devdesc *idev; - 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; devsw[i] != NULL; i++) { - dv = devsw[i]; - if (!strncmp(devspec, dv->dv_name, strlen(dv->dv_name))) - break; - } - if (devsw[i] == 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(&idev, np, path); - if (err != 0) - goto fail; - break; - -#ifdef EFI_ZFS_BOOT - case DEVT_ZFS: - err = zfs_parsedev(&idev, np, path); - if (err != 0) - goto fail; - break; -#endif - default: - idev = malloc(sizeof(struct devdesc)); - if (idev == NULL) - return (ENOMEM); - - unit = 0; - cp = (char *)np; - - if (*np != '\0' && *np != ':') { - errno = 0; - unit = strtol(np, &cp, 0); - if (errno != 0 || cp == np) { - err = EUNIT; - goto fail; - } - } - if (*cp != '\0' && *cp != ':') { - err = EINVAL; - goto fail; - } - - idev->d_unit = unit; - if (path != NULL) - *path = (*cp == 0) ? cp : cp + 1; - break; - } - - idev->d_dev = dv; - - if (dev != NULL) - *dev = idev; - else - free(idev); - return (0); - -fail: - free(idev); - return (err); + return (devparse(dev, devspec, path)); } /* @@ -172,7 +73,7 @@ efi_setcurrdev(struct env_var *ev, int flags, const void *value) struct devdesc *ncurr; int rv; - rv = efi_parsedev(&ncurr, value, NULL); + rv = devparse(&ncurr, value, NULL); if (rv != 0) return (rv); free(ncurr);