Skip to content

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

@Alxhr0

Description

@Alxhr0

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,
        }
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions