X-Git-Url: http://wien.tomnetworks.com/gitweb/?a=blobdiff_plain;f=mono%2Fmetadata%2Ffilewatcher.c;h=7b971aa6fc92ba06e56b1d6efd1796899a51c21b;hb=dd07fe7aaf26f0ecac3fe846218b6f960c7cbf9e;hp=fb8ba9ed16268889fb6c0c78ff0d99a9ca2f6cd0;hpb=4e8db5f7f14d1af2daeff2c331b5b724be47e86f;p=mono.git diff --git a/mono/metadata/filewatcher.c b/mono/metadata/filewatcher.c index fb8ba9ed162..7b971aa6fc9 100644 --- a/mono/metadata/filewatcher.c +++ b/mono/metadata/filewatcher.c @@ -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 @@ -15,7 +15,9 @@ #include #include #include -#if (defined (PLATFORM_WIN32) && WINVER >= 0x0400) +#include +#include +#ifdef HOST_WIN32 /* * TODO: @@ -46,10 +48,11 @@ ves_icall_System_IO_FSW_SupportsFSW (void) #if HAVE_KQUEUE return 3; #else - GModule *fam_module; - gchar *filename; + MonoDl *fam_module; int lib_used = 4; /* gamin */ int inotify_instance; + void *iter; + char *err; MONO_ARCH_SAVE_REGS; @@ -59,20 +62,19 @@ ves_icall_System_IO_FSW_SupportsFSW (void) return 5; /* inotify */ } - filename = g_module_build_path (NULL, "libgamin-1.so.0"); - fam_module = g_module_open (filename, G_MODULE_BIND_LAZY); - g_free (filename); + iter = NULL; + fam_module = mono_dl_open ("libgamin-1.so", MONO_DL_LAZY, NULL); if (fam_module == NULL) { lib_used = 2; /* FAM */ - filename = g_module_build_path (NULL, "libfam.so.0"); - fam_module = g_module_open (filename, G_MODULE_BIND_LAZY); - g_free (filename); + iter = NULL; + fam_module = mono_dl_open ("libfam.so", MONO_DL_LAZY, NULL); } if (fam_module == NULL) return 0; - g_module_symbol (fam_module, "FAMNextEvent", (gpointer *) &FAMNextEvent); + err = mono_dl_symbol (fam_module, "FAMNextEvent", (gpointer *) &FAMNextEvent); + g_free (err); if (FAMNextEvent == NULL) return 0; @@ -115,35 +117,7 @@ ves_icall_System_IO_FAMW_InternalFAMNextEvent (gpointer conn, } #endif -#if defined(__linux__) && defined(HAVE_SYS_SYSCALL_H) && !defined(__NR_inotify_init) -# if defined(__i386__) -# define __NR_inotify_init 291 -# elif defined(__x86_64__) -# define __NR_inotify_init 253 -# elif defined(__ppc__) || defined(__powerpc__) || defined(__powerpc64__) -# define __NR_inotify_init 275 -# elif defined (__s390__) || defined (__s390x__) -# define __NR_inotify_init 284 -# elif defined(__sparc__) || defined (__sparc64__) -# define __NR_inotify_init 151 -# elif defined (__ia64__) -# define __NR_inotify_init 1277 -# elif defined (__arm__) -# define __NR_inotify_init 316 -# elif defined(__alpha__) -# define __NR_inotify_init 444 -# endif -#ifdef __NR_inotify_init -# ifndef __NR_inotify_add_watch -# define __NR_inotify_add_watch (__NR_inotify_init + 1) -# endif -# ifndef __NR_inotify_rm_watch -# define __NR_inotify_rm_watch (__NR_inotify_init + 2) -# endif -#endif -#endif - -#if !defined(__linux__) || !defined(__NR_inotify_init) +#ifndef HAVE_SYS_INOTIFY_H int ves_icall_System_IO_InotifyWatcher_GetInotifyInstance () { return -1; @@ -154,23 +128,24 @@ 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; } #else +#include #include int ves_icall_System_IO_InotifyWatcher_GetInotifyInstance () { - return syscall (__NR_inotify_init); + return inotify_init (); } int ves_icall_System_IO_InotifyWatcher_AddWatch (int fd, MonoString *name, gint32 mask) { - char *str; + char *str, *path; int retval; MONO_ARCH_SAVE_REGS; @@ -179,7 +154,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 = inotify_add_watch (fd, path, mask); if (retval < 0) { switch (errno) { case EACCES: @@ -206,6 +185,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; } @@ -213,7 +194,7 @@ ves_icall_System_IO_InotifyWatcher_AddWatch (int fd, MonoString *name, gint32 ma int ves_icall_System_IO_InotifyWatcher_RemoveWatch (int fd, gint32 watch_descriptor) { - return syscall (__NR_inotify_rm_watch, fd, watch_descriptor); + return inotify_rm_watch (fd, watch_descriptor); } #endif