summaryrefslogtreecommitdiffstats
path: root/usr.sbin/boot0cfg/boot0cfg.c
diff options
context:
space:
mode:
authordwmalone <dwmalone@FreeBSD.org>2000-08-17 18:42:13 +0000
committerdwmalone <dwmalone@FreeBSD.org>2000-08-17 18:42:13 +0000
commitd2bdccc3f89d8e510f1953252ff3057c2b08046b (patch)
treedd9c2ac800e7711e0a639d9b737cc1ddcf50630f /usr.sbin/boot0cfg/boot0cfg.c
parent988a836b1e5f7933772ab1724012eb49bafcb430 (diff)
downloadFreeBSD-src-d2bdccc3f89d8e510f1953252ff3057c2b08046b.zip
FreeBSD-src-d2bdccc3f89d8e510f1953252ff3057c2b08046b.tar.gz
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
Diffstat (limited to 'usr.sbin/boot0cfg/boot0cfg.c')
-rw-r--r--usr.sbin/boot0cfg/boot0cfg.c23
1 files changed, 19 insertions, 4 deletions
diff --git a/usr.sbin/boot0cfg/boot0cfg.c b/usr.sbin/boot0cfg/boot0cfg.c
index 7724436..ac60c69 100644
--- a/usr.sbin/boot0cfg/boot0cfg.c
+++ b/usr.sbin/boot0cfg/boot0cfg.c
@@ -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");
}
/*
OpenPOWER on IntegriCloud