utimens must not follow symlinks
authorSebastian Pipping <sebastian@pipping.org>
Sat, 25 Jun 2011 17:14:29 +0000 (19:14 +0200)
committerMiklos Szeredi <mszeredi@suse.cz>
Mon, 4 Jul 2011 11:01:35 +0000 (13:01 +0200)
Make xmp_utimens of examples "fusexmp" and "fusexmp_fh" not follow
symlinks as other layers do that already.

ChangeLog
example/fusexmp.c
example/fusexmp_fh.c

index db029ff0ea2e9b0822186108f1638f97074dfc21..0af270332cc5241517ddf605ef85e024843da8bf 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,8 @@
+2011-07-02  Sebastian Pipping <sebastian@pipping.org>
+
+       * Make xmp_utimens of examples "fusexmp" and "fusexmp_fh"
+       not follow symlinks as other layers do that already.
+
 2011-06-02  Miklos Szeredi <miklos@szeredi.hu>
 
        * Add "remember" option.  This works similar to "noforget" except
index 083bbea95f5a458193e012f68c7dc875a750a230..58b77a8fd04b9a37dca6c0aed9f5af93d56a6cb9 100644 (file)
@@ -1,6 +1,7 @@
 /*
   FUSE: Filesystem in Userspace
   Copyright (C) 2001-2007  Miklos Szeredi <miklos@szeredi.hu>
+  Copyright (C) 2011       Sebastian Pipping <sebastian@pipping.org>
 
   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 <fuse.h>
@@ -24,6 +25,7 @@
 #include <string.h>
 #include <unistd.h>
 #include <fcntl.h>
+#include <sys/stat.h>
 #include <dirent.h>
 #include <errno.h>
 #include <sys/time.h>
@@ -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;
 
index 8f8b1a983e415a14db128858737369d595ab75d0..96427b38f9917ae4bdf482c542a944c2d218423d 100644 (file)
@@ -1,6 +1,7 @@
 /*
   FUSE: Filesystem in Userspace
   Copyright (C) 2001-2007  Miklos Szeredi <miklos@szeredi.hu>
+  Copyright (C) 2011       Sebastian Pipping <sebastian@pipping.org>
 
   This program can be distributed under the terms of the GNU GPL.
   See the file COPYING.
@@ -23,6 +24,7 @@
 #include <string.h>
 #include <unistd.h>
 #include <fcntl.h>
+#include <sys/stat.h>
 #include <dirent.h>
 #include <errno.h>
 #include <sys/time.h>
@@ -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;