2014-11-19 00:15:15 +01:00
|
|
|
#pragma once
|
2015-10-15 13:04:57 +02:00
|
|
|
#ifndef MESSMER_FSPP_FUSE_FILESYSTEM_H_
|
|
|
|
#define MESSMER_FSPP_FUSE_FILESYSTEM_H_
|
2014-11-19 00:15:15 +01:00
|
|
|
|
|
|
|
#include <boost/filesystem.hpp>
|
2016-02-11 12:53:42 +01:00
|
|
|
#include <cpp-utils/pointer/unique_ref.h>
|
2014-11-19 00:15:15 +01:00
|
|
|
#include <sys/stat.h>
|
|
|
|
#include <sys/statvfs.h>
|
2015-03-10 21:51:12 +01:00
|
|
|
#include "../fs_interface/Dir.h"
|
2014-11-19 00:15:15 +01:00
|
|
|
|
|
|
|
namespace fspp {
|
2014-11-28 14:46:45 +01:00
|
|
|
namespace fuse {
|
2014-11-19 00:15:15 +01:00
|
|
|
class Filesystem {
|
|
|
|
public:
|
|
|
|
virtual ~Filesystem() {}
|
|
|
|
|
2015-04-25 03:26:59 +02:00
|
|
|
//TODO Test uid/gid parameters of createAndOpenFile
|
2018-09-14 11:34:11 +02:00
|
|
|
virtual int createAndOpenFile(const boost::filesystem::path &path, ::mode_t mode, ::uid_t uid, ::gid_t gid) = 0;
|
2014-11-19 00:15:15 +01:00
|
|
|
virtual int openFile(const boost::filesystem::path &path, int flags) = 0;
|
2014-11-21 01:11:24 +01:00
|
|
|
virtual void flush(int descriptor) = 0;
|
2014-11-19 00:15:15 +01:00
|
|
|
virtual void closeFile(int descriptor) = 0;
|
|
|
|
virtual void lstat(const boost::filesystem::path &path, struct ::stat *stbuf) = 0;
|
|
|
|
virtual void fstat(int descriptor, struct ::stat *stbuf) = 0;
|
2015-04-25 03:26:59 +02:00
|
|
|
//TODO Test chmod
|
2018-09-14 11:34:11 +02:00
|
|
|
virtual void chmod(const boost::filesystem::path &path, ::mode_t mode) = 0;
|
2015-04-25 03:26:59 +02:00
|
|
|
//TODO Test chown
|
2018-09-14 11:34:11 +02:00
|
|
|
virtual void chown(const boost::filesystem::path &path, ::uid_t uid, ::gid_t gid) = 0;
|
2018-09-15 23:32:58 +02:00
|
|
|
virtual void truncate(const boost::filesystem::path &path, fspp::num_bytes_t size) = 0;
|
|
|
|
virtual void ftruncate(int descriptor, fspp::num_bytes_t size) = 0;
|
|
|
|
virtual fspp::num_bytes_t read(int descriptor, void *buf, fspp::num_bytes_t count, fspp::num_bytes_t offset) = 0;
|
|
|
|
virtual void write(int descriptor, const void *buf, fspp::num_bytes_t count, fspp::num_bytes_t offset) = 0;
|
2014-11-19 00:15:15 +01:00
|
|
|
virtual void fsync(int descriptor) = 0;
|
|
|
|
virtual void fdatasync(int descriptor) = 0;
|
|
|
|
virtual void access(const boost::filesystem::path &path, int mask) = 0;
|
2015-04-25 03:26:59 +02:00
|
|
|
//TODO Test uid/gid parameters of mkdir
|
2018-09-14 11:34:11 +02:00
|
|
|
virtual void mkdir(const boost::filesystem::path &path, ::mode_t mode, ::uid_t uid, ::gid_t gid) = 0;
|
2014-11-19 00:15:15 +01:00
|
|
|
virtual void rmdir(const boost::filesystem::path &path) = 0;
|
|
|
|
virtual void unlink(const boost::filesystem::path &path) = 0;
|
|
|
|
virtual void rename(const boost::filesystem::path &from, const boost::filesystem::path &to) = 0;
|
2016-02-09 09:19:45 +01:00
|
|
|
virtual void utimens(const boost::filesystem::path &path, timespec lastAccessTime, timespec lastModificationTime) = 0;
|
2018-09-12 03:26:33 +02:00
|
|
|
virtual void statfs(const boost::filesystem::path &path, struct ::statvfs *fsstat) = 0;
|
2015-03-10 21:51:12 +01:00
|
|
|
//TODO We shouldn't use Dir::Entry here, that's in another layer
|
2015-06-18 19:30:52 +02:00
|
|
|
virtual cpputils::unique_ref<std::vector<Dir::Entry>> readDir(const boost::filesystem::path &path) = 0;
|
2015-04-25 03:26:59 +02:00
|
|
|
//TODO Test createSymlink
|
2018-09-14 11:34:11 +02:00
|
|
|
virtual void createSymlink(const boost::filesystem::path &to, const boost::filesystem::path &from, ::uid_t uid, ::gid_t gid) = 0;
|
2015-04-25 03:26:59 +02:00
|
|
|
//TODO Test readSymlink
|
2018-09-15 23:32:58 +02:00
|
|
|
virtual void readSymlink(const boost::filesystem::path &path, char *buf, fspp::num_bytes_t size) = 0;
|
2014-11-19 00:15:15 +01:00
|
|
|
};
|
|
|
|
|
2014-11-28 14:46:45 +01:00
|
|
|
}
|
2014-11-19 00:15:15 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
#endif
|