Verified Commit ce8e9f8c authored by Marc Vef's avatar Marc Vef
Browse files

Removed util.cpp remnant. Renamed iointer lib to adafs_preload_client

parent 138e04ca
Loading
Loading
Loading
Loading
+0 −1
Original line number Diff line number Diff line
@@ -121,7 +121,6 @@ add_subdirectory(src/preload)

set(DAEMON_SRC
    main.cpp
    util.cpp
    src/daemon/adafs_daemon.cpp
    src/daemon/db/db_util.cpp
    src/daemon/db/db_ops.cpp
+3 −3
Original line number Diff line number Diff line
@@ -26,9 +26,9 @@ set(PRELOAD_HEADERS
    ../../include/preload/rpc/ld_rpc_metadentry.hpp
    )

add_library(iointer SHARED ${PRELOAD_SRC} ${PRELOAD_HEADERS})
add_library(adafs_preload_client SHARED ${PRELOAD_SRC} ${PRELOAD_HEADERS})

target_link_libraries(iointer
target_link_libraries(adafs_preload_client
    dl
    ${ABT_LIBRARIES}
    ${ABT_SNOOZER_LIBRARIES}
@@ -38,4 +38,4 @@ target_link_libraries(iointer
    ${MARGO_LIBRARIES}
)

set_target_properties(iointer PROPERTIES LINK_FLAGS "-lpthread -lboost_system")
set_target_properties(adafs_preload_client PROPERTIES LINK_FLAGS "-lpthread -lboost_system")

ifs/util.cpp

deleted100644 → 0
+0 −63
Original line number Diff line number Diff line

#include <boost/archive/binary_iarchive.hpp>
#include <boost/archive/binary_oarchive.hpp>
#include "main.hpp"

using namespace std;

namespace Util {

    int init_inode_no() {
        auto n_hosts = ADAFS_DATA->hosts().size();
        // We are working locally. Start with inode 1
        if (n_hosts == 0) {
            ADAFS_DATA->inode_count(1);
            return 0;
        }
        // hostname was found in given hostlist TODO doublecheck calculation
        auto inode_max_chunk = std::numeric_limits<ino_t>::max();
        auto first_inode = static_cast<ino_t>(((inode_max_chunk / n_hosts) * ADAFS_DATA->host_id()) + 1);
        ADAFS_DATA->inode_count(first_inode);
        return 0;
    }

    ino_t generate_inode_no() {
        std::lock_guard<std::mutex> inode_lock(ADAFS_DATA->inode_mutex);
        // TODO check that our inode counter is within boundaries of inode numbers in the given node
        return ADAFS_DATA->raise_inode_count(1);
    }

    // XXX error handling
    int read_inode_cnt() {
        auto i_path = bfs::path(ADAFS_DATA->mgmt_path() + "/inode_count");
        bfs::ifstream ifs{i_path};
        boost::archive::binary_iarchive ba(ifs);
        ino_t inode_count;
        ba >> inode_count;
        ADAFS_DATA->inode_count(inode_count);

        return 0;
    }

    // XXX error handling
    int write_inode_cnt() {
        auto i_path = bfs::path(ADAFS_DATA->mgmt_path() + "/inode_count");
        bfs::ofstream ofs{i_path};
        boost::archive::binary_oarchive ba(ofs);
        auto inode = ADAFS_DATA->inode_count();
        ba << inode;

        return 0;
    }

    /**
     * Returns the machine's hostname
     * @return
     */
    string get_my_hostname() {
        char hostname[1024];
        auto ret = gethostname(hostname, 1024);
        return ret == 0 ? string(hostname) : ""s;
    }

}
 No newline at end of file