summaryrefslogtreecommitdiffstats
path: root/gl/m4/fcntl-o.m4
diff options
context:
space:
mode:
authorHolger Weiss <holger@zedat.fu-berlin.de>2013-08-19 21:27:12 (GMT)
committerHolger Weiss <holger@zedat.fu-berlin.de>2013-08-19 21:27:12 (GMT)
commit26fbe7f1e68bb0c96da32491efcf3696fe6c299b (patch)
treec4d95289187a64e9c7517bf73d8208026c3d2fb3 /gl/m4/fcntl-o.m4
parent5f79e3e9f62ca5487d9881973149136ba1d19d3e (diff)
downloadmonitoring-plugins-26fbe7f1e68bb0c96da32491efcf3696fe6c299b.tar.gz
Sync with the latest Gnulib code (6f2d632)
Diffstat (limited to 'gl/m4/fcntl-o.m4')
-rw-r--r--gl/m4/fcntl-o.m489
1 files changed, 69 insertions, 20 deletions
diff --git a/gl/m4/fcntl-o.m4 b/gl/m4/fcntl-o.m4
index 1adacc8..87cc4bd 100644
--- a/gl/m4/fcntl-o.m4
+++ b/gl/m4/fcntl-o.m4
@@ -1,5 +1,5 @@
1# fcntl-o.m4 serial 2 1# fcntl-o.m4 serial 4
2dnl Copyright (C) 2006, 2009-2010 Free Software Foundation, Inc. 2dnl Copyright (C) 2006, 2009-2013 Free Software Foundation, Inc.
3dnl This file is free software; the Free Software Foundation 3dnl This file is free software; the Free Software Foundation
4dnl gives unlimited permission to copy and/or distribute it, 4dnl gives unlimited permission to copy and/or distribute it,
5dnl with or without modifications, as long as this notice is preserved. 5dnl with or without modifications, as long as this notice is preserved.
@@ -17,12 +17,21 @@ AC_DEFUN([gl_FCNTL_O_FLAGS],
17 m4_ifdef([AC_USE_SYSTEM_EXTENSIONS], 17 m4_ifdef([AC_USE_SYSTEM_EXTENSIONS],
18 [AC_REQUIRE([AC_USE_SYSTEM_EXTENSIONS])], 18 [AC_REQUIRE([AC_USE_SYSTEM_EXTENSIONS])],
19 [AC_REQUIRE([AC_GNU_SOURCE])]) 19 [AC_REQUIRE([AC_GNU_SOURCE])])
20
21 AC_CHECK_HEADERS_ONCE([unistd.h])
22 AC_CHECK_FUNCS_ONCE([symlink])
20 AC_CACHE_CHECK([for working fcntl.h], [gl_cv_header_working_fcntl_h], 23 AC_CACHE_CHECK([for working fcntl.h], [gl_cv_header_working_fcntl_h],
21 [AC_RUN_IFELSE( 24 [AC_RUN_IFELSE(
22 [AC_LANG_PROGRAM( 25 [AC_LANG_PROGRAM(
23 [[#include <sys/types.h> 26 [[#include <sys/types.h>
24 #include <sys/stat.h> 27 #include <sys/stat.h>
25 #include <unistd.h> 28 #if HAVE_UNISTD_H
29 # include <unistd.h>
30 #else /* on Windows with MSVC */
31 # include <io.h>
32 # include <stdlib.h>
33 # defined sleep(n) _sleep ((n) * 1000)
34 #endif
26 #include <fcntl.h> 35 #include <fcntl.h>
27 #ifndef O_NOATIME 36 #ifndef O_NOATIME
28 #define O_NOATIME 0 37 #define O_NOATIME 0
@@ -37,34 +46,74 @@ AC_DEFUN([gl_FCNTL_O_FLAGS],
37 }; 46 };
38 ]], 47 ]],
39 [[ 48 [[
40 int status = !constants; 49 int result = !constants;
50 #if HAVE_SYMLINK
41 { 51 {
42 static char const sym[] = "conftest.sym"; 52 static char const sym[] = "conftest.sym";
43 if (symlink (".", sym) != 0 53 if (symlink ("/dev/null", sym) != 0)
44 || close (open (sym, O_RDONLY | O_NOFOLLOW)) == 0) 54 result |= 2;
45 status |= 32; 55 else
56 {
57 int fd = open (sym, O_WRONLY | O_NOFOLLOW | O_CREAT, 0);
58 if (fd >= 0)
59 {
60 close (fd);
61 result |= 4;
62 }
63 }
64 if (unlink (sym) != 0 || symlink (".", sym) != 0)
65 result |= 2;
66 else
67 {
68 int fd = open (sym, O_RDONLY | O_NOFOLLOW);
69 if (fd >= 0)
70 {
71 close (fd);
72 result |= 4;
73 }
74 }
46 unlink (sym); 75 unlink (sym);
47 } 76 }
77 #endif
48 { 78 {
49 static char const file[] = "confdefs.h"; 79 static char const file[] = "confdefs.h";
50 int fd = open (file, O_RDONLY | O_NOATIME); 80 int fd = open (file, O_RDONLY | O_NOATIME);
51 char c; 81 if (fd < 0)
52 struct stat st0, st1; 82 result |= 8;
53 if (fd < 0 83 else
54 || fstat (fd, &st0) != 0 84 {
55 || sleep (1) != 0 85 struct stat st0;
56 || read (fd, &c, 1) != 1 86 if (fstat (fd, &st0) != 0)
57 || close (fd) != 0 87 result |= 16;
58 || stat (file, &st1) != 0 88 else
59 || st0.st_atime != st1.st_atime) 89 {
60 status |= 64; 90 char c;
91 sleep (1);
92 if (read (fd, &c, 1) != 1)
93 result |= 24;
94 else
95 {
96 if (close (fd) != 0)
97 result |= 32;
98 else
99 {
100 struct stat st1;
101 if (stat (file, &st1) != 0)
102 result |= 40;
103 else
104 if (st0.st_atime != st1.st_atime)
105 result |= 64;
106 }
107 }
108 }
109 }
61 } 110 }
62 return status;]])], 111 return result;]])],
63 [gl_cv_header_working_fcntl_h=yes], 112 [gl_cv_header_working_fcntl_h=yes],
64 [case $? in #( 113 [case $? in #(
65 32) gl_cv_header_working_fcntl_h='no (bad O_NOFOLLOW)';; #( 114 4) gl_cv_header_working_fcntl_h='no (bad O_NOFOLLOW)';; #(
66 64) gl_cv_header_working_fcntl_h='no (bad O_NOATIME)';; #( 115 64) gl_cv_header_working_fcntl_h='no (bad O_NOATIME)';; #(
67 96) gl_cv_header_working_fcntl_h='no (bad O_NOATIME, O_NOFOLLOW)';; #( 116 68) gl_cv_header_working_fcntl_h='no (bad O_NOATIME, O_NOFOLLOW)';; #(
68 *) gl_cv_header_working_fcntl_h='no';; 117 *) gl_cv_header_working_fcntl_h='no';;
69 esac], 118 esac],
70 [gl_cv_header_working_fcntl_h=cross-compiling])]) 119 [gl_cv_header_working_fcntl_h=cross-compiling])])