+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.
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
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;
/* 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);
}
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;
}
}
-/* 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
/* 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
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;
}
#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]);
# 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
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. */
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;
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
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);
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. */
#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. */
#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. */
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;