-
Notifications
You must be signed in to change notification settings - Fork 13.3k
File-locking API uses incorrect fnctl constants on at least sparc64 #57007
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
Comments
I guess the mechanism would be "use the |
@jonas-schievink Indeed, I forgot the most obvious solution. The constants are there and usable: https://github.com/rust-lang/libc/blob/master/src/unix/notbsd/linux/other/b64/sparc64.rs |
I assume the correct code would be: pub const F_RDLCK: libc::c_short = libc::F_RDLCK;
pub const F_WRLCK: libc::c_short = libc::F_WRLCK;
pub const F_UNLCK: libc::c_short = libc::F_UNLCK;
pub const F_SETLK: libc::c_int = libc::F_SETLK;
pub const F_SETLKW: libc::c_int = libc::F_SETLKW; |
Also don't forget https://github.com/rust-lang/libc/blob/master/src/unix/notbsd/linux/other/mod.rs containing struct flock. As |
This will break, because we lose the dummy field |
Could this be fixed in the |
Note that |
That sounds like it should already work. |
The code in |
And actually, it does not matter at all for us, because in the FreeBSD documentation, it says
So this field is an output field used by an operation not used at all here. If it's not a syntax error to not specify it, we can just ignore its existence. |
We can handle this via either |
@michaelwoerister is spot on that these were added to rustc way before we could depend on libc and crates.io crates. The |
Since the values for the fcntl constants can vary from architecture to architecture, it is better to use the values defined in the libc crate instead of assigning literals in the flock code which would make the assumption that all architectures use the same values. Fixes rust-lang#57007
flock: Use fcntl constants directly from libc crate on Unix targets Since the values for the fcntl constants can vary from architecture to architecture, it is better to use the values defined in the libc crate instead of assigning literals in the flock code which would make the assumption that all architectures use the same values. Fixes #57007
As described in #49773 (comment), the file-locking API uses incorrect fnctl constants on sparc64.
Compare the glibc headers on sparc64:
and what's in the rust sources:
Would there be a mechanism to sync the constants directly with the glibc sources, i.e. "using the headers"?
@jrtc27 @karcherm @psumbera @michaelwoerister @alexcrichton
The text was updated successfully, but these errors were encountered: