diff options
author | Russ Cox <rsc@swtch.com> | 2008-12-23 12:38:16 -0800 |
---|---|---|
committer | Russ Cox <rsc@swtch.com> | 2008-12-23 12:38:16 -0800 |
commit | 3b06b757665bbec4bf2617e7e0ed0db8e96eeada (patch) | |
tree | d2694b95484426a7d7a97f0c82c7df65dd313d33 /src/cmd/venti | |
parent | 9b5f23c2de89bbd39d57f413cca78f2f11e7c395 (diff) | |
download | plan9port-3b06b757665bbec4bf2617e7e0ed0db8e96eeada.tar.gz plan9port-3b06b757665bbec4bf2617e7e0ed0db8e96eeada.tar.bz2 plan9port-3b06b757665bbec4bf2617e7e0ed0db8e96eeada.zip |
venti: better inconsistency errors
Diffstat (limited to 'src/cmd/venti')
-rw-r--r-- | src/cmd/venti/srv/index.c | 57 |
1 files changed, 45 insertions, 12 deletions
diff --git a/src/cmd/venti/srv/index.c b/src/cmd/venti/srv/index.c index 0cb0a039..0b68928a 100644 --- a/src/cmd/venti/srv/index.c +++ b/src/cmd/venti/srv/index.c @@ -75,18 +75,44 @@ fprint(2, "no mem\n"); blocksize = ix->blocksize; for(i = 0; i < ix->nsects; i++){ is = sects[i]; - if(namecmp(ix->name, is->index) != 0 - || is->blocksize != blocksize - || is->tabsize != tabsize - || namecmp(is->name, ix->smap[i].name) != 0 - || is->start != ix->smap[i].start - || is->stop != ix->smap[i].stop - || last != is->start - || is->start > is->stop){ - seterr(ECorrupt, "inconsistent index sections in %s", ix->name); + if(namecmp(is->index, ix->name) != 0) { + seterr(ECorrupt, "%s: index name is %s, not %s", + sects[i]->part->name, is->index, ix->name); + bad: freeindex(ix); return nil; } + if(is->blocksize != blocksize) { + seterr(ECorrupt, "%s: blocksize is %d, not %d", + sects[i]->part->name, (int)is->blocksize, (int)blocksize); + goto bad; + } + if(is->tabsize != tabsize) { + seterr(ECorrupt, "%s: tabsize is %d, not %d", + sects[i]->part->name, (int)is->tabsize, (int)tabsize); + goto bad; + } + if(namecmp(is->name, ix->smap[i].name) != 0) { + seterr(ECorrupt, "%s: name is %s, not %s", + sects[i]->part->name, is->name, ix->smap[i].name); + goto bad; + } + if(is->start != ix->smap[i].start || is->stop != ix->smap[i].stop) { + seterr(ECorrupt, "%s: range is %lld,%lld, not %lld,%lld", + sects[i]->part->name, is->start, is->stop, + ix->smap[i].start, ix->smap[i].stop); + goto bad; + } + if(is->start > is->stop) { + seterr(ECorrupt, "%s: invalid range %lld,%lld", + sects[i]->part->name, is->start, is->stop); + goto bad; + } + if(is->start != last || is->start > is->stop) { + seterr(ECorrupt, "%s: range %lld-%lld, but last section ended at %lld", + sects[i]->part->name, is->start, is->stop, last); + goto bad; + } last = is->stop; } ix->tabsize = tabsize; @@ -272,11 +298,15 @@ newindex(char *name, ISect **sects, int n) return nil; } if(blocksize != sects[i]->blocksize){ - seterr(EOk, "mismatched block sizes in index sections"); + seterr(EOk, "%s has block size %d, but %s has %d", + sects[0]->part->name, (int)blocksize, + sects[i]->part->name, (int)sects[i]->blocksize); return nil; } if(tabsize != sects[i]->tabsize){ - seterr(EOk, "mismatched config table sizes in index sections"); + seterr(EOk, "%s has table size %d, but %s has %d", + sects[0]->part->name, (int)tabsize, + sects[i]->part->name, (int)sects[i]->tabsize); return nil; } nb += sects[i]->blocks; @@ -288,7 +318,10 @@ newindex(char *name, ISect **sects, int n) for(i = 0; i < n; i++){ for(j = i + 1; j < n; j++){ if(namecmp(sects[i]->name, sects[j]->name) == 0){ - seterr(EOk, "duplicate section name %s for index %s", sects[i]->name, name); + seterr(EOk, "%s and %s both have section name %s", + sects[i]->part->name, + sects[j]->part->name, + sects[i]->name); return nil; } } |