diff options
author | Kenneth R Westerback <krw@cvs.openbsd.org> | 2006-07-03 20:00:23 +0000 |
---|---|---|
committer | Kenneth R Westerback <krw@cvs.openbsd.org> | 2006-07-03 20:00:23 +0000 |
commit | 141511f529dd014f1123943b675252f612002909 (patch) | |
tree | 34678c11938563da654bf6f33425fd39d76dee5c | |
parent | dd326d0b747ea6e80c64b072ac3845516fd575ab (diff) |
Eliminate most of the #if/#endif maze in alpha, hppa, hppa64, and mips64
disklabel code that was intended to support cross-endian and cross-architecture
use of disklabels. Never actually used except for Alpha<->Amiga moves that now
can't happen anyway.
Leave native and DOS MBR disklabel code. Tested on alpha and hppa.
No functional change.
-rw-r--r-- | sys/arch/alpha/alpha/disksubr.c | 118 | ||||
-rw-r--r-- | sys/arch/hppa/hppa/disksubr.c | 146 | ||||
-rw-r--r-- | sys/arch/hppa/include/disklabel.h | 10 | ||||
-rw-r--r-- | sys/arch/hppa64/hppa64/disksubr.c | 146 | ||||
-rw-r--r-- | sys/arch/hppa64/include/disklabel.h | 10 | ||||
-rw-r--r-- | sys/arch/mips64/include/disklabel.h | 106 | ||||
-rw-r--r-- | sys/arch/mips64/mips64/disksubr.c | 329 |
7 files changed, 62 insertions, 803 deletions
diff --git a/sys/arch/alpha/alpha/disksubr.c b/sys/arch/alpha/alpha/disksubr.c index ad31b6d365a..b4827b779e5 100644 --- a/sys/arch/alpha/alpha/disksubr.c +++ b/sys/arch/alpha/alpha/disksubr.c @@ -1,4 +1,4 @@ -/* $OpenBSD: disksubr.c,v 1.45 2006/07/01 16:50:32 krw Exp $ */ +/* $OpenBSD: disksubr.c,v 1.46 2006/07/03 20:00:22 krw Exp $ */ /* $NetBSD: disksubr.c,v 1.21 1996/05/03 19:42:03 christos Exp $ */ /* @@ -38,9 +38,6 @@ * This disksubr.c module started to take its present form on OpenBSD/alpha * but it was always thought it should be made completely MI and not need to * be in that alpha-specific tree at all. - * - * XXX The DOS partitioning code is not endian-independent, only native - * endian DOS partition tables can be parsed yet. */ #include <sys/param.h> @@ -52,91 +49,33 @@ #include <sys/disk.h> /* The native defaults... */ -#if defined(alpha) && !defined(DISKLABEL_ALPHA) -#define DISKLABEL_ALPHA -#elif (defined(i386) || defined(arc)) && !defined(DISKLABEL_I386) +#if defined(DISKLABEL_ALL) && !defined(DISKLABEL_I386) #define DISKLABEL_I386 #endif -#if defined(DISKLABEL_I386) || defined(DISKLABEL_ALPHA) || defined(DISKLABEL_ALL) -void swapdisklabel(struct disklabel *d); char *readbsdlabel(struct buf *, void (*)(struct buf *), int, int, - int, int, struct disklabel *, int); -#endif -#if defined(DISKLABEL_I386) || defined(DISKLABEL_ALL) + int, struct disklabel *, int); +#if defined(DISKLABEL_I386) char *readdoslabel(struct buf *, void (*)(struct buf *), struct disklabel *, struct cpu_disklabel *, int *, int *, int); #endif static enum disklabel_tag probe_order[] = { LABELPROBES, -1 }; -#if defined(DISKLABEL_I386) || defined(DISKLABEL_ALPHA) || defined(DISKLABEL_ALL) - -/* - * Byteswap all the fields that might be swapped. - */ -void -swapdisklabel(dlp) - struct disklabel *dlp; -{ - int i; - struct partition *pp; - - swap32(dlp->d_magic); - swap16(dlp->d_type); - swap16(dlp->d_subtype); - swap32(dlp->d_secsize); - swap32(dlp->d_nsectors); - swap32(dlp->d_ntracks); - swap32(dlp->d_ncylinders); - swap32(dlp->d_secpercyl); - swap32(dlp->d_secperunit); - swap16(dlp->d_sparespertrack); - swap16(dlp->d_sparespercyl); - swap32(dlp->d_acylinders); - swap16(dlp->d_rpm); - swap16(dlp->d_interleave); - swap16(dlp->d_trackskew); - swap16(dlp->d_cylskew); - swap32(dlp->d_headswitch); - swap32(dlp->d_trkseek); - swap32(dlp->d_flags); - for (i = 0; i < NDDATA; i++) - swap32(dlp->d_drivedata[i]); - for (i = 0; i < NSPARE; i++) - swap32(dlp->d_spare[i]); - swap32(dlp->d_magic2); - swap16(dlp->d_checksum); - swap16(dlp->d_npartitions); - swap32(dlp->d_bbsize); - swap32(dlp->d_sbsize); - for (i = 0; i < MAXPARTITIONS; i++) { - pp = &dlp->d_partitions[i]; - swap32(pp->p_size); - swap32(pp->p_offset); - swap32(pp->p_fsize); - swap16(pp->p_cpg); - } -} - /* * Try to read a standard BSD disklabel at a certain sector. */ char * -readbsdlabel(bp, strat, cyl, sec, off, endian, lp, spoofonly) +readbsdlabel(bp, strat, cyl, sec, off, lp, spoofonly) struct buf *bp; void (*strat)(struct buf *); - int cyl, sec, off, endian; + int cyl, sec, off; struct disklabel *lp; int spoofonly; { struct disklabel *dlp; char *msg = NULL; u_int16_t cksum; - u_int32_t magic; - - if (endian != LITTLE_ENDIAN && endian != BIG_ENDIAN) - panic("readbsdlabel: unsupported byteorder %d", endian); /* don't read the on-disk label if we are in spoofed-only mode */ if (spoofonly) @@ -155,8 +94,6 @@ readbsdlabel(bp, strat, cyl, sec, off, endian, lp, spoofonly) return (msg); } - magic = endian == BIG_ENDIAN ? htobe32(DISKMAGIC) : htole32(DISKMAGIC); - /* * If off is negative, search until the end of the sector for * the label, otherwise, just look at the specific location @@ -164,25 +101,15 @@ readbsdlabel(bp, strat, cyl, sec, off, endian, lp, spoofonly) */ dlp = (struct disklabel *)(bp->b_data + (off >= 0 ? off : 0)); do { - if (dlp->d_magic != magic || dlp->d_magic2 != magic) { + if (dlp->d_magic != DISKMAGIC || dlp->d_magic2 != DISKMAGIC) { if (msg == NULL) msg = "no disk label"; } else { cksum = dkcksum(dlp); - if (endian != BYTE_ORDER) - swapdisklabel(dlp); if (dlp->d_npartitions > MAXPARTITIONS || cksum != 0) { msg = "disk label corrupted"; - /* swap back if necessary. */ - if (off < 0 && endian != BYTE_ORDER) - swapdisklabel(dlp); } else { *lp = *dlp; - /* Recalc magic on foreign labels */ - if (endian != BYTE_ORDER) { - lp->d_checksum = 0; - lp->d_checksum = dkcksum(lp); - } msg = NULL; break; } @@ -194,7 +121,6 @@ readbsdlabel(bp, strat, cyl, sec, off, endian, lp, spoofonly) sizeof(*dlp))); return (msg); } -#endif /* * Attempt to read a disk label from a device @@ -246,14 +172,12 @@ readdisklabel(dev, strat, lp, osdep, spoofonly) for (tp = probe_order; msg && *tp != -1; tp++) { switch (*tp) { case DLT_ALPHA: -#if defined(DISKLABEL_ALPHA) || defined(DISKLABEL_ALL) msg = readbsdlabel(bp, strat, 0, ALPHA_LABELSECTOR, - ALPHA_LABELOFFSET, LITTLE_ENDIAN, lp, spoofonly); -#endif + ALPHA_LABELOFFSET, lp, spoofonly); break; case DLT_I386: -#if defined(DISKLABEL_I386) || defined(DISKLABEL_ALL) +#if defined(DISKLABEL_I386) msg = readdoslabel(bp, strat, lp, osdep, 0, 0, spoofonly); if (msg) /* Fallback alternative */ @@ -295,7 +219,7 @@ done: return (msg); } -#if defined(DISKLABEL_I386) || defined(DISKLABEL_ALL) +#if defined(DISKLABEL_I386) /* * If dos partition table requested, attempt to load it and * find disklabel inside a DOS partition. Also, if bad block @@ -485,7 +409,7 @@ donot: /* next, dig out disk label */ msg = readbsdlabel(bp, strat, cyl, dospartoff + I386_LABELSECTOR, -1, - LITTLE_ENDIAN, lp, spoofonly); + lp, spoofonly); if (msg) return (msg); @@ -616,10 +540,10 @@ writedisklabel(dev, strat, lp, osdep) char *msg = "no disk label"; struct buf *bp; struct disklabel dl; -#if defined(DISKLABEL_I386) || defined(DISKLABEL_ALL) +#if defined(DISKLABEL_I386) struct cpu_disklabel cdl; #endif - int labeloffset, error, i, endian, partoff = 0, cyl = 0; + int labeloffset, error, i, partoff = 0, cyl = 0; u_int64_t csum, *p; /* get a buffer and initialize it */ @@ -636,20 +560,16 @@ writedisklabel(dev, strat, lp, osdep) dl = *lp; switch (*tp) { case DLT_ALPHA: -#if defined(DISKLABEL_ALPHA) || defined(DISKLABEL_ALL) msg = readbsdlabel(bp, strat, 0, ALPHA_LABELSECTOR, - ALPHA_LABELOFFSET, LITTLE_ENDIAN, &dl, 0); + ALPHA_LABELOFFSET, &dl, 0); labeloffset = ALPHA_LABELOFFSET; - endian = LITTLE_ENDIAN; -#endif break; case DLT_I386: -#if defined(DISKLABEL_I386) || defined(DISKLABEL_ALL) +#if defined(DISKLABEL_I386) msg = readdoslabel(bp, strat, &dl, &cdl, &partoff, &cyl, 0); labeloffset = I386_LABELOFFSET; - endian = LITTLE_ENDIAN; #endif break; @@ -664,19 +584,11 @@ writedisklabel(dev, strat, lp, osdep) /* Write it in the regular place with native byte order. */ labeloffset = LABELOFFSET; - endian = BYTE_ORDER; bp->b_blkno = partoff + LABELSECTOR; bp->b_cylinder = cyl; bp->b_bcount = lp->d_secsize; } - if (endian != BYTE_ORDER) { - swapdisklabel(lp); - /* recalc checksum */ - lp->d_checksum = 0; - lp->d_checksum = dkcksum(lp); - } - *(struct disklabel *)(bp->b_data + labeloffset) = *lp; /* Alpha bootblocks are checksummed. */ diff --git a/sys/arch/hppa/hppa/disksubr.c b/sys/arch/hppa/hppa/disksubr.c index bfb6e703016..d835103c18e 100644 --- a/sys/arch/hppa/hppa/disksubr.c +++ b/sys/arch/hppa/hppa/disksubr.c @@ -1,4 +1,4 @@ -/* $OpenBSD: disksubr.c,v 1.25 2006/07/01 16:50:32 krw Exp $ */ +/* $OpenBSD: disksubr.c,v 1.26 2006/07/03 20:00:22 krw Exp $ */ /* * Copyright (c) 1999 Michael Shalayeff @@ -39,9 +39,6 @@ * but it was always thought it should be made completely MI and not need to * be in that alpha-specific tree at all. * - * XXX The DOS partitioning code is not endian-independent, only native - * endian DOS partition tables can be parsed yet. - * * XXX HPUX disklabel is not understood yet. */ @@ -54,97 +51,35 @@ #include <sys/disk.h> /* The native defaults... */ -#if defined(alpha) && !defined(DISKLABEL_ALPHA) -#define DISKLABEL_ALPHA -#elif (defined(i386) || defined(arc)) && !defined(DISKLABEL_I386) +#if defined(DISKLABEL_ALL) && !defined(DISKLABEL_I386) #define DISKLABEL_I386 -#elif (defined(hppa) || defined(hppa64)) && !defined(DISKLABEL_HPPA) -#define DISKLABEL_HPPA #endif -#if defined(DISKLABEL_I386) || defined(DISKLABEL_ALPHA) || defined(DISKLABEL_HPPA) || defined(DISKLABEL_ALL) -void swapdisklabel(struct disklabel *d); char *readbsdlabel(struct buf *, void (*)(struct buf *), int, int, - int, int, struct disklabel *, int); -#endif -#if defined(DISKLABEL_I386) || defined(DISKLABEL_ALL) + int, struct disklabel *, int); +#if defined(DISKLABEL_I386) char *readdoslabel(struct buf *, void (*)(struct buf *), struct disklabel *, struct cpu_disklabel *, int *, int *, int); #endif -#if defined(DISKLABEL_HPPA) || defined(DISKLABEL_ALL) char *readliflabel(struct buf *, void (*)(struct buf *), struct disklabel *, struct cpu_disklabel *, int *, int *, int); -#endif static enum disklabel_tag probe_order[] = { LABELPROBES, -1 }; -#if defined(DISKLABEL_I386) || defined(DISKLABEL_ALPHA) || defined(DISKLABEL_HPPA) || defined(DISKLABEL_ALL) - -/* - * Byteswap all the fields that might be swapped. - */ -void -swapdisklabel(dlp) - struct disklabel *dlp; -{ - int i; - struct partition *pp; - - swap32(dlp->d_magic); - swap16(dlp->d_type); - swap16(dlp->d_subtype); - swap32(dlp->d_secsize); - swap32(dlp->d_nsectors); - swap32(dlp->d_ntracks); - swap32(dlp->d_ncylinders); - swap32(dlp->d_secpercyl); - swap32(dlp->d_secperunit); - swap16(dlp->d_sparespertrack); - swap16(dlp->d_sparespercyl); - swap32(dlp->d_acylinders); - swap16(dlp->d_rpm); - swap16(dlp->d_interleave); - swap16(dlp->d_trackskew); - swap16(dlp->d_cylskew); - swap32(dlp->d_headswitch); - swap32(dlp->d_trkseek); - swap32(dlp->d_flags); - for (i = 0; i < NDDATA; i++) - swap32(dlp->d_drivedata[i]); - for (i = 0; i < NSPARE; i++) - swap32(dlp->d_spare[i]); - swap32(dlp->d_magic2); - swap16(dlp->d_checksum); - swap16(dlp->d_npartitions); - swap32(dlp->d_bbsize); - swap32(dlp->d_sbsize); - for (i = 0; i < MAXPARTITIONS; i++) { - pp = &dlp->d_partitions[i]; - swap32(pp->p_size); - swap32(pp->p_offset); - swap32(pp->p_fsize); - swap16(pp->p_cpg); - } -} - /* * Try to read a standard BSD disklabel at a certain sector. */ char * -readbsdlabel(bp, strat, cyl, sec, off, endian, lp, spoofonly) +readbsdlabel(bp, strat, cyl, sec, off, lp, spoofonly) struct buf *bp; void (*strat)(struct buf *); - int cyl, sec, off, endian; + int cyl, sec, off; struct disklabel *lp; int spoofonly; { struct disklabel *dlp; char *msg = NULL; u_int16_t cksum; - u_int32_t magic; - - if (endian != LITTLE_ENDIAN && endian != BIG_ENDIAN) - panic("readbsdlabel: unsupported byteorder %d", endian); /* don't read the on-disk label if we are in spoofed-only mode */ if (spoofonly) @@ -163,8 +98,6 @@ readbsdlabel(bp, strat, cyl, sec, off, endian, lp, spoofonly) return (msg); } - magic = endian == BIG_ENDIAN ? htobe32(DISKMAGIC) : htole32(DISKMAGIC); - /* * If off is negative, search until the end of the sector for * the label, otherwise, just look at the specific location @@ -172,25 +105,15 @@ readbsdlabel(bp, strat, cyl, sec, off, endian, lp, spoofonly) */ dlp = (struct disklabel *)(bp->b_data + (off >= 0 ? off : 0)); do { - if (dlp->d_magic != magic || dlp->d_magic2 != magic) { + if (dlp->d_magic != DISKMAGIC || dlp->d_magic2 != DISKMAGIC) { if (msg == NULL) msg = "no disk label"; } else { cksum = dkcksum(dlp); - if (endian != BYTE_ORDER) - swapdisklabel(dlp); if (dlp->d_npartitions > MAXPARTITIONS || cksum != 0) { msg = "disk label corrupted"; - /* swap back if necessary. */ - if (off < 0 && endian != BYTE_ORDER) - swapdisklabel(dlp); } else { *lp = *dlp; - /* Recalc magic on foreign labels */ - if (endian != BYTE_ORDER) { - lp->d_checksum = 0; - lp->d_checksum = dkcksum(lp); - } msg = NULL; break; } @@ -202,7 +125,6 @@ readbsdlabel(bp, strat, cyl, sec, off, endian, lp, spoofonly) sizeof(*dlp))); return (msg); } -#endif /* * Attempt to read a disk label from a device @@ -253,15 +175,8 @@ readdisklabel(dev, strat, lp, osdep, spoofonly) for (tp = probe_order; msg && *tp != -1; tp++) { switch (*tp) { - case DLT_ALPHA: -#if defined(DISKLABEL_ALPHA) || defined(DISKLABEL_ALL) - msg = readbsdlabel(bp, strat, 0, ALPHA_LABELSECTOR, - ALPHA_LABELOFFSET, LITTLE_ENDIAN, lp, spoofonly); -#endif - break; - case DLT_I386: -#if defined(DISKLABEL_I386) || defined(DISKLABEL_ALL) +#if defined(DISKLABEL_I386) msg = readdoslabel(bp, strat, lp, osdep, 0, 0, spoofonly); if (msg) /* Fallback alternative */ @@ -270,9 +185,7 @@ readdisklabel(dev, strat, lp, osdep, spoofonly) break; case DLT_HPPA: -#if defined(DISKLABEL_HPPA) || defined(DISKLABEL_ALL) msg = readliflabel(bp, strat, lp, osdep, 0, 0, spoofonly); -#endif break; default: @@ -309,7 +222,7 @@ done: return (msg); } -#if defined(DISKLABEL_I386) || defined(DISKLABEL_ALL) +#if defined(DISKLABEL_I386) /* * If dos partition table requested, attempt to load it and * find disklabel inside a DOS partition. Also, if bad block @@ -499,7 +412,7 @@ donot: /* next, dig out disk label */ msg = readbsdlabel(bp, strat, cyl, dospartoff + I386_LABELSECTOR, -1, - LITTLE_ENDIAN, lp, spoofonly); + lp, spoofonly); if (msg) return (msg); @@ -551,7 +464,6 @@ donot: } #endif -#if defined(DISKLABEL_HPPA) || defined(DISKLABEL_ALL) char * readliflabel (bp, strat, lp, osdep, partoffp, cylp, spoofonly) struct buf *bp; @@ -711,9 +623,8 @@ readliflabel (bp, strat, lp, osdep, partoffp, cylp, spoofonly) *partoffp = fsoff; return readbsdlabel(bp, strat, 0, fsoff + HPPA_LABELSECTOR, - HPPA_LABELOFFSET, BIG_ENDIAN, lp, spoofonly); + HPPA_LABELOFFSET, lp, spoofonly); } -#endif /* * Check new disk label for sensibility @@ -794,11 +705,8 @@ writedisklabel(dev, strat, lp, osdep) char *msg = "no disk label"; struct buf *bp; struct disklabel dl; -#if defined(DISKLABEL_I386) || defined(DISKLABEL_HPPA) || defined(DISKLABEL_ALL) struct cpu_disklabel cdl; -#endif - int labeloffset, error, i, endian, partoff = 0, cyl = 0; - u_int64_t csum, *p; + int labeloffset, error, partoff = 0, cyl = 0; /* get a buffer and initialize it */ bp = geteblk((int)lp->d_secsize); @@ -813,31 +721,18 @@ writedisklabel(dev, strat, lp, osdep) for (tp = probe_order; msg && *tp != -1; tp++) { dl = *lp; switch (*tp) { - case DLT_ALPHA: -#if defined(DISKLABEL_ALPHA) || defined(DISKLABEL_ALL) - msg = readbsdlabel(bp, strat, 0, ALPHA_LABELSECTOR, - ALPHA_LABELOFFSET, LITTLE_ENDIAN, &dl, 0); - labeloffset = ALPHA_LABELOFFSET; - endian = LITTLE_ENDIAN; -#endif - break; - case DLT_I386: -#if defined(DISKLABEL_I386) || defined(DISKLABEL_ALL) +#if defined(DISKLABEL_I386) msg = readdoslabel(bp, strat, &dl, &cdl, &partoff, &cyl, 0); labeloffset = I386_LABELOFFSET; - endian = LITTLE_ENDIAN; #endif break; case DLT_HPPA: -#if defined(DISKLABEL_HPPA) || defined(DISKLABEL_ALL) msg = readliflabel(bp, strat, &dl, &cdl, &partoff, &cyl, 0); labeloffset = HPPA_LABELOFFSET; - endian = BIG_ENDIAN; -#endif break; default: @@ -851,28 +746,13 @@ writedisklabel(dev, strat, lp, osdep) /* Write it in the regular place with native byte order. */ labeloffset = LABELOFFSET; - endian = BYTE_ORDER; bp->b_blkno = partoff + LABELSECTOR; bp->b_cylinder = cyl; bp->b_bcount = lp->d_secsize; } - if (endian != BYTE_ORDER) { - swapdisklabel(lp); - /* recalc checksum */ - lp->d_checksum = 0; - lp->d_checksum = dkcksum(lp); - } - *(struct disklabel *)(bp->b_data + labeloffset) = *lp; - /* Alpha bootblocks are checksummed. */ - if (*tp == DLT_ALPHA) { - for (csum = i = 0, p = (u_int64_t *)bp->b_data; i < 63; i++) - csum += *p++; - *p = csum; - } - bp->b_flags = B_BUSY | B_WRITE; (*strat)(bp); error = biowait(bp); diff --git a/sys/arch/hppa/include/disklabel.h b/sys/arch/hppa/include/disklabel.h index e73efe8b578..a3e5b90e628 100644 --- a/sys/arch/hppa/include/disklabel.h +++ b/sys/arch/hppa/include/disklabel.h @@ -1,4 +1,4 @@ -/* $OpenBSD: disklabel.h,v 1.10 2006/06/26 23:11:31 krw Exp $ */ +/* $OpenBSD: disklabel.h,v 1.11 2006/07/03 20:00:22 krw Exp $ */ /* $NetBSD: disklabel.h,v 1.1 1995/02/13 23:07:34 cgd Exp $ */ /* @@ -34,17 +34,15 @@ #ifndef _MACHINE_DISKLABEL_H_ #define _MACHINE_DISKLABEL_H_ -enum disklabel_tag { DLT_ALPHA, DLT_I386, DLT_HPPA }; +enum disklabel_tag { DLT_I386, DLT_HPPA }; /* * What disklabels are we probing for, and in which order? */ #ifndef LABELPROBES -#define LABELPROBES DLT_ALPHA, DLT_I386, DLT_HPPA +#define LABELPROBES DLT_I386, DLT_HPPA #endif -#define ALPHA_LABELSECTOR 0 /* sector containing label */ -#define ALPHA_LABELOFFSET 64 /* offset of label in sector */ #define I386_LABELSECTOR 1 /* sector containing label */ #define I386_LABELOFFSET 0 /* offset of label in sector */ #define HPPA_LABELSECTOR 1 /* sector containing label */ @@ -192,8 +190,6 @@ struct cpu_disklabel { int labelsector; union { struct { - } _alpha; - struct { struct dos_partition dosparts[NDOSPART]; struct dkbad bad; } _i386; diff --git a/sys/arch/hppa64/hppa64/disksubr.c b/sys/arch/hppa64/hppa64/disksubr.c index 28747a2b886..e5ae72737c9 100644 --- a/sys/arch/hppa64/hppa64/disksubr.c +++ b/sys/arch/hppa64/hppa64/disksubr.c @@ -1,4 +1,4 @@ -/* $OpenBSD: disksubr.c,v 1.8 2006/07/01 16:50:32 krw Exp $ */ +/* $OpenBSD: disksubr.c,v 1.9 2006/07/03 20:00:22 krw Exp $ */ /* * Copyright (c) 1999 Michael Shalayeff @@ -39,9 +39,6 @@ * but it was always thought it should be made completely MI and not need to * be in that alpha-specific tree at all. * - * XXX The DOS partitioning code is not endian-independent, only native - * endian DOS partition tables can be parsed yet. - * * XXX HPUX disklabel is not understood yet. */ @@ -54,97 +51,35 @@ #include <sys/disk.h> /* The native defaults... */ -#if defined(alpha) && !defined(DISKLABEL_ALPHA) -#define DISKLABEL_ALPHA -#elif (defined(i386) || defined(arc)) && !defined(DISKLABEL_I386) +#if defined(DISKLABEL_ALL) && !defined(DISKLABEL_I386) #define DISKLABEL_I386 -#elif (defined(hppa) || defined(hppa64)) && !defined(DISKLABEL_HPPA) -#define DISKLABEL_HPPA #endif -#if defined(DISKLABEL_I386) || defined(DISKLABEL_ALPHA) || defined(DISKLABEL_HPPA) || defined(DISKLABEL_ALL) -void swapdisklabel(struct disklabel *d); char *readbsdlabel(struct buf *, void (*)(struct buf *), int, int, - int, int, struct disklabel *, int); -#endif -#if defined(DISKLABEL_I386) || defined(DISKLABEL_ALL) + int, struct disklabel *, int); +#if defined(DISKLABEL_I386) char *readdoslabel(struct buf *, void (*)(struct buf *), struct disklabel *, struct cpu_disklabel *, int *, int *, int); #endif -#if defined(DISKLABEL_HPPA) || defined(DISKLABEL_ALL) char *readliflabel(struct buf *, void (*)(struct buf *), struct disklabel *, struct cpu_disklabel *, int *, int *, int); -#endif static enum disklabel_tag probe_order[] = { LABELPROBES, -1 }; -#if defined(DISKLABEL_I386) || defined(DISKLABEL_ALPHA) || defined(DISKLABEL_HPPA) || defined(DISKLABEL_ALL) - -/* - * Byteswap all the fields that might be swapped. - */ -void -swapdisklabel(dlp) - struct disklabel *dlp; -{ - int i; - struct partition *pp; - - swap32(dlp->d_magic); - swap16(dlp->d_type); - swap16(dlp->d_subtype); - swap32(dlp->d_secsize); - swap32(dlp->d_nsectors); - swap32(dlp->d_ntracks); - swap32(dlp->d_ncylinders); - swap32(dlp->d_secpercyl); - swap32(dlp->d_secperunit); - swap16(dlp->d_sparespertrack); - swap16(dlp->d_sparespercyl); - swap32(dlp->d_acylinders); - swap16(dlp->d_rpm); - swap16(dlp->d_interleave); - swap16(dlp->d_trackskew); - swap16(dlp->d_cylskew); - swap32(dlp->d_headswitch); - swap32(dlp->d_trkseek); - swap32(dlp->d_flags); - for (i = 0; i < NDDATA; i++) - swap32(dlp->d_drivedata[i]); - for (i = 0; i < NSPARE; i++) - swap32(dlp->d_spare[i]); - swap32(dlp->d_magic2); - swap16(dlp->d_checksum); - swap16(dlp->d_npartitions); - swap32(dlp->d_bbsize); - swap32(dlp->d_sbsize); - for (i = 0; i < MAXPARTITIONS; i++) { - pp = &dlp->d_partitions[i]; - swap32(pp->p_size); - swap32(pp->p_offset); - swap32(pp->p_fsize); - swap16(pp->p_cpg); - } -} - /* * Try to read a standard BSD disklabel at a certain sector. */ char * -readbsdlabel(bp, strat, cyl, sec, off, endian, lp, spoofonly) +readbsdlabel(bp, strat, cyl, sec, off, lp, spoofonly) struct buf *bp; void (*strat)(struct buf *); - int cyl, sec, off, endian; + int cyl, sec, off; struct disklabel *lp; int spoofonly; { struct disklabel *dlp; char *msg = NULL; u_int16_t cksum; - u_int32_t magic; - - if (endian != LITTLE_ENDIAN && endian != BIG_ENDIAN) - panic("readbsdlabel: unsupported byteorder %d", endian); /* don't read the on-disk label if we are in spoofed-only mode */ if (spoofonly) @@ -163,8 +98,6 @@ readbsdlabel(bp, strat, cyl, sec, off, endian, lp, spoofonly) return (msg); } - magic = endian == BIG_ENDIAN ? htobe32(DISKMAGIC) : htole32(DISKMAGIC); - /* * If off is negative, search until the end of the sector for * the label, otherwise, just look at the specific location @@ -172,25 +105,15 @@ readbsdlabel(bp, strat, cyl, sec, off, endian, lp, spoofonly) */ dlp = (struct disklabel *)(bp->b_data + (off >= 0 ? off : 0)); do { - if (dlp->d_magic != magic || dlp->d_magic2 != magic) { + if (dlp->d_magic != DISKMAGIC || dlp->d_magic2 != DISKMAGIC) { if (msg == NULL) msg = "no disk label"; } else { cksum = dkcksum(dlp); - if (endian != BYTE_ORDER) - swapdisklabel(dlp); if (dlp->d_npartitions > MAXPARTITIONS || cksum != 0) { msg = "disk label corrupted"; - /* swap back if necessary. */ - if (off < 0 && endian != BYTE_ORDER) - swapdisklabel(dlp); } else { *lp = *dlp; - /* Recalc magic on foreign labels */ - if (endian != BYTE_ORDER) { - lp->d_checksum = 0; - lp->d_checksum = dkcksum(lp); - } msg = NULL; break; } @@ -202,7 +125,6 @@ readbsdlabel(bp, strat, cyl, sec, off, endian, lp, spoofonly) sizeof(*dlp))); return (msg); } -#endif /* * Attempt to read a disk label from a device @@ -253,15 +175,8 @@ readdisklabel(dev, strat, lp, osdep, spoofonly) for (tp = probe_order; msg && *tp != -1; tp++) { switch (*tp) { - case DLT_ALPHA: -#if defined(DISKLABEL_ALPHA) || defined(DISKLABEL_ALL) - msg = readbsdlabel(bp, strat, 0, ALPHA_LABELSECTOR, - ALPHA_LABELOFFSET, LITTLE_ENDIAN, lp, spoofonly); -#endif - break; - case DLT_I386: -#if defined(DISKLABEL_I386) || defined(DISKLABEL_ALL) +#if defined(DISKLABEL_I386) msg = readdoslabel(bp, strat, lp, osdep, 0, 0, spoofonly); if (msg) /* Fallback alternative */ @@ -270,9 +185,7 @@ readdisklabel(dev, strat, lp, osdep, spoofonly) break; case DLT_HPPA: -#if defined(DISKLABEL_HPPA) || defined(DISKLABEL_ALL) msg = readliflabel(bp, strat, lp, osdep, 0, 0, spoofonly); -#endif break; default: @@ -305,7 +218,7 @@ done: return (msg); } -#if defined(DISKLABEL_I386) || defined(DISKLABEL_ALL) +#if defined(DISKLABEL_I386) /* * If dos partition table requested, attempt to load it and * find disklabel inside a DOS partition. Also, if bad block @@ -495,7 +408,7 @@ donot: /* next, dig out disk label */ msg = readbsdlabel(bp, strat, cyl, dospartoff + I386_LABELSECTOR, -1, - LITTLE_ENDIAN, lp, spoofonly); + lp, spoofonly); if (msg) return (msg); @@ -547,7 +460,6 @@ donot: } #endif -#if defined(DISKLABEL_HPPA) || defined(DISKLABEL_ALL) char * readliflabel (bp, strat, lp, osdep, partoffp, cylp, spoofonly) struct buf *bp; @@ -707,9 +619,8 @@ readliflabel (bp, strat, lp, osdep, partoffp, cylp, spoofonly) *partoffp = fsoff; return readbsdlabel(bp, strat, 0, fsoff + HPPA_LABELSECTOR, - HPPA_LABELOFFSET, BIG_ENDIAN, lp, spoofonly); + HPPA_LABELOFFSET, lp, spoofonly); } -#endif /* * Check new disk label for sensibility @@ -790,11 +701,8 @@ writedisklabel(dev, strat, lp, osdep) char *msg = "no disk label"; struct buf *bp; struct disklabel dl; -#if defined(DISKLABEL_I386) || defined(DISKLABEL_HPPA) || defined(DISKLABEL_ALL) struct cpu_disklabel cdl; -#endif - int labeloffset, error, i, endian, partoff = 0, cyl = 0; - u_int64_t csum, *p; + int labeloffset, error, partoff = 0, cyl = 0; /* get a buffer and initialize it */ bp = geteblk((int)lp->d_secsize); @@ -809,31 +717,18 @@ writedisklabel(dev, strat, lp, osdep) for (tp = probe_order; msg && *tp != -1; tp++) { dl = *lp; switch (*tp) { - case DLT_ALPHA: -#if defined(DISKLABEL_ALPHA) || defined(DISKLABEL_ALL) - msg = readbsdlabel(bp, strat, 0, ALPHA_LABELSECTOR, - ALPHA_LABELOFFSET, LITTLE_ENDIAN, &dl, 0); - labeloffset = ALPHA_LABELOFFSET; - endian = LITTLE_ENDIAN; -#endif - break; - case DLT_I386: -#if defined(DISKLABEL_I386) || defined(DISKLABEL_ALL) +#if defined(DISKLABEL_I386) msg = readdoslabel(bp, strat, &dl, &cdl, &partoff, &cyl, 0); labeloffset = I386_LABELOFFSET; - endian = LITTLE_ENDIAN; #endif break; case DLT_HPPA: -#if defined(DISKLABEL_HPPA) || defined(DISKLABEL_ALL) msg = readliflabel(bp, strat, &dl, &cdl, &partoff, &cyl, 0); labeloffset = HPPA_LABELOFFSET; - endian = BIG_ENDIAN; -#endif break; default: @@ -847,28 +742,13 @@ writedisklabel(dev, strat, lp, osdep) /* Write it in the regular place with native byte order. */ labeloffset = LABELOFFSET; - endian = BYTE_ORDER; bp->b_blkno = partoff + LABELSECTOR; bp->b_cylinder = cyl; bp->b_bcount = lp->d_secsize; } - if (endian != BYTE_ORDER) { - swapdisklabel(lp); - /* recalc checksum */ - lp->d_checksum = 0; - lp->d_checksum = dkcksum(lp); - } - *(struct disklabel *)(bp->b_data + labeloffset) = *lp; - /* Alpha bootblocks are checksummed. */ - if (*tp == DLT_ALPHA) { - for (csum = i = 0, p = (u_int64_t *)bp->b_data; i < 63; i++) - csum += *p++; - *p = csum; - } - bp->b_flags = B_BUSY | B_WRITE; (*strat)(bp); error = biowait(bp); diff --git a/sys/arch/hppa64/include/disklabel.h b/sys/arch/hppa64/include/disklabel.h index 5e99a86c884..08bd639495c 100644 --- a/sys/arch/hppa64/include/disklabel.h +++ b/sys/arch/hppa64/include/disklabel.h @@ -1,4 +1,4 @@ -/* $OpenBSD: disklabel.h,v 1.4 2006/06/26 23:11:31 krw Exp $ */ +/* $OpenBSD: disklabel.h,v 1.5 2006/07/03 20:00:22 krw Exp $ */ /* $NetBSD: disklabel.h,v 1.1 1995/02/13 23:07:34 cgd Exp $ */ /* @@ -34,17 +34,15 @@ #ifndef _MACHINE_DISKLABEL_H_ #define _MACHINE_DISKLABEL_H_ -enum disklabel_tag { DLT_ALPHA, DLT_I386, DLT_HPPA }; +enum disklabel_tag { DLT_I386, DLT_HPPA }; /* * What disklabels are we probing for, and in which order? */ #ifndef LABELPROBES -#define LABELPROBES DLT_ALPHA, DLT_I386, DLT_HPPA +#define LABELPROBES DLT_I386, DLT_HPPA #endif -#define ALPHA_LABELSECTOR 0 /* sector containing label */ -#define ALPHA_LABELOFFSET 64 /* offset of label in sector */ #define I386_LABELSECTOR 1 /* sector containing label */ #define I386_LABELOFFSET 0 /* offset of label in sector */ #define HPPA_LABELSECTOR 1 /* sector containing label */ @@ -192,8 +190,6 @@ struct cpu_disklabel { int labelsector; union { struct { - } _alpha; - struct { struct dos_partition dosparts[NDOSPART]; struct dkbad bad; } _i386; diff --git a/sys/arch/mips64/include/disklabel.h b/sys/arch/mips64/include/disklabel.h index 4ff7b4708f5..bf205a370e3 100644 --- a/sys/arch/mips64/include/disklabel.h +++ b/sys/arch/mips64/include/disklabel.h @@ -1,4 +1,4 @@ -/* $OpenBSD: disklabel.h,v 1.6 2006/06/26 23:11:31 krw Exp $ */ +/* $OpenBSD: disklabel.h,v 1.7 2006/07/03 20:00:22 krw Exp $ */ /* $NetBSD: disklabel.h,v 1.1 1995/02/13 23:07:34 cgd Exp $ */ /* @@ -34,21 +34,17 @@ #ifndef _MACHINE_DISKLABEL_H_ #define _MACHINE_DISKLABEL_H_ -enum disklabel_tag { DLT_ALPHA, DLT_I386, DLT_HPPA, DLT_SGI }; +enum disklabel_tag { DLT_I386, DLT_SGI }; /* * What disklabels are we probing for, and in which order? */ #ifndef LABELPROBES -#define LABELPROBES DLT_ALPHA, DLT_I386, DLT_HPPA, DLT_SGI +#define LABELPROBES DLT_I386, DLT_SGI #endif -#define ALPHA_LABELSECTOR 0 /* sector containing label */ -#define ALPHA_LABELOFFSET 64 /* offset of label in sector */ #define I386_LABELSECTOR 1 /* sector containing label */ #define I386_LABELOFFSET 0 /* offset of label in sector */ -#define HPPA_LABELSECTOR 1 /* sector containing label */ -#define HPPA_LABELOFFSET 0 /* offset of label in sector */ #define SGI_LABELSECTOR 1 /* sector containing label */ #define SGI_LABELOFFSET 0 /* offset of label in sector */ @@ -99,95 +95,6 @@ struct dos_partition { #define DPSECT(s) ((s) & 0x3f) #define DPCYL(c, s) ((c) + (((s) & 0xc0) << 2)) -/* - * volume header for "LIF" format volumes - */ -struct lifvol { - short vol_id; - char vol_label[6]; - u_int vol_addr; - short vol_oct; - short vol_dummy; - u_int vol_dirsize; - short vol_version; - short vol_zero; - u_int vol_number; - u_int vol_lastvol; - u_int vol_length; - char vol_toc[6]; - char vol_dummy1[198]; - - u_int ipl_addr; - u_int ipl_size; - u_int ipl_entry; - - u_int vol_dummy2; -}; - -struct lifdir { - char dir_name[10]; - u_short dir_type; - u_int dir_addr; - u_int dir_length; - char dir_toc[6]; - short dir_flag; - u_int dir_implement; -}; - -struct lif_load { - int address; - int count; -}; - -#define HPUX_MAGIC 0x8b7f6a3c -#define HPUX_MAXPART 16 -struct hpux_label { - int32_t hl_magic1; - u_int32_t hl_magic; - int32_t hl_version; - struct { - int32_t hlp_blah[2]; - int32_t hlp_start; - int32_t hlp_length; - } hl_parts[HPUX_MAXPART]; - u_int8_t hl_flags[HPUX_MAXPART]; -#define HPUX_PART_ROOT 0x10 -#define HPUX_PART_SWAP 0x14 -#define HPUX_PART_BOOT 0x32 - int32_t hl_blah[3*16]; - u_int16_t hl_boot; - u_int16_t hl_reserved; - int32_t hl_magic2; -}; - -#define LIF_VOL_ID -32768 -#define LIF_VOL_OCT 4096 -#define LIF_DIR_SWAP 0x5243 -#define LIF_DIR_HPLBL 0xa271 -#define LIF_DIR_FS 0xcd38 -#define LIF_DIR_IOMAP 0xcd60 -#define LIF_DIR_HPUX 0xcd80 -#define LIF_DIR_ISL 0xce00 -#define LIF_DIR_PAD 0xcffe -#define LIF_DIR_AUTO 0xcfff -#define LIF_DIR_EST 0xd001 -#define LIF_DIR_TYPE 0xe942 - -#define LIF_DIR_FLAG 0x8001 /* dont ask me! */ -#define LIF_SECTSIZE 256 - -#define LIF_NUMDIR 16 - -#define LIF_VOLSTART 0 -#define LIF_VOLSIZE sizeof(struct lifvol) -#define LIF_DIRSTART 2048 -#define LIF_DIRSIZE (LIF_NUMDIR * sizeof(struct lifdir)) -#define LIF_FILESTART 8192 - -#define btolifs(b) (((b) + (LIF_SECTSIZE - 1)) / LIF_SECTSIZE) -#define lifstob(s) ((s) * LIF_SECTSIZE) -#define lifstodb(s) ((s) * LIF_SECTSIZE / DEV_BSIZE) - /* SGI */ struct devparms { u_int8_t dp_skew; @@ -255,16 +162,9 @@ struct cpu_disklabel { int labelsector; union { struct { - } _alpha; - struct { struct dos_partition dosparts[NDOSPART]; struct dkbad bad; } _i386; - struct { - struct lifvol lifvol; - struct lifdir lifdir[LIF_NUMDIR]; - struct hpux_label hplabel; - } _hppa; } u; }; diff --git a/sys/arch/mips64/mips64/disksubr.c b/sys/arch/mips64/mips64/disksubr.c index 1ba80434cd4..95ab2485988 100644 --- a/sys/arch/mips64/mips64/disksubr.c +++ b/sys/arch/mips64/mips64/disksubr.c @@ -1,4 +1,4 @@ -/* $OpenBSD: disksubr.c,v 1.14 2006/07/01 16:50:33 krw Exp $ */ +/* $OpenBSD: disksubr.c,v 1.15 2006/07/03 20:00:22 krw Exp $ */ /* * Copyright (c) 1999 Michael Shalayeff @@ -39,9 +39,6 @@ * but it was always thought it should be made completely MI and not need to * be in that alpha-specific tree at all. * - * XXX The DOS partitioning code is not endian-independent, only native - * endian DOS partition tables can be parsed yet. - * * XXX HPUX disklabel is not understood yet. */ @@ -54,104 +51,36 @@ #include <sys/disk.h> /* The native defaults... */ -#if defined(alpha) && !defined(DISKLABEL_ALPHA) -#define DISKLABEL_ALPHA -#elif (defined(i386) || defined(arc)) && !defined(DISKLABEL_I386) +#if defined(DISKLABEL_ALL) && !defined(DISKLABEL_I386) #define DISKLABEL_I386 -#elif defined(hppa) && !defined(DISKLABEL_HPPA) -#define DISKLABEL_HPPA -#elif defined(__sgi__) && !defined(DISKLABEL_SGI) -#define DISKLABEL_SGI #endif -#if defined(DISKLABEL_I386) || defined(DISKLABEL_ALPHA) || defined(DISKLABEL_HPPA) || defined(DISKLABEL_SGI) || defined(DISKLABEL_ALL) -void swapdisklabel(struct disklabel *d); char *readbsdlabel(struct buf *, void (*)(struct buf *), int, int, - int, int, struct disklabel *, int); -#endif -#if defined(DISKLABEL_I386) || defined(DISKLABEL_ALL) + int, struct disklabel *, int); +#if defined(DISKLABEL_I386) char *readdoslabel(struct buf *, void (*)(struct buf *), struct disklabel *, struct cpu_disklabel *, int *, int *, int); #endif -#if defined(DISKLABEL_HPPA) || defined(DISKLABEL_ALL) -char *readliflabel(struct buf *, void (*)(struct buf *), - struct disklabel *, struct cpu_disklabel *, int *, int *, int); -#endif -#if defined(DISKLABEL_SGI) || defined(DISKLABEL_ALL) char *readsgilabel(struct buf *, void (*)(struct buf *), struct disklabel *, struct cpu_disklabel *, int *, int *, int); void map_sgi_label(struct disklabel *, struct sgilabel *); -#endif static enum disklabel_tag probe_order[] = { LABELPROBES, -1 }; -#if defined(DISKLABEL_I386) || defined(DISKLABEL_ALPHA) || defined(DISKLABEL_HPPA) || defined(DISKLABEL_SGI) || defined(DISKLABEL_ALL) - -/* - * Byteswap all the fields that might be swapped. - */ -void -swapdisklabel(dlp) - struct disklabel *dlp; -{ - int i; - struct partition *pp; - - swap32(dlp->d_magic); - swap16(dlp->d_type); - swap16(dlp->d_subtype); - swap32(dlp->d_secsize); - swap32(dlp->d_nsectors); - swap32(dlp->d_ntracks); - swap32(dlp->d_ncylinders); - swap32(dlp->d_secpercyl); - swap32(dlp->d_secperunit); - swap16(dlp->d_sparespertrack); - swap16(dlp->d_sparespercyl); - swap32(dlp->d_acylinders); - swap16(dlp->d_rpm); - swap16(dlp->d_interleave); - swap16(dlp->d_trackskew); - swap16(dlp->d_cylskew); - swap32(dlp->d_headswitch); - swap32(dlp->d_trkseek); - swap32(dlp->d_flags); - for (i = 0; i < NDDATA; i++) - swap32(dlp->d_drivedata[i]); - for (i = 0; i < NSPARE; i++) - swap32(dlp->d_spare[i]); - swap32(dlp->d_magic2); - swap16(dlp->d_checksum); - swap16(dlp->d_npartitions); - swap32(dlp->d_bbsize); - swap32(dlp->d_sbsize); - for (i = 0; i < MAXPARTITIONS; i++) { - pp = &dlp->d_partitions[i]; - swap32(pp->p_size); - swap32(pp->p_offset); - swap32(pp->p_fsize); - swap16(pp->p_cpg); - } -} - /* * Try to read a standard BSD disklabel at a certain sector. */ char * -readbsdlabel(bp, strat, cyl, sec, off, endian, lp, spoofonly) +readbsdlabel(bp, strat, cyl, sec, off, lp, spoofonly) struct buf *bp; void (*strat)(struct buf *); - int cyl, sec, off, endian; + int cyl, sec, off; struct disklabel *lp; int spoofonly; { struct disklabel *dlp; char *msg = NULL; u_int16_t cksum; - u_int32_t magic; - - if (endian != LITTLE_ENDIAN && endian != BIG_ENDIAN) - panic("readbsdlabel: unsupported byteorder %d", endian); /* don't read the on-disk label if we are in spoofed-only mode */ if (spoofonly) @@ -170,8 +99,6 @@ readbsdlabel(bp, strat, cyl, sec, off, endian, lp, spoofonly) return (msg); } - magic = endian == BIG_ENDIAN ? htobe32(DISKMAGIC) : htole32(DISKMAGIC); - /* * If off is negative, search until the end of the sector for * the label, otherwise, just look at the specific location @@ -179,25 +106,15 @@ readbsdlabel(bp, strat, cyl, sec, off, endian, lp, spoofonly) */ dlp = (struct disklabel *)(bp->b_data + (off >= 0 ? off : 0)); do { - if (dlp->d_magic != magic || dlp->d_magic2 != magic) { + if (dlp->d_magic != DISKMAGIC || dlp->d_magic2 != DISKMAGIC) { if (msg == NULL) msg = "no disk label"; } else { cksum = dkcksum(dlp); - if (endian != BYTE_ORDER) - swapdisklabel(dlp); if (dlp->d_npartitions > MAXPARTITIONS || cksum != 0) { msg = "disk label corrupted"; - /* swap back if necessary. */ - if (off < 0 && endian != BYTE_ORDER) - swapdisklabel(dlp); } else { *lp = *dlp; - /* Recalc magic on foreign labels */ - if (endian != BYTE_ORDER) { - lp->d_checksum = 0; - lp->d_checksum = dkcksum(lp); - } msg = NULL; break; } @@ -209,7 +126,6 @@ readbsdlabel(bp, strat, cyl, sec, off, endian, lp, spoofonly) sizeof(*dlp))); return (msg); } -#endif /* * Attempt to read a disk label from a device @@ -260,15 +176,8 @@ readdisklabel(dev, strat, lp, osdep, spoofonly) for (tp = probe_order; msg && *tp != -1; tp++) { switch (*tp) { - case DLT_ALPHA: -#if defined(DISKLABEL_ALPHA) || defined(DISKLABEL_ALL) - msg = readbsdlabel(bp, strat, 0, ALPHA_LABELSECTOR, - ALPHA_LABELOFFSET, LITTLE_ENDIAN, lp, spoofonly); -#endif - break; - case DLT_I386: -#if defined(DISKLABEL_I386) || defined(DISKLABEL_ALL) +#if defined(DISKLABEL_I386) msg = readdoslabel(bp, strat, lp, osdep, 0, 0, spoofonly); if (msg) /* Fallback alternative */ @@ -276,19 +185,11 @@ readdisklabel(dev, strat, lp, osdep, spoofonly) #endif break; - case DLT_HPPA: -#if defined(DISKLABEL_HPPA) || defined(DISKLABEL_ALL) - msg = readliflabel(bp, strat, lp, osdep, 0, 0, spoofonly); -#endif - break; - case DLT_SGI: -#if defined(DISKLABEL_SGI) || defined(DISKLABEL_ALL) msg = readsgilabel(bp, strat, lp, osdep, 0, 0, spoofonly); if (msg) /* Fallback alternative */ fallbacklabel = *lp; -#endif break; default: @@ -325,7 +226,7 @@ done: return (msg); } -#if defined(DISKLABEL_I386) || defined(DISKLABEL_ALL) +#if defined(DISKLABEL_I386) /* * If dos partition table requested, attempt to load it and * find disklabel inside a DOS partition. Also, if bad block @@ -515,7 +416,7 @@ donot: /* next, dig out disk label */ msg = readbsdlabel(bp, strat, cyl, dospartoff + I386_LABELSECTOR, -1, - LITTLE_ENDIAN, lp, spoofonly); + lp, spoofonly); if (msg) return (msg); @@ -567,171 +468,6 @@ donot: } #endif -#if defined(DISKLABEL_HPPA) || defined(DISKLABEL_ALL) -char * -readliflabel (bp, strat, lp, osdep, partoffp, cylp, spoofonly) - struct buf *bp; - void (*strat)(struct buf *); - struct disklabel *lp; - struct cpu_disklabel *osdep; - int *partoffp; - int *cylp; - int spoofonly; -{ - int fsoff; - - /* read LIF volume header */ - bp->b_blkno = btodb(LIF_VOLSTART); - bp->b_bcount = lp->d_secsize; - bp->b_flags = B_BUSY | B_READ; - bp->b_cylinder = btodb(LIF_VOLSTART) / lp->d_secpercyl; - (*strat)(bp); - - if (biowait(bp)) { - if (partoffp) - *partoffp = -1; - return "LIF volume header I/O error"; - } - - bcopy (bp->b_data, &osdep->u._hppa.lifvol, sizeof(struct lifvol)); - if (osdep->u._hppa.lifvol.vol_id != LIF_VOL_ID) { - fsoff = 0; - } else { - struct lifdir *p; - struct buf *dbp; - dev_t dev; - - dev = bp->b_dev; - dbp = geteblk(LIF_DIRSIZE); - dbp->b_dev = dev; - - /* read LIF directory */ - dbp->b_blkno = lifstodb(osdep->u._hppa.lifvol.vol_addr); - dbp->b_bcount = lp->d_secsize; - dbp->b_flags = B_BUSY | B_READ; - dbp->b_cylinder = dbp->b_blkno / lp->d_secpercyl; - (*strat)(dbp); - - if (biowait(dbp)) { - if (partoffp) - *partoffp = -1; - - dbp->b_flags |= B_INVAL; - brelse(dbp); - return ("LIF directory I/O error"); - } - - bcopy(dbp->b_data, osdep->u._hppa.lifdir, LIF_DIRSIZE); - dbp->b_flags |= B_INVAL; - brelse(dbp); - - /* scan for LIF_DIR_FS dir entry */ - for (fsoff = -1, p = &osdep->u._hppa.lifdir[0]; - fsoff < 0 && p < &osdep->u._hppa.lifdir[LIF_NUMDIR]; p++) { - if (p->dir_type == LIF_DIR_FS || - p->dir_type == LIF_DIR_HPLBL) - break; - } - - if (p->dir_type == LIF_DIR_FS) - fsoff = lifstodb(p->dir_addr); - else if (p->dir_type == LIF_DIR_HPLBL) { - struct hpux_label *hl; - struct partition *pp; - u_int8_t fstype; - int i; - - dev = bp->b_dev; - dbp = geteblk(LIF_DIRSIZE); - dbp->b_dev = dev; - - /* read LIF directory */ - dbp->b_blkno = lifstodb(p->dir_addr); - dbp->b_bcount = lp->d_secsize; - dbp->b_flags = B_BUSY | B_READ; - dbp->b_cylinder = dbp->b_blkno / lp->d_secpercyl; - (*strat)(dbp); - - if (biowait(dbp)) { - if (partoffp) - *partoffp = -1; - - dbp->b_flags |= B_INVAL; - brelse(dbp); - return ("HOUX label I/O error"); - } - - bcopy(dbp->b_data, &osdep->u._hppa.hplabel, - sizeof(osdep->u._hppa.hplabel)); - dbp->b_flags |= B_INVAL; - brelse(dbp); - - hl = &osdep->u._hppa.hplabel; - if (hl->hl_magic1 != hl->hl_magic2 || - hl->hl_magic != HPUX_MAGIC || - hl->hl_version != 1) { - if (partoffp) - *partoffp = -1; - - return "HPUX label magic mismatch"; - } - - lp->d_bbsize = 8192; - lp->d_sbsize = 8192; - for (i = 0; i < MAXPARTITIONS; i++) { - lp->d_partitions[i].p_size = 0; - lp->d_partitions[i].p_offset = 0; - lp->d_partitions[i].p_fstype = 0; - } - - for (i = 0; i < HPUX_MAXPART; i++) { - if (!hl->hl_flags[i]) - continue; - - if (hl->hl_flags[i] == HPUX_PART_ROOT) { - pp = &lp->d_partitions[0]; - fstype = FS_BSDFFS; - } else if (hl->hl_flags[i] == HPUX_PART_SWAP) { - pp = &lp->d_partitions[1]; - fstype = FS_SWAP; - } else if (hl->hl_flags[i] == HPUX_PART_BOOT) { - pp = &lp->d_partitions[RAW_PART + 1]; - fstype = FS_BSDFFS; - } else - continue; - - pp->p_size = hl->hl_parts[i].hlp_length * 2; - pp->p_offset = hl->hl_parts[i].hlp_start * 2; - pp->p_fstype = fstype; - } - - lp->d_partitions[RAW_PART].p_size = lp->d_secperunit; - lp->d_partitions[RAW_PART].p_offset = 0; - lp->d_partitions[RAW_PART].p_fstype = FS_UNUSED; - lp->d_npartitions = MAXPARTITIONS; - lp->d_magic = DISKMAGIC; - lp->d_magic2 = DISKMAGIC; - lp->d_checksum = 0; - lp->d_checksum = dkcksum(lp); - - return (NULL); - } - - /* if no suitable lifdir entry found assume zero */ - if (fsoff < 0) { - fsoff = 0; - } - } - - if (partoffp) - *partoffp = fsoff; - - return readbsdlabel(bp, strat, 0, fsoff + HPPA_LABELSECTOR, - HPPA_LABELOFFSET, BIG_ENDIAN, lp, spoofonly); -} -#endif - -#if defined(DISKLABEL_SGI) || defined(DISKLABEL_ALL) /* * */ @@ -835,7 +571,6 @@ static struct {int m; int b;} maptab[] = { } } } -#endif /* * Check new disk label for sensibility @@ -916,11 +651,8 @@ writedisklabel(dev, strat, lp, osdep) char *msg = "no disk label"; struct buf *bp; struct disklabel dl; -#if defined(DISKLABEL_I386) || defined(DISKLABEL_HPPA) || defined(DISKLABEL_SGI) || defined(DISKLABEL_ALL) struct cpu_disklabel cdl; -#endif - int labeloffset, error, i, endian, partoff = 0, cyl = 0; - u_int64_t csum, *p; + int labeloffset, error, partoff = 0, cyl = 0; /* get a buffer and initialize it */ bp = geteblk((int)lp->d_secsize); @@ -935,40 +667,18 @@ writedisklabel(dev, strat, lp, osdep) for (tp = probe_order; msg && *tp != -1; tp++) { dl = *lp; switch (*tp) { - case DLT_ALPHA: -#if defined(DISKLABEL_ALPHA) || defined(DISKLABEL_ALL) - msg = readbsdlabel(bp, strat, 0, ALPHA_LABELSECTOR, - ALPHA_LABELOFFSET, LITTLE_ENDIAN, &dl, 0); - labeloffset = ALPHA_LABELOFFSET; - endian = LITTLE_ENDIAN; -#endif - break; - case DLT_I386: -#if defined(DISKLABEL_I386) || defined(DISKLABEL_ALL) +#if defined(DISKLABEL_I386) msg = readdoslabel(bp, strat, &dl, &cdl, &partoff, &cyl, 0); labeloffset = I386_LABELOFFSET; - endian = LITTLE_ENDIAN; -#endif - break; - - case DLT_HPPA: -#if defined(DISKLABEL_HPPA) || defined(DISKLABEL_ALL) - msg = readliflabel(bp, strat, &dl, &cdl, &partoff, - &cyl, 0); - labeloffset = HPPA_LABELOFFSET; - endian = BIG_ENDIAN; #endif break; case DLT_SGI: -#if defined(DISKLABEL_SGI) || defined(DISKLABEL_ALL) msg = readsgilabel(bp, strat, &dl, &cdl, &partoff, &cyl, 0); labeloffset = SGI_LABELOFFSET; - endian = BIG_ENDIAN; -#endif break; default: @@ -982,28 +692,13 @@ writedisklabel(dev, strat, lp, osdep) /* Write it in the regular place with native byte order. */ labeloffset = LABELOFFSET; - endian = BYTE_ORDER; bp->b_blkno = partoff + LABELSECTOR; bp->b_cylinder = cyl; bp->b_bcount = lp->d_secsize; } - if (endian != BYTE_ORDER) { - swapdisklabel(lp); - /* recalc checksum */ - lp->d_checksum = 0; - lp->d_checksum = dkcksum(lp); - } - *(struct disklabel *)(bp->b_data + labeloffset) = *lp; - /* Alpha bootblocks are checksummed. */ - if (*tp == DLT_ALPHA) { - for (csum = i = 0, p = (u_int64_t *)bp->b_data; i < 63; i++) - csum += *p++; - *p = csum; - } - bp->b_flags = B_BUSY | B_WRITE; (*strat)(bp); error = biowait(bp); |