Add utime operations
This commit is contained in:
parent
eec782057c
commit
4909a35a6a
@ -48,6 +48,8 @@
|
|||||||
|
|
||||||
int auto_create_perm = GRANT_TEMP;
|
int auto_create_perm = GRANT_TEMP;
|
||||||
|
|
||||||
|
#define HAVE_UTIMENSAT
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Sets the default permission granted by file creation.
|
* 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],
|
static int xmp_utimens(const char *path, const struct timespec ts[2],
|
||||||
struct fuse_file_info *fi) {
|
struct fuse_file_info *fi) {
|
||||||
int res;
|
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 */
|
/* don't use utime/utimes since they follow symlinks */
|
||||||
if (fi)
|
if (fi)
|
||||||
res = futimens(fi->fh, ts);
|
res = futimens(fi->fh, ts);
|
||||||
else
|
else
|
||||||
res = utimensat(0, path, ts, AT_SYMLINK_NOFOLLOW);
|
res = source_utimens(path, ts, AT_SYMLINK_NOFOLLOW);
|
||||||
if (res == -1)
|
if (res == -1)
|
||||||
return -errno;
|
return -errno;
|
||||||
|
|
||||||
@ -756,7 +767,7 @@ static const struct fuse_operations xmp_oper = {
|
|||||||
.chown = xmp_chown,
|
.chown = xmp_chown,
|
||||||
.truncate = xmp_truncate,
|
.truncate = xmp_truncate,
|
||||||
#ifdef HAVE_UTIMENSAT
|
#ifdef HAVE_UTIMENSAT
|
||||||
// .utimens = xmp_utimens,
|
.utimens = xmp_utimens,
|
||||||
#endif
|
#endif
|
||||||
.create = xmp_create,
|
.create = xmp_create,
|
||||||
.open = xmp_open,
|
.open = xmp_open,
|
||||||
|
@ -277,3 +277,9 @@ int source_create(const char *filename, int flags, mode_t mode) {
|
|||||||
const char *relative_filename = source_filename_translate(filename);
|
const char *relative_filename = source_filename_translate(filename);
|
||||||
return openat(handle.root_fd, relative_filename, flags | O_CREAT, mode);
|
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);
|
||||||
|
}
|
||||||
|
@ -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_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
|
#endif // !SOURCEFS_H
|
||||||
|
Loading…
x
Reference in New Issue
Block a user