7 $zwrite="/usr/athena/bin/zwrite"
9 $afs_data="/moira/afs/afs_data";
10 $afs_save="$afs_data.tmp";
15 %vtypes_ATHENA_MIT_EDU =
16 ("ACTIVITY", "activity",
32 # cell server partition total used alloc
34 # Locking/re-write algorithm:
35 # 1. Open the data file.
36 # 2. Obtain a lock on the data file.
37 # 3. Check for the existence of a temporary data file - die if it exists.
38 # 4. Save current contents into temporary data file.
39 # 5. Re-write output (with line-buffering).
40 # 6. Unlink temporary file.
41 # 7. Unlock data file.
42 # 8. Close the data file.
47 open(SRV,"+<$afs_data") || die "Unable to open $afs_data\n";
48 select((select(SRV), $|=1)[$[]);
49 flock(SRV, $LOCK_EX) || die "Unable to lock $afs_data\n";
50 die "Temporary status file: $afs_save exists... aborting\n"
52 open(SRV2, ">$afs_save");
65 # Find server/partition for allocation.
67 # Best fit algorithm used:
68 # max[ (2*free space) - (unused quota) ]
69 # = max(2*total - usage - alloc)
71 # Note: This routine does not actually adjust the quota; the caller
72 # should use afs_quota_adj();
76 local($cell,$type,$quota,@except) = @_;
78 local(@max) = ("", "", -10000000);
85 local ($a, $asrv, $apart, $t, $total, $used, $alloc) = split(/\s+/,$_);
86 next if ($a ne $cell || !$total || $type !~ /$t/);
88 next sloop if ($j eq $asrv);
90 $alloc = $used if ($alloc < $used);
91 $j = 2*$total - $used - $alloc;
92 @max = ($asrv,$apart,$j) if (! @max || $j > $max[2]);
104 local($cell,$asrv,$apart,$adj) = @_;
111 local ($c, $as, $ap, $t, $total, $used, $alloc) = split(/\s+/,$_);
112 if ($c eq $cell && $as eq $asrv && $ap eq $apart) {
114 $_ = join(' ',$c,$asrv,$apart,$t,$total,$used,$alloc);