diff --git a/src/bees-context.cc b/src/bees-context.cc index 932c01a..10783ca 100644 --- a/src/bees-context.cc +++ b/src/bees-context.cc @@ -229,12 +229,23 @@ BeesContext::show_progress() } } +Fd +BeesContext::home_fd() +{ + const char *base_dir = getenv("BEESHOME"); + if (!base_dir) { + base_dir = ".beeshome"; + } + m_home_fd = openat(root_fd(), base_dir, FLAGS_OPEN_DIR); + if (!m_home_fd) { + THROW_ERRNO("openat: " << name_fd(root_fd()) << " / " << base_dir); + } + return m_home_fd; +} + BeesContext::BeesContext(shared_ptr parent) : m_parent_ctx(parent) { - auto base_dir = getenv_or_die("BEESHOME"); - BEESLOG("BEESHOME = " << base_dir); - m_home_fd = open_or_die(base_dir, FLAGS_OPEN_DIR); if (m_parent_ctx) { m_hash_table = m_parent_ctx->hash_table(); m_hash_table->set_shared(true); diff --git a/src/bees.h b/src/bees.h index 154b695..82cbdae 100644 --- a/src/bees.h +++ b/src/bees.h @@ -719,7 +719,7 @@ public: void set_root_path(string path); Fd root_fd() const { return m_root_fd; } - Fd home_fd() const { return m_home_fd; } + Fd home_fd(); string root_path() const { return m_root_path; } string root_uuid() const { return m_root_uuid; }