diff --git a/src/cpp-utils/system/time.h b/src/cpp-utils/system/time.h new file mode 100644 index 00000000..eeb0e1c6 --- /dev/null +++ b/src/cpp-utils/system/time.h @@ -0,0 +1,19 @@ +#pragma once +#ifndef MESSMER_CPPUTILS_SYSTEM_TIME_H +#define MESSMER_CPPUTILS_SYSTEM_TIME_H + +#include +#include "clock_gettime.h" + +namespace cpputils { + namespace time { + // TODO Test + inline timespec now() { + struct timespec now; + clock_gettime(CLOCK_REALTIME, &now); + return now; + } + } +} + +#endif diff --git a/src/cryfs/filesystem/CryDir.cpp b/src/cryfs/filesystem/CryDir.cpp index cb0bb859..b7480397 100644 --- a/src/cryfs/filesystem/CryDir.cpp +++ b/src/cryfs/filesystem/CryDir.cpp @@ -9,7 +9,7 @@ #include "CryDevice.h" #include "CryFile.h" #include "CryOpenFile.h" -#include "fsblobstore/utils/time.h" +#include //TODO Get rid of this in favor of exception hierarchy using fspp::fuse::CHECK_RETVAL; @@ -40,7 +40,7 @@ CryDir::~CryDir() { unique_ref CryDir::createAndOpenFile(const string &name, mode_t mode, uid_t uid, gid_t gid) { device()->callFsActionCallbacks(); auto child = device()->CreateFileBlob(); - auto now = fsblobstore::time::now(); + auto now = cpputils::time::now(); auto dirBlob = LoadBlob(); dirBlob->AddChildFile(name, child->key(), mode, uid, gid, now, now); return make_unique_ref(device(), cpputils::to_unique_ptr(std::move(dirBlob)), std::move(child)); @@ -50,7 +50,7 @@ void CryDir::createDir(const string &name, mode_t mode, uid_t uid, gid_t gid) { device()->callFsActionCallbacks(); auto blob = LoadBlob(); auto child = device()->CreateDirBlob(); - auto now = fsblobstore::time::now(); + auto now = cpputils::time::now(); blob->AddChildDir(name, child->key(), mode, uid, gid, now, now); } @@ -80,7 +80,7 @@ void CryDir::createSymlink(const string &name, const bf::path &target, uid_t uid device()->callFsActionCallbacks(); auto blob = LoadBlob(); auto child = device()->CreateSymlinkBlob(target); - auto now = fsblobstore::time::now(); + auto now = cpputils::time::now(); blob->AddChildSymlink(name, child->key(), uid, gid, now, now); } diff --git a/src/cryfs/filesystem/fsblobstore/utils/DirEntry.h b/src/cryfs/filesystem/fsblobstore/utils/DirEntry.h index 88340371..7084b92d 100644 --- a/src/cryfs/filesystem/fsblobstore/utils/DirEntry.h +++ b/src/cryfs/filesystem/fsblobstore/utils/DirEntry.h @@ -4,7 +4,7 @@ #include #include -#include "time.h" +#include namespace cryfs { namespace fsblobstore { @@ -166,7 +166,7 @@ namespace cryfs { } inline void DirEntry::_updateLastMetadataChangeTime() { - setLastMetadataChangeTime(time::now()); + setLastMetadataChangeTime(cpputils::time::now()); } } diff --git a/src/cryfs/filesystem/fsblobstore/utils/DirEntryList.cpp b/src/cryfs/filesystem/fsblobstore/utils/DirEntryList.cpp index 334a7345..53025e01 100644 --- a/src/cryfs/filesystem/fsblobstore/utils/DirEntryList.cpp +++ b/src/cryfs/filesystem/fsblobstore/utils/DirEntryList.cpp @@ -1,6 +1,6 @@ #include "DirEntryList.h" #include -#include "time.h" +#include //TODO Get rid of that in favor of better error handling #include @@ -59,7 +59,7 @@ void DirEntryList::add(const string &name, const Key &blobKey, fspp::Dir::EntryT void DirEntryList::_add(const string &name, const Key &blobKey, fspp::Dir::EntryType entryType, mode_t mode, uid_t uid, gid_t gid, timespec lastAccessTime, timespec lastModificationTime) { auto insert_pos = _findUpperBound(blobKey); - _entries.emplace(insert_pos, entryType, name, blobKey, mode, uid, gid, lastAccessTime, lastModificationTime, time::now()); + _entries.emplace(insert_pos, entryType, name, blobKey, mode, uid, gid, lastAccessTime, lastModificationTime, cpputils::time::now()); } void DirEntryList::addOrOverwrite(const string &name, const Key &blobKey, fspp::Dir::EntryType entryType, mode_t mode, diff --git a/src/cryfs/filesystem/fsblobstore/utils/time.h b/src/cryfs/filesystem/fsblobstore/utils/time.h deleted file mode 100644 index f5311154..00000000 --- a/src/cryfs/filesystem/fsblobstore/utils/time.h +++ /dev/null @@ -1,22 +0,0 @@ -#pragma once -#ifndef MESSMER_CRYFS_FILESYTEM_FSBLOBSTORE_UTILS_TIME_H -#define MESSMER_CRYFS_FILESYTEM_FSBLOBSTORE_UTILS_TIME_H - -#include -#include - -namespace cryfs { - namespace fsblobstore { - namespace time { - - inline timespec now() { - struct timespec now; - clock_gettime(CLOCK_REALTIME, &now); - return now; - } - - } - } -} - -#endif