-
Notifications
You must be signed in to change notification settings - Fork 166
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Basic fcntl-style locking. #555
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
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Somewhat superficial LGTM
#[cfg(target_pointer_width = "32")] | ||
{ | ||
ret(syscall_readonly!( | ||
__NR_fcntl64, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
How about if cfg!(target_pointer_width = "32") { __NR_fcntl64 } else { __NR_fcntl }
here and dedup the blocks?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Feels like we could rely on core::mem::zeroed()
also handling the zero-init for the other members?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Add an
fcntl_lock
function implementing fcntl-style process-associated locking. Currently this only supports locking the entire file.