For a regular file st_rdev is 0, for a device file (e.g. /dev/tty) it holds the major and minor device numbers (assuming a POSIX like system) which can derived by masking and shifting appropriately. You can see how this is done in the source of File::Stat::Bits. The following is derived from that module:

my $tty_rdev = (stat('/dev/dsp0'))[6]; print major($tty_rdev), " ", minor($tty_rdev),"\n"; sub MAJOR_MASK () { 03777400 } sub MAJOR_SHIFT () { 0000010 } sub MINOR_MASK () { 037774000377 } sub MINOR_SHIFT () { 0000000 } sub major { my $dev = shift; return defined MAJOR_MASK ? ($dev & MAJOR_MASK) >> MAJOR_SHIFT : u +ndef; } sub minor { my $dev = shift; return defined MINOR_MASK ? ($dev & MINOR_MASK) >> MINOR_SHIFT : u +ndef; }
If you want to recreate the st_rdev from the output of the stat command you want to get the values for the major and minor device type and combine them using the dev_join from File::Stat::Bits.

I'm not clear however why you want to use the external command rather than the builtin stat.

/J\


In reply to Re: Meaning of stat's 'rdev' value. by gellyfish
in thread Meaning of stat's 'rdev' value. by palamedes

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.