From ad8b40dc80bb5196bcda61858efc1a817ab4b9d1 Mon Sep 17 00:00:00 2001 From: Michael Meffie Date: Mon, 13 May 2013 13:47:06 -0400 Subject: [PATCH] vldb_check: cope with broken names and volids 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. Reviewed-on: http://gerrit.openafs.org/9905 Tested-by: BuildBot Reviewed-by: Derrick Brashear (cherry picked from commit 7a89c4f94440ac1c8ebf16107ece3b56c178ffc9) Change-Id: I2cf2d711f6dee08b2d27429ff4d37290bc21b9a2 Reviewed-on: http://gerrit.openafs.org/10268 Tested-by: BuildBot Reviewed-by: Derrick Brashear Reviewed-by: Jeffrey Altman Reviewed-by: Stephan Wiesand --- src/vlserver/vldb_check.c | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/src/vlserver/vldb_check.c b/src/vlserver/vldb_check.c index 64b1ca7785..4afc7f7f0a 100644 --- a/src/vlserver/vldb_check.c +++ b/src/vlserver/vldb_check.c @@ -244,6 +244,8 @@ InvalidVolname(char *volname) slen = strlen(volname); if (slen >= VL_MAXNAMELEN) return 1; + if (slen == 0) + return 1; return (slen != strspn(volname, map)); } @@ -1521,6 +1523,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.