Loading lfs/src/adafs_ops/dentry_ops.cpp +13 −12 Original line number Diff line number Diff line Loading @@ -27,16 +27,16 @@ bool init_dentry_dir(const fuse_ino_t inode) { /** * Destroys the dentry directory * @param inode * @return true if successfully deleted * @return 0 if successfully deleted */ bool destroy_dentry_dir(const fuse_ino_t inode) { int destroy_dentry_dir(const fuse_ino_t inode) { auto d_path = bfs::path(ADAFS_DATA->dentry_path()); d_path /= to_string(inode); // remove dentry dir bfs::remove_all(d_path); return !bfs::exists(d_path); return 0; } /** Loading Loading @@ -202,15 +202,16 @@ pair<int, fuse_ino_t> remove_dentry(const fuse_ino_t p_inode, const string &name } /** * Checks if a directory has no dentries, i.e., is empty. * Checks if a directory has no dentries, i.e., is empty. Returns zero if empty, or err code. * @param inode * @return bool * @return err */ bool is_dir_empty(const fuse_ino_t inode) { // auto d_path = bfs::path(ADAFS_DATA->dentry_path()); // // use hash function to path and append it to d_path // d_path /= to_string(ADAFS_DATA->hashf(inode.string())); // // return bfs::is_empty(d_path); return false; int is_dir_empty(const fuse_ino_t inode) { auto d_path = bfs::path(ADAFS_DATA->dentry_path()); d_path /= to_string(inode); if (bfs::is_empty(d_path)) return 0; else return ENOTEMPTY; } lfs/src/adafs_ops/dentry_ops.h +2 −2 Original line number Diff line number Diff line Loading @@ -11,7 +11,7 @@ bool init_dentry_dir(const fuse_ino_t inode); bool destroy_dentry_dir(const fuse_ino_t inode); int destroy_dentry_dir(const fuse_ino_t inode); bool verify_dentry(const fuse_ino_t inode); Loading @@ -25,6 +25,6 @@ int create_dentry(const fuse_ino_t p_inode, const fuse_ino_t inode, const std::s std::pair<int, fuse_ino_t> remove_dentry(const fuse_ino_t p_inode, const std::string &name); bool is_dir_empty(const fuse_ino_t inode); int is_dir_empty(const fuse_ino_t inode); #endif //FS_DENTRY_OPS_H lfs/src/fuse_ops/directory.cpp +40 −1 Original line number Diff line number Diff line Loading @@ -250,8 +250,47 @@ void adafs_ll_mkdir(fuse_req_t req, fuse_ino_t parent, const char* name, mode_t * @param name to remove */ void adafs_ll_rmdir(fuse_req_t req, fuse_ino_t parent, const char* name) { ADAFS_DATA->spdlogger()->debug("adafs_ll_rmdir() enter: p_inode {} name {}", parent, name); // XXX consider the whole lookup count functionality. We need something like a hashtable here, which marks the file // XXX see adafs_ll_unlink int err; fuse_ino_t inode; // get inode of file tie(err, inode) = do_lookup(req, parent, name); if (err != 0) { fuse_reply_err(req, err); return; } // check if dir is empty err = is_dir_empty(inode); if (err != 0) { fuse_reply_err(req, err); return; } // remove dentry from parent dir tie(err, inode) = remove_dentry(parent, name); if (err != 0) { fuse_reply_err(req, err); return; } // remove dentry structure of dir err = destroy_dentry_dir(inode); if (err != 0) { fuse_reply_err(req, err); return; } // remove metadata (inode) of dir err = remove_metadata(inode); if (err != 0) { fuse_reply_err(req, err); return; } // TODO fuse_reply_err(req, 0); } Loading Loading
lfs/src/adafs_ops/dentry_ops.cpp +13 −12 Original line number Diff line number Diff line Loading @@ -27,16 +27,16 @@ bool init_dentry_dir(const fuse_ino_t inode) { /** * Destroys the dentry directory * @param inode * @return true if successfully deleted * @return 0 if successfully deleted */ bool destroy_dentry_dir(const fuse_ino_t inode) { int destroy_dentry_dir(const fuse_ino_t inode) { auto d_path = bfs::path(ADAFS_DATA->dentry_path()); d_path /= to_string(inode); // remove dentry dir bfs::remove_all(d_path); return !bfs::exists(d_path); return 0; } /** Loading Loading @@ -202,15 +202,16 @@ pair<int, fuse_ino_t> remove_dentry(const fuse_ino_t p_inode, const string &name } /** * Checks if a directory has no dentries, i.e., is empty. * Checks if a directory has no dentries, i.e., is empty. Returns zero if empty, or err code. * @param inode * @return bool * @return err */ bool is_dir_empty(const fuse_ino_t inode) { // auto d_path = bfs::path(ADAFS_DATA->dentry_path()); // // use hash function to path and append it to d_path // d_path /= to_string(ADAFS_DATA->hashf(inode.string())); // // return bfs::is_empty(d_path); return false; int is_dir_empty(const fuse_ino_t inode) { auto d_path = bfs::path(ADAFS_DATA->dentry_path()); d_path /= to_string(inode); if (bfs::is_empty(d_path)) return 0; else return ENOTEMPTY; }
lfs/src/adafs_ops/dentry_ops.h +2 −2 Original line number Diff line number Diff line Loading @@ -11,7 +11,7 @@ bool init_dentry_dir(const fuse_ino_t inode); bool destroy_dentry_dir(const fuse_ino_t inode); int destroy_dentry_dir(const fuse_ino_t inode); bool verify_dentry(const fuse_ino_t inode); Loading @@ -25,6 +25,6 @@ int create_dentry(const fuse_ino_t p_inode, const fuse_ino_t inode, const std::s std::pair<int, fuse_ino_t> remove_dentry(const fuse_ino_t p_inode, const std::string &name); bool is_dir_empty(const fuse_ino_t inode); int is_dir_empty(const fuse_ino_t inode); #endif //FS_DENTRY_OPS_H
lfs/src/fuse_ops/directory.cpp +40 −1 Original line number Diff line number Diff line Loading @@ -250,8 +250,47 @@ void adafs_ll_mkdir(fuse_req_t req, fuse_ino_t parent, const char* name, mode_t * @param name to remove */ void adafs_ll_rmdir(fuse_req_t req, fuse_ino_t parent, const char* name) { ADAFS_DATA->spdlogger()->debug("adafs_ll_rmdir() enter: p_inode {} name {}", parent, name); // XXX consider the whole lookup count functionality. We need something like a hashtable here, which marks the file // XXX see adafs_ll_unlink int err; fuse_ino_t inode; // get inode of file tie(err, inode) = do_lookup(req, parent, name); if (err != 0) { fuse_reply_err(req, err); return; } // check if dir is empty err = is_dir_empty(inode); if (err != 0) { fuse_reply_err(req, err); return; } // remove dentry from parent dir tie(err, inode) = remove_dentry(parent, name); if (err != 0) { fuse_reply_err(req, err); return; } // remove dentry structure of dir err = destroy_dentry_dir(inode); if (err != 0) { fuse_reply_err(req, err); return; } // remove metadata (inode) of dir err = remove_metadata(inode); if (err != 0) { fuse_reply_err(req, err); return; } // TODO fuse_reply_err(req, 0); } Loading