diff options
author | Eric Blake <eblake@redhat.com> | 2010-09-16 17:12:35 -0600 |
---|---|---|
committer | Eric Blake <eblake@redhat.com> | 2010-09-16 17:28:55 -0600 |
commit | 9ea0943bfd68afa3412a139fa1a29d9b6c046916 (patch) | |
tree | 917bf997b155f7c6ea7ed50f3891812c2f84b866 /lib/fdutimensat.c | |
parent | 61d8728839e77d615f102f12a06bbd3928d55cf8 (diff) | |
download | gnulib-9ea0943bfd68afa3412a139fa1a29d9b6c046916.tar.gz |
fdutimensat: add an atflag parameter
* lib/fdutimensat.c (fdutimensat): Add new parameter.
* lib/utimens.h (fdutimensat): Update prototype.
* tests/test-fdutimensat.c: Adjust test to match.
* NEWS: Document the change.
Suggested by Paul Eggert.
Signed-off-by: Eric Blake <eblake@redhat.com>
Diffstat (limited to 'lib/fdutimensat.c')
-rw-r--r-- | lib/fdutimensat.c | 21 |
1 files changed, 18 insertions, 3 deletions
diff --git a/lib/fdutimensat.c b/lib/fdutimensat.c index 7c08a525a9..77f893bb3b 100644 --- a/lib/fdutimensat.c +++ b/lib/fdutimensat.c @@ -35,16 +35,31 @@ 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. + ATFLAG must be 0 if FD is non-negative; otherwise it may be + AT_SYMLINK_NOFOLLOW to operate on FILE as a symlink. 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 dir, char const *file, int fd, struct timespec const ts[2], + int atflag) { int result = 1; + if (atflag & ~AT_SYMLINK_NOFOLLOW) + { + errno = EINVAL; + return -1; + } if (0 <= fd) - result = futimens (fd, ts); + { + if (atflag) + { + errno = EINVAL; + return -1; + } + result = futimens (fd, ts); + } if (file && (fd < 0 || (result == -1 && errno == ENOSYS))) - result = utimensat (dir, file, ts, 0); + result = utimensat (dir, file, ts, atflag); if (result == 1) { errno = EBADF; |