From patchwork Tue Oct 18 13:21:30 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Riku Voipio X-Patchwork-Id: 78043 Delivered-To: patch@linaro.org Received: by 10.140.97.247 with SMTP id m110csp887873qge; Tue, 18 Oct 2016 06:33:32 -0700 (PDT) X-Received: by 10.200.48.104 with SMTP id g37mr591755qte.6.1476797612461; Tue, 18 Oct 2016 06:33:32 -0700 (PDT) Return-Path: Received: from lists.gnu.org (lists.gnu.org. [2001:4830:134:3::11]) by mx.google.com with ESMTPS id b41si17787681qtb.136.2016.10.18.06.33.32 for (version=TLS1 cipher=AES128-SHA bits=128/128); Tue, 18 Oct 2016 06:33: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 dis=NONE) header.from=linaro.org Received: from localhost ([::1]:41548 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bwUWJ-0006uS-SG for patch@linaro.org; Tue, 18 Oct 2016 09:33:31 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:53766) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bwULE-0006Fj-R9 for qemu-devel@nongnu.org; Tue, 18 Oct 2016 09:22:05 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1bwUL8-0000ck-UQ for qemu-devel@nongnu.org; Tue, 18 Oct 2016 09:22:04 -0400 Received: from mail-lf0-x231.google.com ([2a00:1450:4010:c07::231]:35754) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1bwUL8-0000c9-Kq for qemu-devel@nongnu.org; Tue, 18 Oct 2016 09:21:58 -0400 Received: by mail-lf0-x231.google.com with SMTP id l131so25232377lfl.2 for ; Tue, 18 Oct 2016 06:21:58 -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; bh=OxBrL6zB/EHuYIHHEMvVnL1Z8K2tXI+7mjMs6mTAykk=; b=VuWwq//RZ1cN2kgkm5yH4tMXqi6dIYjS3O85DChochHVELOa3/LUdU/APQ9AN+kJe0 aCjzDMJyefYwex1c0hRrI6ryCJ7Kz7FiU0ZLI/pctB4GslACjMeZI83wzf6G1YsPHdYM a2Ov4EHvpoRj/23aWP9pDlGYnKX3OdLebPCd0= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=OxBrL6zB/EHuYIHHEMvVnL1Z8K2tXI+7mjMs6mTAykk=; b=J6pReFDmEFAuaA8GxBNfTmIMwt1mUu5yUUWr64bj/bAzog9bA1q2bVioCdcCfnHQ78 Owxk2LxpHhfBwABT2Fyy20mQVHfGl5IjfDHorXYGBwdvhxis+MDGf7ADpyGz6OglQFxp bsMrxK7+F5RHa24Z3qeYKw6QxIk6XvJYEm4KMFCxpRHvmPNoMGZr07r0FJdlN0mo8/sO YVMM2R160/hipz5af3+3/GrfqqyR3vYJQUNbOwIS4W0FahRivdZwRHZUggAFPMc6soLl 9bp0UflSLF42mZAxQIpTjPgEJfMSsnLy/VVeaq9VZFCBIeEXpXlugdzHk+sshbA2K4n1 c8eQ== X-Gm-Message-State: AA6/9Rm5SP6WO1iqOpyR/hvXiOuwZKfbaiYg6S9AItdMaD69jKJrRwsnhXKUlCX0FGoWAvA3 X-Received: by 10.25.99.4 with SMTP id x4mr557671lfb.128.1476796914763; Tue, 18 Oct 2016 06:21:54 -0700 (PDT) Received: from beaming.home (91-157-170-157.elisa-laajakaista.fi. [91.157.170.157]) by smtp.gmail.com with ESMTPSA id 201sm9535359ljf.48.2016.10.18.06.21.53 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Tue, 18 Oct 2016 06:21:53 -0700 (PDT) From: riku.voipio@linaro.org To: qemu-devel@nongnu.org Date: Tue, 18 Oct 2016 16:21:30 +0300 Message-Id: <56840fa18f62a5fcfeee5cf08e71e21b3008b5c5.1476796525.git.riku.voipio@linaro.org> X-Mailer: git-send-email 2.1.4 In-Reply-To: References: X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 2a00:1450:4010:c07::231 Subject: [Qemu-devel] [PULL v2 02/22] linux-user: Add support for ustat() syscall 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 , Aleksandar Markovic Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" From: Aleksandar Markovic This patch implements Qemu user mode ustat() syscall support. Syscall ustat() returns information about a mounted filesystem. Its declaration is: int ustat(dev_t dev, struct ustat *ubuf); Its Linux kernel implementation is at fs/compat.c, line 334. The Qemu implementation proposed in this patch is similar to the Qemu implementations of statfs(), fstatfs() and other related syscalls. It is based on invocation of host's ustat(), and its key part is in the correspondent case segment of the main switch statement of the function do_syscall(), in file linux-user/syscalls.c. All necessary conversions of data structures from target to host and from host to target are covered. Support for target_ustat is included. Sufficient support for "-strace" option for this syscall is already present, and this patch does not change it. This patch also fixes failures of LTP tests ustat01, and ustat02, if executed on Qemu-emulated systems. Signed-off-by: Aleksandar Markovic Signed-off-by: Riku Voipio --- linux-user/syscall.c | 23 +++++++++++++++++++++-- linux-user/syscall_defs.h | 6 ++++++ 2 files changed, 27 insertions(+), 2 deletions(-) -- 2.1.4 diff --git a/linux-user/syscall.c b/linux-user/syscall.c index 0379b8a..88007e0 100644 --- a/linux-user/syscall.c +++ b/linux-user/syscall.c @@ -48,6 +48,7 @@ int __clone2(int (*fn)(void *), void *child_stack_base, #include #include #include +#include #include #include #include @@ -8227,9 +8228,27 @@ abi_long do_syscall(void *cpu_env, int num, abi_long arg1, ret = get_errno(chroot(p)); unlock_user(p, arg1, 0); break; -#ifdef TARGET_NR_ustat +#if defined(TARGET_NR_ustat) case TARGET_NR_ustat: - goto unimplemented; + { + struct ustat ust; + + ret = get_errno(ustat(arg1, &ust)); + if (!is_error(ret)) { + struct target_ustat *target_ust; + + if (!lock_user_struct(VERIFY_WRITE, target_ust, arg2, 0)) { + goto efault; + } + __put_user(ust.f_tfree, &target_ust->f_tfree); + __put_user(ust.f_tinode, &target_ust->f_tinode); + memcpy(target_ust->f_fname, ust.f_fname, 6); + memcpy(target_ust->f_fpack, ust.f_fpack, 6); + unlock_user_struct(target_ust, arg2, 1); + } + } + break; + #endif #ifdef TARGET_NR_dup2 case TARGET_NR_dup2: diff --git a/linux-user/syscall_defs.h b/linux-user/syscall_defs.h index ca8fa6e..7872b9d 100644 --- a/linux-user/syscall_defs.h +++ b/linux-user/syscall_defs.h @@ -2168,6 +2168,12 @@ struct target_statfs64 { }; #endif +struct target_ustat { + abi_ulong f_tfree; + abi_int f_tinode; + char f_fname[6]; + char f_fpack[6]; +}; #define TARGET_F_DUPFD 0 /* dup */ #define TARGET_F_GETFD 1 /* get close_on_exec */