diff options
author | Theo de Raadt <deraadt@cvs.openbsd.org> | 2007-06-05 00:38:25 +0000 |
---|---|---|
committer | Theo de Raadt <deraadt@cvs.openbsd.org> | 2007-06-05 00:38:25 +0000 |
commit | 27424f98f99646fb8b3e4ef11652da62014a7ceb (patch) | |
tree | 47b5f078f236f633651ce1bad4b1228fac2f6d7d /sys/arch/sparc | |
parent | 91862e2af60dd7be0a8d86f5f3fe187dbb400d7f (diff) |
use six new macros to access & store the 48-bit disklabel fields related
to size. tested on almost all machines, double checked by miod and krw
next comes the type handling surrounding these values
Diffstat (limited to 'sys/arch/sparc')
-rw-r--r-- | sys/arch/sparc/dev/fd.c | 4 | ||||
-rw-r--r-- | sys/arch/sparc/dev/presto.c | 8 | ||||
-rw-r--r-- | sys/arch/sparc/dev/xd.c | 6 | ||||
-rw-r--r-- | sys/arch/sparc/dev/xy.c | 6 | ||||
-rw-r--r-- | sys/arch/sparc/sparc/disksubr.c | 61 |
5 files changed, 43 insertions, 42 deletions
diff --git a/sys/arch/sparc/dev/fd.c b/sys/arch/sparc/dev/fd.c index d379f2c3c55..39205876b29 100644 --- a/sys/arch/sparc/dev/fd.c +++ b/sys/arch/sparc/dev/fd.c @@ -1,4 +1,4 @@ -/* $OpenBSD: fd.c,v 1.49 2007/06/01 00:07:48 krw Exp $ */ +/* $OpenBSD: fd.c,v 1.50 2007/06/05 00:38:18 deraadt Exp $ */ /* $NetBSD: fd.c,v 1.51 1997/05/24 20:16:19 pk Exp $ */ /*- @@ -1964,7 +1964,7 @@ fdgetdisklabel(dev) lp->d_nsectors = fd->sc_type->sectrac; lp->d_ncylinders = fd->sc_type->tracks; lp->d_ntracks = fd->sc_type->heads; /* Go figure... */ - lp->d_secperunit = fd->sc_type->size; + DL_SETDSIZE(lp, fd->sc_type->size); lp->d_rpm = 300; /* XXX like it matters... */ strncpy(lp->d_typename, "floppy disk", sizeof(lp->d_typename)); diff --git a/sys/arch/sparc/dev/presto.c b/sys/arch/sparc/dev/presto.c index 17337f75072..8fa71113b39 100644 --- a/sys/arch/sparc/dev/presto.c +++ b/sys/arch/sparc/dev/presto.c @@ -1,4 +1,4 @@ -/* $OpenBSD: presto.c,v 1.8 2007/06/04 16:38:58 krw Exp $ */ +/* $OpenBSD: presto.c,v 1.9 2007/06/05 00:38:18 deraadt Exp $ */ /* * Copyright (c) 2003, Miodrag Vallat. * All rights reserved. @@ -198,7 +198,7 @@ prestosize(dev_t dev) if (part >= sc->sc_dk.dk_label->d_npartitions) return (0); else - return (sc->sc_dk.dk_label->d_partitions[part].p_size * + return (DL_GETPSIZE(&sc->sc_dk.dk_label->d_partitions[part]) * (sc->sc_dk.dk_label->d_secsize / DEV_BSIZE)); } @@ -378,8 +378,8 @@ presto_getdisklabel(dev_t dev, struct presto_softc *sc) lp->d_secsize = DEV_BSIZE; lp->d_ntracks = 1; lp->d_nsectors = 32; - lp->d_secperunit = (sc->sc_memsize - PSERVE_OFFSET) >> DEV_BSHIFT; - lp->d_ncylinders = lp->d_secperunit / lp->d_nsectors; + DL_SETDSIZE(lp, (sc->sc_memsize - PSERVE_OFFSET) >> DEV_BSHIFT); + lp->d_ncylinders = DL_GETDSIZE(lp) / lp->d_nsectors; lp->d_secpercyl = lp->d_nsectors; strncpy(lp->d_typename, "Prestoserve", 16); diff --git a/sys/arch/sparc/dev/xd.c b/sys/arch/sparc/dev/xd.c index accb5f40fa3..41683456a49 100644 --- a/sys/arch/sparc/dev/xd.c +++ b/sys/arch/sparc/dev/xd.c @@ -1,4 +1,4 @@ -/* $OpenBSD: xd.c,v 1.35 2007/04/29 18:59:37 krw Exp $ */ +/* $OpenBSD: xd.c,v 1.36 2007/06/05 00:38:18 deraadt Exp $ */ /* $NetBSD: xd.c,v 1.37 1997/07/29 09:58:16 fair Exp $ */ /* @@ -1009,7 +1009,7 @@ xdsize(dev) if (xdsc->sc_dk.dk_label->d_partitions[part].p_fstype != FS_SWAP) size = -1; /* only give valid size for swap partitions */ else - size = xdsc->sc_dk.dk_label->d_partitions[part].p_size * + size = DL_GETPSIZE(&xdsc->sc_dk.dk_label->d_partitions[part]) * (xdsc->sc_dk.dk_label->d_secsize / DEV_BSIZE); if (omask == 0 && xdclose(dev, 0, S_IFBLK, NULL) != 0) return (-1); @@ -1425,7 +1425,7 @@ xdc_startbuf(xdcsc, xdsc, bp) */ block = bp->b_blkno + ((partno == RAW_PART) ? 0 : - xdsc->sc_dk.dk_label->d_partitions[partno].p_offset); + DL_GETPOFFSET(&xdsc->sc_dk.dk_label->d_partitions[partno])); dbuf = kdvma_mapin(bp->b_data, bp->b_bcount, 0); if (dbuf == NULL) { /* out of DVMA space */ diff --git a/sys/arch/sparc/dev/xy.c b/sys/arch/sparc/dev/xy.c index 5ad979a6d5d..f860780ff4c 100644 --- a/sys/arch/sparc/dev/xy.c +++ b/sys/arch/sparc/dev/xy.c @@ -1,4 +1,4 @@ -/* $OpenBSD: xy.c,v 1.31 2007/04/29 18:59:37 krw Exp $ */ +/* $OpenBSD: xy.c,v 1.32 2007/06/05 00:38:18 deraadt Exp $ */ /* $NetBSD: xy.c,v 1.26 1997/07/19 21:43:56 pk Exp $ */ /* @@ -972,7 +972,7 @@ xysize(dev) if (xysc->sc_dk.dk_label->d_partitions[part].p_fstype != FS_SWAP) size = -1; /* only give valid size for swap partitions */ else - size = xysc->sc_dk.dk_label->d_partitions[part].p_size * + size = DL_GETPSIZE(&xysc->sc_dk.dk_label->d_partitions[part]) * (xysc->sc_dk.dk_label->d_secsize / DEV_BSIZE); if (omask == 0 && xyclose(dev, 0, S_IFBLK, NULL) != 0) return (-1); @@ -1283,7 +1283,7 @@ xyc_startbuf(xycsc, xysc, bp) */ block = bp->b_blkno + ((partno == RAW_PART) ? 0 : - xysc->sc_dk.dk_label->d_partitions[partno].p_offset); + DL_GETPOFFSET(&xysc->sc_dk.dk_label->d_partitions[partno])); dbuf = kdvma_mapin(bp->b_data, bp->b_bcount, 0); if (dbuf == NULL) { /* out of DVMA space */ diff --git a/sys/arch/sparc/sparc/disksubr.c b/sys/arch/sparc/sparc/disksubr.c index 510fbb6cfd3..50d42e00009 100644 --- a/sys/arch/sparc/sparc/disksubr.c +++ b/sys/arch/sparc/sparc/disksubr.c @@ -1,4 +1,4 @@ -/* $OpenBSD: disksubr.c,v 1.48 2007/06/02 02:35:27 krw Exp $ */ +/* $OpenBSD: disksubr.c,v 1.49 2007/06/05 00:38:18 deraadt Exp $ */ /* $NetBSD: disksubr.c,v 1.16 1996/04/28 20:25:59 thorpej Exp $ */ /* @@ -87,20 +87,20 @@ readdisklabel(dev, strat, lp, clp, spoofonly) /* minimal requirements for archetypal disk label */ if (lp->d_secsize < DEV_BSIZE) lp->d_secsize = DEV_BSIZE; - if (lp->d_secperunit == 0) - lp->d_secperunit = 0x1fffffff; + if (DL_GETDSIZE(lp) == 0) + DL_SETDSIZE(lp, MAXDISKSIZE); if (lp->d_secpercyl == 0) { msg = "invalid geometry"; goto done; } lp->d_npartitions = RAW_PART+1; for (i = 0; i < RAW_PART; i++) { - lp->d_partitions[i].p_size = 0; - lp->d_partitions[i].p_offset = 0; + DL_SETPSIZE(&lp->d_partitions[i], 0); + DL_SETPOFFSET(&lp->d_partitions[i], 0); } - if (lp->d_partitions[i].p_size == 0) - lp->d_partitions[i].p_size = lp->d_secperunit; - lp->d_partitions[i].p_offset = 0; + if (DL_GETPSIZE(&lp->d_partitions[i]) == 0) + DL_SETPSIZE(&lp->d_partitions[i], DL_GETDSIZE(lp)); + DL_SETPOFFSET(&lp->d_partitions[i], 0); lp->d_bbsize = 8192; lp->d_sbsize = 64*1024; /* XXX ? */ @@ -225,7 +225,8 @@ setdisklabel(olp, nlp, openmask, clp) return (EBUSY); opp = &olp->d_partitions[i]; npp = &nlp->d_partitions[i]; - if (npp->p_offset != opp->p_offset || npp->p_size < opp->p_size) + if (DL_GETPOFFSET(npp) != DL_GETPOFFSET(opp) || + DL_GETPSIZE(npp) < DL_GETPSIZE(opp)) return (EBUSY); } @@ -299,15 +300,15 @@ bounds_check_with_label(struct buf *bp, struct disklabel *lp, /* XXX should also protect bootstrap in first 8K */ /* XXX this assumes everything <=LABELSECTOR is label! */ /* But since LABELSECTOR is 0, that's ok for now. */ - if ((bp->b_blkno + blockpersec(p->p_offset, lp) <= LABELSECTOR) && + if ((bp->b_blkno + blockpersec(DL_GETPOFFSET(p), lp) <= LABELSECTOR) && ((bp->b_flags & B_READ) == 0) && (wlabel == 0)) { bp->b_error = EROFS; goto bad; } /* beyond partition? */ - if (bp->b_blkno + sz > blockpersec(p->p_size, lp)) { - sz = blockpersec(p->p_size, lp) - bp->b_blkno; + if (bp->b_blkno + sz > blockpersec(DL_GETPSIZE(p), lp)) { + sz = blockpersec(DL_GETPSIZE(p), lp) - bp->b_blkno; if (sz == 0) { /* If exactly at end of disk, return EOF. */ bp->b_resid = bp->b_bcount; @@ -323,7 +324,7 @@ bounds_check_with_label(struct buf *bp, struct disklabel *lp, } /* calculate cylinder for disksort to order transfers with */ - bp->b_cylinder = (bp->b_blkno + blockpersec(p->p_offset, lp)) / + bp->b_cylinder = (bp->b_blkno + blockpersec(DL_GETPOFFSET(p), lp)) / lp->d_secpercyl; return (1); bad: @@ -420,7 +421,7 @@ disklabel_sun_to_bsd(cp, lp) secpercyl = sl->sl_nsectors * sl->sl_ntracks; lp->d_secpercyl = secpercyl; - lp->d_secperunit = secpercyl * sl->sl_ncylinders; + DL_SETDSIZE(lp, (daddr64_t)secpercyl * sl->sl_ncylinders); lp->d_version = 1; /* 48 bit addressing */ lp->d_sparespercyl = sl->sl_sparespercyl; @@ -436,9 +437,9 @@ disklabel_sun_to_bsd(cp, lp) for (i = 0; i < 8; i++) { spp = &sl->sl_part[i]; npp = &lp->d_partitions[i]; - npp->p_offset = spp->sdkp_cyloffset * secpercyl; - npp->p_size = spp->sdkp_nsectors; - if (npp->p_size == 0) { + DL_SETPOFFSET(npp, spp->sdkp_cyloffset * secpercyl); + DL_SETPSIZE(npp, spp->sdkp_nsectors); + if (DL_GETPSIZE(npp) == 0) { npp->p_fstype = FS_UNUSED; } else { npp->p_fstype = sun_fstypes[i]; @@ -457,8 +458,8 @@ disklabel_sun_to_bsd(cp, lp) /* Clear "extended" partition info, tentatively */ for (i = 0; i < SUNXPART; i++) { npp = &lp->d_partitions[i+8]; - npp->p_offset = 0; - npp->p_size = 0; + DL_SETPOFFSET(npp, 0); + DL_SETPSIZE(npp, 0); npp->p_fstype = FS_UNUSED; } @@ -472,9 +473,9 @@ disklabel_sun_to_bsd(cp, lp) for (i = 0; i < SUNXPART; i++) { spp = &sl->sl_xpart[i]; npp = &lp->d_partitions[i+8]; - npp->p_offset = spp->sdkp_cyloffset * secpercyl; - npp->p_size = spp->sdkp_nsectors; - if (npp->p_size == 0) { + DL_SETPOFFSET(npp, spp->sdkp_cyloffset * secpercyl); + DL_SETPSIZE(npp, spp->sdkp_nsectors); + if (DL_GETPSIZE(npp) == 0) { npp->p_fstype = FS_UNUSED; continue; } @@ -538,10 +539,10 @@ disklabel_bsd_to_sun(lp, cp) spp = &sl->sl_part[i]; npp = &lp->d_partitions[i]; - if (npp->p_offset % secpercyl) + if (DL_GETPOFFSET(npp) % secpercyl) return (EINVAL); - spp->sdkp_cyloffset = npp->p_offset / secpercyl; - spp->sdkp_nsectors = npp->p_size; + spp->sdkp_cyloffset = DL_GETPOFFSET(npp) / secpercyl; + spp->sdkp_nsectors = DL_GETPSIZE(npp); } sl->sl_magic = SUN_DKMAGIC; @@ -553,8 +554,8 @@ disklabel_bsd_to_sun(lp, cp) * certainly doesn't hurt anything and it's easy to do. */ for (i = 0; i < SUNXPART; i++) { - if (lp->d_partitions[i+8].p_offset || - lp->d_partitions[i+8].p_size) + if (DL_GETPOFFSET(&lp->d_partitions[i+8]) || + DL_GETPSIZE(&lp->d_partitions[i+8])) break; } /* We do need to load the extended table? */ @@ -563,11 +564,11 @@ disklabel_bsd_to_sun(lp, cp) for (i = 0; i < SUNXPART; i++) { spp = &sl->sl_xpart[i]; npp = &lp->d_partitions[i+8]; - if (npp->p_offset % secpercyl) + if (DL_GETPOFFSET(npp) % secpercyl) return (EINVAL); sl->sl_xpart[i].sdkp_cyloffset = - npp->p_offset / secpercyl; - sl->sl_xpart[i].sdkp_nsectors = npp->p_size; + DL_GETPOFFSET(npp) / secpercyl; + sl->sl_xpart[i].sdkp_nsectors = DL_GETPSIZE(npp); } for (i = 0; i < MAXPARTITIONS; i++) { npp = &lp->d_partitions[i]; |