From patchwork Fri Jun 1 07:30:42 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 137475 Delivered-To: patch@linaro.org Received: by 2002:a2e:9706:0:0:0:0:0 with SMTP id r6-v6csp613146lji; Fri, 1 Jun 2018 00:44:33 -0700 (PDT) X-Google-Smtp-Source: ADUXVKLCeIzn+P1kn0bKNJQqk1k0vo4RyXT3ImdUCj5Pd/+6WRVOBenXNyieiJfCC/VAdCKJ6rSz X-Received: by 2002:ac8:1798:: with SMTP id o24-v6mr10227743qtj.72.1527839073762; Fri, 01 Jun 2018 00:44:33 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1527839073; cv=none; d=google.com; s=arc-20160816; b=EWUusciJ68YMZfsVx5NmjfJRVC4OW86WkyhCLoVimJpGpZS/ojzOgOUOaaLFSC76ZW Hg36HlA7QKRmPCQPWtdq9W7v0OYvyD6AG4C1O+aXFbAWyH1KzG5gYhqI5v72ZyflrAF1 z6qVMqFIeQexdA/zTrxlxwFrvSU31nRKqHdGt1Tnrb89Od1ZhrAAd/SwCK7dbNYRc2m/ hWhMRLIVWHsclDlwHdtHhrgkGv4s4wyoV7pjlRsjPTjXc2unJy+Dp8IK3tj+YhM0+4jX POjgxRDRbYlPDKwwxuUKpsjColQq2S2xxiFubxEPnzu1EZaasQpUuhXaJgyCbHkp8CO3 kCVg== 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=7TG6NzpTpxsHJFgGfeNtYvgbvgcDYj1wa91hnUQOp/s=; b=jdzMBmzsOwA1fuVVtVTdBgj0n2jaxckciQExuNYZixaQSj7o7LZbTEHVywYMSsiXNw z7yYVPLYO7AzjLw6KaFfogCe2BVDcsZoxYZ5wy8a+BE6h/H1T2aZPcu9Kr3DySOiKQrQ x88vEAZknRXnTKpX7UiQDwBH/VBkZGOhqGgReT7jWDGV9YEC3XRXzGGZVtk2zzhxqCpP LPtHPwuSUdupOlsdKzgX41qthe45IAgDjQyY5e40T4rmmenRKQn5QIfifL821NpZRjtA 5KrYVqBQJXcMtLPR0x3yzKPgV94kOF+Ydqur15iLU7UaZxZNlVygefwFDJGcukC4mynv mLMA== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=das/cHMx; 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 w32-v6si1740374qtj.301.2018.06.01.00.44.33 for (version=TLS1 cipher=AES128-SHA bits=128/128); Fri, 01 Jun 2018 00:44:33 -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=das/cHMx; 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]:47872 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fOejg-0006Mi-3L for patch@linaro.org; Fri, 01 Jun 2018 03:44:32 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:57647) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fOeX5-0005p1-HH for qemu-devel@nongnu.org; Fri, 01 Jun 2018 03:31:32 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fOeX4-0000jz-FG for qemu-devel@nongnu.org; Fri, 01 Jun 2018 03:31:31 -0400 Received: from mail-pf0-x241.google.com ([2607:f8b0:400e:c00::241]:37618) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1fOeX4-0000jN-9T for qemu-devel@nongnu.org; Fri, 01 Jun 2018 03:31:30 -0400 Received: by mail-pf0-x241.google.com with SMTP id e9-v6so12083209pfi.4 for ; Fri, 01 Jun 2018 00:31:30 -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=7TG6NzpTpxsHJFgGfeNtYvgbvgcDYj1wa91hnUQOp/s=; b=das/cHMxqXVkgfPWGUrJfLXn+eoe842KSVNr6eI+cY+p3fwY+ERBoNQODg7GZbHFtZ +aZcQVQCYUKUXtB9ydzLevK0Sho9ESTfUEXuKsXNf2lRa8x1uVGfO0gFuMLhrBkOiWIN dYny9X+BuezMB7REWBTTYVCKHMMyN5SiMLaaA= 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=7TG6NzpTpxsHJFgGfeNtYvgbvgcDYj1wa91hnUQOp/s=; b=QKPvoFifjzdZ7Gr4PkqdHf/n/Sd0XFRLq9ktn9769wqAP0L47zAlsfF86ZGElmt4Ca VqvmDSm607be/tG8rgGtgv4m3FBnOGFv9umG6mumG4dVDwlpnXDl1qWPuxYymJehob2b XvWCuOQYSeAwl9emN7551FRtwcdTh4KfqGvyPaRDX7D4dgfXvLXLeolh8T8jdjfiT77X ErJSsGIgX/gaf4M6a43QBe7BZjhdvzCcZsie/y7gMbx5aMgIPwQUp33OgF0ccijVAs6y /RsnIalR7UOcaXJ/k+IkuencjvsO+vSwKh4uxnDmSfS9epE9kG311JHkNOLMdYKlKJga Leow== X-Gm-Message-State: ALKqPwcUmZPNRVT/8o6Zfo9EmGl4lNPfyPWQywid7bTXtbPgafMrSjsf x9iUq2MdkNoALGh2MxkIUY4vCb4gKUY= X-Received: by 2002:a62:6c87:: with SMTP id h129-v6mr9741040pfc.179.1527838288950; Fri, 01 Jun 2018 00:31:28 -0700 (PDT) Received: from cloudburst.twiddle.net (97-126-112-211.tukw.qwest.net. [97.126.112.211]) by smtp.gmail.com with ESMTPSA id c4-v6sm4431782pgv.86.2018.06.01.00.31.27 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Fri, 01 Jun 2018 00:31:27 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Date: Fri, 1 Jun 2018 00:30:42 -0700 Message-Id: <20180601073050.8054-26-richard.henderson@linaro.org> X-Mailer: git-send-email 2.17.0 In-Reply-To: <20180601073050.8054-1-richard.henderson@linaro.org> References: <20180601073050.8054-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::241 Subject: [Qemu-devel] [PATCH 25/33] 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" Signed-off-by: Richard Henderson --- linux-user/syscall.c | 109 +++++++++++++++++++++++++++++-------------- 1 file changed, 73 insertions(+), 36 deletions(-) -- 2.17.0 diff --git a/linux-user/syscall.c b/linux-user/syscall.c index 24514329b0..36092d753d 100644 --- a/linux-user/syscall.c +++ b/linux-user/syscall.c @@ -7977,6 +7977,20 @@ IMPL(creat) } #endif +IMPL(dup) +{ + abi_long ret; + + if (is_hostfd(arg1)) { + return -TARGET_EBADF; + } + ret = get_errno(dup(arg1)); + if (ret >= 0) { + fd_trans_dup(arg1, ret); + } + return ret; +} + IMPL(execve) { abi_ulong *guest_ptrs; @@ -8249,6 +8263,40 @@ 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 + +#ifdef TARGET_NR_mkdirat +IMPL(mkdirat) +{ + char *p; + abi_long ret; + + if (is_hostfd(arg1)) { + return -TARGET_EBADF; + } + p = lock_user_string(arg2); + if (!p) { + return -TARGET_EFAULT; + } + ret = get_errno(mkdirat(arg1, p, arg3)); + unlock_user(p, arg2, 0); + return ret; +} +#endif + #ifdef TARGET_NR_mknod IMPL(mknod) { @@ -8558,6 +8606,21 @@ IMPL(renameat2) } #endif +#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) { @@ -8768,42 +8831,6 @@ IMPL(everything_else) char *fn; 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 (is_hostfd(arg1)) { - return -TARGET_EBADF; - } - 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: - if (is_hostfd(arg1)) { - return -TARGET_EBADF; - } - 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); @@ -12922,6 +12949,7 @@ static impl_fn * const syscall_table[] = { #ifdef TARGET_NR_creat [TARGET_NR_creat] = impl_creat, #endif + [TARGET_NR_dup] = impl_dup, [TARGET_NR_execve] = impl_execve, [TARGET_NR_exit] = impl_exit, #ifdef TARGET_NR_faccessat @@ -12947,6 +12975,12 @@ static impl_fn * const syscall_table[] = { [TARGET_NR_linkat] = impl_linkat, #endif [TARGET_NR_lseek] = impl_lseek, +#ifdef TARGET_NR_mkdir + [TARGET_NR_mkdir] = impl_mkdir, +#endif +#ifdef TARGET_NR_mkdirat + [TARGET_NR_mkdirat] = impl_mkdirat, +#endif #ifdef TARGET_NR_mknod [TARGET_NR_mknod] = impl_mknod, #endif @@ -12980,6 +13014,9 @@ static impl_fn * const syscall_table[] = { #ifdef TARGET_NR_renameat2 [TARGET_NR_renameat2] = impl_renameat2, #endif +#ifdef TARGET_NR_rmdir + [TARGET_NR_rmdir] = impl_rmdir, +#endif #ifdef TARGET_NR_stime [TARGET_NR_stime] = impl_stime, #endif