Mountpoint reports non-mount point directories like /etc as mount points while it shouldn't

Open
#366 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Assessment

Difficulty
3/5
Estimated time
1-2 days
Newbie friendliness
50/100
Issue type
Bug
Clarity
Mostly clear
Activity status
Stale
Tech stack
rust

Research direction

Start from the mountpoint command's is_mountpoint function shown in the issue and reproduce the behavior with mountpoint /etc on the affected filesystem. Compare the result with GNU util-linux and verify that ordinary directories are reported as non-mount points while actual mount points remain recognized.

Written by the indexing model from the issue text.

Description

Version of uutils util-linux is master

Uutils version:

./target/release/util-linux mountpoint /etc
/etc is a mountpoint

Version of GNU util-linux is 2.40

GNU version:

mountpoint /etc
/etc is not a mountpoint

It seems to be getting confused on BTRFS? especially in the inode check since when I checked inode was 293 for /etc on my system

#[cfg(not(windows))]
fn is_mountpoint(path: &str) -> bool {
    let metadata = match fs::metadata(path) {
        Ok(metadata) => metadata,
        Err(_) => return false,
    };

    let dev = metadata.dev();
    let inode = metadata.ino();

    // Root inode (typically 2 in most Unix filesystems) indicates a mount point
    inode == 2
        || match fs::metadata("..") {
            Ok(parent_metadata) => parent_metadata.dev() != dev,
            Err(_) => false,
        }
}
Dominant language
Rust
Stars
219
Forks
59
Avg merge
4h 8m
Merged PRs (30d)
5

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from uutils/util-linux

All issues in uutils/util-linux

Similar issues

More Rust issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.