00c0d4
Partial backport of:
00c0d4
00c0d4
commit 04986243d1af37ac0177ed2f9db0a066ebd2b212
00c0d4
Author: Adhemerval Zanella <adhemerval.zanella@linaro.org>
00c0d4
Date:   Wed Jul 15 19:35:58 2020 +0000
00c0d4
00c0d4
    Remove internal usage of extensible stat functions
00c0d4
00c0d4
    It replaces the internal usage of __{f,l}xstat{at}{64} with the
00c0d4
    __{f,l}stat{at}{64}.  It should not change the generate code since
00c0d4
    sys/stat.h explicit defines redirections to internal calls back to
00c0d4
    xstat* symbols.
00c0d4
00c0d4
    Checked with a build for all affected ABIs.  I also check on
00c0d4
    x86_64-linux-gnu and i686-linux-gnu.
00c0d4
00c0d4
    Reviewed-by: Lukasz Majewski <lukma@denx.de>
00c0d4
00c0d4
Only the changes to include/sys/stat.h and sysdeps/posix/tempname.c
00c0d4
are included here.
00c0d4
00c0d4
diff --git a/include/sys/stat.h b/include/sys/stat.h
00c0d4
index b82d4527801d4797..c5b1938b87c9c5c3 100644
00c0d4
--- a/include/sys/stat.h
00c0d4
+++ b/include/sys/stat.h
00c0d4
@@ -52,6 +52,7 @@ extern __typeof (__fxstatat64) __fxstatat64 attribute_hidden;
00c0d4
 #define lstat64(fname, buf)  __lxstat64 (_STAT_VER, fname, buf)
00c0d4
 #define __lstat64(fname, buf)  __lxstat64 (_STAT_VER, fname, buf)
00c0d4
 #define stat64(fname, buf) __xstat64 (_STAT_VER, fname, buf)
00c0d4
+#define __stat64(fname, buf) __xstat64 (_STAT_VER, fname, buf)
00c0d4
 #define fstat64(fd, buf) __fxstat64 (_STAT_VER, fd, buf)
00c0d4
 #define __fstat64(fd, buf) __fxstat64 (_STAT_VER, fd, buf)
00c0d4
 #define fstat(fd, buf) __fxstat (_STAT_VER, fd, buf)
00c0d4
diff --git a/sysdeps/posix/tempname.c b/sysdeps/posix/tempname.c
00c0d4
index 61d7a9f36d37abae..a7b404cf4410cb00 100644
00c0d4
--- a/sysdeps/posix/tempname.c
00c0d4
+++ b/sysdeps/posix/tempname.c
00c0d4
@@ -66,7 +66,6 @@
00c0d4
 # define __gettimeofday gettimeofday
00c0d4
 # define __mkdir mkdir
00c0d4
 # define __open open
00c0d4
-# define __lxstat64(version, file, buf) lstat (file, buf)
00c0d4
 # define __secure_getenv secure_getenv
00c0d4
 #endif
00c0d4
 
00c0d4
@@ -97,7 +96,7 @@ static int
00c0d4
 direxists (const char *dir)
00c0d4
 {
00c0d4
   struct_stat64 buf;
00c0d4
-  return __xstat64 (_STAT_VER, dir, &buf) == 0 && S_ISDIR (buf.st_mode);
00c0d4
+  return __stat64 (dir, &buf) == 0 && S_ISDIR (buf.st_mode);
00c0d4
 }
00c0d4
 
00c0d4
 /* Path search algorithm, for tmpnam, tmpfile, etc.  If DIR is
00c0d4
@@ -252,10 +251,10 @@ __gen_tempname (char *tmpl, int suffixlen, int flags, int kind)
00c0d4
 
00c0d4
 	case __GT_NOCREATE:
00c0d4
 	  /* This case is backward from the other three.  __gen_tempname
00c0d4
-	     succeeds if __xstat fails because the name does not exist.
00c0d4
+	     succeeds if lstat fails because the name does not exist.
00c0d4
 	     Note the continue to bypass the common logic at the bottom
00c0d4
 	     of the loop.  */
00c0d4
-	  if (__lxstat64 (_STAT_VER, tmpl, &st) < 0)
00c0d4
+	  if (__lstat64 (tmpl, &st) < 0)
00c0d4
 	    {
00c0d4
 	      if (errno == ENOENT)
00c0d4
 		{