diff options
author | Warner Losh <imp@FreeBSD.org> | 2023-01-11 22:14:28 +0000 |
---|---|---|
committer | Warner Losh <imp@FreeBSD.org> | 2023-01-11 22:15:15 +0000 |
commit | ad70f2e22ef29f94bf5208b3a9a2389575330b06 (patch) | |
tree | 3b618617e1b53853facf76abfbd47e7ad3aee082 | |
parent | bf020787d5f1b4a1274135b49309f7e9ef3955e1 (diff) | |
download | src-ad70f2e22ef29f94bf5208b3a9a2389575330b06.tar.gz src-ad70f2e22ef29f94bf5208b3a9a2389575330b06.zip |
-rw-r--r-- | stand/common/bootstrap.h | 1 | ||||
-rw-r--r-- | stand/common/misc.c | 17 | ||||
-rw-r--r-- | stand/efi/loader/main.c | 14 | ||||
-rw-r--r-- | stand/i386/loader/main.c | 5 | ||||
-rw-r--r-- | 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 @@ -186,20 +186,6 @@ out: } 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) { const char *devname; 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. |