summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTheo de Raadt <deraadt@cvs.openbsd.org>1997-04-07 11:21:26 +0000
committerTheo de Raadt <deraadt@cvs.openbsd.org>1997-04-07 11:21:26 +0000
commited4b5fb807fdd5a7e218f297becb2c93d7afc66b (patch)
treead4e5e8ad6dbacd05669efeb4efa3e3f2beb99e4
parentafa1402e05f3d9301ccf548dfc59145241c6431b (diff)
add cd9660 spoofing and repair partition offset/block offset stuff
-rw-r--r--sys/arch/mvme68k/mvme68k/disksubr.c6
-rw-r--r--sys/arch/mvme88k/mvme88k/disksubr.c50
2 files changed, 31 insertions, 25 deletions
diff --git a/sys/arch/mvme68k/mvme68k/disksubr.c b/sys/arch/mvme68k/mvme68k/disksubr.c
index 6d8f6accb10..9b8e937a0ba 100644
--- a/sys/arch/mvme68k/mvme68k/disksubr.c
+++ b/sys/arch/mvme68k/mvme68k/disksubr.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: disksubr.c,v 1.12 1997/04/06 06:13:03 deraadt Exp $ */
+/* $OpenBSD: disksubr.c,v 1.13 1997/04/07 11:21:25 deraadt Exp $ */
/*
* Copyright (c) 1995 Dale Rahn.
@@ -309,9 +309,9 @@ bounds_check_with_label(bp, lp, wlabel)
/* overwriting disk label ? */
/* XXX should also protect bootstrap in first 8K */
- if (bp->b_blkno + p->p_offset <= labelsect &&
+ if (bp->b_blkno + blockpersec(p->p_offset, lp) <= labelsect &&
#if LABELSECTOR != 0
- bp->b_blkno + p->p_offset + sz > labelsect &&
+ bp->b_blkno + blockpersec(p->p_offset, lp) + sz > labelsect &&
#endif
(bp->b_flags & B_READ) == 0 && wlabel == 0) {
bp->b_error = EROFS;
diff --git a/sys/arch/mvme88k/mvme88k/disksubr.c b/sys/arch/mvme88k/mvme88k/disksubr.c
index 3057237b89d..4d507e1e0f5 100644
--- a/sys/arch/mvme88k/mvme88k/disksubr.c
+++ b/sys/arch/mvme88k/mvme88k/disksubr.c
@@ -94,6 +94,10 @@ readdisklabel(dev, strat, lp, clp)
brelse(bp);
if (msg || clp->magic1 != DISKMAGIC || clp->magic2 != DISKMAGIC) {
+#if defined(CD9660)
+ if (iso_disklabelspoof(dev, strat, lp) == 0)
+ msg = NULL;
+#endif
return (msg);
}
@@ -256,40 +260,42 @@ bounds_check_with_label(bp, lp, wlabel)
struct disklabel *lp;
int wlabel;
{
+#define blockpersec(count, lp) ((count) * (((lp)->d_secsize) / DEV_BSIZE))
struct partition *p = lp->d_partitions + DISKPART(bp->b_dev);
- int labelsect = lp->d_partitions[0].p_offset;
- int maxsz = p->p_size;
- int sz = (bp->b_bcount + DEV_BSIZE - 1) >> DEV_BSHIFT;
+ int labelsect = blockpersec(lp->d_partitions[0].p_offset, lp) +
+ LABELSECTOR;
+ int sz = howmany(bp->b_bcount, DEV_BSIZE);
/* overwriting disk label ? */
/* XXX should also protect bootstrap in first 8K */
- if (bp->b_blkno + p->p_offset <= LABELSECTOR + labelsect &&
+ if (bp->b_blkno + blockpersec(p->p_offset, lp) <= labelsect &&
#if LABELSECTOR != 0
- bp->b_blkno + p->p_offset + sz > LABELSECTOR + labelsect &&
+ bp->b_blkno + blockpersec(p->p_offset, lp) + sz > labelsect &&
#endif
- (bp->b_flags & B_READ) == 0 && wlabel == 0) {
- bp->b_error = EROFS;
- goto bad;
- }
+ (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) {
- bp->b_resid = bp->b_bcount;
- return(0);
- }
- /* or truncate if part of it fits */
- sz = maxsz - bp->b_blkno;
- if (sz <= 0) {
+ if (bp->b_blkno + sz > blockpersec(p->p_size, lp)) {
+ sz = blockpersec(p->p_size, lp) - bp->b_blkno;
+ if (bp->b_blkno == maxsz) {
+ /* if exactly at end of disk, return an EOF */
+ bp->b_resid = bp->b_bcount;
+ return(0);
+ }
+ if (sz <= 0) {
bp->b_error = EINVAL;
- goto bad;
+ goto bad;
}
- bp->b_bcount = sz << DEV_BSHIFT;
- }
+ /* 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: