]> andersk Git - moira.git/commitdiff
Deal with entries in the nfsphys table having allocations bigger than
authorzacheiss <zacheiss>
Tue, 20 Sep 2005 22:03:18 +0000 (22:03 +0000)
committerzacheiss <zacheiss>
Tue, 20 Sep 2005 22:03:18 +0000 (22:03 +0000)
will fit in an unsigned int.

Don't call cleanup() if we're running as MODE_NO.

dbck/dbck.h
dbck/dbck.pc
dbck/phase1.pc
dbck/phase4.pc

index a7ac2e01cd5415a53108b8047db713403b69146e..6888e3bb38236c60b80239f64e245b44d3704a86 100644 (file)
@@ -99,9 +99,9 @@ struct nfsphys {
   char dir[NFSPHYS_DIR_SIZE];
   int mach_id;
   int nfsphys_id;
-  int allocated;
+  unsigned long long allocated;
   int modby;
-  int count;
+  unsigned long long count;
 };
 
 struct printserver {
index 10e44e93882cc768ddfde53650ee43eaeb114269..9bcabd7d8c4c68b104a78bf5f0545079351dcab6 100644 (file)
@@ -130,7 +130,8 @@ int main(int argc, char **argv)
   phase4();
   EXEC SQL COMMIT WORK;
 
-  cleanup();
+  if (mode != MODE_NO)
+    cleanup();
   printf("Done.\n");
   exit(0);
 }
index e49fbcf1c8e44c749171bd726606bc13abb2dff2..0b35abbd2df62531894b4696a93942f3b07e2c79 100644 (file)
@@ -849,13 +849,14 @@ void phase1(void)
     out_of_mem("loading nfsphs");
 
   EXEC SQL DECLARE csr111 CURSOR FOR
-    SELECT nfsphys_id, dir, mach_id, allocated, modby FROM nfsphys;
+    SELECT nfsphys_id, dir, mach_id, TO_CHAR(allocated), modby FROM nfsphys;
   EXEC SQL OPEN csr111;
   while (1)
     {
       EXEC SQL BEGIN DECLARE SECTION;
-      int nfsphys_id, mach_id, allocated, modby;
+      int nfsphys_id, mach_id, modby;
       char dir[NFSPHYS_DIR_SIZE];
+      char allocated[39];
       EXEC SQL END DECLARE SECTION;
 
       EXEC SQL FETCH csr111 INTO :nfsphys_id, :dir, :mach_id,
@@ -869,7 +870,7 @@ void phase1(void)
       strcpy(n->dir, strtrim(dir));
       n->mach_id = mach_id;
       n->nfsphys_id = nfsphys_id;
-      n->allocated = allocated;
+      n->allocated = strtoull(allocated, NULL, 0);
       n->modby = modby;
       n->count = 0;
       retval = hash_store(nfsphys, nfsphys_id, n);
index 052f5c28066a2164aa6696050a908634e9edad3e..eb8f3d21d7b68a6dffac1e8d2d662de800cd4af2 100644 (file)
@@ -77,18 +77,21 @@ void check_nfs_counts(int id, void *nfsphys, void *hint)
 {
   struct nfsphys *n = nfsphys;
   EXEC SQL BEGIN DECLARE SECTION;
-  int iid = id, val, rowcount;
+  int iid = id, rowcount;
+  unsigned long long val;
+  char valstr[40] = {0}, *endptr = valstr+39;
   EXEC SQL END DECLARE SECTION;
 
   val = n->count;
   if (n->allocated != val)
     {
-      printf("Count wrong on NFSphys %s:%s; is %d in db, counted %d\n",
+      printf("Count wrong on NFSphys %s:%s; is %lld in db, counted %lld\n",
             ((struct machine *) hash_lookup(machines, n->mach_id))->name,
             n->dir, n->allocated, val);
       if (single_fix("Update", 1))
        {
-         EXEC SQL UPDATE nfsphys SET allocated = :val
+         strcpy(valstr, ulltostr(val, endptr));
+         EXEC SQL UPDATE nfsphys SET allocated = TO_NUMBER(:valstr)
            WHERE nfsphys_id = :iid;
          rowcount = sqlca.sqlerrd[2];
          if (rowcount > 0)
This page took 0.047214 seconds and 5 git commands to generate.