#pragma once #ifndef MESSMER_FSPP_IMPL_FILESYSTEMIMPL_H_ #define MESSMER_FSPP_IMPL_FILESYSTEMIMPL_H_ #include "FuseOpenFileList.h" #include "../fuse/Filesystem.h" #include #include //Remove this line if you don't want profiling //#define FSPP_PROFILE 1 namespace fspp { class Node; class File; class Symlink; class OpenFile; class FilesystemImpl final: public fuse::Filesystem { public: explicit FilesystemImpl(Device *device); virtual ~FilesystemImpl(); int openFile(const boost::filesystem::path &path, int flags) override; void flush(int descriptor) override; void closeFile(int descriptor) override; void lstat(const boost::filesystem::path &path, struct ::stat *stbuf) override; void fstat(int descriptor, struct ::stat *stbuf) override; void chmod(const boost::filesystem::path &path, mode_t mode) override; void chown(const boost::filesystem::path &path, uid_t uid, gid_t gid) override; void truncate(const boost::filesystem::path &path, off_t size) override; void ftruncate(int descriptor, off_t size) override; size_t read(int descriptor, void *buf, size_t count, off_t offset) override; void write(int descriptor, const void *buf, size_t count, off_t offset) override; void fsync(int descriptor) override; void fdatasync(int descriptor) override; void access(const boost::filesystem::path &path, int mask) override; int createAndOpenFile(const boost::filesystem::path &path, mode_t mode, uid_t uid, gid_t gid) override; void mkdir(const boost::filesystem::path &path, mode_t mode, uid_t uid, gid_t gid) override; void rmdir(const boost::filesystem::path &path) override; void unlink(const boost::filesystem::path &path) override; void rename(const boost::filesystem::path &from, const boost::filesystem::path &to) override; cpputils::unique_ref> readDir(const boost::filesystem::path &path) override; void utimens(const boost::filesystem::path &path, const timespec times[2]) override; void statfs(const boost::filesystem::path &path, struct statvfs *fsstat) override; void createSymlink(const boost::filesystem::path &to, const boost::filesystem::path &from, uid_t uid, gid_t gid) override; void readSymlink(const boost::filesystem::path &path, char *buf, size_t size) override; private: cpputils::unique_ref LoadFile(const boost::filesystem::path &path); cpputils::unique_ref LoadDir(const boost::filesystem::path &path); cpputils::unique_ref LoadSymlink(const boost::filesystem::path &path); cpputils::unique_ref LoadFileOrSymlink(const boost::filesystem::path &path); int openFile(const File &file, int flags); #ifdef FSPP_PROFILE std::atomic _loadFileNanosec; std::atomic _loadDirNanosec; std::atomic _loadSymlinkNanosec; std::atomic _loadFileOrSymlinkNanosec; std::atomic _openFileNanosec; std::atomic _flushNanosec; std::atomic _closeFileNanosec; std::atomic _lstatNanosec; std::atomic _fstatNanosec; std::atomic _chmodNanosec; std::atomic _chownNanosec; std::atomic _truncateNanosec; std::atomic _ftruncateNanosec; std::atomic _readNanosec; std::atomic _writeNanosec; std::atomic _fsyncNanosec; std::atomic _fdatasyncNanosec; std::atomic _accessNanosec; std::atomic _createAndOpenFileNanosec; std::atomic _createAndOpenFileNanosec_withoutLoading; std::atomic _mkdirNanosec; std::atomic _mkdirNanosec_withoutLoading; std::atomic _rmdirNanosec; std::atomic _rmdirNanosec_withoutLoading; std::atomic _unlinkNanosec; std::atomic _unlinkNanosec_withoutLoading; std::atomic _renameNanosec; std::atomic _readDirNanosec; std::atomic _readDirNanosec_withoutLoading; std::atomic _utimensNanosec; std::atomic _statfsNanosec; std::atomic _createSymlinkNanosec; std::atomic _createSymlinkNanosec_withoutLoading; std::atomic _readSymlinkNanosec; std::atomic _readSymlinkNanosec_withoutLoading; #endif Device *_device; FuseOpenFileList _open_files; DISALLOW_COPY_AND_ASSIGN(FilesystemImpl); }; } #endif