1 #!/afs/athena/contrib/perl/perl
2 # Usage: afs_quota path quota
4 $incdir = "/mit/moiradev/src/incremental";
5 require "$incdir/afs_utils.pl";
7 die "Usage: $0 path quota\n" unless (@ARGV==2);
10 $path =~ s:^/afs/([^.]):/afs/.\1:;
12 system("$fs checkb >/dev/null");
14 open(PROG,"$fs lv $path|");
17 die "Unable to get information about $path\n" if ($?);
19 @tmp = split(/\s+/, shift(@fs));
21 @tmp = split(/\s+/, shift(@fs));
24 open(PROG,"$fs whichcell $path|");
27 die "Unable to get information about $path\n" if ($?);
30 ($cell=pop(@tmp)) =~ s/^'(.*)'$/\1/;
33 open(PROG,"$vos ex $vname -cell $cell|");
36 die "Unable to get volume information about $vname ($path)\n" if ($?);
39 ($vusage, $vusage, $vusage, $vusage) = split(/\s+/,$_);
41 ($asrv,$asrv,$apart) = split(/\s+/,$_);
43 open(PROG,"$vos partinfo $asrv $apart -cell $cell|");
46 die "Unable to get partition information about $asrv $apart\n" if ($?);
48 @tmp = split(/\s+/,$_);
50 $dusage = $dtotal - $tmp[5];
52 system("$fs","sq",$path,$newq);
53 die "Unable to change quota on $path\n" if ($?);
55 &afs_quota_adj($cell,$asrv,$apart,$newq-$oldq);
57 if ($dusage > (0.9 * $dtotal)) {
58 system("$zwrite","-q","-n","-c","afsadm","-m",
59 "WARNING: Disk usage on $asrv:$apart is greater than 90%
60 Used $dusage K out of $dtotal K");
62 elsif (($dusage + ($newq-$vusage)) > (0.9 * $dtotal)) {
63 system("$zwrite","-q","-n","-c","afsadm","-m",
64 "Quota change on volume $vname, if used completely will cause
65 $asrv:$apart to be over 90% used.
67 Current volume usage: $vusage, old quota $oldq, new quota $newq");
69 elsif ($newq-$oldq > 39999) {
70 system("$zwrite","-q","-n","-c","afsadm","-m",
71 "Increased quota on volume $vname ($asrv:$apart) from $oldq to $newq");
75 #$stat_qa = &afs_quota_adj($cell,$asrv,$apart,($stat_fs ? 0 : $newq-$oldq));
76 #die "Unable to change quota on $path\n" if ($stat_fs && $stat_qa);
77 #warn "Unable to change quota on $path\n" if ($stat_fs);