1 --- ./exo-mount/Makefile.am.orig 2009-03-15 01:38:29.000000000 +1000
2 +++ ./exo-mount/Makefile.am 2009-03-15 01:39:18.000000000 +1000
4 -DG_LOG_DOMAIN=\"exo-mount\" \
5 -DLIBEXECDIR=\"$(libexecdir)\" \
6 -DLIBEXO_VERSION_API=\"$(LIBEXO_VERSION_API)\" \
7 - -DPACKAGE_LOCALE_DIR=\"$(localedir)\"
8 + -DPACKAGE_LOCALE_DIR=\"$(localedir)\" \
9 + -DDATADIR=\"$(datadir)\"
13 --- ./exo-mount/Makefile.in.orig 2009-03-15 01:38:21.000000000 +1000
14 +++ ./exo-mount/Makefile.in 2009-03-15 01:40:11.000000000 +1000
16 -DG_LOG_DOMAIN=\"exo-mount\" \
17 -DLIBEXECDIR=\"$(libexecdir)\" \
18 -DLIBEXO_VERSION_API=\"$(LIBEXO_VERSION_API)\" \
19 - -DPACKAGE_LOCALE_DIR=\"$(localedir)\"
20 + -DPACKAGE_LOCALE_DIR=\"$(localedir)\" \
21 + -DDATADIR=\"$(datadir)\"
23 exo_mount_SOURCES = exo-mount-fstab.c exo-mount-fstab.h \
24 exo-mount-utils.c exo-mount-utils.h main.c $(am__append_1)
26 echo " rm -f $$p $$f"; \
29 -exo-mount$(EXEEXT): $(exo_mount_OBJECTS) $(exo_mount_DEPENDENCIES)
30 +exo-mount$(EXEEXT): $(exo_mount_OBJECTS) $(exo_mount_DEPENDENCIES)
31 @rm -f exo-mount$(EXEEXT)
32 $(exo_mount_LINK) $(exo_mount_OBJECTS) $(exo_mount_LDADD) $(LIBS)
34 --- ./exo-mount/exo-mount-hal.c.orig 2009-03-15 00:54:02.000000000 +1000
35 +++ ./exo-mount/exo-mount-hal.c 2009-03-15 20:06:31.000000000 +1000
38 #include <exo-mount/exo-mount-hal.h>
41 +#define CONFIG_FILE_GLOBAL DATADIR "/xfce4/mount.rules"
43 static gboolean exo_mount_hal_init (GError **error);
44 static void exo_mount_hal_propagate_error (GError **error,
46 LibHalVolumeUsage fsusage;
49 +typedef struct _ExoVolumeOptions
51 + char** mount_options;
52 + char* fstype_override;
56 static LibHalContext *hal_context = NULL;
57 static DBusConnection *dbus_connection = NULL;
60 +static gboolean exo_volume_hal_get_options( const char* fs, ExoVolumeOptions* ret );
63 exo_mount_hal_init (GError **error)
68 + ExoVolumeOptions opts;
70 g_return_val_if_fail (device != NULL, FALSE);
71 g_return_val_if_fail (error == NULL || *error == NULL, FALSE);
73 - /* determine the required mount options */
74 - options = g_new0 (gchar *, 20);
76 - /* check if we know any valid mount options */
77 - if (G_LIKELY (device->fsoptions != NULL))
78 + /* get mount options set by pcmanfm first */
79 + if( exo_volume_hal_get_options( device->fstype, &opts ) )
81 - /* process all valid mount options */
82 - for (m = 0; device->fsoptions[m] != NULL; ++m)
84 - /* this is currently mostly Linux specific noise */
85 - if (strcmp (device->fsoptions[m], "uid=") == 0
86 - && (strcmp (device->fstype, "vfat") == 0
87 - || strcmp (device->fstype, "iso9660") == 0
88 - || strcmp (device->fstype, "udf") == 0
89 - || device->volume == NULL))
91 - options[n++] = g_strdup_printf ("uid=%u", (guint) getuid ());
93 - else if (strcmp (device->fsoptions[m], "shortname=") == 0
94 - && strcmp (device->fstype, "vfat") == 0)
96 - options[n++] = g_strdup_printf ("shortname=winnt");
98 - else if (strcmp (device->fsoptions[m], "sync") == 0
99 - && device->volume == NULL)
100 + char** popts = opts.mount_options;
101 + n = g_strv_length( popts );
105 + /* We have to allocate a new larger array bacause we might need to
106 + * append new options to the array later */
107 + options = g_new0 (gchar *, n + 4);
108 + for( i = 0; i < n; ++i )
110 - /* non-pollable drive... */
111 - options[n++] = g_strdup ("sync");
112 + options[i] = popts[i];
114 + /* steal the string */
116 - else if (strcmp (device->fsoptions[m], "longnames") == 0
117 - && strcmp (device->fstype, "vfat") == 0)
118 + /* the strings in the array are already stolen, so strfreev is not needed. */
120 + g_free( opts.mount_options );
122 + fstype = opts.fstype_override;
125 + if( G_UNLIKELY( ! options ) )
127 + /* determine the required mount options */
128 + options = g_new0 (gchar *, 20);
130 + /* check if we know any valid mount options */
131 + if (G_LIKELY (device->fsoptions != NULL))
133 + /* process all valid mount options */
134 + for (m = 0; device->fsoptions[m] != NULL; ++m)
136 - /* however this one is FreeBSD specific */
137 - options[n++] = g_strdup ("longnames");
138 + /* this is currently mostly Linux specific noise */
139 + if (strcmp (device->fsoptions[m], "uid=") == 0
140 + && (strcmp (device->fstype, "vfat") == 0
141 + || strcmp (device->fstype, "iso9660") == 0
142 + || strcmp (device->fstype, "udf") == 0
143 + || device->volume == NULL))
145 + options[n++] = g_strdup_printf ("uid=%u", (guint) getuid ());
147 + else if (strcmp (device->fsoptions[m], "shortname=") == 0
148 + && strcmp (device->fstype, "vfat") == 0)
150 + options[n++] = g_strdup_printf ("shortname=winnt");
152 + else if (strcmp (device->fsoptions[m], "sync") == 0
153 + && device->volume == NULL)
155 + /* non-pollable drive... */
156 + options[n++] = g_strdup ("sync");
158 + else if (strcmp (device->fsoptions[m], "longnames") == 0
159 + && strcmp (device->fstype, "vfat") == 0)
161 + /* however this one is FreeBSD specific */
162 + options[n++] = g_strdup ("longnames");
164 + else if (strcmp (device->fsoptions[m], "locale=") == 0
165 + && strcmp (device->fstype, "ntfs-3g") == 0)
167 + options[n++] = g_strdup_printf ("locale=%s", setlocale (LC_ALL, ""));
173 /* try to determine a usable mount point */
174 if (G_LIKELY (device->volume != NULL))
178 /* make sure that the mount point is usable (i.e. does not contain G_DIR_SEPARATOR's) */
179 mount_point = (mount_point != NULL && *mount_point != '\0')
180 - ? exo_str_replace (mount_point, G_DIR_SEPARATOR_S, "_")
181 + ? exo_str_replace (mount_point, G_DIR_SEPARATOR_S, "_")
184 /* let HAL guess the fstype */
186 if (dbus_error_is_set (&derror))
188 /* try to translate the error appropriately */
189 - if (strcmp (derror.name, "org.freedesktop.Hal.Device.Volume.PermissionDenied") == 0)
190 + if (strcmp (derror.name, "org.freedesktop.Hal.Device.Volume.PermissionDenied") == 0)
192 /* TRANSLATORS: User tried to mount a volume, but is not privileged to do so. */
193 g_set_error (error, G_FILE_ERROR, G_FILE_ERROR_FAILED, _("You are not privileged to mount the volume \"%s\""), device->name);
194 @@ -1015,7 +1052,7 @@
195 if (G_UNLIKELY (dbus_error_is_set (&derror)))
197 /* try to translate the error appropriately */
198 - if (strcmp (derror.name, "org.freedesktop.Hal.Device.Volume.PermissionDenied") == 0)
199 + if (strcmp (derror.name, "org.freedesktop.Hal.Device.Volume.PermissionDenied") == 0)
201 /* TRANSLATORS: User tried to unmount a volume, but is not privileged to do so. */
202 g_set_error (error, G_FILE_ERROR, G_FILE_ERROR_FAILED, _("You are not privileged to unmount the volume \"%s\""), device->name);
203 @@ -1055,3 +1092,76 @@
208 + * exo_volume_hal_get_options:
209 + * @fs : files system name.
210 + * @ret : an #ExoVolumeOptions.
212 + * return mount options for specified file sytem or
213 + * override file system name. If options not found return %NULL
215 + * code taked from PCManFM project.
217 + * Return value: %TRUE if options is found or %FALSE if not.
220 +exo_volume_hal_get_options (const char* fs,
221 + ExoVolumeOptions* ret)
224 + const gchar* user_opts = g_strconcat(g_getenv("HOME"), "/.config/xfce4/mount.rules", NULL);
225 + gboolean is_options_read = FALSE;
226 + if( fs == NULL || ! *fs)
228 + g_return_val_if_fail( ret != NULL, FALSE );
230 + printf("Global config: %s\n", CONFIG_FILE_GLOBAL);
232 + f = g_key_file_new();
233 + if( g_key_file_load_from_file( f, user_opts, 0, NULL ))
235 + printf("User's mount options is readed\n");
236 + is_options_read = TRUE;
238 + else if( g_key_file_load_from_file( f, CONFIG_FILE_GLOBAL, 0, NULL) )
240 + printf("Global mount options is readed\n");
241 + is_options_read = TRUE;
244 + if(is_options_read == TRUE)
248 + ret->mount_options = g_key_file_get_string_list( f, fs, "mount_options", &n, NULL );
249 + ret->fstype_override = g_key_file_get_string(f, fs, "fstype_override", NULL );
251 + for( i = 0; i < n; ++i )
253 + /* replace "uid=" with "uid=<actual uid>" */
255 + if (strcmp (ret->mount_options[i], "uid=") == 0) {
256 + g_free (ret->mount_options[i]);
257 + ret->mount_options[i] = g_strdup_printf ("uid=%u", getuid ());
260 + if (strcmp (ret->mount_options[i], "-u=") == 0) {
261 + g_free (ret->mount_options[i]);
262 + ret->mount_options[i] = g_strdup_printf ("-u=%u", getuid ());
266 + if (strcmp (ret->mount_options[i], "locale=") == 0) {
267 + g_free (ret->mount_options[i]);
268 + ret->mount_options[i] = g_strdup_printf ("locale=%s", setlocale (LC_ALL, ""));
274 + ret->mount_options = NULL;
275 + ret->fstype_override = NULL;
277 + g_key_file_free(f);
278 + return (ret->mount_options || ret->fstype_override);