$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;
}
$path->mount_pointwould return the mount point of the filesystem containing the path. It is the path given bydf -P $pathin the "Mounted on" field. Here is a simple implementation: