On Unix (but not on Windows), lstat and stat on the directories can help.
(Actually, this works for every file, but df only looks at mountpoints, i.e. directories.)
#!/usr/bin/perl use strict; use warnings; for my $d (qw( / /bin /sbin /lib /usr /usr/bin /usr/sbin /usr/lib /pro +c /sys /run /tmp /var/run /var/tmp )) { print "$d: on device ",(lstat($d))[0]; if (-l $d) { print " (symlink to ",readlink($d),")"; } print "\n"; }
Running that on a recent debian in a VM shows:
$ perl lstat.pl /: on device 1795 /bin: on device 1795 (symlink to usr/bin) /sbin: on device 1795 (symlink to usr/sbin) /lib: on device 1795 (symlink to usr/lib) /usr: on device 1795 /usr/bin: on device 1795 /usr/sbin: on device 1795 /usr/lib: on device 1795 /proc: on device 99 /sys: on device 100 /run: on device 105 /tmp: on device 1795 /var/run: on device 1795 (symlink to /run) /var/tmp: on device 1795 $
Most stuff is on device 1795, the root filesystem of this VM. /proc is a completely different device (that of the virtual proc filesystem), and so are /run (105) and /sys (100). /var/run is a symlink stored on device 1795 (root filesystem), it points to /run, which is on device 105.
Due to the way symlinks work, everything that appears to be in /var/run/ is really in /run.
Changing lstat() to stat() allows the system to follow symlinks instead of working on them:
#!/usr/bin/perl use strict; use warnings; for my $d (qw( / /bin /sbin /lib /usr /usr/bin /usr/sbin /usr/lib /pro +c /sys /run /tmp /var/run /var/tmp )) { print "$d: on device ",(stat($d))[0]; if (-l $d) { print " (followed symlink to ",readlink($d),")"; } print "\n"; }
$ perl stat.pl /: on device 1795 /bin: on device 1795 (followed symlink to usr/bin) /sbin: on device 1795 (followed symlink to usr/sbin) /lib: on device 1795 (followed symlink to usr/lib) /usr: on device 1795 /usr/bin: on device 1795 /usr/sbin: on device 1795 /usr/lib: on device 1795 /proc: on device 99 /sys: on device 100 /run: on device 105 /tmp: on device 1795 /var/run: on device 105 (followed symlink to /run) /var/tmp: on device 1795 $
Alexander
In reply to Re^2: An anomaly with Filesys::DfPortable, I need your eyes
by afoken
in thread An anomaly with Filesys::DfPortable, I need your eyes
by Intrepid
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |