diff options
author | Markos Chandras <markos.chandras@imgtec.com> | 2012-10-11 16:25:32 +0100 |
---|---|---|
committer | Bernhard Reutner-Fischer <rep.dot.nop@gmail.com> | 2013-02-20 13:45:13 +0100 |
commit | 634e74f630772fe2eb0e731d8a5cd35cf4a0da79 (patch) | |
tree | 53fb89d17967d5be73426d7b284393bfc56a20cc | |
parent | 9f44c4ca56c2a318fb51029340a26764ed2b708f (diff) |
ldso: Use newer syscalls if arch does not have the deprecated syscalls
Signed-off-by: Markos Chandras <markos.chandras@imgtec.com>
Signed-off-by: Bernhard Reutner-Fischer <rep.dot.nop@gmail.com>
-rw-r--r-- | ldso/include/dl-syscall.h | 41 | ||||
-rw-r--r-- | ldso/include/ldso.h | 4 |
2 files changed, 40 insertions, 5 deletions
diff --git a/ldso/include/dl-syscall.h b/ldso/include/dl-syscall.h index acfef529a..b1f69ab64 100644 --- a/ldso/include/dl-syscall.h +++ b/ldso/include/dl-syscall.h @@ -23,7 +23,7 @@ extern int _dl_errno; /* Pull in whatever this particular arch's kernel thinks the kernel version of * struct stat should look like. It turns out that each arch has a different * opinion on the subject, and different kernel revs use different names... */ -#if defined(__sparc_v9__) && (__WORDSIZE == 64) +#if !defined __NR_stat || (defined(__sparc_v9__) && (__WORDSIZE == 64)) #define kernel_stat64 stat #else #define kernel_stat stat @@ -48,9 +48,18 @@ static __always_inline _syscall1(void, _dl_exit, int, status) #define __NR__dl_close __NR_close static __always_inline _syscall1(int, _dl_close, int, fd) -#define __NR__dl_open __NR_open +#if defined __NR_openat && !defined __NR_open +static __always_inline int _dl_open(const char *fn, + int flags, __kernel_mode_t mode) +{ + return INLINE_SYSCALL(openat, 4, AT_FDCWD, fn, flags, mode); +} + +#elif defined __NR_open +# define __NR__dl_open __NR_open static __always_inline _syscall3(int, _dl_open, const char *, fn, int, flags, __kernel_mode_t, mode) +#endif #define __NR__dl_write __NR_write static __always_inline _syscall3(unsigned long, _dl_write, int, fd, @@ -64,11 +73,27 @@ static __always_inline _syscall3(unsigned long, _dl_read, int, fd, static __always_inline _syscall3(int, _dl_mprotect, const void *, addr, unsigned long, len, int, prot) -#define __NR__dl_stat __NR_stat +#if defined __NR_fstatat64 && !defined __NR_stat +# define __NR__dl_fstatat64 __NR_fstatat64 +static __always_inline _syscall4(int, _dl_fstatat64, int, fd, const char *, + fn, struct stat *, stat, int, flags) + +static __always_inline int _dl_stat(const char *file_name, + struct stat *buf) +{ + return _dl_fstatat64(AT_FDCWD, file_name, buf, 0); +} +#elif defined __NR_stat +# define __NR__dl_stat __NR_stat static __always_inline _syscall2(int, _dl_stat, const char *, file_name, struct stat *, buf) +#endif -#define __NR__dl_fstat __NR_fstat +#if defined __NR_fstat64 && !defined __NR_fstat +# define __NR__dl_fstat __NR_fstat64 +#elif defined __NR_fstat +# define __NR__dl_fstat __NR_fstat +#endif static __always_inline _syscall2(int, _dl_fstat, int, fd, struct stat *, buf) #define __NR__dl_munmap __NR_munmap @@ -104,9 +129,15 @@ static __always_inline _syscall0(gid_t, _dl_getegid) #define __NR__dl_getpid __NR_getpid static __always_inline _syscall0(gid_t, _dl_getpid) -#define __NR__dl_readlink __NR_readlink +#if defined __NR_readlinkat && !defined __NR_readlink +# define __NR__dl_readlink __NR_readlinkat +static __always_inline _syscall4(int, _dl_readlink, int, id, const char *, path, + char *, buf, size_t, bufsiz) +#elif defined __NR_readlink +# define __NR__dl_readlink __NR_readlink static __always_inline _syscall3(int, _dl_readlink, const char *, path, char *, buf, size_t, bufsiz) +#endif #ifdef __NR_pread64 #define __NR___syscall_pread __NR_pread64 diff --git a/ldso/include/ldso.h b/ldso/include/ldso.h index e0671f74a..1e0465382 100644 --- a/ldso/include/ldso.h +++ b/ldso/include/ldso.h @@ -30,6 +30,10 @@ #include <stddef.h> /* for ptrdiff_t */ #include <stdbool.h> #define _FCNTL_H +/* We need this if arch has only new syscalls defined */ +#ifndef AT_FDCWD +#define AT_FDCWD -100 +#endif /* AT_FDCWD */ #include <bits/fcntl.h> #include <bits/wordsize.h> /* Pull in the arch specific type information */ |