Signed-off-by: Mark Salter <[email protected]>
---
ldso/include/dl-syscall.h | 15 ++++++++++++++-
libc/sysdeps/linux/common/fstatfs.c | 25 +++++++++++++++++++++++++
libc/sysdeps/linux/common/ftruncate.c | 7 +++++++
libc/sysdeps/linux/common/stat.c | 7 ++++++-
libc/sysdeps/linux/common/statfs.c | 25 +++++++++++++++++++++++++
libc/sysdeps/linux/common/truncate.c | 7 +++++++
6 files changed, 84 insertions(+), 2 deletions(-)
diff --git a/ldso/include/dl-syscall.h b/ldso/include/dl-syscall.h
index 547dad1..4c8aeaf 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
@@ -35,6 +35,7 @@ extern int _dl_errno;
#define S_ISUID 04000 /* Set user ID on execution. */
#define S_ISGID 02000 /* Set group ID on execution. */
+#define AT_FDCWD -100
/* Here are the definitions for some syscalls that are used
by the dynamic linker. The idea is that we want to be able
@@ -64,11 +65,23 @@ 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)
+#if defined(__NR_stat)
#define __NR__dl_stat __NR_stat
static __always_inline _syscall2(int, _dl_stat, const char *, file_name,
struct stat *, buf)
+#elif defined(__NR_fstatat64)
+static __always_inline int
+_dl_stat(const char *fn, struct stat *stat)
+{
+ return INLINE_SYSCALL(fstatat64, 4, AT_FDCWD, fn, stat, 0);
+}
+#endif
+#if defined(__NR_fstat)
#define __NR__dl_fstat __NR_fstat
+#elif defined(__NR_fstat64)
+#define __NR__dl_fstat __NR_fstat64
+#endif
static __always_inline _syscall2(int, _dl_fstat, int, fd, struct stat *, buf)
#define __NR__dl_munmap __NR_munmap
diff --git a/libc/sysdeps/linux/common/fstatfs.c
b/libc/sysdeps/linux/common/fstatfs.c
index fa0024a..3c8c53e 100644
--- a/libc/sysdeps/linux/common/fstatfs.c
+++ b/libc/sysdeps/linux/common/fstatfs.c
@@ -22,9 +22,34 @@ extern int __REDIRECT_NTH (fstatfs, (int __fildes, struct
statfs *__buf),
# endif
#endif
+#ifdef __NR_fstatfs
extern __typeof(fstatfs) __libc_fstatfs attribute_hidden;
#define __NR___libc_fstatfs __NR_fstatfs
_syscall2(int, __libc_fstatfs, int, fd, struct statfs *, buf)
+#elif defined __NR_fstatfs64
+int __libc_fstatfs(int fd, struct statfs *buf)
+{
+ struct statfs64 st;
+ int err;
+
+ err = INLINE_SYSCALL(fstatfs64, 3, fd, sizeof(st), &st);
+ if (err)
+ return err;
+
+ buf->f_type = st.f_type;
+ buf->f_bsize = st.f_bsize;
+ buf->f_blocks = st.f_blocks;
+ buf->f_bfree = st.f_bfree;
+ buf->f_bavail = st.f_bavail;
+ buf->f_files = st.f_files;
+ buf->f_ffree = st.f_ffree;
+ buf->f_fsid = st.f_fsid;
+ buf->f_namelen = st.f_namelen;
+ buf->f_frsize = st.f_frsize;
+
+ return 0;
+}
+#endif
#if defined __UCLIBC_LINUX_SPECIFIC__
weak_alias(__libc_fstatfs,fstatfs)
diff --git a/libc/sysdeps/linux/common/ftruncate.c
b/libc/sysdeps/linux/common/ftruncate.c
index 3bdef3f..a2bb016 100644
--- a/libc/sysdeps/linux/common/ftruncate.c
+++ b/libc/sysdeps/linux/common/ftruncate.c
@@ -11,5 +11,12 @@
#include <unistd.h>
+#ifdef __NR_ftruncate
_syscall2(int, ftruncate, int, fd, __off_t, length)
+#elif defined __NR_truncate64
+int ftruncate(int fd, __off_t length)
+{
+ return ftruncate64(fd, length);
+}
+#endif
libc_hidden_def(ftruncate)
diff --git a/libc/sysdeps/linux/common/stat.c b/libc/sysdeps/linux/common/stat.c
index 829f35a..8e0e9f5 100644
--- a/libc/sysdeps/linux/common/stat.c
+++ b/libc/sysdeps/linux/common/stat.c
@@ -9,6 +9,7 @@
#include <sys/syscall.h>
#include <unistd.h>
+#include <fcntl.h>
#include <sys/stat.h>
#include "xstatconv.h"
@@ -17,14 +18,18 @@
int stat(const char *file_name, struct stat *buf)
{
int result;
-#ifdef __NR_stat64
+#if defined __NR_stat64 || defined __NR_fstatat64
/* normal stat call has limited values for various stat elements
* e.g. uid device major/minor etc.
* so we use 64 variant if available
* in order to get newer versions of stat elements
*/
struct kernel_stat64 kbuf;
+#ifdef __NR_stat64
result = INLINE_SYSCALL(stat64, 2, file_name, &kbuf);
+#else
+ result = INLINE_SYSCALL(fstatat64, 4, AT_FDCWD, file_name, &kbuf, 0);
+#endif
if (result == 0) {
__xstat32_conv(&kbuf, buf);
}
diff --git a/libc/sysdeps/linux/common/statfs.c
b/libc/sysdeps/linux/common/statfs.c
index d24bc9d..9def2f5 100644
--- a/libc/sysdeps/linux/common/statfs.c
+++ b/libc/sysdeps/linux/common/statfs.c
@@ -12,9 +12,34 @@
#include <sys/param.h>
#include <sys/vfs.h>
+#if defined __NR_statfs
extern __typeof(statfs) __libc_statfs attribute_hidden;
#define __NR___libc_statfs __NR_statfs
_syscall2(int, __libc_statfs, const char *, path, struct statfs *, buf)
+#elif defined __NR_statfs64
+int __libc_statfs(const char *path, struct statfs *buf)
+{
+ struct statfs64 st;
+ int err;
+
+ err = INLINE_SYSCALL(statfs64, 3, path, sizeof(st), &st);
+ if (err)
+ return err;
+
+ buf->f_type = st.f_type;
+ buf->f_bsize = st.f_bsize;
+ buf->f_blocks = st.f_blocks;
+ buf->f_bfree = st.f_bfree;
+ buf->f_bavail = st.f_bavail;
+ buf->f_files = st.f_files;
+ buf->f_ffree = st.f_ffree;
+ buf->f_fsid = st.f_fsid;
+ buf->f_namelen = st.f_namelen;
+ buf->f_frsize = st.f_frsize;
+
+ return 0;
+}
+#endif
#if defined __UCLIBC_LINUX_SPECIFIC__ || defined __UCLIBC_HAS_THREADS_NATIVE__
/* statfs is used by NPTL, so it must exported in case */
diff --git a/libc/sysdeps/linux/common/truncate.c
b/libc/sysdeps/linux/common/truncate.c
index 2331bdd..596acb7 100644
--- a/libc/sysdeps/linux/common/truncate.c
+++ b/libc/sysdeps/linux/common/truncate.c
@@ -11,5 +11,12 @@
#include <unistd.h>
+#ifdef __NR_truncate
_syscall2(int, truncate, const char *, path, __off_t, length)
+#elif defined(__NR_truncate64)
+int truncate(const char *path, __off_t length)
+{
+ return truncate64(path, length);
+}
+#endif
libc_hidden_def(truncate)
--
1.7.9.1
_______________________________________________
uClibc mailing list
[email protected]
http://lists.busybox.net/mailman/listinfo/uclibc