From patchwork Mon Sep 5 14:00:47 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Aleksandar Markovic X-Patchwork-Id: 9314079 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 8DE98607D3 for ; Mon, 5 Sep 2016 14:15:42 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 7C7F328ABF for ; Mon, 5 Sep 2016 14:15:42 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 6CCEC28AC5; Mon, 5 Sep 2016 14:15:42 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.9 required=2.0 tests=BAYES_00,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id DAACB28ABF for ; Mon, 5 Sep 2016 14:15:41 +0000 (UTC) Received: from localhost ([::1]:54901 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bgugW-0001x2-KU for patchwork-qemu-devel@patchwork.kernel.org; Mon, 05 Sep 2016 10:15:40 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:33399) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bguTE-0007aM-0O for qemu-devel@nongnu.org; Mon, 05 Sep 2016 10:01:59 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1bguT7-0005Ht-3D for qemu-devel@nongnu.org; Mon, 05 Sep 2016 10:01:55 -0400 Received: from mx2.rt-rk.com ([89.216.37.149]:37135 helo=mail.rt-rk.com) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bguT6-0005By-SN for qemu-devel@nongnu.org; Mon, 05 Sep 2016 10:01:49 -0400 Received: from localhost (localhost [127.0.0.1]) by mail.rt-rk.com (Postfix) with ESMTP id 52D301A451C; Mon, 5 Sep 2016 16:01:26 +0200 (CEST) X-Virus-Scanned: amavisd-new at rt-rk.com Received: from mcs19.ba.imgtec.org (unknown [82.117.201.26]) by mail.rt-rk.com (Postfix) with ESMTPSA id 310411A1D91; Mon, 5 Sep 2016 16:01:26 +0200 (CEST) From: Aleksandar Markovic To: qemu-devel@nongnu.org, riku.voipio@iki.fi, peter.maydell@linaro.org, petar.jovanovic@imgtec.com, miodrag.dinic@imgtec.com, aleksandar.markovic@imgtec.com Date: Mon, 5 Sep 2016 16:00:47 +0200 Message-Id: <1473084049-35412-4-git-send-email-aleksandar.markovic@rt-rk.com> X-Mailer: git-send-email 1.7.9.5 In-Reply-To: <1473084049-35412-1-git-send-email-aleksandar.markovic@rt-rk.com> References: <1473084049-35412-1-git-send-email-aleksandar.markovic@rt-rk.com> X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 89.216.37.149 Subject: [Qemu-devel] [PATCH v2 3/3] 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: , Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" X-Virus-Scanned: ClamAV using ClamSMTP From: Aleksandar Markovic This patch implements Qemu user mode ustat() syscall support. Syscall ustat() returns information about a mounted filesystem. The implementation is similar to the 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. 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 --- linux-user/syscall.c | 25 ++++++++++++++++++++++++- 1 file changed, 24 insertions(+), 1 deletion(-) diff --git a/linux-user/syscall.c b/linux-user/syscall.c index 38d69f1..b118bd9 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 @@ -8098,7 +8099,29 @@ abi_long do_syscall(void *cpu_env, int num, abi_long arg1, break; #ifdef TARGET_NR_ustat case TARGET_NR_ustat: - goto unimplemented; + { + struct ustat ust; + int cnt; + ret = get_errno(ustat(arg1, &ust)); + + if (!is_error(ret)) { + struct 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); + + for (cnt = 0; cnt < 6; cnt++) { + __put_user(ust.f_fname[cnt], &target_ust->f_fname[cnt]); + __put_user(ust.f_fpack[cnt], &target_ust->f_fpack[cnt]); + } + unlock_user_struct(target_ust, arg2, 1); + } + break; + } #endif #ifdef TARGET_NR_dup2 case TARGET_NR_dup2: