From nobody Wed Jan 11 22:17:11 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 4Nshqr1lCxz2sLCD; Wed, 11 Jan 2023 22:17:12 +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 4Nshqr12zBz3tdy; Wed, 11 Jan 2023 22:17:12 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1673475432; 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=FsTZGG2OPo2zhi+N0LE1snUW0BV2KRsmK9mt1BDToNQ=; b=HbSUTs/l/TFAqFm1ncr/LpJM6GfzdRgJc4FYrcuaiyDon+S9Oo3gsI9cN8+nXzkbAhRUyb TBp0V/n1Xv7V4PFHIlRpR38xLDCO0XLYLPXqTqkjbM9GGlVxyldevRSQqU6Q/gJXAQgxir xNb4t8Duvud2tt38r8nny0fpdAP5KrHUDGhRcCKqb7YbsGEeYn9qY4yvgLNUmsyBmR2sYC G2wM+nUpZHWHF21qUacOoxlyEXWN5TrOhSu7TCXx4rk2IOCR/DvWgQpcU73iR8Cap3bNCM yeC4S6K3iKal/g64SJYzOv/XrCPG1fp0v6JgyN0xk5V4kHOMrWvX1XWIMZlebg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1673475432; 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=FsTZGG2OPo2zhi+N0LE1snUW0BV2KRsmK9mt1BDToNQ=; b=pPvOp6sWzZ9zrYW1ql6fA+D6DzOM/soQYM938MAUsWTVEy7LyRgLYYUUK8Tm1riKIhn7pR VRShICM6YDwtAHYYNv0+y+/FmSfGchiQY+qCkYDaVzSsUO6BepEiustaKAHWkq7jxP3Hwy AKg68RHmiJbryQJP1Hri2kCKHIRKDbCNFMl1+/RZ8ztAB3798QgZsncEJ2/GVlxbNrkRGl HP3+WObFJqiC5JuJ6Hhjyt6OIj0qRnQjxlDGlOuGWsKbEFokreOSZAZGD04hSGaEL6ieL1 NRROysTLS62TdtzBSf+o6MXwYQUtGDj9QFzQyn4JQO2JQWVPK7/OsZEJkAkABg== ARC-Authentication-Results: i=1; mx1.freebsd.org; none ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1673475432; a=rsa-sha256; cv=none; b=tHt7rhiN0JZe3d2ha1ySpNT2wIYm8Uik25ou8PEPHnIOydIVgGy6a9pi7LQOuO2HwBbZTp PrhVqxEWFJl4AAlgb8R8d0ZKX8Mq+Dq73WlkAxZO09wijVYqAK1VxX9ErewfALfg3jQd5q AcI7TcP6DQ0wNDLIrXct+pu/QVACEsx+t5L5qeT0ls8YuhYzUQzhmHltaEQEUAPFt0/Pkb ZTGv3XmF0u2crDFgGxpt9vCJk98Mtk9nvpGkMWVQBVLCvhB1RWty5n8a8c2UG4F6OxebEu gn8NrUGYDrwCIWmMru2ohKq7ag7jL9AUDNpRGJqq8ZMi9XJUmsiHERpA0ur/1A== 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 4Nshqr015Fz14VK; Wed, 11 Jan 2023 22:17:11 +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 30BMHBuk093409; Wed, 11 Jan 2023 22:17:11 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 30BMHBB3093408; Wed, 11 Jan 2023 22:17:11 GMT (envelope-from git) Date: Wed, 11 Jan 2023 22:17:11 GMT Message-Id: <202301112217.30BMHBB3093408@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: 1c1783d66bc8 - main - stand: Create common gen_setcurrdev and replace code 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: 1c1783d66bc81ebd0c1304b1f613a9403c073915 Auto-Submitted: auto-generated X-ThisMailContainsUnwantedMimeParts: N The branch main has been updated by imp: URL: https://cgit.FreeBSD.org/src/commit/?id=1c1783d66bc81ebd0c1304b1f613a9403c073915 commit 1c1783d66bc81ebd0c1304b1f613a9403c073915 Author: Warner Losh AuthorDate: 2023-01-11 22:14:02 +0000 Commit: Warner Losh CommitDate: 2023-01-11 22:15:14 +0000 stand: Create common gen_setcurrdev and replace code Replace 4 identical copies of *_setcurrdev with gen_setcurrdev to avoid having to create a 5th copy. uboot_setcurrdev is actually different and needs to remain separate (even though it's quite similar). Sponsored by: Netflix Reviewed by: fuz@fuz.su, kevans Differential Revision: https://reviews.freebsd.org/D38003 --- stand/common/bootstrap.h | 3 ++- stand/common/misc.c | 16 ++++++++++++++++ stand/efi/include/efilib.h | 2 -- stand/efi/libefi/devicename.c | 17 ----------------- stand/efi/loader/main.c | 4 ++-- stand/i386/libi386/devicename.c | 16 ---------------- stand/i386/libi386/libi386.h | 1 - stand/i386/loader/main.c | 4 ++-- stand/i386/zfsboot/zfsboot.c | 4 ++-- stand/libofw/devicename.c | 14 -------------- stand/libofw/libofw.h | 1 - stand/powerpc/ofw/main.c | 6 +++--- stand/userboot/userboot/devicename.c | 16 ---------------- stand/userboot/userboot/libuserboot.h | 1 - stand/userboot/userboot/main.c | 5 ++--- 15 files changed, 29 insertions(+), 81 deletions(-) diff --git a/stand/common/bootstrap.h b/stand/common/bootstrap.h index bbe97e80323b..b16625774ce5 100644 --- a/stand/common/bootstrap.h +++ b/stand/common/bootstrap.h @@ -415,7 +415,8 @@ int nvstore_set_var_from_string(void *, const char *, const char *, int nvstore_unset_var(void *, const char *); /* common code to set currdev variable. */ -extern int mount_currdev(struct env_var *, int, const void *); +int gen_setcurrdev(struct env_var *ev, int flags, const void *value); +int mount_currdev(struct env_var *, int, const void *); #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 9cb5550344ca..e1945b24be5a 100644 --- a/stand/common/misc.c +++ b/stand/common/misc.c @@ -201,3 +201,19 @@ int mount_currdev(struct env_var *ev, int flags, const void *value) } return (rv); } + +/* + * Set currdev to suit the value being supplied in (value) + */ +int +gen_setcurrdev(struct env_var *ev, int flags, const void *value) +{ + struct devdesc *ncurr; + int rv; + + if ((rv = devparse(&ncurr, value, NULL)) != 0) + return (rv); + free(ncurr); + + return (mount_currdev(ev, flags, value)); +} diff --git a/stand/efi/include/efilib.h b/stand/efi/include/efilib.h index bbef44fca4b3..1673ac97fdf2 100644 --- a/stand/efi/include/efilib.h +++ b/stand/efi/include/efilib.h @@ -85,8 +85,6 @@ efi_exit_boot_services(UINTN key) } int efi_getdev(void **vdev, const char *devspec, const char **path); -int efi_setcurrdev(struct env_var *ev, int flags, const void *value); - int efi_register_handles(struct devsw *, EFI_HANDLE *, EFI_HANDLE *, int); EFI_HANDLE efi_find_handle(struct devsw *, int); diff --git a/stand/efi/libefi/devicename.c b/stand/efi/libefi/devicename.c index 83f4e6e99201..ec821821bdf5 100644 --- a/stand/efi/libefi/devicename.c +++ b/stand/efi/libefi/devicename.c @@ -63,20 +63,3 @@ efi_getdev(void **vdev, const char *devspec, const char **path) return (devparse(dev, devspec, path)); } - -/* - * Set currdev to suit the value being supplied in (value) - */ -int -efi_setcurrdev(struct env_var *ev, int flags, const void *value) -{ - struct devdesc *ncurr; - int rv; - - rv = devparse(&ncurr, value, NULL); - if (rv != 0) - return (rv); - free(ncurr); - - return (mount_currdev(ev, flags, value)); -} diff --git a/stand/efi/loader/main.c b/stand/efi/loader/main.c index a315fdea8edc..1e91817410b6 100644 --- a/stand/efi/loader/main.c +++ b/stand/efi/loader/main.c @@ -189,7 +189,7 @@ static void set_currdev(const char *devname) { - env_setenv("currdev", EV_VOLATILE, devname, efi_setcurrdev, + env_setenv("currdev", EV_VOLATILE, devname, gen_setcurrdev, env_nounset); /* * Don't execute hook here; the loaddev hook makes it immutable @@ -970,7 +970,7 @@ main(int argc, CHAR16 *argv[]) cons_probe(); /* Set up currdev variable to have hooks in place. */ - env_setenv("currdev", EV_VOLATILE, "", efi_setcurrdev, env_nounset); + env_setenv("currdev", EV_VOLATILE, "", gen_setcurrdev, env_nounset); /* Init the time source */ efi_time_init(); diff --git a/stand/i386/libi386/devicename.c b/stand/i386/libi386/devicename.c index 99d3aa7920bc..99674a4ac877 100644 --- a/stand/i386/libi386/devicename.c +++ b/stand/i386/libi386/devicename.c @@ -63,19 +63,3 @@ i386_getdev(void **vdev, const char *devspec, const char **path) */ return(devparse(dev, devspec, path)); } - -/* - * Set currdev to suit the value being supplied in (value) - */ -int -i386_setcurrdev(struct env_var *ev, int flags, const void *value) -{ - struct devdesc *ncurr; - int rv; - - if ((rv = devparse(&ncurr, value, NULL)) != 0) - return (rv); - free(ncurr); - - return (mount_currdev(ev, flags, value)); -} diff --git a/stand/i386/libi386/libi386.h b/stand/i386/libi386/libi386.h index 0115f30e31c7..587a367ccf9c 100644 --- a/stand/i386/libi386/libi386.h +++ b/stand/i386/libi386/libi386.h @@ -80,7 +80,6 @@ extern uint16_t relocator_a20_enabled; int i386_getdev(void **vdev, const char *devspec, const char **path); char *i386_fmtdev(void *vdev); -int i386_setcurrdev(struct env_var *ev, int flags, const void *value); extern struct devdesc currdev; /* our current device */ diff --git a/stand/i386/loader/main.c b/stand/i386/loader/main.c index e5cc766f5781..8337ca378832 100644 --- a/stand/i386/loader/main.c +++ b/stand/i386/loader/main.c @@ -164,7 +164,7 @@ main(void) /* Set up currdev variable to have hooks in place. */ env_setenv("currdev", EV_VOLATILE | EV_NOHOOK, "", - i386_setcurrdev, env_nounset); + gen_setcurrdev, env_nounset); /* * Initialise the block cache. Set the upper limit. @@ -384,7 +384,7 @@ extract_currdev(void) #endif env_setenv("currdev", EV_VOLATILE, devformat(&new_currdev.dd), - i386_setcurrdev, env_nounset); + gen_setcurrdev, env_nounset); env_setenv("loaddev", EV_VOLATILE, devformat(&new_currdev.dd), env_noset, env_nounset); } diff --git a/stand/i386/zfsboot/zfsboot.c b/stand/i386/zfsboot/zfsboot.c index da91fc3a5d20..6b8c72ea0fb8 100644 --- a/stand/i386/zfsboot/zfsboot.c +++ b/stand/i386/zfsboot/zfsboot.c @@ -208,7 +208,7 @@ main(void) bd_bios2unit(bootinfo.bi_bios_dev)); /* Set up currdev variable to have hooks in place. */ - env_setenv("currdev", EV_VOLATILE, "", i386_setcurrdev, + env_setenv("currdev", EV_VOLATILE, "", gen_setcurrdev, env_nounset); devinit(); @@ -256,7 +256,7 @@ main(void) free(bdev); i386_getdev((void **)&bdev, boot_devname, NULL); - env_setenv("currdev", EV_VOLATILE, boot_devname, i386_setcurrdev, + env_setenv("currdev", EV_VOLATILE, boot_devname, gen_setcurrdev, env_nounset); /* Process configuration file */ diff --git a/stand/libofw/devicename.c b/stand/libofw/devicename.c index 77a53ccd90ce..76ba5530520c 100644 --- a/stand/libofw/devicename.c +++ b/stand/libofw/devicename.c @@ -92,20 +92,6 @@ ofw_path_to_handle(const char *ofwpath, const char *want_type, const char **path return ((phandle_t)-1); } -int -ofw_setcurrdev(struct env_var *ev, int flags, const void *value) -{ - struct devdesc *ncurr; - int rv; - - if ((rv = devparse(&ncurr, value, NULL)) != 0) - return (rv); - - free(ncurr); - - return (mount_currdev(ev, flags, value)); -} - int ofw_common_parsedev(struct devdesc **dev, const char *devspec, const char **path, const char *ofwtype) diff --git a/stand/libofw/libofw.h b/stand/libofw/libofw.h index 2d6ea9a5bf24..3101dcb645be 100644 --- a/stand/libofw/libofw.h +++ b/stand/libofw/libofw.h @@ -45,7 +45,6 @@ struct ofw_devdesc { }; extern int ofw_getdev(void **vdev, const char *devspec, const char **path); -extern ev_sethook_t ofw_setcurrdev; extern struct devsw ofwdisk; extern struct devsw ofw_netdev; diff --git a/stand/powerpc/ofw/main.c b/stand/powerpc/ofw/main.c index 177e665a4dc7..83ab2647f308 100644 --- a/stand/powerpc/ofw/main.c +++ b/stand/powerpc/ofw/main.c @@ -180,7 +180,7 @@ main(int (*openfirm)(void *)) #endif /* Set up currdev variable to have hooks in place. */ - env_setenv("currdev", EV_VOLATILE, "", ofw_setcurrdev, env_nounset); + env_setenv("currdev", EV_VOLATILE, "", gen_setcurrdev, env_nounset); devinit(); @@ -202,11 +202,11 @@ main(int (*openfirm)(void *)) bargc = 0; parse(&bargc, &bargv, bootargs); if (bargc == 1) - env_setenv("currdev", EV_VOLATILE, bargv[0], ofw_setcurrdev, + env_setenv("currdev", EV_VOLATILE, bargv[0], gen_setcurrdev, env_nounset); else env_setenv("currdev", EV_VOLATILE, bootpath, - ofw_setcurrdev, env_nounset); + gen_setcurrdev, env_nounset); env_setenv("loaddev", EV_VOLATILE, bootpath, env_noset, env_nounset); setenv("LINES", "24", 1); /* optional */ diff --git a/stand/userboot/userboot/devicename.c b/stand/userboot/userboot/devicename.c index e6d7e9706c18..8caafd1cab67 100644 --- a/stand/userboot/userboot/devicename.c +++ b/stand/userboot/userboot/devicename.c @@ -64,19 +64,3 @@ userboot_getdev(void **vdev, const char *devspec, const char **path) */ return (devparse(dev, devspec, path)); } - -/* - * Set currdev to suit the value being supplied in (value) - */ -int -userboot_setcurrdev(struct env_var *ev, int flags, const void *value) -{ - struct devdesc *ncurr; - int rv; - - if ((rv = devparse(&ncurr, value, NULL)) != 0) - return (rv); - free(ncurr); - - return (mount_currdev(ev, flags, value)); -} diff --git a/stand/userboot/userboot/libuserboot.h b/stand/userboot/userboot/libuserboot.h index 6d7dc0c3ff40..5539b617cdce 100644 --- a/stand/userboot/userboot/libuserboot.h +++ b/stand/userboot/userboot/libuserboot.h @@ -57,7 +57,6 @@ extern ssize_t userboot_copyin(const void *, vm_offset_t, size_t); extern ssize_t userboot_copyout(vm_offset_t, void *, size_t); extern ssize_t userboot_readin(readin_handle_t, vm_offset_t, size_t); extern int userboot_getdev(void **, const char *, const char **); -int userboot_setcurrdev(struct env_var *ev, int flags, const void *value); int bi_getboothowto(char *kargs); void bi_setboothowto(int howto); diff --git a/stand/userboot/userboot/main.c b/stand/userboot/userboot/main.c index b403d9b48f56..02118c2ec1ae 100644 --- a/stand/userboot/userboot/main.c +++ b/stand/userboot/userboot/main.c @@ -172,8 +172,7 @@ loader_main(struct loader_callbacks *cb, void *arg, int version, int ndisks) cons_probe(); /* Set up currdev variable to have hooks in place. */ - env_setenv("currdev", EV_VOLATILE, "", - userboot_setcurrdev, env_nounset); + env_setenv("currdev", EV_VOLATILE, "", gen_setcurrdev, env_nounset); printf("\n%s", bootprog_info); #if 0 @@ -230,7 +229,7 @@ set_currdev(const char *devname) { env_setenv("currdev", EV_VOLATILE, devname, - userboot_setcurrdev, env_nounset); + gen_setcurrdev, env_nounset); env_setenv("loaddev", EV_VOLATILE, devname, env_noset, env_nounset); }