diff options
author | marcus <marcus@df743ca5-7f9a-e211-a948-0013205c9059> | 2008-10-09 13:12:36 +0800 |
---|---|---|
committer | marcus <marcus@df743ca5-7f9a-e211-a948-0013205c9059> | 2008-10-09 13:12:36 +0800 |
commit | 4feb891af534b0a33741b12bf2a51519a1536f7f (patch) | |
tree | bb4d15f3e82492fe375b81c388183fba21173b18 | |
parent | f98df082310f8387f0a0def3c2b474abd164b74b (diff) | |
download | marcuscom-ports-4feb891af534b0a33741b12bf2a51519a1536f7f.tar marcuscom-ports-4feb891af534b0a33741b12bf2a51519a1536f7f.tar.gz marcuscom-ports-4feb891af534b0a33741b12bf2a51519a1536f7f.tar.bz2 marcuscom-ports-4feb891af534b0a33741b12bf2a51519a1536f7f.tar.lz marcuscom-ports-4feb891af534b0a33741b12bf2a51519a1536f7f.tar.xz marcuscom-ports-4feb891af534b0a33741b12bf2a51519a1536f7f.tar.zst marcuscom-ports-4feb891af534b0a33741b12bf2a51519a1536f7f.zip |
Allow fuse mounts to work with HAL.
Tested by: Kris Moore and NTFS-3g
git-svn-id: svn://creme-brulee.marcuscom.com/ports/trunk@11673 df743ca5-7f9a-e211-a948-0013205c9059
-rw-r--r-- | sysutils/hal/Makefile | 4 | ||||
-rw-r--r-- | sysutils/hal/files/patch-hald_freebsd_hf-volume.c | 100 | ||||
-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 | 43 |
4 files changed, 228 insertions, 5 deletions
diff --git a/sysutils/hal/Makefile b/sysutils/hal/Makefile index 8aadf6d5c..61a2d6d11 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.46 2008/08/21 21:52:59 mezz Exp $ +# $MCom: ports/sysutils/hal/Makefile,v 1.47 2008/09/28 23:30:41 marcus Exp $ # PORTNAME= hal DISTVERSION= 0.5.11 -PORTREVISION= 3 +PORTREVISION= 4 CATEGORIES= sysutils MASTER_SITES= http://hal.freedesktop.org/releases/ 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..b34ee563b --- /dev/null +++ b/sysutils/hal/files/patch-hald_freebsd_hf-volume.c @@ -0,0 +1,100 @@ +--- hald/freebsd/hf-volume.c.orig 2008-05-07 19:24:03.000000000 -0400 ++++ hald/freebsd/hf-volume.c 2008-10-09 01:07:34.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,11 @@ 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); ++ } + } + + 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..9a19c9d4f --- /dev/null +++ b/sysutils/hal/files/patch-tools_hal-storage-shared.c @@ -0,0 +1,43 @@ +--- tools/hal-storage-shared.c.orig 2008-05-07 19:24:24.000000000 -0400 ++++ tools/hal-storage-shared.c 2008-10-09 01:09:33.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; ++#endif + + #ifdef DEBUG + printf ("device = %s\n", device); +@@ -473,7 +476,18 @@ line_found: + #endif + if (option_force) + args[na++] = "-f"; +- args[na++] = (char *) device; ++#ifdef __FreeBSD__ ++ dbus_error_init (&error); ++ 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 +511,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); |