From fee81527b9cc452ce1b0a7f7c0c8af31a8272b56 Mon Sep 17 00:00:00 2001 From: Vladimir Kondratiev Date: Mon, 23 Mar 2015 14:35:15 +0300 Subject: [PATCH] Move O_SYMLINK and O_EVTONLY defines from compat header to place where open called as O_RDONLY and O_NOFOLLOW are not 1:1 replacements. Suggested by Dmitry Matveev --- compat.h | 7 ------- watch.c | 13 +++++++++++-- 2 files changed, 11 insertions(+), 9 deletions(-) diff --git a/compat.h b/compat.h index 4bcfaac..70dc1ef 100644 --- a/compat.h +++ b/compat.h @@ -44,13 +44,6 @@ #include #include -#ifndef O_SYMLINK -#define O_SYMLINK O_NOFOLLOW -#endif -#ifndef O_EVTONLY -#define O_EVTONLY O_RDONLY -#endif - #ifndef DTTOIF #define DTTOIF(dirtype) ((dirtype) << 12) #endif diff --git a/watch.c b/watch.c index 224e108..96d5f19 100644 --- a/watch.c +++ b/watch.c @@ -87,12 +87,21 @@ watch_open (int dirfd, const char *path, uint32_t flags) { assert (path != NULL); - int openflags = O_EVTONLY | O_NONBLOCK; + int openflags = O_NONBLOCK; +#ifdef O_EVTONLY + openflags |= O_EVTONLY; +#else + openflags |= O_RDONLY; +#endif #ifdef O_CLOEXEC - openflags |= O_CLOEXEC; + openflags |= O_CLOEXEC; #endif if (flags & IN_DONT_FOLLOW) { +#ifdef O_SYMLINK openflags |= O_SYMLINK; +#else + openflags |= O_NOFOLLOW; +#endif } #ifdef O_DIRECTORY if (flags & IN_ONLYDIR) {