[sgen] Binary protocol for every write barrier, not just the generic store one.
[mono.git] / mono / metadata / filewatcher.c
index 954b1111e435b91dc2388d238922f5da27926139..c0c37bc45b22ecec123aeae5af9ba6b60ed67893 100644 (file)
@@ -4,7 +4,7 @@
  * Authors:
  *     Gonzalo Paniagua Javier (gonzalo@ximian.com)
  *
- * (C) 2004,2005,2006 Novell, Inc. (http://www.novell.com)
+ * Copyright 2004-2009 Novell, Inc (http://www.novell.com)
  */
 
 #ifdef HAVE_CONFIG_H
@@ -16,7 +16,8 @@
 #include <mono/metadata/filewatcher.h>
 #include <mono/metadata/marshal.h>
 #include <mono/utils/mono-dl.h>
-#if (defined (PLATFORM_WIN32) && WINVER >= 0x0400)
+#include <mono/utils/mono-io-portability.h>
+#ifdef HOST_WIN32
 
 /*
  * TODO:
@@ -48,7 +49,6 @@ ves_icall_System_IO_FSW_SupportsFSW (void)
        return 3;
 #else
        MonoDl *fam_module;
-       gchar *filename;
        int lib_used = 4; /* gamin */
        int inotify_instance;
        void *iter;
@@ -63,16 +63,11 @@ ves_icall_System_IO_FSW_SupportsFSW (void)
        }
 
        iter = NULL;
-       /* the build_path calls here should be avoided, since we provide the full name */
-       filename = mono_dl_build_path (NULL, "libgamin-1.so.0", &iter);
-       fam_module = mono_dl_open (filename, MONO_DL_LAZY, NULL);
-       g_free (filename);
+       fam_module = mono_dl_open ("libgamin-1.so", MONO_DL_LAZY, NULL);
        if (fam_module == NULL) {
                lib_used = 2; /* FAM */
                iter = NULL;
-               filename = mono_dl_build_path (NULL, "libfam.so.0", &iter);
-               fam_module = mono_dl_open (filename, MONO_DL_LAZY, NULL);
-               g_free (filename);
+               fam_module = mono_dl_open ("libfam.so", MONO_DL_LAZY, NULL);
        }
 
        if (fam_module == NULL)
@@ -161,7 +156,7 @@ int ves_icall_System_IO_InotifyWatcher_AddWatch (int fd, MonoString *directory,
        return -1;
 }
 
-int ves_icall_System_IO_InotifyWatcher_RemoveWatch (int fd, int watch_descriptor)
+int ves_icall_System_IO_InotifyWatcher_RemoveWatch (int fd, gint32 watch_descriptor)
 {
        return -1;
 }
@@ -177,7 +172,7 @@ ves_icall_System_IO_InotifyWatcher_GetInotifyInstance ()
 int
 ves_icall_System_IO_InotifyWatcher_AddWatch (int fd, MonoString *name, gint32 mask)
 {
-       char *str;
+       char *str, *path;
        int retval;
 
        MONO_ARCH_SAVE_REGS;
@@ -186,7 +181,11 @@ ves_icall_System_IO_InotifyWatcher_AddWatch (int fd, MonoString *name, gint32 ma
                return -1;
 
        str = mono_string_to_utf8 (name);
-       retval = syscall (__NR_inotify_add_watch, fd, str, mask);
+       path = mono_portability_find_file (str, TRUE);
+       if (!path)
+               path = str;
+
+       retval = syscall (__NR_inotify_add_watch, fd, path, mask);
        if (retval < 0) {
                switch (errno) {
                case EACCES:
@@ -213,6 +212,8 @@ ves_icall_System_IO_InotifyWatcher_AddWatch (int fd, MonoString *name, gint32 ma
                }
                mono_marshal_set_last_error ();
        }
+       if (path != str)
+               g_free (path);
        g_free (str);
        return retval;
 }