Loading ifs/include/global/path_util.hpp +1 −0 Original line number Diff line number Diff line Loading @@ -8,5 +8,6 @@ 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); #endif //IFS_PATH_UTIL_HPP ifs/src/global/path_util.cpp +13 −0 Original line number Diff line number Diff line Loading @@ -56,3 +56,16 @@ std::string path_to_relative(const std::string& root_path, const std::string& ab return {rel_it_begin, rel_it_end}; } std::string dirname(const std::string& path) { assert(path.size() > 1 || path.front() == PSP); assert(path.size() == 1 || !has_trailing_slash(path)); auto parent_path_size = path.find_last_of(PSP); assert(parent_path_size != std::string::npos); if(parent_path_size == 0) { // parent is '/' parent_path_size = 1; } return path.substr(0, parent_path_size); } ifs/src/preload/adafs_functions.cpp +14 −0 Original line number Diff line number Diff line #include <sys/statfs.h> #include <global/configure.hpp> #include <global/path_util.hpp> #include <preload/preload.hpp> #include <preload/adafs_functions.hpp> #include <preload/rpc/ld_rpc_metadentry.hpp> Loading Loading @@ -78,6 +79,19 @@ int adafs_mk_node(const std::string& path, const mode_t mode) { //file type must be either regular file or directory assert(S_ISREG(mode) || S_ISDIR(mode)); struct stat st; auto p_comp = dirname(path); auto ret = adafs_stat(p_comp, &st); if(ret != 0) { CTX->log()->debug("{}() parent component does not exists: '{}'", __func__, p_comp); errno = ENOENT; return -1; } if(!S_ISDIR(st.st_mode)) { CTX->log()->debug("{}() parent component is not a direcotory: '{}'", __func__, p_comp); errno = ENOTDIR; return -1; } return rpc_send_mk_node(path, mode); } Loading Loading
ifs/include/global/path_util.hpp +1 −0 Original line number Diff line number Diff line Loading @@ -8,5 +8,6 @@ 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); #endif //IFS_PATH_UTIL_HPP
ifs/src/global/path_util.cpp +13 −0 Original line number Diff line number Diff line Loading @@ -56,3 +56,16 @@ std::string path_to_relative(const std::string& root_path, const std::string& ab return {rel_it_begin, rel_it_end}; } std::string dirname(const std::string& path) { assert(path.size() > 1 || path.front() == PSP); assert(path.size() == 1 || !has_trailing_slash(path)); auto parent_path_size = path.find_last_of(PSP); assert(parent_path_size != std::string::npos); if(parent_path_size == 0) { // parent is '/' parent_path_size = 1; } return path.substr(0, parent_path_size); }
ifs/src/preload/adafs_functions.cpp +14 −0 Original line number Diff line number Diff line #include <sys/statfs.h> #include <global/configure.hpp> #include <global/path_util.hpp> #include <preload/preload.hpp> #include <preload/adafs_functions.hpp> #include <preload/rpc/ld_rpc_metadentry.hpp> Loading Loading @@ -78,6 +79,19 @@ int adafs_mk_node(const std::string& path, const mode_t mode) { //file type must be either regular file or directory assert(S_ISREG(mode) || S_ISDIR(mode)); struct stat st; auto p_comp = dirname(path); auto ret = adafs_stat(p_comp, &st); if(ret != 0) { CTX->log()->debug("{}() parent component does not exists: '{}'", __func__, p_comp); errno = ENOENT; return -1; } if(!S_ISDIR(st.st_mode)) { CTX->log()->debug("{}() parent component is not a direcotory: '{}'", __func__, p_comp); errno = ENOTDIR; return -1; } return rpc_send_mk_node(path, mode); } Loading