diff --git a/.gitignore b/.gitignore index 6fb38b1ce569f0a0da170bab187b4858ca258fe2..a846ad14829e07c0baada638c54dca62e342bbca 100644 --- a/.gitignore +++ b/.gitignore @@ -66,6 +66,10 @@ *.idea/ .run/ +# clangd +.clangd +.cache + # OS generated files .DS_Store .DS_Store? diff --git a/CHANGELOG.md b/CHANGELOG.md index f360b69b91ab61433facc33aaad5bc321d549b8b..2e945f6bf6a6972769ec5f984ecef778c272d74f 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -302,7 +302,7 @@ to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). - Paths inside kernel pseudo filesystems (`/sys`, `/proc`) are forwarded directly to the kernel and internal path resolution will be skipped. Be aware that also paths like `/sys/../tmp/gkfs_mountpoint/asd` will be forwarded to the kernel -- Added new Cmake flag `CREATE_CHECK_PARENTS` to controls if the existance of the parent node needs to be checked during +- Added new Cmake flag `GKFS_CREATE_CHECK_PARENTS` to controls if the existance of the parent node needs to be checked during the creation of a child node. ### Changed diff --git a/CMake/gkfs-options.cmake b/CMake/gkfs-options.cmake index 598de903ca9a82d9dd4496a2bd96a704792fe2ad..3355375191f5ddc2f4dab960f85ffc7ecb54e3ea 100644 --- a/CMake/gkfs-options.cmake +++ b/CMake/gkfs-options.cmake @@ -235,16 +235,14 @@ cmake_dependent_option(GKFS_INSTALL_TESTS "Install GekkoFS self tests" OFF "GKFS ################################################################################ ## check before create -# FIXME: should be prefixed with GKFS_ gkfs_define_option( - CREATE_CHECK_PARENTS + GKFS_CREATE_CHECK_PARENTS HELP_TEXT "Enable checking parent directory for existence before creating children" DEFAULT_VALUE ON DESCRIPTION "Verify that a parent directory exists before creating new files or directories" ) ## symbolic link support -# FIXME: should be prefixed with GKFS_ gkfs_define_option( GKFS_SYMLINK_SUPPORT HELP_TEXT "Enable support for symlinks" @@ -266,13 +264,11 @@ gkfs_define_option( ################################################################################ ## Maximum number of internal file descriptors reserved for GekkoFS -# FIXME: should be prefixed with GKFS_ -gkfs_define_variable(MAX_INTERNAL_FDS 256 +gkfs_define_variable(GKFS_MAX_INTERNAL_FDS 256 STRING "Number of file descriptors reserved for internal use" ADVANCED ) ## Maximum number of open file descriptors for GekkoFS -# FIXME: should be prefixed with GKFS_ execute_process(COMMAND getconf OPEN_MAX OUTPUT_VARIABLE _GETCONF_MAX_FDS OUTPUT_STRIP_TRAILING_WHITESPACE @@ -282,7 +278,7 @@ if (NOT _GETCONF_MAX_FDS) endif () gkfs_define_variable( - MAX_OPEN_FDS + GKFS_MAX_OPEN_FDS ${_GETCONF_MAX_FDS} STRING "Maximum number of open file descriptors supported" @@ -326,15 +322,13 @@ gkfs_define_option( ################################################################################ ## Client logging support -# FIXME: should be prefixed with GKFS_ gkfs_define_option( - ENABLE_CLIENT_LOG HELP_TEXT "Enable logging messages in clients" + GKFS_ENABLE_CLIENT_LOG HELP_TEXT "Enable logging messages in clients" DEFAULT_VALUE ON ) -# FIXME: should be prefixed with GKFS_ gkfs_define_variable( - CLIENT_LOG_MESSAGE_SIZE + GKFS_CLIENT_LOG_MESSAGE_SIZE 1024 STRING "Maximum size of a log message in the client library" diff --git a/CMakeLists.txt b/CMakeLists.txt index 71e7c842f6c73bc814feaff9203b6c97048f8058..38d7f6992225f8510014517cae76591668a80ce6 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -121,7 +121,7 @@ include(gkfs-utils) ################################################################################ include(gkfs-options) -set(CMAKE_EXPORT_COMPILE_COMMANDS 0) +set(CMAKE_EXPORT_COMPILE_COMMANDS 1) # ############################################################################## @@ -266,17 +266,17 @@ if (GKFS_RENAME_SUPPORT) add_definitions(-DHAS_RENAME) endif () -if(MAX_INTERNAL_FDS) - add_definitions(-DMAX_INTERNAL_FDS=${MAX_INTERNAL_FDS}) +if(GKFS_MAX_INTERNAL_FDS) + add_definitions(-DGKFS_MAX_INTERNAL_FDS=${GKFS_MAX_INTERNAL_FDS}) endif() -if(MAX_OPEN_FDS) - add_definitions(-DMAX_OPEN_FDS=${MAX_OPEN_FDS}) +if(GKFS_MAX_OPEN_FDS) + add_definitions(-DGKFS_MAX_OPEN_FDS=${GKFS_MAX_OPEN_FDS}) endif() -if(ENABLE_CLIENT_LOG) +if(GKFS_ENABLE_CLIENT_LOG) add_definitions(-DGKFS_ENABLE_LOGGING) - add_definitions(-DLIBGKFS_LOG_MESSAGE_SIZE=${CLIENT_LOG_MESSAGE_SIZE}) + add_definitions(-DLIBGKFS_LOG_MESSAGE_SIZE=${GKFS_CLIENT_LOG_MESSAGE_SIZE}) endif () if(GKFS_ENABLE_UNUSED_FUNCTIONS) @@ -289,7 +289,7 @@ endif () configure_file(include/common/cmake_configure.hpp.in include/common/cmake_configure.hpp) -if(ENABLE_CLIENT_LOG) +if(GKFS_ENABLE_CLIENT_LOG) option(HERMES_LOGGING "" ON) option(HERMES_LOGGING_FMT_USE_BUNDLED "" OFF) option(HERMES_LOGGING_FMT_HEADER_ONLY "" OFF) diff --git a/CMakePresets.json b/CMakePresets.json index 88fc9ce80df87c14a5217b3334b7e30e1dd8bfcb..9f12e9c734ceabc71595221f384db23c67ff7bf9 100644 --- a/CMakePresets.json +++ b/CMakePresets.json @@ -18,8 +18,8 @@ "GKFS_ENABLE_PARALLAX": false, "GKFS_BUILD_TESTS": false, "GKFS_INSTALL_TESTS": false, - "ENABLE_CLIENT_LOG": true, - "CLIENT_LOG_MESSAGE_SIZE": "1024", + "GKFS_ENABLE_CLIENT_LOG": true, + "GKFS_CLIENT_LOG_MESSAGE_SIZE": "1024", "GKFS_SYMLINK_SUPPORT": false }, "warnings": { @@ -85,8 +85,8 @@ "GKFS_CHUNK_STATS": true, "GKFS_ENABLE_PROMETHEUS": true, "GKFS_RENAME_SUPPORT": true, - "MAX_OPEN_FDS": "10000", - "MAX_INTERNAL_FDS": "1024" + "GKFS_MAX_OPEN_FDS": "10000", + "GKFS_MAX_INTERNAL_FDS": "1024" } }, { diff --git a/docs/sphinx/devs/coverage.md b/docs/sphinx/devs/coverage.md index 7bd9932a7b8569c8ae2077f00675322ca7e08cd9..29070570dc9e63c8be825b9bd18acd10ca422527 100644 --- a/docs/sphinx/devs/coverage.md +++ b/docs/sphinx/devs/coverage.md @@ -49,7 +49,6 @@ that greatly simplify this process. Thus, GekkoFS provides a CMake $ cmake --preset=default-coverage Preset CMake variables: - CLIENT_LOG_MESSAGE_SIZE="512" CMAKE_BUILD_TYPE="Coverage" CMAKE_CXX_COMPILER="/usr/bin/g++" CMAKE_CXX_FLAGS="-Wall -Wextra -fdiagnostics-color=always --pedantic -Wno-unused-parameter -Wno-missing-field-initializers -DGKFS_DEBUG_BUILD -DHERMES_DEBUG_BUILD" @@ -59,7 +58,8 @@ Preset CMake variables: CMAKE_EXE_LINKER_FLAGS_COVERAGE="--coverage" CMAKE_MAP_IMPORTED_CONFIG_COVERAGE="Coverage;RelWithDebInfo;Release;Debug;" CMAKE_SHARED_LINKER_FLAGS_COVERAGE="--coverage" - ENABLE_CLIENT_LOG:BOOL="TRUE" + GKFS_CLIENT_LOG_MESSAGE_SIZE="512" + GKFS_ENABLE_CLIENT_LOG:BOOL="TRUE" GKFS_BUILD_DOCUMENTATION:BOOL="TRUE" GKFS_BUILD_TESTS:BOOL="TRUE" GKFS_CHUNK_STATS:BOOL="TRUE" diff --git a/include/client/preload_context.hpp b/include/client/preload_context.hpp index 26875435b3f1546b9dd455160d845811ade38166..4be2eeeb0e156fba42d0105dd09ac9913355e8eb 100644 --- a/include/client/preload_context.hpp +++ b/include/client/preload_context.hpp @@ -77,7 +77,8 @@ enum class RelativizeStatus { internal, external, fd_unknown, fd_not_a_dir }; */ class PreloadContext { - static auto constexpr MIN_INTERNAL_FD = MAX_OPEN_FDS - MAX_INTERNAL_FDS; + static auto constexpr MIN_INTERNAL_FD = + GKFS_MAX_OPEN_FDS - GKFS_MAX_INTERNAL_FDS; static auto constexpr MAX_USER_FDS = MIN_INTERNAL_FD; private: @@ -99,7 +100,7 @@ private: bool interception_enabled_; - std::bitset internal_fds_; + std::bitset internal_fds_; mutable std::mutex internal_fds_mutex_; bool internal_fds_must_relocate_; std::bitset protected_fds_; diff --git a/include/common/cmake_configure.hpp.in b/include/common/cmake_configure.hpp.in index 8b3ee852be9138d1e839dc4c2aecbcb5b2bef7c6..8d24058059f3fad937853432fad01f1a30bdb281 100644 --- a/include/common/cmake_configure.hpp.in +++ b/include/common/cmake_configure.hpp.in @@ -14,7 +14,7 @@ #ifndef GKFS_CMAKE_CONFIGURE_HPP #define GKFS_CMAKE_CONFIGURE_HPP -#cmakedefine01 CREATE_CHECK_PARENTS +#cmakedefine01 GKFS_CREATE_CHECK_PARENTS #cmakedefine01 LOG_SYSCALLS #cmakedefine GKFS_USE_GUIDED_DISTRIBUTION #define GKFS_USE_GUIDED_DISTRIBUTION_PATH "@GKFS_USE_GUIDED_DISTRIBUTION_PATH@" diff --git a/src/client/gkfs_functions.cpp b/src/client/gkfs_functions.cpp index 282a3eae95ce173ae6add0f735a704ba61797393..a19373d889913cb55980a88c491de3fc9ddfb354 100644 --- a/src/client/gkfs_functions.cpp +++ b/src/client/gkfs_functions.cpp @@ -91,13 +91,13 @@ namespace { /** * Checks if metadata for parent directory exists (can be disabled with - * CREATE_CHECK_PARENTS). errno may be set + * GKFS_CREATE_CHECK_PARENTS). errno may be set * @param path * @return 0 on success, -1 on failure */ int check_parent_dir(const std::string& path) { -#if CREATE_CHECK_PARENTS +#if GKFS_CREATE_CHECK_PARENTS auto p_comp = gkfs::path::dirname(path); auto md = gkfs::utils::get_metadata(p_comp); if(!md) { @@ -114,7 +114,7 @@ check_parent_dir(const std::string& path) { errno = ENOTDIR; return -1; } -#endif // CREATE_CHECK_PARENTS +#endif // GKFS_CREATE_CHECK_PARENTS return 0; } } // namespace diff --git a/src/client/preload.cpp b/src/client/preload.cpp index 7b05ca9a3fa416b66a97d2985f2e6c0856c61049..33973419413d3c4078b355cafb99b4841fdfbb8a 100644 --- a/src/client/preload.cpp +++ b/src/client/preload.cpp @@ -266,7 +266,9 @@ init_preload() { // happens during our internal initialization, there's no way for us to // control this creation and the fd will be created in the // [0, MAX_USER_FDS) range rather than in our private - // [MAX_USER_FDS, MAX_OPEN_FDS) range. To prevent this for our internal + // [MAX_USER_FDS, GKFS_MAX_OPEN_FDS) range. + // with MAX_USER_FDS = GKFS_MAX_OPEN_FDS - GKFS_MAX_INTERNAL_FDS + // To prevent this for our internal // initialization code, we forcefully occupy the user fd range to force // such modules to create fds in our private range. CTX->protect_user_fds(); diff --git a/src/client/preload_context.cpp b/src/client/preload_context.cpp index 236d2583f8dda978f3ad65e6e8c6c5815cc205ad..f8ac782fe6979f6c7a5c6e7dabf465aa8668c77a 100644 --- a/src/client/preload_context.cpp +++ b/src/client/preload_context.cpp @@ -316,7 +316,7 @@ PreloadContext::register_internal_fd(int fd) { if(static_cast(pos) == internal_fds_.size()) { throw std::runtime_error( - "Internal GekkoFS file descriptors exhausted, increase MAX_INTERNAL_FDS in " + "Internal GekkoFS file descriptors exhausted, increase GKFS_MAX_INTERNAL_FDS in " "CMake, rebuild GekkoFS and try again."); } internal_fds_.reset(pos); diff --git a/src/daemon/daemon.cpp b/src/daemon/daemon.cpp index 0cff0fc6e815817cf5bad1f058b2102fb5a1fbb2..cae92f201196abb99b322e2da40cdd1769202a6a 100644 --- a/src/daemon/daemon.cpp +++ b/src/daemon/daemon.cpp @@ -813,7 +813,7 @@ main(int argc, const char* argv[]) { #else cout << "Debug: OFF" << endl; #endif -#if CREATE_CHECK_PARENTS +#if GKFS_CREATE_CHECK_PARENTS cout << "Create check parents: ON" << endl; #else cout << "Create check parents: OFF" << endl;