Commit c33b2eed authored by Jannis Pohlmann's avatar Jannis Pohlmann

* configure.in.in, thunar-vfs/thunar-vfs-monitor.c: Add HAVE_LINUX

	  define to config.h and implement support for excluding certain base
	  paths (such as /dev and /proc) from being being monitored. Gamin
	  does the same but only for dnotify and inotify, not for polling.

(Old svn revision: 28928)
parent 17f0b11b
2008-11-27 Jannis Pohlmann <jannis@xfce.org>
* configure.in.in, thunar-vfs/thunar-vfs-monitor.c: Add HAVE_LINUX
define to config.h and implement support for excluding certain base
paths (such as /dev and /proc) from being being monitored. Gamin
does the same but only for dnotify and inotify, not for polling.
2008-11-26 Nick Schermer <nick@xfce.org>
* thunar/thunar-application.c: Create a new window group for
......
......@@ -49,6 +49,10 @@ AC_AIX()
AC_ISC_POSIX()
AC_MINIX()
if test "x$target_os" = "xlinux-gnu"; then
AC_DEFINE([HAVE_LINUX], [], [Whether we are building on Linux or not])
fi
dnl ********************************
dnl *** Check for basic programs ***
dnl ********************************
......
......@@ -73,6 +73,8 @@ static gboolean thunar_vfs_monitor_fam_watch (GIOChannel *
GIOCondition condition,
gpointer user_data);
#endif
static gboolean thunar_vfs_monitor_is_excluded_path (ThunarVfsMonitor *monitor,
ThunarVfsPath *path);
......@@ -102,6 +104,9 @@ struct _ThunarVfsMonitor
FAMConnection fc;
gint fc_watch_id;
#endif
/* Excluded paths */
GList *excluded_paths;
};
struct _ThunarVfsMonitorHandle
......@@ -134,6 +139,15 @@ struct _ThunarVfsMonitorNotification
static GObjectClass *thunar_vfs_monitor_parent_class;
static const gchar *excluded_paths[] =
{
#ifdef HAVE_LINUX
"/proc/*",
"/dev/*",
#endif
NULL
};
GType
......@@ -174,10 +188,17 @@ thunar_vfs_monitor_class_init (ThunarVfsMonitorClass *klass)
static void
thunar_vfs_monitor_init (ThunarVfsMonitor *monitor)
{
gint i;
/* initialize the monitor */
monitor->cond = g_cond_new ();
monitor->lock = g_mutex_new ();
/* Generate pattern specs for excluded paths */
monitor->excluded_paths = NULL;
for (i = 0; excluded_paths[i] != NULL; ++i)
monitor->excluded_paths = g_list_append (monitor->excluded_paths, g_pattern_spec_new (excluded_paths[i]));
#ifdef HAVE_LIBFAM
if (FAMOpen2 (&monitor->fc, PACKAGE_NAME) == 0)
{
......@@ -214,6 +235,9 @@ thunar_vfs_monitor_finalize (GObject *object)
thunar_vfs_monitor_fam_cancel (monitor);
#endif
/* drop excluded path patterns */
g_list_foreach (monitor->excluded_paths, (GFunc) g_pattern_spec_free, NULL);
/* drop the notifications timer source */
if (G_UNLIKELY (monitor->notifications_timer_id != 0))
g_source_remove (monitor->notifications_timer_id);
......@@ -491,6 +515,53 @@ thunar_vfs_monitor_fam_watch (GIOChannel *channel,
/**
* thunar_vfs_monitor_is_excluded_path:
* @monitor : a #ThunarVfsMonitor.
* @path : a #ThunarVfsPath
*
* Checks whether the path is among the paths to be excluded from
* monitoring.
*
* Return value: %TRUE if @path should be excluded from monitoring,
* %FALSE otherwise.
**/
static gboolean
thunar_vfs_monitor_is_excluded_path (ThunarVfsMonitor *monitor,
ThunarVfsPath *path)
{
GList *iter;
gboolean excluded = FALSE;
gchar *path_string;
gint length;
_thunar_vfs_return_val_if_fail (THUNAR_VFS_IS_MONITOR (monitor), TRUE);
_thunar_vfs_return_val_if_fail (path != NULL, TRUE);
/* Turn path into a string */
path_string = thunar_vfs_path_dup_string (path);
if (G_LIKELY (path_string != NULL))
{
length = strlen (path_string);
/* Match path against all exclude patterns. Return TRUE if it matches at
* least one of these patterns */
for (iter = g_list_first (monitor->excluded_paths); iter != NULL; iter = g_list_next (iter))
if (g_pattern_match (iter->data, length, path_string, NULL))
{
excluded = TRUE;
break;
}
g_free (path_string);
}
return excluded;
}
/**
* thunar_vfs_monitor_get_default:
*
......@@ -540,6 +611,9 @@ thunar_vfs_monitor_add_directory (ThunarVfsMonitor *monitor,
g_return_val_if_fail (callback != NULL, NULL);
g_return_val_if_fail (path != NULL, NULL);
if (G_UNLIKELY (_thunar_vfs_path_is_local (path) && thunar_vfs_monitor_is_excluded_path (monitor, path)))
return NULL;
/* acquire the monitor lock */
g_mutex_lock (monitor->lock);
......@@ -604,6 +678,9 @@ thunar_vfs_monitor_add_file (ThunarVfsMonitor *monitor,
g_return_val_if_fail (callback != NULL, NULL);
g_return_val_if_fail (path != NULL, NULL);
if (G_UNLIKELY (_thunar_vfs_path_is_local (path) && thunar_vfs_monitor_is_excluded_path (monitor, path)))
return NULL;
/* acquire the monitor lock */
g_mutex_lock (monitor->lock);
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment