diff --git a/src/fuse_operations.c b/src/fuse_operations.c index d9172ae..a2ea0df 100644 --- a/src/fuse_operations.c +++ b/src/fuse_operations.c @@ -48,6 +48,8 @@ int auto_create_perm = GRANT_TEMP; +#define HAVE_UTIMENSAT + /* * Sets the default permission granted by file creation. * @@ -451,12 +453,21 @@ static int xmp_truncate(const char *path, off_t size, static int xmp_utimens(const char *path, const struct timespec ts[2], struct fuse_file_info *fi) { int res; + struct process_info pi; + struct fuse_context *fc = fuse_get_context(); + + pi = get_process_info(fc->pid); + + if (!interactive_access(path, pi, 0)) { + free(pi.name); + return -EACCES; + } /* don't use utime/utimes since they follow symlinks */ if (fi) res = futimens(fi->fh, ts); else - res = utimensat(0, path, ts, AT_SYMLINK_NOFOLLOW); + res = source_utimens(path, ts, AT_SYMLINK_NOFOLLOW); if (res == -1) return -errno; @@ -756,7 +767,7 @@ static const struct fuse_operations xmp_oper = { .chown = xmp_chown, .truncate = xmp_truncate, #ifdef HAVE_UTIMENSAT -// .utimens = xmp_utimens, + .utimens = xmp_utimens, #endif .create = xmp_create, .open = xmp_open, diff --git a/src/sourcefs.c b/src/sourcefs.c index 0d54416..cf2b4ee 100644 --- a/src/sourcefs.c +++ b/src/sourcefs.c @@ -277,3 +277,9 @@ int source_create(const char *filename, int flags, mode_t mode) { const char *relative_filename = source_filename_translate(filename); return openat(handle.root_fd, relative_filename, flags | O_CREAT, mode); } + +int source_utimens(const char *filename, const struct timespec ts[2], + int flags) { + const char *relative_filename = source_filename_translate(filename); + return utimensat(handle.root_fd, relative_filename, ts, AT_SYMLINK_NOFOLLOW); +} diff --git a/src/sourcefs.h b/src/sourcefs.h index c957d1b..b2a364a 100644 --- a/src/sourcefs.h +++ b/src/sourcefs.h @@ -138,4 +138,7 @@ int source_open(const char *filename, int flags); */ int source_create(const char *filename, int flags, mode_t mode); +int source_utimens(const char *filename, const struct timespec ts[2], + int flags); + #endif // !SOURCEFS_H