Re: [Tracker] how to handle this case (nfs share home directory among two PC)



Hi, Jamie,

Please review the patch. It is not fully tested yet and not compatible with Solaris since more work may be needed.

a. Is get_files()(tracker-utils.c) appropriate place to check remote dir? If user explicitly add a remote mounted directoy in watch/crawl list, and the SkipRemoteMount == True, the directory should still be indexed.

b. Is another SkipRemoteMounts needed? or just use current SkipMountPoints? I am not sure what exactly SkipMountPoints means.

-rick


jamie wrote:
On Mon, 2007-11-26 at 13:46 +0800, Rick Ju wrote:
Yes, of course. A cache and checking mtab file modification , this is what I was thinking.

-rick


ok great - look forward to seeing the patch

jamie


_______________________________________________
tracker-list mailing list
tracker-list gnome org
http://mail.gnome.org/mailman/listinfo/tracker-list

Index: tracker-utils.h
===================================================================
--- tracker-utils.h     (revision 1055)
+++ tracker-utils.h     (working copy)
@@ -309,6 +309,7 @@
        
        gboolean        skip_mount_points;      /* should tracker descend into mounted directories? see 
Tracker.root_directory_devices */
        GSList *        root_directory_devices;
+       GHashTable      *remote_directories;
 
        IndexStatus     index_status;
 
@@ -594,6 +595,7 @@
 void           tracker_add_root_dir            (const char *uri);  /* add a directory to the list of 
watch/crawl/service roots */
 void           tracker_add_root_directories    (GSList *uri_list); /* adds a bunch of directories to the 
list of watch/crawl/service roots */
 gboolean       tracker_file_is_in_root_dir     (const char *uri);  /* test if a given file resides in the 
watch/crawl/service roots */
+gboolean  tracker_file_is_remote_mounted (const char *uri);
 
 GSList *       tracker_get_all_files           (const char *dir, gboolean dir_only);
 GSList *       tracker_get_files               (const char *dir, gboolean dir_only);
Index: tracker-utils.c
===================================================================
--- tracker-utils.c     (revision 1055)
+++ tracker-utils.c     (working copy)
@@ -40,6 +40,7 @@
 #include <glib/gpattern.h>
 #include <zlib.h>
 #include <math.h>
+#include <mntent.h>
 #include "tracker-dbus.h"
 #include "tracker-utils.h"
 #include "tracker-indexer.h"
@@ -105,6 +106,9 @@
                {NULL, NULL},
 };
 
+static const char * g_remote_fs_type_list[] = {"nfs", "smbfs", NULL};
+static const char * g_mnt_tab_linux   = "/etc/mtab";
+static const char * g_mnt_tab_solaris = "/etc/mnttab";
 
 char *
 tracker_get_service_by_id (int service_type_id)
@@ -1264,7 +1268,58 @@
 }
 
 
+static gboolean
+tracker_is_remote_fs_type(const char *fs_type)
+{
+  int i;
+       for (i = 0; NULL != g_remote_fs_type_list[i]; i++) {
+               if (g_str_equal(g_remote_fs_type_list[i], fs_type))
+                       return TRUE;
+       }
+
+       return FALSE;
+}
+ 
+
+static void
+tracker_init_remote_dirs()
+{
+       if (tracker->remote_directories)
+               return;
+
+       tracker->remote_directories = g_hash_table_new_full (g_str_hash, g_str_equal, NULL, NULL);
+
+       FILE *file = setmntent(g_mnt_tab_linux, "r");
+       if (!file)
+               file = setmntent(g_mnt_tab_solaris, "r");
+       if (!file)
+        return;
+
+       struct mntent * ent = getmntent(file);
+       while   (ent) {
+               if (tracker_is_remote_fs_type(ent->mnt_type))
+                       g_hash_table_insert (tracker->remote_directories, ent->mnt_dir, NULL);
+
+               ent = getmntent(file);
+       }
+
+       endmntent(file);
+       return;
+}
+
+
 gboolean
+tracker_file_is_remote_mounted (const char *uri)
+{
+       if (!tracker->remote_directories) {
+               tracker_init_remote_dirs();
+       }
+
+       return g_hash_table_lookup_extended(tracker->remote_directories, uri, NULL, NULL);
+}
+
+
+gboolean
 tracker_file_info_is_valid (FileInfo *info)
 {
        if (!info || !info->uri) {
@@ -1999,6 +2054,12 @@
                                continue;
                        }
 
+                       if (tracker->skip_mount_points && tracker_file_is_remote_mounted (mystr)) {
+                               tracker_log ("Skipping remote mount point %s", mystr);
+                               g_free (mystr);
+                               continue;
+                       }
+
                        if (!dir_only || tracker_is_directory (mystr)) {
 
                                if (!tracker_file_is_no_watched (mystr)) {


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