X-Git-Url: https://git.gag.com/?a=blobdiff_plain;f=m4%2Futimensat.m4;h=78472a5fbd7edcbfd569161e9c0b7f8753748d21;hb=1a44d77d50f4fb37c0410eed04b82303624ea2ec;hp=1110e07c63fcb5bd46b59a9cc1a2991755ffbac3;hpb=dda6367c9eac71da8f2ab1c60b3df60f19ce4755;p=debian%2Ftar diff --git a/m4/utimensat.m4 b/m4/utimensat.m4 index 1110e07c..78472a5f 100644 --- a/m4/utimensat.m4 +++ b/m4/utimensat.m4 @@ -1,7 +1,7 @@ -# serial 3 +# serial 4 # See if we need to provide utimensat replacement. -dnl Copyright (C) 2009, 2010 Free Software Foundation, Inc. +dnl Copyright (C) 2009-2011 Free Software Foundation, Inc. dnl This file is free software; the Free Software Foundation dnl gives unlimited permission to copy and/or distribute it, dnl with or without modifications, as long as this notice is preserved. @@ -19,22 +19,39 @@ AC_DEFUN([gl_FUNC_UTIMENSAT], else AC_CACHE_CHECK([whether utimensat works], [gl_cv_func_utimensat_works], - [AC_RUN_IFELSE([AC_LANG_PROGRAM([[ + [AC_RUN_IFELSE( + [AC_LANG_PROGRAM([[ #include #include #include -]], [[struct timespec ts[2] = { { 1, UTIME_OMIT }, { 1, UTIME_NOW } }; - struct stat st; - const char *f = "conftest.file"; - if (close (creat (f, 0600))) return 1; - if (utimensat (AT_FDCWD, f, NULL, AT_SYMLINK_NOFOLLOW)) return 2; - if (utimensat (AT_FDCWD, f, ts, 0)) return 3; - sleep (1); - ts[0].tv_nsec = UTIME_NOW; - ts[1].tv_nsec = UTIME_OMIT; - if (utimensat (AT_FDCWD, f, ts, 0)) return 4; - if (stat (f, &st)) return 5; - if (st.st_ctime < st.st_atime) return 6;]])], +]], [[int result = 0; + const char *f = "conftest.file"; + if (close (creat (f, 0600))) + return 1; + /* Test whether the AT_SYMLINK_NOFOLLOW flag is supported. */ + { + if (utimensat (AT_FDCWD, f, NULL, AT_SYMLINK_NOFOLLOW)) + result |= 2; + } + /* Test whether UTIME_NOW and UTIME_OMIT work. */ + { + struct timespec ts[2] = { { 1, UTIME_OMIT }, { 1, UTIME_NOW } }; + if (utimensat (AT_FDCWD, f, ts, 0)) + result |= 4; + } + sleep (1); + { + struct timespec ts[2] = { { 1, UTIME_NOW }, { 1, UTIME_OMIT } }; + struct stat st; + if (utimensat (AT_FDCWD, f, ts, 0)) + result |= 8; + if (stat (f, &st)) + result |= 16; + else if (st.st_ctime < st.st_atime) + result |= 32; + } + return result; + ]])], dnl FIXME: simplify this in 2012, when file system bugs are no longer common [AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[ #ifdef __linux__