From patchwork Fri Jan 18 21:31:15 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 156090 Delivered-To: patch@linaro.org Received: by 2002:a02:48:0:0:0:0:0 with SMTP id 69csp3755329jaa; Fri, 18 Jan 2019 14:09:52 -0800 (PST) X-Google-Smtp-Source: ALg8bN7LVxPTwE1W6HuJeHHbq/alv4Avwzv/xmM7Y5BrJ+VeTdVnekIVYfRIW7x7jEFsOAmxCDCR X-Received: by 2002:a1c:2787:: with SMTP id n129mr17619572wmn.128.1547849392588; Fri, 18 Jan 2019 14:09:52 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1547849392; cv=none; d=google.com; s=arc-20160816; b=nYm8RCGrkX2CH0dysblnWWfN/DTzi4cj2e0ZDrVSEESYt1Qs9H09lnYGyGjaXVaZQP 40nYarHFQRhV/nXp0pm233SLCSB5lO/5CLO+BLu5CA3GRL7WMS+reo7PuFJqP8xdnSEB ocJfsa+f99/3fw859On+EFFGSLKcr9N69Vxs+ou2AGNLchM9tzwoGby9ihifsWR2TjOZ hvw1HPAwch++KILpLZl8iH+NyQV+/cW4O16bbPv5MaGEU6MIS2v/WWqNkSKA2eQlgm67 d5MegZisymXLr7ajmuU47vjfAeET1atTWdDriUmXrBPmOtNX9APNGm7IXl7kuQ9pMMXR ac2w== 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; bh=l2U9V7OWcdwqxw57y+bKKgPCSnPcotL021xUC/JbE6c=; b=uZnUfORVdFEyEqC/1RAAkU0y8SB+6JrGTg3fpllkIabvDXz4xH89MSjZFAY5Q3MaPk mtmQwjXQNMmqI9Bbe8itJiEkhBbBnfFTsfoqv2mtGpRwTiPp4ZVNaBduutpOYR0Hsc91 JsYEzYRS1M7q6m/YlzazZyOD/dBkyM9OVXAeOtIDfyE1y6htJWSZsA/r9OYyz32eS/OB F9UkSvoyGoOpJngERxwIctJeRMSfaD6LCsTTZaFNqiFqb5FPREApk/Avyc6svlZybViP oWVkMSD2nR2+u4++FHQSZrOJaBH0lH6+OevyNdhKwYZFhWmmqh1YDkwdc9YQsaqn4SZ4 KRtw== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=O8qBEX2l; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 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. [209.51.188.17]) by mx.google.com with ESMTPS id v185si28101393wme.44.2019.01.18.14.09.52 for (version=TLS1 cipher=AES128-SHA bits=128/128); Fri, 18 Jan 2019 14:09:52 -0800 (PST) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=O8qBEX2l; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 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 ([127.0.0.1]:47917 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gkcKl-0001A5-AK for patch@linaro.org; Fri, 18 Jan 2019 17:09:51 -0500 Received: from eggs.gnu.org ([209.51.188.92]:56417) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gkblD-0005mr-QT for qemu-devel@nongnu.org; Fri, 18 Jan 2019 16:33:08 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1gkblC-0005Xn-Qj for qemu-devel@nongnu.org; Fri, 18 Jan 2019 16:33:07 -0500 Received: from mail-pl1-x642.google.com ([2607:f8b0:4864:20::642]:42955) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1gkblC-0005Wg-KW for qemu-devel@nongnu.org; Fri, 18 Jan 2019 16:33:06 -0500 Received: by mail-pl1-x642.google.com with SMTP id y1so6881261plp.9 for ; Fri, 18 Jan 2019 13:33:06 -0800 (PST) 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=l2U9V7OWcdwqxw57y+bKKgPCSnPcotL021xUC/JbE6c=; b=O8qBEX2lSA28jSsUdzd4X4UW/aE/umX+htbqOf47v7GuLQ3C2qZctQFMiqCywRMWW7 vSpeu1N/bOh79ZS5MmT4BdYv0iRG6JuUe5Juc4epRIMj7ia93qI5DGBMzVhu2t/IpqMV o3Iv62pfM+rsRd0ZhkDDwDPGVhaK9pa8RQExg= 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=l2U9V7OWcdwqxw57y+bKKgPCSnPcotL021xUC/JbE6c=; b=cMsCXSKfz/Jc4NDH2tNGrDV1kQ4PkqSvbutV4bXdkFgTpEmf2+LGWfV++OKGbcyUqs QDPvKVmKq14V4H5ECgdCsiPxspMNP96idTwbcScNZ8sPyTcnbwy2EOLFq/By88/52oeA icKcOmhCF2evCEF0vZvJeU61VyqVQwqXCu64MYB8Y/lnXEK4ZaUC+XrhCXImUG40jq5Y MxLze23sEPC0pnp4sEmKinV9DD20skaro2xNobADk/eENbS/4AawqDhaPGA1NFI9tFy+ HC9wJIRimGZJCBlmE5d+DEMTb0JiVFPZaEhGkSX9+y9k1ijqZeiUVfx7QV6xLWvbm3Su uuEA== X-Gm-Message-State: AJcUukd4KyPzEoqiDI1KtiqkHpMQ01mFTjxW4eCG13panOlDXX1u658O cNgo4NCXkDLlhkUTIqCQH5W7en4zLRA= X-Received: by 2002:a17:902:b112:: with SMTP id q18mr20752660plr.255.1547847185391; Fri, 18 Jan 2019 13:33:05 -0800 (PST) Received: from cloudburst.twiddle.net ([2001:8000:10e0:a000:c673:a6b6:fdef:1933]) by smtp.gmail.com with ESMTPSA id v12sm5833667pgg.41.2019.01.18.13.33.03 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Fri, 18 Jan 2019 13:33:04 -0800 (PST) From: Richard Henderson To: qemu-devel@nongnu.org Date: Sat, 19 Jan 2019 08:31:15 +1100 Message-Id: <20190118213122.22865-42-richard.henderson@linaro.org> X-Mailer: git-send-email 2.17.2 In-Reply-To: <20190118213122.22865-1-richard.henderson@linaro.org> References: <20190118213122.22865-1-richard.henderson@linaro.org> X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2607:f8b0:4864:20::642 Subject: [Qemu-devel] [PATCH v6 42/49] linux-user: Split out mkdir, mkdirat 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" Note that mkdirat is universally available. Signed-off-by: Richard Henderson --- linux-user/syscall-defs.h | 4 ++++ linux-user/strace.c | 27 --------------------------- linux-user/syscall-file.inc.c | 25 +++++++++++++++++++++++++ linux-user/syscall.c | 16 ---------------- linux-user/strace.list | 6 ------ 5 files changed, 29 insertions(+), 49 deletions(-) -- 2.17.2 diff --git a/linux-user/syscall-defs.h b/linux-user/syscall-defs.h index 0ed01aa100..8b6d8f75ff 100644 --- a/linux-user/syscall-defs.h +++ b/linux-user/syscall-defs.h @@ -69,6 +69,10 @@ SYSCALL_DEF(lseek, ARG_DEC, ARG_DEC, ARG_LSEEKWHENCE); #ifdef TARGET_NR_llseek SYSCALL_DEF_ARGS(llseek, ARG_DEC, ARG_DEC, ARG_PTR, ARG_LSEEKWHENCE); #endif +#ifdef TARGET_NR_mkdir +SYSCALL_DEF(mkdir, ARG_STR, ARG_MODEFLAG); +#endif +SYSCALL_DEF(mkdirat, ARG_ATDIRFD, ARG_STR, ARG_MODEFLAG); #ifdef TARGET_NR_mknod SYSCALL_DEF(mknod, ARG_STR, ARG_MODEFLAG, ARG_HEX); #endif diff --git a/linux-user/strace.c b/linux-user/strace.c index 6dce7e52c0..ca8e110675 100644 --- a/linux-user/strace.c +++ b/linux-user/strace.c @@ -1664,33 +1664,6 @@ print_fstat(const struct syscallname *name, #define print_fstat64 print_fstat #endif -#ifdef TARGET_NR_mkdir -static void -print_mkdir(const struct syscallname *name, - abi_long arg0, abi_long arg1, abi_long arg2, - abi_long arg3, abi_long arg4, abi_long arg5) -{ - print_syscall_prologue(name); - print_string(arg0, 0); - print_file_mode(arg1, 1); - print_syscall_epilogue(name); -} -#endif - -#ifdef TARGET_NR_mkdirat -static void -print_mkdirat(const struct syscallname *name, - abi_long arg0, abi_long arg1, abi_long arg2, - abi_long arg3, abi_long arg4, abi_long arg5) -{ - print_syscall_prologue(name); - print_at_dirfd(arg0, 0); - print_string(arg1, 0); - print_file_mode(arg2, 1); - print_syscall_epilogue(name); -} -#endif - #ifdef TARGET_NR_rt_sigaction static void print_rt_sigaction(const struct syscallname *name, diff --git a/linux-user/syscall-file.inc.c b/linux-user/syscall-file.inc.c index 9099107631..83174c5781 100644 --- a/linux-user/syscall-file.inc.c +++ b/linux-user/syscall-file.inc.c @@ -205,6 +205,31 @@ SYSCALL_IMPL(llseek) } #endif +static abi_long do_mkdirat(int dirfd, abi_ulong target_path, mode_t mode) +{ + char *p = lock_user_string(target_path); + abi_long ret; + + if (!p) { + return -TARGET_EFAULT; + } + ret = get_errno(mkdirat(dirfd, p, mode)); + unlock_user(p, target_path, 0); + return ret; +} + +#ifdef TARGET_NR_mkdir +SYSCALL_IMPL(mkdir) +{ + return do_mkdirat(AT_FDCWD, arg1, arg2); +} +#endif + +SYSCALL_IMPL(mkdirat) +{ + return do_mkdirat(arg1, arg2, arg3); +} + static abi_long do_mknodat(int dirfd, abi_ulong target_path, mode_t mode, dev_t dev) { diff --git a/linux-user/syscall.c b/linux-user/syscall.c index fe38ec59d4..7874a48840 100644 --- a/linux-user/syscall.c +++ b/linux-user/syscall.c @@ -5320,22 +5320,6 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1, void *p; switch(num) { -#ifdef TARGET_NR_mkdir - case TARGET_NR_mkdir: - if (!(p = lock_user_string(arg1))) - return -TARGET_EFAULT; - ret = get_errno(mkdir(p, arg2)); - unlock_user(p, arg1, 0); - return ret; -#endif -#if defined(TARGET_NR_mkdirat) - case TARGET_NR_mkdirat: - if (!(p = lock_user_string(arg2))) - return -TARGET_EFAULT; - ret = get_errno(mkdirat(arg1, p, arg3)); - unlock_user(p, arg2, 0); - return ret; -#endif case TARGET_NR_dup: ret = get_errno(dup(arg1)); if (ret >= 0) { diff --git a/linux-user/strace.list b/linux-user/strace.list index 56aab25d9f..678feeeb7b 100644 --- a/linux-user/strace.list +++ b/linux-user/strace.list @@ -473,12 +473,6 @@ #ifdef TARGET_NR_mincore { TARGET_NR_mincore, "mincore" , NULL, NULL, NULL }, #endif -#ifdef TARGET_NR_mkdir -{ TARGET_NR_mkdir, "mkdir" , NULL, print_mkdir, NULL }, -#endif -#ifdef TARGET_NR_mkdirat -{ TARGET_NR_mkdirat, "mkdirat" , NULL, print_mkdirat, NULL }, -#endif #ifdef TARGET_NR_modify_ldt { TARGET_NR_modify_ldt, "modify_ldt" , NULL, NULL, NULL }, #endif