summaryrefslogtreecommitdiff
path: root/lib/fcntl.in.h
diff options
context:
space:
mode:
authorPaul Eggert <eggert@cs.ucla.edu>2012-11-05 13:53:36 -0800
committerPaul Eggert <eggert@cs.ucla.edu>2012-11-05 13:54:38 -0800
commite99cec677e1bf25595c6b65992c0228160508f8b (patch)
tree3f757d8e72993e40b8d9278b1389d71dc20cc170 /lib/fcntl.in.h
parent613bcb6205cf2b64d835c19074c5a7e7c6cb99eb (diff)
downloadgnulib-e99cec677e1bf25595c6b65992c0228160508f8b.tar.gz
fcntl-h: default O_SEARCH, O_EXEC to O_PATH if available
Linux kernel 2.6.39 introduced O_PATH (see <http://lwn.net/Articles/433854/>) and this is a better fallback for O_SEARCH and O_EXEC than O_RDONLY, if O_PATH is available. * doc/posix-headers/fcntl.texi (fcntl.h): Document this. * lib/fcntl.in.h (O_EXEC, O_SEARCH) [O_PATH]: Default to O_PATH. * lib/fcntl.in.h (O_ACCMODE): * tests/test-fcntl-h.c (main): Do not reject O_ACCMODE merely because it has more than the minimal number of bits, as POSIX allows extensions here.
Diffstat (limited to 'lib/fcntl.in.h')
-rw-r--r--lib/fcntl.in.h14
1 files changed, 11 insertions, 3 deletions
diff --git a/lib/fcntl.in.h b/lib/fcntl.in.h
index 5fdac2313d..fb402ee1f0 100644
--- a/lib/fcntl.in.h
+++ b/lib/fcntl.in.h
@@ -213,7 +213,11 @@ _GL_WARN_ON_USE (openat, "openat is not portable - "
#endif
#ifndef O_EXEC
-# define O_EXEC O_RDONLY /* This is often close enough in older systems. */
+# ifdef O_PATH
+# define O_EXEC O_PATH
+# else
+# define O_EXEC O_RDONLY /* This is often close enough in older systems. */
+# endif
#endif
#ifndef O_IGNORE_CTTY
@@ -270,7 +274,11 @@ _GL_WARN_ON_USE (openat, "openat is not portable - "
#endif
#ifndef O_SEARCH
-# define O_SEARCH O_RDONLY /* This is often close enough in older systems. */
+# ifdef O_PATH
+# define O_SEARCH O_PATH
+# else
+# define O_SEARCH O_RDONLY /* This is often close enough in older systems. */
+# endif
#endif
#ifndef O_SYNC
@@ -281,7 +289,7 @@ _GL_WARN_ON_USE (openat, "openat is not portable - "
# define O_TTY_INIT 0
#endif
-#if O_ACCMODE != (O_RDONLY | O_WRONLY | O_RDWR | O_EXEC | O_SEARCH)
+#if ~O_ACCMODE & (O_RDONLY | O_WRONLY | O_RDWR | O_EXEC | O_SEARCH)
# undef O_ACCMODE
# define O_ACCMODE (O_RDONLY | O_WRONLY | O_RDWR | O_EXEC | O_SEARCH)
#endif