#!/usr/bin/perl -w

print <<"EOHEAD";
# This file has been automatically generated by update-wmmount
# PLEASE EDIT! See wmmount(1x) for details.

icon /usr/share/wmmount/cdrom.xpm
icon /usr/share/wmmount/floppy.xpm
icon /usr/share/wmmount/zip.xpm
icon /usr/share/wmmount/harddisk.xpm
EOHEAD
    ;

$, = ' ';		# set output field separator
$\ = "\n";		# set output record separator

my $FSTAB;
open (FSTAB, "< /etc/fstab") or die "Can't open /etc/fstab: $!";

line: while (<FSTAB>) {
    chop;

    next line if /^(\#|$)/;

    (my $filesystem, my $mountpoint, my $fstype, undef) = split;

    next line if (/^(\#|$)/ || $fstype =~ /(proc|swap)/);

    my $IconNumber = 3;
    my $DisplayType = 'Free';

    if ($filesystem =~ /fd/ || $mountpoint =~ /floppy/) {
        $IconNumber = 1;
        $DisplayType = 'Free';
    }

    if ($filesystem =~ /cdrom/ || $mountpoint =~ /cdrom/ || $fstype =~ /iso9660/) {
        $IconNumber = 0;
        $DisplayType = 'None';
    }

    if ($filesystem =~ /zip/ || $mountpoint =~ /zip/) {
        $IconNumber = 2;
        $DisplayType = 'Free';
    }

    if ($mountpoint =~ /^\/$/) {
        print "\nmountname ", ucfirst $ENV{'HOSTNAME'};
    } else {
        my @paths = split('/', $mountpoint);
        print "\nmountname ", $paths[$#paths];
    }
                  
    print "   mountpoint   ", $mountpoint;
    print "   iconnumber   ", $IconNumber;
    print "   usagedisplay ", $DisplayType;
}

close FSTAB;
