diff --git a/stand/common/bootstrap.h b/stand/common/bootstrap.h --- a/stand/common/bootstrap.h +++ b/stand/common/bootstrap.h @@ -415,7 +415,8 @@ 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 --- a/stand/common/misc.c +++ b/stand/common/misc.c @@ -201,3 +201,19 @@ } 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 --- a/stand/efi/include/efilib.h +++ b/stand/efi/include/efilib.h @@ -85,8 +85,6 @@ } 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 --- a/stand/efi/libefi/devicename.c +++ b/stand/efi/libefi/devicename.c @@ -63,20 +63,3 @@ 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 --- a/stand/efi/loader/main.c +++ b/stand/efi/loader/main.c @@ -189,7 +189,7 @@ 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 @@ 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 --- a/stand/i386/libi386/devicename.c +++ b/stand/i386/libi386/devicename.c @@ -63,19 +63,3 @@ */ 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 --- a/stand/i386/libi386/libi386.h +++ b/stand/i386/libi386/libi386.h @@ -80,7 +80,6 @@ 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 --- a/stand/i386/loader/main.c +++ b/stand/i386/loader/main.c @@ -164,7 +164,7 @@ /* 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 @@ #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 --- a/stand/i386/zfsboot/zfsboot.c +++ b/stand/i386/zfsboot/zfsboot.c @@ -208,7 +208,7 @@ 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 @@ 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 --- a/stand/libofw/devicename.c +++ b/stand/libofw/devicename.c @@ -92,20 +92,6 @@ 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 --- a/stand/libofw/libofw.h +++ b/stand/libofw/libofw.h @@ -45,7 +45,6 @@ }; 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 --- a/stand/powerpc/ofw/main.c +++ b/stand/powerpc/ofw/main.c @@ -180,7 +180,7 @@ #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 @@ 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 --- a/stand/userboot/userboot/devicename.c +++ b/stand/userboot/userboot/devicename.c @@ -64,19 +64,3 @@ */ 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 --- a/stand/userboot/userboot/libuserboot.h +++ b/stand/userboot/userboot/libuserboot.h @@ -57,7 +57,6 @@ 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 --- a/stand/userboot/userboot/main.c +++ b/stand/userboot/userboot/main.c @@ -172,8 +172,7 @@ 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 @@ { env_setenv("currdev", EV_VOLATILE, devname, - userboot_setcurrdev, env_nounset); + gen_setcurrdev, env_nounset); env_setenv("loaddev", EV_VOLATILE, devname, env_noset, env_nounset); }