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.
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.
@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.
Thanks for the pointer, I'll take a look.
There was a problem hiding this comment.
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.
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)?; |
There was a problem hiding this comment.
In some niche cases, /proc might not be mounted - I agree with Copilot here - but use UError instead.
| 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.
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.
There was a problem hiding this comment.
Copilot is correct here - I have a ro mounted partition and I'm unable to see it. This document specifies the exact format of the file.
xbjfk
left a comment
There was a problem hiding this comment.
Not a maintainer of uutils, so take this with a grain of salt, but will add my two cents.
| pub fn form_nodes(&mut self) { | ||
| let res = fs::read_to_string(self.file_name).unwrap(); |
There was a problem hiding this comment.
In some niche cases, /proc might not be mounted - I agree with Copilot here - but use UError instead.
| 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.
Copilot is correct here - I have a ro mounted partition and I'm unable to see it. This document specifies the exact format of the file.
| "renice", | ||
| "rev", | ||
| "setsid", | ||
| "findmnt", |
There was a problem hiding this comment.
This should be in alphabetical order :)
There was a problem hiding this comment.
Maybe the project should consider adding cargo sort to the CI.
| renice = { optional = true, version = "0.0.1", package = "uu_renice", path = "src/uu/renice" } | ||
| rev = { optional = true, version = "0.0.1", package = "uu_rev", path = "src/uu/rev" } | ||
| setsid = { optional = true, version = "0.0.1", package = "uu_setsid", path ="src/uu/setsid" } | ||
| findmnt = { optional = true, version = "0.0.1", package = "uu_findmnt", path = "src/uu/findmnt" } |
On BSD, Mac OS and friends, there is getfsstat (man page) for this purpose. It's even easier as it is a real API and not a text file you need to parse :). It's available in the ubiquitous libc crate: getfsstat You could theoretically write this for Windows too, but you would need to be a masochist :). You would need to consider not only drive letters, but also NTFS mount points and Network shares. |
|
Hey @xbjfk, thanks for the review. I will try to complete this PR at the end of this week. I am too much occupied with some work at the current moment. |
For now the output of
findmntis:Potential fix #23