Verified Commit 3d3dd0ff authored by Tunahan Kaya's avatar Tunahan Kaya Committed by Marc Vef
Browse files

Mountdir existence is no longer required for clients

Previously, an empty mountdir directory must have existed for no reason. As a result, the daemon created and removed this empty directory. This has been removed
parent fbead267
Loading
Loading
Loading
Loading
+6 −2
Original line number Diff line number Diff line
@@ -185,8 +185,12 @@ resolve(const string& path, string& resolved, bool resolve_last_link) {
        resolved.push_back(path::separator);
        last_slash_pos = resolved.size() - 1;
        resolved.append(path, start, comp_size);

        if(matched_components < mnt_components.size()) {
        /*
         * This will be true for all path components outside of GKFS and up to
         * the mountdir's parent path The mountdir directory is considered to be
         * inside GKFS as it is entirely virtual and does not need to exist
         */
        if(matched_components < mnt_components.size() - 1) {
            // Outside GekkoFS
            if(matched_components == resolved_components &&
               path.compare(start, comp_size,
+16 −8
Original line number Diff line number Diff line
@@ -388,9 +388,6 @@ agios_initialize() {
 */
void
destroy_enviroment() {
    GKFS_DATA->spdlogger()->debug("{}() Removing mount directory", __func__);
    std::error_code ecode;
    fs::remove_all(GKFS_DATA->mountdir(), ecode);
    GKFS_DATA->spdlogger()->debug("{}() Freeing I/O executions streams",
                                  __func__);
    for(unsigned int i = 0; i < RPC_DATA->io_streams().size(); i++) {
@@ -552,11 +549,22 @@ parse_input(const po::variables_map& vm) {
    GKFS_DATA->hosts_file(hosts_file);

    assert(vm.count("mountdir"));
    auto mountdir = vm["mountdir"].as<string>();
    // Create mountdir. We use this dir to get some information on the
    // underlying fs with statfs in gkfs_statfs
    fs::create_directories(mountdir);
    GKFS_DATA->mountdir(fs::canonical(mountdir).native());
    // Store mountdir and ensure parent dir exists as it is required for path
    // resolution on the client
    try {
        fs::path mountdir(vm["mountdir"].as<string>());
        auto mountdir_parent = fs::canonical(mountdir.parent_path());
        GKFS_DATA->mountdir(fmt::format("{}/{}", mountdir_parent.native(),
                                        mountdir.filename().native()));
        GKFS_DATA->spdlogger()->info("{}() Mountdir '{}'", __func__,
                                     GKFS_DATA->mountdir());
    } catch(const std::exception& e) {
        auto emsg = fmt::format(
                "Parent directory for given mountdir does not exist. err '{}' Exiting ...",
                e.what());
        cerr << emsg << endl;
        exit(EXIT_FAILURE);
    }

    assert(vm.count("rootdir"));
    auto rootdir = vm["rootdir"].as<string>();