From: Bruno Haible Date: Thu, 27 Oct 2011 12:44:05 +0000 (+0200) Subject: utimensat: Work around problem on Linux/hppa. X-Git-Tag: v0.1~1535 X-Git-Url: https://gitweb.git.savannah.gnu.org/gitweb/?a=commitdiff_plain;h=2857f7e70459c583839e089bf55159460beefb5e;p=gnulib.git 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. --- diff --git a/ChangeLog b/ChangeLog index 546005ed08..5fd57d3497 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,10 @@ +2011-10-27 Bruno Haible + + 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 maint.mk: fix a bug in sc_prohibit_stddef_without_use diff --git a/doc/posix-functions/utimensat.texi b/doc/posix-functions/utimensat.texi index bcc06d6bc6..3d69c6f8b2 100644 --- a/doc/posix-functions/utimensat.texi +++ b/doc/posix-functions/utimensat.texi @@ -34,6 +34,10 @@ Linux kernel 2.6.25. 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: diff --git a/lib/utimensat.c b/lib/utimensat.c index 5a55e64f72..37f0ea89e3 100644 --- a/lib/utimensat.c +++ b/lib/utimensat.c @@ -84,6 +84,21 @@ rpl_utimensat (int fd, char const *file, struct timespec const times[2], 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