fts: new version with size_t fts_pathlen, fts_namelen & long fts_level

Message ID 4d3ll6kdfd2ivrtwf2vurnbhpf7drqelem24dmg5524ejqbqbc@tarta.nabijaczleweli.xyz (mailing list archive)
State Under Review
Delegated to: DJ Delorie
Headers
Series fts: new version with size_t fts_pathlen, fts_namelen & long fts_level |

Checks

Context Check Description
redhat-pt-bot/TryBot-apply_patch fail Patch failed to apply to master at the time it was sent
redhat-pt-bot/TryBot-32bit fail Patch series failed to apply

Commit Message

наб Oct. 17, 2026, 4:57 p.m. UTC
  The current API uses unsigned short and short for these fields,
and neither of them is adequate, especially fts_pathlen
(BZ 22944, Debian 1150233, [1]).

Other implementations have already upgraded:
                fts_{path,name}len  fts_level
  4.4BSD-Lite2  unsigned short      short
  OpenBSD 7.9   size_t              int
  FreeBSD 15.1  size_t              long
  NetBSD 11.0   short               short
  musl-fts      unsigned int        int
  glibc 2.44    unsigned short      short
  (this patch)  size_t              long

This fixes the io/tst-fts-bz22944-verylong test from [1]
from FAIL/UNSUPPORTED to PASS.

Tested on i386-linux-gnu and x86_64-linux-gnu.

[1]: https://sourceware.org/pipermail/libc-alpha/2026-October/181310.html

Signed-off-by: Ahelenia Ziemiańska <nabijaczleweli@nabijaczleweli.xyz>
---
$ nm -D /lib/x86_64-linux-gnu/libc.so.6 libc.so.6 | grep -Fe fts -e libc.so.6
/lib/x86_64-linux-gnu/libc.so.6:
00000000000fc0d0 W fts64_children@@GLIBC_2.23
00000000000fbaa0 W fts64_close@@GLIBC_2.23
00000000000fb790 W fts64_open@@GLIBC_2.23
00000000000fbb90 W fts64_read@@GLIBC_2.23
00000000000fc0a0 W fts64_set@@GLIBC_2.23
00000000000fc0d0 T fts_children@@GLIBC_2.2.5
00000000000fbaa0 T fts_close@@GLIBC_2.2.5
00000000000fb790 T fts_open@@GLIBC_2.2.5
00000000000fbb90 T fts_read@@GLIBC_2.2.5
00000000000fc0a0 T fts_set@@GLIBC_2.2.5
libc.so.6:
0000000000139b77 T fts64_children@GLIBC_2.23
00000000000e2ad2 T fts64_children@@GLIBC_2.45
0000000000139378 T fts64_close@GLIBC_2.23
00000000000e22e6 T fts64_close@@GLIBC_2.45
0000000000138f77 T fts64_open@GLIBC_2.23
00000000000e1edc T fts64_open@@GLIBC_2.45
00000000000e242c T fts64_read@@GLIBC_2.45
00000000001394be T fts64_read@GLIBC_2.23
00000000000e2aaf T fts64_set@@GLIBC_2.45
0000000000139b54 T fts64_set@GLIBC_2.23
00000000000e2ad2 T fts_children@@GLIBC_2.45
0000000000139b77 T fts_children@GLIBC_2.2.5
0000000000139378 T fts_close@GLIBC_2.2.5
00000000000e22e6 T fts_close@@GLIBC_2.45
00000000000e1edc T fts_open@@GLIBC_2.45
0000000000138f77 T fts_open@GLIBC_2.2.5
00000000000e242c T fts_read@@GLIBC_2.45
00000000001394be T fts_read@GLIBC_2.2.5
00000000000e2aaf T fts_set@@GLIBC_2.45
0000000000139b54 T fts_set@GLIBC_2.2.5

# nm -D /lib/i386-linux-gnu/libc.so.6 libc.so.6 | grep -Fe fts -e libc.so.6
/lib/i386-linux-gnu/libc.so.6:
00117500 T __fts64_children_time64@@GLIBC_2.34
00116e50 T __fts64_close_time64@@GLIBC_2.34
00116ac0 T __fts64_open_time64@@GLIBC_2.34
00116f80 T __fts64_read_time64@@GLIBC_2.34
001174c0 T __fts64_set_time64@@GLIBC_2.34
00115ae0 T fts64_children@@GLIBC_2.23
00115430 T fts64_close@@GLIBC_2.23
001150a0 T fts64_open@@GLIBC_2.23
00115560 T fts64_read@@GLIBC_2.23
00115aa0 T fts64_set@@GLIBC_2.23
001140c0 T fts_children@@GLIBC_2.0
00113a10 T fts_close@@GLIBC_2.0
00113680 T fts_open@@GLIBC_2.0
00113b40 T fts_read@@GLIBC_2.0
00114080 T fts_set@@GLIBC_2.0
libc.so.6:
000fc7d6 T __fts64_children_time64@@GLIBC_2.45
0010361c T __fts64_children_time64@GLIBC_2.34
00102dde T __fts64_close_time64@GLIBC_2.34
000fbfb0 T __fts64_close_time64@@GLIBC_2.45
000fbb85 T __fts64_open_time64@@GLIBC_2.45
001029ba T __fts64_open_time64@GLIBC_2.34
00102f50 T __fts64_read_time64@GLIBC_2.34
000fc120 T __fts64_read_time64@@GLIBC_2.45
001035e7 T __fts64_set_time64@GLIBC_2.34
000fc7a1 T __fts64_set_time64@@GLIBC_2.45
0010111c T fts64_children@GLIBC_2.23
000fa376 T fts64_children@@GLIBC_2.45
001008de T fts64_close@GLIBC_2.23
000f9b50 T fts64_close@@GLIBC_2.45
001004ba T fts64_open@GLIBC_2.23
000f9725 T fts64_open@@GLIBC_2.45
000f9cc0 T fts64_read@@GLIBC_2.45
00100a50 T fts64_read@GLIBC_2.23
000fa341 T fts64_set@@GLIBC_2.45
001010e7 T fts64_set@GLIBC_2.23
000f7efd T fts_children@@GLIBC_2.45
000fec33 T fts_children@GLIBC_2.0
000fe3f7 T fts_close@GLIBC_2.0
000f76e9 T fts_close@@GLIBC_2.45
000fdfde T fts_open@GLIBC_2.0
000f72c5 T fts_open@@GLIBC_2.45
000f7859 T fts_read@@GLIBC_2.45
000fe569 T fts_read@GLIBC_2.0
000f7ec8 T fts_set@@GLIBC_2.45
000febfe T fts_set@GLIBC_2.0

 include/fts.h                    | 146 ++++++++++++++++++++++++++++++-
 io/Makefile                      |   3 +
 io/Versions                      |   4 +
 io/fts-common.c                  |  17 ----
 io/fts-v1.c                      |  48 ++++++++++
 io/fts.c                         |  20 +++++
 io/fts.h                         |  16 ++--
 io/fts64-time64-v1.c             |  47 ++++++++++
 io/fts64-time64.c                |  16 ++--
 io/fts64-v1.c                    |  69 +++++++++++++++
 io/fts64.c                       |  30 +++----
 sysdeps/unix/sysv/linux/Versions |   9 ++
 12 files changed, 376 insertions(+), 49 deletions(-)
 create mode 100644 io/fts-v1.c
 create mode 100644 io/fts64-time64-v1.c
 create mode 100644 io/fts64-v1.c
  

Comments

DJ Delorie Oct. 20, 2026, 3:42 a.m. UTC | #1
A few comments...

Please use two spaces for indents, unless the original file used
something else.  Changing whitespace makes diffs bigger and harder to
review, and style should be maintained within each file.  The GNU
standard is two spaces, we only use eight (or a tab) when we copy
files from other sources (like the kernel).

Did you really need to move fts_pathlen?  I know it packs better on
some platforms, but it seemed a bit out of place and makes the
structure ordering different for different versions.

The new versioning macros cause the resulting symbols to no longer be
WEAK in some cases.  When you replace a weak_alias() with a
versioned_symbol() you need something separate to make it weak.
Your samples even show this.

This patch adds new symbols to the HURD libc.so (the _time64 variants,
which hurd doesn't have), although they don't end up in the dynamic
symbol table they show up with "nm" with version tags.  Please test
with an i686-gnu target, or something else that has only a 32-bit
time_t.  Testing against something new enough to default to 64-bit
time_t (like riscv) would be useful too, as it also won't have the
_time64 variants but does have a 64-bit time.

I was going to add "it might be good to make all those similar
structures into a macro" but I didn't want to encourage someone to
change them in the future.  The compat structures are only ever used
by the compat *.c files, perhaps move them there, each in the file
that uses it?  That makes the main header file easier to understand
and maintain, and reduces the chance of the compat structures getting
changed in the future.

Typo: FSTENT64 should be FTSENT64.  Yes, I know the original file had
the typo, but this can be fixed, and fixing is better than
propagating.

As for actual compatibility: we're changing a public structure, so if
an application compiled against a new glibc calls a dll compiled
against an old glibc and passes a pointer to such a structure, it will
break.  I don't think we have a solution for that, and we've changed
structures in the past.  The FTS structure is opaque(ish) so is less
of a problem.

On Sat, Oct 17, 2026 at 12:58 PM наб <nabijaczleweli@nabijaczleweli.xyz> wrote:
>
> The current API uses unsigned short and short for these fields,
> and neither of them is adequate, especially fts_pathlen
> (BZ 22944, Debian 1150233, [1]).
  

Patch

diff --git include/fts.h include/fts.h
index 972884647b..9fd364eef4 100644
--- include/fts.h
+++ include/fts.h
@@ -2,9 +2,147 @@ 
 #include <io/fts.h>
 
 #ifndef _ISOMAC
+typedef struct {
+	struct _ftsent_v1 *fts_cur;
+	struct _ftsent_v1 *fts_child;
+	struct _ftsent_v1 **fts_array;
+	dev_t fts_dev;
+	char *fts_path;
+	int fts_rfd;
+	int fts_pathlen;
+	int fts_nitems;
+	int (*fts_compar) (const void *, const void *);
+	int fts_options;
+	int fts_cwd_fd;
+	struct hash_table *fts_leaf_optimization_works_ht;
+	union {
+	        struct hash_table *ht;
+	        struct cycle_check_state *state;
+	} fts_cycle;
+	__I_ring fts_fd_ring;
+} __FTS_V1;
+
+#ifdef __USE_LARGEFILE64
+typedef struct {
+	struct _ftsent64_v1 *fts_cur;
+	struct _ftsent64_v1 *fts_child;
+	struct _ftsent64_v1 **fts_array;
+	dev_t fts_dev;
+	char *fts_path;
+	int fts_rfd;
+	int fts_pathlen;
+	int fts_nitems;
+	int (*fts_compar) (const void *, const void *);
+	int fts_options;
+	int fts_cwd_fd;
+	struct hash_table *fts_leaf_optimization_works_ht;
+	union {
+	        struct hash_table *ht;
+	        struct cycle_check_state *state;
+	} fts_cycle;
+	__I_ring fts_fd_ring;
+} __FTS64_V1;
+#endif
+
+typedef struct _ftsent_v1 {
+	struct _ftsent_v1 *fts_cycle;
+	struct _ftsent_v1 *fts_parent;
+	struct _ftsent_v1 *fts_link;
+	long fts_number;
+	void *fts_pointer;
+	char *fts_accpath;
+	char *fts_path;
+	int fts_errno;
+	int fts_symfd;
+	unsigned short fts_pathlen;
+	unsigned short fts_namelen;
+	ino_t fts_ino;
+	dev_t fts_dev;
+	nlink_t fts_nlink;
+	short fts_level;
+	unsigned short fts_info;
+	unsigned short fts_flags;
+	unsigned short fts_instr;
+	struct stat *fts_statp;
+	char fts_name[1];
+} __FTSENT_V1;
+
+#ifdef __USE_LARGEFILE64
+typedef struct _ftsent64_v1 {
+	struct _ftsent64_v1 *fts_cycle;
+	struct _ftsent64_v1 *fts_parent;
+	struct _ftsent64_v1 *fts_link;
+	long fts_number;
+	void *fts_pointer;
+	char *fts_accpath;
+	char *fts_path;
+	int fts_errno;
+	int fts_symfd;
+	unsigned short fts_pathlen;
+	unsigned short fts_namelen;
+	ino64_t fts_ino;
+	dev_t fts_dev;
+	nlink_t fts_nlink;
+	short fts_level;
+	unsigned short fts_info;
+	unsigned short fts_flags;
+	unsigned short fts_instr;
+	struct stat64 *fts_statp;
+	char fts_name[1];
+} __FTSENT64_V1;
+#endif
+
 # if __TIMESIZE != 64
 #  include <sys/stat.h>
 
+typedef struct
+{
+  struct _ftsent64_time64_v1 *fts_cur;
+  struct _ftsent64_time64_v1 *fts_child;
+  struct _ftsent64_time64_v1 **fts_array;
+  dev_t fts_dev;
+  char *fts_path;
+  int fts_rfd;
+  int fts_pathlen;
+  int fts_nitems;
+  int (*fts_compar) (const void *, const void *);
+  int fts_options;
+  int fts_cwd_fd;
+  struct hash_table *fts_leaf_optimization_works_ht;
+  union {
+	  struct hash_table *ht;
+	  struct cycle_check_state *state;
+  } fts_cycle;
+  __I_ring fts_fd_ring;
+} __FTS64_TIME64_V1;
+
+typedef struct _ftsent64_time64_v1
+{
+  struct _ftsent64_time64_v1 *fts_cycle;
+  struct _ftsent64_time64_v1 *fts_parent;
+  struct _ftsent64_time64_v1 *fts_link;
+  long fts_number;
+  void *fts_pointer;
+  char *fts_accpath;
+  char *fts_path;
+  int fts_errno;
+  int fts_symfd;
+  unsigned short fts_pathlen;
+  unsigned short fts_namelen;
+
+  ino64_t fts_ino;
+  dev_t fts_dev;
+  nlink_t fts_nlink;
+
+  short fts_level;
+  unsigned short fts_info;
+  unsigned short fts_flags;
+  unsigned short fts_instr;
+
+  struct __stat64_t64 *fts_statp;
+  char fts_name[1];
+} __FSTENT64_TIME64_V1;
+
 typedef struct
 {
   struct _ftsent64_time64 *fts_cur;
@@ -12,8 +150,8 @@  typedef struct
   struct _ftsent64_time64 **fts_array;
   dev_t fts_dev;
   char *fts_path;
+  size_t fts_pathlen;
   int fts_rfd;
-  int fts_pathlen;
   int fts_nitems;
   int (*fts_compar) (const void *, const void *);
   int fts_options;
@@ -37,14 +175,14 @@  typedef struct _ftsent64_time64
   char *fts_path;
   int fts_errno;
   int fts_symfd;
-  unsigned short fts_pathlen;
-  unsigned short fts_namelen;
+  size_t fts_pathlen;
+  size_t fts_namelen;
 
   ino64_t fts_ino;
   dev_t fts_dev;
   nlink_t fts_nlink;
 
-  short fts_level;
+  int fts_level;
   unsigned short fts_info;
   unsigned short fts_flags;
   unsigned short fts_instr;
diff --git io/Makefile io/Makefile
index 9a83578a83..7018e63ef9 100644
--- io/Makefile
+++ io/Makefile
@@ -84,6 +84,9 @@  routines := \
   fts \
   fts64 \
   fts64-time64 \
+  fts-v1 \
+  fts64-v1 \
+  fts64-time64-v1 \
   ftw \
   ftw64 \
   ftw64-time64 \
diff --git io/Versions io/Versions
index e5f297e39e..bc96687df3 100644
--- io/Versions
+++ io/Versions
@@ -137,6 +137,10 @@  libc {
   GLIBC_2.34 {
     closefrom;
   }
+  GLIBC_2.45 {
+    fts_children; fts_close; fts_open; fts_read; fts_set;
+    fts64_children; fts64_close; fts64_open; fts64_read; fts64_set;
+  }
   GLIBC_PRIVATE {
     __fcntl_nocancel;
     __open64_nocancel;
diff --git io/fts-common.c io/fts-common.c
index 351ba6a022..2562a1be8d 100644
--- io/fts-common.c
+++ io/fts-common.c
@@ -67,23 +67,6 @@  static char sccsid[] = "@(#)fts.c       8.6 (Berkeley) 8/14/94";
 #include <string.h>
 #include <unistd.h>
 
-/* Support for the LFS API version.  */
-#ifndef FTS_OPEN
-# define FTS_OPEN fts_open
-# define FTS_CLOSE fts_close
-# define FTS_READ fts_read
-# define FTS_SET fts_set
-# define FTS_CHILDREN fts_children
-# define FTSOBJ FTS
-# define FTSENTRY FTSENT
-# define INO_T ino_t
-# define STRUCT_STAT stat
-# define FSTAT __fstat
-# define FSTATAT __fstatat
-# define STRUCT_STATFS statfs
-# define FSTATFS __fstatfs
-#endif
-
 #if ! _LIBC
 # include "attribute.h"
 # include "fcntl--.h"
diff --git io/fts-v1.c io/fts-v1.c
new file mode 100644
index 0000000000..b4170111db
--- /dev/null
+++ io/fts-v1.c
@@ -0,0 +1,48 @@ 
+/* File tree traversal functions LFS version.
+   Copyright (C) 2026 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 <shlib-compat.h>
+
+#if SHLIB_COMPAT (libc, GLIBC_2_0, GLIBC_2_45)
+# include <sys/types.h>
+
+# if !defined __OFF_T_MATCHES_OFF64_T \
+     || !defined __INO_T_MATCHES_INO64_T
+#  define FTS_OPEN __fts_open_v1
+#  define FTS_CLOSE __fts_close_v1
+#  define FTS_READ __fts_read_v1
+#  define FTS_SET __fts_set_v1
+#  define FTS_CHILDREN __fts_children_v1
+#  define FTSOBJ __FTS_V1
+#  define FTSENTRY __FTSENT_V1
+#  define INO_T ino_t
+#  define STRUCT_STAT stat
+#  define FSTAT __fstat
+#  define FSTATAT __fstatat
+#  define STRUCT_STATFS statfs
+#  define FSTATFS __fstatfs
+
+#  include "io/fts-common.c"
+
+compat_symbol (libc, __fts_open_v1,     fts_open,     GLIBC_2_0);
+compat_symbol (libc, __fts_close_v1,    fts_close,    GLIBC_2_0);
+compat_symbol (libc, __fts_read_v1,     fts_read,     GLIBC_2_0);
+compat_symbol (libc, __fts_set_v1,      fts_set,      GLIBC_2_0);
+compat_symbol (libc, __fts_children_v1, fts_children, GLIBC_2_0);
+# endif
+#endif
diff --git io/fts.c io/fts.c
index c7df552b83..e5d6f73dee 100644
--- io/fts.c
+++ io/fts.c
@@ -20,5 +20,25 @@ 
 
 #if !defined __OFF_T_MATCHES_OFF64_T \
     || !defined __INO_T_MATCHES_INO64_T
+# define FTS_OPEN __fts_open_v2
+# define FTS_CLOSE __fts_close_v2
+# define FTS_READ __fts_read_v2
+# define FTS_SET __fts_set_v2
+# define FTS_CHILDREN __fts_children_v2
+# define FTSOBJ FTS
+# define FTSENTRY FTSENT
+# define INO_T ino_t
+# define STRUCT_STAT stat
+# define FSTAT __fstat
+# define FSTATAT __fstatat
+# define STRUCT_STATFS statfs
+# define FSTATFS __fstatfs
+
 # include "io/fts-common.c"
+
+versioned_symbol (libc, __fts_open_v2,     fts_open,     GLIBC_2_45);
+versioned_symbol (libc, __fts_close_v2,    fts_close,    GLIBC_2_45);
+versioned_symbol (libc, __fts_read_v2,     fts_read,     GLIBC_2_45);
+versioned_symbol (libc, __fts_set_v2,      fts_set,      GLIBC_2_45);
+versioned_symbol (libc, __fts_children_v2, fts_children, GLIBC_2_45);
 #endif
diff --git io/fts.h io/fts.h
index 50636e6c87..47d6190d05 100644
--- io/fts.h
+++ io/fts.h
@@ -82,8 +82,8 @@  typedef struct {
 	struct _ftsent **fts_array;	/* sort array */
 	dev_t fts_dev;			/* starting device # */
 	char *fts_path;			/* path for this descent */
+	size_t fts_pathlen;		/* sizeof(path) */
 	int fts_rfd;			/* fd for root */
-	int fts_pathlen;		/* sizeof(path) */
 	int fts_nitems;			/* elements in the sort array */
 	int (*fts_compar) (const void *, const void *); /* compare fn */
 
@@ -204,8 +204,8 @@  typedef struct {
 	struct _ftsent64 **fts_array;	/* sort array */
 	dev_t fts_dev;			/* starting device # */
 	char *fts_path;			/* path for this descent */
+	size_t fts_pathlen;		/* sizeof(path) */
 	int fts_rfd;			/* fd for root */
-	int fts_pathlen;		/* sizeof(path) */
 	int fts_nitems;			/* elements in the sort array */
 	int (*fts_compar) (const void *, const void *); /* compare fn */
 	int fts_options;		/* fts_open options, global flags */
@@ -229,8 +229,8 @@  typedef struct _ftsent {
 	char *fts_path;			/* root path */
 	int fts_errno;			/* errno for this node */
 	int fts_symfd;			/* fd for symlink */
-	unsigned short fts_pathlen;	/* strlen(fts_path) */
-	unsigned short fts_namelen;	/* strlen(fts_name) */
+	size_t fts_pathlen;		/* strlen(fts_path) */
+	size_t fts_namelen;		/* strlen(fts_name) */
 
 	ino_t fts_ino;			/* inode */
 	dev_t fts_dev;			/* device */
@@ -238,7 +238,7 @@  typedef struct _ftsent {
 
 #define	FTS_ROOTPARENTLEVEL	-1
 #define	FTS_ROOTLEVEL		 0
-	short fts_level;		/* depth (-1 to N) */
+	long fts_level;			/* depth (-1 to N) */
 
 #define	FTS_D		 1		/* preorder directory */
 #define	FTS_DC		 2		/* directory that causes cycles */
@@ -281,14 +281,14 @@  typedef struct _ftsent64 {
 	char *fts_path;			/* root path */
 	int fts_errno;			/* errno for this node */
 	int fts_symfd;			/* fd for symlink */
-	unsigned short fts_pathlen;		/* strlen(fts_path) */
-	unsigned short fts_namelen;		/* strlen(fts_name) */
+	size_t fts_pathlen;		/* strlen(fts_path) */
+	size_t fts_namelen;		/* strlen(fts_name) */
 
 	ino64_t fts_ino;		/* inode */
 	dev_t fts_dev;			/* device */
 	nlink_t fts_nlink;		/* link count */
 
-	short fts_level;		/* depth (-1 to N) */
+	long fts_level;			/* depth (-1 to N) */
 
 	unsigned short fts_info;	/* user flags for FTSENT structure */
 
diff --git io/fts64-time64-v1.c io/fts64-time64-v1.c
new file mode 100644
index 0000000000..fd68dc4430
--- /dev/null
+++ io/fts64-time64-v1.c
@@ -0,0 +1,47 @@ 
+/* File tree traversal functions LFS version.
+   Copyright (C) 2015-2026 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 <shlib-compat.h>
+
+#if SHLIB_COMPAT (libc, GLIBC_2_34, GLIBC_2_45)
+# include <time.h>
+
+# if __TIMESIZE != 64
+#  define FTS_OPEN           __fts64_open_time64_v1
+#  define FTS_CLOSE          __fts64_close_time64_v1
+#  define FTS_READ           __fts64_read_time64_v1
+#  define FTS_SET            __fts64_set_time64_v1
+#  define FTS_CHILDREN       __fts64_children_time64_v1
+#  define FTSOBJ             __FTS64_TIME64_V1
+#  define FTSENTRY           __FSTENT64_TIME64_V1
+#  define INO_T              ino64_t
+#  define STRUCT_STAT        __stat64_t64
+#  define FSTAT              __fstat64_time64
+#  define FSTATAT            __fstatat64_time64
+#  define STRUCT_STATFS      statfs64
+#  define FSTATFS            __fstatfs64
+
+#  include "fts-common.c"
+
+compat_symbol (libc, __fts64_open_time64_v1,     __fts64_open_time64,     GLIBC_2_34);
+compat_symbol (libc, __fts64_close_time64_v1,    __fts64_close_time64,    GLIBC_2_34);
+compat_symbol (libc, __fts64_read_time64_v1,     __fts64_read_time64,     GLIBC_2_34);
+compat_symbol (libc, __fts64_set_time64_v1,      __fts64_set_time64,      GLIBC_2_34);
+compat_symbol (libc, __fts64_children_time64_v1, __fts64_children_time64, GLIBC_2_34);
+# endif
+#endif
diff --git io/fts64-time64.c io/fts64-time64.c
index 29f2dbc28c..12244d73b9 100644
--- io/fts64-time64.c
+++ io/fts64-time64.c
@@ -19,11 +19,11 @@ 
 #include <time.h>
 
 #if __TIMESIZE != 64
-# define FTS_OPEN           __fts64_open_time64
-# define FTS_CLOSE          __fts64_close_time64
-# define FTS_READ           __fts64_read_time64
-# define FTS_SET            __fts64_set_time64
-# define FTS_CHILDREN       __fts64_children_time64
+# define FTS_OPEN           __fts64_open_time64_v2
+# define FTS_CLOSE          __fts64_close_time64_v2
+# define FTS_READ           __fts64_read_time64_v2
+# define FTS_SET            __fts64_set_time64_v2
+# define FTS_CHILDREN       __fts64_children_time64_v2
 # define FTSOBJ             FTS64_TIME64
 # define FTSENTRY           FSTENT64_TIME64
 # define INO_T              ino64_t
@@ -34,4 +34,10 @@ 
 # define FSTATFS            __fstatfs64
 
 # include "fts-common.c"
+
+versioned_symbol (libc, __fts64_open_time64_v2,     __fts64_open_time64,     GLIBC_2_45);
+versioned_symbol (libc, __fts64_close_time64_v2,    __fts64_close_time64,    GLIBC_2_45);
+versioned_symbol (libc, __fts64_read_time64_v2,     __fts64_read_time64,     GLIBC_2_45);
+versioned_symbol (libc, __fts64_set_time64_v2,      __fts64_set_time64,      GLIBC_2_45);
+versioned_symbol (libc, __fts64_children_time64_v2, __fts64_children_time64, GLIBC_2_45);
 #endif
diff --git io/fts64-v1.c io/fts64-v1.c
new file mode 100644
index 0000000000..5f362bb920
--- /dev/null
+++ io/fts64-v1.c
@@ -0,0 +1,69 @@ 
+/* File tree traversal functions LFS version.
+   Copyright (C) 2015-2026 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 <shlib-compat.h>
+
+#if SHLIB_COMPAT (libc, GLIBC_2_0, GLIBC_2_45) \
+    || SHLIB_COMPAT (libc, GLIBC_2_23, GLIBC_2_45)
+# define FTS_OPEN __fts64_open_v1
+# define FTS_CLOSE __fts64_close_v1
+# define FTS_READ __fts64_read_v1
+# define FTS_SET __fts64_set_v1
+# define FTS_CHILDREN __fts64_children_v1
+# define FTSOBJ __FTS64_V1
+# define FTSENTRY __FTSENT64_V1
+# define INO_T ino64_t
+# define STRUCT_STAT stat64
+# define FSTAT __fstat64
+# define FSTATAT __fstatat64
+# define STRUCT_STATFS statfs64
+# define FSTATFS __fstatfs64
+
+#define fts_open __rename_fts_open
+#define fts_close __rename_fts_close
+#define fts_read __rename_fts_read
+#define fts_set __rename_fts_set
+#define fts_children __rename_fts_children
+
+# include "fts-common.c"
+
+#undef fts_open
+#undef fts_close
+#undef fts_read
+#undef fts_set
+#undef fts_children
+
+# if SHLIB_COMPAT (libc, GLIBC_2_33, GLIBC_2_45)
+compat_symbol (libc, __fts64_open_v1,     fts64_open,     GLIBC_2_23);
+compat_symbol (libc, __fts64_close_v1,    fts64_close,    GLIBC_2_23);
+compat_symbol (libc, __fts64_read_v1,     fts64_read,     GLIBC_2_23);
+compat_symbol (libc, __fts64_set_v1,      fts64_set,      GLIBC_2_23);
+compat_symbol (libc, __fts64_children_v1, fts64_children, GLIBC_2_23);
+# endif
+
+# if SHLIB_COMPAT (libc, GLIBC_2_0, GLIBC_2_45)
+#  if defined __OFF_T_MATCHES_OFF64_T \
+      && defined __INO_T_MATCHES_INO64_T
+compat_symbol (libc, __fts64_open_v1,     fts_open,     GLIBC_2_0);
+compat_symbol (libc, __fts64_close_v1,    fts_close,    GLIBC_2_0);
+compat_symbol (libc, __fts64_read_v1,     fts_read,     GLIBC_2_0);
+compat_symbol (libc, __fts64_set_v1,      fts_set,      GLIBC_2_0);
+compat_symbol (libc, __fts64_children_v1, fts_children, GLIBC_2_0);
+#  endif
+# endif
+#endif
diff --git io/fts64.c io/fts64.c
index c2cf45523e..a72133178a 100644
--- io/fts64.c
+++ io/fts64.c
@@ -16,11 +16,11 @@ 
    License along with the GNU C Library; if not, see
    <https://www.gnu.org/licenses/>.  */
 
-#define FTS_OPEN __fts64_open
-#define FTS_CLOSE __fts64_close
-#define FTS_READ __fts64_read
-#define FTS_SET __fts64_set
-#define FTS_CHILDREN __fts64_children
+#define FTS_OPEN __fts64_open_v2
+#define FTS_CLOSE __fts64_close_v2
+#define FTS_READ __fts64_read_v2
+#define FTS_SET __fts64_set_v2
+#define FTS_CHILDREN __fts64_children_v2
 #define FTSOBJ FTS64
 #define FTSENTRY FTSENT64
 #define INO_T ino64_t
@@ -44,17 +44,17 @@ 
 #undef fts_set
 #undef fts_children
 
-weak_alias (__fts64_open, fts64_open)
-weak_alias (__fts64_close, fts64_close)
-weak_alias (__fts64_read, fts64_read)
-weak_alias (__fts64_set, fts64_set)
-weak_alias (__fts64_children, fts64_children)
+versioned_symbol (libc, __fts64_open_v2,     fts64_open,     GLIBC_2_45);
+versioned_symbol (libc, __fts64_close_v2,    fts64_close,    GLIBC_2_45);
+versioned_symbol (libc, __fts64_read_v2,     fts64_read,     GLIBC_2_45);
+versioned_symbol (libc, __fts64_set_v2,      fts64_set,      GLIBC_2_45);
+versioned_symbol (libc, __fts64_children_v2, fts64_children, GLIBC_2_45);
 
 #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)
-weak_alias (__fts64_set, fts_set)
-weak_alias (__fts64_children, fts_children)
+versioned_symbol (libc, __fts64_open_v2,     fts_open,     GLIBC_2_45);
+versioned_symbol (libc, __fts64_close_v2,    fts_close,    GLIBC_2_45);
+versioned_symbol (libc, __fts64_read_v2,     fts_read,     GLIBC_2_45);
+versioned_symbol (libc, __fts64_set_v2,      fts_set,      GLIBC_2_45);
+versioned_symbol (libc, __fts64_children_v2, fts_children, GLIBC_2_45);
 #endif
diff --git sysdeps/unix/sysv/linux/Versions sysdeps/unix/sysv/linux/Versions
index c7f199f13f..6e4f4e1706 100644
--- sysdeps/unix/sysv/linux/Versions
+++ sysdeps/unix/sysv/linux/Versions
@@ -343,6 +343,15 @@  libc {
     mseal;
     openat2;
   }
+  GLIBC_2.45 {
+%ifdef TIME64_NON_DEFAULT
+    __fts64_open_time64;
+    __fts64_close_time64;
+    __fts64_read_time64;
+    __fts64_set_time64;
+    __fts64_children_time64;
+%endif
+  }
   GLIBC_PRIVATE {
     # functions used in other libraries
     __syscall_rt_sigqueueinfo;