Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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
rm: rm3 now passes #4013
rm: rm3 now passes #4013
Changes from all commits
6245029
30adc8e
1f50df2
6856ce0
50d2948
3c39a57
70bf4f3
0507270
3a10984
3551369
e11dd50
a3f35a7
fddc8c9
e89d9d0
21b066a
7e62945
4306521
1c507c6
b3b90e4
b612ce5
03578a7
2e61580
87df47d
79895a7
00af775
5968f53
fd13ced
99942b4
744481c
9069d48
0079f73
c4417bf
c7af9a6
4b4222f
7049c64
File filter
Filter by extension
Conversations
Jump to
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
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 is expected,
libc
defines the modes as the typemode_t
, which isu32
on linux andu16
on mac. You can check it here: https://docs.rs/libc/latest/libc/type.mode_t.html (and by changing the platform in the top-left corner)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.
The permission check seems different from before now? I think we need something like this:
coreutils/src/uu/test/src/test.rs
Lines 366 to 374 in 2021c56
Could that be correct? I have to admit I'm not an expert on this, so I could be wrong :)
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.
Looking at there's it looks to be the same as what I was doing before with shifting of bits with that magic number
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.
Since for rm we don't care about read or execute permission we don't need to use a Permission enum like they use and because I found the libc constant I don't need to use the bit shifting... I believe
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 don't think it's quite the same. It feels like we should do something like what test is doing (though indeed only for writing).
S_IWUSR
is documented as "write permissions for the owner of the file" so that does not say much about the current user or access by group. Several sources also recommend usinglibc::access
(ornix::access
). @sylvestre do you know how this all works and what the right approach is?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.
The gnu rm only checks for owner write permission you can test that by running:
Then use
rm *
rm then only prompts for u-w-empty.txt
rm: remove write-protected regular empty file 'u-w-empty.txt'? y
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.
Hmmm, you seem to be right. I think you've got a nice approximation at the moment. Looking at the GNU code this whole thing is quite complicated. Let's put a comment here that it's probably not 100% compatible and move on with our lives 😄