From 6827e7cbd5d5024eca33569ad6886fe9f4b6ae04 Mon Sep 17 00:00:00 2001 From: KO Myung-Hun Date: Fri, 28 Nov 2014 16:43:14 +0900 Subject: [PATCH] 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. 2. OS/2 itself supports 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. --- m4/utimes.m4 | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/m4/utimes.m4 b/m4/utimes.m4 index c361357..ce6435c 100644 --- a/m4/utimes.m4 +++ b/m4/utimes.m4 @@ -1,5 +1,5 @@ # Detect some bugs in glibc's implementation of utimes. -# serial 3 +# serial 4 dnl Copyright (C) 2003-2005, 2009-2014 Free Software Foundation, Inc. dnl This file is free software; the Free Software Foundation @@ -45,7 +45,9 @@ main () { int result = 0; char const *file = "conftest.utimes"; - static struct timeval timeval[2] = {{9, 10}, {999999, 999999}}; + /* On OS/2, a file date should be since 1980 year and even seconds */ + static struct timeval timeval[2] = {{315500400 + 10, 10}, + {315500400 + 1000000, 999998}}; /* Test whether utimes() essentially works. */ { @@ -82,11 +84,16 @@ main () result |= 1; else if (fstat (fd, &st0) != 0) result |= 1; + /* utimes() of OS/2 kLIBC does not work on an opened file */ + else if (close (fd) != 0) + result |= 1; else if (utimes (file, timeval) != 0) result |= 2; else if (utimes (file, NULL) != 0) result |= 8; - else if (fstat (fd, &st1) != 0) + else if (lstat (file, &st1) != 0) + result |= 1; + else if ((fd = open (file, O_WRONLY)) < 0) result |= 1; else if (write (fd, "\n", 1) != 1) result |= 1; -- 1.8.5.2