diff options
author | Theo de Raadt <deraadt@cvs.openbsd.org> | 2007-06-17 00:32:22 +0000 |
---|---|---|
committer | Theo de Raadt <deraadt@cvs.openbsd.org> | 2007-06-17 00:32:22 +0000 |
commit | ad5e118396fcd2a9b7b0e050d2afe54576f65cba (patch) | |
tree | 99adb4a0ec68c89788a0b5d911d2e6cc6cc58d9b /sbin | |
parent | ea009c71d607b258f0ac14f65c465aed5c53f364 (diff) |
On Sun machines, disklabels coming from the kernel will now have a d_flags
bit D_VENDOR if they face the Sun cylinder / start-at-zero semantics. Other
disklabels found on these architectures do not have these issues, and do
not need to be constrained. checked by otto
Diffstat (limited to 'sbin')
-rw-r--r-- | sbin/disklabel/Makefile | 4 | ||||
-rw-r--r-- | sbin/disklabel/disklabel.c | 27 | ||||
-rw-r--r-- | sbin/disklabel/editor.c | 32 |
3 files changed, 39 insertions, 24 deletions
diff --git a/sbin/disklabel/Makefile b/sbin/disklabel/Makefile index 2171bc7f567..0c71f15a09e 100644 --- a/sbin/disklabel/Makefile +++ b/sbin/disklabel/Makefile @@ -1,4 +1,4 @@ -# $OpenBSD: Makefile,v 1.44 2007/06/16 17:32:13 deraadt Exp $ +# $OpenBSD: Makefile,v 1.45 2007/06/17 00:32:21 deraadt Exp $ PROG= disklabel SRCS= disklabel.c dkcksum.c editor.c manual.c @@ -58,7 +58,7 @@ CFLAGS+= -DSEEALSO="\"installboot(8)\"" .if (${MACHINE} == "solbourne") || (${MACHINE} == "sparc") || \ (${MACHINE} == "sparc64") -CFLAGS+= -DSEEALSO="\"installboot(8)\"" -DCYLCHECK -DAAT0 +CFLAGS+= -DSEEALSO="\"installboot(8)\"" -DSUN_CYLCHECK -DSUN_AAT0 .endif .if (${MACHINE} == "zaurus") diff --git a/sbin/disklabel/disklabel.c b/sbin/disklabel/disklabel.c index 6c3bdd49bf9..b64099e807f 100644 --- a/sbin/disklabel/disklabel.c +++ b/sbin/disklabel/disklabel.c @@ -1,4 +1,4 @@ -/* $OpenBSD: disklabel.c,v 1.113 2007/06/08 19:08:35 otto Exp $ */ +/* $OpenBSD: disklabel.c,v 1.114 2007/06/17 00:32:21 deraadt Exp $ */ /* * Copyright (c) 1987, 1993 @@ -39,7 +39,7 @@ static const char copyright[] = #endif /* not lint */ #ifndef lint -static const char rcsid[] = "$OpenBSD: disklabel.c,v 1.113 2007/06/08 19:08:35 otto Exp $"; +static const char rcsid[] = "$OpenBSD: disklabel.c,v 1.114 2007/06/17 00:32:21 deraadt Exp $"; #endif /* not lint */ #include <sys/param.h> @@ -1083,6 +1083,8 @@ display(FILE *f, struct disklabel *lp, char **mp, char unit, int edit, fprintf(f, "flags:"); if (lp->d_flags & D_BADSECT) fprintf(f, " badsect"); + if (lp->d_flags & D_VENDOR) + fprintf(f, " vendor"); putc('\n', f); } fprintf(f, "bytes/sector: %u\n", lp->d_secsize); @@ -1656,16 +1658,19 @@ checklabel(struct disklabel *lp) if (DL_GETPSIZE(pp) == 0 && DL_GETPOFFSET(pp) != 0) warnx("warning, partition %c: size 0, but offset %lld", part, DL_GETPSIZE(pp)); -#ifdef CYLCHECK - if (i != RAW_PART && DL_GETPSIZE(pp) % lp->d_secpercyl) - warnx("warning, partition %c: size %% cylinder-size != 0", - part); - if (i != RAW_PART && DL_GETPOFFSET(pp) % lp->d_secpercyl) - warnx("warning, partition %c: offset %% cylinder-size != 0", - part); +#ifdef SUN_CYLCHECK + if (lp->d_flags & D_VENDOR) { + if (i != RAW_PART && DL_GETPSIZE(pp) % lp->d_secpercyl) + warnx("warning, partition %c: size %% " + "cylinder-size != 0", part); + if (i != RAW_PART && DL_GETPOFFSET(pp) % lp->d_secpercyl) + warnx("warning, partition %c: offset %% " + "cylinder-size != 0", part); + } #endif -#ifdef AAT0 - if (i == 0 && DL_GETPSIZE(pp) != 0 && DL_GETPOFFSET(pp) != 0) { +#ifdef SUN_AAT0 + if ((lp->d_flags & D_VENDOR) && + i == 0 && DL_GETPSIZE(pp) != 0 && DL_GETPOFFSET(pp) != 0) { warnx("this architecture requires partition 'a' to " "start at sector 0"); errors++; diff --git a/sbin/disklabel/editor.c b/sbin/disklabel/editor.c index df0196dd9a6..a4087326a45 100644 --- a/sbin/disklabel/editor.c +++ b/sbin/disklabel/editor.c @@ -1,4 +1,4 @@ -/* $OpenBSD: editor.c,v 1.121 2007/06/08 20:21:13 millert Exp $ */ +/* $OpenBSD: editor.c,v 1.122 2007/06/17 00:32:21 deraadt Exp $ */ /* * Copyright (c) 1997-2000 Todd C. Miller <Todd.Miller@courtesan.com> @@ -17,7 +17,7 @@ */ #ifndef lint -static char rcsid[] = "$OpenBSD: editor.c,v 1.121 2007/06/08 20:21:13 millert Exp $"; +static char rcsid[] = "$OpenBSD: editor.c,v 1.122 2007/06/17 00:32:21 deraadt Exp $"; #endif /* not lint */ #include <sys/types.h> @@ -150,8 +150,13 @@ editor(struct disklabel *lp, int f, char *dev, char *fstabfile) pp->p_fragblock = pp->p_cpg = 0; } -#ifdef CYLCHECK - puts("This platform requires that partition offsets/sizes be on cylinder boundaries.\nPartition offsets/sizes will be rounded to the nearest cylinder automatically."); +#ifdef SUN_CYLCHECK + if (label.d_flags & D_VENDOR) { + puts("This platform requires that partition offsets/sizes " + "be on cylinder boundaries.\n" + "Partition offsets/sizes will be rounded to the " + "nearest cylinder automatically."); + } #endif /* Set d_bbsize and d_sbsize as necessary */ @@ -438,12 +443,15 @@ editor_add(struct disklabel *lp, char **mp, u_int64_t *freep, char *p) u_int64_t ui, old_offset, old_size, new_offset, new_size; /* XXX - prompt user to steal space from another partition instead */ -#ifdef CYLCHECK - if (*freep < lp->d_secpercyl) -#else - if (*freep == 0) +#ifdef SUN_CYLCHECK + if ((lp->d_flags & D_VENDOR) && *freep < lp->d_secpercyl) { + fputs("No space left, you need to shrink a partition " + "(need at least one full cylinder)\n", + stderr); + return; + } #endif - { + if (*freep == 0) { fputs("No space left, you need to shrink a partition\n", stderr); return; @@ -1116,7 +1124,9 @@ getuint(struct disklabel *lp, int partno, char *prompt, char *helpstring, if ((flags & DO_ROUNDING) && rval != ULLONG_MAX) { /* Round to nearest cylinder unless given in sectors */ if ( -#ifndef CYLCHECK +#ifdef SUN_CYLCHECK + ((lp->d_flags & D_VENDOR) || mult != 1) && +#else mult != 1 && #endif (rval + offset) % lp->d_secpercyl != 0) { @@ -1984,7 +1994,7 @@ get_offset(struct disklabel *lp, int partno) "at sector %llu, you tried to add a partition at %llu." " You can use the 'b' command to change the size " "of the OpenBSD portion.\n", ending_sector, ui); -#ifdef AAT0 +#ifdef SUN_AAT0 else if (partno == 0 && ui != 0) fprintf(stderr, "This architecture requires that " "partition 'a' start at sector 0.\n"); |