- * 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. */
| 38 | * The message is printed with printf. |
| 39 | */ |
| 40 | void |
| 41 | disk_err(struct bio *bp, const char *what, int blkdone, int nl) |
| 42 | { |
| 43 | daddr_t sn; |
| 44 | |
| 45 | if (bp->bio_dev != NULL) |
| 46 | printf("%s: %s ", devtoname(bp->bio_dev), what); |
| 47 | else if (bp->bio_disk != NULL) |
| 48 | printf("%s%d: %s ", |
| 49 | bp->bio_disk->d_name, bp->bio_disk->d_unit, what); |
| 50 | else |
| 51 | printf("disk??: %s ", what); |
| 52 | switch(bp->bio_cmd) { |
| 53 | case BIO_READ: printf("cmd=read "); break; |
| 54 | case BIO_WRITE: printf("cmd=write "); break; |
| 55 | case BIO_DELETE: printf("cmd=delete "); break; |
| 56 | case BIO_GETATTR: printf("cmd=getattr "); break; |
| 57 | case BIO_FLUSH: printf("cmd=flush "); break; |
| 58 | default: printf("cmd=%x ", bp->bio_cmd); break; |
| 59 | } |
| 60 | sn = bp->bio_pblkno; |
| 61 | if (bp->bio_bcount <= DEV_BSIZE) { |
| 62 | printf("fsbn %jd%s", (intmax_t)sn, nl ? "\n" : ""); |
| 63 | return; |
| 64 | } |
| 65 | if (blkdone >= 0) { |
| 66 | sn += blkdone; |
| 67 | printf("fsbn %jd of ", (intmax_t)sn); |
| 68 | } |
| 69 | printf("%jd-%jd", (intmax_t)bp->bio_pblkno, |
| 70 | (intmax_t)(bp->bio_pblkno + (bp->bio_bcount - 1) / DEV_BSIZE)); |
| 71 | if (nl) |
| 72 | printf("\n"); |
| 73 | } |
| 74 | |
| 75 | /* |
| 76 | * BIO queue implementation |