+2016-01-15 KO Myung-Hun <komh@chollian.net>
+
+ utimes: detect utimes() correctly on OS/2 kLIBC
+ utimes() of OS/2 kLIBC has some limitations.
+ 1. OS/2 itself supports a file date since 1980 year in local time.
+ 2. OS/2 itself supports only even seconds for a file time.
+ 3. utimes() of OS/2 kLIBC does not work on an opened file.
+ * m4/utimes.m4: Detect utimes() correctly on OS/2 kLIBC.
+ * doc/posix-functions/utimes.texi: Document the above limitations of
+ utimes() on OS/2 kLIBC.
+
2016-01-15 Paul Eggert <eggert@cs.ucla.edu>
KO Myung-Hun <komh@chollian.net>
On some platforms, @code{utimes} failed on read-only files when
@code{utime} worked fine.
glibc 2.2.5.
+@item
+On OS/2, this function cannot set the timestamp to earlier than the
+year 1980 in local time.
+@item
+On OS/2, this function cannot set the timestamp to an odd number of
+seconds.
+@item
+On OS/2, this function does not work on an opened file.
@end itemize
Extension: Gnulib provides a module @samp{utimens} that works around these
# Detect some bugs in glibc's implementation of utimes.
-# serial 3
+# serial 4
dnl Copyright (C) 2003-2005, 2009-2016 Free Software Foundation, Inc.
dnl This file is free software; the Free Software Foundation
#include <stdlib.h>
#include <stdio.h>
#include <utime.h>
+#include <errno.h>
static int
inorder (time_t a, time_t b, time_t c)
{
int result = 0;
char const *file = "conftest.utimes";
- static struct timeval timeval[2] = {{9, 10}, {999999, 999999}};
+ /* On OS/2, file timestamps must be on or after 1980 in local time,
+ with an even number of seconds. */
+ static struct timeval timeval[2] = {{315620000 + 10, 10},
+ {315620000 + 1000000, 999998}};
/* Test whether utimes() essentially works. */
{
result |= 1;
else if (fstat (fd, &st0) != 0)
result |= 1;
- else if (utimes (file, timeval) != 0)
+ else if (utimes (file, timeval) != 0
+ && (errno != EACCES
+ /* OS/2 kLIBC utimes fails on opened files. */
+ || close (fd) != 0
+ || utimes (file, timeval) != 0
+ || (fd = open (file, O_WRONLY)) < 0))
result |= 2;
- else if (utimes (file, NULL) != 0)
+ else if (utimes (file, NULL) != 0
+ && (errno != EACCES
+ /* OS/2 kLIBC utimes fails on opened files. */
+ || close (fd) != 0
+ || utimes (file, NULL) != 0
+ || (fd = open (file, O_WRONLY)) < 0))
result |= 8;
else if (fstat (fd, &st1) != 0)
result |= 1;