diff options
author | dwmalone <dwmalone@FreeBSD.org> | 2000-08-17 18:42:13 +0000 |
---|---|---|
committer | dwmalone <dwmalone@FreeBSD.org> | 2000-08-17 18:42:13 +0000 |
commit | d2bdccc3f89d8e510f1953252ff3057c2b08046b (patch) | |
tree | dd9c2ac800e7711e0a639d9b737cc1ddcf50630f /usr.sbin | |
parent | 988a836b1e5f7933772ab1724012eb49bafcb430 (diff) | |
download | FreeBSD-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')
-rw-r--r-- | usr.sbin/boot0cfg/boot0cfg.8 | 9 | ||||
-rw-r--r-- | usr.sbin/boot0cfg/boot0cfg.c | 23 |
2 files changed, 28 insertions, 4 deletions
diff --git a/usr.sbin/boot0cfg/boot0cfg.8 b/usr.sbin/boot0cfg/boot0cfg.8 index a56356a..07643da 100644 --- a/usr.sbin/boot0cfg/boot0cfg.8 +++ b/usr.sbin/boot0cfg/boot0cfg.8 @@ -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 . 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"); } /* |