Improve utimens interface

This commit is contained in:
Sebastian Messmer 2016-02-09 09:19:45 +01:00
parent afe4556a0c
commit a583ff6970
5 changed files with 6 additions and 7 deletions

View File

@ -17,7 +17,7 @@ public:
virtual void chown(uid_t uid, gid_t gid) = 0; virtual void chown(uid_t uid, gid_t gid) = 0;
virtual void access(int mask) const = 0; virtual void access(int mask) const = 0;
virtual void rename(const boost::filesystem::path &to) = 0; virtual void rename(const boost::filesystem::path &to) = 0;
virtual void utimens(const timespec times[2]) = 0; virtual void utimens(const timespec lastAccessTime, const timespec lastModificationTime) = 0;
virtual void remove() = 0; virtual void remove() = 0;
}; };

View File

@ -37,7 +37,7 @@ public:
virtual void rmdir(const boost::filesystem::path &path) = 0; virtual void rmdir(const boost::filesystem::path &path) = 0;
virtual void unlink(const boost::filesystem::path &path) = 0; virtual void unlink(const boost::filesystem::path &path) = 0;
virtual void rename(const boost::filesystem::path &from, const boost::filesystem::path &to) = 0; virtual void rename(const boost::filesystem::path &from, const boost::filesystem::path &to) = 0;
virtual void utimens(const boost::filesystem::path &path, const timespec times[2]) = 0; virtual void utimens(const boost::filesystem::path &path, timespec lastAccessTime, timespec lastModificationTime) = 0;
virtual void statfs(const boost::filesystem::path &path, struct statvfs *fsstat) = 0; virtual void statfs(const boost::filesystem::path &path, struct statvfs *fsstat) = 0;
//TODO We shouldn't use Dir::Entry here, that's in another layer //TODO We shouldn't use Dir::Entry here, that's in another layer
virtual cpputils::unique_ref<std::vector<Dir::Entry>> readDir(const boost::filesystem::path &path) = 0; virtual cpputils::unique_ref<std::vector<Dir::Entry>> readDir(const boost::filesystem::path &path) = 0;

View File

@ -525,13 +525,12 @@ int Fuse::ftruncate(const bf::path &path, off_t size, fuse_file_info *fileinfo)
} }
} }
//TODO
int Fuse::utimens(const bf::path &path, const timespec times[2]) { int Fuse::utimens(const bf::path &path, const timespec times[2]) {
#ifdef FSPP_LOG #ifdef FSPP_LOG
LOG(DEBUG) << "utimens(" << path << ", _)"; LOG(DEBUG) << "utimens(" << path << ", _)";
#endif #endif
try { try {
_fs->utimens(path, times); _fs->utimens(path, times[0], times[1]);
return 0; return 0;
} catch(const cpputils::AssertFailed &e) { } catch(const cpputils::AssertFailed &e) {
LOG(ERROR) << "AssertFailed in Fuse::utimens: " << e.what(); LOG(ERROR) << "AssertFailed in Fuse::utimens: " << e.what();

View File

@ -290,13 +290,13 @@ unique_ref<vector<Dir::Entry>> FilesystemImpl::readDir(const bf::path &path) {
return dir->children(); return dir->children();
} }
void FilesystemImpl::utimens(const bf::path &path, const timespec times[2]) { void FilesystemImpl::utimens(const bf::path &path, timespec lastAccessTime, timespec lastModificationTime) {
PROFILE(_utimensNanosec); PROFILE(_utimensNanosec);
auto node = _device->Load(path); auto node = _device->Load(path);
if(node == none) { if(node == none) {
throw fuse::FuseErrnoException(ENOENT); throw fuse::FuseErrnoException(ENOENT);
} else { } else {
(*node)->utimens(times); (*node)->utimens(lastAccessTime, lastModificationTime);
} }
} }

View File

@ -44,7 +44,7 @@ public:
void unlink(const boost::filesystem::path &path) override; void unlink(const boost::filesystem::path &path) override;
void rename(const boost::filesystem::path &from, const boost::filesystem::path &to) override; void rename(const boost::filesystem::path &from, const boost::filesystem::path &to) override;
cpputils::unique_ref<std::vector<Dir::Entry>> readDir(const boost::filesystem::path &path) override; cpputils::unique_ref<std::vector<Dir::Entry>> readDir(const boost::filesystem::path &path) override;
void utimens(const boost::filesystem::path &path, const timespec times[2]) override; void utimens(const boost::filesystem::path &path, timespec lastAccessTime, timespec lastModificationTime) override;
void statfs(const boost::filesystem::path &path, struct statvfs *fsstat) override; void statfs(const boost::filesystem::path &path, struct statvfs *fsstat) override;
void createSymlink(const boost::filesystem::path &to, const boost::filesystem::path &from, uid_t uid, gid_t gid) override; void createSymlink(const boost::filesystem::path &to, const boost::filesystem::path &from, uid_t uid, gid_t gid) override;
void readSymlink(const boost::filesystem::path &path, char *buf, size_t size) override; void readSymlink(const boost::filesystem::path &path, char *buf, size_t size) override;