-
-
Notifications
You must be signed in to change notification settings - Fork 1.3k
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
df: better error message when executed in a chroot without /proc #3601 #3602
Conversation
Please fix the warning:
|
Thank you for pointing out the warning. I have fixed it in the new commit. |
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.
Looks great, thanks! I just have one suggestion for a little bit of further cleanup.
src/uu/df/src/df.rs
Outdated
@@ -448,7 +448,7 @@ pub fn uumain(args: impl uucore::Args) -> UResult<()> { | |||
Err(error) => { |
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 this could be:
use uucore::error::FromIo;
// --- snip ---
let filesystems = get_all_filesystems(&opt)
.map_err_context(|| "cannot read table of mounted file systems".into())?;
See the docs for UIoError
.
Sidenote: if you have any ideas about how to make this feature more discoverable/intuitive, I would be happy to hear it, because first-time contributors often miss this.
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 made the requested changes in the new commit, thanks for the suggestion.
It would be useful for first-time contributors to explicitly recommend this way of error construction in the documentation.
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.
Nice! Is it possible to add a test for this?
src/uu/stat/src/stat.rs
Outdated
@@ -501,7 +501,7 @@ impl Stater { | |||
// mount points aren't displayed when showing filesystem information | |||
None | |||
} else { | |||
let mut mount_list = read_fs_list() | |||
let mut mount_list = read_fs_list()? |
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'm wondering about this case, because it's currently missing a context. Do we know that GNU's error in this case 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.
I tested the Rust and GNU versions of stat in the same environment I used to test df (chroot without proc).
While the Rust version fails, the GNU version does not but displays the expected output. For this reason I was not able to produce the error with GNU's stat.
I could only find GNU's error message in the sources:
https://github.com/coreutils/coreutils/blob/93e099e4c3b659b2e329f655fbdc73fdf594a66e/src/stat.c#L961
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.
Interesting, let's use that error message in stat
then too
To add a test I would need a way to make /proc inaccessible to df. Is that possible? |
Hmm, yeah I guess that's not really possible. At least not with how the tests are currently set up. |
@tertsdiepraam is it ok with you? |
No description provided.