From nobody Wed Jan 11 22:17:14 2023 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 4Nshqt3MRkz2sL8l; Wed, 11 Jan 2023 22:17:14 +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 4Nshqt2Q78z3tjY; Wed, 11 Jan 2023 22:17:14 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1673475434; 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=9F+ylXgryOCVvDxv8Euv9pZh3vK+K++DOKFhGqkVDqE=; b=fMoluDQuN9YkhpuIGcM81tGzrRjkP+vp3FxGnacMrGREeC1J/sJO3PnaN19CeHlauNYSN7 Prhfa756zlEliZ/BRGVjmdhDALADkRyxe/2+W188aF9ZAsj0qZdmWFaUS7rCr09Xv5wKq7 ZlYvPSZ3lkfUMxIINv/w2EyjyqUw/lgn46tjoBytrH4p0LWodqXm7Wu8AGTNAy6bPMZwOY vL+Zm+QR8Xj0b/RYBfLlh1c1bzXAB8Auuym1nvcY6WHmPFVv8VYU4dpi4hcxbdnGBS4TnW 6JaFD8LYEYStR4yByzudWVKrLA7pv4ho7uBQpaRTWC/lq8BLpLs5WICiPNAlDA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1673475434; 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=9F+ylXgryOCVvDxv8Euv9pZh3vK+K++DOKFhGqkVDqE=; b=TRALDqdbXtBRk7azDcxo7FnjU4q/r+vmx0COtOQ6ETttb/HfXHyRkNCpGi/RDE5KQ1iCct 5pGwIYJXfD/n3CTKy7VKxL4MRJWgGkD1vT5CAAIDhZoudeEwp7J/0voUXg4nIib3v8iq1O qI5D6xgIzc2rzT+lLy3OYaZq6uhB+2a+nKpG1X2Qfa65CnR9p/dfO8v6ErubvwQ/udclN6 Uda0G6lOoLtRoSo0+hA27e+DZB5MYqyhnGG+T/jC6yt4bbuA8AEm1qwtH217Ux4wUXVk43 1pN/qNRCnDY204k32jJ36PwiTFaNn1CFrM6hCDuznt+nvW76xx6KWVZvGXGIEg== ARC-Authentication-Results: i=1; mx1.freebsd.org; none ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1673475434; a=rsa-sha256; cv=none; b=q4zAlKZKE+uuzJXzV6v1/6mYCnj/g8v31QfSA+ywhjGo2j5C/VMRVHQvOM7p/Ldu71hv7x nYdSd86PQlGTxaRrnFIAUReftA+ARGgvYpEA3vshvOYnMlvWvJL1uk+uSyfDB0FH/70u5K oq5LP/vBo4XXdnbaesoi7gGj4QRaMJyEzWR1j4zAr4FapkK9rGS+uedaT1Kbx9MrJwYjtv LoJt9jg2sEAi0XiIbJXxwq4GNQgmKf5w25vXTO2x6HvqJebv1efEWrjG1yZxXn9fQVw97O z4CGktxLVJzpy1q46eXlNGlRnFTQI28NKTJIaw1I9a9KQf45U2cpPaqeSQs1XA== 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 4Nshqt1NHxz147d; Wed, 11 Jan 2023 22:17:14 +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 30BMHECN093459; Wed, 11 Jan 2023 22:17:14 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 30BMHERY093458; Wed, 11 Jan 2023 22:17:14 GMT (envelope-from git) Date: Wed, 11 Jan 2023 22:17:14 GMT Message-Id: <202301112217.30BMHERY093458@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: ad70f2e22ef2 - main - stand: create common set_currdev 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: ad70f2e22ef29f94bf5208b3a9a2389575330b06 Auto-Submitted: auto-generated X-ThisMailContainsUnwantedMimeParts: N The branch main has been updated by imp: URL: https://cgit.FreeBSD.org/src/commit/?id=ad70f2e22ef29f94bf5208b3a9a2389575330b06 commit ad70f2e22ef29f94bf5208b3a9a2389575330b06 Author: Warner Losh AuthorDate: 2023-01-11 22:14:28 +0000 Commit: Warner Losh CommitDate: 2023-01-11 22:15:15 +0000 stand: create common set_currdev Pull together the nearly identical copies of set_currdev in i386, userboot and efi. Other boot loaders have variances that might be fine to use the common routine, or not. Since they are harder to test for me, and ofw and uboot do handle these setting differently, leave them be for now. Sponsored by: Netflix Reviewed by: kevans Differential Revision: https://reviews.freebsd.org/D38005 --- stand/common/bootstrap.h | 1 + stand/common/misc.c | 17 +++++++++++++++++ stand/efi/loader/main.c | 14 -------------- stand/i386/loader/main.c | 5 +---- stand/userboot/userboot/main.c | 10 ---------- 5 files changed, 19 insertions(+), 28 deletions(-) diff --git a/stand/common/bootstrap.h b/stand/common/bootstrap.h index 138e2e51ceff..261eefaac943 100644 --- a/stand/common/bootstrap.h +++ b/stand/common/bootstrap.h @@ -415,6 +415,7 @@ int nvstore_unset_var(void *, const char *); /* common code to set currdev variable. */ int gen_setcurrdev(struct env_var *ev, int flags, const void *value); int mount_currdev(struct env_var *, int, const void *); +void set_currdev(const char *devname); #ifndef CTASSERT #define CTASSERT(x) _Static_assert(x, "compile-time assertion failed") diff --git a/stand/common/misc.c b/stand/common/misc.c index e27191796a72..b80909b9edfb 100644 --- a/stand/common/misc.c +++ b/stand/common/misc.c @@ -206,3 +206,20 @@ gen_setcurrdev(struct env_var *ev, int flags, const void *value) return (mount_currdev(ev, flags, value)); } + +/* + * Wrapper to set currdev and loaddev at the same time. + */ +void +set_currdev(const char *devname) +{ + + env_setenv("currdev", EV_VOLATILE, devname, gen_setcurrdev, + env_nounset); + /* + * Don't execute hook here; the loaddev hook makes it immutable + * once we've determined what the proper currdev is. + */ + env_setenv("loaddev", EV_VOLATILE | EV_NOHOOK, devname, env_noset, + env_nounset); +} diff --git a/stand/efi/loader/main.c b/stand/efi/loader/main.c index 1e91817410b6..446c267a517a 100644 --- a/stand/efi/loader/main.c +++ b/stand/efi/loader/main.c @@ -185,20 +185,6 @@ out: return retval; } -static void -set_currdev(const char *devname) -{ - - env_setenv("currdev", EV_VOLATILE, devname, gen_setcurrdev, - env_nounset); - /* - * Don't execute hook here; the loaddev hook makes it immutable - * once we've determined what the proper currdev is. - */ - env_setenv("loaddev", EV_VOLATILE | EV_NOHOOK, devname, env_noset, - env_nounset); -} - static void set_currdev_devdesc(struct devdesc *currdev) { diff --git a/stand/i386/loader/main.c b/stand/i386/loader/main.c index 8337ca378832..76e309d4130b 100644 --- a/stand/i386/loader/main.c +++ b/stand/i386/loader/main.c @@ -383,10 +383,7 @@ extract_currdev(void) init_zfs_boot_options(devformat(&new_currdev.dd)); #endif - env_setenv("currdev", EV_VOLATILE, devformat(&new_currdev.dd), - gen_setcurrdev, env_nounset); - env_setenv("loaddev", EV_VOLATILE, devformat(&new_currdev.dd), - env_noset, env_nounset); + set_currdev(devformat(&new_currdev.dd)); } COMMAND_SET(reboot, "reboot", "reboot the system", command_reboot); diff --git a/stand/userboot/userboot/main.c b/stand/userboot/userboot/main.c index 02118c2ec1ae..40911f35020a 100644 --- a/stand/userboot/userboot/main.c +++ b/stand/userboot/userboot/main.c @@ -224,16 +224,6 @@ loader_main(struct loader_callbacks *cb, void *arg, int version, int ndisks) exit(0); } -static void -set_currdev(const char *devname) -{ - - env_setenv("currdev", EV_VOLATILE, devname, - gen_setcurrdev, env_nounset); - env_setenv("loaddev", EV_VOLATILE, devname, - env_noset, env_nounset); -} - /* * Set the 'current device' by (if possible) recovering the boot device as * supplied by the initial bootstrap.