1 /* $NetBSD: dev.c,v 1.1 2008/12/22 00:56:59 haad Exp $ */
4 * NetBSD specific device routines are added to this file.
10 #include <sys/sysctl.h>
22 #define LVM_FAILURE -1
25 * Find major numbers for char/block parts of all block devices.
26 * In NetBSD every block device has it's char counter part.
27 * Return success only for device drivers with defined char/block
31 nbsd_check_dev(int major
, const char *path
)
36 struct kinfo_drivers
*kd
;
39 if (strcmp(path
,"/dev/console") == 0)
42 /* get size kernel drivers array from kernel*/
43 if (sysctlbyname("kern.drivers",NULL
,&val_len
,NULL
,0) < 0) {
44 printf("sysctlbyname failed");
48 if ((kd
= malloc (val_len
)) == NULL
){
49 printf("malloc kd info error\n");
53 /* get array from kernel */
54 if (sysctlbyname("kern.drivers", kd
, &val_len
, NULL
, 0) < 0) {
55 printf("sysctlbyname failed kd");
59 for (i
= 0, val_len
/= sizeof(*kd
); i
< val_len
; i
++)
60 /* We select only devices with correct char/block major number. */
61 if (kd
[i
].d_cmajor
!= -1 && kd
[i
].d_bmajor
!= -1) {
63 if (kd
[i
].d_cmajor
== major
)