[gnome-settings-daemon] housekeeping: Split "ignore unix mount" code



commit 4c7069f58b326ec55bd243ec34859756011e6f3d
Author: Bastien Nocera <hadess hadess net>
Date:   Thu Apr 19 11:47:52 2012 +0100

    housekeeping: Split "ignore unix mount" code
    
    So it can be reused in gnome-control-center.

 plugins/housekeeping/Makefile.am             |    4 +-
 plugins/housekeeping/gsd-disk-space-helper.c |  105 ++++++++++++++++++++++++++
 plugins/housekeeping/gsd-disk-space-helper.h |   38 +++++++++
 plugins/housekeeping/gsd-disk-space.c        |   95 ++---------------------
 4 files changed, 153 insertions(+), 89 deletions(-)
---
diff --git a/plugins/housekeeping/Makefile.am b/plugins/housekeeping/Makefile.am
index 5440e2d..7fa500b 100644
--- a/plugins/housekeeping/Makefile.am
+++ b/plugins/housekeeping/Makefile.am
@@ -4,7 +4,9 @@ COMMON_FILES =				\
 	gsd-disk-space.c		\
 	gsd-disk-space.h		\
 	gsd-ldsm-dialog.c		\
-	gsd-ldsm-dialog.h
+	gsd-ldsm-dialog.h		\
+	gsd-disk-space-helper.h		\
+	gsd-disk-space-helper.c
 
 noinst_PROGRAMS = gsd-disk-space-test gsd-empty-trash-test
 
diff --git a/plugins/housekeeping/gsd-disk-space-helper.c b/plugins/housekeeping/gsd-disk-space-helper.c
new file mode 100644
index 0000000..e505d48
--- /dev/null
+++ b/plugins/housekeeping/gsd-disk-space-helper.c
@@ -0,0 +1,105 @@
+/* -*- 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
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+ *
+ */
+
+#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;
+        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 */
+
+        const gchar *ignore_fs[] = {
+                "adfs",
+                "afs",
+                "auto",
+                "autofs",
+                "autofs4",
+                "cifs",
+                "cxfs",
+                "devfs",
+                "devpts",
+                "ecryptfs",
+                "fdescfs",
+                "gfs",
+                "gfs2",
+                "kernfs",
+                "linprocfs",
+                "linsysfs",
+                "lustre",
+                "lustre_lite",
+                "ncpfs",
+                "nfs",
+                "nfs4",
+                "nfsd",
+                "ocfs2",
+                "proc",
+                "procfs",
+                "ptyfs",
+                "rpc_pipefs",
+                "selinuxfs",
+                "smbfs",
+                "sysfs",
+                "tmpfs",
+                "usbfs",
+                "zfs",
+                NULL
+        };
+        const gchar *ignore_devices[] = {
+                "none",
+                "sunrpc",
+                "devpts",
+                "nfsd",
+                "/dev/loop",
+                "/dev/vn",
+                NULL
+        };
+
+        fs = g_unix_mount_get_fs_type (mount);
+        device = g_unix_mount_get_device_path (mount);
+
+        for (i = 0; ignore_fs[i] != NULL; i++)
+                if (g_str_equal (ignore_fs[i], fs))
+                        return TRUE;
+
+        for (i = 0; ignore_devices[i] != NULL; i++)
+                if (g_str_equal (ignore_devices[i], device))
+                        return TRUE;
+
+        return FALSE;
+}
diff --git a/plugins/housekeeping/gsd-disk-space-helper.h b/plugins/housekeeping/gsd-disk-space-helper.h
new file mode 100644
index 0000000..99c16eb
--- /dev/null
+++ b/plugins/housekeeping/gsd-disk-space-helper.h
@@ -0,0 +1,38 @@
+/* -*- 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
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+ *
+ */
+
+#ifndef __GSD_DISK_SPACE_HELPER_H
+#define __GSD_DISK_SPACE_HELPER_H
+
+#include <glib.h>
+#include <gio/gunixmounts.h>
+
+G_BEGIN_DECLS
+
+gboolean gsd_should_ignore_unix_mount (GUnixMountEntry *mount);
+
+G_END_DECLS
+
+#endif /* __GSD_DISK_SPACE_HELPER_H */
diff --git a/plugins/housekeeping/gsd-disk-space.c b/plugins/housekeeping/gsd-disk-space.c
index 0fd733c..ee7e2fd 100644
--- a/plugins/housekeeping/gsd-disk-space.c
+++ b/plugins/housekeeping/gsd-disk-space.c
@@ -37,6 +37,7 @@
 
 #include "gsd-disk-space.h"
 #include "gsd-ldsm-dialog.h"
+#include "gsd-disk-space-helper.h"
 
 #define GIGABYTE                   1024 * 1024 * 1024
 
@@ -479,93 +480,6 @@ ldsm_mount_is_user_ignore (const gchar *path)
 }                
 
 
-static gboolean
-is_in (const gchar *value, const gchar *set[])
-{
-        int i;
-        for (i = 0; set[i] != NULL; i++)
-        {
-              if (strcmp (set[i], value) == 0)
-                return TRUE;
-        }
-        return FALSE;
-}
-
-static gboolean
-ldsm_mount_should_ignore (GUnixMountEntry *mount)
-{
-        const gchar *fs, *device, *path;
-        
-        path = g_unix_mount_get_mount_path (mount);
-        if (ldsm_mount_is_user_ignore (path))
-                return TRUE;
-        
-        /* 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 */
-                 
-        const gchar *ignore_fs[] = {
-                "adfs",
-                "afs",
-                "auto",
-                "autofs",
-                "autofs4",
-                "cifs",
-                "cxfs",
-                "devfs",
-                "devpts",
-                "ecryptfs",
-                "fdescfs",
-                "gfs",
-                "gfs2",
-                "kernfs",
-                "linprocfs",
-                "linsysfs",
-                "lustre",
-                "lustre_lite",
-                "ncpfs",
-                "nfs",
-                "nfs4",
-                "nfsd",
-                "ocfs2",
-                "proc",
-                "procfs",
-                "ptyfs",
-                "rpc_pipefs",
-                "selinuxfs",
-                "smbfs",
-                "sysfs",
-                "tmpfs",
-                "usbfs",
-                "zfs",
-                NULL
-        };
-        const gchar *ignore_devices[] = {
-                "none",
-                "sunrpc",
-                "devpts",
-                "nfsd",
-                "/dev/loop",
-                "/dev/vn",
-                NULL
-        };
-        
-        fs = g_unix_mount_get_fs_type (mount);
-        device = g_unix_mount_get_device_path (mount);
-        
-        if (is_in (fs, ignore_fs))
-                return TRUE;
-  
-        if (is_in (device, ignore_devices))
-                return TRUE;
-
-        return FALSE;
-}
-
 static void
 ldsm_free_mount_info (gpointer data)
 {
@@ -685,7 +599,12 @@ ldsm_check_all_mounts (gpointer data)
                         continue;
                 }
 
-                if (ldsm_mount_should_ignore (mount)) {
+                if (ldsm_mount_is_user_ignore (g_unix_mount_get_mount_path (mount))) {
+                        ldsm_free_mount_info (mount_info);
+                        continue;
+                }
+
+                if (gsd_should_ignore_unix_mount (mount)) {
                         ldsm_free_mount_info (mount_info);
                         continue;
                 }



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]