From fbcdf864613bfeb84edfa945304c065f6a29b44e Mon Sep 17 00:00:00 2001 From: Benjamin Barenblat Date: Sat, 13 Feb 2016 22:14:04 -0500 Subject: Save root file descriptor when starting up MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Allow access to underlying file system by saving a file descriptor to the underlying directory when starting. Close the FD during FUSE’s destroy routine, though it won’t matter much. --- src/operations.cc | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) (limited to 'src/operations.cc') diff --git a/src/operations.cc b/src/operations.cc index abd2f0c..d22a1e2 100644 --- a/src/operations.cc +++ b/src/operations.cc @@ -33,10 +33,14 @@ #include #include +#include "utility.h" + namespace scoville { namespace { +int root_fd_; + struct Directory { DIR* fd; dirent* entry; @@ -75,6 +79,8 @@ void* Initialize(fuse_conn_info*) { void Destroy(void*) { LOG(INFO) << "destroy"; + LOG_IF(ERROR, close(root_fd_) == -1) << "could not close root FD: " + << ErrnoText(); } int Getattr(const char* const path, struct stat* output) { @@ -153,7 +159,9 @@ int Releasedir(const char*, fuse_file_info* const file_info) { } // namespace -fuse_operations FuseOperations() { +fuse_operations FuseOperations(const int root_fd) { + root_fd_ = root_fd; + fuse_operations result; result.flag_nullpath_ok = true; -- cgit v1.2.3