summaryrefslogtreecommitdiff
path: root/sys
diff options
context:
space:
mode:
Diffstat (limited to 'sys')
-rw-r--r--sys/arch/alpha/alpha/disksubr.c54
-rw-r--r--sys/arch/amd64/amd64/disksubr.c57
-rw-r--r--sys/arch/arm/arm/disksubr.c53
-rw-r--r--sys/arch/aviion/aviion/disksubr.c53
-rw-r--r--sys/arch/hp300/dev/hd.c14
-rw-r--r--sys/arch/hp300/hp300/disksubr.c33
-rw-r--r--sys/arch/hppa/hppa/disksubr.c66
-rw-r--r--sys/arch/hppa64/hppa64/disksubr.c66
-rw-r--r--sys/arch/i386/i386/disksubr.c57
-rw-r--r--sys/arch/landisk/landisk/disksubr.c53
-rw-r--r--sys/arch/luna88k/luna88k/disksubr.c42
-rw-r--r--sys/arch/mac68k/mac68k/disksubr.c39
-rw-r--r--sys/arch/macppc/macppc/disksubr.c58
-rw-r--r--sys/arch/mips64/mips64/disksubr.c60
-rw-r--r--sys/arch/mvme68k/mvme68k/disksubr.c158
-rw-r--r--sys/arch/mvme88k/mvme88k/disksubr.c158
-rw-r--r--sys/arch/mvmeppc/mvmeppc/disksubr.c53
-rw-r--r--sys/arch/sparc/dev/fd.c4
-rw-r--r--sys/arch/sparc/dev/presto.c8
-rw-r--r--sys/arch/sparc/dev/xd.c6
-rw-r--r--sys/arch/sparc/dev/xy.c6
-rw-r--r--sys/arch/sparc/sparc/disksubr.c61
-rw-r--r--sys/arch/sparc64/dev/fd.c4
-rw-r--r--sys/arch/sparc64/sparc64/disksubr.c61
-rw-r--r--sys/arch/vax/mba/hp.c8
-rw-r--r--sys/arch/vax/mscp/mscp_disk.c21
-rw-r--r--sys/arch/vax/vax/disksubr.c29
-rw-r--r--sys/arch/vax/vsa/hdc9224.c22
-rw-r--r--sys/arch/zaurus/dev/zaurus_flash.c26
-rw-r--r--sys/compat/linux/linux_blkio.c4
-rw-r--r--sys/compat/linux/linux_hdio.c6
-rw-r--r--sys/dev/ata/wd.c21
-rw-r--r--sys/dev/ccd.c10
-rw-r--r--sys/dev/flash.c6
-rw-r--r--sys/dev/isa/fd.c4
-rw-r--r--sys/dev/isa/mcd.c6
-rw-r--r--sys/dev/raidframe/rf_copyback.c4
-rw-r--r--sys/dev/raidframe/rf_disks.c6
-rw-r--r--sys/dev/raidframe/rf_openbsdkintf.c22
-rw-r--r--sys/dev/raidframe/rf_reconstruct.c4
-rw-r--r--sys/dev/ramdisk.c6
-rw-r--r--sys/dev/softraid.c4
-rw-r--r--sys/dev/vnd.c8
-rw-r--r--sys/isofs/cd9660/cd9660_vfsops.c14
-rw-r--r--sys/isofs/udf/udf_subr.c10
-rw-r--r--sys/kern/subr_disk.c29
-rw-r--r--sys/scsi/cd.c6
-rw-r--r--sys/scsi/sd.c12
-rw-r--r--sys/sys/disklabel.h28
-rw-r--r--sys/uvm/uvm_vnode.c4
50 files changed, 668 insertions, 876 deletions
diff --git a/sys/arch/alpha/alpha/disksubr.c b/sys/arch/alpha/alpha/disksubr.c
index 1cd40476a04..479879eb215 100644
--- a/sys/arch/alpha/alpha/disksubr.c
+++ b/sys/arch/alpha/alpha/disksubr.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: disksubr.c,v 1.72 2007/06/02 02:35:26 krw Exp $ */
+/* $OpenBSD: disksubr.c,v 1.73 2007/06/05 00:38:12 deraadt Exp $ */
/* $NetBSD: disksubr.c,v 1.21 1996/05/03 19:42:03 christos Exp $ */
/*
@@ -139,20 +139,20 @@ readdisklabel(dev, strat, lp, osdep, 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);
minilabel = fallbacklabel = *lp;
/* get a buffer and initialize it */
@@ -284,9 +284,9 @@ readdoslabel(bp, strat, lp, osdep, partoffp, cylp, spoofonly)
cyl = DPCYL(dp2->dp_scyl, dp2->dp_ssect);
/* XXX build a temporary disklabel */
- lp->d_partitions[0].p_size = letoh32(dp2->dp_size);
- lp->d_partitions[0].p_offset =
- letoh32(dp2->dp_start) + part_blkno;
+ DL_SETPSIZE(&lp->d_partitions[0], letoh32(dp2->dp_size));
+ DL_SETPOFFSET(&lp->d_partitions[0],
+ letoh32(dp2->dp_start) + part_blkno);
if (lp->d_ntracks == 0)
lp->d_ntracks = dp2->dp_ehd + 1;
if (lp->d_nsectors == 0)
@@ -305,17 +305,17 @@ donot:
if (dp2->dp_typ == DOSPTYP_OPENBSD)
continue;
- if (letoh32(dp2->dp_size) > lp->d_secperunit)
+ if (letoh32(dp2->dp_size) > DL_GETDSIZE(lp))
continue;
- if (letoh32(dp2->dp_start) > lp->d_secperunit)
+ if (letoh32(dp2->dp_start) > DL_GETDSIZE(lp))
continue;
if (letoh32(dp2->dp_size) == 0)
continue;
if (letoh32(dp2->dp_start))
- pp->p_offset =
- letoh32(dp2->dp_start) + part_blkno;
+ DL_SETPOFFSET(pp,
+ letoh32(dp2->dp_start) + part_blkno);
- pp->p_size = letoh32(dp2->dp_size);
+ DL_SETPSIZE(pp, letoh32(dp2->dp_size));
switch (dp2->dp_typ) {
case DOSPTYP_UNUSED:
@@ -378,9 +378,9 @@ donot:
goto notfat;
/* Looks like a FAT filesystem. Spoof 'i'. */
- lp->d_partitions['i' - 'a'].p_size =
- lp->d_partitions[RAW_PART].p_size;
- lp->d_partitions['i' - 'a'].p_offset = 0;
+ DL_SETPSIZE(&lp->d_partitions['i' - 'a'],
+ DL_GETPSIZE(&lp->d_partitions[RAW_PART]));
+ DL_SETPOFFSET(&lp->d_partitions['i' - 'a'], 0);
lp->d_partitions['i' - 'a'].p_fstype = FS_MSDOS;
}
notfat:
@@ -442,8 +442,8 @@ setdisklabel(olp, nlp, openmask, osdep)
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);
/*
* Copy internally-set partition information
@@ -540,7 +540,7 @@ bounds_check_with_label(struct buf *bp, struct disklabel *lp,
{
#define blockpersec(count, lp) ((count) * (((lp)->d_secsize) / DEV_BSIZE))
struct partition *p = lp->d_partitions + DISKPART(bp->b_dev);
- int labelsector = blockpersec(lp->d_partitions[RAW_PART].p_offset, lp) +
+ int labelsector = blockpersec(DL_GETPOFFSET(&lp->d_partitions[RAW_PART]), lp) +
osdep->labelsector;
int sz = howmany(bp->b_bcount, DEV_BSIZE);
@@ -551,8 +551,8 @@ bounds_check_with_label(struct buf *bp, struct disklabel *lp,
}
/* 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;
@@ -568,15 +568,15 @@ bounds_check_with_label(struct buf *bp, struct disklabel *lp,
}
/* Overwriting disk label? */
- if (bp->b_blkno + blockpersec(p->p_offset, lp) <= labelsector &&
- bp->b_blkno + blockpersec(p->p_offset, lp) + sz > labelsector &&
+ if (bp->b_blkno + blockpersec(DL_GETPOFFSET(p), lp) <= labelsector &&
+ bp->b_blkno + blockpersec(DL_GETPOFFSET(p), lp) + sz > labelsector &&
(bp->b_flags & B_READ) == 0 && !wlabel) {
bp->b_error = EROFS;
goto bad;
}
/* 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);
diff --git a/sys/arch/amd64/amd64/disksubr.c b/sys/arch/amd64/amd64/disksubr.c
index b4d657de6c3..a0a19e0d6d8 100644
--- a/sys/arch/amd64/amd64/disksubr.c
+++ b/sys/arch/amd64/amd64/disksubr.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: disksubr.c,v 1.36 2007/06/02 02:35:26 krw Exp $ */
+/* $OpenBSD: disksubr.c,v 1.37 2007/06/05 00:38:13 deraadt Exp $ */
/* $NetBSD: disksubr.c,v 1.21 1996/05/03 19:42:03 christos Exp $ */
/*
@@ -85,20 +85,20 @@ readdisklabel(dev_t dev, void (*strat)(struct buf *), struct disklabel *lp,
/* 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);
/* Look for any BIOS geometry information we should honour. */
devno = chrtoblk(dev);
@@ -111,12 +111,12 @@ readdisklabel(dev_t dev, void (*strat)(struct buf *), struct disklabel *lp,
printf("Disk GEOM %u/%u/%u -> BIOS GEOM %u/%u/%u\n",
lp->d_ntracks, lp->d_nsectors, lp->d_ncylinders,
pdi->bios_heads, pdi->bios_sectors,
- lp->d_secperunit / (pdi->bios_heads * pdi->bios_sectors));
+ DL_GETDSIZE(lp) / (pdi->bios_heads * pdi->bios_sectors));
#endif
lp->d_ntracks = pdi->bios_heads;
lp->d_nsectors = pdi->bios_sectors;
lp->d_secpercyl = pdi->bios_sectors * pdi->bios_heads;
- lp->d_ncylinders = lp->d_secperunit / lp->d_secpercyl;
+ lp->d_ncylinders = DL_GETDSIZE(lp) / lp->d_secpercyl;
}
/* get a buffer and initialize it */
@@ -169,9 +169,9 @@ readdisklabel(dev_t dev, void (*strat)(struct buf *), struct disklabel *lp,
cyl = DPCYL(dp2->dp_scyl, dp2->dp_ssect);
/* XXX build a temporary disklabel */
- lp->d_partitions[0].p_size = letoh32(dp2->dp_size);
- lp->d_partitions[0].p_offset =
- letoh32(dp2->dp_start) + part_blkno;
+ DL_SETPSIZE(&lp->d_partitions[0], letoh32(dp2->dp_size));
+ DL_SETPOFFSET(&lp->d_partitions[0],
+ letoh32(dp2->dp_start) + part_blkno);
if (lp->d_ntracks == 0)
lp->d_ntracks = dp2->dp_ehd + 1;
if (lp->d_nsectors == 0)
@@ -190,17 +190,17 @@ donot:
if (dp2->dp_typ == DOSPTYP_OPENBSD)
continue;
- if (letoh32(dp2->dp_size) > lp->d_secperunit)
+ if (letoh32(dp2->dp_size) > DL_GETDSIZE(lp))
continue;
- if (letoh32(dp2->dp_start) > lp->d_secperunit)
+ if (letoh32(dp2->dp_start) > DL_GETDSIZE(lp))
continue;
if (letoh32(dp2->dp_size) == 0)
continue;
if (letoh32(dp2->dp_start))
- pp->p_offset =
- letoh32(dp2->dp_start) + part_blkno;
+ DL_SETPOFFSET(pp,
+ letoh32(dp2->dp_start) + part_blkno);
- pp->p_size = letoh32(dp2->dp_size);
+ DL_SETPSIZE(pp, letoh32(dp2->dp_size));
switch (dp2->dp_typ) {
case DOSPTYP_UNUSED:
@@ -262,9 +262,9 @@ donot:
goto notfat;
/* Looks like a FAT filesystem. Spoof 'i'. */
- lp->d_partitions['i' - 'a'].p_size =
- lp->d_partitions[RAW_PART].p_size;
- lp->d_partitions['i' - 'a'].p_offset = 0;
+ DL_SETPSIZE(&lp->d_partitions['i' - 'a'],
+ DL_GETPSIZE(&lp->d_partitions[RAW_PART]));
+ DL_SETPOFFSET(&lp->d_partitions['i' - 'a'], 0);
lp->d_partitions['i' - 'a'].p_fstype = FS_MSDOS;
}
notfat:
@@ -355,7 +355,8 @@ setdisklabel(struct disklabel *olp, struct disklabel *nlp, u_long openmask,
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);
/*
* Copy internally-set partition information
@@ -470,7 +471,7 @@ bounds_check_with_label(struct buf *bp, struct disklabel *lp,
{
#define blockpersec(count, lp) ((count) * (((lp)->d_secsize) / DEV_BSIZE))
struct partition *p = lp->d_partitions + DISKPART(bp->b_dev);
- int labelsector = blockpersec(lp->d_partitions[RAW_PART].p_offset, lp) +
+ int labelsector = blockpersec(DL_GETPOFFSET(&lp->d_partitions[RAW_PART]), lp) +
LABELSECTOR;
int sz = howmany(bp->b_bcount, DEV_BSIZE);
@@ -481,8 +482,8 @@ bounds_check_with_label(struct buf *bp, struct disklabel *lp,
}
/* 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;
@@ -498,9 +499,9 @@ bounds_check_with_label(struct buf *bp, struct disklabel *lp,
}
/* Overwriting disk label? */
- if (bp->b_blkno + blockpersec(p->p_offset, lp) <= labelsector &&
+ if (bp->b_blkno + blockpersec(DL_GETPOFFSET(p), lp) <= labelsector &&
#if LABELSECTOR != 0
- bp->b_blkno + blockpersec(p->p_offset, lp) + sz > labelsector &&
+ bp->b_blkno + blockpersec(DL_GETPOFFSET(p), lp) + sz > labelsector &&
#endif
(bp->b_flags & B_READ) == 0 && !wlabel) {
bp->b_error = EROFS;
@@ -508,7 +509,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);
diff --git a/sys/arch/arm/arm/disksubr.c b/sys/arch/arm/arm/disksubr.c
index 5657eb7489f..6fc8947caab 100644
--- a/sys/arch/arm/arm/disksubr.c
+++ b/sys/arch/arm/arm/disksubr.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: disksubr.c,v 1.31 2007/06/02 02:35:26 krw Exp $ */
+/* $OpenBSD: disksubr.c,v 1.32 2007/06/05 00:38:14 deraadt Exp $ */
/* $NetBSD: disksubr.c,v 1.21 1996/05/03 19:42:03 christos Exp $ */
/*
@@ -81,20 +81,20 @@ readdisklabel(dev, strat, lp, osdep, 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);
/* get a buffer and initialize it */
bp = geteblk((int)lp->d_secsize);
@@ -146,9 +146,9 @@ readdisklabel(dev, strat, lp, osdep, spoofonly)
cyl = DPCYL(dp2->dp_scyl, dp2->dp_ssect);
/* XXX build a temporary disklabel */
- lp->d_partitions[0].p_size = letoh32(dp2->dp_size);
- lp->d_partitions[0].p_offset =
- letoh32(dp2->dp_start) + part_blkno;
+ DL_SETPSIZE(&lp->d_partitions[0], letoh32(dp2->dp_size));
+ DL_SETPOFFSET(&lp->d_partitions[0],
+ letoh32(dp2->dp_start) + part_blkno);
if (lp->d_ntracks == 0)
lp->d_ntracks = dp2->dp_ehd + 1;
if (lp->d_nsectors == 0)
@@ -167,17 +167,17 @@ donot:
if (dp2->dp_typ == DOSPTYP_OPENBSD)
continue;
- if (letoh32(dp2->dp_size) > lp->d_secperunit)
+ if (letoh32(dp2->dp_size) > DL_GETDSIZE(lp))
continue;
- if (letoh32(dp2->dp_start) > lp->d_secperunit)
+ if (letoh32(dp2->dp_start) > DL_GETDSIZE(lp))
continue;
if (letoh32(dp2->dp_size) == 0)
continue;
if (letoh32(dp2->dp_start))
- pp->p_offset =
- letoh32(dp2->dp_start) + part_blkno;
+ DL_SETPOFFSET(pp,
+ letoh32(dp2->dp_start) + part_blkno);
- pp->p_size = letoh32(dp2->dp_size);
+ DL_SETPSIZE(pp, letoh32(dp2->dp_size));
switch (dp2->dp_typ) {
case DOSPTYP_UNUSED:
@@ -238,9 +238,9 @@ donot:
goto notfat;
/* Looks like a FAT filesystem. Spoof 'i'. */
- lp->d_partitions['i' - 'a'].p_size =
- lp->d_partitions[RAW_PART].p_size;
- lp->d_partitions['i' - 'a'].p_offset = 0;
+ DL_SETPSIZE(&lp->d_partitions['i' - 'a'],
+ DL_GETPSIZE(&lp->d_partitions[RAW_PART]));
+ DL_SETPOFFSET(&lp->d_partitions['i' - 'a'], 0);
lp->d_partitions['i' - 'a'].p_fstype = FS_MSDOS;
}
notfat:
@@ -333,7 +333,8 @@ setdisklabel(olp, nlp, openmask, osdep)
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);
/*
* Copy internally-set partition information
@@ -451,7 +452,7 @@ bounds_check_with_label(struct buf *bp, struct disklabel *lp,
{
#define blockpersec(count, lp) ((count) * (((lp)->d_secsize) / DEV_BSIZE))
struct partition *p = lp->d_partitions + DISKPART(bp->b_dev);
- int labelsector = blockpersec(lp->d_partitions[RAW_PART].p_offset, lp) +
+ int labelsector = blockpersec(DL_GETPOFFSET(&lp->d_partitions[RAW_PART]), lp) +
LABELSECTOR;
int sz = howmany(bp->b_bcount, DEV_BSIZE);
@@ -462,8 +463,8 @@ bounds_check_with_label(struct buf *bp, struct disklabel *lp,
}
/* 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;
@@ -479,9 +480,9 @@ bounds_check_with_label(struct buf *bp, struct disklabel *lp,
}
/* Overwriting disk label? */
- if (bp->b_blkno + blockpersec(p->p_offset, lp) <= labelsector &&
+ if (bp->b_blkno + blockpersec(DL_GETPOFFSET(p), lp) <= labelsector &&
#if LABELSECTOR != 0
- bp->b_blkno + blockpersec(p->p_offset, lp) + sz > labelsector &&
+ bp->b_blkno + blockpersec(DL_GETPOFFSET(p), lp) + sz > labelsector &&
#endif
(bp->b_flags & B_READ) == 0 && !wlabel) {
bp->b_error = EROFS;
@@ -489,7 +490,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);
diff --git a/sys/arch/aviion/aviion/disksubr.c b/sys/arch/aviion/aviion/disksubr.c
index 0f4e36e6b9c..625a03e3ee2 100644
--- a/sys/arch/aviion/aviion/disksubr.c
+++ b/sys/arch/aviion/aviion/disksubr.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: disksubr.c,v 1.22 2007/06/02 02:35:26 krw Exp $ */
+/* $OpenBSD: disksubr.c,v 1.23 2007/06/05 00:38:14 deraadt Exp $ */
/* $NetBSD: disksubr.c,v 1.21 1996/05/03 19:42:03 christos Exp $ */
/*
@@ -81,20 +81,20 @@ readdisklabel(dev, strat, lp, osdep, 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);
/* get a buffer and initialize it */
bp = geteblk((int)lp->d_secsize);
@@ -146,9 +146,9 @@ readdisklabel(dev, strat, lp, osdep, spoofonly)
cyl = DPCYL(dp2->dp_scyl, dp2->dp_ssect);
/* XXX build a temporary disklabel */
- lp->d_partitions[0].p_size = letoh32(dp2->dp_size);
- lp->d_partitions[0].p_offset =
- letoh32(dp2->dp_start) + part_blkno;
+ DL_SETPSIZE(&lp->d_partitions[0], letoh32(dp2->dp_size));
+ DL_SETPOFFSET(&lp->d_partitions[0],
+ letoh32(dp2->dp_start) + part_blkno);
if (lp->d_ntracks == 0)
lp->d_ntracks = dp2->dp_ehd + 1;
if (lp->d_nsectors == 0)
@@ -167,17 +167,17 @@ donot:
if (dp2->dp_typ == DOSPTYP_OPENBSD)
continue;
- if (letoh32(dp2->dp_size) > lp->d_secperunit)
+ if (letoh32(dp2->dp_size) > DL_GETDSIZE(lp))
continue;
- if (letoh32(dp2->dp_start) > lp->d_secperunit)
+ if (letoh32(dp2->dp_start) > DL_GETDSIZE(lp))
continue;
if (letoh32(dp2->dp_size) == 0)
continue;
if (letoh32(dp2->dp_start))
- pp->p_offset =
- letoh32(dp2->dp_start) + part_blkno;
+ DL_SETPOFFSET(pp,
+ letoh32(dp2->dp_start) + part_blkno);
- pp->p_size = letoh32(dp2->dp_size);
+ DL_SETPSIZE(pp, letoh32(dp2->dp_size));
switch (dp2->dp_typ) {
case DOSPTYP_UNUSED:
@@ -238,9 +238,9 @@ donot:
goto notfat;
/* Looks like a FAT filesystem. Spoof 'i'. */
- lp->d_partitions['i' - 'a'].p_size =
- lp->d_partitions[RAW_PART].p_size;
- lp->d_partitions['i' - 'a'].p_offset = 0;
+ DL_SETPSIZE(&lp->d_partitions['i' - 'a'],
+ DL_GETPSIZE(&lp->d_partitions[RAW_PART]));
+ DL_GETPOFFSET(&lp->d_partitions['i' - 'a'], 0);
lp->d_partitions['i' - 'a'].p_fstype = FS_MSDOS;
}
notfat:
@@ -333,7 +333,8 @@ setdisklabel(olp, nlp, openmask, osdep)
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);
/*
* Copy internally-set partition information
@@ -450,7 +451,7 @@ bounds_check_with_label(struct buf *bp, struct disklabel *lp,
{
#define blockpersec(count, lp) ((count) * (((lp)->d_secsize) / DEV_BSIZE))
struct partition *p = lp->d_partitions + DISKPART(bp->b_dev);
- int labelsector = blockpersec(lp->d_partitions[RAW_PART].p_offset, lp) +
+ int labelsector = blockpersec(DL_GETPOFFSET(&lp->d_partitions[RAW_PART], lp) +
LABELSECTOR;
int sz = howmany(bp->b_bcount, DEV_BSIZE);
@@ -461,8 +462,8 @@ bounds_check_with_label(struct buf *bp, struct disklabel *lp,
}
/* 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;
@@ -478,9 +479,9 @@ bounds_check_with_label(struct buf *bp, struct disklabel *lp,
}
/* Overwriting disk label? */
- if (bp->b_blkno + blockpersec(p->p_offset, lp) <= labelsector &&
+ if (bp->b_blkno + blockpersec(DL_GETPOFFSET(p), lp) <= labelsector &&
#if LABELSECTOR != 0
- bp->b_blkno + blockpersec(p->p_offset, lp) + sz > labelsector &&
+ bp->b_blkno + blockpersec(DL_GETPOFFSET(p), lp) + sz > labelsector &&
#endif
(bp->b_flags & B_READ) == 0 && !wlabel) {
bp->b_error = EROFS;
@@ -488,7 +489,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);
diff --git a/sys/arch/hp300/dev/hd.c b/sys/arch/hp300/dev/hd.c
index b6b27dac541..0113225da01 100644
--- a/sys/arch/hp300/dev/hd.c
+++ b/sys/arch/hp300/dev/hd.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: hd.c,v 1.47 2007/06/01 00:07:48 krw Exp $ */
+/* $OpenBSD: hd.c,v 1.48 2007/06/05 00:38:14 deraadt Exp $ */
/* $NetBSD: rd.c,v 1.33 1997/07/10 18:14:08 kleink Exp $ */
/*
@@ -509,7 +509,7 @@ hdgetdisklabel(dev, rs, lp, clp, spoofonly)
sizeof(lp->d_typename));
strncpy(lp->d_packname, "fictitious", sizeof lp->d_packname);
- lp->d_secperunit = hdidentinfo[rs->sc_type].ri_nblocks;
+ DL_SETDSIZE(lp, hdidentinfo[rs->sc_type].ri_nblocks);
lp->d_rpm = 3600;
lp->d_interleave = 1;
lp->d_flags = 0;
@@ -709,7 +709,7 @@ hdstrategy(bp)
* XXX bounds_check_with_label() has put in there.
*/
pinfo = &rs->sc_dkdev.dk_label->d_partitions[DISKPART(bp->b_dev)];
- bp->b_cylinder = bp->b_blkno + pinfo->p_offset;
+ bp->b_cylinder = bp->b_blkno + DL_GETPOFFSET(pinfo);
}
s = splbio();
@@ -1065,7 +1065,7 @@ hderror(unit)
* we just use b_blkno.
*/
bp = rs->sc_tab.b_actf;
- pbn = rs->sc_dkdev.dk_label->d_partitions[DISKPART(bp->b_dev)].p_offset;
+ pbn = DL_GETPOFFSET(&rs->sc_dkdev.dk_label->d_partitions[DISKPART(bp->b_dev)]);
if ((sp->c_fef & FEF_CU) || (sp->c_fef & FEF_DR) ||
(sp->c_ief & IEF_RRMASK)) {
hwbn = HDBTOS(pbn + bp->b_blkno);
@@ -1243,7 +1243,7 @@ hdsize(dev)
if (rs->sc_dkdev.dk_label->d_partitions[part].p_fstype != FS_SWAP)
size = -1;
else
- size = rs->sc_dkdev.dk_label->d_partitions[part].p_size *
+ size = DL_GETPSIZE(&rs->sc_dkdev.dk_label->d_partitions[part]) *
(rs->sc_dkdev.dk_label->d_secsize / DEV_BSIZE);
if (hdclose(dev, FREAD | FWRITE, S_IFBLK, NULL) != 0)
@@ -1326,8 +1326,8 @@ hddump(dev, blkno, va, size)
totwrt = size / sectorsize;
blkno = dbtob(blkno) / sectorsize; /* blkno in DEV_BSIZE units */
- nsects = lp->d_partitions[part].p_size;
- sectoff = lp->d_partitions[part].p_offset;
+ nsects = DL_GETPSIZE(&lp->d_partitions[part]);
+ sectoff = DL_GETPOFFSET(&lp->d_partitions[part]);
/* Check transfer bounds against partition size. */
if ((blkno < 0) || (blkno + totwrt) > nsects)
diff --git a/sys/arch/hp300/hp300/disksubr.c b/sys/arch/hp300/hp300/disksubr.c
index 2ef84441d2e..a4d6e45642c 100644
--- a/sys/arch/hp300/hp300/disksubr.c
+++ b/sys/arch/hp300/hp300/disksubr.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: disksubr.c,v 1.29 2007/06/02 02:35:26 krw Exp $ */
+/* $OpenBSD: disksubr.c,v 1.30 2007/06/05 00:38:15 deraadt Exp $ */
/* $NetBSD: disksubr.c,v 1.9 1997/04/01 03:12:13 scottr Exp $ */
/*
@@ -67,20 +67,20 @@ readdisklabel(dev, strat, lp, osdep, 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);
/* don't read the on-disk label if we are in spoofed-only mode */
if (spoofonly)
@@ -151,7 +151,8 @@ setdisklabel(olp, nlp, openmask, osdep)
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);
/*
* Copy internally-set partition information
@@ -185,8 +186,8 @@ writedisklabel(dev, strat, lp, osdep)
int error = 0;
labelpart = DISKPART(dev);
- if (lp->d_partitions[labelpart].p_offset != 0) {
- if (lp->d_partitions[0].p_offset != 0)
+ if (DL_GETPOFFSET(&lp->d_partitions[labelpart]) != 0) {
+ if (DL_GETPOFFSET(&lp->d_partitions[0]) != 0)
return (EXDEV); /* not quite right */
labelpart = 0;
}
@@ -233,7 +234,7 @@ bounds_check_with_label(struct buf *bp, struct disklabel *lp,
{
#define blockpersec(count, lp) ((count) * (((lp)->d_secsize) / DEV_BSIZE))
struct partition *p = lp->d_partitions + DISKPART(bp->b_dev);
- int labelsector = blockpersec(lp->d_partitions[0].p_offset, lp) +
+ int labelsector = blockpersec(DL_GETPOFFSET(&lp->d_partitions[0]), lp) +
LABELSECTOR;
int sz = howmany(bp->b_bcount, DEV_BSIZE);
@@ -244,15 +245,15 @@ bounds_check_with_label(struct buf *bp, struct disklabel *lp,
}
/* Overwriting disk label? */
- 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) {
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;
@@ -268,7 +269,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);
diff --git a/sys/arch/hppa/hppa/disksubr.c b/sys/arch/hppa/hppa/disksubr.c
index d0f40529112..09711c3afa4 100644
--- a/sys/arch/hppa/hppa/disksubr.c
+++ b/sys/arch/hppa/hppa/disksubr.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: disksubr.c,v 1.52 2007/06/02 02:35:26 krw Exp $ */
+/* $OpenBSD: disksubr.c,v 1.53 2007/06/05 00:38:15 deraadt Exp $ */
/*
* Copyright (c) 1999 Michael Shalayeff
@@ -143,20 +143,20 @@ readdisklabel(dev, strat, lp, osdep, 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);
minilabel = fallbacklabel = *lp;
/* get a buffer and initialize it */
@@ -287,9 +287,9 @@ readdoslabel(bp, strat, lp, osdep, partoffp, cylp, spoofonly)
cyl = DPCYL(dp2->dp_scyl, dp2->dp_ssect);
/* XXX build a temporary disklabel */
- lp->d_partitions[0].p_size = letoh32(dp2->dp_size);
- lp->d_partitions[0].p_offset =
- letoh32(dp2->dp_start) + part_blkno;
+ DL_SETPSIZE(&lp->d_partitions[0], letoh32(dp2->dp_size));
+ DL_SETPOFFSET(&lp->d_partitions[0],
+ letoh32(dp2->dp_start) + part_blkno);
if (lp->d_ntracks == 0)
lp->d_ntracks = dp2->dp_ehd + 1;
if (lp->d_nsectors == 0)
@@ -308,17 +308,17 @@ donot:
if (dp2->dp_typ == DOSPTYP_OPENBSD)
continue;
- if (letoh32(dp2->dp_size) > lp->d_secperunit)
+ if (letoh32(dp2->dp_size) > DL_GETDSIZE(lp))
continue;
- if (letoh32(dp2->dp_start) > lp->d_secperunit)
+ if (letoh32(dp2->dp_start) > DL_GETDSIZE(lp))
continue;
if (letoh32(dp2->dp_size) == 0)
continue;
if (letoh32(dp2->dp_start))
- pp->p_offset =
- letoh32(dp2->dp_start) + part_blkno;
+ DL_SETPOFFSET(pp,
+ letoh32(dp2->dp_start) + part_blkno);
- pp->p_size = letoh32(dp2->dp_size);
+ DL_SETPSIZE(pp, letoh32(dp2->dp_size));
switch (dp2->dp_typ) {
case DOSPTYP_UNUSED:
@@ -381,9 +381,9 @@ donot:
goto notfat;
/* Looks like a FAT filesystem. Spoof 'i'. */
- lp->d_partitions['i' - 'a'].p_size =
- lp->d_partitions[RAW_PART].p_size;
- lp->d_partitions['i' - 'a'].p_offset = 0;
+ DL_SETPSIZE(&lp->d_partitions['i' - 'a'],
+ DL_GETPSIZE(&lp->d_partitions[RAW_PART]));
+ DL_SETPOFFSET(&lp->d_partitions['i' - 'a'], 0);
lp->d_partitions['i' - 'a'].p_fstype = FS_MSDOS;
}
notfat:
@@ -512,8 +512,8 @@ readliflabel (bp, strat, lp, osdep, partoffp, cylp, spoofonly)
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;
+ DL_SETPSIZE(&lp->d_partitions[i], 0);
+ DL_SETPOFFSET(&lp->d_partitions[i], 0);
lp->d_partitions[i].p_fstype = 0;
}
@@ -533,13 +533,13 @@ readliflabel (bp, strat, lp, osdep, partoffp, cylp, spoofonly)
} else
continue;
- pp->p_size = hl->hl_parts[i].hlp_length * 2;
- pp->p_offset = hl->hl_parts[i].hlp_start * 2;
+ DL_SETPSIZE(pp, hl->hl_parts[i].hlp_length * 2);
+ DL_SETPOFFSET(pp, 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;
+ DL_SETPSIZE(&lp->d_partitions[RAW_PART], DL_GETDSIZE(lp));
+ DL_SETPOFFSET(&lp->d_partitions[RAW_PART], 0);
lp->d_partitions[RAW_PART].p_fstype = FS_UNUSED;
lp->d_npartitions = MAXPARTITIONS;
lp->d_magic = DISKMAGIC;
@@ -607,8 +607,8 @@ setdisklabel(olp, nlp, openmask, osdep)
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);
/*
* Copy internally-set partition information
@@ -694,7 +694,7 @@ bounds_check_with_label(struct buf *bp, struct disklabel *lp,
{
#define blockpersec(count, lp) ((count) * (((lp)->d_secsize) / DEV_BSIZE))
struct partition *p = lp->d_partitions + DISKPART(bp->b_dev);
- int labelsector = blockpersec(lp->d_partitions[RAW_PART].p_offset, lp) +
+ int labelsector = blockpersec(DL_GETPOFFSET(&lp->d_partitions[RAW_PART]), lp) +
osdep->labelsector;
int sz = howmany(bp->b_bcount, DEV_BSIZE);
@@ -705,8 +705,8 @@ bounds_check_with_label(struct buf *bp, struct disklabel *lp,
}
/* 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;
@@ -722,15 +722,15 @@ bounds_check_with_label(struct buf *bp, struct disklabel *lp,
}
/* Overwriting disk label? */
- if (bp->b_blkno + blockpersec(p->p_offset, lp) <= labelsector &&
- bp->b_blkno + blockpersec(p->p_offset, lp) + sz > labelsector &&
+ if (bp->b_blkno + blockpersec(DL_GETPOFFSET(p), lp) <= labelsector &&
+ bp->b_blkno + blockpersec(DL_GETPOFFSET(p), lp) + sz > labelsector &&
(bp->b_flags & B_READ) == 0 && !wlabel) {
bp->b_error = EROFS;
goto bad;
}
/* 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);
diff --git a/sys/arch/hppa64/hppa64/disksubr.c b/sys/arch/hppa64/hppa64/disksubr.c
index 86fdfac40cd..d5bb99c2c7f 100644
--- a/sys/arch/hppa64/hppa64/disksubr.c
+++ b/sys/arch/hppa64/hppa64/disksubr.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: disksubr.c,v 1.35 2007/06/02 02:35:26 krw Exp $ */
+/* $OpenBSD: disksubr.c,v 1.36 2007/06/05 00:38:15 deraadt Exp $ */
/*
* Copyright (c) 1999 Michael Shalayeff
@@ -143,20 +143,20 @@ readdisklabel(dev, strat, lp, osdep, 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);
minilabel = fallbacklabel = *lp;
/* get a buffer and initialize it */
@@ -283,9 +283,9 @@ readdoslabel(bp, strat, lp, osdep, partoffp, cylp, spoofonly)
cyl = DPCYL(dp2->dp_scyl, dp2->dp_ssect);
/* XXX build a temporary disklabel */
- lp->d_partitions[0].p_size = letoh32(dp2->dp_size);
- lp->d_partitions[0].p_offset =
- letoh32(dp2->dp_start) + part_blkno;
+ DL_SETPSIZE(&lp->d_partitions[0], letoh32(dp2->dp_size));
+ DL_SETPOFFSET(&lp->d_partitions[0],
+ letoh32(dp2->dp_start) + part_blkno);
if (lp->d_ntracks == 0)
lp->d_ntracks = dp2->dp_ehd + 1;
if (lp->d_nsectors == 0)
@@ -304,17 +304,17 @@ donot:
if (dp2->dp_typ == DOSPTYP_OPENBSD)
continue;
- if (letoh32(dp2->dp_size) > lp->d_secperunit)
+ if (letoh32(dp2->dp_size) > DL_GETDSIZE(lp))
continue;
- if (letoh32(dp2->dp_start) > lp->d_secperunit)
+ if (letoh32(dp2->dp_start) > DL_GETDSIZE(lp))
continue;
if (letoh32(dp2->dp_size) == 0)
continue;
if (letoh32(dp2->dp_start))
- pp->p_offset =
- letoh32(dp2->dp_start) + part_blkno;
+ DL_SETPOFFSET(pp,
+ letoh32(dp2->dp_start) + part_blkno);
- pp->p_size = letoh32(dp2->dp_size);
+ DL_SETPSIZE(pp, letoh32(dp2->dp_size));
switch (dp2->dp_typ) {
case DOSPTYP_UNUSED:
@@ -377,9 +377,9 @@ donot:
goto notfat;
/* Looks like a FAT filesystem. Spoof 'i'. */
- lp->d_partitions['i' - 'a'].p_size =
- lp->d_partitions[RAW_PART].p_size;
- lp->d_partitions['i' - 'a'].p_offset = 0;
+ DL_SETPSIZE(&lp->d_partitions['i' - 'a'],
+ DL_GETPSIZE(&lp->d_partitions[RAW_PART]));
+ DL_SETPOFFSET(&lp->d_partitions['i' - 'a'], 0);
lp->d_partitions['i' - 'a'].p_fstype = FS_MSDOS;
}
notfat:
@@ -508,8 +508,8 @@ readliflabel (bp, strat, lp, osdep, partoffp, cylp, spoofonly)
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;
+ DL_SETPSIZE(&lp->d_partitions[i], 0);
+ DL_SETPOFFSET(&lp->d_partitions[i], 0);
lp->d_partitions[i].p_fstype = 0;
}
@@ -529,13 +529,13 @@ readliflabel (bp, strat, lp, osdep, partoffp, cylp, spoofonly)
} else
continue;
- pp->p_size = hl->hl_parts[i].hlp_length * 2;
- pp->p_offset = hl->hl_parts[i].hlp_start * 2;
+ DL_SETPSIZE(pp, hl->hl_parts[i].hlp_length * 2);
+ DL_SETPOFFSET(pp, 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;
+ DL_SETPSIZE(&lp->d_partitions[RAW_PART], DL_GETDSIZE(lp));
+ DL_SETPOFFSET(&lp->d_partitions[RAW_PART], 0);
lp->d_partitions[RAW_PART].p_fstype = FS_UNUSED;
lp->d_npartitions = MAXPARTITIONS;
lp->d_magic = DISKMAGIC;
@@ -603,8 +603,8 @@ setdisklabel(olp, nlp, openmask, osdep)
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);
/*
* Copy internally-set partition information
@@ -690,7 +690,7 @@ bounds_check_with_label(struct buf *bp, struct disklabel *lp,
{
#define blockpersec(count, lp) ((count) * (((lp)->d_secsize) / DEV_BSIZE))
struct partition *p = lp->d_partitions + DISKPART(bp->b_dev);
- int labelsector = blockpersec(lp->d_partitions[RAW_PART].p_offset, lp) +
+ int labelsector = blockpersec(DL_GETPOFFSET(&lp->d_partitions[RAW_PART]), lp) +
osdep->labelsector;
int sz = howmany(bp->b_bcount, DEV_BSIZE);
@@ -701,8 +701,8 @@ bounds_check_with_label(struct buf *bp, struct disklabel *lp,
}
/* 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;
@@ -718,15 +718,15 @@ bounds_check_with_label(struct buf *bp, struct disklabel *lp,
}
/* Overwriting disk label? */
- if (bp->b_blkno + blockpersec(p->p_offset, lp) <= labelsector &&
- bp->b_blkno + blockpersec(p->p_offset, lp) + sz > labelsector &&
+ if (bp->b_blkno + blockpersec(DL_GETPOFFSET(p), lp) <= labelsector &&
+ bp->b_blkno + blockpersec(DL_GETPOFFSET(p), lp) + sz > labelsector &&
(bp->b_flags & B_READ) == 0 && !wlabel) {
bp->b_error = EROFS;
goto bad;
}
/* 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);
diff --git a/sys/arch/i386/i386/disksubr.c b/sys/arch/i386/i386/disksubr.c
index d62a6eff889..e233087352a 100644
--- a/sys/arch/i386/i386/disksubr.c
+++ b/sys/arch/i386/i386/disksubr.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: disksubr.c,v 1.76 2007/06/02 02:35:26 krw Exp $ */
+/* $OpenBSD: disksubr.c,v 1.77 2007/06/05 00:38:15 deraadt Exp $ */
/* $NetBSD: disksubr.c,v 1.21 1996/05/03 19:42:03 christos Exp $ */
/*
@@ -85,20 +85,20 @@ readdisklabel(dev_t dev, void (*strat)(struct buf *), struct disklabel *lp,
/* 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);
/* Look for any BIOS geometry information we should honour. */
devno = chrtoblk(dev);
@@ -111,12 +111,12 @@ readdisklabel(dev_t dev, void (*strat)(struct buf *), struct disklabel *lp,
printf("Disk GEOM %u/%u/%u -> BIOS GEOM %u/%u/%u\n",
lp->d_ntracks, lp->d_nsectors, lp->d_ncylinders,
pdi->bios_heads, pdi->bios_sectors,
- lp->d_secperunit / (pdi->bios_heads * pdi->bios_sectors));
+ DL_GETDSIZE(lp) / (pdi->bios_heads * pdi->bios_sectors));
#endif
lp->d_ntracks = pdi->bios_heads;
lp->d_nsectors = pdi->bios_sectors;
lp->d_secpercyl = pdi->bios_sectors * pdi->bios_heads;
- lp->d_ncylinders = lp->d_secperunit / lp->d_secpercyl;
+ lp->d_ncylinders = DL_GETDSIZE(lp) / lp->d_secpercyl;
}
/* get a buffer and initialize it */
@@ -169,9 +169,9 @@ readdisklabel(dev_t dev, void (*strat)(struct buf *), struct disklabel *lp,
cyl = DPCYL(dp2->dp_scyl, dp2->dp_ssect);
/* XXX build a temporary disklabel */
- lp->d_partitions[0].p_size = letoh32(dp2->dp_size);
- lp->d_partitions[0].p_offset =
- letoh32(dp2->dp_start) + part_blkno;
+ DL_SETPSIZE(&lp->d_partitions[0], letoh32(dp2->dp_size));
+ DL_SETPOFFSET(&lp->d_partitions[0],
+ letoh32(dp2->dp_start) + part_blkno);
if (lp->d_ntracks == 0)
lp->d_ntracks = dp2->dp_ehd + 1;
if (lp->d_nsectors == 0)
@@ -190,17 +190,17 @@ donot:
if (dp2->dp_typ == DOSPTYP_OPENBSD)
continue;
- if (letoh32(dp2->dp_size) > lp->d_secperunit)
+ if (letoh32(dp2->dp_size) > DL_GETDSIZE(lp))
continue;
- if (letoh32(dp2->dp_start) > lp->d_secperunit)
+ if (letoh32(dp2->dp_start) > DL_GETDSIZE(lp))
continue;
if (letoh32(dp2->dp_size) == 0)
continue;
if (letoh32(dp2->dp_start))
- pp->p_offset =
- letoh32(dp2->dp_start) + part_blkno;
+ DL_SETPOFFSET(pp,
+ letoh32(dp2->dp_start) + part_blkno);
- pp->p_size = letoh32(dp2->dp_size);
+ DL_SETPSIZE(pp, letoh32(dp2->dp_size));
switch (dp2->dp_typ) {
case DOSPTYP_UNUSED:
@@ -262,9 +262,9 @@ donot:
goto notfat;
/* Looks like a FAT filesystem. Spoof 'i'. */
- lp->d_partitions['i' - 'a'].p_size =
- lp->d_partitions[RAW_PART].p_size;
- lp->d_partitions['i' - 'a'].p_offset = 0;
+ DL_SETPSIZE(&lp->d_partitions['i' - 'a'],
+ DL_GETPSIZE(&lp->d_partitions[RAW_PART]));
+ DL_SETPOFFSET(&lp->d_partitions['i' - 'a'], 0);
lp->d_partitions['i' - 'a'].p_fstype = FS_MSDOS;
}
notfat:
@@ -355,7 +355,8 @@ setdisklabel(struct disklabel *olp, struct disklabel *nlp, u_long openmask,
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);
/*
* Copy internally-set partition information
@@ -470,7 +471,7 @@ bounds_check_with_label(struct buf *bp, struct disklabel *lp,
{
#define blockpersec(count, lp) ((count) * (((lp)->d_secsize) / DEV_BSIZE))
struct partition *p = lp->d_partitions + DISKPART(bp->b_dev);
- int labelsector = blockpersec(lp->d_partitions[RAW_PART].p_offset, lp) +
+ int labelsector = blockpersec(DL_GETPOFFSET(&lp->d_partitions[RAW_PART]), lp) +
LABELSECTOR;
int sz = howmany(bp->b_bcount, DEV_BSIZE);
@@ -481,8 +482,8 @@ bounds_check_with_label(struct buf *bp, struct disklabel *lp,
}
/* 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;
@@ -498,9 +499,9 @@ bounds_check_with_label(struct buf *bp, struct disklabel *lp,
}
/* Overwriting disk label? */
- if (bp->b_blkno + blockpersec(p->p_offset, lp) <= labelsector &&
+ if (bp->b_blkno + blockpersec(DL_GETPOFFSET(p), lp) <= labelsector &&
#if LABELSECTOR != 0
- bp->b_blkno + blockpersec(p->p_offset, lp) + sz > labelsector &&
+ bp->b_blkno + blockpersec(DL_GETPOFFSET(p), lp) + sz > labelsector &&
#endif
(bp->b_flags & B_READ) == 0 && !wlabel) {
bp->b_error = EROFS;
@@ -508,7 +509,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);
diff --git a/sys/arch/landisk/landisk/disksubr.c b/sys/arch/landisk/landisk/disksubr.c
index fd9e3b63bd8..9e88527ccee 100644
--- a/sys/arch/landisk/landisk/disksubr.c
+++ b/sys/arch/landisk/landisk/disksubr.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: disksubr.c,v 1.19 2007/06/02 02:35:27 krw Exp $ */
+/* $OpenBSD: disksubr.c,v 1.20 2007/06/05 00:38:16 deraadt Exp $ */
/* $NetBSD: disksubr.c,v 1.21 1996/05/03 19:42:03 christos Exp $ */
/*
@@ -81,20 +81,20 @@ readdisklabel(dev, strat, lp, osdep, 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_SETPSIZE(&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);
/* get a buffer and initialize it */
bp = geteblk((int)lp->d_secsize);
@@ -146,9 +146,9 @@ readdisklabel(dev, strat, lp, osdep, spoofonly)
cyl = DPCYL(dp2->dp_scyl, dp2->dp_ssect);
/* XXX build a temporary disklabel */
- lp->d_partitions[0].p_size = letoh32(dp2->dp_size);
- lp->d_partitions[0].p_offset =
- letoh32(dp2->dp_start) + part_blkno;
+ DL_SETPSIZE(&lp->d_partitions[0], letoh32(dp2->dp_size));
+ DL_SETPOFFSET(&lp->d_partitions[0],
+ letoh32(dp2->dp_start) + part_blkno);
if (lp->d_ntracks == 0)
lp->d_ntracks = dp2->dp_ehd + 1;
if (lp->d_nsectors == 0)
@@ -167,17 +167,17 @@ donot:
if (dp2->dp_typ == DOSPTYP_OPENBSD)
continue;
- if (letoh32(dp2->dp_size) > lp->d_secperunit)
+ if (letoh32(dp2->dp_size) > DL_GETDSIZE(lp))
continue;
- if (letoh32(dp2->dp_start) > lp->d_secperunit)
+ if (letoh32(dp2->dp_start) > DL_GETDSIZE(lp))
continue;
if (letoh32(dp2->dp_size) == 0)
continue;
if (letoh32(dp2->dp_start))
- pp->p_offset =
- letoh32(dp2->dp_start) + part_blkno;
+ DL_SETPOFFSET(pp,
+ letoh32(dp2->dp_start) + part_blkno);
- pp->p_size = letoh32(dp2->dp_size);
+ DL_SETPSIZE(pp, letoh32(dp2->dp_size));
switch (dp2->dp_typ) {
case DOSPTYP_UNUSED:
@@ -238,9 +238,9 @@ donot:
goto notfat;
/* Looks like a FAT filesystem. Spoof 'i'. */
- lp->d_partitions['i' - 'a'].p_size =
- lp->d_partitions[RAW_PART].p_size;
- lp->d_partitions['i' - 'a'].p_offset = 0;
+ DL_SETPSIZE(&lp->d_partitions['i' - 'a'],
+ DL_GETPSIZE(&lp->d_partitions[RAW_PART]));
+ DL_SETPOFFSET(&lp->d_partitions['i' - 'a'], 0);
lp->d_partitions['i' - 'a'].p_fstype = FS_MSDOS;
}
notfat:
@@ -333,7 +333,8 @@ setdisklabel(olp, nlp, openmask, osdep)
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);
/*
* Copy internally-set partition information
@@ -451,7 +452,7 @@ bounds_check_with_label(struct buf *bp, struct disklabel *lp,
{
#define blockpersec(count, lp) ((count) * (((lp)->d_secsize) / DEV_BSIZE))
struct partition *p = lp->d_partitions + DISKPART(bp->b_dev);
- int labelsector = blockpersec(lp->d_partitions[RAW_PART].p_offset, lp) +
+ int labelsector = blockpersec(DL_GETPOFFSET(&lp->d_partitions[RAW_PART]), lp) +
LABELSECTOR;
int sz = howmany(bp->b_bcount, DEV_BSIZE);
@@ -462,8 +463,8 @@ bounds_check_with_label(struct buf *bp, struct disklabel *lp,
}
/* 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;
@@ -479,9 +480,9 @@ bounds_check_with_label(struct buf *bp, struct disklabel *lp,
}
/* Overwriting disk label? */
- if (bp->b_blkno + blockpersec(p->p_offset, lp) <= labelsector &&
+ if (bp->b_blkno + blockpersec(DL_GETPOFFSET(p), lp) <= labelsector &&
#if LABELSECTOR != 0
- bp->b_blkno + blockpersec(p->p_offset, lp) + sz > labelsector &&
+ bp->b_blkno + blockpersec(DL_GETPOFFSET(p), lp) + sz > labelsector &&
#endif
(bp->b_flags & B_READ) == 0 && !wlabel) {
bp->b_error = EROFS;
@@ -489,7 +490,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);
diff --git a/sys/arch/luna88k/luna88k/disksubr.c b/sys/arch/luna88k/luna88k/disksubr.c
index a2716c6d976..c0516604eed 100644
--- a/sys/arch/luna88k/luna88k/disksubr.c
+++ b/sys/arch/luna88k/luna88k/disksubr.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: disksubr.c,v 1.14 2007/06/02 02:35:27 krw Exp $ */
+/* $OpenBSD: disksubr.c,v 1.15 2007/06/05 00:38:16 deraadt Exp $ */
/* $NetBSD: disksubr.c,v 1.12 2002/02/19 17:09:44 wiz Exp $ */
/*
@@ -128,20 +128,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);
/* don't read the on-disk label if we are in spoofed-only mode */
if (spoofonly)
@@ -249,8 +249,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);
}
@@ -322,15 +322,15 @@ bounds_check_with_label(struct buf *bp, struct disklabel *lp,
/* overwriting disk label ? */
/* 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;
@@ -346,7 +346,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);
@@ -417,7 +417,7 @@ disklabel_om_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_sparespercyl = 0; /* no way to know */
lp->d_acylinders = sl->sl_acylinders;
@@ -436,9 +436,9 @@ disklabel_om_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 {
/* Partition has non-zero size. Set type, etc. */
@@ -464,7 +464,7 @@ disklabel_om_to_bsd(cp, lp)
* UniOS rootfs sits on part c which don't begin at sect 0,
* and impossible to mount. Thus, make it usable as part b.
*/
- if (sl->sl_rpm == 0 && lp->d_partitions[2].p_offset != 0) {
+ if (sl->sl_rpm == 0 && DL_GETPOFFSET(&lp->d_partitions[2]) != 0) {
lp->d_partitions[1] = lp->d_partitions[2];
lp->d_partitions[1].p_fstype = FS_BSDFFS;
}
@@ -513,8 +513,8 @@ disklabel_bsd_to_om(lp, cp)
spp = &sl->sl_part[i];
npp = &lp->d_partitions[i];
- spp->sdkp_cyloffset = npp->p_offset; /* UniOS */
- spp->sdkp_nsectors = npp->p_size;
+ spp->sdkp_cyloffset = DL_GETPOFFSET(npp); /* UniOS */
+ spp->sdkp_nsectors = DL_GETPSIZE(npp);
}
sl->sl_magic = SUN_DKMAGIC;
diff --git a/sys/arch/mac68k/mac68k/disksubr.c b/sys/arch/mac68k/mac68k/disksubr.c
index e25f4512f81..a1b6cb6a606 100644
--- a/sys/arch/mac68k/mac68k/disksubr.c
+++ b/sys/arch/mac68k/mac68k/disksubr.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: disksubr.c,v 1.37 2007/06/02 02:35:27 krw Exp $ */
+/* $OpenBSD: disksubr.c,v 1.38 2007/06/05 00:38:16 deraadt Exp $ */
/* $NetBSD: disksubr.c,v 1.22 1997/11/26 04:18:20 briggs Exp $ */
/*
@@ -210,8 +210,8 @@ fixPartTable(partTable, size, base)
void
setPart(struct partmapentry *part, struct disklabel *lp, int fstype, int slot)
{
- lp->d_partitions[slot].p_size = part->pmPartBlkCnt;
- lp->d_partitions[slot].p_offset = part->pmPyPartStart;
+ DL_SETPSIZE(&lp->d_partitions[slot], part->pmPartBlkCnt);
+ DL_SETPOFFSET(&lp->d_partitions[slot], part->pmPyPartStart);
lp->d_partitions[slot].p_fstype = fstype;
part->pmPartType[0] = '\0';
}
@@ -372,20 +372,20 @@ readdisklabel(dev, strat, lp, osdep, 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);
/* don't read the on-disk label if we are in spoofed-only mode */
if (spoofonly)
@@ -474,7 +474,8 @@ setdisklabel(olp, nlp, openmask, osdep)
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);
/*
* Copy internally-set partition information
@@ -512,8 +513,8 @@ writedisklabel(dev, strat, lp, osdep)
u_int16_t *sbSigp;
labelpart = DISKPART(dev);
- if (lp->d_partitions[labelpart].p_offset != 0) {
- if (lp->d_partitions[0].p_offset != 0)
+ if (DL_GETPOFFSET(&lp->d_partitions[labelpart]) != 0) {
+ if (DL_GETPOFFSET(&lp->d_partitions[0]) != 0)
return (EXDEV); /* not quite right */
labelpart = 0;
}
@@ -563,7 +564,7 @@ bounds_check_with_label(struct buf *bp, struct disklabel *lp,
{
#define blockpersec(count, lp) ((count) * (((lp)->d_secsize) / DEV_BSIZE))
struct partition *p = lp->d_partitions + DISKPART(bp->b_dev);
- int labelsector = blockpersec(lp->d_partitions[RAW_PART].p_offset, lp) +
+ int labelsector = blockpersec(DL_GETPOFFSET(&lp->d_partitions[RAW_PART]), lp) +
LABELSECTOR;
int sz = howmany(bp->b_bcount, DEV_BSIZE);
@@ -574,8 +575,8 @@ bounds_check_with_label(struct buf *bp, struct disklabel *lp,
}
/* 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;
@@ -592,9 +593,9 @@ bounds_check_with_label(struct buf *bp, struct disklabel *lp,
/* overwriting disk label ? */
/* XXX should also protect bootstrap in first 8K */
- if (bp->b_blkno + blockpersec(p->p_offset, lp) <= labelsector &&
+ if (bp->b_blkno + blockpersec(DL_GETPOFFSET(p), lp) <= labelsector &&
#if LABELSECTOR != 0
- bp->b_blkno + blockpersec(p->p_offset, lp) + sz > labelsector &&
+ bp->b_blkno + blockpersec(DL_GETPOFFSET(p), lp) + sz > labelsector &&
#endif /* LABELSECTOR != 0 */
(bp->b_flags & B_READ) == 0 && wlabel == 0) {
bp->b_error = EROFS;
@@ -602,7 +603,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);
diff --git a/sys/arch/macppc/macppc/disksubr.c b/sys/arch/macppc/macppc/disksubr.c
index c0e2beae511..92320bff4e8 100644
--- a/sys/arch/macppc/macppc/disksubr.c
+++ b/sys/arch/macppc/macppc/disksubr.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: disksubr.c,v 1.41 2007/06/02 02:35:27 krw Exp $ */
+/* $OpenBSD: disksubr.c,v 1.42 2007/06/05 00:38:17 deraadt Exp $ */
/* $NetBSD: disksubr.c,v 1.21 1996/05/03 19:42:03 christos Exp $ */
/*
@@ -85,20 +85,20 @@ readdisklabel(dev_t dev, void (*strat)(struct buf *),
/* 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);
/* get a buffer and initialize it */
bp = geteblk((int)lp->d_secsize);
@@ -152,8 +152,8 @@ readdisklabel(dev_t dev, void (*strat)(struct buf *),
}
/* currently we ignore all but HFS partitions */
if (strcmp(part->pmPartType, PART_TYPE_MAC) == 0) {
- pp->p_offset = part->pmPyPartStart;
- pp->p_size = part->pmPartBlkCnt;
+ DL_SETPOFFSET(pp, part->pmPyPartStart);
+ DL_SETPSIZE(pp, part->pmPartBlkCnt);
pp->p_fstype = FS_HFS;
n++;
}
@@ -231,10 +231,9 @@ hfs_done:
cyl = DPCYL(dp2->dp_scyl, dp2->dp_ssect);
/* XXX build a temporary disklabel */
- lp->d_partitions[0].p_size =
- letoh32(dp2->dp_size);
- lp->d_partitions[0].p_offset =
- letoh32(dp2->dp_start) + part_blkno;
+ DL_SETPSIZE(&lp->d_partitions[0], letoh32(dp2->dp_size));
+ DL_SETPOFFSET(&lp->d_partitions[0],
+ letoh32(dp2->dp_start) + part_blkno);
if (lp->d_ntracks == 0)
lp->d_ntracks = dp2->dp_ehd + 1;
if (lp->d_nsectors == 0)
@@ -253,17 +252,17 @@ donot:
if (dp2->dp_typ == DOSPTYP_OPENBSD)
continue;
- if (letoh32(dp2->dp_size) > lp->d_secperunit)
+ if (letoh32(dp2->dp_size) > DL_GETDSIZE(lp))
continue;
- if (letoh32(dp2->dp_start) > lp->d_secperunit)
+ if (letoh32(dp2->dp_start) > DL_GETDSIZE(lp))
continue;
if (letoh32(dp2->dp_size) == 0)
continue;
if (letoh32(dp2->dp_start))
- pp->p_offset =
- letoh32(dp2->dp_start) + part_blkno;
+ DL_SETPOFFSET(pp,
+ letoh32(dp2->dp_start) + part_blkno);
- pp->p_size = letoh32(dp2->dp_size);
+ DL_SETPSIZE(pp, letoh32(dp2->dp_size));
switch (dp2->dp_typ) {
case DOSPTYP_UNUSED:
@@ -324,9 +323,9 @@ donot:
goto notfat;
/* Looks like a FAT filesystem. Spoof 'i'. */
- lp->d_partitions['i' - 'a'].p_size =
- lp->d_partitions[RAW_PART].p_size;
- lp->d_partitions['i' - 'a'].p_offset = 0;
+ DL_SETPSIZE(&lp->d_partitions['i' - 'a'],
+ DL_GETPSIZE(&lp->d_partitions[RAW_PART]));
+ DL_SETPOFFSET(&lp->d_partitions['i' - 'a'], 0);
lp->d_partitions['i' - 'a'].p_fstype = FS_MSDOS;
}
notfat:
@@ -420,7 +419,8 @@ setdisklabel(struct disklabel *olp, struct disklabel *nlp, u_long openmask,
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);
/*
* Copy internally-set partition information
@@ -557,7 +557,7 @@ bounds_check_with_label(struct buf *bp, struct disklabel *lp,
{
#define blockpersec(count, lp) ((count) * (((lp)->d_secsize) / DEV_BSIZE))
struct partition *p = lp->d_partitions + DISKPART(bp->b_dev);
- int labelsector = blockpersec(lp->d_partitions[RAW_PART].p_offset, lp) +
+ int labelsector = blockpersec(DL_GETPOFFSET(&lp->d_partitions[RAW_PART]), lp) +
LABELSECTOR;
int sz = howmany(bp->b_bcount, DEV_BSIZE);
@@ -568,8 +568,8 @@ bounds_check_with_label(struct buf *bp, struct disklabel *lp,
}
/* 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;
@@ -585,9 +585,9 @@ bounds_check_with_label(struct buf *bp, struct disklabel *lp,
}
/* Overwriting disk label? */
- if (bp->b_blkno + blockpersec(p->p_offset, lp) <= labelsector &&
+ if (bp->b_blkno + blockpersec(DL_GETPOFFSET(p), lp) <= labelsector &&
#if LABELSECTOR != 0
- bp->b_blkno + blockpersec(p->p_offset, lp) + sz > labelsector &&
+ bp->b_blkno + blockpersec(DL_GETPOFFSET(p), lp) + sz > labelsector &&
#endif
(bp->b_flags & B_READ) == 0 && !wlabel) {
bp->b_error = EROFS;
@@ -595,7 +595,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);
diff --git a/sys/arch/mips64/mips64/disksubr.c b/sys/arch/mips64/mips64/disksubr.c
index 6ddae6e36f0..e24069bb02b 100644
--- a/sys/arch/mips64/mips64/disksubr.c
+++ b/sys/arch/mips64/mips64/disksubr.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: disksubr.c,v 1.41 2007/06/02 02:35:27 krw Exp $ */
+/* $OpenBSD: disksubr.c,v 1.42 2007/06/05 00:38:17 deraadt Exp $ */
/*
* Copyright (c) 1999 Michael Shalayeff
@@ -144,20 +144,20 @@ readdisklabel(dev, strat, lp, osdep, 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);
minilabel = fallbacklabel = *lp;
/* get a buffer and initialize it */
@@ -291,9 +291,9 @@ readdoslabel(bp, strat, lp, osdep, partoffp, cylp, spoofonly)
cyl = DPCYL(dp2->dp_scyl, dp2->dp_ssect);
/* XXX build a temporary disklabel */
- lp->d_partitions[0].p_size = letoh32(dp2->dp_size);
- lp->d_partitions[0].p_offset =
- letoh32(dp2->dp_start) + part_blkno;
+ DL_SETPSIZE(&lp->d_partitions[0], letoh32(dp2->dp_size));
+ DL_SETPOFFSET(&lp->d_partitions[0],
+ letoh32(dp2->dp_start) + part_blkno);
if (lp->d_ntracks == 0)
lp->d_ntracks = dp2->dp_ehd + 1;
if (lp->d_nsectors == 0)
@@ -312,17 +312,17 @@ donot:
if (dp2->dp_typ == DOSPTYP_OPENBSD)
continue;
- if (letoh32(dp2->dp_size) > lp->d_secperunit)
+ if (letoh32(dp2->dp_size) > DL_GETDSIZE(lp))
continue;
- if (letoh32(dp2->dp_start) > lp->d_secperunit)
+ if (letoh32(dp2->dp_start) > DL_GETDSIZE(lp))
continue;
if (letoh32(dp2->dp_size) == 0)
continue;
if (letoh32(dp2->dp_start))
- pp->p_offset =
- letoh32(dp2->dp_start) + part_blkno;
+ DL_SETPOFFSET(pp,
+ letoh32(dp2->dp_start) + part_blkno);
- pp->p_size = letoh32(dp2->dp_size);
+ DL_GETPSIZE(pp, letoh32(dp2->dp_size));
switch (dp2->dp_typ) {
case DOSPTYP_UNUSED:
@@ -385,9 +385,9 @@ donot:
goto notfat;
/* Looks like a FAT filesystem. Spoof 'i'. */
- lp->d_partitions['i' - 'a'].p_size =
- lp->d_partitions[RAW_PART].p_size;
- lp->d_partitions['i' - 'a'].p_offset = 0;
+ DL_SETPSIZE(&lp->d_partitions['i' - 'a'],
+ DL_GETPSIZE(&lp->d_partitions[RAW_PART]));
+ DL_SETPOFFSET(&lp->d_partitions['i' - 'a'], 0);
lp->d_partitions['i' - 'a'].p_fstype = FS_MSDOS;
}
notfat:
@@ -498,8 +498,10 @@ static struct {int m; int b;} maptab[] = {
for (i = 0; i < 16; i++) {
int bsd = maptab[i].m;
- lp->d_partitions[bsd].p_offset = dlp->partitions[i].first;
- lp->d_partitions[bsd].p_size = dlp->partitions[i].blocks;
+ DL_SETPOFFSET(&lp->d_partitions[bsd],
+ dlp->partitions[i].first);
+ DL_SETPSIZE(&lp->d_partitions[bsd],
+ dlp->partitions[i].blocks);
lp->d_partitions[bsd].p_fstype = maptab[i].b;
if (lp->d_partitions[bsd].p_fstype == FS_BSDFFS) {
lp->d_partitions[bsd].p_fragblock =
@@ -553,8 +555,8 @@ setdisklabel(olp, nlp, openmask, osdep)
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);
/*
* Copy internally-set partition information
@@ -640,7 +642,7 @@ bounds_check_with_label(struct buf *bp, struct disklabel *lp,
{
#define blockpersec(count, lp) ((count) * (((lp)->d_secsize) / DEV_BSIZE))
struct partition *p = lp->d_partitions + DISKPART(bp->b_dev);
- int labelsector = blockpersec(lp->d_partitions[RAW_PART].p_offset, lp) +
+ int labelsector = blockpersec(DL_GETPOFFSET(&lp->d_partitions[RAW_PART]), lp) +
osdep->labelsector;
int sz = howmany(bp->b_bcount, DEV_BSIZE);
@@ -651,8 +653,8 @@ bounds_check_with_label(struct buf *bp, struct disklabel *lp,
}
/* 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;
@@ -668,15 +670,15 @@ bounds_check_with_label(struct buf *bp, struct disklabel *lp,
}
/* Overwriting disk label? */
- if (bp->b_blkno + blockpersec(p->p_offset, lp) <= labelsector &&
- bp->b_blkno + blockpersec(p->p_offset, lp) + sz > labelsector &&
+ if (bp->b_blkno + blockpersec(DL_GETPOFFSET(p), lp) <= labelsector &&
+ bp->b_blkno + blockpersec(DL_GETPOFFSET(p), lp) + sz > labelsector &&
(bp->b_flags & B_READ) == 0 && !wlabel) {
bp->b_error = EROFS;
goto bad;
}
/* 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);
diff --git a/sys/arch/mvme68k/mvme68k/disksubr.c b/sys/arch/mvme68k/mvme68k/disksubr.c
index fc48b2eebcb..be1748bb260 100644
--- a/sys/arch/mvme68k/mvme68k/disksubr.c
+++ b/sys/arch/mvme68k/mvme68k/disksubr.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: disksubr.c,v 1.42 2007/06/02 02:35:27 krw Exp $ */
+/* $OpenBSD: disksubr.c,v 1.43 2007/06/05 00:38:17 deraadt Exp $ */
/*
* Copyright (c) 1998 Steve Murphree, Jr.
* Copyright (c) 1995 Dale Rahn.
@@ -34,20 +34,11 @@
#include <sys/disklabel.h>
#include <sys/disk.h>
-#ifdef DEBUG
-int disksubr_debug = 0;
-#endif
-
static void bsdtocpulabel(struct disklabel *lp,
struct cpu_disklabel *clp);
static void cputobsdlabel(struct disklabel *lp,
struct cpu_disklabel *clp);
-#ifdef DEBUG
-static void printlp(struct disklabel *lp, char *str);
-static void printclp(struct cpu_disklabel *clp, char *str);
-#endif
-
/*
* Attempt to read a disk label from a device
* using the indicated strategy routine.
@@ -72,20 +63,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);
/* don't read the on-disk label if we are in spoofed-only mode */
if (spoofonly)
@@ -136,12 +127,6 @@ readdisklabel(dev, strat, lp, clp, spoofonly)
goto done;
}
-#ifdef DEBUG
- if (disksubr_debug > 0) {
- printlp(lp, "readdisklabel:bsd label");
- printclp(clp, "readdisklabel:cpu label");
- }
-#endif
done:
if (bp) {
bp->b_flags = B_INVAL | B_AGE | B_READ;
@@ -164,15 +149,6 @@ setdisklabel(olp, nlp, openmask, clp)
int i;
struct partition *opp, *npp;
-#ifdef DEBUG
- if(disksubr_debug > 0) {
- printlp(nlp, "setdisklabel:new disklabel");
- printlp(olp, "setdisklabel:old disklabel");
- printclp(clp, "setdisklabel:cpu disklabel");
- }
-#endif
-
-
/* sanity clause */
if (nlp->d_secpercyl == 0 || nlp->d_secsize == 0 ||
(nlp->d_secsize % DEV_BSIZE) != 0)
@@ -195,7 +171,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);
/*
* Copy internally-set partition information
@@ -211,11 +188,6 @@ setdisklabel(olp, nlp, openmask, clp)
nlp->d_checksum = 0;
nlp->d_checksum = dkcksum(nlp);
*olp = *nlp;
-#ifdef DEBUG
- if(disksubr_debug > 0) {
- printlp(olp, "setdisklabel:old->new disklabel");
- }
-#endif
return (0);
}
@@ -232,12 +204,6 @@ writedisklabel(dev, strat, lp, clp)
struct buf *bp;
int error;
-#ifdef DEBUG
- if(disksubr_debug > 0) {
- printlp(lp, "writedisklabel: bsd label");
- }
-#endif
-
/* obtain buffer to read initial cpu_disklabel, for bootloader size :-) */
bp = geteblk((int)lp->d_secsize);
@@ -264,12 +230,6 @@ writedisklabel(dev, strat, lp, clp)
bsdtocpulabel(lp, clp);
-#ifdef DEBUG
- if (disksubr_debug > 0) {
- printclp(clp, "writedisklabel: cpu label");
- }
-#endif
-
if (lp->d_magic == DISKMAGIC && lp->d_magic2 == DISKMAGIC &&
dkcksum(lp) == 0) {
/* obtain buffer to scrozz drive with */
@@ -300,7 +260,7 @@ bounds_check_with_label(struct buf *bp, struct disklabel *lp,
{
#define blockpersec(count, lp) ((count) * (((lp)->d_secsize) / DEV_BSIZE))
struct partition *p = lp->d_partitions + DISKPART(bp->b_dev);
- int labelsector = blockpersec(lp->d_partitions[0].p_offset, lp) +
+ int labelsector = blockpersec(DL_GETPOFFSET(&lp->d_partitions[0]), lp) +
LABELSECTOR;
int sz = howmany(bp->b_bcount, DEV_BSIZE);
@@ -312,9 +272,9 @@ bounds_check_with_label(struct buf *bp, struct disklabel *lp,
/* overwriting disk label ? */
/* XXX should also protect bootstrap in first 8K */
- if (bp->b_blkno + blockpersec(p->p_offset, lp) <= labelsector &&
+ if (bp->b_blkno + blockpersec(DL_GETPOFFSET(p), lp) <= labelsector &&
#if LABELSECTOR != 0
- bp->b_blkno + blockpersec(p->p_offset, lp) + sz > labelsector &&
+ bp->b_blkno + blockpersec(DL_GETPOFFSET(p), lp) + sz > labelsector &&
#endif
(bp->b_flags & B_READ) == 0 && wlabel == 0) {
bp->b_error = EROFS;
@@ -322,8 +282,8 @@ bounds_check_with_label(struct buf *bp, struct disklabel *lp,
}
/* 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;
@@ -339,7 +299,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);
@@ -370,7 +330,7 @@ bsdtocpulabel(lp, clp)
clp->cfg_hds = lp->d_ntracks;
clp->secpercyl = lp->d_secpercyl;
- clp->secperunit = lp->d_secperunit;
+ clp->secperunit = DL_GETDSIZE(lp);
clp->sparespertrack = lp->d_sparespertrack;
clp->sparespercyl = lp->d_sparespercyl;
clp->acylinders = lp->d_acylinders;
@@ -506,11 +466,6 @@ cputobsdlabel(lp, clp)
int i;
if (clp->version == 0) {
-#ifdef DEBUG
- if (disksubr_debug > 0) {
- printf("Reading old disklabel\n");
- }
-#endif
lp->d_magic = clp->magic1;
lp->d_type = clp->type;
lp->d_subtype = clp->subtype;
@@ -522,9 +477,7 @@ cputobsdlabel(lp, clp)
lp->d_ntracks = clp->cfg_hds;
lp->d_secpercyl = clp->secpercyl;
- lp->d_secperunit = clp->secperunit;
- lp->d_secpercyl = clp->secpercyl;
- lp->d_secperunit = clp->secperunit;
+ DL_SETDSIZE(lp, clp->secperunit);
lp->d_sparespertrack = clp->sparespertrack;
lp->d_sparespercyl = clp->sparespercyl;
lp->d_acylinders = clp->acylinders;
@@ -570,11 +523,6 @@ cputobsdlabel(lp, clp)
lp->d_checksum = 0;
lp->d_checksum = dkcksum(lp);
} else {
-#ifdef DEBUG
- if (disksubr_debug > 0) {
- printf("Reading new disklabel\n");
- }
-#endif
lp->d_magic = clp->magic1;
lp->d_type = clp->type;
lp->d_subtype = clp->subtype;
@@ -586,9 +534,7 @@ cputobsdlabel(lp, clp)
lp->d_ntracks = clp->cfg_hds;
lp->d_secpercyl = clp->secpercyl;
- lp->d_secperunit = clp->secperunit;
- lp->d_secpercyl = clp->secpercyl;
- lp->d_secperunit = clp->secperunit;
+ DL_SETDSIZE(lp, clp->secperunit);
lp->d_sparespertrack = clp->sparespertrack;
lp->d_sparespercyl = clp->sparespercyl;
lp->d_acylinders = clp->acylinders;
@@ -634,70 +580,4 @@ cputobsdlabel(lp, clp)
lp->d_checksum = 0;
lp->d_checksum = dkcksum(lp);
}
-#if DEBUG
- if (disksubr_debug > 0) {
- printlp(lp, "translated label read from disk\n");
- }
-#endif
}
-
-#ifdef DEBUG
-static void
-printlp(lp, str)
- struct disklabel *lp;
- char *str;
-{
- int i;
-
- printf("%s\n", str);
- printf("magic1 %x\n", lp->d_magic);
- printf("magic2 %x\n", lp->d_magic2);
- printf("typename %s\n", lp->d_typename);
- printf("secsize %x nsect %x ntrack %x ncylinders %x\n",
- lp->d_secsize, lp->d_nsectors, lp->d_ntracks, lp->d_ncylinders);
- printf("Num partitions %x\n", lp->d_npartitions);
- for (i = 0; i < lp->d_npartitions; i++) {
- struct partition *part = &lp->d_partitions[i];
- char *fstyp = fstypenames[part->p_fstype];
-
- printf("%c: size %10x offset %10x type %7s frag %5x cpg %3x\n",
- 'a' + i, part->p_size, part->p_offset, fstyp,
- part->p_frag, part->p_cpg);
- }
-}
-
-static void
-printclp(clp, str)
- struct cpu_disklabel *clp;
- char *str;
-{
- int max, i;
-
- printf("%s\n", str);
- printf("magic1 %x\n", clp->magic1);
- printf("magic2 %x\n", clp->magic2);
- printf("typename %s\n", clp->vid_vd);
- printf("secsize %x nsect %x ntrack %x ncylinders %x\n",
- clp->cfg_psm, clp->cfg_spt, clp->cfg_hds, clp->cfg_trk);
- printf("Num partitions %x\n", clp->partitions);
- max = clp->partitions < 16 ? clp->partitions : 16;
- for (i = 0; i < max; i++) {
- struct partition *part;
- char *fstyp;
-
- if (i < 4) {
- part = (void *)&clp->vid_4[0];
- part = &part[i];
- } else {
- part = (void *)&clp->cfg_4[0];
- part = &part[i-4];
- }
-
- fstyp = fstypenames[part->p_fstype];
-
- printf("%c: size %10x offset %10x type %7s frag %5x cpg %3x\n",
- 'a' + i, part->p_size, part->p_offset, fstyp,
- part->p_frag, part->p_cpg);
- }
-}
-#endif
diff --git a/sys/arch/mvme88k/mvme88k/disksubr.c b/sys/arch/mvme88k/mvme88k/disksubr.c
index 34169dfd5cc..21cebb280b7 100644
--- a/sys/arch/mvme88k/mvme88k/disksubr.c
+++ b/sys/arch/mvme88k/mvme88k/disksubr.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: disksubr.c,v 1.38 2007/06/02 02:35:27 krw Exp $ */
+/* $OpenBSD: disksubr.c,v 1.39 2007/06/05 00:38:17 deraadt Exp $ */
/*
* Copyright (c) 1998 Steve Murphree, Jr.
* Copyright (c) 1995 Dale Rahn.
@@ -34,18 +34,9 @@
#include <sys/disklabel.h>
#include <sys/disk.h>
-#ifdef DEBUG
-int disksubr_debug;
-#endif
-
void bsdtocpulabel(struct disklabel *, struct cpu_disklabel *);
void cputobsdlabel(struct disklabel *, struct cpu_disklabel *);
-#ifdef DEBUG
-void printlp(struct disklabel *, char *);
-void printclp(struct cpu_disklabel *, char *);
-#endif
-
/*
* Attempt to read a disk label from a device
* using the indicated strategy routine.
@@ -70,20 +61,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);
/* don't read the on-disk label if we are in spoofed-only mode */
if (spoofonly)
@@ -133,12 +124,6 @@ readdisklabel(dev, strat, lp, clp, spoofonly)
goto done;
}
-#ifdef DEBUG
- if (disksubr_debug != 0) {
- printlp(lp, "readdisklabel:bsd label");
- printclp(clp, "readdisklabel:cpu label");
- }
-#endif
done:
if (bp) {
bp->b_flags = B_INVAL | B_AGE | B_READ;
@@ -161,15 +146,6 @@ setdisklabel(olp, nlp, openmask, clp)
int i;
struct partition *opp, *npp;
-#ifdef DEBUG
- if (disksubr_debug != 0) {
- printlp(nlp, "setdisklabel:new disklabel");
- printlp(olp, "setdisklabel:old disklabel");
- printclp(clp, "setdisklabel:cpu disklabel");
- }
-#endif
-
-
/* sanity clause */
if (nlp->d_secpercyl == 0 || nlp->d_secsize == 0 ||
(nlp->d_secsize % DEV_BSIZE) != 0)
@@ -192,7 +168,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);
/*
* Copy internally-set partition information
@@ -208,11 +185,6 @@ setdisklabel(olp, nlp, openmask, clp)
nlp->d_checksum = 0;
nlp->d_checksum = dkcksum(nlp);
*olp = *nlp;
-#ifdef DEBUG
- if (disksubr_debug != 0) {
- printlp(olp, "setdisklabel:old->new disklabel");
- }
-#endif
return (0);
}
@@ -229,12 +201,6 @@ writedisklabel(dev, strat, lp, clp)
struct buf *bp;
int error;
-#ifdef DEBUG
- if (disksubr_debug != 0) {
- printlp(lp, "writedisklabel: bsd label");
- }
-#endif
-
/* obtain buffer to read initial cpu_disklabel, for bootloader size :-) */
bp = geteblk((int)lp->d_secsize);
@@ -261,12 +227,6 @@ writedisklabel(dev, strat, lp, clp)
bsdtocpulabel(lp, clp);
-#ifdef DEBUG
- if (disksubr_debug != 0) {
- printclp(clp, "writedisklabel: cpu label");
- }
-#endif
-
if (lp->d_magic == DISKMAGIC && lp->d_magic2 == DISKMAGIC &&
dkcksum(lp) == 0) {
/* obtain buffer to scrozz drive with */
@@ -297,7 +257,7 @@ bounds_check_with_label(struct buf *bp, struct disklabel *lp,
{
#define blockpersec(count, lp) ((count) * (((lp)->d_secsize) / DEV_BSIZE))
struct partition *p = lp->d_partitions + DISKPART(bp->b_dev);
- int labelsector = blockpersec(lp->d_partitions[0].p_offset, lp) +
+ int labelsector = blockpersec(DL_GETPOFFSET(&lp->d_partitions[0]), lp) +
LABELSECTOR;
int sz = howmany(bp->b_bcount, DEV_BSIZE);
@@ -309,9 +269,9 @@ bounds_check_with_label(struct buf *bp, struct disklabel *lp,
/* overwriting disk label ? */
/* XXX should also protect bootstrap in first 8K */
- if (bp->b_blkno + blockpersec(p->p_offset, lp) <= labelsector &&
+ if (bp->b_blkno + blockpersec(DL_GETPOFFSET(p), lp) <= labelsector &&
#if LABELSECTOR != 0
- bp->b_blkno + blockpersec(p->p_offset, lp) + sz > labelsector &&
+ bp->b_blkno + blockpersec(DL_GETPOFFSET(p), lp) + sz > labelsector &&
#endif
(bp->b_flags & B_READ) == 0 && wlabel == 0) {
bp->b_error = EROFS;
@@ -319,8 +279,8 @@ bounds_check_with_label(struct buf *bp, struct disklabel *lp,
}
/* 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;
@@ -336,7 +296,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);
@@ -367,7 +327,7 @@ bsdtocpulabel(lp, clp)
clp->cfg_hds = lp->d_ntracks;
clp->secpercyl = lp->d_secpercyl;
- clp->secperunit = lp->d_secperunit;
+ clp->secperunit = DL_GETDSIZE(lp);
clp->sparespertrack = lp->d_sparespertrack;
clp->sparespercyl = lp->d_sparespercyl;
clp->acylinders = lp->d_acylinders;
@@ -427,11 +387,6 @@ cputobsdlabel(lp, clp)
int i;
if (clp->version == 0) {
-#ifdef DEBUG
- if (disksubr_debug != 0) {
- printf("Reading old disklabel\n");
- }
-#endif
lp->d_magic = clp->magic1;
lp->d_type = clp->type;
lp->d_subtype = clp->subtype;
@@ -443,9 +398,7 @@ cputobsdlabel(lp, clp)
lp->d_ntracks = clp->cfg_hds;
lp->d_secpercyl = clp->secpercyl;
- lp->d_secperunit = clp->secperunit;
- lp->d_secpercyl = clp->secpercyl;
- lp->d_secperunit = clp->secperunit;
+ DL_SETDSIZE(lp, clp->secperunit);
lp->d_sparespertrack = clp->sparespertrack;
lp->d_sparespercyl = clp->sparespercyl;
lp->d_acylinders = clp->acylinders;
@@ -491,11 +444,6 @@ cputobsdlabel(lp, clp)
lp->d_checksum = 0;
lp->d_checksum = dkcksum(lp);
} else {
-#ifdef DEBUG
- if (disksubr_debug != 0) {
- printf("Reading new disklabel\n");
- }
-#endif
lp->d_magic = clp->magic1;
lp->d_type = clp->type;
lp->d_subtype = clp->subtype;
@@ -507,9 +455,7 @@ cputobsdlabel(lp, clp)
lp->d_ntracks = clp->cfg_hds;
lp->d_secpercyl = clp->secpercyl;
- lp->d_secperunit = clp->secperunit;
- lp->d_secpercyl = clp->secpercyl;
- lp->d_secperunit = clp->secperunit;
+ DL_SETDSIZE(lp, clp->secperunit);
lp->d_sparespertrack = clp->sparespertrack;
lp->d_sparespercyl = clp->sparespercyl;
lp->d_acylinders = clp->acylinders;
@@ -555,70 +501,4 @@ cputobsdlabel(lp, clp)
lp->d_checksum = 0;
lp->d_checksum = dkcksum(lp);
}
-#if defined(DEBUG)
- if (disksubr_debug != 0) {
- printlp(lp, "translated label read from disk\n");
- }
-#endif
-}
-
-#ifdef DEBUG
-void
-printlp(lp, str)
- struct disklabel *lp;
- char *str;
-{
- int i;
-
- printf("%s\n", str);
- printf("magic1 %x\n", lp->d_magic);
- printf("magic2 %x\n", lp->d_magic2);
- printf("typename %.*s\n", (int)sizeof(lp->d_typename), lp->d_typename);
- printf("secsize %x nsect %x ntrack %x ncylinders %x\n",
- lp->d_secsize, lp->d_nsectors, lp->d_ntracks, lp->d_ncylinders);
- printf("Num partitions %x\n", lp->d_npartitions);
- for (i = 0; i < lp->d_npartitions; i++) {
- struct partition *part = &lp->d_partitions[i];
- char *fstyp = fstypenames[part->p_fstype];
-
- printf("%c: size %10x offset %10x type %7s frag %5x cpg %3x\n",
- 'a' + i, part->p_size, part->p_offset, fstyp,
- part->p_frag, part->p_cpg);
- }
}
-
-void
-printclp(clp, str)
- struct cpu_disklabel *clp;
- char *str;
-{
- int max, i;
-
- printf("%s\n", str);
- printf("magic1 %x\n", clp->magic1);
- printf("magic2 %x\n", clp->magic2);
- printf("typename %s\n", clp->vid_vd);
- printf("secsize %x nsect %x ntrack %x ncylinders %x\n",
- clp->cfg_psm, clp->cfg_spt, clp->cfg_hds, clp->cfg_trk);
- printf("Num partitions %x\n", clp->partitions);
- max = clp->partitions < 16 ? clp->partitions : 16;
- for (i = 0; i < max; i++) {
- struct partition *part;
- char *fstyp;
-
- if (i < 4) {
- part = (void *)&clp->vid_4[0];
- part = &part[i];
- } else {
- part = (void *)&clp->cfg_4[0];
- part = &part[i-4];
- }
-
- fstyp = fstypenames[part->p_fstype];
-
- printf("%c: size %10x offset %10x type %7s frag %5x cpg %3x\n",
- 'a' + i, part->p_size, part->p_offset, fstyp,
- part->p_frag, part->p_cpg);
- }
-}
-#endif
diff --git a/sys/arch/mvmeppc/mvmeppc/disksubr.c b/sys/arch/mvmeppc/mvmeppc/disksubr.c
index 7965ae1d197..f7498b32ebd 100644
--- a/sys/arch/mvmeppc/mvmeppc/disksubr.c
+++ b/sys/arch/mvmeppc/mvmeppc/disksubr.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: disksubr.c,v 1.37 2007/06/02 02:35:27 krw Exp $ */
+/* $OpenBSD: disksubr.c,v 1.38 2007/06/05 00:38:17 deraadt Exp $ */
/* $NetBSD: disksubr.c,v 1.21 1996/05/03 19:42:03 christos Exp $ */
/*
@@ -84,20 +84,20 @@ readdisklabel(dev, strat, lp, osdep, 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);
/* get a buffer and initialize it */
bp = geteblk((int)lp->d_secsize);
@@ -149,9 +149,9 @@ readdisklabel(dev, strat, lp, osdep, spoofonly)
cyl = DPCYL(dp2->dp_scyl, dp2->dp_ssect);
/* XXX build a temporary disklabel */
- lp->d_partitions[0].p_size = letoh32(dp2->dp_size);
- lp->d_partitions[0].p_offset =
- letoh32(dp2->dp_start) + part_blkno;
+ DL_SETPSIZE(&lp->d_partitions[0], letoh32(dp2->dp_size));
+ DL_SETPOFFSET(&lp->d_partitions[0],
+ letoh32(dp2->dp_start) + part_blkno);
if (lp->d_ntracks == 0)
lp->d_ntracks = dp2->dp_ehd + 1;
if (lp->d_nsectors == 0)
@@ -170,17 +170,17 @@ donot:
if (dp2->dp_typ == DOSPTYP_OPENBSD)
continue;
- if (letoh32(dp2->dp_size) > lp->d_secperunit)
+ if (letoh32(dp2->dp_size) > DL_GETDSIZE(lp))
continue;
- if (letoh32(dp2->dp_start) > lp->d_secperunit)
+ if (letoh32(dp2->dp_start) > DL_GETDSIZE(lp))
continue;
if (letoh32(dp2->dp_size) == 0)
continue;
if (letoh32(dp2->dp_start))
- pp->p_offset =
- letoh32(dp2->dp_start) + part_blkno;
+ DL_SETPOFFSET(pp,
+ letoh32(dp2->dp_start) + part_blkno);
- pp->p_size = letoh32(dp2->dp_size);
+ DL_SETPSIZE(pp, letoh32(dp2->dp_size));
switch (dp2->dp_typ) {
case DOSPTYP_UNUSED:
@@ -241,9 +241,9 @@ donot:
goto notfat;
/* Looks like a FAT filesystem. Spoof 'i'. */
- lp->d_partitions['i' - 'a'].p_size =
- lp->d_partitions[RAW_PART].p_size;
- lp->d_partitions['i' - 'a'].p_offset = 0;
+ DL_SETPSIZE(&lp->d_partitions['i' - 'a'],
+ DL_GETPSIZE(&lp->d_partitions[RAW_PART]));
+ DL_SETPOFFSET(&lp->d_partitions['i' - 'a'], 0);
lp->d_partitions['i' - 'a'].p_fstype = FS_MSDOS;
}
notfat:
@@ -336,7 +336,8 @@ setdisklabel(olp, nlp, openmask, osdep)
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);
/*
* Copy internally-set partition information
@@ -453,7 +454,7 @@ bounds_check_with_label(struct buf *bp, struct disklabel *lp,
{
#define blockpersec(count, lp) ((count) * (((lp)->d_secsize) / DEV_BSIZE))
struct partition *p = lp->d_partitions + DISKPART(bp->b_dev);
- int labelsector = blockpersec(lp->d_partitions[RAW_PART].p_offset, lp) +
+ int labelsector = blockpersec(DL_GETPOFFSET(&lp->d_partitions[RAW_PART]), lp) +
LABELSECTOR;
int sz = howmany(bp->b_bcount, DEV_BSIZE);
@@ -464,8 +465,8 @@ bounds_check_with_label(struct buf *bp, struct disklabel *lp,
}
/* 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;
@@ -481,9 +482,9 @@ bounds_check_with_label(struct buf *bp, struct disklabel *lp,
}
/* Overwriting disk label? */
- if (bp->b_blkno + blockpersec(p->p_offset, lp) <= labelsector &&
+ if (bp->b_blkno + blockpersec(DL_GETPOFFSET(p), lp) <= labelsector &&
#if LABELSECTOR != 0
- bp->b_blkno + blockpersec(p->p_offset, lp) + sz > labelsector &&
+ bp->b_blkno + blockpersec(DL_GETPOFFSET(p), lp) + sz > labelsector &&
#endif
(bp->b_flags & B_READ) == 0 && !wlabel) {
bp->b_error = EROFS;
@@ -491,7 +492,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);
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];
diff --git a/sys/arch/sparc64/dev/fd.c b/sys/arch/sparc64/dev/fd.c
index 313db79d502..a3c4990fcc6 100644
--- a/sys/arch/sparc64/dev/fd.c
+++ b/sys/arch/sparc64/dev/fd.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: fd.c,v 1.12 2007/06/01 00:07:48 krw Exp $ */
+/* $OpenBSD: fd.c,v 1.13 2007/06/05 00:38:19 deraadt Exp $ */
/* $NetBSD: fd.c,v 1.112 2003/08/07 16:29:35 agc Exp $ */
/*-
@@ -2013,7 +2013,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 = lp->d_secpercyl * lp->d_ncylinders;
+ DL_SETDSIZE(lp, (daddr64_t)lp->d_secpercyl * lp->d_ncylinders);
lp->d_rpm = 300; /* XXX like it matters... */
strncpy(lp->d_typename, "floppy disk", sizeof(lp->d_typename));
diff --git a/sys/arch/sparc64/sparc64/disksubr.c b/sys/arch/sparc64/sparc64/disksubr.c
index 39fd2474119..33aeda7dcae 100644
--- a/sys/arch/sparc64/sparc64/disksubr.c
+++ b/sys/arch/sparc64/sparc64/disksubr.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: disksubr.c,v 1.27 2007/06/02 02:35:27 krw Exp $ */
+/* $OpenBSD: disksubr.c,v 1.28 2007/06/05 00:38:19 deraadt Exp $ */
/* $NetBSD: disksubr.c,v 1.13 2000/12/17 22:39:18 pk 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 ? */
@@ -224,7 +224,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);
}
@@ -296,15 +297,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;
@@ -320,7 +321,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:
@@ -417,7 +418,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;
@@ -433,9 +434,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];
@@ -454,8 +455,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;
}
@@ -469,9 +470,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;
}
@@ -535,10 +536,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;
@@ -550,8 +551,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? */
@@ -560,11 +561,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];
diff --git a/sys/arch/vax/mba/hp.c b/sys/arch/vax/mba/hp.c
index 21e603384d6..a1216c49385 100644
--- a/sys/arch/vax/mba/hp.c
+++ b/sys/arch/vax/mba/hp.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: hp.c,v 1.16 2007/02/15 00:53:26 krw Exp $ */
+/* $OpenBSD: hp.c,v 1.17 2007/06/05 00:38:19 deraadt Exp $ */
/* $NetBSD: hp.c,v 1.22 2000/02/12 16:09:33 ragge Exp $ */
/*
* Copyright (c) 1996 Ludd, University of Lule}, Sweden.
@@ -167,7 +167,7 @@ hpattach(parent, self, aux)
/*printf(": %s", msg);*/
}
printf(": %.*s, size = %d sectors\n",
- (int)sizeof(dl->d_typename), dl->d_typename, dl->d_secperunit);
+ (int)sizeof(dl->d_typename), dl->d_typename, DL_GETDSIZE(dl));
/*
* check if this was what we booted from.
*/
@@ -194,7 +194,7 @@ hpstrategy(bp)
goto done;
bp->b_rawblkno =
- bp->b_blkno + lp->d_partitions[DISKPART(bp->b_dev)].p_offset;
+ bp->b_blkno + DL_GETPOFFSET(&lp->d_partitions[DISKPART(bp->b_dev)]);
bp->b_cylinder = bp->b_rawblkno / lp->d_secpercyl;
s = splbio();
@@ -455,7 +455,7 @@ hpsize(dev)
return -1;
sc = hp_cd.cd_devs[unit];
- size = sc->sc_disk.dk_label->d_partitions[DISKPART(dev)].p_size *
+ size = DL_GETPSIZE(&sc->sc_disk.dk_label->d_partitions[DISKPART(dev)]) *
(sc->sc_disk.dk_label->d_secsize / DEV_BSIZE);
return size;
diff --git a/sys/arch/vax/mscp/mscp_disk.c b/sys/arch/vax/mscp/mscp_disk.c
index 8f84693992b..e7c293a3ccc 100644
--- a/sys/arch/vax/mscp/mscp_disk.c
+++ b/sys/arch/vax/mscp/mscp_disk.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: mscp_disk.c,v 1.19 2007/03/13 21:05:24 miod Exp $ */
+/* $OpenBSD: mscp_disk.c,v 1.20 2007/06/05 00:38:19 deraadt Exp $ */
/* $NetBSD: mscp_disk.c,v 1.30 2001/11/13 07:38:28 lukem Exp $ */
/*
* Copyright (c) 1996 Ludd, University of Lule}, Sweden.
@@ -170,7 +170,7 @@ ra_putonline(ra)
ra->ra_state = DK_OPEN;
}
- printf(": size %d sectors\n", dl->d_secperunit);
+ printf(": size %lld sectors\n", DL_GETDSIZE(dl));
return MSCP_DONE;
}
@@ -444,7 +444,7 @@ rasize(dev)
if (ra_putonline(ra) == MSCP_FAILED)
return -1;
- return ra->ra_disk.dk_label->d_partitions[DISKPART(dev)].p_size *
+ return DL_GETPSIZE(&ra->ra_disk.dk_label->d_partitions[DISKPART(dev)]) *
(ra->ra_disk.dk_label->d_secsize / DEV_BSIZE);
}
@@ -648,7 +648,7 @@ rxstrategy(bp)
* Determine the size of the transfer, and make sure it is
* within the boundaries of the partition.
*/
- if (bp->b_blkno >= rx->ra_disk.dk_label->d_secperunit) {
+ if (bp->b_blkno >= DL_GETDSIZE(rx->ra_disk.dk_label)) {
bp->b_resid = bp->b_bcount;
goto done;
}
@@ -828,10 +828,10 @@ rronline(usc, mp)
rx->ra_state = DK_OPEN;
dl = rx->ra_disk.dk_label;
- dl->d_secperunit = (daddr_t)mp->mscp_onle.onle_unitsize;
+ DL_SETDSIZE(dl, (daddr_t)mp->mscp_onle.onle_unitsize);
if (dl->d_secpercyl) {
- dl->d_ncylinders = dl->d_secperunit/dl->d_secpercyl;
+ dl->d_ncylinders = DL_GETDSIZE(dl) / dl->d_secpercyl;
dl->d_type = DTYPE_MSCP;
dl->d_rpm = 3600;
} else {
@@ -870,9 +870,10 @@ rrmakelabel(dl, type)
dl->d_typename[p++] = n + '0';
dl->d_typename[p] = 0;
dl->d_npartitions = MAXPARTITIONS;
- dl->d_partitions[0].p_size = dl->d_partitions[2].p_size =
- dl->d_secperunit;
- dl->d_partitions[0].p_offset = dl->d_partitions[2].p_offset = 0;
+ DL_SETPSIZE(&dl->d_partitions[0], DL_GETDSIZE(dl));
+ DL_SETPSIZE(&dl->d_partitions[2], DL_GETDSIZE(dl));
+ DL_SETPOFFSET(&dl->d_partitions[0], 0);
+ DL_SETPOFFSET(&dl->d_partitions[2], 0);
dl->d_interleave = dl->d_headswitch = 1;
dl->d_magic = dl->d_magic2 = DISKMAGIC;
dl->d_checksum = dkcksum(dl);
@@ -971,7 +972,7 @@ rrfillin(bp, mp)
#endif
lp = rx->ra_disk.dk_label;
- mp->mscp_seq.seq_lbn = lp->d_partitions[part].p_offset + bp->b_blkno;
+ mp->mscp_seq.seq_lbn = DL_GETPOFFSET(&lp->d_partitions[part]) + bp->b_blkno;
mp->mscp_unit = rx->ra_hwunit;
mp->mscp_seq.seq_bytecount = bp->b_bcount;
}
diff --git a/sys/arch/vax/vax/disksubr.c b/sys/arch/vax/vax/disksubr.c
index a4da2292245..3f62f6c26c3 100644
--- a/sys/arch/vax/vax/disksubr.c
+++ b/sys/arch/vax/vax/disksubr.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: disksubr.c,v 1.39 2007/06/02 02:35:27 krw Exp $ */
+/* $OpenBSD: disksubr.c,v 1.40 2007/06/05 00:38:19 deraadt Exp $ */
/* $NetBSD: disksubr.c,v 1.21 1999/06/30 18:48:06 ragge Exp $ */
/*
@@ -60,9 +60,9 @@ bounds_check_with_label(struct buf *bp, struct disklabel *lp,
struct cpu_disklabel *osdep, int wlabel)
{
struct partition *p = lp->d_partitions + DISKPART(bp->b_dev);
- int labelsector = lp->d_partitions[RAW_PART].p_offset;
- int maxsz = p->p_size,
- sz = (bp->b_bcount + DEV_BSIZE - 1) >> DEV_BSHIFT;
+ int labelsector = DL_GETPOFFSET(&lp->d_partitions[RAW_PART]);
+ int maxsz = DL_GETPSIZE(p);
+ int sz = (bp->b_bcount + DEV_BSIZE - 1) >> DEV_BSHIFT;
/* avoid division by zero */
if (lp->d_secpercyl == 0) {
@@ -71,7 +71,7 @@ bounds_check_with_label(struct buf *bp, struct disklabel *lp,
}
/* overwriting disk label ? */
- if (bp->b_blkno + p->p_offset <= LABELSECTOR + labelsector &&
+ if (bp->b_blkno + DL_GETPOFFSET(p) <= LABELSECTOR + labelsector &&
(bp->b_flags & B_READ) == 0 && wlabel == 0) {
bp->b_error = EROFS;
goto bad;
@@ -95,7 +95,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 + p->p_offset) / lp->d_secpercyl;
+ bp->b_cylinder = (bp->b_blkno + DL_GETPOFFSET(p)) / lp->d_secpercyl;
return (1);
bad:
@@ -127,20 +127,20 @@ readdisklabel(dev, strat, lp, osdep, 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;
@@ -222,7 +222,8 @@ setdisklabel(olp, nlp, openmask, osdep)
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);
/*
* Copy internally-set partition information
diff --git a/sys/arch/vax/vsa/hdc9224.c b/sys/arch/vax/vsa/hdc9224.c
index 692f059a240..0402691fdd9 100644
--- a/sys/arch/vax/vsa/hdc9224.c
+++ b/sys/arch/vax/vsa/hdc9224.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: hdc9224.c,v 1.14 2007/02/15 00:53:26 krw Exp $ */
+/* $OpenBSD: hdc9224.c,v 1.15 2007/06/05 00:38:19 deraadt Exp $ */
/* $NetBSD: hdc9224.c,v 1.16 2001/07/26 15:05:09 wiz Exp $ */
/*
* Copyright (c) 1996 Ludd, University of Lule}, Sweden.
@@ -366,8 +366,8 @@ hdattach(struct device *parent, struct device *self, void *aux)
msg = readdisklabel(MAKEDISKDEV(HDMAJOR, hd->sc_dev.dv_unit, RAW_PART),
hdstrategy, dl, NULL, 0);
printf("%s: %luMB, %lu sectors\n",
- hd->sc_dev.dv_xname, dl->d_secperunit / (1048576 / DEV_BSIZE),
- dl->d_secperunit);
+ hd->sc_dev.dv_xname, DL_GETDSIZE(dl) / (1048576 / DEV_BSIZE),
+ DL_GETDSIZE(dl));
if (msg) {
/*printf("%s: %s\n", hd->sc_dev.dv_xname, msg);*/
}
@@ -464,7 +464,7 @@ hdstrategy(struct buf *bp)
* this also truncates the block number at 4G, but there shouldn't be
* any MFM disk that large.
*/
- bn = bp->b_blkno + lp->d_partitions[DISKPART(bp->b_dev)].p_offset;
+ bn = bp->b_blkno + DL_GETPOFFSET(&lp->d_partitions[DISKPART(bp->b_dev)]);
bp->b_cylinder = bn;
s = splbio();
@@ -636,7 +636,7 @@ hdsize(dev_t dev)
if (unit >= hd_cd.cd_ndevs || hd_cd.cd_devs[unit] == 0)
return -1;
hd = hd_cd.cd_devs[unit];
- size = hd->sc_disk.dk_label->d_partitions[DISKPART(dev)].p_size *
+ size = DL_GETPSIZE(&hd->sc_disk.dk_label->d_partitions[DISKPART(dev)]) *
(hd->sc_disk.dk_label->d_secsize / DEV_BSIZE);
return (size);
@@ -866,16 +866,18 @@ hdmakelabel(struct disklabel *dl, struct hdgeom *g)
dl->d_rpm = 3600;
dl->d_secsize = DEV_BSIZE;
- dl->d_secperunit = g->lbn_count;
+ DL_SETDSIZE(dl, g->lbn_count);
dl->d_nsectors = g->nspt;
dl->d_ntracks = g->ntracks;
dl->d_secpercyl = dl->d_nsectors * dl->d_ntracks;
- dl->d_ncylinders = dl->d_secperunit / dl->d_secpercyl;
+ dl->d_ncylinders = DL_GETDSIZE(dl) / dl->d_secpercyl;
dl->d_npartitions = MAXPARTITIONS;
- dl->d_partitions[0].p_size = dl->d_partitions[2].p_size =
- dl->d_secperunit;
- dl->d_partitions[0].p_offset = dl->d_partitions[2].p_offset = 0;
+ DL_SETPSIZE(&dl->d_partitions[0], DL_GETDSIZE(dl));
+ DL_SETPSIZE(&dl->d_partitions[2], DL_GETDSIZE(dl));
+
+ DL_SETPOFFSET(&dl->d_partitions[0], 0);
+ DL_SETPOFFSET(&dl->d_partitions[2], 0);
dl->d_interleave = dl->d_headswitch = 1;
dl->d_magic = dl->d_magic2 = DISKMAGIC;
dl->d_checksum = dkcksum(dl);
diff --git a/sys/arch/zaurus/dev/zaurus_flash.c b/sys/arch/zaurus/dev/zaurus_flash.c
index 8dc584a5f32..15b269a268e 100644
--- a/sys/arch/zaurus/dev/zaurus_flash.c
+++ b/sys/arch/zaurus/dev/zaurus_flash.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: zaurus_flash.c,v 1.1 2006/11/25 14:31:59 uwe Exp $ */
+/* $OpenBSD: zaurus_flash.c,v 1.2 2007/06/05 00:38:20 deraadt Exp $ */
/*
* Copyright (c) 2005 Uwe Stuehler <uwe@openbsd.org>
@@ -351,30 +351,30 @@ zflash_default_disklabel(void *arg, dev_t dev, struct disklabel *lp,
switch (sc->sc_flash.sc_flashdev->id) {
case FLASH_DEVICE_SAMSUNG_K9F2808U0C:
- lp->d_partitions[8].p_size = 7*1024*1024 / bsize;
- lp->d_partitions[9].p_size = 5*1024*1024 / bsize;
- lp->d_partitions[10].p_size = 4*1024*1024 / bsize;
+ DL_SETPSIZE(&lp->d_partitions[8], 7*1024*1024 / bsize);
+ DL_SETPSIZE(&lp->d_partitions[9], 5*1024*1024 / bsize);
+ DL_SETPSIZE(&lp->d_partitions[10], 4*1024*1024 / bsize);
break;
case FLASH_DEVICE_SAMSUNG_K9F1G08U0A:
- lp->d_partitions[8].p_size = 7*1024*1024 / bsize;
- lp->d_partitions[9].p_size = 32*1024*1024 / bsize;
- lp->d_partitions[10].p_size = 89*1024*1024 / bsize;
+ DL_SETPSIZE(&lp->d_partitions[8], 7*1024*1024 / bsize);
+ DL_SETPSIZE(&lp->d_partitions[9], 32*1024*1024 / bsize);
+ DL_SETPSIZE(&lp->d_partitions[10], 89*1024*1024 / bsize);
break;
default:
return;
}
/* The "smf" partition uses logical addressing. */
- lp->d_partitions[8].p_offset = 0;
+ DL_SETPOFFSET(&lp->d_partitions[8], 0);
lp->d_partitions[8].p_fstype = FS_OTHER;
/* The "root" partition uses physical addressing. */
- lp->d_partitions[9].p_offset = lp->d_partitions[8].p_size;
+ DL_SETPSIZE(&lp->d_partitions[9], DL_GETPSIZE(&lp->d_partitions[8]));
lp->d_partitions[9].p_fstype = FS_OTHER;
/* The "home" partition uses physical addressing. */
- lp->d_partitions[10].p_offset = lp->d_partitions[9].p_offset +
- lp->d_partitions[9].p_size;
+ DL_SETPOFFSET(&lp->d_partitions[10],
+ DL_GETPOFFSET(&lp->d_partitions[9]) + DL_GETPSIZE(&lp->d_partitions[9]));
lp->d_partitions[10].p_fstype = FS_OTHER;
lp->d_npartitions = 11;
@@ -621,7 +621,7 @@ zflash_safe_start(struct zflash_softc *sc, dev_t dev)
/* Safe partitions must start on a flash block boundary. */
blksect = (sc->sc_flash.sc_flashdev->blkpages *
sc->sc_flash.sc_flashdev->pagesize) / lp->d_secsize;
- if (lp->d_partitions[part].p_offset % blksect)
+ if (DL_GETPOFFSET(&lp->d_partitions[part]) % blksect)
return EIO;
MALLOC(sp, struct zflash_safe *, sizeof(struct zflash_safe),
@@ -632,7 +632,7 @@ zflash_safe_start(struct zflash_softc *sc, dev_t dev)
bzero(sp, sizeof(struct zflash_safe));
sp->sp_dev = dev;
- sp->sp_pblks = lp->d_partitions[part].p_size / blksect;
+ sp->sp_pblks = DL_GETPSIZE(&lp->d_partitions[part]) / blksect;
sp->sp_lblks = sp->sp_pblks;
/* Try to reserve a number of spare physical blocks. */
diff --git a/sys/compat/linux/linux_blkio.c b/sys/compat/linux/linux_blkio.c
index 6d2eff284bc..74c7063379b 100644
--- a/sys/compat/linux/linux_blkio.c
+++ b/sys/compat/linux/linux_blkio.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: linux_blkio.c,v 1.5 2002/03/14 01:26:50 millert Exp $ */
+/* $OpenBSD: linux_blkio.c,v 1.6 2007/06/05 00:38:20 deraadt Exp $ */
/* $NetBSD: linux_blkio.c,v 1.3 2001/01/18 17:48:04 tv Exp $ */
/*
@@ -91,7 +91,7 @@ linux_ioctl_blkio(struct proc *p, struct linux_sys_ioctl_args *uap,
size = label.d_nsectors * label.d_ntracks *
label.d_ncylinders;
} else
- size = partp.part->p_size;
+ size = DL_GETPSIZE(partp.part);
error = copyout(&size, SCARG(uap, data), sizeof size);
break;
case LINUX_BLKSECTGET:
diff --git a/sys/compat/linux/linux_hdio.c b/sys/compat/linux/linux_hdio.c
index 8e4704ccb40..4eb2edba747 100644
--- a/sys/compat/linux/linux_hdio.c
+++ b/sys/compat/linux/linux_hdio.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: linux_hdio.c,v 1.5 2002/03/14 01:26:50 millert Exp $ */
+/* $OpenBSD: linux_hdio.c,v 1.6 2007/06/05 00:38:20 deraadt Exp $ */
/* $NetBSD: linux_hdio.c,v 1.1 2000/12/10 14:12:17 fvdl Exp $ */
/*
@@ -130,7 +130,7 @@ linux_ioctl_hdio(struct proc *p, struct linux_sys_ioctl_args *uap,
break;
}
labp = error != 0 ? &label : partp.disklab;
- hdg.start = error1 != 0 ? partp.part->p_offset : 0;
+ hdg.start = error1 != 0 ? DL_GETPOFFSET(partp.part) & 0x7fffffff: 0;
hdg.heads = labp->d_ntracks;
hdg.cylinders = labp->d_ncylinders;
hdg.sectors = labp->d_nsectors;
@@ -148,7 +148,7 @@ linux_ioctl_hdio(struct proc *p, struct linux_sys_ioctl_args *uap,
break;
}
labp = error != 0 ? &label : partp.disklab;
- hdg_big.start = error1 != 0 ? partp.part->p_offset : 0;
+ hdg_big.start = error1 != 0 ? DL_GETPOFFSET(partp.part) & 0x7fffffff : 0;
hdg_big.heads = labp->d_ntracks;
hdg_big.cylinders = labp->d_ncylinders;
hdg_big.sectors = labp->d_nsectors;
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;
diff --git a/sys/isofs/cd9660/cd9660_vfsops.c b/sys/isofs/cd9660/cd9660_vfsops.c
index 4a322f89877..3ae09a46f71 100644
--- a/sys/isofs/cd9660/cd9660_vfsops.c
+++ b/sys/isofs/cd9660/cd9660_vfsops.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: cd9660_vfsops.c,v 1.44 2007/03/25 10:20:50 pedro Exp $ */
+/* $OpenBSD: cd9660_vfsops.c,v 1.45 2007/06/05 00:38:22 deraadt Exp $ */
/* $NetBSD: cd9660_vfsops.c,v 1.26 1997/06/13 15:38:58 pk Exp $ */
/*-
@@ -513,14 +513,14 @@ iso_disklabelspoof(dev, strat, lp)
strncpy(lp->d_typename, pri->volume_id, sizeof lp->d_typename);
strncpy(lp->d_packname, pri->volume_id+16, sizeof lp->d_packname);
for (i = 0; i < MAXPARTITIONS; 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);
}
- lp->d_partitions[0].p_offset = 0;
- lp->d_partitions[0].p_size = lp->d_secperunit;
+ DL_SETPOFFSET(&lp->d_partitions[0], 0);
+ DL_SETPSIZE(&lp->d_partitions[0], DL_GETDSIZE(lp));
lp->d_partitions[0].p_fstype = FS_ISO9660;
- lp->d_partitions[RAW_PART].p_offset = 0;
- lp->d_partitions[RAW_PART].p_size = lp->d_secperunit;
+ DL_SETPOFFSET(&lp->d_partitions[RAW_PART], 0);
+ DL_SETPSIZE(&lp->d_partitions[RAW_PART], DL_GETDSIZE(lp));
lp->d_partitions[RAW_PART].p_fstype = FS_ISO9660;
lp->d_npartitions = RAW_PART + 1;
lp->d_bbsize = 8192; /* fake */
diff --git a/sys/isofs/udf/udf_subr.c b/sys/isofs/udf/udf_subr.c
index 4943c8a0745..531c9697b1d 100644
--- a/sys/isofs/udf/udf_subr.c
+++ b/sys/isofs/udf/udf_subr.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: udf_subr.c,v 1.11 2006/07/11 22:02:08 pedro Exp $ */
+/* $OpenBSD: udf_subr.c,v 1.12 2007/06/05 00:38:22 deraadt Exp $ */
/*
* Copyright (c) 2006, Miodrag Vallat
@@ -155,16 +155,16 @@ udf_disklabelspoof(dev_t dev, void (*strat)(struct buf *),
strlcpy(lp->d_typename, vid, sizeof(lp->d_typename));
for (i = 0; i < MAXPARTITIONS; 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);
}
/*
* Fake two partitions, 'a' and 'c'.
*/
- lp->d_partitions[0].p_size = lp->d_secperunit;
+ DL_SETPSIZE(&lp->d_partitions[0], DL_GETDSIZE(lp));
lp->d_partitions[0].p_fstype = FS_UDF;
- lp->d_partitions[RAW_PART].p_size = lp->d_secperunit;
+ DL_SETPSIZE(&lp->d_partitions[RAW_PART], DL_GETDSIZE(lp));
lp->d_partitions[RAW_PART].p_fstype = FS_UDF;
lp->d_npartitions = RAW_PART + 1;
diff --git a/sys/kern/subr_disk.c b/sys/kern/subr_disk.c
index 86b0da97669..1450de42c02 100644
--- a/sys/kern/subr_disk.c
+++ b/sys/kern/subr_disk.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: subr_disk.c,v 1.46 2007/06/04 22:07:59 deraadt Exp $ */
+/* $OpenBSD: subr_disk.c,v 1.47 2007/06/05 00:38:23 deraadt Exp $ */
/* $NetBSD: subr_disk.c,v 1.17 1996/03/16 23:17:08 christos Exp $ */
/*
@@ -206,20 +206,23 @@ disklabeltokernlabel(struct disklabel *lp)
pp->p_sizeh = 0;
}
- /* In a V1 label no partition extends past DL_SIZE(lp) - 1. */
- if (DL_POFFSET(pp) >= DL_DSIZE(lp)) {
+ /* In a V1 label no partition extends past DL_GETSIZE(lp) - 1. */
+ if (DL_GETPOFFSET(pp) > DL_GETDSIZE(lp)) {
pp->p_fstype = FS_UNUSED;
- pp->p_offset = pp->p_offseth = 0;
- pp->p_size = pp->p_sizeh = 0;
-#ifdef notyet /* older broken sparc/sparc64 fake cyl-based disklabels fool this */
- } else if ((DL_POFFSET(pp) + DL_PSIZE(pp)) > DL_DSIZE(lp)) {
+ DL_SETPSIZE(pp, 0);
+ DL_SETPOFFSET(pp, 0);
+#ifdef notyet /* older broken sparc/sparc64 fake cyl-based disklabels fool this */
+ } else if (DL_GETPOFFSET(pp) + DL_GETPSIZE(pp) > DL_GETDSIZE(lp)) {
daddr64_t sz;
+ printf("%lld %lld %lld\n",
+ DL_GETPOFFSET(pp), DL_GETPSIZE(pp),
+ DL_GETPOFFSET(pp) + DL_GETPSIZE(pp),
+ DL_GETDSIZE(lp));
pp->p_fstype = FS_UNUSED;
- sz = DL_DSIZE(lp) - DL_POFFSET(pp);
- pp->p_size = sz & 0xffffffff;
- pp->p_sizeh = (sz >> 32) & 0xffff;
-#endif /* notyet */
+ sz = DL_GETDSIZE(lp) - DL_GETPOFFSET(pp);
+ DL_SETPSIZE(pp, sz);
+#endif
}
}
}
@@ -267,7 +270,7 @@ diskerr(struct buf *bp, char *dname, char *what, int pri, int blkdone,
bp->b_blkno + (bp->b_bcount - 1) / DEV_BSIZE);
}
if (lp && (blkdone >= 0 || bp->b_bcount <= lp->d_secsize)) {
- sn += lp->d_partitions[part].p_offset;
+ sn += DL_GETPOFFSET(&lp->d_partitions[part]);
(*pr)(" (%s%d bn %d; cn %d", dname, unit, sn,
sn / lp->d_secpercyl);
sn %= lp->d_secpercyl;
@@ -452,7 +455,7 @@ dk_mountroot(void)
(void) (cdevsw[major(rrootdev)].d_close)(rawdev, FREAD,
S_IFCHR, curproc);
- if (dl.d_partitions[part].p_size == 0)
+ if (DL_GETPSIZE(&dl.d_partitions[part]) == 0)
panic("root filesystem has size 0");
switch (dl.d_partitions[part].p_fstype) {
#ifdef EXT2FS
diff --git a/sys/scsi/cd.c b/sys/scsi/cd.c
index 78efcbf8514..0eeffff87f2 100644
--- a/sys/scsi/cd.c
+++ b/sys/scsi/cd.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: cd.c,v 1.126 2007/06/01 00:07:48 krw Exp $ */
+/* $OpenBSD: cd.c,v 1.127 2007/06/05 00:38:23 deraadt Exp $ */
/* $NetBSD: cd.c,v 1.100 1997/04/02 02:29:30 mycroft Exp $ */
/*
@@ -603,7 +603,7 @@ cdstart(void *v)
bp->b_blkno / (cd->sc_dk.dk_label->d_secsize / DEV_BSIZE);
if (DISKPART(bp->b_dev) != RAW_PART) {
p = &cd->sc_dk.dk_label->d_partitions[DISKPART(bp->b_dev)];
- blkno += p->p_offset;
+ blkno += DL_GETPOFFSET(p);
}
nblks = howmany(bp->b_bcount, cd->sc_dk.dk_label->d_secsize);
@@ -1179,7 +1179,7 @@ cdgetdisklabel(dev_t dev, struct cd_softc *cd, struct disklabel *lp,
}
strncpy(lp->d_packname, "fictitious", sizeof(lp->d_packname));
- lp->d_secperunit = cd->params.disksize;
+ DL_SETDSIZE(lp, cd->params.disksize);
lp->d_rpm = 300;
lp->d_interleave = 1;
diff --git a/sys/scsi/sd.c b/sys/scsi/sd.c
index b6127a40ba4..d7cb2e9f19e 100644
--- a/sys/scsi/sd.c
+++ b/sys/scsi/sd.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: sd.c,v 1.129 2007/06/01 00:07:48 krw Exp $ */
+/* $OpenBSD: sd.c,v 1.130 2007/06/05 00:38:23 deraadt Exp $ */
/* $NetBSD: sd.c,v 1.111 1997/04/02 02:29:41 mycroft Exp $ */
/*-
@@ -650,7 +650,7 @@ sdstart(void *v)
bp->b_blkno / (sd->sc_dk.dk_label->d_secsize / DEV_BSIZE);
if (DISKPART(bp->b_dev) != RAW_PART) {
p = &sd->sc_dk.dk_label->d_partitions[DISKPART(bp->b_dev)];
- blkno += p->p_offset;
+ blkno += DL_GETPOFFSET(p);
}
nblks = howmany(bp->b_bcount, sd->sc_dk.dk_label->d_secsize);
@@ -1030,7 +1030,7 @@ sdgetdisklabel(dev_t dev, struct sd_softc *sd, struct disklabel *lp,
*/
bcopy(packname, lp->d_packname, len);
- lp->d_secperunit = sd->params.disksize;
+ DL_SETDSIZE(lp, sd->params.disksize);
lp->d_rpm = sd->params.rot_rate;
lp->d_interleave = 1;
lp->d_flags = 0;
@@ -1161,7 +1161,7 @@ sdsize(dev_t dev)
else if (sd->sc_dk.dk_label->d_partitions[part].p_fstype != FS_SWAP)
size = -1;
else
- size = sd->sc_dk.dk_label->d_partitions[part].p_size *
+ size = DL_GETPSIZE(&sd->sc_dk.dk_label->d_partitions[part]) *
(sd->sc_dk.dk_label->d_secsize / DEV_BSIZE);
if (omask == 0 && sdclose(dev, 0, S_IFBLK, NULL) != 0)
size = -1;
@@ -1227,8 +1227,8 @@ sddump(dev_t dev, daddr_t blkno, caddr_t va, size_t size)
totwrt = size / sectorsize;
blkno = dbtob(blkno) / sectorsize; /* blkno in DEV_BSIZE units */
- nsects = lp->d_partitions[part].p_size;
- sectoff = lp->d_partitions[part].p_offset;
+ nsects = DL_GETPSIZE(&lp->d_partitions[part]);
+ sectoff = DL_GETPOFFSET(&lp->d_partitions[part]);
/* Check transfer bounds against partition size. */
if ((blkno < 0) || ((blkno + totwrt) > nsects))
diff --git a/sys/sys/disklabel.h b/sys/sys/disklabel.h
index b4359607a22..acf54d87283 100644
--- a/sys/sys/disklabel.h
+++ b/sys/sys/disklabel.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: disklabel.h,v 1.34 2007/06/02 02:35:27 krw Exp $ */
+/* $OpenBSD: disklabel.h,v 1.35 2007/06/05 00:38:24 deraadt Exp $ */
/* $NetBSD: disklabel.h,v 1.41 1996/05/10 23:07:37 mark Exp $ */
/*
@@ -71,6 +71,8 @@
#define DISKMAGIC ((u_int32_t)0x82564557) /* The disk magic number */
+#define MAXDISKSIZE 0x1fffffffffffLL /* 47 bits of reach */
+
#ifndef _LOCORE
struct disklabel {
u_int32_t d_magic; /* the magic number */
@@ -203,10 +205,26 @@ struct __partitionv0 { /* the partition table */
#define DISKLABELV1_FFS_FSIZE(i) ((i) == 0 ? 0 : \
(DISKLABELV1_FFS_BSIZE(i) / DISKLABELV1_FFS_FRAG(i)))
-#define DL_PSIZE(p) (((u_int64_t)(p)->p_sizeh << 32) + (p)->p_size)
-#define DL_POFFSET(p) (((u_int64_t)(p)->p_offseth << 32) + (p)->p_offset)
-#define DL_DSIZE(d) (((u_int64_t)(d)->d_secperunith << 32) + (d)->d_secperunit)
-
+#define DL_GETPSIZE(p) (((u_int64_t)(p)->p_sizeh << 32) + (p)->p_size)
+#define DL_GETPOFFSET(p) (((u_int64_t)(p)->p_offseth << 32) + (p)->p_offset)
+#define DL_GETDSIZE(d) (((u_int64_t)(d)->d_secperunith << 32) + \
+ (d)->d_secperunit)
+
+#define DL_SETPSIZE(p, n) do { \
+ daddr64_t x = (n); \
+ (p)->p_sizeh = x >> 32; \
+ (p)->p_size = x; \
+ } while (0)
+#define DL_SETPOFFSET(p, n) do { \
+ daddr64_t x = (n); \
+ (p)->p_offseth = x >> 32; \
+ (p)->p_offset = x; \
+ } while (0)
+#define DL_SETDSIZE(d, n) do { \
+ daddr64_t x = (n); \
+ (d)->d_secperunith = x >> 32; \
+ (d)->d_secperunit = x; \
+ } while (0)
/* d_type values: */
#define DTYPE_SMD 1 /* SMD, XSMD; VAX hp/up */
diff --git a/sys/uvm/uvm_vnode.c b/sys/uvm/uvm_vnode.c
index 95b20053000..dd4762b700d 100644
--- a/sys/uvm/uvm_vnode.c
+++ b/sys/uvm/uvm_vnode.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: uvm_vnode.c,v 1.48 2007/05/29 21:06:34 thib Exp $ */
+/* $OpenBSD: uvm_vnode.c,v 1.49 2007/06/05 00:38:24 deraadt Exp $ */
/* $NetBSD: uvm_vnode.c,v 1.36 2000/11/24 20:34:01 chs Exp $ */
/*
@@ -250,7 +250,7 @@ uvn_attach(arg, accessprot)
if (result == 0) {
/* XXX should remember blocksize */
used_vnode_size = (u_quad_t)pi.disklab->d_secsize *
- (u_quad_t)pi.part->p_size;
+ (u_quad_t)DL_GETPSIZE(pi.part);
}
} else {
result = VOP_GETATTR(vp, &vattr, curproc->p_ucred, curproc);