Commit 1d779e91 authored by Marc Vef's avatar Marc Vef
Browse files

Refact: do_lookup returns pair now. Making errorcodes consistent.

parent 15e6df40
Loading
Loading
Loading
Loading
+4 −4
Original line number Diff line number Diff line
@@ -124,9 +124,9 @@ int get_dentries(vector<Dentry>& dentries, const uint64_t dir_inode) {
 * @param req
 * @param parent_inode
 * @param name
 * @return inode
 * @return pair<err, inode>
 */
uint64_t do_lookup(fuse_req_t& req, const uint64_t p_inode, const string& name) {
pair<int, uint64_t> do_lookup(fuse_req_t& req, const uint64_t p_inode, const string& name) {

    uint64_t inode;
    // XXX error handling
@@ -136,7 +136,7 @@ uint64_t do_lookup(fuse_req_t& req, const uint64_t p_inode, const string& name)
    // XXX check if this is needed later
    d_path /= name;
    if (!bfs::exists(d_path))
        return static_cast<uint64_t>(-ENOENT);
        return make_pair(ENOENT, INVALID_INODE);

    bfs::ifstream ifs{d_path};
    //read inode from disk
@@ -144,7 +144,7 @@ uint64_t do_lookup(fuse_req_t& req, const uint64_t p_inode, const string& name)
    ba >> inode;
    ADAFS_DATA->spdlogger()->debug("do_lookup: p_inode {} name {} resolved_inode {}", p_inode, name, inode);

    return inode;
    return make_pair(0, inode);
}


+1 −1
Original line number Diff line number Diff line
@@ -19,7 +19,7 @@ int read_dentries(const uint64_t p_inode, const unsigned long inode);

int get_dentries(std::vector<Dentry>& dentries, const uint64_t dir_inode);

uint64_t do_lookup(fuse_req_t& req, const uint64_t p_inode, const std::string& name);
std::pair<int, uint64_t> do_lookup(fuse_req_t& req, const uint64_t p_inode, const std::string& name);

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

+1 −1
Original line number Diff line number Diff line
@@ -53,7 +53,7 @@ int get_metadata(Metadata& md, const uint64_t inode) {
        read_all_metadata(md, inode);
        return 0;
    } else
        return -ENOENT;
        return ENOENT;
}

/**
+6 −4
Original line number Diff line number Diff line
@@ -10,6 +10,7 @@

#include "../classes/dentry.h"


using namespace std;

/**
@@ -28,10 +29,11 @@ void adafs_ll_lookup(fuse_req_t req, fuse_ino_t parent, const char* name) {


    //get inode no first (either from cache or disk) with parent inode and name
    auto inode = do_lookup(req, parent, string(name));
    // XXX I DON'T like how this is handled with static_cast. like double negation and large int usage for int ERRcodes
    if (static_cast<int>(inode) < 1) {
        fuse_reply_err(req, static_cast<int>(-inode));
    auto lookup_pair = do_lookup(req, parent, string(name));
    auto err = lookup_pair.first;
    auto inode = lookup_pair.second;
    if (err != 0) {
        fuse_reply_err(req, err);
        return;
    }

+1 −1
Original line number Diff line number Diff line
@@ -53,7 +53,7 @@ void adafs_ll_init(void* pdata, struct fuse_conn_info* conn) {
    auto md = make_shared<Metadata>();

    // Check that root metadata exists. If not initialize it
    if (get_metadata(*md, ADAFS_ROOT_INODE) == -ENOENT) {
    if (get_metadata(*md, ADAFS_ROOT_INODE) == ENOENT) {
        ADAFS_DATA->spdlogger()->debug("Root metadata not found. Initializing..."s);
        md->init_ACM_time();
        md->mode(S_IFDIR | S_IRWXU | S_IRWXG | S_IRWXO); // change_access 777
Loading