From 596f96b08db1b99c820e397cb2030fa27e79ff96 Mon Sep 17 00:00:00 2001 From: Antoine Jacoutot Date: Sat, 17 Nov 2012 09:44:48 +0100 Subject: [PATCH] gio-kqueue: use O_EVTONLY on MacOS MacOS provides the O_EVTONLY flag to open(2) which allow to open a file for monitoring without preventing an unmount of the volume that contains it. https://bugzilla.gnome.org/show_bug.cgi?id=688518 --- gio/kqueue/kqueue-exclusions.c | 5 +++++ gio/kqueue/kqueue-helper.c | 4 ++++ 2 files changed, 9 insertions(+) diff --git a/gio/kqueue/kqueue-exclusions.c b/gio/kqueue/kqueue-exclusions.c index 413391659..6be0e739a 100644 --- a/gio/kqueue/kqueue-exclusions.c +++ b/gio/kqueue/kqueue-exclusions.c @@ -21,6 +21,7 @@ THE SOFTWARE. *******************************************************************************/ +#include #include #include #include "kqueue-exclusions.h" @@ -38,6 +39,9 @@ static gboolean ke_debug_enabled = FALSE; gboolean _ke_is_excluded (const char *full_path) { +#if defined (O_EVTONLY) + return FALSE; +#else GFile *f = NULL; GMount *mount = NULL; @@ -57,4 +61,5 @@ _ke_is_excluded (const char *full_path) } else return FALSE; +#endif } diff --git a/gio/kqueue/kqueue-helper.c b/gio/kqueue/kqueue-helper.c index ba5a1406b..87f40323c 100644 --- a/gio/kqueue/kqueue-helper.c +++ b/gio/kqueue/kqueue-helper.c @@ -512,7 +512,11 @@ _kh_start_watching (kqueue_sub *sub) g_assert (sub->filename != NULL); /* kqueue requires a file descriptor to monitor. Sad but true */ +#if defined (O_EVTONLY) + sub->fd = open (sub->filename, O_EVTONLY); +#else sub->fd = open (sub->filename, O_RDONLY); +#endif if (sub->fd == -1) {