On 5/19/24 2:29 AM, Collin Funk wrote:
> With that those two test cases seem to fail for the same reason as the
> others:
> 
>     $ ./gltests/test-fdutimensat 
>     test-utimens.h:149: assertion 'ctime_compare (&st3, &st2) < 0' failed
>     $ ./gltests/test-utimensat   
>     test-utimens.h:149: assertion 'ctime_compare (&st3, &st2) < 0' failed
> 
> It looks like the behavior is different when one argument has
> tv_nsec == 0 and the other has tv_nsec == UTIME_OMIT. But I am not
> very familiar with these functions.

This patch fixes all the failures in my NetBSD virtual machine.

Essentially, NetBSD 10.0 has the same issues as Linux 2.6 hppa had for
this code.

I'll leave it for review. If it is okay I can push with documentation
updates, xfail removal, ChangeLog.

diff --git a/lib/utimens.c b/lib/utimens.c
index 4bfb9c91a7..6168f36cf2 100644
--- a/lib/utimens.c
+++ b/lib/utimens.c
@@ -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 __linux__ || __sun || __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 in 2024, when these file system bugs are
          no longer common on Gnulib target platforms.  */
@@ -553,7 +554,7 @@ lutimens (char const *file, struct timespec const 
timespec[2])
   if (0 <= lutimensat_works_really)
     {
       int result;
-# if __linux__ || __sun
+# if __linux__ || __sun || __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.  */
diff --git a/lib/utimensat.c b/lib/utimensat.c
index 1321264269..b44207b4be 100644
--- a/lib/utimensat.c
+++ b/lib/utimensat.c
@@ -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

Collin

Reply via email to