aboutsummaryrefslogtreecommitdiff
path: root/src/cmd/venti/fmtindex.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/cmd/venti/fmtindex.c')
-rw-r--r--src/cmd/venti/fmtindex.c116
1 files changed, 0 insertions, 116 deletions
diff --git a/src/cmd/venti/fmtindex.c b/src/cmd/venti/fmtindex.c
deleted file mode 100644
index 6934e3d5..00000000
--- a/src/cmd/venti/fmtindex.c
+++ /dev/null
@@ -1,116 +0,0 @@
-#include "stdinc.h"
-#include "dat.h"
-#include "fns.h"
-
-void
-usage(void)
-{
- fprint(2, "usage: fmtindex config\n");
- threadexitsall(0);
-}
-
-void
-threadmain(int argc, char *argv[])
-{
- Config conf;
- Index *ix;
- ArenaPart *ap;
- Arena **arenas;
- AMap *amap;
- u64int addr;
- char *file;
- u32int i, j, n, narenas;
- int add;
-
- fmtinstall('V', vtscorefmt);
- statsinit();
-
- add = 0;
- ARGBEGIN{
- case 'a':
- add = 1;
- break;
- default:
- usage();
- break;
- }ARGEND
-
- if(argc != 1)
- usage();
-
- file = argv[0];
-
- if(runconfig(file, &conf) < 0)
- sysfatal("can't initialize config %s: %r", file);
- if(conf.index == nil)
- sysfatal("no index specified in %s", file);
- if(nameok(conf.index) < 0)
- sysfatal("illegal index name %s", conf.index);
-
- narenas = 0;
- for(i = 0; i < conf.naparts; i++){
- ap = conf.aparts[i];
- narenas += ap->narenas;
- }
-
- if(add){
- ix = initindex(conf.index, conf.sects, conf.nsects);
- if(ix == nil)
- sysfatal("can't initialize index %s: %r", conf.index);
- }else{
- ix = newindex(conf.index, conf.sects, conf.nsects);
- if(ix == nil)
- sysfatal("can't create new index %s: %r", conf.index);
-
- n = 0;
- for(i = 0; i < ix->nsects; i++)
- n += ix->sects[i]->blocks;
-
- fprint(2, "using %ud buckets of %ud; div=%d\n", ix->buckets, n, ix->div);
- }
- amap = MKNZ(AMap, narenas);
- arenas = MKNZ(Arena*, narenas);
-
- addr = IndexBase;
- n = 0;
- for(i = 0; i < conf.naparts; i++){
- ap = conf.aparts[i];
- for(j = 0; j < ap->narenas; j++){
- if(n >= narenas)
- sysfatal("too few slots in index's arena set");
-
- arenas[n] = ap->arenas[j];
- if(n < ix->narenas){
- if(arenas[n] != ix->arenas[n])
- sysfatal("mismatched arenas %s and %s at slot %d\n",
- arenas[n]->name, ix->arenas[n]->name, n);
- amap[n] = ix->amap[n];
- if(amap[n].start != addr)
- sysfatal("mis-located arena %s in index %s\n", arenas[n]->name, ix->name);
- addr = amap[n].stop;
- }else{
- amap[n].start = addr;
- addr += ap->arenas[j]->size;
- amap[n].stop = addr;
- namecp(amap[n].name, ap->arenas[j]->name);
- fprint(2, "add arena %s at [%lld,%lld)\n",
- amap[n].name, amap[n].start, amap[n].stop);
- }
-
- n++;
- }
- }
- fprint(2, "configured index=%s with arenas=%d and storage=%lld\n",
- ix->name, n, addr - IndexBase);
- fprint(2, "\tbitblocks=%d maxdepth=%d buckets=%d\n",
- ix->bitblocks, ix->maxdepth, ix->buckets);
-
- ix->amap = amap;
- ix->arenas = arenas;
- ix->narenas = narenas;
-
- if(wbindex(ix) < 0)
- fprint(2, "can't write back arena partition header for %s: %r\n", file);
-
- threadexitsall(0);
-}