Loading ifs/include/global/path_util.hpp +3 −0 Original line number Diff line number Diff line Loading @@ -3,11 +3,14 @@ #include <string> #define PATH_MAX_LEN 4096 // 4k chars bool is_relative_path(const std::string& path); bool is_absolute_path(const std::string& path); bool has_trailing_slash(const std::string& path); std::string path_to_relative(const std::string& root_path, const std::string& complete_path); std::string dirname(const std::string& path); std::string get_current_working_dir(); #endif //IFS_PATH_UTIL_HPP ifs/include/preload/preload_context.hpp +4 −0 Original line number Diff line number Diff line Loading @@ -44,6 +44,7 @@ class PreloadContext { std::shared_ptr<Distributor> distributor_; std::shared_ptr<FsConfig> fs_conf_; std::string cwd_; std::string mountdir_; bool initialized_; Loading @@ -62,6 +63,9 @@ class PreloadContext { void mountdir(const std::string& path); std::string mountdir() const; void cwd(const std::string& path); std::string cwd() const; bool relativize_path(std::string& path) const; const std::shared_ptr<OpenFileMap>& file_map() const; Loading ifs/src/global/path_util.cpp +18 −0 Original line number Diff line number Diff line #include <global/path_util.hpp> #include <unistd.h> #include <system_error> #include <cassert> Loading Loading @@ -69,3 +71,19 @@ std::string dirname(const std::string& path) { } return path.substr(0, parent_path_size); } std::string get_current_working_dir() { char temp[PATH_MAX_LEN]; if(getcwd(temp, PATH_MAX_LEN) == NULL) { throw std::system_error(errno, std::system_category(), "Failed to retrieve current working directory"); } // getcwd could return "(unreachable)<PATH>" in some cases if(temp[0] != '/') { throw std::runtime_error( "Current working directory is unreachable"); } return {temp}; } ifs/src/preload/preload.cpp +3 −0 Original line number Diff line number Diff line #include <global/log_util.hpp> #include <global/path_util.hpp> #include <global/global_defs.hpp> #include <global/configure.hpp> #include <preload/preload.hpp> Loading Loading @@ -305,6 +306,8 @@ void init_preload() { init_passthrough_if_needed(); init_logging(); CTX->log()->debug("Initialized logging subsystem"); CTX->cwd(get_current_working_dir()); CTX->log()->debug("Current working directory: '{}'", CTX->cwd()); if (get_daemon_pid() == -1 || CTX->mountdir().empty()) { cerr << "ADA-FS daemon not running or mountdir could not be loaded. Check adafs_preload.log" << endl; CTX->log()->error("{}() Daemon not running or mountdir not set", __func__); Loading ifs/src/preload/preload_context.cpp +8 −0 Original line number Diff line number Diff line Loading @@ -28,6 +28,14 @@ std::string PreloadContext::mountdir() const { return mountdir_; } void PreloadContext::cwd(const std::string& path) { cwd_ = path; } std::string PreloadContext::cwd() const { return cwd_; } bool PreloadContext::relativize_path(std::string& path) const { // Relativize path should be called only after the library constructor has been executed assert(initialized_); Loading Loading
ifs/include/global/path_util.hpp +3 −0 Original line number Diff line number Diff line Loading @@ -3,11 +3,14 @@ #include <string> #define PATH_MAX_LEN 4096 // 4k chars bool is_relative_path(const std::string& path); bool is_absolute_path(const std::string& path); bool has_trailing_slash(const std::string& path); std::string path_to_relative(const std::string& root_path, const std::string& complete_path); std::string dirname(const std::string& path); std::string get_current_working_dir(); #endif //IFS_PATH_UTIL_HPP
ifs/include/preload/preload_context.hpp +4 −0 Original line number Diff line number Diff line Loading @@ -44,6 +44,7 @@ class PreloadContext { std::shared_ptr<Distributor> distributor_; std::shared_ptr<FsConfig> fs_conf_; std::string cwd_; std::string mountdir_; bool initialized_; Loading @@ -62,6 +63,9 @@ class PreloadContext { void mountdir(const std::string& path); std::string mountdir() const; void cwd(const std::string& path); std::string cwd() const; bool relativize_path(std::string& path) const; const std::shared_ptr<OpenFileMap>& file_map() const; Loading
ifs/src/global/path_util.cpp +18 −0 Original line number Diff line number Diff line #include <global/path_util.hpp> #include <unistd.h> #include <system_error> #include <cassert> Loading Loading @@ -69,3 +71,19 @@ std::string dirname(const std::string& path) { } return path.substr(0, parent_path_size); } std::string get_current_working_dir() { char temp[PATH_MAX_LEN]; if(getcwd(temp, PATH_MAX_LEN) == NULL) { throw std::system_error(errno, std::system_category(), "Failed to retrieve current working directory"); } // getcwd could return "(unreachable)<PATH>" in some cases if(temp[0] != '/') { throw std::runtime_error( "Current working directory is unreachable"); } return {temp}; }
ifs/src/preload/preload.cpp +3 −0 Original line number Diff line number Diff line #include <global/log_util.hpp> #include <global/path_util.hpp> #include <global/global_defs.hpp> #include <global/configure.hpp> #include <preload/preload.hpp> Loading Loading @@ -305,6 +306,8 @@ void init_preload() { init_passthrough_if_needed(); init_logging(); CTX->log()->debug("Initialized logging subsystem"); CTX->cwd(get_current_working_dir()); CTX->log()->debug("Current working directory: '{}'", CTX->cwd()); if (get_daemon_pid() == -1 || CTX->mountdir().empty()) { cerr << "ADA-FS daemon not running or mountdir could not be loaded. Check adafs_preload.log" << endl; CTX->log()->error("{}() Daemon not running or mountdir not set", __func__); Loading
ifs/src/preload/preload_context.cpp +8 −0 Original line number Diff line number Diff line Loading @@ -28,6 +28,14 @@ std::string PreloadContext::mountdir() const { return mountdir_; } void PreloadContext::cwd(const std::string& path) { cwd_ = path; } std::string PreloadContext::cwd() const { return cwd_; } bool PreloadContext::relativize_path(std::string& path) const { // Relativize path should be called only after the library constructor has been executed assert(initialized_); Loading