Skip to content

std::unix::fs::get_path: using fcntl codepath for netbsd instead.#125940

Merged
bors merged 1 commit into
rust-lang:masterfrom
devnexen:unix_fs_netbsd_get_path
Jun 5, 2024
Merged

std::unix::fs::get_path: using fcntl codepath for netbsd instead.#125940
bors merged 1 commit into
rust-lang:masterfrom
devnexen:unix_fs_netbsd_get_path

Conversation

@devnexen

@devnexen devnexen commented Jun 3, 2024

Copy link
Copy Markdown
Contributor

on netbsd, procfs is not as central as on linux/solaris thus can be perfectly not mounted.
Thus using fcntl with F_GETPATH, the kernel deals with MAXPATHLEN internally too.

@rustbot

rustbot commented Jun 3, 2024

Copy link
Copy Markdown
Collaborator

r? @cuviper

rustbot has assigned @cuviper.
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

@rustbot rustbot added O-unix Operating system: Unix-like 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 Jun 3, 2024
@tbu-

tbu- commented Jun 3, 2024

Copy link
Copy Markdown
Contributor

Perhaps it could fall back to the proc fs code path in case of MAXPATHLEN difficulties?

@rustbot

rustbot commented Jun 3, 2024

Copy link
Copy Markdown
Collaborator

These commits modify the Cargo.lock file. Unintentional changes to Cargo.lock can be introduced when switching branches and rebasing PRs.

If this was unintentional then you should revert the changes before this PR is merged.
Otherwise, you can ignore this comment.

@devnexen devnexen force-pushed the unix_fs_netbsd_get_path branch from 6bcaac3 to e41e233 Compare June 3, 2024 20:57
Comment thread library/std/src/sys/pal/unix/fs.rs Outdated
// fallback to procfs as last resort
let mut p = PathBuf::from("/proc/self/fd");
p.push(&fd.to_string());
if p.exists() {

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.

Why do you need to check p.exists()? It seems to just add extra syscalls. If the path doesn't exist, I expect readlink will get an error anyway, which ok() will turn to None just like the fallthrough below.

on netbsd, procfs is not as central as on linux/solaris thus
can be perfectly not mounted.
Thus using fcntl with F_GETPATH, the kernel deals with MAXPATHLEN
internally too.
@devnexen devnexen force-pushed the unix_fs_netbsd_get_path branch from e41e233 to fd648a3 Compare June 4, 2024 04:37
@cuviper

cuviper commented Jun 5, 2024

Copy link
Copy Markdown
Member

@bors r+ rollup

@bors

bors commented Jun 5, 2024

Copy link
Copy Markdown
Collaborator

📌 Commit fd648a3 has been approved by cuviper

It is now in the queue for this repository.

@bors bors 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 Jun 5, 2024
@bors bors merged commit 808ad60 into rust-lang:master Jun 5, 2024
@rustbot rustbot added this to the 1.80.0 milestone Jun 5, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

O-unix Operating system: Unix-like 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.

5 participants