diff --git a/stand/common/bootstrap.h b/stand/common/bootstrap.h --- a/stand/common/bootstrap.h +++ b/stand/common/bootstrap.h @@ -415,6 +415,7 @@ /* 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 --- a/stand/common/misc.c +++ b/stand/common/misc.c @@ -206,3 +206,20 @@ 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 --- a/stand/efi/loader/main.c +++ b/stand/efi/loader/main.c @@ -185,20 +185,6 @@ 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 --- a/stand/i386/loader/main.c +++ b/stand/i386/loader/main.c @@ -383,10 +383,7 @@ 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 --- a/stand/userboot/userboot/main.c +++ b/stand/userboot/userboot/main.c @@ -224,16 +224,6 @@ 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.