]> git.lizzy.rs Git - plan9front.git/blob - sys/src/cmd/venti/sync.c
merge
[plan9front.git] / sys / src / cmd / venti / sync.c
1 #include <u.h>
2 #include <libc.h>
3 #include <thread.h>
4 #include <venti.h>
5
6 char *host;
7 int donothing;
8
9 void
10 usage(void)
11 {
12         fprint(2, "usage: sync [-h host]\n");
13         threadexitsall("usage");
14 }
15
16 void
17 threadmain(int argc, char *argv[])
18 {
19         VtConn *z;
20
21         fmtinstall('V', vtscorefmt);
22         fmtinstall('F', vtfcallfmt);
23         
24         ARGBEGIN{
25         case 'h':
26                 host = EARGF(usage());
27                 if(host == nil)
28                         usage();
29                 break;
30         case 'x':
31                 donothing = 1;
32                 break;
33         default:
34                 usage();
35                 break;
36         }ARGEND
37
38         if(argc != 0)
39                 usage();
40
41         z = vtdial(host);
42         if(z == nil)
43                 sysfatal("could not connect to server: %r");
44
45         if(vtconnect(z) < 0)
46                 sysfatal("vtconnect: %r");
47
48         if(!donothing)
49         if(vtsync(z) < 0)
50                 sysfatal("vtsync: %r");
51
52         vthangup(z);
53         threadexitsall(0);
54 }