aboutsummaryrefslogtreecommitdiff
path: root/src/operations.cc
diff options
context:
space:
mode:
Diffstat (limited to 'src/operations.cc')
-rw-r--r--src/operations.cc14
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);