Changeset View
Changeset View
Standalone View
Standalone View
stand/i386/zfsboot/zfsboot.c
Show All 20 Lines | |||||
#include <sys/param.h> | #include <sys/param.h> | ||||
#include <sys/errno.h> | #include <sys/errno.h> | ||||
#include <sys/diskmbr.h> | #include <sys/diskmbr.h> | ||||
#ifdef GPT | #ifdef GPT | ||||
#include <sys/gpt.h> | #include <sys/gpt.h> | ||||
#endif | #endif | ||||
#include <sys/reboot.h> | #include <sys/reboot.h> | ||||
#include <sys/queue.h> | #include <sys/queue.h> | ||||
#include <sys/zfs_bootenv.h> | |||||
#include <machine/bootinfo.h> | #include <machine/bootinfo.h> | ||||
#include <machine/elf.h> | #include <machine/elf.h> | ||||
#include <machine/pc/bios.h> | #include <machine/pc/bios.h> | ||||
#include <stdarg.h> | #include <stdarg.h> | ||||
#include <stddef.h> | #include <stddef.h> | ||||
▲ Show 20 Lines • Show All 176 Lines • ▼ Show 20 Lines | bootdev = MAKEBOOTDEV(dev_maj[DEVT_DISK], devdesc.d_slice + 1, | ||||
devdesc.d_partition >= 0 ? devdesc.d_partition : 0xff); | devdesc.d_partition >= 0 ? devdesc.d_partition : 0xff); | ||||
/* | /* | ||||
* zfs_fmtdev() can be called only after dv_init | * zfs_fmtdev() can be called only after dv_init | ||||
*/ | */ | ||||
if (bdev != NULL && bdev->dd.d_dev->dv_type == DEVT_ZFS) { | if (bdev != NULL && bdev->dd.d_dev->dv_type == DEVT_ZFS) { | ||||
/* set up proper device name string for ZFS */ | /* set up proper device name string for ZFS */ | ||||
strncpy(boot_devname, zfs_fmtdev(bdev), sizeof (boot_devname)); | strncpy(boot_devname, zfs_fmtdev(bdev), sizeof (boot_devname)); | ||||
if (zfs_nextboot(bdev, cmd, sizeof(cmd)) == 0) { | if (zfs_get_bootonce(bdev, OS_BOOTONCE, cmd, | ||||
sizeof(cmd)) == 0) { | |||||
nvlist_t *benv; | |||||
nextboot = 1; | nextboot = 1; | ||||
memcpy(cmddup, cmd, sizeof(cmd)); | memcpy(cmddup, cmd, sizeof(cmd)); | ||||
if (parse_cmd()) { | if (parse_cmd()) { | ||||
if (!OPT_CHECK(RBX_QUIET)) | if (!OPT_CHECK(RBX_QUIET)) | ||||
printf("failed to parse pad2 area\n"); | printf("failed to parse bootonce " | ||||
"command\n"); | |||||
exit(0); | exit(0); | ||||
} | } | ||||
if (!OPT_CHECK(RBX_QUIET)) | if (!OPT_CHECK(RBX_QUIET)) | ||||
printf("zfs nextboot: %s\n", cmddup); | printf("zfs bootonce: %s\n", cmddup); | ||||
if (zfs_get_bootenv(bdev, &benv) == 0) { | |||||
nvlist_add_string(benv, OS_BOOTONCE_USED, | |||||
cmddup); | |||||
zfs_set_bootenv(bdev, benv); | |||||
} | |||||
/* Do not process this command twice */ | /* Do not process this command twice */ | ||||
*cmd = 0; | *cmd = 0; | ||||
} | } | ||||
} | } | ||||
/* now make sure we have bdev on all cases */ | /* now make sure we have bdev on all cases */ | ||||
free(bdev); | free(bdev); | ||||
i386_getdev((void **)&bdev, boot_devname, NULL); | i386_getdev((void **)&bdev, boot_devname, NULL); | ||||
▲ Show 20 Lines • Show All 459 Lines • Show Last 20 Lines |