Beefy Boxes and Bandwidth Generously Provided by pair Networks
P is for Practical
 
PerlMonks  

filesystem type

by vikee (Sexton)
on Jun 21, 2004 at 15:34 UTC ( #368477=perlquestion: print w/replies, xml ) Need Help??

vikee has asked for the wisdom of the Perl Monks concerning the following question:

hello, how can i get the type of the filesystem?
on both unix and win. 
like fat32, ntfs, ext2,3, mvfs...

Replies are listed 'Best First'.
Re: filesystem type
by Tomte (Priest) on Jun 21, 2004 at 15:57 UTC

    On windows: Win32::FsType(), on unix parse the output of mount -n, under linux

    my @result = (); foreach (split("\n",`mount -n`)) { push @result, (split)[0,4]; } my %result = @result;
    will put the filesystem as value of the key "mountpoint" in the hash %result;

    regards,
    tomte


    An intellectual is someone whose mind watches itself.
    -- Albert Camus

      mount -n will know only about supported filessytems, you can try file -s /dev/device,
      pokurcz:# file -s /dev/hda1 /dev/hda1: Linux rev 1.0 ext2 filesystem data (mounted or unclean) pokurcz:# file -s /dev/hda2 /dev/hda2: Linux/i386 swap file (new style) 1 (4K pages) size 124502 p +ages
Re: filesystem type
by rinceWind (Monsignor) on Jun 21, 2004 at 16:40 UTC
    Maybe there's a case for a module here. One that will do the right thing on each platform.

    How about:

    use File::System qw(fstype); ... my $fstype = fstype($filnam);
    Maybe it could do other things, like capacity, freespace.

    --
    I'm Not Just Another Perl Hacker

      hello
      error : can't locate System....
      
Re: filesystem type
by arthas (Hermit) on Jun 21, 2004 at 15:47 UTC

    Hi!

    On Unix you can parse the output of df. I'm unsure about Windows - I don't use it - but I think chkdsk shows you the filesystem type of mounted disks, so you can parse that.

    Hope this helps.

    Michele.

      chkdsk no cause it starts to check the HDD...

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: perlquestion [id://368477]
Approved by rinceWind
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others exploiting the Monastery: (6)
As of 2022-10-07 10:16 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    My preferred way to holiday/vacation is:











    Results (29 votes). Check out past polls.

    Notices?