2 dnl Copyright (C) 2006, 2009-2010 Free Software Foundation, Inc.
3 dnl This file is free software; the Free Software Foundation
4 dnl gives unlimited permission to copy and/or distribute it,
5 dnl with or without modifications, as long as this notice is preserved.
7 dnl Written by Paul Eggert.
9 # Test whether the flags O_NOATIME and O_NOFOLLOW actually work.
10 # Define HAVE_WORKING_O_NOATIME to 1 if O_NOATIME works, or to 0 otherwise.
11 # Define HAVE_WORKING_O_NOFOLLOW to 1 if O_NOFOLLOW works, or to 0 otherwise.
12 AC_DEFUN([gl_FCNTL_O_FLAGS],
14 dnl Persuade glibc <fcntl.h> to define O_NOATIME and O_NOFOLLOW.
15 AC_REQUIRE([AC_USE_SYSTEM_EXTENSIONS])
16 AC_CACHE_CHECK([for working fcntl.h], [gl_cv_header_working_fcntl_h],
19 [[#include <sys/types.h>
29 static int const constants[] =
31 O_CREAT, O_EXCL, O_NOCTTY, O_TRUNC, O_APPEND,
32 O_NONBLOCK, O_SYNC, O_ACCMODE, O_RDONLY, O_RDWR, O_WRONLY
36 int status = !constants;
38 static char const sym[] = "conftest.sym";
39 if (symlink (".", sym) != 0
40 || close (open (sym, O_RDONLY | O_NOFOLLOW)) == 0)
45 static char const file[] = "confdefs.h";
46 int fd = open (file, O_RDONLY | O_NOATIME);
50 || fstat (fd, &st0) != 0
52 || read (fd, &c, 1) != 1
54 || stat (file, &st1) != 0
55 || st0.st_atime != st1.st_atime)
59 [gl_cv_header_working_fcntl_h=yes],
61 32) gl_cv_header_working_fcntl_h='no (bad O_NOFOLLOW)';; #(
62 64) gl_cv_header_working_fcntl_h='no (bad O_NOATIME)';; #(
63 96) gl_cv_header_working_fcntl_h='no (bad O_NOATIME, O_NOFOLLOW)';; #(
64 *) gl_cv_header_working_fcntl_h='no';;
66 [gl_cv_header_working_fcntl_h=cross-compiling])])
68 case $gl_cv_header_working_fcntl_h in #(
69 *O_NOATIME* | no | cross-compiling) ac_val=0;; #(
72 AC_DEFINE_UNQUOTED([HAVE_WORKING_O_NOATIME], [$ac_val],
73 [Define to 1 if O_NOATIME works.])
75 case $gl_cv_header_working_fcntl_h in #(
76 *O_NOFOLLOW* | no | cross-compiling) ac_val=0;; #(
79 AC_DEFINE_UNQUOTED([HAVE_WORKING_O_NOFOLLOW], [$ac_val],
80 [Define to 1 if O_NOFOLLOW works.])