8d0e4d
From 57ee8db4fee8eb6772df1ff18d275594c0b034d4 Mon Sep 17 00:00:00 2001
8d0e4d
From: Paul Eggert <eggert@cs.ucla.edu>
8d0e4d
Date: Thu, 5 Jul 2018 09:22:09 -0700
8d0e4d
Subject: [PATCH 1/2] renameatu: rename from renameat2
8d0e4d
8d0e4d
It's looking like Glibc will add a renameat2 function
8d0e4d
that is incompatible with Gnulib renameat2; see:
8d0e4d
https://sourceware.org/ml/libc-alpha/2018-07/msg00064.html
8d0e4d
To help avoid future confusion, rename renameat2 to something else.
8d0e4d
Use the name 'renameatu', as the Gnulib function is close to the
8d0e4d
Glibc function.  Perhaps someday there will also be a renameat2
8d0e4d
Gnulib module, which mimicks the future glibc renameat2, but that
8d0e4d
can wait as nobody seems to need such a module now.
8d0e4d
* NEWS: Mention this.
8d0e4d
* lib/renameatu.c: Rename from lib/renameat2.c.
8d0e4d
* lib/renameatu.h: Rename from lib/renameat2.h.
8d0e4d
* modules/renameatu: Rename from modules/renameat2.
8d0e4d
* modules/renameatu-tests: Rename from modules/renameat2-tests.
8d0e4d
All uses of "renameat2" in identifiers or file name
8d0e4d
changed to "renameatu", except for two instances in
8d0e4d
lib/renameatu.c that deal with the Linux kernel's
8d0e4d
renameat2 syscall.
8d0e4d
8d0e4d
Upstream-commit: 2522322e5304e7d86c63e607e2bc83c8d8b0a889
8d0e4d
Signed-off-by: Kamil Dudka <kdudka@redhat.com>
8d0e4d
---
8d0e4d
 gnulib-tests/gnulib.mk                             | 12 +++---
8d0e4d
 .../{test-renameat2.c => test-renameatu.c}         | 48 +++++++++++-----------
8d0e4d
 lib/backupfile.c                                   |  4 +-
8d0e4d
 lib/gnulib.mk                                      | 10 ++---
8d0e4d
 lib/renameat.c                                     |  4 +-
8d0e4d
 lib/{renameat2.c => renameatu.c}                   |  9 ++--
8d0e4d
 lib/{renameat2.h => renameatu.h}                   |  8 ++--
8d0e4d
 7 files changed, 48 insertions(+), 47 deletions(-)
8d0e4d
 rename gnulib-tests/{test-renameat2.c => test-renameatu.c} (80%)
8d0e4d
 rename lib/{renameat2.c => renameatu.c} (94%)
8d0e4d
 rename lib/{renameat2.h => renameatu.h} (84%)
8d0e4d
8d0e4d
diff --git a/gnulib-tests/gnulib.mk b/gnulib-tests/gnulib.mk
8d0e4d
index be2b99e..891425b 100644
8d0e4d
--- a/gnulib-tests/gnulib.mk
8d0e4d
+++ b/gnulib-tests/gnulib.mk
8d0e4d
@@ -1750,14 +1750,14 @@ EXTRA_DIST += test-rename.h test-renameat.c signature.h macros.h
8d0e4d
 
8d0e4d
 ## end   gnulib module renameat-tests
8d0e4d
 
8d0e4d
-## begin gnulib module renameat2-tests
8d0e4d
+## begin gnulib module renameatu-tests
8d0e4d
 
8d0e4d
-TESTS += test-renameat2
8d0e4d
-check_PROGRAMS += test-renameat2
8d0e4d
-test_renameat2_LDADD = $(LDADD) @LIBINTL@
8d0e4d
-EXTRA_DIST += test-rename.h test-renameat2.c signature.h macros.h
8d0e4d
+TESTS += test-renameatu
8d0e4d
+check_PROGRAMS += test-renameatu
8d0e4d
+test_renameatu_LDADD = $(LDADD) @LIBINTL@
8d0e4d
+EXTRA_DIST += test-rename.h test-renameatu.c signature.h macros.h
8d0e4d
 
8d0e4d
-## end   gnulib module renameat2-tests
8d0e4d
+## end   gnulib module renameatu-tests
8d0e4d
 
8d0e4d
 ## begin gnulib module rmdir-tests
8d0e4d
 
8d0e4d
diff --git a/gnulib-tests/test-renameat2.c b/gnulib-tests/test-renameatu.c
8d0e4d
similarity index 80%
8d0e4d
rename from gnulib-tests/test-renameat2.c
8d0e4d
rename to gnulib-tests/test-renameatu.c
8d0e4d
index 0104890..988428b 100644
8d0e4d
--- a/gnulib-tests/test-renameat2.c
8d0e4d
+++ b/gnulib-tests/test-renameatu.c
8d0e4d
@@ -1,4 +1,4 @@
8d0e4d
-/* Test renameat2.
8d0e4d
+/* Test renameatu.
8d0e4d
    Copyright (C) 2009-2018 Free Software Foundation, Inc.
8d0e4d
 
8d0e4d
    This program is free software: you can redistribute it and/or modify
8d0e4d
@@ -18,12 +18,12 @@
8d0e4d
 
8d0e4d
 #include <config.h>
8d0e4d
 
8d0e4d
-#include <renameat2.h>
8d0e4d
+#include <renameatu.h>
8d0e4d
 
8d0e4d
 #include <stdio.h>
8d0e4d
 
8d0e4d
 #include "signature.h"
8d0e4d
-SIGNATURE_CHECK (renameat2, int,
8d0e4d
+SIGNATURE_CHECK (renameatu, int,
8d0e4d
                  (int, char const *, int, char const *, unsigned int));
8d0e4d
 
8d0e4d
 #include <dirent.h>
8d0e4d
@@ -39,18 +39,18 @@ SIGNATURE_CHECK (renameat2, int,
8d0e4d
 #include "ignore-value.h"
8d0e4d
 #include "macros.h"
8d0e4d
 
8d0e4d
-#define BASE "test-renameat2.t"
8d0e4d
+#define BASE "test-renameatu.t"
8d0e4d
 
8d0e4d
 #include "test-rename.h"
8d0e4d
 
8d0e4d
 static int dfd1 = AT_FDCWD;
8d0e4d
 static int dfd2 = AT_FDCWD;
8d0e4d
 
8d0e4d
-/* Wrapper to test renameat2 like rename.  */
8d0e4d
+/* Wrapper to test renameatu like rename.  */
8d0e4d
 static int
8d0e4d
 do_rename (char const *name1, char const *name2)
8d0e4d
 {
8d0e4d
-  return renameat2 (dfd1, name1, dfd2, name2, 0);
8d0e4d
+  return renameatu (dfd1, name1, dfd2, name2, 0);
8d0e4d
 }
8d0e4d
 
8d0e4d
 int
8d0e4d
@@ -67,24 +67,24 @@ main (void)
8d0e4d
   /* Test behaviour for invalid file descriptors.  */
8d0e4d
   {
8d0e4d
     errno = 0;
8d0e4d
-    ASSERT (renameat2 (-1, "foo", AT_FDCWD, "bar", 0) == -1);
8d0e4d
+    ASSERT (renameatu (-1, "foo", AT_FDCWD, "bar", 0) == -1);
8d0e4d
     ASSERT (errno == EBADF);
8d0e4d
   }
8d0e4d
   {
8d0e4d
     close (99);
8d0e4d
     errno = 0;
8d0e4d
-    ASSERT (renameat2 (99, "foo", AT_FDCWD, "bar", 0) == -1);
8d0e4d
+    ASSERT (renameatu (99, "foo", AT_FDCWD, "bar", 0) == -1);
8d0e4d
     ASSERT (errno == EBADF);
8d0e4d
   }
8d0e4d
   ASSERT (close (creat (BASE "oo", 0600)) == 0);
8d0e4d
   {
8d0e4d
     errno = 0;
8d0e4d
-    ASSERT (renameat2 (AT_FDCWD, BASE "oo", -1, "bar", 0) == -1);
8d0e4d
+    ASSERT (renameatu (AT_FDCWD, BASE "oo", -1, "bar", 0) == -1);
8d0e4d
     ASSERT (errno == EBADF);
8d0e4d
   }
8d0e4d
   {
8d0e4d
     errno = 0;
8d0e4d
-    ASSERT (renameat2 (AT_FDCWD, BASE "oo", 99, "bar", 0) == -1);
8d0e4d
+    ASSERT (renameatu (AT_FDCWD, BASE "oo", 99, "bar", 0) == -1);
8d0e4d
     ASSERT (errno == EBADF);
8d0e4d
   }
8d0e4d
   ASSERT (unlink (BASE "oo") == 0);
8d0e4d
@@ -133,13 +133,13 @@ main (void)
8d0e4d
 
8d0e4d
       ASSERT (sprintf (strchr (file1, '\0') - 2, "%02d", i) == 2);
8d0e4d
       ASSERT (sprintf (strchr (file2, '\0') - 2, "%02d", i + 1) == 2);
8d0e4d
-      ASSERT (renameat2 (fd1, file1, fd2, file2, 0) == 0);
8d0e4d
+      ASSERT (renameatu (fd1, file1, fd2, file2, 0) == 0);
8d0e4d
       free (file1);
8d0e4d
       free (file2);
8d0e4d
     }
8d0e4d
   dfd2 = open ("..", O_RDONLY);
8d0e4d
   ASSERT (0 <= dfd2);
8d0e4d
-  ASSERT (renameat2 (dfd, "../" BASE "16", dfd2, BASE "17", 0) == 0);
8d0e4d
+  ASSERT (renameatu (dfd, "../" BASE "16", dfd2, BASE "17", 0) == 0);
8d0e4d
   ASSERT (close (dfd2) == 0);
8d0e4d
 
8d0e4d
   /* Now we change back to the parent directory, and set dfd to ".";
8d0e4d
@@ -152,47 +152,47 @@ main (void)
8d0e4d
 
8d0e4d
   ASSERT (close (creat (BASE "sub2/file", 0600)) == 0);
8d0e4d
   errno = 0;
8d0e4d
-  ASSERT (renameat2 (dfd, BASE "sub1", dfd, BASE "sub2", 0) == -1);
8d0e4d
+  ASSERT (renameatu (dfd, BASE "sub1", dfd, BASE "sub2", 0) == -1);
8d0e4d
   ASSERT (errno == EEXIST || errno == ENOTEMPTY);
8d0e4d
   ASSERT (unlink (BASE "sub2/file") == 0);
8d0e4d
   errno = 0;
8d0e4d
-  ASSERT (renameat2 (dfd, BASE "sub2", dfd, BASE "sub1/.", 0) == -1);
8d0e4d
+  ASSERT (renameatu (dfd, BASE "sub2", dfd, BASE "sub1/.", 0) == -1);
8d0e4d
   ASSERT (errno == EINVAL || errno == EISDIR || errno == EBUSY
8d0e4d
           || errno == ENOTEMPTY || errno == EEXIST
8d0e4d
           || errno == ENOENT /* WSL */);
8d0e4d
   errno = 0;
8d0e4d
-  ASSERT (renameat2 (dfd, BASE "sub2/.", dfd, BASE "sub1", 0) == -1);
8d0e4d
+  ASSERT (renameatu (dfd, BASE "sub2/.", dfd, BASE "sub1", 0) == -1);
8d0e4d
   ASSERT (errno == EINVAL || errno == EBUSY || errno == EEXIST
8d0e4d
           || errno == ENOENT /* WSL */);
8d0e4d
   errno = 0;
8d0e4d
-  ASSERT (renameat2 (dfd, BASE "17", dfd, BASE "sub1", 0) == -1);
8d0e4d
+  ASSERT (renameatu (dfd, BASE "17", dfd, BASE "sub1", 0) == -1);
8d0e4d
   ASSERT (errno == EISDIR);
8d0e4d
   errno = 0;
8d0e4d
-  ASSERT (renameat2 (dfd, BASE "nosuch", dfd, BASE "18", 0) == -1);
8d0e4d
+  ASSERT (renameatu (dfd, BASE "nosuch", dfd, BASE "18", 0) == -1);
8d0e4d
   ASSERT (errno == ENOENT);
8d0e4d
   errno = 0;
8d0e4d
-  ASSERT (renameat2 (dfd, "", dfd, BASE "17", 0) == -1);
8d0e4d
+  ASSERT (renameatu (dfd, "", dfd, BASE "17", 0) == -1);
8d0e4d
   ASSERT (errno == ENOENT);
8d0e4d
   errno = 0;
8d0e4d
-  ASSERT (renameat2 (dfd, BASE "17", dfd, "", 0) == -1);
8d0e4d
+  ASSERT (renameatu (dfd, BASE "17", dfd, "", 0) == -1);
8d0e4d
   ASSERT (errno == ENOENT);
8d0e4d
   errno = 0;
8d0e4d
-  ASSERT (renameat2 (dfd, BASE "sub2", dfd, BASE "17", 0) == -1);
8d0e4d
+  ASSERT (renameatu (dfd, BASE "sub2", dfd, BASE "17", 0) == -1);
8d0e4d
   ASSERT (errno == ENOTDIR);
8d0e4d
   errno = 0;
8d0e4d
-  ASSERT (renameat2 (dfd, BASE "17/", dfd, BASE "18", 0) == -1);
8d0e4d
+  ASSERT (renameatu (dfd, BASE "17/", dfd, BASE "18", 0) == -1);
8d0e4d
   ASSERT (errno == ENOTDIR);
8d0e4d
   errno = 0;
8d0e4d
-  ASSERT (renameat2 (dfd, BASE "17", dfd, BASE "18/", 0) == -1);
8d0e4d
+  ASSERT (renameatu (dfd, BASE "17", dfd, BASE "18/", 0) == -1);
8d0e4d
   ASSERT (errno == ENOTDIR || errno == ENOENT);
8d0e4d
 
8d0e4d
   /* Finally, make sure we cannot overwrite existing files.  */
8d0e4d
   ASSERT (close (creat (BASE "sub2/file", 0600)) == 0);
8d0e4d
   errno = 0;
8d0e4d
-  ASSERT ((renameat2 (dfd, BASE "sub2", dfd, BASE "sub1", RENAME_NOREPLACE)
8d0e4d
+  ASSERT ((renameatu (dfd, BASE "sub2", dfd, BASE "sub1", RENAME_NOREPLACE)
8d0e4d
            == -1)
8d0e4d
           && errno == EEXIST);
8d0e4d
-  ASSERT ((renameat2 (dfd, BASE "sub2/file", dfd, BASE "17", RENAME_NOREPLACE)
8d0e4d
+  ASSERT ((renameatu (dfd, BASE "sub2/file", dfd, BASE "17", RENAME_NOREPLACE)
8d0e4d
            == -1)
8d0e4d
           && errno == EEXIST);
8d0e4d
 
8d0e4d
diff --git a/lib/backupfile.c b/lib/backupfile.c
8d0e4d
index d438455..637be6c 100644
8d0e4d
--- a/lib/backupfile.c
8d0e4d
+++ b/lib/backupfile.c
8d0e4d
@@ -23,7 +23,7 @@
8d0e4d
 #include "backup-internal.h"
8d0e4d
 
8d0e4d
 #include "dirname.h"
8d0e4d
-#include "renameat2.h"
8d0e4d
+#include "renameatu.h"
8d0e4d
 #include "xalloc-oversized.h"
8d0e4d
 
8d0e4d
 #include <fcntl.h>
8d0e4d
@@ -353,7 +353,7 @@ backupfile_internal (char const *file, enum backup_type backup_type, bool rename
8d0e4d
           base_offset = 0;
8d0e4d
         }
8d0e4d
       unsigned flags = backup_type == simple_backups ? 0 : RENAME_NOREPLACE;
8d0e4d
-      if (renameat2 (AT_FDCWD, file, sdir, s + base_offset, flags) == 0)
8d0e4d
+      if (renameatu (AT_FDCWD, file, sdir, s + base_offset, flags) == 0)
8d0e4d
         break;
8d0e4d
       int e = errno;
8d0e4d
       if (e != EEXIST)
8d0e4d
diff --git a/lib/gnulib.mk b/lib/gnulib.mk
8d0e4d
index 04473d5..0b747e3 100644
8d0e4d
--- a/lib/gnulib.mk
8d0e4d
+++ b/lib/gnulib.mk
8d0e4d
@@ -21,7 +21,7 @@
8d0e4d
 # the same distribution terms as the rest of that program.
8d0e4d
 #
8d0e4d
 # Generated by gnulib-tool.
8d0e4d
-# Reproduce by: gnulib-tool --import --local-dir=gl --lib=libcoreutils --source-base=lib --m4-base=m4 --doc-base=doc --tests-base=gnulib-tests --aux-dir=build-aux --with-tests --avoid=canonicalize-lgpl --avoid=dummy --makefile-name=gnulib.mk --no-conditional-dependencies --no-libtool --macro-prefix=gl acl alignof alloca announce-gen areadlink-with-size argmatch argv-iter assert autobuild backup-rename backupfile base32 base64 buffer-lcm c-strcase c-strtod c-strtold calloc-gnu canon-host canonicalize chown cloexec closein closeout config-h configmake crypto/md5 crypto/sha1 crypto/sha256 crypto/sha512 cycle-check d-ino d-type di-set diacrit dirfd dirname do-release-commit-and-tag dtoastr dup2 environ error euidaccess exclude exitfail explicit_bzero faccessat fadvise fchdir fchmodat fchownat fclose fcntl fcntl-safer fd-reopen fdatasync fdl fdopen fdutimensat file-has-acl file-type fileblocks filemode filenamecat filevercmp flexmember fnmatch-gnu fopen-safer fprintftime freopen freopen-safer fseeko fstatat fsusage fsync ftoastr ftruncate fts full-read full-write getgroups gethrxtime getline getloadavg getlogin getndelim2 getopt-gnu getpagesize getpass-gnu gettext-h gettime gettimeofday getugroups getusershell git-version-gen gitlog-to-changelog gnu-make gnu-web-doc-update gnumakefile gnupload group-member hard-locale hash hash-pjw heap host-os human idcache ignore-value inttostr inttypes isapipe isatty isblank largefile lchmod lchown ldtoastr lib-ignore linebuffer link link-follow linkat long-options lstat maintainer-makefile malloc-gnu manywarnings mbrlen mbrtowc mbsalign mbschr mbslen mbswidth memcasecmp memchr memcmp2 mempcpy memrchr mgetgroups mkancesdirs mkdir mkdir-p mkfifo mknod mkostemp mkstemp mktime modechange mountlist mpsort netinet_in non-recursive-gnulib-prefix-hack nproc nstrftime obstack open parse-datetime pathmax perl physmem pipe-posix pipe2 posix-shell posixtm posixver priv-set progname propername pthread putenv quote quotearg randint randperm read-file readlink readtokens readtokens0 readutmp realloc-gnu regex remove rename renameat renameat2 rmdir root-dev-ino rpmatch safe-read same save-cwd savedir savewd selinux-at setenv settime sig2str sigaction smack ssize_t stat-macros stat-size stat-time statat stdbool stdlib-safer stpcpy stpncpy strdup-posix strncat strnumcmp strsignal strtod strtoimax strtoumax symlinkat sys_ioctl sys_resource sys_stat sys_wait tempname termios time_rz timer-time timespec tzset uname unicodeio unistd-safer unlink-busy unlinkat unlocked-io unsetenv update-copyright uptime useless-if-before-free userspec utimecmp utimens vasprintf-posix vc-list-files verify verror version-etc-fsf wchar-single wcswidth wcwidth winsz-ioctl winsz-termios write-any-file xalloc xbinary-io xdectoint xfts xgetcwd xgetgroups xgethostname xmemcoll xnanosleep xprintf xprintf-posix xreadlink xstrtod xstrtoimax xstrtol xstrtold xstrtoumax year2038 yesno
8d0e4d
+# Reproduce by: gnulib-tool --import --local-dir=gl --lib=libcoreutils --source-base=lib --m4-base=m4 --doc-base=doc --tests-base=gnulib-tests --aux-dir=build-aux --with-tests --avoid=canonicalize-lgpl --avoid=dummy --makefile-name=gnulib.mk --no-conditional-dependencies --no-libtool --macro-prefix=gl acl alignof alloca announce-gen areadlink-with-size argmatch argv-iter assert autobuild backup-rename backupfile base32 base64 buffer-lcm c-strcase c-strtod c-strtold calloc-gnu canon-host canonicalize chown cloexec closein closeout config-h configmake crypto/md5 crypto/sha1 crypto/sha256 crypto/sha512 cycle-check d-ino d-type di-set diacrit dirfd dirname do-release-commit-and-tag dtoastr dup2 environ error euidaccess exclude exitfail explicit_bzero faccessat fadvise fchdir fchmodat fchownat fclose fcntl fcntl-safer fd-reopen fdatasync fdl fdopen fdutimensat file-has-acl file-type fileblocks filemode filenamecat filevercmp flexmember fnmatch-gnu fopen-safer fprintftime freopen freopen-safer fseeko fstatat fsusage fsync ftoastr ftruncate fts full-read full-write getgroups gethrxtime getline getloadavg getlogin getndelim2 getopt-gnu getpagesize getpass-gnu gettext-h gettime gettimeofday getugroups getusershell git-version-gen gitlog-to-changelog gnu-make gnu-web-doc-update gnumakefile gnupload group-member hard-locale hash hash-pjw heap host-os human idcache ignore-value inttostr inttypes isapipe isatty isblank largefile lchmod lchown ldtoastr lib-ignore linebuffer link link-follow linkat long-options lstat maintainer-makefile malloc-gnu manywarnings mbrlen mbrtowc mbsalign mbschr mbslen mbswidth memcasecmp memchr memcmp2 mempcpy memrchr mgetgroups mkancesdirs mkdir mkdir-p mkfifo mknod mkostemp mkstemp mktime modechange mountlist mpsort netinet_in non-recursive-gnulib-prefix-hack nproc nstrftime obstack open parse-datetime pathmax perl physmem pipe-posix pipe2 posix-shell posixtm posixver priv-set progname propername pthread putenv quote quotearg randint randperm read-file readlink readtokens readtokens0 readutmp realloc-gnu regex remove rename renameat renameatu rmdir root-dev-ino rpmatch safe-read same save-cwd savedir savewd selinux-at setenv settime sig2str sigaction smack ssize_t stat-macros stat-size stat-time statat stdbool stdlib-safer stpcpy stpncpy strdup-posix strncat strnumcmp strsignal strtod strtoimax strtoumax symlinkat sys_ioctl sys_resource sys_stat sys_wait tempname termios time_rz timer-time timespec tzset uname unicodeio unistd-safer unlink-busy unlinkat unlocked-io unsetenv update-copyright uptime useless-if-before-free userspec utimecmp utimens vasprintf-posix vc-list-files verify verror version-etc-fsf wchar-single wcswidth wcwidth winsz-ioctl winsz-termios write-any-file xalloc xbinary-io xdectoint xfts xgetcwd xgetgroups xgethostname xmemcoll xnanosleep xprintf xprintf-posix xreadlink xstrtod xstrtoimax xstrtol xstrtold xstrtoumax year2038 yesno
8d0e4d
 
8d0e4d
 
8d0e4d
 MOSTLYCLEANFILES += lib/core lib/*.stackdump
8d0e4d
@@ -3218,15 +3218,15 @@ EXTRA_lib_libcoreutils_a_SOURCES += lib/renameat.c
8d0e4d
 
8d0e4d
 ## end   gnulib module renameat
8d0e4d
 
8d0e4d
-## begin gnulib module renameat2
8d0e4d
+## begin gnulib module renameatu
8d0e4d
 
8d0e4d
-lib_libcoreutils_a_SOURCES += lib/renameat2.c
8d0e4d
+lib_libcoreutils_a_SOURCES += lib/renameatu.c
8d0e4d
 
8d0e4d
-EXTRA_DIST += lib/at-func2.c lib/renameat2.h
8d0e4d
+EXTRA_DIST += lib/at-func2.c lib/renameatu.h
8d0e4d
 
8d0e4d
 EXTRA_lib_libcoreutils_a_SOURCES += lib/at-func2.c
8d0e4d
 
8d0e4d
-## end   gnulib module renameat2
8d0e4d
+## end   gnulib module renameatu
8d0e4d
 
8d0e4d
 ## begin gnulib module rewinddir
8d0e4d
 
8d0e4d
diff --git a/lib/renameat.c b/lib/renameat.c
8d0e4d
index 0cb7d33..67be22b 100644
8d0e4d
--- a/lib/renameat.c
8d0e4d
+++ b/lib/renameat.c
8d0e4d
@@ -16,10 +16,10 @@
8d0e4d
 
8d0e4d
 #include <config.h>
8d0e4d
 #include <stdio.h>
8d0e4d
-#include "renameat2.h"
8d0e4d
+#include "renameatu.h"
8d0e4d
 
8d0e4d
 int
8d0e4d
 renameat (int fd1, char const *src, int fd2, char const *dst)
8d0e4d
 {
8d0e4d
-  return renameat2 (fd1, src, fd2, dst, 0);
8d0e4d
+  return renameatu (fd1, src, fd2, dst, 0);
8d0e4d
 }
8d0e4d
diff --git a/lib/renameat2.c b/lib/renameatu.c
8d0e4d
similarity index 94%
8d0e4d
rename from lib/renameat2.c
8d0e4d
rename to lib/renameatu.c
8d0e4d
index a295ec3..b013ad6 100644
8d0e4d
--- a/lib/renameat2.c
8d0e4d
+++ b/lib/renameatu.c
8d0e4d
@@ -18,7 +18,7 @@
8d0e4d
 
8d0e4d
 #include <config.h>
8d0e4d
 
8d0e4d
-#include "renameat2.h"
8d0e4d
+#include "renameatu.h"
8d0e4d
 
8d0e4d
 #include <errno.h>
8d0e4d
 #include <stdio.h>
8d0e4d
@@ -68,10 +68,13 @@ rename_noreplace (char const *src, char const *dst)
8d0e4d
    the restore_cwd fails, then give a diagnostic and exit nonzero.
8d0e4d
 
8d0e4d
    Obey FLAGS when doing the renaming.  If FLAGS is zero, this
8d0e4d
-   function is equivalent to renameat (FD1, SRC, FD2, DST).  */
8d0e4d
+   function is equivalent to renameat (FD1, SRC, FD2, DST).
8d0e4d
+   Otherwise, attempt to implement FLAGS even if the implementation is
8d0e4d
+   not atomic; this differs from the GNU/Linux native renameat2,
8d0e4d
+   which fails if it cannot guarantee atomicity.  */
8d0e4d
 
8d0e4d
 int
8d0e4d
-renameat2 (int fd1, char const *src, int fd2, char const *dst,
8d0e4d
+renameatu (int fd1, char const *src, int fd2, char const *dst,
8d0e4d
            unsigned int flags)
8d0e4d
 {
8d0e4d
   int ret_val = -1;
8d0e4d
diff --git a/lib/renameat2.h b/lib/renameatu.h
8d0e4d
similarity index 84%
8d0e4d
rename from lib/renameat2.h
8d0e4d
rename to lib/renameatu.h
8d0e4d
index aba7966..7d79775 100644
8d0e4d
--- a/lib/renameat2.h
8d0e4d
+++ b/lib/renameatu.h
8d0e4d
@@ -16,15 +16,13 @@
8d0e4d
 
8d0e4d
 /* written by Paul Eggert */
8d0e4d
 
8d0e4d
-/* Get RENAME_* macros from linux/fs.h if present, otherwise supply
8d0e4d
+/* Get RENAME_* macros from <stdio.h> if present, otherwise supply
8d0e4d
    the traditional Linux values.  */
8d0e4d
-#if HAVE_LINUX_FS_H
8d0e4d
-# include <linux/fs.h>
8d0e4d
-#endif
8d0e4d
+#include <stdio.h>
8d0e4d
 #ifndef RENAME_NOREPLACE
8d0e4d
 # define RENAME_NOREPLACE  (1 << 0)
8d0e4d
 # define RENAME_EXCHANGE   (1 << 1)
8d0e4d
 # define RENAME_WHITEOUT   (1 << 2)
8d0e4d
 #endif
8d0e4d
 
8d0e4d
-extern int renameat2 (int, char const *, int, char const *, unsigned int);
8d0e4d
+extern int renameatu (int, char const *, int, char const *, unsigned int);
8d0e4d
-- 
8d0e4d
2.14.4
8d0e4d
8d0e4d
8d0e4d
From a6b7ff5ef538bbdff4550a56fed878e9cd951d6d Mon Sep 17 00:00:00 2001
8d0e4d
From: Paul Eggert <eggert@cs.ucla.edu>
8d0e4d
Date: Thu, 5 Jul 2018 09:33:48 -0700
8d0e4d
Subject: [PATCH 2/2] build: update gnulib submodule to latest
8d0e4d
8d0e4d
* bootstrap.conf, src/copy.c, src/mv.c, src/shred.c:
8d0e4d
Adjust to renaming of renameat2 to renameatu.
8d0e4d
8d0e4d
Upstream-commit: 439741053256618eb651e6d43919df29625b8714
8d0e4d
Signed-off-by: Kamil Dudka <kdudka@redhat.com>
8d0e4d
---
8d0e4d
 bootstrap.conf | 2 +-
8d0e4d
 src/copy.c     | 4 ++--
8d0e4d
 src/mv.c       | 4 ++--
8d0e4d
 src/shred.c    | 4 ++--
8d0e4d
 4 files changed, 7 insertions(+), 7 deletions(-)
8d0e4d
8d0e4d
diff --git a/bootstrap.conf b/bootstrap.conf
8d0e4d
index 4da4f94..fcf29dc 100644
8d0e4d
--- a/bootstrap.conf
8d0e4d
+++ b/bootstrap.conf
8d0e4d
@@ -210,7 +210,7 @@ gnulib_modules="
8d0e4d
   remove
8d0e4d
   rename
8d0e4d
   renameat
8d0e4d
-  renameat2
8d0e4d
+  renameatu
8d0e4d
   rmdir
8d0e4d
   root-dev-ino
8d0e4d
   rpmatch
8d0e4d
diff --git a/src/copy.c b/src/copy.c
8d0e4d
index 58d2f6e..1a9cdd1 100644
8d0e4d
--- a/src/copy.c
8d0e4d
+++ b/src/copy.c
8d0e4d
@@ -53,7 +53,7 @@
8d0e4d
 #include "ignore-value.h"
8d0e4d
 #include "ioblksize.h"
8d0e4d
 #include "quote.h"
8d0e4d
-#include "renameat2.h"
8d0e4d
+#include "renameatu.h"
8d0e4d
 #include "root-uid.h"
8d0e4d
 #include "same.h"
8d0e4d
 #include "savedir.h"
8d0e4d
@@ -1873,7 +1873,7 @@ copy_internal (char const *src_name, char const *dst_name,
8d0e4d
   if (x->move_mode)
8d0e4d
     {
8d0e4d
       if (rename_errno < 0)
8d0e4d
-        rename_errno = (renameat2 (AT_FDCWD, src_name, AT_FDCWD, dst_name,
8d0e4d
+        rename_errno = (renameatu (AT_FDCWD, src_name, AT_FDCWD, dst_name,
8d0e4d
                                    RENAME_NOREPLACE)
8d0e4d
                         ? errno : 0);
8d0e4d
       new_dst = rename_errno == 0;
8d0e4d
diff --git a/src/mv.c b/src/mv.c
8d0e4d
index b6dd72d..36fd1af 100644
8d0e4d
--- a/src/mv.c
8d0e4d
+++ b/src/mv.c
8d0e4d
@@ -31,7 +31,7 @@
8d0e4d
 #include "error.h"
8d0e4d
 #include "filenamecat.h"
8d0e4d
 #include "remove.h"
8d0e4d
-#include "renameat2.h"
8d0e4d
+#include "renameatu.h"
8d0e4d
 #include "root-dev-ino.h"
8d0e4d
 #include "priv-set.h"
8d0e4d
 
8d0e4d
@@ -456,7 +456,7 @@ main (int argc, char **argv)
8d0e4d
     {
8d0e4d
       assert (2 <= n_files);
8d0e4d
       if (n_files == 2)
8d0e4d
-        x.rename_errno = (renameat2 (AT_FDCWD, file[0], AT_FDCWD, file[1],
8d0e4d
+        x.rename_errno = (renameatu (AT_FDCWD, file[0], AT_FDCWD, file[1],
8d0e4d
                                      RENAME_NOREPLACE)
8d0e4d
                           ? errno : 0);
8d0e4d
       if (x.rename_errno != 0 && target_directory_operand (file[n_files - 1]))
8d0e4d
diff --git a/src/shred.c b/src/shred.c
8d0e4d
index 2ddaadd..270b1e9 100644
8d0e4d
--- a/src/shred.c
8d0e4d
+++ b/src/shred.c
8d0e4d
@@ -93,7 +93,7 @@
8d0e4d
 #include "human.h"
8d0e4d
 #include "randint.h"
8d0e4d
 #include "randread.h"
8d0e4d
-#include "renameat2.h"
8d0e4d
+#include "renameatu.h"
8d0e4d
 #include "stat-size.h"
8d0e4d
 
8d0e4d
 /* Default number of times to overwrite.  */
8d0e4d
@@ -1096,7 +1096,7 @@ wipename (char *oldname, char const *qoldname, struct Options const *flags)
8d0e4d
         memset (base, nameset[0], len);
8d0e4d
         base[len] = 0;
8d0e4d
         bool rename_ok;
8d0e4d
-        while (! (rename_ok = (renameat2 (AT_FDCWD, oldname, AT_FDCWD, newname,
8d0e4d
+        while (! (rename_ok = (renameatu (AT_FDCWD, oldname, AT_FDCWD, newname,
8d0e4d
                                           RENAME_NOREPLACE)
8d0e4d
                                == 0))
8d0e4d
                && errno == EEXIST && incname (base, len))
8d0e4d
-- 
8d0e4d
2.14.4
8d0e4d