This commit is contained in:
Sebastian Messmer 2014-11-12 21:55:34 +01:00
parent 7ddf6d0672
commit 31aa6228bb
5 changed files with 22 additions and 12 deletions

View File

@ -180,17 +180,13 @@ int CryFuse::ftruncate(const path &path, off_t size, fuse_file_info *fileinfo) {
//TODO //TODO
int CryFuse::utimens(const path &path, const timespec times[2]) { int CryFuse::utimens(const path &path, const timespec times[2]) {
UNUSED(times); //printf("utimens(%s, _)\n", path.c_str());
printf("NOT IMPLEMENTED: utimens(%s, _)\n", path.c_str()); try {
//auto real_path = _device->RootDir() / path; _device->utimens(path, times);
//struct timeval tv[2]; return 0;
//tv[0].tv_sec = times[0].tv_sec; } catch (CryErrnoException &e) {
//tv[0].tv_usec = times[0].tv_nsec / 1000; return -e.getErrno();
//tv[1].tv_sec = times[1].tv_sec; }
//tv[1].tv_usec = times[1].tv_nsec / 1000;
//int retstat = ::lutimes(real_path.c_str(), tv);
//return errcode_map(retstat);
return 0;
} }
int CryFuse::open(const path &path, fuse_file_info *fileinfo) { int CryFuse::open(const path &path, fuse_file_info *fileinfo) {

View File

@ -144,3 +144,7 @@ void CryDevice::closeDir(int descriptor) {
_open_dirs.close(descriptor); _open_dirs.close(descriptor);
} }
void CryDevice::utimens(const bf::path &path, const timespec times[2]) {
auto node = Load(path);
node->utimens(times);
}

View File

@ -39,10 +39,10 @@ public:
void rmdir(const bf::path &path); void rmdir(const bf::path &path);
void unlink(const bf::path &path); void unlink(const bf::path &path);
void rename(const bf::path &from, const bf::path &to); void rename(const bf::path &from, const bf::path &to);
int openDir(const bf::path &path); int openDir(const bf::path &path);
std::unique_ptr<std::vector<std::string>> readDir(int descriptor); std::unique_ptr<std::vector<std::string>> readDir(int descriptor);
void closeDir(int descriptor); void closeDir(int descriptor);
void utimens(const bf::path &path, const timespec times[2]);
const bf::path &RootDir() const; const bf::path &RootDir() const;
private: private:

View File

@ -1,5 +1,7 @@
#include "CryNode.h" #include "CryNode.h"
#include <sys/time.h>
#include "CryDevice.h" #include "CryDevice.h"
#include "CryErrnoException.h" #include "CryErrnoException.h"
@ -29,4 +31,11 @@ void CryNode::rename(const bf::path &to) {
_path = to; _path = to;
} }
void CryNode::utimens(const timespec times[2]) {
struct timeval timevals[2];
TIMESPEC_TO_TIMEVAL(&timevals[0], &times[0]);
TIMESPEC_TO_TIMEVAL(&timevals[1], &times[1]);
::lutimes(base_path().c_str(), timevals);
}
} /* namespace cryfs */ } /* namespace cryfs */

View File

@ -20,6 +20,7 @@ public:
void stat(struct ::stat *result) const; void stat(struct ::stat *result) const;
void access(int mask) const; void access(int mask) const;
void rename(const bf::path &to); void rename(const bf::path &to);
void utimens(const timespec times[2]);
protected: protected:
bf::path base_path() const; bf::path base_path() const;