summaryrefslogtreecommitdiff
path: root/sys/arch/alpha/alpha/disksubr.c
diff options
context:
space:
mode:
Diffstat (limited to 'sys/arch/alpha/alpha/disksubr.c')
-rw-r--r--sys/arch/alpha/alpha/disksubr.c34
1 files changed, 19 insertions, 15 deletions
diff --git a/sys/arch/alpha/alpha/disksubr.c b/sys/arch/alpha/alpha/disksubr.c
index dca301906d4..43a2e32e3bb 100644
--- a/sys/arch/alpha/alpha/disksubr.c
+++ b/sys/arch/alpha/alpha/disksubr.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: disksubr.c,v 1.6 1997/01/24 19:56:32 niklas Exp $ */
+/* $OpenBSD: disksubr.c,v 1.7 1997/04/06 06:03:44 deraadt Exp $ */
/* $NetBSD: disksubr.c,v 1.9 1996/11/13 21:13:05 cgd Exp $ */
/*
@@ -119,6 +119,10 @@ readdisklabel(dev, strat, lp, clp)
*lp = *dlp;
goto done;
}
+#if defined(CD9660)
+ if (iso_disklabelspoof(dev, strat, lp) == 0)
+ goto done;
+#endif
msg = "no disk label";
done:
bp->b_flags = B_INVAL | B_AGE | B_READ;
@@ -247,39 +251,39 @@ bounds_check_with_label(bp, lp, wlabel)
struct disklabel *lp;
int wlabel;
{
-#define dkpart(dev) (minor(dev) & 7)
-
- struct partition *p = lp->d_partitions + dkpart(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;
+#define blockpersec(count, lp) ((count) * (((lp)->d_secsize) / DEV_BSIZE))
+ struct partition *p = lp->d_partitions + DISKPART(bp->b_dev);
+ 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 &&
(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_resid = (bp->b_blkno + p->p_offset) / lp->d_secpercyl;
+ bp->b_resid = (bp->b_blkno + blockpersec(p->p_offset, lp)) /
+ lp->d_secpercyl;
return(1);
bad:
bp->b_flags |= B_ERROR;