diff --git a/ChangeLog.txt b/ChangeLog.txt index b5e827de..d8261a64 100644 --- a/ChangeLog.txt +++ b/ChangeLog.txt @@ -1,7 +1,8 @@ Version 0.9.1 (unreleased) --------------- -* Report file system usage statistics to the operating system (e.g. amount of space used). This information can be queried using the 'df' tool on linux. -* Use stronger scrypt parameters when generating the config file key from the user password. This makes it a bit more secure, but also takes a bit longer to load a file system. +* Report file system usage statistics to the operating system (e.g. amount of space used). This information can be queried using the 'df' tool on linux. See https://github.com/cryfs/cryfs/commit/68acc27e88ff5209ca55ddb4e91f5a449d77fb54 +* Use stronger scrypt parameters when generating the config file key from the user password. This makes it a bit more secure, but also takes a bit longer to load a file system. See https://github.com/cryfs/cryfs/commit/7f1493ab9210319cab008e71d4ee8f4d7d920f39 +* Fix a bug where deleting a non-empty directory could leave some blocks over. Version 0.9.0 --------------- diff --git a/src/cryfs/filesystem/CryDir.cpp b/src/cryfs/filesystem/CryDir.cpp index 87fa08ba..d0b92502 100644 --- a/src/cryfs/filesystem/CryDir.cpp +++ b/src/cryfs/filesystem/CryDir.cpp @@ -79,4 +79,16 @@ void CryDir::createSymlink(const string &name, const bf::path &target, uid_t uid blob->AddChildSymlink(name, child->key(), uid, gid); } +void CryDir::remove() { + device()->callFsActionCallbacks(); + { + auto blob = LoadBlob(); + if (0 != blob->NumChildren()) { + throw FuseErrnoException(ENOTEMPTY); + } + } + //TODO removeNode() calls CryDevice::RemoveBlob, which loads the blob again. So we're loading it twice. Should be optimized. + removeNode(); +} + } diff --git a/src/cryfs/filesystem/CryDir.h b/src/cryfs/filesystem/CryDir.h index 807dd58a..4239c61f 100644 --- a/src/cryfs/filesystem/CryDir.h +++ b/src/cryfs/filesystem/CryDir.h @@ -23,6 +23,8 @@ public: fspp::Dir::EntryType getType() const override; + void remove() override; + private: cpputils::unique_ref LoadBlob() const; diff --git a/src/cryfs/filesystem/CryFile.cpp b/src/cryfs/filesystem/CryFile.cpp index 2816feaf..cdde1c2d 100644 --- a/src/cryfs/filesystem/CryFile.cpp +++ b/src/cryfs/filesystem/CryFile.cpp @@ -51,4 +51,9 @@ fspp::Dir::EntryType CryFile::getType() const { return fspp::Dir::EntryType::FILE; } +void CryFile::remove() { + device()->callFsActionCallbacks(); + removeNode(); +} + } diff --git a/src/cryfs/filesystem/CryFile.h b/src/cryfs/filesystem/CryFile.h index a9aaf4e7..95777ff9 100644 --- a/src/cryfs/filesystem/CryFile.h +++ b/src/cryfs/filesystem/CryFile.h @@ -17,6 +17,7 @@ public: cpputils::unique_ref open(int flags) const override; void truncate(off_t size) const override; fspp::Dir::EntryType getType() const override; + void remove() override; private: cpputils::unique_ref LoadBlob() const; diff --git a/src/cryfs/filesystem/CryNode.cpp b/src/cryfs/filesystem/CryNode.cpp index 4c3e9406..129cad77 100644 --- a/src/cryfs/filesystem/CryNode.cpp +++ b/src/cryfs/filesystem/CryNode.cpp @@ -74,8 +74,7 @@ void CryNode::utimens(timespec lastAccessTime, timespec lastModificationTime) { (*_parent)->utimensChild(_key, lastAccessTime, lastModificationTime); } -void CryNode::remove() { - device()->callFsActionCallbacks(); +void CryNode::removeNode() { //TODO Instead of all these if-else and having _parent being an optional, we could also introduce a CryRootDir which inherits from fspp::Dir. if (_parent == none) { //We are the root direcory. diff --git a/src/cryfs/filesystem/CryNode.h b/src/cryfs/filesystem/CryNode.h index 0fc439c6..4639f24c 100644 --- a/src/cryfs/filesystem/CryNode.h +++ b/src/cryfs/filesystem/CryNode.h @@ -19,7 +19,6 @@ public: void chown(uid_t uid, gid_t gid) override; void rename(const boost::filesystem::path &to) override; void utimens(timespec lastAccessTime, timespec lastModificationTime) override; - void remove() override; protected: CryNode(); @@ -31,6 +30,8 @@ protected: virtual fspp::Dir::EntryType getType() const = 0; + void removeNode(); + private: CryDevice *_device; boost::optional> _parent; diff --git a/src/cryfs/filesystem/CrySymlink.cpp b/src/cryfs/filesystem/CrySymlink.cpp index 5af99832..0d589e20 100644 --- a/src/cryfs/filesystem/CrySymlink.cpp +++ b/src/cryfs/filesystem/CrySymlink.cpp @@ -50,4 +50,9 @@ bf::path CrySymlink::target() const { return blob->target(); } +void CrySymlink::remove() { + device()->callFsActionCallbacks(); + removeNode(); +} + } diff --git a/src/cryfs/filesystem/CrySymlink.h b/src/cryfs/filesystem/CrySymlink.h index 2a030800..375f20b4 100644 --- a/src/cryfs/filesystem/CrySymlink.h +++ b/src/cryfs/filesystem/CrySymlink.h @@ -18,6 +18,8 @@ public: fspp::Dir::EntryType getType() const override; + void remove() override; + private: cpputils::unique_ref LoadBlob() const; diff --git a/src/cryfs/filesystem/cachingfsblobstore/DirBlobRef.h b/src/cryfs/filesystem/cachingfsblobstore/DirBlobRef.h index c4dc41ff..b4ad5cf6 100644 --- a/src/cryfs/filesystem/cachingfsblobstore/DirBlobRef.h +++ b/src/cryfs/filesystem/cachingfsblobstore/DirBlobRef.h @@ -26,6 +26,10 @@ public: return _base->GetChild(key); } + size_t NumChildren() const { + return _base->NumChildren(); + } + void RemoveChild(const blockstore::Key &key) { return _base->RemoveChild(key); } diff --git a/src/cryfs/filesystem/fsblobstore/DirBlob.cpp b/src/cryfs/filesystem/fsblobstore/DirBlob.cpp index 8b6a848b..25d0c160 100644 --- a/src/cryfs/filesystem/fsblobstore/DirBlob.cpp +++ b/src/cryfs/filesystem/fsblobstore/DirBlob.cpp @@ -169,5 +169,9 @@ cpputils::unique_ref DirBlob::releaseBaseBlob() { return FsBlob::releaseBaseBlob(); } +size_t DirBlob::NumChildren() const { + return _entries.size(); +} + } } diff --git a/src/cryfs/filesystem/fsblobstore/DirBlob.h b/src/cryfs/filesystem/fsblobstore/DirBlob.h index cb0ea449..6a32331f 100644 --- a/src/cryfs/filesystem/fsblobstore/DirBlob.h +++ b/src/cryfs/filesystem/fsblobstore/DirBlob.h @@ -28,6 +28,9 @@ namespace cryfs { void AppendChildrenTo(std::vector *result) const; + //TODO Test NumChildren() + size_t NumChildren() const; + boost::optional GetChild(const std::string &name) const; boost::optional GetChild(const blockstore::Key &key) const; diff --git a/src/cryfs/filesystem/parallelaccessfsblobstore/DirBlobRef.h b/src/cryfs/filesystem/parallelaccessfsblobstore/DirBlobRef.h index ceb7e957..3f93287e 100644 --- a/src/cryfs/filesystem/parallelaccessfsblobstore/DirBlobRef.h +++ b/src/cryfs/filesystem/parallelaccessfsblobstore/DirBlobRef.h @@ -22,6 +22,10 @@ public: return _base->GetChild(key); } + size_t NumChildren() const { + return _base->NumChildren(); + } + void RemoveChild(const blockstore::Key &key) { return _base->RemoveChild(key); }