Verified Commit 68be5b2d authored by Marc Vef's avatar Marc Vef
Browse files

Adding getxattr() syscall support

parent 0cbaae39
Loading
Loading
Loading
Loading
Loading
+3 −0
Original line number Diff line number Diff line
@@ -173,6 +173,9 @@ hook_fstatfs(unsigned int fd, struct statfs* buf);
int
hook_fsync(unsigned int fd);

int
hook_getxattr(const char* path, const char* name, void* value, size_t size);

} // namespace gkfs::hook

#endif
+13 −1
Original line number Diff line number Diff line
@@ -182,7 +182,6 @@ hook_lstat(const char* path, struct stat* buf) {
        return with_errno(gkfs::syscall::gkfs_stat(rel_path, buf));
    }
    return syscall_no_intercept_wrapper(SYS_lstat, rel_path.c_str(), buf);
    ;
}

int
@@ -955,4 +954,17 @@ hook_fsync(unsigned int fd) {
    return syscall_no_intercept_wrapper(SYS_fsync, fd);
}

int
hook_getxattr(const char* path, const char* name, void* value, size_t size) {

    LOG(DEBUG, "{}() called with path '{}' name '{}' value '{}' size '{}'",
        __func__, path, name, fmt::ptr(value), size);

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

} // namespace gkfs::hook
+7 −0
Original line number Diff line number Diff line
@@ -774,6 +774,13 @@ hook(long syscall_number, long arg0, long arg1, long arg2, long arg3, long arg4,
            *result = gkfs::hook::hook_fsync(static_cast<unsigned int>(arg0));
            break;

        case SYS_getxattr:
            *result = gkfs::hook::hook_getxattr(
                    reinterpret_cast<const char*>(arg0),
                    reinterpret_cast<const char*>(arg1),
                    reinterpret_cast<void*>(arg2), static_cast<size_t>(arg4));
            break;

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