1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
|
--- hald/freebsd/hf-volume.c.orig 2008-08-10 09:50:10.000000000 -0400
+++ hald/freebsd/hf-volume.c 2009-09-19 02:06:37.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,58 @@ 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)
+ {
+ char *ret;
+
+ ret = g_strdup(fields[1]);
+ g_strfreev(fields);
+ g_strfreev(lines);
+ return ret;
+ }
+ }
+ 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 +124,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 +155,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);
|