summaryrefslogtreecommitdiffstats
path: root/sys/kern
diff options
context:
space:
mode:
authorphk <phk@FreeBSD.org>2002-09-20 12:52:03 +0000
committerphk <phk@FreeBSD.org>2002-09-20 12:52:03 +0000
commit1919170e9039df45d87abbe1d7b256cc0db1ed19 (patch)
tree1d367b627ceceea40420446ef7bb5ef0ae17c419 /sys/kern
parentb003f2381fcadb1c640d68a8885d0a806a0e8d9c (diff)
downloadFreeBSD-src-1919170e9039df45d87abbe1d7b256cc0db1ed19.zip
FreeBSD-src-1919170e9039df45d87abbe1d7b256cc0db1ed19.tar.gz
Make FreeBSD "struct disklabel" agnostic, step 311 of 723:
Rename diskerr() to disk_err() for naming consistency. Drop the by now entirely useless struct disklabel argument. Add a flag argument for new-line termination. Fix a couple of printf-format-casts to %j instead of %l. Correctly print the name of all bio commands. Move the function from subr_disklabel.c to subr_disk.c, and from <sys/disklabel.h> to <sys/disk.h>. Use the new disk_err() throughout, #include <sys/disk.h> as needed. Bump __FreeBSD_version for the sake of the aac disk drivers #ifdefs. Remove unused disklabel members of softc for aac, amr and mlx, which seem to originally have been intended for diskerr() use, but which only rotted and got Copy&Pasted at least two times to many. Sponsored by: DARPA & NAI Labs.
Diffstat (limited to 'sys/kern')
-rw-r--r--sys/kern/subr_disk.c43
-rw-r--r--sys/kern/subr_disklabel.c57
-rw-r--r--sys/kern/subr_diskmbr.c11
3 files changed, 45 insertions, 66 deletions
diff --git a/sys/kern/subr_disk.c b/sys/kern/subr_disk.c
index 8134d8c..801eaaf 100644
--- a/sys/kern/subr_disk.c
+++ b/sys/kern/subr_disk.c
@@ -11,15 +11,16 @@
*/
#include "opt_geom.h"
-#ifndef GEOM
#include <sys/param.h>
#include <sys/systm.h>
-#include <sys/kernel.h>
-#include <sys/sysctl.h>
+#include <sys/stdint.h>
#include <sys/bio.h>
#include <sys/conf.h>
#include <sys/disk.h>
+#ifndef GEOM
+#include <sys/kernel.h>
+#include <sys/sysctl.h>
#include <sys/malloc.h>
#include <sys/sysctl.h>
#include <machine/md_var.h>
@@ -432,3 +433,39 @@ SYSCTL_INT(_debug_sizeof, OID_AUTO, disk, CTLFLAG_RD,
0, sizeof(struct disk), "sizeof(struct disk)");
#endif
+
+/*-
+ * Disk error is the preface to plaintive error messages
+ * about failing disk transfers. It prints messages of the form
+ * "hp0g: BLABLABLA cmd=read fsbn 12345 of 12344-12347"
+ * blkdone should be -1 if the position of the error is unknown.
+ * The message is printed with printf.
+ */
+void
+disk_err(struct bio *bp, const char *what, int blkdone, int nl)
+{
+ daddr_t sn;
+
+ printf("%s: %s", devtoname(bp->bio_dev), what);
+ switch(bp->bio_cmd) {
+ case BIO_READ: printf("cmd=read"); break;
+ case BIO_WRITE: printf("cmd=write"); break;
+ case BIO_DELETE: printf("cmd=delete"); break;
+ case BIO_GETATTR: printf("cmd=getattr"); break;
+ case BIO_SETATTR: printf("cmd=setattr"); break;
+ default: printf("cmd=%x", bp->bio_cmd); break;
+ }
+ sn = bp->bio_blkno;
+ if (bp->bio_bcount <= DEV_BSIZE) {
+ printf("fsbn %jd%s", (intmax_t)sn, nl ? "\n" : "");
+ return;
+ }
+ if (blkdone >= 0) {
+ sn += blkdone;
+ printf("fsbn %jd of ", (intmax_t)sn);
+ }
+ printf("%jd-%jd", (intmax_t)bp->bio_blkno,
+ (intmax_t)(bp->bio_blkno + (bp->bio_bcount - 1) / DEV_BSIZE));
+ if (nl)
+ printf("\n");
+}
diff --git a/sys/kern/subr_disklabel.c b/sys/kern/subr_disklabel.c
index e10bc61..a650e3a 100644
--- a/sys/kern/subr_disklabel.c
+++ b/sys/kern/subr_disklabel.c
@@ -367,60 +367,3 @@ done:
brelse(bp);
return (error);
}
-
-/*
- * 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.
- * The message should be completed with at least a newline. There is no
- * trailing space.
- */
-void
-diskerr(bp, what, blkdone, lp)
- struct bio *bp;
- char *what;
- int blkdone;
- register struct disklabel *lp;
-{
- int part = dkpart(bp->bio_dev);
- char partname[2];
- char *sname;
- daddr_t sn;
-
- *partname = '\0';
- sname = bp->bio_dev->si_name;
- printf("%s%s: %s %sing fsbn ", sname, partname, what,
- bp->bio_cmd == BIO_READ ? "read" : "writ");
- sn = bp->bio_blkno;
- if (bp->bio_bcount <= DEV_BSIZE)
- printf("%jd", (intmax_t)sn);
- else {
- if (blkdone >= 0) {
- sn += blkdone;
- printf("%jd of ", (intmax_t)sn);
- }
- printf("%ld-%ld", (long)bp->bio_blkno,
- (long)(bp->bio_blkno + (bp->bio_bcount - 1) / DEV_BSIZE));
- }
- if (lp && (blkdone >= 0 || bp->bio_bcount <= lp->d_secsize)) {
- sn += lp->d_partitions[part].p_offset;
- /*
- * XXX should add slice offset and not print the slice,
- * but we don't know the slice pointer.
- * XXX should print bp->b_pblkno so that this will work
- * independent of slices, labels and bad sector remapping,
- * but some drivers don't set bp->b_pblkno.
- */
- printf(" (%s bn %jd; cn %jd", sname, (intmax_t)sn,
- (intmax_t)(sn / lp->d_secpercyl));
- sn %= lp->d_secpercyl;
- printf(" tn %ld sn %ld)", (long)(sn / lp->d_nsectors),
- (long)(sn % lp->d_nsectors));
- }
-}
diff --git a/sys/kern/subr_diskmbr.c b/sys/kern/subr_diskmbr.c
index 40d5b2d..2154f30 100644
--- a/sys/kern/subr_diskmbr.c
+++ b/sys/kern/subr_diskmbr.c
@@ -47,6 +47,7 @@
#define PC98_ATCOMPAT
#define dsinit atcompat_dsinit
#endif
+#include <sys/disk.h>
#include <sys/disklabel.h>
#define DOSPTYP_EXTENDED 5
#define DOSPTYP_EXTENDEDX 15
@@ -214,9 +215,8 @@ reread_mbr:
bp->b_iocmd = BIO_READ;
DEV_STRATEGY(bp, 1);
if (bufwait(bp) != 0) {
- diskerr(&bp->b_io, "reading primary partition table: error",
- 0, (struct disklabel *)NULL);
- printf("\n");
+ disk_err(&bp->b_io, "reading primary partition table: error",
+ 0, 1);
error = EIO;
goto done;
}
@@ -417,9 +417,8 @@ mbr_extended(dev, lp, ssp, ext_offset, ext_size, base_ext_offset, nsectors,
bp->b_iocmd = BIO_READ;
DEV_STRATEGY(bp, 1);
if (bufwait(bp) != 0) {
- diskerr(&bp->b_io, "reading extended partition table: error",
- 0, (struct disklabel *)NULL);
- printf("\n");
+ disk_err(&bp->b_io, "reading extended partition table: error",
+ 0, 1);
goto done;
}
OpenPOWER on IntegriCloud