From patchwork Wed Dec 14 14:12:01 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Adhemerval Zanella Netto X-Patchwork-Id: 88031 Delivered-To: patch@linaro.org Received: by 10.140.20.101 with SMTP id 92csp215172qgi; Wed, 14 Dec 2016 06:12:46 -0800 (PST) X-Received: by 10.84.214.1 with SMTP id h1mr211764405pli.47.1481724766579; Wed, 14 Dec 2016 06:12:46 -0800 (PST) Return-Path: Received: from sourceware.org (server1.sourceware.org. [209.132.180.131]) by mx.google.com with ESMTPS id s68si52937995pfi.277.2016.12.14.06.12.46 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 14 Dec 2016 06:12:46 -0800 (PST) Received-SPF: pass (google.com: domain of libc-alpha-return-75869-patch=linaro.org@sourceware.org designates 209.132.180.131 as permitted sender) client-ip=209.132.180.131; Authentication-Results: mx.google.com; dkim=pass header.i=@sourceware.org; spf=pass (google.com: domain of libc-alpha-return-75869-patch=linaro.org@sourceware.org designates 209.132.180.131 as permitted sender) smtp.mailfrom=libc-alpha-return-75869-patch=linaro.org@sourceware.org; dmarc=fail (p=NONE dis=NONE) header.from=linaro.org DomainKey-Signature: a=rsa-sha1; c=nofws; d=sourceware.org; h=list-id :list-unsubscribe:list-subscribe:list-archive:list-post :list-help:sender:from:to:subject:date:message-id; q=dns; s= default; b=U3WVuMU7A4dt7za+yjNnLpICbQJHTd3HlD4t5imO3iw+xHADH/EVf QtNACjlBJzddTa2NsoDhg6i1LHMkwXgyjOfXMme7SBgPjqY4CM1zD6uqLdZkm8kd oU+NI88YUKQlCAJymGAJdrCAlH/Z8Nu7OoDSD+MpYhMfXaBQbCffVA= DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=sourceware.org; h=list-id :list-unsubscribe:list-subscribe:list-archive:list-post :list-help:sender:from:to:subject:date:message-id; s=default; bh=4J8pUmEpblMy2OO5UXC3f7X2xIE=; b=x/wLsClmZTo4wXImYCBAbZSKje6K OZ4K6akuLUGgsw3VbaJZp76bAfc6Az4Ggg7qKKXEMr1WGK7FKl2XkmAnm1piVkW+ UPRxjNvMfyAEh0uAk3keMWXLk5GjH2X2FNT5E09QxJ466fyjK0pL0ce7OlKZoZsF fZu+rLCRnsicchA= Received: (qmail 71671 invoked by alias); 14 Dec 2016 14:12:25 -0000 Mailing-List: contact libc-alpha-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: libc-alpha-owner@sourceware.org Delivered-To: mailing list libc-alpha@sourceware.org Received: (qmail 71624 invoked by uid 89); 14 Dec 2016 14:12:21 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-1.9 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_NONE, SPF_PASS autolearn=ham version=3.3.2 spammy=errnoh, errno.h, UD:errno.h, 1, 35 X-HELO: mail-vk0-f45.google.com X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:subject:date:message-id; bh=ugb+pOefMoCe4nPFN6DrSdPgRPbvCLUx60h8+S/L6C0=; b=N6mm5zqX97lz2S+4PzJ6oyAgedWjHvbjbkvAz8DK8XWZu7Fdk0ZXaBZhh/Fg+FIcJV ezhE16/UbFEiTCteYeEu06iuq9olgdqvaP9L9v4Fm0T0ebGy6vLKcYhqZB0MOC5nQd+/ FMtfqBOJmwFjVGF/vPMwJQlBRue0z7iEbbkYf/9HVmAjxeTaEpe/+DXto3SotyeeDtYO SqTkhhldC3XtEtfoNQeTlBR1w7JW5Kok2uh98jxptCBWMXgGXC54aD2thHA/vaukU1iz kVbEeFCix/D/VQu50cIyaAYcYJlT4MGjVE/n41rq4RX3NfC+5BjCY5K1+DIw4ugRr4vs BQHw== X-Gm-Message-State: AKaTC028qlQXmmhsVX9SEZuxFq6vwkl9jUDfD68ySSa/jak0ZXmdMiDcCF+iCW1iQS1oOx91 X-Received: by 10.159.36.244 with SMTP id 107mr72507073uar.51.1481724728926; Wed, 14 Dec 2016 06:12:08 -0800 (PST) From: Adhemerval Zanella To: libc-alpha@sourceware.org Subject: [PATCH 1/2] Consolidate rename Linux implementation Date: Wed, 14 Dec 2016 12:12:01 -0200 Message-Id: <1481724722-30103-1-git-send-email-adhemerval.zanella@linaro.org> This patch consolidates the Linux rename implementation on sysdeps/unix/sysv/linux/rename.c. Current code try to use __NR_rename if is defined and apply the same strategy for __NR_renameat and __NR_renameat2. Check on x86_64 and aarch64. * sysdeps/unix/sysv/linux/rename.c: New file. * sysdeps/unix/sysv/linux/generic/rename.c: Remove file. --- ChangeLog | 5 +++++ sysdeps/unix/sysv/linux/generic/rename.c | 29 -------------------------- sysdeps/unix/sysv/linux/rename.c | 35 ++++++++++++++++++++++++++++++++ 3 files changed, 40 insertions(+), 29 deletions(-) delete mode 100644 sysdeps/unix/sysv/linux/generic/rename.c create mode 100644 sysdeps/unix/sysv/linux/rename.c -- 2.7.4 diff --git a/sysdeps/unix/sysv/linux/generic/rename.c b/sysdeps/unix/sysv/linux/generic/rename.c deleted file mode 100644 index 174c147..0000000 --- a/sysdeps/unix/sysv/linux/generic/rename.c +++ /dev/null @@ -1,29 +0,0 @@ -/* Copyright (C) 2011-2016 Free Software Foundation, Inc. - This file is part of the GNU C Library. - Contributed by Chris Metcalf , 2011. - - The GNU C Library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) any later version. - - The GNU C Library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with the GNU C Library. If not, see - . */ - -#include -#include -#include -#include - -/* Rename the file OLD to NEW. */ -int -rename (const char *old, const char *new) -{ - return INLINE_SYSCALL (renameat, 4, AT_FDCWD, old, AT_FDCWD, new); -} diff --git a/sysdeps/unix/sysv/linux/rename.c b/sysdeps/unix/sysv/linux/rename.c new file mode 100644 index 0000000..c068346 --- /dev/null +++ b/sysdeps/unix/sysv/linux/rename.c @@ -0,0 +1,35 @@ +/* Linux implementation for rename function. + Copyright (C) 2016 Free Software Foundation, Inc. + This file is part of the GNU C Library. + + The GNU C Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + The GNU C Library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with the GNU C Library. If not, see + . */ + +#include +#include +#include +#include + +/* Rename the file OLD to NEW. */ +int +rename (const char *old, const char *new) +{ +#if defined(__NR_rename) + return INLINE_SYSCALL_CALL (rename, old, new); +#elif defined (__NR_renameat) + return INLINE_SYSCALL_CALL (renameat, AT_FDCWD, old, AT_FDCWD, new); +#else + return INLINE_SYSCALL_CALL (renameat2, AT_FDCWD, old, AT_FDCWD, new, 0); +#endif +}