]> Savannah Git Hosting - gnulib.git/commitdiff
utimensat, utimens: Work around NetBSD 10.0 bugs.
authorCollin Funk <collin.funk1@gmail.com>
Mon, 20 May 2024 21:23:41 +0000 (14:23 -0700)
committerBruno Haible <bruno@clisp.org>
Wed, 22 May 2024 09:02:34 +0000 (11:02 +0200)
* lib/utimens.c (fdutimens): Work around a NetBSD 10.0 UTIME_OMIT bug in
the same way as Linux kernel 2.6.32 and Solaris 11.1.
(lutimens): Likewise.
* lib/utimensat.c (rpl_utimensat): Likewise. Workaround a NetBSD 10.0
bug where invalid tv_nsec values are not rejected in the same way as
Linux kernel 2.6.22.19 on hppa.
* doc/posix-functions/utimensat.texi: Document the invalid tv_nsec bug.

ChangeLog
doc/posix-functions/utimensat.texi
lib/utimens.c
lib/utimensat.c

index 71398561c93ae65c70ca35043c32402f65684181..3f43c80d928d288bc9de3786c0b363b8877ccf3d 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,14 @@
+2024-05-20  Collin Funk  <collin.funk1@gmail.com>
+
+       utimensat, utimens: Work around NetBSD 10.0 bugs.
+       * lib/utimens.c (fdutimens): Work around a NetBSD 10.0 UTIME_OMIT bug in
+       the same way as Linux kernel 2.6.32 and Solaris 11.1.
+       (lutimens): Likewise.
+       * lib/utimensat.c (rpl_utimensat): Likewise. Workaround a NetBSD 10.0
+       bug where invalid tv_nsec values are not rejected in the same way as
+       Linux kernel 2.6.22.19 on hppa.
+       * doc/posix-functions/utimensat.texi: Document the invalid tv_nsec bug.
+
 2024-05-18  Bruno Haible  <bruno@clisp.org>
 
        mkfifoat: Work around a macOS 14 bug.
index 8c2ae927030d608a8f7e13c8479a1f5c555f1dee..147d8050fc811c7c785864bef6ea06c70a7625da 100644 (file)
@@ -35,7 +35,7 @@ Linux kernel 2.6.32, macOS 11.1, NetBSD 9.0, Solaris 11.1.
 @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.
+Linux kernel 2.6.22.19 on hppa, NetBSD 10.0.
 @item
 On some platforms, this function mis-handles a trailing slash:
 AIX 7.2.
index faa197e6cb5f60ee7d430773e8eff70f0aaab3f8..c85bc00966a4c0e83c812d0dedacb8cd5b53e56d 100644 (file)
@@ -1,6 +1,6 @@
 /* Set file access and modification times.
 
-   Copyright (C) 2003-2023 Free Software Foundation, Inc.
+   Copyright (C) 2003-2024 Free Software Foundation, Inc.
 
    This file is free software: you can redistribute it and/or modify
    it under the terms of the GNU Lesser General Public License as
@@ -220,7 +220,7 @@ fdutimens (int fd, char const *file, struct timespec const timespec[2])
   if (0 <= utimensat_works_really)
     {
       int result;
-# if __linux__ || __sun
+# if defined __linux__ || defined __sun || defined __NetBSD__
       /* As recently as Linux kernel 2.6.32 (Dec 2009), several file
          systems (xfs, ntfs-3g) have bugs with a single UTIME_OMIT,
          but work if both times are either explicitly specified or
@@ -230,6 +230,7 @@ fdutimens (int fd, char const *file, struct timespec const timespec[2])
          where UTIME_OMIT would have worked.
 
          The same bug occurs in Solaris 11.1 (Apr 2013).
+         The same bug occurs in NetBSD 10.0 (May 2024).
 
          FIXME: Simplify this for Linux in 2016 and for Solaris in
          2024, when file system bugs are no longer common.  */
@@ -440,7 +441,7 @@ fdutimens (int fd, char const *file, struct timespec const timespec[2])
 #  endif
         if (futimes (fd, t) == 0)
           {
-#  if __linux__ && __GLIBC__
+#  if defined __linux__ && defined __GLIBC__
             /* Work around a longstanding glibc bug, still present as
                of 2010-12-27.  On older Linux kernels that lack both
                utimensat and utimes, glibc's futimes rounds instead of
@@ -553,7 +554,7 @@ lutimens (char const *file, struct timespec const timespec[2])
   if (0 <= lutimensat_works_really)
     {
       int result;
-# if __linux__ || __sun
+# if defined __linux__ || defined __sun || defined __NetBSD__
       /* As recently as Linux kernel 2.6.32 (Dec 2009), several file
          systems (xfs, ntfs-3g) have bugs with a single UTIME_OMIT,
          but work if both times are either explicitly specified or
@@ -563,6 +564,7 @@ lutimens (char const *file, struct timespec const timespec[2])
          UTIME_OMIT would have worked.
 
          The same bug occurs in Solaris 11.1 (Apr 2013).
+         The same bug occurs in NetBSD 10.0 (May 2024).
 
          FIXME: Simplify this for Linux in 2016 and for Solaris in
          2024, when file system bugs are no longer common.  */
index 5cff11cd0a96932da26290b6a64488c5dd6b9696..b44207b4bec50063751236be4a4bfeed016a269b 100644 (file)
@@ -1,5 +1,5 @@
 /* Set the access and modification time of a file relative to directory fd.
-   Copyright (C) 2009-2023 Free Software Foundation, Inc.
+   Copyright (C) 2009-2024 Free Software Foundation, Inc.
 
    This program is free software: you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
@@ -77,7 +77,7 @@ rpl_utimensat (int fd, char const *file, struct timespec const times[2],
                int flag)
 #  undef utimensat
 {
-#  if defined __linux__ || defined __sun
+#  if defined __linux__ || defined __sun || defined __NetBSD__
   struct timespec ts[2];
 #  endif
 
@@ -86,7 +86,7 @@ rpl_utimensat (int fd, char const *file, struct timespec const times[2],
   if (0 <= utimensat_works_really)
     {
       int result;
-#  if defined __linux__ || defined __sun
+#  if defined __linux__ || defined __sun || defined __NetBSD__
       struct stat st;
       /* As recently as Linux kernel 2.6.32 (Dec 2009), several file
          systems (xfs, ntfs-3g) have bugs with a single UTIME_OMIT,
@@ -97,6 +97,7 @@ rpl_utimensat (int fd, char const *file, struct timespec const times[2],
          UTIME_OMIT would have worked.
 
          The same bug occurs in Solaris 11.1 (Apr 2013).
+         The same bug occurs in NetBSD 10.0 (May 2024).
 
          FIXME: Simplify this in 2024, when these file system bugs are
          no longer common on Gnulib target platforms.  */
@@ -117,9 +118,11 @@ rpl_utimensat (int fd, char const *file, struct timespec const times[2],
             ts[1] = times[1];
           times = ts;
         }
-#   ifdef __hppa__
+#   if defined __hppa__ || defined __NetBSD__
       /* Linux kernel 2.6.22.19 on hppa does not reject invalid tv_nsec
-         values.  */
+         values.
+
+         The same bug occurs in NetBSD 10.0 (May 2024).  */
       else if (times
                && ((times[0].tv_nsec != UTIME_NOW
                     && ! (0 <= times[0].tv_nsec