io: Add fts64 with 64-bit time_t support
authorAdhemerval Zanella <adhemerval.zanella@linaro.org>
Wed, 3 Mar 2021 12:00:13 +0000 (09:00 -0300)
committerAdhemerval Zanella <adhemerval.zanella@linaro.org>
Tue, 15 Jun 2021 13:42:11 +0000 (10:42 -0300)
Similar to glob, fts routines passes a stat pointer that might
differ of size and layout when 64-bit time API is used.

Checked on i686-linux-gnu and x86_64-linux-gnu.

Reviewed-by: Lukasz Majewski <lukma@denx.de>
Reviewed-by: Carlos O'Donell <carlos@redhat.com>
Tested-by: Carlos O'Donell <carlos@redhat.com>
24 files changed:
include/fts.h
io/Makefile
io/fts.h
io/fts64-time64.c [new file with mode: 0644]
sysdeps/unix/sysv/linux/Versions
sysdeps/unix/sysv/linux/arm/be/libc.abilist
sysdeps/unix/sysv/linux/arm/le/libc.abilist
sysdeps/unix/sysv/linux/csky/libc.abilist
sysdeps/unix/sysv/linux/hppa/libc.abilist
sysdeps/unix/sysv/linux/i386/libc.abilist
sysdeps/unix/sysv/linux/m68k/coldfire/libc.abilist
sysdeps/unix/sysv/linux/m68k/m680x0/libc.abilist
sysdeps/unix/sysv/linux/microblaze/be/libc.abilist
sysdeps/unix/sysv/linux/microblaze/le/libc.abilist
sysdeps/unix/sysv/linux/mips/mips32/fpu/libc.abilist
sysdeps/unix/sysv/linux/mips/mips32/nofpu/libc.abilist
sysdeps/unix/sysv/linux/mips/mips64/n32/libc.abilist
sysdeps/unix/sysv/linux/nios2/libc.abilist
sysdeps/unix/sysv/linux/powerpc/powerpc32/fpu/libc.abilist
sysdeps/unix/sysv/linux/powerpc/powerpc32/nofpu/libc.abilist
sysdeps/unix/sysv/linux/s390/s390-32/libc.abilist
sysdeps/unix/sysv/linux/sh/be/libc.abilist
sysdeps/unix/sysv/linux/sh/le/libc.abilist
sysdeps/unix/sysv/linux/sparc/sparc32/libc.abilist

index 145dce6..ea36a9b 100644 (file)
@@ -1 +1,52 @@
+#ifndef _FTS_H
 #include <io/fts.h>
+
+#ifndef _ISOMAC
+# if __TIMESIZE != 64
+#  include <sys/stat.h>
+
+typedef struct
+{
+  struct _ftsent64_time64 *fts_cur;
+  struct _ftsent64_time64 *fts_child;
+  struct _ftsent64_time64 **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;
+} FTS64_TIME64;
+
+typedef struct _ftsent64_time64
+{
+  struct _ftsent64_time64 *fts_cycle;
+  struct _ftsent64_time64 *fts_parent;
+  struct _ftsent64_time64 *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;
+
+# endif
+#endif
+
+#endif /* _FTS_H  */
index a22492f..12c832c 100644 (file)
@@ -54,7 +54,8 @@ routines :=                                                           \
        posix_fadvise posix_fadvise64                                   \
        posix_fallocate posix_fallocate64                               \
        sendfile sendfile64 copy_file_range                             \
-       utimensat futimens file_change_detection
+       utimensat futimens file_change_detection                        \
+       fts64-time64
 
 others         := pwd
 test-srcs      := ftwtest
@@ -102,6 +103,7 @@ CFLAGS-statvfs.c += -fexceptions
 CFLAGS-fstatvfs.c += -fexceptions
 CFLAGS-fts.c += -Wno-uninitialized $(uses-callbacks) -fexceptions
 CFLAGS-fts64.c += -Wno-uninitialized $(uses-callbacks) -fexceptions
+CFLAGS-fts64-time64.c += -Wno-uninitialized $(uses-callbacks) -fexceptions
 CFLAGS-ftw.c += $(uses-callbacks) -fexceptions
 CFLAGS-ftw64.c += $(uses-callbacks) -fexceptions
 CFLAGS-posix_fallocate.c += -fexceptions
index 867677a..8d3395f 100644 (file)
--- a/io/fts.h
+++ b/io/fts.h
@@ -187,6 +187,7 @@ FTSENT      *fts_read (FTS *);
 int     fts_set (FTS *, FTSENT *, int) __THROW;
 #else
 # ifdef __REDIRECT
+#  ifndef __USE_TIME_BITS64
 FTSENT *__REDIRECT (fts_children, (FTS *, int), fts64_children);
 int     __REDIRECT (fts_close, (FTS *), fts64_close);
 FTS    *__REDIRECT (fts_open, (char * const *, int,
@@ -194,21 +195,53 @@ FTS       *__REDIRECT (fts_open, (char * const *, int,
                     fts64_open);
 FTSENT *__REDIRECT (fts_read, (FTS *), fts64_read);
 int     __REDIRECT_NTH (fts_set, (FTS *, FTSENT *, int), fts64_set);
+#  else
+FTSENT *__REDIRECT (fts_children, (FTS *, int), __fts64_children_time64);
+int     __REDIRECT (fts_close, (FTS *), __fts64_close_time64);
+FTS    *__REDIRECT (fts_open, (char * const *, int,
+                               int (*)(const FTSENT **, const FTSENT **)),
+                    __fts64_open_time64);
+FTSENT *__REDIRECT (fts_read, (FTS *), __fts64_read_time64);
+int     __REDIRECT_NTH (fts_set, (FTS *, FTSENT *, int),
+                        __fts64_set_time64);
+#  endif
 # else
-#  define fts_children fts64_children
-#  define fts_close fts64_close
-#  define fts_open fts64_open
-#  define fts_read fts64_read
-#  define fts_set fts64_set
+#  ifndef __USE_TIME_BITS64
+#   define fts_children fts64_children
+#   define fts_close fts64_close
+#   define fts_open fts64_open
+#   define fts_read fts64_read
+#   define fts_set fts64_set
+#  else
+#  endif
 # endif
 #endif
 #ifdef __USE_LARGEFILE64
+# ifndef __USE_TIME_BITS64
 FTSENT64 *fts64_children (FTS64 *, int);
 int      fts64_close (FTS64 *);
 FTS64   *fts64_open (char * const *, int,
                      int (*)(const FTSENT64 **, const FTSENT64 **));
 FTSENT64 *fts64_read (FTS64 *);
 int     fts64_set (FTS64 *, FTSENT64 *, int) __THROW;
+# else
+#  ifdef __REDIRECT
+FTSENT *__REDIRECT (fts64_children, (FTS64 *, int), __fts64_children_time64);
+int     __REDIRECT (fts64_close, (FTS64 *), __fts64_close_time64);
+FTS    *__REDIRECT (fts64_open, (char * const *, int,
+                               int (*)(const FTSENT64 **, const FTSENT64 **)),
+                    __fts64_open_time64);
+FTSENT *__REDIRECT (fts64_read, (FTS64 *), __fts64_read_time64);
+int     __REDIRECT_NTH (fts64_set, (FTS64 *, FTSENT64 *, int),
+                        __fts64_set_time64);
+#  else
+#   define fts_children __fts64_children_time64
+#   define fts_close __fts64_close_time64
+#   define fts_open __fts64_open_time64
+#   define fts_read __fts64_read_time64
+#   define fts_set __fts64_set_time64
+#  endif
+# endif
 #endif
 __END_DECLS
 
diff --git a/io/fts64-time64.c b/io/fts64-time64.c
new file mode 100644 (file)
index 0000000..c8885ca
--- /dev/null
@@ -0,0 +1,35 @@
+/* File tree traversal functions LFS version.
+   Copyright (C) 2015-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/>.  */
+
+#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 FTSOBJ FTS64_TIME64
+# define FTSENTRY FSTENT64_TIME64
+# define INO_T ino64_t
+# define STRUCT_STAT __stat64_t64
+# define STAT __stat64_time64
+# define LSTAT __lstat64_time64
+
+# include "fts.c"
+#endif
index 0070ffc..cd9ed89 100644 (file)
@@ -206,6 +206,11 @@ libc {
     __futimens64;
     __futimes64;
     __futimesat64;
+    __fts64_open_time64;
+    __fts64_close_time64;
+    __fts64_read_time64;
+    __fts64_set_time64;
+    __fts64_children_time64;
     __getitimer64;
     __getrusage64;
     __gettimeofday64;
index 8e3101b..49fa140 100644 (file)
@@ -203,6 +203,11 @@ GLIBC_2.34 __ctime64_r F
 GLIBC_2.34 __difftime64 F
 GLIBC_2.34 __fstat64_time64 F
 GLIBC_2.34 __fstatat64_time64 F
+GLIBC_2.34 __fts64_children_time64 F
+GLIBC_2.34 __fts64_close_time64 F
+GLIBC_2.34 __fts64_open_time64 F
+GLIBC_2.34 __fts64_read_time64 F
+GLIBC_2.34 __fts64_set_time64 F
 GLIBC_2.34 __futimens64 F
 GLIBC_2.34 __futimes64 F
 GLIBC_2.34 __futimesat64 F
index b29a0e3..60e3da1 100644 (file)
@@ -200,6 +200,11 @@ GLIBC_2.34 __ctime64_r F
 GLIBC_2.34 __difftime64 F
 GLIBC_2.34 __fstat64_time64 F
 GLIBC_2.34 __fstatat64_time64 F
+GLIBC_2.34 __fts64_children_time64 F
+GLIBC_2.34 __fts64_close_time64 F
+GLIBC_2.34 __fts64_open_time64 F
+GLIBC_2.34 __fts64_read_time64 F
+GLIBC_2.34 __fts64_set_time64 F
 GLIBC_2.34 __futimens64 F
 GLIBC_2.34 __futimes64 F
 GLIBC_2.34 __futimesat64 F
index 5f5427c..a694b01 100644 (file)
@@ -2290,6 +2290,11 @@ GLIBC_2.34 __ctime64_r F
 GLIBC_2.34 __difftime64 F
 GLIBC_2.34 __fstat64_time64 F
 GLIBC_2.34 __fstatat64_time64 F
+GLIBC_2.34 __fts64_children_time64 F
+GLIBC_2.34 __fts64_close_time64 F
+GLIBC_2.34 __fts64_open_time64 F
+GLIBC_2.34 __fts64_read_time64 F
+GLIBC_2.34 __fts64_set_time64 F
 GLIBC_2.34 __futimens64 F
 GLIBC_2.34 __futimes64 F
 GLIBC_2.34 __futimesat64 F
index ca8f7c3..d40edc6 100644 (file)
@@ -2244,6 +2244,11 @@ GLIBC_2.34 __ctime64_r F
 GLIBC_2.34 __difftime64 F
 GLIBC_2.34 __fstat64_time64 F
 GLIBC_2.34 __fstatat64_time64 F
+GLIBC_2.34 __fts64_children_time64 F
+GLIBC_2.34 __fts64_close_time64 F
+GLIBC_2.34 __fts64_open_time64 F
+GLIBC_2.34 __fts64_read_time64 F
+GLIBC_2.34 __fts64_set_time64 F
 GLIBC_2.34 __futimens64 F
 GLIBC_2.34 __futimes64 F
 GLIBC_2.34 __futimesat64 F
index d2b7b4d..cd975e3 100644 (file)
@@ -2427,6 +2427,11 @@ GLIBC_2.34 __ctime64_r F
 GLIBC_2.34 __difftime64 F
 GLIBC_2.34 __fstat64_time64 F
 GLIBC_2.34 __fstatat64_time64 F
+GLIBC_2.34 __fts64_children_time64 F
+GLIBC_2.34 __fts64_close_time64 F
+GLIBC_2.34 __fts64_open_time64 F
+GLIBC_2.34 __fts64_read_time64 F
+GLIBC_2.34 __fts64_set_time64 F
 GLIBC_2.34 __futimens64 F
 GLIBC_2.34 __futimes64 F
 GLIBC_2.34 __futimesat64 F
index 515e383..77c15fd 100644 (file)
@@ -204,6 +204,11 @@ GLIBC_2.34 __ctime64_r F
 GLIBC_2.34 __difftime64 F
 GLIBC_2.34 __fstat64_time64 F
 GLIBC_2.34 __fstatat64_time64 F
+GLIBC_2.34 __fts64_children_time64 F
+GLIBC_2.34 __fts64_close_time64 F
+GLIBC_2.34 __fts64_open_time64 F
+GLIBC_2.34 __fts64_read_time64 F
+GLIBC_2.34 __fts64_set_time64 F
 GLIBC_2.34 __futimens64 F
 GLIBC_2.34 __futimes64 F
 GLIBC_2.34 __futimesat64 F
index 6915fa1..0e1ab15 100644 (file)
@@ -2371,6 +2371,11 @@ GLIBC_2.34 __ctime64_r F
 GLIBC_2.34 __difftime64 F
 GLIBC_2.34 __fstat64_time64 F
 GLIBC_2.34 __fstatat64_time64 F
+GLIBC_2.34 __fts64_children_time64 F
+GLIBC_2.34 __fts64_close_time64 F
+GLIBC_2.34 __fts64_open_time64 F
+GLIBC_2.34 __fts64_read_time64 F
+GLIBC_2.34 __fts64_set_time64 F
 GLIBC_2.34 __futimens64 F
 GLIBC_2.34 __futimes64 F
 GLIBC_2.34 __futimesat64 F
index 9293872..26641a9 100644 (file)
@@ -2341,6 +2341,11 @@ GLIBC_2.34 __ctime64_r F
 GLIBC_2.34 __difftime64 F
 GLIBC_2.34 __fstat64_time64 F
 GLIBC_2.34 __fstatat64_time64 F
+GLIBC_2.34 __fts64_children_time64 F
+GLIBC_2.34 __fts64_close_time64 F
+GLIBC_2.34 __fts64_open_time64 F
+GLIBC_2.34 __fts64_read_time64 F
+GLIBC_2.34 __fts64_set_time64 F
 GLIBC_2.34 __futimens64 F
 GLIBC_2.34 __futimes64 F
 GLIBC_2.34 __futimesat64 F
index cb671c5..dc50753 100644 (file)
@@ -2338,6 +2338,11 @@ GLIBC_2.34 __ctime64_r F
 GLIBC_2.34 __difftime64 F
 GLIBC_2.34 __fstat64_time64 F
 GLIBC_2.34 __fstatat64_time64 F
+GLIBC_2.34 __fts64_children_time64 F
+GLIBC_2.34 __fts64_close_time64 F
+GLIBC_2.34 __fts64_open_time64 F
+GLIBC_2.34 __fts64_read_time64 F
+GLIBC_2.34 __fts64_set_time64 F
 GLIBC_2.34 __futimens64 F
 GLIBC_2.34 __futimes64 F
 GLIBC_2.34 __futimesat64 F
index f5effe3..3d89c74 100644 (file)
@@ -2336,6 +2336,11 @@ GLIBC_2.34 __ctime64_r F
 GLIBC_2.34 __difftime64 F
 GLIBC_2.34 __fstat64_time64 F
 GLIBC_2.34 __fstatat64_time64 F
+GLIBC_2.34 __fts64_children_time64 F
+GLIBC_2.34 __fts64_close_time64 F
+GLIBC_2.34 __fts64_open_time64 F
+GLIBC_2.34 __fts64_read_time64 F
+GLIBC_2.34 __fts64_set_time64 F
 GLIBC_2.34 __futimens64 F
 GLIBC_2.34 __futimes64 F
 GLIBC_2.34 __futimesat64 F
index 2b66d26..6bfac13 100644 (file)
@@ -2334,6 +2334,11 @@ GLIBC_2.34 __ctime64_r F
 GLIBC_2.34 __difftime64 F
 GLIBC_2.34 __fstat64_time64 F
 GLIBC_2.34 __fstatat64_time64 F
+GLIBC_2.34 __fts64_children_time64 F
+GLIBC_2.34 __fts64_close_time64 F
+GLIBC_2.34 __fts64_open_time64 F
+GLIBC_2.34 __fts64_read_time64 F
+GLIBC_2.34 __fts64_set_time64 F
 GLIBC_2.34 __futimens64 F
 GLIBC_2.34 __futimes64 F
 GLIBC_2.34 __futimesat64 F
index bd76490..09c884a 100644 (file)
@@ -2342,6 +2342,11 @@ GLIBC_2.34 __ctime64_r F
 GLIBC_2.34 __difftime64 F
 GLIBC_2.34 __fstat64_time64 F
 GLIBC_2.34 __fstatat64_time64 F
+GLIBC_2.34 __fts64_children_time64 F
+GLIBC_2.34 __fts64_close_time64 F
+GLIBC_2.34 __fts64_open_time64 F
+GLIBC_2.34 __fts64_read_time64 F
+GLIBC_2.34 __fts64_set_time64 F
 GLIBC_2.34 __futimens64 F
 GLIBC_2.34 __futimes64 F
 GLIBC_2.34 __futimesat64 F
index e62a2a5..fd64cce 100644 (file)
@@ -2380,6 +2380,11 @@ GLIBC_2.34 __ctime64_r F
 GLIBC_2.34 __difftime64 F
 GLIBC_2.34 __fstat64_time64 F
 GLIBC_2.34 __fstatat64_time64 F
+GLIBC_2.34 __fts64_children_time64 F
+GLIBC_2.34 __fts64_close_time64 F
+GLIBC_2.34 __fts64_open_time64 F
+GLIBC_2.34 __fts64_read_time64 F
+GLIBC_2.34 __fts64_set_time64 F
 GLIBC_2.34 __futimens64 F
 GLIBC_2.34 __futimes64 F
 GLIBC_2.34 __futimesat64 F
index bc5b23c..306a572 100644 (file)
@@ -2398,6 +2398,11 @@ GLIBC_2.34 __ctime64_r F
 GLIBC_2.34 __difftime64 F
 GLIBC_2.34 __fstat64_time64 F
 GLIBC_2.34 __fstatat64_time64 F
+GLIBC_2.34 __fts64_children_time64 F
+GLIBC_2.34 __fts64_close_time64 F
+GLIBC_2.34 __fts64_open_time64 F
+GLIBC_2.34 __fts64_read_time64 F
+GLIBC_2.34 __fts64_set_time64 F
 GLIBC_2.34 __futimens64 F
 GLIBC_2.34 __futimes64 F
 GLIBC_2.34 __futimesat64 F
index f9421c7..86d4a96 100644 (file)
@@ -2431,6 +2431,11 @@ GLIBC_2.34 __ctime64_r F
 GLIBC_2.34 __difftime64 F
 GLIBC_2.34 __fstat64_time64 F
 GLIBC_2.34 __fstatat64_time64 F
+GLIBC_2.34 __fts64_children_time64 F
+GLIBC_2.34 __fts64_close_time64 F
+GLIBC_2.34 __fts64_open_time64 F
+GLIBC_2.34 __fts64_read_time64 F
+GLIBC_2.34 __fts64_set_time64 F
 GLIBC_2.34 __futimens64 F
 GLIBC_2.34 __futimes64 F
 GLIBC_2.34 __futimesat64 F
index 7581354..8f0716c 100644 (file)
@@ -2396,6 +2396,11 @@ GLIBC_2.34 __ctime64_r F
 GLIBC_2.34 __difftime64 F
 GLIBC_2.34 __fstat64_time64 F
 GLIBC_2.34 __fstatat64_time64 F
+GLIBC_2.34 __fts64_children_time64 F
+GLIBC_2.34 __fts64_close_time64 F
+GLIBC_2.34 __fts64_open_time64 F
+GLIBC_2.34 __fts64_read_time64 F
+GLIBC_2.34 __fts64_set_time64 F
 GLIBC_2.34 __futimens64 F
 GLIBC_2.34 __futimes64 F
 GLIBC_2.34 __futimesat64 F
index 0e45f7f..9c0b91f 100644 (file)
@@ -2251,6 +2251,11 @@ GLIBC_2.34 __ctime64_r F
 GLIBC_2.34 __difftime64 F
 GLIBC_2.34 __fstat64_time64 F
 GLIBC_2.34 __fstatat64_time64 F
+GLIBC_2.34 __fts64_children_time64 F
+GLIBC_2.34 __fts64_close_time64 F
+GLIBC_2.34 __fts64_open_time64 F
+GLIBC_2.34 __fts64_read_time64 F
+GLIBC_2.34 __fts64_set_time64 F
 GLIBC_2.34 __futimens64 F
 GLIBC_2.34 __futimes64 F
 GLIBC_2.34 __futimesat64 F
index ece6721..280984f 100644 (file)
@@ -2248,6 +2248,11 @@ GLIBC_2.34 __ctime64_r F
 GLIBC_2.34 __difftime64 F
 GLIBC_2.34 __fstat64_time64 F
 GLIBC_2.34 __fstatat64_time64 F
+GLIBC_2.34 __fts64_children_time64 F
+GLIBC_2.34 __fts64_close_time64 F
+GLIBC_2.34 __fts64_open_time64 F
+GLIBC_2.34 __fts64_read_time64 F
+GLIBC_2.34 __fts64_set_time64 F
 GLIBC_2.34 __futimens64 F
 GLIBC_2.34 __futimes64 F
 GLIBC_2.34 __futimesat64 F
index 6073443..d46f749 100644 (file)
@@ -2389,6 +2389,11 @@ GLIBC_2.34 __ctime64_r F
 GLIBC_2.34 __difftime64 F
 GLIBC_2.34 __fstat64_time64 F
 GLIBC_2.34 __fstatat64_time64 F
+GLIBC_2.34 __fts64_children_time64 F
+GLIBC_2.34 __fts64_close_time64 F
+GLIBC_2.34 __fts64_open_time64 F
+GLIBC_2.34 __fts64_read_time64 F
+GLIBC_2.34 __fts64_set_time64 F
 GLIBC_2.34 __futimens64 F
 GLIBC_2.34 __futimes64 F
 GLIBC_2.34 __futimesat64 F