Loading src/client/fuse/fuse_client.cpp +37 −2 Original line number Diff line number Diff line Loading @@ -50,6 +50,7 @@ alloc_inode(const std::string& path) { std::lock_guard<std::mutex> lk(ino_mutex); fuse_ino_t ino = next_ino++; ino_map[ino] = {path, {}, 1}; path_map[path] = ino; return ino; } Loading Loading @@ -146,7 +147,6 @@ lookup_handler(fuse_req_t req, fuse_ino_t parent, const char* name) { ino_map[ino].lookup_count++; } else { ino = alloc_inode(child); path_map[child] = ino; } struct stat st; Loading Loading @@ -498,6 +498,41 @@ flush_handler(fuse_req_t req, fuse_ino_t ino, struct fuse_file_info* fi) { fuse_reply_err(req, 0); } static void mkdir_handler(fuse_req_t req, fuse_ino_t parent, const char* name, mode_t mode) { auto* ud = udata(req); auto* parent_inode = get_inode(parent); if(!parent_inode) { fuse_reply_err(req, ENOENT); return; } std::string path = parent_inode->path + name; int rc = gkfs::syscall::gkfs_create(path, mode | S_IFDIR); if(rc == -1) { fuse_reply_err(req, 1); return; } struct stat st; int sc = gkfs::syscall::gkfs_stat(path, &st); if(sc == -1) { fuse_log(FUSE_LOG_DEBUG, "thats why its not allowed \n"); fuse_reply_err(req, 1); return; } fuse_ino_t ino = alloc_inode(path); fuse_log(FUSE_LOG_DEBUG, "create new inode ino %i\n", ino); ino_map[ino].st = st; fuse_entry_param e = {}; e.ino = ino; e.attr = st; e.attr_timeout = ud->timeout; e.entry_timeout = ud->timeout; fuse_reply_entry(req, &e); fuse_log(FUSE_LOG_DEBUG, "flush success \n"); fuse_reply_err(req, 0); } static void init_gekkofs() { // TODO how to handle mount point Loading Loading @@ -553,7 +588,7 @@ init_ll_ops(fuse_lowlevel_ops* ops) { // directory ops->lookup = lookup_handler; // ops->mkdir ops->mkdir = mkdir_handler; // ops->rmdir ops->readdir = readdir_handler; ops->opendir = opendir_handler; Loading tests/integration/fuse/test_basic_operations.py +3 −0 Original line number Diff line number Diff line Loading @@ -45,6 +45,8 @@ def test_read(gkfs_daemon, fuse_client): file = gkfs_daemon.mountdir / "file" file2 = gkfs_daemon.mountdir / "file2" dir = gkfs_daemon.mountdir / "dir" sh.bash("-c", "echo baum > " + str(file)) assert sh.ls(fuse_client.mountdir) == "file\n" assert sh.cat(file) == "baum\n" Loading @@ -52,3 +54,4 @@ def test_read(gkfs_daemon, fuse_client): assert sh.wc("-c", str(file2)) == "0 " + str(file2) + "\n" sh.truncate("-s", "20", str(file2)) assert sh.wc("-c", str(file2)) == "20 " + str(file2) + "\n" sh.mkdir(str(dir)) Loading
src/client/fuse/fuse_client.cpp +37 −2 Original line number Diff line number Diff line Loading @@ -50,6 +50,7 @@ alloc_inode(const std::string& path) { std::lock_guard<std::mutex> lk(ino_mutex); fuse_ino_t ino = next_ino++; ino_map[ino] = {path, {}, 1}; path_map[path] = ino; return ino; } Loading Loading @@ -146,7 +147,6 @@ lookup_handler(fuse_req_t req, fuse_ino_t parent, const char* name) { ino_map[ino].lookup_count++; } else { ino = alloc_inode(child); path_map[child] = ino; } struct stat st; Loading Loading @@ -498,6 +498,41 @@ flush_handler(fuse_req_t req, fuse_ino_t ino, struct fuse_file_info* fi) { fuse_reply_err(req, 0); } static void mkdir_handler(fuse_req_t req, fuse_ino_t parent, const char* name, mode_t mode) { auto* ud = udata(req); auto* parent_inode = get_inode(parent); if(!parent_inode) { fuse_reply_err(req, ENOENT); return; } std::string path = parent_inode->path + name; int rc = gkfs::syscall::gkfs_create(path, mode | S_IFDIR); if(rc == -1) { fuse_reply_err(req, 1); return; } struct stat st; int sc = gkfs::syscall::gkfs_stat(path, &st); if(sc == -1) { fuse_log(FUSE_LOG_DEBUG, "thats why its not allowed \n"); fuse_reply_err(req, 1); return; } fuse_ino_t ino = alloc_inode(path); fuse_log(FUSE_LOG_DEBUG, "create new inode ino %i\n", ino); ino_map[ino].st = st; fuse_entry_param e = {}; e.ino = ino; e.attr = st; e.attr_timeout = ud->timeout; e.entry_timeout = ud->timeout; fuse_reply_entry(req, &e); fuse_log(FUSE_LOG_DEBUG, "flush success \n"); fuse_reply_err(req, 0); } static void init_gekkofs() { // TODO how to handle mount point Loading Loading @@ -553,7 +588,7 @@ init_ll_ops(fuse_lowlevel_ops* ops) { // directory ops->lookup = lookup_handler; // ops->mkdir ops->mkdir = mkdir_handler; // ops->rmdir ops->readdir = readdir_handler; ops->opendir = opendir_handler; Loading
tests/integration/fuse/test_basic_operations.py +3 −0 Original line number Diff line number Diff line Loading @@ -45,6 +45,8 @@ def test_read(gkfs_daemon, fuse_client): file = gkfs_daemon.mountdir / "file" file2 = gkfs_daemon.mountdir / "file2" dir = gkfs_daemon.mountdir / "dir" sh.bash("-c", "echo baum > " + str(file)) assert sh.ls(fuse_client.mountdir) == "file\n" assert sh.cat(file) == "baum\n" Loading @@ -52,3 +54,4 @@ def test_read(gkfs_daemon, fuse_client): assert sh.wc("-c", str(file2)) == "0 " + str(file2) + "\n" sh.truncate("-s", "20", str(file2)) assert sh.wc("-c", str(file2)) == "20 " + str(file2) + "\n" sh.mkdir(str(dir))