diff options
author | Benjamin Barenblat <bbaren@mit.edu> | 2016-02-21 23:05:22 -0500 |
---|---|---|
committer | Benjamin Barenblat <bbaren@mit.edu> | 2016-02-21 23:05:22 -0500 |
commit | bdab511d954a849d06e34f6d801cc374f867213b (patch) | |
tree | 92df0982596d1957232ccde6722504f3f24c84c5 /src/operations.cc | |
parent | 13643137642c5000924e20de56856c909b05769e (diff) |
Implement statfs
Diffstat (limited to 'src/operations.cc')
-rw-r--r-- | src/operations.cc | 14 |
1 files changed, 14 insertions, 0 deletions
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 <fcntl.h> #include <glog/logging.h> #include <sys/stat.h> +#include <sys/statvfs.h> #include <sys/types.h> #include <time.h> @@ -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); |