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