From 19bfe97d52cab6229b0643964107a3cff13543ea Mon Sep 17 00:00:00 2001 From: Sebastian Messmer Date: Sat, 18 Feb 2017 13:21:24 +0000 Subject: [PATCH] du reports correct space usage --- ChangeLog.txt | 3 ++- src/cryfs/filesystem/CryNode.cpp | 4 ++-- src/cryfs/filesystem/CryOpenFile.cpp | 2 +- src/cryfs/filesystem/cachingfsblobstore/DirBlobRef.h | 4 ++-- src/cryfs/filesystem/fsblobstore/DirBlob.cpp | 4 ++-- src/cryfs/filesystem/fsblobstore/DirBlob.h | 2 +- src/cryfs/filesystem/parallelaccessfsblobstore/DirBlobRef.h | 4 ++-- 7 files changed, 12 insertions(+), 11 deletions(-) diff --git a/ChangeLog.txt b/ChangeLog.txt index c94b5d52..192784aa 100644 --- a/ChangeLog.txt +++ b/ChangeLog.txt @@ -1,6 +1,7 @@ Version 0.9.8 (unreleased) -------------- - +Fixed bugs: +* `du` shows correct file system size Version 0.9.7 -------------- diff --git a/src/cryfs/filesystem/CryNode.cpp b/src/cryfs/filesystem/CryNode.cpp index 0524b47c..2ad4547e 100644 --- a/src/cryfs/filesystem/CryNode.cpp +++ b/src/cryfs/filesystem/CryNode.cpp @@ -160,10 +160,10 @@ void CryNode::stat(struct ::stat *result) const { device()->callFsActionCallbacks(); if(_parent == none) { //We are the root directory. - //TODO What should we do? + //TODO What should we do? result->st_uid = getuid(); result->st_gid = getgid(); - result->st_mode = S_IFDIR | S_IRUSR | S_IWUSR | S_IXUSR; + result->st_mode = S_IFDIR | S_IRUSR | S_IWUSR | S_IXUSR; result->st_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->st_nlink = 1; diff --git a/src/cryfs/filesystem/CryOpenFile.cpp b/src/cryfs/filesystem/CryOpenFile.cpp index 336665b4..2376ccf9 100644 --- a/src/cryfs/filesystem/CryOpenFile.cpp +++ b/src/cryfs/filesystem/CryOpenFile.cpp @@ -35,8 +35,8 @@ void CryOpenFile::flush() { void CryOpenFile::stat(struct ::stat *result) const { _device->callFsActionCallbacks(); - _parent->statChildExceptSize(_fileBlob->key(), result); result->st_size = _fileBlob->size(); + _parent->statChildWithSizeAlreadySet(_fileBlob->key(), result); } void CryOpenFile::truncate(off_t size) const { diff --git a/src/cryfs/filesystem/cachingfsblobstore/DirBlobRef.h b/src/cryfs/filesystem/cachingfsblobstore/DirBlobRef.h index b1efc983..e9517b24 100644 --- a/src/cryfs/filesystem/cachingfsblobstore/DirBlobRef.h +++ b/src/cryfs/filesystem/cachingfsblobstore/DirBlobRef.h @@ -56,8 +56,8 @@ public: return _base->statChild(key, result); } - void statChildExceptSize(const blockstore::Key &key, struct ::stat *result) const { - return _base->statChildExceptSize(key, result); + void statChildWithSizeAlreadySet(const blockstore::Key &key, struct ::stat *result) const { + return _base->statChildWithSizeAlreadySet(key, result); } void updateAccessTimestampForChild(const blockstore::Key &key) { diff --git a/src/cryfs/filesystem/fsblobstore/DirBlob.cpp b/src/cryfs/filesystem/fsblobstore/DirBlob.cpp index a029f0d9..53b134c4 100644 --- a/src/cryfs/filesystem/fsblobstore/DirBlob.cpp +++ b/src/cryfs/filesystem/fsblobstore/DirBlob.cpp @@ -135,11 +135,11 @@ off_t DirBlob::lstat_size() const { } void DirBlob::statChild(const Key &key, struct ::stat *result) const { - statChildExceptSize(key, result); result->st_size = _getLstatSize(key); + statChildWithSizeAlreadySet(key, result); } -void DirBlob::statChildExceptSize(const Key &key, struct ::stat *result) const { +void DirBlob::statChildWithSizeAlreadySet(const Key &key, struct ::stat *result) const { auto childOpt = GetChild(key); if (childOpt == boost::none) { throw fspp::fuse::FuseErrnoException(ENOENT); diff --git a/src/cryfs/filesystem/fsblobstore/DirBlob.h b/src/cryfs/filesystem/fsblobstore/DirBlob.h index 0851f37d..4b4e71af 100644 --- a/src/cryfs/filesystem/fsblobstore/DirBlob.h +++ b/src/cryfs/filesystem/fsblobstore/DirBlob.h @@ -57,7 +57,7 @@ namespace cryfs { void statChild(const blockstore::Key &key, struct ::stat *result) const; - void statChildExceptSize(const blockstore::Key &key, struct ::stat *result) const; + void statChildWithSizeAlreadySet(const blockstore::Key &key, struct ::stat *result) const; void updateAccessTimestampForChild(const blockstore::Key &key); diff --git a/src/cryfs/filesystem/parallelaccessfsblobstore/DirBlobRef.h b/src/cryfs/filesystem/parallelaccessfsblobstore/DirBlobRef.h index 46a42226..ac64d198 100644 --- a/src/cryfs/filesystem/parallelaccessfsblobstore/DirBlobRef.h +++ b/src/cryfs/filesystem/parallelaccessfsblobstore/DirBlobRef.h @@ -52,8 +52,8 @@ public: return _base->statChild(key, result); } - void statChildExceptSize(const blockstore::Key &key, struct ::stat *result) const { - return _base->statChildExceptSize(key, result); + void statChildWithSizeAlreadySet(const blockstore::Key &key, struct ::stat *result) const { + return _base->statChildWithSizeAlreadySet(key, result); } void updateAccessTimestampForChild(const blockstore::Key &key) {