Warning: Attempt to read property "date" on null in /usr/local/www/websvn.planix.org/blame.php on line 247

Warning: Attempt to read property "msg" on null in /usr/local/www/websvn.planix.org/blame.php on line 247
WebSVN – planix.SVN – Blame – /os/branches/feature_fixcpp/sys/src/cmd/replica/compactdb.c – Rev 2

Subversion Repositories planix.SVN

Rev

Go to most recent revision | Details | Last modification | View Log | RSS feed

Rev Author Line No. Line
2 - 1
/*
2
 * compact a database file
3
 */
4
#include "all.h"
5
 
6
Db *db;
7
 
8
void
9
usage(void)
10
{
11
	fprint(2, "usage: replica/compactdb db\n");
12
	exits("usage");
13
}
14
 
15
void
16
main(int argc, char **argv)
17
{
18
	Avlwalk *w;
19
	Biobuf bout;
20
	Entry *e;
21
 
22
	quotefmtinstall();
23
	ARGBEGIN{
24
	default:
25
		usage();
26
	}ARGEND
27
 
28
	if(argc != 1)
29
		usage();
30
 
31
	Binit(&bout, 1, OWRITE);
32
	db = opendb(argv[0]);
33
	w = avlwalk(db->avl);
34
	while(e = (Entry*)avlnext(w))
35
		Bprint(&bout, "%q %q %luo %q %q %lud %lld\n",
36
			e->name, strcmp(e->name, e->d.name)==0 ? "-" : e->d.name, e->d.mode,
37
			e->d.uid, e->d.gid, e->d.mtime, e->d.length);
38
	if(Bterm(&bout) < 0)
39
		sysfatal("writing output: %r");
40
 
41
	exits(nil);
42
}