diff options
author | Martin Pärtel <martin.partel@gmail.com> | 2013-09-23 23:57:51 +0300 |
---|---|---|
committer | Martin Pärtel <martin.partel@gmail.com> | 2013-09-23 23:57:51 +0300 |
commit | 189a8d53fa68f0a630ce671fa2ddcccc15588441 (patch) | |
tree | f6ce7d0ee23a14d08df8d3a8f18030b69f00bebd /tests/utimens_nofollow.c | |
parent | e17adbb805c7363b8e6a18fe49d4269a94d4c8b8 (diff) | |
download | bindfs-189a8d53fa68f0a630ce671fa2ddcccc15588441.tar.gz |
Implement fuse_utimens instead of fuse_utime.
Fixes utime'ing symlinks.
Seems to also fix an attribute caching problem.
Diffstat (limited to 'tests/utimens_nofollow.c')
-rw-r--r-- | tests/utimens_nofollow.c | 32 |
1 files changed, 32 insertions, 0 deletions
diff --git a/tests/utimens_nofollow.c b/tests/utimens_nofollow.c new file mode 100644 index 0000000..ced9b5f --- /dev/null +++ b/tests/utimens_nofollow.c @@ -0,0 +1,32 @@ + +#define _BSD_SOURCE /* For atoll */ + +#include <stdlib.h> +#include <stdio.h> +#include <unistd.h> +#include <sys/types.h> +#include <sys/stat.h> +#include <fcntl.h> +#include <errno.h> + +int main(int argc, char* argv[]) +{ + struct timespec times[2]; + + if (argc != 6) { + fprintf(stderr, "Usage: utimens_nofollow path atime atime_nsec mtime mtime_nsec\n"); + return 1; + } + + times[0].tv_sec = (time_t)atoll(argv[2]); + times[0].tv_nsec = atoll(argv[3]); + times[1].tv_sec = (time_t)atoll(argv[4]); + times[1].tv_nsec = atoll(argv[5]); + + if (utimensat(AT_FDCWD, argv[1], times, AT_SYMLINK_NOFOLLOW) == -1) { + perror("failed to utimensat the given path"); + return 2; + } + + return 0; +} |