]>
Commit | Line | Data |
---|---|---|
ed14ca9b BZ |
1 | diff --git a/configure.in b/configure.in |
2 | index e8aa021..8363595 100644 | |
3 | --- a/configure.in | |
4 | +++ b/configure.in | |
5 | @@ -479,9 +479,6 @@ if test "x$with_libpci" != xno ; then | |
6 | fi | |
7 | AM_CONDITIONAL([HAVE_LIBPCI], [test "x$USE_LIBPCI" = "xyes"]) | |
8 | ||
9 | -USE_LIBUSB20=no | |
10 | -USE_LIBUSB=no | |
11 | -LIBUSB20_LIBS="" | |
12 | AC_ARG_WITH([backend], | |
13 | AS_HELP_STRING([--with-backend=<name>], | |
14 | [backend to use (linux/solaris/freebsd/dummy)]), | |
15 | @@ -510,21 +507,25 @@ AM_CONDITIONAL(HALD_COMPILE_FREEBSD, [test x$HALD_BACKEND = xfreebsd], [Compilin | |
16 | AM_CONDITIONAL(HALD_COMPILE_SOLARIS, [test x$HALD_BACKEND = xsolaris], [Compiling for Solaris]) | |
17 | AC_SUBST(HALD_BACKEND) | |
18 | if test "x$HALD_BACKEND" = "xfreebsd"; then | |
19 | - AC_CHECK_LIB([usb20], [libusb20_dev_get_info], [USE_LIBUSB20=yes], [USE_LIBUSB20=no]) | |
20 | -fi | |
21 | -if test "x$USE_LIBUSB20" = "xno"; then | |
22 | - AC_CHECK_LIB([usb], [libusb20_dev_get_info], [USE_LIBUSB=yes], [USE_LIBUSB=no]) | |
23 | -fi | |
24 | -AM_CONDITIONAL([HAVE_LIBUSB20],[test "x$USE_LIBUSB20" = "xyes"]) | |
25 | -AM_CONDITIONAL([HAVE_LIBUSB20],[test "x$USE_LIBUSB" = "xyes"]) | |
26 | -if test "x$USE_LIBUSB20" = "xyes"; then | |
27 | - AC_DEFINE(HAVE_LIBUSB20, 1, [Set if we need libusb20]) | |
28 | - LIBUSB20_LIBS="-lusb20" | |
29 | -elif test "x$USE_LIBUSB" = "xyes"; then | |
30 | - AC_DEFINE(HAVE_LIBUSB20, 1, [Set if we need libsub20]) | |
31 | - LIBUSB20_LIBS="-lusb" | |
32 | + USE_BSDLIBUSB20=no | |
33 | + USE_BSDLIBUSB=no | |
34 | + LIBUSB20_LIBS="" | |
35 | + AC_CHECK_LIB([usb20], [libusb20_dev_get_info], [USE_BSDLIBUSB20=yes], [USE_BSDLIBUSB20=no]) | |
36 | + if test "x$USE_BSDLIBUSB20" = "xno"; then | |
37 | + AC_CHECK_LIB([usb], [libusb20_dev_get_info], [USE_BSDLIBUSB=yes], [USE_BSDLIBUSB=no]) | |
38 | + fi | |
39 | + AM_CONDITIONAL([HAVE_LIBUSB20],[test "x$USE_BSDLIBUSB20" = "xyes" -o "x$USE_BSDLIBUSB" = "xyes"]) | |
40 | + if test "x$USE_BSDLIBUSB20" = "xyes"; then | |
41 | + AC_DEFINE(HAVE_LIBUSB20, 1, [Set if we need libusb20]) | |
42 | + LIBUSB20_LIBS="-lusb20" | |
43 | + elif test "x$USE_BSDLIBUSB" = "xyes"; then | |
44 | + AC_DEFINE(HAVE_LIBUSB20, 1, [Set if we need libsub20]) | |
45 | + LIBUSB20_LIBS="-lusb" | |
46 | + fi | |
47 | + AC_SUBST(LIBUSB20_LIBS) | |
48 | +else | |
49 | + AM_CONDITIONAL([HAVE_LIBUSB20], [false]) | |
50 | fi | |
51 | -AC_SUBST(LIBUSB20_LIBS) | |
52 | ||
53 | dnl DBUS API is subject to changes | |
54 | AC_DEFINE_UNQUOTED(DBUS_API_SUBJECT_TO_CHANGE, [], [DBUS API is subject to change]) | |
55 | diff --git a/hald/freebsd/addons/addon-storage.c b/hald/freebsd/addons/addon-storage.c | |
56 | index 3125037..cd28581 100644 | |
57 | --- a/hald/freebsd/addons/addon-storage.c | |
58 | +++ b/hald/freebsd/addons/addon-storage.c | |
59 | @@ -107,8 +107,7 @@ hf_addon_storage_update (void) | |
60 | ||
61 | if (hf_addon_storage_cdrom_eject_pressed(cdrom)) | |
62 | { | |
63 | - libhal_device_emit_condition(hfp_ctx, hfp_udi, "EjectPressed", "", &hfp_error); | |
64 | - dbus_error_free(&hfp_error); | |
65 | + libhal_device_emit_condition(hfp_ctx, hfp_udi, "EjectPressed", "", NULL); | |
66 | } | |
67 | ||
68 | hfp_cdrom_free(cdrom); | |
69 | @@ -164,19 +163,17 @@ unmount_volumes (void) | |
70 | "block.storage_device", | |
71 | hfp_udi, | |
72 | &num_volumes, | |
73 | - &hfp_error)) != NULL) | |
74 | + NULL)) != NULL) | |
75 | { | |
76 | int i; | |
77 | ||
78 | - dbus_error_free(&hfp_error); | |
79 | - | |
80 | for (i = 0; i < num_volumes; i++) | |
81 | { | |
82 | char *vol_udi; | |
83 | ||
84 | vol_udi = volumes[i]; | |
85 | ||
86 | - if (libhal_device_get_property_bool(hfp_ctx, vol_udi, "volume.is_mounted", &hfp_error)) | |
87 | + if (libhal_device_get_property_bool(hfp_ctx, vol_udi, "volume.is_mounted", NULL)) | |
88 | { | |
89 | DBusMessage *msg = NULL; | |
90 | DBusMessage *reply = NULL; | |
91 | @@ -185,7 +182,6 @@ unmount_volumes (void) | |
92 | char **options = NULL; | |
93 | char *devfile; | |
94 | ||
95 | - dbus_error_free(&hfp_error); | |
96 | hfp_info("Forcing unmount of volume '%s'", vol_udi); | |
97 | ||
98 | dbus_connection = libhal_ctx_get_dbus_connection(hfp_ctx); | |
99 | @@ -265,10 +261,9 @@ poll_for_media (boolean check_only, boolean force) | |
100 | check_lock_state = FALSE; | |
101 | ||
102 | hfp_info("Checking whether device %s is locked by HAL", addon.device_file); | |
103 | - if (libhal_device_is_locked_by_others(hfp_ctx, hfp_udi, "org.freedesktop.Hal.Device.Storage", &hfp_error)) | |
104 | + if (libhal_device_is_locked_by_others(hfp_ctx, hfp_udi, "org.freedesktop.Hal.Device.Storage", NULL)) | |
105 | { | |
106 | hfp_info("... device %s is locked by HAL", addon.device_file); | |
107 | - dbus_error_free(&hfp_error); | |
108 | is_locked_by_hal = TRUE; | |
109 | update_proc_title(addon.device_file); | |
110 | goto skip_check; | |
111 | @@ -278,10 +273,8 @@ poll_for_media (boolean check_only, boolean force) | |
112 | hfp_info("... device %s is not locked by HAL", addon.device_file); | |
113 | is_locked_by_hal = FALSE; | |
114 | } | |
115 | - dbus_error_free(&hfp_error); | |
116 | ||
117 | - should_poll = libhal_device_get_property_bool(hfp_ctx, hfp_udi, "storage.media_check_enabled", &hfp_error); | |
118 | - dbus_error_free(&hfp_error); | |
119 | + should_poll = libhal_device_get_property_bool(hfp_ctx, hfp_udi, "storage.media_check_enabled", NULL); | |
120 | polling_disabled = ! should_poll; | |
121 | update_proc_title(addon.device_file); | |
122 | } | |
123 | @@ -314,8 +307,7 @@ poll_for_media (boolean check_only, boolean force) | |
124 | unmount_volumes(); | |
125 | #endif | |
126 | ||
127 | - libhal_device_rescan(hfp_ctx, hfp_udi, &hfp_error); | |
128 | - dbus_error_free(&hfp_error); | |
129 | + libhal_device_rescan(hfp_ctx, hfp_udi, NULL); | |
130 | addon.had_media = has_media; | |
131 | ||
132 | return TRUE; | |
133 | @@ -412,12 +404,10 @@ main (int argc, char **argv) | |
134 | ! strcmp(driver, "cd")))) && ! strcmp(removable, "true"); | |
135 | addon.had_media = poll_for_media(TRUE, FALSE); | |
136 | ||
137 | - if (! libhal_device_addon_is_ready(hfp_ctx, hfp_udi, &hfp_error)) | |
138 | + if (! libhal_device_addon_is_ready(hfp_ctx, hfp_udi, NULL)) | |
139 | goto end; | |
140 | - dbus_error_free(&hfp_error); | |
141 | ||
142 | - syscon = dbus_bus_get(DBUS_BUS_SYSTEM, &hfp_error); | |
143 | - dbus_error_free(&hfp_error); | |
144 | + syscon = dbus_bus_get(DBUS_BUS_SYSTEM, NULL); | |
145 | assert(syscon != NULL); | |
146 | dbus_connection_set_exit_on_disconnect(syscon, 0); | |
147 | ||
148 | @@ -452,12 +442,11 @@ main (int argc, char **argv) | |
149 | " <method name=\"CheckForMedia\">\n" | |
150 | " <arg name=\"call_had_sideeffect\" direction=\"out\" type=\"b\"/>\n" | |
151 | " </method>\n", | |
152 | - &hfp_error)) | |
153 | + NULL)) | |
154 | { | |
155 | hfp_critical("Cannot claim interface 'org.freedesktop.Hal.Device.Storage.Removable'"); | |
156 | goto end; | |
157 | } | |
158 | - dbus_error_free(&hfp_error); | |
159 | ||
160 | while (TRUE) | |
161 | { | |
162 | diff --git a/hald/freebsd/hf-storage.c b/hald/freebsd/hf-storage.c | |
163 | index 3bc5ab9..3833ec8 100644 | |
164 | --- a/hald/freebsd/hf-storage.c | |
165 | +++ b/hald/freebsd/hf-storage.c | |
166 | @@ -30,6 +30,7 @@ | |
167 | #include <limits.h> | |
168 | #include <inttypes.h> | |
169 | #include <string.h> | |
170 | +#include <unistd.h> | |
171 | #include <sys/param.h> | |
172 | #include <sys/types.h> | |
173 | #include <sys/disklabel.h> | |
174 | @@ -418,10 +419,39 @@ hf_storage_parse_conftxt (const char *conftxt) | |
175 | continue; | |
176 | } | |
177 | ||
178 | + /* XXX This is a hack, but we need to ignore dynamic labels like | |
179 | + * ufsids which are created and destroyed based on whether or not | |
180 | + * the actual device is mounted or not. If we don't then strange | |
181 | + * things happen in applications like nautilus. | |
182 | + */ | |
183 | + if ((! strcmp(fields[1], "LABEL") || | |
184 | + ! strcmp(fields[1], "BSD")) && | |
185 | + ! strncmp(fields[2], "ufsid/", strlen("ufsid/"))) | |
186 | + { | |
187 | + g_strfreev(fields); | |
188 | + continue; | |
189 | + } | |
190 | + | |
191 | geom_obj = g_new0(Geom_Object, 1); | |
192 | ||
193 | geom_obj->class = g_strdup(fields[1]); | |
194 | geom_obj->dev = g_strdup(fields[2]); | |
195 | + /* Allow for spaces in label names. */ | |
196 | + if (! strcmp(fields[1], "LABEL")) | |
197 | + { | |
198 | + int j; | |
199 | + | |
200 | + for (j = 3; g_strv_length(fields) > (j + 2) && | |
201 | + strcmp(fields[j + 2], "i"); j++) | |
202 | + { | |
203 | + char *tmp; | |
204 | + | |
205 | + tmp = g_strdup_printf("%s %s", geom_obj->dev, fields[j]); | |
206 | + g_free(geom_obj->dev); | |
207 | + geom_obj->dev = tmp; | |
208 | + } | |
209 | + } | |
210 | + | |
211 | geom_obj->type = -1; /* We use -1 here to denote a missing type. */ | |
212 | geom_obj->hash = hash; | |
213 | ||
214 | @@ -589,11 +619,16 @@ hf_storage_devd_notify (const char *system, | |
215 | char *conftxt; | |
216 | GSList *new_disks; | |
217 | ||
218 | - if (strcmp(system, "DEVFS") || strcmp(subsystem, "CDEV") || | |
219 | + if (! data || strcmp(system, "DEVFS") || strcmp(subsystem, "CDEV") || | |
220 | (strcmp(type, "CREATE") && strcmp(type, "DESTROY"))) | |
221 | return FALSE; | |
222 | ||
223 | + if (! strcmp(type, "DESTROY")) | |
224 | + g_usleep(G_USEC_PER_SEC/2); | |
225 | + | |
226 | conftxt = hf_get_string_sysctl(NULL, "kern.geom.conftxt"); | |
227 | + if (! conftxt) | |
228 | + return FALSE; | |
229 | new_disks = hf_storage_parse_conftxt(conftxt); | |
230 | g_free(conftxt); | |
231 | ||
232 | @@ -669,7 +704,7 @@ hf_storage_conftxt_timeout_cb (gpointer data) | |
233 | if (hf_is_waiting) | |
234 | return TRUE; | |
235 | ||
236 | - hf_storage_devd_notify("DEVFS", "CDEV", "CREATE", NULL); | |
237 | + hf_storage_devd_notify("DEVFS", "CDEV", "CREATE", ""); | |
238 | ||
239 | return TRUE; | |
240 | } | |
241 | diff --git a/hald/freebsd/hf-usb2.c b/hald/freebsd/hf-usb2.c | |
242 | index fff49e0..f1a02e2 100644 | |
243 | --- a/hald/freebsd/hf-usb2.c | |
244 | +++ b/hald/freebsd/hf-usb2.c | |
245 | @@ -98,10 +98,10 @@ hf_usb2_probe_interfaces(HalDevice *parent) | |
246 | if (driver) | |
247 | { | |
248 | if (! strcmp(driver, "ukbd")) | |
249 | - hf_device_set_input(device, "keyboard", NULL); | |
250 | - else if (! strcmp(driver, "ums")) | |
251 | + hf_device_set_input(device, "keyboard", "keys", devname); | |
252 | + else if (! strcmp(driver, "ums") || ! strcmp(driver, "atp")) | |
253 | { | |
254 | - hf_device_set_input(device, "mouse", devname); | |
255 | + hf_device_set_input(device, "mouse", NULL, devname); | |
256 | hf_runner_run_sync(device, 0, "hald-probe-mouse", NULL); | |
257 | } | |
258 | else if (! strcmp(driver, "uhid")) | |
259 | @@ -192,11 +192,12 @@ hf_usb2_probe (void) | |
260 | addr = libusb20_dev_get_address(pdev); | |
261 | ||
262 | if (addr == 1) | |
263 | - parent = hf_devtree_find_parent_from_info(hald_get_gdl(), "usbus", bus); | |
264 | + parent = hf_devtree_find_from_info(hald_get_gdl(), "usbus", bus); | |
265 | else | |
266 | parent = hf_device_store_match(hald_get_gdl(), "usb_device.bus_number", | |
267 | HAL_PROPERTY_TYPE_INT32, bus, "usb_device.port_number", | |
268 | - HAL_PROPERTY_TYPE_INT32, addr - 1, NULL); | |
269 | + HAL_PROPERTY_TYPE_INT32, addr - 1, "info.bus", | |
270 | + HAL_PROPERTY_TYPE_STRING, "usb_device", NULL); | |
271 | if (! parent || hal_device_property_get_bool(parent, "info.ignore")) | |
272 | continue; | |
273 | ||
274 | @@ -216,7 +217,13 @@ hf_usb2_devd_add (const char *name, | |
275 | HalDevice *parent_device; | |
276 | int bus, addr, pbus, paddr; | |
277 | ||
278 | - if (strncmp(name, "ugen", strlen("ugen"))) | |
279 | + if (! parent) | |
280 | + return FALSE; | |
281 | + | |
282 | + if (strncmp(name, "ugen", strlen("ugen")) && | |
283 | + ! strncmp(parent, "uhub", strlen("uhub"))) | |
284 | + return TRUE; | |
285 | + else if (strncmp(name, "ugen", strlen("ugen"))) | |
286 | return FALSE; | |
287 | else if (strncmp(parent, "ugen", strlen("ugen"))) | |
288 | return TRUE; | |
289 | @@ -232,7 +239,8 @@ hf_usb2_devd_add (const char *name, | |
290 | ||
291 | parent_device = hf_device_store_match(hald_get_gdl(), | |
292 | "usb_device.bus_number", HAL_PROPERTY_TYPE_INT32, pbus, | |
293 | - "usb_device.port_number", HAL_PROPERTY_TYPE_INT32, paddr, NULL); | |
294 | + "usb_device.port_number", HAL_PROPERTY_TYPE_INT32, paddr, "info.bus", | |
295 | + HAL_PROPERTY_TYPE_STRING, "usb_device", NULL); | |
296 | ||
297 | if (parent_device && ! hal_device_property_get_bool(parent_device, | |
298 | "info.ignore")) | |
299 | @@ -255,8 +263,6 @@ hf_usb2_devd_remove (const char *name, | |
300 | ||
301 | if (strncmp(name, "ugen", strlen("ugen"))) | |
302 | return FALSE; | |
303 | - else if (strncmp(parent, "ugen", strlen("ugen"))) | |
304 | - return TRUE; | |
305 | ||
306 | if (sscanf(name, "ugen%i.%i", &bus, &addr) != 2) | |
307 | return FALSE; | |
308 | @@ -265,7 +271,8 @@ hf_usb2_devd_remove (const char *name, | |
309 | ||
310 | device = hf_device_store_match(hald_get_gdl(), "usb_device.bus_number", | |
311 | HAL_PROPERTY_TYPE_INT32, bus, "usb_device.port_number", | |
312 | - HAL_PROPERTY_TYPE_INT32, addr, NULL); | |
313 | + HAL_PROPERTY_TYPE_INT32, addr, "info.bus", | |
314 | + HAL_PROPERTY_TYPE_STRING, "usb_device", NULL); | |
315 | ||
316 | if (device) | |
317 | { | |
318 | @@ -276,6 +283,23 @@ hf_usb2_devd_remove (const char *name, | |
319 | return FALSE; | |
320 | } | |
321 | ||
322 | +static gboolean | |
323 | +hf_usb2_devd_notify (const char *system, | |
324 | + const char *subsystem, | |
325 | + const char *type, | |
326 | + const char *data) | |
327 | +{ | |
328 | + if (! data || strcmp(system, "DEVFS") || strcmp(subsystem, "CDEV") || | |
329 | + (strcmp(type, "CREATE") && strcmp(type, "DESTROY"))) | |
330 | + return FALSE; | |
331 | + | |
332 | + if (! strncmp(data, "cdev=ugen", strlen("cdev=ugen")) || | |
333 | + ! strncmp(data, "cdev=usb", strlen("cdev=usb"))) | |
334 | + return TRUE; | |
335 | + | |
336 | + return FALSE; | |
337 | +} | |
338 | + | |
339 | HFHandler hf_usb2_handler = { | |
340 | .privileged_init = hf_usb2_privileged_init, | |
341 | .probe = hf_usb2_probe | |
342 | @@ -283,5 +307,6 @@ HFHandler hf_usb2_handler = { | |
343 | ||
344 | HFDevdHandler hf_usb2_devd_handler = { | |
345 | .add = hf_usb2_devd_add, | |
346 | - .remove = hf_usb2_devd_remove | |
347 | + .remove = hf_usb2_devd_remove, | |
348 | + .notify = hf_usb2_devd_notify | |
349 | }; | |
350 | diff --git a/hald/freebsd/hf-volume.c b/hald/freebsd/hf-volume.c | |
351 | index 249d2bd..07cf805 100644 | |
352 | --- a/hald/freebsd/hf-volume.c | |
353 | +++ b/hald/freebsd/hf-volume.c | |
354 | @@ -86,9 +86,12 @@ hf_volume_resolve_fuse (const char *special) | |
355 | { | |
356 | if (strcmp(fields[0], special) == 0) | |
357 | { | |
358 | + char *ret; | |
359 | + | |
360 | + ret = g_strdup(fields[1]); | |
361 | g_strfreev(fields); | |
362 | g_strfreev(lines); | |
363 | - return g_strdup(fields[1]); | |
364 | + return ret; | |
365 | } | |
366 | } | |
367 | g_strfreev(fields); | |
368 | diff --git a/hald/freebsd/probing/probe-volume.c b/hald/freebsd/probing/probe-volume.c | |
369 | index 73e0318..e4e1689 100644 | |
370 | --- a/hald/freebsd/probing/probe-volume.c | |
371 | +++ b/hald/freebsd/probing/probe-volume.c | |
372 | @@ -574,6 +574,7 @@ main (int argc, char **argv) | |
373 | ||
374 | snprintf(ufsid, sizeof(ufsid), "%08x%08x", ufsdisk.d_fs.fs_id[0], ufsdisk.d_fs.fs_id[1]); | |
375 | libhal_device_set_property_string(hfp_ctx, hfp_udi, "volume.freebsd.ufsid", ufsid, &hfp_error); | |
376 | + dbus_error_free(&hfp_error); | |
377 | ufs_devs = libhal_manager_find_device_string_match(hfp_ctx, | |
378 | "volume.freebsd.ufsid", | |
379 | ufsid, | |
380 | @@ -582,16 +583,17 @@ main (int argc, char **argv) | |
381 | dbus_error_free(&hfp_error); | |
382 | for (i = 0; i < num_udis; i++) | |
383 | { | |
384 | - if (ufs_devs[i] != NULL) | |
385 | + if (ufs_devs[i] != NULL && strcmp(ufs_devs[i], hfp_udi)) | |
386 | { | |
387 | gboolean mounted; | |
388 | ||
389 | mounted = libhal_device_get_property_bool(hfp_ctx, ufs_devs[i], "volume.is_mounted", &hfp_error); | |
390 | - dbus_error_free(&hfp_error); | |
391 | + dbus_error_free(&hfp_error); | |
392 | if (mounted) | |
393 | - { | |
394 | + { | |
395 | libhal_device_set_property_bool(hfp_ctx, hfp_udi, "volume.ignore", TRUE, &hfp_error); | |
396 | dbus_error_free(&hfp_error); | |
397 | + break; | |
398 | } | |
399 | } | |
400 | } |