From patchwork Wed May 31 13:08:16 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Riku Voipio X-Patchwork-Id: 100750 Delivered-To: patch@linaro.org Received: by 10.182.202.35 with SMTP id kf3csp294117obc; Wed, 31 May 2017 06:11:32 -0700 (PDT) X-Received: by 10.200.48.221 with SMTP id w29mr29116102qta.54.1496236292386; Wed, 31 May 2017 06:11:32 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1496236292; cv=none; d=google.com; s=arc-20160816; b=OJDrsxTAdmyUWtah2Cc1F9tHPSiLRmXbnv01+o2Ok6dX3sOaYPQPO9W2c5Z5fPt6i9 6avPLghB1uT6x8R5XgWp7keiuYUAG2eSrM2m20LqGEhIwykOZ9WKqHTYX11EWa75gdYI exmZQGHbMgCqg1zMEGFugYUzlnzC8IR0dhN6uujqUEkaQuXSngc9pVizvaT43WNpapEi +pKD26EKr52gurdrcFEi9srS1tlV9l3P+BFbMtYPbGV94TvLTN/oEkTGhsjk0ygBXfn6 b2Ifq1Yokq6uWXptHqpmkNPpMDGvgN6YFi9iZrKxq6ZJ31lwpFc9a1heTUDhfIAcTyeO UVLA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:cc:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:subject :content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:to:from:dkim-signature:arc-authentication-results; bh=+8xB72Fd/V/0yQQJdOSrVyVx4BisqTQiYzTSNb9mXGo=; b=NuFjszLz7VytNCAV2hRZPyor3FHkTsAYw4cniSuSyKJwci74SMHQqCC5TAcPvESytJ nutiki8u1/BFGeBKGoIWRq6QmJ6kpdMkgFJs7yuQKHH0+59cbAjmwOaMMqLoQ1uG8rtv +p0r0IkWLn9spUr9LyaivE1JsBHP+t7V9Vx5zp5LXX386D6dLlveiZOdAosOSZc8VJ4B dRVA7gu7Vxhm2q8IiGG6RwkPKi5f+JRtdve9J/UENisi7eGSKBduoUseDmCV08oX5JSm 5cWqHVzNa5ZiCPlpGHgSkN7KtWQxf39ruvhwd7sEmBHDti0g4uksxVk63rC7sgKNbLpM rFzg== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 as permitted sender) smtp.mailfrom=qemu-devel-bounces+patch=linaro.org@nongnu.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [2001:4830:134:3::11]) by mx.google.com with ESMTPS id t1si16221658qtc.9.2017.05.31.06.11.32 for (version=TLS1 cipher=AES128-SHA bits=128/128); Wed, 31 May 2017 06:11:32 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 as permitted sender) client-ip=2001:4830:134:3::11; Authentication-Results: mx.google.com; dkim=fail header.i=@linaro.org; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 as permitted sender) smtp.mailfrom=qemu-devel-bounces+patch=linaro.org@nongnu.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([::1]:59334 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dG3PN-0001Be-VG for patch@linaro.org; Wed, 31 May 2017 09:11:30 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:36717) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dG3Md-0007St-8P for qemu-devel@nongnu.org; Wed, 31 May 2017 09:08:40 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1dG3Mc-0003cr-2o for qemu-devel@nongnu.org; Wed, 31 May 2017 09:08:39 -0400 Received: from mail-lf0-x231.google.com ([2a00:1450:4010:c07::231]:34426) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1dG3Mb-0003cY-RE for qemu-devel@nongnu.org; Wed, 31 May 2017 09:08:37 -0400 Received: by mail-lf0-x231.google.com with SMTP id 99so8618602lfu.1 for ; Wed, 31 May 2017 06:08:37 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=+8xB72Fd/V/0yQQJdOSrVyVx4BisqTQiYzTSNb9mXGo=; b=jGKSc4BC7iovgH8UCeOutoEBB17eSwygJ+j8Kd5kua3qveU0cinXhY1tZnJ8oxKcAc gUhf4Zu9xjF8VxmVRb7qs66yrBNqD8Odbn/2vPY41YF8HBl/6zFU1gMNN9B5NsWU7/lf PLcp1YiEJTqbcwGM0D8C0uQLlMRWVZXs8bRvI= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=+8xB72Fd/V/0yQQJdOSrVyVx4BisqTQiYzTSNb9mXGo=; b=GIhXgG36a9b+AFu5fVjDivPA4it+Ob9ZxG2d5aOUJ25YRYPLWXlwBbCwbfGOtRf7UQ ncbbegTo0JF5wsCV15RPym5p/27BLQvbMepkgKyW3xprhmM/2TQwDq9AQbHPB/ikkJZc 66rAqXIQTecGHyiYvLJn/azpaa4o83IpkG1KMw/x3hRruXUoZsZmmARnrhthBcu+V34Y F1jBB6PXIael9DxWZRk9lYl9ZRdr7XdXsEBQOk6oprkxS9PeDVWeE6rFF0ejDdafAznY TfMqwYxQLFE0BwMLC9cwkPNX1QjvuGrc9vFEnStshRHiJeAi0ay09mIymwJViA5THiPH PsKQ== X-Gm-Message-State: AODbwcDuxSJjWxcT4/WOdxq2iOXuc012X88irvYpzArzS+nvhD6Ttnao hiN2S4VLFsMwfQsDnma4uA== X-Received: by 10.25.229.209 with SMTP id i78mr7505134lfk.146.1496236116419; Wed, 31 May 2017 06:08:36 -0700 (PDT) Received: from localhost.localdomain (91-157-170-157.elisa-laajakaista.fi. [91.157.170.157]) by smtp.gmail.com with ESMTPSA id o101sm3741766lfg.3.2017.05.31.06.08.35 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 31 May 2017 06:08:35 -0700 (PDT) From: riku.voipio@linaro.org To: qemu-devel@nongnu.org Date: Wed, 31 May 2017 16:08:16 +0300 Message-Id: X-Mailer: git-send-email 2.11.0 In-Reply-To: References: MIME-Version: 1.0 X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2a00:1450:4010:c07::231 Subject: [Qemu-devel] [PULL 04/15] linux-user: fix inotify X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: peter.maydell@linaro.org, Laurent Vivier , stefanha@redhat.com Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" From: Laurent Vivier 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 Reviewed-by: Philippe Mathieu-Daudé Signed-off-by: Riku Voipio --- linux-user/syscall.c | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) -- 2.11.0 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_. */ @@ -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