Skip to content

Feature request: $path->mount_point #323

Description

@grr

$path->mount_point would return the mount point of the filesystem containing the path. It is the path given by df -P $path in the "Mounted on" field. Here is a simple implementation:

sub mount_point {
    my $path = $_[0]->realpath;
    my $dev = $path->stat->[0];

    while (! $path->is_rootdir) {
        my $parent = $path->parent->realpath;
        return $path if $parent->stat->[0] != $dev;
        $path = $parent;
    }

    return Path::Tiny->rootdir;
}

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