diff options
author | marcus <marcus@df743ca5-7f9a-e211-a948-0013205c9059> | 2008-10-27 03:42:57 +0800 |
---|---|---|
committer | marcus <marcus@df743ca5-7f9a-e211-a948-0013205c9059> | 2008-10-27 03:42:57 +0800 |
commit | c460de34c8a97fec7522b83576deb9d381496b13 (patch) | |
tree | 06e27b7a8b5ba3b810135cd8394685580a9c9d54 | |
parent | c485145cd1aedb916b619b1908e7e90940873867 (diff) | |
download | marcuscom-ports-c460de34c8a97fec7522b83576deb9d381496b13.tar marcuscom-ports-c460de34c8a97fec7522b83576deb9d381496b13.tar.gz marcuscom-ports-c460de34c8a97fec7522b83576deb9d381496b13.tar.bz2 marcuscom-ports-c460de34c8a97fec7522b83576deb9d381496b13.tar.lz marcuscom-ports-c460de34c8a97fec7522b83576deb9d381496b13.tar.xz marcuscom-ports-c460de34c8a97fec7522b83576deb9d381496b13.tar.zst marcuscom-ports-c460de34c8a97fec7522b83576deb9d381496b13.zip |
Re-add fuse support with some documentation and a helper script to make it
work. Also, temporarily revert the keyboard patch until X.Org 7.4 is
committed.
git-svn-id: svn://creme-brulee.marcuscom.com/ports/trunk@11737 df743ca5-7f9a-e211-a948-0013205c9059
-rw-r--r-- | sysutils/hal/Makefile | 8 | ||||
-rw-r--r-- | sysutils/hal/files/README.fuse | 31 | ||||
-rwxr-xr-x | sysutils/hal/files/mount-fuse | 116 | ||||
-rw-r--r-- | sysutils/hal/files/patch-fdi_policy_10osvendor_10-x11-input.fdi | 14 | ||||
-rw-r--r-- | sysutils/hal/files/patch-hald_freebsd_hf-volume.c | 102 | ||||
-rw-r--r-- | sysutils/hal/files/patch-tools_hal-storage-mount.c | 86 | ||||
-rw-r--r-- | sysutils/hal/files/patch-tools_hal-storage-shared.c | 45 | ||||
-rw-r--r-- | sysutils/hal/pkg-plist | 2 |
8 files changed, 389 insertions, 15 deletions
diff --git a/sysutils/hal/Makefile b/sysutils/hal/Makefile index b6f534490..c0f3c0c7e 100644 --- a/sysutils/hal/Makefile +++ b/sysutils/hal/Makefile @@ -3,12 +3,12 @@ # Whom: Joe Marcus Clarke <marcus@FreeBSD.org> # # $FreeBSD$ -# $MCom: ports/sysutils/hal/Makefile,v 1.48 2008/10/09 05:12:35 marcus Exp $ +# $MCom: ports/sysutils/hal/Makefile,v 1.49 2008/10/10 15:05:06 marcus Exp $ # PORTNAME= hal DISTVERSION= 0.5.11 -PORTREVISION= 5 +PORTREVISION= 6 CATEGORIES= sysutils MASTER_SITES= http://hal.freedesktop.org/releases/ @@ -105,6 +105,8 @@ post-install: ${MKDIR} ${PREFIX}/share/hal/fdi/policy/10osvendor ${INSTALL_DATA} ${FILESDIR}/10-mouse-sysmouse.fdi \ ${PREFIX}/share/hal/fdi/policy/10osvendor + ${INSTALL_SCRIPT} ${FILESDIR}/mount-fuse \ + ${PREFIX}/share/hal/mount-fuse .if !defined(PACKAGE_BUILDING) @${SETENV} PKG_PREFIX=${PREFIX} \ ${SH} ${PKGINSTALL} ${PKGNAME} POST-INSTALL @@ -116,6 +118,8 @@ post-install: ${MKDIR} ${DOCSDIR} ${INSTALL_DATA} ${WRKSRC}/hald/freebsd/README \ ${DOCSDIR}/README.freebsd + ${INSTALL_DATA} ${FILESDIR}/README.fuse \ + ${DOCSDIR}/README.fuse .endif .include <bsd.port.post.mk> diff --git a/sysutils/hal/files/README.fuse b/sysutils/hal/files/README.fuse new file mode 100644 index 000000000..75adcab7d --- /dev/null +++ b/sysutils/hal/files/README.fuse @@ -0,0 +1,31 @@ +Mounting Fuse File Systems with HAL +----------------------------------- + +$FreeBSD$ + +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/mount-fuse b/sysutils/hal/files/mount-fuse new file mode 100755 index 000000000..d23b47141 --- /dev/null +++ b/sysutils/hal/files/mount-fuse @@ -0,0 +1,116 @@ +#!/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" +HWDEV="" +FOUNDDEV="0" + +for i in $@ +do + if [ "$FOUNDOPT" = "1" ] + then + OPTIONS="${OPTIONS} -o ${i}" + 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 [ "${i}" != "-o" ] + then + MNTSTRING="${MNTSTRING} ${i}" + fi + + fi + + if [ "${i}" = "-o" ] + then + FOUNDOPT="1" + else + FOUNDOPT="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-fdi_policy_10osvendor_10-x11-input.fdi b/sysutils/hal/files/patch-fdi_policy_10osvendor_10-x11-input.fdi index 00781db1d..f7af321c0 100644 --- a/sysutils/hal/files/patch-fdi_policy_10osvendor_10-x11-input.fdi +++ b/sysutils/hal/files/patch-fdi_policy_10osvendor_10-x11-input.fdi @@ -1,6 +1,6 @@ ---- fdi/policy/10osvendor/10-x11-input.fdi.orig 2008-09-24 14:32:26.000000000 +0100 -+++ fdi/policy/10osvendor/10-x11-input.fdi 2008-09-24 14:34:22.000000000 +0100 -@@ -1,19 +1,10 @@ +--- fdi/policy/10osvendor/10-x11-input.fdi.orig 2008-03-27 13:42:31.000000000 -0400 ++++ fdi/policy/10osvendor/10-x11-input.fdi 2008-03-27 13:48:06.000000000 -0400 +@@ -1,15 +1,6 @@ <?xml version="1.0" encoding="ISO-8859-1"?> <deviceinfo version="0.2"> <device> @@ -13,12 +13,6 @@ - </match> - </match> - -- <match key="info.capabilities" contains="input.keys"> -+ <match key="info.capabilities" contains="input.keyboard"> + <match key="info.capabilities" contains="input.keys"> <!-- 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_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-tools_hal-storage-mount.c b/sysutils/hal/files/patch-tools_hal-storage-mount.c index c270893c2..390d35111 100644 --- a/sysutils/hal/files/patch-tools_hal-storage-mount.c +++ b/sysutils/hal/files/patch-tools_hal-storage-mount.c @@ -1,11 +1,91 @@ ---- tools/hal-storage-mount.c.orig 2008-04-29 20:05:38.000000000 -0400 -+++ tools/hal-storage-mount.c 2008-04-29 20:05:44.000000000 -0400 -@@ -56,7 +56,7 @@ +--- 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/pkg-plist b/sysutils/hal/pkg-plist index 1c75cccbe..f42809179 100644 --- a/sysutils/hal/pkg-plist +++ b/sysutils/hal/pkg-plist @@ -72,6 +72,7 @@ libexec/hald-probe-volume libexec/hald-runner sbin/hald %%PORTDOCS%%%%DOCSDIR%%/README.freebsd +%%PORTDOCS%%%%DOCSDIR%%/README.fuse %%DATADIR%%/dist/hal.conf %%DATADIR%%/fdi/fdi.dtd %%DATADIR%%/fdi/information/10freedesktop/01-deprecated-keys.fdi @@ -87,6 +88,7 @@ sbin/hald %%DATADIR%%/fdi/policy/10osvendor/15-storage-luks.fdi %%DATADIR%%/fdi/policy/10osvendor/20-storage-methods.fdi %%DATADIR%%/fdi/policy/10osvendor/30-wol.fdi +%%DATADIR%%/mount-fuse share/PolicyKit/policy/org.freedesktop.hal.dockstation.policy share/PolicyKit/policy/org.freedesktop.hal.killswitch.policy share/PolicyKit/policy/org.freedesktop.hal.policy |