#!/usr/bin/perl use strict; use warnings; my $mountlist = `mount`; my %mounts; $mounts{$2} = $1 while($mountlist =~ /(.*) on (.*) type.*\n/g); my $location = `pwd`; chomp $location; my $mount_dir = $location; $mount_dir =~ s#/[^/]*$## while $mount_dir && !$mounts{$mount_dir}; $mount_dir ||= '/'; # Add the 'trailing' slash back in if we're mounted as root print "Directory $location is on device $mounts{$mount_dir}\n";