[PATCH] alpha: Fix fts and fts64 ABI mismatch

Magnus Lindholm <[email protected]> Mon, 3 Aug 2026 21:01:02 +0200
Newsgroups gmane.comp.lib.glibc.alpha
Message-ID <[email protected]>
Alpha has matching off_t and off64_t types, but ino_t and ino64_t
differ.  Consequently, FTSENT and FTSENT64 have different layouts, and
the fts and fts64 interfaces cannot share one implementation.

The generic 64-bit-word-size implementation assumes that matching
offset types are sufficient to alias the two interfaces.  On Alpha,
this causes the ordinary fts interface to operate on the incompatible
FTSENT64 layout, corrupting traversal state.

Only share the implementations when both the offset and inode types
match.  Add Alpha sysdeps wrappers so that separate fts and fts64
implementations are built.

The Alpha sysdeps wrapper files are based on a downstream patch written
by Aurelien Jarno in 2016 and carried by Debian since then.

This fixes io/tst-fts, io/tst-fts-bz22944, and
io/tst-fts-newflags on Alpha.

Signed-off-by: Magnus Lindholm <[email protected]>
---
 io/fts.c                              | 3 ++-
 io/fts64.c                            | 3 ++-
 sysdeps/unix/sysv/linux/alpha/fts.c   | 1 +
 sysdeps/unix/sysv/linux/alpha/fts64.c | 1 +
 4 files changed, 6 insertions(+), 2 deletions(-)
 create mode 100644 sysdeps/unix/sysv/linux/alpha/fts.c
 create mode 100644 sysdeps/unix/sysv/linux/alpha/fts64.c

diff --git a/io/fts.c b/io/fts.c
index d3b8e5a100..c7df552b83 100644
--- a/io/fts.c
+++ b/io/fts.c
@@ -18,6 +18,7 @@
 
 #include <sys/types.h>
 
-#ifndef __OFF_T_MATCHES_OFF64_T
+#if !defined __OFF_T_MATCHES_OFF64_T \
+    || !defined __INO_T_MATCHES_INO64_T
 # include "io/fts-common.c"
 #endif
diff --git a/io/fts64.c b/io/fts64.c
index 1efa06ab3b..c2cf45523e 100644
--- a/io/fts64.c
+++ b/io/fts64.c
@@ -50,7 +50,8 @@ weak_alias (__fts64_read, fts64_read)
 weak_alias (__fts64_set, fts64_set)
 weak_alias (__fts64_children, fts64_children)
 
-#ifdef __OFF_T_MATCHES_OFF64_T
+#if defined __OFF_T_MATCHES_OFF64_T \
+    && defined __INO_T_MATCHES_INO64_T
 weak_alias (__fts64_open, fts_open)
 weak_alias (__fts64_close, fts_close)
 weak_alias (__fts64_read, fts_read)
diff --git a/sysdeps/unix/sysv/linux/alpha/fts.c b/sysdeps/unix/sysv/linux/alpha/fts.c
new file mode 100644
index 0000000000..d0c62e6195
--- /dev/null
+++ b/sysdeps/unix/sysv/linux/alpha/fts.c
@@ -0,0 +1 @@
+#include <io/fts.c>
diff --git a/sysdeps/unix/sysv/linux/alpha/fts64.c b/sysdeps/unix/sysv/linux/alpha/fts64.c
new file mode 100644
index 0000000000..2472f8bf75
--- /dev/null
+++ b/sysdeps/unix/sysv/linux/alpha/fts64.c
@@ -0,0 +1 @@
+#include <io/fts64.c>
-- 
2.53.0