2012-04-19 11:58:29 +01:00
|
|
|
/* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 8 -*-
|
|
|
|
* vim: set et sw=8 ts=8:
|
|
|
|
*
|
|
|
|
* Copyright (c) 2008, Novell, Inc.
|
|
|
|
* Copyright (c) 2012, Red Hat, Inc.
|
|
|
|
*
|
|
|
|
* Authors: Vincent Untz <vuntz@gnome.org>
|
|
|
|
* Bastien Nocera <hadess@hadess.net>
|
|
|
|
*
|
|
|
|
* This program is free software; you can redistribute it and/or modify
|
|
|
|
* it under the terms of the GNU General Public License as published by
|
|
|
|
* the Free Software Foundation; either version 2 of the License, or
|
|
|
|
* (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License
|
2014-01-23 12:57:27 +01:00
|
|
|
* along with this program; if not, see <http://www.gnu.org/licenses/>.
|
2012-04-19 11:58:29 +01:00
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include "config.h"
|
|
|
|
|
|
|
|
#include <glib.h>
|
|
|
|
#include <gio/gio.h>
|
|
|
|
|
|
|
|
#include "gsd-disk-space-helper.h"
|
|
|
|
|
|
|
|
gboolean
|
|
|
|
gsd_should_ignore_unix_mount (GUnixMountEntry *mount)
|
|
|
|
{
|
|
|
|
const char *fs, *device;
|
2018-06-20 12:12:34 +01:00
|
|
|
g_autofree char *label = NULL;
|
2012-04-19 11:58:29 +01:00
|
|
|
guint i;
|
|
|
|
|
|
|
|
/* This is borrowed from GLib and used as a way to determine
|
|
|
|
* which mounts we should ignore by default. GLib doesn't
|
|
|
|
* expose this in a way that allows it to be used for this
|
|
|
|
* purpose
|
|
|
|
*/
|
|
|
|
|
|
|
|
/* We also ignore network filesystems */
|
2018-06-20 12:12:34 +01:00
|
|
|
#if !GLIB_CHECK_VERSION(2, 56, 0)
|
2012-04-19 11:58:29 +01:00
|
|
|
const gchar *ignore_fs[] = {
|
|
|
|
"adfs",
|
|
|
|
"afs",
|
|
|
|
"auto",
|
|
|
|
"autofs",
|
|
|
|
"autofs4",
|
2017-10-12 14:46:27 +01:00
|
|
|
"cgroup",
|
|
|
|
"configfs",
|
2012-04-19 11:58:29 +01:00
|
|
|
"cxfs",
|
2017-10-12 14:46:27 +01:00
|
|
|
"debugfs",
|
2012-04-19 11:58:29 +01:00
|
|
|
"devfs",
|
|
|
|
"devpts",
|
2017-10-12 14:46:27 +01:00
|
|
|
"devtmpfs",
|
2012-04-19 11:58:29 +01:00
|
|
|
"ecryptfs",
|
|
|
|
"fdescfs",
|
2017-10-12 14:46:27 +01:00
|
|
|
"fusectl",
|
2012-04-19 11:58:29 +01:00
|
|
|
"gfs",
|
|
|
|
"gfs2",
|
2017-04-29 14:30:32 +02:00
|
|
|
"gpfs",
|
2017-10-12 14:46:27 +01:00
|
|
|
"hugetlbfs",
|
2012-04-19 11:58:29 +01:00
|
|
|
"kernfs",
|
|
|
|
"linprocfs",
|
|
|
|
"linsysfs",
|
|
|
|
"lustre",
|
|
|
|
"lustre_lite",
|
2017-10-12 14:46:27 +01:00
|
|
|
"mfs",
|
|
|
|
"mqueue",
|
2012-04-19 11:58:29 +01:00
|
|
|
"ncpfs",
|
|
|
|
"nfsd",
|
2017-10-12 14:46:27 +01:00
|
|
|
"nullfs",
|
2012-04-19 11:58:29 +01:00
|
|
|
"ocfs2",
|
2017-10-12 14:46:27 +01:00
|
|
|
"overlay",
|
2012-04-19 11:58:29 +01:00
|
|
|
"proc",
|
|
|
|
"procfs",
|
2017-10-12 14:46:27 +01:00
|
|
|
"pstore",
|
2012-04-19 11:58:29 +01:00
|
|
|
"ptyfs",
|
2013-07-22 16:15:57 -03:00
|
|
|
"rootfs",
|
2012-04-19 11:58:29 +01:00
|
|
|
"rpc_pipefs",
|
2017-10-12 14:46:27 +01:00
|
|
|
"securityfs",
|
2012-04-19 11:58:29 +01:00
|
|
|
"selinuxfs",
|
|
|
|
"sysfs",
|
|
|
|
"tmpfs",
|
|
|
|
"usbfs",
|
|
|
|
"zfs",
|
|
|
|
NULL
|
|
|
|
};
|
2018-06-20 12:12:34 +01:00
|
|
|
#endif /* GLIB < 2.56.0 */
|
|
|
|
const gchar *ignore_network_fs[] = {
|
|
|
|
"cifs",
|
|
|
|
"nfs",
|
|
|
|
"nfs4",
|
|
|
|
"smbfs",
|
|
|
|
NULL
|
|
|
|
};
|
2012-04-19 11:58:29 +01:00
|
|
|
const gchar *ignore_devices[] = {
|
|
|
|
"none",
|
|
|
|
"sunrpc",
|
|
|
|
"devpts",
|
|
|
|
"nfsd",
|
|
|
|
"/dev/loop",
|
|
|
|
"/dev/vn",
|
|
|
|
NULL
|
|
|
|
};
|
2018-06-20 12:12:34 +01:00
|
|
|
const gchar *ignore_labels[] = {
|
|
|
|
"RETRODE",
|
|
|
|
NULL
|
|
|
|
};
|
2012-04-19 11:58:29 +01:00
|
|
|
|
|
|
|
fs = g_unix_mount_get_fs_type (mount);
|
2018-06-20 12:12:34 +01:00
|
|
|
#if GLIB_CHECK_VERSION(2, 56, 0)
|
|
|
|
if (g_unix_is_system_fs_type (fs))
|
|
|
|
return TRUE;
|
|
|
|
#else
|
2012-04-19 11:58:29 +01:00
|
|
|
for (i = 0; ignore_fs[i] != NULL; i++)
|
|
|
|
if (g_str_equal (ignore_fs[i], fs))
|
|
|
|
return TRUE;
|
2018-06-20 12:12:34 +01:00
|
|
|
#endif
|
|
|
|
for (i = 0; ignore_network_fs[i] != NULL; i++)
|
|
|
|
if (g_str_equal (ignore_network_fs[i], fs))
|
|
|
|
return TRUE;
|
2012-04-19 11:58:29 +01:00
|
|
|
|
2018-06-20 12:12:34 +01:00
|
|
|
device = g_unix_mount_get_device_path (mount);
|
2012-04-19 11:58:29 +01:00
|
|
|
for (i = 0; ignore_devices[i] != NULL; i++)
|
|
|
|
if (g_str_equal (ignore_devices[i], device))
|
|
|
|
return TRUE;
|
|
|
|
|
2018-06-20 12:12:34 +01:00
|
|
|
label = g_unix_mount_guess_name (mount);
|
|
|
|
for (i = 0; ignore_labels[i] != NULL; i++)
|
|
|
|
if (g_str_equal (ignore_labels[i], label))
|
|
|
|
return TRUE;
|
|
|
|
|
2012-04-19 11:58:29 +01:00
|
|
|
return FALSE;
|
|
|
|
}
|
2012-04-19 14:25:55 +01:00
|
|
|
|
|
|
|
gboolean
|
|
|
|
gsd_is_removable_mount (GUnixMountEntry *mount)
|
|
|
|
{
|
|
|
|
const char *mount_path;
|
2017-09-25 16:52:58 -04:00
|
|
|
g_autofree gchar *path = NULL;
|
2012-04-19 14:25:55 +01:00
|
|
|
|
|
|
|
mount_path = g_unix_mount_get_mount_path (mount);
|
|
|
|
if (mount_path == NULL)
|
|
|
|
return FALSE;
|
|
|
|
|
|
|
|
path = g_strdup_printf ("/run/media/%s", g_get_user_name ());
|
2017-09-25 16:52:58 -04:00
|
|
|
if (g_str_has_prefix (mount_path, path))
|
2012-04-19 14:25:55 +01:00
|
|
|
return TRUE;
|
2017-09-25 16:52:58 -04:00
|
|
|
|
2012-04-19 14:25:55 +01:00
|
|
|
return FALSE;
|
|
|
|
}
|