void
SCOCacheMountPoint::addNamespace(const backend::Namespace& nspace)
{
    VERIFY(initialised_);

    LOG_INFO(path_ << ": adding namespace " << nspace << " to mountpoint");

    validateNamespace_throw_(nspace);

    if (hasNamespace(nspace))
    {
        // be more forgiving?
        LOG_ERROR(path_ << " namespace " << nspace << " already exists");
        throw fungi::IOException("namespace already exists",
                                 nspace.c_str(),
                                 EEXIST);
    }

    try
    {
        fs::create_directories(path_ / nspace.str());
    }
    catch(std::exception&)
    {
        LOG_ERROR("Problem adding namespace " << nspace << " to mountpoint " <<
                  getPath());
    }
}
void
SCOCacheMountPoint::removeNamespace(const backend::Namespace& nspace)
{
    VERIFY(initialised_);

    LOG_INFO(path_ << ": removing namespace " << nspace << " from mountpoint");

    if (!hasNamespace(nspace))
    {
        // be more forgiving?
        LOG_ERROR(path_ << " namespace " << nspace << " does not exist");
        throw fungi::IOException("namespace does not exist",
                                 nspace.c_str(),
                                 ENOENT);
    }

    validateNamespace_throw_(nspace);
    fs::remove_all(path_ / nspace.str());
}
void
SCOCacheMountPoint::validateNamespace_throw_(const backend::Namespace& nspace)
{
    if (!validateNamespace_(nspace))
    {
        LOG_ERROR("invalid namespace " << nspace);
        throw fungi::IOException("invalid namespace",
                                 nspace.c_str());
    }
}
bool
SCOCacheMountPoint::hasNamespace(const backend::Namespace& nspace)
{
    VERIFY(initialised_);
    return fs::exists(path_ / nspace.str());
}
// Y42: Not needed since lost+found is not a valid namespace name
bool
SCOCacheMountPoint::validateNamespace_(const backend::Namespace& nspace)
{
    return (nspace.str() != "lost+found");
}
std::shared_ptr<failovercache::Backend>
FailOverCacheTestContext::backend(const be::Namespace& nspace)
{
    return acceptor_.find_backend_(nspace.str());
}