Date: Fri, 21 Feb 2003 09:58:10 -0800 (PST) From: Robert Watson <rwatson@FreeBSD.org> To: Perforce Change Reviews <perforce@freebsd.org> Subject: PERFORCE change 25537 for review Message-ID: <200302211758.h1LHwAKu096810@repoman.freebsd.org>
next in thread | raw e-mail | index | archive | help
http://perforce.freebsd.org/chv.cgi?CH=25537 Change 25537 by rwatson@rwatson_tislabs on 2003/02/21 09:57:16 Submerge local revisions due to extensive conflicts with main tree revisions. Affected files ... .. //depot/projects/trustedbsd/mac/sbin/disklabel/Makefile#4 integrate .. //depot/projects/trustedbsd/mac/sbin/disklabel/disklabel.5#7 integrate .. //depot/projects/trustedbsd/mac/sbin/disklabel/disklabel.8#12 integrate .. //depot/projects/trustedbsd/mac/sbin/disklabel/disklabel.c#17 integrate .. //depot/projects/trustedbsd/mac/sbin/disklabel/pathnames.h#2 integrate Differences ... ==== //depot/projects/trustedbsd/mac/sbin/disklabel/Makefile#4 (text+ko) ==== ==== //depot/projects/trustedbsd/mac/sbin/disklabel/disklabel.5#7 (text+ko) ==== ==== //depot/projects/trustedbsd/mac/sbin/disklabel/disklabel.8#12 (text+ko) ==== @@ -33,7 +33,7 @@ .\" SUCH DAMAGE. .\" .\" @(#)disklabel.8 8.2 (Berkeley) 4/19/94 -.\" $FreeBSD: src/sbin/disklabel/disklabel.8,v 1.43 2002/12/24 13:41:46 ru Exp $ +.\" $FreeBSD: src/sbin/disklabel/disklabel.8,v 1.45 2003/01/26 14:35:53 phk Exp $ .\" .Dd July 30, 1999 .Dt DISKLABEL 8 @@ -61,15 +61,11 @@ .Op Fl r .Op Fl n .Ar disk Ar protofile -.Nm -.Op Fl NW -.Ar disk .Pp .Nm .Fl B .Oo -.Fl b Ar boot1 -.Fl s Ar boot2 +.Fl b Ar boot .Oc .Ar disk .Oo Ar disktype/auto Oc @@ -78,8 +74,7 @@ .Fl B .Op Fl n .Oo -.Fl b Ar boot1 -.Fl s Ar boot2 +.Fl b Ar boot .Oc .Ar disk Ar disktype/auto .Oo Ar packid Oc @@ -88,8 +83,7 @@ .Fl B .Op Fl n .Oo -.Fl b Ar boot1 -.Fl s Ar boot2 +.Fl b Ar boot .Oc .Ar disk Ar protofile .Oo Ar disktype/auto Oc @@ -311,27 +305,6 @@ is used, no data will be written to the device, and instead the disklabel that would have been written will be printed to stdout. This is useful to see how a partitioning scheme will work out for a specific disk. -.Ss Enabling and disabling writing to the disk label area -.Pp -By default, it is not possible to write to the disk label area at the beginning -of a disk. The disk driver arranges for -.Xr write 2 -and similar system calls -to return -.Er EROFS -on any attempt to do so. If you need -to write to this area (for example, to obliterate the label), use the form -.Pp -.Nm -.Fl W -.Ar disk -.Pp -To disallow writing to the label area after previously allowing it, use the -command -.Pp -.Nm -.Fl N -.Ar disk .Ss Installing bootstraps .Pp The final three forms of @@ -354,8 +327,7 @@ .Nm .Fl B .Oo -.Fl b Ar boot1 -.Fl s Ar boot2 +.Fl b Ar boot .Oc .Ar disk .Oo Ar disktype Oc @@ -373,8 +345,7 @@ .Fl B .Op Fl n .Oo -.Fl b Ar boot1 -.Fl s Ar boot2 +.Fl b Ar boot .Oc .Ar disk Ar disktype .Oo Ar packid Oc @@ -396,8 +367,7 @@ .Fl B .Op Fl n .Oo -.Fl b Ar boot1 -.Fl s Ar boot2 +.Fl b Ar boot .Oc .Ar disk Ar protofile .Oo Ar disktype Oc @@ -447,12 +417,8 @@ .Xr disktab 5 entry for the disk if the disktab entry exists and includes those parameters. .It -Otherwise, the default boot image names are used: -.Pa /boot/boot1 -and -.Pa /boot/boot2 -for the standard stage1 and stage2 boot images (details may vary -on architectures like the Alpha, where only a single-stage boot is used). +Otherwise, the default boot image name are used: +.Pa /boot/boot . .El .Ss Initializing/Formatting a bootable disk from scratch .Pp @@ -773,21 +739,17 @@ Install a new bootstrap on .Pa da0s1 . The boot code comes from -.Pa /boot/boot1 -and possibly -.Pa /boot/boot2 . +.Pa /boot/boot . On-disk and in-core labels are unchanged. .Pp -.Dl disklabel -w -B /dev/da0s1 -b newboot1 -s newboot2 da2212 +.Dl disklabel -w -B /dev/da0s1 -b newboot da2212 .Pp Install a new label and bootstrap. The label is derived from disktab information for .Dq da2212 and installed both in-core and on-disk. The bootstrap code comes from the files -.Pa /boot/newboot1 -and -.Pa /boot/newboot2 . +.Pa /boot/newboot .Pp .Dl dd if=/dev/zero of=/dev/da0 bs=512 count=32 .Dl fdisk -BI da0 ==== //depot/projects/trustedbsd/mac/sbin/disklabel/disklabel.c#17 (text+ko) ==== @@ -54,7 +54,7 @@ #endif /* not lint */ #include <sys/cdefs.h> -__FBSDID("$FreeBSD: src/sbin/disklabel/disklabel.c,v 1.66 2003/01/16 12:57:53 des Exp $"); +__FBSDID("$FreeBSD: src/sbin/disklabel/disklabel.c,v 1.77 2003/01/26 21:55:43 phk Exp $"); #include <sys/param.h> #include <sys/file.h> @@ -69,9 +69,6 @@ #else #include <sys/diskmbr.h> #endif -#ifdef __sparc64__ -#include <sys/sun_disklabel.h> -#endif #include <unistd.h> #include <string.h> @@ -97,12 +94,6 @@ #ifndef BBSIZE #define BBSIZE 8192 /* size of boot area, with label */ #endif -/* - * Define an upper boundary for the boot blocks. - */ -#ifndef MAXBBSIZE -#define MAXBBSIZE 262144 /* max size of boot area, with label */ -#endif /* FIX! These are too low, but are traditional */ #define DEFAULT_NEWFS_BLOCK 8192U @@ -113,12 +104,11 @@ #define BIG_NEWFS_FRAG 2048U #define BIG_NEWFS_CPG 64U -#if defined(__i386__) || defined(__ia64__) -#define NUMBOOT 2 -#elif defined(__alpha__) || defined(__sparc64__) || defined(__powerpc__) -#define NUMBOOT 1 +#if defined(__i386__) +#elif defined(__alpha__) +#elif defined(__ia64__) #else -#error I do not know about this architecture. +#error I do not know about this architecture, and shall probably not be compiled for it. #endif void makelabel(const char *, const char *, struct disklabel *); @@ -134,7 +124,6 @@ int getasciilabel(FILE *, struct disklabel *); int getasciipartspec(char *, struct disklabel *, int, int); int checklabel(struct disklabel *); -void setbootflag(struct disklabel *); void Warning(const char *, ...) __printflike(1, 2); void usage(void); struct disklabel *getvirginlabel(void); @@ -148,7 +137,7 @@ char namebuf[BBSIZE], *np = namebuf; struct disklabel lab; -char bootarea[MAXBBSIZE]; +char bootarea[BBSIZE]; char blank[] = ""; char unknown[] = "unknown"; @@ -158,53 +147,35 @@ char part_offset_type[MAX_NUM_PARTS]; int part_set[MAX_NUM_PARTS]; -#if NUMBOOT > 0 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 *bootxx; /* secondary boot */ char boot0[MAXPATHLEN]; -char boot1[MAXPATHLEN]; -#endif enum { - UNSPEC, EDIT, NOWRITE, READ, RESTORE, WRITE, WRITEABLE, WRITEBOOT + UNSPEC, EDIT, READ, RESTORE, WRITE, WRITEBOOT } op = UNSPEC; int rflag; int disable_write; /* set to disable writing to disk label */ -#define OPTIONS "BNRWb:enrs:w" +#define OPTIONS "BRb:enrs:w" int main(int argc, char *argv[]) { struct disklabel *lp; FILE *t; - int ch, f = 0, flag, error = 0; + int ch, f = 0, error = 0; char *name = 0; while ((ch = getopt(argc, argv, OPTIONS)) != -1) switch (ch) { -#if NUMBOOT > 0 case 'B': ++installboot; break; case 'b': xxboot = optarg; break; -#if NUMBOOT > 1 - case 's': - bootxx = optarg; - break; -#endif -#endif - case 'N': - if (op != UNSPEC) - usage(); - op = NOWRITE; - break; case 'n': disable_write = 1; break; @@ -213,11 +184,6 @@ usage(); op = RESTORE; break; - case 'W': - if (op != UNSPEC) - usage(); - op = WRITEABLE; - break; case 'e': if (op != UNSPEC) usage(); @@ -237,19 +203,15 @@ } argc -= optind; argv += optind; -#if NUMBOOT > 0 if (installboot) { + rflag++; if (op == UNSPEC) op = WRITEBOOT; } else { if (op == UNSPEC) op = READ; - xxboot = bootxx = 0; + xxboot = 0; } -#else - if (op == UNSPEC) - op = READ; -#endif if (argc < 1) usage(); @@ -266,6 +228,10 @@ np = namebuf + strlen(specname) + 1; f = open(specname, op == READ ? O_RDONLY : O_RDWR); } + if (f < 0 && errno == EBUSY) { + /* lets try to get by with ioctls */ + f = open(specname, O_RDONLY); + } if (f < 0) err(4, "%s", specname); @@ -281,12 +247,6 @@ error = edit(lp, f); break; - case NOWRITE: - flag = 0; - if (ioctl(f, DIOCWLABEL, (char *)&flag) < 0) - err(4, "ioctl DIOCWLABEL"); - break; - case READ: if (argc != 1) usage(); @@ -296,7 +256,6 @@ break; case RESTORE: -#if NUMBOOT > 0 if (installboot && argc == 3) { makelabel(argv[2], 0, &lab); argc--; @@ -309,7 +268,6 @@ */ bzero((char *)&lab, sizeof(lab)); } -#endif if (argc != 2) usage(); if (!(t = fopen(argv[1], "r"))) @@ -335,13 +293,6 @@ error = writelabel(f, bootarea, lp); break; - case WRITEABLE: - flag = 1; - if (ioctl(f, DIOCWLABEL, (char *)&flag) < 0) - err(4, "ioctl DIOCWLABEL"); - break; - -#if NUMBOOT > 0 case WRITEBOOT: { struct disklabel tlab; @@ -350,14 +301,12 @@ tlab = *lp; if (argc == 2) makelabel(argv[1], 0, &lab); - lab.d_bbsize = lp->d_bbsize; lp = makebootarea(bootarea, &lab, f); *lp = tlab; if (checklabel(lp) == 0) error = writelabel(f, bootarea, lp); break; } -#endif } exit(error); } @@ -387,149 +336,58 @@ int writelabel(int f, const char *boot, struct disklabel *lp) { - int flag; #ifdef __alpha__ u_long *p, sum; int i; #endif -#ifdef __sparc64__ - struct sun_disklabel *sl; - u_short cksum, *sp1, *sp2; - struct partition *npp; - struct sun_dkpart *spp; - int i, secpercyl; -#endif if (disable_write) { Warning("write to disk label supressed - label was as follows:"); display(stdout, lp); return (0); - } else { - setbootflag(lp); - lp->d_magic = DISKMAGIC; - lp->d_magic2 = DISKMAGIC; - lp->d_checksum = 0; - lp->d_checksum = dkcksum(lp); - if (rflag || op == WRITEBOOT) { - /* - * 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 (op != WRITEBOOT && ioctl(f, DIOCSDINFO, lp) < 0 && - errno != ENODEV && errno != ENOTTY) { - l_perror("ioctl DIOCSDINFO"); - return (1); - } - (void)lseek(f, (off_t)0, SEEK_SET); - -#ifdef __alpha__ - /* - * Generate the bootblock checksum for the SRM console. - */ - for (p = (u_long *)boot, i = 0, sum = 0; i < 63; i++) - sum += p[i]; - p[63] = sum; -#endif -#ifdef __sparc64__ - /* - * Generate a Sun disklabel around the BSD label for - * PROM compatability. - */ - sl = (struct sun_disklabel *)boot; - memcpy(sl->sl_text, lp->d_packname, sizeof(lp->d_packname)); - sl->sl_rpm = lp->d_rpm; - sl->sl_pcylinders = lp->d_ncylinders + - lp->d_acylinders; /* XXX */ - sl->sl_sparespercyl = lp->d_sparespercyl; - sl->sl_interleave = lp->d_interleave; - sl->sl_ncylinders = lp->d_ncylinders; - sl->sl_acylinders = lp->d_acylinders; - sl->sl_ntracks = lp->d_ntracks; - sl->sl_nsectors = lp->d_nsectors; - sl->sl_magic = SUN_DKMAGIC; - secpercyl = sl->sl_nsectors * sl->sl_ntracks; - for (i = 0; i < 8; i++) { - spp = &sl->sl_part[i]; - npp = &lp->d_partitions[i]; - /* - * SunOS partitions must start on a cylinder - * boundary. Note this restriction is forced - * upon FreeBSD/sparc64 labels too, since we - * want to keep both labels synchronised. - */ - spp->sdkp_cyloffset = npp->p_offset / secpercyl; - spp->sdkp_nsectors = npp->p_size; - } + } - /* Compute the XOR checksum. */ - sp1 = (u_short *)sl; - sp2 = (u_short *)(sl + 1); - sl->sl_cksum = cksum = 0; - while (sp1 < sp2) - cksum ^= *sp1++; - sl->sl_cksum = cksum; -#endif - if (op != WRITEBOOT) { - /* - * write enable label sector before write (if - * necessary), disable after writing. - */ - flag = 1; - (void)ioctl(f, DIOCWLABEL, &flag); - if (write(f, boot, lp->d_bbsize) != (int)lp->d_bbsize) { - warn("write"); - return (1); - } - } else { - /* - * Write out all of the boot area except - * for the sector reserved for the disklabel - * itself; that part is written only by - * the kernel, and we can't get it right. - */ - ssize_t labelareabegin, labelareaend; - - labelareabegin = (LABELSECTOR * lp->d_secsize) - + LABELOFFSET; - labelareaend = labelareabegin + lp->d_secsize; - if (write(f, boot, labelareabegin) != - labelareabegin) { - warn("write"); - return (1); - } - (void)lseek(f, (off_t)labelareaend, SEEK_SET); - if (write(f, boot + labelareaend, - lp->d_bbsize - labelareaend) != - lp->d_bbsize - labelareaend) { - warn("write"); - return (1); - } - } -#if NUMBOOT > 0 - /* - * Output the remainder of the disklabel - */ - if (bootbuf && write(f, bootbuf, bootsize) != bootsize) { - warn("write"); - return(1); - } -#endif - if (op != WRITEBOOT) { - flag = 0; - (void) ioctl(f, DIOCWLABEL, &flag); - } else if (ioctl(f, DIOCWDINFO, lp) < 0) { - l_perror("ioctl DIOCWDINFO"); - return (1); - } - } else if (ioctl(f, DIOCWDINFO, lp) < 0) { + lp->d_magic = DISKMAGIC; + lp->d_magic2 = DISKMAGIC; + lp->d_checksum = 0; + lp->d_checksum = dkcksum(lp); + if (!rflag) { + if (ioctl(f, DIOCWDINFO, lp) < 0) { l_perror("ioctl DIOCWDINFO"); return (1); } + return (0); } + + /* + * 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 (ioctl(f, DIOCSDINFO, lp) < 0 && + errno != ENODEV && errno != ENOTTY) { + l_perror("ioctl DIOCSDINFO"); + return (1); + } + (void)lseek(f, (off_t)0, SEEK_SET); + +#ifdef __alpha__ + /* + * Generate the bootblock checksum for the SRM console. + */ + for (p = (u_long *)boot, i = 0, sum = 0; i < 63; i++) + sum += p[i]; + p[63] = sum; +#endif + if (ioctl(f, DIOCBSDBB, &boot) == 0) + return (0); + if (write(f, boot, lp->d_bbsize) != (int)lp->d_bbsize) { + warn("write"); + return (1); + } return (0); } @@ -604,28 +462,25 @@ struct disklabel *lp; char *p; int b; -#if NUMBOOT > 0 char *dkbasename; struct stat sb; -#endif #ifdef __alpha__ u_long *bootinfo; int n; #endif #ifdef __i386__ char *tmpbuf; - int i, found; + int i, found, dps; #endif /* XXX */ - if (dp->d_secsize == 0) + if (dp->d_secsize == 0) { dp->d_secsize = DEV_BSIZE; - if (dp->d_bbsize == 0) dp->d_bbsize = BBSIZE; + } lp = (struct disklabel *) (boot + (LABELSECTOR * dp->d_secsize) + LABELOFFSET); bzero((char *)lp, 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 @@ -633,7 +488,7 @@ */ if (!installboot) { if (rflag) { - if (read(f, boot, lp->d_bbsize) < lp->d_bbsize) + if (read(f, boot, BBSIZE) < BBSIZE) err(4, "%s", specname); bzero((char *)lp, sizeof *lp); } @@ -643,7 +498,7 @@ * We are installing a boot program. Determine the name(s) and * read them into the appropriate places in the boot area. */ - if (!xxboot || !bootxx) { + if (!xxboot) { dkbasename = np; if ((p = rindex(dkname, '/')) == NULL) p = dkname; @@ -654,36 +509,22 @@ *np++ = '\0'; if (!xxboot) { - (void)sprintf(boot0, "%s/boot1", _PATH_BOOTDIR); + (void)sprintf(boot0, "%s/boot", _PATH_BOOTDIR); xxboot = boot0; } -#if NUMBOOT > 1 - if (!bootxx) { - (void)sprintf(boot1, "%s/boot2", _PATH_BOOTDIR); - bootxx = boot1; - } -#endif } - /* - * Strange rules: - * 1. One-piece bootstrap (hp300/hp800) - * 1. One-piece bootstrap (alpha/sparc64) - * up to d_bbsize bytes of ``xxboot'' go in bootarea, the rest - * is remembered and written later following the bootarea. - * 2. Two-piece bootstraps (i386/ia64) - * up to d_secsize bytes of ``xxboot'' go in first d_secsize - * bytes of bootarea, remaining d_bbsize-d_secsize filled - * from ``bootxx''. - */ b = open(xxboot, O_RDONLY); if (b < 0) err(4, "%s", xxboot); -#if NUMBOOT > 1 + if (fstat(b, &sb) != 0) + err(4, "%s", xxboot); #ifdef __i386__ + if (sb.st_size > BBSIZE) + errx(4, "%s too large", xxboot); /* * XXX Botch alert. - * The i386 has the so-called fdisk table embedded into the + * The i386/PC98 has the so-called fdisk table embedded into the * primary bootstrap. We take care to not clobber it, but * only if it does already contain some data. (Otherwise, * the xxboot provides a template.) @@ -691,77 +532,46 @@ if ((tmpbuf = (char *)malloc((int)dp->d_secsize)) == 0) err(4, "%s", xxboot); memcpy((void *)tmpbuf, (void *)boot, (int)dp->d_secsize); -#endif /* __i386__ */ - if (read(b, boot, (int)dp->d_secsize) < 0) + + if (read(b, boot, BBSIZE) < 0) err(4, "%s", xxboot); - (void)close(b); + + /* XXX: rely on some very precise overlaps in definitions */ #ifdef PC98 + dps = sizeof(struct pc98_partition); +#else + dps = sizeof(struct dos_partition); +#endif for (i = DOSPARTOFF, found = 0; - !found && i < (int)(DOSPARTOFF + NDOSPART * sizeof(struct pc98_partition)); + !found && i < (int)(DOSPARTOFF + NDOSPART * dps); i++) found = tmpbuf[i] != 0; if (found) memcpy((void *)&boot[DOSPARTOFF], (void *)&tmpbuf[DOSPARTOFF], - NDOSPART * sizeof(struct pc98_partition)); + NDOSPART * dps); free(tmpbuf); -#elif defined(__i386__) - for (i = DOSPARTOFF, found = 0; - !found && i < (int)(DOSPARTOFF + NDOSPART*sizeof(struct dos_partition)); - i++) - found = tmpbuf[i] != 0; - if (found) - memcpy((void *)&boot[DOSPARTOFF], - (void *)&tmpbuf[DOSPARTOFF], - NDOSPART * sizeof(struct dos_partition)); - free(tmpbuf); #endif /* __i386__ */ - b = open(bootxx, O_RDONLY); - if (b < 0) - err(4, "%s", bootxx); - if (fstat(b, &sb) != 0) - err(4, "%s", bootxx); - if (dp->d_secsize + sb.st_size > dp->d_bbsize) - errx(4, "%s too large", bootxx); - if (read(b, &boot[dp->d_secsize], - (int)(dp->d_bbsize-dp->d_secsize)) < 0) - err(4, "%s", bootxx); -#else /* !(NUMBOOT > 1) */ + #ifdef __alpha__ + if (sb.st_size > BBSIZE - dp->d_secsize) + errx(4, "%s too large", xxboot); /* * On the alpha, the primary bootstrap starts at the * second sector of the boot area. The first sector * contains the label and must be edited to contain the * size and location of the primary bootstrap. */ - n = read(b, boot + dp->d_secsize, (int)dp->d_bbsize); + n = read(b, boot + dp->d_secsize, BBSIZE - dp->d_secsize); if (n < 0) err(4, "%s", xxboot); bootinfo = (u_long *)(boot + 480); bootinfo[0] = (n + dp->d_secsize - 1) / dp->d_secsize; bootinfo[1] = 1; /* start at sector 1 */ bootinfo[2] = 0; /* flags (must be zero) */ -#else /* !__alpha__ */ - if (read(b, boot, (int)dp->d_bbsize) < 0) - err(4, "%s", xxboot); #endif /* __alpha__ */ - if (fstat(b, &sb) != 0) - err(4, "%s", xxboot); - 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 = (char *)malloc((size_t)bootsize); - if (bootbuf == 0) - err(4, "%s", xxboot); - if (read(b, bootbuf, bootsize) < 0) { - free(bootbuf); - err(4, "%s", xxboot); - } - } -#endif /* NUMBOOT > 1 */ + (void)close(b); -#endif /* NUMBOOT > 0 */ /* * Make sure no part of the bootstrap is written in the area * reserved for the label. @@ -801,7 +611,6 @@ fprintf(f, "sectors/cylinder: %lu\n", (u_long)lp->d_secpercyl); fprintf(f, "cylinders: %lu\n", (u_long)lp->d_ncylinders); fprintf(f, "sectors/unit: %lu\n", (u_long)lp->d_secperunit); - fprintf(f, "boot block size: %u\n", lp->d_bbsize); fprintf(f, "rpm: %u\n", lp->d_rpm); fprintf(f, "interleave: %u\n", lp->d_interleave); fprintf(f, "trackskew: %u\n", lp->d_trackskew); @@ -1143,16 +952,6 @@ lp->d_secperunit = v; continue; } - if (streq(cp, "boot block size")) { - v = strtoul(tp, NULL, 10); - if (v == 0 || v > UINT_MAX) { - fprintf(stderr, "line %d: %s: bad %s\n", - lineno, tp, cp); - errors++; - } else - lp->d_bbsize = v; - continue; - } if (streq(cp, "rpm")) { v = strtoul(tp, NULL, 10); if (v == 0 || v > USHRT_MAX) { @@ -1553,14 +1352,6 @@ if (pp->p_size == 0 && pp->p_offset != 0) Warning("partition %c: size 0, but offset %lu", part, (u_long)pp->p_offset); -#ifdef __sparc64__ - /* See comment in writelabel(). */ - if (pp->p_offset % lp->d_secpercyl != 0) { - fprintf(stderr, "partition %c: does not start on a " - "cylinder boundary!\n", part); - errors++; - } -#endif #ifdef notdef if (pp->p_size % lp->d_secpercyl) Warning("partition %c: size %% cylinder-size != 0", @@ -1686,10 +1477,10 @@ loclab.d_secpercyl = loclab.d_ntracks * loclab.d_nsectors; loclab.d_ncylinders = loclab.d_secperunit / loclab.d_secpercyl; loclab.d_npartitions = MAXPARTITIONS; - loclab.d_bbsize = BBSIZE; /* Various (unneeded) compat stuff */ loclab.d_rpm = 3600; + loclab.d_bbsize = BBSIZE; loclab.d_interleave = 1;; strncpy(loclab.d_typename, "amnesiac", sizeof(loclab.d_typename)); @@ -1701,48 +1492,7 @@ return (&loclab); } -/* - * 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 file system where it might - * clobber bootstrap code. - */ -void -setbootflag(struct disklabel *lp) -{ - struct partition *pp; - int i, errors = 0; - char part; - u_long boffset; - if (bootbuf == 0) - return; - boffset = bootsize / lp->d_secsize; - for (i = 0; i < lp->d_npartitions; i++) { - part = 'a' + i; - pp = &lp->d_partitions[i]; - if (pp->p_size == 0) - continue; - if (boffset <= pp->p_offset) { - if (pp->p_fstype == FS_BOOT) - pp->p_fstype = FS_UNUSED; - } else if (pp->p_fstype != FS_BOOT) { - if (pp->p_fstype != FS_UNUSED) { - fprintf(stderr, - "boot overlaps used partition %c\n", - part); - errors++; - } else { - pp->p_fstype = FS_BOOT; - Warning("boot overlaps partition %c, %s", - part, "marked as FS_BOOT"); - } - } - } - if (errors) - errx(4, "cannot install boot program"); -} - /*VARARGS1*/ void Warning(const char *fmt, ...) @@ -1759,8 +1509,7 @@ void usage(void) { -#if NUMBOOT > 0 - fprintf(stderr, "%s\n%s\n%s\n%s\n%s\n%s\n%s\n%s\n%s\n%s\n%s\n%s\n%s\n%s\n%s\n%s\n", + fprintf(stderr, "%s\n%s\n%s\n%s\n%s\n%s\n%s\n%s\n%s\n%s\n%s\n%s\n%s\n%s\n", "usage: disklabel [-r] disk", "\t\t(to read label)", " disklabel -w [-r] [-n] disk type [ packid ]", @@ -1769,34 +1518,12 @@ "\t\t(to edit label)", " disklabel -R [-r] [-n] disk protofile", "\t\t(to restore label with existing boot program)", -#if NUMBOOT > 1 - " disklabel -B [-n] [ -b boot1 [ -s boot2 ] ] disk [ type ]", - "\t\t(to install boot program with existing label)", - " disklabel -w -B [-n] [ -b boot1 [ -s boot2 ] ] disk type [ packid ]", - "\t\t(to write label and boot program)", - " disklabel -R -B [-n] [ -b boot1 [ -s boot2 ] ] disk protofile [ type ]", - "\t\t(to restore label and boot program)", -#else " disklabel -B [-n] [ -b bootprog ] disk [ type ]", "\t\t(to install boot program with existing on-disk label)", " disklabel -w -B [-n] [ -b bootprog ] disk type [ packid ]", "\t\t(to write label and install boot program)", " disklabel -R -B [-n] [ -b bootprog ] disk protofile [ type ]", - "\t\t(to restore label and install boot program)", -#endif - " disklabel [-NW] disk", - "\t\t(to write disable/enable label)"); -#else - fprintf(stderr, "%s\n%s\n%s\n%s\n%s\n%s\n%s\n%s\n%s\n", - "usage: disklabel [-r] disk", "(to read label)", - " disklabel -w [-r] [-n] disk type [ packid ]", - "\t\t(to write label)", - " disklabel -e [-r] [-n] disk", - "\t\t(to edit label)", - " disklabel -R [-r] [-n] disk protofile", - "\t\t(to restore label)", - " disklabel [-NW] disk", - "\t\t(to write disable/enable label)"); -#endif + "\t\t(to restore label and install boot program)" + ); exit(1); } ==== //depot/projects/trustedbsd/mac/sbin/disklabel/pathnames.h#2 (text+ko) ==== To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe p4-projects" in the body of the message
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200302211758.h1LHwAKu096810>
