From: Markos Chandras <[email protected]>

Signed-off-by: Markos Chandras <[email protected]>
---
 include/sys/stat.h                  |  1 +
 libc/sysdeps/linux/common/fstatat.c |  1 +
 libc/sysdeps/linux/common/stat.c    | 17 ++++++++++++++---
 3 files changed, 16 insertions(+), 3 deletions(-)

diff --git a/include/sys/stat.h b/include/sys/stat.h
index f3a52ad..495a68c 100644
--- a/include/sys/stat.h
+++ b/include/sys/stat.h
@@ -241,6 +241,7 @@ libc_hidden_proto(fstat64)
 extern int fstatat (int __fd, const char *__restrict __file,
                    struct stat *__restrict __buf, int __flag)
      __THROW __nonnull ((2, 3));
+libc_hidden_proto(fstatat)
 # else
 #  ifdef __REDIRECT_NTH
 extern int __REDIRECT_NTH (fstatat, (int __fd, const char *__restrict __file,
diff --git a/libc/sysdeps/linux/common/fstatat.c 
b/libc/sysdeps/linux/common/fstatat.c
index 2fde220..51c2922 100644
--- a/libc/sysdeps/linux/common/fstatat.c
+++ b/libc/sysdeps/linux/common/fstatat.c
@@ -38,6 +38,7 @@ int fstatat(int fd, const char *file, struct stat *buf, int 
flag)
 #endif /* __ARCH_HAS_DEPRECATED_SYSCALLS__ */
        return ret;
 }
+libc_hidden_def(fstatat)
 #else
 /* should add emulation with fstat() and /proc/self/fd/ ... */
 #endif
diff --git a/libc/sysdeps/linux/common/stat.c b/libc/sysdeps/linux/common/stat.c
index 829f35a..41cb363 100644
--- a/libc/sysdeps/linux/common/stat.c
+++ b/libc/sysdeps/linux/common/stat.c
@@ -8,12 +8,21 @@
  */
 
 #include <sys/syscall.h>
+#include <fcntl.h>
 #include <unistd.h>
 #include <sys/stat.h>
 #include "xstatconv.h"
 
 #undef stat
 
+#if defined(__NR_fstatat64) && !defined(__NR_stat)
+int stat(const char *file_name, struct stat *buf)
+{
+       return fstatat(AT_FDCWD, file_name, buf, 0);
+}
+
+#else
+
 int stat(const char *file_name, struct stat *buf)
 {
        int result;
@@ -35,12 +44,14 @@ int stat(const char *file_name, struct stat *buf)
        if (result == 0) {
                __xstat_conv(&kbuf, buf);
        }
-#endif
+#endif /* __NR_stat64 */
        return result;
 }
+#endif /* __NR_fstat64 */
 libc_hidden_def(stat)
 
-#if ! defined __NR_stat64 && defined __UCLIBC_HAS_LFS__
+#if ! defined __NR_stat64 && ! defined __NR_fstatat64 && \
+       defined __UCLIBC_HAS_LFS__
 strong_alias_untyped(stat,stat64)
 libc_hidden_def(stat64)
-#endif
+#endif /* __UCLIBC_HAS_LFS__ */
-- 
1.8.1.1


_______________________________________________
uClibc mailing list
[email protected]
http://lists.busybox.net/mailman/listinfo/uclibc

Reply via email to