Commit ad097bd9 authored by Marc Vef's avatar Marc Vef
Browse files

Merge branch 'jathenst/287-add-system-call-listxattr-family' into 'master'

Resolve "Add system call: listxattr family"

Closes #287

Closes #287

See merge request !186
parents 477005cd 2ce743df
Loading
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -8,6 +8,7 @@ to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
## [Unreleased]
### New

- Added syscall support for listxattr family ([!186](https://storage.bsc.es/gitlab/hpc/gekkofs/-/merge_request/186)).
- Remove optimization, removing one RPC per operation ([!195](https://storage.bsc.es/gitlab/hpc/gekkofs/-/merge_request/195)).
- Added the GekkoFS proxy as an optional gateway between client and daemon. The proxy is started on each compute node
  that houses clients ([!191](https://storage.bsc.es/gitlab/hpc/gekkofs/-/merge_request/191)).
+9 −0
Original line number Diff line number Diff line
@@ -208,6 +208,15 @@ hook_getxattr(const char* path, const char* name, void* value, size_t size);
int
hook_lgetxattr(const char* path, const char* name, void* value, size_t size);

ssize_t
hook_listxattr(const char* path, char* list, size_t size);

ssize_t
hook_llistxattr(const char* path, char* list, size_t size);

ssize_t
hook_flistxattr(int fd, char* list, size_t size);

int
hook_fallocate(int fd, int mode, off_t offset, off_t len);

+37 −2
Original line number Diff line number Diff line
@@ -996,6 +996,43 @@ hook_lgetxattr(const char* path, const char* name, void* value, size_t size) {
    return syscall_no_intercept_wrapper(SYS_lgetxattr, path, name, value, size);
}

ssize_t
hook_listxattr(const char* path, char* list, size_t size) {

    LOG(DEBUG, "{}() called with path '{}' list '{}' size '{}'", __func__, path,
        list, size);

    std::string rel_path;
    if(CTX->relativize_path(path, rel_path)) {
        return -ENOTSUP;
    }
    return syscall_no_intercept_wrapper(SYS_listxattr, path, list, size);
}

ssize_t
hook_llistxattr(const char* path, char* list, size_t size) {

    LOG(DEBUG, "{}() called with path '{}' list '{}' size '{}'", __func__, path,
        list, size);

    std::string rel_path;
    if(CTX->relativize_path(path, rel_path)) {
        return -ENOTSUP;
    }
    return syscall_no_intercept_wrapper(SYS_llistxattr, path, list, size);
}

ssize_t
hook_flistxattr(int fd, char* list, size_t size) {

    LOG(DEBUG, "{}() called with fd '{}' list '{}' size '{}'", __func__, fd,
        list, size);

    if(CTX->file_map()->exist(fd)) {
        return -ENOTSUP;
    }
    return syscall_no_intercept_wrapper(SYS_flistxattr, fd, list, size);
}

int
hook_fallocate(int fd, int mode, off_t offset, off_t len) {
@@ -1018,6 +1055,4 @@ hook_fadvise64(int fd, off_t offset, off_t len, int advice) {
    }
    return syscall_no_intercept_wrapper(SYS_fadvise64, fd, offset, len, advice);
}


} // namespace gkfs::hook
+21 −0
Original line number Diff line number Diff line
@@ -784,6 +784,27 @@ hook(long syscall_number, long arg0, long arg1, long arg2, long arg3, long arg4,
                    reinterpret_cast<const char*>(arg1),
                    reinterpret_cast<void*>(arg2), static_cast<size_t>(arg4));
            break;
#ifdef SYS_listxattr
        case SYS_listxattr:
            *result = gkfs::hook::hook_listxattr(
                    reinterpret_cast<const char*>(arg0),
                    reinterpret_cast<char*>(arg1), static_cast<size_t>(arg2));
            break;
#endif
#ifdef SYS_llistxattr
        case SYS_llistxattr:
            *result = gkfs::hook::hook_llistxattr(
                    reinterpret_cast<const char*>(arg0),
                    reinterpret_cast<char*>(arg1), static_cast<size_t>(arg2));
            break;
#endif
#ifdef SYS_flistxattr
        case SYS_flistxattr:
            *result = gkfs::hook::hook_flistxattr(reinterpret_cast<long>(arg0),
                                                  reinterpret_cast<char*>(arg1),
                                                  static_cast<size_t>(arg2));
            break;
#endif

        case SYS_lgetxattr:
            *result = gkfs::hook::hook_lgetxattr(