Blob


1 #include "stdinc.h"
2 #include "dat.h"
3 #include "fns.h"
5 static int verbose;
6 void
7 usage(void)
8 {
9 fprint(2, "usage: syncindex [-fv] [-B blockcachesize] config\n");
10 threadexitsall("usage");
11 }
13 void
14 threadmain(int argc, char *argv[])
15 {
16 u32int bcmem;
17 int fix;
19 fix = 0;
20 bcmem = 0;
21 ARGBEGIN{
22 case 'B':
23 bcmem = unittoull(ARGF());
24 break;
25 case 'f':
26 fix++;
27 break;
28 case 'v':
29 verbose++;
30 break;
31 default:
32 usage();
33 break;
34 }ARGEND
36 if(!fix)
37 readonly = 1;
39 if(argc != 1)
40 usage();
42 if(initventi(argv[0]) < 0)
43 sysfatal("can't init venti: %r");
45 if(bcmem < maxblocksize * (mainindex->narenas + mainindex->nsects * 4 + 16))
46 bcmem = maxblocksize * (mainindex->narenas + mainindex->nsects * 4 + 16);
47 fprint(2, "initialize %d bytes of disk block cache\n", bcmem);
48 initdcache(bcmem);
50 if(verbose)
51 printindex(2, mainindex);
52 if(syncindex(mainindex, fix) < 0)
53 sysfatal("failed to sync index=%s: %r\n", mainindex->name);
55 threadexitsall(0);
56 }