summaryrefslogtreecommitdiffstats
path: root/sysutils/hal/files
diff options
context:
space:
mode:
authormarcus <marcus@df743ca5-7f9a-e211-a948-0013205c9059>2009-05-17 13:02:48 +0800
committermarcus <marcus@df743ca5-7f9a-e211-a948-0013205c9059>2009-05-17 13:02:48 +0800
commit8c4f04e4a89fef0cf6d753ab345b30e1efc6ec55 (patch)
treee112945e4ddc3a8e5221630b30a910573ea70aba /sysutils/hal/files
parent13c8d5e854ed392a33fd53f6e634e5c821efc86c (diff)
downloadmarcuscom-ports-8c4f04e4a89fef0cf6d753ab345b30e1efc6ec55.tar
marcuscom-ports-8c4f04e4a89fef0cf6d753ab345b30e1efc6ec55.tar.gz
marcuscom-ports-8c4f04e4a89fef0cf6d753ab345b30e1efc6ec55.tar.bz2
marcuscom-ports-8c4f04e4a89fef0cf6d753ab345b30e1efc6ec55.tar.lz
marcuscom-ports-8c4f04e4a89fef0cf6d753ab345b30e1efc6ec55.tar.xz
marcuscom-ports-8c4f04e4a89fef0cf6d753ab345b30e1efc6ec55.tar.zst
marcuscom-ports-8c4f04e4a89fef0cf6d753ab345b30e1efc6ec55.zip
Update to 0.5.12.
git-svn-id: svn://creme-brulee.marcuscom.com/ports/trunk@12315 df743ca5-7f9a-e211-a948-0013205c9059
Diffstat (limited to 'sysutils/hal/files')
-rw-r--r--sysutils/hal/files/10-mouse-sysmouse.fdi8
-rw-r--r--sysutils/hal/files/README.fuse31
-rw-r--r--sysutils/hal/files/extra-patch-tools_hal-storage-mount.c25
-rw-r--r--sysutils/hal/files/hald.in80
-rwxr-xr-xsysutils/hal/files/mount-fuse153
-rw-r--r--sysutils/hal/files/patch-Makefile.in25
-rw-r--r--sysutils/hal/files/patch-config.h.in12
-rw-r--r--sysutils/hal/files/patch-configure540
-rw-r--r--sysutils/hal/files/patch-configure.in64
-rw-r--r--sysutils/hal/files/patch-doc_Makefile.in11
-rw-r--r--sysutils/hal/files/patch-fdi_policy_10osvendor_10-power-mgmt-policy.fdi13
-rw-r--r--sysutils/hal/files/patch-fdi_policy_10osvendor_10-x11-input.fdi24
-rw-r--r--sysutils/hal/files/patch-hald_freebsd_Makefile.am14
-rw-r--r--sysutils/hal/files/patch-hald_freebsd_Makefile.in109
-rw-r--r--sysutils/hal/files/patch-hald_freebsd_addons_Makefile.in93
-rw-r--r--sysutils/hal/files/patch-hald_freebsd_addons_addon-mouse.c374
-rw-r--r--sysutils/hal/files/patch-hald_freebsd_addons_addon-storage.c238
-rw-r--r--sysutils/hal/files/patch-hald_freebsd_clock111
-rw-r--r--sysutils/hal/files/patch-hald_freebsd_hf-acpi.c90
-rw-r--r--sysutils/hal/files/patch-hald_freebsd_hf-devd.c46
-rw-r--r--sysutils/hal/files/patch-hald_freebsd_hf-devtree.c77
-rw-r--r--sysutils/hal/files/patch-hald_freebsd_hf-storage.h13
-rw-r--r--sysutils/hal/files/patch-hald_freebsd_hf-usb.c96
-rw-r--r--sysutils/hal/files/patch-hald_freebsd_hf-usb.h10
-rw-r--r--sysutils/hal/files/patch-hald_freebsd_hf-usb2.c290
-rw-r--r--sysutils/hal/files/patch-hald_freebsd_hf-usb2.h40
-rw-r--r--sysutils/hal/files/patch-hald_freebsd_hf-volume.c102
-rw-r--r--sysutils/hal/files/patch-hald_freebsd_osspec.c22
-rw-r--r--sysutils/hal/files/patch-hald_freebsd_probing_Makefile.am51
-rw-r--r--sysutils/hal/files/patch-hald_freebsd_probing_Makefile.in162
-rw-r--r--sysutils/hal/files/patch-hald_freebsd_probing_probe-hiddev.c37
-rw-r--r--sysutils/hal/files/patch-hald_freebsd_probing_probe-mouse.c315
-rw-r--r--sysutils/hal/files/patch-hald_freebsd_probing_probe-storage.c39
-rw-r--r--sysutils/hal/files/patch-hald_freebsd_probing_probe-usb2-device.c206
-rw-r--r--sysutils/hal/files/patch-hald_freebsd_probing_probe-usb2-interface.c143
-rw-r--r--sysutils/hal/files/patch-hald_freebsd_probing_probe-volume.c12
-rw-r--r--sysutils/hal/files/patch-hald_hf-storage.c226
-rw-r--r--sysutils/hal/files/patch-tools_hal-storage-eject.c11
-rw-r--r--sysutils/hal/files/patch-tools_hal-storage-mount.c91
-rw-r--r--sysutils/hal/files/patch-tools_hal-storage-shared.c45
-rw-r--r--sysutils/hal/files/pkg-deinstall.in17
-rw-r--r--sysutils/hal/files/pkg-install.in52
42 files changed, 4118 insertions, 0 deletions
diff --git a/sysutils/hal/files/10-mouse-sysmouse.fdi b/sysutils/hal/files/10-mouse-sysmouse.fdi
new file mode 100644
index 000000000..cffd4f624
--- /dev/null
+++ b/sysutils/hal/files/10-mouse-sysmouse.fdi
@@ -0,0 +1,8 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<deviceinfo version="0.2">
+ <device>
+ <match key="info.capabilities" contains="input.mouse">
+ <append key="info.addons" type="strlist">hald-addon-mouse-sysmouse</append>
+ </match>
+ </device>
+</deviceinfo>
diff --git a/sysutils/hal/files/README.fuse b/sysutils/hal/files/README.fuse
new file mode 100644
index 000000000..cf390d472
--- /dev/null
+++ b/sysutils/hal/files/README.fuse
@@ -0,0 +1,31 @@
+Mounting Fuse File Systems with HAL
+-----------------------------------
+
+$FreeBSD: ports/sysutils/hal/files/README.fuse,v 1.1 2009/01/10 05:21:51 marcus Exp $
+
+Hal supports mounting Fuse device-backed file systems (e.g. NTFS). To enable
+this feature, copy the included %%LOCALBASE%%/share/hal/mount-fuse script
+to /sbin. Make sure this script is executable. Edit the script, and change
+the FUSE_HELPER environment variable to the name of the executable which
+will actually mount the Fuse volume (e.g. for NTFS, this is ``ntfs-3g'').
+
+Finally, the script must be renamed to ``mount_FSNAME''. FSNAME is the name
+of the file system type (e.g. for NTFS, this is ``ntfs''). If there is
+already an executable in /sbin or /usr/sbin with this name, the
+existing executable must be renamed or deleted.
+
+As is stated in the examples above, overriding FreeBSD's existing NTFS
+support with Fuse's ntfs-3g is the most common use case for this. The
+ntfs-3g Fuse driver uses different mount options than FreeBSD's included
+mount_ntfs. GNOME transparently supports switching between ntfs and
+ntfs-3g. Simply edit the following GConf key in the GNOME
+Configuration Editor (i.e. gconf-editor):
+
+/system/storage/default_options/ntfs/fstype_override
+
+Set the value to ``ntfs-3g'', then add your desired ntfs-3g options to the
+following GConf key:
+
+/system/storage/default_options/ntfs-3g/mount_options
+
+Other desktop systems may have similar options.
diff --git a/sysutils/hal/files/extra-patch-tools_hal-storage-mount.c b/sysutils/hal/files/extra-patch-tools_hal-storage-mount.c
new file mode 100644
index 000000000..f505709e1
--- /dev/null
+++ b/sysutils/hal/files/extra-patch-tools_hal-storage-mount.c
@@ -0,0 +1,25 @@
+--- tools/hal-storage-mount.c.orig 2008-05-20 13:24:30.000000000 -0400
++++ tools/hal-storage-mount.c 2008-05-20 13:30:14.000000000 -0400
+@@ -585,17 +585,11 @@ handle_mount (LibHalContext *hal_ctx,
+ explicit_mount_point_given = FALSE;
+ if (strlen (mount_point) == 0) {
+ char *p;
+-
+- if (label != NULL) {
+- /* best - use label */
+- g_strlcpy (mount_point, label, sizeof (mount_point));
+-
+- /* TODO: use drive type */
+-
+- } else {
+- /* fallback - use "disk" */
+- g_snprintf (mount_point, sizeof (mount_point), "%s", "disk");
+- }
++ char *basename;
++
++ basename = g_path_get_basename (device);
++ g_strlcpy (mount_point, basename, sizeof (mount_point));
++ g_free (basename);
+
+ /* sanitize computed mount point name, e.g. replace invalid chars with '-' */
+ p = mount_point;
diff --git a/sysutils/hal/files/hald.in b/sysutils/hal/files/hald.in
new file mode 100644
index 000000000..4121d4b57
--- /dev/null
+++ b/sysutils/hal/files/hald.in
@@ -0,0 +1,80 @@
+#!/bin/sh
+#
+# $FreeBSD: ports/sysutils/hal/files/hald.in,v 1.7 2009/01/26 17:55:44 marcus Exp $
+# $MCom: ports/sysutils/hal/files/hald.in,v 1.14 2008/08/21 16:04:48 mezz Exp $
+#
+# PROVIDE: hald
+# REQUIRE: DAEMON usbd devd dbus moused
+#
+# Add the following line to /etc/rc.conf to enable the HAL daemon:
+#
+# hald_enable="YES"
+#
+
+. %%RC_SUBR%%
+. %%GNOME_SUBR%%
+
+hald_enable=${hald_enable-${gnome_enable}}
+hald_flags=${hald_flags-""}
+
+name=hald
+rcvar=`set_rcvar`
+
+command="%%PREFIX%%/sbin/hald"
+pidfile="/var/run/${name}/${name}.pid"
+
+stop_postcmd="hald_postcmd"
+start_precmd="hald_precmd"
+start_cmd="hald_start"
+
+local_force_depend()
+{
+ _depend="$1"
+ if [ -f %%LOCALBASE%%/etc/rc.d/${_depend}.sh ]; then
+ _depend="${_depend}.sh"
+ fi
+
+ if ! %%LOCALBASE%%/etc/rc.d/${_depend} forcestatus 1>/dev/null 2>&1 &&
+ ! %%LOCALBASE%%/etc/rc.d/${_depend} forcestart; then
+ return 1
+ fi
+ return 0
+}
+
+hald_precmd()
+{
+ if ! checkyesno dbus_enable
+ then
+ local_force_depend dbus || return 1
+ fi
+
+ chmod 0755 /var/cache
+
+ mkdir -p $(dirname $pidfile)
+}
+
+hald_postcmd()
+{
+ rm -f $pidfile
+}
+
+hald_start()
+{
+ if ! checkyesno hald_enable ; then
+ return 0
+ fi
+ echo "Starting ${name}."
+
+ ( iter=0
+ while ! ps -axoargs | grep "^/usr/libexec/getty " | grep -qv grep >/dev/null 2>&1; do
+ if [ ${iter} -eq 60 ]; then
+ break
+ fi
+ sleep 1
+ iter=$(expr ${iter} + 1)
+ done
+ ${command} ${hald_flags} ) &
+}
+
+load_rc_config ${name}
+run_rc_command "$1"
diff --git a/sysutils/hal/files/mount-fuse b/sysutils/hal/files/mount-fuse
new file mode 100755
index 000000000..a0ea8536e
--- /dev/null
+++ b/sysutils/hal/files/mount-fuse
@@ -0,0 +1,153 @@
+#!/bin/sh
+# Wrapper script for FreeBSD and PC-BSD, which takes calls from HAL
+# for running mount_ntfs, and performs it with a given FUSE helper.
+###################################################################
+
+## Modify this next variable to point to the correct FUSE helper.
+FUSE_HELPER="ntfs-3g"
+## DO NOT modify anything below this.
+
+FUSEDB="/tmp"
+if [ -n "${TMPDIR}" ]
+then
+ FUSEDB=${TMPDIR}
+fi
+
+FUSEDB="${FUSEDB}/.fuse-mnts"
+MNTSTRING=""
+OPTIONS=""
+FOUNDOPT="0"
+FOUNDU="0"
+FOUNDG="0"
+FOUNDBADARG="0"
+HWDEV=""
+FOUNDDEV="0"
+
+for i in $@
+do
+ if [ "$FOUNDOPT" = "1" ]
+ then
+ OPTIONS="${OPTIONS} -o ${i}"
+ elif [ "${FOUNDU}" = "1" ]
+ then
+ OPTIONS="${OPTIONS} -o uid=${i}"
+ elif [ "${FOUNDG}" = "1" ]
+ then
+ OPTIONS="${OPTIONS} -o gid=${i}"
+ elif [ "${FOUNDBADARG}" = "1" ]
+ then
+ # We have an invalid argument flag, so ignore it and following argument
+ FOUNDBADARG="0"
+ else
+
+ if [ "${FOUNDDEV}" = "1" ]
+ then
+ # Save the mount-point, will be used later
+ MNTPOINT="${i}"
+ FOUNDDEV="2"
+ fi
+
+ echo ${i}| grep -q "/dev" 2>/dev/null
+ if [ "$?" = "0" -a "${FOUNDDEV}" = "0" ]
+ then
+ FOUNDDEV="1"
+ # Lets check if we were given a fuse[] device
+ # or a real device name
+ echo "${i}" | grep -q "fuse" 2>/dev/null
+ if [ "$?" = "0" ]
+ then
+ # Lets save the old fuse device name we had saved
+ OLDFUSE="${i}"
+
+ # Lets get the *real* device name for FUSE helper
+ REALHWDEV="`cat ${FUSEDB} | grep ${i} | cut -d '=' -f 2`"
+
+ # Now lets change the string we will be saving
+ i="${REALHWDEV}"
+ else
+ # We are doing a first time mount of this device
+
+ # Set the real device name for mounting
+ REALHWDEV="${i}"
+ fi
+ fi
+
+ # Add the value to our mount string if it isn't any invalid flag
+ if [ "${i}" != "-o" -a "${i}" != "-u" -a "${i}" != "-C" -a "${i}" != "-g" -a "${i}" != "-m" -a "${i}" != "-a" -a "${i}" != "-i" -a "${i}" -a "-W" ]
+ then
+ MNTSTRING="${MNTSTRING} ${i}"
+ fi
+
+ fi
+
+ # Check if we are on a -u user id flag now
+ if [ "${i}" = "-u" ]
+ then
+ FOUNDU="1"
+ else
+ FOUNDU="0"
+ fi
+
+ # Check if we are on a -g group id flag now
+ if [ "${i}" = "-g" ]
+ then
+ FOUNDG="1"
+ else
+ FOUNDG="0"
+ fi
+
+ # Check if we are on a -o option
+ if [ "${i}" = "-o" ]
+ then
+ FOUNDOPT="1"
+ else
+ FOUNDOPT="0"
+ fi
+
+ # Check if we are on some other invalid flag
+ if [ "${i}" = "-C" -o "${i}" = "-m" -o "${i}" = "-W" ]
+ then
+ FOUNDBADARG="1"
+ else
+ FOUNDBADARG="0"
+ fi
+done
+
+# Save our final string which our FUSE helper will use
+FINALSTRING="${MNTSTRING} ${OPTIONS}"
+
+# Check that fuse.ko is loaded
+kldstat | grep -q fuse 2>/dev/null
+if [ "$?" != "0" ]
+then
+ kldload /usr/local/modules/fuse.ko
+fi
+
+# Run the FUSE helper command now, with the options in the right order
+${FUSE_HELPER} ${FINALSTRING}
+
+# If we have an OLDFUSE variable, lets clear it from the list
+if [ ! -z "${OLDFUSE}" -a -e ${FUSEDB} ]
+then
+ cat ${FUSEDB} | grep -v "${OLDFUSE}=" > /tmp/.newfuse
+ mv /tmp/.newfuse ${FUSEDB}
+fi
+
+# Now lets figure out which fuse device was used and save it to DB
+NEWFUSE="`mount | tr -s ' ' | grep \" ${MNTPOINT} \" | cut -d ' ' -f 1`"
+
+# Make sure we don't already have this fuse device listed
+if [ -e ${FUSEDB} ]
+then
+ cat ${FUSEDB} | grep -v "${NEWFUSE}=" > /tmp/.newfuse
+ mv /tmp/.newfuse ${FUSEDB}
+else
+ touch ${FUSEDB}
+fi
+
+# Save the fuse device to our DB
+echo "${NEWFUSE}=${REALHWDEV}" >> ${FUSEDB}
+
+
+# Finished!
+exit 0
diff --git a/sysutils/hal/files/patch-Makefile.in b/sysutils/hal/files/patch-Makefile.in
new file mode 100644
index 000000000..17d23980f
--- /dev/null
+++ b/sysutils/hal/files/patch-Makefile.in
@@ -0,0 +1,25 @@
+--- Makefile.in.orig 2008-01-03 21:28:32.000000000 -0500
++++ Makefile.in 2008-01-03 21:29:15.000000000 -0500
+@@ -311,14 +311,14 @@ clean-libtool:
+ distclean-libtool:
+ -rm -f libtool
+ install-dist_dbusDATA: $(dist_dbus_DATA)
+- @$(NORMAL_INSTALL)
+- test -z "$(dbusdir)" || $(MKDIR_P) "$(DESTDIR)$(dbusdir)"
+- @list='$(dist_dbus_DATA)'; for p in $$list; do \
+- if test -f "$$p"; then d=; else d="$(srcdir)/"; fi; \
+- f=$(am__strip_dir) \
+- echo " $(dist_dbusDATA_INSTALL) '$$d$$p' '$(DESTDIR)$(dbusdir)/$$f'"; \
+- $(dist_dbusDATA_INSTALL) "$$d$$p" "$(DESTDIR)$(dbusdir)/$$f"; \
+- done
++# @$(NORMAL_INSTALL)
++# test -z "$(dbusdir)" || $(MKDIR_P) "$(DESTDIR)$(dbusdir)"
++# @list='$(dist_dbus_DATA)'; for p in $$list; do \
++# if test -f "$$p"; then d=; else d="$(srcdir)/"; fi; \
++# f=$(am__strip_dir) \
++# echo " $(dist_dbusDATA_INSTALL) '$$d$$p' '$(DESTDIR)$(dbusdir)/$$f'"; \
++# $(dist_dbusDATA_INSTALL) "$$d$$p" "$(DESTDIR)$(dbusdir)/$$f"; \
++# done
+
+ uninstall-dist_dbusDATA:
+ @$(NORMAL_UNINSTALL)
diff --git a/sysutils/hal/files/patch-config.h.in b/sysutils/hal/files/patch-config.h.in
new file mode 100644
index 000000000..e1208c9f9
--- /dev/null
+++ b/sysutils/hal/files/patch-config.h.in
@@ -0,0 +1,12 @@
+--- config.h.in.orig 2009-02-17 23:52:07.000000000 -0500
++++ config.h.in 2009-02-17 23:52:41.000000000 -0500
+@@ -61,6 +61,9 @@
+ /* Define to 1 if you have the `dl' library (-ldl). */
+ #undef HAVE_LIBDL
+
++/* Set if we need libusb20 */
++#undef HAVE_LIBUSB20
++
+ /* Define to 1 if you have the `uuid' library (-luuid). */
+ #undef HAVE_LIBUUID
+
diff --git a/sysutils/hal/files/patch-configure b/sysutils/hal/files/patch-configure
new file mode 100644
index 000000000..3a509e06b
--- /dev/null
+++ b/sysutils/hal/files/patch-configure
@@ -0,0 +1,540 @@
+--- configure.orig 2009-05-17 00:54:41.000000000 -0400
++++ configure 2009-05-17 00:56:13.000000000 -0400
+@@ -818,6 +818,8 @@ XMLTO
+ HALD_OS_LIBS
+ BLKID_LIBS
+ BLKID_CFLAGS
++VOLUME_ID_LIBS
++VOLUME_ID_CFLAGS
+ GLIB_LIBS
+ GLIB_CFLAGS
+ DBUS_LIBS
+@@ -847,6 +849,9 @@ HAVE_GPERF
+ GPERF
+ HAVE_CONKIT_FALSE
+ HAVE_CONKIT_TRUE
++LIBUSB20_LIBS
++HAVE_LIBUSB20_FALSE
++HAVE_LIBUSB20_TRUE
+ HALD_BACKEND
+ HALD_COMPILE_SOLARIS_FALSE
+ HALD_COMPILE_SOLARIS_TRUE
+@@ -1101,6 +1106,8 @@ DBUS_CFLAGS
+ DBUS_LIBS
+ GLIB_CFLAGS
+ GLIB_LIBS
++VOLUME_ID_CFLAGS
++VOLUME_ID_LIBS
+ BLKID_CFLAGS
+ BLKID_LIBS'
+
+@@ -1825,6 +1832,10 @@ Some influential environment variables:
+ DBUS_LIBS linker flags for DBUS, overriding pkg-config
+ GLIB_CFLAGS C compiler flags for GLIB, overriding pkg-config
+ GLIB_LIBS linker flags for GLIB, overriding pkg-config
++ VOLUME_ID_CFLAGS
++ C compiler flags for VOLUME_ID, overriding pkg-config
++ VOLUME_ID_LIBS
++ linker flags for VOLUME_ID, overriding pkg-config
+ BLKID_CFLAGS
+ C compiler flags for BLKID, overriding pkg-config
+ BLKID_LIBS linker flags for BLKID, overriding pkg-config
+@@ -2793,6 +2804,7 @@ fi
+ glib_module="glib-2.0 >= 2.10.0 gobject-2.0 > 2.10.0 dbus-glib-1 >= 0.61"
+ dbus_module="dbus-1 >= 0.61"
+ blkid_module="blkid >= 1.43"
++volume_id_module="libvolume_id >= 0.77"
+ polkit_module="polkit >= 0.5"
+
+ # libtool versioning - this applies to libhal and libhal-storage
+@@ -6517,13 +6529,13 @@ if test "${lt_cv_nm_interface+set}" = se
+ else
+ lt_cv_nm_interface="BSD nm"
+ echo "int some_variable = 0;" > conftest.$ac_ext
+- (eval echo "\"\$as_me:6520: $ac_compile\"" >&5)
++ (eval echo "\"\$as_me:6532: $ac_compile\"" >&5)
+ (eval "$ac_compile" 2>conftest.err)
+ cat conftest.err >&5
+- (eval echo "\"\$as_me:6523: $NM \\\"conftest.$ac_objext\\\"\"" >&5)
++ (eval echo "\"\$as_me:6535: $NM \\\"conftest.$ac_objext\\\"\"" >&5)
+ (eval "$NM \"conftest.$ac_objext\"" 2>conftest.err > conftest.out)
+ cat conftest.err >&5
+- (eval echo "\"\$as_me:6526: output\"" >&5)
++ (eval echo "\"\$as_me:6538: output\"" >&5)
+ cat conftest.out >&5
+ if $GREP 'External.*some_variable' conftest.out > /dev/null; then
+ lt_cv_nm_interface="MS dumpbin"
+@@ -7728,7 +7740,7 @@ ia64-*-hpux*)
+ ;;
+ *-*-irix6*)
+ # Find out which ABI we are using.
+- echo '#line 7731 "configure"' > conftest.$ac_ext
++ echo '#line 7743 "configure"' > conftest.$ac_ext
+ if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5
+ (eval $ac_compile) 2>&5
+ ac_status=$?
+@@ -9885,11 +9897,11 @@ else
+ -e 's:.*FLAGS}\{0,1\} :&$lt_compiler_flag :; t' \
+ -e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \
+ -e 's:$: $lt_compiler_flag:'`
+- (eval echo "\"\$as_me:9888: $lt_compile\"" >&5)
++ (eval echo "\"\$as_me:9900: $lt_compile\"" >&5)
+ (eval "$lt_compile" 2>conftest.err)
+ ac_status=$?
+ cat conftest.err >&5
+- echo "$as_me:9892: \$? = $ac_status" >&5
++ echo "$as_me:9904: \$? = $ac_status" >&5
+ if (exit $ac_status) && test -s "$ac_outfile"; then
+ # The compiler can only warn and ignore the option if not recognized
+ # So say no if there are warnings other than the usual output.
+@@ -10224,11 +10236,11 @@ else
+ -e 's:.*FLAGS}\{0,1\} :&$lt_compiler_flag :; t' \
+ -e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \
+ -e 's:$: $lt_compiler_flag:'`
+- (eval echo "\"\$as_me:10227: $lt_compile\"" >&5)
++ (eval echo "\"\$as_me:10239: $lt_compile\"" >&5)
+ (eval "$lt_compile" 2>conftest.err)
+ ac_status=$?
+ cat conftest.err >&5
+- echo "$as_me:10231: \$? = $ac_status" >&5
++ echo "$as_me:10243: \$? = $ac_status" >&5
+ if (exit $ac_status) && test -s "$ac_outfile"; then
+ # The compiler can only warn and ignore the option if not recognized
+ # So say no if there are warnings other than the usual output.
+@@ -10329,11 +10341,11 @@ else
+ -e 's:.*FLAGS}\{0,1\} :&$lt_compiler_flag :; t' \
+ -e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \
+ -e 's:$: $lt_compiler_flag:'`
+- (eval echo "\"\$as_me:10332: $lt_compile\"" >&5)
++ (eval echo "\"\$as_me:10344: $lt_compile\"" >&5)
+ (eval "$lt_compile" 2>out/conftest.err)
+ ac_status=$?
+ cat out/conftest.err >&5
+- echo "$as_me:10336: \$? = $ac_status" >&5
++ echo "$as_me:10348: \$? = $ac_status" >&5
+ if (exit $ac_status) && test -s out/conftest2.$ac_objext
+ then
+ # The compiler can only warn and ignore the option if not recognized
+@@ -10384,11 +10396,11 @@ else
+ -e 's:.*FLAGS}\{0,1\} :&$lt_compiler_flag :; t' \
+ -e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \
+ -e 's:$: $lt_compiler_flag:'`
+- (eval echo "\"\$as_me:10387: $lt_compile\"" >&5)
++ (eval echo "\"\$as_me:10399: $lt_compile\"" >&5)
+ (eval "$lt_compile" 2>out/conftest.err)
+ ac_status=$?
+ cat out/conftest.err >&5
+- echo "$as_me:10391: \$? = $ac_status" >&5
++ echo "$as_me:10403: \$? = $ac_status" >&5
+ if (exit $ac_status) && test -s out/conftest2.$ac_objext
+ then
+ # The compiler can only warn and ignore the option if not recognized
+@@ -13200,7 +13212,7 @@ else
+ lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2
+ lt_status=$lt_dlunknown
+ cat > conftest.$ac_ext <<_LT_EOF
+-#line 13203 "configure"
++#line 13215 "configure"
+ #include "confdefs.h"
+
+ #if HAVE_DLFCN_H
+@@ -13296,7 +13308,7 @@ else
+ lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2
+ lt_status=$lt_dlunknown
+ cat > conftest.$ac_ext <<_LT_EOF
+-#line 13299 "configure"
++#line 13311 "configure"
+ #include "confdefs.h"
+
+ #if HAVE_DLFCN_H
+@@ -15316,11 +15328,11 @@ else
+ -e 's:.*FLAGS}\{0,1\} :&$lt_compiler_flag :; t' \
+ -e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \
+ -e 's:$: $lt_compiler_flag:'`
+- (eval echo "\"\$as_me:15319: $lt_compile\"" >&5)
++ (eval echo "\"\$as_me:15331: $lt_compile\"" >&5)
+ (eval "$lt_compile" 2>conftest.err)
+ ac_status=$?
+ cat conftest.err >&5
+- echo "$as_me:15323: \$? = $ac_status" >&5
++ echo "$as_me:15335: \$? = $ac_status" >&5
+ if (exit $ac_status) && test -s "$ac_outfile"; then
+ # The compiler can only warn and ignore the option if not recognized
+ # So say no if there are warnings other than the usual output.
+@@ -15415,11 +15427,11 @@ else
+ -e 's:.*FLAGS}\{0,1\} :&$lt_compiler_flag :; t' \
+ -e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \
+ -e 's:$: $lt_compiler_flag:'`
+- (eval echo "\"\$as_me:15418: $lt_compile\"" >&5)
++ (eval echo "\"\$as_me:15430: $lt_compile\"" >&5)
+ (eval "$lt_compile" 2>out/conftest.err)
+ ac_status=$?
+ cat out/conftest.err >&5
+- echo "$as_me:15422: \$? = $ac_status" >&5
++ echo "$as_me:15434: \$? = $ac_status" >&5
+ if (exit $ac_status) && test -s out/conftest2.$ac_objext
+ then
+ # The compiler can only warn and ignore the option if not recognized
+@@ -15467,11 +15479,11 @@ else
+ -e 's:.*FLAGS}\{0,1\} :&$lt_compiler_flag :; t' \
+ -e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \
+ -e 's:$: $lt_compiler_flag:'`
+- (eval echo "\"\$as_me:15470: $lt_compile\"" >&5)
++ (eval echo "\"\$as_me:15482: $lt_compile\"" >&5)
+ (eval "$lt_compile" 2>out/conftest.err)
+ ac_status=$?
+ cat out/conftest.err >&5
+- echo "$as_me:15474: \$? = $ac_status" >&5
++ echo "$as_me:15486: \$? = $ac_status" >&5
+ if (exit $ac_status) && test -s out/conftest2.$ac_objext
+ then
+ # The compiler can only warn and ignore the option if not recognized
+@@ -19128,6 +19140,9 @@ else
+ fi
+
+
++USE_LIBUSB20=no
++USE_LIBUSB=no
++LIBUSB20_LIBS=""
+
+ # Check whether --with-backend was given.
+ if test "${with_backend+set}" = set; then
+@@ -19185,6 +19200,184 @@ else
+ fi
+
+
++if test "x$HALD_BACKEND" = "xfreebsd"; then
++ { $as_echo "$as_me:$LINENO: checking for libusb20_dev_get_info in -lusb20" >&5
++$as_echo_n "checking for libusb20_dev_get_info in -lusb20... " >&6; }
++if test "${ac_cv_lib_usb20_libusb20_dev_get_info+set}" = set; then
++ $as_echo_n "(cached) " >&6
++else
++ ac_check_lib_save_LIBS=$LIBS
++LIBS="-lusb20 $LIBS"
++cat >conftest.$ac_ext <<_ACEOF
++/* confdefs.h. */
++_ACEOF
++cat confdefs.h >>conftest.$ac_ext
++cat >>conftest.$ac_ext <<_ACEOF
++/* end confdefs.h. */
++
++/* Override any GCC internal prototype to avoid an error.
++ Use char because int might match the return type of a GCC
++ builtin and then its argument prototype would still apply. */
++#ifdef __cplusplus
++extern "C"
++#endif
++char libusb20_dev_get_info ();
++int
++main ()
++{
++return libusb20_dev_get_info ();
++ ;
++ return 0;
++}
++_ACEOF
++rm -f conftest.$ac_objext conftest$ac_exeext
++if { (ac_try="$ac_link"
++case "(($ac_try" in
++ *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
++ *) ac_try_echo=$ac_try;;
++esac
++eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\""
++$as_echo "$ac_try_echo") >&5
++ (eval "$ac_link") 2>conftest.er1
++ ac_status=$?
++ grep -v '^ *+' conftest.er1 >conftest.err
++ rm -f conftest.er1
++ cat conftest.err >&5
++ $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5
++ (exit $ac_status); } && {
++ test -z "$ac_c_werror_flag" ||
++ test ! -s conftest.err
++ } && test -s conftest$ac_exeext && {
++ test "$cross_compiling" = yes ||
++ $as_test_x conftest$ac_exeext
++ }; then
++ ac_cv_lib_usb20_libusb20_dev_get_info=yes
++else
++ $as_echo "$as_me: failed program was:" >&5
++sed 's/^/| /' conftest.$ac_ext >&5
++
++ ac_cv_lib_usb20_libusb20_dev_get_info=no
++fi
++
++rm -rf conftest.dSYM
++rm -f core conftest.err conftest.$ac_objext conftest_ipa8_conftest.oo \
++ conftest$ac_exeext conftest.$ac_ext
++LIBS=$ac_check_lib_save_LIBS
++fi
++{ $as_echo "$as_me:$LINENO: result: $ac_cv_lib_usb20_libusb20_dev_get_info" >&5
++$as_echo "$ac_cv_lib_usb20_libusb20_dev_get_info" >&6; }
++if test "x$ac_cv_lib_usb20_libusb20_dev_get_info" = x""yes; then
++ USE_LIBUSB20=yes
++else
++ USE_LIBUSB20=no
++fi
++
++fi
++if test "x$USE_LIBUSB20" = "xno"; then
++ { $as_echo "$as_me:$LINENO: checking for libusb20_dev_get_info in -lusb" >&5
++$as_echo_n "checking for libusb20_dev_get_info in -lusb... " >&6; }
++if test "${ac_cv_lib_usb_libusb20_dev_get_info+set}" = set; then
++ $as_echo_n "(cached) " >&6
++else
++ ac_check_lib_save_LIBS=$LIBS
++LIBS="-lusb $LIBS"
++cat >conftest.$ac_ext <<_ACEOF
++/* confdefs.h. */
++_ACEOF
++cat confdefs.h >>conftest.$ac_ext
++cat >>conftest.$ac_ext <<_ACEOF
++/* end confdefs.h. */
++
++/* Override any GCC internal prototype to avoid an error.
++ Use char because int might match the return type of a GCC
++ builtin and then its argument prototype would still apply. */
++#ifdef __cplusplus
++extern "C"
++#endif
++char libusb20_dev_get_info ();
++int
++main ()
++{
++return libusb20_dev_get_info ();
++ ;
++ return 0;
++}
++_ACEOF
++rm -f conftest.$ac_objext conftest$ac_exeext
++if { (ac_try="$ac_link"
++case "(($ac_try" in
++ *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
++ *) ac_try_echo=$ac_try;;
++esac
++eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\""
++$as_echo "$ac_try_echo") >&5
++ (eval "$ac_link") 2>conftest.er1
++ ac_status=$?
++ grep -v '^ *+' conftest.er1 >conftest.err
++ rm -f conftest.er1
++ cat conftest.err >&5
++ $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5
++ (exit $ac_status); } && {
++ test -z "$ac_c_werror_flag" ||
++ test ! -s conftest.err
++ } && test -s conftest$ac_exeext && {
++ test "$cross_compiling" = yes ||
++ $as_test_x conftest$ac_exeext
++ }; then
++ ac_cv_lib_usb_libusb20_dev_get_info=yes
++else
++ $as_echo "$as_me: failed program was:" >&5
++sed 's/^/| /' conftest.$ac_ext >&5
++
++ ac_cv_lib_usb_libusb20_dev_get_info=no
++fi
++
++rm -rf conftest.dSYM
++rm -f core conftest.err conftest.$ac_objext conftest_ipa8_conftest.oo \
++ conftest$ac_exeext conftest.$ac_ext
++LIBS=$ac_check_lib_save_LIBS
++fi
++{ $as_echo "$as_me:$LINENO: result: $ac_cv_lib_usb_libusb20_dev_get_info" >&5
++$as_echo "$ac_cv_lib_usb_libusb20_dev_get_info" >&6; }
++if test "x$ac_cv_lib_usb_libusb20_dev_get_info" = x""yes; then
++ USE_LIBUSB=yes
++else
++ USE_LIBUSB=np
++fi
++
++fi
++ if test "x$USE_LIBUSB20" = "xyes"; then
++ HAVE_LIBUSB20_TRUE=
++ HAVE_LIBUSB20_FALSE='#'
++else
++ HAVE_LIBUSB20_TRUE='#'
++ HAVE_LIBUSB20_FALSE=
++fi
++
++ if test "x$USE_LIBUSB" = "xyes"; then
++ HAVE_LIBUSB20_TRUE=
++ HAVE_LIBUSB20_FALSE='#'
++else
++ HAVE_LIBUSB20_TRUE='#'
++ HAVE_LIBUSB20_FALSE=
++fi
++
++if test "x$USE_LIBUSB20" = "xyes"; then
++
++cat >>confdefs.h <<\_ACEOF
++#define HAVE_LIBUSB20 1
++_ACEOF
++
++ LIBUSB20_LIBS="-lusb20"
++elif test "x$USE_LIBUSB" = "xyes"; then
++
++cat >>confdefs.h <<\_ACEOF
++#define HAVE_LIBUSB20 1
++_ACEOF
++
++ LIBUSB20_LIBS="-lusb"
++fi
++
+
+
+ cat >>confdefs.h <<_ACEOF
+@@ -19942,8 +20135,132 @@ fi
+ { $as_echo "$as_me:$LINENO: result: $have_glib_2_14" >&5
+ $as_echo "$have_glib_2_14" >&6; }
+
++case "$host" in
++*-*-freebsd*)
++
++pkg_failed=no
++{ $as_echo "$as_me:$LINENO: checking for VOLUME_ID" >&5
++$as_echo_n "checking for VOLUME_ID... " >&6; }
++
++if test -n "$PKG_CONFIG"; then
++ if test -n "$VOLUME_ID_CFLAGS"; then
++ pkg_cv_VOLUME_ID_CFLAGS="$VOLUME_ID_CFLAGS"
++ else
++ if test -n "$PKG_CONFIG" && \
++ { ($as_echo "$as_me:$LINENO: \$PKG_CONFIG --exists --print-errors \"\$volume_id_module\"") >&5
++ ($PKG_CONFIG --exists --print-errors "$volume_id_module") 2>&5
++ ac_status=$?
++ $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5
++ (exit $ac_status); }; then
++ pkg_cv_VOLUME_ID_CFLAGS=`$PKG_CONFIG --cflags "$volume_id_module" 2>/dev/null`
++else
++ pkg_failed=yes
++fi
++ fi
++else
++ pkg_failed=untried
++fi
++if test -n "$PKG_CONFIG"; then
++ if test -n "$VOLUME_ID_LIBS"; then
++ pkg_cv_VOLUME_ID_LIBS="$VOLUME_ID_LIBS"
++ else
++ if test -n "$PKG_CONFIG" && \
++ { ($as_echo "$as_me:$LINENO: \$PKG_CONFIG --exists --print-errors \"\$volume_id_module\"") >&5
++ ($PKG_CONFIG --exists --print-errors "$volume_id_module") 2>&5
++ ac_status=$?
++ $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5
++ (exit $ac_status); }; then
++ pkg_cv_VOLUME_ID_LIBS=`$PKG_CONFIG --libs "$volume_id_module" 2>/dev/null`
++else
++ pkg_failed=yes
++fi
++ fi
++else
++ pkg_failed=untried
++fi
++
++
++
++if test $pkg_failed = yes; then
++
++if $PKG_CONFIG --atleast-pkgconfig-version 0.20; then
++ _pkg_short_errors_supported=yes
++else
++ _pkg_short_errors_supported=no
++fi
++ if test $_pkg_short_errors_supported = yes; then
++ VOLUME_ID_PKG_ERRORS=`$PKG_CONFIG --short-errors --errors-to-stdout --print-errors "$volume_id_module"`
++ else
++ VOLUME_ID_PKG_ERRORS=`$PKG_CONFIG --errors-to-stdout --print-errors "$volume_id_module"`
++ fi
++ # Put the nasty error message in config.log where it belongs
++ echo "$VOLUME_ID_PKG_ERRORS" >&5
++
++ { { $as_echo "$as_me:$LINENO: error: Package requirements ($volume_id_module) were not met:
++
++$VOLUME_ID_PKG_ERRORS
++
++Consider adjusting the PKG_CONFIG_PATH environment variable if you
++installed software in a non-standard prefix.
++
++Alternatively, you may set the environment variables VOLUME_ID_CFLAGS
++and VOLUME_ID_LIBS to avoid the need to call pkg-config.
++See the pkg-config man page for more details.
++" >&5
++$as_echo "$as_me: error: Package requirements ($volume_id_module) were not met:
++
++$VOLUME_ID_PKG_ERRORS
++
++Consider adjusting the PKG_CONFIG_PATH environment variable if you
++installed software in a non-standard prefix.
++
++Alternatively, you may set the environment variables VOLUME_ID_CFLAGS
++and VOLUME_ID_LIBS to avoid the need to call pkg-config.
++See the pkg-config man page for more details.
++" >&2;}
++ { (exit 1); exit 1; }; }
++elif test $pkg_failed = untried; then
++ { { $as_echo "$as_me:$LINENO: error: in \`$ac_pwd':" >&5
++$as_echo "$as_me: error: in \`$ac_pwd':" >&2;}
++{ { $as_echo "$as_me:$LINENO: error: The pkg-config script could not be found or is too old. Make sure it
++is in your PATH or set the PKG_CONFIG environment variable to the full
++path to pkg-config.
++
++Alternatively, you may set the environment variables VOLUME_ID_CFLAGS
++and VOLUME_ID_LIBS to avoid the need to call pkg-config.
++See the pkg-config man page for more details.
++
++To get pkg-config, see <http://pkg-config.freedesktop.org/>.
++See \`config.log' for more details." >&5
++$as_echo "$as_me: error: The pkg-config script could not be found or is too old. Make sure it
++is in your PATH or set the PKG_CONFIG environment variable to the full
++path to pkg-config.
++
++Alternatively, you may set the environment variables VOLUME_ID_CFLAGS
++and VOLUME_ID_LIBS to avoid the need to call pkg-config.
++See the pkg-config man page for more details.
++
++To get pkg-config, see <http://pkg-config.freedesktop.org/>.
++See \`config.log' for more details." >&2;}
++ { (exit 1); exit 1; }; }; }
++else
++ VOLUME_ID_CFLAGS=$pkg_cv_VOLUME_ID_CFLAGS
++ VOLUME_ID_LIBS=$pkg_cv_VOLUME_ID_LIBS
++ { $as_echo "$as_me:$LINENO: result: yes" >&5
++$as_echo "yes" >&6; }
++ :
++fi
++
++
++ ;;
++*)
++ ;;
++esac
++
+ # blkid
+ case "$host" in
++*-*-freebsd*)
++ ;;
+ *-*-solaris*)
+ ;;
+ *)
+@@ -21440,6 +21757,20 @@ $as_echo "$as_me: error: conditional \"H
+ Usually this means the macro was only invoked conditionally." >&2;}
+ { (exit 1); exit 1; }; }
+ fi
++if test -z "${HAVE_LIBUSB20_TRUE}" && test -z "${HAVE_LIBUSB20_FALSE}"; then
++ { { $as_echo "$as_me:$LINENO: error: conditional \"HAVE_LIBUSB20\" was never defined.
++Usually this means the macro was only invoked conditionally." >&5
++$as_echo "$as_me: error: conditional \"HAVE_LIBUSB20\" was never defined.
++Usually this means the macro was only invoked conditionally." >&2;}
++ { (exit 1); exit 1; }; }
++fi
++if test -z "${HAVE_LIBUSB20_TRUE}" && test -z "${HAVE_LIBUSB20_FALSE}"; then
++ { { $as_echo "$as_me:$LINENO: error: conditional \"HAVE_LIBUSB20\" was never defined.
++Usually this means the macro was only invoked conditionally." >&5
++$as_echo "$as_me: error: conditional \"HAVE_LIBUSB20\" was never defined.
++Usually this means the macro was only invoked conditionally." >&2;}
++ { (exit 1); exit 1; }; }
++fi
+ if test -z "${HAVE_CONKIT_TRUE}" && test -z "${HAVE_CONKIT_FALSE}"; then
+ { { $as_echo "$as_me:$LINENO: error: conditional \"HAVE_CONKIT\" was never defined.
+ Usually this means the macro was only invoked conditionally." >&5
diff --git a/sysutils/hal/files/patch-configure.in b/sysutils/hal/files/patch-configure.in
new file mode 100644
index 000000000..27866ecee
--- /dev/null
+++ b/sysutils/hal/files/patch-configure.in
@@ -0,0 +1,64 @@
+--- configure.in.orig 2009-05-10 15:43:52.000000000 -0400
++++ configure.in 2009-05-17 00:53:29.000000000 -0400
+@@ -14,6 +14,7 @@ AM_MAINTAINER_MODE
+ glib_module="glib-2.0 >= 2.10.0 gobject-2.0 > 2.10.0 dbus-glib-1 >= 0.61"
+ dbus_module="dbus-1 >= 0.61"
+ blkid_module="blkid >= 1.43"
++volume_id_module="libvolume_id >= 0.77"
+ polkit_module="polkit >= 0.5"
+
+ # libtool versioning - this applies to libhal and libhal-storage
+@@ -477,6 +478,9 @@ if test "x$with_libpci" != xno ; then
+ fi
+ AM_CONDITIONAL([HAVE_LIBPCI], [test "x$USE_LIBPCI" = "xyes"])
+
++USE_LIBUSB20=no
++USE_LIBUSB=no
++LIBUSB20_LIBS=""
+ AC_ARG_WITH([backend],
+ AS_HELP_STRING([--with-backend=<name>],
+ [backend to use (linux/solaris/freebsd/dummy)]),
+@@ -504,6 +508,22 @@ AM_CONDITIONAL(HALD_COMPILE_LINUX, [test
+ AM_CONDITIONAL(HALD_COMPILE_FREEBSD, [test x$HALD_BACKEND = xfreebsd], [Compiling for FreeBSD])
+ AM_CONDITIONAL(HALD_COMPILE_SOLARIS, [test x$HALD_BACKEND = xsolaris], [Compiling for Solaris])
+ AC_SUBST(HALD_BACKEND)
++if test "x$HALD_BACKEND" = "xfreebsd"; then
++ AC_CHECK_LIB([usb20], [libusb20_dev_get_info], [USE_LIBUSB20=yes], [USE_LIBUSB20=no])
++fi
++if test "x$USE_LIBUSB20" = "xno"; then
++ AC_CHECK_LIB([usb], [libusb20_dev_get_info], [USE_LIBUSB=yes], [USE_LIBUSB=np])
++fi
++AM_CONDITIONAL([HAVE_LIBUSB20],[test "x$USE_LIBUSB20" = "xyes"])
++AM_CONDITIONAL([HAVE_LIBUSB20],[test "x$USE_LIBUSB" = "xyes"])
++if test "x$USE_LIBUSB20" = "xyes"; then
++ AC_DEFINE(HAVE_LIBUSB20, 1, [Set if we need libusb20])
++ LIBUSB20_LIBS="-lusb20"
++elif test "x$USE_LIBUSB" = "xyes"; then
++ AC_DEFINE(HAVE_LIBUSB20, 1, [Set if we need libsub20])
++ LIBUSB20_LIBS="-lusb"
++fi
++AC_SUBST(LIBUSB20_LIBS)
+
+ dnl DBUS API is subject to changes
+ AC_DEFINE_UNQUOTED(DBUS_API_SUBJECT_TO_CHANGE, [], [DBUS API is subject to change])
+@@ -685,8 +705,20 @@ else
+ fi
+ AC_MSG_RESULT($have_glib_2_14)
+
++case "$host" in
++*-*-freebsd*)
++ PKG_CHECK_MODULES(VOLUME_ID, [$volume_id_module])
++ AC_SUBST(VOLUME_ID_CFLAGS)
++ AC_SUBST(VOLUME_ID_LIBS)
++ ;;
++*)
++ ;;
++esac
++
+ # blkid
+ case "$host" in
++*-*-freebsd*)
++ ;;
+ *-*-solaris*)
+ ;;
+ *)
diff --git a/sysutils/hal/files/patch-doc_Makefile.in b/sysutils/hal/files/patch-doc_Makefile.in
new file mode 100644
index 000000000..9cd951720
--- /dev/null
+++ b/sysutils/hal/files/patch-doc_Makefile.in
@@ -0,0 +1,11 @@
+--- doc/Makefile.in.orig 2008-01-03 21:41:19.000000000 -0500
++++ doc/Makefile.in 2008-01-03 21:41:31.000000000 -0500
+@@ -203,7 +203,7 @@ target_alias = @target_alias@
+ top_builddir = @top_builddir@
+ top_srcdir = @top_srcdir@
+ EXTRA_DIST = TODO
+-SUBDIRS = api spec man
++SUBDIRS = spec man
+ MAINTAINERCLEANFILES = \
+ *~ \
+ Makefile.in
diff --git a/sysutils/hal/files/patch-fdi_policy_10osvendor_10-power-mgmt-policy.fdi b/sysutils/hal/files/patch-fdi_policy_10osvendor_10-power-mgmt-policy.fdi
new file mode 100644
index 000000000..1391709f8
--- /dev/null
+++ b/sysutils/hal/files/patch-fdi_policy_10osvendor_10-power-mgmt-policy.fdi
@@ -0,0 +1,13 @@
+--- fdi/policy/10osvendor/10-power-mgmt-policy.fdi.orig 2008-05-07 19:21:15.000000000 -0400
++++ fdi/policy/10osvendor/10-power-mgmt-policy.fdi 2009-01-30 17:41:05.000000000 -0500
+@@ -10,7 +10,9 @@
+
+ <device>
+ <match key="power_management.type" string="acpi">
+- <append key="info.addons" type="strlist">hald-addon-acpi</append>
++ <match key="/org/freedesktop/Hal/devices/computer:system.kernel.name" string="Linux">
++ <append key="info.addons" type="strlist">hald-addon-acpi</append>
++ </match>
+ </match>
+ </device>
+
diff --git a/sysutils/hal/files/patch-fdi_policy_10osvendor_10-x11-input.fdi b/sysutils/hal/files/patch-fdi_policy_10osvendor_10-x11-input.fdi
new file mode 100644
index 000000000..f3c0c6186
--- /dev/null
+++ b/sysutils/hal/files/patch-fdi_policy_10osvendor_10-x11-input.fdi
@@ -0,0 +1,24 @@
+--- fdi/policy/10osvendor/10-x11-input.fdi.orig 2009-03-23 03:18:33.000000000 -0400
++++ fdi/policy/10osvendor/10-x11-input.fdi 2009-05-17 00:41:26.000000000 -0400
+@@ -7,19 +7,10 @@
+ <merge key="input.x11_driver" type="string">evdev</merge>
+ </match>
+
+- <!-- FIXME: Support tablets too. -->
+- <match key="info.capabilities" contains="input.mouse">
+- <merge key="input.x11_driver" type="string">mouse</merge>
+- <match key="/org/freedesktop/Hal/devices/computer:system.kernel.name"
+- string="Linux">
+- <merge key="input.x11_driver" type="string">evdev</merge>
+- </match>
+- </match>
+-
+- <match key="info.capabilities" contains="input.keys">
++ <match key="info.capabilities" contains="input.keyboard">
+ <!-- If we're using Linux, we use evdev by default (falling back to
+ keyboard otherwise). -->
+- <merge key="input.x11_driver" type="string">keyboard</merge>
++ <merge key="input.x11_driver" type="string">kbd</merge>
+ <match key="/org/freedesktop/Hal/devices/computer:system.kernel.name"
+ string="Linux">
+ <merge key="input.x11_driver" type="string">evdev</merge>
diff --git a/sysutils/hal/files/patch-hald_freebsd_Makefile.am b/sysutils/hal/files/patch-hald_freebsd_Makefile.am
new file mode 100644
index 000000000..9a6b8c83d
--- /dev/null
+++ b/sysutils/hal/files/patch-hald_freebsd_Makefile.am
@@ -0,0 +1,14 @@
+--- hald/freebsd/Makefile.am.orig 2009-02-17 18:58:12.000000000 -0500
++++ hald/freebsd/Makefile.am 2009-02-18 00:16:12.000000000 -0500
+@@ -54,4 +54,11 @@ libhald_freebsd_la_SOURCES = \
+
+ libhald_freebsd_la_LDFLAGS = -lcam
+
++if HAVE_LIBUSB20
++libhald_freebsd_la_SOURCES += \
++ hf-usb2.c \
++ hf-usb2.h
++libhald_freebsd_la_LDFLAGS += @LIBUSB20_LIBS@
++endif
++
+ EXTRA_DIST = README TODO
diff --git a/sysutils/hal/files/patch-hald_freebsd_Makefile.in b/sysutils/hal/files/patch-hald_freebsd_Makefile.in
new file mode 100644
index 000000000..44dbf8adc
--- /dev/null
+++ b/sysutils/hal/files/patch-hald_freebsd_Makefile.in
@@ -0,0 +1,109 @@
+--- hald/freebsd/Makefile.in.orig 2009-05-17 00:43:12.000000000 -0400
++++ hald/freebsd/Makefile.in 2009-05-17 00:43:12.000000000 -0400
+@@ -32,6 +32,11 @@ PRE_UNINSTALL = :
+ POST_UNINSTALL = :
+ build_triplet = @build@
+ host_triplet = @host@
++@HAVE_LIBUSB20_TRUE@am__append_1 = \
++@HAVE_LIBUSB20_TRUE@ hf-usb2.c \
++@HAVE_LIBUSB20_TRUE@ hf-usb2.h
++
++@HAVE_LIBUSB20_TRUE@am__append_2 = @LIBUSB20_LIBS@
+ subdir = hald/freebsd
+ DIST_COMMON = README $(srcdir)/Makefile.am $(srcdir)/Makefile.in TODO
+ ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
+@@ -44,11 +49,20 @@ CONFIG_HEADER = $(top_builddir)/config.h
+ CONFIG_CLEAN_FILES =
+ LTLIBRARIES = $(noinst_LTLIBRARIES)
+ libhald_freebsd_la_LIBADD =
++am__libhald_freebsd_la_SOURCES_DIST = hf-acpi.c hf-acpi.h hf-ata.c \
++ hf-ata.h hf-block.c hf-block.h hf-computer.c hf-computer.h \
++ hf-devd.c hf-devd.h hf-devtree.c hf-devtree.h hf-drm.c \
++ hf-drm.h hf-net.c hf-net.h hf-osspec.h hf-pci.c hf-pci.h \
++ hf-pcmcia.c hf-pcmcia.h hf-scsi.c hf-scsi.h hf-serial.c \
++ hf-serial.h hf-sound.c hf-sound.h hf-storage.c hf-storage.h \
++ hf-usb.c hf-usb.h hf-util.c hf-util.h hf-volume.c hf-volume.h \
++ osspec.c hal-file-monitor.c hf-usb2.c hf-usb2.h
++@HAVE_LIBUSB20_TRUE@am__objects_1 = hf-usb2.lo
+ am_libhald_freebsd_la_OBJECTS = hf-acpi.lo hf-ata.lo hf-block.lo \
+ hf-computer.lo hf-devd.lo hf-devtree.lo hf-drm.lo hf-net.lo \
+ hf-pci.lo hf-pcmcia.lo hf-scsi.lo hf-serial.lo hf-sound.lo \
+ hf-storage.lo hf-usb.lo hf-util.lo hf-volume.lo osspec.lo \
+- hal-file-monitor.lo
++ hal-file-monitor.lo $(am__objects_1)
+ libhald_freebsd_la_OBJECTS = $(am_libhald_freebsd_la_OBJECTS)
+ libhald_freebsd_la_LINK = $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) \
+ $(LIBTOOLFLAGS) --mode=link $(CCLD) $(AM_CFLAGS) $(CFLAGS) \
+@@ -67,7 +81,7 @@ LINK = $(LIBTOOL) --tag=CC $(AM_LIBTOOLF
+ --mode=link $(CCLD) $(AM_CFLAGS) $(CFLAGS) $(AM_LDFLAGS) \
+ $(LDFLAGS) -o $@
+ SOURCES = $(libhald_freebsd_la_SOURCES)
+-DIST_SOURCES = $(libhald_freebsd_la_SOURCES)
++DIST_SOURCES = $(am__libhald_freebsd_la_SOURCES_DIST)
+ RECURSIVE_TARGETS = all-recursive check-recursive dvi-recursive \
+ html-recursive info-recursive install-data-recursive \
+ install-dvi-recursive install-exec-recursive \
+@@ -250,46 +264,15 @@ AM_CPPFLAGS = \
+ @GLIB_CFLAGS@ @DBUS_CFLAGS@ @POLKIT_CFLAGS@
+
+ @HALD_COMPILE_FREEBSD_TRUE@noinst_LTLIBRARIES = libhald_freebsd.la
+-libhald_freebsd_la_SOURCES = \
+- hf-acpi.c \
+- hf-acpi.h \
+- hf-ata.c \
+- hf-ata.h \
+- hf-block.c \
+- hf-block.h \
+- hf-computer.c \
+- hf-computer.h \
+- hf-devd.c \
+- hf-devd.h \
+- hf-devtree.c \
+- hf-devtree.h \
+- hf-drm.c \
+- hf-drm.h \
+- hf-net.c \
+- hf-net.h \
+- hf-osspec.h \
+- hf-pci.c \
+- hf-pci.h \
+- hf-pcmcia.c \
+- hf-pcmcia.h \
+- hf-scsi.c \
+- hf-scsi.h \
+- hf-serial.c \
+- hf-serial.h \
+- hf-sound.c \
+- hf-sound.h \
+- hf-storage.c \
+- hf-storage.h \
+- hf-usb.c \
+- hf-usb.h \
+- hf-util.c \
+- hf-util.h \
+- hf-volume.c \
+- hf-volume.h \
+- osspec.c \
+- hal-file-monitor.c
+-
+-libhald_freebsd_la_LDFLAGS = -lcam
++libhald_freebsd_la_SOURCES = hf-acpi.c hf-acpi.h hf-ata.c hf-ata.h \
++ hf-block.c hf-block.h hf-computer.c hf-computer.h hf-devd.c \
++ hf-devd.h hf-devtree.c hf-devtree.h hf-drm.c hf-drm.h hf-net.c \
++ hf-net.h hf-osspec.h hf-pci.c hf-pci.h hf-pcmcia.c hf-pcmcia.h \
++ hf-scsi.c hf-scsi.h hf-serial.c hf-serial.h hf-sound.c \
++ hf-sound.h hf-storage.c hf-storage.h hf-usb.c hf-usb.h \
++ hf-util.c hf-util.h hf-volume.c hf-volume.h osspec.c \
++ hal-file-monitor.c $(am__append_1)
++libhald_freebsd_la_LDFLAGS = -lcam $(am__append_2)
+ EXTRA_DIST = README TODO
+ all: all-recursive
+
+@@ -358,6 +341,7 @@ distclean-compile:
+ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/hf-sound.Plo@am__quote@
+ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/hf-storage.Plo@am__quote@
+ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/hf-usb.Plo@am__quote@
++@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/hf-usb2.Plo@am__quote@
+ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/hf-util.Plo@am__quote@
+ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/hf-volume.Plo@am__quote@
+ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/osspec.Plo@am__quote@
diff --git a/sysutils/hal/files/patch-hald_freebsd_addons_Makefile.in b/sysutils/hal/files/patch-hald_freebsd_addons_Makefile.in
new file mode 100644
index 000000000..f554c0650
--- /dev/null
+++ b/sysutils/hal/files/patch-hald_freebsd_addons_Makefile.in
@@ -0,0 +1,93 @@
+--- hald/freebsd/addons/Makefile.in.orig 2008-12-13 12:08:36.000000000 -0500
++++ hald/freebsd/addons/Makefile.in 2008-12-20 21:16:41.000000000 -0500
+@@ -33,7 +33,8 @@ POST_UNINSTALL = :
+ build_triplet = @build@
+ host_triplet = @host@
+ @HALD_COMPILE_FREEBSD_TRUE@libexec_PROGRAMS = \
+-@HALD_COMPILE_FREEBSD_TRUE@ hald-addon-storage$(EXEEXT)
++@HALD_COMPILE_FREEBSD_TRUE@ hald-addon-storage$(EXEEXT) \
++@HALD_COMPILE_FREEBSD_TRUE@ hald-addon-mouse-sysmouse$(EXEEXT)
+ subdir = hald/freebsd/addons
+ DIST_COMMON = $(srcdir)/Makefile.am $(srcdir)/Makefile.in
+ ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
+@@ -47,6 +48,15 @@ CONFIG_CLEAN_FILES =
+ am__installdirs = "$(DESTDIR)$(libexecdir)"
+ libexecPROGRAMS_INSTALL = $(INSTALL_PROGRAM)
+ PROGRAMS = $(libexec_PROGRAMS)
++am_hald_addon_mouse_sysmouse_OBJECTS = \
++ hald_addon_mouse_sysmouse-addon-mouse.$(OBJEXT)
++hald_addon_mouse_sysmouse_OBJECTS = \
++ $(am_hald_addon_mouse_sysmouse_OBJECTS)
++hald_addon_mouse_sysmouse_DEPENDENCIES = $(top_builddir)/hald/freebsd/libprobe/libhald_freebsd_probe.la
++hald_addon_mouse_sysmouse_LINK = $(LIBTOOL) --tag=CC \
++ $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=link $(CCLD) \
++ $(hald_addon_mouse_sysmouse_CFLAGS) $(CFLAGS) $(AM_LDFLAGS) \
++ $(LDFLAGS) -o $@
+ am_hald_addon_storage_OBJECTS = addon-storage.$(OBJEXT)
+ hald_addon_storage_OBJECTS = $(am_hald_addon_storage_OBJECTS)
+ hald_addon_storage_DEPENDENCIES = $(top_builddir)/hald/freebsd/libprobe/libhald_freebsd_probe.la
+@@ -62,8 +72,10 @@ CCLD = $(CC)
+ LINK = $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) \
+ --mode=link $(CCLD) $(AM_CFLAGS) $(CFLAGS) $(AM_LDFLAGS) \
+ $(LDFLAGS) -o $@
+-SOURCES = $(hald_addon_storage_SOURCES)
+-DIST_SOURCES = $(hald_addon_storage_SOURCES)
++SOURCES = $(hald_addon_mouse_sysmouse_SOURCES) \
++ $(hald_addon_storage_SOURCES)
++DIST_SOURCES = $(hald_addon_mouse_sysmouse_SOURCES) \
++ $(hald_addon_storage_SOURCES)
+ ETAGS = etags
+ CTAGS = ctags
+ DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST)
+@@ -229,6 +241,12 @@ hald_addon_storage_SOURCES = addon-stora
+ hald_addon_storage_LDADD = \
+ $(top_builddir)/hald/freebsd/libprobe/libhald_freebsd_probe.la
+
++hald_addon_mouse_sysmouse_SOURCES = addon-mouse.c
++hald_addon_mouse_sysmouse_CFLAGS = $(AM_CPPFLAGS) @GLIB_CFLAGS@
++hald_addon_mouse_sysmouse_LDADD = @GLIB_LIBS@ \
++ -lutil \
++ $(top_builddir)/hald/freebsd/libprobe/libhald_freebsd_probe.la
++
+ all: all-am
+
+ .SUFFIXES:
+@@ -290,6 +308,9 @@ clean-libexecPROGRAMS:
+ echo " rm -f $$p $$f"; \
+ rm -f $$p $$f ; \
+ done
++hald-addon-mouse-sysmouse$(EXEEXT): $(hald_addon_mouse_sysmouse_OBJECTS) $(hald_addon_mouse_sysmouse_DEPENDENCIES)
++ @rm -f hald-addon-mouse-sysmouse$(EXEEXT)
++ $(hald_addon_mouse_sysmouse_LINK) $(hald_addon_mouse_sysmouse_OBJECTS) $(hald_addon_mouse_sysmouse_LDADD) $(LIBS)
+ hald-addon-storage$(EXEEXT): $(hald_addon_storage_OBJECTS) $(hald_addon_storage_DEPENDENCIES)
+ @rm -f hald-addon-storage$(EXEEXT)
+ $(LINK) $(hald_addon_storage_OBJECTS) $(hald_addon_storage_LDADD) $(LIBS)
+@@ -301,6 +322,7 @@ distclean-compile:
+ -rm -f *.tab.c
+
+ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/addon-storage.Po@am__quote@
++@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/hald_addon_mouse_sysmouse-addon-mouse.Po@am__quote@
+
+ .c.o:
+ @am__fastdepCC_TRUE@ $(COMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $<
+@@ -323,6 +345,20 @@ distclean-compile:
+ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+ @am__fastdepCC_FALSE@ $(LTCOMPILE) -c -o $@ $<
+
++hald_addon_mouse_sysmouse-addon-mouse.o: addon-mouse.c
++@am__fastdepCC_TRUE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(hald_addon_mouse_sysmouse_CFLAGS) $(CFLAGS) -MT hald_addon_mouse_sysmouse-addon-mouse.o -MD -MP -MF $(DEPDIR)/hald_addon_mouse_sysmouse-addon-mouse.Tpo -c -o hald_addon_mouse_sysmouse-addon-mouse.o `test -f 'addon-mouse.c' || echo '$(srcdir)/'`addon-mouse.c
++@am__fastdepCC_TRUE@ mv -f $(DEPDIR)/hald_addon_mouse_sysmouse-addon-mouse.Tpo $(DEPDIR)/hald_addon_mouse_sysmouse-addon-mouse.Po
++@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='addon-mouse.c' object='hald_addon_mouse_sysmouse-addon-mouse.o' libtool=no @AMDEPBACKSLASH@
++@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
++@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(hald_addon_mouse_sysmouse_CFLAGS) $(CFLAGS) -c -o hald_addon_mouse_sysmouse-addon-mouse.o `test -f 'addon-mouse.c' || echo '$(srcdir)/'`addon-mouse.c
++
++hald_addon_mouse_sysmouse-addon-mouse.obj: addon-mouse.c
++@am__fastdepCC_TRUE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(hald_addon_mouse_sysmouse_CFLAGS) $(CFLAGS) -MT hald_addon_mouse_sysmouse-addon-mouse.obj -MD -MP -MF $(DEPDIR)/hald_addon_mouse_sysmouse-addon-mouse.Tpo -c -o hald_addon_mouse_sysmouse-addon-mouse.obj `if test -f 'addon-mouse.c'; then $(CYGPATH_W) 'addon-mouse.c'; else $(CYGPATH_W) '$(srcdir)/addon-mouse.c'; fi`
++@am__fastdepCC_TRUE@ mv -f $(DEPDIR)/hald_addon_mouse_sysmouse-addon-mouse.Tpo $(DEPDIR)/hald_addon_mouse_sysmouse-addon-mouse.Po
++@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='addon-mouse.c' object='hald_addon_mouse_sysmouse-addon-mouse.obj' libtool=no @AMDEPBACKSLASH@
++@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
++@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(hald_addon_mouse_sysmouse_CFLAGS) $(CFLAGS) -c -o hald_addon_mouse_sysmouse-addon-mouse.obj `if test -f 'addon-mouse.c'; then $(CYGPATH_W) 'addon-mouse.c'; else $(CYGPATH_W) '$(srcdir)/addon-mouse.c'; fi`
++
+ mostlyclean-libtool:
+ -rm -f *.lo
+
diff --git a/sysutils/hal/files/patch-hald_freebsd_addons_addon-mouse.c b/sysutils/hal/files/patch-hald_freebsd_addons_addon-mouse.c
new file mode 100644
index 000000000..cf9d96346
--- /dev/null
+++ b/sysutils/hal/files/patch-hald_freebsd_addons_addon-mouse.c
@@ -0,0 +1,374 @@
+--- hald/freebsd/addons/addon-mouse.c.orig 2009-01-25 16:54:29.000000000 -0500
++++ hald/freebsd/addons/addon-mouse.c 2009-01-25 23:00:48.000000000 -0500
+@@ -0,0 +1,371 @@
++/***************************************************************************
++ * CVSID: $Id: patch-hald_freebsd_addons_addon-mouse.c,v 1.4 2009-05-17 05:02:48 marcus Exp $
++ *
++ * addon-mouse.c : poll mice to disable moused(8) owned devices
++ *
++ * Copyright (C) 2008 Joe Marcus Clarke
++ *
++ * This program is free software; you can redistribute it and/or modify
++ * it under the terms of the GNU General Public License as published by
++ * the Free Software Foundation; either version 2 of the License, or
++ * (at your option) any later version.
++ *
++ * This program is distributed in the hope that it will be useful,
++ * but WITHOUT ANY WARRANTY; without even the implied warranty of
++ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
++ * GNU General Public License for more details.
++ *
++ * You should have received a copy of the GNU General Public License
++ * along with this program; if not, write to the Free Software
++ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
++ *
++ **************************************************************************/
++
++#ifdef HAVE_CONFIG_H
++# include <config.h>
++#endif
++
++#include <sys/param.h>
++#include <sys/types.h>
++#include <sys/event.h>
++#include <sys/time.h>
++#include <sys/proc.h>
++#if __FreeBSD_version >= 800058
++#include <sys/types.h>
++#include <sys/user.h>
++#include <sys/sysctl.h>
++#include <libutil.h>
++#endif
++#include <string.h>
++#include <stdlib.h>
++#include <assert.h>
++#include <unistd.h>
++#include <glib.h>
++
++#include "libhal/libhal.h"
++
++#include "../libprobe/hfp.h"
++
++#if __FreeBSD_version < 800058
++#define CMD "/usr/bin/fstat %s"
++#endif
++
++#define MOUSED_DEVICE "/dev/sysmouse"
++#define MOUSED_PROC_NAME "moused"
++#define XORG_PROC_NAME "Xorg"
++#define NO_PID -1
++
++static struct
++{
++ const struct timespec update_interval;
++ char *device_file;
++ struct timespec next_update;
++} addon = { { 2, 0 } };
++
++static int kd = -1;
++
++#if __FreeBSD_version >= 800058
++static struct kinfo_proc *
++hfp_kinfo_getproc (int *cntp)
++{
++ int mib[3];
++ int error;
++ int cnt;
++ size_t len;
++ char *buf, *bp, *eb;
++ struct kinfo_proc *kip, *kp, *ki;
++
++ *cntp = 0;
++
++ len = 0;
++ mib[0] = CTL_KERN;
++ mib[1] = KERN_PROC;
++ mib[2] = KERN_PROC_PROC;
++
++ error = sysctl(mib, 3, NULL, &len, NULL, 0);
++ if (error)
++ return NULL;
++
++ len = len * 4 / 3;
++ buf = (char *) g_malloc(len);
++ if (buf == NULL)
++ return NULL;
++
++ error = sysctl(mib, 3, buf, &len, NULL, 0);
++ if (error)
++ {
++ g_free(buf);
++ return NULL;
++ }
++
++ cnt = 0;
++ bp = buf;
++ eb = buf + len;
++ while (bp < eb)
++ {
++ ki = (struct kinfo_proc *) (uintptr_t) bp;
++ bp += ki->ki_structsize;
++ cnt++;
++ }
++
++ kip = calloc(cnt, sizeof (*kip));
++ if (kip == NULL)
++ {
++ g_free(buf);
++ return NULL;
++ }
++
++ bp = buf;
++ eb = buf + len;
++ kp = kip;
++ while (bp < eb)
++ {
++ ki = (struct kinfo_proc *) (uintptr_t) bp;
++ memcpy(kp, ki, ki->ki_structsize);
++ bp += ki->ki_structsize;
++ kp->ki_structsize = sizeof(*kp);
++ kp++;
++ }
++
++ g_free(buf);
++ *cntp = cnt;
++ return kip;
++}
++
++static gboolean
++device_opened_by_proc (const char *device, const char *proc, pid_t *pid)
++{
++ struct kinfo_proc *kip, *pfreep;
++ int cnt, i;
++
++ *pid = NO_PID;
++
++ pfreep = hfp_kinfo_getproc(&cnt);
++ if (pfreep == NULL)
++ return FALSE;
++
++ for (i = 0; i < cnt; i++)
++ {
++ kip = &pfreep[i];
++
++ if (! strcmp(kip->ki_comm, proc))
++ {
++ struct kinfo_file *kif, *ffreep;
++ int fcnt, j;
++
++ ffreep = kinfo_getfile(kip->ki_pid, &fcnt);
++ if (ffreep == NULL)
++ continue;
++ for (j = 0; j < fcnt; j++)
++ {
++ kif = &ffreep[j];
++
++ if (kif->kf_type == KF_TYPE_VNODE &&
++ ! strcmp(kif->kf_path, device))
++ {
++ *pid = kip->ki_pid;
++ g_free(ffreep);
++ g_free(pfreep);
++ return TRUE;
++ }
++ }
++ g_free(ffreep);
++ }
++ }
++ g_free(pfreep);
++
++ return FALSE;
++}
++#else
++static gboolean
++device_opened_by_proc (const char *device, const char *proc, pid_t *pid)
++{
++ char **lines;
++ char *output = NULL;
++ char *cmd;
++ int i;
++ gboolean found = FALSE;
++
++ cmd = g_strdup_printf(CMD, device);
++ *pid = NO_PID;
++
++ if (! g_spawn_command_line_sync(cmd, &output, NULL, NULL, NULL))
++ {
++ g_free(cmd);
++ goto done;
++ }
++ g_free(cmd);
++
++ if (! output || strlen(output) == 0)
++ goto done;
++
++ lines = g_strsplit(output, "\n", 0);
++ if (g_strv_length(lines) < 2)
++ {
++ g_strfreev(lines);
++ goto done;
++ }
++
++ for (i = 1; lines[i]; i++)
++ {
++ char **fields;
++ guint len;
++ guint j;
++
++ fields = g_strsplit_set(lines[i], " ", 0);
++ len = g_strv_length(fields);
++ if (len < 3)
++ {
++ g_strfreev(fields);
++ continue;
++ }
++ for (j = 1; j < len && fields[j] && *fields[j] == '\0'; j++)
++ ;
++ if (j < len && fields[j] && ! strcmp(fields[j], proc))
++ {
++ found = TRUE;
++ for (++j; j < len && fields[j] && *fields[j] == '\0'; j++)
++ ;
++ if (j < len && fields[j])
++ *pid = atoi(fields[j]);
++ g_strfreev(fields);
++ break;
++ }
++ g_strfreev(fields);
++ }
++
++ g_strfreev(lines);
++
++done:
++ g_free(output);
++
++ return found;
++}
++#endif
++
++static const char *
++get_mouse_device (const char *device, pid_t *pid)
++{
++ if (device_opened_by_proc(device, MOUSED_PROC_NAME, pid))
++ return MOUSED_DEVICE;
++
++ return device;
++}
++
++static void
++poll_for_moused (void)
++{
++ struct kevent ev;
++ const char *device;
++ gboolean found;
++ pid_t pid;
++ char *owner = NULL;
++ char *prev_owner = NULL;
++
++again:
++ device = get_mouse_device(addon.device_file, &pid);
++ if (pid != NO_PID)
++ {
++ EV_SET(&ev, pid, EVFILT_PROC, EV_ADD | EV_ENABLE, NOTE_EXIT, 0, NULL);
++ if (kevent(kd, &ev, 1, NULL, 0, NULL) < 0)
++ return;
++ g_free(owner);
++ owner = g_strdup(MOUSED_PROC_NAME);
++ }
++ else
++ {
++ found = device_opened_by_proc(device, XORG_PROC_NAME, &pid);
++ if (found && pid != NO_PID)
++ {
++ EV_SET(&ev, pid, EVFILT_PROC, EV_ADD | EV_ENABLE, NOTE_EXIT, 0, NULL);
++ if (kevent(kd, &ev, 1, NULL, 0, NULL) < 0)
++ return;
++ g_free(owner);
++ owner = g_strdup(XORG_PROC_NAME);
++ }
++ else
++ goto out;
++ }
++
++ if (owner && prev_owner && strcmp(owner, prev_owner))
++ goto out;
++
++ if (kevent(kd, NULL, 0, &ev, 1, NULL) < 0)
++ return;
++
++ sleep(3);
++ g_free(prev_owner);
++ prev_owner = NULL;
++ if (owner)
++ prev_owner = g_strdup(owner);
++ goto again;
++
++out:
++ if (owner)
++ {
++ libhal_device_reprobe(hfp_ctx, hfp_udi, &hfp_error);
++ dbus_error_free(&hfp_error);
++ }
++ g_free(owner);
++ g_free(prev_owner);
++}
++
++int
++main (int argc, char **argv)
++{
++ DBusConnection *connection;
++
++ if (! hfp_init(argc, argv))
++ goto end;
++
++ addon.device_file = getenv("HAL_PROP_FREEBSD_DEVICE_FILE");
++ if (! addon.device_file)
++ goto end;
++
++ setproctitle("%s", addon.device_file);
++
++ if (! libhal_device_addon_is_ready(hfp_ctx, hfp_udi, &hfp_error))
++ goto end;
++ dbus_error_free(&hfp_error);
++
++ connection = libhal_ctx_get_dbus_connection(hfp_ctx);
++ assert(connection != NULL);
++
++ kd = kqueue();
++ assert(kd > -1);
++
++ while (TRUE)
++ {
++ /* process dbus traffic until update interval has elapsed */
++ while (TRUE)
++ {
++ struct timespec now;
++
++ hfp_clock_gettime(&now);
++ if (hfp_timespeccmp(&now, &addon.next_update, <))
++ {
++ struct timespec timeout;
++
++ timeout = addon.next_update;
++ hfp_timespecsub(&timeout, &now);
++
++ if (timeout.tv_sec < 0) /* current time went backwards */
++ timeout = addon.update_interval;
++
++ dbus_connection_read_write_dispatch(connection, timeout.tv_sec * 1000 + timeout.tv_nsec / 1000000);
++ if (! dbus_connection_get_is_connected(connection))
++ goto end;
++ }
++ else
++ break;
++ }
++
++ poll_for_moused();
++
++ hfp_clock_gettime(&addon.next_update);
++ hfp_timespecadd(&addon.next_update, &addon.update_interval);
++ }
++
++ end:
++ return 0;
++}
diff --git a/sysutils/hal/files/patch-hald_freebsd_addons_addon-storage.c b/sysutils/hal/files/patch-hald_freebsd_addons_addon-storage.c
new file mode 100644
index 000000000..474658423
--- /dev/null
+++ b/sysutils/hal/files/patch-hald_freebsd_addons_addon-storage.c
@@ -0,0 +1,238 @@
+--- hald/freebsd/addons/addon-storage.c.orig 2008-05-07 19:24:04.000000000 -0400
++++ hald/freebsd/addons/addon-storage.c 2008-05-19 02:18:59.000000000 -0400
+@@ -36,17 +36,23 @@
+ #include "../libprobe/hfp.h"
+ #include "../libprobe/hfp-cdrom.h"
+
++static boolean is_locked_by_hal = FALSE;
++static boolean check_lock_state = TRUE;
++static boolean polling_disabled = FALSE;
++
+ static struct
+ {
+- const struct timeval update_interval;
++ const struct timespec update_interval;
+ char *device_file;
+ char *parent;
+ boolean is_cdrom;
+ boolean is_scsi_removable;
+ boolean had_media;
+- struct timeval next_update;
++ struct timespec next_update;
+ } addon = { { 2, 0 } };
+
++static void update_proc_title (const char *device);
++
+ /* see MMC-3 Working Draft Revision 10 */
+ static boolean
+ hf_addon_storage_cdrom_eject_pressed (HFPCDROM *cdrom)
+@@ -144,18 +150,49 @@ hf_addon_storage_update (void)
+ }
+ }
+
+- hfp_gettimeofday(&addon.next_update);
+- hfp_timevaladd(&addon.next_update, &addon.update_interval);
+-
+ return has_media;
+ }
+
+ static boolean
+-poll_for_media (void)
++poll_for_media (boolean check_only, boolean force)
+ {
+ boolean has_media;
+
++ if (check_lock_state)
++ {
++ boolean should_poll;
++
++ check_lock_state = FALSE;
++
++ hfp_info("Checking whether device %s is locked by HAL", addon.device_file);
++ if (libhal_device_is_locked_by_others(hfp_ctx, hfp_udi, "org.freedesktop.Hal.Device.Storage", &hfp_error))
++ {
++ hfp_info("... device %s is locked by HAL", addon.device_file);
++ dbus_error_free(&hfp_error);
++ is_locked_by_hal = TRUE;
++ update_proc_title(addon.device_file);
++ goto skip_check;
++ }
++ else
++ {
++ hfp_info("... device %s is not locked by HAL", addon.device_file);
++ is_locked_by_hal = FALSE;
++ }
++ dbus_error_free(&hfp_error);
++
++ should_poll = libhal_device_get_property_bool(hfp_ctx, hfp_udi, "storage.media_check_enabled", &hfp_error);
++ dbus_error_free(&hfp_error);
++ polling_disabled = ! should_poll;
++ update_proc_title(addon.device_file);
++ }
++
++ if (! force && polling_disabled)
++ goto skip_check;
++
+ has_media = hf_addon_storage_update();
++ if (check_only)
++ return has_media;
++
+ if (has_media != addon.had_media)
+ {
+ /*
+@@ -175,20 +212,33 @@ poll_for_media (void)
+
+ return TRUE;
+ }
++
++skip_check:
++
+ return FALSE;
+ }
+
+ static void
+-update_proc_title (const char *device, boolean polling_enabled)
++update_proc_title (const char *device)
+ {
+- if (polling_enabled)
+- setproctitle("%s", device);
+- else
++ if (polling_disabled)
+ setproctitle("no polling on %s because it is explicitly disabled", device);
++ else if (is_locked_by_hal)
++ setproctitle("no polling on %s because it is locked by HAL", device);
++ else
++ setproctitle("%s", device);
+ }
+
+ static DBusHandlerResult
+-filter_function (DBusConnection *connection, DBusMessage *message, void *user_data)
++dbus_filter_function (DBusConnection *connection, DBusMessage *message, void *user_data)
++{
++ check_lock_state = TRUE;
++
++ return DBUS_HANDLER_RESULT_HANDLED;
++}
++
++static DBusHandlerResult
++direct_filter_function (DBusConnection *connection, DBusMessage *message, void *user_data)
+ {
+ if (dbus_message_is_method_call(message,
+ "org.freedesktop.Hal.Device.Storage.Removable",
+@@ -199,7 +249,7 @@ filter_function (DBusConnection *connect
+
+ hfp_info("Forcing poll for media becusse CheckForMedia() was called");
+
+- had_effect = poll_for_media();
++ had_effect = poll_for_media(FALSE, TRUE);
+
+ reply = dbus_message_new_method_return (message);
+ dbus_message_append_args(reply, DBUS_TYPE_BOOLEAN, &had_effect, DBUS_TYPE_INVALID);
+@@ -217,8 +267,9 @@ main (int argc, char **argv)
+ char *removable;
+ char *bus;
+ char *driver;
+- boolean should_poll;
++ char *filter_str;
+ DBusConnection *connection;
++ DBusConnection *syscon;
+
+ if (! hfp_init(argc, argv))
+ goto end;
+@@ -251,16 +302,41 @@ main (int argc, char **argv)
+ addon.is_scsi_removable = (! strcmp(bus, "scsi") ||
+ (! strcmp(bus, "usb") && (! strcmp(driver, "da") || ! strcmp(driver, "sa") ||
+ ! strcmp(driver, "cd")))) && ! strcmp(removable, "true");
+- addon.had_media = hf_addon_storage_update();
++ addon.had_media = poll_for_media(TRUE, FALSE);
+
+ if (! libhal_device_addon_is_ready(hfp_ctx, hfp_udi, &hfp_error))
+ goto end;
+ dbus_error_free(&hfp_error);
+
++ syscon = dbus_bus_get(DBUS_BUS_SYSTEM, &hfp_error);
++ dbus_error_free(&hfp_error);
++ assert(syscon != NULL);
++ dbus_connection_set_exit_on_disconnect(syscon, 0);
++
++ dbus_bus_add_match(syscon,
++ "type='signal'"
++ ",interface='org.freedesktop.Hal.Manager'"
++ ",sender='org.freedesktop.Hal'",
++ NULL);
++ dbus_bus_add_match(syscon,
++ "type='signal'"
++ ",interface='org.freedesktop.Hal.Manager'"
++ ",sender='org.freedesktop.Hal'",
++ NULL);
++ filter_str = hfp_strdup_printf("type='signal'"
++ ",interface='org.freedesktop.Hal.Device'"
++ ",sender='org.freedesktop.Hal'"
++ ",path='%s'",
++ hfp_udi);
++ dbus_bus_add_match(syscon, filter_str, NULL);
++ hfp_free(filter_str);
++
++ dbus_connection_add_filter(syscon, dbus_filter_function, NULL, NULL);
++
+ connection = libhal_ctx_get_dbus_connection(hfp_ctx);
+ assert(connection != NULL);
+ dbus_connection_set_exit_on_disconnect(connection, 0);
+- dbus_connection_add_filter(connection, filter_function, NULL, NULL);
++ dbus_connection_add_filter(connection, direct_filter_function, NULL, NULL);
+
+ if (! libhal_device_claim_interface(hfp_ctx,
+ hfp_udi,
+@@ -280,40 +356,32 @@ main (int argc, char **argv)
+ /* process dbus traffic until update interval has elapsed */
+ while (TRUE)
+ {
+- struct timeval now;
++ struct timespec now;
+
+- hfp_gettimeofday(&now);
+- if (hfp_timevalcmp(&now, &addon.next_update, <))
++ hfp_clock_gettime(&now);
++ if (hfp_timespeccmp(&now, &addon.next_update, <))
+ {
+- struct timeval timeout;
++ struct timespec timeout;
+
+ timeout = addon.next_update;
+- hfp_timevalsub(&timeout, &now);
++ hfp_timespecsub(&timeout, &now);
+
+ if (timeout.tv_sec < 0) /* current time went backwards */
+ timeout = addon.update_interval;
+
+- dbus_connection_read_write_dispatch(connection, timeout.tv_sec * 1000 + timeout.tv_usec / 1000);
+- if (! dbus_connection_get_is_connected(connection))
++ dbus_connection_read_write_dispatch(connection, (int) ((timeout.tv_sec * 1000 + timeout.tv_nsec / 1000000) / 2));
++ dbus_connection_read_write_dispatch(syscon, (int) ((timeout.tv_sec * 1000 + timeout.tv_nsec / 1000000) / 2));
++ if (! dbus_connection_get_is_connected(connection) ||
++ ! dbus_connection_get_is_connected(syscon))
+ goto end;
+ }
+ else
+ break;
+ }
+
+- should_poll = libhal_device_get_property_bool(hfp_ctx, hfp_udi, "storage.media_check_enabled", &hfp_error);
+- dbus_error_free(&hfp_error);
+- update_proc_title(addon.device_file, should_poll);
+-
+- if (should_poll)
+- {
+- poll_for_media();
+- }
+- else
+- {
+- hfp_gettimeofday(&addon.next_update);
+- hfp_timevaladd(&addon.next_update, &addon.update_interval);
+- }
++ poll_for_media(FALSE, FALSE);
++ hfp_clock_gettime(&addon.next_update);
++ hfp_timespecadd(&addon.next_update, &addon.update_interval);
+ }
+
+ end:
diff --git a/sysutils/hal/files/patch-hald_freebsd_clock b/sysutils/hal/files/patch-hald_freebsd_clock
new file mode 100644
index 000000000..488283e02
--- /dev/null
+++ b/sysutils/hal/files/patch-hald_freebsd_clock
@@ -0,0 +1,111 @@
+--- hald/freebsd/libprobe/hfp.c.orig 2008-03-17 17:25:17.000000000 -0400
++++ hald/freebsd/libprobe/hfp.c 2008-03-26 12:07:32.000000000 -0400
+@@ -216,55 +216,59 @@ hfp_getenv_bool (const char *variable)
+ }
+
+ void
+-hfp_gettimeofday (struct timeval *t)
++hfp_clock_gettime (struct timespec *t)
+ {
+ int status;
+
+ assert(t != NULL);
+
+- status = gettimeofday(t, NULL);
++#ifdef CLOCK_MONOTONIC_FAST
++ status = clock_gettime(CLOCK_MONOTONIC_FAST, t);
++#else
++ status = clock_gettime(CLOCK_MONOTONIC, t);
++#endif
+ assert(status == 0);
+ }
+
+-/* timeval functions from sys/kern/kern_time.c */
++/* timespec functions from sys/kern/kern_time.c */
+
+ static void
+-hfp_timevalfix (struct timeval *t)
++hfp_timespecfix (struct timespec *t)
+ {
+ assert(t != NULL);
+
+- if (t->tv_usec < 0)
++ if (t->tv_nsec < 0)
+ {
+ t->tv_sec--;
+- t->tv_usec += 1000000;
++ t->tv_nsec += 1000000000;
+ }
+- if (t->tv_usec >= 1000000)
++ if (t->tv_nsec >= 1000000000)
+ {
+ t->tv_sec++;
+- t->tv_usec -= 1000000;
++ t->tv_nsec -= 1000000000;
+ }
+ }
+
+ void
+-hfp_timevaladd (struct timeval *t1, const struct timeval *t2)
++hfp_timespecadd (struct timespec *t1, const struct timespec *t2)
+ {
+ assert(t1 != NULL);
+ assert(t2 != NULL);
+
+ t1->tv_sec += t2->tv_sec;
+- t1->tv_usec += t2->tv_usec;
++ t1->tv_nsec += t2->tv_nsec;
+
+- hfp_timevalfix(t1);
++ hfp_timespecfix(t1);
+ }
+
+ void
+-hfp_timevalsub (struct timeval *t1, const struct timeval *t2)
++hfp_timespecsub (struct timespec *t1, const struct timespec *t2)
+ {
+ assert(t1 != NULL);
+ assert(t2 != NULL);
+
+ t1->tv_sec -= t2->tv_sec;
+- t1->tv_usec -= t2->tv_usec;
++ t1->tv_nsec -= t2->tv_nsec;
+
+- hfp_timevalfix(t1);
++ hfp_timespecfix(t1);
+ }
+--- hald/freebsd/libprobe/hfp.h.orig 2008-03-17 17:25:17.000000000 -0400
++++ hald/freebsd/libprobe/hfp.h 2008-04-02 14:35:50.000000000 -0400
+@@ -29,8 +29,12 @@
+ #endif
+
+ #include <stdarg.h>
++#include <time.h>
+ #include <sys/types.h>
++#include <sys/param.h>
++#if __FreeBSD_version < 600000
+ #include <sys/time.h>
++#endif
+
+ #include "libhal/libhal.h"
+
+@@ -84,14 +88,14 @@ void volume_id_log (const char *format,
+
+ boolean hfp_getenv_bool (const char *variable);
+
+-void hfp_gettimeofday (struct timeval *t);
+-void hfp_timevaladd (struct timeval *t1, const struct timeval *t2);
+-void hfp_timevalsub (struct timeval *t1, const struct timeval *t2);
++void hfp_clock_gettime (struct timespec *t);
++void hfp_timespecadd (struct timespec *t1, const struct timespec *t2);
++void hfp_timespecsub (struct timespec *t1, const struct timespec *t2);
+
+ /* from sys/time.h (_KERNEL) */
+-#define hfp_timevalcmp(t1, t2, cmp) \
++#define hfp_timespeccmp(t1, t2, cmp) \
+ (((t1)->tv_sec == (t2)->tv_sec \
+- ? ((t1)->tv_usec cmp (t2)->tv_usec) \
++ ? ((t1)->tv_nsec cmp (t2)->tv_nsec) \
+ : ((t1)->tv_sec cmp (t2)->tv_sec)))
+
+ #endif /* _HFP_H */
diff --git a/sysutils/hal/files/patch-hald_freebsd_hf-acpi.c b/sysutils/hal/files/patch-hald_freebsd_hf-acpi.c
new file mode 100644
index 000000000..a21095a5f
--- /dev/null
+++ b/sysutils/hal/files/patch-hald_freebsd_hf-acpi.c
@@ -0,0 +1,90 @@
+--- hald/freebsd/hf-acpi.c.orig 2008-05-07 19:23:59.000000000 -0400
++++ hald/freebsd/hf-acpi.c 2009-02-04 11:32:27.000000000 -0500
+@@ -54,6 +54,7 @@
+ static const struct laptop_panel_type {
+ char *access;
+ char *name;
++ char *get_sysctl;
+ char *max_sysctl;
+ int max_levels;
+ #define HF_ACPI_IBM_MAX_LEVELS 8
+@@ -64,17 +65,29 @@
+ #define HF_ACPI_FUJITSU_MAX_LEVELS 8
+ /* NOTE: Each new type must also be added to hf-devtree.c */
+ } laptop_panel_types[] = {
+- { "ibm", "IBM", NULL,
++ { "ibm", "IBM",
++ "dev.acpi_ibm.0.lcd_brightness",
++ NULL,
+ HF_ACPI_IBM_MAX_LEVELS },
+- { "toshiba", "Toshiba", NULL,
++ { "toshiba", "Toshiba",
++ "hw.acpi.toshiba.lcd_brightness",
++ NULL,
+ HF_ACPI_TOSHIBA_MAX_LEVELS },
+- { "sony", "Sony", NULL,
++ { "sony", "Sony",
++ "dev.acpi_sony.0.brightness",
++ NULL,
+ HF_ACPI_SONY_MAX_LEVELS },
+- { "panasonic", "Panasonic", "hw.acpi.panasonic.lcd_brightness_max",
++ { "panasonic", "Panasonic",
++ "hw.acpi.panasonic.lcd_brightness",
++ "hw.acpi.panasonic.lcd_brightness_max",
+ HF_ACPI_PANASONIC_MAX_LEVELS },
+- { "asus", "Asus", NULL,
++ { "asus", "Asus",
++ "hw.acpi.asus.lcd_brightness",
++ NULL,
+ HF_ACPI_ASUS_MAX_LEVELS },
+- { "fujitsu", "Fujitsu", NULL,
++ { "fujitsu", "Fujitsu",
++ "hw.acpi.fujitsu.lcd_brightness",
++ NULL,
+ HF_ACPI_FUJITSU_MAX_LEVELS }
+ };
+
+@@ -105,6 +118,9 @@
+ gboolean ispresent;
+ union acpi_battery_ioctl_arg battif, battst, battinfo;
+
++ if (! hf_has_sysctl("hw.acpi.battery.units"))
++ return;
++
+ battif.unit = battst.unit = battinfo.unit =
+ hal_device_property_get_int(device, "freebsd.unit");
+
+@@ -497,13 +513,15 @@
+
+ static HalDevice *
+ hf_acpi_laptop_panel_new (HalDevice *parent, int max_levels,
+- const char *max_sysctl, const char *access,
+- const char *name)
++ const char *get_sysctl, const char *max_sysctl,
++ const char *access, const char *name)
+ {
+ HalDevice *device;
+
+ g_return_val_if_fail(HAL_IS_DEVICE(parent), NULL);
+
++ if (get_sysctl == NULL || ! hf_has_sysctl(get_sysctl))
++ return NULL;
+ device = hf_device_new(parent);
+
+ hf_device_property_set_string_printf(device, "info.product", "Laptop Panel (%s)", name);
+@@ -593,11 +611,13 @@
+ HalDevice *panel_device;
+
+ panel_device = hf_acpi_laptop_panel_new(parent,
+- laptop_panel_types[i].max_levels,
++ laptop_panel_types[i].max_levels,
++ laptop_panel_types[i].get_sysctl,
+ laptop_panel_types[i].max_sysctl,
+ laptop_panel_types[i].access,
+ laptop_panel_types[i].name);
+- hf_device_preprobe_and_add(panel_device);
++ if (panel_device)
++ hf_device_preprobe_and_add(panel_device);
+ }
+ }
+ }
diff --git a/sysutils/hal/files/patch-hald_freebsd_hf-devd.c b/sysutils/hal/files/patch-hald_freebsd_hf-devd.c
new file mode 100644
index 000000000..263343c80
--- /dev/null
+++ b/sysutils/hal/files/patch-hald_freebsd_hf-devd.c
@@ -0,0 +1,46 @@
+--- hald/freebsd/hf-devd.c.orig 2008-05-07 19:23:59.000000000 -0400
++++ hald/freebsd/hf-devd.c 2009-02-23 01:44:32.000000000 -0500
+@@ -40,7 +40,11 @@
+ #include "hf-acpi.h"
+ #include "hf-net.h"
+ #include "hf-pcmcia.h"
++#include "hf-storage.h"
+ #include "hf-usb.h"
++#ifdef HAVE_LIBUSB20
++#include "hf-usb2.h"
++#endif
+ #include "hf-util.h"
+
+ #define HF_DEVD_SOCK_PATH "/var/run/devd.pipe"
+@@ -51,10 +55,14 @@
+ #define HF_DEVD_EVENT_NOMATCH '?'
+
+ static HFDevdHandler *handlers[] = {
++#ifdef HAVE_LIBUSB20
++ &hf_usb2_devd_handler,
++#endif
+ &hf_usb_devd_handler,
+ &hf_net_devd_handler,
+ &hf_acpi_devd_handler,
+- &hf_pcmcia_devd_handler
++ &hf_pcmcia_devd_handler,
++ &hf_storage_devd_handler
+ };
+
+ static gboolean hf_devd_inited = FALSE;
+@@ -381,13 +389,13 @@ hf_devd_event_cb (GIOChannel *source, GI
+
+ status = g_io_channel_read_line(source, &event, NULL, &terminator, NULL);
+
+- if (status != G_IO_STATUS_NORMAL)
++ if (status == G_IO_STATUS_NORMAL)
+ {
+ event[terminator] = 0;
+ hf_devd_process_event(event);
+ g_free(event);
+ }
+- else if (status != G_IO_STATUS_AGAIN)
++ else if (status == G_IO_STATUS_AGAIN)
+ {
+ hf_devd_init();
+ if (hf_devd_inited)
diff --git a/sysutils/hal/files/patch-hald_freebsd_hf-devtree.c b/sysutils/hal/files/patch-hald_freebsd_hf-devtree.c
new file mode 100644
index 000000000..afc07d63a
--- /dev/null
+++ b/sysutils/hal/files/patch-hald_freebsd_hf-devtree.c
@@ -0,0 +1,77 @@
+--- hald/freebsd/hf-devtree.c.orig 2008-05-07 19:24:03.000000000 -0400
++++ hald/freebsd/hf-devtree.c 2009-02-16 18:48:41.000000000 -0500
+@@ -86,7 +86,11 @@ hf_devtree_cpu_can_throttle (int cpu)
+ gboolean can = FALSE;
+ char *levels;
+
++#ifdef notyet
+ levels = hf_get_string_sysctl(NULL, "dev.cpu.%i.freq_levels", cpu);
++#else
++ levels = hf_get_string_sysctl(NULL, "dev.cpu.0.freq_levels");
++#endif
+ if (levels)
+ {
+ char **toks;
+@@ -109,7 +113,11 @@ hf_devtree_cpu_get_maxfreq (int cpu)
+ char *levels;
+ int freq = -1;
+
++#ifdef notyet
+ levels = hf_get_string_sysctl(NULL, "dev.cpu.%i.freq_levels", cpu);
++#else
++ levels = hf_get_string_sysctl(NULL, "dev.cpu.0.freq_levels");
++#endif
+ if (levels)
+ {
+ sscanf(levels, "%i/", &freq);
+@@ -379,7 +387,8 @@ static Handler handlers[] = {
+ { "pcm", NULL },
+ { "psm", hf_devtree_psm_set_properties },
+ { "sio", NULL },
+- { "speaker", NULL }
++ { "speaker", NULL },
++ { "usbus", NULL }
+ };
+
+ static void
+@@ -426,7 +435,13 @@ hf_devtree_probe (void)
+ HalDevice *device;
+
+ device = hf_devtree_device_new(parent, info->handler, info->unit);
+- hf_device_preprobe_and_add(device);
++ if (hf_device_preprobe(device))
++ {
++ if (hal_device_has_capability(device, "input.mouse"))
++ hf_runner_run_sync(device, 0, "hald-probe-mouse", NULL);
++
++ hf_device_add(device);
++ }
+ }
+
+ devices = g_slist_delete_link(devices, root);
+@@ -434,6 +449,17 @@ hf_devtree_probe (void)
+ }
+ }
+
++static gboolean
++hf_devtree_rescan (HalDevice *device)
++{
++ if (hal_device_has_capability(device, "input.mouse"))
++ {
++ hf_runner_run_sync(device, 0, "hald-probe-mouse", NULL);
++ return TRUE;
++ }
++ return FALSE;
++}
++
+ HalDevice *
+ hf_devtree_find_from_name (HalDeviceStore *store, const char *name)
+ {
+@@ -597,5 +623,6 @@ hf_devtree_is_driver (const char *name,
+ }
+
+ HFHandler hf_devtree_handler = {
+- .probe = hf_devtree_probe
++ .probe = hf_devtree_probe,
++ .device_rescan = hf_devtree_rescan
+ };
diff --git a/sysutils/hal/files/patch-hald_freebsd_hf-storage.h b/sysutils/hal/files/patch-hald_freebsd_hf-storage.h
new file mode 100644
index 000000000..ca673b5bc
--- /dev/null
+++ b/sysutils/hal/files/patch-hald_freebsd_hf-storage.h
@@ -0,0 +1,13 @@
+--- hald/freebsd/hf-storage.h.orig 2009-02-23 01:43:49.000000000 -0500
++++ hald/freebsd/hf-storage.h 2009-02-23 01:45:17.000000000 -0500
+@@ -29,8 +29,10 @@
+ #endif
+
+ #include "hf-osspec.h"
++#include "hf-devd.h"
+
+ extern HFHandler hf_storage_handler;
++extern HFDevdHandler hf_storage_devd_handler;
+
+ void hf_storage_device_enable (HalDevice *device);
+ void hf_storage_device_enable_tape (HalDevice *device);
diff --git a/sysutils/hal/files/patch-hald_freebsd_hf-usb.c b/sysutils/hal/files/patch-hald_freebsd_hf-usb.c
new file mode 100644
index 000000000..07424b61e
--- /dev/null
+++ b/sysutils/hal/files/patch-hald_freebsd_hf-usb.c
@@ -0,0 +1,96 @@
+--- hald/freebsd/hf-usb.c.orig 2008-05-08 01:24:02.000000000 +0200
++++ hald/freebsd/hf-usb.c 2009-03-02 04:23:32.000000000 +0100
+@@ -25,13 +25,18 @@
+ # include <config.h>
+ #endif
+
++#include <sys/param.h>
+ #include <string.h>
+ #include <errno.h>
+ #include <stdlib.h>
+ #include <fcntl.h>
+ #include <sys/ioctl.h>
+ #include <unistd.h>
++#if __FreeBSD_version >= 800064
++#include <legacy/dev/usb/usb.h>
++#else
+ #include <dev/usb/usb.h>
++#endif
+
+ #include "../logger.h"
+ #include "../osspec.h"
+@@ -41,6 +46,11 @@
+ #include "hf-util.h"
+
+ #define HF_USB_DEVICE "/dev/usb"
++#if __FreeBSD_version < 800066
++#define HF_USB2_DEVICE "/dev/usb "
++#else
++#define HF_USB2_DEVICE "/dev/usbctl"
++#endif
+
+ typedef struct
+ {
+@@ -231,7 +241,7 @@
+ * Adapted from usb_compute_udi() in linux2/physdev.c and
+ * usbclass_compute_udi() in linux2/classdev.c.
+ */
+-static void
++void
+ hf_usb_device_compute_udi (HalDevice *device)
+ {
+ g_return_if_fail(HAL_IS_DEVICE(device));
+@@ -250,12 +260,13 @@
+ hf_device_set_udi(device, "usb_device_%x_%x_%s",
+ hal_device_property_get_int(device, "usb_device.vendor_id"),
+ hal_device_property_get_int(device, "usb_device.product_id"),
+- hal_device_has_property(device, "usb_device.serial")
++ (hal_device_has_property(device, "usb_device.serial") &&
++ strcmp(hal_device_property_get_string(device, "usb_device.serial"), ""))
+ ? hal_device_property_get_string(device, "usb_device.serial")
+ : "noserial");
+ }
+
+-static void
++void
+ hf_usb_add_webcam_properties (HalDevice *device)
+ {
+ int unit;
+@@ -424,7 +435,7 @@
+ hf_devtree_device_set_name(device, di->udi_devnames[0]);
+
+ if ((devname = hf_usb_get_devname(di, "ukbd"))) /* USB keyboard */
+- hf_device_set_input(device, "keyboard", devname);
++ hf_device_set_input(device, "keyboard", NULL);
+ else if ((devname = hf_usb_get_devname(di, "ums"))) /* USB mouse */
+ hf_device_set_input(device, "mouse", devname);
+ else if ((devname = hf_usb_get_devname(di, "uhid"))) /* UHID device */
+@@ -575,6 +586,8 @@
+ {
+ if (hal_device_has_capability(device, "hiddev"))
+ hf_runner_run_sync(device, 0, "hald-probe-hiddev", NULL);
++ if (hal_device_has_capability(device, "input.mouse"))
++ hf_runner_run_sync(device, 0, "hald-probe-mouse", NULL);
+
+ hf_device_add(device);
+ }
+@@ -633,9 +646,18 @@
+ {
+ int i;
+
++ if (g_file_test(HF_USB2_DEVICE, G_FILE_TEST_EXISTS))
++ {
++ hf_usb_fd = -1;
++ return;
++ }
++
+ hf_usb_fd = open(HF_USB_DEVICE, O_RDONLY);
+ if (hf_usb_fd < 0)
+- HAL_INFO(("unable to open %s: %s", HF_USB_DEVICE, g_strerror(errno)));
++ {
++ HAL_INFO(("unable to open %s: %s", HF_USB_DEVICE, g_strerror(errno)));
++ return;
++ }
+
+ for (i = 0; i < 16; i++)
+ {
diff --git a/sysutils/hal/files/patch-hald_freebsd_hf-usb.h b/sysutils/hal/files/patch-hald_freebsd_hf-usb.h
new file mode 100644
index 000000000..32861e202
--- /dev/null
+++ b/sysutils/hal/files/patch-hald_freebsd_hf-usb.h
@@ -0,0 +1,10 @@
+--- hald/freebsd/hf-usb.h.orig 2009-02-17 18:56:56.000000000 -0500
++++ hald/freebsd/hf-usb.h 2009-02-17 18:57:21.000000000 -0500
+@@ -34,4 +34,7 @@
+ extern HFHandler hf_usb_handler;
+ extern HFDevdHandler hf_usb_devd_handler;
+
++void hf_usb_device_compute_udi(HalDevice *device);
++void hf_usb_add_webcam_properties(HalDevice *device);
++
+ #endif /* _HF_USB_H */
diff --git a/sysutils/hal/files/patch-hald_freebsd_hf-usb2.c b/sysutils/hal/files/patch-hald_freebsd_hf-usb2.c
new file mode 100644
index 000000000..cd78786c0
--- /dev/null
+++ b/sysutils/hal/files/patch-hald_freebsd_hf-usb2.c
@@ -0,0 +1,290 @@
+--- hald/freebsd/hf-usb2.c.orig 2009-03-02 20:16:10.000000000 -0600
++++ hald/freebsd/hf-usb2.c 2009-03-02 20:33:13.000000000 -0600
+@@ -0,0 +1,287 @@
++/***************************************************************************
++ * CVSID: $Id: patch-hald_freebsd_hf-usb2.c,v 1.1 2009-05-17 05:02:48 marcus Exp $
++ *
++ * hf-usb.c : USB support
++ *
++ * Copyright (C) 2009 Joe Marcus Clarke <marcus@FreeBSD.org>
++ *
++ * This program is free software; you can redistribute it and/or modify
++ * it under the terms of the GNU General Public License as published by
++ * the Free Software Foundation; either version 2 of the License, or
++ * (at your option) any later version.
++ *
++ * This program is distributed in the hope that it will be useful,
++ * but WITHOUT ANY WARRANTY; without even the implied warranty of
++ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
++ * GNU General Public License for more details.
++ *
++ * You should have received a copy of the GNU General Public License
++ * along with this program; if not, write to the Free Software
++ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
++ *
++ **************************************************************************/
++
++#ifdef HAVE_CONFIG_H
++# include <config.h>
++#endif
++
++#include <string.h>
++#include <errno.h>
++#include <stdlib.h>
++#include <unistd.h>
++#include <libusb20.h>
++
++#include "../logger.h"
++#include "../osspec.h"
++
++#include "hf-usb.h"
++#include "hf-usb2.h"
++#include "hf-devtree.h"
++#include "hf-util.h"
++
++static struct libusb20_backend *hf_usb2_be = NULL;
++
++static void
++hf_usb2_copy_parent (HalDevice *parent,
++ const char *key,
++ gpointer user_data)
++{
++ HalDevice *device;
++
++ g_return_if_fail(HAL_IS_DEVICE(parent));
++ g_return_if_fail(HAL_IS_DEVICE(user_data));
++
++ device = HAL_DEVICE(user_data);
++
++ if (! strncmp(key, "usb_device.", strlen("usb_device.")))
++ hal_device_copy_property(parent, key, device, key);
++}
++
++static void
++hf_usb2_probe_interfaces(HalDevice *parent)
++{
++ int num_interfaces;
++ int i;
++
++ g_return_if_fail(HAL_IS_DEVICE(parent));
++
++ if (hal_device_property_get_bool(parent, "info.ignore"))
++ return;
++
++ num_interfaces = hal_device_property_get_int(parent,
++ "usb_device.num_interfaces");
++
++ for (i = 0; i < num_interfaces; i++)
++ {
++ HalDevice *device;
++
++ device = hf_device_new(parent);
++
++ hal_device_property_set_string(device, "info.subsystem", "usb");
++ hal_device_property_set_int(device, "usb.interface.number", i);
++ hal_device_property_foreach(parent, hf_usb2_copy_parent, device);
++ hal_device_copy_property(parent, "info.product", device, "info.product");
++ hal_device_copy_property(parent, "info.vendor", device, "info.vendor");
++
++ if (hf_device_preprobe(device))
++ {
++ const char *driver, *devname;
++
++ hf_runner_run_sync(device, 0, "hald-probe-usb2-interface", NULL);
++
++ devname = hal_device_property_get_string(device,
++ "usb.freebsd.devname");
++ if (devname)
++ hf_devtree_device_set_name(device, devname);
++
++ driver = hal_device_property_get_string(device, "freebsd.driver");
++ if (driver)
++ {
++ if (! strcmp(driver, "ukbd"))
++ hf_device_set_input(device, "keyboard", NULL);
++ else if (! strcmp(driver, "ums"))
++ {
++ hf_device_set_input(device, "mouse", devname);
++ hf_runner_run_sync(device, 0, "hald-probe-mouse", NULL);
++ }
++ else if (! strcmp(driver, "uhid"))
++ {
++ hal_device_property_set_string(device, "info.category",
++ "hiddev");
++ hal_device_add_capability(device, "hiddev");
++ hf_device_property_set_string_printf(device, "hiddev.device",
++ "/dev/%s", devname);
++ hal_device_copy_property(device, "info.product", device,
++ "hiddev.product");
++ hf_runner_run_sync(device, 0, "hald-probe-hiddev", NULL);
++ }
++ else if (! strcmp(driver, "ldev"))
++ {
++ /* Linux driver (webcam) */
++
++ /*
++ * XXX This is a hack. Currently, all ldev devices are
++ * webcams. That may not always be the case. Hopefully,
++ * when other Linux driver support is added, there will be
++ * a sysctl or some other way to determine device class.
++ */
++ hf_usb_add_webcam_properties(device);
++ }
++ else if (! strcmp(driver, "pwc"))
++ {
++ /* Phillips Web Cam */
++ hf_usb_add_webcam_properties(device);
++ }
++ }
++
++ hf_usb_device_compute_udi(device);
++ hf_device_add(device);
++ }
++ }
++}
++
++static void
++hf_usb2_probe_device (HalDevice *parent, int bus, int addr)
++{
++ HalDevice *device;
++
++ g_return_if_fail(HAL_IS_DEVICE(parent));
++
++ device = hf_device_new(parent);
++
++ hal_device_property_set_string(device, "info.subsystem", "usb_device");
++ hal_device_property_set_int(device, "usb_device.bus_number", bus);
++ hal_device_property_set_int(device, "usb_device.level_number", addr - 1);
++ hal_device_property_set_int(device, "usb_device.port_number", addr);
++
++ if (hf_device_preprobe(device))
++ {
++ hf_runner_run_sync(device, 0, "hald-probe-usb2-device", NULL);
++ hf_usb_device_compute_udi(device);
++
++ hf_device_add(device);
++ }
++ else
++ return;
++
++ hf_usb2_probe_interfaces(device);
++}
++
++static void
++hf_usb2_privileged_init (void)
++{
++ hf_usb2_be = libusb20_be_alloc_default();
++ if (hf_usb2_be == NULL)
++ HAL_INFO(("unable to open USB backend: %s", g_strerror(errno)));
++}
++
++static void
++hf_usb2_probe (void)
++{
++ struct libusb20_device *pdev = NULL;
++
++ if (hf_usb2_be == NULL)
++ return;
++
++ while ((pdev = libusb20_be_device_foreach(hf_usb2_be, pdev)))
++ {
++ HalDevice *parent;
++ int bus, addr;
++
++ bus = libusb20_dev_get_bus_number(pdev);
++ addr = libusb20_dev_get_address(pdev);
++
++ if (addr == 1)
++ parent = hf_devtree_find_parent_from_info(hald_get_gdl(), "usbus", bus);
++ else
++ parent = hf_device_store_match(hald_get_gdl(), "usb_device.bus_number",
++ HAL_PROPERTY_TYPE_INT32, bus, "usb_device.port_number",
++ HAL_PROPERTY_TYPE_INT32, addr - 1, NULL);
++ if (! parent || hal_device_property_get_bool(parent, "info.ignore"))
++ continue;
++
++ hf_usb2_probe_device(parent, bus, addr);
++ }
++
++ libusb20_be_free(hf_usb2_be);
++ hf_usb2_be = NULL;
++}
++
++static gboolean
++hf_usb2_devd_add (const char *name,
++ GHashTable *params,
++ GHashTable *at,
++ const char *parent)
++{
++ HalDevice *parent_device;
++ int bus, addr, pbus, paddr;
++
++ if (strncmp(name, "ugen", strlen("ugen")))
++ return FALSE;
++ else if (strncmp(parent, "ugen", strlen("ugen")))
++ return TRUE;
++
++ if (sscanf(name, "ugen%i.%i", &bus, &addr) != 2)
++ return FALSE;
++
++ if (sscanf(parent, "ugen%i.%i", &pbus, &paddr) != 2)
++ return FALSE;
++
++ HAL_INFO(("received devd add event for device '%s' with parent '%s'",
++ name, parent));
++
++ parent_device = hf_device_store_match(hald_get_gdl(),
++ "usb_device.bus_number", HAL_PROPERTY_TYPE_INT32, pbus,
++ "usb_device.port_number", HAL_PROPERTY_TYPE_INT32, paddr, NULL);
++
++ if (parent_device && ! hal_device_property_get_bool(parent_device,
++ "info.ignore"))
++ {
++ hf_usb2_probe_device(parent_device, bus, addr);
++ return TRUE;
++ }
++
++ return FALSE;
++}
++
++static gboolean
++hf_usb2_devd_remove (const char *name,
++ GHashTable *params,
++ GHashTable *at,
++ const char *parent)
++{
++ HalDevice *device;
++ int bus, addr;
++
++ if (strncmp(name, "ugen", strlen("ugen")))
++ return FALSE;
++ else if (strncmp(parent, "ugen", strlen("ugen")))
++ return TRUE;
++
++ if (sscanf(name, "ugen%i.%i", &bus, &addr) != 2)
++ return FALSE;
++
++ HAL_INFO(("received devd remove event, device %s", name));
++
++ device = hf_device_store_match(hald_get_gdl(), "usb_device.bus_number",
++ HAL_PROPERTY_TYPE_INT32, bus, "usb_device.port_number",
++ HAL_PROPERTY_TYPE_INT32, addr, NULL);
++
++ if (device)
++ {
++ hf_device_remove_tree(device);
++ return TRUE;
++ }
++
++ return FALSE;
++}
++
++HFHandler hf_usb2_handler = {
++ .privileged_init = hf_usb2_privileged_init,
++ .probe = hf_usb2_probe
++};
++
++HFDevdHandler hf_usb2_devd_handler = {
++ .add = hf_usb2_devd_add,
++ .remove = hf_usb2_devd_remove
++};
diff --git a/sysutils/hal/files/patch-hald_freebsd_hf-usb2.h b/sysutils/hal/files/patch-hald_freebsd_hf-usb2.h
new file mode 100644
index 000000000..ae3149585
--- /dev/null
+++ b/sysutils/hal/files/patch-hald_freebsd_hf-usb2.h
@@ -0,0 +1,40 @@
+--- hald/freebsd/hf-usb2.h.orig 2009-02-18 00:22:59.000000000 -0500
++++ hald/freebsd/hf-usb2.h 2009-02-18 00:22:54.000000000 -0500
+@@ -0,0 +1,37 @@
++/***************************************************************************
++ * CVSID: $Id: patch-hald_freebsd_hf-usb2.h,v 1.1 2009-05-17 05:02:48 marcus Exp $
++ *
++ * hf-usb.h : USB support
++ *
++ * Copyright (C) 2009 Joe Marcus Clarke <marcus@FreeBSD.org>
++ *
++ * This program is free software; you can redistribute it and/or modify
++ * it under the terms of the GNU General Public License as published by
++ * the Free Software Foundation; either version 2 of the License, or
++ * (at your option) any later version.
++ *
++ * This program is distributed in the hope that it will be useful,
++ * but WITHOUT ANY WARRANTY; without even the implied warranty of
++ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
++ * GNU General Public License for more details.
++ *
++ * You should have received a copy of the GNU General Public License
++ * along with this program; if not, write to the Free Software
++ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
++ *
++ **************************************************************************/
++
++#ifndef _HF_USB2_H
++#define _HF_USB2_H
++
++#ifdef HAVE_CONFIG_H
++# include <config.h>
++#endif
++
++#include "hf-osspec.h"
++#include "hf-devd.h"
++
++extern HFHandler hf_usb2_handler;
++extern HFDevdHandler hf_usb2_devd_handler;
++
++#endif /* _HF_USB2_H */
diff --git a/sysutils/hal/files/patch-hald_freebsd_hf-volume.c b/sysutils/hal/files/patch-hald_freebsd_hf-volume.c
new file mode 100644
index 000000000..039a1a676
--- /dev/null
+++ b/sysutils/hal/files/patch-hald_freebsd_hf-volume.c
@@ -0,0 +1,102 @@
+--- hald/freebsd/hf-volume.c.orig 2008-05-07 19:24:03.000000000 -0400
++++ hald/freebsd/hf-volume.c 2008-10-26 15:17:09.000000000 -0400
+@@ -45,6 +45,7 @@
+ #include "hf-util.h"
+
+ #define PROBE_VOLUME_TIMEOUT (HAL_HELPER_TIMEOUT * 6)
++#define HF_VOLUME_FUSE_DB "/tmp/.fuse-mnts"
+
+ static void
+ hf_volume_get_mounts (struct statfs **mounts, int *n_mounts)
+@@ -60,6 +61,55 @@ hf_volume_get_mounts (struct statfs **mo
+ }
+ }
+
++static char *
++hf_volume_resolve_fuse (const char *special)
++{
++ gchar *contents;
++ gchar **lines;
++ gsize len;
++ int i;
++
++ g_return_val_if_fail(special != NULL, NULL);
++
++ if (! g_file_get_contents(HF_VOLUME_FUSE_DB, &contents, &len, NULL))
++ return g_strdup(special);
++
++ lines = g_strsplit(contents, "\n", 0);
++ g_free(contents);
++
++ for (i = 0; lines && lines[i]; i++)
++ {
++ gchar **fields;
++
++ fields = g_strsplit(lines[i], "=", 2);
++ if (fields && g_strv_length(fields) == 2)
++ {
++ if (strcmp(fields[0], special) == 0)
++ {
++ g_strfreev(fields);
++ g_strfreev(lines);
++ return g_strdup(fields[1]);
++ }
++ }
++ g_strfreev(fields);
++ }
++
++ g_strfreev(lines);
++
++ return g_strdup(special);
++}
++
++static char *
++hf_volume_resolve_special (const char *special)
++{
++ g_return_val_if_fail(special != NULL, NULL);
++
++ if (strstr(special, "fuse"))
++ return hf_volume_resolve_fuse(special);
++
++ return g_strdup(special);
++}
++
+ static const struct statfs *
+ hf_volume_mounts_find (const struct statfs *mounts,
+ int n_mounts,
+@@ -71,8 +121,18 @@ hf_volume_mounts_find (const struct stat
+ g_return_val_if_fail(special != NULL, NULL);
+
+ for (i = 0; i < n_mounts; i++)
+- if (! strcmp(mounts[i].f_mntfromname, special))
+- return &mounts[i];
++ {
++ char *resolved;
++
++ resolved = hf_volume_resolve_special(mounts[i].f_mntfromname);
++ if (! strcmp(resolved, special))
++ {
++ g_free(resolved);
++ return &mounts[i];
++ }
++
++ g_free(resolved);
++ }
+
+ return NULL;
+ }
+@@ -92,7 +152,13 @@ hf_volume_device_update_mount_properties
+
+ special = hal_device_property_get_string(device, "block.device");
+ if (special)
+- mount = hf_volume_mounts_find(mounts, n_mounts, special);
++ {
++ mount = hf_volume_mounts_find(mounts, n_mounts, special);
++ if (mount && strcmp(special, mount->f_mntfromname))
++ hal_device_property_set_string(device, "volume.freebsd.real_mounted_device", mount->f_mntfromname);
++ else
++ hal_device_property_remove(device, "volume.freebsd.real_mounted_device");
++ }
+ }
+
+ hal_device_property_set_bool(device, "volume.is_mounted", mount != NULL);
diff --git a/sysutils/hal/files/patch-hald_freebsd_osspec.c b/sysutils/hal/files/patch-hald_freebsd_osspec.c
new file mode 100644
index 000000000..01c07099c
--- /dev/null
+++ b/sysutils/hal/files/patch-hald_freebsd_osspec.c
@@ -0,0 +1,22 @@
+--- hald/freebsd/osspec.c.orig 2008-05-07 19:24:01.000000000 -0400
++++ hald/freebsd/osspec.c 2009-02-18 00:24:42.000000000 -0500
+@@ -46,6 +46,9 @@
+ #include "hf-sound.h"
+ #include "hf-storage.h"
+ #include "hf-usb.h"
++#ifdef HAVE_LIBUSB20
++#include "hf-usb2.h"
++#endif
+ #include "hf-volume.h"
+
+ /* the order matters: PCI devices must be created before their children, etc */
+@@ -53,6 +56,9 @@ static HFHandler *handlers[] = {
+ &hf_pci_handler,
+ &hf_devtree_handler,
+ &hf_usb_handler,
++#ifdef HAVE_LIBUSB20
++ &hf_usb2_handler,
++#endif
+ &hf_ata_handler,
+ &hf_scsi_handler,
+ &hf_storage_handler,
diff --git a/sysutils/hal/files/patch-hald_freebsd_probing_Makefile.am b/sysutils/hal/files/patch-hald_freebsd_probing_Makefile.am
new file mode 100644
index 000000000..405026cc6
--- /dev/null
+++ b/sysutils/hal/files/patch-hald_freebsd_probing_Makefile.am
@@ -0,0 +1,51 @@
+--- hald/freebsd/probing/Makefile.am.orig 2008-05-07 19:24:08.000000000 -0400
++++ hald/freebsd/probing/Makefile.am 2009-02-18 00:16:28.000000000 -0500
+@@ -9,11 +9,18 @@ AM_CPPFLAGS = \
+
+ if HALD_COMPILE_FREEBSD
+ libexec_PROGRAMS = \
+- hald-probe-hiddev \
+- hald-probe-scsi \
+- hald-probe-smbios \
+- hald-probe-storage \
++ hald-probe-hiddev \
++ hald-probe-mouse \
++ hald-probe-scsi \
++ hald-probe-smbios \
++ hald-probe-storage \
+ hald-probe-volume
++
++if HAVE_LIBUSB20
++libexec_PROGRAMS += \
++ hald-probe-usb2-device \
++ hald-probe-usb2-interface
++endif
+ endif
+
+ hald_probe_hiddev_SOURCES = probe-hiddev.c
+@@ -21,6 +28,25 @@ hald_probe_hiddev_LDADD = \
+ $(top_builddir)/hald/freebsd/libprobe/libhald_freebsd_probe.la \
+ -lusbhid
+
++if HAVE_LIBUSB20
++hald_probe_usb2_device_SOURCES = probe-usb2-device.c
++hald_probe_usb2_device_LDADD = \
++ $(top_builddir)/hald/freebsd/libprobe/libhald_freebsd_probe.la \
++ @LIBUSB20_LIBS@
++
++hald_probe_usb2_interface_SOURCES = probe-usb2-interface.c
++hald_probe_usb2_interface_LDADD = \
++ $(top_builddir)/hald/freebsd/libprobe/libhald_freebsd_probe.la \
++ @LIBUSB20_LIBS@
++endif
++
++hald_probe_mouse_SOURCES = probe-mouse.c
++hald_probe_mouse_CPPFLAGS = $(AM_CPPFLAGS) @GLIB_CFLAGS@
++hald_probe_mouse_LDADD = \
++ @GLIB_LIBS@ \
++ $(top_builddir)/hald/freebsd/libprobe/libhald_freebsd_probe.la \
++ -lutil
++
+ hald_probe_smbios_SOURCES = probe-smbios.c
+ hald_probe_smbios_LDADD = \
+ $(top_builddir)/hald/freebsd/libprobe/libhald_freebsd_probe.la
diff --git a/sysutils/hal/files/patch-hald_freebsd_probing_Makefile.in b/sysutils/hal/files/patch-hald_freebsd_probing_Makefile.in
new file mode 100644
index 000000000..1a6e94927
--- /dev/null
+++ b/sysutils/hal/files/patch-hald_freebsd_probing_Makefile.in
@@ -0,0 +1,162 @@
+--- hald/freebsd/probing/Makefile.in.orig 2009-05-17 00:44:58.000000000 -0400
++++ hald/freebsd/probing/Makefile.in 2009-05-17 00:44:58.000000000 -0400
+@@ -34,10 +34,16 @@ build_triplet = @build@
+ host_triplet = @host@
+ @HALD_COMPILE_FREEBSD_TRUE@libexec_PROGRAMS = \
+ @HALD_COMPILE_FREEBSD_TRUE@ hald-probe-hiddev$(EXEEXT) \
++@HALD_COMPILE_FREEBSD_TRUE@ hald-probe-mouse$(EXEEXT) \
+ @HALD_COMPILE_FREEBSD_TRUE@ hald-probe-scsi$(EXEEXT) \
+ @HALD_COMPILE_FREEBSD_TRUE@ hald-probe-smbios$(EXEEXT) \
+ @HALD_COMPILE_FREEBSD_TRUE@ hald-probe-storage$(EXEEXT) \
+-@HALD_COMPILE_FREEBSD_TRUE@ hald-probe-volume$(EXEEXT)
++@HALD_COMPILE_FREEBSD_TRUE@ hald-probe-volume$(EXEEXT) \
++@HALD_COMPILE_FREEBSD_TRUE@ $(am__EXEEXT_1)
++@HALD_COMPILE_FREEBSD_TRUE@@HAVE_LIBUSB20_TRUE@am__append_1 = \
++@HALD_COMPILE_FREEBSD_TRUE@@HAVE_LIBUSB20_TRUE@ hald-probe-usb2-device \
++@HALD_COMPILE_FREEBSD_TRUE@@HAVE_LIBUSB20_TRUE@ hald-probe-usb2-interface
++
+ subdir = hald/freebsd/probing
+ DIST_COMMON = $(srcdir)/Makefile.am $(srcdir)/Makefile.in
+ ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
+@@ -48,12 +54,17 @@ am__configure_deps = $(am__aclocal_m4_de
+ mkinstalldirs = $(install_sh) -d
+ CONFIG_HEADER = $(top_builddir)/config.h
+ CONFIG_CLEAN_FILES =
++@HALD_COMPILE_FREEBSD_TRUE@@HAVE_LIBUSB20_TRUE@am__EXEEXT_1 = hald-probe-usb2-device$(EXEEXT) \
++@HALD_COMPILE_FREEBSD_TRUE@@HAVE_LIBUSB20_TRUE@ hald-probe-usb2-interface$(EXEEXT)
+ am__installdirs = "$(DESTDIR)$(libexecdir)"
+ libexecPROGRAMS_INSTALL = $(INSTALL_PROGRAM)
+ PROGRAMS = $(libexec_PROGRAMS)
+ am_hald_probe_hiddev_OBJECTS = probe-hiddev.$(OBJEXT)
+ hald_probe_hiddev_OBJECTS = $(am_hald_probe_hiddev_OBJECTS)
+ hald_probe_hiddev_DEPENDENCIES = $(top_builddir)/hald/freebsd/libprobe/libhald_freebsd_probe.la
++am_hald_probe_mouse_OBJECTS = hald_probe_mouse-probe-mouse.$(OBJEXT)
++hald_probe_mouse_OBJECTS = $(am_hald_probe_mouse_OBJECTS)
++hald_probe_mouse_DEPENDENCIES = $(top_builddir)/hald/freebsd/libprobe/libhald_freebsd_probe.la
+ am_hald_probe_scsi_OBJECTS = probe-scsi.$(OBJEXT)
+ hald_probe_scsi_OBJECTS = $(am_hald_probe_scsi_OBJECTS)
+ hald_probe_scsi_DEPENDENCIES = $(top_builddir)/hald/freebsd/libprobe/libhald_freebsd_probe.la
+@@ -65,6 +76,17 @@ am_hald_probe_storage_OBJECTS = \
+ hald_probe_storage-probe-storage.$(OBJEXT)
+ hald_probe_storage_OBJECTS = $(am_hald_probe_storage_OBJECTS)
+ hald_probe_storage_DEPENDENCIES = $(top_builddir)/hald/freebsd/libprobe/libhald_freebsd_probe.la
++am__hald_probe_usb2_device_SOURCES_DIST = probe-usb2-device.c
++@HAVE_LIBUSB20_TRUE@am_hald_probe_usb2_device_OBJECTS = \
++@HAVE_LIBUSB20_TRUE@ probe-usb2-device.$(OBJEXT)
++hald_probe_usb2_device_OBJECTS = $(am_hald_probe_usb2_device_OBJECTS)
++@HAVE_LIBUSB20_TRUE@hald_probe_usb2_device_DEPENDENCIES = $(top_builddir)/hald/freebsd/libprobe/libhald_freebsd_probe.la
++am__hald_probe_usb2_interface_SOURCES_DIST = probe-usb2-interface.c
++@HAVE_LIBUSB20_TRUE@am_hald_probe_usb2_interface_OBJECTS = \
++@HAVE_LIBUSB20_TRUE@ probe-usb2-interface.$(OBJEXT)
++hald_probe_usb2_interface_OBJECTS = \
++ $(am_hald_probe_usb2_interface_OBJECTS)
++@HAVE_LIBUSB20_TRUE@hald_probe_usb2_interface_DEPENDENCIES = $(top_builddir)/hald/freebsd/libprobe/libhald_freebsd_probe.la
+ am_hald_probe_volume_OBJECTS = \
+ hald_probe_volume-freebsd_dvd_rw_utils.$(OBJEXT) \
+ hald_probe_volume-probe-volume.$(OBJEXT)
+@@ -82,11 +104,17 @@ CCLD = $(CC)
+ LINK = $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) \
+ --mode=link $(CCLD) $(AM_CFLAGS) $(CFLAGS) $(AM_LDFLAGS) \
+ $(LDFLAGS) -o $@
+-SOURCES = $(hald_probe_hiddev_SOURCES) $(hald_probe_scsi_SOURCES) \
+- $(hald_probe_smbios_SOURCES) $(hald_probe_storage_SOURCES) \
++SOURCES = $(hald_probe_hiddev_SOURCES) $(hald_probe_mouse_SOURCES) \
++ $(hald_probe_scsi_SOURCES) $(hald_probe_smbios_SOURCES) \
++ $(hald_probe_storage_SOURCES) \
++ $(hald_probe_usb2_device_SOURCES) \
++ $(hald_probe_usb2_interface_SOURCES) \
+ $(hald_probe_volume_SOURCES)
+-DIST_SOURCES = $(hald_probe_hiddev_SOURCES) $(hald_probe_scsi_SOURCES) \
++DIST_SOURCES = $(hald_probe_hiddev_SOURCES) \
++ $(hald_probe_mouse_SOURCES) $(hald_probe_scsi_SOURCES) \
+ $(hald_probe_smbios_SOURCES) $(hald_probe_storage_SOURCES) \
++ $(am__hald_probe_usb2_device_SOURCES_DIST) \
++ $(am__hald_probe_usb2_interface_SOURCES_DIST) \
+ $(hald_probe_volume_SOURCES)
+ ETAGS = etags
+ CTAGS = ctags
+@@ -263,6 +291,23 @@ hald_probe_hiddev_LDADD = \
+ $(top_builddir)/hald/freebsd/libprobe/libhald_freebsd_probe.la \
+ -lusbhid
+
++@HAVE_LIBUSB20_TRUE@hald_probe_usb2_device_SOURCES = probe-usb2-device.c
++@HAVE_LIBUSB20_TRUE@hald_probe_usb2_device_LDADD = \
++@HAVE_LIBUSB20_TRUE@ $(top_builddir)/hald/freebsd/libprobe/libhald_freebsd_probe.la \
++@HAVE_LIBUSB20_TRUE@ @LIBUSB20_LIBS@
++
++@HAVE_LIBUSB20_TRUE@hald_probe_usb2_interface_SOURCES = probe-usb2-interface.c
++@HAVE_LIBUSB20_TRUE@hald_probe_usb2_interface_LDADD = \
++@HAVE_LIBUSB20_TRUE@ $(top_builddir)/hald/freebsd/libprobe/libhald_freebsd_probe.la \
++@HAVE_LIBUSB20_TRUE@ @LIBUSB20_LIBS@
++
++hald_probe_mouse_SOURCES = probe-mouse.c
++hald_probe_mouse_CPPFLAGS = $(AM_CPPFLAGS) @GLIB_CFLAGS@
++hald_probe_mouse_LDADD = \
++ @GLIB_LIBS@ \
++ $(top_builddir)/hald/freebsd/libprobe/libhald_freebsd_probe.la \
++ -lutil
++
+ hald_probe_smbios_SOURCES = probe-smbios.c
+ hald_probe_smbios_LDADD = \
+ $(top_builddir)/hald/freebsd/libprobe/libhald_freebsd_probe.la
+@@ -349,6 +394,9 @@ clean-libexecPROGRAMS:
+ hald-probe-hiddev$(EXEEXT): $(hald_probe_hiddev_OBJECTS) $(hald_probe_hiddev_DEPENDENCIES)
+ @rm -f hald-probe-hiddev$(EXEEXT)
+ $(LINK) $(hald_probe_hiddev_OBJECTS) $(hald_probe_hiddev_LDADD) $(LIBS)
++hald-probe-mouse$(EXEEXT): $(hald_probe_mouse_OBJECTS) $(hald_probe_mouse_DEPENDENCIES)
++ @rm -f hald-probe-mouse$(EXEEXT)
++ $(LINK) $(hald_probe_mouse_OBJECTS) $(hald_probe_mouse_LDADD) $(LIBS)
+ hald-probe-scsi$(EXEEXT): $(hald_probe_scsi_OBJECTS) $(hald_probe_scsi_DEPENDENCIES)
+ @rm -f hald-probe-scsi$(EXEEXT)
+ $(LINK) $(hald_probe_scsi_OBJECTS) $(hald_probe_scsi_LDADD) $(LIBS)
+@@ -358,6 +406,12 @@ hald-probe-smbios$(EXEEXT): $(hald_probe
+ hald-probe-storage$(EXEEXT): $(hald_probe_storage_OBJECTS) $(hald_probe_storage_DEPENDENCIES)
+ @rm -f hald-probe-storage$(EXEEXT)
+ $(LINK) $(hald_probe_storage_OBJECTS) $(hald_probe_storage_LDADD) $(LIBS)
++hald-probe-usb2-device$(EXEEXT): $(hald_probe_usb2_device_OBJECTS) $(hald_probe_usb2_device_DEPENDENCIES)
++ @rm -f hald-probe-usb2-device$(EXEEXT)
++ $(LINK) $(hald_probe_usb2_device_OBJECTS) $(hald_probe_usb2_device_LDADD) $(LIBS)
++hald-probe-usb2-interface$(EXEEXT): $(hald_probe_usb2_interface_OBJECTS) $(hald_probe_usb2_interface_DEPENDENCIES)
++ @rm -f hald-probe-usb2-interface$(EXEEXT)
++ $(LINK) $(hald_probe_usb2_interface_OBJECTS) $(hald_probe_usb2_interface_LDADD) $(LIBS)
+ hald-probe-volume$(EXEEXT): $(hald_probe_volume_OBJECTS) $(hald_probe_volume_DEPENDENCIES)
+ @rm -f hald-probe-volume$(EXEEXT)
+ $(LINK) $(hald_probe_volume_OBJECTS) $(hald_probe_volume_LDADD) $(LIBS)
+@@ -368,6 +422,7 @@ mostlyclean-compile:
+ distclean-compile:
+ -rm -f *.tab.c
+
++@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/hald_probe_mouse-probe-mouse.Po@am__quote@
+ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/hald_probe_storage-freebsd_dvd_rw_utils.Po@am__quote@
+ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/hald_probe_storage-probe-storage.Po@am__quote@
+ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/hald_probe_volume-freebsd_dvd_rw_utils.Po@am__quote@
+@@ -375,6 +430,8 @@ distclean-compile:
+ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/probe-hiddev.Po@am__quote@
+ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/probe-scsi.Po@am__quote@
+ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/probe-smbios.Po@am__quote@
++@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/probe-usb2-device.Po@am__quote@
++@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/probe-usb2-interface.Po@am__quote@
+
+ .c.o:
+ @am__fastdepCC_TRUE@ $(COMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $<
+@@ -397,6 +454,20 @@ distclean-compile:
+ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+ @am__fastdepCC_FALSE@ $(LTCOMPILE) -c -o $@ $<
+
++hald_probe_mouse-probe-mouse.o: probe-mouse.c
++@am__fastdepCC_TRUE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(hald_probe_mouse_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT hald_probe_mouse-probe-mouse.o -MD -MP -MF $(DEPDIR)/hald_probe_mouse-probe-mouse.Tpo -c -o hald_probe_mouse-probe-mouse.o `test -f 'probe-mouse.c' || echo '$(srcdir)/'`probe-mouse.c
++@am__fastdepCC_TRUE@ mv -f $(DEPDIR)/hald_probe_mouse-probe-mouse.Tpo $(DEPDIR)/hald_probe_mouse-probe-mouse.Po
++@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='probe-mouse.c' object='hald_probe_mouse-probe-mouse.o' libtool=no @AMDEPBACKSLASH@
++@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
++@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(hald_probe_mouse_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o hald_probe_mouse-probe-mouse.o `test -f 'probe-mouse.c' || echo '$(srcdir)/'`probe-mouse.c
++
++hald_probe_mouse-probe-mouse.obj: probe-mouse.c
++@am__fastdepCC_TRUE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(hald_probe_mouse_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT hald_probe_mouse-probe-mouse.obj -MD -MP -MF $(DEPDIR)/hald_probe_mouse-probe-mouse.Tpo -c -o hald_probe_mouse-probe-mouse.obj `if test -f 'probe-mouse.c'; then $(CYGPATH_W) 'probe-mouse.c'; else $(CYGPATH_W) '$(srcdir)/probe-mouse.c'; fi`
++@am__fastdepCC_TRUE@ mv -f $(DEPDIR)/hald_probe_mouse-probe-mouse.Tpo $(DEPDIR)/hald_probe_mouse-probe-mouse.Po
++@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='probe-mouse.c' object='hald_probe_mouse-probe-mouse.obj' libtool=no @AMDEPBACKSLASH@
++@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
++@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(hald_probe_mouse_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o hald_probe_mouse-probe-mouse.obj `if test -f 'probe-mouse.c'; then $(CYGPATH_W) 'probe-mouse.c'; else $(CYGPATH_W) '$(srcdir)/probe-mouse.c'; fi`
++
+ hald_probe_storage-freebsd_dvd_rw_utils.o: freebsd_dvd_rw_utils.c
+ @am__fastdepCC_TRUE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(hald_probe_storage_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT hald_probe_storage-freebsd_dvd_rw_utils.o -MD -MP -MF $(DEPDIR)/hald_probe_storage-freebsd_dvd_rw_utils.Tpo -c -o hald_probe_storage-freebsd_dvd_rw_utils.o `test -f 'freebsd_dvd_rw_utils.c' || echo '$(srcdir)/'`freebsd_dvd_rw_utils.c
+ @am__fastdepCC_TRUE@ mv -f $(DEPDIR)/hald_probe_storage-freebsd_dvd_rw_utils.Tpo $(DEPDIR)/hald_probe_storage-freebsd_dvd_rw_utils.Po
diff --git a/sysutils/hal/files/patch-hald_freebsd_probing_probe-hiddev.c b/sysutils/hal/files/patch-hald_freebsd_probing_probe-hiddev.c
new file mode 100644
index 000000000..ee627c451
--- /dev/null
+++ b/sysutils/hal/files/patch-hald_freebsd_probing_probe-hiddev.c
@@ -0,0 +1,37 @@
+--- hald/freebsd/probing/probe-hiddev.c.orig 2008-05-07 19:24:08.000000000 -0400
++++ hald/freebsd/probing/probe-hiddev.c 2009-02-24 00:42:06.000000000 -0500
+@@ -25,12 +25,21 @@
+ # include <config.h>
+ #endif
+
++#include <sys/param.h>
+ #include <unistd.h>
+ #include <stdlib.h>
+ #include <fcntl.h>
++#ifndef HAVE_LIBUSB20
+ #include <sys/ioctl.h>
+ #include <dev/usb/usb.h>
+ #include <dev/usb/usbhid.h>
++#else
++#if __FreeBSD_version >= 800064
++#include <dev/usb/usbhid.h>
++#else
++#include <dev/usb2/include/usb2_hid.h>
++#endif
++#endif
+ #include <usbhid.h>
+
+ #include "../libprobe/hfp.h"
+@@ -65,7 +74,12 @@ main (int argc, char **argv)
+ /* give a meaningful process title for ps(1) */
+ setproctitle("%s", device_file);
+
++#ifdef HAVE_LIBUSB20
++ report_id = hid_get_report_id(fd);
++ if (report_id == -1)
++#else
+ if (ioctl(fd, USB_GET_REPORT_ID, &report_id) < 0)
++#endif
+ goto end;
+
+ hid_init(NULL);
diff --git a/sysutils/hal/files/patch-hald_freebsd_probing_probe-mouse.c b/sysutils/hal/files/patch-hald_freebsd_probing_probe-mouse.c
new file mode 100644
index 000000000..fd69bf341
--- /dev/null
+++ b/sysutils/hal/files/patch-hald_freebsd_probing_probe-mouse.c
@@ -0,0 +1,315 @@
+--- hald/freebsd/probing/probe-mouse.c.orig 2009-02-04 11:00:00.000000000 -0500
++++ hald/freebsd/probing/probe-mouse.c 2009-02-04 11:04:43.000000000 -0500
+@@ -0,0 +1,312 @@
++/***************************************************************************
++ * CVSID: $Id: patch-hald_freebsd_probing_probe-mouse.c,v 1.1 2009-05-17 05:02:48 marcus Exp $
++ *
++ * probe-hiddev.c : Mouse prober
++ *
++ * Copyright (C) 2008 Joe Marcus Clarke <marcus@FreeBSD.org>
++ *
++ * This program is free software; you can redistribute it and/or modify
++ * it under the terms of the GNU General Public License as published by
++ * the Free Software Foundation; either version 2 of the License, or
++ * (at your option) any later version.
++ *
++ * This program is distributed in the hope that it will be useful,
++ * but WITHOUT ANY WARRANTY; without even the implied warranty of
++ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
++ * GNU General Public License for more details.
++ *
++ * You should have received a copy of the GNU General Public License
++ * along with this program; if not, write to the Free Software
++ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
++ *
++ **************************************************************************/
++
++#ifdef HAVE_CONFIG_H
++# include <config.h>
++#endif
++
++#include <sys/param.h>
++#if __FreeBSD_version >= 800058
++#include <sys/types.h>
++#include <sys/user.h>
++#include <sys/sysctl.h>
++#include <libutil.h>
++#endif
++#include <unistd.h>
++#include <stdlib.h>
++#include <string.h>
++#include <fcntl.h>
++#include <glib.h>
++
++#include "../libprobe/hfp.h"
++
++#if __FreeBSD_version < 800058
++#define CMD "/usr/bin/fstat %s"
++#endif
++
++#define MOUSE_DRIVER "mouse"
++#define MOUSED_DEVICE "/dev/sysmouse"
++#define MOUSED_PROC_NAME "moused"
++#define XORG_PROC_NAME "Xorg"
++
++#if __FreeBSD_version >= 800058
++static struct kinfo_proc *
++hfp_kinfo_getproc (int *cntp)
++{
++ int mib[3];
++ int error;
++ int cnt;
++ size_t len;
++ char *buf, *bp, *eb;
++ struct kinfo_proc *kip, *kp, *ki;
++
++ *cntp = 0;
++
++ len = 0;
++ mib[0] = CTL_KERN;
++ mib[1] = KERN_PROC;
++ mib[2] = KERN_PROC_PROC;
++
++ error = sysctl(mib, 3, NULL, &len, NULL, 0);
++ if (error)
++ return NULL;
++
++ len = len * 4 / 3;
++ buf = (char *) g_malloc(len);
++ if (buf == NULL)
++ return NULL;
++
++ error = sysctl(mib, 3, buf, &len, NULL, 0);
++ if (error)
++ {
++ g_free(buf);
++ return NULL;
++ }
++
++ cnt = 0;
++ bp = buf;
++ eb = buf + len;
++ while (bp < eb)
++ {
++ ki = (struct kinfo_proc *) (uintptr_t) bp;
++ bp += ki->ki_structsize;
++ cnt++;
++ }
++
++ kip = calloc(cnt, sizeof (*kip));
++ if (kip == NULL)
++ {
++ g_free(buf);
++ return NULL;
++ }
++
++ bp = buf;
++ eb = buf + len;
++ kp = kip;
++ while (bp < eb)
++ {
++ ki = (struct kinfo_proc *) (uintptr_t) bp;
++ memcpy(kp, ki, ki->ki_structsize);
++ bp += ki->ki_structsize;
++ kp->ki_structsize = sizeof(*kp);
++ kp++;
++ }
++
++ g_free(buf);
++ *cntp = cnt;
++ return kip;
++}
++
++static gboolean
++device_opened_by_proc (const char *device, const char *proc)
++{
++ struct kinfo_proc *kip, *pfreep;
++ int cnt, i;
++
++ pfreep = hfp_kinfo_getproc(&cnt);
++ if (pfreep == NULL)
++ return FALSE;
++
++ for (i = 0; i < cnt; i++)
++ {
++ kip = &pfreep[i];
++
++ if (! strcmp(kip->ki_comm, proc))
++ {
++ struct kinfo_file *kif, *ffreep;
++ int fcnt, j;
++
++ ffreep = kinfo_getfile(kip->ki_pid, &fcnt);
++ if (ffreep == NULL)
++ continue;
++ for (j = 0; j < fcnt; j++)
++ {
++ kif = &ffreep[j];
++
++ if (kif->kf_type == KF_TYPE_VNODE &&
++ ! strcmp(kif->kf_path, device))
++ {
++ g_free(ffreep);
++ g_free(pfreep);
++ return TRUE;
++ }
++ }
++ g_free(ffreep);
++ }
++ }
++ g_free(pfreep);
++
++ return FALSE;
++}
++#else
++static gboolean
++device_opened_by_proc (const char *device, const char *proc)
++{
++ char **lines;
++ char *output = NULL;
++ char *cmd;
++ int i;
++ gboolean found = FALSE;
++
++ cmd = g_strdup_printf(CMD, device);
++
++ if (! g_spawn_command_line_sync(cmd, &output, NULL, NULL, NULL))
++ {
++ g_free(cmd);
++ goto done;
++ }
++ g_free(cmd);
++
++ if (! output || strlen(output) == 0)
++ goto done;
++
++ lines = g_strsplit(output, "\n", 0);
++ if (g_strv_length(lines) < 2)
++ {
++ g_strfreev(lines);
++ goto done;
++ }
++
++ for (i = 1; lines[i]; i++)
++ {
++ char **fields;
++ guint len;
++ guint j;
++
++ fields = g_strsplit_set(lines[i], " ", 0);
++ len = g_strv_length(fields);
++ if (len < 3)
++ {
++ g_strfreev(fields);
++ continue;
++ }
++ for (j = 1; j < len && fields[j] && *fields[j] == '\0'; j++)
++ ;
++ if (j < len && fields[j] && ! strcmp(fields[j], proc))
++ {
++ found = TRUE;
++ g_strfreev(fields);
++ break;
++ }
++ g_strfreev(fields);
++ }
++
++ g_strfreev(lines);
++
++done:
++ g_free(output);
++
++ return found;
++}
++#endif
++
++static void
++probe_mouse (const char *device_file)
++{
++ gboolean found;
++ char **udis;
++ char *driver;
++ int num_udis;
++
++ driver = libhal_device_get_property_string(hfp_ctx, hfp_udi,
++ "input.x11_driver", &hfp_error);
++ dbus_error_free(&hfp_error);
++
++ found = device_opened_by_proc(device_file, XORG_PROC_NAME);
++ if (found)
++ {
++ if (driver)
++ {
++ libhal_device_remove_property(hfp_ctx, hfp_udi, "input.x11_driver",
++ &hfp_error);
++ dbus_error_free(&hfp_error);
++ g_free(driver);
++ }
++ return;
++ }
++
++ found = device_opened_by_proc(device_file, MOUSED_PROC_NAME);
++ if (found)
++ {
++ libhal_device_set_property_string(hfp_ctx, hfp_udi, "input.device",
++ MOUSED_DEVICE, &hfp_error);
++ dbus_error_free(&hfp_error);
++ found = device_opened_by_proc(MOUSED_DEVICE, XORG_PROC_NAME);
++ if (! found)
++ {
++ udis = libhal_manager_find_device_string_match(hfp_ctx,
++ "input.device",
++ MOUSED_DEVICE,
++ &num_udis,
++ &hfp_error);
++ dbus_error_free(&hfp_error);
++ if (num_udis > 0 && udis != NULL && !strcmp(udis[0], hfp_udi)) {
++ libhal_device_set_property_string(hfp_ctx, hfp_udi,
++ "input.x11_driver",
++ MOUSE_DRIVER, &hfp_error);
++ dbus_error_free(&hfp_error);
++ libhal_free_string_array(udis);
++ }
++ }
++ else if (driver)
++ {
++ libhal_device_remove_property(hfp_ctx, hfp_udi, "input.x11_driver",
++ &hfp_error);
++ dbus_error_free(&hfp_error);
++ }
++ }
++ else
++ {
++ libhal_device_set_property_string(hfp_ctx, hfp_udi, "input.device",
++ device_file, &hfp_error);
++ dbus_error_free(&hfp_error);
++ libhal_device_set_property_string(hfp_ctx, hfp_udi, "input.x11_driver",
++ MOUSE_DRIVER, &hfp_error);
++ dbus_error_free(&hfp_error);
++ }
++
++ g_free(driver);
++}
++
++int
++main (int argc, char **argv)
++{
++ char *device_file;
++
++ if (! hfp_init(argc, argv))
++ goto end;
++
++ device_file = getenv("HAL_PROP_FREEBSD_DEVICE_FILE");
++ if (! device_file)
++ goto end;
++
++ /* give a meaningful process title for ps(1) */
++ setproctitle("%s", device_file);
++
++ /* Sleep for a second to give moused a chance to connect. */
++ sleep(1);
++ probe_mouse(device_file);
++
++ end:
++ return 0;
++}
diff --git a/sysutils/hal/files/patch-hald_freebsd_probing_probe-storage.c b/sysutils/hal/files/patch-hald_freebsd_probing_probe-storage.c
new file mode 100644
index 000000000..d67ce03bf
--- /dev/null
+++ b/sysutils/hal/files/patch-hald_freebsd_probing_probe-storage.c
@@ -0,0 +1,39 @@
+--- hald/freebsd/probing/probe-storage.c.orig 2009-01-12 16:07:59.000000000 -0500
++++ hald/freebsd/probing/probe-storage.c 2009-01-12 16:20:20.000000000 -0500
+@@ -31,6 +31,8 @@
+ #include <unistd.h>
+ #include <errno.h>
+ #include <sys/types.h>
++#include <sys/ioctl.h>
++#include <sys/disk.h>
+ #include <netinet/in.h>
+ #include <glib.h>
+ #include <libvolume_id.h>
+@@ -211,7 +213,26 @@ main (int argc, char **argv)
+ goto end;
+
+ if (hfp_cdrom_test_unit_ready(cdrom))
+- ret = 2; /* has media */
++ {
++ int fd;
++ off_t size;
++
++ libhal_device_set_property_bool(hfp_ctx, hfp_udi, "storage.removable.media_available", TRUE, &hfp_error);
++ fd = open(device_file, O_RDONLY | O_NONBLOCK);
++ if (fd > -1)
++ {
++ if (ioctl (fd, DIOCGMEDIASIZE, &size) == 0)
++ {
++ libhal_device_set_property_uint64(hfp_ctx, hfp_udi, "storage.removable.media_size", size, &hfp_error);
++ }
++ close(fd);
++ }
++ ret = 2; /* has media */
++ }
++ else
++ {
++ libhal_device_set_property_bool(hfp_ctx, hfp_udi, "storage.removable.media_available", FALSE, &hfp_error);
++ }
+
+ hfp_cdrom_free(cdrom);
+ }
diff --git a/sysutils/hal/files/patch-hald_freebsd_probing_probe-usb2-device.c b/sysutils/hal/files/patch-hald_freebsd_probing_probe-usb2-device.c
new file mode 100644
index 000000000..7099e5689
--- /dev/null
+++ b/sysutils/hal/files/patch-hald_freebsd_probing_probe-usb2-device.c
@@ -0,0 +1,206 @@
+--- hald/freebsd/probing/probe-usb2-device.c.orig 2009-02-24 00:36:27.000000000 -0500
++++ hald/freebsd/probing/probe-usb2-device.c 2009-02-24 00:39:54.000000000 -0500
+@@ -0,0 +1,203 @@
++/***************************************************************************
++ * CVSID: $Id: patch-hald_freebsd_probing_probe-usb2-device.c,v 1.1 2009-05-17 05:02:48 marcus Exp $
++ *
++ * probe-usb2-device.c : USB2 Device poller
++ *
++ * Copyright (C) 2009 Joe Marcus Clarke <marcus@FreeBSD.org>
++ *
++ * This program is free software; you can redistribute it and/or modify
++ * it under the terms of the GNU General Public License as published by
++ * the Free Software Foundation; either version 2 of the License, or
++ * (at your option) any later version.
++ *
++ * This program is distributed in the hope that it will be useful,
++ * but WITHOUT ANY WARRANTY; without even the implied warranty of
++ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
++ * GNU General Public License for more details.
++ *
++ * You should have received a copy of the GNU General Public License
++ * along with this program; if not, write to the Free Software
++ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
++ *
++ **************************************************************************/
++
++#ifdef HAVE_CONFIG_H
++# include <config.h>
++#endif
++
++#include <sys/param.h>
++#include <sys/types.h>
++#include <stdio.h>
++#include <stdlib.h>
++#include <string.h>
++#include <unistd.h>
++
++#include <libusb20_desc.h>
++#include <libusb20.h>
++#if __FreeBSD_version >= 800064
++#include <dev/usb/usb_ioctl.h>
++#else
++#include <dev/usb2/include/usb2_standard.h>
++#include <dev/usb2/include/usb2_ioctl.h>
++#endif
++
++#include "../libprobe/hfp.h"
++
++int
++main(int argc, char **argv)
++{
++ struct libusb20_backend *pbe = NULL;
++ struct libusb20_device *pdev = NULL;
++ char *busstr, *addrstr;
++ int bus, addr;
++
++ if (! hfp_init(argc, argv))
++ goto end;
++
++ pbe = libusb20_be_alloc_default();
++ if (pbe == NULL)
++ goto end;
++
++ busstr = getenv("HAL_PROP_USB_DEVICE_BUS_NUMBER");
++ if (! busstr)
++ goto end;
++
++ addrstr = getenv("HAL_PROP_USB_DEVICE_PORT_NUMBER");
++ if (! addrstr)
++ goto end;
++
++ bus = atoi(busstr);
++ addr = atoi(addrstr);
++
++ while ((pdev = libusb20_be_device_foreach(pbe, pdev)))
++ {
++ struct LIBUSB20_DEVICE_DESC_DECODED *ddesc;
++ struct LIBUSB20_CONFIG_DESC_DECODED *cdesc;
++ struct usb2_device_info di;
++ struct libusb20_config *pcfg = NULL;
++ int curr_config;
++ int bcdspeed = 0;
++ uint8_t temp_string[256];
++ double speed = 0.0;
++ double version = 1.0;
++
++ if (libusb20_dev_get_bus_number(pdev) != bus ||
++ libusb20_dev_get_address(pdev) != addr)
++ continue;
++
++ if (libusb20_dev_open(pdev, 0))
++ continue;
++
++ ddesc = libusb20_dev_get_device_desc(pdev);
++ curr_config = libusb20_dev_get_config_index(pdev);
++ pcfg = libusb20_dev_alloc_config(pdev, curr_config);
++ cdesc = &(pcfg->desc);
++
++ if (libusb20_dev_get_info(pdev, &di))
++ {
++ free(pcfg);
++ continue;
++ }
++
++ memset(temp_string, 0, sizeof(temp_string));
++
++ if (cdesc->iConfiguration !=0)
++ libusb20_dev_req_string_simple_sync(pdev, cdesc->iConfiguration,
++ temp_string, sizeof(temp_string));
++
++ libhal_device_set_property_string(hfp_ctx, hfp_udi,
++ "usb_device.configuration", (char *) temp_string, &hfp_error);
++ libhal_device_set_property_int(hfp_ctx, hfp_udi,
++ "usb_device.configuration_value", cdesc->bConfigurationValue,
++ &hfp_error);
++ libhal_device_set_property_int(hfp_ctx, hfp_udi,
++ "usb_device.num_configurations", ddesc->bNumConfigurations,
++ &hfp_error);
++ libhal_device_set_property_int(hfp_ctx, hfp_udi,
++ "usb_device.device_class", di.udi_class, &hfp_error);
++ libhal_device_set_property_int(hfp_ctx, hfp_udi,
++ "usb_device.device_subclass", di.udi_subclass, &hfp_error);
++ libhal_device_set_property_int(hfp_ctx, hfp_udi,
++ "usb_device.device_protocol", di.udi_protocol, &hfp_error);
++ libhal_device_set_property_bool(hfp_ctx, hfp_udi,
++ "usb_device.is_self_powered",
++ di.udi_power == 0 ? TRUE : FALSE, &hfp_error);
++ libhal_device_set_property_bool(hfp_ctx, hfp_udi,
++ "usb_device.can_wake_up",
++ (cdesc->bmAttributes & UC_REMOTE_WAKEUP) != 0 ? TRUE : FALSE,
++ &hfp_error);
++ libhal_device_set_property_int(hfp_ctx, hfp_udi,
++ "usb_device.max_power", di.udi_power, &hfp_error);
++ libhal_device_set_property_int(hfp_ctx, hfp_udi,
++ "usb_device.num_interfaces", pcfg->num_interface, &hfp_error);
++ libhal_device_set_property_int(hfp_ctx, hfp_udi,
++ "usb_device.num_ports", di.udi_nports, &hfp_error);
++
++ switch (libusb20_dev_get_speed(pdev))
++ {
++ case LIBUSB20_SPEED_LOW:
++ speed = 1.5;
++ bcdspeed = 0x00150;
++ break;
++ case LIBUSB20_SPEED_FULL:
++ speed = 12.0;
++ bcdspeed = 0x01200;
++ break;
++ case LIBUSB20_SPEED_HIGH:
++ speed = 480.0;
++ bcdspeed = 0x48000;
++ break;
++ case LIBUSB20_SPEED_SUPER:
++ speed = 4800.0;
++ bcdspeed = 0x480000;
++ break;
++ default:
++ ;
++ }
++
++ libhal_device_set_property_double(hfp_ctx, hfp_udi, "usb_device.speed",
++ speed, &hfp_error);
++ libhal_device_set_property_int(hfp_ctx, hfp_udi, "usb_device.speed_bcd",
++ bcdspeed, &hfp_error);
++
++ switch (ddesc->bcdUSB)
++ {
++ case UD_USB_2_0:
++ version = 2.0;
++ break;
++ case UD_USB_3_0:
++ version = 3.0;
++ break;
++ default:
++ version = 1.0;
++ break;
++ }
++
++ libhal_device_set_property_double(hfp_ctx, hfp_udi,
++ "usb_device.version", version, &hfp_error);
++ libhal_device_set_property_int(hfp_ctx, hfp_udi,
++ "usb_device.product_id", di.udi_productNo, &hfp_error);
++ libhal_device_set_property_int(hfp_ctx, hfp_udi,
++ "usb_device.vendor_id", di.udi_vendorNo, &hfp_error);
++ libhal_device_set_property_int(hfp_ctx, hfp_udi,
++ "usb_device.device_revision_bcd", ddesc->bcdUSB, &hfp_error);
++ libhal_device_set_property_string(hfp_ctx, hfp_udi,
++ "usb_device.serial", di.udi_serial, &hfp_error);
++ libhal_device_set_property_string(hfp_ctx, hfp_udi,
++ "usb_device.product", di.udi_product, &hfp_error);
++ libhal_device_set_property_string(hfp_ctx, hfp_udi,
++ "usb_device.vendor", di.udi_vendor, &hfp_error);
++
++ libhal_device_set_property_string(hfp_ctx, hfp_udi,
++ "info.product", di.udi_product, &hfp_error);
++ libhal_device_set_property_string(hfp_ctx, hfp_udi,
++ "info.vendor", di.udi_vendor, &hfp_error);
++
++ free(pcfg);
++ }
++end:
++ if (pbe)
++ libusb20_be_free(pbe);
++
++ return 0;
++}
diff --git a/sysutils/hal/files/patch-hald_freebsd_probing_probe-usb2-interface.c b/sysutils/hal/files/patch-hald_freebsd_probing_probe-usb2-interface.c
new file mode 100644
index 000000000..d8010b3e7
--- /dev/null
+++ b/sysutils/hal/files/patch-hald_freebsd_probing_probe-usb2-interface.c
@@ -0,0 +1,143 @@
+--- hald/freebsd/probing/probe-usb2-interface.c.orig 2009-02-24 00:36:27.000000000 -0500
++++ hald/freebsd/probing/probe-usb2-interface.c 2009-02-24 00:39:42.000000000 -0500
+@@ -0,0 +1,140 @@
++/***************************************************************************
++ * CVSID: $Id: patch-hald_freebsd_probing_probe-usb2-interface.c,v 1.1 2009-05-17 05:02:48 marcus Exp $
++ *
++ * probe-usb2-interface.c : USB2 Interface poller
++ *
++ * Copyright (C) 2009 Joe Marcus Clarke <marcus@FreeBSD.org>
++ *
++ * This program is free software; you can redistribute it and/or modify
++ * it under the terms of the GNU General Public License as published by
++ * the Free Software Foundation; either version 2 of the License, or
++ * (at your option) any later version.
++ *
++ * This program is distributed in the hope that it will be useful,
++ * but WITHOUT ANY WARRANTY; without even the implied warranty of
++ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
++ * GNU General Public License for more details.
++ *
++ * You should have received a copy of the GNU General Public License
++ * along with this program; if not, write to the Free Software
++ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
++ *
++ **************************************************************************/
++
++#ifdef HAVE_CONFIG_H
++# include <config.h>
++#endif
++
++#include <sys/param.h>
++#include <sys/types.h>
++#include <stdio.h>
++#include <stdlib.h>
++#include <string.h>
++#include <unistd.h>
++
++#include <libusb20_desc.h>
++#include <libusb20.h>
++#if __FreeBSD_version >= 800064
++#include <dev/usb/usb_ioctl.h>
++#else
++#include <dev/usb2/include/usb2_standard.h>
++#include <dev/usb2/include/usb2_ioctl.h>
++#endif
++
++#include "../libprobe/hfp.h"
++
++int
++main(int argc, char **argv)
++{
++ struct libusb20_backend *pbe = NULL;
++ struct libusb20_device *pdev = NULL;
++ char *busstr, *addrstr, *ifacestr;
++ int bus, addr, iface;
++
++ if (! hfp_init(argc, argv))
++ goto end;
++
++ pbe = libusb20_be_alloc_default();
++ if (pbe == NULL)
++ goto end;
++
++ busstr = getenv("HAL_PROP_USB_DEVICE_BUS_NUMBER");
++ if (! busstr)
++ goto end;
++
++ addrstr = getenv("HAL_PROP_USB_DEVICE_PORT_NUMBER");
++ if (! addrstr)
++ goto end;
++
++ ifacestr = getenv("HAL_PROP_USB_INTERFACE_NUMBER");
++ if (! ifacestr)
++ goto end;
++
++ bus = atoi(busstr);
++ addr = atoi(addrstr);
++ iface = atoi(ifacestr);
++
++ while ((pdev = libusb20_be_device_foreach(pbe, pdev)))
++ {
++ struct LIBUSB20_INTERFACE_DESC_DECODED *idesc;
++ struct libusb20_config *pcfg = NULL;
++ struct libusb20_interface *pif;
++ uint8_t temp_string[256];
++ char ifdrv[128];
++ int curr_config;
++
++ if (libusb20_dev_get_bus_number(pdev) != bus ||
++ libusb20_dev_get_address(pdev) != addr)
++ continue;
++
++ if (libusb20_dev_open(pdev, 0))
++ continue;
++
++ curr_config = libusb20_dev_get_config_index(pdev);
++ pcfg = libusb20_dev_alloc_config(pdev, curr_config);
++ if (! pcfg)
++ continue;
++
++ pif = pcfg->interface + iface;
++
++ idesc = &pif->desc;
++
++ libhal_device_set_property_int(hfp_ctx, hfp_udi,
++ "usb.interface.class", idesc->bInterfaceClass, &hfp_error);
++ libhal_device_set_property_int(hfp_ctx, hfp_udi,
++ "usb.interface.subclass", idesc->bInterfaceSubClass, &hfp_error);
++ libhal_device_set_property_int(hfp_ctx, hfp_udi,
++ "usb.interface.protocol", idesc->bInterfaceProtocol, &hfp_error);
++
++ memset(temp_string, 0, sizeof(temp_string));
++ if (idesc->iInterface != 0)
++ libusb20_dev_req_string_simple_sync(pdev, idesc->iInterface,
++ temp_string, sizeof(temp_string));
++
++ libhal_device_set_property_string(hfp_ctx, hfp_udi,
++ "usb.interface.description", (char *) temp_string, &hfp_error);
++
++ memset(ifdrv, 0, sizeof(ifdrv));
++ libusb20_dev_get_iface_desc(pdev, iface, ifdrv, sizeof(ifdrv));
++ if (ifdrv[0] != '\0')
++ {
++ char *ifdesc;
++
++ ifdesc = strchr(ifdrv, ':');
++ if (ifdesc)
++ {
++ *ifdesc = '\0';
++ libhal_device_set_property_string(hfp_ctx, hfp_udi,
++ "usb.freebsd.devname", ifdrv, &hfp_error);
++ }
++ }
++
++ free(pcfg);
++ }
++
++end:
++ if (pbe)
++ libusb20_be_free(pbe);
++
++ return 0;
++}
diff --git a/sysutils/hal/files/patch-hald_freebsd_probing_probe-volume.c b/sysutils/hal/files/patch-hald_freebsd_probing_probe-volume.c
new file mode 100644
index 000000000..b9dc099e6
--- /dev/null
+++ b/sysutils/hal/files/patch-hald_freebsd_probing_probe-volume.c
@@ -0,0 +1,12 @@
+--- hald/freebsd/probing/probe-volume.c.orig 2008-04-07 00:41:22.000000000 -0400
++++ hald/freebsd/probing/probe-volume.c 2008-04-07 00:43:32.000000000 -0400
+@@ -502,7 +502,8 @@ main (int argc, char **argv)
+ hfp_cdrom_free(cdrom);
+ }
+
+- if (has_data)
++ if (has_data && vid && (! strcmp(vid->type, "iso9660") ||
++ ! strcmp(vid->type, "udf")))
+ hf_probe_volume_advanced_disc_detect(fd);
+ }
+ else
diff --git a/sysutils/hal/files/patch-hald_hf-storage.c b/sysutils/hal/files/patch-hald_hf-storage.c
new file mode 100644
index 000000000..58d00a896
--- /dev/null
+++ b/sysutils/hal/files/patch-hald_hf-storage.c
@@ -0,0 +1,226 @@
+--- hald/freebsd/hf-storage.c.orig 2008-05-07 19:23:57.000000000 -0400
++++ hald/freebsd/hf-storage.c 2009-02-25 16:38:35.000000000 -0500
+@@ -30,6 +30,7 @@
+ #include <limits.h>
+ #include <inttypes.h>
+ #include <string.h>
++#include <sys/param.h>
+ #include <sys/types.h>
+ #include <sys/disklabel.h>
+
+@@ -38,6 +39,7 @@
+
+ #include "hf-storage.h"
+ #include "hf-block.h"
++#include "hf-devd.h"
+ #include "hf-devtree.h"
+ #include "hf-volume.h"
+ #include "hf-util.h"
+@@ -64,7 +66,7 @@ typedef struct
+ static GNode *hf_storage_geom_tree = NULL;
+ static GHashTable *hf_storage_geom_hash = NULL;
+
+-static void hf_storage_init_geom (void);
++static void hf_storage_init_geom (gboolean force);
+ static gboolean hf_storage_device_has_addon (HalDevice *device);
+
+ static void
+@@ -104,6 +106,8 @@ hf_storage_class_is_partitionable (const
+ {
+ return (! strcmp(geom_class, "MBR") ||
+ ! strcmp(geom_class, "MBREXT") ||
++ ! strcmp(geom_class, "PART") ||
++ ! strcmp(geom_class, "JOURNAL") ||
+ ! strcmp(geom_class, "GPT") ||
+ ! strcmp(geom_class, "APPLE") || ! strcmp(geom_class, "SUN"));
+ }
+@@ -117,6 +121,7 @@ hf_storage_geom_has_partitions (const Ge
+ if (g_node_n_children(node) > 0)
+ return TRUE;
+
++ /*
+ if (hf_storage_class_is_partitionable(geom_obj->class) &&
+ g_node_next_sibling(node) != NULL)
+ {
+@@ -135,6 +140,7 @@ hf_storage_geom_has_partitions (const Ge
+ return TRUE;
+ }
+ }
++ */
+
+ return FALSE;
+ }
+@@ -146,6 +152,7 @@ hf_storage_geom_is_swap (const Geom_Obje
+
+ return (! strcmp(geom_obj->class, "BSD") && geom_obj->type == FS_SWAP)
+ || ((! strcmp(geom_obj->class, "MBR") ||
++ ! strcmp(geom_obj->class, "PART") ||
+ ! strcmp(geom_obj->class, "MBREXT"))
+ && (geom_obj->type == 0x18 /* AST Windows swapfile */
+ || geom_obj->type == 0x42 /* SFS or Linux swap */
+@@ -294,7 +301,7 @@ hf_storage_device_probe (HalDevice *devi
+ {
+ g_return_if_fail(HAL_IS_DEVICE(device));
+
+- hf_storage_init_geom();
++ hf_storage_init_geom(TRUE);
+
+ if (hf_runner_run_sync(device, 0, "hald-probe-storage",
+ "HF_HAS_CHILDREN", HF_BOOL_TO_STRING(hf_storage_device_has_partitions(device)),
+@@ -433,6 +440,29 @@ hf_storage_parse_conftxt (const char *co
+ if (! strcmp (geom_obj->class, "GPT") ||
+ ! strcmp (geom_obj->class, "APPLE"))
+ geom_obj->str_type = g_strdup(fields[10]);
++ else if (! strcmp (geom_obj->class, "PART"))
++ {
++ if (g_strv_length(fields) >= 15)
++ {
++ if (! strcmp(fields[13], "xt"))
++ {
++ geom_obj->type = atoi(fields[14]);
++ if (! strcmp(fields[11], "xs"))
++ {
++ g_free(geom_obj->class);
++ geom_obj->class = g_strdup(fields[12]);
++ }
++ }
++ }
++ }
++ else if (fields[10][0] == '!')
++ {
++ char *nottype;
++
++ nottype = fields[10];
++ nottype++;
++ geom_obj->type = atoi(nottype);
++ }
+ else
+ geom_obj->type = atoi(fields[10]);
+ }
+@@ -541,15 +571,20 @@ hf_storage_device_rescan_real (HalDevice
+ }
+
+ static gboolean
+-hf_storage_conftxt_timeout_cb (gpointer data)
++hf_storage_devd_notify (const char *system,
++ const char *subsystem,
++ const char *type,
++ const char *data)
+ {
+ static GSList *disks = NULL;
+ static gboolean first = TRUE;
++ gboolean handled = FALSE;
+ char *conftxt;
+ GSList *new_disks;
+
+- if (hf_is_waiting)
+- return TRUE;
++ if (strcmp(system, "DEVFS") || strcmp(subsystem, "CDEV") ||
++ (strcmp(type, "CREATE") && strcmp(type, "DESTROY")))
++ return FALSE;
+
+ conftxt = hf_get_string_sysctl(NULL, "kern.geom.conftxt");
+ new_disks = hf_storage_parse_conftxt(conftxt);
+@@ -572,6 +607,7 @@ hf_storage_conftxt_timeout_cb (gpointer
+ if (! hf_storage_find_disk(disks, disk->name))
+ {
+ osspec_probe(); /* catch new disk(s) */
++ handled = TRUE;
+ break;
+ }
+ }
+@@ -593,7 +629,10 @@ hf_storage_conftxt_timeout_cb (gpointer
+ device = hf_devtree_find_from_name(hald_get_gdl(), disk->name);
+ if (device && hal_device_has_capability(device, "storage") &&
+ ! hf_storage_device_has_addon(device))
+- hf_storage_device_rescan_real(device);
++ {
++ hf_storage_device_rescan_real(device);
++ handled = TRUE;
++ }
+ }
+ }
+ else
+@@ -601,7 +640,10 @@ hf_storage_conftxt_timeout_cb (gpointer
+ /* disk removed */
+ device = hf_devtree_find_from_name(hald_get_gdl(), disk->name);
+ if (device && hal_device_has_capability(device, "storage"))
+- hf_device_remove_tree(device);
++ {
++ hf_device_remove_tree(device);
++ handled = TRUE;
++ }
+ }
+ }
+ }
+@@ -610,17 +652,30 @@ hf_storage_conftxt_timeout_cb (gpointer
+ g_slist_free(disks);
+ disks = new_disks;
+
++ return handled;
++}
++
++#if __FreeBSD_version < 700110
++static gboolean
++hf_storage_conftxt_timeout_cb (gpointer data)
++{
++ if (hf_is_waiting)
++ return TRUE;
++
++ hf_storage_devd_notify("DEVFS", "CDEV", "CREATE", NULL);
++
+ return TRUE;
+ }
++#endif
+
+ static void
+-hf_storage_init_geom (void)
++hf_storage_init_geom (gboolean force)
+ {
+ char *conftxt;
+ static gboolean inited = FALSE;
+ GSList *disks;
+
+- if (inited)
++ if (inited && ! force)
+ return;
+
+ conftxt = hf_get_string_sysctl(NULL, "kern.geom.conftxt");
+@@ -636,8 +691,10 @@ hf_storage_init_geom (void)
+ static void
+ hf_storage_init (void)
+ {
+- hf_storage_init_geom();
++ hf_storage_init_geom(FALSE);
++#if __FreeBSD_version < 700110
+ g_timeout_add(3000, hf_storage_conftxt_timeout_cb, NULL);
++#endif
+ }
+
+ void
+@@ -720,8 +777,6 @@ hf_storage_device_add (HalDevice *device
+ {
+ g_return_if_fail(HAL_IS_DEVICE(device));
+
+- hf_storage_init_geom();
+-
+ if (hf_device_preprobe(device))
+ {
+ hf_storage_device_probe(device, FALSE);
+@@ -739,7 +794,7 @@ hf_storage_get_geoms (const char *devnam
+
+ g_return_val_if_fail(devname != NULL, NULL);
+
+- hf_storage_init_geom();
++ hf_storage_init_geom(FALSE);
+
+ hash = g_str_hash(devname);
+ node = g_node_find(hf_storage_geom_tree, G_PRE_ORDER, G_TRAVERSE_ALL,
+@@ -802,3 +857,7 @@ HFHandler hf_storage_handler = {
+ .probe = hf_storage_probe,
+ .device_rescan = hf_storage_device_rescan
+ };
++
++HFDevdHandler hf_storage_devd_handler = {
++ .notify = hf_storage_devd_notify
++};
diff --git a/sysutils/hal/files/patch-tools_hal-storage-eject.c b/sysutils/hal/files/patch-tools_hal-storage-eject.c
new file mode 100644
index 000000000..730e2a076
--- /dev/null
+++ b/sysutils/hal/files/patch-tools_hal-storage-eject.c
@@ -0,0 +1,11 @@
+--- tools/hal-storage-eject.c.orig 2008-10-27 13:23:11.000000000 -0400
++++ tools/hal-storage-eject.c 2008-10-27 13:23:23.000000000 -0400
+@@ -190,7 +190,7 @@ main (int argc, char *argv[])
+ unknown_eject_error ("Cannot obtain lock on /media/.hal-mtab");
+ }
+ handle_unmount (hal_ctx,
+- udi, volume_to_unmount, drive,
++ volume_udi, volume_to_unmount, drive,
+ libhal_volume_get_device_file (volume_to_unmount),
+ invoked_by_uid, invoked_by_syscon_name,
+ FALSE, FALSE); /* use neither lazy nor force */
diff --git a/sysutils/hal/files/patch-tools_hal-storage-mount.c b/sysutils/hal/files/patch-tools_hal-storage-mount.c
new file mode 100644
index 000000000..390d35111
--- /dev/null
+++ b/sysutils/hal/files/patch-tools_hal-storage-mount.c
@@ -0,0 +1,91 @@
+--- tools/hal-storage-mount.c.orig 2008-05-07 19:24:23.000000000 -0400
++++ tools/hal-storage-mount.c 2008-10-09 00:54:34.000000000 -0400
+@@ -56,8 +56,9 @@
+
+ #ifdef __FreeBSD__
+ #define MOUNT "/sbin/mount"
+-#define MOUNT_OPTIONS "noexec,nosuid"
++#define MOUNT_OPTIONS "nosuid"
+ #define MOUNT_TYPE_OPT "-t"
++#define FUSE_DB "/tmp/.fuse-mnts"
+ #elif sun
+ #define MOUNT "/sbin/mount"
+ #define MOUNT_OPTIONS "noexec,nosuid"
+@@ -255,6 +256,51 @@ out:
+ return f;
+ }
+
++#ifdef __FreeBSD__
++static char *
++resolve_fuse (const char *special)
++{
++ gchar *contents;
++ gchar **lines;
++ gsize len;
++ int i;
++
++ if (! g_file_get_contents (FUSE_DB, &contents, &len, NULL))
++ return g_strdup (special);
++
++ lines = g_strsplit (contents, "\n", 0);
++ g_free (contents);
++
++ for (i = 0; lines && lines[i]; i++) {
++ gchar **fields;
++
++ fields = g_strsplit (lines[i], "=", 2);
++ if (fields && g_strv_length (fields) == 2) {
++ if (strcmp (fields[0], special) == 0) {
++ g_strfreev (fields);
++ g_strfreev (lines);
++ return g_strdup (fields[1]);
++ }
++ }
++ g_strfreev (fields);
++ }
++
++ g_strfreev (lines);
++
++ return g_strdup (special);
++}
++#endif
++
++static char *
++resolve_special (const char *special)
++{
++#ifdef __FreeBSD__
++ if (strstr(special, "fuse"))
++ return resolve_fuse (special);
++#endif
++ return g_strdup (special);
++}
++
+ static LibHalVolume *
+ volume_findby (LibHalContext *hal_ctx, const char *property, const char *value)
+ {
+@@ -400,18 +446,20 @@ device_is_mounted (const char *device, c
+ unknown_error ("Cannot open /etc/mtab or equivalent");
+ }
+ while (((entry = mtab_next (handle, mount_point)) != NULL) && (ret == FALSE)) {
+- char *resolved;
++ char *resolved, *rspecial;
+
+ resolved = resolve_symlink (entry);
++ rspecial = resolve_special (resolved);
++ g_free (resolved);
+ #ifdef DEBUG
+- printf ("/proc/mounts: device %s -> %s \n", entry, resolved);
++ printf ("/proc/mounts: device %s -> %s \n", entry, rspecial);
+ #endif
+- if (strcmp (device, resolved) == 0) {
+- printf ("%s (-> %s) found in mount list. Not mounting.\n", entry, resolved);
++ if (strcmp (device, rspecial) == 0) {
++ printf ("%s (-> %s) found in mount list. Not mounting.\n", entry, rspecial);
+ ret = TRUE;
+ }
+
+- g_free (resolved);
++ g_free (rspecial);
+ }
+ mtab_close (handle);
+ return ret;
diff --git a/sysutils/hal/files/patch-tools_hal-storage-shared.c b/sysutils/hal/files/patch-tools_hal-storage-shared.c
new file mode 100644
index 000000000..1ed7fe907
--- /dev/null
+++ b/sysutils/hal/files/patch-tools_hal-storage-shared.c
@@ -0,0 +1,45 @@
+--- tools/hal-storage-shared.c.orig 2008-05-07 19:24:24.000000000 -0400
++++ tools/hal-storage-shared.c 2008-10-20 14:53:35.000000000 -0400
+@@ -297,6 +297,9 @@ handle_unmount (LibHalContext *hal_ctx,
+ char *mount_point_to_unmount;
+ gboolean mounted_by_other_uid;
+ FILE *hal_mtab_new;
++#ifdef __FreeBSD__
++ char *rdevice = NULL;
++#endif
+
+ #ifdef DEBUG
+ printf ("device = %s\n", device);
+@@ -473,7 +476,20 @@ line_found:
+ #endif
+ if (option_force)
+ args[na++] = "-f";
+- args[na++] = (char *) device;
++#ifdef __FreeBSD__
++ dbus_error_init (&error);
++ if (libhal_device_property_exists (hal_ctx, udi, "volume.freebsd.real_mounted_device", NULL)) {
++ rdevice = libhal_device_get_property_string (hal_ctx, udi, "volume.freebsd.real_mounted_device", &error);
++ if (dbus_error_is_set (&error)) {
++ dbus_error_free (&error);
++ unknown_error ("Error while getting volume.freebsd.real_mounted_device");
++ }
++ }
++ if (rdevice)
++ args[na++] = rdevice;
++ else
++#endif
++ args[na++] = (char *) device;
+ args[na++] = NULL;
+
+ #ifdef DEBUG
+@@ -497,6 +513,10 @@ line_found:
+ unknown_error ("Cannot spawn " UMOUNT);
+ }
+
++#ifdef __FreeBSD__
++ g_free (rdevice);
++#endif
++
+ /* check if unmount was succesful */
+ if (exit_status != 0) {
+ printf ("%s error %d, stdout='%s', stderr='%s'\n", UMOUNT, exit_status, sout, serr);
diff --git a/sysutils/hal/files/pkg-deinstall.in b/sysutils/hal/files/pkg-deinstall.in
new file mode 100644
index 000000000..4650d60fe
--- /dev/null
+++ b/sysutils/hal/files/pkg-deinstall.in
@@ -0,0 +1,17 @@
+#!/bin/sh
+
+[ "$2" != DEINSTALL ] && exit 0
+
+USER=haldaemon
+
+%%LOCALBASE%%/bin/polkit-auth --user ${USER} --revoke \
+ org.freedesktop.policykit.read
+
+for pair in %%RC_FILES%%; do
+ file=`echo $pair | cut -f 1 -d :`
+ destdir=`echo $pair | cut -f 2 -d :`
+
+ if cmp -s %%DATADIR%%/dist/$file $destdir/$file; then
+ rm -f $destdir/$file
+ fi
+done
diff --git a/sysutils/hal/files/pkg-install.in b/sysutils/hal/files/pkg-install.in
new file mode 100644
index 000000000..59505fc30
--- /dev/null
+++ b/sysutils/hal/files/pkg-install.in
@@ -0,0 +1,52 @@
+#!/bin/sh
+
+case $2 in
+POST-INSTALL)
+ USER=haldaemon
+ GROUP=${USER}
+ UID=560
+ GID=${UID}
+ PW=/usr/sbin/pw
+
+ if ${PW} group show "${GROUP}" 2>/dev/null; then
+ echo "You already have a group \"${GROUP}\", so I will use it."
+ else
+ if ${PW} groupadd ${GROUP} -g ${GID}; then
+ echo "Added group \"${GROUP}\"."
+ else
+ echo "Adding group \"${GROUP}\" failed..."
+ exit 1
+ fi
+ fi
+
+ if ${PW} user show "${USER}" 2>/dev/null; then
+ echo "You already have a user \"${USER}\", so I will use it."
+ else
+ if ${PW} useradd ${USER} -u ${UID} -g ${GROUP} -h - \
+ -d "/nonexistent" -s /sbin/nologin -c "HAL Daemon User"
+ then
+ echo "Added user \"${USER}\"."
+ else
+ echo "Adding user \"${USER}\" failed..."
+ exit 1
+ fi
+ fi
+
+ /usr/bin/install -d -o ${USER} -g ${GROUP} /var/run/hald
+ /usr/bin/install -d -o ${USER} -g ${GROUP} /var/cache/hald
+ /usr/bin/install -d -o ${USER} -g ${GROUP} /var/lib/hal
+ %%LOCALBASE%%/bin/polkit-auth --user ${USER} --grant \
+ org.freedesktop.policykit.read
+
+ for pair in %%RC_FILES%%; do
+ file=`echo $pair | cut -f 1 -d :`
+ destdir=`echo $pair | cut -f 2 -d :`
+
+ if [ ! -f $destdir/$file ]; then
+ mkdir -p $destdir
+ cp -p %%DATADIR%%/dist/$file $destdir/$file
+ fi
+ done
+ exit 0
+ ;;
+esac