]> git.ipfire.org Git - thirdparty/gnulib.git/commitdiff
renameatu: rename from renameat2
authorPaul Eggert <eggert@cs.ucla.edu>
Thu, 5 Jul 2018 16:22:09 +0000 (09:22 -0700)
committerPaul Eggert <eggert@cs.ucla.edu>
Thu, 5 Jul 2018 16:25:34 +0000 (09:25 -0700)
It's looking like Glibc will add a renameat2 function
that is incompatible with Gnulib renameat2; see:
https://sourceware.org/ml/libc-alpha/2018-07/msg00064.html
To help avoid future confusion, rename renameat2 to something else.
Use the name 'renameatu', as the Gnulib function is close to the
Glibc function.  Perhaps someday there will also be a renameat2
Gnulib module, which mimicks the future glibc renameat2, but that
can wait as nobody seems to need such a module now.
* NEWS: Mention this.
* lib/renameatu.c: Rename from lib/renameat2.c.
* lib/renameatu.h: Rename from lib/renameat2.h.
* modules/renameat2: Rename from modules/renameatu.
* modules/renameat2-tests: Rename from modules/renameat2-tests.
All uses of "renameat2" in identifiers or file name
changed to "renameatu", except for two instances in
lib/renameatu.c that deal with the Linux kernel's
renameat2 syscall.

13 files changed:
ChangeLog
MODULES.html.sh
NEWS
lib/backupfile.c
lib/renameat.c
lib/renameatu.c [moved from lib/renameat2.c with 94% similarity]
lib/renameatu.h [moved from lib/renameat2.h with 84% similarity]
modules/backup-rename
modules/backupfile
modules/renameat
modules/renameatu [moved from modules/renameat2 with 84% similarity]
modules/renameatu-tests [moved from modules/renameat2-tests with 57% similarity]
tests/test-renameatu.c [moved from tests/test-renameat2.c with 80% similarity]

index 02d210ed9a424df8e41c44fcbc959d3b613db449..c670b3962d88d74f31678c111ed4e4aef9d63e24 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,24 @@
+2018-07-05  Paul Eggert  <eggert@cs.ucla.edu>
+
+       renameatu: rename from renameat2
+       It's looking like Glibc will add a renameat2 function
+       that is incompatible with Gnulib renameat2; see:
+       https://sourceware.org/ml/libc-alpha/2018-07/msg00064.html
+       To help avoid future confusion, rename renameat2 to something else.
+       Use the name 'renameatu', as the Gnulib function is close to the
+       Glibc function.  Perhaps someday there will also be a renameat2
+       Gnulib module, which mimicks the future glibc renameat2, but that
+       can wait as nobody seems to need such a module now.
+       * NEWS: Mention this.
+       * lib/renameatu.c: Rename from lib/renameat2.c.
+       * lib/renameatu.h: Rename from lib/renameat2.h.
+       * modules/renameat2: Rename from modules/renameatu.
+       * modules/renameat2-tests: Rename from modules/renameat2-tests.
+       All uses of "renameat2" in identifiers or file name
+       changed to "renameatu", except for two instances in
+       lib/renameatu.c that deal with the Linux kernel's
+       renameat2 syscall.
+
 2018-07-04  Paul Eggert  <eggert@cs.ucla.edu>
 
        gnulib-tool: minor tweaks for --gnu-make
index 2cb4cd30f845550668fbeee9c9a0d9fe0c773b87..a61a84e4d8bf623858ed045c6c28edac6002c8e3 100755 (executable)
@@ -2689,7 +2689,7 @@ func_all_modules ()
   func_module qset-acl
   func_module read-file
   func_module readlinkat
-  func_module renameat2
+  func_module renameatu
   func_module same
   func_module save-cwd
   func_module savedir
diff --git a/NEWS b/NEWS
index f4fc2e2ba42480dea3f0d3e18bcbb1cd55864e41..156e49cdebf88640ff06fae8bfb6ee8e33b2f1c6 100644 (file)
--- a/NEWS
+++ b/NEWS
@@ -42,6 +42,10 @@ User visible incompatible changes
 
 Date        Modules         Changes
 
+2018-07-05  renameat2       This module is renamed to 'renameatu' and all
+                            its include files and functions are renamed
+                            accordingly.
+
 2017-12-30  chdir-safer     This module is removed.  It was deprecated
                             on 2006-07-17.
 
index d438455b889c869f8de928f266b257321a33d70d..637be6c242ee9d175ce7a5ff068d2549ea73d194 100644 (file)
@@ -23,7 +23,7 @@
 #include "backup-internal.h"
 
 #include "dirname.h"
-#include "renameat2.h"
+#include "renameatu.h"
 #include "xalloc-oversized.h"
 
 #include <fcntl.h>
@@ -353,7 +353,7 @@ backupfile_internal (char const *file, enum backup_type backup_type, bool rename
           base_offset = 0;
         }
       unsigned flags = backup_type == simple_backups ? 0 : RENAME_NOREPLACE;
-      if (renameat2 (AT_FDCWD, file, sdir, s + base_offset, flags) == 0)
+      if (renameatu (AT_FDCWD, file, sdir, s + base_offset, flags) == 0)
         break;
       int e = errno;
       if (e != EEXIST)
index 0cb7d339981a84ee4ca25015c6f898ee3d230858..67be22bc868c4491eb30119f515ef4d83bbc9f32 100644 (file)
 
 #include <config.h>
 #include <stdio.h>
-#include "renameat2.h"
+#include "renameatu.h"
 
 int
 renameat (int fd1, char const *src, int fd2, char const *dst)
 {
-  return renameat2 (fd1, src, fd2, dst, 0);
+  return renameatu (fd1, src, fd2, dst, 0);
 }
similarity index 94%
rename from lib/renameat2.c
rename to lib/renameatu.c
index a295ec33f33dfe14e1d29cfae5d2c36e82d01ef4..b013ad697f723fd1923675b6d5459ee4d09851e6 100644 (file)
@@ -18,7 +18,7 @@
 
 #include <config.h>
 
-#include "renameat2.h"
+#include "renameatu.h"
 
 #include <errno.h>
 #include <stdio.h>
@@ -68,10 +68,13 @@ rename_noreplace (char const *src, char const *dst)
    the restore_cwd fails, then give a diagnostic and exit nonzero.
 
    Obey FLAGS when doing the renaming.  If FLAGS is zero, this
-   function is equivalent to renameat (FD1, SRC, FD2, DST).  */
+   function is equivalent to renameat (FD1, SRC, FD2, DST).
+   Otherwise, attempt to implement FLAGS even if the implementation is
+   not atomic; this differs from the GNU/Linux native renameat2,
+   which fails if it cannot guarantee atomicity.  */
 
 int
-renameat2 (int fd1, char const *src, int fd2, char const *dst,
+renameatu (int fd1, char const *src, int fd2, char const *dst,
            unsigned int flags)
 {
   int ret_val = -1;
similarity index 84%
rename from lib/renameat2.h
rename to lib/renameatu.h
index aba79664f4766380357e67d7528ebaf31f2034a6..7d797757b6b3be2c08b1665dcbc367ec9a0da12f 100644 (file)
 
 /* written by Paul Eggert */
 
-/* Get RENAME_* macros from linux/fs.h if present, otherwise supply
+/* Get RENAME_* macros from <stdio.h> if present, otherwise supply
    the traditional Linux values.  */
-#if HAVE_LINUX_FS_H
-# include <linux/fs.h>
-#endif
+#include <stdio.h>
 #ifndef RENAME_NOREPLACE
 # define RENAME_NOREPLACE  (1 << 0)
 # define RENAME_EXCHANGE   (1 << 1)
 # define RENAME_WHITEOUT   (1 << 2)
 #endif
 
-extern int renameat2 (int, char const *, int, char const *, unsigned int);
+extern int renameatu (int, char const *, int, char const *, unsigned int);
index 4d8932d293a5070bf616c27526b820a1140c2f21..7e551af52a64657c9fec7973c26f02a47b24f0b3 100644 (file)
@@ -18,7 +18,7 @@ dirname-lgpl
 fcntl
 memcmp
 opendir
-renameat2
+renameatu
 readdir
 stdbool
 
index 9e4efd76d3256f615241895898fae2e7eadfe38b..e9933fbc0a1d84c69744679752a95f4a2bb583be 100644 (file)
@@ -18,7 +18,7 @@ dirname-lgpl
 fcntl
 memcmp
 opendir
-renameat2
+renameatu
 readdir
 stdbool
 
index 9af022505219100628990cca6a9ea328975c5178..48b32c3692d52abdbf381514913f04efd5f24dd8 100644 (file)
@@ -6,7 +6,7 @@ lib/renameat.c
 m4/renameat.m4
 
 Depends-on:
-renameat2        [test $HAVE_RENAMEAT = 0 || test $REPLACE_RENAMEAT = 1]
+renameatu        [test $HAVE_RENAMEAT = 0 || test $REPLACE_RENAMEAT = 1]
 
 configure.ac:
 gl_FUNC_RENAMEAT
similarity index 84%
rename from modules/renameat2
rename to modules/renameatu
index 54f72e1c8447fed38a5aa16f5dd59ab2f8cb387f..1c3fd998462d601458c5d170515a19b51eac7b58 100644 (file)
@@ -1,10 +1,10 @@
 Description:
-renameat2() function: rename a file, relative to two directories
+renameatu() function: rename a file, relative to two dirs, with unsigned flag
 
 Files:
 lib/at-func2.c
-lib/renameat2.c
-lib/renameat2.h
+lib/renameatu.c
+lib/renameatu.h
 m4/renameat.m4
 
 Depends-on:
@@ -30,10 +30,10 @@ if test $HAVE_RENAMEAT = 0; then
 fi
 
 Makefile.am:
-lib_SOURCES += renameat2.c
+lib_SOURCES += renameatu.c
 
 Include:
-"renameat2.h"
+"renameatu.h"
 
 License:
 GPL
similarity index 57%
rename from modules/renameat2-tests
rename to modules/renameatu-tests
index accf3c448631a4a0b9a40e04bece32611faa4d57..135755e4334e40dcca962120b1d809c96f95a0f7 100644 (file)
@@ -1,6 +1,6 @@
 Files:
 tests/test-rename.h
-tests/test-renameat2.c
+tests/test-renameatu.c
 tests/signature.h
 tests/macros.h
 
@@ -15,6 +15,6 @@ closedir
 configure.ac:
 
 Makefile.am:
-TESTS += test-renameat2
-check_PROGRAMS += test-renameat2
-test_renameat2_LDADD = $(LDADD) @LIBINTL@
+TESTS += test-renameatu
+check_PROGRAMS += test-renameatu
+test_renameatu_LDADD = $(LDADD) @LIBINTL@
similarity index 80%
rename from tests/test-renameat2.c
rename to tests/test-renameatu.c
index 010489053408f07eb5d8ed36acb4bbd9c00976fe..988428b05ed4ec7b108b426c70c89681da285762 100644 (file)
@@ -1,4 +1,4 @@
-/* Test renameat2.
+/* Test renameatu.
    Copyright (C) 2009-2018 Free Software Foundation, Inc.
 
    This program is free software: you can redistribute it and/or modify
 
 #include <config.h>
 
-#include <renameat2.h>
+#include <renameatu.h>
 
 #include <stdio.h>
 
 #include "signature.h"
-SIGNATURE_CHECK (renameat2, int,
+SIGNATURE_CHECK (renameatu, int,
                  (int, char const *, int, char const *, unsigned int));
 
 #include <dirent.h>
@@ -39,18 +39,18 @@ SIGNATURE_CHECK (renameat2, int,
 #include "ignore-value.h"
 #include "macros.h"
 
-#define BASE "test-renameat2.t"
+#define BASE "test-renameatu.t"
 
 #include "test-rename.h"
 
 static int dfd1 = AT_FDCWD;
 static int dfd2 = AT_FDCWD;
 
-/* Wrapper to test renameat2 like rename.  */
+/* Wrapper to test renameatu like rename.  */
 static int
 do_rename (char const *name1, char const *name2)
 {
-  return renameat2 (dfd1, name1, dfd2, name2, 0);
+  return renameatu (dfd1, name1, dfd2, name2, 0);
 }
 
 int
@@ -67,24 +67,24 @@ main (void)
   /* Test behaviour for invalid file descriptors.  */
   {
     errno = 0;
-    ASSERT (renameat2 (-1, "foo", AT_FDCWD, "bar", 0) == -1);
+    ASSERT (renameatu (-1, "foo", AT_FDCWD, "bar", 0) == -1);
     ASSERT (errno == EBADF);
   }
   {
     close (99);
     errno = 0;
-    ASSERT (renameat2 (99, "foo", AT_FDCWD, "bar", 0) == -1);
+    ASSERT (renameatu (99, "foo", AT_FDCWD, "bar", 0) == -1);
     ASSERT (errno == EBADF);
   }
   ASSERT (close (creat (BASE "oo", 0600)) == 0);
   {
     errno = 0;
-    ASSERT (renameat2 (AT_FDCWD, BASE "oo", -1, "bar", 0) == -1);
+    ASSERT (renameatu (AT_FDCWD, BASE "oo", -1, "bar", 0) == -1);
     ASSERT (errno == EBADF);
   }
   {
     errno = 0;
-    ASSERT (renameat2 (AT_FDCWD, BASE "oo", 99, "bar", 0) == -1);
+    ASSERT (renameatu (AT_FDCWD, BASE "oo", 99, "bar", 0) == -1);
     ASSERT (errno == EBADF);
   }
   ASSERT (unlink (BASE "oo") == 0);
@@ -133,13 +133,13 @@ main (void)
 
       ASSERT (sprintf (strchr (file1, '\0') - 2, "%02d", i) == 2);
       ASSERT (sprintf (strchr (file2, '\0') - 2, "%02d", i + 1) == 2);
-      ASSERT (renameat2 (fd1, file1, fd2, file2, 0) == 0);
+      ASSERT (renameatu (fd1, file1, fd2, file2, 0) == 0);
       free (file1);
       free (file2);
     }
   dfd2 = open ("..", O_RDONLY);
   ASSERT (0 <= dfd2);
-  ASSERT (renameat2 (dfd, "../" BASE "16", dfd2, BASE "17", 0) == 0);
+  ASSERT (renameatu (dfd, "../" BASE "16", dfd2, BASE "17", 0) == 0);
   ASSERT (close (dfd2) == 0);
 
   /* Now we change back to the parent directory, and set dfd to ".";
@@ -152,47 +152,47 @@ main (void)
 
   ASSERT (close (creat (BASE "sub2/file", 0600)) == 0);
   errno = 0;
-  ASSERT (renameat2 (dfd, BASE "sub1", dfd, BASE "sub2", 0) == -1);
+  ASSERT (renameatu (dfd, BASE "sub1", dfd, BASE "sub2", 0) == -1);
   ASSERT (errno == EEXIST || errno == ENOTEMPTY);
   ASSERT (unlink (BASE "sub2/file") == 0);
   errno = 0;
-  ASSERT (renameat2 (dfd, BASE "sub2", dfd, BASE "sub1/.", 0) == -1);
+  ASSERT (renameatu (dfd, BASE "sub2", dfd, BASE "sub1/.", 0) == -1);
   ASSERT (errno == EINVAL || errno == EISDIR || errno == EBUSY
           || errno == ENOTEMPTY || errno == EEXIST
           || errno == ENOENT /* WSL */);
   errno = 0;
-  ASSERT (renameat2 (dfd, BASE "sub2/.", dfd, BASE "sub1", 0) == -1);
+  ASSERT (renameatu (dfd, BASE "sub2/.", dfd, BASE "sub1", 0) == -1);
   ASSERT (errno == EINVAL || errno == EBUSY || errno == EEXIST
           || errno == ENOENT /* WSL */);
   errno = 0;
-  ASSERT (renameat2 (dfd, BASE "17", dfd, BASE "sub1", 0) == -1);
+  ASSERT (renameatu (dfd, BASE "17", dfd, BASE "sub1", 0) == -1);
   ASSERT (errno == EISDIR);
   errno = 0;
-  ASSERT (renameat2 (dfd, BASE "nosuch", dfd, BASE "18", 0) == -1);
+  ASSERT (renameatu (dfd, BASE "nosuch", dfd, BASE "18", 0) == -1);
   ASSERT (errno == ENOENT);
   errno = 0;
-  ASSERT (renameat2 (dfd, "", dfd, BASE "17", 0) == -1);
+  ASSERT (renameatu (dfd, "", dfd, BASE "17", 0) == -1);
   ASSERT (errno == ENOENT);
   errno = 0;
-  ASSERT (renameat2 (dfd, BASE "17", dfd, "", 0) == -1);
+  ASSERT (renameatu (dfd, BASE "17", dfd, "", 0) == -1);
   ASSERT (errno == ENOENT);
   errno = 0;
-  ASSERT (renameat2 (dfd, BASE "sub2", dfd, BASE "17", 0) == -1);
+  ASSERT (renameatu (dfd, BASE "sub2", dfd, BASE "17", 0) == -1);
   ASSERT (errno == ENOTDIR);
   errno = 0;
-  ASSERT (renameat2 (dfd, BASE "17/", dfd, BASE "18", 0) == -1);
+  ASSERT (renameatu (dfd, BASE "17/", dfd, BASE "18", 0) == -1);
   ASSERT (errno == ENOTDIR);
   errno = 0;
-  ASSERT (renameat2 (dfd, BASE "17", dfd, BASE "18/", 0) == -1);
+  ASSERT (renameatu (dfd, BASE "17", dfd, BASE "18/", 0) == -1);
   ASSERT (errno == ENOTDIR || errno == ENOENT);
 
   /* Finally, make sure we cannot overwrite existing files.  */
   ASSERT (close (creat (BASE "sub2/file", 0600)) == 0);
   errno = 0;
-  ASSERT ((renameat2 (dfd, BASE "sub2", dfd, BASE "sub1", RENAME_NOREPLACE)
+  ASSERT ((renameatu (dfd, BASE "sub2", dfd, BASE "sub1", RENAME_NOREPLACE)
            == -1)
           && errno == EEXIST);
-  ASSERT ((renameat2 (dfd, BASE "sub2/file", dfd, BASE "17", RENAME_NOREPLACE)
+  ASSERT ((renameatu (dfd, BASE "sub2/file", dfd, BASE "17", RENAME_NOREPLACE)
            == -1)
           && errno == EEXIST);