Changeset View
Changeset View
Standalone View
Standalone View
sys/boot/i386/loader/main.c
Show First 20 Lines • Show All 63 Lines • ▼ Show 20 Lines | |||||
struct arch_switch archsw; /* MI/MD interface boundary */ | struct arch_switch archsw; /* MI/MD interface boundary */ | ||||
static void extract_currdev(void); | static void extract_currdev(void); | ||||
static int isa_inb(int port); | static int isa_inb(int port); | ||||
static void isa_outb(int port, int value); | static void isa_outb(int port, int value); | ||||
void exit(int code); | void exit(int code); | ||||
#ifdef LOADER_ZFS_SUPPORT | #ifdef LOADER_ZFS_SUPPORT | ||||
static void list_zfs_bootenv(char *currdev); | |||||
static void i386_zfs_probe(void); | static void i386_zfs_probe(void); | ||||
#endif | #endif | ||||
/* from vers.c */ | /* from vers.c */ | ||||
extern char bootprog_name[], bootprog_rev[], bootprog_date[], bootprog_maker[]; | extern char bootprog_name[], bootprog_rev[], bootprog_date[], bootprog_maker[]; | ||||
/* XXX debugging */ | /* XXX debugging */ | ||||
extern char end[]; | extern char end[]; | ||||
▲ Show 20 Lines • Show All 214 Lines • ▼ Show 20 Lines | if ((biosdev == 0) && (B_TYPE(initial_bootdev) != 2)) /* biosdev doesn't match major */ | ||||
*/ | */ | ||||
if ((new_currdev.d_type == biosdisk.dv_type) && | if ((new_currdev.d_type == biosdisk.dv_type) && | ||||
((new_currdev.d_unit = bd_bios2unit(biosdev)) == -1)) { | ((new_currdev.d_unit = bd_bios2unit(biosdev)) == -1)) { | ||||
printf("Can't work out which disk we are booting from.\n" | printf("Can't work out which disk we are booting from.\n" | ||||
"Guessed BIOS device 0x%x not found by probes, defaulting to disk0:\n", biosdev); | "Guessed BIOS device 0x%x not found by probes, defaulting to disk0:\n", biosdev); | ||||
new_currdev.d_unit = 0; | new_currdev.d_unit = 0; | ||||
} | } | ||||
#ifdef LOADER_ZFS_SUPPORT | |||||
list_zfs_bootenv(zfs_fmtdev(&new_currdev)); | |||||
#endif | |||||
env_setenv("currdev", EV_VOLATILE, i386_fmtdev(&new_currdev), | env_setenv("currdev", EV_VOLATILE, i386_fmtdev(&new_currdev), | ||||
i386_setcurrdev, env_nounset); | i386_setcurrdev, env_nounset); | ||||
env_setenv("loaddev", EV_VOLATILE, i386_fmtdev(&new_currdev), env_noset, | env_setenv("loaddev", EV_VOLATILE, i386_fmtdev(&new_currdev), env_noset, | ||||
env_nounset); | env_nounset); | ||||
} | } | ||||
#ifdef LOADER_ZFS_SUPPORT | |||||
static void | |||||
list_zfs_bootenv(char *currdev) | |||||
{ | |||||
char *beroot; | |||||
/* Remove the trailing : */ | |||||
currdev[strlen(currdev) - 1] = '\0'; | |||||
setenv("zfs_be_active", currdev, 1); | |||||
/* Do not overwrite if already set */ | |||||
setenv("vfs.root.mountfrom", currdev, 0); | |||||
/* Forward past zfs: */ | |||||
currdev = strchr(currdev, ':'); | |||||
currdev++; | |||||
/* Remove the last element (current bootenv) */ | |||||
beroot = strrchr(currdev, '/'); | |||||
beroot[0] = '\0'; | |||||
beroot = currdev; | |||||
if (beroot && beroot[0] != '\0') | |||||
zfs_bootenv(beroot); | |||||
} | |||||
#endif | |||||
COMMAND_SET(reboot, "reboot", "reboot the system", command_reboot); | COMMAND_SET(reboot, "reboot", "reboot the system", command_reboot); | ||||
static int | static int | ||||
command_reboot(int argc, char *argv[]) | command_reboot(int argc, char *argv[]) | ||||
{ | { | ||||
int i; | int i; | ||||
for (i = 0; devsw[i] != NULL; ++i) | for (i = 0; devsw[i] != NULL; ++i) | ||||
Show All 37 Lines | command_lszfs(int argc, char *argv[]) | ||||
return (CMD_ERROR); | return (CMD_ERROR); | ||||
} | } | ||||
err = zfs_list(argv[1]); | err = zfs_list(argv[1]); | ||||
if (err != 0) { | if (err != 0) { | ||||
command_errmsg = strerror(err); | command_errmsg = strerror(err); | ||||
return (CMD_ERROR); | return (CMD_ERROR); | ||||
} | } | ||||
return (CMD_OK); | |||||
} | |||||
COMMAND_SET(reloadbe, "reloadbe", "refresh the list of ZFS Boot Environments", | |||||
smh: Guard with #ifdef LOADER_ZFS_SUPPORT? | |||||
Done Inline ActionsIt is already guarded, the ifdef starts above the previous function (lszfs) and ends just below 'command_reloadbe' allanjude: It is already guarded, the ifdef starts above the previous function (lszfs) and ends just below… | |||||
command_reloadbe); | |||||
static int | |||||
command_reloadbe(int argc, char *argv[]) | |||||
{ | |||||
int err; | |||||
if (argc != 2) { | |||||
command_errmsg = "wrong number of arguments"; | |||||
return (CMD_ERROR); | |||||
} | |||||
err = zfs_bootenv(argv[1]); | |||||
if (err != 0) { | |||||
command_errmsg = strerror(err); | |||||
return (CMD_ERROR); | |||||
} | |||||
return (CMD_OK); | return (CMD_OK); | ||||
} | } | ||||
#endif | #endif | ||||
/* ISA bus access functions for PnP. */ | /* ISA bus access functions for PnP. */ | ||||
static int | static int | ||||
isa_inb(int port) | isa_inb(int port) | ||||
{ | { | ||||
Show All 30 Lines |
Guard with #ifdef LOADER_ZFS_SUPPORT?