vldb_check: cope with broken names and volids
authorMichael Meffie <mmeffie@sinenomine.net>
Mon, 13 May 2013 17:47:06 +0000 (13:47 -0400)
committerDerrick Brashear <shadow@your-file-system.com>
Tue, 21 May 2013 21:25:27 +0000 (14:25 -0700)
Fix-up broken vlentry names and rw volid so entries can be looked
up in the vlserver and can be deleted with vos delentry if needed.

Change-Id: Ide4855b0ef149977b04e3f0b5c966b13dd1cf417
Reviewed-on: http://gerrit.openafs.org/9905
Tested-by: BuildBot <buildbot@rampaginggeek.com>
Reviewed-by: Derrick Brashear <shadow@your-file-system.com>

src/vlserver/vldb_check.c

index d944f49..773fdcc 100644 (file)
@@ -226,6 +226,8 @@ InvalidVolname(char *volname)
     slen = strlen(volname);
     if (slen >= VL_MAXNAMELEN)
        return 1;
+    if (slen == 0)
+       return 1;
     return (slen != strspn(volname, map));
 }
 
@@ -1447,6 +1449,21 @@ WorkerBee(struct cmd_syndesc *as, void *arock)
                char newNameBuffer[10 + VL_MAXNAMELEN];
                char *oldname, *newname;
 
+               /* Fix broken names and numbers so entries can be inspected and deleted. */
+               if (InvalidVolname(vlentry.name)) {
+                   char bogus[VL_MAXNAMELEN];
+                   memset(bogus, 0, sizeof(bogus));
+                   snprintf(bogus, sizeof(bogus)-1, ".bogus.%ld", record[i].addr);
+                   strcpy(vlentry.name, bogus);
+                   quiet_println("FIX: Record %ld invalid volume name set to '%s'\n", record[i].addr, bogus);
+               }
+               if (vlentry.volumeId[0] == 0) {
+                   afs_uint32 next_volid = header.vital_header.MaxVolumeId++;
+                   vlentry.volumeId[0] = next_volid;
+                   quiet_println("FIX: Record %ld invalid volume id set to %ld. New max volid is %ld\n",
+                       record[i].addr, next_volid, header.vital_header.MaxVolumeId);
+               }
+
                /*
                 * Put the current hash table contexts into our 'next'
                 * and our address into the hash table.