summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKenneth R Westerback <krw@cvs.openbsd.org>2022-09-23 12:32:51 +0000
committerKenneth R Westerback <krw@cvs.openbsd.org>2022-09-23 12:32:51 +0000
commit5711df0fdd9bd6fa8a7329ad60c18e69088ec176 (patch)
treef1f76735dd0dec5bbd7ba91b9d1adc7b547f60e6
parentae7ac8c5eb54cd139fc092477a708f999c8b008f (diff)
Don't hardcode disk major device types inside DEBUG block. Use
findblkname() and DISKUNIT(). Allows all block devices, not just sd* and vnd* to generate useful names in DEBUG output. Cluebat by deraadt@
-rw-r--r--sys/kern/subr_disk.c29
1 files changed, 12 insertions, 17 deletions
diff --git a/sys/kern/subr_disk.c b/sys/kern/subr_disk.c
index 6931359aeba..c6272fd2359 100644
--- a/sys/kern/subr_disk.c
+++ b/sys/kern/subr_disk.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: subr_disk.c,v 1.263 2022/09/15 09:08:29 krw Exp $ */
+/* $OpenBSD: subr_disk.c,v 1.264 2022/09/23 12:32:50 krw Exp $ */
/* $NetBSD: subr_disk.c,v 1.17 1996/03/16 23:17:08 christos Exp $ */
/*
@@ -330,23 +330,18 @@ readdoslabel(struct buf *bp, void (*strat)(struct buf *), struct disklabel *lp,
#ifdef DEBUG
char devname[32];
+ const char *blkname;
+
+ blkname = findblkname(major(bp->b_dev));
+ if (blkname == NULL)
+ blkname = findblkname(major(chrtoblk(bp->b_dev)));
+ if (blkname == NULL)
+ snprintf(devname, sizeof(devname), "<%d, %d>", major(bp->b_dev),
+ minor(bp->b_dev));
+ else
+ snprintf(devname, sizeof(devname), "%s%d", blkname,
+ DISKUNIT(bp->b_dev));
- switch (major(bp->b_dev)) {
- case 13:
- case 4:
- snprintf(devname, sizeof(devname), "sd%d",
- minor(bp->b_dev) / MAXPARTITIONS);
- break;
- case 41:
- case 14:
- snprintf(devname, sizeof(devname), "vnd%d",
- minor(bp->b_dev) / MAXPARTITIONS);
- break;
- default:
- snprintf(devname, sizeof(devname), "<%d,%d>",
- major(bp->b_dev), minor(bp->b_dev));
- break;
- }
printf("readdoslabel enter: %s, spoofonly %d, partoffp %sNULL\n",
devname, spoofonly, (partoffp == NULL) ? "" : "not ");
#endif /* DEBUG */