[PATCH v3 37/48] lstat: Use fstatat64 if arch does not have the lstat syscall

Markos Chandras markos.chandras at gmail.com
Wed Jan 23 11:42:01 UTC 2013


From: Markos Chandras <markos.chandras at imgtec.com>

Signed-off-by: Markos Chandras <markos.chandras at imgtec.com>
---
 libc/sysdeps/linux/common/lstat.c | 17 +++++++++++++++--
 1 file changed, 15 insertions(+), 2 deletions(-)

diff --git a/libc/sysdeps/linux/common/lstat.c b/libc/sysdeps/linux/common/lstat.c
index db72d1f..9f086f4 100644
--- a/libc/sysdeps/linux/common/lstat.c
+++ b/libc/sysdeps/linux/common/lstat.c
@@ -8,10 +8,20 @@
  */
 
 #include <sys/syscall.h>
+#include <fcntl.h>
 #include <unistd.h>
 #include <sys/stat.h>
 #include "xstatconv.h"
 
+#if defined(__NR_fstatat64) && !defined(__NR_lstat)
+int lstat(const char *file_name, struct stat *buf)
+{
+	return fstatat(AT_FDCWD, file_name, buf, AT_SYMLINK_NOFOLLOW);
+}
+libc_hidden_def(lstat)
+
+/* For systems which have both, prefer the old one */
+#else
 int lstat(const char *file_name, struct stat *buf)
 {
 	int result;
@@ -33,12 +43,15 @@ int lstat(const char *file_name, struct stat *buf)
 	if (result == 0) {
 		__xstat_conv(&kbuf, buf);
 	}
-#endif
+#endif /* __NR_lstat64 */
 	return result;
 }
 libc_hidden_def(lstat)
 
-#if ! defined __NR_lstat64 && defined __UCLIBC_HAS_LFS__
+#if ! defined __NR_fstatat64 && ! defined __NR_lstat64 \
+	&& defined __UCLIBC_HAS_LFS__
 strong_alias_untyped(lstat,lstat64)
 libc_hidden_def(lstat64)
 #endif
+
+#endif /* __NR_fstatat64 */
-- 
1.8.1.1




More information about the uClibc mailing list