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

--
Today I will gladly share my knowledge and experience, for there are no sweeter words than "I told you so". ;-)

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

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.