fdutimens, fdutimensat: update signature, again
authorEric Blake <eblake@redhat.com>
Fri, 17 Sep 2010 21:08:29 +0000 (15:08 -0600)
committerEric Blake <eblake@redhat.com>
Fri, 17 Sep 2010 21:08:44 +0000 (15:08 -0600)
In general, merging:

f<act>(fd,args) and <act>at(dir,name,args)

should produce:

fd<act>at(fd,dir,name,args)

* lib/utimens.h (gl_futimens): Delete, and move signature...
(fdutimens): ...here.
(fdutimensat): Rearrange signature.
(lutimensat): Rename variable for clarity.
* lib/fdutimensat.c (fdutimensat): Update signature.
* lib/utimens.c (fdutimens): Likewise.
(gl_futimens): Delete.
(utimens, lutimens): Update callers.
* lib/futimens.c (futimens): Likewise.
* tests/test-fdutimensat.c: Likewise.
* tests/test-utimens.c: Likewise.
* tests/test-futimens.h: Update comment.
* NEWS: Mention this.
Suggested by Paul Eggert.

Signed-off-by: Eric Blake <eblake@redhat.com>
ChangeLog
NEWS
lib/fdutimensat.c
lib/futimens.c
lib/utimens.c
lib/utimens.h
tests/test-fdutimensat.c
tests/test-futimens.h
tests/test-utimens.c

index 2356ea56e250fb3997f65cda1ca6c65c07d0652f..6c46a5b8d96b064afc959fac8509384acba0aaa7 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,21 @@
+2010-09-17  Eric Blake  <eblake@redhat.com>
+
+       fdutimens, fdutimensat: update signature, again
+       * lib/utimens.h (gl_futimens): Delete, and move signature...
+       (fdutimens): ...here.
+       (fdutimensat): Rearrange signature.
+       (lutimensat): Rename variable for clarity.
+       * lib/fdutimensat.c (fdutimensat): Update signature.
+       * lib/utimens.c (fdutimens): Likewise.
+       (gl_futimens): Delete.
+       (utimens, lutimens): Update callers.
+       * lib/futimens.c (futimens): Likewise.
+       * tests/test-fdutimensat.c: Likewise.
+       * tests/test-utimens.c: Likewise.
+       * tests/test-futimens.h: Update comment.
+       * NEWS: Mention this.
+       Suggested by Paul Eggert.
+
 2010-09-17  Bruno Haible  <bruno@clisp.org>
 
        Take over the maintenance of some older macros from Autoconf.
diff --git a/NEWS b/NEWS
index 7d01eef3a07e70f50c7f2bfcea0898fcb5574cf3..377898dcb843b32a791430960bf3349c1fb30fb8 100644 (file)
--- a/NEWS
+++ b/NEWS
@@ -12,8 +12,15 @@ User visible incompatible changes
 
 Date        Modules         Changes
 
-2010-09-16  fdutimensat     The function now takes a new parameter; old users
-                            can safely pass atflag=0 for no semantic change.
+2010-09-17  utimens         The function gl_futimens is removed, and its
+                            signature has been migrated to fdutimens.  Callers
+                            of gl_futimens should change function name, and
+                            callers of fdutimens should swap parameter order.
+
+2010-09-17  fdutimensat     This function has a new signature: the fd now comes
+                            first instead of the dir/name pair, and a new
+                            atflag parameter is added at the end.  Old code
+                            should rearrange parameters, and pass 0 for atflag.
 
 2010-09-13  regex           The module is not guaranteeing anymore support for
                             64-bit regoff_t on 64-bit systems.  The size of
index 0219a783266477deae65ab25595546f5f42d741e..6766b931f4a13ab68a7ee9b18a36b6344e5c9f3f 100644 (file)
@@ -40,7 +40,7 @@
    Return 0 on success, -1 (setting errno) on failure.  */
 
 int
-fdutimensat (int dir, char const *file, int fd, struct timespec const ts[2],
+fdutimensat (int fd, int dir, char const *file, struct timespec const ts[2],
              int atflag)
 {
   int result = 1;
index ff7c7b4d367caa4071eb6a8416b74a51d3e876bd..f5f4d7497f84976a10ff46f6fa3df5d74c43d9fc 100644 (file)
@@ -33,5 +33,5 @@ futimens (int fd, struct timespec const times[2])
   /* fdutimens also works around bugs in native futimens, when running
      with glibc compiled against newer headers but on a Linux kernel
      older than 2.6.32.  */
-  return fdutimens (NULL, fd, times);
+  return fdutimens (fd, NULL, times);
 }
index 35d082de568a0894f25e1573970621f00d899ad6..088c4baa7e92cd64f853d24ea806e254945095d1 100644 (file)
@@ -164,7 +164,7 @@ update_timespec (struct stat const *statbuf, struct timespec *ts[2])
    Return 0 on success, -1 (setting errno) on failure.  */
 
 int
-fdutimens (char const *file, int fd, struct timespec const timespec[2])
+fdutimens (int fd, char const *file, struct timespec const timespec[2])
 {
   struct timespec adjusted_timespec[2];
   struct timespec *ts = timespec ? adjusted_timespec : NULL;
@@ -370,28 +370,12 @@ fdutimens (char const *file, int fd, struct timespec const timespec[2])
   }
 }
 
-/* Set the access and modification time stamps of FD (a.k.a. FILE) to be
-   TIMESPEC[0] and TIMESPEC[1], respectively.
-   FD must be either negative -- in which case it is ignored --
-   or a file descriptor that is open on FILE.
-   If FD is nonnegative, then FILE can be NULL, which means
-   use just futimes (or equivalent) instead of utimes (or equivalent),
-   and fail if on an old system without futimes (or equivalent).
-   If TIMESPEC is null, set the time stamps to the current time.
-   Return 0 on success, -1 (setting errno) on failure.  */
-
-int
-gl_futimens (int fd, char const *file, struct timespec const timespec[2])
-{
-  return fdutimens (file, fd, timespec);
-}
-
 /* Set the access and modification time stamps of FILE to be
    TIMESPEC[0] and TIMESPEC[1], respectively.  */
 int
 utimens (char const *file, struct timespec const timespec[2])
 {
-  return fdutimens (file, -1, timespec);
+  return fdutimens (-1, file, timespec);
 }
 
 /* Set the access and modification time stamps of FILE to be
@@ -417,7 +401,7 @@ lutimens (char const *file, struct timespec const timespec[2])
 
   /* The Linux kernel did not support symlink timestamps until
      utimensat, in version 2.6.22, so we don't need to mimic
-     gl_futimens' worry about buggy NFS clients.  But we do have to
+     fdutimens' worry about buggy NFS clients.  But we do have to
      worry about bogus return values.  */
 
 #if HAVE_UTIMENSAT
@@ -507,7 +491,7 @@ lutimens (char const *file, struct timespec const timespec[2])
   if (!(adjustment_needed || REPLACE_FUNC_STAT_FILE) && lstat (file, &st))
     return -1;
   if (!S_ISLNK (st.st_mode))
-    return fdutimens (file, -1, ts);
+    return fdutimens (-1, file, ts);
   errno = ENOSYS;
   return -1;
 }
index f651beebaded642d83080dc92de6c834672d9435..8c47cf93f887dc05a2e84eb3349d61d91da22177 100644 (file)
@@ -1,6 +1,5 @@
 #include <time.h>
-int fdutimens (char const *, int, struct timespec const [2]);
-int gl_futimens (int, char const *, struct timespec const [2]);
+int fdutimens (int, char const *, struct timespec const [2]);
 int utimens (char const *, struct timespec const [2]);
 int lutimens (char const *, struct timespec const [2]);
 
@@ -8,13 +7,13 @@ int lutimens (char const *, struct timespec const [2]);
 # include <fcntl.h>
 # include <sys/stat.h>
 
-int fdutimensat (int dir, char const *name, int fd, struct timespec const [2],
+int fdutimensat (int fd, int dir, char const *name, struct timespec const [2],
                  int atflag);
 
 /* Using this function makes application code slightly more readable.  */
 static inline int
-lutimensat (int fd, char const *file, struct timespec const times[2])
+lutimensat (int dir, char const *file, struct timespec const times[2])
 {
-  return utimensat (fd, file, times, AT_SYMLINK_NOFOLLOW);
+  return utimensat (dir, file, times, AT_SYMLINK_NOFOLLOW);
 }
 #endif
index 80eb373d0076b024b15b27d0675e8876d5998ed8..d94667af91954860d3483b7220d17ad69283028d 100644 (file)
@@ -40,7 +40,7 @@ static int dfd = AT_FDCWD;
 static int
 do_futimens (int fd, struct timespec const times[2])
 {
-  return fdutimensat (dfd, NULL, fd, times, 0);
+  return fdutimensat (fd, dfd, NULL, times, 0);
 }
 
 /* Test the use of file descriptors alongside a name.  */
@@ -52,8 +52,8 @@ do_fdutimens (char const *name, struct timespec const times[2])
   if (fd < 0)
     fd = openat (dfd, name, O_RDONLY);
   errno = 0;
-  result = fdutimensat (dfd, name, fd, times, 0);
-  ASSERT (fdutimensat (dfd, name, fd, times, AT_SYMLINK_NOFOLLOW) == result);
+  result = fdutimensat (fd, dfd, name, times, 0);
+  ASSERT (fdutimensat (fd, dfd, name, times, AT_SYMLINK_NOFOLLOW) == result);
   if (0 <= fd)
     {
       int saved_errno = errno;
@@ -74,14 +74,14 @@ do_lutimens (const char *name, struct timespec const times[2])
 static int
 do_lutimens1 (const char *name, struct timespec const times[2])
 {
-  return fdutimensat (dfd, name, -1, times, AT_SYMLINK_NOFOLLOW);
+  return fdutimensat (-1, dfd, name, times, AT_SYMLINK_NOFOLLOW);
 }
 
 /* Wrap fdutimensat to behave like utimens.  */
 static int
 do_utimens (const char *name, struct timespec const times[2])
 {
-  return fdutimensat (dfd, name, -1, times, 0);
+  return fdutimensat (-1, dfd, name, times, 0);
 }
 
 int
@@ -117,12 +117,12 @@ main (void)
   fd = creat ("file", 0600);
   ASSERT (0 <= fd);
   errno = 0;
-  ASSERT (fdutimensat (fd, ".", AT_FDCWD, NULL, 0) == -1);
+  ASSERT (fdutimensat (AT_FDCWD, fd, ".", NULL, 0) == -1);
   ASSERT (errno == ENOTDIR);
   {
     struct timespec ts[2] = { { Y2K, 0 }, { Y2K, 0 } };
     struct stat st;
-    ASSERT (fdutimensat (dfd, BASE "dir/file", fd, ts, 0) == 0);
+    ASSERT (fdutimensat (fd, dfd, BASE "dir/file", ts, 0) == 0);
     ASSERT (stat ("file", &st) == 0);
     ASSERT (st.st_atime == Y2K);
     ASSERT (get_stat_atime_ns (&st) == 0);
@@ -132,7 +132,7 @@ main (void)
   ASSERT (close (fd) == 0);
   ASSERT (close (dfd) == 0);
   errno = 0;
-  ASSERT (fdutimensat (dfd, ".", -1, NULL, 0) == -1);
+  ASSERT (fdutimensat (-1, dfd, ".", NULL, 0) == -1);
   ASSERT (errno == EBADF);
 
   /* Cleanup.  */
index 97c7acddcbabeba29cdf8bac61df77a7125331dc..ab86ae2171e9b36703328871e93966b4e2a74a88 100644 (file)
@@ -16,7 +16,7 @@
 
 #include "test-utimens-common.h"
 
-/* This file is designed to test both gl_futimens(a,NULL,b) and
+/* This file is designed to test both fdutimens(a,NULL,b) and
    futimens(a,b).  FUNC is the function to test.  Assumes that BASE
    and ASSERT are already defined.  If PRINT, warn before skipping
    tests with status 77.  */
index f2a31a88eda612a3c5e9892fc7cc146a71e49509..09c353b0154aafea8b1745cb967e4b03e9df7562 100644 (file)
 #include "test-lutimens.h"
 #include "test-utimens.h"
 
-/* Wrap gl_futimens to behave like futimens.  */
+/* Wrap fdutimens to behave like futimens.  */
 static int
 do_futimens (int fd, struct timespec const times[2])
 {
-  return gl_futimens (fd, NULL, times);
+  return fdutimens (fd, NULL, times);
 }
 
 /* Test the use of file descriptors alongside a name.  */
@@ -49,7 +49,7 @@ do_fdutimens (char const *name, struct timespec const times[2])
   if (fd < 0)
     fd = open (name, O_RDONLY);
   errno = 0;
-  result = fdutimens (name, fd, times);
+  result = fdutimens (fd, name, times);
   if (0 <= fd)
     {
       int saved_errno = errno;