From patchwork Mon Oct 17 13:24:20 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Riku Voipio X-Patchwork-Id: 682949 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [IPv6:2001:4830:134:3::11]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 3syJrD6D1nz9s9c for ; Tue, 18 Oct 2016 00:26:20 +1100 (AEDT) Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (1024-bit key; unprotected) header.d=linaro.org header.i=@linaro.org header.b=hcuY9/zY; dkim-atps=neutral Received: from localhost ([::1]:33058 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bw7vl-0004Hs-C2 for incoming@patchwork.ozlabs.org; Mon, 17 Oct 2016 09:26:17 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:38291) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bw7uM-00034C-IZ for qemu-devel@nongnu.org; Mon, 17 Oct 2016 09:24:51 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1bw7uK-00039g-08 for qemu-devel@nongnu.org; Mon, 17 Oct 2016 09:24:50 -0400 Received: from mail-lf0-x236.google.com ([2a00:1450:4010:c07::236]:34344) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1bw7uJ-00039N-Nc for qemu-devel@nongnu.org; Mon, 17 Oct 2016 09:24:47 -0400 Received: by mail-lf0-x236.google.com with SMTP id b81so285329930lfe.1 for ; Mon, 17 Oct 2016 06:24:47 -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=hcuY9/zYBXsoMRH079kofUDQ5j5VzE6cMKHVqNKsZJn66jdiO51N6/bIlFU1qIRCjw v+Dprl+obZ3iq3B/0WU+mH7Nob5Re+F5G5tUd44ldxE8FzWI0jl4SPufJ7VtZen3Y6na MWPGeYeTxuV7kEbPEEop/agFEwXcgYzdQ5JZ0= 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=UFwclBDM/fwom7y5Rdpxg9AySZzyYGeQ0MSmyKSe/DqM+Z4PwUxtsVcSRbVK+yZwNU 2i+2KSuFwM5zrI8P4benm4XYVCj/18trXxElyfyOoChmKooyQsE9G7AKm70lK4bJZNOq Cdm931elv5dez25e1ME3tt4KHLzszpzOf73sOtrioVxwaXpqIKRK04vfgonM/ujxypQJ ovsw6OktsPs4Lk3MbvI69ttMHtddmMelOENrLPziXZsUrzkFj65oxmaUZmvtutnnsAgH kiYQ5knZrC1a9Xb7ddCEDhFdrjl0C0kv6k1BgwWxrynunnw6JfGIulkgvNsCWX3v69uj NEgw== X-Gm-Message-State: AA6/9Rlmij6jUkCqfbWgHWRj7m9TsPuj+bVnCIOHrQBe9wKI3Bf9ne9K87/NWA7UWB99++Y4 X-Received: by 10.25.24.93 with SMTP id o90mr15185007lfi.74.1476710685191; Mon, 17 Oct 2016 06:24:45 -0700 (PDT) Received: from beaming.home (91-157-170-157.elisa-laajakaista.fi. [91.157.170.157]) by smtp.gmail.com with ESMTPSA id y81sm7782857lff.29.2016.10.17.06.24.44 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Mon, 17 Oct 2016 06:24:44 -0700 (PDT) From: riku.voipio@linaro.org To: qemu-devel@nongnu.org Date: Mon, 17 Oct 2016 16:24:20 +0300 Message-Id: <56840fa18f62a5fcfeee5cf08e71e21b3008b5c5.1476710352.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::236 Subject: [Qemu-devel] [PULL 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+incoming=patchwork.ozlabs.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(-) 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 */