#!/usr/bin/perl -w

# Re-create the file system.

use Getopt::Long;
GetOptions qw(-b:i);

$dev = "da2s1e";
$mountpoint = "/fsys/swift/c";

# $dev = "dsk/c2t3d0s6";
# $mountpoint = "/fsys/swift/d";

sub docmd {
	my($cmd) = @_;
	my($rv);
	print "$cmd\n";
	print `$cmd`;
	$rv = ($? >> 8);
	if($rv > 0) {
		die "Non zero exit status ($rv, $?) from command: \n$cmd\n$!";
	}
}

if($opt_b < 1024) {
	die "Must specify block size option on command line: -b=32768 or -b=8192";
}

$block_size = $opt_b;
$frag_size = $block_size / 8;

print `umount /dev/$dev`;
docmd("echo y | newfs -b $block_size -f $frag_size /dev/r$dev");
docmd("mount /dev/$dev $mountpoint");
docmd("mkdir -p $mountpoint/alderman/bf");
docmd("chown -R alderman $mountpoint/alderman");

#for(0..9) {
#	$file = sprintf("file%4.4d");
#	docmd("/home/alderman/cs736proj/mkbigfile $mountpoint/files/$file");
#}


