Module: xenomai-3 Branch: next Commit: 0e3014ee177d9ab7cc37951870f79badc9a8bda3 URL: http://git.xenomai.org/?p=xenomai-3.git;a=commit;h=0e3014ee177d9ab7cc37951870f79badc9a8bda3
Author: Philippe Gerum <r...@xenomai.org> Date: Fri Jul 24 09:51:22 2015 +0200 lib/cobalt: enable application built with large file support i.e. provide support for applications turning on -D_FILE_OFFSET_BITS=64. --- include/cobalt/fcntl.h | 2 ++ include/cobalt/kernel/compat.h | 2 +- include/cobalt/mqueue.h | 2 -- include/cobalt/sys/mman.h | 4 ++++ include/rtdm/rtdm.h | 5 +++-- include/rtdm/uapi/rtdm.h | 2 +- lib/cobalt/cobalt.wrappers | 2 ++ lib/cobalt/rtdm.c | 45 +++++++++++++++++++++++++++++++++------- lib/cobalt/wrappers.c | 31 +++++++++++++++++++++++---- 9 files changed, 78 insertions(+), 17 deletions(-) diff --git a/include/cobalt/fcntl.h b/include/cobalt/fcntl.h index 2a83a7a..d549893 100644 --- a/include/cobalt/fcntl.h +++ b/include/cobalt/fcntl.h @@ -29,6 +29,8 @@ extern "C" { COBALT_DECL(int, open(const char *path, int oflag, ...)); +COBALT_DECL(int, open64(const char *path, int oflag, ...)); + COBALT_DECL(int, fcntl(int fd, int cmd, ...)); #ifdef __cplusplus diff --git a/include/cobalt/kernel/compat.h b/include/cobalt/kernel/compat.h index 6304a85..7420804 100644 --- a/include/cobalt/kernel/compat.h +++ b/include/cobalt/kernel/compat.h @@ -78,8 +78,8 @@ typedef struct { } compat_fd_set; struct compat_rtdm_mmap_request { + u64 offset; compat_size_t length; - compat_off_t offset; int prot; int flags; }; diff --git a/include/cobalt/mqueue.h b/include/cobalt/mqueue.h index b335623..496632d 100644 --- a/include/cobalt/mqueue.h +++ b/include/cobalt/mqueue.h @@ -27,8 +27,6 @@ extern "C" { #endif -COBALT_DECL(int, open(const char *path, int oflag, ...)); - COBALT_DECL(mqd_t, mq_open(const char *name, int oflags, ...)); diff --git a/include/cobalt/sys/mman.h b/include/cobalt/sys/mman.h index f1cd704..1c47777 100644 --- a/include/cobalt/sys/mman.h +++ b/include/cobalt/sys/mman.h @@ -21,6 +21,7 @@ #ifndef _COBALT_SYS_MMAN_H #define _COBALT_SYS_MMAN_H +#include <sys/types.h> #include <cobalt/wrappers.h> #ifdef __cplusplus @@ -30,6 +31,9 @@ extern "C" { COBALT_DECL(void *, mmap(void *addr, size_t length, int prot, int flags, int fd, off_t offset)); +COBALT_DECL(void *, mmap64(void *addr, size_t length, int prot, int flags, + int fd, off64_t offset)); + #ifdef __cplusplus } #endif diff --git a/include/rtdm/rtdm.h b/include/rtdm/rtdm.h index dab4bf9..01f07fe 100644 --- a/include/rtdm/rtdm.h +++ b/include/rtdm/rtdm.h @@ -20,13 +20,14 @@ #ifndef _RTDM_RTDM_H #define _RTDM_RTDM_H +#include <linux/types.h> +#include <sys/ioctl.h> +#include <sys/socket.h> #include <fcntl.h> #include <stddef.h> #include <stdint.h> #include <errno.h> #include <unistd.h> -#include <sys/ioctl.h> -#include <sys/socket.h> #include <boilerplate/wrappers.h> /** diff --git a/include/rtdm/uapi/rtdm.h b/include/rtdm/uapi/rtdm.h index 2faa14f..eed3b36 100644 --- a/include/rtdm/uapi/rtdm.h +++ b/include/rtdm/uapi/rtdm.h @@ -197,8 +197,8 @@ struct _rtdm_setsockaddr_args { /* Internally used for mmap() */ struct _rtdm_mmap_request { + __u64 offset; size_t length; - off_t offset; int prot; int flags; }; diff --git a/lib/cobalt/cobalt.wrappers b/lib/cobalt/cobalt.wrappers index e66b9c1..4968340 100644 --- a/lib/cobalt/cobalt.wrappers +++ b/lib/cobalt/cobalt.wrappers @@ -47,6 +47,7 @@ --wrap mq_timedreceive --wrap mq_notify --wrap open +--wrap open64 --wrap socket --wrap close --wrap ioctl @@ -105,5 +106,6 @@ --wrap kill --wrap sleep --wrap mmap +--wrap mmap64 --wrap time --wrap fcntl diff --git a/lib/cobalt/rtdm.c b/lib/cobalt/rtdm.c index 4e1e24e..aced887 100644 --- a/lib/cobalt/rtdm.c +++ b/lib/cobalt/rtdm.c @@ -39,10 +39,9 @@ static inline int set_errno(int ret) return -1; } -COBALT_IMPL(int, open, (const char *path, int oflag, ...)) +static int do_open(const char *path, int oflag, mode_t mode) { int fd, oldtype; - va_list ap; /* * Don't dereference path, as it might be invalid. Leave it to @@ -55,12 +54,38 @@ COBALT_IMPL(int, open, (const char *path, int oflag, ...)) if (fd != -ENODEV && fd != -ENOSYS) return set_errno(fd); + fd = __STD(open(path, oflag, mode)); + } + + return fd; +} + +COBALT_IMPL(int, open, (const char *path, int oflag, ...)) +{ + mode_t mode = 0; + va_list ap; + + if (oflag & O_CREAT) { va_start(ap, oflag); - fd = __STD(open(path, oflag, va_arg(ap, mode_t))); + mode = va_arg(ap, int); va_end(ap); } - return fd; + return do_open(path, oflag, mode); +} + +COBALT_IMPL(int, open64, (const char *path, int oflag, ...)) +{ + mode_t mode = 0; + va_list ap; + + if (oflag & O_CREAT) { + va_start(ap, oflag); + mode = va_arg(ap, int); + va_end(ap); + } + + return do_open(path, oflag | O_LARGEFILE, mode); } COBALT_IMPL(int, socket, (int protocol_family, int socket_type, int protocol)) @@ -392,8 +417,8 @@ COBALT_IMPL(int, shutdown, (int fd, int how)) return __STD(shutdown(fd, how)); } -COBALT_IMPL(void *, mmap, (void *addr, size_t length, int prot, int flags, - int fd, off_t offset)) +COBALT_IMPL(void *, mmap64, (void *addr, size_t length, int prot, int flags, + int fd, off64_t offset)) { struct _rtdm_mmap_request rma; int ret; @@ -417,5 +442,11 @@ COBALT_IMPL(void *, mmap, (void *addr, size_t length, int prot, int flags, } regular: - return __STD(mmap(addr, length, prot, flags, fd, offset)); + return __STD(mmap64(addr, length, prot, flags, fd, offset)); +} + +COBALT_IMPL(void *, mmap, (void *addr, size_t length, int prot, int flags, + int fd, off_t offset)) +{ + return __COBALT(mmap64(addr, length, prot, flags, fd, offset)); } diff --git a/lib/cobalt/wrappers.c b/lib/cobalt/wrappers.c index 4776e36..4656e6e 100644 --- a/lib/cobalt/wrappers.c +++ b/lib/cobalt/wrappers.c @@ -152,16 +152,32 @@ int __real_sem_getvalue(sem_t * sem, int *sval) __weak int __real_open(const char *path, int oflag, ...) { + mode_t mode = 0; va_list ap; - mode_t mode; if (oflag & O_CREAT) { va_start(ap, oflag); mode = va_arg(ap, mode_t); va_end(ap); - return open(path, oflag, mode); - } else - return open(path, oflag); + } + + return open(path, oflag, mode); +} + +/* rtdm */ +__weak +int __real_open64(const char *path, int oflag, ...) +{ + mode_t mode = 0; + va_list ap; + + if (oflag & O_CREAT) { + va_start(ap, oflag); + mode = va_arg(ap, mode_t); + va_end(ap); + } + + return open64(path, oflag, mode); } __weak @@ -325,6 +341,13 @@ void *__real_mmap(void *addr, size_t length, int prot, int flags, } __weak +void *__real_mmap64(void *addr, size_t length, int prot, int flags, + int fd, off64_t offset) +{ + return mmap64(addr, length, prot, flags, fd, offset); +} + +__weak int __real_vfprintf(FILE *stream, const char *fmt, va_list args) { return vfprintf(stream, fmt, args); _______________________________________________ Xenomai-git mailing list Xenomai-git@xenomai.org http://xenomai.org/mailman/listinfo/xenomai-git