Commit b48dd578 authored by Marc Vef's avatar Marc Vef
Browse files

Added: adafs_ll_unlink() finalized

parent 8b807dc4
Loading
Loading
Loading
Loading
+19 −18
Original line number Diff line number Diff line
@@ -142,7 +142,6 @@ pair<int, fuse_ino_t> do_lookup(fuse_req_t& req, const fuse_ino_t p_inode, const
    //read inode from disk
    boost::archive::binary_iarchive ba(ifs);
    ba >> inode;
    ADAFS_DATA->spdlogger()->debug("do_lookup: p_inode {} name {} resolved_inode {}", p_inode, name, inode);

    return make_pair(0, inode);
}
@@ -176,27 +175,29 @@ int create_dentry(const fuse_ino_t p_inode, const fuse_ino_t inode, const string
}

/**
 * Removes a dentry from the parent directory
 * Removes a dentry from the parent directory. It is not tested if the parent inode path exists. This should have been
 * done by do_lookup preceeding this call (impicit or explicit).
 * @param p_inode
 * @param inode
 * @return
 * @param name
 * @return pair<err, inode>
 */
// XXX errorhandling
int remove_dentry(const unsigned long p_inode, const fuse_ino_t inode) {
//    auto f_path = bfs::path(ADAFS_DATA->dentry_path());
//    f_path /= to_string(p_inode);
//    if (!bfs::exists(f_path)) {
//        ADAFS_DATA->logger->error("remove_dentry() dentry_path '{}' not found", f_path.string());
//        return -ENOENT;
//    }
//
//    f_path /= inode;
//    // remove dentry here
//    bfs::remove(f_path);
//
//    // XXX make sure dentry has been deleted
pair<int, fuse_ino_t> remove_dentry(const fuse_ino_t p_inode, const string &name) {
    int inode; // file inode to be read from dentry before deletion
    auto d_path = bfs::path(ADAFS_DATA->dentry_path());
    d_path /= to_string(p_inode);
    d_path /= name;

    return 0;
    // retrieve inode number of dentry
    bfs::ifstream ifs{d_path};
    boost::archive::binary_iarchive ba(ifs);
    ba >> inode;

    bfs::remove(d_path);

    // XXX make sure dentry has been deleted

    return make_pair(0, inode);
}

/**
+1 −1
Original line number Diff line number Diff line
@@ -23,7 +23,7 @@ std::pair<int, fuse_ino_t> do_lookup(fuse_req_t& req, const fuse_ino_t p_inode,

int create_dentry(const fuse_ino_t p_inode, const fuse_ino_t inode, const std::string& name, mode_t mode);

int remove_dentry(const fuse_ino_t p_inode, const fuse_ino_t inode);
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);

+14 −18
Original line number Diff line number Diff line
@@ -90,25 +90,21 @@ void metadata_to_stat(const Metadata& md, struct stat& attr) {
}

/**
 * Returns the metadata of an object based on its hash
 * @param path
 * @return
 * Removes the metadata of a file based on the inode. The function does not check if the inode path exists. This should
 * be done by the get_metadata() (implicit or explicit)
 * @param inode
 * @return err
 */
int remove_metadata(const fuse_ino_t inode) {
    // XXX Errorhandling
//int remove_metadata(const unsigned long hash) {
//    auto i_path = bfs::path(ADAFS_DATA->inode_path);
//    i_path /= to_string(hash);
//    // XXX below could be omitted
//    if (!bfs::exists(i_path)) {
//        ADAFS_DATA->spdlogger->error("remove_metadata() metadata_path '{}' not found", i_path.string());
//        return -ENOENT;
//    }
//
//    bfs::remove_all(i_path);
//    // XXX make sure metadata has been deleted
//
//    return 0;
//}
    auto i_path = bfs::path(ADAFS_DATA->inode_path());
    i_path /= to_string(inode);

    bfs::remove_all(i_path);
    // XXX make sure metadata has been deleted

    return 0;
}

int create_node(fuse_req_t& req, struct fuse_entry_param& fep, fuse_ino_t parent, const string& name, mode_t mode) {

+1 −1
Original line number Diff line number Diff line
@@ -73,7 +73,7 @@ int get_attr(struct stat& attr, const fuse_ino_t inode);

void metadata_to_stat(const Metadata& md, struct stat& attr);

//int remove_metadata(const unsigned long hash);
int remove_metadata(const fuse_ino_t inode);

int create_node(fuse_req_t& req, struct fuse_entry_param& fep, fuse_ino_t parent, const string& name, mode_t mode);

+4 −4
Original line number Diff line number Diff line
@@ -11,7 +11,7 @@ class Dentry {

private:
    std::string name_;
    fuse_ino_t inode_;
    uint64_t inode_;
    mode_t mode_; // file type code (6 bits) + permission bits (9 bits rwx(user)rwx(group)rwx(others)

public:
@@ -19,15 +19,15 @@ public:

    Dentry(const std::string& name_);

    Dentry(const std::string& name_, fuse_ino_t inode_, mode_t mode_);
    Dentry(const std::string &name_, uint64_t inode_, mode_t mode_);

    const std::string& name() const;

    void name(const std::string& name_);

    fuse_ino_t inode() const;
    uint64_t inode() const;

    void inode(fuse_ino_t inode_);
    void inode(uint64_t inode_);

    mode_t mode() const;

Loading