diff options
Diffstat (limited to 'distrib/special')
-rw-r--r-- | distrib/special/disknames/Makefile | 10 | ||||
-rw-r--r-- | distrib/special/disknames/disknames.c | 23 |
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); +} |