G'day Rick,

As far as I can tell, Sys::Filesystem does not report what fstab file it uses. It relies on the various Sys::Filesystem::<OS> modules, e.g. Sys::Filesystem::AIX, for the filesystem information. See the "Sys-Filesystem distro page" for a list of those modules.

If you simply want to perform some upfront sanity checks, perhaps code similar to the following might suffice.

#!/usr/bin/env perl use 5.010; use strict; use warnings; use Sys::Filesystem (); if (Sys::Filesystem::->supported()) { my $fs = Sys::Filesystem::->new(); say '$Sys::Filesystem::FSTAB: ', $Sys::Filesystem::FSTAB // 'undefined'; say '$fs->{fstab}: ', $fs->{fstab} // 'undefined'; say "O/S '$^O' supported."; say 'Using: ', ref($fs->{filesystems}); my @fs_list = $fs->filesystems(); if (@fs_list) { say 'Filesystems found:'; say "\t$_" for @fs_list; } else { warn "No filesystems found.\n"; } use Data::Dump; say '=' x 60; say 'Sys::Filesystem Object:'; say '=' x 60; dd $fs; say '-' x 60; } else { warn "O/S '$^O' not supported.\n"; }

I've included code to produce a lot of additional information which you may find interesting, but probably isn't wanted in production.

I'm strongly against breaking encapsulation and urge you to stick with the published API. I only included $fs->{fstab} and $fs->{filesystems} for demonstration purposes.

I don't have any of the four OSes you list available at home. Here's the output on my Cygwin system.

$Sys::Filesystem::FSTAB: undefined $fs->{fstab}: undefined O/S 'cygwin' supported. Using: Sys::Filesystem::Cygwin Filesystems found: / /cygdrive/c /cygdrive/d /usr/bin /usr/lib ============================================================ Sys::Filesystem Object: ============================================================ bless({ aliases => { boot_order => ["fs_mntno"], check_frequency => ["fs_freq"], check_order => ["fs_passno"], device => ["fs_spec", "dev"], filesystem => ["fs_file", "mount_point"], format => ["fs_vfstype", "vfs", "vfstype"] +, label => ["fs_label"], mount_point => ["fs_file", "filesystem"], options => ["fs_mntops"], type => ["fs_vfstype", "vfs"], volume => ["fs_volume", "fs_vol", "vol"], }, canondev => undef, filesystems => bless({ "/" => { device => "C:/cygwin64", fs_file => "/", fs_mntops => "binary,auto", fs_spec => "C:/cygwin64", fs_vfstype => "ntfs", mount_point => "/", mounted => 1, }, "/cygdrive/c" => { device => "C:", fs_file => "/cygdrive/c", fs_mntops => "binary,posix=0,user,noumount,auto +", fs_spec => "C:", fs_vfstype => "ntfs", mount_point => "/cygdrive/c", mounted => 1, }, "/cygdrive/d" => { device => "D:", fs_file => "/cygdrive/d", fs_mntops => "binary,posix=0,user,noumount,auto +", fs_spec => "D:", fs_vfstype => "ntfs", mount_point => "/cygdrive/d", mounted => 1, }, "/usr/bin" => { device => "C:/cygwin64/bin", fs_file => "/usr/bin", fs_mntops => "binary,auto", fs_spec => "C:/cygwin64/bin", fs_vfstype => "ntfs", mount_point => "/usr/bin", mounted => 1, }, "/usr/lib" => { device => "C:/cygwin64/lib", fs_file => "/usr/lib", fs_mntops => "binary,auto", fs_spec => "C:/cygwin64/lib", fs_vfstype => "ntfs", mount_point => "/usr/lib", mounted => 1, }, }, "Sys::Filesystem::Cygwin"), fstab => undef, mtab => undef, }, "Sys::Filesystem") ------------------------------------------------------------

— Ken


In reply to Re: Dynamically determinig fstab file name by kcott
in thread Dynamically determinig fstab file name by rgren925

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.