From patchwork Sun Jun 10 03:01:43 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 138143 Delivered-To: patch@linaro.org Received: by 2002:a2e:970d:0:0:0:0:0 with SMTP id r13-v6csp2600670lji; Sat, 9 Jun 2018 20:51:58 -0700 (PDT) X-Google-Smtp-Source: ADUXVKK65YHOBp2lTWZoGpsawzaubPc7+UR8cWcRP/QFrx+HVsXokhpegHNIcgcwxaIfkcs9lQts X-Received: by 2002:a37:7ac2:: with SMTP id v185-v6mr10274286qkc.321.1528602718712; Sat, 09 Jun 2018 20:51:58 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1528602718; cv=none; d=google.com; s=arc-20160816; b=iXicBWIrrhLqALzalUSW6JkUioaQzgwSQ8BennMr5nCfylcE/XGGENU7cbQlWNNax3 2JcZZ5ckB0iFURueLBsYCshLgte5hsJMwE8dngLPHBlc/89A3av8MwlV0TPKdWoHMRiA 2HpRErXHD+hV3i3NPPF+WexVPHJyYok7nF46pwQVGicmAPeIWe/Va5yNeJrranjNwut0 sauDLqPOdCVpJ18augqqjpT4clXgpoY/Z8zazJ0pT+0ojklZuRwnprO/LfcJRgru9h6Z xp+LiyaijmoeCycDuwfxjscnfc63C5hZ4z3i0i7UcOdgAJKnt7+o34qWU6wTr8ZeKBOW 9SiA== 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:references:in-reply-to :message-id:date:to:from:dkim-signature:arc-authentication-results; bh=x3MiIU0NgMU/ZotHQUHhC0rgCoaYX9fX35dm5DONe24=; b=CZYaKTKdzqslws6iV9+dPsedei0zNdkR7M5Qm9DREjk7k2fDWolDff4Ew5d3+It6Y7 EPyZgX5a49FTxlh01TG8O+TljUs6EjtG67xn89HHd4rYa5DcHSYZ8Xajs07sqoEyB2JF +AkgVk1LGdHF+23D/MzuHqyMpa4BL5Y7JB1jlStdQ/88rwMfapJiBU01jIne6D298dfB ToKCp5VT3Li+3bXyzLkHn2aOCYPJd2xr3UNqlskmuOisU0uUdaWTjFqxHMsg/LH6zPcD 5+EgYvlb0nN4xq9Yicceq7WqP8FXsPxQPfm9qa9Y7lLxOiZXBguzXVxG1BWkdU70H6hY u1Hg== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=IsNI5BI7; 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 y9-v6si266544qtf.398.2018.06.09.20.51.58 for (version=TLS1 cipher=AES128-SHA bits=128/128); Sat, 09 Jun 2018 20:51:58 -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 header.s=google header.b=IsNI5BI7; 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]:42443 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fRrOY-0004jS-3X for patch@linaro.org; Sat, 09 Jun 2018 23:51:58 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:41115) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fRqf5-0003ic-84 for qemu-devel@nongnu.org; Sat, 09 Jun 2018 23:05:01 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fRqf3-0004Bp-S8 for qemu-devel@nongnu.org; Sat, 09 Jun 2018 23:04:59 -0400 Received: from mail-pf0-x243.google.com ([2607:f8b0:400e:c00::243]:38122) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1fRqf3-0004As-Kc for qemu-devel@nongnu.org; Sat, 09 Jun 2018 23:04:57 -0400 Received: by mail-pf0-x243.google.com with SMTP id b74-v6so8494347pfl.5 for ; Sat, 09 Jun 2018 20:04:57 -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=x3MiIU0NgMU/ZotHQUHhC0rgCoaYX9fX35dm5DONe24=; b=IsNI5BI7u0N3XywffqDh4vbvjDqkDxAZ1FFSP1hsOlRUNX4wPNz1u15ICGSU1/NuyX KRVRDhIAR0gLnqz7yYPQ0be+tsgvH1SlwTMojQDqIckxbB81/eb15Y6i2gEBhKkY5B81 lGVp1nTk3zRgKU8GyoC3FhZqApHFVOdi8r3Yg= 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; bh=x3MiIU0NgMU/ZotHQUHhC0rgCoaYX9fX35dm5DONe24=; b=BmXLoY3jdMyteolVzSoQd6gQcgGmPvQF4c8kbOlVByRlU4OGhE9bWyr+M2sh8f3u+r AtmFGByY08SzVP29JZYYWjMaFH+LwXSrzYCQcY6fwBXokq14GncD8mJF+n1RlGCXdgag k67uzB3z+h09YyNWipDjkfuBsP/ue/aVSs5xQYIQjS06YFJfMeA32h9nxFPOH0GmB6Wa +ySuY+4Q63Bk3qj+7Zo4c0tmEHeuce1qgKo1ih1PGA6agp3f7FOyLdFxPqPraJWG5j8D aR6njIJ0M055bGTflNVUFiI0W4dGpFqRbnCRuCdjvgkdG2B5TGLIP6bCljBy9acWmC2o fZTg== X-Gm-Message-State: APt69E3q06V3sG95j0OVSiUY1K+Htmjip2uaEiMI7jBctHW7uMcginul cj5xaY49hYTebZuvnFHvOuGBEp2nKvk= X-Received: by 2002:a63:8c4f:: with SMTP id q15-v6mr10645832pgn.236.1528599896465; Sat, 09 Jun 2018 20:04:56 -0700 (PDT) Received: from cloudburst.twiddle.net (rrcs-173-198-77-219.west.biz.rr.com. [173.198.77.219]) by smtp.gmail.com with ESMTPSA id y17-v6sm31712718pfe.33.2018.06.09.20.04.54 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Sat, 09 Jun 2018 20:04:55 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Date: Sat, 9 Jun 2018 17:01:43 -1000 Message-Id: <20180610030220.3777-72-richard.henderson@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20180610030220.3777-1-richard.henderson@linaro.org> References: <20180610030220.3777-1-richard.henderson@linaro.org> X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2607:f8b0:400e:c00::243 Subject: [Qemu-devel] [PATCH v2 071/108] linux-user: Split out fstat64, fstatat64, newfstatat, lstat64, stat64 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: laurent@vivier.eu Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" Comment on the odd overlap of fstatat64 and newfstatat, especially with respect to nios2. Signed-off-by: Richard Henderson --- linux-user/syscall.c | 135 ++++++++++++++++++++++++++++--------------- 1 file changed, 89 insertions(+), 46 deletions(-) -- 2.17.1 diff --git a/linux-user/syscall.c b/linux-user/syscall.c index c2dc7131bb..8d6b949b8a 100644 --- a/linux-user/syscall.c +++ b/linux-user/syscall.c @@ -8140,6 +8140,42 @@ IMPL(fstat) return ret; } +#ifdef TARGET_NR_fstat64 +IMPL(fstat64) +{ + struct stat st; + abi_long ret; + + ret = get_errno(fstat(arg1, &st)); + if (!is_error(ret) && host_to_target_stat64(cpu_env, arg2, &st)) { + return -TARGET_EFAULT; + } + return ret; +} +#endif + +/* Some targets name this syscall newfstatat, with the same arguments. */ +/* ??? Our nios2/syscall_nr.h defines both names; the kernel does not. + * Preserve previous behavior and map both syscalls to this function. + */ +IMPL(fstatat64) +{ + char *p; + abi_long ret; + struct stat st; + + p = lock_user_string(arg2); + if (!p) { + return -TARGET_EFAULT; + } + ret = get_errno(fstatat(arg1, path(p), &st, arg4)); + unlock_user(p, arg2, 0); + if (!is_error(ret) && host_to_target_stat64(cpu_env, arg3, &st)) { + return -TARGET_EFAULT; + } + return ret; +} + IMPL(fstatfs) { struct statfs stfs; @@ -8815,6 +8851,25 @@ IMPL(lstat) } #endif +#ifdef TARGET_NR_lstat64 +IMPL(lstat64) +{ + char *p = lock_user_string(arg1); + struct stat st; + abi_long ret; + + if (!p) { + return -TARGET_EFAULT; + } + ret = get_errno(lstat(path(p), &st)); + unlock_user(p, arg1, 0); + if (!is_error(ret) && host_to_target_stat64(cpu_env, arg2, &st)) { + return -TARGET_EFAULT; + } + return ret; +} +#endif + #ifdef TARGET_NR_mkdir IMPL(mkdir) { @@ -10790,6 +10845,25 @@ IMPL(stat) } #endif +#ifdef TARGET_NR_stat64 +IMPL(stat64) +{ + char *p = lock_user_string(arg1); + struct stat st; + abi_long ret; + + if (!p) { + return -TARGET_EFAULT; + } + ret = get_errno(stat(path(p), &st)); + unlock_user(p, arg1, 0); + if (!is_error(ret) && host_to_target_stat64(cpu_env, arg2, &st)) { + return -TARGET_EFAULT; + } + return ret; +} +#endif + IMPL(statfs) { char *p = lock_user_string(arg1); @@ -11333,55 +11407,9 @@ static abi_long do_syscall1(void *cpu_env, unsigned num, abi_long arg1, { CPUState *cpu __attribute__((unused)) = ENV_GET_CPU(cpu_env); abi_long ret; - struct stat st; void *p; switch(num) { -#ifdef TARGET_NR_stat64 - case TARGET_NR_stat64: - if (!(p = lock_user_string(arg1))) { - return -TARGET_EFAULT; - } - ret = get_errno(stat(path(p), &st)); - unlock_user(p, arg1, 0); - if (!is_error(ret)) - ret = host_to_target_stat64(cpu_env, arg2, &st); - return ret; -#endif -#ifdef TARGET_NR_lstat64 - case TARGET_NR_lstat64: - if (!(p = lock_user_string(arg1))) { - return -TARGET_EFAULT; - } - ret = get_errno(lstat(path(p), &st)); - unlock_user(p, arg1, 0); - if (!is_error(ret)) - ret = host_to_target_stat64(cpu_env, arg2, &st); - return ret; -#endif -#ifdef TARGET_NR_fstat64 - case TARGET_NR_fstat64: - ret = get_errno(fstat(arg1, &st)); - if (!is_error(ret)) - ret = host_to_target_stat64(cpu_env, arg2, &st); - return ret; -#endif -#if (defined(TARGET_NR_fstatat64) || defined(TARGET_NR_newfstatat)) -#ifdef TARGET_NR_fstatat64 - case TARGET_NR_fstatat64: -#endif -#ifdef TARGET_NR_newfstatat - case TARGET_NR_newfstatat: -#endif - if (!(p = lock_user_string(arg2))) { - return -TARGET_EFAULT; - } - ret = get_errno(fstatat(arg1, path(p), &st, arg4)); - unlock_user(p, arg2, 0); - if (!is_error(ret)) - ret = host_to_target_stat64(cpu_env, arg3, &st); - return ret; -#endif #ifdef TARGET_NR_lchown case TARGET_NR_lchown: if (!(p = lock_user_string(arg1))) @@ -13041,6 +13069,12 @@ static impl_fn *syscall_table(unsigned num) SYSCALL(fork); #endif SYSCALL(fstat); +#ifdef TARGET_NR_fstat64 + SYSCALL(fstat64); +#endif +#ifdef TARGET_NR_fstatat64 + SYSCALL(fstatat64); +#endif SYSCALL(fstatfs); #ifdef TARGET_NR_fstatfs64 SYSCALL(fstatfs64); @@ -13109,6 +13143,9 @@ static impl_fn *syscall_table(unsigned num) #ifdef TARGET_NR_lstat SYSCALL(lstat); #endif +#ifdef TARGET_NR_lstat64 + SYSCALL(lstat64); +#endif #ifdef TARGET_NR_mkdir SYSCALL(mkdir); #endif @@ -13151,6 +13188,9 @@ static impl_fn *syscall_table(unsigned num) SYSCALL(name_to_handle_at); #endif SYSCALL(nanosleep); +#ifdef TARGET_NR_newfstatat + SYSCALL_WITH(newfstatat, fstatat64); +#endif #ifdef TARGET_NR__newselect SYSCALL(_newselect); #endif @@ -13322,6 +13362,9 @@ static impl_fn *syscall_table(unsigned num) #endif #ifdef TARGET_NR_stat SYSCALL(stat); +#endif +#ifdef TARGET_NR_stat64 + SYSCALL(stat64); #endif SYSCALL(statfs); #ifdef TARGET_NR_statfs64