Hi Bruno,
On 5/20/24 3:54 AM, Bruno Haible wrote:
>> I'll leave it for review.
>
> Looks good to me. Just please change the #if conditions to not test the
> *values* of __linux__, __sun, __NetBSD__. That is, the proper way to test
> for Linux, Solaris, NetBSD is
> defined __linux__
> defined __sun
> defined __NetBSD__
Yeah, I noticed that after sending the diff. I think it shouldn't have
caused any problems since gcc defines them to 1 IIRC. But I agree
defined is better.
>> If it is okay I can push with documentation updates, xfail removal,
>> ChangeLog.
>
> Yes please!
Done in the two attached patches.
It looks like you added the UTIME_OMIT ctime bug to the documentation
in this commit:
commit e6c7f8be2fe11e72c3fff2503be9ab3f798b787a
Author: Bruno Haible <br...@clisp.org>
Date: Sat Jul 25 23:27:40 2020 +0200
doc: Update for NetBSD 7.1, 8.0, 9.0.
Not too sure if that was a mistake in the bulk doc update or if the
code wasn't updated. I think it should be correct now but feel free to
look into it more if you would like:
$ git diff e6c7f8be2fe11e72c3fff2503be9ab3f798b787a^
e6c7f8be2fe11e72c3fff2503be9ab3f798b787a doc/posix-functions/futimens.texi
doc/posix-functions/utimensat.texi
Collin
From 7e842de9d80ddd94abd61f529702b2e27f31c175 Mon Sep 17 00:00:00 2001
From: Collin Funk <collin.fu...@gmail.com>
Date: Mon, 20 May 2024 14:23:41 -0700
Subject: [PATCH 1/2] 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.
---
ChangeLog | 11 +++++++++++
doc/posix-functions/utimensat.texi | 2 +-
lib/utimens.c | 8 +++++---
lib/utimensat.c | 11 +++++++----
4 files changed, 24 insertions(+), 8 deletions(-)
diff --git a/ChangeLog b/ChangeLog
index 88258bec2c..5dd7fe7e69 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,14 @@
+2024-05-20 Collin Funk <collin.fu...@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-20 Paul Eggert <egg...@cs.ucla.edu>
byteswap: fix problem on macOS
diff --git a/doc/posix-functions/utimensat.texi b/doc/posix-functions/utimensat.texi
index d7b4f6914f..1ba560fb0a 100644
--- a/doc/posix-functions/utimensat.texi
+++ b/doc/posix-functions/utimensat.texi
@@ -35,7 +35,7 @@ @node utimensat
@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.
diff --git a/lib/utimens.c b/lib/utimens.c
index 4bfb9c91a7..6b9f62a53c 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 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 in 2024, when these file system bugs are
no longer common on Gnulib target platforms. */
@@ -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. */
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
--
2.45.1
From 1bbdb03ecbffddaebbe043382bc2e5657b768672 Mon Sep 17 00:00:00 2001
From: Collin Funk <collin.fu...@gmail.com>
Date: Mon, 20 May 2024 14:34:11 -0700
Subject: [PATCH 2/2] tests: Update expected tests results on NetBSD.
These tests were fixed by the previous commit.
* modules/fdutimensat-tests (Depends-on): Remove test-xfail.
(Makefile.am): Expect that test-fdutimensat succeeds on NetBSD.
* modules/futimens-tests (Depends-on): Remove test-xfail.
(Makefile.am): Expect that test-futimens succeeds on NetBSD.
* modules/utimens-tests (Depends-on): Remove test-xfail.
(Makefile.am): Expect that test-utimens succeeds on NetBSD.
* modules/utimensat-tests (Depends-on): Remove test-xfail.
(Makefile.am): Expect that test-utimensat succeeds on NetBSD.
---
ChangeLog | 11 +++++++++++
modules/fdutimensat-tests | 5 -----
modules/futimens-tests | 5 -----
modules/utimens-tests | 5 -----
modules/utimensat-tests | 5 -----
5 files changed, 11 insertions(+), 20 deletions(-)
diff --git a/ChangeLog b/ChangeLog
index 5dd7fe7e69..dd5b0c4c66 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,16 @@
2024-05-20 Collin Funk <collin.fu...@gmail.com>
+ tests: Update expected tests results on NetBSD.
+ These tests were fixed by the previous commit.
+ * modules/fdutimensat-tests (Depends-on): Remove test-xfail.
+ (Makefile.am): Expect that test-fdutimensat succeeds on NetBSD.
+ * modules/futimens-tests (Depends-on): Remove test-xfail.
+ (Makefile.am): Expect that test-futimens succeeds on NetBSD.
+ * modules/utimens-tests (Depends-on): Remove test-xfail.
+ (Makefile.am): Expect that test-utimens succeeds on NetBSD.
+ * modules/utimensat-tests (Depends-on): Remove test-xfail.
+ (Makefile.am): Expect that test-utimensat succeeds on NetBSD.
+
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.
diff --git a/modules/fdutimensat-tests b/modules/fdutimensat-tests
index 29113f0cdb..c2f0d59f3d 100644
--- a/modules/fdutimensat-tests
+++ b/modules/fdutimensat-tests
@@ -16,7 +16,6 @@ stdckdint
timespec
dup
utimecmp
-test-xfail
configure.ac:
@@ -25,7 +24,3 @@ TESTS += test-fdutimensat
check_PROGRAMS += test-fdutimensat
test_fdutimensat_LDADD = $(LDADD) $(CLOCK_TIME_LIB) \
$(NANOSLEEP_LIB) @LIBINTL@
-
-if OS_IS_NETBSD
-XFAIL_TESTS += test-fdutimensat
-endif
diff --git a/modules/futimens-tests b/modules/futimens-tests
index 7364321cb5..c6f62d9d3c 100644
--- a/modules/futimens-tests
+++ b/modules/futimens-tests
@@ -15,7 +15,6 @@ stdckdint
timespec
dup
utimecmp
-test-xfail
configure.ac:
@@ -23,7 +22,3 @@ Makefile.am:
TESTS += test-futimens
check_PROGRAMS += test-futimens
test_futimens_LDADD = $(LDADD) $(CLOCK_TIME_LIB) $(NANOSLEEP_LIB) @LIBINTL@
-
-if OS_IS_NETBSD
-XFAIL_TESTS += test-futimens
-endif
diff --git a/modules/utimens-tests b/modules/utimens-tests
index 3ef54ce36d..381139c8dd 100644
--- a/modules/utimens-tests
+++ b/modules/utimens-tests
@@ -16,7 +16,6 @@ stdckdint
symlink
timespec
utimecmp
-test-xfail
configure.ac:
@@ -24,7 +23,3 @@ Makefile.am:
TESTS += test-utimens
check_PROGRAMS += test-utimens
test_utimens_LDADD = $(LDADD) $(CLOCK_TIME_LIB) $(NANOSLEEP_LIB) @LIBINTL@
-
-if OS_IS_NETBSD
-XFAIL_TESTS += test-utimens
-endif
diff --git a/modules/utimensat-tests b/modules/utimensat-tests
index 720f46e1c7..0ba5e09e02 100644
--- a/modules/utimensat-tests
+++ b/modules/utimensat-tests
@@ -13,7 +13,6 @@ nanosleep
stdckdint
timespec
utimecmp
-test-xfail
configure.ac:
@@ -21,7 +20,3 @@ Makefile.am:
TESTS += test-utimensat
check_PROGRAMS += test-utimensat
test_utimensat_LDADD = $(LDADD) $(CLOCK_TIME_LIB) $(NANOSLEEP_LIB) @LIBINTL@
-
-if OS_IS_NETBSD
-XFAIL_TESTS += test-utimensat
-endif
--
2.45.1