~ctf/unity-settings-daemon/bug1389099_mic_volume_icons

« back to all changes in this revision

Viewing changes to plugins/housekeeping/gsd-disk-space-helper.c

  • Committer: Package Import Robot
  • Author(s): Robert Ancell
  • Date: 2014-02-07 11:44:36 UTC
  • Revision ID: package-import@ubuntu.com-20140207114436-7t5u3yvwc4ul7w3e
Tags: upstream-14.04.0
ImportĀ upstreamĀ versionĀ 14.04.0

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 8 -*-
 
2
 * vim: set et sw=8 ts=8:
 
3
 *
 
4
 * Copyright (c) 2008, Novell, Inc.
 
5
 * Copyright (c) 2012, Red Hat, Inc.
 
6
 *
 
7
 * Authors: Vincent Untz <vuntz@gnome.org>
 
8
 * Bastien Nocera <hadess@hadess.net>
 
9
 *
 
10
 * This program is free software; you can redistribute it and/or modify
 
11
 * it under the terms of the GNU General Public License as published by
 
12
 * the Free Software Foundation; either version 2 of the License, or
 
13
 * (at your option) any later version.
 
14
 *
 
15
 * This program is distributed in the hope that it will be useful,
 
16
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 
17
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 
18
 * GNU General Public License for more details.
 
19
 *
 
20
 * You should have received a copy of the GNU General Public License
 
21
 * along with this program; if not, write to the Free Software
 
22
 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
 
23
 *
 
24
 */
 
25
 
 
26
#include "config.h"
 
27
 
 
28
#include <glib.h>
 
29
#include <gio/gio.h>
 
30
 
 
31
#include "gsd-disk-space-helper.h"
 
32
 
 
33
gboolean
 
34
gsd_should_ignore_unix_mount (GUnixMountEntry *mount)
 
35
{
 
36
        const char *fs, *device;
 
37
        guint i;
 
38
 
 
39
        /* This is borrowed from GLib and used as a way to determine
 
40
         * which mounts we should ignore by default. GLib doesn't
 
41
         * expose this in a way that allows it to be used for this
 
42
         * purpose
 
43
         */
 
44
 
 
45
         /* We also ignore network filesystems */
 
46
 
 
47
        const gchar *ignore_fs[] = {
 
48
                "adfs",
 
49
                "afs",
 
50
                "auto",
 
51
                "autofs",
 
52
                "autofs4",
 
53
                "cifs",
 
54
                "cxfs",
 
55
                "devfs",
 
56
                "devpts",
 
57
                "ecryptfs",
 
58
                "fdescfs",
 
59
                "gfs",
 
60
                "gfs2",
 
61
                "kernfs",
 
62
                "linprocfs",
 
63
                "linsysfs",
 
64
                "lustre",
 
65
                "lustre_lite",
 
66
                "ncpfs",
 
67
                "nfs",
 
68
                "nfs4",
 
69
                "nfsd",
 
70
                "ocfs2",
 
71
                "proc",
 
72
                "procfs",
 
73
                "ptyfs",
 
74
                "rpc_pipefs",
 
75
                "selinuxfs",
 
76
                "smbfs",
 
77
                "sysfs",
 
78
                "tmpfs",
 
79
                "usbfs",
 
80
                "zfs",
 
81
                NULL
 
82
        };
 
83
        const gchar *ignore_devices[] = {
 
84
                "none",
 
85
                "sunrpc",
 
86
                "devpts",
 
87
                "nfsd",
 
88
                "/dev/loop",
 
89
                "/dev/vn",
 
90
                NULL
 
91
        };
 
92
 
 
93
        fs = g_unix_mount_get_fs_type (mount);
 
94
        device = g_unix_mount_get_device_path (mount);
 
95
 
 
96
        for (i = 0; ignore_fs[i] != NULL; i++)
 
97
                if (g_str_equal (ignore_fs[i], fs))
 
98
                        return TRUE;
 
99
 
 
100
        for (i = 0; ignore_devices[i] != NULL; i++)
 
101
                if (g_str_equal (ignore_devices[i], device))
 
102
                        return TRUE;
 
103
 
 
104
        return FALSE;
 
105
}
 
106
 
 
107
gboolean
 
108
gsd_is_removable_mount (GUnixMountEntry *mount)
 
109
{
 
110
        const char *mount_path;
 
111
        char *path;
 
112
 
 
113
        mount_path = g_unix_mount_get_mount_path (mount);
 
114
        if (mount_path == NULL)
 
115
                return FALSE;
 
116
 
 
117
        path = g_strdup_printf ("/run/media/%s", g_get_user_name ());
 
118
        if (g_str_has_prefix (mount_path, path)) {
 
119
                g_free (path);
 
120
                return TRUE;
 
121
        }
 
122
        g_free (path);
 
123
        return FALSE;
 
124
}