changeset 15991:19758b0c3160

utimensat: Work around problem on Linux/hppa. * lib/utimensat.c (rpl_utimensat) [Linux/hppa]: Reject invalid tv_nsec values. * doc/posix-functions/utimensat.texi: Mention the problem on Linux/hppa.
author Bruno Haible <bruno@clisp.org>
date Thu, 27 Oct 2011 14:44:05 +0200
parents 2f6844abf7fd
children 5d8e9728d9c0
files ChangeLog doc/posix-functions/utimensat.texi lib/utimensat.c
diffstat 3 files changed, 26 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,10 @@
+2011-10-27  Bruno Haible  <bruno@clisp.org>
+
+	utimensat: Work around problem on Linux/hppa.
+	* lib/utimensat.c (rpl_utimensat) [Linux/hppa]: Reject invalid tv_nsec
+	values.
+	* doc/posix-functions/utimensat.texi: Mention the problem on Linux/hppa.
+
 2011-10-25  Jim Meyering  <meyering@redhat.com>
 
 	maint.mk: fix a bug in sc_prohibit_stddef_without_use
--- a/doc/posix-functions/utimensat.texi
+++ b/doc/posix-functions/utimensat.texi
@@ -34,6 +34,10 @@
 When using @code{UTIME_OMIT} for the modification time, but specifying
 an access time, some systems fail to update the change time:
 Linux kernel 2.6.32.
+@item
+Out-of-range values of @code{tv_nsec} do not lead to a failure on some
+platforms:
+Linux kernel 2.6.22.19 on hppa.
 @end itemize
 
 Portability problems not fixed by Gnulib:
--- a/lib/utimensat.c
+++ b/lib/utimensat.c
@@ -84,6 +84,21 @@
             ts[1] = times[1];
           times = ts;
         }
+#  ifdef __hppa__
+      /* Linux kernel 2.6.22.19 on hppa does not reject invalid tv_nsec
+         values.  */
+      else if (times
+               && ((times[0].tv_nsec != UTIME_NOW
+                    && (times[0].tv_nsec < 0
+                        || times[0].tv_nsec >= 1000000000))
+                   || (times[1].tv_nsec != UTIME_NOW
+                       && (times[1].tv_nsec < 0
+                           || times[1].tv_nsec >= 1000000000))))
+        {
+          errno = EINVAL;
+          return -1;
+        }
+#  endif
 # endif /* __linux__ */
       result = utimensat (fd, file, times, flag);
       /* Linux kernel 2.6.25 has a bug where it returns EINVAL for