Commit 9700cccd authored by Marc Vef's avatar Marc Vef Committed by Alberto Miranda
Browse files

daemon: checking access permissions for chunk directory during startup

parent 11f4107c
Loading
Loading
Loading
Loading
+6 −5
Original line number Diff line number Diff line
@@ -79,11 +79,12 @@ ChunkStorage::ChunkStorage(string& path, const size_t chunksize) :
    log_ = spdlog::get(LOGGER_NAME);
    assert(log_);
    assert(gkfs::path::is_absolute(root_path_));
    // Verify that we have sufficient write access
    // This will throw on error, canceling daemon initialization
    auto test_file_path = "/.__chunk_dir_test"s;
    init_chunk_space(test_file_path);
    destroy_chunk_space(test_file_path);
    // Verify that we have sufficient access for chunk directories
    if (access(root_path_.c_str(), W_OK | R_OK) != 0) {
        auto err_str = fmt::format("{}() Insufficient permissions to create chunk directories in path '{}'", __func__,
                                   root_path_);
        throw ChunkStorageException(EPERM, err_str);
    }
    log_->debug("{}() Chunk storage initialized with path: '{}'", __func__, root_path_);
}