Skip to content

Support file locking on Solaris - #5167

Open
ChrisDenton wants to merge 1 commit into
rust-lang:mainfrom
ChrisDenton:flock-sloaris
Open

ChrisDenton wants to merge 1 commit into
rust-lang:mainfrom
ChrisDenton:flock-sloaris

Conversation

@ChrisDenton

@ChrisDenton ChrisDenton commented Oct 25, 2026 •

Copy link
Copy Markdown
Member

Fixes: #5164

This is mostly a copy/paste from Cargo's implementation. I also added a clippy restriction lint to prevent us accidentally using File::lock directly.

@ChrisDenton
ChrisDenton force-pushed the flock-sloaris branch 4 times, most recently from ea63892 to b54a614 Compare October 25, 2026 16:37
Comment thread src/utils/raw.rs
@djc

djc commented Oct 26, 2026

Copy link
Copy Markdown
Contributor

(Also, why is this related to #5151 ?)

@ChrisDenton

Copy link
Copy Markdown
Member Author

(Also, why is this related to #5151 ?)

Oh I originally had a thing to ignore unimplemented errors so it doesn't crash (but you get the old concurrency issues). Then I thought that might be going too far.

@rami3l rami3l left a comment •

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Nice work!

If @djc agrees I think we can merge this first and then separately decide whether/how should we support Termux in #5151.

View changes since this review

Comment thread src/utils/raw.rs Outdated
fn fcntl_lock_raw(file: &File, lock_type: libc::c_short, cmd: libc::c_int) -> io::Result<()> {
let mut lock = flock_for_whole_file(lock_type);
loop {
let result = unsafe { libc::fcntl(file.as_raw_fd(), cmd, &mut lock) };

@djc djc Oct 27, 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.

Should we have some safety comments for the unsafe blocks at least?

(We should probably enable the clippy lint for this.)

View changes since the review

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

I've added safety comments. I also added an FcntlCmd enum to help contain the fcntl unsafety to one place since the function takes a variable number and type of arguments based on the command.

Comment thread src/utils/raw.rs Outdated
Comment thread src/utils/raw.rs Outdated

@kulikjak kulikjak left a comment •

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

This branch has not been deployed

No deployments
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.

Solaris support is broken on 1.29.2

4 participants