summaryrefslogtreecommitdiff
path: root/sys/arch
diff options
context:
space:
mode:
authorTheo de Raadt <deraadt@cvs.openbsd.org>2007-06-05 00:38:25 +0000
committerTheo de Raadt <deraadt@cvs.openbsd.org>2007-06-05 00:38:25 +0000
commit27424f98f99646fb8b3e4ef11652da62014a7ceb (patch)
tree47b5f078f236f633651ce1bad4b1228fac2f6d7d /sys/arch
parent91862e2af60dd7be0a8d86f5f3fe187dbb400d7f (diff)
use six new macros to access & store the 48-bit disklabel fields related
to size. tested on almost all machines, double checked by miod and krw next comes the type handling surrounding these values
Diffstat (limited to 'sys/arch')
-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
29 files changed, 553 insertions, 777 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. */