Allow people to set the default boot slice with boot0cfg.
PR: 18923 Submitted by: Ian Dowse <iedowse@maths.tcd.ie> Reviewed by: jhb Approved by: rnordier
This commit is contained in:
parent
83e6c3a401
commit
81e309b71b
Notes:
svn2git
2020-12-20 02:59:44 +00:00
svn path=/head/; revision=64797
@ -38,6 +38,7 @@
|
||||
.Op Fl f Ar file
|
||||
.Op Fl m Ar mask
|
||||
.Op Fl o Ar options
|
||||
.Op Fl s Ar slice
|
||||
.Op Fl t Ar ticks
|
||||
.Ar disk
|
||||
.Sh DESCRIPTION
|
||||
@ -118,6 +119,14 @@ and to save slice selection information.) This is the default; a
|
||||
.Sq noupdate
|
||||
option causes the MBR to be treated as read-only.
|
||||
.El
|
||||
.It Fl s Ar slice
|
||||
Set the default boot selection to
|
||||
.Ar slice .
|
||||
Values between 1 and 4 refer to slices; a value of 5 refers to the
|
||||
option of booting from a second disk. This would normally be used in
|
||||
conjunction with the
|
||||
.Sq noupdate
|
||||
option.
|
||||
.It Fl t Ar ticks
|
||||
Set the timeout value to
|
||||
.Ar ticks .
|
||||
|
@ -45,6 +45,7 @@ static const char rcsid[] =
|
||||
#define MBRSIZE 512 /* master boot record size */
|
||||
|
||||
#define OFF_VERSION 0x1b0 /* offset: version number */
|
||||
#define OFF_OPT 0x1b9 /* offset: default boot option */
|
||||
#define OFF_DRIVE 0x1ba /* offset: setdrv drive */
|
||||
#define OFF_FLAGS 0x1bb /* offset: option flags */
|
||||
#define OFF_TICKS 0x1bc /* offset: clock ticks */
|
||||
@ -93,17 +94,17 @@ main(int argc, char *argv[])
|
||||
int boot0_size, mbr_size;
|
||||
const char *bpath, *fpath, *disk;
|
||||
int B_flag, v_flag, o_flag;
|
||||
int d_arg, m_arg, t_arg;
|
||||
int d_arg, m_arg, s_arg, t_arg;
|
||||
int o_and, o_or;
|
||||
int up, c;
|
||||
|
||||
bpath = "/boot/boot0";
|
||||
fpath = NULL;
|
||||
B_flag = v_flag = o_flag = 0;
|
||||
d_arg = m_arg = t_arg = -1;
|
||||
d_arg = m_arg = s_arg = t_arg = -1;
|
||||
o_and = 0xff;
|
||||
o_or = 0;
|
||||
while ((c = getopt(argc, argv, "Bvb:d:f:m:o:t:")) != -1)
|
||||
while ((c = getopt(argc, argv, "Bvb:d:f:m:o:s:t:")) != -1)
|
||||
switch (c) {
|
||||
case 'B':
|
||||
B_flag = 1;
|
||||
@ -127,6 +128,9 @@ main(int argc, char *argv[])
|
||||
stropt(optarg, &o_and, &o_or);
|
||||
o_flag = 1;
|
||||
break;
|
||||
case 's':
|
||||
s_arg = argtoi(optarg, 1, 5, 's');
|
||||
break;
|
||||
case 't':
|
||||
t_arg = argtoi(optarg, 1, 0xffff, 't');
|
||||
break;
|
||||
@ -138,7 +142,8 @@ main(int argc, char *argv[])
|
||||
if (argc != 1)
|
||||
usage();
|
||||
disk = mkrdev(*argv);
|
||||
up = B_flag || d_arg != -1 || m_arg != -1 || o_flag || t_arg != -1;
|
||||
up = B_flag || d_arg != -1 || m_arg != -1 || o_flag || s_arg != -1
|
||||
|| t_arg != -1;
|
||||
|
||||
/* open the disk and read in the existing mbr */
|
||||
mbr_size = read_mbr(disk, &mbr, !B_flag);
|
||||
@ -176,6 +181,10 @@ main(int argc, char *argv[])
|
||||
boot0[OFF_FLAGS] |= o_or;
|
||||
}
|
||||
|
||||
/* set the default boot selection */
|
||||
if (s_arg != -1)
|
||||
boot0[OFF_OPT] = s_arg - 1;
|
||||
|
||||
/* set the timeout */
|
||||
if (t_arg != -1)
|
||||
mk2(boot0 + OFF_TICKS, t_arg);
|
||||
@ -285,6 +294,12 @@ display_mbr(u_int8_t *mbr)
|
||||
printf("%s", opttbl[i].tok);
|
||||
}
|
||||
printf("\n");
|
||||
printf("default_selection=F%d (", mbr[OFF_OPT] + 1);
|
||||
if (mbr[OFF_OPT] < 4)
|
||||
printf("Slice %d", mbr[OFF_OPT] + 1);
|
||||
else
|
||||
printf("Drive 1");
|
||||
printf(")\n");
|
||||
}
|
||||
|
||||
/*
|
||||
|
Loading…
Reference in New Issue
Block a user