From ad38393034af13edf433128b9734322f2ad8f5a8 Mon Sep 17 00:00:00 2001 From: miod Date: Thu, 15 Oct 2015 19:31:15 +0000 Subject: [PATCH] Remove disklabel -B (NUMBOOT) support. All the platforms which used to need it are now using MI installboot for that purpose. ok krw@ deraadt@ --- sbin/disklabel/Makefile | 4 +- sbin/disklabel/disklabel.8 | 65 +--------- sbin/disklabel/disklabel.c | 244 +------------------------------------ sbin/disklabel/editor.c | 15 +-- 4 files changed, 8 insertions(+), 320 deletions(-) diff --git a/sbin/disklabel/Makefile b/sbin/disklabel/Makefile index 49b96592871..062abb754fc 100644 --- a/sbin/disklabel/Makefile +++ b/sbin/disklabel/Makefile @@ -1,4 +1,4 @@ -# $OpenBSD: Makefile,v 1.58 2015/10/05 04:43:03 miod Exp $ +# $OpenBSD: Makefile,v 1.59 2015/10/15 19:31:15 miod Exp $ PROG= disklabel SRCS= disklabel.c dkcksum.c editor.c manual.c @@ -38,7 +38,7 @@ CFLAGS+= -DSEEALSO="\"fdisk(8)\"" .endif .if (${MACHINE} == "vax") -CFLAGS+= -DNUMBOOT=1 +CFLAGS+= -DSEEALSO="\"installboot(8)\"" .endif .if (${MACHINE} == "landisk") diff --git a/sbin/disklabel/disklabel.8 b/sbin/disklabel/disklabel.8 index e43b4e94dd0..ce6048888a5 100644 --- a/sbin/disklabel/disklabel.8 +++ b/sbin/disklabel/disklabel.8 @@ -1,4 +1,4 @@ -.\" $OpenBSD: disklabel.8,v 1.115 2015/05/19 18:50:39 sobrado Exp $ +.\" $OpenBSD: disklabel.8,v 1.116 2015/10/15 19:31:15 miod Exp $ .\" $NetBSD: disklabel.8,v 1.9 1995/03/18 14:54:38 cgd Exp $ .\" .\" Copyright (c) 1987, 1988, 1991, 1993 @@ -33,7 +33,7 @@ .\" .\" @(#)disklabel.8 8.2 (Berkeley) 4/19/94 .\" -.Dd $Mdocdate: May 19 2015 $ +.Dd $Mdocdate: October 15 2015 $ .Dt DISKLABEL 8 .Os .Sh NAME @@ -67,26 +67,6 @@ .Op Fl nv .Op Fl F Ns | Ns Fl f Ar file .Ar disk Ar protofile -.Pp -.Nm disklabel -.Fl B\ \& -.Op Fl nv -.Op Fl b Ar boot1 -.Ar disk -.Op Ar disktype -.Nm disklabel -.Fl Bw -.Op Fl nv -.Op Fl b Ar boot1 -.Ar disk Ar disktype -.Op Ar packid -.Nm disklabel -.Fl BR -.Op Fl nv -.Op Fl b Ar boot1 -.Op Fl F Ns | Ns Fl f Ar file -.Ar disk Ar protofile -.Op Ar disktype .Sh DESCRIPTION The .Nm @@ -127,15 +107,6 @@ portion of the disk in the recommended manner. See .Sx AUTOMATIC DISK ALLOCATION , below. -.It Fl B -Install bootstrap code. -Some architectures instead require bootstrap code installation to be -done using an -.Xr installboot 8 -type program, as described in -.Xr boot 8 . -.It Fl b Ar boot1 -Specify the primary boot program. .It Fl c Clear the system's in-core copy of the label and update it based on the on-disk label. @@ -491,38 +462,6 @@ The final three forms of are used to install bootstrap code on machines where the bootstrap is part of the label. .Pp -When installing bootstrap code with the -.Fl B -flag, if the boot program name is not explicitly given with -.Fl b Ar boot1 , -a standard boot program -will be used. -The standard boot programs are located in -.Pa /usr/mdec . -The name of the program is taken from the -.Dq b0 -parameter of the -.Xr disktab 5 -entry for the disk if -.Ar disktype -was given and its disktab entry exists and includes a b0 field. -Otherwise, the boot program name is derived from the name of the -disk. -These names are of the form -.Pa basename Ns boot . -For example, -.Pa /usr/mdec/sdboot -if the disk device is -.Em sd0 . -.Pp -The first of the three boot-installation forms is used to install -bootstrap code without changing the existing label. -It is essentially a read command with respect to the disk label itself -and all options are related to the specification of the boot program -as described previously. -The final two forms are analogous to the basic write and restore versions -except that they will install bootstrap code in addition to a new label. -.Pp Note that when a disk has no real .Bx disklabel, the kernel creates a diff --git a/sbin/disklabel/disklabel.c b/sbin/disklabel/disklabel.c index 0634bdc02d8..ccf1217ec93 100644 --- a/sbin/disklabel/disklabel.c +++ b/sbin/disklabel/disklabel.c @@ -1,4 +1,4 @@ -/* $OpenBSD: disklabel.c,v 1.209 2015/10/11 04:36:22 deraadt Exp $ */ +/* $OpenBSD: disklabel.c,v 1.210 2015/10/15 19:31:15 miod Exp $ */ /* * Copyright (c) 1987, 1993 @@ -70,28 +70,14 @@ #define BBSIZE 8192 /* size of boot area, with label */ #endif -#ifndef NUMBOOT -#define NUMBOOT 0 -#endif - char *dkname, *specname, *fstabfile; char tmpfil[] = _PATH_TMPFILE; char *mountpoints[MAXPARTITIONS]; struct disklabel lab; char bootarea[BBSIZE]; -#if NUMBOOT > 0 -char namebuf[BBSIZE], *np = namebuf; -int installboot; /* non-zero if we should install a boot program */ -char *bootbuf; /* pointer to buffer with remainder of boot prog */ -int bootsize; /* size of remaining boot program */ -char *xxboot; /* primary boot */ -char boot0[MAXPATHLEN]; -void setbootflag(struct disklabel *); -#endif - enum { - UNSPEC, EDIT, EDITOR, READ, RESTORE, WRITE, WRITEBOOT + UNSPEC, EDIT, EDITOR, READ, RESTORE, WRITE } op = UNSPEC; int aflag; @@ -124,19 +110,11 @@ main(int argc, char *argv[]) FILE *t; char *autotable = NULL; - while ((ch = getopt(argc, argv, "ABEf:F:hRb:cdenp:tT:vw")) != -1) + while ((ch = getopt(argc, argv, "AEf:F:hRcdenp:tT:vw")) != -1) switch (ch) { case 'A': aflag = 1; break; -#if NUMBOOT > 0 - case 'B': - installboot = 1; - break; - case 'b': - xxboot = optarg; - break; -#endif case 'R': if (op != UNSPEC) usage(); @@ -201,18 +179,8 @@ main(int argc, char *argv[]) argc -= optind; argv += optind; -#if NUMBOOT > 0 - if (installboot) { - if (op == UNSPEC) - op = WRITEBOOT; - } else { - if (op == UNSPEC) - op = READ; - } -#else if (op == UNSPEC) op = READ; -#endif if (argc < 1 || (fstabfile && !(op == EDITOR || op == RESTORE || aflag))) @@ -258,10 +226,6 @@ main(int argc, char *argv[]) if (argc < 2 || argc > 3) usage(); readlabel(f); -#if NUMBOOT > 0 - if (installboot && argc == 3) - makelabel(argv[2], NULL, &lab); -#endif lp = makebootarea(bootarea, &lab); *lp = lab; if (!(t = fopen(argv[1], "r"))) @@ -291,23 +255,6 @@ main(int argc, char *argv[]) if (error == 0) error = writelabel(f, bootarea, lp); break; -#if NUMBOOT > 0 - case WRITEBOOT: - { - struct disklabel tlab; - - readlabel(f); - tlab = lab; - if (argc == 2) - makelabel(argv[1], NULL, &lab); - lp = makebootarea(bootarea, &lab); - *lp = tlab; - error = checklabel(&lab); - if (error == 0) - error = writelabel(f, bootarea, lp); - break; - } -#endif default: break; } @@ -328,23 +275,6 @@ makelabel(char *type, char *name, struct disklabel *lp) if (dp == NULL) errx(1, "unknown disk type: %s", type); *lp = *dp; -#if NUMBOOT > 0 - /* - * Set bootstrap name(s). - * 1. If set from command line, use those, - * 2. otherwise, check if disktab specifies them (b0 or b1), - * 3. otherwise, makebootarea() will choose ones based on the name - * of the disk special file. E.g. /dev/ra0 -> raboot, bootra - */ - if (!xxboot && lp->d_boot0) { - if (*lp->d_boot0 != '/') - (void)snprintf(boot0, sizeof boot0, "%s%s", - _PATH_BOOTDIR, lp->d_boot0); - else - (void)strlcpy(boot0, lp->d_boot0, sizeof boot0); - xxboot = boot0; - } -#endif /* d_packname is union d_boot[01], so zero */ memset(lp->d_packname, 0, sizeof(lp->d_packname)); if (name) @@ -355,49 +285,10 @@ makelabel(char *type, char *name, struct disklabel *lp) int writelabel(int f, char *boot, struct disklabel *lp) { -#if NUMBOOT > 0 - setbootflag(lp); -#endif lp->d_magic = DISKMAGIC; lp->d_magic2 = DISKMAGIC; lp->d_checksum = 0; lp->d_checksum = dkcksum(lp); -#if NUMBOOT > 0 - if (installboot) { - /* - * First set the kernel disk label, - * then write a label to the raw disk. - * If the SDINFO ioctl fails because it is unimplemented, - * keep going; otherwise, the kernel consistency checks - * may prevent us from changing the current (in-core) - * label. - */ - if (!donothing) { - if (ioctl(f, DIOCSDINFO, lp) < 0 && - errno != ENODEV && errno != ENOTTY) { - l_perror("ioctl DIOCSDINFO"); - return (1); - } - } - if (!donothing) { - if (lseek(f, 0, SEEK_SET) < 0) { - perror("lseek"); - return (1); - } - if (write(f, boot, lp->d_bbsize) != lp->d_bbsize) { - perror("write"); - return (1); - } - } - /* - * Output the remainder of the disklabel - */ - if (!donothing && bootbuf && write(f, bootbuf, bootsize) != bootsize) { - perror("write"); - return(1); - } - } else -#endif /* NUMBOOT > 0 */ if (!donothing) { if (ioctl(f, DIOCWDINFO, lp) < 0) { l_perror("ioctl DIOCWDINFO"); @@ -498,11 +389,6 @@ makebootarea(char *boot, struct disklabel *dp) { struct disklabel *lp; char *p; -#if NUMBOOT > 0 - char *dkbasename; - int b; - struct stat sb; -#endif /* XXX */ if (dp->d_secsize == 0) { @@ -512,66 +398,6 @@ makebootarea(char *boot, struct disklabel *dp) lp = (struct disklabel *) (boot + (LABELSECTOR * dp->d_secsize) + LABELOFFSET); memset(lp, 0, sizeof *lp); -#if NUMBOOT > 0 - /* - * If we are not installing a boot program but we are installing a - * label on disk then we must read the current bootarea so we don't - * clobber the existing boot. - */ - if (!installboot) - return (lp); - /* - * We are installing a boot program. Determine the name(s) and - * read them into the appropriate places in the boot area. - */ - if (!xxboot) { - dkbasename = np; - if ((p = strrchr(dkname, '/')) == NULL) - p = dkname; - else - p++; - while (*p && !isdigit((unsigned char)*p)) - *np++ = *p++; - *np++ = '\0'; - - (void)snprintf(np, namebuf + sizeof namebuf - np, - "%s%sboot", _PATH_BOOTDIR, dkbasename); - if (access(np, F_OK) < 0 && dkbasename[0] == 'r') - dkbasename++; - xxboot = np; - (void)snprintf(xxboot, - namebuf + sizeof namebuf - np, - "%s%sboot", _PATH_BOOTDIR, dkbasename); - np += strlen(xxboot) + 1; - } - if (verbose) - warnx("bootstrap: xxboot = %s", xxboot); - - /* - * For NUMBOOT > 0 architectures (vax) - * up to d_bbsize bytes of ``xxboot'' go in bootarea, the rest - * is remembered and written later following the bootarea. - */ - b = open(xxboot, O_RDONLY); - if (b < 0) - err(4, "%s", xxboot); - if (read(b, boot, (int)dp->d_bbsize) < 0) - err(4, "%s", xxboot); - (void)fstat(b, &sb); - bootsize = (int)sb.st_size - dp->d_bbsize; - if (bootsize > 0) { - /* XXX assume d_secsize is a power of two */ - bootsize = (bootsize + dp->d_secsize-1) & ~(dp->d_secsize-1); - bootbuf = malloc((size_t)bootsize); - if (bootbuf == NULL) - err(4, "%s", xxboot); - if (read(b, bootbuf, bootsize) < 0) { - free(bootbuf); - err(4, "%s", xxboot); - } - } - (void)close(b); -#endif /* * Make sure no part of the bootstrap is written in the area * reserved for the label. @@ -1389,60 +1215,6 @@ checklabel(struct disklabel *lp) return (errors > 0); } -#if NUMBOOT > 0 -/* - * If we are installing a boot program that doesn't fit in d_bbsize - * we need to mark those partitions that the boot overflows into. - * This allows newfs to prevent creation of a filesystem where it might - * clobber bootstrap code. - */ -void -setbootflag(struct disklabel *lp) -{ - struct partition *pp; - int i, errors = 0; - u_int64_t bend; - char part; - - if (bootbuf == NULL) - return; - - bend = (u_int64_t)bootsize / lp->d_secsize; - for (i = 0; i < lp->d_npartitions; i++) { - if (i == RAW_PART) - /* It will *ALWAYS* overlap 'c'. */ - continue; - pp = &lp->d_partitions[i]; - if (DL_GETPSIZE(pp) == 0) - /* Partition is unused. */ - continue; - if (bend <= DL_GETPOFFSET(pp)) { - /* Boot blocks end before this partition starts. */ - if (pp->p_fstype == FS_BOOT) - pp->p_fstype = FS_UNUSED; - continue; - } - - part = 'a' + i; - switch (pp->p_fstype) { - case FS_BOOT: /* Already marked. */ - break; - case FS_UNUSED: /* Mark. */ - pp->p_fstype = FS_BOOT; - warnx("warning, boot overlaps partition %c, %s", - part, "marked as FS_BOOT"); - break; - default: - warnx("boot overlaps used partition %c", part); - errors++; - break; - } - } - if (errors) - errx(4, "cannot install boot program"); -} -#endif - int cmplabel(struct disklabel *lp1, struct disklabel *lp2) { @@ -1477,16 +1249,6 @@ usage(void) "\n"); fprintf(stderr, " disklabel -R [-nv] [-F|-f file] disk protofile\t\t(restore)\n\n"); -#if NUMBOOT > 0 - fprintf(stderr, - " disklabel -B [-nv] [-b boot1] disk [disktype]\t\t(boot)\n"); - fprintf(stderr, - " disklabel -Bw [-nv] [-b boot1] disk disktype [packid]\t" - "(boot+write)\n"); - fprintf(stderr, - " disklabel -BR [-nv] [-F|-f file ] [-b boot1] disk protofile\t\t" - "(boot+restore)\n\n"); -#endif fprintf(stderr, "`disk' may be of the form: sd0 or /dev/rsd0%c.\n", 'a'+RAW_PART); fprintf(stderr, diff --git a/sbin/disklabel/editor.c b/sbin/disklabel/editor.c index a230bd004b0..b871302ff51 100644 --- a/sbin/disklabel/editor.c +++ b/sbin/disklabel/editor.c @@ -1,4 +1,4 @@ -/* $OpenBSD: editor.c,v 1.296 2015/09/08 13:54:09 millert Exp $ */ +/* $OpenBSD: editor.c,v 1.297 2015/10/15 19:31:15 miod Exp $ */ /* * Copyright (c) 1997-2000 Todd C. Miller @@ -47,10 +47,6 @@ #define DO_CONVERSIONS 0x00000001 #define DO_ROUNDING 0x00000002 -#ifndef NUMBOOT -#define NUMBOOT 0 -#endif - /* structure to describe a portion of a disk */ struct diskchunk { u_int64_t start; @@ -1751,15 +1747,6 @@ find_bounds(struct disklabel *lp) " portion of the disk.\nYou can use the 'b'" " command to change this.\n\n", starting_sector, ending_sector); - } else { -#if NUMBOOT > 0 - /* Boot blocks take up the first cylinder */ - starting_sector = lp->d_secpercyl; - if (verbose) - printf("Reserving the first data cylinder for boot" - " blocks.\nYou can use the 'b' command to change" - " this.\n\n"); -#endif } } -- 2.20.1