[PATCH 06/46] chown: Use fchownat if arch does not have the chown syscall

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


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

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

diff --git a/libc/sysdeps/linux/common/chown.c b/libc/sysdeps/linux/common/chown.c
index f2c60e0..4cc686b 100644
--- a/libc/sysdeps/linux/common/chown.c
+++ b/libc/sysdeps/linux/common/chown.c
@@ -8,9 +8,17 @@
  */
 
 #include <sys/syscall.h>
+#include <fcntl.h>
 #include <unistd.h>
 #include <bits/wordsize.h>
 
+#if defined(__NR_fchownat) && ! defined(__NR_chown)
+int chown(const char *path, uid_t owner, gid_t group)
+{
+	return fchownat(AT_FDCWD, path, owner, group, 0);
+}
+
+#else
 
 #if (__WORDSIZE == 32 && defined(__NR_chown32)) || __WORDSIZE == 64
 # ifdef __NR_chown32
@@ -37,4 +45,5 @@ int chown(const char *path, uid_t owner, gid_t group)
 }
 #endif
 
+#endif
 libc_hidden_def(chown)
-- 
1.7.1




More information about the uClibc mailing list