summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJoe Marcus Clarke <marcus@FreeBSD.org>2009-08-18 13:07:20 -0400
committerJoe Marcus Clarke <marcus@FreeBSD.org>2009-08-18 13:07:20 -0400
commit0cc145355e980d62ebe81a6c6075a534308a0479 (patch)
tree416cb01dfdfc42bb91b0d334b7597a21b80a9e0e
parent4d92b1ca4f9343d62641c37f366e46e900a3aed3 (diff)
add support for Fuse mounts
Add support for mounting Fuse volumes in the FreeBSD backend.
-rw-r--r--hald/freebsd/hf-volume.c72
1 files changed, 69 insertions, 3 deletions
diff --git a/hald/freebsd/hf-volume.c b/hald/freebsd/hf-volume.c
index 3512a8aa..249d2bd1 100644
--- a/hald/freebsd/hf-volume.c
+++ b/hald/freebsd/hf-volume.c
@@ -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 **mounts, int *n_mounts)
}
}
+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 statfs *mounts,
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 (HalDevice *device,
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);