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/dev | |
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/dev')
-rw-r--r-- | sys/dev/ata/wd.c | 21 | ||||
-rw-r--r-- | sys/dev/ccd.c | 10 | ||||
-rw-r--r-- | sys/dev/flash.c | 6 | ||||
-rw-r--r-- | sys/dev/isa/fd.c | 4 | ||||
-rw-r--r-- | sys/dev/isa/mcd.c | 6 | ||||
-rw-r--r-- | sys/dev/raidframe/rf_copyback.c | 4 | ||||
-rw-r--r-- | sys/dev/raidframe/rf_disks.c | 6 | ||||
-rw-r--r-- | sys/dev/raidframe/rf_openbsdkintf.c | 22 | ||||
-rw-r--r-- | sys/dev/raidframe/rf_reconstruct.c | 4 | ||||
-rw-r--r-- | sys/dev/ramdisk.c | 6 | ||||
-rw-r--r-- | sys/dev/softraid.c | 4 | ||||
-rw-r--r-- | sys/dev/vnd.c | 8 |
12 files changed, 48 insertions, 53 deletions
diff --git a/sys/dev/ata/wd.c b/sys/dev/ata/wd.c index a9c23e1b1ba..d1aeeccabd2 100644 --- a/sys/dev/ata/wd.c +++ b/sys/dev/ata/wd.c @@ -1,4 +1,4 @@ -/* $OpenBSD: wd.c,v 1.60 2007/06/01 00:07:48 krw Exp $ */ +/* $OpenBSD: wd.c,v 1.61 2007/06/05 00:38:20 deraadt Exp $ */ /* $NetBSD: wd.c,v 1.193 1999/02/28 17:15:27 explorer Exp $ */ /* @@ -506,15 +506,10 @@ wdstart(void *arg) void __wdstart(struct wd_softc *wd, struct buf *bp) { - daddr_t p_offset; daddr_t nblks; - if (DISKPART(bp->b_dev) != RAW_PART) - p_offset = - wd->sc_dk.dk_label->d_partitions[DISKPART(bp->b_dev)].p_offset; - else - p_offset = 0; - wd->sc_wdc_bio.blkno = bp->b_blkno + p_offset; + wd->sc_wdc_bio.blkno = bp->b_blkno + + DL_GETPOFFSET(&wd->sc_dk.dk_label->d_partitions[DISKPART(bp->b_dev)]); wd->sc_wdc_bio.blkno /= (wd->sc_dk.dk_label->d_secsize / DEV_BSIZE); wd->sc_wdc_bio.blkdone =0; wd->sc_bp = bp; @@ -777,11 +772,11 @@ wdgetdefaultlabel(struct wd_softc *wd, struct disklabel *lp) bzero(lp, sizeof(struct disklabel)); lp->d_secsize = DEV_BSIZE; - lp->d_secperunit = wd->sc_capacity; + DL_SETDSIZE(lp, wd->sc_capacity); lp->d_ntracks = wd->sc_params.atap_heads; lp->d_nsectors = wd->sc_params.atap_sectors; lp->d_secpercyl = lp->d_ntracks * lp->d_nsectors; - lp->d_ncylinders = lp->d_secperunit / lp->d_secpercyl; + lp->d_ncylinders = DL_GETDSIZE(lp) / lp->d_secpercyl; if (wd->drvp->ata_vers == -1) { lp->d_type = DTYPE_ST506; strncpy(lp->d_typename, "ST506/MFM/RLL", sizeof lp->d_typename); @@ -978,7 +973,7 @@ wdsize(dev_t dev) goto exit; } - size = wd->sc_dk.dk_label->d_partitions[part].p_size * + size = DL_GETPSIZE(&wd->sc_dk.dk_label->d_partitions[part]) * (wd->sc_dk.dk_label->d_secsize / DEV_BSIZE); if (omask == 0 && wdclose(dev, 0, S_IFBLK, NULL) != 0) size = -1; @@ -1030,11 +1025,11 @@ wddump(dev_t dev, daddr_t blkno, caddr_t va, size_t size) blkno = blkno / (lp->d_secsize / DEV_BSIZE); /* Check transfer bounds against partition size. */ - if ((blkno < 0) || ((blkno + nblks) > lp->d_partitions[part].p_size)) + if ((blkno < 0) || ((blkno + nblks) > DL_GETPSIZE(&lp->d_partitions[part]))) return EINVAL; /* Offset block number to start of partition. */ - blkno += lp->d_partitions[part].p_offset; + blkno += DL_GETPOFFSET(&lp->d_partitions[part]); /* Recalibrate, if first dump transfer. */ if (wddumprecalibrated == 0) { diff --git a/sys/dev/ccd.c b/sys/dev/ccd.c index 7009bb00642..4f6e9b89c13 100644 --- a/sys/dev/ccd.c +++ b/sys/dev/ccd.c @@ -1,4 +1,4 @@ -/* $OpenBSD: ccd.c,v 1.73 2007/06/01 00:07:48 krw Exp $ */ +/* $OpenBSD: ccd.c,v 1.74 2007/06/05 00:38:20 deraadt Exp $ */ /* $NetBSD: ccd.c,v 1.33 1996/05/05 04:21:14 thorpej Exp $ */ /*- @@ -355,7 +355,7 @@ ccdinit(struct ccddevice *ccd, char **cpaths, struct proc *p) maxsecsize = ((dpart.disklab->d_secsize > maxsecsize) ? dpart.disklab->d_secsize : maxsecsize); - size = dpart.part->p_size; + size = DL_GETPSIZE(dpart.part); } else { CCD_DPRINTF(CCDB_FOLLOW | CCDB_INIT, ("%s: %s: incorrect partition type\n", @@ -725,7 +725,7 @@ ccdstart(struct ccd_softc *cs, struct buf *bp) bn = bp->b_blkno; if (DISKPART(bp->b_dev) != RAW_PART) { pp = &cs->sc_dkdev.dk_label->d_partitions[DISKPART(bp->b_dev)]; - bn += pp->p_offset; + bn += DL_GETPOFFSET(pp); } /* @@ -1290,7 +1290,7 @@ ccdsize(dev_t dev) if (cs->sc_dkdev.dk_label->d_partitions[part].p_fstype != FS_SWAP) size = -1; else - size = cs->sc_dkdev.dk_label->d_partitions[part].p_size; + size = DL_GETPSIZE(&cs->sc_dkdev.dk_label->d_partitions[part]); if (ccdclose(dev, 0, S_IFBLK, curproc)) return (-1); @@ -1371,7 +1371,7 @@ ccdgetdisklabel(dev_t dev, struct ccd_softc *cs, struct disklabel *lp, bzero(lp, sizeof(*lp)); bzero(clp, sizeof(*clp)); - lp->d_secperunit = cs->sc_size; + DL_SETDSIZE(lp, cs->sc_size); lp->d_secsize = ccg->ccg_secsize; lp->d_nsectors = ccg->ccg_nsectors; lp->d_ntracks = ccg->ccg_ntracks; diff --git a/sys/dev/flash.c b/sys/dev/flash.c index 403091b9d48..c96562cb342 100644 --- a/sys/dev/flash.c +++ b/sys/dev/flash.c @@ -1,4 +1,4 @@ -/* $OpenBSD: flash.c,v 1.3 2007/06/01 00:07:48 krw Exp $ */ +/* $OpenBSD: flash.c,v 1.4 2007/06/05 00:38:20 deraadt Exp $ */ /* * Copyright (c) 2005 Uwe Stuehler <uwe@openbsd.org> @@ -905,7 +905,7 @@ _flashstart(struct flash_softc *sc, struct buf *bp) part = flashpart(bp->b_dev); if (part != RAW_PART) - offset = sc->sc_dk.dk_label->d_partitions[part].p_offset; + offset = DL_GETPOFFSET(&sc->sc_dk.dk_label->d_partitions[part]); else offset = 0; @@ -991,7 +991,7 @@ flashgetdefaultlabel(dev_t dev, struct flash_softc *sc, lp->d_nsectors = sc->sc_flashdev->capacity / lp->d_ntracks / lp->d_ncylinders; lp->d_secpercyl = lp->d_ntracks * lp->d_nsectors; - lp->d_secperunit = lp->d_ncylinders * lp->d_secpercyl; + DL_SETDSIZE(lp, (daddr64_t)lp->d_ncylinders * lp->d_secpercyl); /* Fake hardware characteristics. */ lp->d_rpm = 3600; diff --git a/sys/dev/isa/fd.c b/sys/dev/isa/fd.c index 3d824ea5e26..2c45df9ed71 100644 --- a/sys/dev/isa/fd.c +++ b/sys/dev/isa/fd.c @@ -1,4 +1,4 @@ -/* $OpenBSD: fd.c,v 1.63 2007/06/01 00:07:48 krw Exp $ */ +/* $OpenBSD: fd.c,v 1.64 2007/06/05 00:38:21 deraadt Exp $ */ /* $NetBSD: fd.c,v 1.90 1996/05/12 23:12:03 mycroft Exp $ */ /*- @@ -982,7 +982,7 @@ fdioctl(dev, cmd, addr, flag, p) strncpy(lp->d_typename, "floppy disk", sizeof lp->d_typename); lp->d_type = DTYPE_FLOPPY; strncpy(lp->d_packname, "fictitious", sizeof lp->d_packname); - lp->d_secperunit = fd->sc_type->size; + DL_SETDSIZE(lp, fd->sc_type->size); lp->d_rpm = 300; lp->d_interleave = 1; diff --git a/sys/dev/isa/mcd.c b/sys/dev/isa/mcd.c index ec87e7cfc2e..07a51bc3fd9 100644 --- a/sys/dev/isa/mcd.c +++ b/sys/dev/isa/mcd.c @@ -1,4 +1,4 @@ -/* $OpenBSD: mcd.c,v 1.44 2007/06/01 00:07:48 krw Exp $ */ +/* $OpenBSD: mcd.c,v 1.45 2007/06/05 00:38:21 deraadt Exp $ */ /* $NetBSD: mcd.c,v 1.60 1998/01/14 12:14:41 drochner Exp $ */ /* @@ -579,7 +579,7 @@ loop: if (DISKPART(bp->b_dev) != RAW_PART) { struct partition *p; p = &sc->sc_dk.dk_label->d_partitions[DISKPART(bp->b_dev)]; - sc->mbx.blkno += p->p_offset; + sc->mbx.blkno += DL_GETPOFFSET(p); } sc->mbx.nblk = bp->b_bcount / sc->blksize; sc->mbx.sz = sc->blksize; @@ -754,7 +754,7 @@ mcdgetdisklabel(dev, sc, lp, clp, spoofonly) strncpy(lp->d_typename, "Mitsumi CD-ROM", sizeof lp->d_typename); lp->d_type = DTYPE_SCSI; /* XXX */ strncpy(lp->d_packname, "fictitious", sizeof lp->d_packname); - lp->d_secperunit = sc->disksize; + DL_SETDSIZE(lp, sc->disksize); lp->d_rpm = 300; lp->d_interleave = 1; diff --git a/sys/dev/raidframe/rf_copyback.c b/sys/dev/raidframe/rf_copyback.c index 9b573cd9234..65b5f2ccf9c 100644 --- a/sys/dev/raidframe/rf_copyback.c +++ b/sys/dev/raidframe/rf_copyback.c @@ -1,4 +1,4 @@ -/* $OpenBSD: rf_copyback.c,v 1.7 2002/12/16 07:01:03 tdeval Exp $ */ +/* $OpenBSD: rf_copyback.c,v 1.8 2007/06/05 00:38:22 deraadt Exp $ */ /* $NetBSD: rf_copyback.c,v 1.14 2000/03/07 02:59:50 oster Exp $ */ /* @@ -177,7 +177,7 @@ rf_CopybackReconstructedData(RF_Raid_t *raidPtr) } raidPtr->Disks[frow][fcol].blockSize = dpart.disklab->d_secsize; - raidPtr->Disks[frow][fcol].numBlocks = dpart.part->p_size - + raidPtr->Disks[frow][fcol].numBlocks = DL_GETPSIZE(dpart.part) - rf_protectedSectors; raidPtr->raid_cinfo[frow][fcol].ci_vp = vp; diff --git a/sys/dev/raidframe/rf_disks.c b/sys/dev/raidframe/rf_disks.c index 66afd87c22b..2a310d8c630 100644 --- a/sys/dev/raidframe/rf_disks.c +++ b/sys/dev/raidframe/rf_disks.c @@ -1,4 +1,4 @@ -/* $OpenBSD: rf_disks.c,v 1.11 2006/10/13 00:30:08 cloder Exp $ */ +/* $OpenBSD: rf_disks.c,v 1.12 2007/06/05 00:38:22 deraadt Exp $ */ /* $NetBSD: rf_disks.c,v 1.31 2000/06/02 01:17:14 oster Exp $ */ /* @@ -685,8 +685,8 @@ rf_ConfigureDisk(RF_Raid_t *raidPtr, char *buf, RF_RaidDisk_t *diskPtr, } diskPtr->blockSize = dpart.disklab->d_secsize; - diskPtr->numBlocks = dpart.part->p_size - rf_protectedSectors; - diskPtr->partitionSize = dpart.part->p_size; + diskPtr->numBlocks = DL_GETPSIZE(dpart.part) - rf_protectedSectors; + diskPtr->partitionSize = DL_GETPSIZE(dpart.part); raidPtr->raid_cinfo[row][col].ci_vp = vp; raidPtr->raid_cinfo[row][col].ci_dev = va.va_rdev; diff --git a/sys/dev/raidframe/rf_openbsdkintf.c b/sys/dev/raidframe/rf_openbsdkintf.c index 5c3b1294ff9..7b2b4f2336d 100644 --- a/sys/dev/raidframe/rf_openbsdkintf.c +++ b/sys/dev/raidframe/rf_openbsdkintf.c @@ -1,4 +1,4 @@ -/* $OpenBSD: rf_openbsdkintf.c,v 1.35 2007/04/28 12:32:13 krw Exp $ */ +/* $OpenBSD: rf_openbsdkintf.c,v 1.36 2007/06/05 00:38:22 deraadt Exp $ */ /* $NetBSD: rf_netbsdkintf.c,v 1.109 2001/07/27 03:30:07 oster Exp $ */ /*- @@ -600,7 +600,7 @@ raidsize(dev_t dev) if (lp->d_partitions[part].p_fstype != FS_SWAP) size = -1; else - size = lp->d_partitions[part].p_size * + size = DL_GETPSIZE(&lp->d_partitions[part]) * (lp->d_secsize / DEV_BSIZE); if (omask == 0 && raidclose(dev, 0, S_IFBLK, curproc)) @@ -1758,7 +1758,7 @@ raidstart(RF_Raid_t *raidPtr) blocknum = bp->b_blkno; if (DISKPART(bp->b_dev) != RAW_PART) { pp = &rs->sc_dkdev.dk_label->d_partitions[DISKPART(bp->b_dev)]; - blocknum += pp->p_offset; + blocknum += DL_GETPOFFSET(pp); } db1_printf(("Blocks: %d, %d\n", (int) bp->b_blkno, @@ -2096,7 +2096,7 @@ raidgetdefaultlabel(RF_Raid_t *raidPtr, struct raid_softc *rs, bzero(lp, sizeof(*lp)); /* Fabricate a label... */ - lp->d_secperunit = raidPtr->totalSectors; + DL_SETDSIZE(lp, raidPtr->totalSectors); lp->d_secsize = raidPtr->bytesPerSector; lp->d_nsectors = raidPtr->Layout.dataSectorsPerStripe; lp->d_ntracks = 4 * raidPtr->numCol; @@ -2111,8 +2111,8 @@ raidgetdefaultlabel(RF_Raid_t *raidPtr, struct raid_softc *rs, lp->d_interleave = 1; lp->d_flags = 0; - lp->d_partitions[RAW_PART].p_offset = 0; - lp->d_partitions[RAW_PART].p_size = raidPtr->totalSectors; + DL_SETPOFFSET(&lp->d_partitions[RAW_PART], 0); + DL_SETPSIZE(&lp->d_partitions[RAW_PART], raidPtr->totalSectors); lp->d_partitions[RAW_PART].p_fstype = FS_UNUSED; lp->d_npartitions = RAW_PART + 1; @@ -2165,15 +2165,15 @@ raidgetdisklabel(dev_t dev) * if that is found. */ #ifdef RAIDDEBUG - if (lp->d_secperunit != rs->sc_size) + if (DL_GETDSIZE(lp) != rs->sc_size) printf("WARNING: %s: " "total sector size in disklabel (%d) != " "the size of raid (%ld)\n", rs->sc_xname, - lp->d_secperunit, (long) rs->sc_size); + DL_GETDSIZE(lp), (long) rs->sc_size); #endif /* RAIDDEBUG */ for (i = 0; i < lp->d_npartitions; i++) { pp = &lp->d_partitions[i]; - if (pp->p_offset + pp->p_size > rs->sc_size) + if (DL_GETPOFFSET(pp) + DL_GETPSIZE(pp) > rs->sc_size) printf("WARNING: %s: end of partition `%c' " "exceeds the size of raid (%ld)\n", rs->sc_xname, 'a' + i, (long) rs->sc_size); @@ -2844,11 +2844,11 @@ rf_find_raid_components(void) /* Got the label. Does it look reasonable ? */ if (rf_reasonable_label(clabel) && (clabel->partitionSize <= - label.d_partitions[i].p_size)) { + DL_GETPSIZE(&label.d_partitions[i]))) { #ifdef RAIDDEBUG printf("Component on: %s%c: %d\n", dv->dv_xname, 'a'+i, - label.d_partitions[i].p_size); + DL_GETPSIZE(&label.d_partitions[i])); rf_print_component_label(clabel); #endif /* RAIDDEBUG */ /* diff --git a/sys/dev/raidframe/rf_reconstruct.c b/sys/dev/raidframe/rf_reconstruct.c index abe9a072f54..43896e524da 100644 --- a/sys/dev/raidframe/rf_reconstruct.c +++ b/sys/dev/raidframe/rf_reconstruct.c @@ -1,4 +1,4 @@ -/* $OpenBSD: rf_reconstruct.c,v 1.15 2003/10/26 15:07:26 jmc Exp $ */ +/* $OpenBSD: rf_reconstruct.c,v 1.16 2007/06/05 00:38:22 deraadt Exp $ */ /* $NetBSD: rf_reconstruct.c,v 1.26 2000/06/04 02:05:13 oster Exp $ */ /* @@ -623,7 +623,7 @@ rf_ReconstructInPlace(RF_Raid_t *raidPtr, RF_RowCol_t row, RF_RowCol_t col) dpart.disklab->d_secsize; raidPtr->Disks[row][col].numBlocks = - dpart.part->p_size - rf_protectedSectors; + DL_GETPSIZE(dpart.part) - rf_protectedSectors; raidPtr->raid_cinfo[row][col].ci_vp = vp; raidPtr->raid_cinfo[row][col].ci_dev = va.va_rdev; diff --git a/sys/dev/ramdisk.c b/sys/dev/ramdisk.c index 6bd7a5da072..f5fcc1d70b5 100644 --- a/sys/dev/ramdisk.c +++ b/sys/dev/ramdisk.c @@ -1,4 +1,4 @@ -/* $OpenBSD: ramdisk.c,v 1.31 2007/06/01 00:07:48 krw Exp $ */ +/* $OpenBSD: ramdisk.c,v 1.32 2007/06/05 00:38:20 deraadt Exp $ */ /* $NetBSD: ramdisk.c,v 1.8 1996/04/12 08:30:09 leo Exp $ */ /* @@ -240,7 +240,7 @@ rdsize(dev_t dev) if (part >= sc->sc_dkdev.dk_label->d_npartitions) return 0; else - return sc->sc_dkdev.dk_label->d_partitions[part].p_size * + return DL_GETPSIZE(&sc->sc_dkdev.dk_label->d_partitions[part]) * (sc->sc_dkdev.dk_label->d_secsize / DEV_BSIZE); } @@ -492,7 +492,7 @@ rdgetdisklabel(dev_t dev, struct rd_softc *sc) strncpy(lp->d_typename, "RAM disk", sizeof(lp->d_typename)); lp->d_type = DTYPE_SCSI; strncpy(lp->d_packname, "fictitious", sizeof(lp->d_packname)); - lp->d_secperunit = lp->d_nsectors; + DL_SETDSIZE(lp, lp->d_nsectors); lp->d_rpm = 3600; lp->d_interleave = 1; diff --git a/sys/dev/softraid.c b/sys/dev/softraid.c index 5e81ac92fca..25ae3a7c5a1 100644 --- a/sys/dev/softraid.c +++ b/sys/dev/softraid.c @@ -1,4 +1,4 @@ -/* $OpenBSD: softraid.c,v 1.77 2007/06/04 04:53:31 marco Exp $ */ +/* $OpenBSD: softraid.c,v 1.78 2007/06/05 00:38:20 deraadt Exp $ */ /* * Copyright (c) 2007 Marco Peereboom <marco@peereboom.us> * @@ -1073,7 +1073,7 @@ sr_open_chunks(struct sr_softc *sc, struct sr_chunk_head *cl, dev_t *dt, } /* get partition size */ - ch_entry->src_size = size = label.d_partitions[part].p_size - + ch_entry->src_size = size = DL_GETPSIZE(&label.d_partitions[part]) - SR_META_SIZE - SR_META_OFFSET; if (size <= 0) { printf("%s: %s partition too small\n", diff --git a/sys/dev/vnd.c b/sys/dev/vnd.c index 7225fc3db97..15777a7df78 100644 --- a/sys/dev/vnd.c +++ b/sys/dev/vnd.c @@ -1,4 +1,4 @@ -/* $OpenBSD: vnd.c,v 1.75 2007/06/01 00:07:48 krw Exp $ */ +/* $OpenBSD: vnd.c,v 1.76 2007/06/05 00:38:20 deraadt Exp $ */ /* $NetBSD: vnd.c,v 1.26 1996/03/30 23:06:11 christos Exp $ */ /* @@ -309,7 +309,7 @@ vndgetdisklabel(dev_t dev, struct vnd_softc *sc) strncpy(lp->d_typename, "vnd device", sizeof(lp->d_typename)); lp->d_type = DTYPE_VND; strncpy(lp->d_packname, "fictitious", sizeof(lp->d_packname)); - lp->d_secperunit = sc->sc_size; + DL_SETDSIZE(lp, sc->sc_size); lp->d_rpm = 3600; lp->d_interleave = 1; lp->d_flags = 0; @@ -437,7 +437,7 @@ vndstrategy(struct buf *bp) /* Loop until all queued requests are handled. */ for (;;) { int part = DISKPART(bp->b_dev); - int off = vnd->sc_dk.dk_label->d_partitions[part].p_offset; + int off = DL_GETPOFFSET(&vnd->sc_dk.dk_label->d_partitions[part]); aiov.iov_base = bp->b_data; auio.uio_resid = aiov.iov_len = bp->b_bcount; @@ -496,7 +496,7 @@ vndstrategy(struct buf *bp) } /* The old-style buffercache bypassing method. */ - bn += vnd->sc_dk.dk_label->d_partitions[DISKPART(bp->b_dev)].p_offset; + bn += DL_GETPOFFSET(&vnd->sc_dk.dk_label->d_partitions[DISKPART(bp->b_dev)]); bn = dbtob(bn); bsize = vnd->sc_vp->v_mount->mnt_stat.f_iosize; addr = bp->b_data; |