Skip to content

linux: Add open file descriptor locks - #1731

Open
alexlarsson wants to merge 1 commit into
bytecodealliance:mainfrom
alexlarsson:add-ofd-locks
Open

alexlarsson wants to merge 1 commit into
bytecodealliance:mainfrom
alexlarsson:add-ofd-locks

Conversation

@alexlarsson

Copy link
Copy Markdown

This adds support for fnctl locks using F_OFD_SETLK/F_OFD_GETLK. These are linux-only fcntls similar to (and compatible with) normal fcntl locks but thy have nicer semantics relative to fd closing.

This adds support for fnctl locks using F_OFD_SETLK/F_OFD_GETLK.
These are linux-only fcntls similar to (and compatible with) normal
fcntl locks but thy have nicer semantics relative to fd closing.

Signed-off-by: Alexander Larsson <alexl@redhat.com>
@alexlarsson

Copy link
Copy Markdown
Author

Not sure why the mac CI run was cancelled. But it should not be affected by this change.

alexlarsson added a commit to composefs/composefs-rs that referenced this pull request Nov 9, 2026
containers/storage uses POSIX fcntl record locks, not flock. Use Linux
open-file-description locks, which conflict with those record locks but retain
independent guard lifetimes when other descriptors for the same inode close.

NOTE: This uses libc to access this, because rustix doesn't support it.
Upstream MR to add it: bytecodealliance/rustix#1731

Assisted-by: AI
Signed-off-by: Alexander Larsson <alexl@redhat.com>

@cgwalters cgwalters left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I only superficially skimmed this, but looks sane

fcntl_lock_impl(fd, operation, c::F_OFD_SETLK, c::F_OFD_SETLKW)
}

#[cfg(not(any(

@cgwalters cgwalters Nov 6, 2026 •

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Aren't OFD locks Linux specific?

EDIT: Sorry I see this is just a generic helper.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants