summaryrefslogtreecommitdiffstats
path: root/daemon/inotify.c
diff options
context:
space:
mode:
authorRichard Jones <rjones@trick.home.annexia.org>2009-08-06 15:44:20 +0100
committerRichard Jones <rjones@trick.home.annexia.org>2009-08-06 16:36:57 +0100
commit1503652d07683b21c69a16f6e6f6af9aef84b839 (patch)
treed99ba27abcc54218d93cefa58b239abceebaa480 /daemon/inotify.c
parent690472768c2b94daaca3c9980bc31fcd6b09e8b7 (diff)
downloadlibguestfs-1503652d07683b21c69a16f6e6f6af9aef84b839.tar.gz
libguestfs-1503652d07683b21c69a16f6e6f6af9aef84b839.tar.xz
libguestfs-1503652d07683b21c69a16f6e6f6af9aef84b839.zip
RHEL 5: inotify_init1 call did not exist on RHEL 5.
Diffstat (limited to 'daemon/inotify.c')
-rw-r--r--daemon/inotify.c22
1 files changed, 22 insertions, 0 deletions
diff --git a/daemon/inotify.c b/daemon/inotify.c
index 4bc6f179..1b90f2be 100644
--- a/daemon/inotify.c
+++ b/daemon/inotify.c
@@ -21,6 +21,8 @@
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
+#include <unistd.h>
+#include <fcntl.h>
#include <sys/inotify.h>
#include "../src/guestfs_protocol.h"
@@ -70,11 +72,31 @@ do_inotify_init (int max_events)
if (do_inotify_close () == -1)
return -1;
+#ifdef HAVE_INOTIFY_INIT1
inotify_fd = inotify_init1 (IN_NONBLOCK | IN_CLOEXEC);
if (inotify_fd == -1) {
reply_with_perror ("inotify_init");
return -1;
}
+#else
+ inotify_fd = inotify_init ();
+ if (inotify_fd == -1) {
+ reply_with_perror ("inotify_init");
+ return -1;
+ }
+ if (fcntl (inotify_fd, F_SETFL, O_NONBLOCK) == -1) {
+ reply_with_perror ("fcntl: O_NONBLOCK");
+ close (inotify_fd);
+ inotify_fd = -1;
+ return -1;
+ }
+ if (fcntl (inotify_fd, F_SETFD, FD_CLOEXEC) == -1) {
+ reply_with_perror ("fcntl: FD_CLOEXEC");
+ close (inotify_fd);
+ inotify_fd = -1;
+ return -1;
+ }
+#endif
return 0;
}