-
Notifications
You must be signed in to change notification settings - Fork 13.9k
fix: from FIXME(#24570) added more info #148156
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
base: master
Are you sure you want to change the base?
Changes from all commits
68ab2c1
98a7209
33fbf38
5a42b13
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -1022,12 +1022,21 @@ impl FromRawHandle for File { | |
|
|
||
| impl fmt::Debug for File { | ||
| fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { | ||
| // FIXME(#24570): add more info here (e.g., mode) | ||
| let mut b = f.debug_struct("File"); | ||
| b.field("handle", &self.handle.as_raw_handle()); | ||
| if let Ok(path) = get_path(self) { | ||
| b.field("path", &path); | ||
| } | ||
|
|
||
| if let Ok(file_attr) = self.file_attr() { | ||
| b.field("read", &true); | ||
| b.field("write", &file_attr.perm().readonly()); | ||
|
|
||
| // Getting analogue of file mode (unix) using file attributes | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. File attributes aren't really an analogue of file mode because they don't have much to do with permissions. That would be ACLs. In any case, what we care most about is how the opened file handle can be used, rather than what the on-disk file has set. E.g. can I There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. In windows files readable as default, if attrs set to the readonly of course you cannot write to them and use file handler for writing, i don't get the point about examples part, for debugging this infromation useful, than just check you opened the file in write or read mode i think so There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. If the |
||
| // See https://learn.microsoft.com/windows/win32/fileio/file-attribute-constants | ||
| b.field("attrs", &file_attr.attributes); | ||
| } | ||
|
|
||
| b.finish() | ||
| } | ||
| } | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This does not look correct to me. If you use
File::createto create and open a write-only file this will claim it's readable when it is not. And a file opened only for reads may not have the readonly attribute set on the file itself.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I will rewrite it for ACL
I thought that if I added this information, it would also not bad
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think what matters here is how the file was opened rather than permissions specifically. For example, on Linux this program:
Produces this result:
So read is
falsebecause you can't read from the openedFile. But you can reopen the file and read it.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As i understand, you interested only in permission during using "session" of file descriptor, not permissions given by system (that i think will be also informative). So, if i add ACCESS_MASK (also add windows target binding from NtQueryObject and another impls) and add acl (via winapi GetSecurityInfo or other similar lower cost functions) to File struct as method file_acl (like file_attr) and finally bind to debug, would that be acceptable to you?