diff --git a/CMakeLists.txt b/CMakeLists.txt index 0e6d61290c9cd164b509ad2abb17b0d1b793380b..60f9230b019618a6413267863f93af21aa8afc6d 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -203,6 +203,18 @@ include_directories( ) include(GNUInstallDirs) +include(CheckSymbolExists) + +check_cxx_source_compiles(" + #include + #include + + int main() { + struct statx buf; + statx(AT_FDCWD, \"/foo\", AT_EMPTY_PATH, STATX_BASIC_STATS, &buf); + return 0; + } +" GLIBC_HAS_STATX) # Global components add_subdirectory(src/global) diff --git a/include/client/gkfs_functions.hpp b/include/client/gkfs_functions.hpp index bda2fc57a146d18b7a49df609df9d57f06a40175..86ec304482d78e69ad1eebab59ecf7bca4a099dc 100644 --- a/include/client/gkfs_functions.hpp +++ b/include/client/gkfs_functions.hpp @@ -41,7 +41,9 @@ int gkfs_stat(const std::string& path, struct stat* buf, bool follow_links = tru // Implementation of statx, it uses the normal stat and maps the information to the statx structure // Follow links is true by default +#ifdef STATX_TYPE int gkfs_statx(int dirfd, const std::string& path, int flags, unsigned int mask,struct statx* buf, bool follow_links = true ); +#endif int gkfs_statfs(struct statfs* buf); diff --git a/include/client/hooks.hpp b/include/client/hooks.hpp index 2f2a65463c0eaa95fe1128a95cfc3c91a0e8178e..9af366dd40d38eb7b08f46b073b76fa698c52416 100644 --- a/include/client/hooks.hpp +++ b/include/client/hooks.hpp @@ -30,7 +30,9 @@ int hook_close(int fd); int hook_stat(const char* path, struct stat* buf); +#ifdef STATX_TYPE int hook_statx(int dirfd, const char* path, int flags, unsigned int mask,struct statx* buf); +#endif int hook_lstat(const char* path, struct stat* buf); diff --git a/src/client/gkfs_functions.cpp b/src/client/gkfs_functions.cpp index 29854a51828cbad0b706d39c773bf98aec3bdab5..c944e6fc459883aa46c59e74917c05704fb57f2b 100644 --- a/src/client/gkfs_functions.cpp +++ b/src/client/gkfs_functions.cpp @@ -232,7 +232,7 @@ int gkfs_stat(const string& path, struct stat* buf, bool follow_links) { return 0; } - +#ifdef STATX_TYPE int gkfs_statx(int dirfs, const std::string& path, int flags, unsigned int mask, struct statx* buf, bool follow_links) { auto md = gkfs::util::get_metadata(path, follow_links); if (!md) { @@ -268,6 +268,7 @@ int gkfs_statx(int dirfs, const std::string& path, int flags, unsigned int mask, return 0; } +#endif int gkfs_statfs(struct statfs* buf) { auto blk_stat = gkfs::rpc::forward_get_chunk_stat(); diff --git a/src/client/hooks.cpp b/src/client/hooks.cpp index b84f6f1d7fb04517815fa8cf3573a47e44afb4cb..7ca89a4fe762b03cbe908cb0a1701b8943beca32 100644 --- a/src/client/hooks.cpp +++ b/src/client/hooks.cpp @@ -98,7 +98,7 @@ int hook_stat(const char* path, struct stat* buf) { return syscall_no_intercept(SYS_stat, rel_path.c_str(), buf); } - +#ifdef STATX_TYPE int hook_statx(int dirfd, const char* path, int flags, unsigned int mask, struct ::statx* buf) { LOG(DEBUG, "{}() called with dirfd: '{}', path: \"{}\", flags: '{}', mask: '{}', buf: '{}'", @@ -127,9 +127,7 @@ int hook_statx(int dirfd, const char* path, int flags, unsigned int mask, struct return syscall_no_intercept(SYS_statx, dirfd, path, flags, mask, buf); } - - - +#endif int hook_lstat(const char* path, struct stat* buf) { diff --git a/src/client/intercept.cpp b/src/client/intercept.cpp index fe1a766e0588bc3e034ef846f338cbf9e9c1fe19..708cafe6d5e2560d9ce25c42025d11486b706827 100644 --- a/src/client/intercept.cpp +++ b/src/client/intercept.cpp @@ -466,7 +466,7 @@ int hook(long syscall_number, reinterpret_cast(arg1)); break; -#ifdef SYS_statx +#ifdef STATX_TYPE case SYS_statx: *result = gkfs::hook::hook_statx(static_cast(arg0), reinterpret_cast(arg1), diff --git a/tests/integration/CMakeLists.txt b/tests/integration/CMakeLists.txt index 3ba045901f0534083c5ccb4fb82de1025f9e3270..b3a084766ed05440474c7f33c55816a03136ad90 100644 --- a/tests/integration/CMakeLists.txt +++ b/tests/integration/CMakeLists.txt @@ -16,12 +16,14 @@ gkfs_add_python_test( SOURCE directories/test_directories.py ) -gkfs_add_python_test( - NAME test_status - PYTHON_VERSION 3.6 - WORKING_DIRECTORY ${PROJECT_SOURCE_DIR}/tests/integration - SOURCE status/test_status.py -) +if (GLIBC_HAS_STATX) + gkfs_add_python_test( + NAME test_status + PYTHON_VERSION 3.6 + WORKING_DIRECTORY ${PROJECT_SOURCE_DIR}/tests/integration + SOURCE status/test_status.py + ) +endif() gkfs_add_python_test( NAME test_operations diff --git a/tests/integration/harness/gkfs.io/commands.hpp b/tests/integration/harness/gkfs.io/commands.hpp index edda1c289d1b32a6aafcacf558033cb032a21071..7d111c60943651794822a1ce321394bbe0c85e54 100644 --- a/tests/integration/harness/gkfs.io/commands.hpp +++ b/tests/integration/harness/gkfs.io/commands.hpp @@ -59,8 +59,10 @@ writev_init(CLI::App& app); void pwritev_init(CLI::App& app); +#ifdef STATX_TYPE void statx_init(CLI::App& app); +#endif void lseek_init(CLI::App& app); diff --git a/tests/integration/harness/gkfs.io/main.cpp b/tests/integration/harness/gkfs.io/main.cpp index 0cde949dba4b6729e1631e0fc2d66e54674b543c..e946d1b116e9185f3eeed82c3ea7e25d7a5caebe 100644 --- a/tests/integration/harness/gkfs.io/main.cpp +++ b/tests/integration/harness/gkfs.io/main.cpp @@ -34,7 +34,9 @@ init_commands(CLI::App& app) { pwrite_init(app); writev_init(app); pwritev_init(app); + #ifdef STATX_TYPE statx_init(app); + #endif lseek_init(app); } diff --git a/tests/integration/harness/gkfs.io/serialize.hpp b/tests/integration/harness/gkfs.io/serialize.hpp index ceb22db803c0baa550a4875dbf6944324d37e425..df1a7b1dbad952a5a86aa3ea332fe591ebd0a507 100644 --- a/tests/integration/harness/gkfs.io/serialize.hpp +++ b/tests/integration/harness/gkfs.io/serialize.hpp @@ -105,6 +105,7 @@ struct adl_serializer { } }; +#ifdef STATX_TYPE // ADL specialization for struct ::statx_timestamp type template <> struct adl_serializer { @@ -116,8 +117,7 @@ struct adl_serializer { }; } }; - - +#endif // ADL specialization for struct ::dirent type template <> @@ -162,6 +162,7 @@ struct adl_serializer { } }; +#ifdef STATX_TYPE // ADL specialization for struct ::statx type template <> struct adl_serializer { @@ -192,6 +193,7 @@ struct adl_serializer { }; } }; +#endif } // namespace nlohmann diff --git a/tests/integration/harness/gkfs.io/statx.cpp b/tests/integration/harness/gkfs.io/statx.cpp index 0ffe481ba7eabd6688a7642af8779adfd36f4783..1882b1c8c0061ec9b5446d7d710ec5f5202d7b76 100644 --- a/tests/integration/harness/gkfs.io/statx.cpp +++ b/tests/integration/harness/gkfs.io/statx.cpp @@ -32,6 +32,7 @@ using json = nlohmann::json; unsigned int mask, struct statx *statxbuf); */ +#ifdef STATX_TYPE struct statx_options { bool verbose; int dirfd; @@ -135,4 +136,4 @@ statx_init(CLI::App& app) { statx_exec(*opts); }); } - +#endif diff --git a/tests/integration/position/test_lseek.py b/tests/integration/position/test_lseek.py index 51b9b05c68db34a9b4a4e542b05b9e5fe8e40fdb..daf357c7ac237b15f37f1d1791cb7c99bdeda14e 100644 --- a/tests/integration/position/test_lseek.py +++ b/tests/integration/position/test_lseek.py @@ -53,12 +53,12 @@ def test_lseek(gkfs_daemon, gkfs_client): assert ret.retval == 0 assert ret.errno == 115 #FIXME: Should be 0! - # test statx on existing dir - ret = gkfs_client.statx(0, topdir, 0, 0) + # test stat on existing dir + ret = gkfs_client.stat(topdir) assert ret.retval == 0 assert ret.errno == 115 #FIXME: Should be 0! - assert stat.S_ISDIR(ret.statbuf.stx_mode) + assert stat.S_ISDIR(ret.statbuf.st_mode) ret = gkfs_client.open(file_a, os.O_CREAT, @@ -83,11 +83,11 @@ def test_lseek(gkfs_daemon, gkfs_client): assert ret.errno == 115 #FIXME: Should be 0 # Size needs to be 0 - ret = gkfs_client.statx(0, file_a, 0, 0) + ret = gkfs_client.stat(file_a) assert ret.retval == 0 - assert (stat.S_ISDIR(ret.statbuf.stx_mode)==0) - assert (ret.statbuf.stx_size == 0) + assert (stat.S_ISDIR(ret.statbuf.st_mode)==0) + assert (ret.statbuf.st_size == 0) # next commands write at the end of the file (pos0), as the filedescriptor is not shared @@ -97,11 +97,13 @@ def test_lseek(gkfs_daemon, gkfs_client): assert ret.retval == 2 # Size should be 2 - ret = gkfs_client.statx(0, file_a, 0, 0) + ret = gkfs_client.stat(file_a) assert ret.retval == 0 - assert (ret.statbuf.stx_size == 2) - + assert (stat.S_ISDIR(ret.statbuf.st_mode)==0) + assert (ret.statbuf.st_size == 2) + + ret = gkfs_client.lseek(file_a, 0, os.SEEK_END) assert ret.retval == 2 #FAILS assert ret.errno == 115 #FIXME: Should be 0