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