Verified Commit 8c48919c authored by Tommaso Tocci's avatar Tommaso Tocci
Browse files

daemon: create_metadentry accepts Metadata object

Instead of passing only the mode as paramenter, we now pass an entire
Metadata object in such a way that the parameter can be configured at
compile time. For instace if we support symlinks we would like also to
pass the target path
parent bdded127
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -8,7 +8,7 @@

int create_node(const std::string& path, const uid_t uid, const gid_t gid, mode_t mode);

void create_metadentry(const std::string& path, mode_t mode);
void create_metadentry(const std::string& path, Metadata& md);

std::string get_metadentry_str(const std::string& path);

+2 −1
Original line number Diff line number Diff line
@@ -82,8 +82,9 @@ bool init_environment() {
    ADAFS_DATA->link_cnt_state(MDATA_USE_LINK_CNT);
    ADAFS_DATA->blocks_state(MDATA_USE_BLOCKS);
    // Create metadentry for root directory
    Metadata root_md = {S_IFDIR | 0777};
    try {
        create_metadentry("/", S_IFDIR | 777);
        create_metadentry("/", root_md);
    } catch (const std::exception& e ) {
        ADAFS_DATA->spdlogger()->error("{}() Unable to write root metadentry to KV store: {}", __func__, e.what());
        return false;
+1 −2
Original line number Diff line number Diff line
@@ -10,9 +10,8 @@ using namespace std;
 * @param path
 * @param mode
 */
void create_metadentry(const std::string& path, mode_t mode) {
void create_metadentry(const std::string& path, Metadata& md) {

    Metadata md{mode};
    // update metadata object based on what metadata is needed
    if (ADAFS_DATA->atime_state() || ADAFS_DATA->mtime_state() || ADAFS_DATA->ctime_state()) {
        std::time_t time;
+2 −1
Original line number Diff line number Diff line
@@ -43,9 +43,10 @@ static hg_return_t rpc_srv_mk_node(hg_handle_t handle) {
    assert(ret == HG_SUCCESS);
    ADAFS_DATA->spdlogger()->debug("{}() Got RPC (from local {}) with path {}", __func__,
                                   (margo_get_info(handle)->context_id == ADAFS_DATA->host_id()), in.path);
    Metadata md = {in.mode};
    try {
        // create metadentry
        create_metadentry(in.path, in.mode);
        create_metadentry(in.path, md);
        out.err = 0;
    } catch (const std::exception& e) {
        ADAFS_DATA->spdlogger()->error("{}() Failed to create metadentry: {}",  __func__, e.what());