From: Sascha Wildner Date: Mon, 24 Mar 2008 23:04:19 +0000 (+0000) Subject: Bring in some fixes from FreeBSD. X-Git-Tag: v2.0.1~927 X-Git-Url: https://gitweb.dragonflybsd.org/dragonfly.git/commitdiff_plain/3a3af6afe40f34041a15fff45109282e54455cf3 Bring in some fixes from FreeBSD. --- diff --git a/usr.sbin/boot0cfg/boot0cfg.8 b/usr.sbin/boot0cfg/boot0cfg.8 index fa4628a9db..1e9fb30d43 100644 --- a/usr.sbin/boot0cfg/boot0cfg.8 +++ b/usr.sbin/boot0cfg/boot0cfg.8 @@ -23,9 +23,9 @@ .\" EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. .\" .\" $FreeBSD: src/usr.sbin/boot0cfg/boot0cfg.8,v 1.5.2.6 2003/03/12 22:08:13 trhodes Exp $ -.\" $DragonFly: src/usr.sbin/boot0cfg/boot0cfg.8,v 1.3 2004/03/11 12:28:58 hmp Exp $ +.\" $DragonFly: src/usr.sbin/boot0cfg/boot0cfg.8,v 1.4 2008/03/24 23:04:19 swildner Exp $ .\" -.Dd February 21, 1999 +.Dd March 23, 2008 .Dt BOOT0CFG 8 .Os .Sh NAME @@ -79,8 +79,6 @@ Install the boot manager. This option causes MBR code to be replaced, without affecting the embedded slice table. -.It Fl v -Verbose: display information about the slices defined, etc. .It Fl b Ar boot0 Specify which .Sq boot0 @@ -110,7 +108,7 @@ specified (with prepended as necessary): .Bl -tag -width indent .It packet -Use the disk packet (BIOS Int 0x13 extensions) interface, as +Use the disk packet (BIOS INT 0x13 extensions) interface, as opposed to the legacy (CHS) interface, when doing disk I/O. This allows booting above cylinder 1023, but requires specific BIOS support. @@ -135,13 +133,12 @@ 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 . (There are approximately 18.2 ticks per second.) +.It Fl v +Verbose: display information about the slices defined, etc. .El .Sh FILES .Bl -tag -width /boot/boot0 -compact @@ -150,15 +147,22 @@ The default .Sq boot0 image .El +.Sh EXIT STATUS +.Ex -std .Sh EXAMPLES -The following is an example of a typical usage -of the -.Nm -utility to affect the next boot: +To boot slice 2 on the next boot: .Pp .Dl "boot0cfg -s 2 ad0" -.Sh DIAGNOSTICS -.Ex -std +.Pp +To enable just slices 1 and 2 in the menu: +.Pp +.Dl "boot0cfg -m 0x3 ad0" +.Pp +To go back to non-interactive booting, use +.Xr fdisk 8 +to install the default MBR: +.Pp +.Dl "fdisk -B ad0" .Sh SEE ALSO .Xr boot 8 , .Xr fdisk 8 diff --git a/usr.sbin/boot0cfg/boot0cfg.c b/usr.sbin/boot0cfg/boot0cfg.c index 2ede24ab6f..53e7e95ea5 100644 --- a/usr.sbin/boot0cfg/boot0cfg.c +++ b/usr.sbin/boot0cfg/boot0cfg.c @@ -24,7 +24,7 @@ * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * * $FreeBSD: src/usr.sbin/boot0cfg/boot0cfg.c,v 1.7.2.4 2002/03/16 01:06:51 mikeh Exp $ - * $DragonFly: src/usr.sbin/boot0cfg/boot0cfg.c,v 1.5 2007/05/20 23:21:37 dillon Exp $ + * $DragonFly: src/usr.sbin/boot0cfg/boot0cfg.c,v 1.6 2008/03/24 23:04:19 swildner Exp $ */ #include @@ -218,9 +218,9 @@ read_mbr(const char *disk, u_int8_t **mbr, int check_version) ssize_t n; if ((fd = open(disk, O_RDONLY)) == -1) - err(1, "%s", disk); + err(1, "open %s", disk); if ((n = read(fd, buf, MBRSIZE)) == -1) - err(1, "%s", disk); + err(1, "read %s", disk); if (n != MBRSIZE) errx(1, "%s: short read", disk); if (cv2(buf + OFF_MAGIC) != 0xaa55) @@ -254,12 +254,18 @@ write_mbr(const char *fname, int flags, u_int8_t *mbr, int mbr_size) { int fd; ssize_t n; - - if ((fd = open(fname, O_WRONLY | flags, 0666)) == -1 || - (n = write(fd, mbr, mbr_size)) == -1 || close(fd)) + + fd = open(fname, O_WRONLY | flags, 0666); + if (fd != -1) { + n = write(fd, mbr, mbr_size); + close(fd); + if (n != mbr_size) + errx(1, "%s: short write", fname); + return; + } + if (flags != 0) err(1, "%s", fname); - if (n != mbr_size) - errx(1, "%s: short write", fname); + err(1, "write_mbr: %s", fname); } /* @@ -350,7 +356,7 @@ boot0bs(const u_int8_t *bs) if (count >= 2) return 1; return 0; -}; +} /* * Adjust "and" and "or" masks for a -o option argument.