summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKenneth R Westerback <krw@cvs.openbsd.org>2007-02-14 22:51:17 +0000
committerKenneth R Westerback <krw@cvs.openbsd.org>2007-02-14 22:51:17 +0000
commit7779a164331ea0d4fdac89c39636177a6279ac11 (patch)
tree0d913ed6578cc1620130aa10a8df4acec92e0d87
parenta6e0e9559137021ddbc64bba9e95f4ed09b67463 (diff)
Hack a small program to return hw.disknames so that install scripts
are not dependant on a clean dmesg to scan for disks and cds. "Looks good, seems right" art@ "commit" deraadt@
-rw-r--r--distrib/special/disknames/Makefile10
-rw-r--r--distrib/special/disknames/disknames.c23
2 files changed, 33 insertions, 0 deletions
diff --git a/distrib/special/disknames/Makefile b/distrib/special/disknames/Makefile
new file mode 100644
index 00000000000..e52741a4285
--- /dev/null
+++ b/distrib/special/disknames/Makefile
@@ -0,0 +1,10 @@
+# $OpenBSD: Makefile,v 1.1 2007/02/14 22:51:16 krw Exp $
+
+PROG= disknames
+SRCS= disknames.c
+CFLAGS= -Os ${PIPE} ${DEBUG} -I${.CURDIR}
+MAN=
+
+.PATH: ${.CURDIR}/../../../distrib/special/disknames
+
+.include <bsd.prog.mk>
diff --git a/distrib/special/disknames/disknames.c b/distrib/special/disknames/disknames.c
new file mode 100644
index 00000000000..bc7de9b3096
--- /dev/null
+++ b/distrib/special/disknames/disknames.c
@@ -0,0 +1,23 @@
+#include <sys/param.h>
+#include <sys/sysctl.h>
+#include <sys/malloc.h>
+
+#include <stdlib.h>
+
+int
+main() {
+ int mib[2];
+ size_t len;
+ char *p;
+
+ mib[0] = CTL_HW;
+ mib[1] = HW_DISKNAMES;
+
+ if (sysctl(mib, 2, NULL, &len, NULL, 0) != -1)
+ if ((p = (char *)malloc(len)) != NULL)
+ if (sysctl(mib, 2, p, &len, NULL, 0) != -1) {
+ write(1, p, len);
+ _exit(0);
+ }
+ _exit(1);
+}