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