Loading include/client/fuse/fuse_client.hpp +0 −13 Original line number Diff line number Diff line Loading @@ -45,19 +45,6 @@ extern "C" { #define FUSE_USE_VERSION FUSE_MAKE_VERSION(3, 12) #include <fuse3/fuse_lowlevel.h> // TODO do we really need this? sizeof(DIR) statement, copied from gkfs_libc.hpp struct __dirstream { int fd; // File descriptor. //__libc_lock_define (, lock) // Mutex lock for this structure. //TODO size_t allocation; // Space allocated for the block. size_t size; // Total valid data in the block. size_t offset; // Current offset into the block. off_t filepos; // Position of next entry to read. // Directory block. char* path; char data[1] __attribute__((aligned(__alignof__(void*)))); }; // Originally its 0, but C++ does not permit it } #include <unistd.h> Loading src/client/fuse/fuse_client.cpp +7 −40 Original line number Diff line number Diff line Loading @@ -442,41 +442,20 @@ opendir_handler(fuse_req_t req, fuse_ino_t ino, struct fuse_file_info* fi) { fuse_reply_err(req, ENOTDIR); return; } struct stat st; if(ud->debug) fuse_log(FUSE_LOG_DEBUG, "open dir %s \n", inode->path.c_str()); if(gkfs::syscall::gkfs_stat(inode->path, &st) != 0 || S_ISREG(st.st_mode)) { fuse_reply_err(req, ENOTDIR); return; } const int fd = gkfs::syscall::gkfs_opendir(inode->path); if(fd < 0) { fuse_reply_err(req, ENOTDIR); return; } // Simulate DIR structure for GekkoFS DIR* dirp = static_cast<DIR*>(malloc(sizeof(DIR) + inode->path.length() + 1)); // Approximate size for DIR and path if(dirp == nullptr) { gkfs::syscall::gkfs_close(fd); // Clean up opened GekkoFS fd fuse_reply_err(req, ENOMEM); return; } if(ud->debug) fuse_log(FUSE_LOG_DEBUG, "\t with fd %i \n", fd); GkfsDir* gkfs_dir = reinterpret_cast<GkfsDir*>(dirp); gkfs_dir->fd = fd; gkfs_dir->path = strdup(inode->path.c_str()); // strdup allocates memory if(!gkfs_dir->path) { free(dirp); gkfs::syscall::gkfs_close(fd); fuse_reply_err(req, ENOMEM); if(fd < 0) { fuse_reply_err(req, ENOTDIR); return; } fi->fh = (uint64_t) dirp; // pointer trick fi->fh = (uint64_t) fd; fuse_reply_open(req, fi); } Loading @@ -486,13 +465,8 @@ readdir_handler(fuse_req_t req, fuse_ino_t ino, size_t size, off_t off, auto* ud = udata(req); if(ud->debug) fuse_log(FUSE_LOG_DEBUG, "readdir handler \n"); auto* dir_ptr = reinterpret_cast<GkfsDir*>(fi->fh); if(!dir_ptr) { fuse_reply_err(req, EBADF); return; } auto open_dir = CTX->file_map()->get_dir(dir_ptr->fd); auto open_dir = CTX->file_map()->get_dir(fi->fh); if(ud->debug) fuse_log(FUSE_LOG_DEBUG, "read dir %s \n", open_dir->path().c_str()); Loading @@ -516,7 +490,6 @@ readdir_handler(fuse_req_t req, fuse_ino_t ino, size_t size, off_t off, auto de = open_dir->getdent(pos); struct stat st{}; // TODO cannot be right, right? no stat? st.st_ino = std::hash<std::string>()(open_dir->path() + "/" + de.name()); st.st_mode = (de.type() == gkfs::filemap::FileType::regular) ? S_IFREG Loading Loading @@ -572,15 +545,9 @@ releasedir_handler(fuse_req_t req, fuse_ino_t ino, struct fuse_file_info* fi) { auto* ud = udata(req); if(ud->debug) fuse_log(FUSE_LOG_DEBUG, "releasedir handler \n"); GkfsDir* dir_ptr = reinterpret_cast<GkfsDir*>(fi->fh); if(CTX->interception_enabled() && CTX->file_map()->exist(dir_ptr->fd)) { int fd = dir_ptr->fd; if(CTX->interception_enabled() && CTX->file_map()->exist(fi->fh)) { int ret = gkfs::syscall::gkfs_close(fd); // Close GekkoFS internal FD if(dir_ptr->path) { // Check if path was strdup'd free(dir_ptr->path); } free(dir_ptr); // Free the DIR struct itself fuse_reply_err(req, ret); return; } Loading Loading
include/client/fuse/fuse_client.hpp +0 −13 Original line number Diff line number Diff line Loading @@ -45,19 +45,6 @@ extern "C" { #define FUSE_USE_VERSION FUSE_MAKE_VERSION(3, 12) #include <fuse3/fuse_lowlevel.h> // TODO do we really need this? sizeof(DIR) statement, copied from gkfs_libc.hpp struct __dirstream { int fd; // File descriptor. //__libc_lock_define (, lock) // Mutex lock for this structure. //TODO size_t allocation; // Space allocated for the block. size_t size; // Total valid data in the block. size_t offset; // Current offset into the block. off_t filepos; // Position of next entry to read. // Directory block. char* path; char data[1] __attribute__((aligned(__alignof__(void*)))); }; // Originally its 0, but C++ does not permit it } #include <unistd.h> Loading
src/client/fuse/fuse_client.cpp +7 −40 Original line number Diff line number Diff line Loading @@ -442,41 +442,20 @@ opendir_handler(fuse_req_t req, fuse_ino_t ino, struct fuse_file_info* fi) { fuse_reply_err(req, ENOTDIR); return; } struct stat st; if(ud->debug) fuse_log(FUSE_LOG_DEBUG, "open dir %s \n", inode->path.c_str()); if(gkfs::syscall::gkfs_stat(inode->path, &st) != 0 || S_ISREG(st.st_mode)) { fuse_reply_err(req, ENOTDIR); return; } const int fd = gkfs::syscall::gkfs_opendir(inode->path); if(fd < 0) { fuse_reply_err(req, ENOTDIR); return; } // Simulate DIR structure for GekkoFS DIR* dirp = static_cast<DIR*>(malloc(sizeof(DIR) + inode->path.length() + 1)); // Approximate size for DIR and path if(dirp == nullptr) { gkfs::syscall::gkfs_close(fd); // Clean up opened GekkoFS fd fuse_reply_err(req, ENOMEM); return; } if(ud->debug) fuse_log(FUSE_LOG_DEBUG, "\t with fd %i \n", fd); GkfsDir* gkfs_dir = reinterpret_cast<GkfsDir*>(dirp); gkfs_dir->fd = fd; gkfs_dir->path = strdup(inode->path.c_str()); // strdup allocates memory if(!gkfs_dir->path) { free(dirp); gkfs::syscall::gkfs_close(fd); fuse_reply_err(req, ENOMEM); if(fd < 0) { fuse_reply_err(req, ENOTDIR); return; } fi->fh = (uint64_t) dirp; // pointer trick fi->fh = (uint64_t) fd; fuse_reply_open(req, fi); } Loading @@ -486,13 +465,8 @@ readdir_handler(fuse_req_t req, fuse_ino_t ino, size_t size, off_t off, auto* ud = udata(req); if(ud->debug) fuse_log(FUSE_LOG_DEBUG, "readdir handler \n"); auto* dir_ptr = reinterpret_cast<GkfsDir*>(fi->fh); if(!dir_ptr) { fuse_reply_err(req, EBADF); return; } auto open_dir = CTX->file_map()->get_dir(dir_ptr->fd); auto open_dir = CTX->file_map()->get_dir(fi->fh); if(ud->debug) fuse_log(FUSE_LOG_DEBUG, "read dir %s \n", open_dir->path().c_str()); Loading @@ -516,7 +490,6 @@ readdir_handler(fuse_req_t req, fuse_ino_t ino, size_t size, off_t off, auto de = open_dir->getdent(pos); struct stat st{}; // TODO cannot be right, right? no stat? st.st_ino = std::hash<std::string>()(open_dir->path() + "/" + de.name()); st.st_mode = (de.type() == gkfs::filemap::FileType::regular) ? S_IFREG Loading Loading @@ -572,15 +545,9 @@ releasedir_handler(fuse_req_t req, fuse_ino_t ino, struct fuse_file_info* fi) { auto* ud = udata(req); if(ud->debug) fuse_log(FUSE_LOG_DEBUG, "releasedir handler \n"); GkfsDir* dir_ptr = reinterpret_cast<GkfsDir*>(fi->fh); if(CTX->interception_enabled() && CTX->file_map()->exist(dir_ptr->fd)) { int fd = dir_ptr->fd; if(CTX->interception_enabled() && CTX->file_map()->exist(fi->fh)) { int ret = gkfs::syscall::gkfs_close(fd); // Close GekkoFS internal FD if(dir_ptr->path) { // Check if path was strdup'd free(dir_ptr->path); } free(dir_ptr); // Free the DIR struct itself fuse_reply_err(req, ret); return; } Loading