From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:41895) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1d33PP-0004bF-70 for qemu-devel@nongnu.org; Tue, 25 Apr 2017 12:33:48 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1d33PM-0000YJ-0Z for qemu-devel@nongnu.org; Tue, 25 Apr 2017 12:33:47 -0400 Received: from mout.kundenserver.de ([212.227.126.135]:51630) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1d33PL-0000Y0-KZ for qemu-devel@nongnu.org; Tue, 25 Apr 2017 12:33:43 -0400 References: <20170302005448.21336-1-laurent@vivier.eu> From: Laurent Vivier Message-ID: Date: Tue, 25 Apr 2017 18:33:41 +0200 MIME-Version: 1.0 In-Reply-To: <20170302005448.21336-1-laurent@vivier.eu> Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 8bit Subject: Re: [Qemu-devel] [PATCH] linux-user: fix inotify List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Riku Voipio Cc: qemu-devel@nongnu.org Ping? Laurent Le 02/03/2017 à 01:54, Laurent Vivier a écrit : > 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 > --- > linux-user/syscall.c | 29 +++++++++++++++++++++++++++++ > 1 file changed, 29 insertions(+) > > diff --git a/linux-user/syscall.c b/linux-user/syscall.c > index cec8428..c2c4f3a 100644 > --- a/linux-user/syscall.c > +++ b/linux-user/syscall.c > @@ -7671,6 +7671,33 @@ static target_timer_t get_timer_id(abi_long arg) > return timerid; > } > > +#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_. */ > @@ -11694,6 +11721,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 > @@ -11701,6 +11729,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 >