From bdab511d954a849d06e34f6d801cc374f867213b Mon Sep 17 00:00:00 2001 From: Benjamin Barenblat Date: Sun, 21 Feb 2016 23:05:22 -0500 Subject: Implement statfs --- src/operations.cc | 14 ++++++++++++++ 1 file changed, 14 insertions(+) (limited to 'src/operations.cc') diff --git a/src/operations.cc b/src/operations.cc index 79d2d07..cf53b05 100644 --- a/src/operations.cc +++ b/src/operations.cc @@ -33,6 +33,7 @@ #include #include #include +#include #include #include @@ -61,6 +62,17 @@ void* Initialize(fuse_conn_info*) noexcept { return nullptr; } void Destroy(void*) noexcept {} +int Statfs(const char* const c_path, struct statvfs* const output) { + const std::string path(c_path); + if (path == "/") { + *output = root_->StatVFs(); + } else { + *output = + root_->OpenAt(EncodePath(path).c_str(), O_RDONLY | O_PATH).StatVFs(); + } + return 0; +} + int Getattr(const char* const c_path, struct stat* output) { const std::string path(c_path); if (path == "/") { @@ -276,6 +288,8 @@ fuse_operations FuseOperations(File* const root) { result.init = Initialize; result.destroy = Destroy; + result.statfs = CATCH_AND_RETURN_EXCEPTIONS(Statfs); + result.getattr = CATCH_AND_RETURN_EXCEPTIONS(Getattr); result.fgetattr = CATCH_AND_RETURN_EXCEPTIONS(Fgetattr); -- cgit v1.2.3