Under Unix-like systems, sometimes checking the device field returned by lstat() will work. For instance, here's the wanted() routine generated by find2perl / -xdev:
use File::Find;
File::Find::find({wanted => \&wanted}, '/');
exit;
sub wanted {
my ($dev,$ino,$mode,$nlink,$uid,$gid);
(($dev,$ino,$mode,$nlink,$uid,$gid) = lstat($_)) &&
!($File::Find::prune |= ($dev != $File::Find::topdev))
&& print("$name\n");
}
$File::Find::topdev is simply the device associated with the root directory /:
($File::Find::topdev) = lstat("/");
|