Check for statx support

I was testing the new version of master with statx and it failed in my machine.

Looking at the documentation:

statx() was added to Linux in kernel 4.11; library support was added
       in glibc 2.28.

I have kernel 5.3.0-51-generic with ldd (Ubuntu GLIBC 2.27-3ubuntu1) 2.27.

I've included some #ifdefs to check for support for statx.

Merge request reports

Loading
+2 −0
Changes for include/client/gkfs_functions.hpp: 2 added lines, 0 removed lines.
Original line number Diff line number Diff line
@@ -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);

+2 −0
Changes for include/client/hooks.hpp: 2 added lines, 0 removed lines.
Original line number Diff line number Diff line
@@ -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);

+2 −1
Changes for src/client/gkfs_functions.cpp: 2 added lines, 1 removed line.
Original line number Diff line number Diff line
@@ -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();
+2 −4
Changes for src/client/hooks.cpp: 2 added lines, 4 removed lines.
Original line number Diff line number Diff line
@@ -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) {

+1 −1
Changes for src/client/intercept.cpp: 1 added line, 1 removed line.
Original line number Diff line number Diff line
@@ -466,7 +466,7 @@ int hook(long syscall_number,
                                            reinterpret_cast<struct stat*>(arg1));
            break;

#ifdef SYS_statx
#ifdef STATX_TYPE
        case SYS_statx:
            *result = gkfs::hook::hook_statx(static_cast<int>(arg0),
                                            reinterpret_cast<char*>(arg1),
Loading
Loading