void threadmain(int argc, char *argv[]) { uint32_t bcmem; bcmem = 0; ARGBEGIN{ case 'B': bcmem = unittoull(ARGF()); break; default: usage(); break; }ARGEND readonly = 1; if(argc != 1) usage(); if(initventi(argv[0], &conf) < 0) sysfatal("can't init venti: %r"); if(bcmem < maxblocksize * (mainindex->narenas + mainindex->nsects * 4 + 16)) bcmem = maxblocksize * (mainindex->narenas + mainindex->nsects * 4 + 16); if(0) fprint(2, "initialize %d bytes of disk block cache\n", bcmem); initdcache(bcmem); clumpstats(mainindex); threadexitsall(0); }
void threadmain(int argc, char *argv[]) { u32int bcmem; int fix; fix = 0; bcmem = 0; ARGBEGIN{ case 'B': bcmem = unittoull(ARGF()); break; default: usage(); break; }ARGEND if(!fix) readonly = 1; if(argc != 1) usage(); if(initventi(argv[0], &conf) < 0) sysfatal("can't init venti: %r"); printindex(1, mainindex); threadexitsall(0); }
void threadmain(int argc, char *argv[]) { int i; Index *ix; u32int bcmem; bcmem = 0; ARGBEGIN{ case 'B': bcmem = unittoull(ARGF()); break; default: usage(); break; }ARGEND if(argc < 1) usage(); fmtinstall('H', encodefmt); if(initventi(argv[0], &conf) < 0) sysfatal("can't init venti: %r"); if(bcmem < maxblocksize * (mainindex->narenas + mainindex->nsects * 4 + 16)) bcmem = maxblocksize * (mainindex->narenas + mainindex->nsects * 4 + 16); if(0) fprint(2, "initialize %d bytes of disk block cache\n", bcmem); initdcache(bcmem); ix = mainindex; Binit(&bout, 1, OWRITE); for(i=0; i<ix->nsects; i++) if(shoulddump(ix->sects[i]->name, argc-1, argv+1)) dumpisect(ix->sects[i]); Bterm(&bout); threadexitsall(0); }
void threadmain(int argc, char **argv) { int i, j, fd, n, printstats; Dir *d; char *s; uint64_t u; VacFile *f, *fdiff; VacFs *fsdiff; int blocksize; int outfd; char *stdinname; char *diffvac; uint64_t qid; fmtinstall('F', vtfcallfmt); fmtinstall('H', encodefmt); fmtinstall('V', vtscorefmt); blocksize = BlockSize; stdinname = nil; printstats = 0; fsdiff = nil; diffvac = nil; ARGBEGIN{ case 'V': chattyventi++; break; case 'a': archivefile = EARGF(usage()); break; case 'b': u = unittoull(EARGF(usage())); if(u < 512) u = 512; if(u > VtMaxLumpSize) u = VtMaxLumpSize; blocksize = u; break; case 'd': diffvac = EARGF(usage()); break; case 'e': excludepattern(EARGF(usage())); break; case 'f': vacfile = EARGF(usage()); break; case 'h': host = EARGF(usage()); break; case 'i': stdinname = EARGF(usage()); break; case 'm': merge++; break; case 'q': qdiff++; break; case 's': printstats++; break; case 'v': verbose++; break; case 'x': loadexcludefile(EARGF(usage())); break; default: usage(); }ARGEND if(argc == 0 && !stdinname) usage(); if(archivefile && (vacfile || diffvac)){ fprint(2, "cannot use -a with -f, -d\n"); usage(); } z = vtdial(host); if(z == nil) sysfatal("could not connect to server: %r"); if(vtconnect(z) < 0) sysfatal("vtconnect: %r"); // Setup: // fs is the output vac file system // f is directory in output vac to write new files // fdiff is corresponding directory in existing vac if(archivefile){ VacFile *fp; char yyyy[5]; char mmdd[10]; char oldpath[40]; Tm tm; fdiff = nil; if((outfd = open(archivefile, ORDWR)) < 0){ if(access(archivefile, 0) >= 0) sysfatal("open %s: %r", archivefile); if((outfd = create(archivefile, OWRITE, 0666)) < 0) sysfatal("create %s: %r", archivefile); atexit(removevacfile); // because it is new if((fs = vacfscreate(z, blocksize, 512)) == nil) sysfatal("vacfscreate: %r"); }else{ if((fs = vacfsopen(z, archivefile, VtORDWR, 512)) == nil) sysfatal("vacfsopen %s: %r", archivefile); if((fdiff = recentarchive(fs, oldpath)) != nil){ if(verbose) fprint(2, "diff %s\n", oldpath); }else if(verbose) fprint(2, "no recent archive to diff against\n"); } // Create yyyy/mmdd. tm = *localtime(time(0)); snprint(yyyy, sizeof yyyy, "%04d", tm.year+1900); fp = vacfsgetroot(fs); if((f = vacfilewalk(fp, yyyy)) == nil && (f = vacfilecreate(fp, yyyy, ModeDir|0555)) == nil) sysfatal("vacfscreate %s: %r", yyyy); vacfiledecref(fp); fp = f; snprint(mmdd, sizeof mmdd, "%02d%02d", tm.mon+1, tm.mday); n = 0; while((f = vacfilewalk(fp, mmdd)) != nil){ vacfiledecref(f); n++; snprint(mmdd+4, sizeof mmdd-4, ".%d", n); } f = vacfilecreate(fp, mmdd, ModeDir|0555); if(f == nil) sysfatal("vacfscreate %s/%s: %r", yyyy, mmdd); vacfiledecref(fp); if(verbose) fprint(2, "archive %s/%s\n", yyyy, mmdd); }else{ if(vacfile == nil) outfd = 1; else if((outfd = create(vacfile, OWRITE, 0666)) < 0) sysfatal("create %s: %r", vacfile); atexit(removevacfile); if((fs = vacfscreate(z, blocksize, 512)) == nil) sysfatal("vacfscreate: %r"); f = vacfsgetroot(fs); fdiff = nil; if(diffvac){ if((fsdiff = vacfsopen(z, diffvac, VtOREAD, 128)) == nil) warn("vacfsopen %s: %r", diffvac); else fdiff = vacfsgetroot(fsdiff); } } if(stdinname) vacstdin(f, stdinname); for(i=0; i<argc; i++){ // We can't use / and . and .. and ../.. as valid archive // names, so expand to the list of files in the directory. if(argv[i][0] == 0){ warn("empty string given as command-line argument"); continue; } cleanname(argv[i]); if(strcmp(argv[i], "/") == 0 || strcmp(argv[i], ".") == 0 || strcmp(argv[i], "..") == 0 || (strlen(argv[i]) > 3 && strcmp(argv[i]+strlen(argv[i])-3, "/..") == 0)){ if((fd = open(argv[i], OREAD)) < 0){ warn("open %s: %r", argv[i]); continue; } while((n = dirread(fd, &d)) > 0){ for(j=0; j<n; j++){ s = vtmalloc(strlen(argv[i])+1+strlen(d[j].name)+1); strcpy(s, argv[i]); strcat(s, "/"); strcat(s, d[j].name); cleanname(s); vac(f, fdiff, s, &d[j]); } free(d); } close(fd); continue; } if((d = dirstat(argv[i])) == nil){ warn("stat %s: %r", argv[i]); continue; } vac(f, fdiff, argv[i], d); free(d); } if(fdiff) vacfiledecref(fdiff); /* * Record the maximum qid so that vacs can be merged * without introducing overlapping qids. Older versions * of vac arranged that the root would have the largest * qid in the file system, but we can't do that anymore * (the root gets created first!). */ if(_vacfsnextqid(fs, &qid) >= 0) vacfilesetqidspace(f, 0, qid); vacfiledecref(f); /* * Copy fsdiff's root block score into fs's slot for that, * so that vacfssync will copy it into root.prev for us. * Just nice documentation, no effect. */ if(fsdiff) memmove(fs->score, fsdiff->score, VtScoreSize); if(vacfssync(fs) < 0) fprint(2, "vacfssync: %r\n"); fprint(outfd, "vac:%V\n", fs->score); atexitdont(removevacfile); vacfsclose(fs); vthangup(z); if(printstats){ fprint(2, "%d files, %d files skipped, %d directories\n" "%lld data bytes written, %lld data bytes skipped\n", stats.nfile, stats.skipfiles, stats.ndir, stats.data, stats.skipdata); dup(2, 1); packetstats(); } threadexitsall(0); }
void threadmain(int argc, char *argv[]) { int vers; ArenaPart *ap; Part *part; Arena *arena; uint64_t addr, limit, asize, apsize; char *file, *name, aname[ANameSize]; int i, n, blocksize, tabsize, zero; ventifmtinstall(); statsinit(); blocksize = 8 * 1024; asize = 512 * 1024 *1024; tabsize = 512 * 1024; /* BUG: should be determine from number of arenas */ zero = -1; vers = ArenaVersion5; ARGBEGIN{ case 'D': settrace(EARGF(usage())); break; case 'a': asize = unittoull(EARGF(usage())); if(asize == TWID64) usage(); break; case 'b': blocksize = unittoull(EARGF(usage())); if(blocksize == ~0) usage(); if(blocksize > MaxDiskBlock){ fprint(2, "block size too large, max %d\n", MaxDiskBlock); threadexitsall("usage"); } break; case '4': vers = ArenaVersion4; break; case 'Z': zero = 0; break; default: usage(); break; }ARGEND if(zero == -1){ if(vers == ArenaVersion4) zero = 1; else zero = 0; } if(argc != 2) usage(); name = argv[0]; file = argv[1]; if(nameok(name) < 0) sysfatal("illegal name template %s", name); part = initpart(file, ORDWR|ODIRECT); if(part == nil) sysfatal("can't open partition %s: %r", file); if(zero) zeropart(part, blocksize); maxblocksize = blocksize; initdcache(20*blocksize); ap = newarenapart(part, blocksize, tabsize); if(ap == nil) sysfatal("can't initialize arena: %r"); apsize = ap->size - ap->arenabase; n = apsize / asize; if(apsize - (n * asize) >= MinArenaSize) n++; fprint(2, "fmtarenas %s: %,d arenas, %,lld bytes storage, %,d bytes for index map\n", file, n, apsize, ap->tabsize); ap->narenas = n; ap->map = MKNZ(AMap, n); ap->arenas = MKNZ(Arena*, n); addr = ap->arenabase; for(i = 0; i < n; i++){ limit = addr + asize; if(limit >= ap->size || ap->size - limit < MinArenaSize){ limit = ap->size; if(limit - addr < MinArenaSize) sysfatal("bad arena set math: runt arena at %lld,%lld %lld", addr, limit, ap->size); } snprint(aname, ANameSize, "%s%d", name, i); if(0) fprint(2, "adding arena %s at [%lld,%lld)\n", aname, addr, limit); arena = newarena(part, vers, aname, addr, limit - addr, blocksize); if(!arena) fprint(2, "can't make new arena %s: %r", aname); freearena(arena); ap->map[i].start = addr; ap->map[i].stop = limit; namecp(ap->map[i].name, aname); addr = limit; } if(wbarenapart(ap) < 0) fprint(2, "can't write back arena partition header for %s: %r\n", file); flushdcache(); threadexitsall(0); }
void main(int argc, char *argv[]) { int fd, i; int n = 1000, m; int s = 1; double *t, t0, t1; unsigned char *buf; double a, d, max, min; m = OREAD; ARGBEGIN{ case 'n': n = atoi(ARGF()); break; case 's': s = unittoull(ARGF()); if(s < 1 || s > 1024*1024) sysfatal("bad size"); break; case 'r': m = OREAD; break; case 'w': m = OWRITE; break; }ARGEND fd = 0; if(argc == 1){ fd = open(argv[0], m); if(fd < 0) sysfatal("could not open file: %s: %r", argv[0]); } buf = malloc(s); t = malloc(n*sizeof(double)); t0 = nsec(); for(i=0; i<n; i++){ if(m == OREAD){ if(pread(fd, buf, s, 0) < s) sysfatal("bad read: %r"); }else{ if(pwrite(fd, buf, s, 0) < s) sysfatal("bad write: %r"); } t1 = nsec(); t[i] = (t1 - t0)*1e-3; t0 = t1; } a = 0.; d = 0.; max = 0.; min = 1e12; for(i=0; i<n; i++){ a += t[i]; if(max < t[i]) max = t[i]; if(min > t[i]) min = t[i]; } a /= n; for(i=0; i<n; i++) d += (a - t[i]) * (a - t[i]); d /= n; d = sqrt(d); print("avg = %.0fµs min = %.0fµs max = %.0fµs dev = %.0fµs\n", a, min, max, d); exits(0); }
void main(int argc, char *argv[]) { int fd, force; Header h; ulong bn; Entry e; char *label = "vfs"; char *host = nil; char *score = nil; u32int root; Dir *d; force = 0; ARGBEGIN{ default: usage(); case 'b': bsize = unittoull(EARGF(usage())); if(bsize == ~0) usage(); break; case 'h': host = EARGF(usage()); break; case 'i': iso9660file = EARGF(usage()); iso9660off = atoi(EARGF(usage())); break; case 'l': label = EARGF(usage()); break; case 'v': score = EARGF(usage()); break; /* * This is -y instead of -f because flchk has a * (frequently used) -f option. I type flfmt instead * of flchk all the time, and want to make it hard * to reformat my file system accidentally. */ case 'y': force = 1; break; }ARGEND if(argc != 1) usage(); if(iso9660file && score) vtFatal("cannot use -i with -v"); vtAttach(); fmtinstall('V', scoreFmt); fmtinstall('R', vtErrFmt); fmtinstall('L', labelFmt); fd = open(argv[0], ORDWR); if(fd < 0) vtFatal("could not open file: %s: %r", argv[0]); buf = vtMemAllocZ(bsize); if(pread(fd, buf, bsize, HeaderOffset) != bsize) vtFatal("could not read fs header block: %r"); if(headerUnpack(&h, buf) && !force && !confirm("fs header block already exists; are you sure?")) goto Out; if((d = dirfstat(fd)) == nil) vtFatal("dirfstat: %r"); if(d->type == 'M' && !force && !confirm("fs file is mounted via devmnt (is not a kernel device); are you sure?")) goto Out; partition(fd, bsize, &h); headerPack(&h, buf); if(pwrite(fd, buf, bsize, HeaderOffset) < bsize) vtFatal("could not write fs header: %r"); disk = diskAlloc(fd); if(disk == nil) vtFatal("could not open disk: %r"); if(iso9660file) iso9660init(fd, &h, iso9660file, iso9660off); /* zero labels */ memset(buf, 0, bsize); for(bn = 0; bn < diskSize(disk, PartLabel); bn++) blockWrite(PartLabel, bn); if(iso9660file) iso9660labels(disk, buf, blockWrite); if(score) root = ventiRoot(host, score); else{ rootMetaInit(&e); root = rootInit(&e); } superInit(label, root, vtZeroScore); diskFree(disk); if(score == nil) topLevel(argv[0]); Out: vtDetach(); exits(0); }
void threadmain(int argc, char *argv[]) { char *defsrv, *srvname; int p[2], fd; int stdio; char *host = nil; ulong mem; mem = 16<<20; stdio = 0; fmtinstall('H', encodefmt); fmtinstall('V', vtscorefmt); fmtinstall('F', vtfcallfmt); defmnt = nil; defsrv = nil; ARGBEGIN{ case 'd': fmtinstall('F', fcallfmt); dflag = 1; break; case 'i': defmnt = nil; stdio = 1; mfd[0] = 0; mfd[1] = 1; break; case 'h': host = EARGF(usage()); break; case 'S': defsrv = EARGF(usage()); break; case 's': defsrv = "vacfs"; break; case 'M': mem = unittoull(EARGF(usage())); break; case 'm': defmnt = EARGF(usage()); break; case 'p': noperm = 1; break; case 'V': chattyventi = 1; break; default: usage(); }ARGEND if(argc != 1) usage(); #ifdef PLAN9PORT if(defsrv == nil && defmnt == nil && !stdio){ srvname = strchr(argv[0], '/'); if(srvname) srvname++; else srvname = argv[0]; defsrv = vtmalloc(6+strlen(srvname)+1); strcpy(defsrv, "vacfs."); strcat(defsrv, srvname); if(strcmp(defsrv+strlen(defsrv)-4, ".vac") == 0) defsrv[strlen(defsrv)-4] = 0; } #else if(defsrv == nil && defmnt == nil && !stdio) defmnt = "/n/vac"; #endif if(stdio && defmnt) sysfatal("cannot use -m with -i"); initfcalls(); notify(notifyf); user = getuser(); conn = vtdial(host); if(conn == nil) sysfatal("could not connect to server: %r"); if(vtconnect(conn) < 0) sysfatal("vtconnect: %r"); fs = vacfsopen(conn, argv[0], VtOREAD, mem); if(fs == nil) sysfatal("vacfsopen: %r"); if(!stdio){ if(pipe(p) < 0) sysfatal("pipe failed: %r"); mfd[0] = p[0]; mfd[1] = p[0]; srvfd = p[1]; #ifndef PLAN9PORT if(defsrv){ srvname = smprint("/srv/%s", defsrv); fd = create(srvname, OWRITE|ORCLOSE, 0666); if(fd < 0) sysfatal("create %s: %r", srvname); if(fprint(fd, "%d", srvfd) < 0) sysfatal("write %s: %r", srvname); free(srvname); } #endif } #ifdef PLAN9PORT USED(fd); proccreate(srv, 0, 32 * 1024); if(!stdio && post9pservice(p[1], defsrv, defmnt) < 0) sysfatal("post9pservice"); #else procrfork(srv, 0, 32 * 1024, RFFDG|RFNAMEG|RFNOTEG); if(!stdio){ close(p[0]); if(defmnt){ if(mount(srvfd, -1, defmnt, MREPL|MCREATE, "") < 0) sysfatal("mount %s: %r", defmnt); } } #endif threadexits(0); }
void threadmain(int argc, char *argv[]) { char *configfile, *haddr, *vaddr, *webroot; u32int mem, icmem, bcmem, minbcmem, mempcnt, stfree; Allocs allocs; Config config; traceinit(); threadsetname("main"); mempcnt = 0; vaddr = nil; haddr = nil; configfile = nil; webroot = nil; mem = Unspecified; icmem = 0; bcmem = 0; ARGBEGIN{ case 'a': vaddr = EARGF(usage()); break; case 'B': bcmem = unittoull(EARGF(usage())); break; case 'c': configfile = EARGF(usage()); break; case 'C': mem = unittoull(EARGF(usage())); break; case 'D': settrace(EARGF(usage())); break; case 'd': debug = 1; nofork = 1; break; case 'h': haddr = EARGF(usage()); break; case 'm': mempcnt = atoi(EARGF(usage())); if (mempcnt <= 0 || mempcnt >= 100) usage(); break; case 'I': icmem = unittoull(EARGF(usage())); break; case 'L': ventilogging = 1; break; case 'r': readonly = 1; break; case 's': nofork = 1; break; case 'w': /* compatibility with old venti */ queuewrites = 1; break; case 'W': webroot = EARGF(usage()); break; default: usage(); }ARGEND if(argc) usage(); if(!nofork) rfork(RFNOTEG); #ifdef PLAN9PORT { /* sigh - needed to avoid signals when writing to hungup networks */ struct sigaction sa; memset(&sa, 0, sizeof sa); sa.sa_handler = SIG_IGN; sigaction(SIGPIPE, &sa, nil); } #endif ventifmtinstall(); trace(TraceQuiet, "venti started"); fprint(2, "%T venti: "); if(configfile == nil) configfile = "venti.conf"; /* remember free memory before initventi & loadbloom, for auto-sizing */ stfree = freemem(); fprint(2, "conf..."); if(initventi(configfile, &config) < 0) sysfatal("can't init server: %r"); /* * load bloom filter */ if(mainindex->bloom && loadbloom(mainindex->bloom) < 0) sysfatal("can't load bloom filter: %r"); /* * size memory allocations; assumes bloom filter is loaded */ allocs = sizeallocs((Allocs){mem, bcmem, icmem, stfree, mempcnt}, &config); mem = allocs.mem; bcmem = allocs.bcmem; icmem = allocs.icmem; fprint(2, "%s: mem %,ud bcmem %,ud icmem %,ud...", argv0, mem, bcmem, icmem); /* * default other configuration-file parameters */ if(haddr == nil) haddr = config.haddr; if(vaddr == nil) vaddr = config.vaddr; if(vaddr == nil) vaddr = "tcp!*!venti"; if(webroot == nil) webroot = config.webroot; if(queuewrites == 0) queuewrites = config.queuewrites; if(haddr){ fprint(2, "httpd %s...", haddr); if(httpdinit(haddr, webroot) < 0) fprint(2, "warning: can't start http server: %r"); } fprint(2, "init..."); /* * lump cache */ if(0) fprint(2, "initialize %d bytes of lump cache for %d lumps\n", mem, mem / (8 * 1024)); initlumpcache(mem, mem / (8 * 1024)); /* * index cache */ initicache(icmem); initicachewrite(); /* * block cache: need a block for every arena and every process */ minbcmem = maxblocksize * (mainindex->narenas + mainindex->nsects*4 + 16); if(bcmem < minbcmem) bcmem = minbcmem; if(0) fprint(2, "initialize %d bytes of disk block cache\n", bcmem); initdcache(bcmem); if(mainindex->bloom) startbloomproc(mainindex->bloom); fprint(2, "sync..."); if(!readonly && syncindex(mainindex) < 0) sysfatal("can't sync server: %r"); if(!readonly && queuewrites){ fprint(2, "queue..."); if(initlumpqueues(mainindex->nsects) < 0){ fprint(2, "can't initialize lump queues," " disabling write queueing: %r"); queuewrites = 0; } } if(initarenasum() < 0) fprint(2, "warning: can't initialize arena summing process: %r"); fprint(2, "announce %s...", vaddr); ventisrv = vtlisten(vaddr); if(ventisrv == nil) sysfatal("can't announce %s: %r", vaddr); fprint(2, "serving.\n"); if(nofork) ventiserver(nil); else vtproc(ventiserver, nil); threadexits(nil); }
void threadmain(int argc, char *argv[]) { int i, nline; char *p, *q, *table, *table1, *f[10], line[256]; vlong start, stop; ArenaPart ap; ArenaPart ap1; ventifmtinstall(); blocksize = MaxIoSize; ARGBEGIN{ case 'b': blocksize = unittoull(EARGF(usage())); break; case 's': sleepms = atoi(EARGF(usage())); break; case 'v': verbose++; break; default: usage(); break; }ARGEND if(argc < 2) usage(); data = vtmalloc(blocksize); data1 = vtmalloc(blocksize); if((fd = open(argv[0], OREAD)) < 0) sysfatal("open %s: %r", argv[0]); if((fd1 = open(argv[1], OREAD)) < 0) sysfatal("open %s: %r", argv[0]); table = readap(fd, &ap); table1 = readap(fd1, &ap1); if(strcmp(table, table1) != 0) sysfatal("arena partitions do not have identical tables"); nline = atoi(table); p = strchr(table, '\n'); if(p) p++; for(i=0; i<nline; i++){ if(p == nil){ fprint(2, "warning: unexpected arena table end\n"); break; } q = strchr(p, '\n'); if(q) *q++ = 0; if(strlen(p) >= sizeof line){ fprint(2, "warning: long arena table line: %s\n", p); p = q; continue; } strcpy(line, p); memset(f, 0, sizeof f); if(tokenize(line, f, nelem(f)) < 3){ fprint(2, "warning: bad arena table line: %s\n", p); p = q; continue; } p = q; if(shouldcheck(f[0], argv+1, argc-1)){ start = strtoull(f[1], 0, 0); stop = strtoull(f[2], 0, 0); if(stop <= start){ fprint(2, "%s: bad start,stop %lld,%lld\n", f[0], stop, start); continue; } if(seek(fd, start, 0) < 0) fprint(2, "%s: seek to start: %r\n", f[0]); if(seek(fd1, start, 0) < 0) fprint(2, "%s: seek to start: %r\n", f[0]); cmparena(f[0], stop - start); } } for(i=2; i<argc; i++) if(argv[i] != 0) fprint(2, "%s: did not find arena\n", argv[i]); threadexitsall(nil); }
void threadmain(int argc, char *argv[]) { int vers; ISect *is; Part *part; char *file, *name; int blocksize, setsize, zero; ventifmtinstall(); statsinit(); blocksize = 8 * 1024; setsize = 512 * 1024; zero = -1; vers = ISectVersion2; ARGBEGIN{ case 'b': blocksize = unittoull(ARGF()); if(blocksize == ~0) usage(); if(blocksize > MaxDiskBlock){ fprint(2, "block size too large, max %d\n", MaxDiskBlock); threadexitsall("usage"); } break; case '1': vers = ISectVersion1; break; case 'Z': zero = 0; break; default: usage(); break; }ARGEND if(zero == -1){ if(vers == ISectVersion1) zero = 1; else zero = 0; } if(argc != 2) usage(); name = argv[0]; file = argv[1]; if(nameok(name) < 0) sysfatal("illegal name %s", name); part = initpart(file, ORDWR|ODIRECT); if(part == nil) sysfatal("can't open partition %s: %r", file); if(zero) zeropart(part, blocksize); is = newisect(part, vers, name, blocksize, setsize); if(is == nil) sysfatal("can't initialize new index: %r"); fprint(2, "fmtisect %s: %,d buckets of %,d entries, %,d bytes for index map\n", file, is->blocks, is->buckmax, setsize); if(wbisect(is) < 0) fprint(2, "can't write back index section header for %s: %r\n", file); threadexitsall(0); }