2 * Copyright 2000, International Business Machines Corporation and others.
5 * This software has been released under the terms of the IBM Public
6 * License. For details, see the LICENSE file in the top-level source
7 * directory or online at http://www.openafs.org/dl/license10.html
10 #include <afsconfig.h>
11 #include <afs/param.h>
16 #include <WINNT/afsevent.h>
20 #include <afs/afsutil.h>
26 /* Read a VLDB file and verify it for correctness */
28 #define VL 0x001 /* good volume entry */
29 #define FR 0x002 /* free volume entry */
30 #define MH 0x004 /* multi-homed entry */
32 #define RWH 0x010 /* on rw hash chain */
33 #define ROH 0x020 /* on ro hash chain */
34 #define BKH 0x040 /* on bk hash chain */
35 #define NH 0x080 /* on name hash chain */
37 #define MHC 0x100 /* on multihomed chain */
38 #define FRC 0x200 /* on free chain */
40 #define REFRW 0x1000 /* linked from something (RW) */
41 #define REFRO 0x2000 /* linked from something (RO) */
42 #define REFBK 0x4000 /* linked from something (BK) */
43 #define REFN 0x8000 /* linked from something (name) */
45 #define MULTRW 0x10000 /* multiply-chained (RW) */
46 #define MULTRO 0x20000 /* multiply-chained (RO) */
47 #define MULTBK 0x40000 /* multiply-chained (BK) */
48 #define MULTN 0x80000 /* multiply-chained (name) */
50 #define MISRWH 0x100000 /* mischained (RW) */
51 #define MISROH 0x200000 /* mischained (RO) */
52 #define MISBKH 0x400000 /* mischained (BK) */
53 #define MISNH 0x800000 /* mischained (name) */
55 #define VLDB_CHECK_NO_VLDB_CHECK_ERROR 0
56 #define VLDB_CHECK_WARNING 1
57 #define VLDB_CHECK_ERROR 2
58 #define VLDB_CHECK_FATAL 4
59 #define vldbread(x,y,z) vldbio(x,y,z,0)
60 #define vldbwrite(x,y,z) vldbio(x,y,z,1)
62 #define ADDR(x) (x/sizeof(struct nvlentry))
65 int listentries, listservers, listheader, listuheader, verbose, quiet;
69 /* if quiet, don't send anything to stdout */
71 /* error level. 0 = no error, 1 = warning, 2 = error, 4 = fatal */
79 int serveraddrs[MAXSERVERID + 2];
80 u_char serverxref[MAXSERVERID + 2]; /**< to resolve cross-linked mh entries */
82 /* Used to control what goes to stdout based on quiet flag */
84 quiet_println(const char *fmt,...) {
88 vfprintf(stdout, fmt, args);
93 /* Used to set the error level and ship messages to stderr */
95 log_error(int eval, const char *fmt, ...)
98 if (error_level < eval) error_level = eval ; /* bump up the severity */
100 vfprintf(stderr, fmt, args);
103 if (error_level == VLDB_CHECK_FATAL) exit(VLDB_CHECK_FATAL);
112 struct ubik_hdr uheader;
114 offset = lseek(fd, 0, 0);
116 log_error(VLDB_CHECK_FATAL,"error: lseek to 0 failed: %d %d\n", offset, errno);
117 return (VLDB_CHECK_FATAL);
120 /* now read the info */
121 r = read(fd, &uheader, sizeof(uheader));
122 if (r != sizeof(uheader)) {
123 log_error(VLDB_CHECK_FATAL,"error: read of %lu bytes failed: %d %d\n", sizeof(uheader), r,
125 return (VLDB_CHECK_FATAL);
128 uheader.magic = ntohl(uheader.magic);
129 uheader.size = ntohs(uheader.size);
130 uheader.version.epoch = ntohl(uheader.version.epoch);
131 uheader.version.counter = ntohl(uheader.version.counter);
134 quiet_println("Ubik Header\n");
135 quiet_println(" Magic = 0x%x\n", uheader.magic);
136 quiet_println(" Size = %u\n", uheader.size);
137 quiet_println(" Version.epoch = %u\n", uheader.version.epoch);
138 quiet_println(" Version.counter = %u\n", uheader.version.counter);
141 if (uheader.size != HDRSIZE)
142 log_error(VLDB_CHECK_WARNING,"VLDB_CHECK_WARNING: Ubik header size is %u (should be %u)\n", uheader.size,
144 if (uheader.magic != UBIK_MAGIC)
145 log_error(VLDB_CHECK_ERROR,"Ubik header magic is 0x%x (should be 0x%x)\n", uheader.magic,
152 vldbio(int position, void *buffer, int size, int rdwr)
156 /* seek to the correct spot. skip ubik stuff */
157 p = position + HDRSIZE;
158 offset = lseek(fd, p, 0);
160 log_error(VLDB_CHECK_FATAL,"error: lseek to %d failed: %d %d\n", p, offset, errno);
165 r = write(fd, buffer, size);
167 r = read(fd, buffer, size);
170 log_error(VLDB_CHECK_FATAL,"error: %s of %d bytes failed: %d %d\n", rdwr==1?"write":"read",
194 NameHash(char *volname)
200 for (vchar = volname + strlen(volname) - 1; vchar >= volname; vchar--)
201 hash = (hash * 63) + (*((unsigned char *)vchar) - 63);
202 return (hash % HASHSIZE);
206 IdHash(afs_uint32 volid)
208 return ((abs(volid)) % HASHSIZE);
211 #define LEGALCHARS ".ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_"
213 InvalidVolname(char *volname)
219 slen = strlen(volname);
220 if (slen >= VL_MAXNAMELEN)
222 return (slen != strspn(volname, map));
226 validVolumeAddr(afs_uint32 fileOffset)
228 if (ADDR(fileOffset) >= maxentries) {
229 /* Are we in range */
233 * We cannot test whether the offset is aligned
234 * since the vl entries are not in a regular array
240 readheader(struct vlheader *headerp)
244 vldbread(0, (char *)headerp, sizeof(*headerp));
246 headerp->vital_header.vldbversion =
247 ntohl(headerp->vital_header.vldbversion);
248 headerp->vital_header.headersize =
249 ntohl(headerp->vital_header.headersize);
250 headerp->vital_header.freePtr = ntohl(headerp->vital_header.freePtr);
251 headerp->vital_header.eofPtr = ntohl(headerp->vital_header.eofPtr);
252 headerp->vital_header.allocs = ntohl(headerp->vital_header.allocs);
253 headerp->vital_header.frees = ntohl(headerp->vital_header.frees);
254 headerp->vital_header.MaxVolumeId =
255 ntohl(headerp->vital_header.MaxVolumeId);
256 headerp->vital_header.totalEntries[0] =
257 ntohl(headerp->vital_header.totalEntries[0]);
258 for (i = 0; i < MAXTYPES; i++)
259 headerp->vital_header.totalEntries[i] =
260 ntohl(headerp->vital_header.totalEntries[1]);
262 headerp->SIT = ntohl(headerp->SIT);
263 for (i = 0; i <= MAXSERVERID; i++)
264 headerp->IpMappedAddr[i] = ntohl(headerp->IpMappedAddr[i]);
265 for (i = 0; i < HASHSIZE; i++)
266 headerp->VolnameHash[i] = ntohl(headerp->VolnameHash[i]);
267 for (i = 0; i < MAXTYPES; i++)
268 for (j = 0; j < HASHSIZE; j++)
269 headerp->VolidHash[i][j] = ntohl(headerp->VolidHash[i][j]);
272 quiet_println("vldb header\n");
273 quiet_println(" vldbversion = %u\n",
274 headerp->vital_header.vldbversion);
275 quiet_println(" headersize = %u [actual=%lu]\n",
276 headerp->vital_header.headersize, sizeof(*headerp));
277 quiet_println(" freePtr = 0x%x\n", headerp->vital_header.freePtr);
278 quiet_println(" eofPtr = %u\n", headerp->vital_header.eofPtr);
279 quiet_println(" allocblock calls = %10u\n", headerp->vital_header.allocs);
280 quiet_println(" freeblock calls = %10u\n", headerp->vital_header.frees);
281 quiet_println(" MaxVolumeId = %u\n",
282 headerp->vital_header.MaxVolumeId);
283 quiet_println(" rw vol entries = %u\n",
284 headerp->vital_header.totalEntries[0]);
285 quiet_println(" ro vol entries = %u\n",
286 headerp->vital_header.totalEntries[1]);
287 quiet_println(" bk vol entries = %u\n",
288 headerp->vital_header.totalEntries[2]);
289 quiet_println(" multihome info = 0x%x (%u)\n", headerp->SIT,
291 quiet_println(" server ip addr table: size = %d entries\n",
293 quiet_println(" volume name hash table: size = %d buckets\n", HASHSIZE);
294 quiet_println(" volume id hash table: %d tables with %d buckets each\n",
298 /* Check the header size */
299 if (headerp->vital_header.headersize != sizeof(*headerp))
300 log_error(VLDB_CHECK_WARNING,"Header reports its size as %d (should be %lu)\n",
301 headerp->vital_header.headersize, sizeof(*headerp));
306 writeheader(struct vlheader *headerp)
310 headerp->vital_header.vldbversion =
311 htonl(headerp->vital_header.vldbversion);
312 headerp->vital_header.headersize =
313 htonl(headerp->vital_header.headersize);
314 headerp->vital_header.freePtr = htonl(headerp->vital_header.freePtr);
315 headerp->vital_header.eofPtr = htonl(headerp->vital_header.eofPtr);
316 headerp->vital_header.allocs = htonl(headerp->vital_header.allocs);
317 headerp->vital_header.frees = htonl(headerp->vital_header.frees);
318 headerp->vital_header.MaxVolumeId =
319 htonl(headerp->vital_header.MaxVolumeId);
320 headerp->vital_header.totalEntries[0] =
321 htonl(headerp->vital_header.totalEntries[0]);
322 for (i = 0; i < MAXTYPES; i++)
323 headerp->vital_header.totalEntries[i] =
324 htonl(headerp->vital_header.totalEntries[1]);
326 headerp->SIT = htonl(headerp->SIT);
327 for (i = 0; i <= MAXSERVERID; i++)
328 headerp->IpMappedAddr[i] = htonl(headerp->IpMappedAddr[i]);
329 for (i = 0; i < HASHSIZE; i++)
330 headerp->VolnameHash[i] = htonl(headerp->VolnameHash[i]);
331 for (i = 0; i < MAXTYPES; i++)
332 for (j = 0; j < HASHSIZE; j++)
333 headerp->VolidHash[i][j] = htonl(headerp->VolidHash[i][j]);
335 vldbwrite(0, (char *)headerp, sizeof(*headerp));
339 readMH(afs_int32 addr, struct extentaddr *mhblockP)
342 struct extentaddr *e;
344 vldbread(addr, (char *)mhblockP, VL_ADDREXTBLK_SIZE);
346 mhblockP->ex_count = ntohl(mhblockP->ex_count);
347 mhblockP->ex_hdrflags = ntohl(mhblockP->ex_hdrflags);
348 for (i = 0; i < VL_MAX_ADDREXTBLKS; i++)
349 mhblockP->ex_contaddrs[i] = ntohl(mhblockP->ex_contaddrs[i]);
351 for (i = 1; i < VL_MHSRV_PERBLK; i++) {
354 /* won't convert hostuuid */
355 e->ex_uniquifier = ntohl(e->ex_uniquifier);
356 for (j = 0; j < VL_MAXIPADDRS_PERMH; j++)
357 e->ex_addrs[j] = ntohl(e->ex_addrs[j]);
363 readentry(afs_int32 addr, struct nvlentry *vlentryp, afs_int32 *type)
367 vldbread(addr, (char *)vlentryp, sizeof(*vlentryp));
369 for (i = 0; i < MAXTYPES; i++)
370 vlentryp->volumeId[i] = ntohl(vlentryp->volumeId[i]);
371 vlentryp->flags = ntohl(vlentryp->flags);
372 vlentryp->LockAfsId = ntohl(vlentryp->LockAfsId);
373 vlentryp->LockTimestamp = ntohl(vlentryp->LockTimestamp);
374 vlentryp->cloneId = ntohl(vlentryp->cloneId);
375 for (i = 0; i < MAXTYPES; i++)
376 vlentryp->nextIdHash[i] = ntohl(vlentryp->nextIdHash[i]);
377 vlentryp->nextNameHash = ntohl(vlentryp->nextNameHash);
378 for (i = 0; i < NMAXNSERVERS; i++) {
379 /* make sure not to ntohl these, as they're chars, not ints */
380 vlentryp->serverNumber[i] = vlentryp->serverNumber[i];
381 vlentryp->serverPartition[i] = vlentryp->serverPartition[i];
382 vlentryp->serverFlags[i] = vlentryp->serverFlags[i];
385 if (vlentryp->flags == VLCONTBLOCK) {
387 } else if (vlentryp->flags == VLFREE) {
394 quiet_println("address %u: ", addr);
395 if (vlentryp->flags == VLCONTBLOCK) {
396 quiet_println("mh extension block\n");
397 } else if (vlentryp->flags == VLFREE) {
398 quiet_println("free vlentry\n");
400 quiet_println("vlentry %s\n", vlentryp->name);
401 quiet_println(" rw id = %u ; ro id = %u ; bk id = %u\n",
402 vlentryp->volumeId[0], vlentryp->volumeId[1],
403 vlentryp->volumeId[2]);
404 quiet_println(" flags =");
405 if (vlentryp->flags & VLF_RWEXISTS)
406 quiet_println(" rw");
407 if (vlentryp->flags & VLF_ROEXISTS)
408 quiet_println(" ro");
409 if (vlentryp->flags & VLF_BACKEXISTS)
410 quiet_println(" bk");
411 if (vlentryp->flags & VLOP_MOVE)
412 quiet_println(" lock_move");
413 if (vlentryp->flags & VLOP_RELEASE)
414 quiet_println(" lock_release");
415 if (vlentryp->flags & VLOP_BACKUP)
416 quiet_println(" lock_backup");
417 if (vlentryp->flags & VLOP_DELETE)
418 quiet_println(" lock_delete");
419 if (vlentryp->flags & VLOP_DUMP)
420 quiet_println(" lock_dump");
422 /* all bits not covered by VLF_* and VLOP_* constants */
423 if (vlentryp->flags & 0xffff8e0f)
424 quiet_println(" errorflag(0x%x)", vlentryp->flags);
426 quiet_println(" LockAfsId = %d\n", vlentryp->LockAfsId);
427 quiet_println(" LockTimestamp = %d\n", vlentryp->LockTimestamp);
428 quiet_println(" cloneId = %u\n", vlentryp->cloneId);
430 (" next hash for rw = %u ; ro = %u ; bk = %u ; name = %u\n",
431 vlentryp->nextIdHash[0], vlentryp->nextIdHash[1],
432 vlentryp->nextIdHash[2], vlentryp->nextNameHash);
433 for (i = 0; i < NMAXNSERVERS; i++) {
434 if (vlentryp->serverNumber[i] != 255) {
435 quiet_println(" server %d ; partition %d ; flags =",
436 vlentryp->serverNumber[i],
437 vlentryp->serverPartition[i]);
438 if (vlentryp->serverFlags[i] & VLSF_RWVOL)
439 quiet_println(" rw");
440 if (vlentryp->serverFlags[i] & VLSF_ROVOL)
441 quiet_println(" ro");
442 if (vlentryp->serverFlags[i] & VLSF_BACKVOL)
443 quiet_println(" bk");
444 if (vlentryp->serverFlags[i] & VLSF_NEWREPSITE)
445 quiet_println(" newro");
455 writeentry(afs_int32 addr, struct nvlentry *vlentryp)
459 if (verbose) quiet_println("Writing back entry at addr %u\n", addr);
460 for (i = 0; i < MAXTYPES; i++)
461 vlentryp->volumeId[i] = htonl(vlentryp->volumeId[i]);
462 vlentryp->flags = htonl(vlentryp->flags);
463 vlentryp->LockAfsId = htonl(vlentryp->LockAfsId);
464 vlentryp->LockTimestamp = htonl(vlentryp->LockTimestamp);
465 vlentryp->cloneId = htonl(vlentryp->cloneId);
466 for (i = 0; i < MAXTYPES; i++)
467 vlentryp->nextIdHash[i] = htonl(vlentryp->nextIdHash[i]);
468 vlentryp->nextNameHash = htonl(vlentryp->nextNameHash);
469 for (i = 0; i < NMAXNSERVERS; i++) {
470 /* make sure not to htonl these, as they're chars, not ints */
471 vlentryp->serverNumber[i] = vlentryp->serverNumber[i] ;
472 vlentryp->serverPartition[i] = vlentryp->serverPartition[i] ;
473 vlentryp->serverFlags[i] = vlentryp->serverFlags[i] ;
475 vldbwrite(addr, (char *)vlentryp, sizeof(*vlentryp));
479 * Read each entry in the database:
480 * Record what type of entry it is and its address in the record array.
481 * Remember what the maximum volume id we found is and check against the header.
484 ReadAllEntries(struct vlheader *header)
486 afs_int32 type, rindex, i, j, e;
487 int freecount = 0, mhcount = 0, vlcount = 0;
488 int rwcount = 0, rocount = 0, bkcount = 0;
489 struct nvlentry vlentry;
491 afs_uint32 entrysize = 0;
492 afs_uint32 maxvolid = 0;
494 if (verbose) quiet_println("Read each entry in the database\n");
495 for (addr = header->vital_header.headersize;
496 addr < header->vital_header.eofPtr; addr += entrysize) {
498 /* Remember the highest volume id */
499 readentry(addr, &vlentry, &type);
501 if (!(vlentry.flags & VLF_RWEXISTS))
502 log_error(VLDB_CHECK_WARNING,"VLDB_CHECK_WARNING: VLDB entry '%s' has no RW volume\n",
505 for (i = 0; i < MAXTYPES; i++)
506 if (maxvolid < vlentry.volumeId[i])
507 maxvolid = vlentry.volumeId[i];
510 for (j = 0; j < NMAXNSERVERS; j++) {
511 if (vlentry.serverNumber[j] == 255)
513 if (vlentry.serverFlags[j] & (VLSF_ROVOL | VLSF_NEWREPSITE)) {
517 if (vlentry.serverFlags[j] & VLSF_RWVOL) {
519 if (vlentry.flags & VLF_BACKEXISTS)
523 if (!vlentry.serverFlags[j]) {
529 (VLDB_CHECK_ERROR,"VLDB entry '%s' contains an unknown RW/RO index serverFlag\n",
534 (" index %d : serverNumber %d : serverPartition %d : serverFlag %d\n",
535 j, vlentry.serverNumber[j], vlentry.serverPartition[j],
536 vlentry.serverFlags[j]);
540 rindex = addr / sizeof(vlentry);
541 if (record[rindex].type) {
542 log_error(VLDB_CHECK_ERROR,"INTERNAL VLDB_CHECK_ERROR: record holder %d already in use\n",
546 record[rindex].addr = addr;
547 record[rindex].type = type;
549 /* Determine entrysize and keep count */
551 entrysize = sizeof(vlentry);
553 } else if (type == FR) {
554 entrysize = sizeof(vlentry);
556 } else if (type == MH) {
557 entrysize = VL_ADDREXTBLK_SIZE;
560 log_error(VLDB_CHECK_ERROR, "Unknown entry at %u. Aborting\n", addr);
565 quiet_println("Found %d entries, %d free entries, %d multihomed blocks\n",
566 vlcount, freecount, mhcount);
567 quiet_println("Found %d RW volumes, %d BK volumes, %d RO volumes\n", rwcount,
571 /* Check the maxmimum volume id in the header */
572 if (maxvolid != header->vital_header.MaxVolumeId - 1)
574 ("Header's maximum volume id is %u and largest id found in VLDB is %u\n",
575 header->vital_header.MaxVolumeId, maxvolid);
579 * Follow each Name hash bucket marking it as read in the record array.
580 * Record we found it in the name hash within the record array.
581 * Check that the name is hashed correctly.
584 FollowNameHash(struct vlheader *header)
586 int count = 0, longest = 0, shortest = -1, chainlength;
587 struct nvlentry vlentry;
589 afs_int32 i, type, rindex;
591 /* Now follow the Name Hash Table */
592 if (verbose) quiet_println("Check Volume Name Hash\n");
593 for (i = 0; i < HASHSIZE; i++) {
596 if (!validVolumeAddr(header->VolnameHash[i])) {
597 log_error(VLDB_CHECK_ERROR,"Name Hash %d: Bad entry %u is out of range\n",
598 i, header->VolnameHash[i]);
602 for (addr = header->VolnameHash[i]; addr; addr = vlentry.nextNameHash) {
603 readentry(addr, &vlentry, &type);
605 log_error(VLDB_CHECK_ERROR,"Name Hash %d: Bad entry at %u: Not a valid vlentry\n",
613 * we know that the address is valid because we
614 * checked it either above or below
616 if (record[rindex].addr != addr && record[rindex].addr) {
618 (VLDB_CHECK_ERROR,"INTERNAL VLDB_CHECK_ERROR: addresses %ld and %u use same record slot %d\n",
619 record[rindex].addr, addr, rindex);
621 if (record[rindex].type & NH) {
623 (VLDB_CHECK_ERROR,"Name Hash %d: Bad entry '%s': Already in the name hash\n",
625 record[rindex].type |= MULTN;
629 if (!validVolumeAddr(vlentry.nextNameHash)) {
630 log_error(VLDB_CHECK_ERROR,"Name Hash forward link of '%s' is out of range\n",
632 record[rindex].type |= MULTN;
636 record[rindex].type |= NH;
637 record[rindex].type |= REFN;
642 /* Hash the name and check if in correct hash table */
643 if (NameHash(vlentry.name) != i) {
645 (VLDB_CHECK_ERROR,"Name Hash %d: Bad entry '%s': Incorrect name hash chain (should be in %d)\n",
646 i, vlentry.name, NameHash(vlentry.name));
647 record[rindex].type |= MULTN;
650 if (chainlength > longest)
651 longest = chainlength;
652 if ((shortest == -1) || (chainlength < shortest))
653 shortest = chainlength;
657 ("%d entries in name hash, longest is %d, shortest is %d, average length is %f\n",
658 count, longest, shortest, ((float)count / (float)HASHSIZE));
664 * Follow the ID hash chains for the RW, RO, and BK hash tables.
665 * Record we found it in the id hash within the record array.
666 * Check that the ID is hashed correctly.
669 FollowIdHash(struct vlheader *header)
671 int count = 0, longest = 0, shortest = -1, chainlength;
672 struct nvlentry vlentry;
674 afs_int32 i, j, hash, type, rindex, ref, badref, badhash;
676 /* Now follow the RW, RO, and BK Hash Tables */
677 if (verbose) quiet_println("Check RW, RO, and BK id Hashes\n");
678 for (i = 0; i < MAXTYPES; i++) {
679 hash = ((i == 0) ? RWH : ((i == 1) ? ROH : BKH));
680 ref = ((i == 0) ? REFRW : ((i == 1) ? REFRO : REFBK));
681 badref = ((i == 0) ? MULTRW : ((i == 1) ? MULTRO : MULTBK));
682 badhash = ((i == 0) ? MULTRW : ((i == 1) ? MULTRO : MULTBK));
686 for (j = 0; j < HASHSIZE; j++) {
688 if (!validVolumeAddr(header->VolidHash[i][j])) {
689 log_error(VLDB_CHECK_ERROR,"%s Hash %d: Bad entry %u is out of range\n",
690 vtype(i), j, header->VolidHash[i][j]);
694 for (addr = header->VolidHash[i][j]; addr;
695 addr = vlentry.nextIdHash[i]) {
696 readentry(addr, &vlentry, &type);
699 (VLDB_CHECK_ERROR,"%s Id Hash %d: Bad entry at %u: Not a valid vlentry\n",
705 if (record[rindex].addr != addr && record[rindex].addr) {
707 (VLDB_CHECK_ERROR,"INTERNAL VLDB_CHECK_ERROR: addresses %ld and %u use same record slot %d\n",
708 record[rindex].addr, addr, rindex);
710 if (record[rindex].type & hash) {
712 (VLDB_CHECK_ERROR,"%s Id Hash %d: Bad entry '%s': Already in the hash table\n",
713 vtype(i), j, vlentry.name);
714 record[rindex].type |= badref;
718 if (!validVolumeAddr(vlentry.nextIdHash[i])) {
719 log_error(VLDB_CHECK_ERROR,"%s Id Hash forward link of '%s' is out of range\n",
720 vtype(i), vlentry.name);
721 record[rindex].type |= badref;
725 record[rindex].type |= hash;
726 record[rindex].type |= ref;
731 /* Hash the id and check if in correct hash table */
732 if (IdHash(vlentry.volumeId[i]) != j) {
734 (VLDB_CHECK_ERROR,"%s Id Hash %d: Bad entry '%s': Incorrect Id hash chain (should be in %d)\n",
735 vtype(i), j, vlentry.name,
736 IdHash(vlentry.volumeId[i]));
737 record[rindex].type |= badhash;
741 if (chainlength > longest)
742 longest = chainlength;
743 if ((shortest == -1) || (chainlength < shortest))
744 shortest = chainlength;
748 ("%d entries in %s hash, longest is %d, shortest is %d, average length is %f\n",
749 count, vtype(i), longest, shortest,((float)count / (float)HASHSIZE));
756 * Follow the free chain.
757 * Record we found it in the free chain within the record array.
760 FollowFreeChain(struct vlheader *header)
763 struct nvlentry vlentry;
765 afs_int32 type, rindex;
767 /* Now follow the Free Chain */
768 if (verbose) quiet_println("Check Volume Free Chain\n");
769 for (addr = header->vital_header.freePtr; addr;
770 addr = vlentry.nextIdHash[0]) {
771 readentry(addr, &vlentry, &type);
774 (VLDB_CHECK_ERROR,"Free Chain %d: Bad entry at %u: Not a valid free vlentry (0x%x)\n",
779 rindex = addr / sizeof(vlentry);
780 if (record[rindex].addr != addr && record[rindex].addr) {
782 (VLDB_CHECK_ERROR,"INTERNAL VLDB_CHECK_ERROR: addresses %u and %ld use same record slot %d\n",
783 record[rindex].addr, addr, rindex);
785 if (record[rindex].type & FRC) {
786 log_error(VLDB_CHECK_ERROR,"Free Chain: Bad entry at %u: Already in the free chain\n",
790 record[rindex].type |= FRC;
795 quiet_println("%d entries on free chain\n", count);
800 * Read each multihomed block and mark it as found in the record.
801 * Read each entry in each multihomed block and mark the serveraddrs
802 * array with the number of ip addresses found for this entry.
804 * Then read the IpMappedAddr array in the header.
805 * Verify that multihomed entries base and index are valid and points to
806 * a good multhomed entry.
807 * Mark the serveraddrs array with 1 ip address for regular entries.
809 * By the end, the severaddrs array will have a 0 if the entry has no
810 * IP addresses in it or the count of the number of IP addresses.
812 * The code does not verify if there are duplicate IP addresses in the
813 * list. The vlserver does this when a fileserver registeres itself.
816 CheckIpAddrs(struct vlheader *header)
819 afs_int32 i, j, m, rindex;
820 afs_int32 mhentries, regentries;
821 afs_uint32 caddrs[VL_MAX_ADDREXTBLKS];
822 char mhblock[VL_ADDREXTBLK_SIZE];
823 struct extentaddr *MHblock = (struct extentaddr *)mhblock;
824 struct extentaddr *e;
825 int ipindex, ipaddrs;
828 memset(&nulluuid, 0, sizeof(nulluuid));
831 quiet_println("Check Multihomed blocks\n");
834 /* Read the first MH block and from it, gather the
835 * addresses of all the mh blocks.
837 readMH(header->SIT, MHblock);
838 if (MHblock->ex_hdrflags != VLCONTBLOCK) {
840 (VLDB_CHECK_ERROR,"Multihomed Block 0: Bad entry at %u: Not a valid multihomed block\n",
844 for (i = 0; i < VL_MAX_ADDREXTBLKS; i++) {
845 caddrs[i] = MHblock->ex_contaddrs[i];
848 if (header->SIT != caddrs[0]) {
850 (VLDB_CHECK_ERROR,"MH block does not point to self %u in header, %u in block\n",
851 header->SIT, caddrs[0]);
854 /* Now read each MH block and record it in the record array */
855 for (i = 0; i < VL_MAX_ADDREXTBLKS; i++) {
859 readMH(caddrs[i], MHblock);
860 if (MHblock->ex_hdrflags != VLCONTBLOCK) {
862 (VLDB_CHECK_ERROR,"Multihomed Block 0: Bad entry at %u: Not a valid multihomed block\n",
866 rindex = caddrs[i] / sizeof(vlentry);
867 if (record[rindex].addr != caddrs[i] && record[rindex].addr) {
869 (VLDB_CHECK_ERROR,"INTERNAL VLDB_CHECK_ERROR: addresses %u and %u use same record slot %d\n",
870 record[rindex].addr, caddrs[i], rindex);
872 if (record[rindex].type & FRC) {
874 (VLDB_CHECK_ERROR,"MH Blocks Chain %d: Bad entry at %ld: Already a MH block\n",
875 i, record[rindex].addr);
878 record[rindex].type |= MHC;
882 /* Read each entry in a multihomed block.
883 * Find the pointer to the entry in the IpMappedAddr array and
884 * verify that the entry is good (has IP addresses in it).
887 for (j = 1; j < VL_MHSRV_PERBLK; j++) {
888 int first_ipindex = -1;
889 e = (struct extentaddr *)&(MHblock[j]);
891 /* Search the IpMappedAddr array for all the references to this entry. */
892 /* Use the first reference for checking the ip addresses of this entry. */
893 for (ipindex = 0; ipindex <= MAXSERVERID; ipindex++) {
894 if (((header->IpMappedAddr[ipindex] & 0xff000000) == 0xff000000)
895 && (((header-> IpMappedAddr[ipindex] & 0x00ff0000) >> 16) == i)
896 && ((header->IpMappedAddr[ipindex] & 0x0000ffff) == j)) {
897 if (first_ipindex == -1) {
898 first_ipindex = ipindex;
900 serverxref[ipindex] = first_ipindex;
904 ipindex = first_ipindex;
906 serveraddrs[ipindex] = -1;
908 if (memcmp(&e->ex_hostuuid, &nulluuid, sizeof(afsUUID)) == 0) {
911 (VLDB_CHECK_ERROR,"Server Addrs index %d references null MH block %d, index %d\n",
913 serveraddrs[ipindex] = 0; /* avoids printing 2nd error below */
918 /* Step through each ip address and count the good addresses */
920 for (m = 0; m < VL_MAXIPADDRS_PERMH; m++) {
925 /* If we found any good ip addresses, mark it in the serveraddrs record */
930 (VLDB_CHECK_ERROR,"MH block %d, index %d: Not referenced by server addrs\n",
933 serveraddrs[ipindex] = ipaddrs; /* It is good */
937 if (listservers && ipaddrs) {
938 quiet_println("MH block %d, index %d:", i, j);
939 for (m = 0; m < VL_MAXIPADDRS_PERMH; m++) {
942 quiet_println(" %d.%d.%d.%d",
943 (e->ex_addrs[m] & 0xff000000) >> 24,
944 (e->ex_addrs[m] & 0x00ff0000) >> 16,
945 (e->ex_addrs[m] & 0x0000ff00) >> 8,
946 (e->ex_addrs[m] & 0x000000ff));
952 * if (mhentries != MHblock->ex_count) {
953 * quiet_println("MH blocks says it has %d entries (found %d)\n",
954 * MHblock->ex_count, mhentries);
960 quiet_println("%d multihomed blocks\n", mhblocks);
962 /* Check the server addresses */
964 quiet_println("Check server addresses\n");
965 mhentries = regentries = 0;
966 for (i = 0; i <= MAXSERVERID; i++) {
967 if (header->IpMappedAddr[i]) {
968 if ((header->IpMappedAddr[i] & 0xff000000) == 0xff000000) {
970 if (((header->IpMappedAddr[i] & 0x00ff0000) >> 16) >
973 (VLDB_CHECK_ERROR,"IP Addr for entry %d: Multihome block is bad (%d)\n",
974 i, ((header->IpMappedAddr[i] & 0x00ff0000) >> 16));
975 if (caddrs[(header->IpMappedAddr[i] & 0x00ff0000) >> 16] == 0)
976 log_error(VLDB_CHECK_ERROR,"IP Addr for entry %d: No such multihome block (%d)\n",
977 i, ((header->IpMappedAddr[i] & 0x00ff0000) >> 16));
978 if (((header->IpMappedAddr[i] & 0x0000ffff) > VL_MHSRV_PERBLK)
979 || ((header->IpMappedAddr[i] & 0x0000ffff) < 1))
981 (VLDB_CHECK_ERROR,"IP Addr for entry %d: Multihome index is bad (%d)\n",
982 i, (header->IpMappedAddr[i] & 0x0000ffff));
983 if (serveraddrs[i] == -1) {
985 (VLDB_CHECK_WARNING,"warning: IP Addr for entry %d: Multihome entry has no ip addresses\n",
989 if (serverxref[i] != BADSERVERID) {
992 "warning: MH block %d, index %d is cross-linked by server numbers %d and %d.\n",
993 (header->IpMappedAddr[i] & 0x00ff0000) >> 16,
994 (header->IpMappedAddr[i] & 0x0000ffff),
996 /* set addresses found/not found for this server number,
997 * using the first index to the mh we found above. */
998 serveraddrs[i] = serveraddrs[serverxref[i]];
1001 quiet_println(" Server ip addr %d = MH block %d, index %d\n",
1002 i, (header->IpMappedAddr[i] & 0x00ff0000) >> 16,
1003 (header->IpMappedAddr[i] & 0x0000ffff));
1007 serveraddrs[i] = 1; /* It is good */
1009 quiet_println(" Server ip addr %d = %d.%d.%d.%d\n", i,
1010 (header->IpMappedAddr[i] & 0xff000000) >> 24,
1011 (header->IpMappedAddr[i] & 0x00ff0000) >> 16,
1012 (header->IpMappedAddr[i] & 0x0000ff00) >> 8,
1013 (header->IpMappedAddr[i] & 0x000000ff));
1019 quiet_println("%d simple entries, %d multihomed entries, Total = %d\n",
1020 regentries, mhentries, mhentries + regentries);
1026 nameForAddr(afs_uint32 addr, int hashtype, afs_uint32 *hash, char *buffer)
1029 * We need to simplify the reporting, while retaining
1030 * legible messages. This is a helper function. The return address
1031 * is either a fixed char or the provided buffer - so don't use the
1032 * name after the valid lifetime of the buffer.
1035 struct nvlentry entry;
1037 /* Distinguished, invalid, hash */
1040 } else if (!validVolumeAddr(addr)) {
1041 /* Different, invalid, hash */
1045 readentry(addr, &entry, &type);
1050 if (hashtype >= MAXTYPES) {
1051 *hash = NameHash(entry.name);
1053 *hash = IdHash(entry.volumeId[hashtype]);
1055 sprintf(buffer, "for '%s'", entry.name);
1060 reportHashChanges(struct vlheader *header, afs_uint32 oldnamehash[HASHSIZE], afs_uint32 oldidhash[MAXTYPES][HASHSIZE])
1063 afs_uint32 oldhash, newhash;
1064 char oldNameBuffer[10 + VL_MAXNAMELEN];
1065 char newNameBuffer[10 + VL_MAXNAMELEN];
1066 char *oldname, *newname;
1068 * report hash changes
1071 for (i = 0; i < HASHSIZE; i++) {
1072 if (oldnamehash[i] != header->VolnameHash[i]) {
1074 oldname = nameForAddr(oldnamehash[i], MAXTYPES, &oldhash, oldNameBuffer);
1075 newname = nameForAddr(header->VolnameHash[i], MAXTYPES, &newhash, newNameBuffer);
1076 if (verbose || (oldhash != newhash)) {
1077 quiet_println("FIX: Name hash header at %d was %s, is now %s\n", i, oldname, newname);
1080 for (j = 0; j < MAXTYPES; j++) {
1081 if (oldidhash[j][i] != header->VolidHash[j][i]) {
1083 oldname = nameForAddr(oldidhash[j][i], j, &oldhash, oldNameBuffer);
1084 newname = nameForAddr(header->VolidHash[j][i], j, &newhash, newNameBuffer);
1085 if (verbose || (oldhash != newhash)) {
1086 quiet_println("FIX: %s hash header at %d was %s, is now %s\n", vtype(j), i, oldname, newname);
1094 WorkerBee(struct cmd_syndesc *as, void *arock)
1098 struct vlheader header;
1099 struct nvlentry vlentry, vlentry2;
1101 afs_uint32 oldnamehash[HASHSIZE];
1102 afs_uint32 oldidhash[MAXTYPES][HASHSIZE];
1104 error_level = 0; /* start clean with no error status */
1105 dbfile = as->parms[0].items->data; /* -database */
1106 listuheader = (as->parms[1].items ? 1 : 0); /* -uheader */
1107 listheader = (as->parms[2].items ? 1 : 0); /* -vheader */
1108 listservers = (as->parms[3].items ? 1 : 0); /* -servers */
1109 listentries = (as->parms[4].items ? 1 : 0); /* -entries */
1110 verbose = (as->parms[5].items ? 1 : 0); /* -verbose */
1111 quiet = (as->parms[6].items ? 1 : 0); /* -quiet */
1112 fix = (as->parms[7].items ? 1 : 0); /* -fix */
1115 if (quiet && (verbose || listuheader || listheader ||listservers \
1117 log_error(VLDB_CHECK_FATAL," -quiet cannot be used other display flags\n");
1118 return VLDB_CHECK_FATAL;
1122 /* open the vldb database file */
1123 fd = open(dbfile, (fix > 0)?O_RDWR:O_RDONLY, 0);
1125 log_error(VLDB_CHECK_FATAL,"can't open file '%s'. error = %d\n", dbfile, errno);
1129 /* read the ubik header and the vldb database header */
1131 readheader(&header);
1132 if (header.vital_header.vldbversion < 3) {
1133 log_error(VLDB_CHECK_FATAL,"does not support vldb with version less than 3\n");
1134 return VLDB_CHECK_FATAL;
1137 maxentries = (header.vital_header.eofPtr / sizeof(vlentry)) + 1;
1138 record = calloc(maxentries, sizeof(struct er));
1139 memset(serveraddrs, 0, sizeof(serveraddrs));
1140 for (i = 0; i <= MAXSERVERID; i++) {
1141 serverxref[i] = BADSERVERID;
1144 /* Will fill in the record array of entries it found */
1145 ReadAllEntries(&header);
1146 listentries = 0; /* Listed all the entries */
1148 /* Check the multihomed blocks for valid entries as well as
1149 * the IpMappedAddrs array in the header for valid entries.
1151 CheckIpAddrs(&header);
1153 /* Follow the hash tables */
1154 FollowNameHash(&header);
1155 FollowIdHash(&header);
1157 /* Follow the chain of free entries */
1158 FollowFreeChain(&header);
1160 /* Now check the record we have been keeping for inconsistencies
1161 * For valid vlentries, also check that the server we point to is
1162 * valid (the serveraddrs array).
1165 quiet_println("Verify each volume entry\n");
1166 for (i = 0; i < maxentries; i++) {
1171 if (record[i].type == 0)
1174 /* If a vlentry, verify that its name is valid, its name and ids are
1175 * on the hash chains, and its server numbers are good.
1177 if (record[i].type & VL) {
1179 int foundbroken = 0;
1182 readentry(record[i].addr, &vlentry, &type);
1184 if (InvalidVolname(vlentry.name))
1185 log_error(VLDB_CHECK_ERROR,"Volume '%s' at addr %ld has an invalid name\n",
1186 vlentry.name, record[i].addr);
1188 if (!(record[i].type & NH)) {
1189 hash = NameHash(vlentry.name);
1195 if (vlentry.volumeId[0] && !(record[i].type & RWH)) {
1196 hash = IdHash(vlentry.volumeId[0]);
1198 sprintf(volidbuf, "id %u ", vlentry.volumeId[0]);
1202 if (vlentry.volumeId[1] && !(record[i].type & ROH)) {
1203 hash = IdHash(vlentry.volumeId[1]);
1205 sprintf(volidbuf, "id %u ", vlentry.volumeId[1]);
1209 if (vlentry.volumeId[2] && !(record[i].type & BKH)) {
1210 hash = IdHash(vlentry.volumeId[2]);
1212 sprintf(volidbuf, "id %u ", vlentry.volumeId[2]);
1216 if (!validVolumeAddr(vlentry.nextNameHash) ||
1217 record[ADDR(vlentry.nextNameHash)].type & MULTN) {
1218 hash = NameHash(vlentry.name);
1221 if (validVolumeAddr(vlentry.nextNameHash)) {
1222 readentry(vlentry.nextNameHash, &vlentry2, &type);
1223 nexthash = NameHash(vlentry2.name);
1225 nexthash = 0xFFFFFFFF;
1227 if (hash != nexthash)
1231 if (!validVolumeAddr(vlentry.nextIdHash[0]) ||
1232 record[ADDR(vlentry.nextIdHash[0])].type & MULTRW) {
1233 hash = IdHash(vlentry.volumeId[0]);
1235 sprintf(volidbuf, "id %u ", vlentry.volumeId[0]);
1236 if (validVolumeAddr(vlentry.nextIdHash[0])) {
1237 readentry(vlentry.nextIdHash[0], &vlentry2, &type);
1238 nexthash = IdHash(vlentry2.volumeId[0]);
1240 nexthash = 0xFFFFFFFF;
1242 if (hash != nexthash)
1246 if (!validVolumeAddr(vlentry.nextIdHash[1]) ||
1247 record[ADDR(vlentry.nextIdHash[1])].type & MULTRO) {
1248 hash = IdHash(vlentry.volumeId[1]);
1250 sprintf(volidbuf, "id %u ", vlentry.volumeId[1]);
1251 if (validVolumeAddr(vlentry.nextIdHash[1])) {
1252 readentry(vlentry.nextIdHash[1], &vlentry2, &type);
1253 nexthash = IdHash(vlentry2.volumeId[1]);
1255 nexthash = 0xFFFFFFFF;
1257 if (hash != nexthash)
1261 if (!validVolumeAddr(vlentry.nextIdHash[2]) ||
1262 record[ADDR(vlentry.nextIdHash[2])].type & MULTBK) {
1263 hash = IdHash(vlentry.volumeId[2]);
1265 sprintf(volidbuf, "id %u ", vlentry.volumeId[2]);
1266 if (validVolumeAddr(vlentry.nextIdHash[2])) {
1267 readentry(vlentry.nextIdHash[2], &vlentry2, &type);
1268 nexthash = IdHash(vlentry2.volumeId[2]);
1270 nexthash = 0xFFFFFFFF;
1272 if (hash != nexthash)
1277 log_error(VLDB_CHECK_ERROR, "%d: Volume '%s' %s forward link in %s hash chain is broken (hash %d != %d)\n", i,
1278 vlentry.name, volidbuf, which, hash, nexthash);
1279 } else if (foundbad) {
1280 log_error(VLDB_CHECK_ERROR, "%d: Volume '%s' %snot found in %s hash %d\n", i,
1281 vlentry.name, volidbuf, which, hash);
1284 for (j = 0; j < NMAXNSERVERS; j++) {
1285 if ((vlentry.serverNumber[j] != 255)
1286 && (serveraddrs[vlentry.serverNumber[j]] == 0)) {
1288 (VLDB_CHECK_ERROR,"Volume '%s', index %d points to empty server entry %d\n",
1289 vlentry.name, j, vlentry.serverNumber[j]);
1293 if (record[i].type & 0xffff0f00)
1295 (VLDB_CHECK_ERROR,"Volume '%s' id %u also found on other chains (0x%x)\n",
1296 vlentry.name, vlentry.volumeId[0], record[i].type);
1299 } else if (record[i].type & FR) {
1300 if (!(record[i].type & FRC))
1301 log_error(VLDB_CHECK_ERROR,"Free vlentry at %ld not on free chain\n",
1304 if (record[i].type & 0xfffffdf0)
1306 (VLDB_CHECK_ERROR,"Free vlentry at %ld also found on other chains (0x%x)\n",
1307 record[i].addr, record[i].type);
1309 /* A multihomed entry */
1310 } else if (record[i].type & MH) {
1311 if (!(record[i].type & MHC))
1312 log_error(VLDB_CHECK_ERROR,"Multihomed block at %ld is orphaned\n",
1315 if (record[i].type & 0xfffffef0)
1317 (VLDB_CHECK_ERROR,"Multihomed block at %ld also found on other chains (0x%x)\n",
1318 record[i].addr, record[i].type);
1321 log_error(VLDB_CHECK_ERROR,"Unknown entry type at %u (0x%x)\n", record[i].addr,
1328 * If we are fixing we will rebuild all the hash lists from the ground up
1330 memcpy(oldnamehash, header.VolnameHash, sizeof(oldnamehash));
1331 memset(header.VolnameHash, 0, sizeof(header.VolnameHash));
1333 memcpy(oldidhash, header.VolidHash, sizeof(oldidhash));
1334 memset(header.VolidHash, 0, sizeof(header.VolidHash));
1335 quiet_println("Rebuilding %u entries\n", maxentries);
1337 quiet_println("Scanning %u entries for possible repairs\n", maxentries);
1339 for (i = 0; i < maxentries; i++) {
1341 if (record[i].type & VL) {
1342 readentry(record[i].addr, &vlentry, &type);
1343 if (!(record[i].type & REFN)) {
1344 log_error(VLDB_CHECK_ERROR,"%d: Record %ld (type 0x%x) not in a name chain\n", i,
1345 record[i].addr, record[i].type);
1347 if (vlentry.volumeId[0] && !(record[i].type & REFRW)) {
1348 log_error(VLDB_CHECK_ERROR,"%d: Record %ld (type 0x%x) not in a RW chain\n", i,
1349 record[i].addr, record[i].type);
1351 if (vlentry.volumeId[1] && !(record[i].type & REFRO)) {
1352 log_error(VLDB_CHECK_ERROR,"%d: Record %ld (type 0x%x) not in a RO chain\n", i,
1353 record[i].addr, record[i].type);
1355 if (vlentry.volumeId[2] && !(record[i].type & REFBK)) {
1356 log_error(VLDB_CHECK_ERROR,"%d: Record %ld (type 0x%x) not in a BK chain\n", i,
1357 record[i].addr, record[i].type);
1360 afs_uint32 oldhash, newhash;
1361 char oldNameBuffer[10 + VL_MAXNAMELEN];
1362 char newNameBuffer[10 + VL_MAXNAMELEN];
1363 char *oldname, *newname;
1366 * Put the current hash table contexts into our 'next'
1367 * and our address into the hash table.
1369 hash = NameHash(vlentry.name);
1371 if (vlentry.nextNameHash != header.VolnameHash[hash]) {
1372 oldname = nameForAddr(vlentry.nextNameHash, MAXTYPES, &oldhash, oldNameBuffer);
1373 newname = nameForAddr(header.VolnameHash[hash], MAXTYPES, &newhash, newNameBuffer);
1374 if (verbose || ((oldhash != newhash) &&
1375 (0 != vlentry.nextNameHash) &&
1376 (0 != header.VolnameHash[hash]))) {
1378 * That is, only report if we are verbose
1379 * or the hash is changing (and one side wasn't NULL
1381 quiet_println("FIX: Name hash link for '%s' was %s, is now %s\n",
1382 vlentry.name, oldname, newname);
1386 vlentry.nextNameHash = header.VolnameHash[hash];
1387 header.VolnameHash[hash] = record[i].addr;
1389 for (j = 0; j < MAXTYPES; j++) {
1391 if (0 == vlentry.volumeId[j]) {
1393 * No volume of that type. Continue
1397 hash = IdHash(vlentry.volumeId[j]);
1399 if (vlentry.nextIdHash[j] != header.VolidHash[j][hash]) {
1400 oldname = nameForAddr(vlentry.nextIdHash[j], j, &oldhash, oldNameBuffer);
1401 newname = nameForAddr(header.VolidHash[j][hash], j, &newhash, newNameBuffer);
1402 if (verbose || ((oldhash != newhash) &&
1403 (0 != vlentry.nextIdHash[j]) &&
1404 (0 != header.VolidHash[j][hash]))) {
1405 quiet_println("FIX: %s hash link for '%s' was %s, is now %s\n",
1406 vtype(j), vlentry.name, oldname, newname);
1410 vlentry.nextIdHash[j] = header.VolidHash[j][hash];
1411 header.VolidHash[j][hash] = record[i].addr;
1413 writeentry(record[i].addr, &vlentry);
1418 reportHashChanges(&header, oldnamehash, oldidhash);
1419 writeheader(&header);
1428 main(int argc, char **argv)
1430 struct cmd_syndesc *ts;
1434 ts = cmd_CreateSyntax(NULL, WorkerBee, NULL, "vldb check");
1435 cmd_AddParm(ts, "-database", CMD_SINGLE, CMD_REQUIRED, "vldb_file");
1436 cmd_AddParm(ts, "-uheader", CMD_FLAG, CMD_OPTIONAL,
1437 "Display UBIK header");
1438 cmd_AddParm(ts, "-vheader", CMD_FLAG, CMD_OPTIONAL,
1439 "Display VLDB header");
1440 cmd_AddParm(ts, "-servers", CMD_FLAG, CMD_OPTIONAL,
1441 "Display server list");
1442 cmd_AddParm(ts, "-entries", CMD_FLAG, CMD_OPTIONAL, "Display entries");
1443 cmd_AddParm(ts, "-verbose", CMD_FLAG, CMD_OPTIONAL, "verbose");
1444 cmd_AddParm(ts, "-quiet", CMD_FLAG, CMD_OPTIONAL, "quiet");
1445 cmd_AddParm(ts, "-fix", CMD_FLAG, CMD_OPTIONAL, "attempt to patch the database (potentially dangerous)");
1447 return cmd_Dispatch(argc, argv);