]> andersk Git - moira.git/blobdiff - incremental/afs_utils.pl
Document new blanche exit status semantics. (Don't claim success
[moira.git] / incremental / afs_utils.pl
index c5e5415215811eecc5ad7b39dbcf216b32224839..bdd5a2d2f4753930aa3385a6cba9f93ac05dbdb8 100644 (file)
@@ -1,16 +1,18 @@
 # $Header$
 
+# kludge kludge kludge
+sub __STDC__ {0;}
+require "fcntl.ph";
+
 $afsbin="/moira/bin";
 $vos="$afsbin/vos";
 $pts="$afsbin/pts";
 $fs="$afsbin/fs";
+$zwrite="/usr/athena/bin/zwrite";
 
 $afs_data="/moira/afs/afs_data";
 $afs_save="$afs_data.tmp";
 
-$LOCK_EX=2;
-$LOCK_UN=8;
-
 %vtypes_ATHENA_MIT_EDU =
     ("ACTIVITY", "activity",
      "APROJ", "aproj",
@@ -41,11 +43,17 @@ $LOCK_UN=8;
 # 8. Close the data file.
 
 
+$flock_t="ssllllllll";
+
 sub afs_lock
 {
     open(SRV,"+<$afs_data") || die "Unable to open $afs_data\n";
     select((select(SRV), $|=1)[$[]);
-    flock(SRV, $LOCK_EX) || die "Unable to lock $afs_data\n";
+    $flkarr[0]=&F_WRLCK;
+    $flkarr[1]=$flkarr[2]=$flkarr[3]=$flkarr[4]=$flkarr[5]=$flkarr[6]=0;
+    $flkarr[7]=$flkarr[8]=$flkarr[9]=0;
+    $flk=pack($flock_t,@flkarr);
+    fcntl(SRV, &F_SETLKW, $flk) || die "Unable to lock $afs_data:$!\n";
     die "Temporary status file: $afs_save exists... aborting\n"
        if (-f $afs_save);
     open(SRV2, ">$afs_save");
@@ -67,8 +75,8 @@ sub afs_unlock
 #    max[ (2*free space) - (unused quota) ]
 #    = max(2*total - usage - alloc)
 #
-# Note: This routine does not actually adjust the quota; the caller
-# should use afs_quota_adj();
+# Note: This routine does not actually adjust the quota;
+# the calling routine should use afs_quota_adj();
 
 sub afs_find
 {
@@ -100,7 +108,7 @@ sub afs_find
 #
 sub afs_quota_adj
 {
-    local($cell,$asrv,$apart,$adj) = @_;
+    local($cell,$asrv,$apart,$adj,$dusage) = @_;
     local($found) = 0;
 
     &afs_lock;
@@ -109,8 +117,9 @@ sub afs_quota_adj
     for (@afs_data) {
        local ($c, $as, $ap, $t, $total, $used, $alloc) = split(/\s+/,$_);
        if ($c eq $cell && $as eq $asrv && $ap eq $apart) {
+           $dusage = $used unless ($dusage);
            $alloc += $adj;
-           $_ = join(' ',$c,$asrv,$apart,$t,$total,$used,$alloc);
+           $_ = join(' ',$c,$asrv,$apart,$t,$total,$dusage,$alloc);
            $found = 1;
        }
        print SRV "$_\n";
This page took 0.03431 seconds and 4 git commands to generate.