summaryrefslogtreecommitdiff
path: root/sys
diff options
context:
space:
mode:
authorTheo de Raadt <deraadt@cvs.openbsd.org>1996-11-06 01:35:45 +0000
committerTheo de Raadt <deraadt@cvs.openbsd.org>1996-11-06 01:35:45 +0000
commit1ef47398324136945975a96d73ca08b5cdcaedca (patch)
tree0c635e8b346635e24d16140f3dbde8a3fc3c55d6 /sys
parent595b4055ca3401d562e87711eead46dbae7a4902 (diff)
add blktochr()
Diffstat (limited to 'sys')
-rw-r--r--sys/arch/i386/i386/conf.c20
-rw-r--r--sys/arch/sparc/sparc/conf.c18
2 files changed, 37 insertions, 1 deletions
diff --git a/sys/arch/i386/i386/conf.c b/sys/arch/i386/i386/conf.c
index 2442e8eda1d..80863341d02 100644
--- a/sys/arch/i386/i386/conf.c
+++ b/sys/arch/i386/i386/conf.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: conf.c,v 1.25 1996/11/06 01:35:06 deraadt Exp $ */
+/* $OpenBSD: conf.c,v 1.26 1996/11/06 01:35:25 deraadt Exp $ */
/* $NetBSD: conf.c,v 1.75 1996/05/03 19:40:20 christos Exp $ */
/*
@@ -376,6 +376,24 @@ chrtoblk(dev)
}
/*
+ * Convert a character device number to a block device number.
+ */
+dev_t
+blktochr(dev)
+ dev_t dev;
+{
+ int blkmaj = major(dev);
+ int i;
+
+ if (blkmaj >= nblkdev)
+ return (NODEV);
+ for (i = 0; i < sizeof(chrtoblktbl)/sizeof(chrtoblktbl[0]); i++)
+ if (blkmaj == chrtoblktbl[i])
+ return (makedev(i, minor(dev)));
+ return (NODEV);
+}
+
+/*
* This entire table could be autoconfig()ed but that would mean that
* the kernel's idea of the console would be out of sync with that of
* the standalone boot. I think it best that they both use the same
diff --git a/sys/arch/sparc/sparc/conf.c b/sys/arch/sparc/sparc/conf.c
index 228fcd7d05d..9cbca7042cb 100644
--- a/sys/arch/sparc/sparc/conf.c
+++ b/sys/arch/sparc/sparc/conf.c
@@ -404,3 +404,21 @@ chrtoblk(dev)
return (NODEV);
return (makedev(blkmaj, minor(dev)));
}
+
+/*
+ * Convert a character device number to a block device number.
+ */
+dev_t
+blktochr(dev)
+ dev_t dev;
+{
+ int blkmaj = major(dev);
+ int i;
+
+ if (blkmaj >= nblkdev)
+ return (NODEV);
+ for (i = 0; i < sizeof(chrtoblktbl)/sizeof(chrtoblktbl[0]); i++)
+ if (blkmaj == chrtoblktbl[i])
+ return (makedev(i, minor(dev)));
+ return (NODEV);
+}