summaryrefslogtreecommitdiffstats
path: root/sys/kern/subr_disk.c
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/subr_disk.c
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/subr_disk.c')
-rw-r--r--sys/kern/subr_disk.c43
1 files changed, 40 insertions, 3 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");
+}
OpenPOWER on IntegriCloud