Changeset View
Changeset View
Standalone View
Standalone View
stand/userboot/userboot/main.c
Show First 20 Lines • Show All 208 Lines • ▼ Show 20 Lines | #endif | ||||
if (setjmp(jb)) | if (setjmp(jb)) | ||||
return; | return; | ||||
interact(); /* doesn't return */ | interact(); /* doesn't return */ | ||||
exit(0); | exit(0); | ||||
} | } | ||||
static void | |||||
set_currdev(const char *devname) | |||||
{ | |||||
env_setenv("currdev", EV_VOLATILE, devname, | |||||
userboot_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 | * Set the 'current device' by (if possible) recovering the boot device as | ||||
* supplied by the initial bootstrap. | * supplied by the initial bootstrap. | ||||
*/ | */ | ||||
static void | static void | ||||
extract_currdev(void) | extract_currdev(void) | ||||
{ | { | ||||
struct disk_devdesc dev; | struct disk_devdesc dev; | ||||
struct devdesc *dd; | struct devdesc *dd; | ||||
#if defined(USERBOOT_ZFS_SUPPORT) | #if defined(USERBOOT_ZFS_SUPPORT) | ||||
struct zfs_devdesc zdev; | struct zfs_devdesc zdev; | ||||
char *buf = NULL; | |||||
if (userboot_zfs_found) { | if (userboot_zfs_found) { | ||||
/* Leave the pool/root guid's unassigned */ | /* Leave the pool/root guid's unassigned */ | ||||
bzero(&zdev, sizeof(zdev)); | bzero(&zdev, sizeof(zdev)); | ||||
zdev.dd.d_dev = &zfs_dev; | zdev.dd.d_dev = &zfs_dev; | ||||
init_zfs_bootenv(zfs_fmtdev(&zdev)); | init_zfs_bootenv(zfs_fmtdev(&zdev)); | ||||
Show All 16 Lines | if (userboot_disk_maxunit > 0) { | ||||
} | } | ||||
dd = &dev.dd; | dd = &dev.dd; | ||||
} else { | } else { | ||||
dev.dd.d_dev = &host_dev; | dev.dd.d_dev = &host_dev; | ||||
dev.dd.d_unit = 0; | dev.dd.d_unit = 0; | ||||
dd = &dev.dd; | dd = &dev.dd; | ||||
} | } | ||||
env_setenv("currdev", EV_VOLATILE, userboot_fmtdev(dd), | set_currdev(userboot_fmtdev(dd)); | ||||
userboot_setcurrdev, env_nounset); | |||||
env_setenv("loaddev", EV_VOLATILE, userboot_fmtdev(dd), | #if defined(USERBOOT_ZFS_SUPPORT) | ||||
env_noset, env_nounset); | buf = malloc(VDEV_PAD_SIZE); | ||||
if (buf != NULL) { | |||||
if (zfs_nextboot(&zdev, buf, VDEV_PAD_SIZE) == 0) { | |||||
printf("zfs nextboot: %s\n", buf); | |||||
set_currdev(buf); | |||||
} | |||||
free(buf); | |||||
} | |||||
#endif | |||||
} | } | ||||
#if defined(USERBOOT_ZFS_SUPPORT) | #if defined(USERBOOT_ZFS_SUPPORT) | ||||
static void | static void | ||||
userboot_zfs_probe(void) | userboot_zfs_probe(void) | ||||
{ | { | ||||
char devname[32]; | char devname[32]; | ||||
uint64_t pool_guid; | uint64_t pool_guid; | ||||
Show All 35 Lines |