[PATCH 08/46] lchown: Use fchownat if arch does not have the lchown syscall

Markos Chandras markos.chandras at gmail.com
Tue Nov 13 11:31:17 UTC 2012


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

Signed-off-by: Markos Chandras <markos.chandras at imgtec.com>
---
 libc/sysdeps/linux/common/lchown.c |   11 +++++++++++
 1 files changed, 11 insertions(+), 0 deletions(-)

diff --git a/libc/sysdeps/linux/common/lchown.c b/libc/sysdeps/linux/common/lchown.c
index c0f8ce7..5cc62a2 100644
--- a/libc/sysdeps/linux/common/lchown.c
+++ b/libc/sysdeps/linux/common/lchown.c
@@ -8,9 +8,18 @@
  */
 
 #include <sys/syscall.h>
+#include <fcntl.h>
 #include <unistd.h>
 #include <bits/wordsize.h>
 
+#if defined(__NR_fchownat) && ! defined(__NR_lchown)
+int lchown(const char* path, uid_t owner, gid_t group)
+{
+	return fchownat(AT_FDCWD, path, owner, group, AT_SYMLINK_NOFOLLOW);
+}
+
+#else
+
 #if (__WORDSIZE == 32 && defined(__NR_lchown32)) || __WORDSIZE == 64
 # ifdef __NR_lchown32
 #  undef __NR_lchown
@@ -36,3 +45,5 @@ int lchown(const char *path, uid_t owner, gid_t group)
 }
 
 #endif
+
+#endif
-- 
1.7.1




More information about the uClibc mailing list