[Xenomai] [PATCH] rtdm: add integer file descriptor to struct rtdm_fd
RTDM drivers refer to open files or sockets by using struct rtdm_fd. Normally, the integer file descriptor returned by socket() or open() calls is not necessary for driver operations. However, in some special cases this value has to be determined. To ease the retrieval of this value for those drivers it is added directly to struct rtdm_fd. Otherwise it would be necessary to iterate over the fd's rb_tree. Signed-off-by: Sebastian Smolorz --- include/cobalt/kernel/rtdm/fd.h | 6 ++ kernel/cobalt/rtdm/fd.c | 1 + 2 files changed, 7 insertions(+) diff --git a/include/cobalt/kernel/rtdm/fd.h b/include/cobalt/kernel/rtdm/fd.h index 58d3c4a..572b17e 100644 --- a/include/cobalt/kernel/rtdm/fd.h +++ b/include/cobalt/kernel/rtdm/fd.h @@ -298,6 +298,7 @@ struct rtdm_fd { struct rtdm_fd_ops *ops; struct cobalt_ppd *owner; unsigned int refs; + int ufd; int minor; int oflags; #ifdef CONFIG_XENO_ARCH_SYS3264 @@ -320,6 +321,11 @@ static inline struct cobalt_ppd *rtdm_fd_owner(const struct rtdm_fd *fd) return fd->owner; } +static inline int rtdm_fd_ufd(const struct rtdm_fd *fd) +{ + return fd->ufd; +} + static inline int rtdm_fd_minor(const struct rtdm_fd *fd) { return fd->minor; diff --git a/kernel/cobalt/rtdm/fd.c b/kernel/cobalt/rtdm/fd.c index 8d577b2..807a11e 100644 --- a/kernel/cobalt/rtdm/fd.c +++ b/kernel/cobalt/rtdm/fd.c @@ -166,6 +166,7 @@ int rtdm_fd_enter(struct rtdm_fd *fd, int ufd, unsigned int magic, fd->magic = magic; fd->ops = ops; fd->owner = ppd; + fd->ufd = ufd; fd->refs = 1; set_compat_bit(fd); -- 2.7.4 ___ Xenomai mailing list Xenomai@xenomai.org https://xenomai.org/mailman/listinfo/xenomai
[Xenomai] Fun with cobalt interposing fcntl
Hello, I ran into an annoying problem with cobalt, namely that it interposes functions with varargs like fcntl, The issue is that it won't ever be able to correctly forward the varags. In the example, fcntl will be interpreted as having an additional int parameter, while some functionality has a pointer instead, This yields to truncation and errors. Unfortunatly I don't see any way of fixing this easily, but I consider this harmful (silently breaking code). IMHO Would be better to remove the wrapping for fcntl and use an explicit cobalt function where necessary. King regards, Norbert - offending code bool lockfile(const char *fname) { int fd = open(fname, O_WRONLY | O_CREAT, S_IRUSR | S_IWUSR | S_IRGRP | S_IROTH); if (fd < 0) { perror("Opening Component Lock"); return false; } struct flock fl = {F_WRLCK, SEEK_SET}; int ret = fcntl(fd, F_SETLK, &fl); if (ret != 0) { perror("Acquiring Component Lock"); return false; } return true; } - wrapping in rtdm.c COBALT_IMPL(int, fcntl, (int fd, int cmd, ...)) { va_list ap; int arg; int ret; va_start(ap, cmd); arg = va_arg(ap, int); va_end(ap); ret = XENOMAI_SYSCALL3(sc_cobalt_fcntl, fd, cmd, arg); if (ret != -EBADF && ret != -ENOSYS) return set_errno(ret); return __STD(fcntl(fd, cmd, arg)); } This message and any attachments are solely for the use of the intended recipients. They may contain privileged and/or confidential information or other information protected from disclosure. If you are not an intended recipient, you are hereby notified that you received this email in error and that any review, dissemination, distribution or copying of this email and any attachment is strictly prohibited. If you have received this email in error, please contact the sender and delete the message and any attachment from your system. ANDRITZ HYDRO GmbH Rechtsform/ Legal form: Gesellschaft mit beschränkter Haftung / Corporation Firmensitz/ Registered seat: Wien Firmenbuchgericht/ Court of registry: Handelsgericht Wien Firmenbuchnummer/ Company registration: FN 61833 g DVR: 0605077 UID-Nr.: ATU14756806 Thank You ___ Xenomai mailing list Xenomai@xenomai.org https://xenomai.org/mailman/listinfo/xenomai
[Xenomai] [PATCH] cobalt: fcntl uses void* instead of int
this is consistent with glibc internals, and fixes truncation when passing 64bit pointers --- lib/cobalt/rtdm.c | 4 ++-- lib/cobalt/wrappers.c | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/lib/cobalt/rtdm.c b/lib/cobalt/rtdm.c index 6b8898e70..a01752cdd 100644 --- a/lib/cobalt/rtdm.c +++ b/lib/cobalt/rtdm.c @@ -139,11 +139,11 @@ static int do_ioctl(int fd, unsigned int request, void *arg) COBALT_IMPL(int, fcntl, (int fd, int cmd, ...)) { va_list ap; - int arg; + void *arg; int ret; va_start(ap, cmd); - arg = va_arg(ap, int); + arg = va_arg(ap, void *); va_end(ap); ret = XENOMAI_SYSCALL3(sc_cobalt_fcntl, fd, cmd, arg); diff --git a/lib/cobalt/wrappers.c b/lib/cobalt/wrappers.c index 20ad63a61..2540e3c50 100644 --- a/lib/cobalt/wrappers.c +++ b/lib/cobalt/wrappers.c @@ -216,10 +216,10 @@ __weak int __real_fcntl(int fd, int cmd, ...) { va_list ap; - int arg; + void *arg; va_start(ap, cmd); - arg = va_arg(ap, int); + arg = va_arg(ap, void *); va_end(ap); return fcntl(fd, cmd, arg); -- 2.19.1 ___ Xenomai mailing list Xenomai@xenomai.org https://xenomai.org/mailman/listinfo/xenomai