Loading src/posix_file/CMakeLists.txt +2 −0 Original line number Diff line number Diff line Loading @@ -51,6 +51,8 @@ target_sources( posix_file/fs_plugin/posix_plugin.hpp posix_file/fs_plugin/fs_plugin.cpp posix_file/fs_plugin/posix_plugin.cpp posix_file/fs_plugin/none_plugin.hpp posix_file/fs_plugin/none_plugin.cpp ${GEKKO_INCLUDES} ${HERCULES_INCLUDES} ${EXPAND_INCLUDES} Loading src/posix_file/posix_file/fs_plugin/fs_plugin.cpp +16 −2 Original line number Diff line number Diff line #include "fs_plugin.hpp" #include "posix_plugin.hpp" #include "none_plugin.hpp" #ifdef GEKKOFS_PLUGIN #include "gekko_plugin.hpp" #endif Loading @@ -17,11 +18,20 @@ namespace cargo { static std::shared_ptr<FSPlugin> m_fs_posix; static std::shared_ptr<FSPlugin> m_fs_gekkofs; static std::shared_ptr<FSPlugin> m_fs_dataclay; static std::shared_ptr<FSPlugin> m_fs_hercules; static std::shared_ptr<FSPlugin> m_fs_expand; static std::shared_ptr<FSPlugin> m_fs_none; std::shared_ptr<FSPlugin> FSPlugin::make_fs(type t) { switch(t) { case type::none: if(m_fs_none == nullptr) m_fs_none = std::make_shared<cargo::none_plugin>(); return m_fs_none; case type::posix: case type::parallel: if(m_fs_posix == nullptr) Loading @@ -43,11 +53,15 @@ FSPlugin::make_fs(type t) { #endif #ifdef HERCULES_PLUGIN case type::hercules: return std::make_unique<cargo::hercules_plugin>(); if(m_fs_hercules == nullptr) m_fs_hercules = std::make_shared<cargo::hercules_plugin>(); return m_fs_hercules; #endif #ifdef EXPAND_PLUGIN case type::expand: return std::make_unique<cargo::expand_plugin>(); if(m_fs_expand == nullptr) m_fs_expand = std::make_shared<cargo::expand_plugin>(); return m_fs_expand; #endif default: return {}; Loading src/posix_file/posix_file/fs_plugin/none_plugin.cpp 0 → 100644 +93 −0 Original line number Diff line number Diff line #include <fcntl.h> #include <unistd.h> #include <sys/types.h> #include <sys/stat.h> #include "none_plugin.hpp" namespace cargo { none_plugin::none_plugin() {} int none_plugin::open(const std::string& path, int flags, unsigned int mode) { (void) path; (void) flags; (void) mode; return 0; } bool none_plugin::close(int fd) { (void) fd; return true; } ssize_t none_plugin::pread(int fd, void* buf, size_t count, off_t offset) { (void) fd; (void) buf; (void) count; (void) offset; return count; } ssize_t none_plugin::pwrite(int fd, const void* buf, size_t count, off_t offset) { (void) fd; (void) buf; (void) count; (void) offset; return count; } bool none_plugin::mkdir(const std::string& path, mode_t mode) { (void) path; (void) mode; return true; } off_t none_plugin::lseek(int fd, off_t offset, int whence) { (void) fd; (void) whence; return offset; } off_t none_plugin::fallocate(int fd, int mode, off_t offset, off_t len) { (void) fd; (void) mode; (void) len; return offset; } std::vector<std::string> none_plugin::readdir(const std::string& path) { (void) path; std::vector<std::string> files; return files; } int none_plugin::unlink(const std::string& path) { (void) path; return 0; } int none_plugin::stat(const std::string& path, struct stat* buf) { (void) path; (void) buf; return 0; } ssize_t none_plugin::size(const std::string& path) { (void) path; return 0; } }; // namespace cargo No newline at end of file src/posix_file/posix_file/fs_plugin/none_plugin.hpp 0 → 100644 +38 −0 Original line number Diff line number Diff line #ifndef NONE_PLUGIN_HPP #define NONE_PLUGIN_HPP #include "fs_plugin.hpp" #include <iostream> namespace cargo { class none_plugin : public FSPlugin { public: none_plugin(); int open(const std::string& path, int flags, unsigned int mode) final; bool close(int fd) final; ssize_t pread(int fd, void* buf, size_t count, off_t offset) final; ssize_t pwrite(int fd, const void* buf, size_t count, off_t offset) final; bool mkdir(const std::string& path, mode_t mode) final; off_t lseek(int fd, off_t offset, int whence) final; off_t fallocate(int fd, int mode, off_t offset, off_t len) final; std::vector<std::string> readdir(const std::string& path) final; int unlink(const std::string& path) final; int stat(const std::string& path, struct stat* buf) final; ssize_t size(const std::string& path) final; }; } // namespace cargo #endif // NONE_PLUGIN_HPP Loading
src/posix_file/CMakeLists.txt +2 −0 Original line number Diff line number Diff line Loading @@ -51,6 +51,8 @@ target_sources( posix_file/fs_plugin/posix_plugin.hpp posix_file/fs_plugin/fs_plugin.cpp posix_file/fs_plugin/posix_plugin.cpp posix_file/fs_plugin/none_plugin.hpp posix_file/fs_plugin/none_plugin.cpp ${GEKKO_INCLUDES} ${HERCULES_INCLUDES} ${EXPAND_INCLUDES} Loading
src/posix_file/posix_file/fs_plugin/fs_plugin.cpp +16 −2 Original line number Diff line number Diff line #include "fs_plugin.hpp" #include "posix_plugin.hpp" #include "none_plugin.hpp" #ifdef GEKKOFS_PLUGIN #include "gekko_plugin.hpp" #endif Loading @@ -17,11 +18,20 @@ namespace cargo { static std::shared_ptr<FSPlugin> m_fs_posix; static std::shared_ptr<FSPlugin> m_fs_gekkofs; static std::shared_ptr<FSPlugin> m_fs_dataclay; static std::shared_ptr<FSPlugin> m_fs_hercules; static std::shared_ptr<FSPlugin> m_fs_expand; static std::shared_ptr<FSPlugin> m_fs_none; std::shared_ptr<FSPlugin> FSPlugin::make_fs(type t) { switch(t) { case type::none: if(m_fs_none == nullptr) m_fs_none = std::make_shared<cargo::none_plugin>(); return m_fs_none; case type::posix: case type::parallel: if(m_fs_posix == nullptr) Loading @@ -43,11 +53,15 @@ FSPlugin::make_fs(type t) { #endif #ifdef HERCULES_PLUGIN case type::hercules: return std::make_unique<cargo::hercules_plugin>(); if(m_fs_hercules == nullptr) m_fs_hercules = std::make_shared<cargo::hercules_plugin>(); return m_fs_hercules; #endif #ifdef EXPAND_PLUGIN case type::expand: return std::make_unique<cargo::expand_plugin>(); if(m_fs_expand == nullptr) m_fs_expand = std::make_shared<cargo::expand_plugin>(); return m_fs_expand; #endif default: return {}; Loading
src/posix_file/posix_file/fs_plugin/none_plugin.cpp 0 → 100644 +93 −0 Original line number Diff line number Diff line #include <fcntl.h> #include <unistd.h> #include <sys/types.h> #include <sys/stat.h> #include "none_plugin.hpp" namespace cargo { none_plugin::none_plugin() {} int none_plugin::open(const std::string& path, int flags, unsigned int mode) { (void) path; (void) flags; (void) mode; return 0; } bool none_plugin::close(int fd) { (void) fd; return true; } ssize_t none_plugin::pread(int fd, void* buf, size_t count, off_t offset) { (void) fd; (void) buf; (void) count; (void) offset; return count; } ssize_t none_plugin::pwrite(int fd, const void* buf, size_t count, off_t offset) { (void) fd; (void) buf; (void) count; (void) offset; return count; } bool none_plugin::mkdir(const std::string& path, mode_t mode) { (void) path; (void) mode; return true; } off_t none_plugin::lseek(int fd, off_t offset, int whence) { (void) fd; (void) whence; return offset; } off_t none_plugin::fallocate(int fd, int mode, off_t offset, off_t len) { (void) fd; (void) mode; (void) len; return offset; } std::vector<std::string> none_plugin::readdir(const std::string& path) { (void) path; std::vector<std::string> files; return files; } int none_plugin::unlink(const std::string& path) { (void) path; return 0; } int none_plugin::stat(const std::string& path, struct stat* buf) { (void) path; (void) buf; return 0; } ssize_t none_plugin::size(const std::string& path) { (void) path; return 0; } }; // namespace cargo No newline at end of file
src/posix_file/posix_file/fs_plugin/none_plugin.hpp 0 → 100644 +38 −0 Original line number Diff line number Diff line #ifndef NONE_PLUGIN_HPP #define NONE_PLUGIN_HPP #include "fs_plugin.hpp" #include <iostream> namespace cargo { class none_plugin : public FSPlugin { public: none_plugin(); int open(const std::string& path, int flags, unsigned int mode) final; bool close(int fd) final; ssize_t pread(int fd, void* buf, size_t count, off_t offset) final; ssize_t pwrite(int fd, const void* buf, size_t count, off_t offset) final; bool mkdir(const std::string& path, mode_t mode) final; off_t lseek(int fd, off_t offset, int whence) final; off_t fallocate(int fd, int mode, off_t offset, off_t len) final; std::vector<std::string> readdir(const std::string& path) final; int unlink(const std::string& path) final; int stat(const std::string& path, struct stat* buf) final; ssize_t size(const std::string& path) final; }; } // namespace cargo #endif // NONE_PLUGIN_HPP