Merged
Conversation
35909b1 to
b030c43
Compare
Add an `fcntl_lock` function implementing fcntl-style process-associated locking. Currently this only supports locking the entire file.
b030c43 to
5390d82
Compare
cgwalters
approved these changes
Mar 4, 2023
Contributor
cgwalters
left a comment
There was a problem hiding this comment.
Somewhat superficial LGTM
| #[cfg(target_pointer_width = "32")] | ||
| { | ||
| ret(syscall_readonly!( | ||
| __NR_fcntl64, |
Contributor
There was a problem hiding this comment.
How about if cfg!(target_pointer_width = "32") { __NR_fcntl64 } else { __NR_fcntl } here and dedup the blocks?
Member
Author
There was a problem hiding this comment.
Unfortunately syscall_readonly! is a macro that does special things with the first parameter and needs it to be a __NR_* literal.
| l_whence: 0, | ||
| l_start: 0, | ||
| l_len: 0, | ||
| ..core::mem::zeroed() |
Contributor
There was a problem hiding this comment.
Feels like we could rely on core::mem::zeroed() also handling the zero-init for the other members?
Member
Author
There was a problem hiding this comment.
Setting l_len to zero is a special case in the documented behavior of fcntl, so I like keeping it explicit. I've now added more comments about this though.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Add an
fcntl_lockfunction implementing fcntl-style process-associated locking. Currently this only supports locking the entire file.