tracker r2107 - in branches/indexer-split: . src src/libinotify src/trackerd tests/common



Author: mr
Date: Tue Aug 19 16:06:19 2008
New Revision: 2107
URL: http://svn.gnome.org/viewvc/tracker?rev=2107&view=rev

Log:
	* configure.ac:
	* src/Makefile.am:
	* src/libinotify/.cvsignore:
	* src/libinotify/Makefile.am:
	* src/libinotify/inotify-handle.c:
	* src/libinotify/inotify-handle.h:
	* src/libinotify/inotify-listhash.c:
	* src/libinotify/inotify-listhash.h:
	* src/libinotify/inotify-log.h:
	* src/libinotify/inotify-monitor.c:
	* src/libinotify/inotify-monitor.h:
	* src/libinotify/libinotify.h:
	* src/libinotify/linux-inotify-syscalls.h:
	* src/trackerd/Makefile.am:
	* src/trackerd/tracker-monitor.c: Add the initial inotify replacement work
	while glib upstream is fixed. This is to support MOVE events for
	files and directories. This is not yet working.

	* tests/common/Makefile.am: Fixed some small errors.


Added:
   branches/indexer-split/src/libinotify/
   branches/indexer-split/src/libinotify/.cvsignore
   branches/indexer-split/src/libinotify/Makefile.am
   branches/indexer-split/src/libinotify/inotify-handle.c
   branches/indexer-split/src/libinotify/inotify-handle.h
   branches/indexer-split/src/libinotify/inotify-listhash.c
   branches/indexer-split/src/libinotify/inotify-listhash.h
   branches/indexer-split/src/libinotify/inotify-log.h
   branches/indexer-split/src/libinotify/inotify-monitor.c
   branches/indexer-split/src/libinotify/inotify-monitor.h
   branches/indexer-split/src/libinotify/libinotify.h
   branches/indexer-split/src/libinotify/linux-inotify-syscalls.h
Modified:
   branches/indexer-split/ChangeLog
   branches/indexer-split/configure.ac
   branches/indexer-split/src/Makefile.am
   branches/indexer-split/src/trackerd/Makefile.am
   branches/indexer-split/src/trackerd/tracker-monitor.c
   branches/indexer-split/tests/common/Makefile.am

Modified: branches/indexer-split/configure.ac
==============================================================================
--- branches/indexer-split/configure.ac	(original)
+++ branches/indexer-split/configure.ac	Tue Aug 19 16:06:19 2008
@@ -429,6 +429,27 @@
 fi
 
 ####################################################################
+#  libinotify
+####################################################################
+
+AC_MSG_CHECKING(for inotify)
+AC_TRY_COMPILE(,
+	[
+        #include <sys/inotify.h>
+
+        inotify_init(void);
+	],
+	have_inotify=no; AC_MSG_RESULT(no),
+	have_inotify=yes; AC_MSG_RESULT(yes),
+)
+
+AM_CONDITIONAL(HAVE_INOTIFY, test "$have_inotify" = "yes")
+
+if test "$have_inotify" = "yes" ; then
+   AC_DEFINE(HAVE_INOTIFY, 1, [Define if we have inotify])
+fi
+
+####################################################################
 #  SQLite check
 ####################################################################
 
@@ -834,6 +855,7 @@
 	po/Makefile.in
 	python/deskbar-handler/Makefile
 	python/Makefile
+	src/libinotify/Makefile
 	src/libstemmer/Makefile
 	src/libtracker-common/Makefile
 	src/libtracker-db/Makefile

Modified: branches/indexer-split/src/Makefile.am
==============================================================================
--- branches/indexer-split/src/Makefile.am	(original)
+++ branches/indexer-split/src/Makefile.am	Tue Aug 19 16:06:19 2008
@@ -1,36 +1,41 @@
 if HAVE_GNOME
-tracker_gui_dir = tracker-search-tool
+build_tracker_search_tool = tracker-search-tool
+endif
+
+if HAVE_INOTIFY
+build_libinotify = libinotify
 endif
 
 if !USING_EXTERNAL_QDBM
-qdbm_dir = qdbm
+build_qdbm = qdbm
 endif
 
 if ENABLE_PREFERENCES
-tracker_preferences_dir = tracker-preferences
+build_tracker_preferences = tracker-preferences
 endif
 
 if ENABLE_LIBTRACKERGTK
-libtrackergtk_dir = libtracker-gtk
+build_libtrackergtk = libtracker-gtk
 endif
 
 if ENABLE_TRACKERAPPLET
-trackerapplet_dir = tracker-applet
+build_trackerapplet = tracker-applet
 endif
 
 SUBDIRS = 					\
 	libstemmer				\
 	xdgmime					\
-	$(qdbm_dir)				\
+	$(build_qdbm)				\
+	$(build_libinotify)			\
 	libtracker-common 			\
 	libtracker-db				\
-	trackerd				\
 	libtracker				\
+	trackerd				\
 	tracker-utils				\
 	tracker-extract				\
 	tracker-thumbnailer			\
 	tracker-indexer				\
-	$(libtrackergtk_dir)			\
-	$(tracker_gui_dir)			\
-	$(trackerapplet_dir) 			\
-	$(tracker_preferences_dir)
+	$(build_libtrackergtk)			\
+	$(build_tracker_gui)			\
+	$(build_trackerapplet) 			\
+	$(build_tracker_preferences)

Added: branches/indexer-split/src/libinotify/.cvsignore
==============================================================================
--- (empty file)
+++ branches/indexer-split/src/libinotify/.cvsignore	Tue Aug 19 16:06:19 2008
@@ -0,0 +1,5 @@
+Makefile
+Makefile.in
+config.h
+config.h.in
+stamp-h1

Added: branches/indexer-split/src/libinotify/Makefile.am
==============================================================================
--- (empty file)
+++ branches/indexer-split/src/libinotify/Makefile.am	Tue Aug 19 16:06:19 2008
@@ -0,0 +1,19 @@
+INCLUDES =						\
+	-DG_LOG_DOMAIN=\"libinotify\"			\
+	-I$(top_srcdir)/src				\
+	$(GLIB2_CFLAGS)
+
+noinst_LTLIBRARIES = libinotify.la
+
+libinotify_la_SOURCES = inotify-monitor.c 		\
+			inotify-handle.c 		\
+			inotify-listhash.c 		\
+			inotify-monitor.h		\
+			inotify-handle.h 		\
+			inotify-listhash.h 		\
+			inotify-log.h 			\
+			linux-inotify-syscalls.h
+
+libinotify_la_LDFLAGS = -version-info 0:0:0
+libinotify_la_LIBADD = 					\
+	$(GLIB2_LIBS)

Added: branches/indexer-split/src/libinotify/inotify-handle.c
==============================================================================
--- (empty file)
+++ branches/indexer-split/src/libinotify/inotify-handle.c	Tue Aug 19 16:06:19 2008
@@ -0,0 +1,274 @@
+/*
+ * inotify-handle.c - a structure to represent a client-side watch
+ * Copyright  2005 Ryan Lortie <desrt desrt ca>
+ *
+ *   This library is free software; you can redistribute it and/or
+ *   modify it under the terms of version 2.1 of the GNU Lesser General
+ *   Public as published by the Free Software Foundation.
+ *
+ *   This library 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
+ *   Lesser General Public License for more details.
+ *
+ *   You should have received a copy of the GNU Lesser General Public
+ *   License along with this library; if not, write to the Free Software
+ *   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110
+ *
+ *   $Id: inotify-handle.c 23 2005-11-09 13:21:16Z ryanl $
+ */
+
+#include <string.h>
+#include <glib.h>
+#include <linux/inotify.h>
+
+#include "inotify-handle.h"
+#include "inotify-log.h"
+
+enum inh_state
+{
+  inh_state_initial,
+  inh_state_deleted,
+  inh_state_created
+};
+
+struct _INotifyHandle
+{
+  int refcount;
+  INotifyCallback callback;
+  gpointer user_data;
+  gint32 wd;
+  guint32 mask;
+  char *filename;
+  unsigned long flags;
+  enum inh_state state;
+  INotifyHandle *parent;
+};
+
+INotifyHandle *
+inotify_handle_new( const char *filename, guint32 mask, unsigned long flags )
+{
+  INotifyHandle *inh;
+
+  inh = g_new( INotifyHandle, 1 );
+  inh->wd = -1;
+  inh->mask = mask;
+  inh->filename = g_strdup( filename );
+  inh->refcount = 1;
+  inh->callback = NULL;
+  inh->user_data = NULL;
+  inh->flags = flags;
+  inh->state = inh_state_initial;
+  inh->parent = NULL;
+
+  inotify_debug( "New handle %p on %s", inh, inh->filename );
+
+  return inh;
+}
+
+void
+inotify_handle_ref( INotifyHandle *inh )
+{
+  inotify_debug( "Ref handle %p on %s", inh, inh->filename );
+
+  g_atomic_int_inc( &inh->refcount );
+}
+
+void
+inotify_handle_unref( INotifyHandle *inh )
+{
+  inotify_debug( "Deref handle %p on %s", inh, inh->filename );
+
+  if( g_atomic_int_dec_and_test( &inh->refcount ) )
+  {
+    inotify_debug( "  and destroy" );
+    g_free( inh->filename );
+    g_free( inh );
+  }
+}
+
+gint32
+inotify_handle_get_wd( INotifyHandle *inh )
+{
+  return inh->wd;
+}
+
+void
+inotify_handle_set_wd( INotifyHandle *inh, gint32 wd )
+{
+  inh->wd = wd;
+}
+  
+guint32
+inotify_handle_get_mask( INotifyHandle *inh )
+{
+  return inh->mask;
+}
+
+const char *
+inotify_handle_get_filename( INotifyHandle *inh )
+{
+  return inh->filename;
+}
+
+const char *
+inotify_handle_get_basename( INotifyHandle *inh )
+{
+  const char *bn;
+
+  bn = rindex( inh->filename, '/' );
+
+  if( bn == NULL )
+    return NULL;
+
+  if( bn == inh->filename )
+    return bn;
+
+  return bn + 1;
+}
+
+void
+inotify_handle_set_parent( INotifyHandle *inh, INotifyHandle *parent )
+{
+  inh->parent = parent;
+}
+
+INotifyHandle *
+inotify_handle_get_parent( INotifyHandle *inh )
+{
+  return inh->parent;
+}
+
+void
+inotify_handle_set_callback( INotifyHandle *inh, INotifyCallback callback,
+                             gpointer user_data )
+{
+  inh->callback = callback;
+  inh->user_data = user_data;
+}
+
+static guint32
+inotify_handle_event_applicable( INotifyHandle *inh, guint32 type,
+                                 const char *filename )
+{
+  enum inh_state state = inh->state;
+
+  inotify_debug( "Juding applicability of event %x on %p/%s",
+                 type, inh, filename );
+
+  if( type & IN_SYNTHETIC )
+  {
+    inotify_debug( "  event is synthetic" );
+
+    /* Synthetic events should not be delivered except as the first event. */
+    if( state != inh_state_initial )
+    {
+      inotify_debug( "  dropping synthetic event on non-initial state" );
+      return 0;
+    }
+
+    /* Synthetic create event... */
+    if( type & IN_CREATE )
+    {
+      inotify_debug( "  synthetic create event" );
+
+      inh->state = inh_state_created;
+
+      /* Only deliver if the user wants to receive synthetic create events. */
+      if( inh->flags & IN_FLAG_SYNTH_CREATE )
+      {
+        inotify_debug( "  user wants it -- delivering" );
+        return IN_CREATE | (IN_SYNTHETIC & inh->mask);
+      }
+      else
+      {
+        inotify_debug( "  user doesn't want it -- dropping" );
+        return 0;
+      }
+    }
+
+    if( type & IN_DELETE )
+    {
+      inotify_debug( "  synthetic delete event" );
+      inh->state = inh_state_deleted;
+
+      /* Only deliver if the user wants to receive synthetic delete events. */
+      if( inh->flags & IN_FLAG_SYNTH_DELETE )
+      {
+        inotify_debug( "  user wants it -- delivering" );
+        return IN_DELETE | (IN_SYNTHETIC & inh->mask);
+      }
+      else
+      {
+        inotify_debug( "  user doesn't want it -- dropping" );
+        return 0;
+      }
+    }
+
+    inotify_warn( "Invalid synthetic event" );
+    return 0;
+  }
+
+  /* Non-synthetic events. */
+  type &= inh->mask;
+
+  /* Event occured on a file in a directory -- not the object itself. */
+  if( filename != NULL )
+  {
+    if( state != inh_state_created )
+      inotify_warn( "Received directory event on non-created inh" );
+
+    inotify_debug( "  event is on file -- passing through" );
+
+    return type;
+  }
+
+  /* Else, non-synthetic event directly on the watched object. */
+  switch( type )
+  {
+    case IN_CREATE:
+    case IN_MOVED_TO:
+      inh->state = inh_state_created;
+
+      if( state == inh_state_created )
+        inotify_warn( "Create on already-existing file" );
+
+      inotify_debug( "  event is create-type.  passing through" );
+
+      return type;
+
+    case IN_DELETE:
+    case IN_DELETE_SELF:
+    case IN_MOVED_FROM:
+      inh->state = inh_state_deleted;
+
+      if( state == inh_state_deleted )
+      {
+        inotify_debug( "  dropping remove event on already-removed file" );
+        return 0;
+      }
+
+      inotify_debug( "  event is delete-type.  passing through" );
+
+      return type;
+
+    default:
+      if( state != inh_state_created )
+        inotify_warn( "Received direct event on non-created inh" );
+
+      inotify_debug( "  event is other type.  passing through" );
+
+      return type;
+  }
+}
+
+void
+inotify_handle_invoke_callback( INotifyHandle *inh, const char *filename,
+                                guint32 type, guint32 cookie )
+{
+  type = inotify_handle_event_applicable( inh, type, filename );
+
+  if( type != 0 && inh->callback )
+    inh->callback( inh, inh->filename, filename, type,
+                   cookie, inh->user_data );
+}

Added: branches/indexer-split/src/libinotify/inotify-handle.h
==============================================================================
--- (empty file)
+++ branches/indexer-split/src/libinotify/inotify-handle.h	Tue Aug 19 16:06:19 2008
@@ -0,0 +1,57 @@
+/*
+ * inotify-handle.h - a structure to represent a client-side watch
+ * Copyright  2005 Ryan Lortie <desrt desrt ca>
+ *
+ *   This library is free software; you can redistribute it and/or
+ *   modify it under the terms of version 2.1 of the GNU Lesser General
+ *   Public as published by the Free Software Foundation.
+ *
+ *   This library 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
+ *   Lesser General Public License for more details.
+ *
+ *   You should have received a copy of the GNU Lesser General Public
+ *   License along with this library; if not, write to the Free Software
+ *   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110
+ *
+ *   $Id: inotify-handle.h 22 2005-09-16 23:16:11Z ryanl $
+ */
+
+#ifndef _libinotify_inotify_handle_h_
+#define _libinotify_inotify_handle_h_
+
+#define IN_FLAG_NONE                    0x00000000
+#define IN_FLAG_FILE_BASED              0x00000001
+#define IN_FLAG_SYNTH_CREATE            0x00000002
+#define IN_FLAG_SYNTH_DELETE            0x00000004
+
+#define IN_SYNTHETIC                    0x00001000
+
+#include <glib.h>
+
+typedef struct _INotifyHandle INotifyHandle;
+typedef void (*INotifyCallback)( INotifyHandle *inh,
+                                 const char *monitor_name,
+                                 const char *filename,
+                                 guint32 event_type,
+                                 guint32 cookie,
+                                 gpointer user_data );
+
+INotifyHandle *inotify_handle_new( const char *filename, guint32 mask,
+                                   unsigned long flags );
+void inotify_handle_ref( INotifyHandle *inh );
+void inotify_handle_unref( INotifyHandle *inh );
+gint32 inotify_handle_get_wd( INotifyHandle *inh );
+void inotify_handle_set_wd( INotifyHandle *inh, gint32 wd );
+guint32 inotify_handle_get_mask( INotifyHandle *inh );
+const char *inotify_handle_get_filename( INotifyHandle *inh );
+const char *inotify_handle_get_basename( INotifyHandle *inh );
+void inotify_handle_set_parent( INotifyHandle *inh, INotifyHandle *parent );
+INotifyHandle *inotify_handle_get_parent( INotifyHandle *inh );
+void inotify_handle_set_callback( INotifyHandle *inh, INotifyCallback callback,
+                                  gpointer user_data );
+void inotify_handle_invoke_callback( INotifyHandle *inh, const char *filename,
+                                     guint32 event_type, guint32 cookie );
+
+#endif /* _libinotify_inotify_handle_h_ */

Added: branches/indexer-split/src/libinotify/inotify-listhash.c
==============================================================================
--- (empty file)
+++ branches/indexer-split/src/libinotify/inotify-listhash.c	Tue Aug 19 16:06:19 2008
@@ -0,0 +1,133 @@
+/*
+ * inotify-listhash.c - a structure to map wd's to client-side watches
+ * Copyright  2005 Ryan Lortie <desrt desrt ca>
+ *
+ *   This library is free software; you can redistribute it and/or
+ *   modify it under the terms of version 2.1 of the GNU Lesser General
+ *   Public as published by the Free Software Foundation.
+ *
+ *   This library 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
+ *   Lesser General Public License for more details.
+ *
+ *   You should have received a copy of the GNU Lesser General Public
+ *   License along with this library; if not, write to the Free Software
+ *   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110
+ *
+ *   $Id: inotify-listhash.c 22 2005-09-16 23:16:11Z ryanl $
+ */
+
+#include <glib.h>
+
+#include "inotify-handle.h"
+
+#include "inotify-listhash.h"
+
+static GHashTable *inotify_wd_table;
+
+GSList *
+inotify_listhash_get( gint32 wd )
+{
+  GSList *list;
+
+  list = g_hash_table_lookup( inotify_wd_table, (gpointer) wd );
+
+  return list;
+}
+
+int
+inotify_listhash_remove( INotifyHandle *inh )
+{
+  GSList *list;
+  gint32 wd;
+
+  wd = inotify_handle_get_wd( inh );
+
+  list = g_hash_table_lookup( inotify_wd_table, (gpointer) wd );
+
+  if( list == NULL )
+    return -1;
+
+  list = g_slist_remove( list, inh );
+  inotify_handle_unref( inh );
+
+  if( list != NULL )
+    g_hash_table_replace( inotify_wd_table, (gpointer) wd, list );
+  else
+    g_hash_table_remove( inotify_wd_table, (gpointer) wd );
+
+  return g_slist_length( list );
+}
+
+void
+inotify_listhash_append( INotifyHandle *inh, gint32 wd )
+{
+  GSList *list;
+
+  inotify_handle_ref( inh );
+  inotify_handle_set_wd( inh, wd );
+
+  list = g_hash_table_lookup( inotify_wd_table, (gpointer) wd );
+  list = g_slist_append( list, inh );
+  g_hash_table_replace( inotify_wd_table, (gpointer) wd, list );
+}
+
+int
+inotify_listhash_ignore( gint32 wd )
+{
+  GSList *link, *next;
+
+  link = g_hash_table_lookup( inotify_wd_table, (gpointer) wd );
+  g_hash_table_remove( inotify_wd_table, (gpointer) wd );
+
+  if( link == NULL )
+    return -1;
+
+  for( ; link; link = next )
+  {
+    next = link->next;
+
+    inotify_handle_unref( link->data );
+    g_slist_free_1( link );
+  }
+
+  return 0;
+}
+
+int
+inotify_listhash_length( gint32 wd )
+{
+  GSList *list;
+
+  list = g_hash_table_lookup( inotify_wd_table, (gpointer) wd );
+
+  return g_slist_length( list );
+}
+
+guint32
+inotify_listhash_get_mask( gint32 wd )
+{
+  GSList *list;
+  guint32 mask;
+
+  list = g_hash_table_lookup( inotify_wd_table, (gpointer) wd );
+
+  for( mask = 0; list; list = list->next )
+    mask |= inotify_handle_get_mask( list->data );
+
+  return mask;
+}
+
+void
+inotify_listhash_initialise( void )
+{
+  inotify_wd_table = g_hash_table_new( NULL, NULL );
+}
+
+void
+inotify_listhash_destroy( void )
+{
+  g_hash_table_destroy( inotify_wd_table );
+}
+

Added: branches/indexer-split/src/libinotify/inotify-listhash.h
==============================================================================
--- (empty file)
+++ branches/indexer-split/src/libinotify/inotify-listhash.h	Tue Aug 19 16:06:19 2008
@@ -0,0 +1,35 @@
+/*
+ * inotify-listhash.h - a structure to map wd's to client-side watches
+ * Copyright  2005 Ryan Lortie <desrt desrt ca>
+ *
+ *   This library is free software; you can redistribute it and/or
+ *   modify it under the terms of version 2.1 of the GNU Lesser General
+ *   Public as published by the Free Software Foundation.
+ *
+ *   This library 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
+ *   Lesser General Public License for more details.
+ *
+ *   You should have received a copy of the GNU Lesser General Public
+ *   License along with this library; if not, write to the Free Software
+ *   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110
+ *
+ *   $Id: inotify-listhash.h 17 2005-09-15 01:22:30Z ryanl $
+ */
+
+#ifndef _libinotify_inotify_listhash_h_
+#define _libinotify_inotify_listhash_h_
+
+#include "inotify-handle.h"
+
+GSList *inotify_listhash_get( gint32 wd );
+int inotify_listhash_remove( INotifyHandle *inh );
+void inotify_listhash_append( INotifyHandle *inh, gint32 wd );
+int inotify_listhash_ignore( gint32 wd );
+int inotify_listhash_length( gint32 wd );
+guint32 inotify_listhash_get_mask( gint32 wd );
+void inotify_listhash_initialise( void );
+void inotify_listhash_destroy( void );
+
+#endif /* _libinotify_inotify_lasthash_h_ */

Added: branches/indexer-split/src/libinotify/inotify-log.h
==============================================================================
--- (empty file)
+++ branches/indexer-split/src/libinotify/inotify-log.h	Tue Aug 19 16:06:19 2008
@@ -0,0 +1,52 @@
+/*
+ * inotify-log.h - internal libinotify logging/debugging functions
+ * Copyright  2005 Ryan Lortie <desrt desrt ca>
+ *
+ *   This library is free software; you can redistribute it and/or
+ *   modify it under the terms of version 2.1 of the GNU Lesser General
+ *   Public as published by the Free Software Foundation.
+ *
+ *   This library 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
+ *   Lesser General Public License for more details.
+ *
+ *   You should have received a copy of the GNU Lesser General Public
+ *   License along with this library; if not, write to the Free Software
+ *   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110
+ *
+ *   $Id: inotify-log.h 17 2005-09-15 01:22:30Z ryanl $
+ */
+
+#ifndef _libinotify_inotify_log_h_
+#define _libinotify_inotify_log_h_
+
+#include <stdlib.h>
+#include <glib.h>
+
+#include "config.h"
+
+#ifdef LIBINOTIFY_DEBUG
+# define inotify_debug(x, ...) g_log("libinotify", G_LOG_LEVEL_DEBUG, \
+                                     x, ## __VA_ARGS__)
+#else
+# define inotify_debug(x, ...) 0
+#endif
+
+#define inotify_warn(x, ...) g_log("libinotify", G_LOG_LEVEL_WARNING, \
+                                   x, ## __VA_ARGS__)
+
+#define inotify_fatal(x, ...) g_log("libinotify", G_LOG_LEVEL_ERROR, \
+                                    x, ## __VA_ARGS__)
+
+static inline void
+inotify_debug_initialise()
+{
+#ifdef LIBINOTIFY_DEBUG
+  if( getenv( "DEBUG_LIBINOTIFY" ) == NULL )
+    g_log_set_handler( "libinotify", G_LOG_LEVEL_DEBUG,
+                       (GLogFunc) strlen, NULL );
+#endif
+}
+
+#endif /* _libinotify_inotify_log_h_ */

Added: branches/indexer-split/src/libinotify/inotify-monitor.c
==============================================================================
--- (empty file)
+++ branches/indexer-split/src/libinotify/inotify-monitor.c	Tue Aug 19 16:06:19 2008
@@ -0,0 +1,390 @@
+/*
+ * inotify-monitor.c - the primary interface for adding/removing watches
+ * Copyright  2005 Ryan Lortie <desrt desrt ca>
+ *
+ *   This library is free software; you can redistribute it and/or
+ *   modify it under the terms of version 2.1 of the GNU Lesser General
+ *   Public as published by the Free Software Foundation.
+ *
+ *   This library 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
+ *   Lesser General Public License for more details.
+ *
+ *   You should have received a copy of the GNU Lesser General Public
+ *   License along with this library; if not, write to the Free Software
+ *   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110
+ *
+ *   $Id: inotify-monitor.c 26 2005-12-01 19:11:01Z ryanl $
+ */
+
+#include <string.h>
+#include <stdlib.h>
+#include <glib.h>
+#include <linux/inotify.h>
+
+#include "linux-inotify-syscalls.h"
+
+#include "inotify-handle.h"
+#include "inotify-listhash.h"
+#include "inotify-log.h"
+
+#include "inotify-monitor.h"
+
+GStaticRecMutex inotify_monitor_lock = G_STATIC_REC_MUTEX_INIT;
+static int inotify_monitor_fd = -1;
+
+static void
+process_one_event( struct inotify_event *ine )
+{
+  const char *filename;
+  GSList *list;
+
+  if( ine->len )
+    filename = ine->name;
+  else
+    filename = NULL;
+
+  inotify_debug( "Got one event" );
+
+  for( list = inotify_listhash_get( ine->wd ); list; list = list->next )
+  {
+    inotify_debug( "  dispatch to %p", list->data );
+    inotify_handle_invoke_callback( list->data, filename,
+                                    ine->mask, ine->cookie );
+  }
+
+  if( ine->mask & IN_IGNORED )
+    inotify_listhash_ignore( ine->wd );
+}
+
+static gboolean
+inotify_watch_func( GIOChannel *source, GIOCondition condition, gpointer data )
+{
+  struct inotify_event ine[20];
+  int size, namesize;
+  int fd;
+
+  g_static_rec_mutex_lock( &inotify_monitor_lock );
+
+  fd = g_io_channel_unix_get_fd( source );
+
+  while( (size = read( fd, ine, sizeof ine )) >= 0 )
+  {
+    inotify_debug( "Original size %d", size );
+    size /= sizeof *ine;
+
+    inotify_debug( "Got size %d", size );
+
+    while( size > 0 )
+    {
+      /* Division, rounding up. */
+      namesize = (ine->len + sizeof *ine - 1) / sizeof *ine + 1;
+
+      if( namesize > size )
+      {
+        // XXX might be false if lots of events stack up
+        inotify_fatal( "namesize > size!" );
+      }
+
+      size -= namesize;
+
+      process_one_event( ine );
+      memmove( ine, &ine[namesize], sizeof *ine * size );
+    }
+  }
+
+  g_static_rec_mutex_unlock( &inotify_monitor_lock );
+
+  return TRUE;
+}
+
+static int
+inotify_monitor_initialise( void )
+{
+  GIOChannel *gio;
+
+  if( inotify_monitor_fd != -1 )
+    return 0;
+
+  inotify_monitor_fd = inotify_init();
+
+  if( inotify_monitor_fd < 0 )
+    return -1;
+
+  inotify_listhash_initialise();
+
+  gio = g_io_channel_unix_new( inotify_monitor_fd );
+  g_io_add_watch( gio, G_IO_IN, inotify_watch_func, NULL );
+  g_io_channel_set_flags( gio, G_IO_FLAG_NONBLOCK, NULL );
+
+  inotify_debug_initialise();
+
+  return 0;
+}
+
+static int
+inotify_monitor_add_raw( INotifyHandle *inh )
+{
+  const char *filename = inotify_handle_get_filename( inh );
+  guint32 mask = inotify_handle_get_mask( inh );
+#ifndef IN_MASK_ADD
+  guint32 needmask;
+  int wd2;
+#endif
+  int wd;
+
+#ifdef IN_MASK_ADD
+  wd = inotify_add_watch( inotify_monitor_fd, filename, mask | IN_MASK_ADD );
+#else
+  wd = inotify_add_watch( inotify_monitor_fd, filename, mask );
+
+  if( wd < 0 )
+    return -1;
+
+  needmask = mask | inotify_listhash_get_mask( wd );
+
+  if( needmask != mask )
+  {
+    /* This can only happen if we've already been watching the inode and we
+     * just requested another watch on it with fewer events.  We now have
+     * to change the watch mask to restore the events we just blew away.
+     */
+
+    /* *Very* slight risk of race condition here if 'filename' has
+     * disappeared or changed inodes since last inotify_add_watch call.
+     */
+    wd2 = inotify_add_watch( inotify_monitor_fd, filename, needmask );
+
+    /* If this happens, we're in trouble no matter how you look at it since
+     * we have no way of giving the proper mask to the inode.  Even worse,
+     * we might have just screwed up the mask on another inode.  Find out.
+     */
+    if( wd2 != wd )
+      inotify_warn( "race condition in inotify_monitor_add! (%d vs %d)",
+                                                                 wd, wd2 );
+
+    if( wd2 < 0 )
+    {
+      /* File has since disappeared -- nothing we can do! */
+    }
+    else if( wd2 != wd )
+    {
+      /* File has changed inode.  Even worse! */
+
+      if( inotify_listhash_length( wd2 ) == 0 )
+      {
+        /* We're not supposed to be watching this inode. */
+        inotify_rm_watch( inotify_monitor_fd, wd2 );
+      }
+      else
+      {
+        /* If we did hit an inode we're already watching then we just
+         * modified its mask.  Ow.  We could go hunting with the list of
+         * filenames that we have in the listhash in hopes that one of them
+         * still references the inode that we're looking for but this is
+         * such a rare case and going hunting is likely to cause further
+         * errors anyway...
+         */
+      }
+    }
+
+    /* We've either fixed it or can't fix it.  Proceed... */
+  }
+#endif
+
+  if( wd < 0 )
+    return -1;
+
+  inotify_listhash_append( inh, wd );
+
+  return 0;
+}
+
+static void
+inotify_monitor_remove_raw( INotifyHandle *inh )
+{
+  if( inotify_listhash_remove( inh ) == 0 )
+  {
+    /* No watches left, so cancel the watch with the kernel.  This Will
+     * generate an IN_IGNORED event which will free the listhash stuff.
+     */
+    inotify_rm_watch( inotify_monitor_fd, inotify_handle_get_wd( inh ) );
+  }
+
+  /* We currently have no way of safely reducing the event mask on an
+   * inode that we're watching.  As such, just leave it alone.  This means
+   * that we'll receive extra events (which we'll filter out), but at least
+   * we won't potentially put ourselves in an inconsistent state.
+   */
+}
+
+static void
+inotify_internal_callback( INotifyHandle *inh, const char *monitor_name,
+                           const char *filename, guint32 event_type,
+                           guint32 cookie, gpointer user_data )
+{
+  INotifyHandle *child = user_data;
+  int result;
+
+  inotify_debug( "Got event for %s:%x while watching for %s on %s",
+                 filename, event_type, inotify_handle_get_basename( child ),
+                 monitor_name );
+
+  event_type &= ~IN_ISDIR;
+
+  if( !filename )
+  {
+    switch( event_type & ~IN_SYNTHETIC )
+    {
+      case IN_CREATE:
+      case IN_MOVED_TO:
+        result = inotify_monitor_add_raw( child );
+
+        /* If child exists... */
+        if( result == 0 )
+          inotify_handle_invoke_callback( child, NULL, event_type, cookie );
+
+        break;
+
+      case IN_DELETE:
+      case IN_DELETE_SELF:
+      case IN_MOVE_SELF:
+      case IN_MOVED_FROM:
+        /* Parent just disappeared.  Report that we've also been deleted. */
+        inotify_handle_invoke_callback( child, NULL, event_type, cookie );
+
+        /* Then unregister our watch with the kernel. */
+        inotify_monitor_remove_raw( child );
+
+        break;
+    }
+
+    return;
+  }
+
+  if( strcmp( inotify_handle_get_basename( child ), filename ) )
+    return;
+
+  switch( event_type )
+  {
+    case IN_CREATE:
+    case IN_MOVED_TO:
+      result = inotify_monitor_add_raw( child );
+
+      inotify_handle_invoke_callback( child, NULL, event_type, cookie );
+
+      if( result != 0 )
+        inotify_handle_invoke_callback( child, NULL, IN_DELETE, cookie );
+
+      break;
+
+    case IN_DELETE:
+    case IN_MOVED_FROM:
+      /* We just disappeared.  Report that we've been deleted.  We must
+       * send the event manually since the remove_raw might cause the
+       * event not to be delivered normally.
+       */
+      inotify_handle_invoke_callback( child, NULL, event_type, cookie );
+
+      /* Then unregister our watch with the kernel. */
+      inotify_monitor_remove_raw( child );
+      break;
+  }
+}
+
+INotifyHandle *
+inotify_monitor_add( const char *filename, guint32 mask, unsigned long flags,
+                     INotifyCallback callback, gpointer user_data )
+{
+  INotifyHandle *pinh, *inh;
+  int result;
+
+  g_static_rec_mutex_lock( &inotify_monitor_lock );
+
+  if( inotify_monitor_initialise() )
+    return NULL;
+
+  inh = inotify_handle_new( filename, mask, flags );
+  inotify_handle_set_callback( inh, callback, user_data );
+
+  if( (flags & IN_FLAG_FILE_BASED) == 0 || !strcmp( filename, "/" ) )
+  {
+    inotify_debug( "%s is raw", filename );
+    result = inotify_monitor_add_raw( inh );
+
+    if( result == 0 )
+      inotify_handle_invoke_callback( inh, NULL, IN_CREATE | IN_SYNTHETIC, -1 );
+  }
+  else
+  {
+    const char *parent = g_path_get_dirname( filename );
+    unsigned long flags;
+    guint32 mask;
+
+    flags = IN_FLAG_FILE_BASED | IN_FLAG_SYNTH_CREATE;
+    mask = IN_MOVED_FROM | IN_MOVED_TO | IN_CREATE | IN_DELETE |
+           IN_DELETE_SELF | IN_MOVE_SELF | IN_SYNTHETIC;
+
+    inotify_debug( "Adding internal callback %p for %p(%s)",
+                   inotify_internal_callback, inh, parent );
+
+    pinh = inotify_monitor_add( parent, mask, flags,
+                                inotify_internal_callback, inh );
+
+    inotify_handle_set_parent( inh, pinh );
+
+    /* This will be filtered out if it shouldn't be delivered. */
+    inotify_handle_invoke_callback( inh, NULL, IN_DELETE | IN_SYNTHETIC, -1 );
+
+    result = 0;
+  }
+
+  if( result )
+  {
+    inotify_handle_unref( inh );
+    inh = NULL;
+  }
+
+  g_static_rec_mutex_unlock( &inotify_monitor_lock );
+
+  return inh;
+}
+
+void
+inotify_monitor_remove( INotifyHandle *inh )
+{
+  INotifyHandle *parent;
+
+  g_static_rec_mutex_lock( &inotify_monitor_lock );
+
+  if( inotify_monitor_initialise() )
+    goto error;
+
+  if( inh == NULL )
+    goto error;
+
+  if( (parent = inotify_handle_get_parent( inh )) != NULL )
+    inotify_monitor_remove( parent );
+
+  inotify_monitor_remove_raw( inh );
+
+  inotify_handle_unref( inh );
+
+error:
+  g_static_rec_mutex_unlock( &inotify_monitor_lock );
+}
+
+gboolean
+inotify_is_available( void )
+{
+  int result;
+
+  g_static_rec_mutex_lock( &inotify_monitor_lock );
+
+  result = inotify_monitor_initialise();
+
+  g_static_rec_mutex_unlock( &inotify_monitor_lock );
+
+  return (result == 0);
+}

Added: branches/indexer-split/src/libinotify/inotify-monitor.h
==============================================================================
--- (empty file)
+++ branches/indexer-split/src/libinotify/inotify-monitor.h	Tue Aug 19 16:06:19 2008
@@ -0,0 +1,34 @@
+/*
+ * inotify-monitor.h - the primary interface for adding/removing watches
+ * Copyright  2005 Ryan Lortie <desrt desrt ca>
+ *
+ *   This library is free software; you can redistribute it and/or
+ *   modify it under the terms of version 2.1 of the GNU Lesser General
+ *   Public as published by the Free Software Foundation.
+ *
+ *   This library 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
+ *   Lesser General Public License for more details.
+ *
+ *   You should have received a copy of the GNU Lesser General Public
+ *   License along with this library; if not, write to the Free Software
+ *   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110
+ *
+ *   $Id: inotify-monitor.h 22 2005-09-16 23:16:11Z ryanl $
+ */
+
+#ifndef _libinotify_inotify_monitor_h_
+#define _libinotify_inotify_monitor_h_
+
+#include "inotify-handle.h"
+
+INotifyHandle *inotify_monitor_add( const char *filename,
+                                    guint32 mask,
+                                    unsigned long flags,
+                                    INotifyCallback callback,
+                                    gpointer user_data );
+void inotify_monitor_remove( INotifyHandle *inh );
+gboolean inotify_is_available( void );
+
+#endif /* _libinotify_inotify_monitor_h_ */

Added: branches/indexer-split/src/libinotify/libinotify.h
==============================================================================
--- (empty file)
+++ branches/indexer-split/src/libinotify/libinotify.h	Tue Aug 19 16:06:19 2008
@@ -0,0 +1,27 @@
+/*
+ * inotify.h - public interface to libinotify
+ * Copyright  2005 Ryan Lortie <desrt desrt ca>
+ *
+ *   This library is free software; you can redistribute it and/or
+ *   modify it under the terms of version 2.1 of the GNU Lesser General
+ *   Public as published by the Free Software Foundation.
+ *
+ *   This library 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
+ *   Lesser General Public License for more details.
+ *
+ *   You should have received a copy of the GNU Lesser General Public
+ *   License along with this library; if not, write to the Free Software
+ *   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110
+ *
+ *   $Id: libinotify.h 12 2005-09-04 15:55:51Z ryanl $
+ */
+
+#ifndef _libinotify_libinotify_h_
+#define _libinotify_libinotify_h_
+
+#include <libinotify/inotify-handle.h>
+#include <libinotify/inotify-monitor.h>
+
+#endif /* _libinotify_libinotify_h_ */

Added: branches/indexer-split/src/libinotify/linux-inotify-syscalls.h
==============================================================================
--- (empty file)
+++ branches/indexer-split/src/libinotify/linux-inotify-syscalls.h	Tue Aug 19 16:06:19 2008
@@ -0,0 +1,90 @@
+/*
+ * linux-inotify-syscalls.h - temporary shim for syscalls
+ * Copyright  2005 Ryan Lortie <desrt desrt ca>
+ *
+ *   This library is free software; you can redistribute it and/or
+ *   modify it under the terms of version 2.1 of the GNU Lesser General
+ *   Public as published by the Free Software Foundation.
+ *
+ *   This library 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
+ *   Lesser General Public License for more details.
+ *
+ *   You should have received a copy of the GNU Lesser General Public
+ *   License along with this library; if not, write to the Free Software
+ *   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110
+ *
+ *   $Id: linux-inotify-syscalls.h 12 2005-09-04 15:55:51Z ryanl $
+ */
+
+#ifndef _linux_inotify_syscalls_h_
+#define _linux_inotify_syscalls_h_
+
+#include <asm/types.h>
+#include <sys/syscall.h>
+#include <unistd.h>
+
+#if defined(__i386__)
+# define __NR_inotify_init	291
+# define __NR_inotify_add_watch	292
+# define __NR_inotify_rm_watch	293
+#elif defined(__x86_64__)
+# define __NR_inotify_init	253
+# define __NR_inotify_add_watch	254
+# define __NR_inotify_rm_watch	255
+#elif defined(__alpha__)
+# define __NR_inotify_init      444
+# define __NR_inotify_add_watch 445
+# define __NR_inotify_rm_watch  446
+#elif defined(__ppc__) || defined(__powerpc__) || defined(__powerpc64__)
+# define __NR_inotify_init      275
+# define __NR_inotify_add_watch 276
+# define __NR_inotify_rm_watch  277
+#elif defined(__sparc__) || defined (__sparc64__)
+# define __NR_inotify_init      151
+# define __NR_inotify_add_watch 152
+# define __NR_inotify_rm_watch  156
+#elif defined (__ia64__)
+# define __NR_inotify_init  1277
+# define __NR_inotify_add_watch 1278
+# define __NR_inotify_rm_watch  1279
+#elif defined (__s390__) || defined (__s390x__)
+# define __NR_inotify_init  284
+# define __NR_inotify_add_watch 285
+# define __NR_inotify_rm_watch  286
+#elif defined (__arm__)
+# define __NR_inotify_init  316
+# define __NR_inotify_add_watch 317
+# define __NR_inotify_rm_watch  318
+#elif defined (__SH4__)
+# define __NR_inotify_init  290
+# define __NR_inotify_add_watch 291
+# define __NR_inotify_rm_watch  292
+#elif defined (__SH5__)
+# define __NR_inotify_init  318
+# define __NR_inotify_add_watch 319
+# define __NR_inotify_rm_watch  320
+#else
+# error "Unsupported architecture"
+#endif
+
+static inline int
+inotify_init (void)
+{
+  return syscall( __NR_inotify_init );
+}
+
+static inline int
+inotify_add_watch( int fd, const char *name, guint32 mask )
+{
+  return syscall( __NR_inotify_add_watch, fd, name, mask );
+}
+
+static inline int
+inotify_rm_watch( int fd, gint32 wd )
+{
+  return syscall( __NR_inotify_rm_watch, fd, wd );
+}
+
+#endif /* _linux_inotify_syscalls_h_ */

Modified: branches/indexer-split/src/trackerd/Makefile.am
==============================================================================
--- branches/indexer-split/src/trackerd/Makefile.am	(original)
+++ branches/indexer-split/src/trackerd/Makefile.am	Tue Aug 19 16:06:19 2008
@@ -16,6 +16,9 @@
 	$(GTHREAD_CFLAGS)						\
 	$(GLIB2_CFLAGS)
 
+if HAVE_INOTIFY
+inotify_libs = $(top_builddir)/src/libinotify/libinotify.la
+endif
 
 #
 # Daemon sources
@@ -74,6 +77,7 @@
 	$(top_builddir)/src/libtracker-common/libtracker-common.la 	\
 	$(top_builddir)/src/libstemmer/libstemmer.la	 		\
 	$(top_builddir)/src/xdgmime/libxdgmime.la 			\
+	$(inotify_libs)							\
 	$(GMIME_LIBS)							\
 	$(FAM_LIBS)							\
 	$(SQLITE3_LIBS)							\

Modified: branches/indexer-split/src/trackerd/tracker-monitor.c
==============================================================================
--- branches/indexer-split/src/trackerd/tracker-monitor.c	(original)
+++ branches/indexer-split/src/trackerd/tracker-monitor.c	Tue Aug 19 16:06:19 2008
@@ -18,6 +18,8 @@
  * Boston, MA  02110-1301, USA.
  */
 
+#include "config.h"
+
 #include <string.h>
 #include <stdlib.h>
 
@@ -25,6 +27,12 @@
 #include <libtracker-common/tracker-file-utils.h>
 #include <libtracker-common/tracker-module-config.h>
 
+#ifdef HAVE_INOTIFY
+#include <linux/inotify.h>
+#include <libinotify/libinotify.h>
+#define USE_LIBINOTIFY
+#endif /* HAVE_INOTIFY */
+
 #include "tracker-monitor.h"
 #include "tracker-dbus.h"
 #include "tracker-indexer-client.h"
@@ -1098,3 +1106,141 @@
 	return monitor->private->monitors_ignored;
 }
 
+#ifdef USE_LIBINOTIFY
+
+static gchar *
+get_events (guint32 event_type)
+{
+	GString *s;
+
+	s = g_string_new ("");
+
+	if (event_type & IN_ACCESS) {
+		s = g_string_append (s, "IN_ACCESS | ");
+	}	
+	if (event_type & IN_MODIFY) {
+		s = g_string_append (s, "IN_MODIFY | ");
+	}	
+	if (event_type & IN_ATTRIB) {
+		s = g_string_append (s, "IN_ATTRIB | ");
+	}	
+	if (event_type & IN_CLOSE_WRITE) {
+		s = g_string_append (s, "IN_CLOSE_WRITE | ");
+	}	
+	if (event_type & IN_CLOSE_NOWRITE) {
+		s = g_string_append (s, "IN_CLOSE_NOWRITE | ");
+	}	
+	if (event_type & IN_OPEN) {
+		s = g_string_append (s, "IN_OPEN | ");
+	}	
+	if (event_type & IN_MOVED_FROM) {
+		s = g_string_append (s, "IN_MOVED_FROM | ");
+	}	
+	if (event_type & IN_MOVED_TO) {
+		s = g_string_append (s, "IN_MOVED_TO | ");
+	}	
+	if (event_type & IN_CREATE) {
+		s = g_string_append (s, "IN_CREATE | ");
+	}	
+	if (event_type & IN_DELETE) {
+		s = g_string_append (s, "IN_DELETE | ");
+	}	
+	if (event_type & IN_DELETE_SELF) {
+		s = g_string_append (s, "IN_DELETE_SELF | ");
+	}	
+	if (event_type & IN_MOVE_SELF) {
+		s = g_string_append (s, "IN_MOVE_SELF | ");
+	}	
+	if (event_type & IN_UNMOUNT) {
+		s = g_string_append (s, "IN_UNMOUNT | ");
+	}	
+	if (event_type & IN_Q_OVERFLOW) {
+		s = g_string_append (s, "IN_Q_OVERFLOW | ");
+	}	
+	if (event_type & IN_IGNORED) {
+		s = g_string_append (s, "IN_IGNORED | ");
+	}	
+	
+	/* helper events */
+	if (event_type & IN_CLOSE) {
+		s = g_string_append (s, "IN_CLOSE* | ");
+	}	
+	if (event_type & IN_MOVE) {
+		s = g_string_append (s, "IN_MOVE* | ");
+	}
+	
+	/* special flags */	
+	if (event_type & IN_MASK_ADD) {
+		s = g_string_append (s, "IN_MASK_ADD^ | ");
+	}	
+	if (event_type & IN_ISDIR) {
+		s = g_string_append (s, "IN_ISDIR^ | ");
+	}	
+	if (event_type & IN_ONESHOT) {
+		s = g_string_append (s, "IN_ONESHOT^ | ");
+	}	
+
+	s->len -= 3;
+
+	return g_string_free (s, FALSE);	
+}
+
+static void 
+callback (INotifyHandle *handle,
+	  const char    *monitor_name,
+	  const char    *filename,
+	  guint32        event_type,
+	  guint32        cookie,
+	  gpointer       user_data)
+{
+	gchar *event_type_str = get_events (event_type);
+
+	g_message ("Received monitor event:%d->'%s' for file:'%s'",
+		   event_type,
+		   event_type_str,
+		   filename ? filename : "");
+	
+	g_free (event_type_str);
+}
+
+void start (const gchar *path);
+
+void
+start (const gchar *path)
+{
+	INotifyHandle **handle;
+	guint32	        mask;
+	unsigned long   flags;
+	gboolean        is_directory;
+	static gint     i = 0;
+	static gint     count = 0;
+
+	if (!inotify_is_available ()) {
+		return;
+	}
+
+	handle = g_new (INotifyHandle *, 1);
+
+	is_directory = TRUE;
+	flags = 0;
+	mask = IN_ALL_EVENTS;
+
+	/* For files */
+	if (is_directory) {
+		flags &= ~IN_FLAG_FILE_BASED;
+	} else {
+		flags |= IN_FLAG_FILE_BASED;
+	}
+
+	g_message ("Addeding monitor for path:'%s'", path);
+	handle[i] = inotify_monitor_add (path, mask, flags, callback, NULL);
+
+	if (handle[i] == NULL) {
+		g_warning ("failed to add monitor for path:'%s'", path);
+	} else {
+		count++;
+		i++;
+	}
+}
+
+#endif /* USE_LIBINOTIFY */

Modified: branches/indexer-split/tests/common/Makefile.am
==============================================================================
--- branches/indexer-split/tests/common/Makefile.am	(original)
+++ branches/indexer-split/tests/common/Makefile.am	Tue Aug 19 16:06:19 2008
@@ -1,12 +1,15 @@
 include $(top_srcdir)/Makefile.decl
 
-CFLAGS = "-I."
-
 noinst_LTLIBRARIES = libtracker-testcommon.la
 
-INCLUDES = $(GLIB2_CFLAGS)
-
-libtracker_testcommon_la_SOURCES = tracker-test-helpers.c tracker-test-helpers.h
+INCLUDES = 				\
+	-I.				\
+	$(GLIB2_CFLAGS)
+
+libtracker_testcommon_la_SOURCES = 	\
+	tracker-test-helpers.c 		\
+	tracker-test-helpers.h
 
-libtracker_testcommon_la_LIBDADD = $(GLIB2_LIBS)
+libtracker_testcommon_la_LIBDADD = 	\
+	$(GLIB2_LIBS)
 



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