summaryrefslogtreecommitdiff
path: root/libc/sysdeps/linux
diff options
context:
space:
mode:
Diffstat (limited to 'libc/sysdeps/linux')
-rw-r--r--libc/sysdeps/linux/common/chown.c15
-rw-r--r--libc/sysdeps/linux/common/fchown.c14
-rw-r--r--libc/sysdeps/linux/common/getgid.c6
-rw-r--r--libc/sysdeps/linux/common/getuid.c8
-rw-r--r--libc/sysdeps/linux/common/lchown.c15
-rw-r--r--libc/sysdeps/linux/common/setfsgid.c14
-rw-r--r--libc/sysdeps/linux/common/setfsuid.c14
-rw-r--r--libc/sysdeps/linux/common/setgid.c14
-rw-r--r--libc/sysdeps/linux/common/setregid.c15
-rw-r--r--libc/sysdeps/linux/common/setreuid.c15
-rw-r--r--libc/sysdeps/linux/common/setuid.c14
11 files changed, 129 insertions, 15 deletions
diff --git a/libc/sysdeps/linux/common/chown.c b/libc/sysdeps/linux/common/chown.c
index d6461394b..6e663a03b 100644
--- a/libc/sysdeps/linux/common/chown.c
+++ b/libc/sysdeps/linux/common/chown.c
@@ -9,10 +9,21 @@
#include "syscalls.h"
#include <unistd.h>
+#include <bits/wordsize.h>
libc_hidden_proto(chown)
-#define __NR___syscall_chown __NR_chown
+#if (__WORDSIZE == 32 && defined(__NR_chown32)) || __WORDSIZE == 64
+# ifdef __NR_chown32
+# undef __NR_chown
+# define __NR_chown __NR_chown32
+# endif
+
+_syscall3(int, chown, const char *, path, uid_t, owner, gid_t, group);
+
+#else
+
+# define __NR___syscall_chown __NR_chown
static inline _syscall3(int, __syscall_chown, const char *, path,
__kernel_uid_t, owner, __kernel_gid_t, group);
@@ -25,4 +36,6 @@ int chown(const char *path, uid_t owner, gid_t group)
}
return (__syscall_chown(path, owner, group));
}
+#endif
+
libc_hidden_def(chown)
diff --git a/libc/sysdeps/linux/common/fchown.c b/libc/sysdeps/linux/common/fchown.c
index fa8734284..2373ed7ac 100644
--- a/libc/sysdeps/linux/common/fchown.c
+++ b/libc/sysdeps/linux/common/fchown.c
@@ -2,24 +2,26 @@
/*
* fchown() for uClibc
*
- * Copyright (C) 2000-2006 by Erik Andersen <andersen@codepoet.org>
+ * Copyright (C) 2000-2006 Erik Andersen <andersen@codepoet.org>
*
* Licensed under the LGPL v2.1, see the file COPYING.LIB in this tarball.
*/
#include "syscalls.h"
#include <unistd.h>
-#include <linux/version.h>
+#include <bits/wordsize.h>
-/* Linux 2.3.39 introduced 32bit UID/GIDs. Some platforms had 32
- bit type all along. */
-#if LINUX_VERSION_CODE >= 131879
+#if (__WORDSIZE == 32 && defined(__NR_fchown32)) || __WORDSIZE == 64
+# ifdef __NR_fchown32
+# undef __NR_fchown
+# define __NR_fchown __NR_fchown32
+# endif
_syscall3(int, fchown, int, fd, uid_t, owner, gid_t, group);
#else
-#define __NR___syscall_fchown __NR_fchown
+# define __NR___syscall_fchown __NR_fchown
static inline _syscall3(int, __syscall_fchown, int, fd,
__kernel_uid_t, owner, __kernel_gid_t, group);
diff --git a/libc/sysdeps/linux/common/getgid.c b/libc/sysdeps/linux/common/getgid.c
index 3f48c33c8..f155b580e 100644
--- a/libc/sysdeps/linux/common/getgid.c
+++ b/libc/sysdeps/linux/common/getgid.c
@@ -11,8 +11,14 @@
#include <unistd.h>
#if defined __NR_getxgid
+# undef __NR_getgid
# define __NR_getgid __NR_getxgid
#endif
+#ifdef __NR_getgid32
+# undef __NR_getgid
+# define __NR_getgid __NR_getgid32
+#endif
+
libc_hidden_proto(getgid)
_syscall0(gid_t, getgid);
libc_hidden_def(getgid)
diff --git a/libc/sysdeps/linux/common/getuid.c b/libc/sysdeps/linux/common/getuid.c
index 21c504d65..484db370f 100644
--- a/libc/sysdeps/linux/common/getuid.c
+++ b/libc/sysdeps/linux/common/getuid.c
@@ -11,8 +11,14 @@
#include <unistd.h>
#if defined __NR_getxuid
-# define __NR_getuid __NR_getxuid
+# undef __NR_getuid
+# define __NR_getuid __NR_getxuid
#endif
+#ifdef __NR_getuid32
+# undef __NR_getuid
+# define __NR_getuid __NR_getuid32
+#endif
+
libc_hidden_proto(getuid)
_syscall0(uid_t, getuid);
libc_hidden_def(getuid)
diff --git a/libc/sysdeps/linux/common/lchown.c b/libc/sysdeps/linux/common/lchown.c
index ffee39126..5858c26b9 100644
--- a/libc/sysdeps/linux/common/lchown.c
+++ b/libc/sysdeps/linux/common/lchown.c
@@ -9,8 +9,19 @@
#include "syscalls.h"
#include <unistd.h>
+#include <bits/wordsize.h>
-#define __NR___syscall_lchown __NR_lchown
+#if (__WORDSIZE == 32 && defined(__NR_lchown32)) || __WORDSIZE == 64
+# ifdef __NR_lchown32
+# undef __NR_lchown
+# define __NR_lchown __NR_lchown32
+# endif
+
+_syscall3(int, lchown, const char *, path, uid_t, owner, gid_t, group);
+
+#else
+
+# define __NR___syscall_lchown __NR_lchown
static inline _syscall3(int, __syscall_lchown, const char *, path,
__kernel_uid_t, owner, __kernel_gid_t, group);
@@ -23,3 +34,5 @@ int lchown(const char *path, uid_t owner, gid_t group)
}
return __syscall_lchown(path, owner, group);
}
+
+#endif
diff --git a/libc/sysdeps/linux/common/setfsgid.c b/libc/sysdeps/linux/common/setfsgid.c
index 027dd11f6..c07a861f9 100644
--- a/libc/sysdeps/linux/common/setfsgid.c
+++ b/libc/sysdeps/linux/common/setfsgid.c
@@ -9,8 +9,19 @@
#include "syscalls.h"
#include <sys/fsuid.h>
+#include <bits/wordsize.h>
-#define __NR___syscall_setfsgid __NR_setfsgid
+#if (__WORDSIZE == 32 && defined(__NR_setfsgid32)) || __WORDSIZE == 64
+# ifdef __NR_setfsgid32
+# undef __NR_setfsgid
+# define __NR_setfsgid __NR_setfsgid32
+# endif
+
+_syscall1(int, setfsgid, gid_t, gid);
+
+#else
+
+# define __NR___syscall_setfsgid __NR_setfsgid
static inline _syscall1(int, __syscall_setfsgid, __kernel_gid_t, gid);
int setfsgid(gid_t gid)
@@ -21,3 +32,4 @@ int setfsgid(gid_t gid)
}
return (__syscall_setfsgid(gid));
}
+#endif
diff --git a/libc/sysdeps/linux/common/setfsuid.c b/libc/sysdeps/linux/common/setfsuid.c
index 4bbc931cf..7f2375ca1 100644
--- a/libc/sysdeps/linux/common/setfsuid.c
+++ b/libc/sysdeps/linux/common/setfsuid.c
@@ -9,8 +9,19 @@
#include "syscalls.h"
#include <sys/fsuid.h>
+#include <bits/wordsize.h>
-#define __NR___syscall_setfsuid __NR_setfsuid
+#if (__WORDSIZE == 32 && defined(__NR_setfsuid32)) || __WORDSIZE == 64
+# ifdef __NR_setfsuid32
+# undef __NR_setfsuid
+# define __NR_setfsuid __NR_setfsuid32
+# endif
+
+_syscall1(int, setfsuid, uid_t, uid);
+
+#else
+
+# define __NR___syscall_setfsuid __NR_setfsuid
static inline _syscall1(int, __syscall_setfsuid, __kernel_uid_t, uid);
int setfsuid(uid_t uid)
@@ -21,3 +32,4 @@ int setfsuid(uid_t uid)
}
return (__syscall_setfsuid(uid));
}
+#endif
diff --git a/libc/sysdeps/linux/common/setgid.c b/libc/sysdeps/linux/common/setgid.c
index d0698f517..45bcdb2e9 100644
--- a/libc/sysdeps/linux/common/setgid.c
+++ b/libc/sysdeps/linux/common/setgid.c
@@ -9,8 +9,19 @@
#include "syscalls.h"
#include <unistd.h>
+#include <bits/wordsize.h>
-#define __NR___syscall_setgid __NR_setgid
+#if (__WORDSIZE == 32 && defined(__NR_setgid32)) || __WORDSIZE == 64
+# ifdef __NR_setgid32
+# undef __NR_setgid
+# define __NR_setgid __NR_setgid32
+# endif
+
+_syscall1(int, setgid, gid_t, gid);
+
+#else
+
+# define __NR___syscall_setgid __NR_setgid
static inline _syscall1(int, __syscall_setgid, __kernel_gid_t, gid);
int setgid(gid_t gid)
@@ -21,3 +32,4 @@ int setgid(gid_t gid)
}
return (__syscall_setgid(gid));
}
+#endif
diff --git a/libc/sysdeps/linux/common/setregid.c b/libc/sysdeps/linux/common/setregid.c
index a085ed2ab..b37a888e9 100644
--- a/libc/sysdeps/linux/common/setregid.c
+++ b/libc/sysdeps/linux/common/setregid.c
@@ -9,10 +9,21 @@
#include "syscalls.h"
#include <unistd.h>
+#include <bits/wordsize.h>
libc_hidden_proto(setregid)
-#define __NR___syscall_setregid __NR_setregid
+#if (__WORDSIZE == 32 && defined(__NR_setregid32)) || __WORDSIZE == 64
+# ifdef __NR_setregid32
+# undef __NR_setregid
+# define __NR_setregid __NR_setregid32
+# endif
+
+_syscall2(int, setregid, gid_t, rgid, gid_t, egid);
+
+#else
+
+# define __NR___syscall_setregid __NR_setregid
static inline _syscall2(int, __syscall_setregid,
__kernel_gid_t, rgid, __kernel_gid_t, egid);
@@ -25,4 +36,6 @@ int setregid(gid_t rgid, gid_t egid)
}
return (__syscall_setregid(rgid, egid));
}
+#endif
+
libc_hidden_def(setregid)
diff --git a/libc/sysdeps/linux/common/setreuid.c b/libc/sysdeps/linux/common/setreuid.c
index dcbe4adfe..acff36047 100644
--- a/libc/sysdeps/linux/common/setreuid.c
+++ b/libc/sysdeps/linux/common/setreuid.c
@@ -9,10 +9,21 @@
#include "syscalls.h"
#include <unistd.h>
+#include <bits/wordsize.h>
libc_hidden_proto(setreuid)
-#define __NR___syscall_setreuid __NR_setreuid
+#if (__WORDSIZE == 32 && defined(__NR_setreuid32)) || __WORDSIZE == 64
+# ifdef __NR_setreuid32
+# undef __NR_setreuid
+# define __NR_setreuid __NR_setreuid32
+# endif
+
+_syscall2(int, setreuid, uid_t, ruid, uid_t, euid);
+
+#else
+
+# define __NR___syscall_setreuid __NR_setreuid
static inline _syscall2(int, __syscall_setreuid,
__kernel_uid_t, ruid, __kernel_uid_t, euid);
@@ -25,4 +36,6 @@ int setreuid(uid_t ruid, uid_t euid)
}
return (__syscall_setreuid(ruid, euid));
}
+#endif
+
libc_hidden_def(setreuid)
diff --git a/libc/sysdeps/linux/common/setuid.c b/libc/sysdeps/linux/common/setuid.c
index b4b2e1bd1..9390713ff 100644
--- a/libc/sysdeps/linux/common/setuid.c
+++ b/libc/sysdeps/linux/common/setuid.c
@@ -9,8 +9,19 @@
#include "syscalls.h"
#include <unistd.h>
+#include <bits/wordsize.h>
-#define __NR___syscall_setuid __NR_setuid
+#if (__WORDSIZE == 32 && defined(__NR_setuid32)) || __WORDSIZE == 64
+# ifdef __NR_setuid32
+# undef __NR_setuid
+# define __NR_setuid __NR_setuid32
+# endif
+
+_syscall1(int, setuid, uid_t, uid);
+
+#else
+
+# define __NR___syscall_setuid __NR_setuid
static inline _syscall1(int, __syscall_setuid, __kernel_uid_t, uid);
int setuid(uid_t uid)
@@ -21,3 +32,4 @@ int setuid(uid_t uid)
}
return (__syscall_setuid(uid));
}
+#endif