Commit 0a7463bd authored by Marc Vef's avatar Marc Vef
Browse files

Support lgetxattr()

parent 28b5c214
Loading
Loading
Loading
Loading
Loading
+3 −0
Original line number Diff line number Diff line
@@ -176,6 +176,9 @@ hook_fsync(unsigned int fd);
int
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);

} // namespace gkfs::hook

#endif
+14 −0
Original line number Diff line number Diff line
@@ -1008,4 +1008,18 @@ hook_getxattr(const char* path, const char* name, void* value, size_t size) {
                                            size);
}

int
hook_lgetxattr(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);

    auto normalized_path = gkfs::path::normalize(path);
    if(gkfs::path::is_in_gkfs(normalized_path, true))
        return -ENOTSUP;
    else
        return syscall_no_intercept_wrapper(SYS_lgetxattr, path, name, value,
                                            size);
}

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

        case SYS_lgetxattr:
            *result = gkfs::hook::hook_lgetxattr(
                    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