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