summaryrefslogtreecommitdiff
path: root/distrib/special/disknames/disknames.c
blob: bc7de9b3096191b2752cd4c9e35d737519ca2b94 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
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);
}