summaryrefslogtreecommitdiff
path: root/sys/arch/sun3
diff options
context:
space:
mode:
authorTheo de Raadt <deraadt@cvs.openbsd.org>1997-04-07 12:01:20 +0000
committerTheo de Raadt <deraadt@cvs.openbsd.org>1997-04-07 12:01:20 +0000
commit0a899465af1b5c690b8a7c86e64db38204c23d5f (patch)
tree4ef9270ac29bf1d8ef9e8a32563fb04e9fd4e0ed /sys/arch/sun3
parent424044fb70fe3c2dd4ca8115f6b27958e019edb5 (diff)
cd9660 & partition/block number confusion correction
Diffstat (limited to 'sys/arch/sun3')
-rw-r--r--sys/arch/sun3/sun3/disksubr.c30
1 files changed, 17 insertions, 13 deletions
diff --git a/sys/arch/sun3/sun3/disksubr.c b/sys/arch/sun3/sun3/disksubr.c
index 9eb01e5ec21..40dd1a150f8 100644
--- a/sys/arch/sun3/sun3/disksubr.c
+++ b/sys/arch/sun3/sun3/disksubr.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: disksubr.c,v 1.9 1997/02/04 01:31:33 kstailey Exp $ */
+/* $OpenBSD: disksubr.c,v 1.10 1997/04/07 12:01:19 deraadt Exp $ */
/* $NetBSD: disksubr.c,v 1.14 1996/09/26 18:10:21 gwr Exp $ */
/*
@@ -135,6 +135,10 @@ readdisklabel(dev, strat, lp, clp)
return(NULL);
}
+#if defined(CD9660)
+ if (iso_disklabelspoof(dev, strat, lp) == 0)
+ return (NULL);
+#endif
bzero(clp->cd_block, sizeof(clp->cd_block));
return("no disk label");
}
@@ -237,38 +241,38 @@ writedisklabel(dev, strat, lp, clp)
int
bounds_check_with_label(struct buf *bp, struct disklabel *lp, int wlabel)
{
+#define blockpersec(count, lp) ((count) * (((lp)->d_secsize) / DEV_BSIZE))
struct partition *p = lp->d_partitions + dkpart(bp->b_dev);
- int maxsz = p->p_size;
- int sz = (bp->b_bcount + DEV_BSIZE - 1) >> DEV_BSHIFT;
+ int sz = howmany(bp->b_bcount, DEV_BSIZE);
/* overwriting disk label ? */
/* XXX should also protect bootstrap in first 8K */
/* XXX PR#2598: labelsect is always sector zero. */
- if (((bp->b_blkno + p->p_offset) <= LABELSECTOR) &&
- ((bp->b_flags & B_READ) == 0) && (wlabel == 0))
- {
+ if (((bp->b_blkno + blockpersec(p->p_offset, lp)) <= LABELSECTOR) &&
+ ((bp->b_flags & B_READ) == 0) && (wlabel == 0)) {
bp->b_error = EROFS;
goto bad;
}
/* beyond partition? */
- if (bp->b_blkno < 0 || bp->b_blkno + sz > maxsz) {
- /* if exactly at end of disk, return an EOF */
- if (bp->b_blkno == maxsz) {
+ if (bp->b_blkno + sz > blockpersec(p->p_size, lp)) {
+ sz = blockpersec(p->p_size, lp) - bp->b_blkno;
+ if (sz == 0) {
+ /* if exactly at end of disk, return an EOF */
bp->b_resid = bp->b_bcount;
return(0);
}
- /* or truncate if part of it fits */
- sz = maxsz - bp->b_blkno;
- if (sz <= 0) {
+ if (sz < 0) {
bp->b_error = EINVAL;
goto bad;
}
+ /* or truncate if part of it fits */
bp->b_bcount = sz << DEV_BSHIFT;
}
/* calculate cylinder for disksort to order transfers with */
- bp->b_cylin = (bp->b_blkno + p->p_offset) / lp->d_secpercyl;
+ bp->b_cylin = (bp->b_blkno + blockpersec(p->p_offset, lp)) /
+ lp->d_secpercyl;
return(1);
bad: