X-Git-Url: https://git.subgeniuskitty.com/unix-history/.git/blobdiff_plain/5adcb3378978e4a331d22a26a291a6adbb9db374..b702c21db8cef3072e2845d46ab411775f9ec58c:/usr/src/sys/ufs/ffs/ufs_disksubr.c diff --git a/usr/src/sys/ufs/ffs/ufs_disksubr.c b/usr/src/sys/ufs/ffs/ufs_disksubr.c index faaf9ad33c..fb22543a0c 100644 --- a/usr/src/sys/ufs/ffs/ufs_disksubr.c +++ b/usr/src/sys/ufs/ffs/ufs_disksubr.c @@ -1,17 +1,17 @@ /* - * Copyright (c) 1982, 1986 Regents of the University of California. - * All rights reserved. The Berkeley software License Agreement - * specifies the terms and conditions for redistribution. + * Copyright (c) 1982, 1986, 1988 Regents of the University of California. + * All rights reserved. * - * @(#)ufs_disksubr.c 7.7 (Berkeley) %G% + * %sccs.include.redist.c% + * + * @(#)ufs_disksubr.c 7.14 (Berkeley) %G% */ #include "param.h" #include "systm.h" #include "buf.h" #include "disklabel.h" - -#include "dir.h" +#include "syslog.h" #include "user.h" /* @@ -148,9 +148,7 @@ readdisklabel(dev, strat, lp) bp->b_flags = B_BUSY | B_READ; bp->b_cylin = LABELSECTOR / lp->d_secpercyl; (*strat)(bp); - biowait(bp); - if (bp->b_flags & B_ERROR) { - u.u_error = 0; /* XXX */ + if (biowait(bp)) { msg = "I/O error"; } else for (dlp = (struct disklabel *)bp->b_un.b_addr; dlp <= (struct disklabel *)(bp->b_un.b_addr+DEV_BSIZE-sizeof(*dlp)); @@ -158,7 +156,8 @@ readdisklabel(dev, strat, lp) if (dlp->d_magic != DISKMAGIC || dlp->d_magic2 != DISKMAGIC) { if (msg == NULL) msg = "no disk label"; - } else if (dkcksum(dlp) != 0) + } else if (dlp->d_npartitions > MAXPARTITIONS || + dkcksum(dlp) != 0) msg = "disk label corrupted"; else { *lp = *dlp; @@ -166,8 +165,6 @@ readdisklabel(dev, strat, lp) break; } } - if (lp->d_npartitions > MAXPARTITIONS) - lp->d_npartitions = MAXPARTITIONS; bp->b_flags = B_INVAL | B_AGE; brelse(bp); return (msg); @@ -243,12 +240,8 @@ writedisklabel(dev, strat, lp) bp->b_bcount = lp->d_secsize; bp->b_flags = B_READ; (*strat)(bp); - biowait(bp); - if (bp->b_flags & B_ERROR) { - error = u.u_error; /* XXX */ - u.u_error = 0; + if (error = biowait(bp)) goto done; - } for (dlp = (struct disklabel *)bp->b_un.b_addr; dlp <= (struct disklabel *) (bp->b_un.b_addr + lp->d_secsize - sizeof(*dlp)); @@ -258,11 +251,7 @@ writedisklabel(dev, strat, lp) *dlp = *lp; bp->b_flags = B_WRITE; (*strat)(bp); - biowait(bp); - if (bp->b_flags & B_ERROR) { - error = u.u_error; /* XXX */ - u.u_error = 0; - } + error = biowait(bp); goto done; } } @@ -287,3 +276,58 @@ dkcksum(lp) sum ^= *start++; return (sum); } + +/* + * Disk error is the preface to plaintive error messages + * about failing disk transfers. It prints messages of the form + +hp0g: hard error reading fsbn 12345 of 12344-12347 (hp0 bn %d cn %d tn %d sn %d) + + * if the offset of the error in the transfer and a disk label + * are both available. blkdone should be -1 if the position of the error + * is unknown; the disklabel pointer may be null from drivers that have not + * been converted to use them. The message is printed with printf + * if pri is LOG_PRINTF, otherwise it uses log at the specified priority. + * The message should be completed (with at least a newline) with printf + * or addlog, respectively. There is no trailing space. + */ +diskerr(bp, dname, what, pri, blkdone, lp) + register struct buf *bp; + char *dname, *what; + int pri, blkdone; + register struct disklabel *lp; +{ + int unit = dkunit(bp->b_dev), part = dkpart(bp->b_dev); + register int (*pr)(), sn; + char partname = 'a' + part; + extern printf(), addlog(); + + if (pri != LOG_PRINTF) { + log(pri, ""); + pr = addlog; + } else + pr = printf; + (*pr)("%s%d%c: %s %sing fsbn ", dname, unit, partname, what, + bp->b_flags & B_READ ? "read" : "writ"); + sn = bp->b_blkno; + if (bp->b_bcount <= DEV_BSIZE) + (*pr)("%d", sn); + else { + if (blkdone >= 0) { + sn += blkdone; + (*pr)("%d of ", sn); + } + (*pr)("%d-%d", bp->b_blkno, + bp->b_blkno + (bp->b_bcount - 1) / DEV_BSIZE); + } + if (lp && (blkdone >= 0 || bp->b_bcount <= lp->d_secsize)) { +#ifdef tahoe + sn *= DEV_BSIZE / lp->d_secsize; /* XXX */ +#endif + sn += lp->d_partitions[part].p_offset; + (*pr)(" (%s%d bn %d; cn %d", dname, unit, sn, + sn / lp->d_secpercyl); + sn %= lp->d_secpercyl; + (*pr)(" tn %d sn %d)", sn / lp->d_nsectors, sn % lp->d_nsectors); + } +}