#!/usr/bin/perl -w
#
# Create list of POSSIBLE temp disks for AIM7 usage.

`rm -f fstab.aim`;

foreach (`df; cat /etc/fstab`) {
	next if /Filesystem/;
	next if !/^\//;
	s/\// /g;
	@f = split;
	$name = $f[1];
	$inuse{$name} = 1;
	$name =~ s/\d//g;
	$inuse{$name} = 2;
}

$dnum = 0;
open FH, ">fstab.aim" or die;
foreach (`ls -l /dev/disk/by-id`) {
	chomp;
	next if /^total/;
	s/\// /g;
	@f = split;
	$name = $f[@f - 1];
	print "SKIP $name\n" if $inuse{$name};
	next if $inuse{$name};
	print FH "/dev/$name /aimtmp/tmp$dnum\n";
	$dnum++;
}
close FH;

__DATA__
j=1
for i in $SLICES ; do
        echo /dev/$i /aim_mounts/tmp$j >> fstab.aim
        if [ ! -d /aim_mounts/tmp$j ] ; then
                mkdir -p /aim_mounts/tmp$j
        fi
        ((j++))
done
