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

Merge branch 'marc/245-fadvise64-syscall-not-hooked' into 'master'

Resolve "fadvise64 syscall not hooked"

Closes #245

Closes #245

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


- Added intercepton of `fadvise64()` and
  `fallocate()` ([!161](https://storage.bsc.es/gitlab/hpc/gekkofs/-/merge_request/161)).
- Added user library `gkfs_user_lib` that can be used to directly link to an
- Added user library `gkfs_user_lib` that can be used to directly link to an
  application ([!171](https://storage.bsc.es/gitlab/hpc/gekkofs/-/merge_request/171)).
  application ([!171](https://storage.bsc.es/gitlab/hpc/gekkofs/-/merge_request/171)).
- FMT10 and date removal, several dependencies updated. ([!172](https://storage.bsc.es/gitlab/hpc/gekkofs/-/merge_request/172)).
- FMT10 and date removal, several dependencies updated. ([!172](https://storage.bsc.es/gitlab/hpc/gekkofs/-/merge_request/172)).
+6 −0
Original line number Original line Diff line number Diff line
@@ -205,6 +205,12 @@ hook_fsync(unsigned int fd);
int
int
hook_getxattr(const char* path, const char* name, void* value, size_t size);
hook_getxattr(const char* path, const char* name, void* value, size_t size);


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

int
hook_fadvise64(int fd, off_t offset, off_t len, int advice);

} // namespace gkfs::hook
} // namespace gkfs::hook


#endif
#endif
+24 −0
Original line number Original line Diff line number Diff line
@@ -983,4 +983,28 @@ hook_getxattr(const char* path, const char* name, void* value, size_t size) {
    return syscall_no_intercept_wrapper(SYS_getxattr, path, name, value, size);
    return syscall_no_intercept_wrapper(SYS_getxattr, path, name, value, size);
}
}



int
hook_fallocate(int fd, int mode, off_t offset, off_t len) {
    LOG(DEBUG, "{}() called with fd '{}' mode '{}' offset '{}' len '{}'",
        __func__, fd, mode, offset, len);

    if(CTX->file_map()->exist(fd)) {
        return -ENOTSUP;
    }
    return syscall_no_intercept_wrapper(SYS_fallocate, fd, mode, offset, len);
}

int
hook_fadvise64(int fd, off_t offset, off_t len, int advice) {
    LOG(DEBUG, "{}() called with fd '{}' offset '{}' len '{}' advice '{}'",
        __func__, fd, offset, len, advice);

    if(CTX->file_map()->exist(fd)) {
        return -ENOTSUP;
    }
    return syscall_no_intercept_wrapper(SYS_fadvise64, fd, offset, len, advice);
}


} // namespace gkfs::hook
} // namespace gkfs::hook
+12 −0
Original line number Original line Diff line number Diff line
@@ -785,6 +785,18 @@ hook(long syscall_number, long arg0, long arg1, long arg2, long arg3, long arg4,
                    reinterpret_cast<void*>(arg2), static_cast<size_t>(arg4));
                    reinterpret_cast<void*>(arg2), static_cast<size_t>(arg4));
            break;
            break;


        case SYS_fallocate:
            *result = gkfs::hook::hook_fallocate(
                    static_cast<int>(arg0), static_cast<int>(arg1),
                    static_cast<off_t>(arg2), static_cast<off_t>(arg3));
            break;

        case SYS_fadvise64:
            *result = gkfs::hook::hook_fadvise64(
                    static_cast<int>(arg0), static_cast<off_t>(arg1),
                    static_cast<off_t>(arg2), static_cast<int>(arg4));
            break;

        default:
        default:
            // ignore any other syscalls, i.e.: pass them on to the kernel
            // ignore any other syscalls, i.e.: pass them on to the kernel
            // (syscalls forwarded to the kernel that return are logged in
            // (syscalls forwarded to the kernel that return are logged in