2014-11-15 15:16:18 +01:00
|
|
|
#pragma once
|
2014-11-15 17:24:07 +01:00
|
|
|
#ifndef FUSEPP_FILESYSTEMIMPL_H_
|
|
|
|
#define FUSEPP_FILESYSTEMIMPL_H_
|
2014-11-15 15:16:18 +01:00
|
|
|
|
|
|
|
#include <boost/filesystem.hpp>
|
2014-11-15 17:24:07 +01:00
|
|
|
#include "FuseOpenFileList.h"
|
2014-11-15 15:16:18 +01:00
|
|
|
#include <memory>
|
|
|
|
#include <sys/stat.h>
|
|
|
|
#include <sys/statvfs.h>
|
|
|
|
|
2014-11-15 17:24:07 +01:00
|
|
|
#include "fusepp/utils/macros.h"
|
2014-11-15 15:16:18 +01:00
|
|
|
|
|
|
|
namespace fusepp {
|
2014-11-15 23:47:38 +01:00
|
|
|
class Node;
|
|
|
|
class File;
|
|
|
|
class OpenFile;
|
|
|
|
class Dir;
|
2014-11-15 15:16:18 +01:00
|
|
|
|
2014-11-15 17:24:07 +01:00
|
|
|
class FilesystemImpl {
|
2014-11-15 15:16:18 +01:00
|
|
|
public:
|
2014-11-15 23:47:38 +01:00
|
|
|
FilesystemImpl(Device *device);
|
2014-11-15 17:24:07 +01:00
|
|
|
virtual ~FilesystemImpl();
|
2014-11-15 15:16:18 +01:00
|
|
|
|
2014-11-15 16:33:24 +01:00
|
|
|
int openFile(const boost::filesystem::path &path, int flags);
|
2014-11-15 15:16:18 +01:00
|
|
|
void closeFile(int descriptor);
|
2014-11-15 16:33:24 +01:00
|
|
|
void lstat(const boost::filesystem::path &path, struct ::stat *stbuf);
|
2014-11-15 15:16:18 +01:00
|
|
|
void fstat(int descriptor, struct ::stat *stbuf);
|
2014-11-15 16:33:24 +01:00
|
|
|
void truncate(const boost::filesystem::path &path, off_t size);
|
2014-11-15 15:16:18 +01:00
|
|
|
void ftruncate(int descriptor, off_t size);
|
|
|
|
int read(int descriptor, void *buf, size_t count, off_t offset);
|
|
|
|
void write(int descriptor, const void *buf, size_t count, off_t offset);
|
|
|
|
void fsync(int descriptor);
|
|
|
|
void fdatasync(int descriptor);
|
2014-11-15 16:33:24 +01:00
|
|
|
void access(const boost::filesystem::path &path, int mask);
|
|
|
|
int createAndOpenFile(const boost::filesystem::path &path, mode_t mode);
|
|
|
|
void mkdir(const boost::filesystem::path &path, mode_t mode);
|
|
|
|
void rmdir(const boost::filesystem::path &path);
|
|
|
|
void unlink(const boost::filesystem::path &path);
|
|
|
|
void rename(const boost::filesystem::path &from, const boost::filesystem::path &to);
|
|
|
|
std::unique_ptr<std::vector<std::string>> readDir(const boost::filesystem::path &path);
|
|
|
|
void utimens(const boost::filesystem::path &path, const timespec times[2]);
|
2014-11-15 17:24:07 +01:00
|
|
|
void statfs(const boost::filesystem::path &path, struct statvfs *fsstat);
|
2014-11-15 15:16:18 +01:00
|
|
|
|
|
|
|
private:
|
2014-11-15 23:47:38 +01:00
|
|
|
std::unique_ptr<File> LoadFile(const boost::filesystem::path &path);
|
|
|
|
std::unique_ptr<Dir> LoadDir(const boost::filesystem::path &path);
|
|
|
|
int openFile(const File &file, int flags);
|
2014-11-15 17:24:07 +01:00
|
|
|
|
2014-11-15 23:47:38 +01:00
|
|
|
Device *_device;
|
2014-11-15 15:16:18 +01:00
|
|
|
FuseOpenFileList _open_files;
|
|
|
|
|
2014-11-15 17:24:07 +01:00
|
|
|
DISALLOW_COPY_AND_ASSIGN(FilesystemImpl);
|
2014-11-15 15:16:18 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
}
|
|
|
|
|
2014-11-15 17:24:07 +01:00
|
|
|
#endif /* FUSEPP_FILESYSTEMIMPL_H_ */
|