Fix fsstat on osx

This commit is contained in:
Sebastian Messmer 2017-08-31 23:40:25 +01:00
parent bc46bc88e9
commit 3aa8b74fd9
2 changed files with 6 additions and 2 deletions

View File

@ -100,8 +100,11 @@ uint64_t OnDiskBlockStore2::numBlocks() const {
uint64_t OnDiskBlockStore2::estimateNumFreeBytes() const {
struct statvfs stat;
::statvfs(_rootDir.c_str(), &stat);
return stat.f_bsize*stat.f_bavail;
int result = ::statvfs(_rootDir.c_str(), &stat);
if (0 != result) {
throw std::runtime_error("Error calling statvfs()");
}
return stat.f_frsize*stat.f_bavail;
}
uint64_t OnDiskBlockStore2::blockSizeFromPhysicalBlockSize(uint64_t blockSize) const {

View File

@ -255,6 +255,7 @@ void CryDevice::statfs(const bf::path &path, struct statvfs *fsstat) {
fsstat->f_ffree = numFreeBlocks;
fsstat->f_namemax = 255; // We theoretically support unlimited file name length, but this is default for many Linux file systems, so probably also makes sense for CryFS.
//f_frsize, f_favail, f_fsid and f_flag are ignored in fuse, see http://fuse.sourcearchive.com/documentation/2.7.0/structfuse__operations_4e765e29122e7b6b533dc99849a52655.html#4e765e29122e7b6b533dc99849a52655
fsstat->f_frsize = fsstat->f_bsize; // even though this is supposed to be ignored, osxfuse needs it.
}
unique_ref<FileBlobRef> CryDevice::CreateFileBlob(const blockstore::Key &parent) {