-
Notifications
You must be signed in to change notification settings - Fork 24
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
Add support for findmnt
#210
base: main
Are you sure you want to change the base?
Conversation
Can you please run |
01071f2
to
2977baa
Compare
Yup. I guess that is the case. I'll feature gate this on linux only
|
there might be crate or equivalent for mac/unix. Maybe have a look before making this linux specific |
@sylvestre I see there are some alternatives present inside macOS like the mount and diskutil commands. But shouldn't they be implemented differently from the findmnt one? I am a bit confused here on what do I need to do further. |
path = "src/main.rs" | ||
|
||
[dependencies] | ||
tabled = { workspace = true } |
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.
We recently removed tabled
and so this will no longer work. And as the output currently looks quite different from the output of the original findmnt
, I think it is probably easier to do the output manually than trying to figure out how to do it with tabled
.
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.
@Harshit933 I had started working on a findmnt
implementation as well before realizing you had this PR open, feel free to take the output code from here, that version doesn't use tabled
.
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.
Thanks for the pointer, I'll take a look.
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.
PR Overview
This PR adds support for the findmnt utility by introducing its own Rust package, command-line interface, and associated tests.
- Added a new package (uu_findmnt) with implementation and CLI entry point.
- Updated workspace configuration to include findmnt as a dependency.
- Added tests and documentation for the new utility.
Reviewed Changes
File | Description |
---|---|
src/uu/findmnt/Cargo.toml | New package manifest for the findmnt utility |
src/uu/findmnt/src/findmnt.rs | Core implementation including parsing and table formatting |
src/uu/findmnt/src/main.rs | CLI entry point for findmnt |
src/uu/findmnt/findmnt.md | Documentation for findmnt |
tests/by-util/test_findmnt.rs | Test validating the findmnt output on Linux |
Cargo.toml | Workspace dependencies updated to include findmnt |
tests/tests.rs | Integration of findmnt tests into the overall test suite |
Copilot reviewed 8 out of 8 changed files in this pull request and generated 2 comments.
pub fn form_nodes(&mut self) { | ||
let res = fs::read_to_string(self.file_name).unwrap(); |
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.
Using unwrap() here can lead to a panic if the mountinfo file cannot be read; consider handling the error gracefully with proper error messaging.
pub fn form_nodes(&mut self) { | |
let res = fs::read_to_string(self.file_name).unwrap(); | |
pub fn form_nodes(&mut self) -> Result<(), Box<dyn std::error::Error>> { | |
let res = fs::read_to_string(self.file_name)?; |
Copilot is powered by AI, so mistakes are possible. Review output carefully before use.
let (_, rest) = rest.trim().split_once("-").unwrap(); | ||
let (fstype, rest) = rest.trim().split_once(" ").unwrap(); | ||
let (source, rest) = rest.trim().split_once(" ").unwrap(); | ||
let options_added = if rest.split_once("rw").is_some() { |
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 current logic splitting on "rw" may be unreliable if the options string unexpectedly contains this substring; consider a more robust parsing strategy or document the assumptions clearly.
Copilot is powered by AI, so mistakes are possible. Review output carefully before use.
For now the output of
findmnt
is:Potential fix #23