From patchwork Sun Jun 10 03:00:55 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 138091 Delivered-To: patch@linaro.org Received: by 2002:a2e:970d:0:0:0:0:0 with SMTP id r13-v6csp2580057lji; Sat, 9 Jun 2018 20:13:57 -0700 (PDT) X-Google-Smtp-Source: ADUXVKKJkjeKYsobNHhsuKulZkCW+UFiOr4XrafQb3CxkGyaxBpCeDmfROlQIo1CUKOJPjZJhwUW X-Received: by 2002:ac8:1a57:: with SMTP id q23-v6mr11788172qtk.297.1528600436957; Sat, 09 Jun 2018 20:13:56 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1528600436; cv=none; d=google.com; s=arc-20160816; b=Izo6ECF/K4djfddS5rAYRjXc8mMX4d7VP8xmlQPZA4udOnm8UAoGqGlf0c7TiN/Gf+ o/wtvryUnT7bZDAACzPUDhc09kKMBuS6p7Zir2oQI1/tTAS8e7kqSO9m3bPwpfVgOHhW ZVr22V4LjxUAlrBrS8tYRSuWd5SCmfxq2qAUAKoa+oK1b+pcWCTwk5cFqLaZkZVi5C00 QoLGFTYg/QHT9fR6TAF0+T/Dpy3ljIOPHSsctJPyD0FTh30Pn8VNz7aJJWL9VMI/Qv9G Sh+WwHMjdkVocK2ukYjqIBkz9LUzWgxcQbeS/Si7TQzel737H5K5HRbTNxmhYp4/gh31 Tz2A== 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=WzmxZGdBvDscGIP/VGLn2OBk+WbNmgR42R8XKXkR1x4=; b=HOJg5GpKx4N9oz2bUP6TnP48Ts9oRdatfeAJ6OZ+6RIzMqvKacpyqahvto+16Xy4qi mJ1lD8XME6mrHdHJaBt/UkLE2jw+ql1rTE0FSuS5M692sUzyg82KwTvTff9LgFDyX662 lw9uhDbr9XDbWFAi2XwZLWaQ+m4jtelNBea6vCyQRKs7VcMNV2qzzkb/dBpr83XJJu/4 RB2q9KPAw3wHL1cD2DC78i9gZ3nkadZfcbqQdSv1TuDzaNWq83t3ZCojl9A3+BHbAxjC O3NwoIzxEZmYX7ysIZG4CaLqg2khx8uXCvs578kEqeyu/bi+MauDjzHOigvybke/wAY9 JiCw== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=cog0wfr3; 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 u10-v6si13317099qkk.26.2018.06.09.20.13.56 for (version=TLS1 cipher=AES128-SHA bits=128/128); Sat, 09 Jun 2018 20:13:56 -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=cog0wfr3; 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]:42230 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fRqnk-000328-DZ for patch@linaro.org; Sat, 09 Jun 2018 23:13:56 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:40339) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fRqdR-00028L-T7 for qemu-devel@nongnu.org; Sat, 09 Jun 2018 23:03:19 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fRqdQ-0003N1-SK for qemu-devel@nongnu.org; Sat, 09 Jun 2018 23:03:17 -0400 Received: from mail-pl0-x244.google.com ([2607:f8b0:400e:c01::244]:34528) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1fRqdQ-0003Mc-M9 for qemu-devel@nongnu.org; Sat, 09 Jun 2018 23:03:16 -0400 Received: by mail-pl0-x244.google.com with SMTP id g20-v6so10400192plq.1 for ; Sat, 09 Jun 2018 20:03:16 -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=WzmxZGdBvDscGIP/VGLn2OBk+WbNmgR42R8XKXkR1x4=; b=cog0wfr38kxOu8tWF6dRDl+hE1TEVnkqQnhqjIGt440ia6K4MGUjK1Z1FgIKQoQdfh z1QtxqFEPupMH+o9/dkkfK6aZrq0NZbe61xmiYFC0kw+In/aECzoloH8UpGODpUHkzcr XQAjcP2VEqWzbFv/f0PbemyHVBOgjp9+LwXiA= 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=WzmxZGdBvDscGIP/VGLn2OBk+WbNmgR42R8XKXkR1x4=; b=QMd8P7epOFxBPD0DPOWBuy7HLUl2cza5CqmT9NP59Cb2N15Eo4ypYjRu7DZ9k7VEY0 XBotphS+0qga+Ls2W/9keJ1Fj4A0ggzPR7P4nyNhUZbNAUY41n15T579XktZwvUkIcEZ guBKLMtTcWQFOQipCp075NQOzaaN76dFHdMBjAngtxZYU3zXWSKO5kIMLR8wNV5+j9Ya oanOJUe9odP4rsrbvXmX4opiWdvOXYlU8EUkFtji0anXdkH3qjbLSdJS9WwzIYtSEsk1 vm+U6WkSH0aYTQaGfZo8nvhGjo8tvS3eveauC2bEblgb9GUKR62J3VxIiY5252KOg3Fq A8rw== X-Gm-Message-State: APt69E1/VuBphwAWfGR4QOmMlIs9Uz39AdbzKxFXbdOVPfZfuRpxRzBf oQQHFU7ZkbGsgyAhuk4gkb+doz9uw+4= X-Received: by 2002:a17:902:9f84:: with SMTP id g4-v6mr12918048plq.339.1528599795369; Sat, 09 Jun 2018 20:03:15 -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.12 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Sat, 09 Jun 2018 20:03:14 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Date: Sat, 9 Jun 2018 17:00:55 -1000 Message-Id: <20180610030220.3777-24-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 023/108] 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" All targets define renameat2; remove the ifdefs. Signed-off-by: Richard Henderson --- linux-user/syscall.c | 101 +++++++++++++++++++++++-------------------- 1 file changed, 53 insertions(+), 48 deletions(-) -- 2.17.1 diff --git a/linux-user/syscall.c b/linux-user/syscall.c index 6729a960ea..e0a5d86956 100644 --- a/linux-user/syscall.c +++ b/linux-user/syscall.c @@ -628,7 +628,6 @@ static int sys_utimensat(int dirfd, const char *pathname, #endif #endif /* TARGET_NR_utimensat */ -#ifdef TARGET_NR_renameat2 #if defined(__NR_renameat2) #define __NR_sys_renameat2 __NR_renameat2 _syscall5(int, sys_renameat2, int, oldfd, const char *, old, int, newfd, @@ -644,7 +643,6 @@ static int sys_renameat2(int oldfd, const char *old, return -1; } #endif -#endif /* TARGET_NR_renameat2 */ #ifdef CONFIG_INOTIFY #include @@ -8420,6 +8418,52 @@ 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 + +#ifdef TARGET_NR_renameat +IMPL(renameat) +{ + 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 + +IMPL(renameat2) +{ + 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; +} + #ifdef TARGET_NR_stime IMPL(stime) { @@ -8621,52 +8665,6 @@ static abi_long do_syscall1(void *cpu_env, unsigned num, abi_long arg1, void *p; 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: - { - 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: - { - 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))) @@ -12626,6 +12624,13 @@ static impl_fn *syscall_table(unsigned num) SYSCALL(pause); #endif SYSCALL(read); +#ifdef TARGET_NR_rename + SYSCALL(rename); +#endif +#ifdef TARGET_NR_renameat + SYSCALL(renameat); +#endif + SYSCALL(renameat2); #ifdef TARGET_NR_stime SYSCALL(stime); #endif