Implement flush()
This commit is contained in:
parent
6e05240cb6
commit
2ff9c416df
@ -16,6 +16,7 @@ public:
|
||||
virtual void truncate(off_t size) const = 0;
|
||||
virtual int read(void *buf, size_t count, off_t offset) = 0;
|
||||
virtual void write(const void *buf, size_t count, off_t offset) = 0;
|
||||
virtual void flush() = 0;
|
||||
virtual void fsync() = 0;
|
||||
virtual void fdatasync() = 0;
|
||||
};
|
||||
|
@ -431,10 +431,14 @@ int Fuse::statfs(const bf::path &path, struct statvfs *fsstat) {
|
||||
|
||||
//TODO
|
||||
int Fuse::flush(const bf::path &path, fuse_file_info *fileinfo) {
|
||||
//printf("Called non-implemented flush(%s, _)\n", path.c_str());
|
||||
UNUSED(path);
|
||||
UNUSED(fileinfo);
|
||||
return 0;
|
||||
//printf("Called non-implemented flush(%s, _)\n", path.c_str());
|
||||
try {
|
||||
_fs->flush(fileinfo->fh);
|
||||
return 0;
|
||||
} catch (FuseErrnoException &e) {
|
||||
return -e.getErrno();
|
||||
}
|
||||
}
|
||||
|
||||
int Fuse::fsync(const bf::path &path, int datasync, fuse_file_info *fileinfo) {
|
||||
|
@ -13,6 +13,7 @@ public:
|
||||
virtual ~Filesystem() {}
|
||||
|
||||
virtual int openFile(const boost::filesystem::path &path, int flags) = 0;
|
||||
virtual void flush(int descriptor) = 0;
|
||||
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;
|
||||
|
@ -54,6 +54,10 @@ int FilesystemImpl::openFile(const File &file, int flags) {
|
||||
return _open_files.open(file, flags);
|
||||
}
|
||||
|
||||
void FilesystemImpl::flush(int descriptor) {
|
||||
_open_files.get(descriptor)->flush();
|
||||
}
|
||||
|
||||
void FilesystemImpl::closeFile(int descriptor) {
|
||||
_open_files.close(descriptor);
|
||||
}
|
||||
|
@ -19,6 +19,7 @@ public:
|
||||
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;
|
||||
|
@ -22,6 +22,7 @@ public:
|
||||
MOCK_CONST_METHOD1(truncate, void(off_t));
|
||||
MOCK_METHOD3(read, int(void*, size_t, off_t));
|
||||
MOCK_METHOD3(write, void(const void*, size_t, off_t));
|
||||
MOCK_METHOD0(flush, void());
|
||||
MOCK_METHOD0(fsync, void());
|
||||
MOCK_METHOD0(fdatasync, void());
|
||||
};
|
||||
|
@ -42,6 +42,7 @@ public:
|
||||
MOCK_METHOD2(ftruncate, void(int, off_t));
|
||||
MOCK_METHOD4(read, int(int, void*, size_t, off_t));
|
||||
MOCK_METHOD4(write, void(int, const void*, size_t, off_t));
|
||||
MOCK_METHOD1(flush, void(int));
|
||||
MOCK_METHOD1(fsync, void(int));
|
||||
MOCK_METHOD1(fdatasync, void(int));
|
||||
MOCK_PATH_METHOD2(access, void, int);
|
||||
|
Loading…
Reference in New Issue
Block a user