Test Implementation to verify mkstemp behavior (RHEL-50545)

Resolves: RHEL-50545

Includes base FUSE filesystem testing framework support.
This commit is contained in:
DJ Delorie 2024-10-23 16:03:18 -04:00
parent 2fc78c10da
commit 6fbaa68419
15 changed files with 5988 additions and 1 deletions

121
glibc-RHEL-50545-1.patch Normal file
View File

@ -0,0 +1,121 @@
From 3bfdc4e2bceb601b90c81a9baa73c1904db58b2f Mon Sep 17 00:00:00 2001
From: Andreas Schwab <schwab@suse.de>
Date: Tue, 28 Feb 2023 10:37:18 -0300
Subject: [PATCH] support: use 64-bit time_t (bug 30111)
Content-type: text/plain; charset=UTF-8
Ensure to use 64-bit time_t in the test infrastructure.
---
support/Makefile | 18 ++++++++++++++++++
support/shell-container.c | 2 --
support/support_can_chroot.c | 4 ++--
support/support_copy_file.c | 2 +-
support/support_descriptor_supports_holes.c | 2 +-
support/test-container.c | 2 --
6 files changed, 22 insertions(+), 8 deletions(-)
diff --git a/support/Makefile b/support/Makefile
index b29b7eb505..a304c5cdc0 100644
--- a/support/Makefile
+++ b/support/Makefile
@@ -239,6 +239,24 @@ CFLAGS-support_paths.c = \
CFLAGS-timespec.c += -fexcess-precision=standard
CFLAGS-timespec-time64.c += -fexcess-precision=standard
+# Ensure that general support files use 64-bit time_t
+CFLAGS-delayed_exit.c += -D_FILE_OFFSET_BITS=64 -D_TIME_BITS=64
+CFLAGS-shell-container.c += -D_FILE_OFFSET_BITS=64 -D_TIME_BITS=64
+CFLAGS-support_can_chroot.c += -D_FILE_OFFSET_BITS=64 -D_TIME_BITS=64
+CFLAGS-support_copy_file.c += -D_FILE_OFFSET_BITS=64 -D_TIME_BITS=64
+CFLAGS-support_copy_file_range.c += -D_FILE_OFFSET_BITS=64 -D_TIME_BITS=64
+CFLAGS-support_descriptor_supports_holes.c += -D_FILE_OFFSET_BITS=64 -D_TIME_BITS=64
+CFLAGS-support_descriptors.c += -D_FILE_OFFSET_BITS=64 -D_TIME_BITS=64
+CFLAGS-support_process_state.c += -D_FILE_OFFSET_BITS=64 -D_TIME_BITS=64
+CFLAGS-support_stat_nanoseconds.c += -D_FILE_OFFSET_BITS=64 -D_TIME_BITS=64
+CFLAGS-support_subprocess.c += -D_FILE_OFFSET_BITS=64 -D_TIME_BITS=64
+CFLAGS-support_test_main.c += -D_FILE_OFFSET_BITS=64 -D_TIME_BITS=64
+CFLAGS-test-container.c += -D_FILE_OFFSET_BITS=64 -D_TIME_BITS=64
+CFLAGS-xmkdirp.c += -D_FILE_OFFSET_BITS=64 -D_TIME_BITS=64
+# This is required to get an mkstemp which can create large files on some
+# 32-bit platforms.
+CFLAGS-temp_file.c += -D_FILE_OFFSET_BITS=64 -D_TIME_BITS=64
+
ifeq (,$(CXX))
LINKS_DSO_PROGRAM = links-dso-program-c
else
diff --git a/support/shell-container.c b/support/shell-container.c
index e9ac9b6d04..ffa3378b5e 100644
--- a/support/shell-container.c
+++ b/support/shell-container.c
@@ -16,8 +16,6 @@
License along with the GNU C Library; if not, see
<https://www.gnu.org/licenses/>. */
-#define _FILE_OFFSET_BITS 64
-
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
diff --git a/support/support_can_chroot.c b/support/support_can_chroot.c
index 7d9f91205d..7b4f491b53 100644
--- a/support/support_can_chroot.c
+++ b/support/support_can_chroot.c
@@ -29,14 +29,14 @@ static void
callback (void *closure)
{
int *result = closure;
- struct stat64 before;
+ struct stat before;
xstat ("/dev", &before);
if (chroot ("/dev") != 0)
{
*result = errno;
return;
}
- struct stat64 after;
+ struct stat after;
xstat ("/", &after);
TEST_VERIFY (before.st_dev == after.st_dev);
TEST_VERIFY (before.st_ino == after.st_ino);
diff --git a/support/support_copy_file.c b/support/support_copy_file.c
index 50ff87b9f1..f3e0a2d1b7 100644
--- a/support/support_copy_file.c
+++ b/support/support_copy_file.c
@@ -24,7 +24,7 @@
void
support_copy_file (const char *from, const char *to)
{
- struct stat64 st;
+ struct stat st;
xstat (from, &st);
int fd_from = xopen (from, O_RDONLY, 0);
mode_t mode = st.st_mode & 0777;
diff --git a/support/support_descriptor_supports_holes.c b/support/support_descriptor_supports_holes.c
index 7af5934808..91db216bf0 100644
--- a/support/support_descriptor_supports_holes.c
+++ b/support/support_descriptor_supports_holes.c
@@ -40,7 +40,7 @@ support_descriptor_supports_holes (int fd)
block_headroom = 32,
};
- struct stat64 st;
+ struct stat st;
xfstat (fd, &st);
if (!S_ISREG (st.st_mode))
FAIL_EXIT1 ("descriptor %d does not refer to a regular file", fd);
diff --git a/support/test-container.c b/support/test-container.c
index f1a68b224a..e68f16eecf 100644
--- a/support/test-container.c
+++ b/support/test-container.c
@@ -16,8 +16,6 @@
License along with the GNU C Library; if not, see
<https://www.gnu.org/licenses/>. */
-#define _FILE_OFFSET_BITS 64
-
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
--
2.43.5

1337
glibc-RHEL-50545-10.patch Normal file

File diff suppressed because it is too large Load Diff

501
glibc-RHEL-50545-11.patch Normal file
View File

@ -0,0 +1,501 @@
From e3db0a699c639e97deddcb15939fd9c162801c77 Mon Sep 17 00:00:00 2001
From: Florian Weimer <fweimer@redhat.com>
Date: Sat, 21 Sep 2024 19:25:35 +0200
Subject: [PATCH] misc: FUSE-based tests for mkstemp
Content-type: text/plain; charset=UTF-8
The tests check that O_EXCL is used properly, that 0600 is used
as the mode, that the characters used are as expected, and that
the distribution of names generated is reasonably random.
The tests run very slowly on some kernel versions, so make them
xtests.
Reviewed-by: DJ Delorie <dj@redhat.com>
Conflicts
misc/Makefile
context
---
misc/Makefile | 6 +
misc/tst-mkstemp-fuse-parallel.c | 219 +++++++++++++++++++++++++++++++
misc/tst-mkstemp-fuse.c | 197 +++++++++++++++++++++++++++
3 files changed, 422 insertions(+)
create mode 100644 misc/tst-mkstemp-fuse-parallel.c
create mode 100644 misc/tst-mkstemp-fuse.c
diff --git a/misc/Makefile b/misc/Makefile
index 7b7f8351bf..1422c95317 100644
--- a/misc/Makefile
+++ b/misc/Makefile
@@ -109,6 +109,12 @@ tests-static := tst-empty
tests-internal += tst-fd_to_filename
tests-static += tst-fd_to_filename
+# Tests with long run times.
+xtests += \
+ tst-mkstemp-fuse \
+ tst-mkstemp-fuse-parallel \
+ # xtests
+
ifeq ($(run-built-tests),yes)
tests-special += $(objpfx)tst-error1-mem.out \
$(objpfx)tst-allocate_once-mem.out
diff --git a/misc/tst-mkstemp-fuse-parallel.c b/misc/tst-mkstemp-fuse-parallel.c
new file mode 100644
index 0000000000..219f26cb3b
--- /dev/null
+++ b/misc/tst-mkstemp-fuse-parallel.c
@@ -0,0 +1,246 @@
+/* FUSE-based test for mkstemp. Parallel collision statistics.
+ Copyright (C) 2024 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, see
+ <https://www.gnu.org/licenses/>. */
+
+#include <stdlib.h>
+
+#include <array_length.h>
+#include <errno.h>
+#include <fcntl.h>
+#include <limits.h>
+#include <stdint.h>
+#include <stdio.h>
+#include <string.h>
+#include <support/check.h>
+#include <support/fuse.h>
+#include <support/support.h>
+#include <support/xthread.h>
+#include <support/xunistd.h>
+
+/* The number of subprocesses that call mkstemp. */
+static pid_t processes[4];
+
+/* Enough space to record the expected number of replies (62**3) for
+ each process. */
+enum { results_allocated = array_length (processes) * 62 * 62 * 62 };
+
+/* The thread will store the results there. */
+static uint64_t *results;
+
+/* Currently used part of the results array. */
+static size_t results_used;
+
+
+/* Copied from upstream's string/strlcpy.c . */
+static size_t
+strlcpy (char *__restrict dest, const char *__restrict src, size_t size)
+{
+ size_t src_length = strlen (src);
+
+ if (__glibc_unlikely (src_length >= size))
+ {
+ if (size > 0)
+ {
+ /* Copy the leading portion of the string. The last
+ character is subsequently overwritten with the NUL
+ terminator, but the destination size is usually a
+ multiple of a small power of two, so writing it twice
+ should be more efficient than copying an odd number of
+ bytes. */
+ memcpy (dest, src, size);
+ dest[size - 1] = '\0';
+ }
+ }
+ else
+ /* Copy the string and its terminating NUL character. */
+ memcpy (dest, src, src_length + 1);
+ return src_length;
+}
+
+/* Fail with EEXIST (so that mkstemp tries again). Record observed
+ names for later statistical analysis. */
+static void
+fuse_thread (struct support_fuse *f, void *closure)
+{
+ struct fuse_in_header *inh;
+ while ((inh = support_fuse_next (f)) != NULL)
+ {
+ if (support_fuse_handle_mountpoint (f)
+ || (inh->nodeid == 1 && support_fuse_handle_directory (f)))
+ continue;
+ if (inh->opcode != FUSE_LOOKUP || results_used >= results_allocated)
+ {
+ support_fuse_reply_error (f, EIO);
+ continue;
+ }
+
+ char *name = support_fuse_cast (LOOKUP, inh);
+ TEST_COMPARE_BLOB (name, 3, "new", 3);
+ TEST_COMPARE (strlen (name), 9);
+ /* Extract 8 bytes of the name: 'w', the X replacements, and the
+ null terminator. Treat it as an uint64_t for easy sorting
+ below. Endianess does not matter because the relative order
+ of the entries is not important; sorting is only used to find
+ duplicates. */
+ TEST_VERIFY_EXIT (results_used < results_allocated);
+ memcpy (&results[results_used], name + 2, 8);
+ ++results_used;
+ struct fuse_entry_out *out = support_fuse_prepare_entry (f, 2);
+ out->attr.mode = S_IFREG | 0600;
+ support_fuse_reply_prepared (f);
+ }
+}
+
+/* Used to sort the results array, to find duplicates. */
+static int
+results_sort (const void *a1, const void *b1)
+{
+ const uint64_t *a = a1;
+ const uint64_t *b = b1;
+ if (*a < *b)
+ return -1;
+ if (*a == *b)
+ return 0;
+ return 1;
+}
+
+/* Number of occurrences of certain streak lengths. */
+static size_t streak_lengths[6];
+
+/* Called for every encountered streak. */
+static inline void
+report_streak (uint64_t current, size_t length)
+{
+ if (length > 1)
+ {
+ printf ("info: name \"ne%.8s\" repeats: %zu\n",
+ (char *) &current, length);
+ TEST_VERIFY_EXIT (length < array_length (streak_lengths));
+ }
+ TEST_VERIFY_EXIT (length < array_length (streak_lengths));
+ ++streak_lengths[length];
+}
+
+static int
+do_test (void)
+{
+ support_fuse_init ();
+
+ results = xmalloc (results_allocated * sizeof (*results));
+
+ struct shared
+ {
+ /* Used to synchronize the start of all subprocesses, to make it
+ more likely to expose concurrency-related bugs. */
+ pthread_barrier_t barrier1;
+ pthread_barrier_t barrier2;
+
+ /* Filled in after fork. */
+ char mountpoint[4096];
+ };
+
+ /* Used to synchronize the start of all subprocesses, to make it
+ more likely to expose concurrency-related bugs. */
+ struct shared *pshared = support_shared_allocate (sizeof (*pshared));
+ {
+ pthread_barrierattr_t attr;
+ xpthread_barrierattr_init (&attr);
+ xpthread_barrierattr_setpshared (&attr, PTHREAD_PROCESS_SHARED);
+ xpthread_barrierattr_destroy (&attr);
+ xpthread_barrier_init (&pshared->barrier1, &attr,
+ array_length (processes) + 1);
+ xpthread_barrier_init (&pshared->barrier2, &attr,
+ array_length (processes) + 1);
+ xpthread_barrierattr_destroy (&attr);
+ }
+
+ for (int i = 0; i < array_length (processes); ++i)
+ {
+ processes[i] = xfork ();
+ if (processes[i] == 0)
+ {
+ /* Wait for mountpoint initialization. */
+ xpthread_barrier_wait (&pshared->barrier1);
+ char *path = xasprintf ("%s/newXXXXXX", pshared->mountpoint);
+
+ /* Park this process until all processes have started. */
+ xpthread_barrier_wait (&pshared->barrier2);
+ errno = 0;
+ TEST_COMPARE (mkstemp (path), -1);
+ TEST_COMPARE (errno, EEXIST);
+ free (path);
+ _exit (0);
+ }
+ }
+
+ /* Do this after the forking, to minimize initialization inteference. */
+ struct support_fuse *f = support_fuse_mount (fuse_thread, NULL);
+ TEST_VERIFY (strlcpy (pshared->mountpoint, support_fuse_mountpoint (f),
+ sizeof (pshared->mountpoint))
+ < sizeof (pshared->mountpoint));
+ xpthread_barrier_wait (&pshared->barrier1);
+
+ puts ("info: performing mkstemp calls");
+ xpthread_barrier_wait (&pshared->barrier2);
+
+ for (int i = 0; i < array_length (processes); ++i)
+ {
+ int status;
+ xwaitpid (processes[i], &status, 0);
+ TEST_COMPARE (status, 0);
+ }
+
+ support_fuse_unmount (f);
+ xpthread_barrier_destroy (&pshared->barrier2);
+ xpthread_barrier_destroy (&pshared->barrier1);
+
+ printf ("info: checking results (count %zu)\n", results_used);
+ qsort (results, results_used, sizeof (*results), results_sort);
+
+ uint64_t current = -1;
+ size_t streak = 0;
+ for (size_t i = 0; i < results_used; ++i)
+ if (results[i] == current)
+ ++streak;
+ else
+ {
+ report_streak (current, streak);
+ current = results[i];
+ streak = 1;
+ }
+ report_streak (current, streak);
+
+ puts ("info: repetition count distribution:");
+ for (int i = 1; i < array_length (streak_lengths); ++i)
+ printf (" length %d: %zu\n", i, streak_lengths[i]);
+ /* Some arbitrary threshold, hopefully unlikely enough. In over
+ 260,000 runs of a simulation of this test, at most 26 pairs were
+ observed, and only one three-way collisions. */
+ if (streak_lengths[2] > 30)
+ FAIL ("unexpected repetition count 2: %zu", streak_lengths[2]);
+ if (streak_lengths[3] > 2)
+ FAIL ("unexpected repetition count 3: %zu", streak_lengths[3]);
+ for (int i = 4; i < array_length (streak_lengths); ++i)
+ if (streak_lengths[i] > 0)
+ FAIL ("too many repeats of count %d: %zu", i, streak_lengths[i]);
+
+ free (results);
+
+ return 0;
+}
+
+#include <support/test-driver.c>
diff --git a/misc/tst-mkstemp-fuse.c b/misc/tst-mkstemp-fuse.c
new file mode 100644
index 0000000000..5ac6a6872a
--- /dev/null
+++ b/misc/tst-mkstemp-fuse.c
@@ -0,0 +1,197 @@
+/* FUSE-based test for mkstemp.
+ Copyright (C) 2024 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, see
+ <https://www.gnu.org/licenses/>. */
+
+#include <stdlib.h>
+
+#include <errno.h>
+#include <fcntl.h>
+#include <stdint.h>
+#include <stdio.h>
+#include <string.h>
+#include <support/check.h>
+#include <support/fuse.h>
+#include <support/support.h>
+#include <support/xunistd.h>
+
+/* Set to true in do_test to cause the first FUSE_CREATE attempt to fail. */
+static _Atomic bool simulate_creat_race;
+
+/* Basic tests with eventually successful creation. */
+static void
+fuse_thread_basic (struct support_fuse *f, void *closure)
+{
+ char *previous_name = NULL;
+ int state = 0;
+ struct fuse_in_header *inh;
+ while ((inh = support_fuse_next (f)) != NULL)
+ {
+ if (support_fuse_handle_mountpoint (f)
+ || (inh->nodeid == 1 && support_fuse_handle_directory (f)))
+ continue;
+
+ switch (inh->opcode)
+ {
+ case FUSE_LOOKUP:
+ /* File does not exist initially. */
+ TEST_COMPARE (inh->nodeid, 1);
+ if (simulate_creat_race)
+ {
+ if (state < 3)
+ ++state;
+ else
+ FAIL ("invalid state: %d", state);
+ }
+ else
+ {
+ TEST_COMPARE (state, 0);
+ state = 3;
+ }
+ support_fuse_reply_error (f, ENOENT);
+ break;
+ case FUSE_CREATE:
+ {
+ TEST_COMPARE (inh->nodeid, 1);
+ char *name;
+ struct fuse_create_in *p
+ = support_fuse_cast_name (CREATE, inh, &name);
+ /* Name follows after struct fuse_create_in. */
+ TEST_COMPARE (p->flags & O_ACCMODE, O_RDWR);
+ TEST_VERIFY (p->flags & O_EXCL);
+ TEST_VERIFY (p->flags & O_CREAT);
+ TEST_COMPARE (p->mode & 07777, 0600);
+ TEST_VERIFY (S_ISREG (p->mode));
+ TEST_COMPARE_BLOB (name, 3, "new", 3);
+
+ if (state != 3 && simulate_creat_race)
+ {
+ ++state;
+ support_fuse_reply_error (f, EEXIST);
+ }
+ else
+ {
+ if (previous_name != NULL)
+ /* This test has a very small probability of failure
+ due to a harmless collision (one in 62**6 tests). */
+ TEST_VERIFY (strcmp (name, previous_name) != 0);
+ TEST_COMPARE (state, 3);
+ ++state;
+ struct fuse_entry_out *entry;
+ struct fuse_open_out *open;
+ support_fuse_prepare_create (f, 2, &entry, &open);
+ entry->attr.mode = S_IFREG | 0600;
+ support_fuse_reply_prepared (f);
+ }
+ free (previous_name);
+ previous_name = xstrdup (name);
+ }
+ break;
+ case FUSE_FLUSH:
+ case FUSE_RELEASE:
+ TEST_COMPARE (state, 4);
+ TEST_COMPARE (inh->nodeid, 2);
+ support_fuse_reply_empty (f);
+ break;
+ default:
+ support_fuse_reply_error (f, EIO);
+ }
+ }
+ free (previous_name);
+}
+
+/* Reply that all files exist. */
+static void
+fuse_thread_eexist (struct support_fuse *f, void *closure)
+{
+ uint64_t counter = 0;
+ struct fuse_in_header *inh;
+ while ((inh = support_fuse_next (f)) != NULL)
+ {
+ if (support_fuse_handle_mountpoint (f)
+ || (inh->nodeid == 1 && support_fuse_handle_directory (f)))
+ continue;
+
+ switch (inh->opcode)
+ {
+ case FUSE_LOOKUP:
+ ++counter;
+ TEST_COMPARE (inh->nodeid, 1);
+ char *name = support_fuse_cast (LOOKUP, inh);
+ TEST_COMPARE_BLOB (name, 3, "new", 3);
+ TEST_COMPARE (strlen (name), 9);
+ for (int i = 3; i <= 8; ++i)
+ {
+ /* The glibc implementation uses letters and digits only. */
+ char ch = name[i];
+ TEST_VERIFY (('0' <= ch && ch <= '9')
+ || ('a' <= ch && ch <= 'z')
+ || ('A' <= ch && ch <= 'Z'));
+ }
+ struct fuse_entry_out out =
+ {
+ .nodeid = 2,
+ .attr = {
+ .mode = S_IFREG | 0600,
+ .ino = 2,
+ },
+ };
+ support_fuse_reply (f, &out, sizeof (out));
+ break;
+ default:
+ support_fuse_reply_error (f, EIO);
+ }
+ }
+ /* Verify that mkstemp has retried a lot. The current
+ implementation tries 62 * 62 * 62 times until it goves up. */
+ TEST_VERIFY (counter >= 200000);
+}
+
+static int
+do_test (void)
+{
+ support_fuse_init ();
+
+ for (int do_simulate_creat_race = 0; do_simulate_creat_race < 2;
+ ++do_simulate_creat_race)
+ {
+ simulate_creat_race = do_simulate_creat_race;
+ printf ("info: testing with simulate_creat_race == %d\n",
+ (int) simulate_creat_race);
+ struct support_fuse *f = support_fuse_mount (fuse_thread_basic, NULL);
+ char *path = xasprintf ("%s/newXXXXXX", support_fuse_mountpoint (f));
+ int fd = mkstemp (path);
+ TEST_VERIFY (fd > 2);
+ xclose (fd);
+ free (path);
+ support_fuse_unmount (f);
+ }
+
+ puts ("info: testing EEXIST failure case for mkstemp");
+ {
+ struct support_fuse *f = support_fuse_mount (fuse_thread_eexist, NULL);
+ char *path = xasprintf ("%s/newXXXXXX", support_fuse_mountpoint (f));
+ errno = 0;
+ TEST_COMPARE (mkstemp (path), -1);
+ TEST_COMPARE (errno, EEXIST);
+ free (path);
+ support_fuse_unmount (f);
+ }
+
+ return 0;
+}
+
+#include <support/test-driver.c>
--
2.43.5

40
glibc-RHEL-50545-12.patch Normal file
View File

@ -0,0 +1,40 @@
From 455c7622835d16c79e49fe75b8d3a1ae59a3d0ee Mon Sep 17 00:00:00 2001
From: Florian Weimer <fweimer@redhat.com>
Date: Sat, 21 Sep 2024 19:25:35 +0200
Subject: [PATCH] support: Fix memory leaks in FUSE tests
Content-type: text/plain; charset=UTF-8
The internal read buffer (used by all FUSE tests) was not freed.
The support/tst-support_fuse test missed a deallocation.
---
support/support_fuse.c | 1 +
support/tst-support_fuse.c | 1 +
2 files changed, 2 insertions(+)
diff --git a/support/support_fuse.c b/support/support_fuse.c
index 135dbf1198..f6c063b549 100644
--- a/support/support_fuse.c
+++ b/support/support_fuse.c
@@ -659,6 +659,7 @@ support_fuse_unmount (struct support_fuse *f)
if (rmdir (f->mountpoint) != 0)
FAIL ("FUSE: rmdir (\"%s\"): %m", f->mountpoint);
xclose (f->fd);
+ free (f->buffer_start);
free (f->mountpoint);
free (f->readdir_buffer);
free (f);
diff --git a/support/tst-support_fuse.c b/support/tst-support_fuse.c
index c4075a6608..9ee637cbab 100644
--- a/support/tst-support_fuse.c
+++ b/support/tst-support_fuse.c
@@ -331,6 +331,7 @@ do_test (void)
{
char *subdir_path = xasprintf ("%s/subdir", support_fuse_mountpoint (f));
xmkdir (subdir_path, 01234);
+ free (subdir_path);
}
{
--
2.43.5

32
glibc-RHEL-50545-13.patch Normal file
View File

@ -0,0 +1,32 @@
From 366cce74d2aa2e5753d8787d415b745fd57fda04 Mon Sep 17 00:00:00 2001
From: Florian Weimer <fweimer@redhat.com>
Date: Sat, 21 Sep 2024 19:29:13 +0200
Subject: [PATCH] support: Add valgrind instructions to <support/fuse.h>
Content-type: text/plain; charset=UTF-8
Replacing an outdated comment (namespace setup is now handled by
support_fuse_init).
---
support/fuse.h | 6 ++++--
1 file changed, 4 insertions(+), 2 deletions(-)
diff --git a/support/fuse.h b/support/fuse.h
index 4c365fbc0c..1c862bedbe 100644
--- a/support/fuse.h
+++ b/support/fuse.h
@@ -16,8 +16,10 @@
License along with the GNU C Library; if not, see
<https://www.gnu.org/licenses/>. */
-/* Before using this functionality, use support_enter_mount_namespace
- to ensure that mounts do not impact the overall system. */
+/* To run FUSE tests under valgrind, pass the
+ --sim-hints=fuse-compatible option to valgrind. This option tells
+ valgrind that additional system calls effectively call back into
+ the current program. */
#ifndef SUPPORT_FUSE_H
#define SUPPORT_FUSE_H
--
2.43.5

24
glibc-RHEL-50545-14.patch Normal file
View File

@ -0,0 +1,24 @@
From 3ef26b708725b528a1c69ab3eb523036c50b89d6 Mon Sep 17 00:00:00 2001
From: Florian Weimer <fweimer@redhat.com>
Date: Tue, 24 Sep 2024 13:05:48 +0200
Subject: [PATCH] misc: Link tst-mkstemp-fuse-parallel with
$(shared-thread-library)
Content-type: text/plain; charset=UTF-8
The barrier functions require this on Hurd.
---
misc/Makefile | 1 +
1 file changed, 1 insertion(+)
diff --git a/misc/Makefile b/misc/Makefile
index 1422c95317..a932b1aab4 100644
--- a/misc/Makefile
+++ b/misc/Makefile
@@ -178,3 +178,4 @@ $(objpfx)tst-select: $(librt)
$(objpfx)tst-select-time64: $(librt)
$(objpfx)tst-pselect: $(librt)
$(objpfx)tst-pselect-time64: $(librt)
+$(objpfx)tst-mkstemp-fuse-parallel: $(shared-thread-library)
--
2.43.5

785
glibc-RHEL-50545-2.patch Normal file
View File

@ -0,0 +1,785 @@
From 026a84a54d3b6c23b999b793e2a6f8ecd211e3b8 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20B=C3=A9rat?= <fberat@redhat.com>
Date: Thu, 1 Jun 2023 12:40:05 -0400
Subject: [PATCH] tests: replace write by xwrite
Content-type: text/plain; charset=UTF-8
Using write without cheks leads to warn unused result when __wur is
enabled.
Reviewed-by: Siddhesh Poyarekar <siddhesh@sourceware.org>
---
dirent/tst-fdopendir.c | 4 +++-
io/tst-faccessat.c | 3 ++-
io/tst-fchmodat.c | 3 ++-
io/tst-fchownat.c | 3 ++-
io/tst-fstatat.c | 3 ++-
io/tst-futimesat.c | 3 ++-
io/tst-linkat.c | 3 ++-
io/tst-openat.c | 3 ++-
io/tst-renameat.c | 3 ++-
io/tst-symlinkat.c | 3 ++-
io/tst-unlinkat.c | 3 ++-
libio/bug-ungetc.c | 4 +++-
libio/bug-ungetc3.c | 4 +++-
libio/bug-ungetc4.c | 4 +++-
libio/bug-wfflush.c | 4 +++-
libio/bug-wsetpos.c | 4 +++-
nptl/tst-stackguard1.c | 4 +++-
nptl/tst-tls3.c | 2 ++
nptl/tst-tls3mod.c | 5 +++--
rt/tst-cpuclock2.c | 4 +++-
rt/tst-cputimer1.c | 4 +++-
rt/tst-cputimer2.c | 4 +++-
rt/tst-cputimer3.c | 4 +++-
support/test-container.c | 8 ++++----
sysdeps/pthread/tst-cond18.c | 4 +++-
sysdeps/pthread/tst-flock1.c | 3 ++-
sysdeps/pthread/tst-flock2.c | 3 ++-
sysdeps/pthread/tst-key1.c | 11 ++++++-----
sysdeps/pthread/tst-signal1.c | 3 ++-
sysdeps/pthread/tst-signal2.c | 3 ++-
sysdeps/pthread/tst-timer.c | 3 ++-
time/tst-cpuclock1.c | 4 +++-
32 files changed, 84 insertions(+), 39 deletions(-)
diff --git a/dirent/tst-fdopendir.c b/dirent/tst-fdopendir.c
index 6321af1daa..2c9520574d 100644
--- a/dirent/tst-fdopendir.c
+++ b/dirent/tst-fdopendir.c
@@ -7,6 +7,8 @@
#include <string.h>
#include <sys/stat.h>
+#include <support/xunistd.h>
+
#ifndef O_NOATIME
# define O_NOATIME 0
#endif
@@ -22,7 +24,7 @@ do_test (void)
return 1;
}
- write (fd, "hello", 5);
+ xwrite (fd, "hello", 5);
close (fd);
struct stat64 st;
diff --git a/io/tst-faccessat.c b/io/tst-faccessat.c
index 7bdeed008c..b90954e318 100644
--- a/io/tst-faccessat.c
+++ b/io/tst-faccessat.c
@@ -8,6 +8,7 @@
#include <unistd.h>
#include <sys/stat.h>
+#include <support/xunistd.h>
static void prepare (void);
#define PREPARE(argc, argv) prepare ()
@@ -96,7 +97,7 @@ do_test (void)
puts ("file creation failed");
return 1;
}
- write (fd, "hello", 5);
+ xwrite (fd, "hello", 5);
puts ("file created");
/* Before closing the file, try using this file descriptor to open
diff --git a/io/tst-fchmodat.c b/io/tst-fchmodat.c
index 7d4a8717ff..83003e2f21 100644
--- a/io/tst-fchmodat.c
+++ b/io/tst-fchmodat.c
@@ -8,6 +8,7 @@
#include <unistd.h>
#include <sys/stat.h>
+#include <support/xunistd.h>
static void prepare (void);
#define PREPARE(argc, argv) prepare ()
@@ -98,7 +99,7 @@ do_test (void)
puts ("file creation failed");
return 1;
}
- write (fd, "hello", 5);
+ xwrite (fd, "hello", 5);
puts ("file created");
struct stat64 st1;
diff --git a/io/tst-fchownat.c b/io/tst-fchownat.c
index e8adf6229f..c0b87cda8f 100644
--- a/io/tst-fchownat.c
+++ b/io/tst-fchownat.c
@@ -6,6 +6,7 @@
#include <unistd.h>
#include <sys/stat.h>
+#include <support/xunistd.h>
static void prepare (void);
#define PREPARE(argc, argv) prepare ()
@@ -106,7 +107,7 @@ do_test (void)
puts ("file creation failed");
return 1;
}
- write (fd, "hello", 5);
+ xwrite (fd, "hello", 5);
puts ("file created");
struct stat64 st1;
diff --git a/io/tst-fstatat.c b/io/tst-fstatat.c
index 4766bb2e71..6a60024b63 100644
--- a/io/tst-fstatat.c
+++ b/io/tst-fstatat.c
@@ -6,6 +6,7 @@
#include <unistd.h>
#include <sys/stat.h>
+#include <support/xunistd.h>
static void prepare (void);
#define PREPARE(argc, argv) prepare ()
@@ -94,7 +95,7 @@ do_test (void)
puts ("file creation failed");
return 1;
}
- write (fd, "hello", 5);
+ xwrite (fd, "hello", 5);
puts ("file created");
struct stat64 st1;
diff --git a/io/tst-futimesat.c b/io/tst-futimesat.c
index 3d41721f42..b7ef386e06 100644
--- a/io/tst-futimesat.c
+++ b/io/tst-futimesat.c
@@ -28,6 +28,7 @@
#include <support/test-driver.h>
#include <support/temp_file.h>
+#include <support/xunistd.h>
#ifndef struct_stat
# define struct_stat struct stat64
@@ -114,7 +115,7 @@ do_test (void)
puts ("file creation failed");
return 1;
}
- write (fd, "hello", 5);
+ xwrite (fd, "hello", 5);
puts ("file created");
struct_stat st1;
diff --git a/io/tst-linkat.c b/io/tst-linkat.c
index 97445b7954..6b22a01c88 100644
--- a/io/tst-linkat.c
+++ b/io/tst-linkat.c
@@ -6,6 +6,7 @@
#include <unistd.h>
#include <sys/stat.h>
+#include <support/xunistd.h>
static void prepare (void);
#define PREPARE(argc, argv) prepare ()
@@ -94,7 +95,7 @@ do_test (void)
puts ("file creation failed");
return 1;
}
- write (fd, "hello", 5);
+ xwrite (fd, "hello", 5);
puts ("file created");
struct stat64 st1;
diff --git a/io/tst-openat.c b/io/tst-openat.c
index 741b8d0ad2..2ce89e3db1 100644
--- a/io/tst-openat.c
+++ b/io/tst-openat.c
@@ -6,6 +6,7 @@
#include <string.h>
#include <unistd.h>
+#include <support/xunistd.h>
static void prepare (void);
#define PREPARE(argc, argv) prepare ()
@@ -94,7 +95,7 @@ do_test (void)
puts ("file creation failed");
return 1;
}
- write (fd, "hello", 5);
+ xwrite (fd, "hello", 5);
/* Before closing the file, try using this file descriptor to open
another file. This must fail. */
diff --git a/io/tst-renameat.c b/io/tst-renameat.c
index 435302b52b..0b9da5fd6d 100644
--- a/io/tst-renameat.c
+++ b/io/tst-renameat.c
@@ -6,6 +6,7 @@
#include <unistd.h>
#include <sys/stat.h>
+#include <support/xunistd.h>
static void prepare (void);
#define PREPARE(argc, argv) prepare ()
@@ -94,7 +95,7 @@ do_test (void)
puts ("file creation failed");
return 1;
}
- write (fd, "hello", 5);
+ xwrite (fd, "hello", 5);
puts ("file created");
struct stat64 st1;
diff --git a/io/tst-symlinkat.c b/io/tst-symlinkat.c
index 214a8e348e..4a34994df7 100644
--- a/io/tst-symlinkat.c
+++ b/io/tst-symlinkat.c
@@ -6,6 +6,7 @@
#include <unistd.h>
#include <sys/stat.h>
+#include <support/xunistd.h>
static void prepare (void);
#define PREPARE(argc, argv) prepare ()
@@ -94,7 +95,7 @@ do_test (void)
puts ("file creation failed");
return 1;
}
- write (fd, "hello", 5);
+ xwrite (fd, "hello", 5);
puts ("file created");
struct stat64 st1;
diff --git a/io/tst-unlinkat.c b/io/tst-unlinkat.c
index e21d56f9f7..21a2dbaf57 100644
--- a/io/tst-unlinkat.c
+++ b/io/tst-unlinkat.c
@@ -6,6 +6,7 @@
#include <string.h>
#include <unistd.h>
+#include <support/xunistd.h>
static void prepare (void);
#define PREPARE(argc, argv) prepare ()
@@ -94,7 +95,7 @@ do_test (void)
puts ("file creation failed");
return 1;
}
- write (fd, "hello", 5);
+ xwrite (fd, "hello", 5);
close (fd);
puts ("file created");
diff --git a/libio/bug-ungetc.c b/libio/bug-ungetc.c
index 51940b68f5..4ea2d14ed6 100644
--- a/libio/bug-ungetc.c
+++ b/libio/bug-ungetc.c
@@ -2,6 +2,8 @@
#include <stdio.h>
+#include <support/xunistd.h>
+
static void do_prepare (void);
#define PREPARE(argc, argv) do_prepare ()
static int do_test (void);
@@ -20,7 +22,7 @@ do_prepare (void)
printf ("cannot create temporary file: %m\n");
exit (1);
}
- write (fd, pattern, sizeof (pattern));
+ xwrite (fd, pattern, sizeof (pattern));
close (fd);
}
diff --git a/libio/bug-ungetc3.c b/libio/bug-ungetc3.c
index 0c83c1161e..6100d7a936 100644
--- a/libio/bug-ungetc3.c
+++ b/libio/bug-ungetc3.c
@@ -2,6 +2,8 @@
#include <stdio.h>
+#include <support/xunistd.h>
+
static void do_prepare (void);
#define PREPARE(argc, argv) do_prepare ()
static int do_test (void);
@@ -20,7 +22,7 @@ do_prepare (void)
printf ("cannot create temporary file: %m\n");
exit (1);
}
- write (fd, pattern, sizeof (pattern));
+ xwrite (fd, pattern, sizeof (pattern));
close (fd);
}
diff --git a/libio/bug-ungetc4.c b/libio/bug-ungetc4.c
index 0bd02a570d..8a05def686 100644
--- a/libio/bug-ungetc4.c
+++ b/libio/bug-ungetc4.c
@@ -19,6 +19,8 @@
#include <stdio.h>
+#include <support/xunistd.h>
+
static void do_prepare (void);
#define PREPARE(argc, argv) do_prepare ()
static int do_test (void);
@@ -37,7 +39,7 @@ do_prepare (void)
printf ("cannot create temporary file: %m\n");
exit (1);
}
- write (fd, pattern, sizeof (pattern) - 1);
+ xwrite (fd, pattern, sizeof (pattern) - 1);
close (fd);
}
diff --git a/libio/bug-wfflush.c b/libio/bug-wfflush.c
index a8fd61e997..d1b9d8e9de 100644
--- a/libio/bug-wfflush.c
+++ b/libio/bug-wfflush.c
@@ -3,6 +3,8 @@
#include <stdio.h>
#include <wchar.h>
+#include <support/xunistd.h>
+
static void do_prepare (void);
#define PREPARE(argc, argv) do_prepare ()
static int do_test (void);
@@ -20,7 +22,7 @@ do_prepare (void)
printf ("cannot create temporary file: %m\n");
exit (1);
}
- write (fd, "1!", 2);
+ xwrite (fd, "1!", 2);
close (fd);
}
diff --git a/libio/bug-wsetpos.c b/libio/bug-wsetpos.c
index ccb22a4b62..0fc373ba49 100644
--- a/libio/bug-wsetpos.c
+++ b/libio/bug-wsetpos.c
@@ -4,6 +4,8 @@
#include <stdio.h>
#include <wchar.h>
+#include <support/xunistd.h>
+
static void do_prepare (void);
#define PREPARE(argc, argv) do_prepare ()
static int do_test (void);
@@ -22,7 +24,7 @@ do_prepare (void)
printf ("cannot create temporary file: %m\n");
exit (1);
}
- write (fd, pattern, sizeof (pattern));
+ xwrite (fd, pattern, sizeof (pattern));
close (fd);
}
diff --git a/nptl/tst-stackguard1.c b/nptl/tst-stackguard1.c
index b9cf6844de..4ac57157e9 100644
--- a/nptl/tst-stackguard1.c
+++ b/nptl/tst-stackguard1.c
@@ -28,6 +28,8 @@
#include <tls.h>
#include <unistd.h>
+#include <support/xunistd.h>
+
static const char *command;
static bool child;
static uintptr_t stack_chk_guard_copy;
@@ -97,7 +99,7 @@ do_test (void)
else if (ret != NULL)
return 1;
- write (2, &stack_chk_guard_copy, sizeof (stack_chk_guard_copy));
+ xwrite (2, &stack_chk_guard_copy, sizeof (stack_chk_guard_copy));
return 0;
}
diff --git a/nptl/tst-tls3.c b/nptl/tst-tls3.c
index b1a40c624a..33d94c8cc5 100644
--- a/nptl/tst-tls3.c
+++ b/nptl/tst-tls3.c
@@ -27,6 +27,8 @@
#include <unistd.h>
#include <pthreaddef.h>
+#include <support/xunistd.h>
+
#define THE_SIG SIGUSR1
/* The stack size can be overriden. With a sufficiently large stack
diff --git a/nptl/tst-tls3mod.c b/nptl/tst-tls3mod.c
index c6e8910b1e..345a48e1c7 100644
--- a/nptl/tst-tls3mod.c
+++ b/nptl/tst-tls3mod.c
@@ -26,6 +26,7 @@
#include <pthreaddef.h>
#include <descr.h>
+#include <support/xunistd.h>
extern pthread_barrier_t b;
@@ -44,7 +45,7 @@ handler (int sig)
{
if (sig != THE_SIG)
{
- write (STDOUT_FILENO, "wrong signal\n", 13);
+ xwrite (STDOUT_FILENO, "wrong signal\n", 13);
_exit (1);
}
@@ -52,7 +53,7 @@ handler (int sig)
if (sem_post (&s) != 0)
{
- write (STDOUT_FILENO, "sem_post failed\n", 16);
+ xwrite (STDOUT_FILENO, "sem_post failed\n", 16);
_exit (1);
}
}
diff --git a/rt/tst-cpuclock2.c b/rt/tst-cpuclock2.c
index e4584d8791..8afd34ed9c 100644
--- a/rt/tst-cpuclock2.c
+++ b/rt/tst-cpuclock2.c
@@ -37,6 +37,8 @@ do_test ()
#include <errno.h>
#include <pthread.h>
+#include <support/xunistd.h>
+
static pthread_barrier_t barrier;
/* This function is intended to rack up both user and system time. */
@@ -55,7 +57,7 @@ chew_cpu (void *arg)
for (int i = 0; i < 100; ++i)
for (size_t j = 0; j < sizeof buf; ++j)
buf[j] = 0xbb;
- write (nullfd, (char *) buf, sizeof buf);
+ xwrite (nullfd, (char *) buf, sizeof buf);
close (nullfd);
}
diff --git a/rt/tst-cputimer1.c b/rt/tst-cputimer1.c
index 8f5dd76cf2..18d8b195a2 100644
--- a/rt/tst-cputimer1.c
+++ b/rt/tst-cputimer1.c
@@ -11,6 +11,8 @@
#include <time.h>
#include <pthread.h>
+#include <support/xunistd.h>
+
#define TEST_CLOCK CLOCK_PROCESS_CPUTIME_ID
#define TEST_CLOCK_MISSING(clock) \
(setup_test () ? "process CPU clock timer support" : NULL)
@@ -29,7 +31,7 @@ chew_cpu (void *arg)
for (int i = 0; i < 100; ++i)
for (size_t j = 0; j < sizeof buf; ++j)
buf[j] = 0xbb;
- write (nullfd, (char *) buf, sizeof buf);
+ xwrite (nullfd, (char *) buf, sizeof buf);
close (nullfd);
}
diff --git a/rt/tst-cputimer2.c b/rt/tst-cputimer2.c
index 397d7998c0..a5700d4bac 100644
--- a/rt/tst-cputimer2.c
+++ b/rt/tst-cputimer2.c
@@ -12,6 +12,8 @@
#include <time.h>
#include <pthread.h>
+#include <support/xunistd.h>
+
static clockid_t worker_thread_clock;
#define TEST_CLOCK worker_thread_clock
@@ -32,7 +34,7 @@ chew_cpu (void *arg)
for (int i = 0; i < 100; ++i)
for (size_t j = 0; j < sizeof buf; ++j)
buf[j] = 0xbb;
- write (nullfd, (char *) buf, sizeof buf);
+ xwrite (nullfd, (char *) buf, sizeof buf);
close (nullfd);
}
diff --git a/rt/tst-cputimer3.c b/rt/tst-cputimer3.c
index 056766a377..786de93a02 100644
--- a/rt/tst-cputimer3.c
+++ b/rt/tst-cputimer3.c
@@ -13,6 +13,8 @@
#include <signal.h>
#include <sys/wait.h>
+#include <support/xunistd.h>
+
static clockid_t child_clock;
#define TEST_CLOCK child_clock
@@ -33,7 +35,7 @@ chew_cpu (void)
for (int i = 0; i < 100; ++i)
for (size_t j = 0; j < sizeof buf; ++j)
buf[j] = 0xbb;
- write (nullfd, (char *) buf, sizeof buf);
+ xwrite (nullfd, (char *) buf, sizeof buf);
close (nullfd);
if (getppid () == 1)
_exit (2);
diff --git a/support/test-container.c b/support/test-container.c
index e68f16eecf..d4ca41fe7c 100644
--- a/support/test-container.c
+++ b/support/test-container.c
@@ -1177,7 +1177,7 @@ main (int argc, char **argv)
int status;
/* Send the child's "outside" pid to it. */
- write (pipes[1], &child, sizeof(child));
+ xwrite (pipes[1], &child, sizeof(child));
close (pipes[0]);
close (pipes[1]);
@@ -1246,7 +1246,7 @@ main (int argc, char **argv)
sprintf (tmp, "%lld %lld 1\n",
(long long) (be_su ? 0 : original_uid), (long long) original_uid);
- write (UMAP, tmp, strlen (tmp));
+ xwrite (UMAP, tmp, strlen (tmp));
xclose (UMAP);
/* We must disable setgroups () before we can map our groups, else we
@@ -1255,7 +1255,7 @@ main (int argc, char **argv)
if (GMAP >= 0)
{
/* We support kernels old enough to not have this. */
- write (GMAP, "deny\n", 5);
+ xwrite (GMAP, "deny\n", 5);
xclose (GMAP);
}
@@ -1267,7 +1267,7 @@ main (int argc, char **argv)
sprintf (tmp, "%lld %lld 1\n",
(long long) (be_su ? 0 : original_gid), (long long) original_gid);
- write (GMAP, tmp, strlen (tmp));
+ xwrite (GMAP, tmp, strlen (tmp));
xclose (GMAP);
}
diff --git a/sysdeps/pthread/tst-cond18.c b/sysdeps/pthread/tst-cond18.c
index edac4fa4ff..ffae356c04 100644
--- a/sysdeps/pthread/tst-cond18.c
+++ b/sysdeps/pthread/tst-cond18.c
@@ -25,6 +25,8 @@
#include <stdio.h>
#include <unistd.h>
+#include <support/xunistd.h>
+
pthread_cond_t cv = PTHREAD_COND_INITIALIZER;
pthread_mutex_t lock = PTHREAD_MUTEX_INITIALIZER;
bool exiting;
@@ -41,7 +43,7 @@ tf (void *id)
while (!exiting)
{
if ((spins++ % 1000) == 0)
- write (fd, ".", 1);
+ xwrite (fd, ".", 1);
pthread_mutex_unlock (&lock);
pthread_mutex_lock (&lock);
diff --git a/sysdeps/pthread/tst-flock1.c b/sysdeps/pthread/tst-flock1.c
index 7eef9070ab..9de148afd3 100644
--- a/sysdeps/pthread/tst-flock1.c
+++ b/sysdeps/pthread/tst-flock1.c
@@ -22,6 +22,7 @@
#include <unistd.h>
#include <sys/file.h>
+#include <support/xunistd.h>
static pthread_mutex_t lock = PTHREAD_MUTEX_INITIALIZER;
@@ -57,7 +58,7 @@ do_test (void)
unlink (tmp);
- write (fd, "foobar xyzzy", 12);
+ xwrite (fd, "foobar xyzzy", 12);
if (flock (fd, LOCK_EX | LOCK_NB) != 0)
{
diff --git a/sysdeps/pthread/tst-flock2.c b/sysdeps/pthread/tst-flock2.c
index 8762e93b52..952b79e5db 100644
--- a/sysdeps/pthread/tst-flock2.c
+++ b/sysdeps/pthread/tst-flock2.c
@@ -25,6 +25,7 @@
#include <sys/mman.h>
#include <sys/wait.h>
+#include <support/xunistd.h>
static pthread_mutex_t lock = PTHREAD_MUTEX_INITIALIZER;
static pthread_mutex_t lock2 = PTHREAD_MUTEX_INITIALIZER;
@@ -71,7 +72,7 @@ do_test (void)
int i;
for (i = 0; i < 20; ++i)
- write (fd, "foobar xyzzy", 12);
+ xwrite (fd, "foobar xyzzy", 12);
pthread_barrier_t *b;
b = mmap (NULL, sizeof (pthread_barrier_t), PROT_READ | PROT_WRITE,
diff --git a/sysdeps/pthread/tst-key1.c b/sysdeps/pthread/tst-key1.c
index 933edafef8..60245c4e47 100644
--- a/sysdeps/pthread/tst-key1.c
+++ b/sysdeps/pthread/tst-key1.c
@@ -22,6 +22,7 @@
#include <stdlib.h>
#include <unistd.h>
+#include <support/xunistd.h>
static int do_test (void);
@@ -52,7 +53,7 @@ do_test (void)
if (pthread_setspecific (keys[i], (const void *) (i + 100l)) != 0)
{
- write (2, "setspecific failed\n", 19);
+ xwrite (2, "setspecific failed\n", 19);
_exit (1);
}
}
@@ -61,13 +62,13 @@ do_test (void)
{
if (pthread_getspecific (keys[i]) != (void *) (i + 100l))
{
- write (2, "getspecific failed\n", 19);
+ xwrite (2, "getspecific failed\n", 19);
_exit (1);
}
if (pthread_key_delete (keys[i]) != 0)
{
- write (2, "key_delete failed\n", 18);
+ xwrite (2, "key_delete failed\n", 18);
_exit (1);
}
}
@@ -75,13 +76,13 @@ do_test (void)
/* Now it must be once again possible to allocate keys. */
if (pthread_key_create (&keys[0], NULL) != 0)
{
- write (2, "2nd key_create failed\n", 22);
+ xwrite (2, "2nd key_create failed\n", 22);
_exit (1);
}
if (pthread_key_delete (keys[0]) != 0)
{
- write (2, "2nd key_delete failed\n", 22);
+ xwrite (2, "2nd key_delete failed\n", 22);
_exit (1);
}
diff --git a/sysdeps/pthread/tst-signal1.c b/sysdeps/pthread/tst-signal1.c
index d1073e8459..d1082027ca 100644
--- a/sysdeps/pthread/tst-signal1.c
+++ b/sysdeps/pthread/tst-signal1.c
@@ -26,6 +26,7 @@
#include <sys/mman.h>
#include <sys/wait.h>
+#include <support/xunistd.h>
static sigset_t ss;
static pthread_barrier_t *b;
@@ -106,7 +107,7 @@ do_test (void)
int i;
for (i = 0; i < 20; ++i)
- write (fd, "foobar xyzzy", 12);
+ xwrite (fd, "foobar xyzzy", 12);
b = mmap (NULL, sizeof (pthread_barrier_t), PROT_READ | PROT_WRITE,
MAP_SHARED, fd, 0);
diff --git a/sysdeps/pthread/tst-signal2.c b/sysdeps/pthread/tst-signal2.c
index dfe7d9f64a..15b7747877 100644
--- a/sysdeps/pthread/tst-signal2.c
+++ b/sysdeps/pthread/tst-signal2.c
@@ -26,6 +26,7 @@
#include <sys/wait.h>
#include <string.h>
+#include <support/xunistd.h>
static sigset_t ss;
static pthread_barrier_t *b;
@@ -112,7 +113,7 @@ do_test (void)
int i;
for (i = 0; i < 20; ++i)
- write (fd, "foobar xyzzy", 12);
+ xwrite (fd, "foobar xyzzy", 12);
b = mmap (NULL, sizeof (pthread_barrier_t), PROT_READ | PROT_WRITE,
MAP_SHARED, fd, 0);
diff --git a/sysdeps/pthread/tst-timer.c b/sysdeps/pthread/tst-timer.c
index 47472ab8e1..4cfe0b67dc 100644
--- a/sysdeps/pthread/tst-timer.c
+++ b/sysdeps/pthread/tst-timer.c
@@ -25,6 +25,7 @@
#include <stdlib.h>
#include <stdint.h>
+#include <support/xunistd.h>
static void
notify_func1 (union sigval sigval)
@@ -45,7 +46,7 @@ signal_func (int sig)
{
static const char text[] = "signal_func\n";
signal (sig, signal_func);
- write (STDOUT_FILENO, text, sizeof text - 1);
+ xwrite (STDOUT_FILENO, text, sizeof text - 1);
}
static void
diff --git a/time/tst-cpuclock1.c b/time/tst-cpuclock1.c
index 6f2e70a58a..6a793e06df 100644
--- a/time/tst-cpuclock1.c
+++ b/time/tst-cpuclock1.c
@@ -27,6 +27,8 @@
#include <stdint.h>
#include <sys/wait.h>
+#include <support/xunistd.h>
+
/* This function is intended to rack up both user and system time. */
static void
chew_cpu (void)
@@ -41,7 +43,7 @@ chew_cpu (void)
for (int i = 0; i < 100; ++i)
for (size_t j = 0; j < sizeof buf; ++j)
buf[j] = 0xbb;
- write (nullfd, (char *) buf, sizeof buf);
+ xwrite (nullfd, (char *) buf, sizeof buf);
close (nullfd);
if (getppid () == 1)
_exit (2);
--
2.43.5

30
glibc-RHEL-50545-3.patch Normal file
View File

@ -0,0 +1,30 @@
From 34bb581e7713589d38c797c214f4c6bf2b14b702 Mon Sep 17 00:00:00 2001
From: Florian Weimer <fweimer@redhat.com>
Date: Fri, 16 Aug 2024 16:05:19 +0200
Subject: [PATCH] support: Include <string.h> for strcmp in
support_format_addrinfo.c
Content-type: text/plain; charset=UTF-8
This is currently implied by the internal headers, but it makes
sense not to rely on this.
Reviewed-by: Adhemerval Zanella <adhemerval.zanella@linaro.org>
---
support/support_format_addrinfo.c | 1 +
1 file changed, 1 insertion(+)
diff --git a/support/support_format_addrinfo.c b/support/support_format_addrinfo.c
index cbc72910a9..77f4db345c 100644
--- a/support/support_format_addrinfo.c
+++ b/support/support_format_addrinfo.c
@@ -22,6 +22,7 @@
#include <errno.h>
#include <stdio.h>
#include <stdlib.h>
+#include <string.h>
#include <support/support.h>
#include <support/xmemstream.h>
--
2.43.5

91
glibc-RHEL-50545-4.patch Normal file
View File

@ -0,0 +1,91 @@
From 921690512946d73bf66a8c495baff31316e4489f Mon Sep 17 00:00:00 2001
From: Florian Weimer <fweimer@redhat.com>
Date: Fri, 16 Aug 2024 16:05:19 +0200
Subject: [PATCH] support: Add the xstatx function
Content-type: text/plain; charset=UTF-8
Reviewed-by: Adhemerval Zanella <adhemerval.zanella@linaro.org>
Conflict:
support/Makefile
context
---
support/Makefile | 1 +
support/xstatx.c | 32 ++++++++++++++++++++++++++++++++
support/xunistd.h | 2 ++
3 files changed, 35 insertions(+)
create mode 100644 support/xstatx.c
diff --git a/support/Makefile b/support/Makefile
index aa57207bdc..5b1c96a49e 100644
--- a/support/Makefile
+++ b/support/Makefile
@@ -200,6 +200,7 @@ libsupport-routines = \
xsignal \
xsigstack \
xsocket \
+ xstatx \
xposix_spawn \
xposix_spawn_file_actions_addclose \
xposix_spawn_file_actions_adddup2 \
diff --git a/support/xstatx.c b/support/xstatx.c
new file mode 100644
index 0000000000..621f2440f8
--- /dev/null
+++ b/support/xstatx.c
@@ -0,0 +1,32 @@
+/* Error-checking wrapper for statx.
+ Copyright (C) 2024 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, see
+ <https://www.gnu.org/licenses/>. */
+
+#include <support/xunistd.h>
+
+#include <fcntl.h>
+#include <support/check.h>
+#include <sys/stat.h>
+
+void
+xstatx (int fd, const char *path, int flags, unsigned int mask,
+ struct statx *stx)
+{
+ if (statx (fd, path, flags, mask, stx) != 0)
+ FAIL_EXIT1 ("statx (AT_FDCWD, \"%s\", 0x%x, 0x%x): %m",
+ path, (unsigned int) flags, mask);
+}
diff --git a/support/xunistd.h b/support/xunistd.h
index 13be9a46a3..cc74c4fad0 100644
--- a/support/xunistd.h
+++ b/support/xunistd.h
@@ -30,6 +30,7 @@
__BEGIN_DECLS
struct stat64;
+struct statx;
pid_t xfork (void);
pid_t xwaitpid (pid_t, int *status, int flags);
@@ -51,6 +52,7 @@ void __REDIRECT (xstat, (const char *path, struct stat *), xstat_time64);
void __REDIRECT (xlstat, (const char *path, struct stat *), xlstat_time64);
void __REDIRECT (xfstat, (int fd, struct stat *), xfstat_time64);
#endif
+void xstatx (int, const char *, int, unsigned int, struct statx *);
void xmkdir (const char *path, mode_t);
void xchroot (const char *path);
void xunlink (const char *path);
--
2.43.5

410
glibc-RHEL-50545-5.patch Normal file
View File

@ -0,0 +1,410 @@
From bf2927484152e12996af60ea439cf94b66fcd81d Mon Sep 17 00:00:00 2001
From: Florian Weimer <fweimer@redhat.com>
Date: Fri, 16 Aug 2024 16:05:20 +0200
Subject: [PATCH] io: Use struct statx and xstatx in tests
Content-type: text/plain; charset=UTF-8
This avoids the need to define struct_statx to an appropriate
struct stat type variant because struct statx does not change
based on time/file offset flags.
Reviewed-by: Adhemerval Zanella <adhemerval.zanella@linaro.org>
---
io/tst-futimens-time64.c | 1 -
io/tst-futimens.c | 13 +++++--------
io/tst-futimes-time64.c | 1 -
io/tst-futimes.c | 13 +++++--------
io/tst-futimesat-time64.c | 3 ---
io/tst-futimesat.c | 30 ++++++++----------------------
io/tst-lutimes-time64.c | 1 -
io/tst-lutimes.c | 26 ++++++++++++--------------
io/tst-utime-time64.c | 1 -
io/tst-utime.c | 13 +++++--------
io/tst-utimensat-time64.c | 1 -
io/tst-utimensat.c | 35 +++++++++++++++++------------------
io/tst-utimes-time64.c | 1 -
io/tst-utimes.c | 13 +++++--------
14 files changed, 57 insertions(+), 95 deletions(-)
diff --git a/io/tst-futimens-time64.c b/io/tst-futimens-time64.c
index 88fcb38489..71204a6166 100644
--- a/io/tst-futimens-time64.c
+++ b/io/tst-futimens-time64.c
@@ -1,2 +1 @@
-#define struct_stat struct stat
#include "tst-futimens.c"
diff --git a/io/tst-futimens.c b/io/tst-futimens.c
index 6204befedd..075ca42b93 100644
--- a/io/tst-futimens.c
+++ b/io/tst-futimens.c
@@ -18,26 +18,23 @@
#include <support/check.h>
#include <support/xunistd.h>
+#include <fcntl.h>
#include <sys/stat.h>
-#ifndef struct_stat
-# define struct_stat struct stat64
-#endif
-
static int
test_futimens_helper (const char *file, int fd, const struct timespec *ts)
{
int result = futimens (fd, ts);
TEST_VERIFY_EXIT (result == 0);
- struct_stat st;
- xfstat (fd, &st);
+ struct statx st;
+ xstatx (fd, "", AT_EMPTY_PATH, STATX_BASIC_STATS, &st);
/* Check if seconds for atime match */
- TEST_COMPARE (st.st_atime, ts[0].tv_sec);
+ TEST_COMPARE (st.stx_atime.tv_sec, ts[0].tv_sec);
/* Check if seconds for mtime match */
- TEST_COMPARE (st.st_mtime, ts[1].tv_sec);
+ TEST_COMPARE (st.stx_mtime.tv_sec, ts[1].tv_sec);
return 0;
}
diff --git a/io/tst-futimes-time64.c b/io/tst-futimes-time64.c
index d489c265d1..eeb4bed7c4 100644
--- a/io/tst-futimes-time64.c
+++ b/io/tst-futimes-time64.c
@@ -1,2 +1 @@
-#define struct_stat struct stat
#include "tst-futimes.c"
diff --git a/io/tst-futimes.c b/io/tst-futimes.c
index d21acf6a24..612fe460cf 100644
--- a/io/tst-futimes.c
+++ b/io/tst-futimes.c
@@ -18,27 +18,24 @@
#include <support/check.h>
#include <support/xunistd.h>
+#include <fcntl.h>
#include <sys/stat.h>
#include <sys/time.h>
-#ifndef struct_stat
-# define struct_stat struct stat64
-#endif
-
static int
test_futimens_helper (const char *file, int fd, const struct timeval *tv)
{
int r = futimes (fd, tv);
TEST_VERIFY_EXIT (r == 0);
- struct_stat st;
- xfstat (fd, &st);
+ struct statx st;
+ xstatx (fd, "", AT_EMPTY_PATH, STATX_BASIC_STATS, &st);
/* Check if seconds for atime match */
- TEST_COMPARE (st.st_atime, tv[0].tv_sec);
+ TEST_COMPARE (st.stx_atime.tv_sec, tv[0].tv_sec);
/* Check if seconds for mtime match */
- TEST_COMPARE (st.st_mtime, tv[1].tv_sec);
+ TEST_COMPARE (st.stx_mtime.tv_sec, tv[1].tv_sec);
return 0;
}
diff --git a/io/tst-futimesat-time64.c b/io/tst-futimesat-time64.c
index f6c0500eef..1585317579 100644
--- a/io/tst-futimesat-time64.c
+++ b/io/tst-futimesat-time64.c
@@ -1,4 +1 @@
-#define struct_stat struct stat
-#define fstat fstat
-#define fstatat fstatat
#include "io/tst-futimesat.c"
diff --git a/io/tst-futimesat.c b/io/tst-futimesat.c
index 67a8551beb..feae4e7aa7 100644
--- a/io/tst-futimesat.c
+++ b/io/tst-futimesat.c
@@ -30,12 +30,6 @@
#include <support/temp_file.h>
#include <support/xunistd.h>
-#ifndef struct_stat
-# define struct_stat struct stat64
-# define fstat fstat64
-# define fstatat fstatat64
-#endif
-
static int dir_fd;
static void
@@ -118,19 +112,15 @@ do_test (void)
xwrite (fd, "hello", 5);
puts ("file created");
- struct_stat st1;
- if (fstat (fd, &st1) != 0)
- {
- puts ("fstat64 failed");
- return 1;
- }
+ struct statx st1;
+ xstatx (fd, "", AT_EMPTY_PATH, STATX_BASIC_STATS, &st1);
close (fd);
struct timeval tv[2];
- tv[0].tv_sec = st1.st_atime + 1;
+ tv[0].tv_sec = st1.stx_atime.tv_sec + 1;
tv[0].tv_usec = 0;
- tv[1].tv_sec = st1.st_mtime + 1;
+ tv[1].tv_sec = st1.stx_mtime.tv_sec + 1;
tv[1].tv_usec = 0;
if (futimesat (dir_fd, "some-file", tv) != 0)
{
@@ -138,16 +128,12 @@ do_test (void)
return 1;
}
- struct_stat st2;
- if (fstatat (dir_fd, "some-file", &st2, 0) != 0)
- {
- puts ("fstatat64 failed");
- return 1;
- }
+ struct statx st2;
+ xstatx (dir_fd, "some-file", 0, STATX_BASIC_STATS, &st2);
- if (st2.st_mtime != tv[1].tv_sec
+ if (st2.stx_mtime.tv_sec != tv[1].tv_sec
#ifdef _STATBUF_ST_NSEC
- || st2.st_mtim.tv_nsec != 0
+ || st2.stx_mtime.tv_nsec != 0
#endif
)
{
diff --git a/io/tst-lutimes-time64.c b/io/tst-lutimes-time64.c
index 06caec0a91..c5bea965da 100644
--- a/io/tst-lutimes-time64.c
+++ b/io/tst-lutimes-time64.c
@@ -1,2 +1 @@
-#define struct_stat struct stat
#include "tst-lutimes.c"
diff --git a/io/tst-lutimes.c b/io/tst-lutimes.c
index edef5ab90e..78bcc58291 100644
--- a/io/tst-lutimes.c
+++ b/io/tst-lutimes.c
@@ -18,34 +18,32 @@
#include <support/check.h>
#include <support/xunistd.h>
+#include <fcntl.h>
#include <sys/stat.h>
#include <sys/time.h>
-#ifndef struct_stat
-# define struct_stat struct stat64
-#endif
-
static int
test_lutimes_helper (const char *testfile, int fd, const char *testlink,
const struct timeval *tv)
{
- struct_stat stfile_orig;
- xlstat (testfile, &stfile_orig);
+ struct statx stfile_orig;
+ xstatx (AT_FDCWD, testfile, AT_SYMLINK_NOFOLLOW, STATX_BASIC_STATS,
+ &stfile_orig);
TEST_VERIFY_EXIT (lutimes (testlink, tv) == 0);
- struct_stat stlink;
- xlstat (testlink, &stlink);
+ struct statx stlink;
+ xstatx (AT_FDCWD, testlink, AT_SYMLINK_NOFOLLOW, STATX_BASIC_STATS, &stlink);
- TEST_COMPARE (stlink.st_atime, tv[0].tv_sec);
- TEST_COMPARE (stlink.st_mtime, tv[1].tv_sec);
+ TEST_COMPARE (stlink.stx_atime.tv_sec, tv[0].tv_sec);
+ TEST_COMPARE (stlink.stx_mtime.tv_sec, tv[1].tv_sec);
/* Check if the timestamp from original file is not changed. */
- struct_stat stfile;
- xlstat (testfile, &stfile);
+ struct statx stfile;
+ xstatx (AT_FDCWD, testfile, AT_SYMLINK_NOFOLLOW, STATX_BASIC_STATS, &stfile);
- TEST_COMPARE (stfile_orig.st_atime, stfile.st_atime);
- TEST_COMPARE (stfile_orig.st_mtime, stfile.st_mtime);
+ TEST_COMPARE (stfile_orig.stx_atime.tv_sec, stfile.stx_atime.tv_sec);
+ TEST_COMPARE (stfile_orig.stx_mtime.tv_sec, stfile.stx_mtime.tv_sec);
return 0;
}
diff --git a/io/tst-utime-time64.c b/io/tst-utime-time64.c
index eb62f59126..8894592a15 100644
--- a/io/tst-utime-time64.c
+++ b/io/tst-utime-time64.c
@@ -1,2 +1 @@
-#define struct_stat struct stat
#include "tst-utime.c"
diff --git a/io/tst-utime.c b/io/tst-utime.c
index e2e6dcd04c..f329358289 100644
--- a/io/tst-utime.c
+++ b/io/tst-utime.c
@@ -19,26 +19,23 @@
#include <utime.h>
#include <support/check.h>
#include <support/xunistd.h>
+#include <fcntl.h>
#include <sys/stat.h>
-#ifndef struct_stat
-# define struct_stat struct stat64
-#endif
-
static int
test_utime_helper (const char *file, int fd, const struct utimbuf *ut)
{
int result = utime (file, ut);
TEST_VERIFY_EXIT (result == 0);
- struct_stat st;
- xfstat (fd, &st);
+ struct statx st;
+ xstatx (fd, "", AT_EMPTY_PATH, STATX_BASIC_STATS, &st);
/* Check if seconds for actime match */
- TEST_COMPARE (st.st_atime, ut->actime);
+ TEST_COMPARE (st.stx_atime.tv_sec, ut->actime);
/* Check if seconds for modtime match */
- TEST_COMPARE (st.st_mtime, ut->modtime);
+ TEST_COMPARE (st.stx_mtime.tv_sec, ut->modtime);
return 0;
}
diff --git a/io/tst-utimensat-time64.c b/io/tst-utimensat-time64.c
index 7ac7d8df1d..5d60fce881 100644
--- a/io/tst-utimensat-time64.c
+++ b/io/tst-utimensat-time64.c
@@ -1,2 +1 @@
-#define struct_stat struct stat
#include "tst-utimensat.c"
diff --git a/io/tst-utimensat.c b/io/tst-utimensat.c
index 3d9a72c471..2a756d7b07 100644
--- a/io/tst-utimensat.c
+++ b/io/tst-utimensat.c
@@ -22,10 +22,6 @@
#include <sys/stat.h>
#include <sys/time.h>
-#ifndef struct_stat
-# define struct_stat struct stat64
-#endif
-
static int
test_utimesat_helper (const char *testfile, int fd, const char *testlink,
const struct timespec *ts)
@@ -33,35 +29,38 @@ test_utimesat_helper (const char *testfile, int fd, const char *testlink,
{
TEST_VERIFY_EXIT (utimensat (fd, testfile, ts, 0) == 0);
- struct_stat st;
- xfstat (fd, &st);
+ struct statx st;
+ xstatx (fd, "", AT_EMPTY_PATH, STATX_BASIC_STATS, &st);
/* Check if seconds for atime match */
- TEST_COMPARE (st.st_atime, ts[0].tv_sec);
+ TEST_COMPARE (st.stx_atime.tv_sec, ts[0].tv_sec);
/* Check if seconds for mtime match */
- TEST_COMPARE (st.st_mtime, ts[1].tv_sec);
+ TEST_COMPARE (st.stx_mtime.tv_sec, ts[1].tv_sec);
}
{
- struct_stat stfile_orig;
- xlstat (testfile, &stfile_orig);
+ struct statx stfile_orig;
+ xstatx (AT_FDCWD, testfile, AT_SYMLINK_NOFOLLOW, STATX_BASIC_STATS,
+ &stfile_orig);
TEST_VERIFY_EXIT (utimensat (0 /* ignored */, testlink, ts,
AT_SYMLINK_NOFOLLOW)
== 0);
- struct_stat stlink;
- xlstat (testlink, &stlink);
+ struct statx stlink;
+ xstatx (AT_FDCWD, testlink, AT_SYMLINK_NOFOLLOW, STATX_BASIC_STATS,
+ &stlink);
- TEST_COMPARE (stlink.st_atime, ts[0].tv_sec);
- TEST_COMPARE (stlink.st_mtime, ts[1].tv_sec);
+ TEST_COMPARE (stlink.stx_atime.tv_sec, ts[0].tv_sec);
+ TEST_COMPARE (stlink.stx_mtime.tv_sec, ts[1].tv_sec);
/* Check if the timestamp from original file is not changed. */
- struct_stat stfile;
- xlstat (testfile, &stfile);
+ struct statx stfile;
+ xstatx (AT_FDCWD, testfile, AT_SYMLINK_NOFOLLOW, STATX_BASIC_STATS,
+ &stfile);
- TEST_COMPARE (stfile_orig.st_atime, stfile.st_atime);
- TEST_COMPARE (stfile_orig.st_mtime, stfile.st_mtime);
+ TEST_COMPARE (stfile_orig.stx_atime.tv_sec, stfile.stx_atime.tv_sec);
+ TEST_COMPARE (stfile_orig.stx_mtime.tv_sec, stfile.stx_mtime.tv_sec);
}
return 0;
diff --git a/io/tst-utimes-time64.c b/io/tst-utimes-time64.c
index 234ec02541..026ef5f78d 100644
--- a/io/tst-utimes-time64.c
+++ b/io/tst-utimes-time64.c
@@ -1,2 +1 @@
-#define struct_stat struct stat
#include "tst-utimes.c"
diff --git a/io/tst-utimes.c b/io/tst-utimes.c
index 8edcfabebf..6cd436c5a0 100644
--- a/io/tst-utimes.c
+++ b/io/tst-utimes.c
@@ -18,28 +18,25 @@
#include <support/check.h>
#include <support/xunistd.h>
+#include <fcntl.h>
#include <sys/stat.h>
#include <sys/time.h>
#include <time.h>
-#ifndef struct_stat
-# define struct_stat struct stat64
-#endif
-
static int
test_utimes_helper (const char *file, int fd, const struct timeval *tv)
{
int result = utimes (file, tv);
TEST_VERIFY_EXIT (result == 0);
- struct_stat st;
- xfstat (fd, &st);
+ struct statx st;
+ xstatx (fd, "", AT_EMPTY_PATH, STATX_BASIC_STATS, &st);
/* Check if seconds for atime match */
- TEST_COMPARE (st.st_atime, tv[0].tv_sec);
+ TEST_COMPARE (st.stx_atime.tv_sec, tv[0].tv_sec);
/* Check if seconds for mtime match */
- TEST_COMPARE (st.st_mtime, tv[1].tv_sec);
+ TEST_COMPARE (st.stx_mtime.tv_sec, tv[1].tv_sec);
return 0;
}
--
2.43.5

452
glibc-RHEL-50545-6.patch Normal file
View File

@ -0,0 +1,452 @@
From e7c14e542d8d858b824b5df4f4e3dc93695e6171 Mon Sep 17 00:00:00 2001
From: Florian Weimer <fweimer@redhat.com>
Date: Fri, 16 Aug 2024 16:05:20 +0200
Subject: [PATCH] support: Use macros for *stat wrappers
Content-type: text/plain; charset=UTF-8
Macros will automatically use the correct types, without
having to fiddle with internal glibc macros. It's also
impossible to get the types wrong due to aliasing because
support_check_stat_fd and support_check_stat_path do not
depend on the struct stat* types.
The changes reveal some inconsistencies in tests.
Reviewed-by: Adhemerval Zanella <adhemerval.zanella@linaro.org>
Conflicts
locale/tst-localedef-path-norm.c
context
support/Makefile
context
support/xunistd.h
context
all
copyright years
---
elf/tst-ldconfig-bad-aux-cache.c | 2 +-
io/tst-copy_file_range.c | 2 +-
io/tst-statx.c | 4 +--
locale/tst-localedef-path-norm.c | 2 +-
localedata/tst-localedef-hardlinks.c | 2 +-
posix/tst-execveat.c | 2 +-
stdio-common/tst-renameat2.c | 2 +-
stdlib/tst-system.c | 2 +-
support/Makefile | 8 ++---
support/support-xfstat-time64.c | 32 -------------------
support/support-xstat-time64.c | 32 -------------------
support/support-xstat.c | 30 -----------------
support/{xlstat.c => support_check_stat_fd.c} | 11 +++----
...ort-xfstat.c => support_check_stat_path.c} | 9 +++---
support/xlstat-time64.c | 32 -------------------
support/xunistd.h | 30 ++++++++---------
16 files changed, 34 insertions(+), 168 deletions(-)
delete mode 100644 support/support-xfstat-time64.c
delete mode 100644 support/support-xstat-time64.c
delete mode 100644 support/support-xstat.c
rename support/{xlstat.c => support_check_stat_fd.c} (76%)
rename support/{support-xfstat.c => support_check_stat_path.c} (81%)
delete mode 100644 support/xlstat-time64.c
diff --git a/elf/tst-ldconfig-bad-aux-cache.c b/elf/tst-ldconfig-bad-aux-cache.c
index 7f1fbb5252..8c2e62ecc2 100644
--- a/elf/tst-ldconfig-bad-aux-cache.c
+++ b/elf/tst-ldconfig-bad-aux-cache.c
@@ -85,7 +85,7 @@ do_test (void)
support_capture_subprocess_check (&result, "execv", 0, sc_allow_none);
support_capture_subprocess_free (&result);
- xstat (path, &fs);
+ xstat64 (path, &fs);
size = fs.st_size;
/* Run 3 tests, each truncating aux-cache shorter and shorter. */
diff --git a/io/tst-copy_file_range.c b/io/tst-copy_file_range.c
index 9837b7c339..3d7b0aa901 100644
--- a/io/tst-copy_file_range.c
+++ b/io/tst-copy_file_range.c
@@ -117,7 +117,7 @@ simple_file_copy (void)
TEST_COMPARE (xlseek (outfd, 0, SEEK_CUR), 6 + length);
struct stat64 st;
- xfstat (outfd, &st);
+ xfstat64 (outfd, &st);
if (length > 0)
TEST_COMPARE (st.st_size, out_skipped + length);
else
diff --git a/io/tst-statx.c b/io/tst-statx.c
index d84568859e..685924ae76 100644
--- a/io/tst-statx.c
+++ b/io/tst-statx.c
@@ -78,7 +78,7 @@ both_implementations_tests (statx_function impl, const char *path, int fd)
struct statx stx = { 0, };
TEST_COMPARE (statx (fd, "", AT_EMPTY_PATH, STATX_BASIC_STATS, &stx), 0);
struct stat64 st;
- xfstat (fd, &st);
+ xfstat64 (fd, &st);
TEST_COMPARE (stx.stx_mode, st.st_mode);
TEST_COMPARE (stx.stx_dev_major, major (st.st_dev));
TEST_COMPARE (stx.stx_dev_minor, minor (st.st_dev));
@@ -88,7 +88,7 @@ both_implementations_tests (statx_function impl, const char *path, int fd)
TEST_COMPARE (statx (AT_FDCWD, "/dev/null", 0, STATX_BASIC_STATS, &stx),
0);
struct stat64 st;
- xstat ("/dev/null", &st);
+ xstat64 ("/dev/null", &st);
TEST_COMPARE (stx.stx_mode, st.st_mode);
TEST_COMPARE (stx.stx_dev_major, major (st.st_dev));
TEST_COMPARE (stx.stx_dev_minor, minor (st.st_dev));
diff --git a/locale/tst-localedef-path-norm.c b/locale/tst-localedef-path-norm.c
index ffe8cbd467..f592b9a960 100644
--- a/locale/tst-localedef-path-norm.c
+++ b/locale/tst-localedef-path-norm.c
@@ -81,7 +81,7 @@ run_test (struct test_closure data)
support_capture_subprocess_free (&result);
/* Verify path is present and is a directory. */
- xstat (path, &fs);
+ xstat64 (path, &fs);
TEST_VERIFY_EXIT (S_ISDIR (fs.st_mode));
printf ("info: Directory '%s' exists.\n", path);
}
diff --git a/localedata/tst-localedef-hardlinks.c b/localedata/tst-localedef-hardlinks.c
index e88215a150..23927b462f 100644
--- a/localedata/tst-localedef-hardlinks.c
+++ b/localedata/tst-localedef-hardlinks.c
@@ -62,7 +62,7 @@ check_link (struct test_data step)
char *output;
output = xasprintf ("%s/%s", support_complocaledir_prefix, step.output);
- xstat (output, &locale);
+ xstat64 (output, &locale);
free (output);
TEST_COMPARE (locale.st_nlink, step.st_nlink);
}
diff --git a/posix/tst-execveat.c b/posix/tst-execveat.c
index 4565d6b19f..dde034a9f1 100644
--- a/posix/tst-execveat.c
+++ b/posix/tst-execveat.c
@@ -155,7 +155,7 @@ do_test (void)
tmp_sh = xasprintf ("%s/tmp_sh", tmp_dir);
add_temp_file (tmp_sh);
fd_out = xopen (symlink_name, O_CREAT | O_WRONLY, 0);
- xstat ("/bin/sh", &st);
+ xstat64 ("/bin/sh", &st);
fd = xopen ("/bin/sh", O_RDONLY, 0);
xcopy_file_range (fd, 0, fd_out, 0, st.st_size, 0);
xfchmod (fd_out, 0700);
diff --git a/stdio-common/tst-renameat2.c b/stdio-common/tst-renameat2.c
index b65afed75e..7f4345f716 100644
--- a/stdio-common/tst-renameat2.c
+++ b/stdio-common/tst-renameat2.c
@@ -82,7 +82,7 @@ static void
check_size (const char *path, off64_t expected_size)
{
struct stat64 st;
- xstat (path, &st);
+ xstat64 (path, &st);
if (st.st_size != expected_size)
FAIL_EXIT1 ("file \"%s\": expected size %lld, actual size %lld",
path, (unsigned long long int) expected_size,
diff --git a/stdlib/tst-system.c b/stdlib/tst-system.c
index 47c742f963..b5b630a41b 100644
--- a/stdlib/tst-system.c
+++ b/stdlib/tst-system.c
@@ -156,7 +156,7 @@ do_test (void)
{
struct stat64 st;
- xstat (_PATH_BSHELL, &st);
+ xstat64 (_PATH_BSHELL, &st);
mode_t mode = st.st_mode;
xchmod (_PATH_BSHELL, mode & ~(S_IXUSR | S_IXGRP | S_IXOTH));
diff --git a/support/Makefile b/support/Makefile
index 5b1c96a49e..6e3c55394f 100644
--- a/support/Makefile
+++ b/support/Makefile
@@ -42,14 +42,12 @@ libsupport-routines = \
resolv_test \
set_fortify_handler \
support_stack_alloc \
- support-xfstat \
- support-xfstat-time64 \
- support-xstat \
- support-xstat-time64 \
support_become_root \
support_can_chroot \
support_capture_subprocess \
support_capture_subprocess_check \
+ support_check_stat_fd \
+ support_check_stat_path \
support_chroot \
support_copy_file \
support_copy_file_range \
@@ -130,8 +128,6 @@ libsupport-routines = \
xgetsockname \
xlisten \
xlseek \
- xlstat \
- xlstat-time64 \
xmalloc \
xmemstream \
xmkdir \
diff --git a/support/support-xfstat-time64.c b/support/support-xfstat-time64.c
deleted file mode 100644
index 589a69bb3e..0000000000
--- a/support/support-xfstat-time64.c
+++ /dev/null
@@ -1,32 +0,0 @@
-/* 64-bit time_t stat with error checking.
- Copyright (C) 2021 Free Software Foundation, Inc.
- This file is part of the GNU C Library.
-
- The GNU C Library is free software; you can redistribute it and/or
- modify it under the terms of the GNU Lesser General Public
- License as published by the Free Software Foundation; either
- version 2.1 of the License, or (at your option) any later version.
-
- The GNU C Library is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- Lesser General Public License for more details.
-
- You should have received a copy of the GNU Lesser General Public
- License along with the GNU C Library; if not, see
- <https://www.gnu.org/licenses/>. */
-
-/* NB: Non-standard file name to avoid sysdeps override for xstat. */
-
-#include <support/check.h>
-#include <support/xunistd.h>
-#include <sys/stat.h>
-
-#if __TIMESIZE != 64
-void
-xfstat_time64 (int fd, struct __stat64_t64 *result)
-{
- if (__fstat64_time64 (fd, result) != 0)
- FAIL_EXIT1 ("__fstat64_time64 (%d): %m", fd);
-}
-#endif
diff --git a/support/support-xstat-time64.c b/support/support-xstat-time64.c
deleted file mode 100644
index 451948734a..0000000000
--- a/support/support-xstat-time64.c
+++ /dev/null
@@ -1,32 +0,0 @@
-/* 64-bit time_t stat with error checking.
- Copyright (C) 2021 Free Software Foundation, Inc.
- This file is part of the GNU C Library.
-
- The GNU C Library is free software; you can redistribute it and/or
- modify it under the terms of the GNU Lesser General Public
- License as published by the Free Software Foundation; either
- version 2.1 of the License, or (at your option) any later version.
-
- The GNU C Library is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- Lesser General Public License for more details.
-
- You should have received a copy of the GNU Lesser General Public
- License along with the GNU C Library; if not, see
- <https://www.gnu.org/licenses/>. */
-
-/* NB: Non-standard file name to avoid sysdeps override for xstat. */
-
-#include <support/check.h>
-#include <support/xunistd.h>
-#include <sys/stat.h>
-
-#if __TIMESIZE != 64
-void
-xstat_time64 (const char *path, struct __stat64_t64 *result)
-{
- if (__stat64_time64 (path, result) != 0)
- FAIL_EXIT1 ("__stat64_time64 (\"%s\"): %m", path);
-}
-#endif
diff --git a/support/support-xstat.c b/support/support-xstat.c
deleted file mode 100644
index ce866f74d2..0000000000
--- a/support/support-xstat.c
+++ /dev/null
@@ -1,30 +0,0 @@
-/* stat64 with error checking.
- Copyright (C) 2017-2021 Free Software Foundation, Inc.
- This file is part of the GNU C Library.
-
- The GNU C Library is free software; you can redistribute it and/or
- modify it under the terms of the GNU Lesser General Public
- License as published by the Free Software Foundation; either
- version 2.1 of the License, or (at your option) any later version.
-
- The GNU C Library is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- Lesser General Public License for more details.
-
- You should have received a copy of the GNU Lesser General Public
- License along with the GNU C Library; if not, see
- <https://www.gnu.org/licenses/>. */
-
-/* NB: Non-standard file name to avoid sysdeps override for xstat. */
-
-#include <support/check.h>
-#include <support/xunistd.h>
-#include <sys/stat.h>
-
-void
-xstat (const char *path, struct stat64 *result)
-{
- if (stat64 (path, result) != 0)
- FAIL_EXIT1 ("stat64 (\"%s\"): %m", path);
-}
diff --git a/support/xlstat.c b/support/support_check_stat_fd.c
similarity index 76%
rename from support/xlstat.c
rename to support/support_check_stat_fd.c
index 87df988879..4c12adf6b7 100644
--- a/support/xlstat.c
+++ b/support/support_check_stat_fd.c
@@ -1,5 +1,5 @@
-/* lstat64 with error checking.
- Copyright (C) 2017-2021 Free Software Foundation, Inc.
+/* Error checking for descriptor-based stat functions.
+ Copyright (C) 2024 Free Software Foundation, Inc.
This file is part of the GNU C Library.
The GNU C Library is free software; you can redistribute it and/or
@@ -18,11 +18,10 @@
#include <support/check.h>
#include <support/xunistd.h>
-#include <sys/stat.h>
void
-xlstat (const char *path, struct stat64 *result)
+support_check_stat_fd (const char *name, int fd, int result)
{
- if (lstat64 (path, result) != 0)
- FAIL_EXIT1 ("lstat64 (\"%s\"): %m", path);
+ if (result != 0)
+ FAIL_EXIT1 ("%s (%d): %m", name, fd);
}
diff --git a/support/support-xfstat.c b/support/support_check_stat_path.c
similarity index 81%
rename from support/support-xfstat.c
rename to support/support_check_stat_path.c
index ab4b01c97d..3cf72afe59 100644
--- a/support/support-xfstat.c
+++ b/support/support_check_stat_path.c
@@ -1,4 +1,4 @@
-/* fstat64 with error checking.
+/* Error checking for path-based stat functions.
Copyright (C) 2017-2021 Free Software Foundation, Inc.
This file is part of the GNU C Library.
@@ -18,11 +18,10 @@
#include <support/check.h>
#include <support/xunistd.h>
-#include <sys/stat.h>
void
-xfstat (int fd, struct stat64 *result)
+support_check_stat_path (const char *name, const char *path, int result)
{
- if (fstat64 (fd, result) != 0)
- FAIL_EXIT1 ("fstat64 (%d): %m", fd);
+ if (result != 0)
+ FAIL_EXIT1 ("%s (\"%s\"): %m", name, path);
}
diff --git a/support/xlstat-time64.c b/support/xlstat-time64.c
deleted file mode 100644
index 2bc3ca6593..0000000000
--- a/support/xlstat-time64.c
+++ /dev/null
@@ -1,32 +0,0 @@
-/* 64-bit time_t stat with error checking.
- Copyright (C) 2021 Free Software Foundation, Inc.
- This file is part of the GNU C Library.
-
- The GNU C Library is free software; you can redistribute it and/or
- modify it under the terms of the GNU Lesser General Public
- License as published by the Free Software Foundation; either
- version 2.1 of the License, or (at your option) any later version.
-
- The GNU C Library is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- Lesser General Public License for more details.
-
- You should have received a copy of the GNU Lesser General Public
- License along with the GNU C Library; if not, see
- <https://www.gnu.org/licenses/>. */
-
-/* NB: Non-standard file name to avoid sysdeps override for xstat. */
-
-#include <support/check.h>
-#include <support/xunistd.h>
-#include <sys/stat.h>
-
-#if __TIMESIZE != 64
-void
-xlstat_time64 (const char *path, struct __stat64_t64 *result)
-{
- if (__lstat64_time64 (path, result) != 0)
- FAIL_EXIT1 ("__lstat64_time64 (\"%s\"): %m", path);
-}
-#endif
diff --git a/support/xunistd.h b/support/xunistd.h
index cc74c4fad0..204951bce7 100644
--- a/support/xunistd.h
+++ b/support/xunistd.h
@@ -29,7 +29,6 @@
__BEGIN_DECLS
-struct stat64;
struct statx;
pid_t xfork (void);
@@ -37,21 +36,20 @@ pid_t xwaitpid (pid_t, int *status, int
void xpipe (int[2]);
void xdup2 (int, int);
int xopen (const char *path, int flags, mode_t);
-#ifndef __USE_TIME_BITS64
-# ifdef __USE_FILE_OFFSET64
-void xstat (const char *path, struct stat *);
-void xlstat (const char *path, struct stat *);
-void xfstat (int fd, struct stat *);
-# else
-void xstat (const char *path, struct stat64 *);
-void xlstat (const char *path, struct stat64 *);
-void xfstat (int fd, struct stat64 *);
-# endif
-#else
-void __REDIRECT (xstat, (const char *path, struct stat *), xstat_time64);
-void __REDIRECT (xlstat, (const char *path, struct stat *), xlstat_time64);
-void __REDIRECT (xfstat, (int fd, struct stat *), xfstat_time64);
-#endif
+void support_check_stat_fd (const char *name, int fd, int result);
+void support_check_stat_path (const char *name, const char *path, int result);
+#define xstat(path, st) \
+ (support_check_stat_path ("stat", (path), stat ((path), (st))))
+#define xfstat(fd, st) \
+ (support_check_stat_fd ("fstat", (fd), fstat ((fd), (st))))
+#define xlstat(path, st) \
+ (support_check_stat_path ("lstat", (path), lstat ((path), (st))))
+#define xstat64(path, st) \
+ (support_check_stat_path ("stat64", (path), stat64 ((path), (st))))
+#define xfstat64(fd, st) \
+ (support_check_stat_fd ("fstat64", (fd), fstat64 ((fd), (st))))
+#define xlstat64(path, st) \
+ (support_check_stat_path ("lstat64", (path), lstat64 ((path), (st))))
void xstatx (int, const char *, int, unsigned int, struct statx *);
void xmkdir (const char *path, mode_t);
void xchroot (const char *path);
--
2.43.5

47
glibc-RHEL-50545-7.patch Normal file
View File

@ -0,0 +1,47 @@
From 34e52acd55d69964d14fb3188c5538442b8b32be Mon Sep 17 00:00:00 2001
From: Florian Weimer <fweimer@redhat.com>
Date: Thu, 22 Aug 2024 16:14:17 +0200
Subject: [PATCH] support: Report errno constants in TEST_COMPARE failures
Content-type: text/plain; charset=UTF-8
If the expression is errno, decode it as an errno constant
using strerrorname_np.
Reviewed-by: Arjun Shankar <arjun@redhat.com>
---
support/support_test_compare_failure.c | 11 ++++++++++-
1 file changed, 10 insertions(+), 1 deletion(-)
diff --git a/support/support_test_compare_failure.c b/support/support_test_compare_failure.c
index ae73d200cd..dba79e413f 100644
--- a/support/support_test_compare_failure.c
+++ b/support/support_test_compare_failure.c
@@ -17,7 +17,9 @@
<https://www.gnu.org/licenses/>. */
#include <errno.h>
+#include <limits.h>
#include <stdio.h>
+#include <string.h>
#include <support/check.h>
static void
@@ -31,7 +33,14 @@ report (const char *which, const char *expr, long long value, int positive,
printf ("%lld", value);
unsigned long long mask
= (~0ULL) >> (8 * (sizeof (unsigned long long) - size));
- printf (" (0x%llx); from: %s\n", (unsigned long long) value & mask, expr);
+ const char *errno_constant = NULL;
+ if (strcmp (expr, "errno") == 0
+ && positive && (unsigned long long int) value <= INT_MAX)
+ errno_constant = strerrorname_np (value);
+ printf (" (0x%llx", (unsigned long long) value & mask);
+ if (errno_constant != NULL)
+ printf (", %s", errno_constant);
+ printf ("); from: %s\n", expr);
}
void
--
2.43.5

1661
glibc-RHEL-50545-8.patch Normal file

File diff suppressed because it is too large Load Diff

438
glibc-RHEL-50545-9.patch Normal file
View File

@ -0,0 +1,438 @@
From 3b1d32177635023e37bec7fbfd77c3cfb2659eb1 Mon Sep 17 00:00:00 2001
From: Florian Weimer <fweimer@redhat.com>
Date: Fri, 30 Aug 2024 21:52:10 +0200
Subject: [PATCH] support: Add <support/xdirent.h>
Content-type: text/plain; charset=UTF-8
Use static functions for readdir/readdir_r, so that
-D_FILE_OFFSET_BITS=64 does not improperly redirect calls to the wrong
implementation.
Reviewed-by: DJ Delorie <dj@redhat.com>
Conflicts
support/Makefile
context
---
support/Makefile | 6 +++
support/support_readdir_check.c | 30 +++++++++++
support/support_readdir_r_check.c | 35 +++++++++++++
support/tst-xdirent.c | 76 +++++++++++++++++++++++++++
support/xclosedir.c | 28 ++++++++++
support/xdirent.h | 86 +++++++++++++++++++++++++++++++
support/xfdopendir.c | 30 +++++++++++
support/xopendir.c | 30 +++++++++++
8 files changed, 321 insertions(+)
create mode 100644 support/support_readdir_check.c
create mode 100644 support/support_readdir_r_check.c
create mode 100644 support/tst-xdirent.c
create mode 100644 support/xclosedir.c
create mode 100644 support/xdirent.h
create mode 100644 support/xfdopendir.c
create mode 100644 support/xopendir.c
diff --git a/support/Makefile b/support/Makefile
index 26bd3d38e4..8fb4d2c500 100644
--- a/support/Makefile
+++ b/support/Makefile
@@ -73,6 +73,8 @@ libsupport-routines = \
support_quote_blob \
support_quote_blob_wide \
support_quote_string \
+ support_readdir_check \
+ support_readdir_r_check \
support_record_failure \
support_run_diff \
support_select_modifies_timeout \
@@ -112,6 +114,7 @@ libsupport-routines = \
xclock_settime_time64 \
xclone \
xclose \
+ xclosedir \
xchmod \
xconnect \
xcopy_file_range \
@@ -120,6 +123,7 @@ libsupport-routines = \
xdup2 \
xfchmod \
xfclose \
+ xfdopendir \
xfopen \
xfork \
xftruncate \
@@ -137,6 +141,7 @@ libsupport-routines = \
xmunmap \
xnewlocale \
xopen \
+ xopendir \
xpipe \
xpoll \
xposix_memalign \
@@ -306,6 +311,7 @@ tests = \
tst-test_compare_string \
tst-test_compare_string_wide \
tst-timespec \
+ tst-xdirent \
tst-xreadlink \
tst-xsigstack \
diff --git a/support/support_readdir_check.c b/support/support_readdir_check.c
new file mode 100644
index 0000000000..5687004276
--- /dev/null
+++ b/support/support_readdir_check.c
@@ -0,0 +1,30 @@
+/* Error-checking helper for xreaddir, xreaddir64.
+ Copyright (C) 2024 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, see
+ <https://www.gnu.org/licenses/>. */
+
+#include <support/xdirent.h>
+
+#include <support/check.h>
+
+void *
+support_readdir_check (const char *name, void *result, int saved_errno)
+{
+ if (result == NULL && errno != 0)
+ FAIL_EXIT1 ("%s: %m", name);
+ errno = saved_errno;
+ return result;
+}
diff --git a/support/support_readdir_r_check.c b/support/support_readdir_r_check.c
new file mode 100644
index 0000000000..6bbb0d0b32
--- /dev/null
+++ b/support/support_readdir_r_check.c
@@ -0,0 +1,35 @@
+/* Error-checking helper for xreaddir_r, xreaddir64_r.
+ Copyright (C) 2024 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, see
+ <https://www.gnu.org/licenses/>. */
+
+#include <support/xdirent.h>
+
+#include <support/check.h>
+
+int
+support_readdir_r_check (const char *name, int result, void *buf, void *ptr)
+{
+ if (result != 0)
+ {
+ errno = result;
+ FAIL_EXIT1 ("%s: %m", name);
+ }
+ if (buf != ptr)
+ FAIL_EXIT1 ("%s: buffer pointer and returned pointer differ: %p != %p",
+ name, buf, ptr);
+ return result;
+}
diff --git a/support/tst-xdirent.c b/support/tst-xdirent.c
new file mode 100644
index 0000000000..642483165a
--- /dev/null
+++ b/support/tst-xdirent.c
@@ -0,0 +1,76 @@
+/* Compile test for error-checking wrappers for <dirent.h>
+ Copyright (C) 2024 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, see
+ <https://www.gnu.org/licenses/>. */
+
+#include <support/xdirent.h>
+
+#include <libc-diag.h>
+#include <support/check.h>
+#include <unistd.h>
+
+static int
+do_test (void)
+{
+ {
+ DIR *d = xopendir (".");
+ struct dirent *e = xreaddir (d);
+ /* Assume that the "." special entry always comes first. */
+ TEST_COMPARE_STRING (e->d_name, ".");
+ while (xreaddir (d) != NULL)
+ ;
+ xclosedir (d);
+ }
+
+ {
+ DIR *d = xopendir (".");
+ struct dirent64 *e = xreaddir64 (d);
+ TEST_COMPARE_STRING (e->d_name, ".");
+ while (xreaddir64 (d) != NULL)
+ ;
+ xclosedir (d);
+ }
+
+ /* The functions readdir_r, readdir64_r were deprecated in glibc 2.24. */
+ DIAG_PUSH_NEEDS_COMMENT;
+ DIAG_IGNORE_NEEDS_COMMENT (4.9, "-Wdeprecated-declarations");
+
+ {
+ DIR *d = xopendir (".");
+ struct dirent buf = { 0, };
+ TEST_VERIFY (xreaddir_r (d, &buf));
+ TEST_COMPARE_STRING (buf.d_name, ".");
+ while (xreaddir_r (d, &buf))
+ ;
+ xclosedir (d);
+ }
+
+ {
+ DIR *d = xopendir (".");
+ struct dirent64 buf = { 0, };
+ TEST_VERIFY (xreaddir64_r (d, &buf));
+ TEST_COMPARE_STRING (buf.d_name, ".");
+ while (xreaddir64_r (d, &buf))
+ ;
+ xclosedir (d);
+ }
+
+ DIAG_POP_NEEDS_COMMENT;
+
+ return 0;
+}
+
+#include <support/test-driver.c>
diff --git a/support/xclosedir.c b/support/xclosedir.c
new file mode 100644
index 0000000000..b490df5598
--- /dev/null
+++ b/support/xclosedir.c
@@ -0,0 +1,28 @@
+/* Error-checking wrapper for closedir.
+ Copyright (C) 2024 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, see
+ <https://www.gnu.org/licenses/>. */
+
+#include <support/xdirent.h>
+
+#include <support/check.h>
+
+void
+xclosedir (DIR *dir)
+{
+ if (closedir (dir) != 0)
+ FAIL_EXIT1 ("closedir: %m");
+}
diff --git a/support/xdirent.h b/support/xdirent.h
new file mode 100644
index 0000000000..8465d70ec1
--- /dev/null
+++ b/support/xdirent.h
@@ -0,0 +1,86 @@
+/* Error-checking wrappers for <dirent.h>
+ Copyright (C) 2024 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, see
+ <https://www.gnu.org/licenses/>. */
+
+#ifndef SUPPORT_XDIRENT_H
+#define SUPPORT_XDIRENT_H
+
+#include <dirent.h>
+#include <errno.h>
+#include <libc-diag.h>
+#include <stdbool.h>
+#include <stddef.h>
+
+__BEGIN_DECLS
+
+DIR *xopendir (const char *path);
+DIR *xfdopendir (int fd);
+void xclosedir (DIR *);
+
+void *support_readdir_check (const char *, void *, int);
+
+static __attribute__ ((unused)) struct dirent *
+xreaddir (DIR *stream)
+{
+ int saved_errno = errno;
+ errno = 0;
+ struct dirent *result = readdir (stream);
+ return support_readdir_check ("readdir", result, saved_errno);
+}
+
+static __attribute__ ((unused)) struct dirent64 *
+xreaddir64 (DIR *stream)
+{
+ int saved_errno = errno;
+ errno = 0;
+ struct dirent64 *result = readdir64 (stream);
+ return support_readdir_check ("readdir64", result, saved_errno);
+}
+
+/* The functions readdir_r, readdir64_r were deprecated in glibc 2.24. */
+DIAG_PUSH_NEEDS_COMMENT;
+DIAG_IGNORE_NEEDS_COMMENT (4.9, "-Wdeprecated-declarations");
+
+int support_readdir_r_check (const char *, int, void *, void *);
+
+static __attribute__ ((unused)) bool
+xreaddir_r (DIR *stream, struct dirent *buf)
+{
+ struct dirent *ptr;
+ int ret = readdir_r (stream, buf, &ptr);
+ if (ret == 0 && ptr == NULL)
+ return false;
+ support_readdir_r_check ("readdir_r", ret, buf, ptr);
+ return true;
+}
+
+static __attribute__ ((unused)) bool
+xreaddir64_r (DIR *stream, struct dirent64 *buf)
+{
+ struct dirent64 *ptr;
+ int ret = readdir64_r (stream, buf, &ptr);
+ if (ret == 0 && ptr == NULL)
+ return false;
+ support_readdir_r_check ("readdir64_r", ret, buf, ptr);
+ return true;
+}
+
+DIAG_POP_NEEDS_COMMENT;
+
+__END_DECLS
+
+#endif /* SUPPORT_XDIRENT_H */
diff --git a/support/xfdopendir.c b/support/xfdopendir.c
new file mode 100644
index 0000000000..d881d28c73
--- /dev/null
+++ b/support/xfdopendir.c
@@ -0,0 +1,30 @@
+/* Error-checking wrapper for fdopendir.
+ Copyright (C) 2024 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, see
+ <https://www.gnu.org/licenses/>. */
+
+#include <support/xdirent.h>
+
+#include <support/check.h>
+
+DIR *
+xfdopendir (int fd)
+{
+ DIR *result = fdopendir (fd);
+ if (result == NULL)
+ FAIL_EXIT1 ("fdopendir (%d): %m", fd);
+ return result;
+}
diff --git a/support/xopendir.c b/support/xopendir.c
new file mode 100644
index 0000000000..e4aee07fee
--- /dev/null
+++ b/support/xopendir.c
@@ -0,0 +1,30 @@
+/* Error-checking wrapper for opendir.
+ Copyright (C) 2024 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, see
+ <https://www.gnu.org/licenses/>. */
+
+#include <support/xdirent.h>
+
+#include <support/check.h>
+
+DIR *
+xopendir (const char *path)
+{
+ DIR *result = opendir (path);
+ if (result == NULL)
+ FAIL_EXIT1 ("opendir (\"%s\"): %m", path);
+ return result;
+}
--
2.43.5

View File

@ -157,7 +157,7 @@ end \
Summary: The GNU libc libraries
Name: glibc
Version: %{glibcversion}
Release: 133%{?dist}
Release: 134%{?dist}
# In general, GPLv2+ is used by programs, LGPLv2+ is used for
# libraries.
@ -889,6 +889,20 @@ Patch650: glibc-RHEL-46739-8.patch
Patch651: glibc-RHEL-46739-9.patch
Patch652: glibc-RHEL-46739-10.patch
Patch653: glibc-RHEL-46739-11.patch
Patch654: glibc-RHEL-50545-1.patch
Patch655: glibc-RHEL-50545-2.patch
Patch656: glibc-RHEL-50545-3.patch
Patch657: glibc-RHEL-50545-4.patch
Patch658: glibc-RHEL-50545-5.patch
Patch659: glibc-RHEL-50545-6.patch
Patch660: glibc-RHEL-50545-7.patch
Patch661: glibc-RHEL-50545-8.patch
Patch662: glibc-RHEL-50545-9.patch
Patch663: glibc-RHEL-50545-10.patch
Patch664: glibc-RHEL-50545-11.patch
Patch665: glibc-RHEL-50545-12.patch
Patch666: glibc-RHEL-50545-13.patch
Patch667: glibc-RHEL-50545-14.patch
##############################################################################
# Continued list of core "glibc" package information:
@ -3048,6 +3062,10 @@ update_gconv_modules_cache ()
%endif
%changelog
* Wed Oct 23 2024 DJ Delorie <dj@redhat.com> - 2.34-134
- Test Implementation to verify mkstemp behavior,
with FUSE support (RHEL-50545)
* Mon Sep 30 2024 Arjun Shankar <arjun@redhat.com> - 2.34-133
- strtod: Fix subnormal rounding; do not set errno upon overflowing payload;
and add several new tests (RHEL-46739)