aboutsummaryrefslogtreecommitdiff
path: root/src/cmd/venti/sync.c
blob: 965f19ed81f745dfa1f00787976da6dfec1943b1 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
#include <u.h>
#include <libc.h>
#include <thread.h>
#include <venti.h>

char *host;
int donothing;

void
usage(void)
{
	fprint(2, "usage: sync [-h host]\n");
	threadexitsall("usage");
}

void
threadmain(int argc, char *argv[])
{
	VtConn *z;

	fmtinstall('V', vtscorefmt);
	fmtinstall('F', vtfcallfmt);

	ARGBEGIN{
	case 'h':
		host = EARGF(usage());
		if(host == nil)
			usage();
		break;
	case 'x':
		donothing = 1;
		break;
	default:
		usage();
		break;
	}ARGEND

	if(argc != 0)
		usage();

	z = vtdial(host);
	if(z == nil)
		sysfatal("could not connect to server: %r");

	if(vtconnect(z) < 0)
		sysfatal("vtconnect: %r");

	if(!donothing)
	if(vtsync(z) < 0)
		sysfatal("vtsync: %r");

	vthangup(z);
	threadexitsall(0);
}