[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PULL 04/15] linux-user: fix inotify
From: |
riku . voipio |
Subject: |
[Qemu-devel] [PULL 04/15] linux-user: fix inotify |
Date: |
Wed, 31 May 2017 16:08:16 +0300 |
From: Laurent Vivier <address@hidden>
When a fd is opened using inotify_init(), a read provides
one or more inotify_event structures:
struct inotify_event {
int wd;
uint32_t mask;
uint32_t cookie;
uint32_t len;
char name[];
};
The integer fields must be byte-swapped to the target endianness.
Signed-off-by: Laurent Vivier <address@hidden>
Reviewed-by: Philippe Mathieu-Daudé <address@hidden>
Signed-off-by: Riku Voipio <address@hidden>
---
linux-user/syscall.c | 29 +++++++++++++++++++++++++++++
1 file changed, 29 insertions(+)
diff --git a/linux-user/syscall.c b/linux-user/syscall.c
index 671b13a23b..32aba195c5 100644
--- a/linux-user/syscall.c
+++ b/linux-user/syscall.c
@@ -7693,6 +7693,33 @@ static TargetFdTrans target_eventfd_trans = {
.target_to_host_data = swap_data_eventfd,
};
+#if (defined(TARGET_NR_inotify_init) && defined(__NR_inotify_init)) || \
+ (defined(CONFIG_INOTIFY1) && defined(TARGET_NR_inotify_init1) && \
+ defined(__NR_inotify_init1))
+static abi_long host_to_target_data_inotify(void *buf, size_t len)
+{
+ struct inotify_event *ev;
+ int i;
+ uint32_t name_len;
+
+ for (i = 0; i < len; i += sizeof(struct inotify_event) + name_len) {
+ ev = (struct inotify_event *)((char *)buf + i);
+ name_len = ev->len;
+
+ ev->wd = tswap32(ev->wd);
+ ev->mask = tswap32(ev->mask);
+ ev->cookie = tswap32(ev->cookie);
+ ev->len = tswap32(name_len);
+ }
+
+ return len;
+}
+
+static TargetFdTrans target_inotify_trans = {
+ .host_to_target_data = host_to_target_data_inotify,
+};
+#endif
+
/* do_syscall() should always have a single exit point at the end so
that actions, such as logging of syscall results, can be performed.
All errnos that do_syscall() returns must be -TARGET_<errcode>. */
@@ -11736,6 +11763,7 @@ abi_long do_syscall(void *cpu_env, int num, abi_long
arg1,
#if defined(TARGET_NR_inotify_init) && defined(__NR_inotify_init)
case TARGET_NR_inotify_init:
ret = get_errno(sys_inotify_init());
+ fd_trans_register(ret, &target_inotify_trans);
break;
#endif
#ifdef CONFIG_INOTIFY1
@@ -11743,6 +11771,7 @@ abi_long do_syscall(void *cpu_env, int num, abi_long
arg1,
case TARGET_NR_inotify_init1:
ret = get_errno(sys_inotify_init1(target_to_host_bitmask(arg1,
fcntl_flags_tbl)));
+ fd_trans_register(ret, &target_inotify_trans);
break;
#endif
#endif
--
2.11.0
- [Qemu-devel] [PULL 00/15] Misc linux-user updates, riku . voipio, 2017/05/31
- [Qemu-devel] [PULL 02/15] linux-user: fix eventfd, riku . voipio, 2017/05/31
- [Qemu-devel] [PULL 01/15] linux-user: call fd_trans_target_to_host_data() for write(), riku . voipio, 2017/05/31
- [Qemu-devel] [PULL 03/15] linux-user: fix fadvise64_64() on ppc, riku . voipio, 2017/05/31
- [Qemu-devel] [PULL 04/15] linux-user: fix inotify,
riku . voipio <=
- [Qemu-devel] [PULL 05/15] linux-user: allocate heap memory for execve arguments, riku . voipio, 2017/05/31
- [Qemu-devel] [PULL 08/15] linux-user: add tkill(), tgkill() and rt_sigqueueinfo() strace, riku . voipio, 2017/05/31
- [Qemu-devel] [PULL 09/15] linux-user: fix ssetmask() system call, riku . voipio, 2017/05/31
- [Qemu-devel] [PULL 06/15] linux-user: remove all traces of qemu from /proc/self/cmdline, riku . voipio, 2017/05/31
- [Qemu-devel] [PULL 07/15] linux-user: add strace for getuid(), gettid(), getppid(), geteuid(), riku . voipio, 2017/05/31
- [Qemu-devel] [PULL 10/15] linux-user: fix mismatch of lock/unlock_user() invocations in rt_sigqueinfo() syscall, riku . voipio, 2017/05/31
- [Qemu-devel] [PULL 12/15] linux-user: add support for rt_tgsigqueueinfo() system call, riku . voipio, 2017/05/31
- [Qemu-devel] [PULL 13/15] linux-user: add rt_tgsigqueueinfo() strace, riku . voipio, 2017/05/31
- [Qemu-devel] [PULL 14/15] linux-user: fix inconsistent spaces in print_siginfo() output, riku . voipio, 2017/05/31
- [Qemu-devel] [PULL 11/15] linux-user: fix argument type declaration of rt_sigqueinfo() syscall, riku . voipio, 2017/05/31