From patchwork Sun Jun 10 03:00:56 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 138095 Delivered-To: patch@linaro.org Received: by 2002:a2e:970d:0:0:0:0:0 with SMTP id r13-v6csp2581656lji; Sat, 9 Jun 2018 20:16:51 -0700 (PDT) X-Google-Smtp-Source: ADUXVKIq8OpO7BuopPxvIJPklI+4nRurV8aAighPDpVkwWt/Or/GVLLdw6HCU+1RlUI6cQW5tOxx X-Received: by 2002:a37:16e0:: with SMTP id 93-v6mr10938211qkw.148.1528600611868; Sat, 09 Jun 2018 20:16:51 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1528600611; cv=none; d=google.com; s=arc-20160816; b=FczTssN4sTK0VZhEWpuIeP6HrUtMBTBStJfPCaiX5WfBRORt4v2scLjYWfScJvsr3v WrPouG4s2RtREquLlluO6KDd3NKOZtA5WdnfyKh5+itNBWMpWCVOy+h/dhoxmKLLulMI /GR7HhJq9t7NwwDfXbww8IVDLIYNdGtHtP3YfivaGwyu7oT0M5bOlBrdrMb45leb4rn3 y6kKcSfqaaTCAfT8ceLan7vewuZsSlZnsgd+4HFX6PnycqSBuHIf3vsDrtgAyCR3/epD BL8fh6GxN/ex6abfuIYQWdMkKUoUsdwXW6MSlwYiD3lU/BlJ1F7roIk/3yy4DNqurbJy cTTg== 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=afOKpGObluULY1TIOPi+7mfMElPYC1od3X+Z6eVUsKk=; b=0afFTGtwAwPcQEYEyyrzU++axhT6sKgSyh35D2nnlGR9dW6HBSMtj6ZToZ/NQumkk4 ccOqiaT51RnSGZblFtZ681it4DU6FiElpNCueZiICXGQieHoQY2WMTiTsvC2KeWXunpB zIzoe7G5t3QKjZraRiIkkgi6sJQb+3bk1fKsakxqbuRBXZMQkaYL543XsARGuAeLonhX Mxau+9zcWyj0gwqjpQ+ZLWY5eWulyQEA5O3IDB5HAvez0WElWqiCNmI9QgbwF7Qd+MeQ xQhLnLriFDv4L45IED5FgPGutcSeEE6Vp0GdsAv5S+VLxISdtZ85txPCImifb3Rk4sIS 8skw== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=ij+CKuxu; 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 z14-v6si4705435qvk.103.2018.06.09.20.16.51 for (version=TLS1 cipher=AES128-SHA bits=128/128); Sat, 09 Jun 2018 20:16:51 -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=ij+CKuxu; 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]:42249 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fRqqZ-0005Yo-9y for patch@linaro.org; Sat, 09 Jun 2018 23:16:51 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:40361) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fRqdT-0002AK-N0 for qemu-devel@nongnu.org; Sat, 09 Jun 2018 23:03:20 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fRqdS-0003Oh-R2 for qemu-devel@nongnu.org; Sat, 09 Jun 2018 23:03:19 -0400 Received: from mail-pl0-x244.google.com ([2607:f8b0:400e:c01::244]:45905) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1fRqdS-0003O8-LL for qemu-devel@nongnu.org; Sat, 09 Jun 2018 23:03:18 -0400 Received: by mail-pl0-x244.google.com with SMTP id c23-v6so10384114plz.12 for ; Sat, 09 Jun 2018 20:03:18 -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=afOKpGObluULY1TIOPi+7mfMElPYC1od3X+Z6eVUsKk=; b=ij+CKuxu77ntpFtIdee06rdy8eBAmiK2tMngO7FI3p0jnBjVDLXZv6t0PZIbr4yZDO qufWNPgQtUgRTCNOMnMnKv1lHgECd1wGJGrXy6X4TOgYwYh5RKsAksfW2Pc0QwDyOr65 0HRktjj/c1WqHEa4f9y+i+9gRE1301AE0tJCc= 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=afOKpGObluULY1TIOPi+7mfMElPYC1od3X+Z6eVUsKk=; b=obKi7zBH7Cnlcy+gNzPWNld+sQ+CMPelMRENQjEJ0vsGBMunlTDMC53mCZT/lJ1Kmj 0jH4JDhoX2pU6E3m2NK0vs0dlq7X3SiX7IMQCy9hbiRYB2fobFg5z2HuWUtriiCZTG6B Wh4c9FPDpZpTfjkOfny8o87VUQwTecvM0LcpZ3C9dOd5KT0lioJh/apNV8i1KWikKpcd fJXR9rh+VXt6I7W53anLXb/pBz036ohZRc4Pec7bGES2dem434ezavjLFiYBYg0npFtt JWPT4PbG3SqPNBPmk35jWaWsLmV8QCbj3BpLU0qkV4C7Ti5+EptqwR5o4P1bxEtkP6UY YzzQ== X-Gm-Message-State: APt69E1C3qcrCeQVNJPxnXNvZetT5mC0Y7dewVw9DNw5TjBHuQG55Zbk 2xXKBjaO4FzZL+tmHFAs7Icw6Aj+XOk= X-Received: by 2002:a17:902:123:: with SMTP id 32-v6mr2218917plb.255.1528599797489; Sat, 09 Jun 2018 20:03:17 -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.03.15 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Sat, 09 Jun 2018 20:03:16 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Date: Sat, 9 Jun 2018 17:00:56 -1000 Message-Id: <20180610030220.3777-25-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:c01::244 Subject: [Qemu-devel] [PATCH v2 024/108] linux-user: Split out dup, mkdir, mkdirat, rmdir 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" All targets define mkdirat; remove the ifdef. Signed-off-by: Richard Henderson --- linux-user/syscall.c | 90 +++++++++++++++++++++++++++++--------------- 1 file changed, 60 insertions(+), 30 deletions(-) -- 2.17.1 diff --git a/linux-user/syscall.c b/linux-user/syscall.c index e0a5d86956..f22d45d2cb 100644 --- a/linux-user/syscall.c +++ b/linux-user/syscall.c @@ -7946,6 +7946,15 @@ IMPL(creat) } #endif +IMPL(dup) +{ + abi_long ret = get_errno(dup(arg1)); + if (ret >= 0) { + fd_trans_dup(arg1, ret); + } + return ret; +} + IMPL(execve) { abi_ulong *guest_ptrs; @@ -8191,6 +8200,34 @@ IMPL(lseek) return get_errno(lseek(arg1, arg2, arg3)); } +#ifdef TARGET_NR_mkdir +IMPL(mkdir) +{ + char *p = lock_user_string(arg1); + abi_long ret; + + if (!p) { + return -TARGET_EFAULT; + } + ret = get_errno(mkdir(p, arg2)); + unlock_user(p, arg1, 0); + return ret; +} +#endif + +IMPL(mkdirat) +{ + char *p = lock_user_string(arg2); + abi_long ret; + + if (!p) { + return -TARGET_EFAULT; + } + ret = get_errno(mkdirat(arg1, p, arg3)); + unlock_user(p, arg2, 0); + return ret; +} + #ifdef TARGET_NR_mknod IMPL(mknod) { @@ -8464,6 +8501,21 @@ IMPL(renameat2) return ret; } +#ifdef TARGET_NR_rmdir +IMPL(rmdir) +{ + char *p = lock_user_string(arg1); + abi_long ret; + + if (!p) { + return -TARGET_EFAULT; + } + ret = get_errno(rmdir(p)); + unlock_user(p, arg1, 0); + return ret; +} +#endif + #ifdef TARGET_NR_stime IMPL(stime) { @@ -8665,36 +8717,6 @@ static abi_long do_syscall1(void *cpu_env, unsigned 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 -#ifdef TARGET_NR_rmdir - case TARGET_NR_rmdir: - if (!(p = lock_user_string(arg1))) - return -TARGET_EFAULT; - ret = get_errno(rmdir(p)); - unlock_user(p, arg1, 0); - return ret; -#endif - case TARGET_NR_dup: - ret = get_errno(dup(arg1)); - if (ret >= 0) { - fd_trans_dup(arg1, ret); - } - return ret; #ifdef TARGET_NR_pipe case TARGET_NR_pipe: return do_pipe(cpu_env, arg1, 0, 0); @@ -12581,6 +12603,7 @@ static impl_fn *syscall_table(unsigned num) #ifdef TARGET_NR_creat SYSCALL(creat); #endif + SYSCALL(dup); SYSCALL(execve); SYSCALL(exit); SYSCALL(faccessat); @@ -12602,6 +12625,10 @@ static impl_fn *syscall_table(unsigned num) #endif SYSCALL(linkat); SYSCALL(lseek); +#ifdef TARGET_NR_mkdir + SYSCALL(mkdir); +#endif + SYSCALL(mkdirat); #ifdef TARGET_NR_mknod SYSCALL(mknod); #endif @@ -12631,6 +12658,9 @@ static impl_fn *syscall_table(unsigned num) SYSCALL(renameat); #endif SYSCALL(renameat2); +#ifdef TARGET_NR_rmdir + SYSCALL(rmdir); +#endif #ifdef TARGET_NR_stime SYSCALL(stime); #endif