diff options
| author | rsc <devnull@localhost> | 2005-07-12 15:23:36 +0000 |
|---|---|---|
| committer | rsc <devnull@localhost> | 2005-07-12 15:23:36 +0000 |
| commit | a0d146edd7a7de6236a0d60baafeeb59f8452aae (patch) | |
| tree | b55baa526d9f5adfc73246e6ee2fadf455e0b7a2 /src/cmd/venti/mkroot.c | |
| parent | 88bb285e3d87ec2508840af33f7e0af53ec3c13c (diff) | |
| download | plan9port-a0d146edd7a7de6236a0d60baafeeb59f8452aae.tar.gz plan9port-a0d146edd7a7de6236a0d60baafeeb59f8452aae.zip | |
return of venti
Diffstat (limited to 'src/cmd/venti/mkroot.c')
| -rw-r--r-- | src/cmd/venti/mkroot.c | 59 |
1 files changed, 59 insertions, 0 deletions
diff --git a/src/cmd/venti/mkroot.c b/src/cmd/venti/mkroot.c new file mode 100644 index 00000000..f18cbf35 --- /dev/null +++ b/src/cmd/venti/mkroot.c @@ -0,0 +1,59 @@ +#include "stdinc.h" +#include "dat.h" +#include "fns.h" + +char *host; + +void +usage(void) +{ + fprint(2, "usage: mkroot [-h host] name type score blocksize prev\n"); + threadexitsall("usage"); +} + +void +threadmain(int argc, char *argv[]) +{ + uchar score[VtScoreSize]; + uchar buf[VtRootSize]; + VtConn *z; + VtRoot root; + + ARGBEGIN{ + case 'h': + host = EARGF(usage()); + break; + default: + usage(); + break; + }ARGEND + + if(argc != 5) + usage(); + + ventifmtinstall(); + + strecpy(root.name, root.name+sizeof root.name, argv[0]); + strecpy(root.type, root.type+sizeof root.type, argv[1]); + if(vtparsescore(argv[2], strlen(argv[2]), nil, root.score) < 0) + sysfatal("bad score '%s'", argv[2]); + root.blocksize = atoi(argv[3]); + if(vtparsescore(argv[4], strlen(argv[4]), nil, root.prev) < 0) + sysfatal("bad score '%s'", argv[4]); + vtrootpack(&root, buf); + + z = vtdial(host); + if(z == nil) + sysfatal("could not connect to server: %r"); + + if(vtconnect(z) < 0) + sysfatal("vtconnect: %r"); + + if(vtwrite(z, score, VtRootType, buf, VtRootSize) < 0) + sysfatal("vtwrite: %r"); + if(vtsync(z) < 0) + sysfatal("vtsync: %r"); + vthangup(z); + print("%V\n", score); + threadexitsall(0); +} |
