Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix typo in documentation for std::fs::Permissions #109263

Merged
merged 3 commits into from
Mar 2, 2024
Merged

Conversation

squell
Copy link
Contributor

@squell squell commented Mar 17, 2023

Please check and re-check this PR carefully to see if I got this right.

But by my logic, if the read_only function returns true, I would not expect be able to write to the file (it being read only); so this text is meant to clarify that read_only being false doesn't mean you can actually write to the file, just that "in general" someone is able to.

@rustbot
Copy link
Collaborator

rustbot commented Mar 17, 2023

Thanks for the pull request, and welcome! The Rust team is excited to review your changes, and you should hear from @thomcc (or someone else) soon.

Please see the contribution instructions for more information. Namely, in order to ensure the minimum review times lag, PR authors and assigned reviewers should ensure that the review label (S-waiting-on-review and S-waiting-on-author) stays updated, invoking these commands when appropriate:

  • @rustbot author: the review is finished, PR author should check the comments and take action accordingly
  • @rustbot review: the author is ready for a review, this PR will be queued again in the reviewer's queue

@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 Mar 17, 2023
@rustbot
Copy link
Collaborator

rustbot commented Mar 17, 2023

Hey! It looks like you've submitted a new PR for the library teams!

If this PR contains changes to any rust-lang/rust public library APIs then please comment with @rustbot label +T-libs-api -T-libs to tag it appropriately. If this PR contains changes to any unstable APIs please edit the PR description to add a link to the relevant API Change Proposal or create one if you haven't already. If you're unsure where your change falls no worries, just leave it as is and the reviewer will take a look and make a decision to forward on if necessary.

Examples of T-libs-api changes:

  • Stabilizing library features
  • Introducing insta-stable changes such as new implementations of existing stable traits on existing stable types
  • Introducing new or changing existing unstable library APIs (excluding permanently unstable features / features without a tracking issue)
  • Changing public documentation in ways that create new stability guarantees
  • Changing observable runtime behavior of library APIs

@thomcc
Copy link
Member

thomcc commented Mar 30, 2023

I see your confusion, the issue probably stems from the fact that this is "readonly" rather than "readable" or something.

Copy link
Member

@thomcc thomcc left a comment

Choose a reason for hiding this comment

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

I can see what you mean, but also why it was written the way it was. I honestly think it's a confusing way to phrase it, so probably it's worth rewording the sentence instead.

@@ -1406,7 +1406,7 @@ impl Permissions {
/// On Unix-based platforms this checks if *any* of the owner, group or others
/// write permission bits are set. It does not check if the current
/// user is in the file's assigned group. It also does not check ACLs.
/// Therefore even if this returns true you may not be able to write to the
/// Therefore even if this returns false you may not be able to write to the
Copy link
Member

Choose a reason for hiding this comment

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

Perhaps this should be

Therefore even if this returns true you may not be able to read to the file

Or even

Therefore you may not be able to rely on the return value of this function to predict the success of reads or writes on the file.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I think the second approach is preferable; the first one is better than the original (since it is accurate), but changes the text from talking about writes to reads (while the focus of the read_only function is checking the write permissions).

I.e. any text should allow the reader to make the inference that:

  1. if it returns true doesn't say anything about being actually able to read (all the UNIX read permissions could be unset)
  2. if it returns false that doesn't mean you can write to the file

@thomcc
Copy link
Member

thomcc commented May 5, 2023

@rustbot author

@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 May 5, 2023
@Dylan-DPC
Copy link
Member

@squell any updates on this? thanks

@squell
Copy link
Contributor Author

squell commented Aug 29, 2023

Reworded in the style suggested by @thomcc; but a bit stronger worded (if someone "may not be able to rely", that just means they can't rely); and phrased "the success of reads of writes" in a more active voice.

@Dylan-DPC Dylan-DPC 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 Sep 1, 2023
/// to predict whether attempts to read or write the file will actually succeed.
/// The [`PermissionsExt`] trait gives direct access to the permission bits but
/// also does not read ACLs. If you need to accurately know whether or not a file
/// is writable use the `access()` function from libc.
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
/// is writable use the `access()` function from libc.
/// is writable use the `access()` function from libc.

I think it's work mentioning that using access can lead to time-of-check-time-of-use problems where the permissions get changed between the call to access and the actual access, and therefore the return value of access also cannot be relied on for some things. The only way to figure out whether you can open a file is to open it.

Copy link
Contributor Author

@squell squell Feb 8, 2024

Choose a reason for hiding this comment

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

Perhaps the final sentence should simply be removed lest the documentation for this function turn into a tutorial about interacting with a file system.

Copy link
Member

Choose a reason for hiding this comment

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

That sounds good.

Copy link
Member

Choose a reason for hiding this comment

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

I agree with removing that line.

@thomcc
Copy link
Member

thomcc commented Feb 1, 2024

I'm going to be away for a few months, so I'm rerolling my PRs so that folks don't have to wait for me. Sorry/thanks.

r? libs

@rustbot rustbot assigned cuviper and unassigned thomcc Feb 1, 2024
@Amanieu Amanieu 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 Feb 21, 2024
@joshtriplett
Copy link
Member

(waiting for an update that deletes the last sentence)

@cuviper
Copy link
Member

cuviper commented Mar 2, 2024

@bors r+ rollup

@bors
Copy link
Contributor

bors commented Mar 2, 2024

📌 Commit b353765 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-author Status: This is awaiting some action (such as code changes or more information) from the author. labels Mar 2, 2024
matthiaskrgr added a commit to matthiaskrgr/rust that referenced this pull request Mar 2, 2024
fix typo in documentation for std::fs::Permissions

Please check and re-check this PR carefully to see if I got this right.

But by my logic, if the `read_only` function returns `true`, I would not expect be able to write to the file (it being read only); so this text is meant to clarify that `read_only` being `false` doesn't mean *you* can actually write to the file, just that "in general" someone is able to.
bors added a commit to rust-lang-ci/rust that referenced this pull request Mar 2, 2024
…iaskrgr

Rollup of 10 pull requests

Successful merges:

 - rust-lang#109263 (fix typo in documentation for std::fs::Permissions)
 - rust-lang#120684 (Update E0716.md for clarity)
 - rust-lang#121739 (Display short types for unimplemented trait)
 - rust-lang#121749 (Don't lint on executable crates with `non_snake_case` names)
 - rust-lang#121758 (Move thread local implementation to `sys`)
 - rust-lang#121815 (Move `gather_comments`.)
 - rust-lang#121835 (Move `HandleStore` into `server.rs`.)
 - rust-lang#121847 (Remove hidden use of Global)
 - rust-lang#121861 (Use the guaranteed precision of a couple of float functions in docs)
 - rust-lang#121875 ( Account for unmet T: !Copy in E0277 message)

r? `@ghost`
`@rustbot` modify labels: rollup
Dylan-DPC added a commit to Dylan-DPC/rust that referenced this pull request Mar 2, 2024
fix typo in documentation for std::fs::Permissions

Please check and re-check this PR carefully to see if I got this right.

But by my logic, if the `read_only` function returns `true`, I would not expect be able to write to the file (it being read only); so this text is meant to clarify that `read_only` being `false` doesn't mean *you* can actually write to the file, just that "in general" someone is able to.
bors added a commit to rust-lang-ci/rust that referenced this pull request Mar 2, 2024
Rollup of 9 pull requests

Successful merges:

 - rust-lang#109263 (fix typo in documentation for std::fs::Permissions)
 - rust-lang#117156 (Convert `Unix{Datagram,Stream}::{set_}passcred()` to per-OS traits)
 - rust-lang#120684 (Update E0716.md for clarity)
 - rust-lang#121739 (Display short types for unimplemented trait)
 - rust-lang#121815 (Move `gather_comments`.)
 - rust-lang#121835 (Move `HandleStore` into `server.rs`.)
 - rust-lang#121847 (Remove hidden use of Global)
 - rust-lang#121861 (Use the guaranteed precision of a couple of float functions in docs)
 - rust-lang#121875 ( Account for unmet T: !Copy in E0277 message)

r? `@ghost`
`@rustbot` modify labels: rollup
bors added a commit to rust-lang-ci/rust that referenced this pull request Mar 2, 2024
…iaskrgr

Rollup of 9 pull requests

Successful merges:

 - rust-lang#109263 (fix typo in documentation for std::fs::Permissions)
 - rust-lang#120684 (Update E0716.md for clarity)
 - rust-lang#121715 (match lowering: pre-simplify or-patterns too)
 - rust-lang#121739 (Display short types for unimplemented trait)
 - rust-lang#121815 (Move `gather_comments`.)
 - rust-lang#121835 (Move `HandleStore` into `server.rs`.)
 - rust-lang#121847 (Remove hidden use of Global)
 - rust-lang#121861 (Use the guaranteed precision of a couple of float functions in docs)
 - rust-lang#121875 ( Account for unmet T: !Copy in E0277 message)

r? `@ghost`
`@rustbot` modify labels: rollup
matthiaskrgr added a commit to matthiaskrgr/rust that referenced this pull request Mar 2, 2024
fix typo in documentation for std::fs::Permissions

Please check and re-check this PR carefully to see if I got this right.

But by my logic, if the `read_only` function returns `true`, I would not expect be able to write to the file (it being read only); so this text is meant to clarify that `read_only` being `false` doesn't mean *you* can actually write to the file, just that "in general" someone is able to.
@bors bors merged commit d0e5431 into rust-lang:master Mar 2, 2024
11 checks passed
@rustbot rustbot added this to the 1.78.0 milestone Mar 2, 2024
rust-timer added a commit to rust-lang-ci/rust that referenced this pull request Mar 2, 2024
Rollup merge of rust-lang#109263 - squell:master, r=cuviper

fix typo in documentation for std::fs::Permissions

Please check and re-check this PR carefully to see if I got this right.

But by my logic, if the `read_only` function returns `true`, I would not expect be able to write to the file (it being read only); so this text is meant to clarify that `read_only` being `false` doesn't mean *you* can actually write to the file, just that "in general" someone is able to.
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.

9 participants