From 384f7c422acca2f3658393abfc16ea57cd74caa6 Mon Sep 17 00:00:00 2001 From: Benjamin Barenblat Date: Sun, 21 Feb 2016 19:22:26 -0500 Subject: Implement utimens --- src/operations.cc | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) (limited to 'src/operations.cc') diff --git a/src/operations.cc b/src/operations.cc index df12738..355ffc3 100644 --- a/src/operations.cc +++ b/src/operations.cc @@ -30,6 +30,7 @@ #include #include #include +#include #include "fuse.h" #include "posix_extras.h" @@ -130,6 +131,27 @@ int Open(const char* const path, fuse_file_info* const file_info) noexcept { return OpenResource(path, file_info->flags, &file_info->fh); } +int Utimens(const char* const path, const timespec times[2]) noexcept { + try { + root_->UTimeNs( + std::strcmp(path, "/") == 0 + ? + // Update the times on the mount point. + "." + : + // Trim the leading slash so UTimeNs will treat it relative to + // root_. + path + 1, + times[0], times[1]); + return 0; + } catch (const std::system_error& e) { + return -e.code().value(); + } catch (...) { + LOG(ERROR) << "utimens: caught unexpected value"; + return -ENOTRECOVERABLE; + } +} + int Release(const char*, fuse_file_info* const file_info) noexcept { return ReleaseResource(file_info->fh); } @@ -211,6 +233,7 @@ fuse_operations FuseOperations(File* const root) { result.mknod = &Mknod; result.open = &Open; + result.utimens = &Utimens; result.release = &Release; result.unlink = &Unlink; -- cgit v1.2.3