Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Add support forfindmnt#210

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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Open
Harshit933 wants to merge3 commits intouutils:main
base:main
Choose a base branch
Loading
fromHarshit933:findmnt
Open

Conversation

Harshit933
Copy link
Contributor

@Harshit933Harshit933 commentedFeb 2, 2025
edited
Loading

For now the output offindmnt is:

[harshit:~/dev/util-linux (findmnt|✔)] target/debug/util-linux findmnt target                                     source          fstype       options                                                                                                /                                          /dev/nvme0n1p7  ext4         rw,relatime                                                                                            /proc                                      proc            proc         rw,nosuid,nodev,noexec,relatime                                                                        /proc/sys/fs/binfmt_misc                   systemd-1       autofs       rw,relatime,fd=41,pgrp=1,timeout=0,minproto=5,maxproto=5,direct,pipe_ino=6207                          /proc/sys/fs/binfmt_misc                   binfmt_misc     binfmt_misc  rw,nosuid,nodev,noexec,relatime                                                                        /sys                                       sys             sysfs        rw,nosuid,nodev,noexec,relatime                                                                        /sys/firmware/efi/efivars                  efivarfs        efivarfs     rw,nosuid,nodev,noexec,relatime                                                                        /sys/kernel/security                       securityfs      securityfs   rw,nosuid,nodev,noexec,relatime                                                                        /sys/fs/cgroup                             cgroup2         cgroup2      rw,nosuid,nodev,noexec,relatime,nsdelegate,memory_recursiveprot                                        /sys/fs/pstore                             pstore          pstore       rw,nosuid,nodev,noexec,relatime                                                                        /sys/fs/bpf                                bpf             bpf          rw,nosuid,nodev,noexec,relatime,mode=700                                                               /sys/kernel/tracing                        tracefs         tracefs      rw,nosuid,nodev,noexec,relatime                                                                        /sys/kernel/debug                          debugfs         debugfs      rw,nosuid,nodev,noexec,relatime                                                                        /sys/fs/fuse/connections                   fusectl         fusectl      rw,nosuid,nodev,noexec,relatime                                                                        /sys/kernel/config                         configfs        configfs     rw,nosuid,nodev,noexec,relatime                                                                        /dev                                       dev             devtmpfs     rw,nosuid,relatime,size=8027368k,nr_inodes=2006842,mode=755,inode64                                    /dev/shm                                   tmpfs           tmpfs        rw,nosuid,nodev,inode64                                                                                /dev/pts                                   devpts          devpts       rw,nosuid,noexec,relatime,gid=5,mode=620,ptmxmode=000                                                  /dev/hugepages                             hugetlbfs       hugetlbfs    rw,nosuid,nodev,relatime,pagesize=2M                                                                   /dev/mqueue                                mqueue          mqueue       rw,nosuid,nodev,noexec,relatime                                                                        /run                                       run             tmpfs        rw,nosuid,nodev,relatime,mode=755,inode64                                                              /run/credentials/systemd-journald.service  tmpfs           tmpfs        ro,nosuid,nodev,noexec,relatime,nosymfollow,size=1024k,nr_inodes=1024,mode=700,inode64,noswap          /run/user/1000                             tmpfs           tmpfs        rw,nosuid,nodev,relatime,size=1612004k,nr_inodes=403001,mode=700,uid=1000,gid=1000,inode64             /run/user/1000/doc                         portal          fuse.portal  rw,nosuid,nodev,relatime,user_id=1000,group_id=1000                                                    /tmp                                       tmpfs           tmpfs        rw,nosuid,nodev,nr_inodes=1048576,inode64                                                              /boot                                      /dev/nvme0n1p6  vfat         rw,relatime,fmask=0022,dmask=0022,codepage=437,iocharset=ascii,shortname=mixed,utf8,errors=remount-ro

Potentialfix#23

@cakebaker
Copy link
Contributor

Can you please runcargo clippy? The CI shows some clippy errors. Plus the test fails on macOS because there's no/proc on macOS as far as I know.

@Harshit933Harshit933force-pushed thefindmnt branch 2 times, most recently from01071f2 to2977baaCompareFebruary 8, 2025 06:39
@Harshit933
Copy link
ContributorAuthor

Harshit933 commentedFeb 8, 2025
edited
Loading

Plus the test fails on macOS because there's no/proc on macOS as far as I know.

Yup. I guess that is the case. I'll feature gate this on linux only

error: test failed, to rerun pass `--test tests`run: /Users/runner/work/util-linux/util-linux/target/debug/util-linux findmntthread 'test_findmnt::test_findmnt' panicked at tests/by-util/test_findmnt.rs:5:17:Command was expected to succeed. Exit code: 101.stdout =  stderr = thread 'main' panicked at src/uu/findmnt/src/findmnt.rs:43:54:called `Result::unwrap()` on an `Err` value: Os { code: 2, kind: NotFound, message: "No such file or directory" }note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace

@sylvestre
Copy link
Contributor

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

@Harshit933
Copy link
ContributorAuthor

@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.

@cakebakercakebaker mentioned this pull requestFeb 16, 2025
path = "src/main.rs"

[dependencies]
tabled = { workspace = true }
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

We recently removedtabled and so this will no longer work. And as the output currently looks quite different from the output of the originalfindmnt, I think it is probably easier to do the output manually than trying to figure out how to do it withtabled.

Harshit933 and xbjfk reacted with thumbs up emoji
Copy link
Contributor

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 afindmnt implementation as well before realizing you had this PR open, feel free to take the output code fromhere, that version doesn't usetabled.

Copy link
ContributorAuthor

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.

@sylvestresylvestre requested a review fromCopilotMarch 8, 2025 12:42
Copy link

@CopilotCopilotAI left a 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

FileDescription
src/uu/findmnt/Cargo.tomlNew package manifest for the findmnt utility
src/uu/findmnt/src/findmnt.rsCore implementation including parsing and table formatting
src/uu/findmnt/src/main.rsCLI entry point for findmnt
src/uu/findmnt/findmnt.mdDocumentation for findmnt
tests/by-util/test_findmnt.rsTest validating the findmnt output on Linux
Cargo.tomlWorkspace dependencies updated to include findmnt
tests/tests.rsIntegration of findmnt tests into the overall test suite

Copilot reviewed 8 out of 8 changed files in this pull request and generated 2 comments.

Comment on lines +42 to +43
pub fn form_nodes(&mut self) {
let res = fs::read_to_string(self.file_name).unwrap();
Copy link
Preview

CopilotAIMar 8, 2025

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.

Suggested change
pubfn form_nodes(&mutself){
let res = fs::read_to_string(self.file_name).unwrap();
pubfn form_nodes(&mutself)->Result<(),Box<dyn std::error::Error>>{
let res = fs::read_to_string(self.file_name)?;

Copilot uses AI. Check for mistakes.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

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() {
Copy link
Preview

CopilotAIMar 8, 2025

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 uses AI. Check for mistakes.

Copy link
Contributor

@xbjfkxbjfkApr 20, 2025
edited
Loading

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

Copilot is correct here - I have aro mounted partition and I'm unable to see it.This document specifies the exact format of the file.

Copy link
Contributor

@xbjfkxbjfk left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

Not a maintainer of uutils, so take this with a grain of salt, but will add my two cents.

Comment on lines +42 to +43
pub fn form_nodes(&mut self) {
let res = fs::read_to_string(self.file_name).unwrap();
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

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() {
Copy link
Contributor

@xbjfkxbjfkApr 20, 2025
edited
Loading

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

Copilot is correct here - I have aro mounted partition and I'm unable to see it.This document specifies the exact format of the file.

@@ -41,6 +41,7 @@ feat_common_core = [
"renice",
"rev",
"setsid",
"findmnt",
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

This should be in alphabetical order :)

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

Maybe the project should consider addingcargo sort to the CI.

@@ -94,6 +95,7 @@ mountpoint = { optional = true, version = "0.0.1", package = "uu_mountpoint", pa
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" }
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

also should be alphabetical

@xbjfk
Copy link
Contributor

xbjfk commentedApr 20, 2025
edited
Loading

there might be crate or equivalent for mac/unix. Maybe have a look before making this linux specific

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.

@Harshit933
Copy link
ContributorAuthor

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.

Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment
Reviewers

@cakebakercakebakercakebaker left review comments

@M1chaM1chaM1cha left review comments

@alxndrvalxndrvalxndrv left review comments

Copilot code reviewCopilotCopilot left review comments

@xbjfkxbjfkxbjfk requested changes

Assignees
No one assigned
Labels
None yet
Projects
None yet
Milestone
No milestone
Development

Successfully merging this pull request may close these issues.

Implement programfindmnt
6 participants
@Harshit933@cakebaker@sylvestre@xbjfk@M1cha@alxndrv

[8]ページ先頭

©2009-2025 Movatter.jp