5
#include "vfs-volume-hal-options.h"
8
#include <unistd.h> /* for getuid() */
11
#include <locale.h> /* for setlocale() */
13
#define CONFIG_FILE PACKAGE_DATA_DIR "/mount.rules"
15
gboolean vfs_volume_hal_get_options( const char* fs, VFSVolumeOptions* ret )
18
if( fs == NULL || ! *fs)
20
g_return_val_if_fail( ret != NULL, FALSE );
23
if( g_key_file_load_from_file( f, CONFIG_FILE, 0, NULL) )
27
ret->mount_options = g_key_file_get_string_list( f, fs, "mount_options", &n, NULL );
28
ret->fstype_override = g_key_file_get_string(f, fs, "fstype_override", NULL );
30
for( i = 0; i < n; ++i )
32
/* replace "uid=" with "uid=<actual uid>" */
34
if (strcmp (ret->mount_options[i], "uid=") == 0) {
35
g_free (ret->mount_options[i]);
36
ret->mount_options[i] = g_strdup_printf ("uid=%u", getuid ());
39
if (strcmp (ret->mount_options[i], "-u=") == 0) {
40
g_free (ret->mount_options[i]);
41
ret->mount_options[i] = g_strdup_printf ("-u=%u", getuid ());
45
if (strcmp (ret->mount_options[i], "locale=") == 0) {
46
g_free (ret->mount_options[i]);
47
ret->mount_options[i] = g_strdup_printf ("locale=%s", setlocale (LC_ALL, ""));
53
ret->mount_options = NULL;
54
ret->fstype_override = NULL;
57
return (ret->mount_options || ret->fstype_override);