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: 18452 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 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 +}