[PATCH 01/46] chmod: Use fchmodat if arch does not have the chmod syscall

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


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

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

diff --git a/libc/sysdeps/linux/common/chmod.c b/libc/sysdeps/linux/common/chmod.c
index 871e023..9ceb8c6 100644
--- a/libc/sysdeps/linux/common/chmod.c
+++ b/libc/sysdeps/linux/common/chmod.c
@@ -9,8 +9,16 @@
 
 #include <sys/syscall.h>
 #include <sys/stat.h>
+#include <fcntl.h>
+#include <unistd.h>
 
+#if defined(__NR_fchmodat) && ! defined(__NR_chmod)
+int chmod(const char* path, mode_t mode)
+{
+	return fchmodat(AT_FDCWD, path, mode, 0);
+}
 
+#else
 #define __NR___syscall_chmod __NR_chmod
 static __inline__ _syscall2(int, __syscall_chmod, const char *, path, __kernel_mode_t, mode)
 
@@ -18,4 +26,5 @@ int chmod(const char *path, mode_t mode)
 {
 	return __syscall_chmod(path, mode);
 }
+#endif
 libc_hidden_def(chmod)
-- 
1.7.1




More information about the uClibc mailing list