5 static char vcmagic[] = "venti config\n";
9 Maglen = sizeof vcmagic - 1,
13 readifile(IFile *f, char *name)
19 p = initpart(name, OREAD);
22 b = alloczblock(Maxconfig+1, 1, 0);
24 seterr(EOk, "can't alloc for %s: %R", name);
27 if(p->size > PartBlank){
29 * this is likely a real venti partition, in which case we're
30 * looking for the config file stored as 8k at end of PartBlank.
32 if(readpart(p, PartBlank-Maxconfig, b->data, Maxconfig) < 0){
33 seterr(EOk, "can't read %s: %r", name);
38 b->data[Maxconfig] = '\0';
39 if(memcmp(b->data, vcmagic, Maglen) != 0){
40 seterr(EOk, "bad venti config magic in %s", name);
46 * if we change b->data+b->_size, freezblock
47 * will blow an assertion, so don't.
52 z = memchr(b->data, '\0', b->len);
55 }else if(p->size > Maxconfig){
56 seterr(EOk, "config file is too large");
84 partifile(IFile *f, Part *part, u64int start, u32int size)
88 b = alloczblock(size, 0, part->blocksize);
91 if(readpart(part, start, b->data, size) < 0){
92 seterr(EAdmin, "can't read %s: %r", part->name);
103 * return the next non-blank input line,
104 * stripped of leading white space and with # comments eliminated
113 s = (char*)&f->b->data[f->pos];
114 e = memchr(s, '\n', f->b->len - f->pos);
118 f->pos = e - (char*)f->b->data;
123 if(c != ' ' && c != '\t' && c != '\r')
129 ifilename(IFile *f, char *dst)
134 if(s == nil || strlen(s) >= ANameSize)
141 ifileu32int(IFile *f, u32int *r)
148 return stru32int(s, r);