Adapt to new fspp (which got the symlink fix in 8092bfef8e
)
This commit is contained in:
parent
8e876759bb
commit
3427cf71b3
@ -78,7 +78,11 @@ optional<unique_ref<fspp::Node>> CryDevice::Load(const bf::path &path) {
|
||||
return optional<unique_ref<fspp::Node>>(make_unique_ref<CryDir>(this, none, _rootKey));
|
||||
}
|
||||
auto parent = LoadDirBlob(path.parent_path());
|
||||
const auto &entry = parent->GetChild(path.filename().native());
|
||||
auto optEntry = parent->GetChild(path.filename().native());
|
||||
if (optEntry == boost::none) {
|
||||
return boost::none;
|
||||
}
|
||||
const auto &entry = *optEntry;
|
||||
|
||||
if (entry.type == fspp::Dir::EntryType::DIR) {
|
||||
return optional<unique_ref<fspp::Node>>(make_unique_ref<CryDir>(this, std::move(parent), entry.key));
|
||||
@ -113,7 +117,11 @@ unique_ref<FsBlobRef> CryDevice::LoadBlob(const bf::path &path) {
|
||||
throw FuseErrnoException(ENOTDIR); // Path component is not a dir
|
||||
}
|
||||
|
||||
Key childKey = (*currentDir)->GetChild(component.c_str()).key;
|
||||
auto childOpt = (*currentDir)->GetChild(component.c_str());
|
||||
if (childOpt == boost::none) {
|
||||
throw FuseErrnoException(ENOENT); // Child entry in directory not found
|
||||
}
|
||||
Key childKey = childOpt->key;
|
||||
currentBlob = _fsBlobStore->load(childKey);
|
||||
if (currentBlob == none) {
|
||||
throw FuseErrnoException(ENOENT); // Blob for directory entry not found
|
||||
|
@ -50,7 +50,11 @@ void CryNode::rename(const bf::path &to) {
|
||||
}
|
||||
//TODO More efficient implementation possible: directly rename when it's actually not moved to a different directory
|
||||
// It's also quite ugly code because in the parent==targetDir case, it depends on _parent not overriding the changes made by targetDir.
|
||||
const auto &old = (*_parent)->GetChild(_key);
|
||||
auto optOld = (*_parent)->GetChild(_key);
|
||||
if (optOld == boost::none) {
|
||||
throw FuseErrnoException(ENOENT);
|
||||
}
|
||||
const auto &old = *optOld;
|
||||
auto mode = old.mode;
|
||||
auto uid = old.uid;
|
||||
auto gid = old.gid;
|
||||
|
@ -18,11 +18,11 @@ public:
|
||||
|
||||
using Entry = fsblobstore::DirEntry;
|
||||
|
||||
const Entry &GetChild(const std::string &name) const {
|
||||
boost::optional<const Entry&> GetChild(const std::string &name) const {
|
||||
return _base->GetChild(name);
|
||||
}
|
||||
|
||||
const Entry &GetChild(const blockstore::Key &key) const {
|
||||
boost::optional<const Entry&> GetChild(const blockstore::Key &key) const {
|
||||
return _base->GetChild(key);
|
||||
}
|
||||
|
||||
|
@ -82,12 +82,12 @@ void DirBlob::AddChild(const std::string &name, const Key &blobKey,
|
||||
_changed = true;
|
||||
}
|
||||
|
||||
const DirEntry &DirBlob::GetChild(const string &name) const {
|
||||
boost::optional<const DirEntry&> DirBlob::GetChild(const string &name) const {
|
||||
std::unique_lock<std::mutex> lock(_mutex);
|
||||
return _entries.get(name);
|
||||
}
|
||||
|
||||
const DirEntry &DirBlob::GetChild(const Key &key) const {
|
||||
boost::optional<const DirEntry&> DirBlob::GetChild(const Key &key) const {
|
||||
std::unique_lock<std::mutex> lock(_mutex);
|
||||
return _entries.get(key);
|
||||
}
|
||||
@ -112,7 +112,11 @@ off_t DirBlob::lstat_size() const {
|
||||
}
|
||||
|
||||
void DirBlob::statChild(const Key &key, struct ::stat *result) const {
|
||||
const auto &child = GetChild(key);
|
||||
auto childOpt = GetChild(key);
|
||||
if (childOpt == boost::none) {
|
||||
throw fspp::fuse::FuseErrnoException(ENOENT);
|
||||
}
|
||||
const auto &child = *childOpt;
|
||||
//TODO Loading the blob for only getting the size of the file/symlink is not very performant.
|
||||
// Furthermore, this is the only reason why DirBlob needs a pointer to _fsBlobStore, which is ugly
|
||||
result->st_mode = child.mode;
|
||||
|
@ -27,9 +27,9 @@ namespace cryfs {
|
||||
|
||||
void AppendChildrenTo(std::vector<fspp::Dir::Entry> *result) const;
|
||||
|
||||
const DirEntry &GetChild(const std::string &name) const;
|
||||
boost::optional<const DirEntry&> GetChild(const std::string &name) const;
|
||||
|
||||
const DirEntry &GetChild(const blockstore::Key &key) const;
|
||||
boost::optional<const DirEntry&> GetChild(const blockstore::Key &key) const;
|
||||
|
||||
void AddChildDir(const std::string &name, const blockstore::Key &blobKey, mode_t mode, uid_t uid,
|
||||
gid_t gid);
|
||||
|
@ -57,18 +57,22 @@ void DirEntryList::add(const string &name, const Key &blobKey, fspp::Dir::EntryT
|
||||
_entries.emplace(insert_pos, entryType, name, blobKey, mode, uid, gid);
|
||||
}
|
||||
|
||||
const DirEntry &DirEntryList::get(const string &name) const {
|
||||
boost::optional<const DirEntry&> DirEntryList::get(const string &name) const {
|
||||
auto found = std::find_if(_entries.begin(), _entries.end(), [&name] (const DirEntry &entry) {
|
||||
return entry.name == name;
|
||||
});
|
||||
if (found == _entries.end()) {
|
||||
throw fspp::fuse::FuseErrnoException(ENOENT);
|
||||
return boost::none;
|
||||
}
|
||||
return *found;
|
||||
}
|
||||
|
||||
const DirEntry &DirEntryList::get(const Key &key) const {
|
||||
return *_find(key);
|
||||
boost::optional<const DirEntry&> DirEntryList::get(const Key &key) const {
|
||||
auto found = _find(key);
|
||||
if (found == _entries.end()) {
|
||||
return boost::none;
|
||||
}
|
||||
return *found;
|
||||
}
|
||||
|
||||
void DirEntryList::remove(const Key &key) {
|
||||
|
@ -21,8 +21,8 @@ namespace cryfs {
|
||||
|
||||
void add(const std::string &name, const blockstore::Key &blobKey, fspp::Dir::EntryType entryType,
|
||||
mode_t mode, uid_t uid, gid_t gid);
|
||||
const DirEntry &get(const std::string &name) const;
|
||||
const DirEntry &get(const blockstore::Key &key) const;
|
||||
boost::optional<const DirEntry&> get(const std::string &name) const;
|
||||
boost::optional<const DirEntry&> get(const blockstore::Key &key) const;
|
||||
void remove(const blockstore::Key &key);
|
||||
|
||||
size_t size() const;
|
||||
|
@ -14,11 +14,11 @@ public:
|
||||
|
||||
using Entry = fsblobstore::DirEntry;
|
||||
|
||||
const Entry &GetChild(const std::string &name) const {
|
||||
boost::optional<const Entry&> GetChild(const std::string &name) const {
|
||||
return _base->GetChild(name);
|
||||
}
|
||||
|
||||
const Entry &GetChild(const blockstore::Key &key) const {
|
||||
boost::optional<const Entry&> GetChild(const blockstore::Key &key) const {
|
||||
return _base->GetChild(key);
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user