~ubuntu-branches/ubuntu/utopic/pcmanfm/utopic

« back to all changes in this revision

Viewing changes to src/vfs/vfs-volume-hal-options.c

  • Committer: Bazaar Package Importer
  • Author(s): Andrew Lee (李健秋)
  • Date: 2010-05-23 23:04:11 UTC
  • mfrom: (8.1.1 experimental)
  • Revision ID: james.westby@ubuntu.com-20100523230411-4ei3g4u14pf5rozb
Tags: 0.9.5-2
* Upload to sid. No new additional bug report since last upload into 
  experimental. (Closes:#506243, #509257, #532973, #502225, #535810, 
  #570114, #581033, #518683)
* debian/control:
  Adjusted depends/recommends for people who doesn't want to have gvfs
  on their system. Without gvfs installed, pcmanfm would still works 
  but lose volume management and trashcan support.
  - Drop depends on gamin, shared-mime-info, desktop-file-utils, dbus, 
    xdg-user-dirs
  - Recommends on lxde-icon-theme | gnome-icon-theme, gvfs-backends,
    gvfs-fuse

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
#ifdef HAVE_CONFIG_H
2
 
#include <config.h>
3
 
#endif
4
 
 
5
 
#include "vfs-volume-hal-options.h"
6
 
 
7
 
#include <string.h>
8
 
#include <unistd.h> /* for getuid() */
9
 
#include <sys/types.h>
10
 
 
11
 
#include <locale.h> /* for setlocale() */
12
 
 
13
 
#define CONFIG_FILE     PACKAGE_DATA_DIR "/mount.rules"
14
 
 
15
 
gboolean vfs_volume_hal_get_options( const char* fs, VFSVolumeOptions* ret )
16
 
{
17
 
    GKeyFile* f;
18
 
    if( fs == NULL || ! *fs)
19
 
        return FALSE;
20
 
    g_return_val_if_fail( ret != NULL, FALSE );
21
 
 
22
 
    f = g_key_file_new();
23
 
    if( g_key_file_load_from_file( f, CONFIG_FILE, 0, NULL) )
24
 
    {
25
 
        gsize n = 0;
26
 
        int i;
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 );
29
 
 
30
 
        for( i = 0; i < n; ++i )
31
 
        {
32
 
            /* replace "uid=" with "uid=<actual uid>" */
33
 
#ifndef __FreeBSD__
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 ());
37
 
            }
38
 
#else
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 ());
42
 
            }
43
 
#endif
44
 
            /* for ntfs-3g */
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, ""));
48
 
            }
49
 
        }
50
 
    }
51
 
    else
52
 
    {
53
 
        ret->mount_options = NULL;
54
 
        ret->fstype_override = NULL;
55
 
    }
56
 
    g_key_file_free(f);
57
 
    return (ret->mount_options || ret->fstype_override);
58
 
}