From patchwork Sun May 19 20:36:53 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 164528 Delivered-To: patch@linaro.org Received: by 2002:a92:9e1a:0:0:0:0:0 with SMTP id q26csp4798570ili; Sun, 19 May 2019 14:08:31 -0700 (PDT) X-Google-Smtp-Source: APXvYqwX+7BythRvZoL4RNvKj7o7kafUpQ/RFy+aMRHyQpWTxgAaW9Rk4keYblUAznZMso9mb5a7 X-Received: by 2002:a17:906:f84a:: with SMTP id ks10mr38253931ejb.65.1558300110912; Sun, 19 May 2019 14:08:30 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1558300110; cv=none; d=google.com; s=arc-20160816; b=F9uwPlbzd14IGNLAobES+iObsNkpEcTfDivuEOTAE4oNbVZ6ptQ1aSsr/ucW4xpiu7 lzvh85u4kX/0hogxncIuAxuLSVVj9AZalpvqrjhNSTsY2Vx4SRPuHVKq+fRdSxnmYEaC 4ibrsn0kN8e1SiKNE50LemwLLVCT85VPFl9PqrfI39IBc2KR9yPI61Oh9nOoNRW2NUbs rWGvwfQZBX7UWabEplF9xOhEm00K+mpWaF/o5TS5EX+uDCSsgfSqi5k4zCni43WuSiTp LTw0PUaBLU9zfsUQF92nXamgov2oGJNVRi3XPmfyaoyCrAEZ6f9IBuNXa/fxbAx1wZzs cVdg== 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=sj59YrDaOii9L6seogQrj9UiCSK4yTlGx0hQSWmkpdA=; b=liZ9rByhgqzUTtxZuSlpPD8Bh7XQYFK4q/DeRooW4OKw7Tgv1esNkbV2xshq2ULp3N /p7xqfUBN+Ei8L0cMNsf3LxtPrcRsbt8WeyhYfy2shzCIx22REyMdi/VzTEOSvn3TXh1 x0k3eESp3D3vrWt266CP0dIpsiQjiEG8Y0d6byNF7IRox2K79JvLdqPozP4unlTFQN55 jHjgZtkMTnN0YHhk6PF3nFVTy4StGuxU7tjcjTRu1JJymUrQZS0BY5m/Qnp4AAd/OX89 DK6Fm3LZcsk8asEAd9yC44OS5SGk+xpB8m/KvtZVtq5Qyyx3qsv+ZdKP7dV1+nRNsYYU 0lcw== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=Rd5loNac; 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 o16si9646800ejg.38.2019.05.19.14.08.30 for (version=TLS1 cipher=AES128-SHA bits=128/128); Sun, 19 May 2019 14:08:30 -0700 (PDT) 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=Rd5loNac; 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]:53546 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1hST2j-0003vV-Kb for patch@linaro.org; Sun, 19 May 2019 17:08:29 -0400 Received: from eggs.gnu.org ([209.51.188.92]:50729) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1hSSZe-0003ei-Tf for qemu-devel@nongnu.org; Sun, 19 May 2019 16:38:29 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1hSSZd-0004Pq-Hs for qemu-devel@nongnu.org; Sun, 19 May 2019 16:38:26 -0400 Received: from mail-pg1-x542.google.com ([2607:f8b0:4864:20::542]:46948) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1hSSZd-0004ML-8j for qemu-devel@nongnu.org; Sun, 19 May 2019 16:38:25 -0400 Received: by mail-pg1-x542.google.com with SMTP id t187so5715973pgb.13 for ; Sun, 19 May 2019 13:38:22 -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=sj59YrDaOii9L6seogQrj9UiCSK4yTlGx0hQSWmkpdA=; b=Rd5loNaceU2JTZWTz70p9BYyr9D2BAwEvrsapMfTqsgfsZKpr5wxUiiXPuVDNBb6/e pB7CEE8j/eg6Bhun1IbPfPP3mh2Hmbp3VVy144bY4T9ewk0czfDhbi65i5soJ0JAslvM trLfSE7+adcc2u9WGpJHJEJ7uLVMbi0RJDgAWTd3XSUGsNnM5gAoJrFRHusnx2laWzQq sbV1S1Ry5ntpOm7MMxSOKHacVR9FO44AC9XGabpeWw3kMwReunuvqk1+kWWGGARrTIQr zITZ/W/b/iK8dtWWI/FYxPLukLOX8DzejL+1fsE8v01sYRQ68dolq+uCrQ6unzcnlfdE Q+FQ== 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=sj59YrDaOii9L6seogQrj9UiCSK4yTlGx0hQSWmkpdA=; b=ImbxxclGwugF19YrC3g1qXNcojN8cDKoigZ0ufBBnH+HXpheSzQ8OemNq1AolqgVdO /MWc1CZJIkwxIq53oMLk18GBni6cSJOR/3FbVon3G4IgpgVHN28VSJ2VJ2Kw1WftQIRn vZvQjXyKC+AX8pG5TZxr/RRZhtRoRmjeO6Ld0iOx99VS+fXLYOMznb+GZi9DygrwAVtx G2Pbjyc3SiDt++3owBE2vsDrC3RcG7QwWqypkWXSoq5RIrIzhJD42IJ35YsSaMQ6RZ56 k7HCIV3mbhaqPBtWHVBrHor1oLojYgvJmSLieSqw6RVQC/D9MHXccIfZOPSMecaBB45/ trNg== X-Gm-Message-State: APjAAAUvnwUMfCxvYlndl9FvzL7N3nIDCLXA5hXNxztTUM6FoErTEte6 +Lg5kCnyQKEr7BnNNs7wyHe+s4WvGMI= X-Received: by 2002:a63:fb02:: with SMTP id o2mr70159867pgh.357.1558298301857; Sun, 19 May 2019 13:38:21 -0700 (PDT) Received: from localhost.localdomain (97-113-13-231.tukw.qwest.net. [97.113.13.231]) by smtp.gmail.com with ESMTPSA id i7sm11397448pfo.19.2019.05.19.13.38.20 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sun, 19 May 2019 13:38:21 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Date: Sun, 19 May 2019 13:36:53 -0700 Message-Id: <20190519203726.20729-42-richard.henderson@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20190519203726.20729-1-richard.henderson@linaro.org> References: <20190519203726.20729-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::542 Subject: [Qemu-devel] [PATCH v7 41/74] 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.1 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 8f871b30ae..2b31998dbd 100644 --- a/linux-user/strace.c +++ b/linux-user/strace.c @@ -1676,33 +1676,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 18553f055e..5ed8b78c79 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 d8f6da63cc..0d6a9b7a6c 100644 --- a/linux-user/syscall.c +++ b/linux-user/syscall.c @@ -5373,22 +5373,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 3b002a0500..cdbc59bffd 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