feat: add required syscalls for remove_dir_all - #5057
Conversation
|
Thank you for contributing to Miri! A reviewer will take a look at your PR, typically within a week or two. |
|
Thanks for giving this a try! This week we Rust devs are all meeting at a conference so a backlog of PRs will pile up that'll take a bit to get through -- please be patient. However I can already tell you that the PR is missing tests. :) Specifically
If you look around the test suite you can find examples for both, e.g. |
There was a problem hiding this comment.
Looking at the implementation, it seems you are trying to implement these APIs based on top of paths represented as strings. I don't think we should do that. Lucky enough the standard library is gaining support for directory handles so the hope is that we can use those. :)
It's bad enough that we have this hack on Windows, but you can't actually do much with a DirHandle there so it's not too big of a problem.
@rustbot author
| Ok(file) if is_directory => | ||
| match file.metadata() { | ||
| Ok(meta) if meta.is_dir() => | ||
| this.machine.fds.insert_new(DirHandle { path: path.to_path_buf() }), |
There was a problem hiding this comment.
Given that these APIs are meant specifically to avoid the risk of race conditions, I don't think we should implement them by just storing a path. Rather, a DirHandle should hold a fs::Dir so that we can be actually sure that this refers to a stable directory.
|
Reminder, once the PR becomes ready for a review, use |
|
So my suggestion would to instead add a new FD type that wraps That means it's not yet enough to |
|
Also, a note on terminology, since it also came up in another PR of course: the PR title talks about "sycalls" but that's not quite correct. What we are implementing here aren't syscalls, they are libc functions. These often but not always correspond to syscalls. If you say "syscall" in the context of Miri, then I will assume you are referring to supporting more cases in |
|
☔ The latest upstream changes (possibly #5082) made this pull request unmergeable. Please resolve the merge conflicts. |
|
@phraakture do you still plan to get back to this PR? It's fine if not, we should just know about it so someone else can then pick up the work. :) |
Sorry for the delay. I do still plan to work on this PR. |
|
Okay, thanks for the update! Note that
Ignore |
summary
implemented three syscalls- openat(), unlinkat() and fdopendir(), that the standard library's remove_dir_all uses. kept the fd type similar to windows's DirHandle. The only difference is unix one additionally overrides path(), which the Windows doesn't need as they are unix specific.
related issue #4982
Note: I haven't included any test yet. Any guidance on how these syscalls should be tested, or references to similar existing tests, would be really appreciated.