2009-10-10 Eric Blake <ebb9@byu.net>
+ utimens: introduce fdutimens
+ * lib/utimens.h (fdutimens): New prototype.
+ * lib/utimens.c (gl_futimens): Move guts...
+ (fdutimens): ...to new interface.
+ * tests/test-utimens.c (do_fdutimens): Use it.
+
utimens: add UTIME_NOW and UTIME_OMIT support
* lib/utimens.c (validate_timespec, update_timespec): New helper
functions.
Return 0 on success, -1 (setting errno) on failure. */
int
-gl_futimens (int fd, char const *file, struct timespec const timespec[2])
+fdutimens (char const *file, int fd, 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
#include <time.h>
+int fdutimens (char const *, int, struct timespec const [2]);
int gl_futimens (int, char const *, struct timespec const [2]);
int utimens (char const *, struct timespec const [2]);
int lutimens (char const *, struct timespec const [2]);
if (fd < 0)
fd = open (name, O_RDONLY);
errno = 0;
- result = gl_futimens (fd, name, times);
+ result = fdutimens (name, fd, times);
if (0 <= fd)
{
int saved_errno = errno;