From c605b5f73c458eeacdb6653e6899b5ebe7f1fc1a Mon Sep 17 00:00:00 2001 From: Sebastian Pipping Date: Sat, 25 Jun 2011 19:14:29 +0200 Subject: utimens must not follow symlinks Make xmp_utimens of examples "fusexmp" and "fusexmp_fh" not follow symlinks as other layers do that already. --- ChangeLog | 5 +++++ example/fusexmp.c | 14 +++++--------- example/fusexmp_fh.c | 10 +++------- 3 files changed, 13 insertions(+), 16 deletions(-) diff --git a/ChangeLog b/ChangeLog index db029ff..0af2703 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,8 @@ +2011-07-02 Sebastian Pipping + + * Make xmp_utimens of examples "fusexmp" and "fusexmp_fh" + not follow symlinks as other layers do that already. + 2011-06-02 Miklos Szeredi * Add "remember" option. This works similar to "noforget" except diff --git a/example/fusexmp.c b/example/fusexmp.c index 083bbea..58b77a8 100644 --- a/example/fusexmp.c +++ b/example/fusexmp.c @@ -1,6 +1,7 @@ /* FUSE: Filesystem in Userspace Copyright (C) 2001-2007 Miklos Szeredi + Copyright (C) 2011 Sebastian Pipping This program can be distributed under the terms of the GNU GPL. See the file COPYING. @@ -15,8 +16,8 @@ #endif #ifdef linux -/* For pread()/pwrite() */ -#define _XOPEN_SOURCE 500 +/* For pread()/pwrite()/utimensat() */ +#define _XOPEN_SOURCE 700 #endif #include @@ -24,6 +25,7 @@ #include #include #include +#include #include #include #include @@ -214,14 +216,8 @@ static int xmp_truncate(const char *path, off_t size) static int xmp_utimens(const char *path, const struct timespec ts[2]) { int res; - struct timeval tv[2]; - tv[0].tv_sec = ts[0].tv_sec; - tv[0].tv_usec = ts[0].tv_nsec / 1000; - tv[1].tv_sec = ts[1].tv_sec; - tv[1].tv_usec = ts[1].tv_nsec / 1000; - - res = utimes(path, tv); + res = utimensat(0, path, ts, AT_SYMLINK_NOFOLLOW); if (res == -1) return -errno; diff --git a/example/fusexmp_fh.c b/example/fusexmp_fh.c index 8f8b1a9..96427b3 100644 --- a/example/fusexmp_fh.c +++ b/example/fusexmp_fh.c @@ -1,6 +1,7 @@ /* FUSE: Filesystem in Userspace Copyright (C) 2001-2007 Miklos Szeredi + Copyright (C) 2011 Sebastian Pipping This program can be distributed under the terms of the GNU GPL. See the file COPYING. @@ -23,6 +24,7 @@ #include #include #include +#include #include #include #include @@ -283,14 +285,8 @@ static int xmp_ftruncate(const char *path, off_t size, static int xmp_utimens(const char *path, const struct timespec ts[2]) { int res; - struct timeval tv[2]; - tv[0].tv_sec = ts[0].tv_sec; - tv[0].tv_usec = ts[0].tv_nsec / 1000; - tv[1].tv_sec = ts[1].tv_sec; - tv[1].tv_usec = ts[1].tv_nsec / 1000; - - res = utimes(path, tv); + res = utimensat(0, path, ts, AT_SYMLINK_NOFOLLOW); if (res == -1) return -errno; -- cgit v1.2.3