Repository navigation
Conversation
There was a problem hiding this comment.
Copilot was unable to review this pull request because the user who requested the review has insufficient remaining quota. Try requesting a review at a lower effort level.
An organization owner can choose the repository organization as the billing source for reviews requested by members with a paid Copilot license. Learn about Copilot code review billing. Review the Copilot code review billing settings.
| /// topmost (last) mountinfo entry for the path, which can differ from the | ||
| /// path's `st_dev`, for example for a bind-mounted file. | ||
| #[cfg(target_os = "linux")] | ||
| fn fs_devno(path: &str) -> std::io::Result<Option<String>> { |
There was a problem hiding this comment.
this is almost the same code as is_mountpoint (mountinfo scan + by-device fallback)
could is_mountpoint just be fs_devno(path).map(|d| d.is_some()), no?
| #[cfg(not(windows))] | ||
| fn format_devno(dev: u64) -> String { | ||
| // dev_t is narrower than u64 on some platforms, such as macOS | ||
| #[allow(clippy::unnecessary_cast)] |
There was a problem hiding this comment.
could we avoid the #[allow]? e.g. libc::dev_t::try_from(dev) or take a libc::dev_t directly
The usage line of
mountpointlists-dand-x, but neither was implemented:This adds them, following util-linux 2.41.3:
-d/--fs-devno PATHprints themajor:minordevice number of the filesystem mounted on PATH. Like util-linux, it is taken from the topmost (last)/proc/self/mountinfoentry for the path rather than fromst_dev. The two differ for a bind-mounted file such as WSL's/mnt/wslg/versions.txt(0:42in mountinfo,0:44fromstat). Without/proc, it falls back tost_devwith the existing device check. A path that is not a mount point gives the usual message and exit status 32.-x/--devno DEVICEprints themajor:minorof a block device, and otherwise fails withPATH: not a block deviceand exit status 32. Like util-linux,-xwins when both are given.On my machine,
-dprints the same output and exit status as util-linux for all 37 mount points in mountinfo (including two stacked ones), and-xmatches for/dev/sda,/dev/sdb,/,/dev/nulland a missing path.major/minorcome fromlibc, which is now a unix dependency ofuu_mountpoint.The 3 new tests in
tests/by-util/test_mountpoint.rsfail onmainand pass with this change.cargo fmtandcargo clippy --all-targets -- -D warningsare clean. This touches the same function as #725 (-q). Whichever is merged second will need a small rebase, which I'll do.I used Claude Code (Opus 5.5) to help investigate and draft this change; I reproduced the bug and checked the fix myself.