Skip to content

Implement unlinkat to support fs::remove_dir_all - #5414

Draft
programskillforverification wants to merge 2 commits into
rust-lang:masterfrom
programskillforverification:unix-unlinkat
Draft

programskillforverification wants to merge 2 commits into
rust-lang:masterfrom
programskillforverification:unix-unlinkat

Conversation

@programskillforverification

@programskillforverification programskillforverification commented Oct 12, 2026 •

Copy link
Copy Markdown
Contributor

Fix #5408

@rustbot rustbot added the S-waiting-on-review Status: Waiting for a review to complete label Oct 12, 2026
@programskillforverification
programskillforverification marked this pull request as draft October 13, 2026 08:26
@rustbot rustbot added S-waiting-on-author Status: Waiting for the PR author to address review comments and removed S-waiting-on-review Status: Waiting for a review to complete labels Oct 13, 2026
@rustbot

This comment has been minimized.

Comment thread src/shims/unix/fs.rs
interp_ok(())
}

fn unlink(&mut self, path_op: &OpTy<'tcx>) -> InterpResult<'tcx, Scalar> {

@RalfJung RalfJung Oct 18, 2026 •

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.

It's probably best to share the code between unlink and unlinkat by adding parameters like

dirfd_op: Option<&OpTy<'tcx>>,
...
flags_op: Option<&OpTy<'tcx>>,

View changes since the review

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.

Ah wait this can also do rmdir... yeah then it's probably better to keep them separate.

Comment on lines +27 to +28
assert_eq!(libc::unlinkat(libc::AT_FDCWD, c"foo.txt".as_ptr(), 0), -1);
assert_eq!(Error::last_os_error().raw_os_error(), Some(libc::EACCES));

@RalfJung RalfJung Oct 18, 2026 •

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.

Please use errno_result here instead. #5434 does that for the rest of this file.

View changes since the review

@programskillforverification

Copy link
Copy Markdown
Contributor Author

@RalfJung Dir on std is still under development. Could you add blocked label for this PR?

@RalfJung

Copy link
Copy Markdown
Member

There is Dir::remove_file and Dir::remove_dir so I don't think this is blocked?

@programskillforverification

Copy link
Copy Markdown
Contributor Author

There is Dir::remove_file and Dir::remove_dir so I don't think this is blocked?

My description is not accurate. Yes, the methods exist, so this is not blocked on missing API. The problem is a bug in them which make CI not pass: on Windows, Dir::remove_file and Dir::remove_dir follow symlinks, so they remove the link target and leave the link in place, while still returning Ok(()). I reported it as rust-lang/rust#164249.

@RalfJung

Copy link
Copy Markdown
Member

on Windows, Dir::remove_file and Dir::remove_dir follow symlinks, so they remove the link target and leave the link in place, while still returning Ok(())

Oh yeah that is pretty wrong indeed.
Nice catch!

@RalfJung RalfJung added S-blocked-on-rust Status: Blocked on landing a Rust PR and removed S-waiting-on-author Status: Waiting for the PR author to address review comments labels Oct 19, 2026
@rustbot

rustbot commented Oct 23, 2026

Copy link
Copy Markdown
Collaborator

☔ The latest upstream changes (possibly #5471) made this pull request unmergeable. Please resolve the merge conflicts.

@rustbot rustbot added the S-waiting-on-author Status: Waiting for the PR author to address review comments label Oct 23, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

S-blocked-on-rust Status: Blocked on landing a Rust PR S-waiting-on-author Status: Waiting for the PR author to address review comments

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Support unlinkat

3 participants