On NetBSD/arm with FDT, the root device is "armfdt0" instead of "mainbus0". Bump pkg revision.diff -r1.79 -r1.80 pkgsrc/sysutils/hal/Makefile
(jmcneill)
@@ -1,130 +1,130 @@ | @@ -1,130 +1,130 @@ | |||
1 | # $NetBSD: Makefile,v 1.79 2017/10/10 13:51:21 jperkin Exp $ | 1 | # $NetBSD: Makefile,v 1.80 2018/05/19 13:25:36 jmcneill Exp $ | |
2 | 2 | |||
3 | DISTNAME= hal-0.5.14 | 3 | DISTNAME= hal-0.5.14 | |
4 | PKGREVISION= 18 | 4 | PKGREVISION= 19 | |
5 | CATEGORIES= sysutils | 5 | CATEGORIES= sysutils | |
6 | MASTER_SITES= http://hal.freedesktop.org/releases/ | 6 | MASTER_SITES= http://hal.freedesktop.org/releases/ | |
7 | EXTRACT_SUFX= .tar.bz2 | 7 | EXTRACT_SUFX= .tar.bz2 | |
8 | 8 | |||
9 | MAINTAINER= pkgsrc-users@NetBSD.org | 9 | MAINTAINER= pkgsrc-users@NetBSD.org | |
10 | HOMEPAGE= http://hal.freedesktop.org/ | 10 | HOMEPAGE= http://hal.freedesktop.org/ | |
11 | COMMENT= FreeDesktop hardware abstraction layer | 11 | COMMENT= FreeDesktop hardware abstraction layer | |
12 | LICENSE= gnu-gpl-v2 | 12 | LICENSE= gnu-gpl-v2 | |
13 | 13 | |||
14 | DEPENDS+= pciids-[0-9]*:../../misc/pciids | 14 | DEPENDS+= pciids-[0-9]*:../../misc/pciids | |
15 | 15 | |||
16 | BUILD_DEFS+= VARBASE PKG_SYSCONFBASE | 16 | BUILD_DEFS+= VARBASE PKG_SYSCONFBASE | |
17 | 17 | |||
18 | GNU_CONFIGURE= YES | 18 | GNU_CONFIGURE= YES | |
19 | USE_PKGLOCALEDIR= YES | 19 | USE_PKGLOCALEDIR= YES | |
20 | USE_TOOLS+= gmake intltool msgfmt perl pkg-config | 20 | USE_TOOLS+= gmake intltool msgfmt perl pkg-config | |
21 | USE_TOOLS+= autoconf automake autoreconf | 21 | USE_TOOLS+= autoconf automake autoreconf | |
22 | USE_LIBTOOL= YES | 22 | USE_LIBTOOL= YES | |
23 | 23 | |||
24 | MAKE_DIRS+= /media | 24 | MAKE_DIRS+= /media | |
25 | MAKE_DIRS+= ${VARBASE}/cache/hald | 25 | MAKE_DIRS+= ${VARBASE}/cache/hald | |
26 | SPECIAL_PERMS+= ${VARBASE}/cache/hald ${HAL_USER} ${HAL_GROUP} 0644 | 26 | SPECIAL_PERMS+= ${VARBASE}/cache/hald ${HAL_USER} ${HAL_GROUP} 0644 | |
27 | 27 | |||
28 | EGDIR= ${PREFIX}/share/examples/hal | 28 | EGDIR= ${PREFIX}/share/examples/hal | |
29 | 29 | |||
30 | CONF_FILES= ${EGDIR}/hal.conf ${PKG_SYSCONFBASE}/dbus-1/system.d/hal.conf | 30 | CONF_FILES= ${EGDIR}/hal.conf ${PKG_SYSCONFBASE}/dbus-1/system.d/hal.conf | |
31 | 31 | |||
32 | CONFIGURE_ARGS+= --sysconfdir=${PKG_SYSCONFBASE} | 32 | CONFIGURE_ARGS+= --sysconfdir=${PKG_SYSCONFBASE} | |
33 | CONFIGURE_ARGS+= --localstatedir=${VARBASE} | 33 | CONFIGURE_ARGS+= --localstatedir=${VARBASE} | |
34 | CONFIGURE_ARGS+= --with-pci-ids=${PREFIX}/share/pciids | 34 | CONFIGURE_ARGS+= --with-pci-ids=${PREFIX}/share/pciids | |
35 | CONFIGURE_ARGS+= --with-usb-ids=${PREFIX}/share/usbids | 35 | CONFIGURE_ARGS+= --with-usb-ids=${PREFIX}/share/usbids | |
36 | CONFIGURE_ARGS+= --without-os-type | 36 | CONFIGURE_ARGS+= --without-os-type | |
37 | 37 | |||
38 | .include "../../mk/bsd.prefs.mk" | 38 | .include "../../mk/bsd.prefs.mk" | |
39 | 39 | |||
40 | .if ${OPSYS} == "DragonFly" | 40 | .if ${OPSYS} == "DragonFly" | |
41 | .include "../../devel/libvolume_id/buildlink3.mk" | 41 | .include "../../devel/libvolume_id/buildlink3.mk" | |
42 | CONFIGURE_ARGS+= --with-eject=/usr/sbin/cdcontrol | 42 | CONFIGURE_ARGS+= --with-eject=/usr/sbin/cdcontrol | |
43 | CONFIGURE_ARGS+= --with-backend=freebsd | 43 | CONFIGURE_ARGS+= --with-backend=freebsd | |
44 | PLIST_SRC= PLIST.DragonFly PLIST | 44 | PLIST_SRC= PLIST.DragonFly PLIST | |
45 | 45 | |||
46 | .elif ${OPSYS} == "FreeBSD" | 46 | .elif ${OPSYS} == "FreeBSD" | |
47 | .include "../../devel/libvolume_id/buildlink3.mk" | 47 | .include "../../devel/libvolume_id/buildlink3.mk" | |
48 | CONFIGURE_ARGS+= --with-eject=/usr/sbin/cdcontrol | 48 | CONFIGURE_ARGS+= --with-eject=/usr/sbin/cdcontrol | |
49 | CONFIGURE_ARGS+= --with-backend=freebsd | 49 | CONFIGURE_ARGS+= --with-backend=freebsd | |
50 | PLIST_SRC= PLIST.FreeBSD PLIST | 50 | PLIST_SRC= PLIST.FreeBSD PLIST | |
51 | 51 | |||
52 | .elif !empty(MACHINE_PLATFORM:MNetBSD-[5-9]*) | 52 | .elif !empty(MACHINE_PLATFORM:MNetBSD-[5-9]*) | |
53 | .include "../../devel/libvolume_id/buildlink3.mk" | 53 | .include "../../devel/libvolume_id/buildlink3.mk" | |
54 | CONFIGURE_ARGS+= --with-backend=netbsd | 54 | CONFIGURE_ARGS+= --with-backend=netbsd | |
55 | HAL_GROUP= operator | 55 | HAL_GROUP= operator | |
56 | 56 | |||
57 | .elif ${OPSYS} == "Linux" | 57 | .elif ${OPSYS} == "Linux" | |
58 | .include "../../devel/gperf/buildlink3.mk" | 58 | .include "../../devel/gperf/buildlink3.mk" | |
59 | .include "../../devel/libblkid/buildlink3.mk" | 59 | .include "../../devel/libblkid/buildlink3.mk" | |
60 | .include "../../devel/libvolume_id/buildlink3.mk" | 60 | .include "../../devel/libvolume_id/buildlink3.mk" | |
61 | .include "../../sysutils/pciutils/buildlink3.mk" | 61 | .include "../../sysutils/pciutils/buildlink3.mk" | |
62 | CONFIGURE_ARGS+= --with-backend=linux | 62 | CONFIGURE_ARGS+= --with-backend=linux | |
63 | MAKE_DIRS+= /etc/udev | 63 | MAKE_DIRS+= /etc/udev | |
64 | MAKE_DIRS+= /etc/udev/rules.d | 64 | MAKE_DIRS+= /etc/udev/rules.d | |
65 | CONF_FILES+= ${EGDIR}/90-hal.rules \ | 65 | CONF_FILES+= ${EGDIR}/90-hal.rules \ | |
66 | /etc/udev/rules.d/90-hal.rules | 66 | /etc/udev/rules.d/90-hal.rules | |
67 | PLIST_VARS+= imac | 67 | PLIST_VARS+= imac | |
68 | .if ${MACHINE_ARCH} == "i386" || ${MACHINE_ARCH} == "x86_64" | 68 | .if ${MACHINE_ARCH} == "i386" || ${MACHINE_ARCH} == "x86_64" | |
69 | PLIST.imac= yes | 69 | PLIST.imac= yes | |
70 | CONFIGURE_ARGS+= --with-imac | 70 | CONFIGURE_ARGS+= --with-imac | |
71 | .else | 71 | .else | |
72 | CONFIGURE_ARGS+= --without-imac | 72 | CONFIGURE_ARGS+= --without-imac | |
73 | .endif | 73 | .endif | |
74 | .else # Unsupported systems | 74 | .else # Unsupported systems | |
75 | # Pull in the dummy backend | 75 | # Pull in the dummy backend | |
76 | .include "../../devel/libvolume_id/buildlink3.mk" | 76 | .include "../../devel/libvolume_id/buildlink3.mk" | |
77 | CONFIGURE_ARGS+= --with-backend=dummy | 77 | CONFIGURE_ARGS+= --with-backend=dummy | |
78 | PLIST_SRC= PLIST | 78 | PLIST_SRC= PLIST | |
79 | .endif | 79 | .endif | |
80 | 80 | |||
81 | CFLAGS.SunOS+= -Du_int32_t=uint32_t | 81 | CFLAGS.SunOS+= -Du_int32_t=uint32_t | |
82 | 82 | |||
83 | BUILDLINK_TRANSFORM.SunOS+= opt:-Wl,--as-needed:-Wl,-zignore | 83 | BUILDLINK_TRANSFORM.SunOS+= opt:-Wl,--as-needed:-Wl,-zignore | |
84 | 84 | |||
85 | REPLACE_INTERPRETER+= bash | 85 | REPLACE_INTERPRETER+= bash | |
86 | REPLACE.bash.old= /bin/bash | 86 | REPLACE.bash.old= /bin/bash | |
87 | REPLACE.bash.new= ${SH} | 87 | REPLACE.bash.new= ${SH} | |
88 | .for halscript in luks-remove luks-setup luks-teardown system-wol-enable system-wol-enabled system-wol-supported | 88 | .for halscript in luks-remove luks-setup luks-teardown system-wol-enable system-wol-enabled system-wol-supported | |
89 | REPLACE_FILES.bash+= tools/hal-${halscript} | 89 | REPLACE_FILES.bash+= tools/hal-${halscript} | |
90 | .endfor | 90 | .endfor | |
91 | 91 | |||
92 | HAL_USER?= haldaemon | 92 | HAL_USER?= haldaemon | |
93 | HAL_GROUP?= haldaemon | 93 | HAL_GROUP?= haldaemon | |
94 | CONFIGURE_ARGS+= --with-hal-user=${HAL_USER} | 94 | CONFIGURE_ARGS+= --with-hal-user=${HAL_USER} | |
95 | CONFIGURE_ARGS+= --with-hal-group=${HAL_GROUP} | 95 | CONFIGURE_ARGS+= --with-hal-group=${HAL_GROUP} | |
96 | CONFIGURE_ARGS+= --disable-pmu | 96 | CONFIGURE_ARGS+= --disable-pmu | |
97 | 97 | |||
98 | RCD_SCRIPTS= hal | 98 | RCD_SCRIPTS= hal | |
99 | SMF_METHODS= hal | 99 | SMF_METHODS= hal | |
100 | 100 | |||
101 | .if ${HAL_GROUP} != "operator" | 101 | .if ${HAL_GROUP} != "operator" | |
102 | PKG_GROUPS= ${HAL_GROUP} | 102 | PKG_GROUPS= ${HAL_GROUP} | |
103 | .endif | 103 | .endif | |
104 | PKG_USERS= ${HAL_USER}:${HAL_GROUP} | 104 | PKG_USERS= ${HAL_USER}:${HAL_GROUP} | |
105 | PKG_HOME.haldaemon= ${VARBASE}/run/hald | 105 | PKG_HOME.haldaemon= ${VARBASE}/run/hald | |
106 | 106 | |||
107 | FILES_SUBST+= HAL_USER=${HAL_USER} | 107 | FILES_SUBST+= HAL_USER=${HAL_USER} | |
108 | FILES_SUBST+= HAL_GROUP=${HAL_GROUP} | 108 | FILES_SUBST+= HAL_GROUP=${HAL_GROUP} | |
109 | FILES_SUBST+= PKG_HOME.haldaemon=${PKG_HOME.haldaemon} | 109 | FILES_SUBST+= PKG_HOME.haldaemon=${PKG_HOME.haldaemon} | |
110 | 110 | |||
111 | PLIST_SUBST+= PKG_SYSCONFDIR=${PKG_SYSCONFDIR} | 111 | PLIST_SUBST+= PKG_SYSCONFDIR=${PKG_SYSCONFDIR} | |
112 | 112 | |||
113 | TEST_TARGET= check | 113 | TEST_TARGET= check | |
114 | 114 | |||
115 | post-extract: | 115 | post-extract: | |
116 | ${CP} -r ${FILESDIR}/hald-netbsd ${WRKSRC}/hald/netbsd | 116 | ${CP} -r ${FILESDIR}/hald-netbsd ${WRKSRC}/hald/netbsd | |
117 | ${CP} -r ${FILESDIR}/tools-netbsd ${WRKSRC}/tools/netbsd | 117 | ${CP} -r ${FILESDIR}/tools-netbsd ${WRKSRC}/tools/netbsd | |
118 | 118 | |||
119 | pre-configure: | 119 | pre-configure: | |
120 | cd ${WRKSRC} && autoreconf -vi ${AUTORECONF_ARGS} | 120 | cd ${WRKSRC} && autoreconf -vi ${AUTORECONF_ARGS} | |
121 | 121 | |||
122 | .include "../../devel/GConf/schemas.mk" | 122 | .include "../../devel/GConf/schemas.mk" | |
123 | .include "../../devel/glib2/buildlink3.mk" | 123 | .include "../../devel/glib2/buildlink3.mk" | |
124 | .include "../../misc/usbids/buildlink3.mk" | 124 | .include "../../misc/usbids/buildlink3.mk" | |
125 | .include "../../security/policykit/buildlink3.mk" | 125 | .include "../../security/policykit/buildlink3.mk" | |
126 | .include "../../sysutils/dbus/buildlink3.mk" | 126 | .include "../../sysutils/dbus/buildlink3.mk" | |
127 | .include "../../sysutils/dbus-glib/buildlink3.mk" | 127 | .include "../../sysutils/dbus-glib/buildlink3.mk" | |
128 | .include "../../sysutils/hal-info/buildlink3.mk" | 128 | .include "../../sysutils/hal-info/buildlink3.mk" | |
129 | .include "../../textproc/expat/buildlink3.mk" | 129 | .include "../../textproc/expat/buildlink3.mk" | |
130 | .include "../../mk/bsd.pkg.mk" | 130 | .include "../../mk/bsd.pkg.mk" |
@@ -1,418 +1,433 @@ | @@ -1,418 +1,433 @@ | |||
1 | /*************************************************************************** | 1 | /*************************************************************************** | |
2 | * | 2 | * | |
3 | * devinfo.c : main file for drvctl-based device enumeration | 3 | * devinfo.c : main file for drvctl-based device enumeration | |
4 | * | 4 | * | |
5 | * Copyright 2006 Sun Microsystems, Inc. All rights reserved. | 5 | * Copyright 2006 Sun Microsystems, Inc. All rights reserved. | |
6 | * Use is subject to license terms. | 6 | * Use is subject to license terms. | |
7 | * | 7 | * | |
8 | * Licensed under the Academic Free License version 2.1 | 8 | * Licensed under the Academic Free License version 2.1 | |
9 | * | 9 | * | |
10 | **************************************************************************/ | 10 | **************************************************************************/ | |
11 | 11 | |||
12 | #ifdef HAVE_CONFIG_H | 12 | #ifdef HAVE_CONFIG_H | |
13 | # include <config.h> | 13 | # include <config.h> | |
14 | #endif | 14 | #endif | |
15 | 15 | |||
16 | #include <stdio.h> | 16 | #include <stdio.h> | |
17 | #include <string.h> | 17 | #include <string.h> | |
18 | 18 | |||
19 | #include <sys/drvctlio.h> | 19 | #include <sys/drvctlio.h> | |
20 | 20 | |||
21 | #include "../osspec.h" | 21 | #include "../osspec.h" | |
22 | #include "../logger.h" | 22 | #include "../logger.h" | |
23 | #include "../hald.h" | 23 | #include "../hald.h" | |
24 | #include "../hald_dbus.h" | 24 | #include "../hald_dbus.h" | |
25 | #include "../device_info.h" | 25 | #include "../device_info.h" | |
26 | #include "../util.h" | 26 | #include "../util.h" | |
27 | #include "../hald_runner.h" | 27 | #include "../hald_runner.h" | |
28 | #include "osspec_netbsd.h" | 28 | #include "osspec_netbsd.h" | |
29 | #include "hotplug.h" | 29 | #include "hotplug.h" | |
30 | #include "devinfo.h" | 30 | #include "devinfo.h" | |
31 | #include "devinfo_audio.h" | 31 | #include "devinfo_audio.h" | |
32 | #include "devinfo_video.h" | 32 | #include "devinfo_video.h" | |
33 | #include "devinfo_pci.h" | 33 | #include "devinfo_pci.h" | |
34 | #include "devinfo_storage.h" | 34 | #include "devinfo_storage.h" | |
35 | #include "devinfo_mass.h" | 35 | #include "devinfo_mass.h" | |
36 | #include "devinfo_usb.h" | 36 | #include "devinfo_usb.h" | |
37 | #include "devinfo_misc.h" | 37 | #include "devinfo_misc.h" | |
38 | #include "devinfo_cpu.h" | 38 | #include "devinfo_cpu.h" | |
39 | #include "devinfo_optical.h" | 39 | #include "devinfo_optical.h" | |
40 | /* #include "devinfo_scsipi.h" */ | 40 | /* #include "devinfo_scsipi.h" */ | |
41 | #include "drvctl.h" | 41 | #include "drvctl.h" | |
42 | 42 | |||
43 | void devinfo_add_subtree(HalDevice *parent, const char *devnode, gboolean is_root); | 43 | void devinfo_add_subtree(HalDevice *parent, const char *devnode, gboolean is_root); | |
44 | 44 | |||
45 | void | 45 | void | |
46 | devinfo_add(HalDevice *parent, gchar *name) | 46 | devinfo_add(HalDevice *parent, gchar *name) | |
47 | { | 47 | { | |
48 | devinfo_add_subtree (parent, name, TRUE); | 48 | devinfo_add_subtree (parent, name, TRUE); | |
49 | } | 49 | } | |
50 | 50 | |||
51 | gboolean | |||
52 | devinfo_probe(HalDevice *parent, gchar *name) | |||
53 | { | |||
54 | struct devlistargs laa; | |||
55 | ||||
56 | if (drvctl_list (name, &laa) == -1) { | |||
57 | HAL_INFO (("devinfo_probe: no %s device found", name)); | |||
58 | return FALSE; | |||
59 | } | |||
60 | ||||
61 | free (laa.l_childname); | |||
62 | ||||
63 | return TRUE; | |||
64 | } | |||
65 | ||||
51 | void | 66 | void | |
52 | devinfo_add_subtree(HalDevice *parent, const char *devnode, gboolean is_root) | 67 | devinfo_add_subtree(HalDevice *parent, const char *devnode, gboolean is_root) | |
53 | { | 68 | { | |
54 | HalDevice *d; | 69 | HalDevice *d; | |
55 | struct devlistargs laa; | 70 | struct devlistargs laa; | |
56 | int i; | 71 | int i; | |
57 | 72 | |||
58 | HAL_INFO (("add_subtree: %s", devnode)); | 73 | HAL_INFO (("add_subtree: %s", devnode)); | |
59 | 74 | |||
60 | if (parent == NULL) { | 75 | if (parent == NULL) { | |
61 | parent = devinfo_add_node (NULL, devnode); | 76 | parent = devinfo_add_node (NULL, devnode); | |
62 | } | 77 | } | |
63 | 78 | |||
64 | if (drvctl_list (devnode, &laa) == -1) { | 79 | if (drvctl_list (devnode, &laa) == -1) { | |
65 | HAL_INFO (("devinfo_add_subtree: drvctl_list failed")); | 80 | HAL_INFO (("devinfo_add_subtree: drvctl_list failed")); | |
66 | return; | 81 | return; | |
67 | } | 82 | } | |
68 | 83 | |||
69 | for (i = 0; i < laa.l_children; i++) { | 84 | for (i = 0; i < laa.l_children; i++) { | |
70 | d = devinfo_add_node (parent, laa.l_childname[i]); | 85 | d = devinfo_add_node (parent, laa.l_childname[i]); | |
71 | if (d) | 86 | if (d) | |
72 | devinfo_add_subtree (d, laa.l_childname[i], FALSE); | 87 | devinfo_add_subtree (d, laa.l_childname[i], FALSE); | |
73 | } | 88 | } | |
74 | 89 | |||
75 | if (laa.l_childname) | 90 | if (laa.l_childname) | |
76 | free(laa.l_childname); | 91 | free(laa.l_childname); | |
77 | } | 92 | } | |
78 | 93 | |||
79 | void | 94 | void | |
80 | devinfo_set_default_properties (HalDevice *d, HalDevice *parent, const char *devnode, char *devfs_path) | 95 | devinfo_set_default_properties (HalDevice *d, HalDevice *parent, const char *devnode, char *devfs_path) | |
81 | { | 96 | { | |
82 | char *driver_name, *s; | 97 | char *driver_name, *s; | |
83 | const char *s1; | 98 | const char *s1; | |
84 | char udi[HAL_PATH_MAX]; | 99 | char udi[HAL_PATH_MAX]; | |
85 | 100 | |||
86 | if (parent != NULL) { | 101 | if (parent != NULL) { | |
87 | char *pdevice = hal_device_property_get_string (parent, "netbsd.device"); | 102 | char *pdevice = hal_device_property_get_string (parent, "netbsd.device"); | |
88 | if (pdevice) { | 103 | if (pdevice) { | |
89 | gchar *path; | 104 | gchar *path; | |
90 | if (strcmp (pdevice, "mainbus0") == 0) | 105 | if (strcmp (pdevice, "mainbus0") == 0 || strcmp (pdevice, "armfdt0") == 0) | |
91 | pdevice = "computer"; | 106 | pdevice = "computer"; | |
92 | path = g_strdup_printf ("/org/freedesktop/Hal/devices/%s", pdevice); | 107 | path = g_strdup_printf ("/org/freedesktop/Hal/devices/%s", pdevice); | |
93 | hal_device_property_set_string (d, "info.parent", path); | 108 | hal_device_property_set_string (d, "info.parent", path); | |
94 | g_free (path); | 109 | g_free (path); | |
95 | } | 110 | } | |
96 | } else { | 111 | } else { | |
97 | gchar pdevnode[512]; | 112 | gchar pdevnode[512]; | |
98 | char *pdevice = pdevnode; | 113 | char *pdevice = pdevnode; | |
99 | if (drvctl_find_parent (devnode, pdevnode) == TRUE) { | 114 | if (drvctl_find_parent (devnode, pdevnode) == TRUE) { | |
100 | gchar *path; | 115 | gchar *path; | |
101 | if (strcmp (pdevnode, "mainbus0") == 0) | 116 | if (strcmp (pdevnode, "mainbus0") == 0 || strcmp (pdevnode, "armfdt0") == 0) | |
102 | pdevice = "computer"; | 117 | pdevice = "computer"; | |
103 | path = g_strdup_printf ("/org/freedesktop/Hal/devices/%s", pdevice); | 118 | path = g_strdup_printf ("/org/freedesktop/Hal/devices/%s", pdevice); | |
104 | hal_device_property_set_string (d, "info.parent", path); | 119 | hal_device_property_set_string (d, "info.parent", path); | |
105 | g_free (path); | 120 | g_free (path); | |
106 | } else | 121 | } else | |
107 | hal_device_property_set_string (d, "info.parent", "/org/freedesktop/Hal/devices/local"); | 122 | hal_device_property_set_string (d, "info.parent", "/org/freedesktop/Hal/devices/local"); | |
108 | } | 123 | } | |
109 | 124 | |||
110 | hald_compute_udi (udi, sizeof (udi), | 125 | hald_compute_udi (udi, sizeof (udi), | |
111 | "/org/freedesktop/Hal/devices/%s", devnode); | 126 | "/org/freedesktop/Hal/devices/%s", devnode); | |
112 | hal_device_set_udi (d, udi); | 127 | hal_device_set_udi (d, udi); | |
113 | 128 | |||
114 | #if notyet | 129 | #if notyet | |
115 | if (di_prop_lookup_strings (DDI_DEV_T_ANY, node, "model", &s) > 0) { | 130 | if (di_prop_lookup_strings (DDI_DEV_T_ANY, node, "model", &s) > 0) { | |
116 | hal_device_property_set_string (d, "info.product", s); | 131 | hal_device_property_set_string (d, "info.product", s); | |
117 | } else { | 132 | } else { | |
118 | hal_device_property_set_string (d, "info.product", di_node_name (node)); | 133 | hal_device_property_set_string (d, "info.product", di_node_name (node)); | |
119 | } | 134 | } | |
120 | #else | 135 | #else | |
121 | hal_device_property_set_string (d, "info.product", devnode); | 136 | hal_device_property_set_string (d, "info.product", devnode); | |
122 | #endif | 137 | #endif | |
123 | 138 | |||
124 | hal_device_property_set_string (d, "netbsd.device", devnode); | 139 | hal_device_property_set_string (d, "netbsd.device", devnode); | |
125 | 140 | |||
126 | #if notyet | 141 | #if notyet | |
127 | if ((driver_name = di_driver_name (node)) != NULL) { | 142 | if ((driver_name = di_driver_name (node)) != NULL) { | |
128 | hal_device_property_set_string (d, "info.solaris.driver", | 143 | hal_device_property_set_string (d, "info.solaris.driver", | |
129 | driver_name); | 144 | driver_name); | |
130 | } | 145 | } | |
131 | 146 | |||
132 | /* inherit parent's claim attributes */ | 147 | /* inherit parent's claim attributes */ | |
133 | if (hal_device_property_get_bool (parent, "info.claimed")) { | 148 | if (hal_device_property_get_bool (parent, "info.claimed")) { | |
134 | s1 = hal_device_property_get_string (parent, "info.claimed.service"); | 149 | s1 = hal_device_property_get_string (parent, "info.claimed.service"); | |
135 | if (s1 != NULL) { | 150 | if (s1 != NULL) { | |
136 | hal_device_property_set_bool (d, "info.claimed", TRUE); | 151 | hal_device_property_set_bool (d, "info.claimed", TRUE); | |
137 | hal_device_property_set_string (d, "info.claimed.service", s1); | 152 | hal_device_property_set_string (d, "info.claimed.service", s1); | |
138 | } | 153 | } | |
139 | } | 154 | } | |
140 | #endif | 155 | #endif | |
141 | } | 156 | } | |
142 | 157 | |||
143 | /* device handlers, ordered specific to generic */ | 158 | /* device handlers, ordered specific to generic */ | |
144 | static DevinfoDevHandler *devinfo_handlers[] = { | 159 | static DevinfoDevHandler *devinfo_handlers[] = { | |
145 | &devinfo_computer_handler, | 160 | &devinfo_computer_handler, | |
146 | &devinfo_cpu_handler, | 161 | &devinfo_cpu_handler, | |
147 | &devinfo_optical_handler, | 162 | &devinfo_optical_handler, | |
148 | #if notyet | 163 | #if notyet | |
149 | &devinfo_scsipi_handler, | 164 | &devinfo_scsipi_handler, | |
150 | &devinfo_ide_handler, | 165 | &devinfo_ide_handler, | |
151 | &devinfo_scsi_handler, | 166 | &devinfo_scsi_handler, | |
152 | &devinfo_floppy_handler, | 167 | &devinfo_floppy_handler, | |
153 | &devinfo_usb_handler, | 168 | &devinfo_usb_handler, | |
154 | &devinfo_pci_handler, | 169 | &devinfo_pci_handler, | |
155 | &devinfo_lofi_handler, | 170 | &devinfo_lofi_handler, | |
156 | #endif | 171 | #endif | |
157 | &devinfo_audio_handler, | 172 | &devinfo_audio_handler, | |
158 | &devinfo_audio_mixer_handler, | 173 | &devinfo_audio_mixer_handler, | |
159 | &devinfo_audio_dsp_handler, | 174 | &devinfo_audio_dsp_handler, | |
160 | &devinfo_video_handler, | 175 | &devinfo_video_handler, | |
161 | &devinfo_mass_handler, | 176 | &devinfo_mass_handler, | |
162 | &devinfo_default_handler, | 177 | &devinfo_default_handler, | |
163 | NULL | 178 | NULL | |
164 | }; | 179 | }; | |
165 | 180 | |||
166 | HalDevice * | 181 | HalDevice * | |
167 | devinfo_add_node(HalDevice *parent, const char *devnode) | 182 | devinfo_add_node(HalDevice *parent, const char *devnode) | |
168 | { | 183 | { | |
169 | HalDevice *d = NULL; | 184 | HalDevice *d = NULL; | |
170 | char *devfs_path; | 185 | char *devfs_path; | |
171 | char *device_type = NULL; | 186 | char *device_type = NULL; | |
172 | DevinfoDevHandler *handler; | 187 | DevinfoDevHandler *handler; | |
173 | int i; | 188 | int i; | |
174 | 189 | |||
175 | devfs_path = g_strdup_printf ("%s", devnode); | 190 | devfs_path = g_strdup_printf ("%s", devnode); | |
176 | 191 | |||
177 | #if notyet | 192 | #if notyet | |
178 | (void) di_prop_lookup_strings (DDI_DEV_T_ANY, node, "device_type", | 193 | (void) di_prop_lookup_strings (DDI_DEV_T_ANY, node, "device_type", | |
179 | &device_type); | 194 | &device_type); | |
180 | #else | 195 | #else | |
181 | device_type = "unknown"; | 196 | device_type = "unknown"; | |
182 | #endif | 197 | #endif | |
183 | 198 | |||
184 | for (i = 0; (d == NULL) && (devinfo_handlers[i] != NULL); i++) { | 199 | for (i = 0; (d == NULL) && (devinfo_handlers[i] != NULL); i++) { | |
185 | handler = devinfo_handlers[i]; | 200 | handler = devinfo_handlers[i]; | |
186 | d = handler->add (parent, devnode, devfs_path, device_type); | 201 | d = handler->add (parent, devnode, devfs_path, device_type); | |
187 | } | 202 | } | |
188 | 203 | |||
189 | g_free(devfs_path); | 204 | g_free(devfs_path); | |
190 | 205 | |||
191 | HAL_INFO (("add_node: %s", d ? hal_device_get_udi (d) : "none")); | 206 | HAL_INFO (("add_node: %s", d ? hal_device_get_udi (d) : "none")); | |
192 | return (d); | 207 | return (d); | |
193 | } | 208 | } | |
194 | 209 | |||
195 | void | 210 | void | |
196 | devinfo_hotplug_enqueue(HalDevice *d, gchar *devfs_path, DevinfoDevHandler *handler, int action, int front) | 211 | devinfo_hotplug_enqueue(HalDevice *d, gchar *devfs_path, DevinfoDevHandler *handler, int action, int front) | |
197 | { | 212 | { | |
198 | HotplugEvent *hotplug_event; | 213 | HotplugEvent *hotplug_event; | |
199 | 214 | |||
200 | hotplug_event = g_new0 (HotplugEvent, 1); | 215 | hotplug_event = g_new0 (HotplugEvent, 1); | |
201 | hotplug_event->action = action; | 216 | hotplug_event->action = action; | |
202 | hotplug_event->type = HOTPLUG_EVENT_DEVFS; | 217 | hotplug_event->type = HOTPLUG_EVENT_DEVFS; | |
203 | hotplug_event->d = d; | 218 | hotplug_event->d = d; | |
204 | strlcpy (hotplug_event->un.devfs.devfs_path, devfs_path, | 219 | strlcpy (hotplug_event->un.devfs.devfs_path, devfs_path, | |
205 | sizeof (hotplug_event->un.devfs.devfs_path)); | 220 | sizeof (hotplug_event->un.devfs.devfs_path)); | |
206 | hotplug_event->un.devfs.handler = handler; | 221 | hotplug_event->un.devfs.handler = handler; | |
207 | 222 | |||
208 | hotplug_event_enqueue (hotplug_event, front); | 223 | hotplug_event_enqueue (hotplug_event, front); | |
209 | } | 224 | } | |
210 | 225 | |||
211 | void | 226 | void | |
212 | devinfo_add_enqueue(HalDevice *d, gchar *devfs_path, DevinfoDevHandler *handler) | 227 | devinfo_add_enqueue(HalDevice *d, gchar *devfs_path, DevinfoDevHandler *handler) | |
213 | { | 228 | { | |
214 | devinfo_hotplug_enqueue (d, devfs_path, handler, HOTPLUG_ACTION_ADD, 0); | 229 | devinfo_hotplug_enqueue (d, devfs_path, handler, HOTPLUG_ACTION_ADD, 0); | |
215 | } | 230 | } | |
216 | 231 | |||
217 | void | 232 | void | |
218 | devinfo_add_enqueue_at_front(HalDevice *d, gchar *devfs_path, DevinfoDevHandler *handler) | 233 | devinfo_add_enqueue_at_front(HalDevice *d, gchar *devfs_path, DevinfoDevHandler *handler) | |
219 | { | 234 | { | |
220 | devinfo_hotplug_enqueue (d, devfs_path, handler, HOTPLUG_ACTION_ADD, 1); | 235 | devinfo_hotplug_enqueue (d, devfs_path, handler, HOTPLUG_ACTION_ADD, 1); | |
221 | } | 236 | } | |
222 | 237 | |||
223 | void | 238 | void | |
224 | devinfo_remove_enqueue(gchar *devfs_path, DevinfoDevHandler *handler) | 239 | devinfo_remove_enqueue(gchar *devfs_path, DevinfoDevHandler *handler) | |
225 | { | 240 | { | |
226 | devinfo_hotplug_enqueue (NULL, devfs_path, handler, HOTPLUG_ACTION_REMOVE, 0); | 241 | devinfo_hotplug_enqueue (NULL, devfs_path, handler, HOTPLUG_ACTION_REMOVE, 0); | |
227 | } | 242 | } | |
228 | 243 | |||
229 | void | 244 | void | |
230 | devinfo_callouts_add_done (HalDevice *d, gpointer userdata1, gpointer userdata2) | 245 | devinfo_callouts_add_done (HalDevice *d, gpointer userdata1, gpointer userdata2) | |
231 | { | 246 | { | |
232 | void *end_token = (void *) userdata1; | 247 | void *end_token = (void *) userdata1; | |
233 | 248 | |||
234 | /* Move from temporary to global device store */ | 249 | /* Move from temporary to global device store */ | |
235 | hal_device_store_remove (hald_get_tdl (), d); | 250 | hal_device_store_remove (hald_get_tdl (), d); | |
236 | hal_device_store_add (hald_get_gdl (), d); | 251 | hal_device_store_add (hald_get_gdl (), d); | |
237 | 252 | |||
238 | hotplug_event_end (end_token); | 253 | hotplug_event_end (end_token); | |
239 | } | 254 | } | |
240 | 255 | |||
241 | void | 256 | void | |
242 | devinfo_callouts_probing_done (HalDevice *d, guint32 exit_type, gint return_code, char **error, gpointer userdata1, gpointer userdata2) | 257 | devinfo_callouts_probing_done (HalDevice *d, guint32 exit_type, gint return_code, char **error, gpointer userdata1, gpointer userdata2) | |
243 | { | 258 | { | |
244 | void *end_token = (void *) userdata1; | 259 | void *end_token = (void *) userdata1; | |
245 | 260 | |||
246 | /* Discard device if probing reports failure */ | 261 | /* Discard device if probing reports failure */ | |
247 | if (exit_type != HALD_RUN_SUCCESS || (return_code != 0)) { | 262 | if (exit_type != HALD_RUN_SUCCESS || (return_code != 0)) { | |
248 | HAL_INFO (("Probing for %s failed %d", hal_device_get_udi (d), return_code)); | 263 | HAL_INFO (("Probing for %s failed %d", hal_device_get_udi (d), return_code)); | |
249 | hal_device_store_remove (hald_get_tdl (), d); | 264 | hal_device_store_remove (hald_get_tdl (), d); | |
250 | g_object_unref (d); | 265 | g_object_unref (d); | |
251 | hotplug_event_end (end_token); | 266 | hotplug_event_end (end_token); | |
252 | return; | 267 | return; | |
253 | } | 268 | } | |
254 | 269 | |||
255 | /* Merge properties from .fdi files */ | 270 | /* Merge properties from .fdi files */ | |
256 | di_search_and_merge (d, DEVICE_INFO_TYPE_INFORMATION); | 271 | di_search_and_merge (d, DEVICE_INFO_TYPE_INFORMATION); | |
257 | di_search_and_merge (d, DEVICE_INFO_TYPE_POLICY); | 272 | di_search_and_merge (d, DEVICE_INFO_TYPE_POLICY); | |
258 | 273 | |||
259 | hal_util_callout_device_add (d, devinfo_callouts_add_done, end_token, NULL); | 274 | hal_util_callout_device_add (d, devinfo_callouts_add_done, end_token, NULL); | |
260 | } | 275 | } | |
261 | 276 | |||
262 | void | 277 | void | |
263 | devinfo_callouts_preprobing_done (HalDevice *d, gpointer userdata1, gpointer userdata2) | 278 | devinfo_callouts_preprobing_done (HalDevice *d, gpointer userdata1, gpointer userdata2) | |
264 | { | 279 | { | |
265 | void *end_token = (void *) userdata1; | 280 | void *end_token = (void *) userdata1; | |
266 | DevinfoDevHandler *handler = (DevinfoDevHandler *) userdata2; | 281 | DevinfoDevHandler *handler = (DevinfoDevHandler *) userdata2; | |
267 | void (*probing_done) (HalDevice *, guint32, gint, char **, gpointer, gpointer); | 282 | void (*probing_done) (HalDevice *, guint32, gint, char **, gpointer, gpointer); | |
268 | const gchar *prober; | 283 | const gchar *prober; | |
269 | int prober_timeout; | 284 | int prober_timeout; | |
270 | 285 | |||
271 | if (hal_device_property_get_bool (d, "info.ignore")) { | 286 | if (hal_device_property_get_bool (d, "info.ignore")) { | |
272 | HAL_INFO (("Preprobing merged info.ignore==TRUE")); | 287 | HAL_INFO (("Preprobing merged info.ignore==TRUE")); | |
273 | 288 | |||
274 | /* Leave device with info.ignore==TRUE so we won't pick up children */ | 289 | /* Leave device with info.ignore==TRUE so we won't pick up children */ | |
275 | hal_device_property_remove (d, "info.category"); | 290 | hal_device_property_remove (d, "info.category"); | |
276 | hal_device_property_remove (d, "info.capabilities"); | 291 | hal_device_property_remove (d, "info.capabilities"); | |
277 | 292 | |||
278 | hal_device_store_remove (hald_get_tdl (), d); | 293 | hal_device_store_remove (hald_get_tdl (), d); | |
279 | hal_device_store_add (hald_get_gdl (), d); | 294 | hal_device_store_add (hald_get_gdl (), d); | |
280 | 295 | |||
281 | hotplug_event_end (end_token); | 296 | hotplug_event_end (end_token); | |
282 | return; | 297 | return; | |
283 | } | 298 | } | |
284 | 299 | |||
285 | if (handler != NULL && handler->get_prober != NULL) { | 300 | if (handler != NULL && handler->get_prober != NULL) { | |
286 | prober = handler->get_prober (d, &prober_timeout); | 301 | prober = handler->get_prober (d, &prober_timeout); | |
287 | } else { | 302 | } else { | |
288 | prober = NULL; | 303 | prober = NULL; | |
289 | } | 304 | } | |
290 | 305 | |||
291 | if (handler->probing_done != NULL) { | 306 | if (handler->probing_done != NULL) { | |
292 | probing_done = handler->probing_done; | 307 | probing_done = handler->probing_done; | |
293 | } else { | 308 | } else { | |
294 | probing_done = devinfo_callouts_probing_done; | 309 | probing_done = devinfo_callouts_probing_done; | |
295 | } | 310 | } | |
296 | 311 | |||
297 | if (prober != NULL) { | 312 | if (prober != NULL) { | |
298 | /* probe the device */ | 313 | /* probe the device */ | |
299 | HAL_INFO(("Probing udi=%s", hal_device_get_udi (d))); | 314 | HAL_INFO(("Probing udi=%s", hal_device_get_udi (d))); | |
300 | hald_runner_run (d, | 315 | hald_runner_run (d, | |
301 | prober, NULL, | 316 | prober, NULL, | |
302 | prober_timeout, | 317 | prober_timeout, | |
303 | probing_done, | 318 | probing_done, | |
304 | (gpointer) end_token, (gpointer) handler); | 319 | (gpointer) end_token, (gpointer) handler); | |
305 | } else { | 320 | } else { | |
306 | probing_done (d, 0, 0, NULL, userdata1, userdata2); | 321 | probing_done (d, 0, 0, NULL, userdata1, userdata2); | |
307 | } | 322 | } | |
308 | } | 323 | } | |
309 | 324 | |||
310 | /* This is the beginning of hotplug even handling */ | 325 | /* This is the beginning of hotplug even handling */ | |
311 | void | 326 | void | |
312 | hotplug_event_begin_add_devinfo (HalDevice *d, HalDevice *parent, DevinfoDevHandler *handler, void *end_token) | 327 | hotplug_event_begin_add_devinfo (HalDevice *d, HalDevice *parent, DevinfoDevHandler *handler, void *end_token) | |
313 | { | 328 | { | |
314 | HAL_INFO(("Preprobing udi=%s", hal_device_get_udi (d))); | 329 | HAL_INFO(("Preprobing udi=%s", hal_device_get_udi (d))); | |
315 | 330 | |||
316 | if (parent != NULL && hal_device_property_get_bool (parent, "info.ignore")) { | 331 | if (parent != NULL && hal_device_property_get_bool (parent, "info.ignore")) { | |
317 | HAL_INFO (("Ignoring device since parent has info.ignore==TRUE")); | 332 | HAL_INFO (("Ignoring device since parent has info.ignore==TRUE")); | |
318 | 333 | |||
319 | hotplug_event_end (end_token); | 334 | hotplug_event_end (end_token); | |
320 | return; | 335 | return; | |
321 | } | 336 | } | |
322 | 337 | |||
323 | /* add to TDL so preprobing callouts and prober can access it */ | 338 | /* add to TDL so preprobing callouts and prober can access it */ | |
324 | hal_device_store_add (hald_get_tdl (), d); | 339 | hal_device_store_add (hald_get_tdl (), d); | |
325 | 340 | |||
326 | #if 0 | 341 | #if 0 | |
327 | /* Process preprobe fdi files */ | 342 | /* Process preprobe fdi files */ | |
328 | di_search_and_merge (d, DEVICE_INFO_TYPE_PREPROBE); | 343 | di_search_and_merge (d, DEVICE_INFO_TYPE_PREPROBE); | |
329 | #endif | 344 | #endif | |
330 | 345 | |||
331 | /* Run preprobe callouts */ | 346 | /* Run preprobe callouts */ | |
332 | hal_util_callout_device_preprobe (d, devinfo_callouts_preprobing_done, end_token, handler); | 347 | hal_util_callout_device_preprobe (d, devinfo_callouts_preprobing_done, end_token, handler); | |
333 | } | 348 | } | |
334 | 349 | |||
335 | void | 350 | void | |
336 | devinfo_remove (gchar *devfs_path) | 351 | devinfo_remove (gchar *devfs_path) | |
337 | { | 352 | { | |
338 | devinfo_remove_enqueue ((gchar *)devfs_path, NULL); | 353 | devinfo_remove_enqueue ((gchar *)devfs_path, NULL); | |
339 | } | 354 | } | |
340 | 355 | |||
341 | /* generate hotplug event for each device in this branch */ | 356 | /* generate hotplug event for each device in this branch */ | |
342 | void | 357 | void | |
343 | devinfo_remove_branch (gchar *devnode, HalDevice *d) | 358 | devinfo_remove_branch (gchar *devnode, HalDevice *d) | |
344 | { | 359 | { | |
345 | GSList *i; | 360 | GSList *i; | |
346 | GSList *children; | 361 | GSList *children; | |
347 | HalDevice *child; | 362 | HalDevice *child; | |
348 | char *child_devfs_path; | 363 | char *child_devfs_path; | |
349 | 364 | |||
350 | if (d == NULL) { | 365 | if (d == NULL) { | |
351 | d = hal_device_store_match_key_value_string (hald_get_gdl (), | 366 | d = hal_device_store_match_key_value_string (hald_get_gdl (), | |
352 | "netbsd.device", devnode); | 367 | "netbsd.device", devnode); | |
353 | if (d == NULL) | 368 | if (d == NULL) | |
354 | return; | 369 | return; | |
355 | } | 370 | } | |
356 | 371 | |||
357 | HAL_INFO (("remove_branch: %s %s\n", devnode, hal_device_get_udi (d))); | 372 | HAL_INFO (("remove_branch: %s %s\n", devnode, hal_device_get_udi (d))); | |
358 | 373 | |||
359 | /* first remove children */ | 374 | /* first remove children */ | |
360 | children = hal_device_store_match_multiple_key_value_string (hald_get_gdl(), | 375 | children = hal_device_store_match_multiple_key_value_string (hald_get_gdl(), | |
361 | "info.parent", hal_device_get_udi (d)); | 376 | "info.parent", hal_device_get_udi (d)); | |
362 | for (i = children; i != NULL; i = g_slist_next (i)) { | 377 | for (i = children; i != NULL; i = g_slist_next (i)) { | |
363 | child = HAL_DEVICE (i->data); | 378 | child = HAL_DEVICE (i->data); | |
364 | HAL_INFO (("remove_branch: child %s\n", hal_device_get_udi (child))); | 379 | HAL_INFO (("remove_branch: child %s\n", hal_device_get_udi (child))); | |
365 | devinfo_remove_branch ((gchar *)hal_device_property_get_string (child, "netbsd.device"), child); | 380 | devinfo_remove_branch ((gchar *)hal_device_property_get_string (child, "netbsd.device"), child); | |
366 | } | 381 | } | |
367 | g_slist_free (children); | 382 | g_slist_free (children); | |
368 | HAL_INFO (("remove_branch: done with children")); | 383 | HAL_INFO (("remove_branch: done with children")); | |
369 | 384 | |||
370 | /* then remove self */ | 385 | /* then remove self */ | |
371 | HAL_INFO (("remove_branch: queueing %s", devnode)); | 386 | HAL_INFO (("remove_branch: queueing %s", devnode)); | |
372 | devinfo_remove_enqueue (devnode, NULL); | 387 | devinfo_remove_enqueue (devnode, NULL); | |
373 | } | 388 | } | |
374 | 389 | |||
375 | void | 390 | void | |
376 | devinfo_callouts_remove_done (HalDevice *d, gpointer userdata1, gpointer userdata2) | 391 | devinfo_callouts_remove_done (HalDevice *d, gpointer userdata1, gpointer userdata2) | |
377 | { | 392 | { | |
378 | void *end_token = (void *) userdata1; | 393 | void *end_token = (void *) userdata1; | |
379 | 394 | |||
380 | HAL_INFO (("Remove callouts completed udi=%s", hal_device_get_udi (d))); | 395 | HAL_INFO (("Remove callouts completed udi=%s", hal_device_get_udi (d))); | |
381 | 396 | |||
382 | if (!hal_device_store_remove (hald_get_gdl (), d)) { | 397 | if (!hal_device_store_remove (hald_get_gdl (), d)) { | |
383 | HAL_WARNING (("Error removing device")); | 398 | HAL_WARNING (("Error removing device")); | |
384 | } | 399 | } | |
385 | g_object_unref (d); | 400 | g_object_unref (d); | |
386 | 401 | |||
387 | hotplug_event_end (end_token); | 402 | hotplug_event_end (end_token); | |
388 | } | 403 | } | |
389 | 404 | |||
390 | void | 405 | void | |
391 | hotplug_event_begin_remove_devinfo (HalDevice *d, gchar *devfs_path, void *end_token) | 406 | hotplug_event_begin_remove_devinfo (HalDevice *d, gchar *devfs_path, void *end_token) | |
392 | { | 407 | { | |
393 | #if notyet | 408 | #if notyet | |
394 | if (hal_device_has_capability (d, "volume")) { | 409 | if (hal_device_has_capability (d, "volume")) { | |
395 | devinfo_volume_hotplug_begin_remove (d, devfs_path, end_token); | 410 | devinfo_volume_hotplug_begin_remove (d, devfs_path, end_token); | |
396 | } else { | 411 | } else { | |
397 | hal_util_callout_device_remove (d, devinfo_callouts_remove_done, end_token, NULL); | 412 | hal_util_callout_device_remove (d, devinfo_callouts_remove_done, end_token, NULL); | |
398 | } | 413 | } | |
399 | #else | 414 | #else | |
400 | #warning hotplug_event_begin_remove_devinfo TODO | 415 | #warning hotplug_event_begin_remove_devinfo TODO | |
401 | hal_util_callout_device_remove (d, devinfo_callouts_remove_done, end_token, NULL); | 416 | hal_util_callout_device_remove (d, devinfo_callouts_remove_done, end_token, NULL); | |
402 | #endif | 417 | #endif | |
403 | } | 418 | } | |
404 | 419 | |||
405 | gboolean | 420 | gboolean | |
406 | devinfo_device_rescan (HalDevice *d) | 421 | devinfo_device_rescan (HalDevice *d) | |
407 | { | 422 | { | |
408 | #if notyet | 423 | #if notyet | |
409 | if (hal_device_has_capability (d, "block")) { | 424 | if (hal_device_has_capability (d, "block")) { | |
410 | return (devinfo_storage_device_rescan (d)); | 425 | return (devinfo_storage_device_rescan (d)); | |
411 | } else { | 426 | } else { | |
412 | return (FALSE); | 427 | return (FALSE); | |
413 | } | 428 | } | |
414 | #else | 429 | #else | |
415 | #warning devinfo_device_rescan TODO | 430 | #warning devinfo_device_rescan TODO | |
416 | return FALSE; | 431 | return FALSE; | |
417 | #endif | 432 | #endif | |
418 | } | 433 | } |
@@ -1,72 +1,73 @@ | @@ -1,72 +1,73 @@ | |||
1 | /*************************************************************************** | 1 | /*************************************************************************** | |
2 | * | 2 | * | |
3 | * devinfo.h : definitions for libdevinfo-based device enumeration | 3 | * devinfo.h : definitions for libdevinfo-based device enumeration | |
4 | * | 4 | * | |
5 | * Copyright 2007 Sun Microsystems, Inc. All rights reserved. | 5 | * Copyright 2007 Sun Microsystems, Inc. All rights reserved. | |
6 | * Use is subject to license terms. | 6 | * Use is subject to license terms. | |
7 | * | 7 | * | |
8 | * Licensed under the Academic Free License version 2.1 | 8 | * Licensed under the Academic Free License version 2.1 | |
9 | * | 9 | * | |
10 | **************************************************************************/ | 10 | **************************************************************************/ | |
11 | 11 | |||
12 | #ifndef DEVINFO_H | 12 | #ifndef DEVINFO_H | |
13 | #define DEVINFO_H | 13 | #define DEVINFO_H | |
14 | 14 | |||
15 | #include <glib.h> | 15 | #include <glib.h> | |
16 | 16 | |||
17 | #include <prop/proplib.h> | 17 | #include <prop/proplib.h> | |
18 | 18 | |||
19 | #include "../hald.h" | 19 | #include "../hald.h" | |
20 | #include "../device_info.h" | 20 | #include "../device_info.h" | |
21 | 21 | |||
22 | typedef struct DevinfoDevHandler_s | 22 | typedef struct DevinfoDevHandler_s | |
23 | { | 23 | { | |
24 | HalDevice *(*add) (HalDevice *parent, const char *devnode, char *devfs_path, char *device_type); | 24 | HalDevice *(*add) (HalDevice *parent, const char *devnode, char *devfs_path, char *device_type); | |
25 | 25 | |||
26 | /* yet unused */ | 26 | /* yet unused */ | |
27 | void (*remove) (char *devfs_path); | 27 | void (*remove) (char *devfs_path); | |
28 | 28 | |||
29 | void (*hotplug_begin_add) (HalDevice *d, HalDevice *parent, struct DevinfoDevHandler_s *handler, void *end_token); | 29 | void (*hotplug_begin_add) (HalDevice *d, HalDevice *parent, struct DevinfoDevHandler_s *handler, void *end_token); | |
30 | 30 | |||
31 | void (*hotplug_begin_remove) (HalDevice *d, struct DevinfoDevHandler_s *handler, void *end_token); | 31 | void (*hotplug_begin_remove) (HalDevice *d, struct DevinfoDevHandler_s *handler, void *end_token); | |
32 | 32 | |||
33 | void (*probing_done) (HalDevice *d, guint32 exit_type, gint return_code, char **error, gpointer userdata1, gpointer userdata2); | 33 | void (*probing_done) (HalDevice *d, guint32 exit_type, gint return_code, char **error, gpointer userdata1, gpointer userdata2); | |
34 | 34 | |||
35 | const gchar *(*get_prober) (HalDevice *d, int *timeout); | 35 | const gchar *(*get_prober) (HalDevice *d, int *timeout); | |
36 | } DevinfoDevHandler; | 36 | } DevinfoDevHandler; | |
37 | 37 | |||
38 | #define PROP_INT(d, node, v, diprop, halprop) \ | 38 | #define PROP_INT(d, node, v, diprop, halprop) \ | |
39 | if (di_prop_lookup_ints(DDI_DEV_T_ANY, node, diprop, &(v)) > 0) { \ | 39 | if (di_prop_lookup_ints(DDI_DEV_T_ANY, node, diprop, &(v)) > 0) { \ | |
40 | hal_device_property_set_int (d, halprop, *(v)); \ | 40 | hal_device_property_set_int (d, halprop, *(v)); \ | |
41 | } | 41 | } | |
42 | 42 | |||
43 | #define PROP_STR(d, node, v, diprop, halprop) \ | 43 | #define PROP_STR(d, node, v, diprop, halprop) \ | |
44 | if (di_prop_lookup_strings(DDI_DEV_T_ANY, node, diprop, &(v)) > 0) { \ | 44 | if (di_prop_lookup_strings(DDI_DEV_T_ANY, node, diprop, &(v)) > 0) { \ | |
45 | hal_device_property_set_string (d, halprop, v); \ | 45 | hal_device_property_set_string (d, halprop, v); \ | |
46 | } | 46 | } | |
47 | 47 | |||
48 | #define PROP_BOOL(d, node, v, diprop, halprop) \ | 48 | #define PROP_BOOL(d, node, v, diprop, halprop) \ | |
49 | hal_device_property_set_bool (d, halprop, \ | 49 | hal_device_property_set_bool (d, halprop, \ | |
50 | (di_prop_lookup_ints(DDI_DEV_T_ANY, node, diprop, &(v)) >= 0)); | 50 | (di_prop_lookup_ints(DDI_DEV_T_ANY, node, diprop, &(v)) >= 0)); | |
51 | 51 | |||
52 | #define NELEM(a) (sizeof (a) / sizeof (*(a))) | 52 | #define NELEM(a) (sizeof (a) / sizeof (*(a))) | |
53 | 53 | |||
54 | void devinfo_add (HalDevice *parent, gchar *path); | 54 | void devinfo_add (HalDevice *parent, gchar *path); | |
55 | gboolean devinfo_probe (HalDevice *parent, gchar *path); | |||
55 | HalDevice *devinfo_add_node(HalDevice *parent, const char *devnode); | 56 | HalDevice *devinfo_add_node(HalDevice *parent, const char *devnode); | |
56 | void devinfo_set_default_properties (HalDevice *d, HalDevice *parent, const char *devnode, char *devfs_path); | 57 | void devinfo_set_default_properties (HalDevice *d, HalDevice *parent, const char *devnode, char *devfs_path); | |
57 | void devinfo_callouts_preprobing_done (HalDevice *d, gpointer userdata1, gpointer userdata2); | 58 | void devinfo_callouts_preprobing_done (HalDevice *d, gpointer userdata1, gpointer userdata2); | |
58 | void devinfo_callouts_probing_done (HalDevice *d, guint32 exit_type, gint return_code, char **error, | 59 | void devinfo_callouts_probing_done (HalDevice *d, guint32 exit_type, gint return_code, char **error, | |
59 | gpointer userdata1, gpointer userdata2); | 60 | gpointer userdata1, gpointer userdata2); | |
60 | void devinfo_callouts_add_done (HalDevice *d, gpointer userdata1, gpointer userdata2); | 61 | void devinfo_callouts_add_done (HalDevice *d, gpointer userdata1, gpointer userdata2); | |
61 | void devinfo_callouts_remove_done (HalDevice *d, gpointer userdata1, gpointer userdata2); | 62 | void devinfo_callouts_remove_done (HalDevice *d, gpointer userdata1, gpointer userdata2); | |
62 | void hotplug_event_begin_add_devinfo (HalDevice *d, HalDevice *parent, DevinfoDevHandler *handler, void *end_token); | 63 | void hotplug_event_begin_add_devinfo (HalDevice *d, HalDevice *parent, DevinfoDevHandler *handler, void *end_token); | |
63 | void devinfo_remove (gchar *path); | 64 | void devinfo_remove (gchar *path); | |
64 | void devinfo_remove_branch (gchar *path, HalDevice *d); | 65 | void devinfo_remove_branch (gchar *path, HalDevice *d); | |
65 | void hotplug_event_begin_remove_devinfo (HalDevice *d, gchar *devfs_path, void *end_token); | 66 | void hotplug_event_begin_remove_devinfo (HalDevice *d, gchar *devfs_path, void *end_token); | |
66 | void devinfo_hotplug_enqueue(HalDevice *d, gchar *devfs_path, DevinfoDevHandler *handler, int action, int front); | 67 | void devinfo_hotplug_enqueue(HalDevice *d, gchar *devfs_path, DevinfoDevHandler *handler, int action, int front); | |
67 | void devinfo_add_enqueue(HalDevice *d, gchar *devfs_path, DevinfoDevHandler *handler); | 68 | void devinfo_add_enqueue(HalDevice *d, gchar *devfs_path, DevinfoDevHandler *handler); | |
68 | void devinfo_add_enqueue_at_front(HalDevice *d, gchar *devfs_path, DevinfoDevHandler *handler); | 69 | void devinfo_add_enqueue_at_front(HalDevice *d, gchar *devfs_path, DevinfoDevHandler *handler); | |
69 | void devinfo_remove_enqueue(gchar *devfs_path, DevinfoDevHandler *handler); | 70 | void devinfo_remove_enqueue(gchar *devfs_path, DevinfoDevHandler *handler); | |
70 | gboolean devinfo_device_rescan (HalDevice *d); | 71 | gboolean devinfo_device_rescan (HalDevice *d); | |
71 | 72 | |||
72 | #endif /* DEVINFO_H */ | 73 | #endif /* DEVINFO_H */ |
@@ -1,204 +1,204 @@ | @@ -1,204 +1,204 @@ | |||
1 | /*************************************************************************** | 1 | /*************************************************************************** | |
2 | * | 2 | * | |
3 | * hotplug.c : HAL-internal hotplug events | 3 | * hotplug.c : HAL-internal hotplug events | |
4 | * | 4 | * | |
5 | * Copyright 2006 Sun Microsystems, Inc. All rights reserved. | 5 | * Copyright 2006 Sun Microsystems, Inc. All rights reserved. | |
6 | * Use is subject to license terms. | 6 | * Use is subject to license terms. | |
7 | * | 7 | * | |
8 | * Licensed under the Academic Free License version 2.1 | 8 | * Licensed under the Academic Free License version 2.1 | |
9 | * | 9 | * | |
10 | **************************************************************************/ | 10 | **************************************************************************/ | |
11 | 11 | |||
12 | #pragma ident "@(#)hotplug.c 1.2 06/10/13 SMI" | 12 | #pragma ident "@(#)hotplug.c 1.2 06/10/13 SMI" | |
13 | 13 | |||
14 | #ifdef HAVE_CONFIG_H | 14 | #ifdef HAVE_CONFIG_H | |
15 | # include <config.h> | 15 | # include <config.h> | |
16 | #endif | 16 | #endif | |
17 | 17 | |||
18 | #include <stdio.h> | 18 | #include <stdio.h> | |
19 | #include <string.h> | 19 | #include <string.h> | |
20 | #include <errno.h> | 20 | #include <errno.h> | |
21 | #include <sys/types.h> | 21 | #include <sys/types.h> | |
22 | #include <sys/stat.h> | 22 | #include <sys/stat.h> | |
23 | #include <sys/un.h> | 23 | #include <sys/un.h> | |
24 | #include <sys/utsname.h> | 24 | #include <sys/utsname.h> | |
25 | #include <unistd.h> | 25 | #include <unistd.h> | |
26 | 26 | |||
27 | #include <glib.h> | 27 | #include <glib.h> | |
28 | #include <dbus/dbus.h> | 28 | #include <dbus/dbus.h> | |
29 | #include <dbus/dbus-glib.h> | 29 | #include <dbus/dbus-glib.h> | |
30 | 30 | |||
31 | #include "../osspec.h" | 31 | #include "../osspec.h" | |
32 | #include "../logger.h" | 32 | #include "../logger.h" | |
33 | #include "../hald.h" | 33 | #include "../hald.h" | |
34 | #include "../device_info.h" | 34 | #include "../device_info.h" | |
35 | 35 | |||
36 | #include "osspec_netbsd.h" | 36 | #include "osspec_netbsd.h" | |
37 | #include "hotplug.h" | 37 | #include "hotplug.h" | |
38 | #include "devinfo.h" | 38 | #include "devinfo.h" | |
39 | 39 | |||
40 | /** Queue of ordered hotplug events */ | 40 | /** Queue of ordered hotplug events */ | |
41 | GQueue *hotplug_event_queue; | 41 | GQueue *hotplug_event_queue; | |
42 | 42 | |||
43 | /** List of HotplugEvent objects we are currently processing */ | 43 | /** List of HotplugEvent objects we are currently processing */ | |
44 | GSList *hotplug_events_in_progress = NULL; | 44 | GSList *hotplug_events_in_progress = NULL; | |
45 | 45 | |||
46 | static void hotplug_event_begin (HotplugEvent *hotplug_event); | 46 | static void hotplug_event_begin (HotplugEvent *hotplug_event); | |
47 | 47 | |||
48 | void | 48 | void | |
49 | hotplug_event_end (void *end_token) | 49 | hotplug_event_end (void *end_token) | |
50 | { | 50 | { | |
51 | HotplugEvent *hotplug_event = (HotplugEvent *) end_token; | 51 | HotplugEvent *hotplug_event = (HotplugEvent *) end_token; | |
52 | 52 | |||
53 | hotplug_events_in_progress = g_slist_remove (hotplug_events_in_progress, hotplug_event); | 53 | hotplug_events_in_progress = g_slist_remove (hotplug_events_in_progress, hotplug_event); | |
54 | g_free (hotplug_event); | 54 | g_free (hotplug_event); | |
55 | hotplug_event_process_queue (); | 55 | hotplug_event_process_queue (); | |
56 | } | 56 | } | |
57 | 57 | |||
58 | static void | 58 | static void | |
59 | hotplug_event_begin_devfs_add (HotplugEvent *hotplug_event, HalDevice *d) | 59 | hotplug_event_begin_devfs_add (HotplugEvent *hotplug_event, HalDevice *d) | |
60 | { | 60 | { | |
61 | HalDevice *parent; | 61 | HalDevice *parent; | |
62 | const gchar *parent_udi; | 62 | const gchar *parent_udi; | |
63 | void (*begin_add_func) (HalDevice *, HalDevice *, DevinfoDevHandler *, void *); | 63 | void (*begin_add_func) (HalDevice *, HalDevice *, DevinfoDevHandler *, void *); | |
64 | 64 | |||
65 | if (d != NULL) { | 65 | if (d != NULL) { | |
66 | /* XXX */ | 66 | /* XXX */ | |
67 | HAL_ERROR (("devpath %s already present in store, ignore event", hotplug_event->un.devfs.devfs_path)); | 67 | HAL_ERROR (("devpath %s already present in store, ignore event", hotplug_event->un.devfs.devfs_path)); | |
68 | hotplug_event_end ((void *) hotplug_event); | 68 | hotplug_event_end ((void *) hotplug_event); | |
69 | return; | 69 | return; | |
70 | } | 70 | } | |
71 | 71 | |||
72 | /* find parent */ | 72 | /* find parent */ | |
73 | parent_udi = hal_device_property_get_string (hotplug_event->d, "info.parent"); | 73 | parent_udi = hal_device_property_get_string (hotplug_event->d, "info.parent"); | |
74 | if (parent_udi == NULL || strlen(parent_udi) == 0) { | 74 | if (parent_udi == NULL || strlen(parent_udi) == 0) { | |
75 | parent = NULL; | 75 | parent = NULL; | |
76 | HAL_INFO (("no info.parent parameter found")); | 76 | HAL_INFO (("no info.parent parameter found")); | |
77 | } else { | 77 | } else { | |
78 | parent = hal_device_store_match_key_value_string (hald_get_gdl (), "info.udi", parent_udi); | 78 | parent = hal_device_store_match_key_value_string (hald_get_gdl (), "info.udi", parent_udi); | |
79 | if (parent == NULL) | 79 | if (parent == NULL) | |
80 | HAL_INFO (("no info.udi=%s parameter found", parent_udi)); | 80 | HAL_INFO (("no info.udi=%s parameter found", parent_udi)); | |
81 | } | 81 | } | |
82 | 82 | |||
83 | if (parent == NULL) { | 83 | if (parent == NULL) { | |
84 | gchar pdevnode[512]; | 84 | gchar pdevnode[512]; | |
85 | HAL_INFO (("couldn't look up %s parent by udi, trying netbsd.device", hotplug_event->un.devfs.devfs_path)); | 85 | HAL_INFO (("couldn't look up %s parent by udi, trying netbsd.device", hotplug_event->un.devfs.devfs_path)); | |
86 | if (drvctl_find_parent (hotplug_event->un.devfs.devfs_path, pdevnode) == TRUE) | 86 | if (drvctl_find_parent (hotplug_event->un.devfs.devfs_path, pdevnode) == TRUE) | |
87 | parent = hal_device_store_match_key_value_string (hald_get_gdl (), "netbsd.device", pdevnode); | 87 | parent = hal_device_store_match_key_value_string (hald_get_gdl (), "netbsd.device", pdevnode); | |
88 | } | 88 | } | |
89 | 89 | |||
90 | /* only root node is allowed to be orphan */ | 90 | /* only root node is allowed to be orphan */ | |
91 | if (parent == NULL) { | 91 | if (parent == NULL) { | |
92 | if (strcmp(hotplug_event->un.devfs.devfs_path, "mainbus0") != 0) { | 92 | if (strcmp(hotplug_event->un.devfs.devfs_path, "mainbus0") != 0 && strcmp(hotplug_event->un.devfs.devfs_path, "armfdt0") != 0) { | |
93 | HAL_ERROR (("Parent is NULL devfs_path=%s parent_udi=%s", hotplug_event->un.devfs.devfs_path, parent_udi ? parent_udi : "<null>")); | 93 | HAL_ERROR (("Parent is NULL devfs_path=%s parent_udi=%s", hotplug_event->un.devfs.devfs_path, parent_udi ? parent_udi : "<null>")); | |
94 | hotplug_event_end ((void *) hotplug_event); | 94 | hotplug_event_end ((void *) hotplug_event); | |
95 | return; | 95 | return; | |
96 | } | 96 | } | |
97 | } | 97 | } | |
98 | 98 | |||
99 | /* children of ignored parent should be ignored */ | 99 | /* children of ignored parent should be ignored */ | |
100 | if (hal_device_property_get_bool (parent, "info.ignore")) { | 100 | if (hal_device_property_get_bool (parent, "info.ignore")) { | |
101 | HAL_INFO (("parent ignored %s", parent_udi)); | 101 | HAL_INFO (("parent ignored %s", parent_udi)); | |
102 | hotplug_event_end ((void *) hotplug_event); | 102 | hotplug_event_end ((void *) hotplug_event); | |
103 | return; | 103 | return; | |
104 | } | 104 | } | |
105 | 105 | |||
106 | /* custom or generic add function */ | 106 | /* custom or generic add function */ | |
107 | begin_add_func = hotplug_event->un.devfs.handler->hotplug_begin_add; | 107 | begin_add_func = hotplug_event->un.devfs.handler->hotplug_begin_add; | |
108 | if (begin_add_func == NULL) { | 108 | if (begin_add_func == NULL) { | |
109 | begin_add_func = hotplug_event_begin_add_devinfo; | 109 | begin_add_func = hotplug_event_begin_add_devinfo; | |
110 | } | 110 | } | |
111 | begin_add_func (hotplug_event->d, | 111 | begin_add_func (hotplug_event->d, | |
112 | parent, | 112 | parent, | |
113 | hotplug_event->un.devfs.handler, | 113 | hotplug_event->un.devfs.handler, | |
114 | (void *) hotplug_event); | 114 | (void *) hotplug_event); | |
115 | } | 115 | } | |
116 | 116 | |||
117 | static void | 117 | static void | |
118 | hotplug_event_begin_devfs_remove (HotplugEvent *hotplug_event, HalDevice *d) | 118 | hotplug_event_begin_devfs_remove (HotplugEvent *hotplug_event, HalDevice *d) | |
119 | { | 119 | { | |
120 | if (d == NULL) { | 120 | if (d == NULL) { | |
121 | HAL_ERROR (("devpath %s not present in store, ignore event", hotplug_event->un.devfs.devfs_path)); | 121 | HAL_ERROR (("devpath %s not present in store, ignore event", hotplug_event->un.devfs.devfs_path)); | |
122 | hotplug_event_end ((void *) hotplug_event); | 122 | hotplug_event_end ((void *) hotplug_event); | |
123 | return; | 123 | return; | |
124 | } | 124 | } | |
125 | HAL_INFO (("hotplug_event_begin_devfs_remove %s", hal_device_get_udi (d))); | 125 | HAL_INFO (("hotplug_event_begin_devfs_remove %s", hal_device_get_udi (d))); | |
126 | 126 | |||
127 | hotplug_event_begin_remove_devinfo(d, | 127 | hotplug_event_begin_remove_devinfo(d, | |
128 | hotplug_event->un.devfs.devfs_path, | 128 | hotplug_event->un.devfs.devfs_path, | |
129 | (void *) hotplug_event); | 129 | (void *) hotplug_event); | |
130 | } | 130 | } | |
131 | 131 | |||
132 | static void | 132 | static void | |
133 | hotplug_event_begin_devfs (HotplugEvent *hotplug_event) | 133 | hotplug_event_begin_devfs (HotplugEvent *hotplug_event) | |
134 | { | 134 | { | |
135 | HalDevice *d; | 135 | HalDevice *d; | |
136 | 136 | |||
137 | HAL_INFO (("hotplug_event_begin_devfs: %s", hotplug_event->un.devfs.devfs_path)); | 137 | HAL_INFO (("hotplug_event_begin_devfs: %s", hotplug_event->un.devfs.devfs_path)); | |
138 | d = hal_device_store_match_key_value_string (hald_get_gdl (), | 138 | d = hal_device_store_match_key_value_string (hald_get_gdl (), | |
139 | "netbsd.device", | 139 | "netbsd.device", | |
140 | hotplug_event->un.devfs.devfs_path); | 140 | hotplug_event->un.devfs.devfs_path); | |
141 | 141 | |||
142 | if (hotplug_event->action == HOTPLUG_ACTION_ADD) { | 142 | if (hotplug_event->action == HOTPLUG_ACTION_ADD) { | |
143 | hotplug_event_begin_devfs_add (hotplug_event, d); | 143 | hotplug_event_begin_devfs_add (hotplug_event, d); | |
144 | } else if (hotplug_event->action == HOTPLUG_ACTION_REMOVE) { | 144 | } else if (hotplug_event->action == HOTPLUG_ACTION_REMOVE) { | |
145 | hotplug_event_begin_devfs_remove (hotplug_event, d); | 145 | hotplug_event_begin_devfs_remove (hotplug_event, d); | |
146 | } else { | 146 | } else { | |
147 | hotplug_event_end ((void *) hotplug_event); | 147 | hotplug_event_end ((void *) hotplug_event); | |
148 | } | 148 | } | |
149 | } | 149 | } | |
150 | 150 | |||
151 | static void | 151 | static void | |
152 | hotplug_event_begin (HotplugEvent *hotplug_event) | 152 | hotplug_event_begin (HotplugEvent *hotplug_event) | |
153 | { | 153 | { | |
154 | switch (hotplug_event->type) { | 154 | switch (hotplug_event->type) { | |
155 | 155 | |||
156 | case HOTPLUG_EVENT_DEVFS: | 156 | case HOTPLUG_EVENT_DEVFS: | |
157 | hotplug_event_begin_devfs (hotplug_event); | 157 | hotplug_event_begin_devfs (hotplug_event); | |
158 | break; | 158 | break; | |
159 | 159 | |||
160 | default: | 160 | default: | |
161 | HAL_ERROR (("Unknown hotplug event type %d", hotplug_event->type)); | 161 | HAL_ERROR (("Unknown hotplug event type %d", hotplug_event->type)); | |
162 | hotplug_event_end ((void *) hotplug_event); | 162 | hotplug_event_end ((void *) hotplug_event); | |
163 | break; | 163 | break; | |
164 | } | 164 | } | |
165 | } | 165 | } | |
166 | 166 | |||
167 | void | 167 | void | |
168 | hotplug_event_enqueue (HotplugEvent *hotplug_event, int front) | 168 | hotplug_event_enqueue (HotplugEvent *hotplug_event, int front) | |
169 | { | 169 | { | |
170 | if (hotplug_event_queue == NULL) | 170 | if (hotplug_event_queue == NULL) | |
171 | hotplug_event_queue = g_queue_new (); | 171 | hotplug_event_queue = g_queue_new (); | |
172 | 172 | |||
173 | if (front) { | 173 | if (front) { | |
174 | g_queue_push_head (hotplug_event_queue, hotplug_event); | 174 | g_queue_push_head (hotplug_event_queue, hotplug_event); | |
175 | } else { | 175 | } else { | |
176 | g_queue_push_tail (hotplug_event_queue, hotplug_event); | 176 | g_queue_push_tail (hotplug_event_queue, hotplug_event); | |
177 | } | 177 | } | |
178 | } | 178 | } | |
179 | 179 | |||
180 | void | 180 | void | |
181 | hotplug_event_process_queue (void) | 181 | hotplug_event_process_queue (void) | |
182 | { | 182 | { | |
183 | HotplugEvent *hotplug_event; | 183 | HotplugEvent *hotplug_event; | |
184 | 184 | |||
185 | if (hotplug_events_in_progress == NULL && | 185 | if (hotplug_events_in_progress == NULL && | |
186 | (hotplug_event_queue == NULL || g_queue_is_empty (hotplug_event_queue))) { | 186 | (hotplug_event_queue == NULL || g_queue_is_empty (hotplug_event_queue))) { | |
187 | hotplug_queue_now_empty (); | 187 | hotplug_queue_now_empty (); | |
188 | goto out; | 188 | goto out; | |
189 | } | 189 | } | |
190 | 190 | |||
191 | /* do not process events if some other event is in progress */ | 191 | /* do not process events if some other event is in progress */ | |
192 | if (hotplug_events_in_progress != NULL && g_slist_length (hotplug_events_in_progress) > 0) | 192 | if (hotplug_events_in_progress != NULL && g_slist_length (hotplug_events_in_progress) > 0) | |
193 | goto out; | 193 | goto out; | |
194 | 194 | |||
195 | hotplug_event = g_queue_pop_head (hotplug_event_queue); | 195 | hotplug_event = g_queue_pop_head (hotplug_event_queue); | |
196 | if (hotplug_event == NULL) | 196 | if (hotplug_event == NULL) | |
197 | goto out; | 197 | goto out; | |
198 | 198 | |||
199 | hotplug_events_in_progress = g_slist_append (hotplug_events_in_progress, hotplug_event); | 199 | hotplug_events_in_progress = g_slist_append (hotplug_events_in_progress, hotplug_event); | |
200 | hotplug_event_begin (hotplug_event); | 200 | hotplug_event_begin (hotplug_event); | |
201 | 201 | |||
202 | out: | 202 | out: | |
203 | ; | 203 | ; | |
204 | } | 204 | } |
@@ -1,168 +1,168 @@ | @@ -1,168 +1,168 @@ | |||
1 | /*************************************************************************** | 1 | /*************************************************************************** | |
2 | * | 2 | * | |
3 | * devinfo_misc : misc devices | 3 | * devinfo_misc : misc devices | |
4 | * | 4 | * | |
5 | * Copyright 2006 Sun Microsystems, Inc. All rights reserved. | 5 | * Copyright 2006 Sun Microsystems, Inc. All rights reserved. | |
6 | * Use is subject to license terms. | 6 | * Use is subject to license terms. | |
7 | * | 7 | * | |
8 | * Licensed under the Academic Free License version 2.1 | 8 | * Licensed under the Academic Free License version 2.1 | |
9 | * | 9 | * | |
10 | **************************************************************************/ | 10 | **************************************************************************/ | |
11 | 11 | |||
12 | #include <sys/types.h> | 12 | #include <sys/types.h> | |
13 | #include <sys/sysctl.h> | 13 | #include <sys/sysctl.h> | |
14 | 14 | |||
15 | #ifdef HAVE_CONFIG_H | 15 | #ifdef HAVE_CONFIG_H | |
16 | # include <config.h> | 16 | # include <config.h> | |
17 | #endif | 17 | #endif | |
18 | 18 | |||
19 | #include <sys/utsname.h> | 19 | #include <sys/utsname.h> | |
20 | #include <stdio.h> | 20 | #include <stdio.h> | |
21 | #include <string.h> | 21 | #include <string.h> | |
22 | 22 | |||
23 | #include "../osspec.h" | 23 | #include "../osspec.h" | |
24 | #include "../logger.h" | 24 | #include "../logger.h" | |
25 | #include "../hald.h" | 25 | #include "../hald.h" | |
26 | #include "../hald_dbus.h" | 26 | #include "../hald_dbus.h" | |
27 | #include "../device_info.h" | 27 | #include "../device_info.h" | |
28 | #include "../util.h" | 28 | #include "../util.h" | |
29 | #include "devinfo_misc.h" | 29 | #include "devinfo_misc.h" | |
30 | #include "drvctl.h" | 30 | #include "drvctl.h" | |
31 | 31 | |||
32 | static HalDevice *devinfo_computer_add(HalDevice *, const char *, char *, char *); | 32 | static HalDevice *devinfo_computer_add(HalDevice *, const char *, char *, char *); | |
33 | static HalDevice *devinfo_cpu_add(HalDevice *, const char *, char *,char *); | 33 | static HalDevice *devinfo_cpu_add(HalDevice *, const char *, char *,char *); | |
34 | static HalDevice *devinfo_default_add(HalDevice *, const char *, char *, char *); | 34 | static HalDevice *devinfo_default_add(HalDevice *, const char *, char *, char *); | |
35 | 35 | |||
36 | DevinfoDevHandler devinfo_computer_handler = { | 36 | DevinfoDevHandler devinfo_computer_handler = { | |
37 | devinfo_computer_add, | 37 | devinfo_computer_add, | |
38 | NULL, | 38 | NULL, | |
39 | NULL, | 39 | NULL, | |
40 | NULL, | 40 | NULL, | |
41 | NULL, | 41 | NULL, | |
42 | NULL | 42 | NULL | |
43 | }; | 43 | }; | |
44 | DevinfoDevHandler devinfo_cpu_handler = { | 44 | DevinfoDevHandler devinfo_cpu_handler = { | |
45 | devinfo_cpu_add, | 45 | devinfo_cpu_add, | |
46 | NULL, | 46 | NULL, | |
47 | NULL, | 47 | NULL, | |
48 | NULL, | 48 | NULL, | |
49 | NULL, | 49 | NULL, | |
50 | NULL | 50 | NULL | |
51 | }; | 51 | }; | |
52 | DevinfoDevHandler devinfo_default_handler = { | 52 | DevinfoDevHandler devinfo_default_handler = { | |
53 | devinfo_default_add, | 53 | devinfo_default_add, | |
54 | NULL, | 54 | NULL, | |
55 | NULL, | 55 | NULL, | |
56 | NULL, | 56 | NULL, | |
57 | NULL, | 57 | NULL, | |
58 | NULL | 58 | NULL | |
59 | }; | 59 | }; | |
60 | 60 | |||
61 | static HalDevice * | 61 | static HalDevice * | |
62 | devinfo_computer_add(HalDevice *parent, const char *devnode, char *devfs_path, char *device_type) | 62 | devinfo_computer_add(HalDevice *parent, const char *devnode, char *devfs_path, char *device_type) | |
63 | { | 63 | { | |
64 | HalDevice *d; | 64 | HalDevice *d; | |
65 | struct utsname un; | 65 | struct utsname un; | |
66 | char acpi_supported_states[20]; | 66 | char acpi_supported_states[20]; | |
67 | size_t len = sizeof(acpi_supported_states); | 67 | size_t len = sizeof(acpi_supported_states); | |
68 | 68 | |||
69 | if (strcmp (devnode, "mainbus0") != 0) { | 69 | if (strcmp (devnode, "mainbus0") != 0 && strcmp (devnode, "armfdt0") != 0) { | |
70 | return (NULL); | 70 | return (NULL); | |
71 | } | 71 | } | |
72 | 72 | |||
73 | HAL_INFO (("devinfo_computer_add parent=%p devnode=%s devfs_path=%s device_type=%s", | 73 | HAL_INFO (("devinfo_computer_add parent=%p devnode=%s devfs_path=%s device_type=%s", | |
74 | parent, devnode, devfs_path, device_type)); | 74 | parent, devnode, devfs_path, device_type)); | |
75 | 75 | |||
76 | d = hal_device_new (); | 76 | d = hal_device_new (); | |
77 | 77 | |||
78 | hal_device_property_set_string (d, "info.subsystem", "unknown"); | 78 | hal_device_property_set_string (d, "info.subsystem", "unknown"); | |
79 | hal_device_property_set_string (d, "info.product", "Computer"); | 79 | hal_device_property_set_string (d, "info.product", "Computer"); | |
80 | hal_device_set_udi (d, "/org/freedesktop/Hal/devices/computer"); | 80 | hal_device_set_udi (d, "/org/freedesktop/Hal/devices/computer"); | |
81 | hal_device_property_set_string (d, "netbsd.device", devnode); | 81 | hal_device_property_set_string (d, "netbsd.device", devnode); | |
82 | 82 | |||
83 | if (uname (&un) >= 0) { | 83 | if (uname (&un) >= 0) { | |
84 | hal_device_property_set_string (d, "system.kernel.name", un.sysname); | 84 | hal_device_property_set_string (d, "system.kernel.name", un.sysname); | |
85 | hal_device_property_set_string (d, "system.kernel.version", un.release); | 85 | hal_device_property_set_string (d, "system.kernel.version", un.release); | |
86 | hal_device_property_set_string (d, "system.kernel.machine", un.machine); | 86 | hal_device_property_set_string (d, "system.kernel.machine", un.machine); | |
87 | } | 87 | } | |
88 | 88 | |||
89 | devinfo_add_enqueue (d, devfs_path, &devinfo_computer_handler); | 89 | devinfo_add_enqueue (d, devfs_path, &devinfo_computer_handler); | |
90 | 90 | |||
91 | if (sysctlbyname ("hw.acpi.supported_states", acpi_supported_states, &len, NULL, 0) == 0 || | 91 | if (sysctlbyname ("hw.acpi.supported_states", acpi_supported_states, &len, NULL, 0) == 0 || | |
92 | sysctlbyname ("hw.acpi.sleep.states", acpi_supported_states, &len, NULL, 0) == 0) { | 92 | sysctlbyname ("hw.acpi.sleep.states", acpi_supported_states, &len, NULL, 0) == 0) { | |
93 | hal_device_property_set_string (d, "power_management.type", "acpi"); | 93 | hal_device_property_set_string (d, "power_management.type", "acpi"); | |
94 | if (strstr (acpi_supported_states, "S3") != NULL) | 94 | if (strstr (acpi_supported_states, "S3") != NULL) | |
95 | hal_device_property_set_bool (d, "power_management.can_suspend", TRUE); | 95 | hal_device_property_set_bool (d, "power_management.can_suspend", TRUE); | |
96 | else | 96 | else | |
97 | hal_device_property_set_bool (d, "power_management.can_suspend", FALSE); | 97 | hal_device_property_set_bool (d, "power_management.can_suspend", FALSE); | |
98 | 98 | |||
99 | hal_device_property_set_bool (d, "power_management.can_hibernate", FALSE); | 99 | hal_device_property_set_bool (d, "power_management.can_hibernate", FALSE); | |
100 | } | 100 | } | |
101 | 101 | |||
102 | if (drvctl_find_device ("acpibat0", NULL) == TRUE) | 102 | if (drvctl_find_device ("acpibat0", NULL) == TRUE) | |
103 | hal_device_property_set_string (d, "system.formfactor", "laptop"); | 103 | hal_device_property_set_string (d, "system.formfactor", "laptop"); | |
104 | else | 104 | else | |
105 | hal_device_property_set_string (d, "system.formfactor", "desktop"); /* XXX */ | 105 | hal_device_property_set_string (d, "system.formfactor", "desktop"); /* XXX */ | |
106 | 106 | |||
107 | devinfo_add_enqueue (d, devnode, &devinfo_default_handler); | 107 | devinfo_add_enqueue (d, devnode, &devinfo_default_handler); | |
108 | 108 | |||
109 | return d; | 109 | return d; | |
110 | } | 110 | } | |
111 | 111 | |||
112 | static HalDevice * | 112 | static HalDevice * | |
113 | devinfo_cpu_add(HalDevice *parent, const char *devnode, char *devfs_path, char *device_type) | 113 | devinfo_cpu_add(HalDevice *parent, const char *devnode, char *devfs_path, char *device_type) | |
114 | { | 114 | { | |
115 | HalDevice *d; | 115 | HalDevice *d; | |
116 | 116 | |||
117 | if (strncmp(devnode, "cpu", 3) != 0) { | 117 | if (strncmp(devnode, "cpu", 3) != 0) { | |
118 | return (NULL); | 118 | return (NULL); | |
119 | } | 119 | } | |
120 | 120 | |||
121 | HAL_INFO (("devinfo_cpu_add: parent=%p devnode=%s devfs_path=%s device_type=%s", | 121 | HAL_INFO (("devinfo_cpu_add: parent=%p devnode=%s devfs_path=%s device_type=%s", | |
122 | parent, devnode, devfs_path, device_type)); | 122 | parent, devnode, devfs_path, device_type)); | |
123 | 123 | |||
124 | d = hal_device_new (); | 124 | d = hal_device_new (); | |
125 | 125 | |||
126 | devinfo_set_default_properties (d, parent, devnode, devnode); | 126 | devinfo_set_default_properties (d, parent, devnode, devnode); | |
127 | hal_device_add_capability (d, "processor"); | 127 | hal_device_add_capability (d, "processor"); | |
128 | 128 | |||
129 | devinfo_add_enqueue (d, devnode, &devinfo_cpu_handler); | 129 | devinfo_add_enqueue (d, devnode, &devinfo_cpu_handler); | |
130 | 130 | |||
131 | return (d); | 131 | return (d); | |
132 | } | 132 | } | |
133 | 133 | |||
134 | static void | 134 | static void | |
135 | devinfo_default_apply_quirks(HalDevice *d, const char *devnode) | 135 | devinfo_default_apply_quirks(HalDevice *d, const char *devnode) | |
136 | { | 136 | { | |
137 | 137 | |||
138 | /* acpiacad(4) */ | 138 | /* acpiacad(4) */ | |
139 | if (strncmp (devnode, "acpiacad", 8) == 0) { | 139 | if (strncmp (devnode, "acpiacad", 8) == 0) { | |
140 | HAL_INFO (("%s: applying acpiacad quirks",devnode)); | 140 | HAL_INFO (("%s: applying acpiacad quirks",devnode)); | |
141 | hal_device_add_capability (d, "ac_adapter"); | 141 | hal_device_add_capability (d, "ac_adapter"); | |
142 | 142 | |||
143 | /* acpibat(4) */ | 143 | /* acpibat(4) */ | |
144 | } else if (strncmp (devnode, "acpibat", 7) == 0) { | 144 | } else if (strncmp (devnode, "acpibat", 7) == 0) { | |
145 | HAL_INFO (("%s: applying acpibat quirks",devnode)); | 145 | HAL_INFO (("%s: applying acpibat quirks",devnode)); | |
146 | hal_device_add_capability (d, "battery"); | 146 | hal_device_add_capability (d, "battery"); | |
147 | hal_device_property_set_string (d, "battery.type", "primary"); | 147 | hal_device_property_set_string (d, "battery.type", "primary"); | |
148 | } | 148 | } | |
149 | 149 | |||
150 | } | 150 | } | |
151 | 151 | |||
152 | static HalDevice * | 152 | static HalDevice * | |
153 | devinfo_default_add(HalDevice *parent, const char *devnode, char *devfs_path, char *device_type) | 153 | devinfo_default_add(HalDevice *parent, const char *devnode, char *devfs_path, char *device_type) | |
154 | { | 154 | { | |
155 | char *driver_name; | 155 | char *driver_name; | |
156 | const char *parent_path; | 156 | const char *parent_path; | |
157 | HalDevice *d; | 157 | HalDevice *d; | |
158 | 158 | |||
159 | d = hal_device_new (); | 159 | d = hal_device_new (); | |
160 | 160 | |||
161 | devinfo_set_default_properties (d, parent, devnode, devnode); | 161 | devinfo_set_default_properties (d, parent, devnode, devnode); | |
162 | 162 | |||
163 | devinfo_default_apply_quirks (d, devnode); | 163 | devinfo_default_apply_quirks (d, devnode); | |
164 | 164 | |||
165 | devinfo_add_enqueue (d, devnode, &devinfo_default_handler); | 165 | devinfo_add_enqueue (d, devnode, &devinfo_default_handler); | |
166 | 166 | |||
167 | return (d); | 167 | return (d); | |
168 | } | 168 | } |
@@ -1,303 +1,311 @@ | @@ -1,303 +1,311 @@ | |||
1 | /*************************************************************************** | 1 | /*************************************************************************** | |
2 | * | 2 | * | |
3 | * drvctl.c : NetBSD drvctl events | 3 | * drvctl.c : NetBSD drvctl events | |
4 | * | 4 | * | |
5 | * Copyright 2006 Sun Microsystems, Inc. All rights reserved. | 5 | * Copyright 2006 Sun Microsystems, Inc. All rights reserved. | |
6 | * Use is subject to license terms. | 6 | * Use is subject to license terms. | |
7 | * | 7 | * | |
8 | * Licensed under the Academic Free License version 2.1 | 8 | * Licensed under the Academic Free License version 2.1 | |
9 | * | 9 | * | |
10 | **************************************************************************/ | 10 | **************************************************************************/ | |
11 | 11 | |||
12 | #ifdef HAVE_CONFIG_H | 12 | #ifdef HAVE_CONFIG_H | |
13 | # include <config.h> | 13 | # include <config.h> | |
14 | #endif | 14 | #endif | |
15 | 15 | |||
16 | #include <stdio.h> | 16 | #include <stdio.h> | |
17 | #include <unistd.h> | 17 | #include <unistd.h> | |
18 | #include <stdlib.h> | 18 | #include <stdlib.h> | |
19 | #include <string.h> | 19 | #include <string.h> | |
20 | #include <errno.h> | 20 | #include <errno.h> | |
21 | #include <fcntl.h> | 21 | #include <fcntl.h> | |
22 | #include <sys/ioctl.h> | 22 | #include <sys/ioctl.h> | |
23 | #include <sys/drvctlio.h> | 23 | #include <sys/drvctlio.h> | |
24 | #include <sys/dkio.h> | 24 | #include <sys/dkio.h> | |
25 | #include <sys/stat.h> | 25 | #include <sys/stat.h> | |
26 | #include <sys/drvctlio.h> | 26 | #include <sys/drvctlio.h> | |
27 | #include <glib.h> | 27 | #include <glib.h> | |
28 | 28 | |||
29 | #include "../osspec.h" | 29 | #include "../osspec.h" | |
30 | #include "../logger.h" | 30 | #include "../logger.h" | |
31 | #include "../hald.h" | 31 | #include "../hald.h" | |
32 | #include "../hald_dbus.h" | 32 | #include "../hald_dbus.h" | |
33 | #include "../device_info.h" | 33 | #include "../device_info.h" | |
34 | #include "../util.h" | 34 | #include "../util.h" | |
35 | #include "osspec_netbsd.h" | 35 | #include "osspec_netbsd.h" | |
36 | #include "hotplug.h" | 36 | #include "hotplug.h" | |
37 | #include "devinfo.h" | 37 | #include "devinfo.h" | |
38 | #include "devinfo_storage.h" | 38 | #include "devinfo_storage.h" | |
39 | #include "drvctl.h" | 39 | #include "drvctl.h" | |
40 | 40 | |||
41 | static gboolean drvctl_iochannel_data(GIOChannel *, GIOCondition, gpointer); | 41 | static gboolean drvctl_iochannel_data(GIOChannel *, GIOCondition, gpointer); | |
42 | static void drvctl_dev_add(gchar *); | 42 | static void drvctl_dev_add(gchar *); | |
43 | static void drvctl_dev_remove(gchar *); | 43 | static void drvctl_dev_remove(gchar *); | |
44 | static void drvctl_dev_branch(gchar *); | 44 | static void drvctl_dev_branch(gchar *); | |
45 | 45 | |||
46 | static int drvctl_fd; | 46 | static int drvctl_fd; | |
47 | static GIOChannel *drvctl_iochannel; | 47 | static GIOChannel *drvctl_iochannel; | |
48 | 48 | |||
49 | gboolean | 49 | gboolean | |
50 | drvctl_init(void) | 50 | drvctl_init(void) | |
51 | { | 51 | { | |
52 | drvctl_fd = open (DRVCTLDEV, O_RDWR); | 52 | drvctl_fd = open (DRVCTLDEV, O_RDWR); | |
53 | if (drvctl_fd == -1) { | 53 | if (drvctl_fd == -1) { | |
54 | HAL_INFO (("open(%s, O_RDWR) failed: %s", DRVCTLDEV, strerror(errno))); | 54 | HAL_INFO (("open(%s, O_RDWR) failed: %s", DRVCTLDEV, strerror(errno))); | |
55 | return FALSE; | 55 | return FALSE; | |
56 | } | 56 | } | |
57 | 57 | |||
58 | drvctl_iochannel = g_io_channel_unix_new (drvctl_fd); | 58 | drvctl_iochannel = g_io_channel_unix_new (drvctl_fd); | |
59 | if (drvctl_iochannel == NULL) { | 59 | if (drvctl_iochannel == NULL) { | |
60 | HAL_INFO (("g_io_channel_unix_new failed")); | 60 | HAL_INFO (("g_io_channel_unix_new failed")); | |
61 | return FALSE; | 61 | return FALSE; | |
62 | } | 62 | } | |
63 | g_io_add_watch (drvctl_iochannel, G_IO_IN, drvctl_iochannel_data, NULL); | 63 | g_io_add_watch (drvctl_iochannel, G_IO_IN, drvctl_iochannel_data, NULL); | |
64 | 64 | |||
65 | return TRUE; | 65 | return TRUE; | |
66 | } | 66 | } | |
67 | 67 | |||
68 | void | 68 | void | |
69 | drvctl_fini(void) | 69 | drvctl_fini(void) | |
70 | { | 70 | { | |
71 | HAL_INFO (("drvctl_fini")); | 71 | HAL_INFO (("drvctl_fini")); | |
72 | } | 72 | } | |
73 | 73 | |||
74 | static gboolean | 74 | static gboolean | |
75 | drvctl_iochannel_data (GIOChannel *source, | 75 | drvctl_iochannel_data (GIOChannel *source, | |
76 | GIOCondition condition, | 76 | GIOCondition condition, | |
77 | gpointer user_data) | 77 | gpointer user_data) | |
78 | { | 78 | { | |
79 | prop_dictionary_t ev; | 79 | prop_dictionary_t ev; | |
80 | const char *event, *device; | 80 | const char *event, *device; | |
81 | int res; | 81 | int res; | |
82 | 82 | |||
83 | HAL_INFO (("drvctl_iochannel_data")); | 83 | HAL_INFO (("drvctl_iochannel_data")); | |
84 | 84 | |||
85 | res = prop_dictionary_recv_ioctl (drvctl_fd, DRVGETEVENT, &ev); | 85 | res = prop_dictionary_recv_ioctl (drvctl_fd, DRVGETEVENT, &ev); | |
86 | if (res) { | 86 | if (res) { | |
87 | HAL_WARNING (("DRVGETEVENT failed: %s", strerror(errno))); | 87 | HAL_WARNING (("DRVGETEVENT failed: %s", strerror(errno))); | |
88 | return FALSE; | 88 | return FALSE; | |
89 | } | 89 | } | |
90 | 90 | |||
91 | if (!prop_dictionary_get_cstring_nocopy (ev, "event", &event)) { | 91 | if (!prop_dictionary_get_cstring_nocopy (ev, "event", &event)) { | |
92 | HAL_WARNING (("DRVGETEVENT missing \"event\" parameter")); | 92 | HAL_WARNING (("DRVGETEVENT missing \"event\" parameter")); | |
93 | goto done; | 93 | goto done; | |
94 | } | 94 | } | |
95 | if (!prop_dictionary_get_cstring_nocopy (ev, "device", &device)) { | 95 | if (!prop_dictionary_get_cstring_nocopy (ev, "device", &device)) { | |
96 | HAL_WARNING (("DRVGETEVENT missing \"device\" parameter")); | 96 | HAL_WARNING (("DRVGETEVENT missing \"device\" parameter")); | |
97 | goto done; | 97 | goto done; | |
98 | } | 98 | } | |
99 | 99 | |||
100 | HAL_INFO (("DRVGETEVENT event=%s device=%s", event, device)); | 100 | HAL_INFO (("DRVGETEVENT event=%s device=%s", event, device)); | |
101 | 101 | |||
102 | if (strcmp (event, "device-attach") == 0) { | 102 | if (strcmp (event, "device-attach") == 0) { | |
103 | drvctl_dev_add (device); | 103 | drvctl_dev_add (device); | |
104 | } else { | 104 | } else { | |
105 | drvctl_dev_remove (device); | 105 | drvctl_dev_remove (device); | |
106 | } | 106 | } | |
107 | 107 | |||
108 | done: | 108 | done: | |
109 | prop_object_release(ev); | 109 | prop_object_release(ev); | |
110 | return TRUE; | 110 | return TRUE; | |
111 | } | 111 | } | |
112 | 112 | |||
113 | static void | 113 | static void | |
114 | drvctl_dev_add(gchar *name) | 114 | drvctl_dev_add(gchar *name) | |
115 | { | 115 | { | |
116 | HalDevice *parent, *d; | 116 | HalDevice *parent, *d; | |
117 | gchar pdevnode[512]; | 117 | gchar pdevnode[512]; | |
118 | 118 | |||
119 | if (drvctl_find_parent (name, pdevnode) == FALSE) { | 119 | if (drvctl_find_parent (name, pdevnode) == FALSE) { | |
120 | HAL_INFO (("dev_add: name=%s orphan", name)); | 120 | HAL_INFO (("dev_add: name=%s orphan", name)); | |
121 | parent = NULL; | 121 | parent = NULL; | |
122 | } else { | 122 | } else { | |
123 | parent = hal_device_store_match_key_value_string ( | 123 | parent = hal_device_store_match_key_value_string ( | |
124 | hald_get_gdl(), "netbsd.device", pdevnode); | 124 | hald_get_gdl(), "netbsd.device", pdevnode); | |
125 | if (parent == NULL) | 125 | if (parent == NULL) | |
126 | HAL_INFO (("dev_add: name=%s but netbsd.device=%s not found",name, pdevnode)); | 126 | HAL_INFO (("dev_add: name=%s but netbsd.device=%s not found",name, pdevnode)); | |
127 | } | 127 | } | |
128 | 128 | |||
129 | d = devinfo_add_node (parent, name); | 129 | d = devinfo_add_node (parent, name); | |
130 | if (d == NULL) | 130 | if (d == NULL) | |
131 | HAL_WARNING (("dev_add: couldn't add %s node (parent=%p)", name, parent)); | 131 | HAL_WARNING (("dev_add: couldn't add %s node (parent=%p)", name, parent)); | |
132 | 132 | |||
133 | hotplug_event_process_queue (); | 133 | hotplug_event_process_queue (); | |
134 | } | 134 | } | |
135 | 135 | |||
136 | static void | 136 | static void | |
137 | drvctl_dev_remove(gchar *name) | 137 | drvctl_dev_remove(gchar *name) | |
138 | { | 138 | { | |
139 | HAL_INFO (("dev_remove: %s", name)); | 139 | HAL_INFO (("dev_remove: %s", name)); | |
140 | 140 | |||
141 | devinfo_remove_branch (name, NULL); | 141 | devinfo_remove_branch (name, NULL); | |
142 | hotplug_event_process_queue (); | 142 | hotplug_event_process_queue (); | |
143 | } | 143 | } | |
144 | 144 | |||
145 | static void | 145 | static void | |
146 | drvctl_dev_branch(gchar *name) | 146 | drvctl_dev_branch(gchar *name) | |
147 | { | 147 | { | |
148 | HAL_INFO (("branch_remove: %s", name)); | 148 | HAL_INFO (("branch_remove: %s", name)); | |
149 | 149 | |||
150 | devinfo_remove_branch (name, NULL); | 150 | devinfo_remove_branch (name, NULL); | |
151 | hotplug_event_process_queue (); | 151 | hotplug_event_process_queue (); | |
152 | } | 152 | } | |
153 | 153 | |||
154 | int | 154 | int | |
155 | drvctl_list(const gchar *name, struct devlistargs *laa) | 155 | drvctl_list(const gchar *name, struct devlistargs *laa) | |
156 | { | 156 | { | |
157 | size_t children; | 157 | size_t children; | |
158 | 158 | |||
159 | /* HAL_INFO (("drvctl_list: %s", name)); */ | 159 | /* HAL_INFO (("drvctl_list: %s", name)); */ | |
160 | 160 | |||
161 | memset (laa, 0, sizeof (*laa)); | 161 | memset (laa, 0, sizeof (*laa)); | |
162 | strlcpy (laa->l_devname, name, sizeof (laa->l_devname)); | 162 | strlcpy (laa->l_devname, name, sizeof (laa->l_devname)); | |
163 | if (ioctl (drvctl_fd, DRVLISTDEV, laa) == -1) { | 163 | if (ioctl (drvctl_fd, DRVLISTDEV, laa) == -1) { | |
164 | HAL_INFO (("DRVLISTDEV/1 failed: %s", strerror(errno))); | 164 | HAL_INFO (("DRVLISTDEV/1 failed: %s", strerror(errno))); | |
165 | return -1; | 165 | return -1; | |
166 | } | 166 | } | |
167 | children = laa->l_children; | 167 | children = laa->l_children; | |
168 | /* HAL_INFO (("%s: found %d children", name, children)); */ | 168 | /* HAL_INFO (("%s: found %d children", name, children)); */ | |
169 | if (children == 0) | 169 | if (children == 0) | |
170 | return -1; | 170 | return -1; | |
171 | laa->l_childname = malloc (children * sizeof (laa->l_childname[0])); | 171 | laa->l_childname = malloc (children * sizeof (laa->l_childname[0])); | |
172 | if (laa->l_childname == NULL) { | 172 | if (laa->l_childname == NULL) { | |
173 | HAL_INFO (("drvctl_list couldn't allocate %d children: %s\n", children, strerror(errno))); | 173 | HAL_INFO (("drvctl_list couldn't allocate %d children: %s\n", children, strerror(errno))); | |
174 | return -1; | 174 | return -1; | |
175 | } | 175 | } | |
176 | if (ioctl (drvctl_fd, DRVLISTDEV, laa) == -1) { | 176 | if (ioctl (drvctl_fd, DRVLISTDEV, laa) == -1) { | |
177 | HAL_INFO (("DRVLISTDEV/2 failed: %s", strerror(errno))); | 177 | HAL_INFO (("DRVLISTDEV/2 failed: %s", strerror(errno))); | |
178 | return -1; | 178 | return -1; | |
179 | } | 179 | } | |
180 | if (children != laa->l_children) | 180 | if (children != laa->l_children) | |
181 | HAL_WARNING (("DRVLISTDEV/3 expected %d children, got %d", children, laa->l_childname)); | 181 | HAL_WARNING (("DRVLISTDEV/3 expected %d children, got %d", children, laa->l_childname)); | |
182 | return 0; | |||
182 | } | 183 | } | |
183 | 184 | |||
184 | gboolean | 185 | gboolean | |
185 | drvctl_find_device(const gchar *devnode, prop_dictionary_t *properties) | 186 | drvctl_find_device(const gchar *devnode, prop_dictionary_t *properties) | |
186 | { | 187 | { | |
187 | prop_dictionary_t command_dict; | 188 | prop_dictionary_t command_dict; | |
188 | prop_dictionary_t args_dict; | 189 | prop_dictionary_t args_dict; | |
189 | prop_dictionary_t results_dict; | 190 | prop_dictionary_t results_dict; | |
190 | int err; | 191 | int err; | |
191 | 192 | |||
192 | command_dict = prop_dictionary_create (); | 193 | command_dict = prop_dictionary_create (); | |
193 | args_dict = prop_dictionary_create (); | 194 | args_dict = prop_dictionary_create (); | |
194 | 195 | |||
195 | prop_dictionary_set_cstring_nocopy (command_dict, "drvctl-command", "get-properties"); | 196 | prop_dictionary_set_cstring_nocopy (command_dict, "drvctl-command", "get-properties"); | |
196 | prop_dictionary_set_cstring_nocopy (args_dict, "device-name", devnode); | 197 | prop_dictionary_set_cstring_nocopy (args_dict, "device-name", devnode); | |
197 | prop_dictionary_set (command_dict, "drvctl-arguments", args_dict); | 198 | prop_dictionary_set (command_dict, "drvctl-arguments", args_dict); | |
198 | prop_object_release (args_dict); | 199 | prop_object_release (args_dict); | |
199 | 200 | |||
200 | err = prop_dictionary_sendrecv_ioctl (command_dict, drvctl_fd, | 201 | err = prop_dictionary_sendrecv_ioctl (command_dict, drvctl_fd, | |
201 | DRVCTLCOMMAND, &results_dict); | 202 | DRVCTLCOMMAND, &results_dict); | |
202 | prop_object_release (command_dict); | 203 | prop_object_release (command_dict); | |
203 | if (err) | 204 | if (err) | |
204 | return FALSE; | 205 | return FALSE; | |
205 | 206 | |||
206 | if (prop_dictionary_get_int8 (results_dict, "drvctl-error", &err) == false || err != 0) { | 207 | if (prop_dictionary_get_int8 (results_dict, "drvctl-error", &err) == false || err != 0) { | |
207 | prop_object_release (results_dict); | 208 | prop_object_release (results_dict); | |
208 | return FALSE; | 209 | return FALSE; | |
209 | } | 210 | } | |
210 | 211 | |||
211 | if (properties) { | 212 | if (properties) { | |
212 | prop_dictionary_t result_data; | 213 | prop_dictionary_t result_data; | |
213 | result_data = prop_dictionary_get (results_dict, "drvctl-result-data"); | 214 | result_data = prop_dictionary_get (results_dict, "drvctl-result-data"); | |
214 | if (result_data) | 215 | if (result_data) | |
215 | *properties = prop_dictionary_copy (result_data); | 216 | *properties = prop_dictionary_copy (result_data); | |
216 | } | 217 | } | |
217 | 218 | |||
218 | prop_object_release (results_dict); | 219 | prop_object_release (results_dict); | |
219 | 220 | |||
220 | return TRUE; | 221 | return TRUE; | |
221 | } | 222 | } | |
222 | 223 | |||
223 | static gboolean | 224 | static gboolean | |
224 | drvctl_find_device_with_child(const gchar *curnode, const gchar *devnode, | 225 | drvctl_find_device_with_child(const gchar *curnode, const gchar *devnode, | |
225 | char *parent) | 226 | char *parent) | |
226 | { | 227 | { | |
227 | struct devlistargs laa; | 228 | struct devlistargs laa; | |
228 | u_int i; | 229 | u_int i; | |
229 | 230 | |||
230 | if (drvctl_list (curnode, &laa) == -1) | 231 | if (drvctl_list (curnode, &laa) == -1) | |
231 | return FALSE; | 232 | return FALSE; | |
232 | 233 | |||
233 | for (i = 0; i < laa.l_children; i++) { | 234 | for (i = 0; i < laa.l_children; i++) { | |
234 | if (strcmp (laa.l_childname[i], devnode) == 0) { | 235 | if (strcmp (laa.l_childname[i], devnode) == 0) { | |
235 | strlcpy(parent, curnode, 16); | 236 | strlcpy(parent, curnode, 16); | |
236 | free(laa.l_childname); | 237 | free(laa.l_childname); | |
237 | return TRUE; | 238 | return TRUE; | |
238 | } | 239 | } | |
239 | if (drvctl_find_device_with_child (laa.l_childname[i], devnode, parent) == TRUE) { | 240 | if (drvctl_find_device_with_child (laa.l_childname[i], devnode, parent) == TRUE) { | |
240 | free(laa.l_childname); | 241 | free(laa.l_childname); | |
241 | return TRUE; | 242 | return TRUE; | |
242 | } | 243 | } | |
243 | } | 244 | } | |
244 | 245 | |||
245 | if (laa.l_childname) | 246 | if (laa.l_childname) | |
246 | free(laa.l_childname); | 247 | free(laa.l_childname); | |
247 | 248 | |||
248 | HAL_INFO (("%s: couldn't find device with child %s", curnode, devnode)); | 249 | HAL_INFO (("%s: couldn't find device with child %s", curnode, devnode)); | |
249 | return FALSE; | 250 | return FALSE; | |
250 | } | 251 | } | |
251 | 252 | |||
252 | gboolean | 253 | gboolean | |
253 | drvctl_find_parent(const gchar *devnode, char *parent) | 254 | drvctl_find_parent(const gchar *devnode, char *parent) | |
254 | { | 255 | { | |
255 | return drvctl_find_device_with_child("mainbus0", devnode, parent); | 256 | gboolean ret; | |
257 | ||||
258 | ret = drvctl_find_device_with_child("mainbus0", devnode, parent); | |||
259 | if (ret == FALSE) { | |||
260 | ret = drvctl_find_device_with_child("armfdt0", devnode, parent); | |||
261 | } | |||
262 | ||||
263 | return ret; | |||
256 | } | 264 | } | |
257 | 265 | |||
258 | #if 0 | 266 | #if 0 | |
259 | static void | 267 | static void | |
260 | drvctl_lofi_add(gchar *devfs_path, gchar *name) | 268 | drvctl_lofi_add(gchar *devfs_path, gchar *name) | |
261 | { | 269 | { | |
262 | di_node_t node; | 270 | di_node_t node; | |
263 | const char *parent_udi; | 271 | const char *parent_udi; | |
264 | HalDevice *d, *parent; | 272 | HalDevice *d, *parent; | |
265 | 273 | |||
266 | HAL_INFO (("lofi_add: %s %s", name, devfs_path)); | 274 | HAL_INFO (("lofi_add: %s %s", name, devfs_path)); | |
267 | 275 | |||
268 | if ((d = hal_device_store_match_key_value_string (hald_get_gdl (), | 276 | if ((d = hal_device_store_match_key_value_string (hald_get_gdl (), | |
269 | "solaris.devfs_path", devfs_path)) == NULL) { | 277 | "solaris.devfs_path", devfs_path)) == NULL) { | |
270 | HAL_INFO (("device not found in GDL %s", devfs_path)); | 278 | HAL_INFO (("device not found in GDL %s", devfs_path)); | |
271 | return; | 279 | return; | |
272 | } | 280 | } | |
273 | parent_udi = hal_device_property_get_string (d, "info.parent"); | 281 | parent_udi = hal_device_property_get_string (d, "info.parent"); | |
274 | if ((parent_udi == NULL) || (strlen(parent_udi) == 0)) { | 282 | if ((parent_udi == NULL) || (strlen(parent_udi) == 0)) { | |
275 | HAL_INFO (("parent not found in GDL %s", parent_udi)); | 283 | HAL_INFO (("parent not found in GDL %s", parent_udi)); | |
276 | return; | 284 | return; | |
277 | } | 285 | } | |
278 | if ((parent = hal_device_store_match_key_value_string (hald_get_gdl (), | 286 | if ((parent = hal_device_store_match_key_value_string (hald_get_gdl (), | |
279 | "info.udi", parent_udi)) == NULL) { | 287 | "info.udi", parent_udi)) == NULL) { | |
280 | HAL_INFO (("parent not found in GDL %s", parent_udi)); | 288 | HAL_INFO (("parent not found in GDL %s", parent_udi)); | |
281 | return; | 289 | return; | |
282 | } | 290 | } | |
283 | 291 | |||
284 | if ((node = di_init (devfs_path, DINFOCPYALL)) == DI_NODE_NIL) { | 292 | if ((node = di_init (devfs_path, DINFOCPYALL)) == DI_NODE_NIL) { | |
285 | HAL_INFO (("device not found in devinfo %s", devfs_path)); | 293 | HAL_INFO (("device not found in devinfo %s", devfs_path)); | |
286 | return; | 294 | return; | |
287 | } | 295 | } | |
288 | 296 | |||
289 | HAL_INFO (("device %s parent %s", hal_device_get_udi (d), parent_udi)); | 297 | HAL_INFO (("device %s parent %s", hal_device_get_udi (d), parent_udi)); | |
290 | devinfo_lofi_add_major (parent, node, devfs_path, NULL, TRUE, d); | 298 | devinfo_lofi_add_major (parent, node, devfs_path, NULL, TRUE, d); | |
291 | 299 | |||
292 | di_fini (node); | 300 | di_fini (node); | |
293 | 301 | |||
294 | hotplug_event_process_queue (); | 302 | hotplug_event_process_queue (); | |
295 | } | 303 | } | |
296 | 304 | |||
297 | static void | 305 | static void | |
298 | drvctl_lofi_remove(gchar *parent_devfs_path, gchar *name) | 306 | drvctl_lofi_remove(gchar *parent_devfs_path, gchar *name) | |
299 | { | 307 | { | |
300 | devinfo_lofi_remove_minor(parent_devfs_path, name); | 308 | devinfo_lofi_remove_minor(parent_devfs_path, name); | |
301 | hotplug_event_process_queue (); | 309 | hotplug_event_process_queue (); | |
302 | } | 310 | } | |
303 | #endif | 311 | #endif |
@@ -1,183 +1,188 @@ | @@ -1,183 +1,188 @@ | |||
1 | /*************************************************************************** | 1 | /*************************************************************************** | |
2 | * | 2 | * | |
3 | * osspec.c : NetBSD HAL backend entry points | 3 | * osspec.c : NetBSD HAL backend entry points | |
4 | * | 4 | * | |
5 | * Copyright 2008 Jared D. McNeill <jmcneill@NetBSD.org> | 5 | * Copyright 2008 Jared D. McNeill <jmcneill@NetBSD.org> | |
6 | * Copyright 2006 Sun Microsystems, Inc. All rights reserved. | 6 | * Copyright 2006 Sun Microsystems, Inc. All rights reserved. | |
7 | * Use is subject to license terms. | 7 | * Use is subject to license terms. | |
8 | * | 8 | * | |
9 | * Licensed under the Academic Free License version 2.1 | 9 | * Licensed under the Academic Free License version 2.1 | |
10 | * | 10 | * | |
11 | **************************************************************************/ | 11 | **************************************************************************/ | |
12 | 12 | |||
13 | #ifdef HAVE_CONFIG_H | 13 | #ifdef HAVE_CONFIG_H | |
14 | # include <config.h> | 14 | # include <config.h> | |
15 | #endif | 15 | #endif | |
16 | 16 | |||
17 | #include <stdio.h> | 17 | #include <stdio.h> | |
18 | #include <unistd.h> | 18 | #include <unistd.h> | |
19 | #include <strings.h> | 19 | #include <strings.h> | |
20 | #include <sys/stat.h> | 20 | #include <sys/stat.h> | |
21 | #include <fcntl.h> | 21 | #include <fcntl.h> | |
22 | #include <sys/types.h> | 22 | #include <sys/types.h> | |
23 | #include <sys/statvfs.h> | 23 | #include <sys/statvfs.h> | |
24 | 24 | |||
25 | #include "../osspec.h" | 25 | #include "../osspec.h" | |
26 | #include "../logger.h" | 26 | #include "../logger.h" | |
27 | #include "../hald.h" | 27 | #include "../hald.h" | |
28 | #include "../hald_dbus.h" | 28 | #include "../hald_dbus.h" | |
29 | #include "../device_info.h" | 29 | #include "../device_info.h" | |
30 | #include "../util.h" | 30 | #include "../util.h" | |
31 | #include "../ids.h" | 31 | #include "../ids.h" | |
32 | #include "osspec_netbsd.h" | 32 | #include "osspec_netbsd.h" | |
33 | #include "hotplug.h" | 33 | #include "hotplug.h" | |
34 | #include "drvctl.h" | 34 | #include "drvctl.h" | |
35 | #include "envsys.h" | 35 | #include "envsys.h" | |
36 | #include "devinfo.h" | 36 | #include "devinfo.h" | |
37 | #include "devinfo_storage.h" | 37 | #include "devinfo_storage.h" | |
38 | 38 | |||
39 | static void mntinfo_event_init (); | 39 | static void mntinfo_event_init (); | |
40 | static gboolean mntinfo_timeout (gpointer user_data); | 40 | static gboolean mntinfo_timeout (gpointer user_data); | |
41 | 41 | |||
42 | HalFileMonitor * | 42 | HalFileMonitor * | |
43 | osspec_get_file_monitor (void) | 43 | osspec_get_file_monitor (void) | |
44 | { | 44 | { | |
45 | #warning Please implement | 45 | #warning Please implement | |
46 | return NULL; | 46 | return NULL; | |
47 | } | 47 | } | |
48 | 48 | |||
49 | void | 49 | void | |
50 | osspec_init (void) | 50 | osspec_init (void) | |
51 | { | 51 | { | |
52 | ids_init (); | 52 | ids_init (); | |
53 | mntinfo_event_init (); | 53 | mntinfo_event_init (); | |
54 | envsys_init (); | 54 | envsys_init (); | |
55 | } | 55 | } | |
56 | 56 | |||
57 | void | 57 | void | |
58 | osspec_privileged_init (void) | 58 | osspec_privileged_init (void) | |
59 | { | 59 | { | |
60 | drvctl_init (); | 60 | drvctl_init (); | |
61 | } | 61 | } | |
62 | 62 | |||
63 | void | 63 | void | |
64 | hotplug_queue_now_empty (void) | 64 | hotplug_queue_now_empty (void) | |
65 | { | 65 | { | |
66 | if (hald_is_initialising) { | 66 | if (hald_is_initialising) { | |
67 | osspec_probe_done (); | 67 | osspec_probe_done (); | |
68 | } | 68 | } | |
69 | } | 69 | } | |
70 | 70 | |||
71 | void | 71 | void | |
72 | osspec_probe (void) | 72 | osspec_probe (void) | |
73 | { | 73 | { | |
74 | /* add entire device tree */ | 74 | /* add entire device tree */ | |
75 | devinfo_add (NULL, "mainbus0"); | 75 | if (devinfo_probe (NULL, "mainbus0") == TRUE) { | |
76 | devinfo_add (NULL, "mainbus0"); | |||
77 | } | |||
78 | if (devinfo_probe (NULL, "armfdt0") == TRUE) { | |||
79 | devinfo_add (NULL, "armfdt0"); | |||
80 | } | |||
76 | 81 | |||
77 | /* start processing events */ | 82 | /* start processing events */ | |
78 | hotplug_event_process_queue (); | 83 | hotplug_event_process_queue (); | |
79 | } | 84 | } | |
80 | 85 | |||
81 | gboolean | 86 | gboolean | |
82 | osspec_device_rescan (HalDevice *d) | 87 | osspec_device_rescan (HalDevice *d) | |
83 | { | 88 | { | |
84 | return (devinfo_device_rescan (d)); | 89 | return (devinfo_device_rescan (d)); | |
85 | } | 90 | } | |
86 | 91 | |||
87 | gboolean | 92 | gboolean | |
88 | osspec_device_reprobe (HalDevice *d) | 93 | osspec_device_reprobe (HalDevice *d) | |
89 | { | 94 | { | |
90 | return FALSE; | 95 | return FALSE; | |
91 | } | 96 | } | |
92 | 97 | |||
93 | DBusHandlerResult | 98 | DBusHandlerResult | |
94 | osspec_filter_function (DBusConnection *connection, DBusMessage *message, void *user_data) | 99 | osspec_filter_function (DBusConnection *connection, DBusMessage *message, void *user_data) | |
95 | { | 100 | { | |
96 | return DBUS_HANDLER_RESULT_NOT_YET_HANDLED; | 101 | return DBUS_HANDLER_RESULT_NOT_YET_HANDLED; | |
97 | } | 102 | } | |
98 | 103 | |||
99 | /** | 104 | /** | |
100 | * hal_util_find_closest_ancestor: | 105 | * hal_util_find_closest_ancestor: | |
101 | * @devfs_path: Path into devfs, e.g. /pci@0,0/pci1025,57@10,2/storage@1 | 106 | * @devfs_path: Path into devfs, e.g. /pci@0,0/pci1025,57@10,2/storage@1 | |
102 | * | 107 | * | |
103 | * Returns: Parent Hal Device Object or #NULL if there is none | 108 | * Returns: Parent Hal Device Object or #NULL if there is none | |
104 | * | 109 | * | |
105 | * Find the closest ancestor by looking at devfs paths | 110 | * Find the closest ancestor by looking at devfs paths | |
106 | */ | 111 | */ | |
107 | HalDevice * | 112 | HalDevice * | |
108 | hal_util_find_closest_ancestor (const gchar *devfs_path, gchar **ancestor_devfs_path, gchar **hotplug_devfs_path) | 113 | hal_util_find_closest_ancestor (const gchar *devfs_path, gchar **ancestor_devfs_path, gchar **hotplug_devfs_path) | |
109 | { | 114 | { | |
110 | gchar buf[512]; | 115 | gchar buf[512]; | |
111 | gchar c; | 116 | gchar c; | |
112 | HalDevice *parent; | 117 | HalDevice *parent; | |
113 | 118 | |||
114 | parent = NULL; | 119 | parent = NULL; | |
115 | 120 | |||
116 | if (drvctl_find_parent (devfs_path, buf) == FALSE) | 121 | if (drvctl_find_parent (devfs_path, buf) == FALSE) | |
117 | return NULL; | 122 | return NULL; | |
118 | 123 | |||
119 | HAL_INFO (("hal_util_find_closest_ancestor: devnode=%s parent=%s\n", devfs_path, buf)); | 124 | HAL_INFO (("hal_util_find_closest_ancestor: devnode=%s parent=%s\n", devfs_path, buf)); | |
120 | 125 | |||
121 | parent = hal_device_store_match_key_value_string (hald_get_gdl (), | 126 | parent = hal_device_store_match_key_value_string (hald_get_gdl (), | |
122 | "netbsd.device", | 127 | "netbsd.device", | |
123 | buf); | 128 | buf); | |
124 | if (parent != NULL) { | 129 | if (parent != NULL) { | |
125 | if (ancestor_devfs_path != NULL) { | 130 | if (ancestor_devfs_path != NULL) { | |
126 | *ancestor_devfs_path = g_strdup (buf); | 131 | *ancestor_devfs_path = g_strdup (buf); | |
127 | } | 132 | } | |
128 | if (hotplug_devfs_path != NULL) { | 133 | if (hotplug_devfs_path != NULL) { | |
129 | *hotplug_devfs_path = g_strdup (buf); | 134 | *hotplug_devfs_path = g_strdup (buf); | |
130 | } | 135 | } | |
131 | } | 136 | } | |
132 | 137 | |||
133 | return parent; | 138 | return parent; | |
134 | } | 139 | } | |
135 | 140 | |||
136 | char * | 141 | char * | |
137 | dsk_to_rdsk(char *dsk) | 142 | dsk_to_rdsk(char *dsk) | |
138 | { | 143 | { | |
139 | int len, pos; | 144 | int len, pos; | |
140 | char *p; | 145 | char *p; | |
141 | char *rdsk; | 146 | char *rdsk; | |
142 | 147 | |||
143 | if ((len = strlen (dsk)) < sizeof ("/dev/AANA") - 1) { | 148 | if ((len = strlen (dsk)) < sizeof ("/dev/AANA") - 1) { | |
144 | return (strdup("")); | 149 | return (strdup("")); | |
145 | } | 150 | } | |
146 | p = strstr (dsk, "/dev/"); | 151 | p = strstr (dsk, "/dev/"); | |
147 | if (p == NULL) { | 152 | if (p == NULL) { | |
148 | return (strdup("")); | 153 | return (strdup("")); | |
149 | } | 154 | } | |
150 | 155 | |||
151 | pos = (uintptr_t)p - (uintptr_t)dsk; | 156 | pos = (uintptr_t)p - (uintptr_t)dsk; | |
152 | if ((rdsk = (char *)calloc (len + 2, 1)) != NULL) { | 157 | if ((rdsk = (char *)calloc (len + 2, 1)) != NULL) { | |
153 | strncpy (rdsk, dsk, pos + 1); | 158 | strncpy (rdsk, dsk, pos + 1); | |
154 | rdsk[pos + 1] = 'r'; | 159 | rdsk[pos + 1] = 'r'; | |
155 | strcpy (rdsk + pos + 2, dsk + pos + 1); | 160 | strcpy (rdsk + pos + 2, dsk + pos + 1); | |
156 | } | 161 | } | |
157 | 162 | |||
158 | return (rdsk); | 163 | return (rdsk); | |
159 | } | 164 | } | |
160 | 165 | |||
161 | /* | 166 | /* | |
162 | * Setup to watch mntinfo changes | 167 | * Setup to watch mntinfo changes | |
163 | */ | 168 | */ | |
164 | static void | 169 | static void | |
165 | mntinfo_event_init () | 170 | mntinfo_event_init () | |
166 | { | 171 | { | |
167 | g_timeout_add (1000, mntinfo_timeout, NULL); | 172 | g_timeout_add (1000, mntinfo_timeout, NULL); | |
168 | } | 173 | } | |
169 | 174 | |||
170 | static gboolean | 175 | static gboolean | |
171 | mntinfo_timeout (gpointer user_data) | 176 | mntinfo_timeout (gpointer user_data) | |
172 | { | 177 | { | |
173 | if (!hald_is_initialising) | 178 | if (!hald_is_initialising) | |
174 | vfsstat_event (NULL); | 179 | vfsstat_event (NULL); | |
175 | 180 | |||
176 | return TRUE; | 181 | return TRUE; | |
177 | } | 182 | } | |
178 | 183 | |||
179 | void | 184 | void | |
180 | osspec_refresh_mount_state_for_block_device (HalDevice *d) | 185 | osspec_refresh_mount_state_for_block_device (HalDevice *d) | |
181 | { | 186 | { | |
182 | vfsstat_event (d); | 187 | vfsstat_event (d); | |
183 | } | 188 | } |