[RFC PATCH 10/38] lchown: prefer fchownat syscall

Jonas Bonn jonas at southpole.se
Tue Sep 6 08:30:34 UTC 2011


Signed-off-by: Jonas Bonn <jonas at southpole.se>
---
 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..c1103a6 100644
--- a/libc/sysdeps/linux/common/lchown.c
+++ b/libc/sysdeps/linux/common/lchown.c
@@ -10,6 +10,15 @@
 #include <sys/syscall.h>
 #include <unistd.h>
 #include <bits/wordsize.h>
+#include <fcntl.h>
+
+#ifdef __NR_fchownat
+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
@@ -36,3 +45,5 @@ int lchown(const char *path, uid_t owner, gid_t group)
 }
 
 #endif
+
+#endif
-- 
1.7.5.4



More information about the uClibc mailing list