Skip to content

dirfd dir operations (3/4) - #160533

Merged
rust-bors[bot] merged 1 commit into
rust-lang:mainfrom
Qelxiros:dirfd-dirs
Aug 25, 2026
Merged

rust-bors[bot] merged 1 commit into
rust-lang:mainfrom
Qelxiros:dirfd-dirs

Conversation

@Qelxiros

@Qelxiros Qelxiros commented Aug 4, 2026 •

Copy link
Copy Markdown
Contributor

View all comments

Previous PR: #150679
Reference: #139514
Tracking issue: #120426

@rustbot

rustbot commented Aug 4, 2026

Copy link
Copy Markdown
Collaborator

Any special-casing of Miri in the standard library requires review.

cc @rust-lang/miri

@rustbot rustbot added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. T-libs Relevant to the library team, which will review and decide on the PR/issue. labels Aug 4, 2026
@rustbot

rustbot commented Aug 4, 2026

Copy link
Copy Markdown
Collaborator

r? @Mark-Simulacrum

rustbot has assigned @Mark-Simulacrum.
They will have a look at your PR within the next two weeks and either review your PR or reassign to another reviewer.

Use r? to explicitly pick a reviewer

Why was this reviewer chosen?

The reviewer was selected based on:

  • Owners of files modified in this PR: @ChrisDenton, libs
  • @ChrisDenton, libs expanded to 13 candidates
  • Random selection from 6 candidates

@rust-log-analyzer

This comment has been minimized.

@rust-log-analyzer

This comment has been minimized.

@rust-log-analyzer

This comment has been minimized.

Comment thread library/std/src/sys/fs/unix/dir.rs Resolved
Comment thread library/std/src/fs.rs Resolved
Comment thread library/std/src/sys/fs/unix/dir.rs Resolved

@Mark-Simulacrum Mark-Simulacrum 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.

r=me with a few comments answered/nits addressed

View changes since this review

Comment thread library/std/src/sys/fs/unix/dir.rs Resolved
Comment thread library/std/src/fs.rs
///
/// # Errors
///
/// This function will return an error if `path` does not point to an existing directory.

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.

I think we follow symlinks, right? Should we note that here?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

We do follow them, but I don't think we need to note it. Dir::open and File::open (and maybe others) also follow symlinks without documenting that fact. If we decide that we should note it, that's a follow-up PR.

@rustbot rustbot added S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Aug 8, 2026
@rustbot

rustbot commented Aug 8, 2026

Copy link
Copy Markdown
Collaborator

Reminder, once the PR becomes ready for a review, use @rustbot ready.

@Qelxiros

Qelxiros commented Aug 9, 2026

Copy link
Copy Markdown
Contributor Author

@rustbot r=@Mark-Simulacrum

@Qelxiros

Qelxiros commented Aug 9, 2026

Copy link
Copy Markdown
Contributor Author

@rustbot ready

@rustbot rustbot added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. and removed S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. labels Aug 9, 2026
@Mark-Simulacrum

Copy link
Copy Markdown
Member

@bors r+

@rust-bors

rust-bors Bot commented Aug 9, 2026

Copy link
Copy Markdown
Contributor

📌 Commit 354d65e has been approved by Mark-Simulacrum

It is now in the queue for this repository.

@rust-bors rust-bors Bot added S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Aug 9, 2026
jhpratt added a commit to jhpratt/rust that referenced this pull request Aug 9, 2026
…crum

dirfd dir operations (3/4)

Previous PR: rust-lang#150679
Reference: rust-lang#139514
Tracking issue: rust-lang#120426
rust-bors Bot pushed a commit that referenced this pull request Aug 10, 2026
Rollup of 7 pull requests

Successful merges:

 - #160533 (dirfd dir operations (3/4))
 - #160675 (bootstrap: Remove `PATH_REMAP` from command-line selector handling )
 - #160807 (Update rustc crate rkyv to 0.8.18)
 - #160560 (Add nightly-only support for Cargo unremap trim-paths files in `rust-gdb`)
 - #160804 (Change .expect message on net/parser to follow precondition style)
 - #160805 (`extern "custom"`: add tests)
 - #160816 (Mark const ptr methods and free functions as inline(always) to match *mut)
@rustbot rustbot added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. and removed S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. labels Aug 24, 2026
@ChrisDenton

Copy link
Copy Markdown
Member

@bors try jobs=aarch64-apple-2

@rust-bors

This comment has been minimized.

rust-bors Bot pushed a commit that referenced this pull request Aug 24, 2026
dirfd dir operations (3/4)


try-job: aarch64-apple-2
@rust-bors

rust-bors Bot commented Aug 25, 2026

Copy link
Copy Markdown
Contributor

☀️ Try build successful (CI)
Build commit: a578780 (a578780fbdb037dbf2ea88f04a0c345a7c3cbef1)
Base parent: e776960 (e7769602aca3770e8d8ea55716becb22e839a579)

@ChrisDenton

Copy link
Copy Markdown
Member

@bors r=Mark-Simulacrum

@rust-bors

rust-bors Bot commented Aug 25, 2026

Copy link
Copy Markdown
Contributor

📌 Commit c2b76de has been approved by Mark-Simulacrum

It is now in the queue for this repository.

@rust-bors rust-bors Bot added S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Aug 25, 2026
Zalathar added a commit to Zalathar/rust that referenced this pull request Aug 25, 2026
…crum

dirfd dir operations (3/4)

Previous PR: rust-lang#150679
Reference: rust-lang#139514
Tracking issue: rust-lang#120426
rust-bors Bot pushed a commit that referenced this pull request Aug 25, 2026
Rollup of 9 pull requests

Successful merges:

 - #160533 (dirfd dir operations (3/4))
 - #161294 (add crashtests [6/N])
 - #160392 (library: motor: bump moto-rt ABI ver to 17)
 - #161646 (interpret: fix after_local_read handling)
 - #160819 (Rework `div_ceil` for nonzero integers)
 - #161591 (run `classify-runtime-const` test for `f128`)
 - #161680 (renovate: add lockfile update warning)
 - #161702 (Use `drop_guard` in some places in {core,alloc,std})
 - #161709 (Stop rustfmt deleting attributes in fn params)
rust-bors Bot pushed a commit that referenced this pull request Aug 25, 2026
…uwer

Rollup of 10 pull requests

Successful merges:

 - #160533 (dirfd dir operations (3/4))
 - #161294 (add crashtests [6/N])
 - #160392 (library: motor: bump moto-rt ABI ver to 17)
 - #161646 (interpret: fix after_local_read handling)
 - #161682 (Update books)
 - #160819 (Rework `div_ceil` for nonzero integers)
 - #161204 (core: Make funnel shifts panic only if overflow checks are enabled)
 - #161591 (run `classify-runtime-const` test for `f128`)
 - #161680 (renovate: add lockfile update warning)
 - #161709 (Stop rustfmt deleting attributes in fn params)
@rust-bors
rust-bors Bot merged commit 824552d into rust-lang:main Aug 25, 2026
14 checks passed
@rustbot rustbot added this to the 1.100.0 milestone Aug 25, 2026
rust-bors Bot pushed a commit that referenced this pull request Aug 25, 2026
Rollup merge of #160533 - Qelxiros:dirfd-dirs, r=Mark-Simulacrum

dirfd dir operations (3/4)

Previous PR: #150679
Reference: #139514
Tracking issue: #120426
pull Bot pushed a commit to LeeeeeeM/miri that referenced this pull request Aug 26, 2026
…uwer

Rollup of 10 pull requests

Successful merges:

 - rust-lang/rust#160533 (dirfd dir operations (3/4))
 - rust-lang/rust#161294 (add crashtests [6/N])
 - rust-lang/rust#160392 (library: motor: bump moto-rt ABI ver to 17)
 - rust-lang/rust#161646 (interpret: fix after_local_read handling)
 - rust-lang/rust#161682 (Update books)
 - rust-lang/rust#160819 (Rework `div_ceil` for nonzero integers)
 - rust-lang/rust#161204 (core: Make funnel shifts panic only if overflow checks are enabled)
 - rust-lang/rust#161591 (run `classify-runtime-const` test for `f128`)
 - rust-lang/rust#161680 (renovate: add lockfile update warning)
 - rust-lang/rust#161709 (Stop rustfmt deleting attributes in fn params)
@RalfJung RalfJung mentioned this pull request Oct 3, 2026
1 of 13 tasks
JonathanBrouwer added a commit to JonathanBrouwer/rust that referenced this pull request Nov 10, 2026
JonathanBrouwer added a commit to JonathanBrouwer/rust that referenced this pull request Nov 10, 2026
JonathanBrouwer added a commit to JonathanBrouwer/rust that referenced this pull request Nov 10, 2026
rust-bors Bot pushed a commit that referenced this pull request Nov 10, 2026
Rollup merge of #165739 - RalfJung:file-flush, r=ChrisDenton

remove NOP File::flush from fs tests

They were added by @ChrisDenton in #116438 and by @Qelxiros in #150679 and #160533. However, `File::flush` is documented to be a NOP:

https://github.com/rust-lang/rust/blob/37bc46f797428b9526874e4daac2ac2b41800d6b/library/std/src/fs.rs#L1446-L1461
RalfJung pushed a commit to mehmettoplu-rs/miri that referenced this pull request Nov 11, 2026
github-actions Bot pushed a commit to rust-lang/stdarch that referenced this pull request Nov 12, 2026
run_path_with_cstr(path, &|path| self.open_file_c(path, opts, libc::O_DIRECTORY)).map(Self)
}

pub fn create_dir(&self, path: &Path) -> io::Result<()> {

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.

@Qelxiros why do you not let callers specify the Unix mode when creating a directory?

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.

Dir::create_dir is available on non-Unix targets too. We don't require passing permissions to File::create either. Instead we have an extension trait on the OpenOptions builder instead. And there is the Dir::open_dir_with method, which I would assume also allows creating a directory. Dir::open_dir_with takes an OpenOptions. I would expect the file permissions you set on that to apply to the created directory.

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.

there is the Dir::open_dir_with method, which I would assume also allows creating a directory.

Currently it doesn't. Unix doesn't have "open dir, create if it doesn't exist yet".

But also the entire state of Dir vs OpenOptions is kind of odd -- for files we have methods on OpenOptions that take a path but here we have methods on Dir that take an OpenOptions...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. T-libs Relevant to the library team, which will review and decide on the PR/issue.

Projects

None yet

Development

Successfully merging this pull request may close these issues.