Introduce fspp::uid_t, fspp::gid_t and fspp::mode_t
This commit is contained in:
parent
8f2fc3b6b8
commit
b1dfd94243
@ -80,9 +80,6 @@ protected:
|
||||
static_assert(std::is_base_of<IdValueType<ConcreteType, UnderlyingType>, ConcreteType>::value,
|
||||
"CRTP violated. First template parameter of this class must be the concrete class.");
|
||||
}
|
||||
constexpr underlying_type& underlying_value() const noexcept {
|
||||
return value_;
|
||||
}
|
||||
|
||||
friend struct std::hash<ConcreteType>;
|
||||
|
||||
|
@ -36,7 +36,7 @@ CryDir::CryDir(CryDevice *device, optional<unique_ref<DirBlobRef>> parent, optio
|
||||
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, fspp::mode_t mode, fspp::uid_t uid, fspp::gid_t gid) {
|
||||
device()->callFsActionCallbacks();
|
||||
if (!isRootDir()) {
|
||||
//TODO Instead of doing nothing when we're the root directory, handle timestamps in the root dir correctly (and delete isRootDir() function)
|
||||
@ -49,7 +49,7 @@ unique_ref<fspp::OpenFile> CryDir::createAndOpenFile(const string &name, mode_t
|
||||
return make_unique_ref<CryOpenFile>(device(), std::move(dirBlob), std::move(child));
|
||||
}
|
||||
|
||||
void CryDir::createDir(const string &name, mode_t mode, uid_t uid, gid_t gid) {
|
||||
void CryDir::createDir(const string &name, fspp::mode_t mode, fspp::uid_t uid, fspp::gid_t gid) {
|
||||
device()->callFsActionCallbacks();
|
||||
if (!isRootDir()) {
|
||||
//TODO Instead of doing nothing when we're the root directory, handle timestamps in the root dir correctly (and delete isRootDir() function)
|
||||
@ -87,7 +87,7 @@ fspp::Dir::EntryType CryDir::getType() const {
|
||||
return fspp::Dir::EntryType::DIR;
|
||||
}
|
||||
|
||||
void CryDir::createSymlink(const string &name, const bf::path &target, uid_t uid, gid_t gid) {
|
||||
void CryDir::createSymlink(const string &name, const bf::path &target, fspp::uid_t uid, fspp::gid_t gid) {
|
||||
device()->callFsActionCallbacks();
|
||||
if (!isRootDir()) {
|
||||
//TODO Instead of doing nothing when we're the root directory, handle timestamps in the root dir correctly (and delete isRootDir() function)
|
||||
|
@ -14,9 +14,9 @@ public:
|
||||
~CryDir();
|
||||
|
||||
//TODO return type variance to CryFile/CryDir?
|
||||
cpputils::unique_ref<fspp::OpenFile> createAndOpenFile(const std::string &name, mode_t mode, uid_t uid, gid_t gid) override;
|
||||
void createDir(const std::string &name, mode_t mode, uid_t uid, gid_t gid) override;
|
||||
void createSymlink(const std::string &name, const boost::filesystem::path &target, uid_t uid, gid_t gid) override;
|
||||
cpputils::unique_ref<fspp::OpenFile> createAndOpenFile(const std::string &name, fspp::mode_t mode, fspp::uid_t uid, fspp::gid_t gid) override;
|
||||
void createDir(const std::string &name, fspp::mode_t mode, fspp::uid_t uid, fspp::gid_t gid) override;
|
||||
void createSymlink(const std::string &name, const boost::filesystem::path &target, fspp::uid_t uid, fspp::gid_t gid) override;
|
||||
|
||||
//TODO Make Entry a public class instead of hidden in DirBlob (which is not publicly visible)
|
||||
cpputils::unique_ref<std::vector<fspp::Dir::Entry>> children() override;
|
||||
|
@ -163,9 +163,9 @@ CryNode::stat_info CryNode::stat() const {
|
||||
stat_info result;
|
||||
//We are the root directory.
|
||||
//TODO What should we do?
|
||||
result.uid = getuid();
|
||||
result.gid = getgid();
|
||||
result.mode = S_IFDIR | S_IRUSR | S_IWUSR | S_IXUSR;
|
||||
result.uid = fspp::uid_t(getuid());
|
||||
result.gid = fspp::gid_t(getgid());
|
||||
result.mode = fspp::mode_t().addDirFlag().addUserReadFlag().addUserWriteFlag().addUserExecFlag();
|
||||
result.size = fsblobstore::DirBlob::DIR_LSTAT_SIZE;
|
||||
//TODO If possible without performance loss, then for a directory, st_nlink should return number of dir entries (including "." and "..")
|
||||
result.nlink = 1;
|
||||
@ -179,7 +179,7 @@ CryNode::stat_info CryNode::stat() const {
|
||||
}
|
||||
}
|
||||
|
||||
void CryNode::chmod(mode_t mode) {
|
||||
void CryNode::chmod(fspp::mode_t mode) {
|
||||
device()->callFsActionCallbacks();
|
||||
if (_parent == none) {
|
||||
//We are the root direcory.
|
||||
@ -189,7 +189,7 @@ void CryNode::chmod(mode_t mode) {
|
||||
(*_parent)->chmodChild(_blockId, mode);
|
||||
}
|
||||
|
||||
void CryNode::chown(uid_t uid, gid_t gid) {
|
||||
void CryNode::chown(fspp::uid_t uid, fspp::gid_t gid) {
|
||||
device()->callFsActionCallbacks();
|
||||
if (_parent == none) {
|
||||
//We are the root direcory.
|
||||
|
@ -18,8 +18,8 @@ public:
|
||||
CryNode(CryDevice *device, boost::optional<cpputils::unique_ref<parallelaccessfsblobstore::DirBlobRef>> parent, boost::optional<cpputils::unique_ref<parallelaccessfsblobstore::DirBlobRef>> grandparent, const blockstore::BlockId &blockId);
|
||||
void access(int mask) const override;
|
||||
stat_info stat() const override;
|
||||
void chmod(mode_t mode) override;
|
||||
void chown(uid_t uid, gid_t gid) override;
|
||||
void chmod(fspp::mode_t mode) override;
|
||||
void chown(fspp::uid_t uid, fspp::gid_t gid) override;
|
||||
void rename(const boost::filesystem::path &to) override;
|
||||
void utimens(timespec lastAccessTime, timespec lastModificationTime) override;
|
||||
|
||||
|
@ -45,7 +45,7 @@ public:
|
||||
}
|
||||
|
||||
void AddOrOverwriteChild(const std::string &name, const blockstore::BlockId &blobId, fspp::Dir::EntryType type,
|
||||
mode_t mode, uid_t uid, gid_t gid, timespec lastAccessTime, timespec lastModificationTime,
|
||||
fspp::mode_t mode, fspp::uid_t uid, fspp::gid_t gid, timespec lastAccessTime, timespec lastModificationTime,
|
||||
std::function<void (const blockstore::BlockId &blockId)> onOverwritten) {
|
||||
return _base->AddOrOverwriteChild(name, blobId, type, mode, uid, gid, lastAccessTime, lastModificationTime, onOverwritten);
|
||||
}
|
||||
@ -70,11 +70,11 @@ public:
|
||||
return _base->updateModificationTimestampForChild(blockId);
|
||||
}
|
||||
|
||||
void chmodChild(const blockstore::BlockId &blockId, mode_t mode) {
|
||||
void chmodChild(const blockstore::BlockId &blockId, fspp::mode_t mode) {
|
||||
return _base->chmodChild(blockId, mode);
|
||||
}
|
||||
|
||||
void chownChild(const blockstore::BlockId &blockId, uid_t uid, gid_t gid) {
|
||||
void chownChild(const blockstore::BlockId &blockId, fspp::uid_t uid, fspp::gid_t gid) {
|
||||
return _base->chownChild(blockId, uid, gid);
|
||||
}
|
||||
|
||||
@ -82,15 +82,15 @@ public:
|
||||
return _base->utimensChild(blockId, lastAccessTime, lastModificationTime);
|
||||
}
|
||||
|
||||
void AddChildDir(const std::string &name, const blockstore::BlockId &blobId, mode_t mode, uid_t uid, gid_t gid, timespec lastAccessTime, timespec lastModificationTime) {
|
||||
void AddChildDir(const std::string &name, const blockstore::BlockId &blobId, fspp::mode_t mode, fspp::uid_t uid, fspp::gid_t gid, timespec lastAccessTime, timespec lastModificationTime) {
|
||||
return _base->AddChildDir(name, blobId, mode, uid, gid, lastAccessTime, lastModificationTime);
|
||||
}
|
||||
|
||||
void AddChildFile(const std::string &name, const blockstore::BlockId &blobId, mode_t mode, uid_t uid, gid_t gid, timespec lastAccessTime, timespec lastModificationTime) {
|
||||
void AddChildFile(const std::string &name, const blockstore::BlockId &blobId, fspp::mode_t mode, fspp::uid_t uid, fspp::gid_t gid, timespec lastAccessTime, timespec lastModificationTime) {
|
||||
return _base->AddChildFile(name, blobId, mode, uid, gid, lastAccessTime, lastModificationTime);
|
||||
}
|
||||
|
||||
void AddChildSymlink(const std::string &name, const blockstore::BlockId &blobId, uid_t uid, gid_t gid, timespec lastAccessTime, timespec lastModificationTime) {
|
||||
void AddChildSymlink(const std::string &name, const blockstore::BlockId &blobId, fspp::uid_t uid, fspp::gid_t gid, timespec lastAccessTime, timespec lastModificationTime) {
|
||||
return _base->AddChildSymlink(name, blobId, uid, gid, lastAccessTime, lastModificationTime);
|
||||
}
|
||||
|
||||
|
@ -63,29 +63,33 @@ void DirBlob::_readEntriesFromBlob() {
|
||||
_entries.deserializeFrom(static_cast<uint8_t*>(data.data()), data.size());
|
||||
}
|
||||
|
||||
void DirBlob::AddChildDir(const std::string &name, const BlockId &blobId, mode_t mode, uid_t uid, gid_t gid, timespec lastAccessTime, timespec lastModificationTime) {
|
||||
void DirBlob::AddChildDir(const std::string &name, const BlockId &blobId, fspp::mode_t mode, fspp::uid_t uid, fspp::gid_t gid, timespec lastAccessTime, timespec lastModificationTime) {
|
||||
std::unique_lock<std::mutex> lock(_mutex);
|
||||
_addChild(name, blobId, fspp::Dir::EntryType::DIR, mode, uid, gid, lastAccessTime, lastModificationTime);
|
||||
}
|
||||
|
||||
void DirBlob::AddChildFile(const std::string &name, const BlockId &blobId, mode_t mode, uid_t uid, gid_t gid, timespec lastAccessTime, timespec lastModificationTime) {
|
||||
void DirBlob::AddChildFile(const std::string &name, const BlockId &blobId, fspp::mode_t mode, fspp::uid_t uid, fspp::gid_t gid, timespec lastAccessTime, timespec lastModificationTime) {
|
||||
std::unique_lock<std::mutex> lock(_mutex);
|
||||
_addChild(name, blobId, fspp::Dir::EntryType::FILE, mode, uid, gid, lastAccessTime, lastModificationTime);
|
||||
}
|
||||
|
||||
void DirBlob::AddChildSymlink(const std::string &name, const blockstore::BlockId &blobId, uid_t uid, gid_t gid, timespec lastAccessTime, timespec lastModificationTime) {
|
||||
void DirBlob::AddChildSymlink(const std::string &name, const blockstore::BlockId &blobId, fspp::uid_t uid, fspp::gid_t gid, timespec lastAccessTime, timespec lastModificationTime) {
|
||||
std::unique_lock<std::mutex> lock(_mutex);
|
||||
_addChild(name, blobId, fspp::Dir::EntryType::SYMLINK, S_IFLNK | S_IRUSR | S_IWUSR | S_IXUSR | S_IRGRP | S_IWGRP | S_IXGRP | S_IROTH | S_IWOTH | S_IXOTH, uid, gid, lastAccessTime, lastModificationTime);
|
||||
auto mode = fspp::mode_t().addSymlinkFlag()
|
||||
.addUserReadFlag().addUserWriteFlag().addUserExecFlag()
|
||||
.addGroupReadFlag().addGroupWriteFlag().addGroupExecFlag()
|
||||
.addOtherReadFlag().addOtherWriteFlag().addOtherExecFlag();
|
||||
_addChild(name, blobId, fspp::Dir::EntryType::SYMLINK, mode, uid, gid, lastAccessTime, lastModificationTime);
|
||||
}
|
||||
|
||||
void DirBlob::_addChild(const std::string &name, const BlockId &blobId,
|
||||
fspp::Dir::EntryType entryType, mode_t mode, uid_t uid, gid_t gid, timespec lastAccessTime, timespec lastModificationTime) {
|
||||
fspp::Dir::EntryType entryType, fspp::mode_t mode, fspp::uid_t uid, fspp::gid_t gid, timespec lastAccessTime, timespec lastModificationTime) {
|
||||
_entries.add(name, blobId, entryType, mode, uid, gid, lastAccessTime, lastModificationTime);
|
||||
_changed = true;
|
||||
}
|
||||
|
||||
void DirBlob::AddOrOverwriteChild(const std::string &name, const BlockId &blobId, fspp::Dir::EntryType entryType,
|
||||
mode_t mode, uid_t uid, gid_t gid, timespec lastAccessTime, timespec lastModificationTime,
|
||||
fspp::mode_t mode, fspp::uid_t uid, fspp::gid_t gid, timespec lastAccessTime, timespec lastModificationTime,
|
||||
std::function<void (const blockstore::BlockId &blockId)> onOverwritten) {
|
||||
std::unique_lock<std::mutex> lock(_mutex);
|
||||
_entries.addOrOverwrite(name, blobId, entryType, mode, uid, gid, lastAccessTime, lastModificationTime, onOverwritten);
|
||||
@ -171,13 +175,13 @@ void DirBlob::updateModificationTimestampForChild(const BlockId &blockId) {
|
||||
_changed = true;
|
||||
}
|
||||
|
||||
void DirBlob::chmodChild(const BlockId &blockId, mode_t mode) {
|
||||
void DirBlob::chmodChild(const BlockId &blockId, fspp::mode_t mode) {
|
||||
std::unique_lock<std::mutex> lock(_mutex);
|
||||
_entries.setMode(blockId, mode);
|
||||
_changed = true;
|
||||
}
|
||||
|
||||
void DirBlob::chownChild(const BlockId &blockId, uid_t uid, gid_t gid) {
|
||||
void DirBlob::chownChild(const BlockId &blockId, fspp::uid_t uid, fspp::gid_t gid) {
|
||||
std::unique_lock<std::mutex> lock(_mutex);
|
||||
if(_entries.setUidGid(blockId, uid, gid)) {
|
||||
_changed = true;
|
||||
|
@ -37,16 +37,16 @@ namespace cryfs {
|
||||
|
||||
boost::optional<const DirEntry&> GetChild(const blockstore::BlockId &blobId) const;
|
||||
|
||||
void AddChildDir(const std::string &name, const blockstore::BlockId &blobId, mode_t mode, uid_t uid,
|
||||
gid_t gid, timespec lastAccessTime, timespec lastModificationTime);
|
||||
void AddChildDir(const std::string &name, const blockstore::BlockId &blobId, fspp::mode_t mode, fspp::uid_t uid,
|
||||
fspp::gid_t gid, timespec lastAccessTime, timespec lastModificationTime);
|
||||
|
||||
void AddChildFile(const std::string &name, const blockstore::BlockId &blobId, mode_t mode, uid_t uid,
|
||||
gid_t gid, timespec lastAccessTime, timespec lastModificationTime);
|
||||
void AddChildFile(const std::string &name, const blockstore::BlockId &blobId, fspp::mode_t mode, fspp::uid_t uid,
|
||||
fspp::gid_t gid, timespec lastAccessTime, timespec lastModificationTime);
|
||||
|
||||
void AddChildSymlink(const std::string &name, const blockstore::BlockId &blobId, uid_t uid, gid_t gid, timespec lastAccessTime, timespec lastModificationTime);
|
||||
void AddChildSymlink(const std::string &name, const blockstore::BlockId &blobId, fspp::uid_t uid, fspp::gid_t gid, timespec lastAccessTime, timespec lastModificationTime);
|
||||
|
||||
void AddOrOverwriteChild(const std::string &name, const blockstore::BlockId &blobId, fspp::Dir::EntryType type,
|
||||
mode_t mode, uid_t uid, gid_t gid, timespec lastAccessTime, timespec lastModificationTime,
|
||||
fspp::mode_t mode, fspp::uid_t uid, fspp::gid_t gid, timespec lastAccessTime, timespec lastModificationTime,
|
||||
std::function<void (const blockstore::BlockId &blockId)> onOverwritten);
|
||||
|
||||
void RenameChild(const blockstore::BlockId &blockId, const std::string &newName, std::function<void (const blockstore::BlockId &blockId)> onOverwritten);
|
||||
@ -65,9 +65,9 @@ namespace cryfs {
|
||||
|
||||
void updateModificationTimestampForChild(const blockstore::BlockId &blockId);
|
||||
|
||||
void chmodChild(const blockstore::BlockId &blockId, mode_t mode);
|
||||
void chmodChild(const blockstore::BlockId &blockId, fspp::mode_t mode);
|
||||
|
||||
void chownChild(const blockstore::BlockId &blockId, uid_t uid, gid_t gid);
|
||||
void chownChild(const blockstore::BlockId &blockId, fspp::uid_t uid, fspp::gid_t gid);
|
||||
|
||||
void utimensChild(const blockstore::BlockId &blockId, timespec lastAccessTime, timespec lastModificationTime);
|
||||
|
||||
@ -76,7 +76,7 @@ namespace cryfs {
|
||||
private:
|
||||
|
||||
void _addChild(const std::string &name, const blockstore::BlockId &blobId, fspp::Dir::EntryType type,
|
||||
mode_t mode, uid_t uid, gid_t gid, timespec lastAccessTime, timespec lastModificationTime);
|
||||
fspp::mode_t mode, fspp::uid_t uid, fspp::gid_t gid, timespec lastAccessTime, timespec lastModificationTime);
|
||||
void _readEntriesFromBlob();
|
||||
void _writeEntriesToBlob();
|
||||
|
||||
|
@ -68,17 +68,17 @@ namespace cryfs {
|
||||
|
||||
void DirEntry::serialize(uint8_t *dest) const {
|
||||
ASSERT(
|
||||
((_type == fspp::Dir::EntryType::FILE) && S_ISREG(_mode) && !S_ISDIR(_mode) && !S_ISLNK(_mode)) ||
|
||||
((_type == fspp::Dir::EntryType::DIR) && !S_ISREG(_mode) && S_ISDIR(_mode) && !S_ISLNK(_mode)) ||
|
||||
((_type == fspp::Dir::EntryType::SYMLINK) && !S_ISREG(_mode) && !S_ISDIR(_mode) && S_ISLNK(_mode))
|
||||
, "Wrong mode bit set for this type: " + std::to_string(_mode & S_IFREG) + ", " + std::to_string(
|
||||
_mode & S_IFDIR) + ", " + std::to_string(_mode & S_IFLNK) + ", " + std::to_string(static_cast<uint8_t>(_type))
|
||||
((_type == fspp::Dir::EntryType::FILE) && _mode.hasFileFlag() && !_mode.hasDirFlag() && !_mode.hasSymlinkFlag()) ||
|
||||
((_type == fspp::Dir::EntryType::DIR) && !_mode.hasFileFlag() && _mode.hasDirFlag() && !_mode.hasSymlinkFlag()) ||
|
||||
((_type == fspp::Dir::EntryType::SYMLINK) && !_mode.hasFileFlag() && !_mode.hasDirFlag() && _mode.hasSymlinkFlag())
|
||||
, "Wrong mode bit set for this type: " + std::to_string(_mode.hasFileFlag()) + ", " + std::to_string(
|
||||
_mode.hasDirFlag()) + ", " + std::to_string(_mode.hasSymlinkFlag()) + ", " + std::to_string(static_cast<uint8_t>(_type))
|
||||
);
|
||||
unsigned int offset = 0;
|
||||
offset += _serialize<uint8_t>(dest + offset, static_cast<uint8_t>(_type));
|
||||
offset += _serialize<uint32_t>(dest + offset, _mode);
|
||||
offset += _serialize<uint32_t>(dest + offset, _uid);
|
||||
offset += _serialize<uint32_t>(dest + offset, _gid);
|
||||
offset += _serialize<uint32_t>(dest + offset, _mode.value());
|
||||
offset += _serialize<uint32_t>(dest + offset, _uid.value());
|
||||
offset += _serialize<uint32_t>(dest + offset, _gid.value());
|
||||
offset += _serializeTimeValue(dest + offset, _lastAccessTime);
|
||||
offset += _serializeTimeValue(dest + offset, _lastModificationTime);
|
||||
offset += _serializeTimeValue(dest + offset, _lastMetadataChangeTime);
|
||||
@ -89,9 +89,9 @@ namespace cryfs {
|
||||
|
||||
const char *DirEntry::deserializeAndAddToVector(const char *pos, vector<DirEntry> *result) {
|
||||
fspp::Dir::EntryType type = static_cast<fspp::Dir::EntryType>(_deserialize<uint8_t>(&pos));
|
||||
mode_t mode = _deserialize<uint32_t>(&pos);
|
||||
uid_t uid = _deserialize<uint32_t>(&pos);
|
||||
gid_t gid = _deserialize<uint32_t>(&pos);
|
||||
fspp::mode_t mode = fspp::mode_t(_deserialize<uint32_t>(&pos));
|
||||
fspp::uid_t uid = fspp::uid_t(_deserialize<uint32_t>(&pos));
|
||||
fspp::gid_t gid = fspp::gid_t(_deserialize<uint32_t>(&pos));
|
||||
timespec lastAccessTime = _deserializeTimeValue(&pos);
|
||||
timespec lastModificationTime = _deserializeTimeValue(&pos);
|
||||
timespec lastMetadataChangeTime = _deserializeTimeValue(&pos);
|
||||
|
@ -4,6 +4,7 @@
|
||||
|
||||
#include <blockstore/utils/BlockId.h>
|
||||
#include <fspp/fs_interface/Dir.h>
|
||||
#include <fspp/fs_interface/Types.h>
|
||||
#include <cpp-utils/system/time.h>
|
||||
#include <sys/stat.h>
|
||||
|
||||
@ -12,8 +13,8 @@ namespace cryfs {
|
||||
|
||||
class DirEntry final {
|
||||
public:
|
||||
DirEntry(fspp::Dir::EntryType type, const std::string &name, const blockstore::BlockId &blockId, mode_t mode,
|
||||
uid_t uid, gid_t gid, timespec lastAccessTime, timespec lastModificationTime,
|
||||
DirEntry(fspp::Dir::EntryType type, const std::string &name, const blockstore::BlockId &blockId, fspp::mode_t mode,
|
||||
fspp::uid_t uid, fspp::gid_t gid, timespec lastAccessTime, timespec lastModificationTime,
|
||||
timespec lastMetadataChangeTime);
|
||||
|
||||
void serialize(uint8_t* dest) const;
|
||||
@ -28,14 +29,14 @@ namespace cryfs {
|
||||
|
||||
const blockstore::BlockId &blockId() const;
|
||||
|
||||
mode_t mode() const;
|
||||
void setMode(mode_t value);
|
||||
fspp::mode_t mode() const;
|
||||
void setMode(fspp::mode_t value);
|
||||
|
||||
uid_t uid() const;
|
||||
void setUid(uid_t value);
|
||||
fspp::uid_t uid() const;
|
||||
void setUid(fspp::uid_t value);
|
||||
|
||||
gid_t gid() const;
|
||||
void setGid(gid_t value);
|
||||
fspp::gid_t gid() const;
|
||||
void setGid(fspp::gid_t value);
|
||||
|
||||
timespec lastAccessTime() const;
|
||||
void setLastAccessTime(timespec value);
|
||||
@ -52,33 +53,33 @@ namespace cryfs {
|
||||
fspp::Dir::EntryType _type;
|
||||
std::string _name;
|
||||
blockstore::BlockId _blockId;
|
||||
mode_t _mode;
|
||||
uid_t _uid;
|
||||
gid_t _gid;
|
||||
fspp::mode_t _mode;
|
||||
fspp::uid_t _uid;
|
||||
fspp::gid_t _gid;
|
||||
timespec _lastAccessTime;
|
||||
timespec _lastModificationTime;
|
||||
timespec _lastMetadataChangeTime;
|
||||
};
|
||||
|
||||
inline DirEntry::DirEntry(fspp::Dir::EntryType type, const std::string &name, const blockstore::BlockId &blockId, mode_t mode,
|
||||
uid_t uid, gid_t gid, timespec lastAccessTime, timespec lastModificationTime,
|
||||
inline DirEntry::DirEntry(fspp::Dir::EntryType type, const std::string &name, const blockstore::BlockId &blockId, fspp::mode_t mode,
|
||||
fspp::uid_t uid, fspp::gid_t gid, timespec lastAccessTime, timespec lastModificationTime,
|
||||
timespec lastMetadataChangeTime)
|
||||
: _type(type), _name(name), _blockId(blockId), _mode(mode), _uid(uid), _gid(gid), _lastAccessTime(lastAccessTime),
|
||||
_lastModificationTime(lastModificationTime), _lastMetadataChangeTime(lastMetadataChangeTime) {
|
||||
switch (_type) {
|
||||
case fspp::Dir::EntryType::FILE:
|
||||
_mode |= S_IFREG;
|
||||
_mode.addFileFlag();
|
||||
break;
|
||||
case fspp::Dir::EntryType::DIR:
|
||||
_mode |= S_IFDIR;
|
||||
_mode.addDirFlag();
|
||||
break;
|
||||
case fspp::Dir::EntryType::SYMLINK:
|
||||
_mode |= S_IFLNK;
|
||||
_mode.addSymlinkFlag();
|
||||
break;
|
||||
}
|
||||
ASSERT((S_ISREG(_mode) && _type == fspp::Dir::EntryType::FILE) ||
|
||||
(S_ISDIR(_mode) && _type == fspp::Dir::EntryType::DIR) ||
|
||||
(S_ISLNK(_mode) && _type == fspp::Dir::EntryType::SYMLINK), "Unknown mode in entry");
|
||||
ASSERT((_mode.hasFileFlag() && _type == fspp::Dir::EntryType::FILE) ||
|
||||
(_mode.hasDirFlag() && _type == fspp::Dir::EntryType::DIR) ||
|
||||
(_mode.hasSymlinkFlag() && _type == fspp::Dir::EntryType::SYMLINK), "Unknown mode in entry");
|
||||
}
|
||||
|
||||
inline fspp::Dir::EntryType DirEntry::type() const {
|
||||
@ -93,15 +94,15 @@ namespace cryfs {
|
||||
return _blockId;
|
||||
}
|
||||
|
||||
inline mode_t DirEntry::mode() const {
|
||||
inline fspp::mode_t DirEntry::mode() const {
|
||||
return _mode;
|
||||
}
|
||||
|
||||
inline uid_t DirEntry::uid() const {
|
||||
inline fspp::uid_t DirEntry::uid() const {
|
||||
return _uid;
|
||||
}
|
||||
|
||||
inline gid_t DirEntry::gid() const {
|
||||
inline fspp::gid_t DirEntry::gid() const {
|
||||
return _gid;
|
||||
}
|
||||
|
||||
@ -127,17 +128,17 @@ namespace cryfs {
|
||||
_updateLastMetadataChangeTime();
|
||||
}
|
||||
|
||||
inline void DirEntry::setMode(mode_t value) {
|
||||
inline void DirEntry::setMode(fspp::mode_t value) {
|
||||
_mode = value;
|
||||
_updateLastMetadataChangeTime();
|
||||
}
|
||||
|
||||
inline void DirEntry::setUid(uid_t value) {
|
||||
inline void DirEntry::setUid(fspp::uid_t value) {
|
||||
_uid = value;
|
||||
_updateLastMetadataChangeTime();
|
||||
}
|
||||
|
||||
inline void DirEntry::setGid(gid_t value) {
|
||||
inline void DirEntry::setGid(fspp::gid_t value) {
|
||||
_gid = value;
|
||||
_updateLastMetadataChangeTime();
|
||||
}
|
||||
|
@ -48,22 +48,22 @@ bool DirEntryList::_hasChild(const string &name) const {
|
||||
return _entries.end() != _findByName(name);
|
||||
}
|
||||
|
||||
void DirEntryList::add(const string &name, const BlockId &blobId, fspp::Dir::EntryType entryType, mode_t mode,
|
||||
uid_t uid, gid_t gid, timespec lastAccessTime, timespec lastModificationTime) {
|
||||
void DirEntryList::add(const string &name, const BlockId &blobId, fspp::Dir::EntryType entryType, fspp::mode_t mode,
|
||||
fspp::uid_t uid, fspp::gid_t gid, timespec lastAccessTime, timespec lastModificationTime) {
|
||||
if (_hasChild(name)) {
|
||||
throw fspp::fuse::FuseErrnoException(EEXIST);
|
||||
}
|
||||
_add(name, blobId, entryType, mode, uid, gid, lastAccessTime, lastModificationTime);
|
||||
}
|
||||
|
||||
void DirEntryList::_add(const string &name, const BlockId &blobId, fspp::Dir::EntryType entryType, mode_t mode,
|
||||
uid_t uid, gid_t gid, timespec lastAccessTime, timespec lastModificationTime) {
|
||||
void DirEntryList::_add(const string &name, const BlockId &blobId, fspp::Dir::EntryType entryType, fspp::mode_t mode,
|
||||
fspp::uid_t uid, fspp::gid_t gid, timespec lastAccessTime, timespec lastModificationTime) {
|
||||
auto insert_pos = _findUpperBound(blobId);
|
||||
_entries.emplace(insert_pos, entryType, name, blobId, mode, uid, gid, lastAccessTime, lastModificationTime, cpputils::time::now());
|
||||
}
|
||||
|
||||
void DirEntryList::addOrOverwrite(const string &name, const BlockId &blobId, fspp::Dir::EntryType entryType, mode_t mode,
|
||||
uid_t uid, gid_t gid, timespec lastAccessTime, timespec lastModificationTime,
|
||||
void DirEntryList::addOrOverwrite(const string &name, const BlockId &blobId, fspp::Dir::EntryType entryType, fspp::mode_t mode,
|
||||
fspp::uid_t uid, fspp::gid_t gid, timespec lastAccessTime, timespec lastModificationTime,
|
||||
std::function<void (const blockstore::BlockId &blockId)> onOverwritten) {
|
||||
auto found = _findByName(name);
|
||||
if (found != _entries.end()) {
|
||||
@ -98,8 +98,8 @@ void DirEntryList::_checkAllowedOverwrite(fspp::Dir::EntryType oldType, fspp::Di
|
||||
}
|
||||
}
|
||||
|
||||
void DirEntryList::_overwrite(vector<DirEntry>::iterator entry, const string &name, const BlockId &blobId, fspp::Dir::EntryType entryType, mode_t mode,
|
||||
uid_t uid, gid_t gid, timespec lastAccessTime, timespec lastModificationTime) {
|
||||
void DirEntryList::_overwrite(vector<DirEntry>::iterator entry, const string &name, const BlockId &blobId, fspp::Dir::EntryType entryType, fspp::mode_t mode,
|
||||
fspp::uid_t uid, fspp::gid_t gid, timespec lastAccessTime, timespec lastModificationTime) {
|
||||
_checkAllowedOverwrite(entry->type(), entryType);
|
||||
// The new entry has possibly a different blockId, so it has to be in a different list position (list is ordered by blockIds).
|
||||
// That's why we remove-and-add instead of just modifying the existing entry.
|
||||
@ -202,20 +202,20 @@ DirEntryList::const_iterator DirEntryList::end() const {
|
||||
return _entries.end();
|
||||
}
|
||||
|
||||
void DirEntryList::setMode(const BlockId &blockId, mode_t mode) {
|
||||
void DirEntryList::setMode(const BlockId &blockId, fspp::mode_t mode) {
|
||||
auto found = _findById(blockId);
|
||||
ASSERT ((S_ISREG(mode) && S_ISREG(found->mode())) || (S_ISDIR(mode) && S_ISDIR(found->mode())) || (S_ISLNK(mode)), "Unknown mode in entry");
|
||||
ASSERT ((mode.hasFileFlag() && found->mode().hasFileFlag()) || (mode.hasDirFlag() && found->mode().hasDirFlag()) || (mode.hasSymlinkFlag()), "Unknown mode in entry");
|
||||
found->setMode(mode);
|
||||
}
|
||||
|
||||
bool DirEntryList::setUidGid(const BlockId &blockId, uid_t uid, gid_t gid) {
|
||||
bool DirEntryList::setUidGid(const BlockId &blockId, fspp::uid_t uid, fspp::gid_t gid) {
|
||||
auto found = _findById(blockId);
|
||||
bool changed = false;
|
||||
if (uid != static_cast<uid_t>(-1)) {
|
||||
if (uid != fspp::uid_t(-1)) {
|
||||
found->setUid(uid);
|
||||
changed = true;
|
||||
}
|
||||
if (gid != static_cast<gid_t>(-1)) {
|
||||
if (gid != fspp::gid_t(-1)) {
|
||||
found->setGid(gid);
|
||||
changed = true;
|
||||
}
|
||||
|
@ -23,9 +23,9 @@ namespace cryfs {
|
||||
void deserializeFrom(const void *data, uint64_t size);
|
||||
|
||||
void add(const std::string &name, const blockstore::BlockId &blobId, fspp::Dir::EntryType entryType,
|
||||
mode_t mode, uid_t uid, gid_t gid, timespec lastAccessTime, timespec lastModificationTime);
|
||||
fspp::mode_t mode, fspp::uid_t uid, fspp::gid_t gid, timespec lastAccessTime, timespec lastModificationTime);
|
||||
void addOrOverwrite(const std::string &name, const blockstore::BlockId &blobId, fspp::Dir::EntryType entryType,
|
||||
mode_t mode, uid_t uid, gid_t gid, timespec lastAccessTime, timespec lastModificationTime,
|
||||
fspp::mode_t mode, fspp::uid_t uid, fspp::gid_t gid, timespec lastAccessTime, timespec lastModificationTime,
|
||||
std::function<void (const blockstore::BlockId &blockId)> onOverwritten);
|
||||
void rename(const blockstore::BlockId &blockId, const std::string &name, std::function<void (const blockstore::BlockId &blockId)> onOverwritten);
|
||||
boost::optional<const DirEntry&> get(const std::string &name) const;
|
||||
@ -37,8 +37,8 @@ namespace cryfs {
|
||||
const_iterator begin() const;
|
||||
const_iterator end() const;
|
||||
|
||||
void setMode(const blockstore::BlockId &blockId, mode_t mode);
|
||||
bool setUidGid(const blockstore::BlockId &blockId, uid_t uid, gid_t gid);
|
||||
void setMode(const blockstore::BlockId &blockId, fspp::mode_t mode);
|
||||
bool setUidGid(const blockstore::BlockId &blockId, fspp::uid_t uid, fspp::gid_t gid);
|
||||
void setAccessTimes(const blockstore::BlockId &blockId, timespec lastAccessTime, timespec lastModificationTime);
|
||||
bool updateAccessTimestampForChild(const blockstore::BlockId &blockId, TimestampUpdateBehavior timestampUpdateBehavior);
|
||||
void updateModificationTimestampForChild(const blockstore::BlockId &blockId);
|
||||
@ -54,9 +54,9 @@ namespace cryfs {
|
||||
std::vector<DirEntry>::iterator _findLowerBound(const blockstore::BlockId &blockId);
|
||||
std::vector<DirEntry>::iterator _findFirst(const blockstore::BlockId &hint, std::function<bool (const DirEntry&)> pred);
|
||||
void _add(const std::string &name, const blockstore::BlockId &blobId, fspp::Dir::EntryType entryType,
|
||||
mode_t mode, uid_t uid, gid_t gid, timespec lastAccessTime, timespec lastModificationTime);
|
||||
fspp::mode_t mode, fspp::uid_t uid, fspp::gid_t gid, timespec lastAccessTime, timespec lastModificationTime);
|
||||
void _overwrite(std::vector<DirEntry>::iterator entry, const std::string &name, const blockstore::BlockId &blobId, fspp::Dir::EntryType entryType,
|
||||
mode_t mode, uid_t uid, gid_t gid, timespec lastAccessTime, timespec lastModificationTime);
|
||||
fspp::mode_t mode, fspp::uid_t uid, fspp::gid_t gid, timespec lastAccessTime, timespec lastModificationTime);
|
||||
static void _checkAllowedOverwrite(fspp::Dir::EntryType oldType, fspp::Dir::EntryType newType);
|
||||
|
||||
std::vector<DirEntry> _entries;
|
||||
|
@ -41,7 +41,7 @@ public:
|
||||
}
|
||||
|
||||
void AddOrOverwriteChild(const std::string &name, const blockstore::BlockId &blobId, fspp::Dir::EntryType type,
|
||||
mode_t mode, uid_t uid, gid_t gid, timespec lastAccessTime, timespec lastModificationTime,
|
||||
fspp::mode_t mode, fspp::uid_t uid, fspp::gid_t gid, timespec lastAccessTime, timespec lastModificationTime,
|
||||
std::function<void (const blockstore::BlockId &blockId)> onOverwritten) {
|
||||
return _base->AddOrOverwriteChild(name, blobId, type, mode, uid, gid, lastAccessTime, lastModificationTime, onOverwritten);
|
||||
}
|
||||
@ -66,11 +66,11 @@ public:
|
||||
return _base->updateModificationTimestampForChild(blockId);
|
||||
}
|
||||
|
||||
void chmodChild(const blockstore::BlockId &blockId, mode_t mode) {
|
||||
void chmodChild(const blockstore::BlockId &blockId, fspp::mode_t mode) {
|
||||
return _base->chmodChild(blockId, mode);
|
||||
}
|
||||
|
||||
void chownChild(const blockstore::BlockId &blockId, uid_t uid, gid_t gid) {
|
||||
void chownChild(const blockstore::BlockId &blockId, fspp::uid_t uid, fspp::gid_t gid) {
|
||||
return _base->chownChild(blockId, uid, gid);
|
||||
}
|
||||
|
||||
@ -78,15 +78,15 @@ public:
|
||||
return _base->utimensChild(blockId, lastAccessTime, lastModificationTime);
|
||||
}
|
||||
|
||||
void AddChildDir(const std::string &name, const blockstore::BlockId &blobId, mode_t mode, uid_t uid, gid_t gid, timespec lastAccessTime, timespec lastModificationTime) {
|
||||
void AddChildDir(const std::string &name, const blockstore::BlockId &blobId, fspp::mode_t mode, fspp::uid_t uid, fspp::gid_t gid, timespec lastAccessTime, timespec lastModificationTime) {
|
||||
return _base->AddChildDir(name, blobId, mode, uid, gid, lastAccessTime, lastModificationTime);
|
||||
}
|
||||
|
||||
void AddChildFile(const std::string &name, const blockstore::BlockId &blobId, mode_t mode, uid_t uid, gid_t gid, timespec lastAccessTime, timespec lastModificationTime) {
|
||||
void AddChildFile(const std::string &name, const blockstore::BlockId &blobId, fspp::mode_t mode, fspp::uid_t uid, fspp::gid_t gid, timespec lastAccessTime, timespec lastModificationTime) {
|
||||
return _base->AddChildFile(name, blobId, mode, uid, gid, lastAccessTime, lastModificationTime);
|
||||
}
|
||||
|
||||
void AddChildSymlink(const std::string &name, const blockstore::BlockId &blobId, uid_t uid, gid_t gid, timespec lastAccessTime, timespec lastModificationTime) {
|
||||
void AddChildSymlink(const std::string &name, const blockstore::BlockId &blobId, fspp::uid_t uid, fspp::gid_t gid, timespec lastAccessTime, timespec lastModificationTime) {
|
||||
return _base->AddChildSymlink(name, blobId, uid, gid, lastAccessTime, lastModificationTime);
|
||||
}
|
||||
|
||||
|
@ -3,9 +3,9 @@
|
||||
#define MESSMER_FSPP_FSINTERFACE_DIR_H_
|
||||
|
||||
#include <cpp-utils/pointer/unique_ref.h>
|
||||
#include <cpp-utils/value_type/ValueType.h>
|
||||
#include <string>
|
||||
#include <boost/filesystem/path.hpp>
|
||||
#include "Types.h"
|
||||
|
||||
namespace fspp {
|
||||
class Device;
|
||||
@ -27,9 +27,9 @@ public:
|
||||
std::string name;
|
||||
};
|
||||
|
||||
virtual cpputils::unique_ref<OpenFile> createAndOpenFile(const std::string &name, mode_t mode, uid_t uid, gid_t gid) = 0;
|
||||
virtual void createDir(const std::string &name, mode_t mode, uid_t uid, gid_t gid) = 0;
|
||||
virtual void createSymlink(const std::string &name, const boost::filesystem::path &target, uid_t uid, gid_t gid) = 0;
|
||||
virtual cpputils::unique_ref<OpenFile> createAndOpenFile(const std::string &name, fspp::mode_t mode, fspp::uid_t uid, fspp::gid_t gid) = 0;
|
||||
virtual void createDir(const std::string &name, fspp::mode_t mode, fspp::uid_t uid, fspp::gid_t gid) = 0;
|
||||
virtual void createSymlink(const std::string &name, const boost::filesystem::path &target, fspp::uid_t uid, fspp::gid_t gid) = 0;
|
||||
|
||||
//TODO Allow alternative implementation returning only children names without more information
|
||||
//virtual std::unique_ptr<std::vector<std::string>> children() const = 0;
|
||||
|
@ -14,8 +14,8 @@ public:
|
||||
using stat_info = fspp::stat_info;
|
||||
|
||||
virtual stat_info stat() const = 0;
|
||||
virtual void chmod(mode_t mode) = 0;
|
||||
virtual void chown(uid_t uid, gid_t gid) = 0;
|
||||
virtual void chmod(fspp::mode_t mode) = 0;
|
||||
virtual void chown(fspp::uid_t uid, fspp::gid_t gid) = 0;
|
||||
virtual void access(int mask) const = 0;
|
||||
virtual void rename(const boost::filesystem::path &to) = 0; // 'to' will always be an absolute path (but on Windows without the device specifier, i.e. starting with '/')
|
||||
virtual void utimens(const timespec lastAccessTime, const timespec lastModificationTime) = 0;
|
||||
|
@ -4,14 +4,120 @@
|
||||
|
||||
#include <cstdint>
|
||||
#include <ctime>
|
||||
#include <cpp-utils/value_type/ValueType.h>
|
||||
|
||||
namespace fspp {
|
||||
|
||||
struct uid_t final : cpputils::value_type::IdValueType<uid_t, uint32_t> {
|
||||
// TODO Remove default constructor
|
||||
constexpr uid_t() noexcept: IdValueType(0) {}
|
||||
|
||||
constexpr explicit uid_t(uint32_t id) noexcept: IdValueType(id) {}
|
||||
|
||||
constexpr uint32_t value() const noexcept {
|
||||
return value_;
|
||||
}
|
||||
};
|
||||
|
||||
struct gid_t final : cpputils::value_type::IdValueType<gid_t, uint32_t> {
|
||||
// TODO Remove default constructor
|
||||
constexpr gid_t() noexcept: IdValueType(0) {}
|
||||
|
||||
constexpr explicit gid_t(uint32_t id) noexcept: IdValueType(id) {}
|
||||
|
||||
constexpr uint32_t value() const noexcept {
|
||||
return value_;
|
||||
}
|
||||
};
|
||||
|
||||
struct mode_t final : cpputils::value_type::FlagsValueType<mode_t, uint32_t> {
|
||||
// TODO Remove default constructor
|
||||
constexpr mode_t() noexcept: FlagsValueType(0) {}
|
||||
|
||||
constexpr explicit mode_t(uint32_t id) noexcept: FlagsValueType(id) {}
|
||||
|
||||
constexpr uint32_t value() const noexcept {
|
||||
return value_;
|
||||
}
|
||||
|
||||
constexpr mode_t& addFileFlag() noexcept {
|
||||
value_ |= S_IFREG;
|
||||
return *this;
|
||||
}
|
||||
|
||||
constexpr mode_t& addDirFlag() noexcept {
|
||||
value_ |= S_IFDIR;
|
||||
return *this;
|
||||
}
|
||||
|
||||
constexpr mode_t& addSymlinkFlag() noexcept {
|
||||
value_ |= S_IFLNK;
|
||||
return *this;
|
||||
}
|
||||
|
||||
constexpr mode_t& addUserReadFlag() noexcept {
|
||||
value_ |= S_IRUSR;
|
||||
return *this;
|
||||
}
|
||||
|
||||
constexpr mode_t& addUserWriteFlag() noexcept {
|
||||
value_ |= S_IWUSR;
|
||||
return *this;
|
||||
}
|
||||
|
||||
constexpr mode_t& addUserExecFlag() noexcept {
|
||||
value_ |= S_IXUSR;
|
||||
return *this;
|
||||
}
|
||||
|
||||
constexpr mode_t& addGroupReadFlag() noexcept {
|
||||
value_ |= S_IRGRP;
|
||||
return *this;
|
||||
}
|
||||
|
||||
constexpr mode_t& addGroupWriteFlag() noexcept {
|
||||
value_ |= S_IWGRP;
|
||||
return *this;
|
||||
}
|
||||
|
||||
constexpr mode_t& addGroupExecFlag() noexcept {
|
||||
value_ |= S_IXGRP;
|
||||
return *this;
|
||||
}
|
||||
|
||||
constexpr mode_t& addOtherReadFlag() noexcept {
|
||||
value_ |= S_IROTH;
|
||||
return *this;
|
||||
}
|
||||
|
||||
constexpr mode_t& addOtherWriteFlag() noexcept {
|
||||
value_ |= S_IWOTH;
|
||||
return *this;
|
||||
}
|
||||
|
||||
constexpr mode_t& addOtherExecFlag() noexcept {
|
||||
value_ |= S_IXOTH;
|
||||
return *this;
|
||||
}
|
||||
|
||||
constexpr bool hasFileFlag() const noexcept {
|
||||
return S_ISREG(value_);
|
||||
}
|
||||
|
||||
constexpr bool hasDirFlag() const noexcept {
|
||||
return S_ISDIR(value_);
|
||||
}
|
||||
|
||||
constexpr bool hasSymlinkFlag() const noexcept {
|
||||
return S_ISLNK(value_);
|
||||
}
|
||||
};
|
||||
|
||||
struct stat_info final {
|
||||
uint32_t nlink;
|
||||
uint32_t mode;
|
||||
uint32_t uid;
|
||||
uint32_t gid;
|
||||
fspp::mode_t mode;
|
||||
fspp::uid_t uid;
|
||||
fspp::gid_t gid;
|
||||
uint64_t size;
|
||||
uint64_t blocks;
|
||||
struct timespec atime;
|
||||
|
@ -8,17 +8,17 @@ template<class ConcreteFileSystemTestFixture>
|
||||
class FsppDeviceTest: public FileSystemTest<ConcreteFileSystemTestFixture> {
|
||||
public:
|
||||
void InitDirStructure() {
|
||||
this->LoadDir("/")->createAndOpenFile("myfile", this->MODE_PUBLIC, 0, 0);
|
||||
this->LoadDir("/")->createSymlink("mysymlink", "/symlink/target", 0, 0);
|
||||
this->LoadDir("/")->createDir("mydir", this->MODE_PUBLIC, 0, 0);
|
||||
this->LoadDir("/")->createDir("myemptydir", this->MODE_PUBLIC, 0, 0);
|
||||
this->LoadDir("/mydir")->createAndOpenFile("myfile", this->MODE_PUBLIC, 0, 0);
|
||||
this->LoadDir("/mydir")->createAndOpenFile("myfile2", this->MODE_PUBLIC, 0, 0);
|
||||
this->LoadDir("/mydir")->createSymlink("mysymlink", "/symlink/target", 0, 0);
|
||||
this->LoadDir("/mydir")->createDir("mysubdir", this->MODE_PUBLIC, 0, 0);
|
||||
this->LoadDir("/mydir/mysubdir")->createAndOpenFile("myfile", this->MODE_PUBLIC, 0, 0);
|
||||
this->LoadDir("/mydir/mysubdir")->createSymlink("mysymlink", "/symlink/target", 0, 0);
|
||||
this->LoadDir("/mydir/mysubdir")->createDir("mysubsubdir", this->MODE_PUBLIC, 0, 0);
|
||||
this->LoadDir("/")->createAndOpenFile("myfile", this->MODE_PUBLIC, fspp::uid_t(0), fspp::gid_t(0));
|
||||
this->LoadDir("/")->createSymlink("mysymlink", "/symlink/target", fspp::uid_t(0), fspp::gid_t(0));
|
||||
this->LoadDir("/")->createDir("mydir", this->MODE_PUBLIC, fspp::uid_t(0), fspp::gid_t(0));
|
||||
this->LoadDir("/")->createDir("myemptydir", this->MODE_PUBLIC, fspp::uid_t(0), fspp::gid_t(0));
|
||||
this->LoadDir("/mydir")->createAndOpenFile("myfile", this->MODE_PUBLIC, fspp::uid_t(0), fspp::gid_t(0));
|
||||
this->LoadDir("/mydir")->createAndOpenFile("myfile2", this->MODE_PUBLIC, fspp::uid_t(0), fspp::gid_t(0));
|
||||
this->LoadDir("/mydir")->createSymlink("mysymlink", "/symlink/target", fspp::uid_t(0), fspp::gid_t(0));
|
||||
this->LoadDir("/mydir")->createDir("mysubdir", this->MODE_PUBLIC, fspp::uid_t(0), fspp::gid_t(0));
|
||||
this->LoadDir("/mydir/mysubdir")->createAndOpenFile("myfile", this->MODE_PUBLIC, fspp::uid_t(0), fspp::gid_t(0));
|
||||
this->LoadDir("/mydir/mysubdir")->createSymlink("mysymlink", "/symlink/target", fspp::uid_t(0), fspp::gid_t(0));
|
||||
this->LoadDir("/mydir/mysubdir")->createDir("mysubsubdir", this->MODE_PUBLIC, fspp::uid_t(0), fspp::gid_t(0));
|
||||
}
|
||||
};
|
||||
|
||||
|
@ -6,14 +6,14 @@ template<class ConcreteFileSystemTestFixture>
|
||||
class FsppDirTest: public FileSystemTest<ConcreteFileSystemTestFixture> {
|
||||
public:
|
||||
void InitDirStructure() {
|
||||
this->LoadDir("/")->createAndOpenFile("myfile", this->MODE_PUBLIC, 0, 0);
|
||||
this->LoadDir("/")->createDir("mydir", this->MODE_PUBLIC, 0, 0);
|
||||
this->LoadDir("/")->createDir("myemptydir", this->MODE_PUBLIC, 0, 0);
|
||||
this->LoadDir("/mydir")->createAndOpenFile("myfile", this->MODE_PUBLIC, 0, 0);
|
||||
this->LoadDir("/mydir")->createAndOpenFile("myfile2", this->MODE_PUBLIC, 0, 0);
|
||||
this->LoadDir("/mydir")->createDir("mysubdir", this->MODE_PUBLIC, 0, 0);
|
||||
this->LoadDir("/mydir/mysubdir")->createAndOpenFile("myfile", this->MODE_PUBLIC, 0, 0);
|
||||
this->LoadDir("/mydir/mysubdir")->createDir("mysubsubdir", this->MODE_PUBLIC, 0, 0);
|
||||
this->LoadDir("/")->createAndOpenFile("myfile", this->MODE_PUBLIC, fspp::uid_t(0), fspp::gid_t(0));
|
||||
this->LoadDir("/")->createDir("mydir", this->MODE_PUBLIC, fspp::uid_t(0), fspp::gid_t(0));
|
||||
this->LoadDir("/")->createDir("myemptydir", this->MODE_PUBLIC, fspp::uid_t(0), fspp::gid_t(0));
|
||||
this->LoadDir("/mydir")->createAndOpenFile("myfile", this->MODE_PUBLIC, fspp::uid_t(0), fspp::gid_t(0));
|
||||
this->LoadDir("/mydir")->createAndOpenFile("myfile2", this->MODE_PUBLIC, fspp::uid_t(0), fspp::gid_t(0));
|
||||
this->LoadDir("/mydir")->createDir("mysubdir", this->MODE_PUBLIC, fspp::uid_t(0), fspp::gid_t(0));
|
||||
this->LoadDir("/mydir/mysubdir")->createAndOpenFile("myfile", this->MODE_PUBLIC, fspp::uid_t(0), fspp::gid_t(0));
|
||||
this->LoadDir("/mydir/mysubdir")->createDir("mysubsubdir", this->MODE_PUBLIC, fspp::uid_t(0), fspp::gid_t(0));
|
||||
}
|
||||
|
||||
void EXPECT_CHILDREN_ARE(const boost::filesystem::path &path, const std::initializer_list<fspp::Dir::Entry> expected) {
|
||||
@ -62,14 +62,14 @@ TYPED_TEST_P(FsppDirTest, Children_RootDir_Empty) {
|
||||
|
||||
TYPED_TEST_P(FsppDirTest, Children_RootDir_OneFile_Directly) {
|
||||
auto rootdir = this->LoadDir("/");
|
||||
rootdir->createAndOpenFile("myfile", this->MODE_PUBLIC, 0, 0);
|
||||
rootdir->createAndOpenFile("myfile", this->MODE_PUBLIC, fspp::uid_t(0), fspp::gid_t(0));
|
||||
this->EXPECT_CHILDREN_ARE(rootdir.get(), {
|
||||
FileEntry("myfile")
|
||||
});
|
||||
}
|
||||
|
||||
TYPED_TEST_P(FsppDirTest, Children_RootDir_OneFile_AfterReloadingDir) {
|
||||
this->LoadDir("/")->createAndOpenFile("myfile", this->MODE_PUBLIC, 0, 0);
|
||||
this->LoadDir("/")->createAndOpenFile("myfile", this->MODE_PUBLIC, fspp::uid_t(0), fspp::gid_t(0));
|
||||
this->EXPECT_CHILDREN_ARE("/", {
|
||||
FileEntry("myfile")
|
||||
});
|
||||
@ -77,14 +77,14 @@ TYPED_TEST_P(FsppDirTest, Children_RootDir_OneFile_AfterReloadingDir) {
|
||||
|
||||
TYPED_TEST_P(FsppDirTest, Children_RootDir_OneDir_Directly) {
|
||||
auto rootdir = this->LoadDir("/");
|
||||
rootdir->createDir("mydir", this->MODE_PUBLIC, 0, 0);
|
||||
rootdir->createDir("mydir", this->MODE_PUBLIC, fspp::uid_t(0), fspp::gid_t(0));
|
||||
this->EXPECT_CHILDREN_ARE(rootdir.get(), {
|
||||
DirEntry("mydir")
|
||||
});
|
||||
}
|
||||
|
||||
TYPED_TEST_P(FsppDirTest, Children_RootDir_OneDir_AfterReloadingDir) {
|
||||
this->LoadDir("/")->createDir("mydir", this->MODE_PUBLIC, 0, 0);
|
||||
this->LoadDir("/")->createDir("mydir", this->MODE_PUBLIC, fspp::uid_t(0), fspp::gid_t(0));
|
||||
this->EXPECT_CHILDREN_ARE("/", {
|
||||
DirEntry("mydir")
|
||||
});
|
||||
@ -100,39 +100,39 @@ TYPED_TEST_P(FsppDirTest, Children_RootDir_LargerStructure) {
|
||||
}
|
||||
|
||||
TYPED_TEST_P(FsppDirTest, Children_Nested_Empty) {
|
||||
this->LoadDir("/")->createDir("myemptydir", this->MODE_PUBLIC, 0, 0);
|
||||
this->LoadDir("/")->createDir("myemptydir", this->MODE_PUBLIC, fspp::uid_t(0), fspp::gid_t(0));
|
||||
this->EXPECT_CHILDREN_ARE("/myemptydir", {});
|
||||
}
|
||||
|
||||
TYPED_TEST_P(FsppDirTest, Children_Nested_OneFile_Directly) {
|
||||
this->LoadDir("/")->createDir("mydir", this->MODE_PUBLIC, 0, 0);
|
||||
this->LoadDir("/")->createDir("mydir", this->MODE_PUBLIC, fspp::uid_t(0), fspp::gid_t(0));
|
||||
auto dir = this->LoadDir("/mydir");
|
||||
dir->createAndOpenFile("myfile", this->MODE_PUBLIC, 0, 0);
|
||||
dir->createAndOpenFile("myfile", this->MODE_PUBLIC, fspp::uid_t(0), fspp::gid_t(0));
|
||||
this->EXPECT_CHILDREN_ARE(dir.get(), {
|
||||
FileEntry("myfile")
|
||||
});
|
||||
}
|
||||
|
||||
TYPED_TEST_P(FsppDirTest, Children_Nested_OneFile_AfterReloadingDir) {
|
||||
this->LoadDir("/")->createDir("mydir", this->MODE_PUBLIC, 0, 0);
|
||||
this->LoadDir("/mydir")->createAndOpenFile("myfile", this->MODE_PUBLIC, 0, 0);
|
||||
this->LoadDir("/")->createDir("mydir", this->MODE_PUBLIC, fspp::uid_t(0), fspp::gid_t(0));
|
||||
this->LoadDir("/mydir")->createAndOpenFile("myfile", this->MODE_PUBLIC, fspp::uid_t(0), fspp::gid_t(0));
|
||||
this->EXPECT_CHILDREN_ARE("/mydir", {
|
||||
FileEntry("myfile")
|
||||
});
|
||||
}
|
||||
|
||||
TYPED_TEST_P(FsppDirTest, Children_Nested_OneDir_Directly) {
|
||||
this->LoadDir("/")->createDir("mydir", this->MODE_PUBLIC, 0, 0);
|
||||
this->LoadDir("/")->createDir("mydir", this->MODE_PUBLIC, fspp::uid_t(0), fspp::gid_t(0));
|
||||
auto dir = this->LoadDir("/mydir");
|
||||
dir->createDir("mysubdir", this->MODE_PUBLIC, 0, 0);
|
||||
dir->createDir("mysubdir", this->MODE_PUBLIC, fspp::uid_t(0), fspp::gid_t(0));
|
||||
this->EXPECT_CHILDREN_ARE(dir.get(), {
|
||||
DirEntry("mysubdir")
|
||||
});
|
||||
}
|
||||
|
||||
TYPED_TEST_P(FsppDirTest, Children_Nested_OneDir_AfterReloadingDir) {
|
||||
this->LoadDir("/")->createDir("mydir", this->MODE_PUBLIC, 0, 0);
|
||||
this->LoadDir("/mydir")->createDir("mysubdir", this->MODE_PUBLIC, 0, 0);
|
||||
this->LoadDir("/")->createDir("mydir", this->MODE_PUBLIC, fspp::uid_t(0), fspp::gid_t(0));
|
||||
this->LoadDir("/mydir")->createDir("mysubdir", this->MODE_PUBLIC, fspp::uid_t(0), fspp::gid_t(0));
|
||||
this->EXPECT_CHILDREN_ARE("/mydir", {
|
||||
DirEntry("mysubdir")
|
||||
});
|
||||
@ -161,14 +161,14 @@ TYPED_TEST_P(FsppDirTest, Children_Nested2_LargerStructure) {
|
||||
}
|
||||
|
||||
TYPED_TEST_P(FsppDirTest, CreateAndOpenFile_InEmptyRoot) {
|
||||
this->LoadDir("/")->createAndOpenFile("myfile", this->MODE_PUBLIC, 0, 0);
|
||||
this->LoadDir("/")->createAndOpenFile("myfile", this->MODE_PUBLIC, fspp::uid_t(0), fspp::gid_t(0));
|
||||
this->LoadFile("/myfile");
|
||||
this->Load("/myfile"); // Test that we can also load the file node
|
||||
}
|
||||
|
||||
TYPED_TEST_P(FsppDirTest, CreateAndOpenFile_InNonemptyRoot) {
|
||||
this->InitDirStructure();
|
||||
this->LoadDir("/")->createAndOpenFile("mynewfile", this->MODE_PUBLIC, 0, 0);
|
||||
this->LoadDir("/")->createAndOpenFile("mynewfile", this->MODE_PUBLIC, fspp::uid_t(0), fspp::gid_t(0));
|
||||
this->EXPECT_CHILDREN_ARE("/", {
|
||||
FileEntry("myfile"),
|
||||
DirEntry("mydir"),
|
||||
@ -179,7 +179,7 @@ TYPED_TEST_P(FsppDirTest, CreateAndOpenFile_InNonemptyRoot) {
|
||||
|
||||
TYPED_TEST_P(FsppDirTest, CreateAndOpenFile_InEmptyNestedDir) {
|
||||
this->InitDirStructure();
|
||||
this->LoadDir("/myemptydir")->createAndOpenFile("mynewfile", this->MODE_PUBLIC, 0, 0);
|
||||
this->LoadDir("/myemptydir")->createAndOpenFile("mynewfile", this->MODE_PUBLIC, fspp::uid_t(0), fspp::gid_t(0));
|
||||
this->EXPECT_CHILDREN_ARE("/myemptydir", {
|
||||
FileEntry("mynewfile")
|
||||
});
|
||||
@ -187,7 +187,7 @@ TYPED_TEST_P(FsppDirTest, CreateAndOpenFile_InEmptyNestedDir) {
|
||||
|
||||
TYPED_TEST_P(FsppDirTest, CreateAndOpenFile_InNonemptyNestedDir) {
|
||||
this->InitDirStructure();
|
||||
this->LoadDir("/mydir")->createAndOpenFile("mynewfile", this->MODE_PUBLIC, 0, 0);
|
||||
this->LoadDir("/mydir")->createAndOpenFile("mynewfile", this->MODE_PUBLIC, fspp::uid_t(0), fspp::gid_t(0));
|
||||
this->EXPECT_CHILDREN_ARE("/mydir", {
|
||||
FileEntry("myfile"),
|
||||
FileEntry("myfile2"),
|
||||
@ -197,22 +197,22 @@ TYPED_TEST_P(FsppDirTest, CreateAndOpenFile_InNonemptyNestedDir) {
|
||||
}
|
||||
|
||||
TYPED_TEST_P(FsppDirTest, CreateAndOpenFile_AlreadyExisting) {
|
||||
this->LoadDir("/")->createAndOpenFile("myfile", this->MODE_PUBLIC, 0, 0);
|
||||
this->LoadDir("/")->createAndOpenFile("myfile", this->MODE_PUBLIC, fspp::uid_t(0), fspp::gid_t(0));
|
||||
//TODO Change, once we know which way of error reporting we want for such errors
|
||||
EXPECT_ANY_THROW(
|
||||
this->LoadDir("/")->createAndOpenFile("myfile", this->MODE_PUBLIC, 0, 0);
|
||||
this->LoadDir("/")->createAndOpenFile("myfile", this->MODE_PUBLIC, fspp::uid_t(0), fspp::gid_t(0));
|
||||
);
|
||||
}
|
||||
|
||||
TYPED_TEST_P(FsppDirTest, CreateDir_InEmptyRoot) {
|
||||
this->LoadDir("/")->createDir("mydir", this->MODE_PUBLIC, 0, 0);
|
||||
this->LoadDir("/")->createDir("mydir", this->MODE_PUBLIC, fspp::uid_t(0), fspp::gid_t(0));
|
||||
this->LoadDir("/mydir");
|
||||
this->Load("/mydir"); // Test we can also load the dir node
|
||||
}
|
||||
|
||||
TYPED_TEST_P(FsppDirTest, CreateDir_InNonemptyRoot) {
|
||||
this->InitDirStructure();
|
||||
this->LoadDir("/")->createDir("mynewdir", this->MODE_PUBLIC, 0, 0);
|
||||
this->LoadDir("/")->createDir("mynewdir", this->MODE_PUBLIC, fspp::uid_t(0), fspp::gid_t(0));
|
||||
this->EXPECT_CHILDREN_ARE("/", {
|
||||
FileEntry("myfile"),
|
||||
DirEntry("mydir"),
|
||||
@ -223,7 +223,7 @@ TYPED_TEST_P(FsppDirTest, CreateDir_InNonemptyRoot) {
|
||||
|
||||
TYPED_TEST_P(FsppDirTest, CreateDir_InEmptyNestedDir) {
|
||||
this->InitDirStructure();
|
||||
this->LoadDir("/myemptydir")->createDir("mynewdir", this->MODE_PUBLIC, 0, 0);
|
||||
this->LoadDir("/myemptydir")->createDir("mynewdir", this->MODE_PUBLIC, fspp::uid_t(0), fspp::gid_t(0));
|
||||
this->EXPECT_CHILDREN_ARE("/myemptydir", {
|
||||
DirEntry("mynewdir")
|
||||
});
|
||||
@ -231,7 +231,7 @@ TYPED_TEST_P(FsppDirTest, CreateDir_InEmptyNestedDir) {
|
||||
|
||||
TYPED_TEST_P(FsppDirTest, CreateDir_InNonemptyNestedDir) {
|
||||
this->InitDirStructure();
|
||||
this->LoadDir("/mydir")->createDir("mynewdir", this->MODE_PUBLIC, 0, 0);
|
||||
this->LoadDir("/mydir")->createDir("mynewdir", this->MODE_PUBLIC, fspp::uid_t(0), fspp::gid_t(0));
|
||||
this->EXPECT_CHILDREN_ARE("/mydir", {
|
||||
FileEntry("myfile"),
|
||||
FileEntry("myfile2"),
|
||||
@ -241,10 +241,10 @@ TYPED_TEST_P(FsppDirTest, CreateDir_InNonemptyNestedDir) {
|
||||
}
|
||||
|
||||
TYPED_TEST_P(FsppDirTest, CreateDir_AlreadyExisting) {
|
||||
this->LoadDir("/")->createDir("mydir", this->MODE_PUBLIC, 0, 0);
|
||||
this->LoadDir("/")->createDir("mydir", this->MODE_PUBLIC, fspp::uid_t(0), fspp::gid_t(0));
|
||||
//TODO Change, once we know which way of error reporting we want for such errors
|
||||
EXPECT_ANY_THROW(
|
||||
this->LoadDir("/")->createDir("mydir", this->MODE_PUBLIC, 0, 0);
|
||||
this->LoadDir("/")->createDir("mydir", this->MODE_PUBLIC, fspp::uid_t(0), fspp::gid_t(0));
|
||||
);
|
||||
}
|
||||
|
||||
|
@ -13,7 +13,7 @@ TYPED_TEST_CASE_P(FsppDirTest_Timestamps);
|
||||
TYPED_TEST_P(FsppDirTest_Timestamps, createAndOpenFile) {
|
||||
auto dir = this->CreateDir("/mydir");
|
||||
auto operation = [&dir] () {
|
||||
dir->createAndOpenFile("childname", S_IFREG, 1000, 1000);
|
||||
dir->createAndOpenFile("childname", fspp::mode_t().addFileFlag(), fspp::uid_t(1000), fspp::gid_t(1000));
|
||||
};
|
||||
this->EXPECT_OPERATION_UPDATES_TIMESTAMPS_AS("/mydir", operation, {this->ExpectDoesntUpdateAccessTimestamp, this->ExpectUpdatesModificationTimestamp, this->ExpectUpdatesMetadataTimestamp});
|
||||
}
|
||||
@ -22,7 +22,7 @@ TYPED_TEST_P(FsppDirTest_Timestamps, createAndOpenFile) {
|
||||
TYPED_TEST_P(FsppDirTest_Timestamps, createAndOpenFile_inRootDir) {
|
||||
auto dir = this->LoadDir("/");
|
||||
auto operation = [&dir] () {
|
||||
dir->createAndOpenFile("childname", S_IFREG, 1000, 1000);
|
||||
dir->createAndOpenFile("childname", fspp::mode_t().addFileFlag(), fspp::uid_t(1000), fspp::gid_t(1000));
|
||||
};
|
||||
this->EXPECT_OPERATION_UPDATES_TIMESTAMPS_AS("/", operation, {this->ExpectDoesntUpdateAccessTimestamp, this->ExpectUpdatesModificationTimestamp, this->ExpectUpdatesMetadataTimestamp});
|
||||
}*/
|
||||
@ -30,7 +30,7 @@ TYPED_TEST_P(FsppDirTest_Timestamps, createAndOpenFile_inRootDir) {
|
||||
TYPED_TEST_P(FsppDirTest_Timestamps, createAndOpenFile_TimestampsOfCreatedFile) {
|
||||
auto dir = this->CreateDir("/mydir");
|
||||
timespec lowerBound = now();
|
||||
dir->createAndOpenFile("childname", S_IFREG, 1000, 1000);
|
||||
dir->createAndOpenFile("childname", fspp::mode_t().addFileFlag(), fspp::uid_t(1000), fspp::gid_t(1000));
|
||||
timespec upperBound = now();
|
||||
auto child = this->Load("/mydir/childname");
|
||||
this->EXPECT_ACCESS_TIMESTAMP_BETWEEN (lowerBound, upperBound, *child);
|
||||
@ -41,7 +41,7 @@ TYPED_TEST_P(FsppDirTest_Timestamps, createAndOpenFile_TimestampsOfCreatedFile)
|
||||
TYPED_TEST_P(FsppDirTest_Timestamps, createDir) {
|
||||
auto dir = this->CreateDir("/mydir");
|
||||
auto operation = [&dir] () {
|
||||
dir->createDir("childname", S_IFDIR, 1000, 1000);
|
||||
dir->createDir("childname", fspp::mode_t().addDirFlag(), fspp::uid_t(1000), fspp::gid_t(1000));
|
||||
};
|
||||
this->EXPECT_OPERATION_UPDATES_TIMESTAMPS_AS("/mydir", operation, {this->ExpectDoesntUpdateAccessTimestamp, this->ExpectUpdatesModificationTimestamp, this->ExpectUpdatesMetadataTimestamp});
|
||||
}
|
||||
@ -50,7 +50,7 @@ TYPED_TEST_P(FsppDirTest_Timestamps, createDir) {
|
||||
TYPED_TEST_P(FsppDirTest_Timestamps, createDir_inRootDir) {
|
||||
auto dir = this->LoadDir("/");
|
||||
auto operation = [&dir] () {
|
||||
dir->createDir("childname", S_IFDIR, 1000, 1000);
|
||||
dir->createDir("childname", fspp::mode_t().addDirFlag(), fspp::uid_t(1000), fspp::gid_t(1000));
|
||||
};
|
||||
this->EXPECT_OPERATION_UPDATES_TIMESTAMPS_AS("/", operation, {this->ExpectDoesntUpdateAccessTimestamp, this->ExpectUpdatesModificationTimestamp, this->ExpectUpdatesMetadataTimestamp});
|
||||
}*/
|
||||
@ -58,7 +58,7 @@ TYPED_TEST_P(FsppDirTest_Timestamps, createDir_inRootDir) {
|
||||
TYPED_TEST_P(FsppDirTest_Timestamps, createDir_TimestampsOfCreatedDir) {
|
||||
auto dir = this->CreateDir("/mydir");
|
||||
timespec lowerBound = now();
|
||||
dir->createDir("childname", S_IFDIR, 1000, 1000);
|
||||
dir->createDir("childname", fspp::mode_t().addDirFlag(), fspp::uid_t(1000), fspp::gid_t(1000));
|
||||
timespec upperBound = now();
|
||||
auto child = this->Load("/mydir/childname");
|
||||
this->EXPECT_ACCESS_TIMESTAMP_BETWEEN (lowerBound, upperBound, *child);
|
||||
@ -69,7 +69,7 @@ TYPED_TEST_P(FsppDirTest_Timestamps, createDir_TimestampsOfCreatedDir) {
|
||||
TYPED_TEST_P(FsppDirTest_Timestamps, createSymlink) {
|
||||
auto dir = this->CreateDir("/mydir");
|
||||
auto operation = [&dir] () {
|
||||
dir->createSymlink("childname", "/target", 1000, 1000);
|
||||
dir->createSymlink("childname", "/target", fspp::uid_t(1000), fspp::gid_t(1000));
|
||||
};
|
||||
this->EXPECT_OPERATION_UPDATES_TIMESTAMPS_AS("/mydir", operation, {this->ExpectDoesntUpdateAccessTimestamp, this->ExpectUpdatesModificationTimestamp, this->ExpectUpdatesMetadataTimestamp});
|
||||
}
|
||||
@ -78,7 +78,7 @@ TYPED_TEST_P(FsppDirTest_Timestamps, createSymlink) {
|
||||
TYPED_TEST_P(FsppDirTest_Timestamps, createSymlink_inRootDir) {
|
||||
auto dir = this->LoadDir("/");
|
||||
auto operation = [&dir] () {
|
||||
dir->createSymlink("childname", "/target", 1000, 1000);
|
||||
dir->createSymlink("childname", "/target", fspp::uid_t(1000), fspp::gid_t(1000));
|
||||
};
|
||||
this->EXPECT_OPERATION_UPDATES_TIMESTAMPS_AS("/", operation, {this->ExpectDoesntUpdateAccessTimestamp, this->ExpectUpdatesModificationTimestamp, this->ExpectUpdatesMetadataTimestamp});
|
||||
}*/
|
||||
@ -86,7 +86,7 @@ TYPED_TEST_P(FsppDirTest_Timestamps, createSymlink_inRootDir) {
|
||||
TYPED_TEST_P(FsppDirTest_Timestamps, createSymlink_TimestampsOfCreatedSymlink) {
|
||||
auto dir = this->CreateDir("/mydir");
|
||||
timespec lowerBound = now();
|
||||
dir->createSymlink("childname", "/target", 1000, 1000);
|
||||
dir->createSymlink("childname", "/target", fspp::uid_t(1000), fspp::gid_t(1000));
|
||||
timespec upperBound = now();
|
||||
auto child = this->Load("/mydir/childname");
|
||||
this->EXPECT_ACCESS_TIMESTAMP_BETWEEN (lowerBound, upperBound, *child);
|
||||
@ -114,7 +114,7 @@ TYPED_TEST_P(FsppDirTest_Timestamps, children_empty_inRootDir) {
|
||||
|
||||
TYPED_TEST_P(FsppDirTest_Timestamps, children_nonempty) {
|
||||
auto dir = this->CreateDir("/mydir");
|
||||
dir->createAndOpenFile("filename", S_IFREG, 1000, 1000);
|
||||
dir->createAndOpenFile("filename", fspp::mode_t().addFileFlag(), fspp::uid_t(1000), fspp::gid_t(1000));
|
||||
auto operation = [&dir] () {
|
||||
dir->children();
|
||||
};
|
||||
@ -124,7 +124,7 @@ TYPED_TEST_P(FsppDirTest_Timestamps, children_nonempty) {
|
||||
/* TODO Re-enable this test once the root dir handles timestamps correctly
|
||||
TYPED_TEST_P(FsppDirTest_Timestamps, children_nonempty_inRootDir) {
|
||||
auto dir = this->LoadDir("/");
|
||||
dir->createAndOpenFile("filename", S_IFREG, 1000, 1000);
|
||||
dir->createAndOpenFile("filename", fspp::mode_t().addFileFlag(), fspp::uid_t(1000), fspp::gid_t(1000));
|
||||
auto operation = [&dir] () {
|
||||
dir->children();
|
||||
};
|
||||
|
@ -57,23 +57,24 @@ public:
|
||||
}
|
||||
|
||||
void Test_Chown_Uid(fspp::File *file, fspp::Node *node) {
|
||||
node->chown(100, 200);
|
||||
node->chown(fspp::uid_t(100), fspp::gid_t(200));
|
||||
this->IN_STAT(file, node, [] (const fspp::Node::stat_info& st){
|
||||
EXPECT_EQ(100u, st.uid);
|
||||
EXPECT_EQ(fspp::uid_t(100u), st.uid);
|
||||
});
|
||||
}
|
||||
|
||||
void Test_Chown_Gid(fspp::File *file, fspp::Node *node) {
|
||||
node->chown(100, 200);
|
||||
node->chown(fspp::uid_t(100), fspp::gid_t(200));
|
||||
this->IN_STAT(file, node, [] (const fspp::Node::stat_info& st){
|
||||
EXPECT_EQ(200u, st.gid);
|
||||
EXPECT_EQ(fspp::gid_t(200u), st.gid);
|
||||
});
|
||||
}
|
||||
|
||||
void Test_Chmod(fspp::File *file, fspp::Node *node) {
|
||||
node->chmod(S_IFREG | S_IRUSR | S_IWOTH);
|
||||
this->IN_STAT(file, node, [] (const fspp::Node::stat_info& st){
|
||||
EXPECT_EQ(static_cast<mode_t>(S_IFREG | S_IRUSR | S_IWOTH), st.mode);
|
||||
constexpr auto mode = fspp::mode_t().addFileFlag().addUserReadFlag().addOtherWriteFlag();
|
||||
node->chmod(mode);
|
||||
this->IN_STAT(file, node, [mode] (const fspp::Node::stat_info& st){
|
||||
EXPECT_EQ(mode, st.mode);
|
||||
});
|
||||
}
|
||||
|
||||
|
@ -33,7 +33,7 @@ TYPED_TEST_P(FsppNodeTest_Stat_FileOnly, FileIsFile) {
|
||||
this->CreateFile("/myfile");
|
||||
auto node = this->Load("/myfile");
|
||||
this->IN_STAT(node.get(), [] (const fspp::Node::stat_info& st) {
|
||||
EXPECT_TRUE(S_ISREG(st.mode));
|
||||
EXPECT_TRUE(st.mode.hasFileFlag());
|
||||
});
|
||||
}
|
||||
|
||||
@ -47,7 +47,7 @@ TYPED_TEST_P(FsppNodeTest_Stat_DirOnly, DirIsDir) {
|
||||
this->CreateDir("/mydir");
|
||||
auto node = this->Load("/mydir");
|
||||
this->IN_STAT(node.get(), [] (const fspp::Node::stat_info& st) {
|
||||
EXPECT_TRUE(S_ISDIR(st.mode));
|
||||
EXPECT_TRUE(st.mode.hasDirFlag());
|
||||
});
|
||||
}
|
||||
|
||||
@ -61,7 +61,7 @@ TYPED_TEST_P(FsppNodeTest_Stat_SymlinkOnly, SymlinkIsSymlink) {
|
||||
this->CreateSymlink("/mysymlink");
|
||||
auto node = this->Load("/mysymlink");
|
||||
this->IN_STAT(node.get(), [] (const fspp::Node::stat_info& st) {
|
||||
EXPECT_TRUE(S_ISLNK(st.mode));
|
||||
EXPECT_TRUE(st.mode.hasSymlinkFlag());
|
||||
});
|
||||
}
|
||||
|
||||
|
@ -35,7 +35,7 @@ public:
|
||||
|
||||
void Test_Chmod() {
|
||||
auto node = this->CreateNode("/mynode");
|
||||
mode_t mode = this->stat(*node).mode;
|
||||
fspp::mode_t mode = this->stat(*node).mode;
|
||||
auto operation = [&node, mode] () {
|
||||
node->chmod(mode);
|
||||
};
|
||||
@ -48,8 +48,8 @@ public:
|
||||
|
||||
void Test_Chown() {
|
||||
auto node = this->CreateNode("/mynode");
|
||||
uid_t uid = this->stat(*node).uid;
|
||||
gid_t gid = this->stat(*node).gid;
|
||||
fspp::uid_t uid = this->stat(*node).uid;
|
||||
fspp::gid_t gid = this->stat(*node).gid;
|
||||
auto operation = [&node, uid, gid] () {
|
||||
node->chown(uid, gid);
|
||||
};
|
||||
|
@ -41,7 +41,7 @@ TYPED_TEST_P(FsppOpenFileTest, FileIsFile) {
|
||||
auto file = this->CreateFile("/myfile");
|
||||
auto openFile = this->LoadFile("/myfile")->open(O_RDONLY);
|
||||
this->IN_STAT(openFile.get(), [] (const fspp::OpenFile::stat_info& st) {
|
||||
EXPECT_TRUE(S_ISREG(st.mode));
|
||||
EXPECT_TRUE(st.mode.hasFileFlag());
|
||||
});
|
||||
}
|
||||
|
||||
|
@ -35,7 +35,10 @@ public:
|
||||
ConcreteFileSystemTestFixture fixture;
|
||||
cpputils::unique_ref<fspp::Device> device;
|
||||
|
||||
static constexpr mode_t MODE_PUBLIC = S_IRUSR | S_IWUSR | S_IXUSR | S_IRGRP | S_IWGRP | S_IXGRP | S_IROTH | S_IWOTH | S_IXOTH;
|
||||
static constexpr fspp::mode_t MODE_PUBLIC = fspp::mode_t()
|
||||
.addUserReadFlag().addUserWriteFlag().addUserExecFlag()
|
||||
.addGroupReadFlag().addGroupWriteFlag().addGroupExecFlag()
|
||||
.addOtherReadFlag().addOtherWriteFlag().addOtherExecFlag();
|
||||
|
||||
cpputils::unique_ref<fspp::Node> Load(const boost::filesystem::path &path) {
|
||||
auto loaded = device->Load(path);
|
||||
@ -62,17 +65,17 @@ public:
|
||||
}
|
||||
|
||||
cpputils::unique_ref<fspp::Dir> CreateDir(const boost::filesystem::path &path) {
|
||||
this->LoadDir(path.parent_path())->createDir(path.filename().string(), this->MODE_PUBLIC, 0, 0);
|
||||
this->LoadDir(path.parent_path())->createDir(path.filename().string(), this->MODE_PUBLIC, fspp::uid_t(0), fspp::gid_t(0));
|
||||
return this->LoadDir(path);
|
||||
}
|
||||
|
||||
cpputils::unique_ref<fspp::File> CreateFile(const boost::filesystem::path &path) {
|
||||
this->LoadDir(path.parent_path())->createAndOpenFile(path.filename().string(), this->MODE_PUBLIC, 0, 0);
|
||||
this->LoadDir(path.parent_path())->createAndOpenFile(path.filename().string(), this->MODE_PUBLIC, fspp::uid_t(0), fspp::gid_t(0));
|
||||
return this->LoadFile(path);
|
||||
}
|
||||
|
||||
cpputils::unique_ref<fspp::Symlink> CreateSymlink(const boost::filesystem::path &path, const boost::filesystem::path &target = "/my/symlink/target") {
|
||||
this->LoadDir(path.parent_path())->createSymlink(path.filename().string(), target, 0, 0);
|
||||
this->LoadDir(path.parent_path())->createSymlink(path.filename().string(), target, fspp::uid_t(0), fspp::gid_t(0));
|
||||
return this->LoadSymlink(path);
|
||||
}
|
||||
|
||||
@ -98,6 +101,7 @@ public:
|
||||
);
|
||||
}
|
||||
};
|
||||
template<class ConcreteFileSystemTestFixture> constexpr fspp::mode_t FileSystemTest<ConcreteFileSystemTestFixture>::MODE_PUBLIC;
|
||||
|
||||
|
||||
#endif
|
||||
|
@ -11,16 +11,16 @@ template<class ConcreteFileSystemTestFixture>
|
||||
class FileTest: public FileSystemTest<ConcreteFileSystemTestFixture> {
|
||||
public:
|
||||
FileTest(): file_root(), file_nested() {
|
||||
this->LoadDir("/")->createAndOpenFile("myfile", this->MODE_PUBLIC, 0, 0);
|
||||
this->LoadDir("/")->createAndOpenFile("myfile", this->MODE_PUBLIC, fspp::uid_t(0), fspp::gid_t(0));
|
||||
file_root = this->LoadFile("/myfile");
|
||||
file_root_node = this->Load("/myfile");
|
||||
|
||||
this->LoadDir("/")->createDir("mydir", this->MODE_PUBLIC, 0, 0);
|
||||
this->LoadDir("/mydir")->createAndOpenFile("mynestedfile", this->MODE_PUBLIC, 0, 0);
|
||||
this->LoadDir("/")->createDir("mydir", this->MODE_PUBLIC, fspp::uid_t(0), fspp::gid_t(0));
|
||||
this->LoadDir("/mydir")->createAndOpenFile("mynestedfile", this->MODE_PUBLIC, fspp::uid_t(0), fspp::gid_t(0));
|
||||
file_nested = this->LoadFile("/mydir/mynestedfile");
|
||||
file_nested_node = this->Load("/mydir/mynestedfile");
|
||||
|
||||
this->LoadDir("/")->createDir("mydir2", this->MODE_PUBLIC, 0, 0);
|
||||
this->LoadDir("/")->createDir("mydir2", this->MODE_PUBLIC, fspp::uid_t(0), fspp::gid_t(0));
|
||||
}
|
||||
std::unique_ptr<fspp::File> file_root;
|
||||
std::unique_ptr<fspp::File> file_nested;
|
||||
|
@ -15,16 +15,16 @@ public:
|
||||
virtual ~Filesystem() {}
|
||||
|
||||
//TODO Test uid/gid parameters of createAndOpenFile
|
||||
virtual int createAndOpenFile(const boost::filesystem::path &path, mode_t mode, uid_t uid, gid_t gid) = 0;
|
||||
virtual int createAndOpenFile(const boost::filesystem::path &path, ::mode_t mode, ::uid_t uid, ::gid_t gid) = 0;
|
||||
virtual int openFile(const boost::filesystem::path &path, int flags) = 0;
|
||||
virtual void flush(int descriptor) = 0;
|
||||
virtual void closeFile(int descriptor) = 0;
|
||||
virtual void lstat(const boost::filesystem::path &path, struct ::stat *stbuf) = 0;
|
||||
virtual void fstat(int descriptor, struct ::stat *stbuf) = 0;
|
||||
//TODO Test chmod
|
||||
virtual void chmod(const boost::filesystem::path &path, mode_t mode) = 0;
|
||||
virtual void chmod(const boost::filesystem::path &path, ::mode_t mode) = 0;
|
||||
//TODO Test chown
|
||||
virtual void chown(const boost::filesystem::path &path, uid_t uid, gid_t gid) = 0;
|
||||
virtual void chown(const boost::filesystem::path &path, ::uid_t uid, ::gid_t gid) = 0;
|
||||
virtual void truncate(const boost::filesystem::path &path, off_t size) = 0;
|
||||
virtual void ftruncate(int descriptor, off_t size) = 0;
|
||||
virtual size_t read(int descriptor, void *buf, size_t count, off_t offset) = 0;
|
||||
@ -33,7 +33,7 @@ public:
|
||||
virtual void fdatasync(int descriptor) = 0;
|
||||
virtual void access(const boost::filesystem::path &path, int mask) = 0;
|
||||
//TODO Test uid/gid parameters of mkdir
|
||||
virtual void mkdir(const boost::filesystem::path &path, mode_t mode, uid_t uid, gid_t gid) = 0;
|
||||
virtual void mkdir(const boost::filesystem::path &path, ::mode_t mode, ::uid_t uid, ::gid_t gid) = 0;
|
||||
virtual void rmdir(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;
|
||||
@ -42,7 +42,7 @@ public:
|
||||
//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;
|
||||
//TODO Test createSymlink
|
||||
virtual void createSymlink(const boost::filesystem::path &to, const boost::filesystem::path &from, uid_t uid, gid_t gid) = 0;
|
||||
virtual void createSymlink(const boost::filesystem::path &to, const boost::filesystem::path &from, ::uid_t uid, ::gid_t gid) = 0;
|
||||
//TODO Test readSymlink
|
||||
virtual void readSymlink(const boost::filesystem::path &path, char *buf, size_t size) = 0;
|
||||
};
|
||||
|
@ -44,11 +44,11 @@ int fusepp_readlink(const char *path, char *buf, size_t size) {
|
||||
return FUSE_OBJ->readlink(bf::path(path), buf, size);
|
||||
}
|
||||
|
||||
int fusepp_mknod(const char *path, mode_t mode, dev_t rdev) {
|
||||
int fusepp_mknod(const char *path, ::mode_t mode, dev_t rdev) {
|
||||
return FUSE_OBJ->mknod(bf::path(path), mode, rdev);
|
||||
}
|
||||
|
||||
int fusepp_mkdir(const char *path, mode_t mode) {
|
||||
int fusepp_mkdir(const char *path, ::mode_t mode) {
|
||||
return FUSE_OBJ->mkdir(bf::path(path), mode);
|
||||
}
|
||||
|
||||
@ -72,11 +72,11 @@ int fusepp_link(const char *from, const char *to) {
|
||||
return FUSE_OBJ->link(bf::path(from), bf::path(to));
|
||||
}
|
||||
|
||||
int fusepp_chmod(const char *path, mode_t mode) {
|
||||
int fusepp_chmod(const char *path, ::mode_t mode) {
|
||||
return FUSE_OBJ->chmod(bf::path(path), mode);
|
||||
}
|
||||
|
||||
int fusepp_chown(const char *path, uid_t uid, gid_t gid) {
|
||||
int fusepp_chown(const char *path, ::uid_t uid, ::gid_t gid) {
|
||||
return FUSE_OBJ->chown(bf::path(path), uid, gid);
|
||||
}
|
||||
|
||||
@ -158,7 +158,7 @@ int fusepp_access(const char *path, int mask) {
|
||||
return FUSE_OBJ->access(bf::path(path), mask);
|
||||
}
|
||||
|
||||
int fusepp_create(const char *path, mode_t mode, fuse_file_info *fileinfo) {
|
||||
int fusepp_create(const char *path, ::mode_t mode, fuse_file_info *fileinfo) {
|
||||
return FUSE_OBJ->create(bf::path(path), mode, fileinfo);
|
||||
}
|
||||
|
||||
@ -385,7 +385,7 @@ int Fuse::readlink(const bf::path &path, char *buf, size_t size) {
|
||||
}
|
||||
}
|
||||
|
||||
int Fuse::mknod(const bf::path &path, mode_t mode, dev_t rdev) {
|
||||
int Fuse::mknod(const bf::path &path, ::mode_t mode, dev_t rdev) {
|
||||
UNUSED(rdev);
|
||||
UNUSED(mode);
|
||||
UNUSED(path);
|
||||
@ -393,7 +393,7 @@ int Fuse::mknod(const bf::path &path, mode_t mode, dev_t rdev) {
|
||||
return ENOSYS;
|
||||
}
|
||||
|
||||
int Fuse::mkdir(const bf::path &path, mode_t mode) {
|
||||
int Fuse::mkdir(const bf::path &path, ::mode_t mode) {
|
||||
#ifdef FSPP_LOG
|
||||
LOG(DEBUG, "mkdir({}, {})", path, mode);
|
||||
#endif
|
||||
@ -516,7 +516,7 @@ int Fuse::link(const bf::path &from, const bf::path &to) {
|
||||
return ENOSYS;
|
||||
}
|
||||
|
||||
int Fuse::chmod(const bf::path &path, mode_t mode) {
|
||||
int Fuse::chmod(const bf::path &path, ::mode_t mode) {
|
||||
#ifdef FSPP_LOG
|
||||
LOG(DEBUG, "chmod({}, {})", path, mode);
|
||||
#endif
|
||||
@ -538,7 +538,7 @@ int Fuse::chmod(const bf::path &path, mode_t mode) {
|
||||
}
|
||||
}
|
||||
|
||||
int Fuse::chown(const bf::path &path, uid_t uid, gid_t gid) {
|
||||
int Fuse::chown(const bf::path &path, ::uid_t uid, ::gid_t gid) {
|
||||
#ifdef FSPP_LOG
|
||||
LOG(DEBUG, "chown({}, {}, {})", path, uid, gid);
|
||||
#endif
|
||||
@ -714,7 +714,7 @@ int Fuse::write(const bf::path &path, const char *buf, size_t size, off_t offset
|
||||
}
|
||||
|
||||
//TODO
|
||||
int Fuse::statfs(const bf::path &path, struct statvfs *fsstat) {
|
||||
int Fuse::statfs(const bf::path &path, struct ::statvfs *fsstat) {
|
||||
#ifdef FSPP_LOG
|
||||
LOG(DEBUG, "statfs({}, _)", path);
|
||||
#endif
|
||||
@ -890,7 +890,7 @@ int Fuse::access(const bf::path &path, int mask) {
|
||||
}
|
||||
}
|
||||
|
||||
int Fuse::create(const bf::path &path, mode_t mode, fuse_file_info *fileinfo) {
|
||||
int Fuse::create(const bf::path &path, ::mode_t mode, fuse_file_info *fileinfo) {
|
||||
#ifdef FSPP_LOG
|
||||
LOG(DEBUG, "create({}, {}, _)", path, mode);
|
||||
#endif
|
||||
|
@ -30,15 +30,15 @@ public:
|
||||
int getattr(const boost::filesystem::path &path, struct stat *stbuf);
|
||||
int fgetattr(const boost::filesystem::path &path, struct stat *stbuf, fuse_file_info *fileinfo);
|
||||
int readlink(const boost::filesystem::path &path, char *buf, size_t size);
|
||||
int mknod(const boost::filesystem::path &path, mode_t mode, dev_t rdev);
|
||||
int mkdir(const boost::filesystem::path &path, mode_t mode);
|
||||
int mknod(const boost::filesystem::path &path, ::mode_t mode, dev_t rdev);
|
||||
int mkdir(const boost::filesystem::path &path, ::mode_t mode);
|
||||
int unlink(const boost::filesystem::path &path);
|
||||
int rmdir(const boost::filesystem::path &path);
|
||||
int symlink(const boost::filesystem::path &from, const boost::filesystem::path &to);
|
||||
int rename(const boost::filesystem::path &from, const boost::filesystem::path &to);
|
||||
int link(const boost::filesystem::path &from, const boost::filesystem::path &to);
|
||||
int chmod(const boost::filesystem::path &path, mode_t mode);
|
||||
int chown(const boost::filesystem::path &path, uid_t uid, gid_t gid);
|
||||
int chmod(const boost::filesystem::path &path, ::mode_t mode);
|
||||
int chown(const boost::filesystem::path &path, ::uid_t uid, ::gid_t gid);
|
||||
int truncate(const boost::filesystem::path &path, off_t size);
|
||||
int ftruncate(const boost::filesystem::path &path, off_t size, fuse_file_info *fileinfo);
|
||||
int utimens(const boost::filesystem::path &path, const timespec times[2]);
|
||||
@ -46,7 +46,7 @@ public:
|
||||
int release(const boost::filesystem::path &path, fuse_file_info *fileinfo);
|
||||
int read(const boost::filesystem::path &path, char *buf, size_t size, off_t offset, fuse_file_info *fileinfo);
|
||||
int write(const boost::filesystem::path &path, const char *buf, size_t size, off_t offset, fuse_file_info *fileinfo);
|
||||
int statfs(const boost::filesystem::path &path, struct statvfs *fsstat);
|
||||
int statfs(const boost::filesystem::path &path, struct ::statvfs *fsstat);
|
||||
int flush(const boost::filesystem::path &path, fuse_file_info *fileinfo);
|
||||
int fsync(const boost::filesystem::path &path, int flags, fuse_file_info *fileinfo);
|
||||
int opendir(const boost::filesystem::path &path, fuse_file_info *fileinfo);
|
||||
@ -56,7 +56,7 @@ public:
|
||||
void init(fuse_conn_info *conn);
|
||||
void destroy();
|
||||
int access(const boost::filesystem::path &path, int mask);
|
||||
int create(const boost::filesystem::path &path, mode_t mode, fuse_file_info *fileinfo);
|
||||
int create(const boost::filesystem::path &path, ::mode_t mode, fuse_file_info *fileinfo);
|
||||
|
||||
private:
|
||||
static void _logException(const std::exception &e);
|
||||
|
@ -141,9 +141,9 @@ void FilesystemImpl::closeFile(int descriptor) {
|
||||
namespace {
|
||||
void convert_stat_info_(const fspp::Node::stat_info& input, struct ::stat *output) {
|
||||
output->st_nlink = input.nlink;
|
||||
output->st_mode = input.mode;
|
||||
output->st_uid = input.uid;
|
||||
output->st_gid = input.gid;
|
||||
output->st_mode = input.mode.value();
|
||||
output->st_uid = input.uid.value();
|
||||
output->st_gid = input.gid.value();
|
||||
output->st_size = input.size;
|
||||
output->st_blocks = input.blocks;
|
||||
output->st_atim = input.atime;
|
||||
@ -169,23 +169,23 @@ void FilesystemImpl::fstat(int descriptor, struct ::stat *stbuf) {
|
||||
convert_stat_info_(stat_info, stbuf);
|
||||
}
|
||||
|
||||
void FilesystemImpl::chmod(const boost::filesystem::path &path, mode_t mode) {
|
||||
void FilesystemImpl::chmod(const boost::filesystem::path &path, ::mode_t mode) {
|
||||
PROFILE(_chmodNanosec);
|
||||
auto node = _device->Load(path);
|
||||
if(node == none) {
|
||||
throw fuse::FuseErrnoException(ENOENT);
|
||||
} else {
|
||||
(*node)->chmod(mode);
|
||||
(*node)->chmod(fspp::mode_t(mode));
|
||||
}
|
||||
}
|
||||
|
||||
void FilesystemImpl::chown(const boost::filesystem::path &path, uid_t uid, gid_t gid) {
|
||||
void FilesystemImpl::chown(const boost::filesystem::path &path, ::uid_t uid, ::gid_t gid) {
|
||||
PROFILE(_chownNanosec);
|
||||
auto node = _device->Load(path);
|
||||
if(node == none) {
|
||||
throw fuse::FuseErrnoException(ENOENT);
|
||||
} else {
|
||||
(*node)->chown(uid, gid);
|
||||
(*node)->chown(fspp::uid_t(uid), fspp::gid_t(gid));
|
||||
}
|
||||
}
|
||||
|
||||
@ -229,19 +229,19 @@ void FilesystemImpl::access(const bf::path &path, int mask) {
|
||||
}
|
||||
}
|
||||
|
||||
int FilesystemImpl::createAndOpenFile(const bf::path &path, mode_t mode, uid_t uid, gid_t gid) {
|
||||
int FilesystemImpl::createAndOpenFile(const bf::path &path, ::mode_t mode, ::uid_t uid, ::gid_t gid) {
|
||||
PROFILE(_createAndOpenFileNanosec);
|
||||
auto dir = LoadDir(path.parent_path());
|
||||
PROFILE(_createAndOpenFileNanosec_withoutLoading);
|
||||
auto file = dir->createAndOpenFile(path.filename().string(), mode, uid, gid);
|
||||
auto file = dir->createAndOpenFile(path.filename().string(), fspp::mode_t(mode), fspp::uid_t(uid), fspp::gid_t(gid));
|
||||
return _open_files.open(std::move(file));
|
||||
}
|
||||
|
||||
void FilesystemImpl::mkdir(const bf::path &path, mode_t mode, uid_t uid, gid_t gid) {
|
||||
void FilesystemImpl::mkdir(const bf::path &path, ::mode_t mode, ::uid_t uid, ::gid_t gid) {
|
||||
PROFILE(_mkdirNanosec);
|
||||
auto dir = LoadDir(path.parent_path());
|
||||
PROFILE(_mkdirNanosec_withoutLoading);
|
||||
dir->createDir(path.filename().string(), mode, uid, gid);
|
||||
dir->createDir(path.filename().string(), fspp::mode_t(mode), fspp::uid_t(uid), fspp::gid_t(gid));
|
||||
}
|
||||
|
||||
void FilesystemImpl::rmdir(const bf::path &path) {
|
||||
@ -310,11 +310,11 @@ void FilesystemImpl::statfs(const bf::path &path, struct ::statvfs *fsstat) {
|
||||
fsstat->f_frsize = fsstat->f_bsize; // even though this is supposed to be ignored, osxfuse needs it.
|
||||
}
|
||||
|
||||
void FilesystemImpl::createSymlink(const bf::path &to, const bf::path &from, uid_t uid, gid_t gid) {
|
||||
void FilesystemImpl::createSymlink(const bf::path &to, const bf::path &from, ::uid_t uid, ::gid_t gid) {
|
||||
PROFILE(_createSymlinkNanosec);
|
||||
auto parent = LoadDir(from.parent_path());
|
||||
PROFILE(_createSymlinkNanosec_withoutLoading);
|
||||
parent->createSymlink(from.filename().string(), to, uid, gid);
|
||||
parent->createSymlink(from.filename().string(), to, fspp::uid_t(uid), fspp::gid_t(gid));
|
||||
}
|
||||
|
||||
void FilesystemImpl::readSymlink(const bf::path &path, char *buf, size_t size) {
|
||||
|
@ -29,8 +29,8 @@ public:
|
||||
void closeFile(int descriptor) override;
|
||||
void lstat(const boost::filesystem::path &path, struct ::stat *stbuf) override;
|
||||
void fstat(int descriptor, struct ::stat *stbuf) override;
|
||||
void chmod(const boost::filesystem::path &path, mode_t mode) override;
|
||||
void chown(const boost::filesystem::path &path, uid_t uid, gid_t gid) override;
|
||||
void chmod(const boost::filesystem::path &path, ::mode_t mode) override;
|
||||
void chown(const boost::filesystem::path &path, ::uid_t uid, ::gid_t gid) override;
|
||||
void truncate(const boost::filesystem::path &path, off_t size) override;
|
||||
void ftruncate(int descriptor, off_t size) override;
|
||||
size_t read(int descriptor, void *buf, size_t count, off_t offset) override;
|
||||
@ -38,15 +38,15 @@ public:
|
||||
void fsync(int descriptor) override;
|
||||
void fdatasync(int descriptor) override;
|
||||
void access(const boost::filesystem::path &path, int mask) override;
|
||||
int createAndOpenFile(const boost::filesystem::path &path, mode_t mode, uid_t uid, gid_t gid) override;
|
||||
void mkdir(const boost::filesystem::path &path, mode_t mode, uid_t uid, gid_t gid) override;
|
||||
int createAndOpenFile(const boost::filesystem::path &path, ::mode_t mode, ::uid_t uid, ::gid_t gid) override;
|
||||
void mkdir(const boost::filesystem::path &path, ::mode_t mode, ::uid_t uid, ::gid_t gid) override;
|
||||
void rmdir(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;
|
||||
cpputils::unique_ref<std::vector<Dir::Entry>> readDir(const boost::filesystem::path &path) 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 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;
|
||||
|
||||
private:
|
||||
|
@ -14,11 +14,14 @@ namespace bf = boost::filesystem;
|
||||
|
||||
class CryNodeTest : public ::testing::Test, public CryTestBase {
|
||||
public:
|
||||
static constexpr mode_t MODE_PUBLIC = S_IRUSR | S_IWUSR | S_IXUSR | S_IRGRP | S_IWGRP | S_IXGRP | S_IROTH | S_IWOTH | S_IXOTH;
|
||||
static constexpr fspp::mode_t MODE_PUBLIC = fspp::mode_t()
|
||||
.addUserReadFlag().addUserWriteFlag().addUserExecFlag()
|
||||
.addGroupReadFlag().addGroupWriteFlag().addGroupExecFlag()
|
||||
.addOtherReadFlag().addOtherWriteFlag().addOtherExecFlag();
|
||||
|
||||
unique_ref<CryNode> CreateFile(const bf::path &path) {
|
||||
auto parentDir = device().LoadDir(path.parent_path()).value();
|
||||
parentDir->createAndOpenFile(path.filename().string(), MODE_PUBLIC, 0, 0);
|
||||
parentDir->createAndOpenFile(path.filename().string(), MODE_PUBLIC, fspp::uid_t(0), fspp::gid_t(0));
|
||||
auto file = device().Load(path).value();
|
||||
return dynamic_pointer_move<CryNode>(file).value();
|
||||
}
|
||||
@ -26,7 +29,7 @@ public:
|
||||
unique_ref<CryNode> CreateDir(const bf::path &path) {
|
||||
auto _parentDir = device().Load(path.parent_path()).value();
|
||||
auto parentDir = dynamic_pointer_move<CryDir>(_parentDir).value();
|
||||
parentDir->createDir(path.filename().string(), MODE_PUBLIC, 0, 0);
|
||||
parentDir->createDir(path.filename().string(), MODE_PUBLIC, fspp::uid_t(0), fspp::gid_t(0));
|
||||
auto createdDir = device().Load(path).value();
|
||||
return dynamic_pointer_move<CryNode>(createdDir).value();
|
||||
}
|
||||
@ -34,11 +37,12 @@ public:
|
||||
unique_ref<CryNode> CreateSymlink(const bf::path &path) {
|
||||
auto _parentDir = device().Load(path.parent_path()).value();
|
||||
auto parentDir = dynamic_pointer_move<CryDir>(_parentDir).value();
|
||||
parentDir->createSymlink(path.filename().string(), "/target", 0, 0);
|
||||
parentDir->createSymlink(path.filename().string(), "/target", fspp::uid_t(0), fspp::gid_t(0));
|
||||
auto createdSymlink = device().Load(path).value();
|
||||
return dynamic_pointer_move<CryNode>(createdSymlink).value();
|
||||
}
|
||||
};
|
||||
constexpr fspp::mode_t CryNodeTest::MODE_PUBLIC;
|
||||
|
||||
TEST_F(CryNodeTest, Rename_DoesntLeaveBlocksOver) {
|
||||
auto node = CreateFile("/oldname");
|
||||
|
Loading…
x
Reference in New Issue
Block a user