Loading fs/CMakeLists.txt +1 −1 Original line number Diff line number Diff line Loading @@ -16,6 +16,6 @@ find_package(FUSE3 REQUIRED) find_package(Boost 1.56.0 COMPONENTS system filesystem serialization) include_directories(${FUSE3_INCLUDE_DIR} include/) set(SOURCE_FILES src/main.cpp src/main.h src/fuse_ops.h src/util.cpp src/classes/metadata.h src/classes/metadata.cpp src/adafs_ops/metadata_ops.h src/adafs_ops/metadata_ops.cpp src/adafs_ops/dentry_ops.cpp src/adafs_ops/dentry_ops.h src/configure.h src/fuse_ops/file.cpp src/fuse_ops/directory.cpp src/fuse_ops/access.cpp src/fuse_ops/sync.cpp src/adafs_ops/access.cpp src/adafs_ops/access.h src/fuse_ops/fs.cpp src/fuse_ops/io.cpp) set(SOURCE_FILES src/main.cpp src/main.h src/fuse_ops.h src/util.cpp src/classes/metadata.h src/classes/metadata.cpp src/adafs_ops/metadata_ops.h src/adafs_ops/metadata_ops.cpp src/adafs_ops/dentry_ops.cpp src/adafs_ops/dentry_ops.h src/configure.h src/fuse_ops/file.cpp src/fuse_ops/directory.cpp src/fuse_ops/access.cpp src/fuse_ops/sync.cpp src/adafs_ops/access.cpp src/adafs_ops/access.h src/fuse_ops/fs.cpp src/fuse_ops/io.cpp src/adafs_ops/io.cpp src/adafs_ops/io.h) add_executable(adafs ${SOURCE_FILES} src/main.cpp) target_link_libraries(adafs ${FUSE3_LIBRARIES} -lpthread -lboost_system -lboost_filesystem -lboost_serialization) No newline at end of file fs/src/adafs_ops/io.cpp 0 → 100644 +43 −0 Original line number Diff line number Diff line // // Created by evie on 4/3/17. // #include "io.h" using namespace std; /** * Creates the directory in the chunk dir for a file to hold data * @param hash * @return */ // XXX this might be just a temp function as long as we don't use chunks // XXX this function creates not only the chunk folder but also a single file which holds the data of the 'real' file int init_chunk_space(const unsigned long hash) { auto chnk_path = bfs::path(ADAFS_DATA->chunk_path); chnk_path /= to_string(hash); // create chunk dir bfs::create_directories(chnk_path); // XXX create temp big file. remember also to modify the return value chnk_path /= "data"s; bfs::ofstream ofs{chnk_path}; return bfs::exists(chnk_path); } /** * Remove the directory in the chunk dir of a file. * @param hash * @return */ // XXX this might be just a temp function as long as we don't use chunks int destroy_chunk_space(const unsigned long hash) { auto chnk_path = bfs::path(ADAFS_DATA->chunk_path); chnk_path /= to_string(hash); // create chunk dir bfs::remove_all(chnk_path); return !bfs::exists(chnk_path); } No newline at end of file fs/src/adafs_ops/io.h 0 → 100644 +14 −0 Original line number Diff line number Diff line // // Created by evie on 4/3/17. // #ifndef FS_IO_H #define FS_IO_H #include "../main.h" int init_chunk_space(const unsigned long hash); int destroy_chunk_space(const unsigned long hash); #endif //FS_IO_H fs/src/fuse_ops.h +1 −0 Original line number Diff line number Diff line Loading @@ -13,6 +13,7 @@ int adafs_mknod(const char* p, mode_t, dev_t); int adafs_open(const char*, struct fuse_file_info* fi); int adafs_unlink(const char* p); int adafs_utimens(const char* p, const struct timespec tv[2], struct fuse_file_info* fi); int adafs_release(const char* p, struct fuse_file_info* fi); // directory int adafs_opendir(const char* p, struct fuse_file_info* fi); Loading fs/src/fuse_ops/file.cpp +24 −0 Original line number Diff line number Diff line Loading @@ -7,6 +7,7 @@ #include "../adafs_ops/metadata_ops.h" #include "../adafs_ops/dentry_ops.h" #include "../adafs_ops/access.h" #include "../adafs_ops/io.h" using namespace std; Loading Loading @@ -66,6 +67,9 @@ int adafs_mknod(const char* p, mode_t mode, dev_t dev) { auto md = make_unique<Metadata>(S_IFREG | mode); write_all_metadata(*md, ADAFS_DATA->hashf(path.string())); // create chunk space init_chunk_space(ADAFS_DATA->hashf(path.string())); return 0; } Loading Loading @@ -125,6 +129,8 @@ int adafs_unlink(const char* p) { if (err) return err; // XXX delete unused data blocks (asynchronously) // XXX currently just throws away the data directory on disk destroy_chunk_space(ADAFS_DATA->hashf(path.string())); return 0; } Loading @@ -146,3 +152,21 @@ int adafs_utimens(const char* p, const struct timespec tv[2], struct fuse_file_i // XXX ignored for now. Later: Make it configurable return 0; } /** Release an open file * * Release is called when there are no more references to an open * file: all file descriptors are closed and all memory mappings * are unmapped. * * For every open() call there will be exactly one release() call * with the same flags and file descriptor. It is possible to * have a file opened more than once, in which case only the last * release will mean, that no more reads/writes will happen on the * file. The return value of release is ignored. */ int adafs_release(const char* p, struct fuse_file_info* fi) { ADAFS_DATA->logger->info("##### FUSE FUNC ###### adafs_release() enter: name '{}'", p); // XXX Dunno what this function is for yet return 0; } No newline at end of file Loading
fs/CMakeLists.txt +1 −1 Original line number Diff line number Diff line Loading @@ -16,6 +16,6 @@ find_package(FUSE3 REQUIRED) find_package(Boost 1.56.0 COMPONENTS system filesystem serialization) include_directories(${FUSE3_INCLUDE_DIR} include/) set(SOURCE_FILES src/main.cpp src/main.h src/fuse_ops.h src/util.cpp src/classes/metadata.h src/classes/metadata.cpp src/adafs_ops/metadata_ops.h src/adafs_ops/metadata_ops.cpp src/adafs_ops/dentry_ops.cpp src/adafs_ops/dentry_ops.h src/configure.h src/fuse_ops/file.cpp src/fuse_ops/directory.cpp src/fuse_ops/access.cpp src/fuse_ops/sync.cpp src/adafs_ops/access.cpp src/adafs_ops/access.h src/fuse_ops/fs.cpp src/fuse_ops/io.cpp) set(SOURCE_FILES src/main.cpp src/main.h src/fuse_ops.h src/util.cpp src/classes/metadata.h src/classes/metadata.cpp src/adafs_ops/metadata_ops.h src/adafs_ops/metadata_ops.cpp src/adafs_ops/dentry_ops.cpp src/adafs_ops/dentry_ops.h src/configure.h src/fuse_ops/file.cpp src/fuse_ops/directory.cpp src/fuse_ops/access.cpp src/fuse_ops/sync.cpp src/adafs_ops/access.cpp src/adafs_ops/access.h src/fuse_ops/fs.cpp src/fuse_ops/io.cpp src/adafs_ops/io.cpp src/adafs_ops/io.h) add_executable(adafs ${SOURCE_FILES} src/main.cpp) target_link_libraries(adafs ${FUSE3_LIBRARIES} -lpthread -lboost_system -lboost_filesystem -lboost_serialization) No newline at end of file
fs/src/adafs_ops/io.cpp 0 → 100644 +43 −0 Original line number Diff line number Diff line // // Created by evie on 4/3/17. // #include "io.h" using namespace std; /** * Creates the directory in the chunk dir for a file to hold data * @param hash * @return */ // XXX this might be just a temp function as long as we don't use chunks // XXX this function creates not only the chunk folder but also a single file which holds the data of the 'real' file int init_chunk_space(const unsigned long hash) { auto chnk_path = bfs::path(ADAFS_DATA->chunk_path); chnk_path /= to_string(hash); // create chunk dir bfs::create_directories(chnk_path); // XXX create temp big file. remember also to modify the return value chnk_path /= "data"s; bfs::ofstream ofs{chnk_path}; return bfs::exists(chnk_path); } /** * Remove the directory in the chunk dir of a file. * @param hash * @return */ // XXX this might be just a temp function as long as we don't use chunks int destroy_chunk_space(const unsigned long hash) { auto chnk_path = bfs::path(ADAFS_DATA->chunk_path); chnk_path /= to_string(hash); // create chunk dir bfs::remove_all(chnk_path); return !bfs::exists(chnk_path); } No newline at end of file
fs/src/adafs_ops/io.h 0 → 100644 +14 −0 Original line number Diff line number Diff line // // Created by evie on 4/3/17. // #ifndef FS_IO_H #define FS_IO_H #include "../main.h" int init_chunk_space(const unsigned long hash); int destroy_chunk_space(const unsigned long hash); #endif //FS_IO_H
fs/src/fuse_ops.h +1 −0 Original line number Diff line number Diff line Loading @@ -13,6 +13,7 @@ int adafs_mknod(const char* p, mode_t, dev_t); int adafs_open(const char*, struct fuse_file_info* fi); int adafs_unlink(const char* p); int adafs_utimens(const char* p, const struct timespec tv[2], struct fuse_file_info* fi); int adafs_release(const char* p, struct fuse_file_info* fi); // directory int adafs_opendir(const char* p, struct fuse_file_info* fi); Loading
fs/src/fuse_ops/file.cpp +24 −0 Original line number Diff line number Diff line Loading @@ -7,6 +7,7 @@ #include "../adafs_ops/metadata_ops.h" #include "../adafs_ops/dentry_ops.h" #include "../adafs_ops/access.h" #include "../adafs_ops/io.h" using namespace std; Loading Loading @@ -66,6 +67,9 @@ int adafs_mknod(const char* p, mode_t mode, dev_t dev) { auto md = make_unique<Metadata>(S_IFREG | mode); write_all_metadata(*md, ADAFS_DATA->hashf(path.string())); // create chunk space init_chunk_space(ADAFS_DATA->hashf(path.string())); return 0; } Loading Loading @@ -125,6 +129,8 @@ int adafs_unlink(const char* p) { if (err) return err; // XXX delete unused data blocks (asynchronously) // XXX currently just throws away the data directory on disk destroy_chunk_space(ADAFS_DATA->hashf(path.string())); return 0; } Loading @@ -146,3 +152,21 @@ int adafs_utimens(const char* p, const struct timespec tv[2], struct fuse_file_i // XXX ignored for now. Later: Make it configurable return 0; } /** Release an open file * * Release is called when there are no more references to an open * file: all file descriptors are closed and all memory mappings * are unmapped. * * For every open() call there will be exactly one release() call * with the same flags and file descriptor. It is possible to * have a file opened more than once, in which case only the last * release will mean, that no more reads/writes will happen on the * file. The return value of release is ignored. */ int adafs_release(const char* p, struct fuse_file_info* fi) { ADAFS_DATA->logger->info("##### FUSE FUNC ###### adafs_release() enter: name '{}'", p); // XXX Dunno what this function is for yet return 0; } No newline at end of file