From patchwork Fri Jun 1 07:30:41 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 137486 Delivered-To: patch@linaro.org Received: by 2002:a2e:9706:0:0:0:0:0 with SMTP id r6-v6csp619565lji; Fri, 1 Jun 2018 00:53:15 -0700 (PDT) X-Google-Smtp-Source: ADUXVKI9ESaUVl61V8bWGj4ieGAvIvzlrX3gJo8FVi+gVhYIxfDdCoGV5Hf27RvfAPHg9Z+ae0kj X-Received: by 2002:ac8:686:: with SMTP id f6-v6mr10178016qth.348.1527839594999; Fri, 01 Jun 2018 00:53:14 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1527839594; cv=none; d=google.com; s=arc-20160816; b=YqfmEyJ1ikzCT4bXxzRipA9Viv6lBNcnNET4tleHOnf/KWaktOalNl6ZEqoX1Dzih+ cmzJjEj4p1YBFqJ+SyUcFdzGwbUGsXfLDoXg1nkKJUN4gUU7pSjGtM6i7hzclbWm26l3 CX6OkiBzCSv4oCS16C70jwmqq7zQxzGZOh2VM4dzqhV9DA3M8LtFt36AACzXQUB2IV2U 0bHsV4cOEVShC4XnJY8/JpZkQGSoxvHE9YNB+01FdXfDSsAFjqXLIgCETdsU+LajhupV lzScCNmyfEmyl+JwbUa71RKeEFu8AIE6Om5i1vwAZbI9CgWAB6VnOxMwKtNYTGBbGl5Z QOpA== 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=Y/6YpethMjyMjAPexK3JzdIUyBPsA29lqLFVZ4htKnA=; b=uTZ1VTe7NSWsnym6RbBnNHPkhJP60AbbXnYkIGzEsEdbO+SAMAbleKKJDbaJ6wy6Au wbaivL0zKpiB8hht7pgzgQmlu0Q4+DMi+EaGkGK45gxn3dUutNX54ojIToVpS1zEL6wY ZsRFBvQPDVhw1agV/mFBXxgleqcUc2GoeHFh0/Mg+UH4beADpn97YfieEkBC04LVNOBC pxft9/6fjeDZjVja9wn+kPiVECQHqzcNaln6zt9u7WXFjVYkmS2MavAbovw9AhPnImsp EyoZ1r7TRjAjsY6rE91hEjnXbuztAEY00pgXwOvfqs1c2UKykNvZYBvrOCqRfN4CB0d7 oYAA== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=QyDRky5c; 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 p184-v6si3248088qkb.380.2018.06.01.00.53.14 for (version=TLS1 cipher=AES128-SHA bits=128/128); Fri, 01 Jun 2018 00:53:14 -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=QyDRky5c; 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]:47926 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fOes6-0005WF-EB for patch@linaro.org; Fri, 01 Jun 2018 03:53:14 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:57634) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fOeX4-0005nz-3A 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 1fOeX3-0000iZ-1j for qemu-devel@nongnu.org; Fri, 01 Jun 2018 03:31:30 -0400 Received: from mail-pl0-x241.google.com ([2607:f8b0:400e:c01::241]:43953) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1fOeX2-0000hw-Sg for qemu-devel@nongnu.org; Fri, 01 Jun 2018 03:31:29 -0400 Received: by mail-pl0-x241.google.com with SMTP id c41-v6so14803978plj.10 for ; Fri, 01 Jun 2018 00:31:28 -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=Y/6YpethMjyMjAPexK3JzdIUyBPsA29lqLFVZ4htKnA=; b=QyDRky5ca7M/l0voL2y8GED2oQJ8BBrkrjmocVyzz74orAKuaye7uzvckRZBBM38n7 8tnKusB+/0p6NjYOLwAyQ+IjRx6xhL6Wm6UMeBIkQZG90FKTsnbYoeBn71mWApNOEN1U 7SUajp0Yh2qdtDgxb4TPbcc3FubDMDz45bHes= 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=Y/6YpethMjyMjAPexK3JzdIUyBPsA29lqLFVZ4htKnA=; b=gTZ8+BqmUHmamU9fmFaLsY1Ls59RwM98oa1PZdmyv/HzP2Q8+NMeZBZpoLw5PfiMJE l9vSF6JRgV1XiZAGhdeoz3ThEMVXkzIPCDxA28vUylKPjep9et5wJIaxxuoveIYE8DnM /XI03nrvTErdwIoRizLdXY0o3f6XjOryjRxgQUpPyB+EambquaRDKSDvYH+obW5nva3n /SOxgHQqyGakpFdqHtimai5Z16OdV9DLgFS7HuNLNh/sIJbR71BFZsC5ZDgLM3asN3Vf 1b4HCil0Jo3sduzlHtsTa0QZ/v4+sDB4n7/BpnuKOg+NOsM5j0T9jbacWIOTBy+DIA0l AVQQ== X-Gm-Message-State: ALKqPwcGwOuLa5drtu3fILsuaz/0dn1z7kQZJXN2YfbHTau4qb0Fv8jo pzD4qzTVg7lIGJ5wdgP0ySj0WZJRN+Q= X-Received: by 2002:a17:902:64cf:: with SMTP id y15-v6mr10208924pli.53.1527838287638; Fri, 01 Jun 2018 00:31:27 -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.26 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Fri, 01 Jun 2018 00:31:26 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Date: Fri, 1 Jun 2018 00:30:41 -0700 Message-Id: <20180601073050.8054-25-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:c01::241 Subject: [Qemu-devel] [PATCH 24/33] linux-user: Split out rename, renameat, renameat2 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 | 113 ++++++++++++++++++++++++------------------- 1 file changed, 63 insertions(+), 50 deletions(-) -- 2.17.0 diff --git a/linux-user/syscall.c b/linux-user/syscall.c index 2a172e24eb..24514329b0 100644 --- a/linux-user/syscall.c +++ b/linux-user/syscall.c @@ -8504,6 +8504,60 @@ IMPL(read) return ret; } +#ifdef TARGET_NR_rename +IMPL(rename) +{ + char *p1 = lock_user_string(arg1); + char *p2 = lock_user_string(arg2); + abi_long ret = -TARGET_EFAULT; + + if (p1 && p2) { + ret = get_errno(rename(p1, p2)); + } + unlock_user(p2, arg2, 0); + unlock_user(p1, arg1, 0); + return ret; +} +#endif + +#if defined(TARGET_NR_renameat) +IMPL(renameat) +{ + if (is_hostfd(arg1)) { + return -TARGET_EBADF; + } + + char *p1 = lock_user_string(arg2); + char *p2 = lock_user_string(arg4); + abi_long ret = -TARGET_EFAULT; + if (p1 && p2) { + ret = get_errno(renameat(arg1, p1, arg3, p2)); + } + unlock_user(p2, arg4, 0); + unlock_user(p1, arg2, 0); + return ret; +} +#endif + +#ifdef TARGET_NR_renameat2 +IMPL(renameat2) +{ + if (is_hostfd(arg1)) { + return -TARGET_EBADF; + } + + char *p1 = lock_user_string(arg2); + char *p2 = lock_user_string(arg4); + abi_long ret = -TARGET_EFAULT; + if (p1 && p2) { + ret = get_errno(sys_renameat2(arg1, p1, arg3, p2, arg5)); + } + unlock_user(p2, arg4, 0); + unlock_user(p1, arg2, 0); + return ret; +} +#endif + #ifdef TARGET_NR_stime IMPL(stime) { @@ -8714,56 +8768,6 @@ IMPL(everything_else) char *fn; switch(num) { -#ifdef TARGET_NR_rename - case TARGET_NR_rename: - { - void *p2; - p = lock_user_string(arg1); - p2 = lock_user_string(arg2); - if (!p || !p2) - ret = -TARGET_EFAULT; - else - ret = get_errno(rename(p, p2)); - unlock_user(p2, arg2, 0); - unlock_user(p, arg1, 0); - } - return ret; -#endif -#if defined(TARGET_NR_renameat) - case TARGET_NR_renameat: - if (is_hostfd(arg1)) { - return -TARGET_EBADF; - } else { - void *p2; - p = lock_user_string(arg2); - p2 = lock_user_string(arg4); - if (!p || !p2) - ret = -TARGET_EFAULT; - else - ret = get_errno(renameat(arg1, p, arg3, p2)); - unlock_user(p2, arg4, 0); - unlock_user(p, arg2, 0); - } - return ret; -#endif -#if defined(TARGET_NR_renameat2) - case TARGET_NR_renameat2: - if (is_hostfd(arg1)) { - return -TARGET_EBADF; - } else { - void *p2; - p = lock_user_string(arg2); - p2 = lock_user_string(arg4); - if (!p || !p2) { - ret = -TARGET_EFAULT; - } else { - ret = get_errno(sys_renameat2(arg1, p, arg3, p2, arg5)); - } - unlock_user(p2, arg4, 0); - unlock_user(p, arg2, 0); - } - return ret; -#endif #ifdef TARGET_NR_mkdir case TARGET_NR_mkdir: if (!(p = lock_user_string(arg1))) @@ -12967,6 +12971,15 @@ static impl_fn * const syscall_table[] = { [TARGET_NR_pause] = impl_pause, #endif [TARGET_NR_read] = impl_read, +#ifdef TARGET_NR_rename + [TARGET_NR_rename] = impl_rename, +#endif +#ifdef TARGET_NR_renameat + [TARGET_NR_renameat] = impl_renameat, +#endif +#ifdef TARGET_NR_renameat2 + [TARGET_NR_renameat2] = impl_renameat2, +#endif #ifdef TARGET_NR_stime [TARGET_NR_stime] = impl_stime, #endif