Move fsblobstore::now() to cpputils
This commit is contained in:
parent
40c64a879c
commit
f6545bbcc3
19
src/cpp-utils/system/time.h
Normal file
19
src/cpp-utils/system/time.h
Normal file
@ -0,0 +1,19 @@
|
|||||||
|
#pragma once
|
||||||
|
#ifndef MESSMER_CPPUTILS_SYSTEM_TIME_H
|
||||||
|
#define MESSMER_CPPUTILS_SYSTEM_TIME_H
|
||||||
|
|
||||||
|
#include <sys/types.h>
|
||||||
|
#include "clock_gettime.h"
|
||||||
|
|
||||||
|
namespace cpputils {
|
||||||
|
namespace time {
|
||||||
|
// TODO Test
|
||||||
|
inline timespec now() {
|
||||||
|
struct timespec now;
|
||||||
|
clock_gettime(CLOCK_REALTIME, &now);
|
||||||
|
return now;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif
|
@ -9,7 +9,7 @@
|
|||||||
#include "CryDevice.h"
|
#include "CryDevice.h"
|
||||||
#include "CryFile.h"
|
#include "CryFile.h"
|
||||||
#include "CryOpenFile.h"
|
#include "CryOpenFile.h"
|
||||||
#include "fsblobstore/utils/time.h"
|
#include <cpp-utils/system/time.h>
|
||||||
|
|
||||||
//TODO Get rid of this in favor of exception hierarchy
|
//TODO Get rid of this in favor of exception hierarchy
|
||||||
using fspp::fuse::CHECK_RETVAL;
|
using fspp::fuse::CHECK_RETVAL;
|
||||||
@ -40,7 +40,7 @@ CryDir::~CryDir() {
|
|||||||
unique_ref<fspp::OpenFile> CryDir::createAndOpenFile(const string &name, mode_t mode, uid_t uid, gid_t gid) {
|
unique_ref<fspp::OpenFile> CryDir::createAndOpenFile(const string &name, mode_t mode, uid_t uid, gid_t gid) {
|
||||||
device()->callFsActionCallbacks();
|
device()->callFsActionCallbacks();
|
||||||
auto child = device()->CreateFileBlob();
|
auto child = device()->CreateFileBlob();
|
||||||
auto now = fsblobstore::time::now();
|
auto now = cpputils::time::now();
|
||||||
auto dirBlob = LoadBlob();
|
auto dirBlob = LoadBlob();
|
||||||
dirBlob->AddChildFile(name, child->key(), mode, uid, gid, now, now);
|
dirBlob->AddChildFile(name, child->key(), mode, uid, gid, now, now);
|
||||||
return make_unique_ref<CryOpenFile>(device(), cpputils::to_unique_ptr(std::move(dirBlob)), std::move(child));
|
return make_unique_ref<CryOpenFile>(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();
|
device()->callFsActionCallbacks();
|
||||||
auto blob = LoadBlob();
|
auto blob = LoadBlob();
|
||||||
auto child = device()->CreateDirBlob();
|
auto child = device()->CreateDirBlob();
|
||||||
auto now = fsblobstore::time::now();
|
auto now = cpputils::time::now();
|
||||||
blob->AddChildDir(name, child->key(), mode, uid, gid, now, 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();
|
device()->callFsActionCallbacks();
|
||||||
auto blob = LoadBlob();
|
auto blob = LoadBlob();
|
||||||
auto child = device()->CreateSymlinkBlob(target);
|
auto child = device()->CreateSymlinkBlob(target);
|
||||||
auto now = fsblobstore::time::now();
|
auto now = cpputils::time::now();
|
||||||
blob->AddChildSymlink(name, child->key(), uid, gid, now, now);
|
blob->AddChildSymlink(name, child->key(), uid, gid, now, now);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -4,7 +4,7 @@
|
|||||||
|
|
||||||
#include <blockstore/utils/Key.h>
|
#include <blockstore/utils/Key.h>
|
||||||
#include <fspp/fs_interface/Dir.h>
|
#include <fspp/fs_interface/Dir.h>
|
||||||
#include "time.h"
|
#include <cpp-utils/system/time.h>
|
||||||
|
|
||||||
namespace cryfs {
|
namespace cryfs {
|
||||||
namespace fsblobstore {
|
namespace fsblobstore {
|
||||||
@ -166,7 +166,7 @@ namespace cryfs {
|
|||||||
}
|
}
|
||||||
|
|
||||||
inline void DirEntry::_updateLastMetadataChangeTime() {
|
inline void DirEntry::_updateLastMetadataChangeTime() {
|
||||||
setLastMetadataChangeTime(time::now());
|
setLastMetadataChangeTime(cpputils::time::now());
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
#include "DirEntryList.h"
|
#include "DirEntryList.h"
|
||||||
#include <limits>
|
#include <limits>
|
||||||
#include "time.h"
|
#include <cpp-utils/system/time.h>
|
||||||
|
|
||||||
//TODO Get rid of that in favor of better error handling
|
//TODO Get rid of that in favor of better error handling
|
||||||
#include <fspp/fuse/FuseErrnoException.h>
|
#include <fspp/fuse/FuseErrnoException.h>
|
||||||
@ -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,
|
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) {
|
uid_t uid, gid_t gid, timespec lastAccessTime, timespec lastModificationTime) {
|
||||||
auto insert_pos = _findUpperBound(blobKey);
|
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,
|
void DirEntryList::addOrOverwrite(const string &name, const Key &blobKey, fspp::Dir::EntryType entryType, mode_t mode,
|
||||||
|
@ -1,22 +0,0 @@
|
|||||||
#pragma once
|
|
||||||
#ifndef MESSMER_CRYFS_FILESYTEM_FSBLOBSTORE_UTILS_TIME_H
|
|
||||||
#define MESSMER_CRYFS_FILESYTEM_FSBLOBSTORE_UTILS_TIME_H
|
|
||||||
|
|
||||||
#include <sys/types.h>
|
|
||||||
#include <cpp-utils/system/clock_gettime.h>
|
|
||||||
|
|
||||||
namespace cryfs {
|
|
||||||
namespace fsblobstore {
|
|
||||||
namespace time {
|
|
||||||
|
|
||||||
inline timespec now() {
|
|
||||||
struct timespec now;
|
|
||||||
clock_gettime(CLOCK_REALTIME, &now);
|
|
||||||
return now;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
#endif
|
|
Loading…
Reference in New Issue
Block a user