6 int paranoid = 1; /* should verify hashes on disk read */
8 static ArenaPart *configarenas(char *file);
9 static ISect *configisect(char *file);
10 static Bloom *configbloom(char *file);
13 initventi(char *file, Config *conf)
18 seterr(EOk, "no configuration file");
21 if(runconfig(file, conf) < 0){
22 seterr(EOk, "can't initialize venti: %r");
25 mainindex = initindex(conf->index, conf->sects, conf->nsects);
28 mainindex->bloom = conf->bloom;
42 if(p[1] == 0 && strchr("MmGgKk", *p))
50 * config : "isect" filename
57 * | "httpaddr" address
60 * '#' and \n delimit comments
67 runconfig(char *file, Config *config)
72 char *s, *line, *flds[MaxArgs + 1];
75 if(readifile(&f, file) < 0)
77 memset(config, 0, sizeof *config);
78 config->mem = 0xFFFFFFFFUL;
88 i = getfields(s, flds, MaxArgs + 1, 1, " \t\r");
89 if(i == 2 && strcmp(flds[0], "isect") == 0){
90 sv = MKN(ISect*, config->nsects + 1);
91 for(i = 0; i < config->nsects; i++)
92 sv[i] = config->sects[i];
95 config->sects[config->nsects] = configisect(flds[1]);
96 if(config->sects[config->nsects] == nil)
99 }else if(i == 2 && strcmp(flds[0], "arenas") == 0){
100 av = MKN(ArenaPart*, config->naparts + 1);
101 for(i = 0; i < config->naparts; i++)
102 av[i] = config->aparts[i];
103 free(config->aparts);
105 config->aparts[config->naparts] = configarenas(flds[1]);
106 if(config->aparts[config->naparts] == nil)
109 }else if(i == 2 && strcmp(flds[0], "bloom") == 0){
111 seterr(EAdmin, "duplicate bloom lines in configuration file %s", file);
114 if((config->bloom = configbloom(flds[1])) == nil)
116 }else if(i == 2 && strcmp(flds[0], "index") == 0){
117 if(nameok(flds[1]) < 0){
118 seterr(EAdmin, "illegal index name %s in config file %s", flds[1], file);
121 if(config->index != nil){
122 seterr(EAdmin, "duplicate indices in config file %s", file);
125 config->index = estrdup(flds[1]);
126 }else if(i == 2 && strcmp(flds[0], "bcmem") == 0){
127 if(numok(flds[1]) < 0){
128 seterr(EAdmin, "illegal size %s in config file %s",
132 if(config->bcmem != 0){
133 seterr(EAdmin, "duplicate bcmem lines in config file %s", file);
136 config->bcmem = unittoull(flds[1]);
137 }else if(i == 2 && strcmp(flds[0], "mem") == 0){
138 if(numok(flds[1]) < 0){
139 seterr(EAdmin, "illegal size %s in config file %s",
143 if(config->mem != 0xFFFFFFFFUL){
144 seterr(EAdmin, "duplicate mem lines in config file %s", file);
147 config->mem = unittoull(flds[1]);
148 }else if(i == 2 && strcmp(flds[0], "icmem") == 0){
149 if(numok(flds[1]) < 0){
150 seterr(EAdmin, "illegal size %s in config file %s",
154 if(config->icmem != 0){
155 seterr(EAdmin, "duplicate icmem lines in config file %s", file);
158 config->icmem = unittoull(flds[1]);
159 }else if(i == 1 && strcmp(flds[0], "queuewrites") == 0){
160 config->queuewrites = 1;
161 }else if(i == 2 && strcmp(flds[0], "httpaddr") == 0){
163 seterr(EAdmin, "duplicate httpaddr lines in configuration file %s", file);
166 config->haddr = estrdup(flds[1]);
167 }else if(i == 2 && strcmp(flds[0], "webroot") == 0){
169 seterr(EAdmin, "duplicate webroot lines in configuration file %s", file);
172 config->webroot = estrdup(flds[1]);
173 }else if(i == 2 && strcmp(flds[0], "addr") == 0){
175 seterr(EAdmin, "duplicate addr lines in configuration file %s", file);
178 config->vaddr = estrdup(flds[1]);
180 seterr(EAdmin, "illegal line '%s' in configuration file %s", line, file);
191 free(config->aparts);
192 config->aparts = nil;
198 configisect(char *file)
203 if(0) fprint(2, "configure index section in %s\n", file);
205 part = initpart(file, ORDWR|ODIRECT);
208 is = initisect(part);
210 werrstr("%s: %r", file);
215 configarenas(char *file)
220 if(0) fprint(2, "configure arenas in %s\n", file);
221 part = initpart(file, ORDWR|ODIRECT);
224 ap = initarenapart(part);
226 werrstr("%s: %r", file);
231 configbloom(char *file)
236 if(0) fprint(2, "configure bloom in %s\n", file);
237 part = initpart(file, ORDWR|ODIRECT);
242 werrstr("%s: %r", file);