Skip to content

LinkFiles errors due to protected_hardlinks not propagated as IOStatus::NotSupported #13664

Open
@nathanlo-hrt

Description

@nathanlo-hrt

The protected_hardlinks kernel option prevents hard linking to files you don't own.

Downstream applications (like https://github.com/apache/kvrocks) call LinkFile directly; they can benefit from knowing whether a hardlink failed because of protected_hardlinks, and fall-back to a less efficient recursive copy.

Some other concerns to keep in mind for a fully correct fix: a naive approach would be to read the /proc/sys/fs/protected_hardlinks file if a LinkFile permission error occurs, and return EPERM if it reads '1'.

However, on older Linux kernels (5.x), this file is not world-readable, so we should perhaps assume that protected_hardlinks is enabled for these machines.

I've also posted a partial fix here which solves most of the issue but fails to address the possibility that the file is unreadable.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions