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_posix/sys/src/cmd/fossil/conf.rc – 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
#!/bin/rc
2
 
3
# the fossil configuration is stored at the 127kB offset in the disk
4
# and extends for at most 1 kB.
5
 
6
rfork e
7
fn usage {
8
	echo 'usage: fossil/conf [-w] /dev/sdC0/fossil [config]' >[1=2]
9
	exit usage
10
}
11
 
12
wflag=no
13
while(! ~ $#* 0 && ~ $1 -* && ! ~ $1 --){
14
	switch($1){
15
	case -w
16
		wflag=yes
17
	case *
18
		usage
19
	}
20
	shift
21
}
22
if(~ $1 --)
23
	shift
24
 
25
if(~ $wflag no && ! ~ $#* 1)
26
	usage
27
if(~ $wflag yes && ! ~ $#* 1 2)
28
	usage
29
 
30
disk=$1
31
if(! test -f $disk){
32
	echo 'unknown disk' $1 >[1=2]
33
	exit nodisk
34
}
35
 
36
fn sigexit {
37
	rm -f /tmp/fossilconf.$pid
38
}
39
 
40
if(~ $wflag yes){
41
	{echo fossil config; cat $2} >/tmp/fossilconf.$pid || exit oops
42
	if(! test -s /tmp/fossilconf.$pid){
43
		echo 'config is empty; will not install' >[1=2]
44
		exit emptyconfig
45
	}
46
	if(test `{ls -l /tmp/fossilconf.$pid | awk '{print $6}'} -gt 1024){
47
		echo 'config is too long; max is a little less than a kilobyte' >[1=2]
48
		exit toolong
49
	}
50
	dd -quiet 1 -bs 1024 -count 1 -if $disk -iseek 127 \
51
		>/tmp/_fossilconf.old || exit backup
52
	dd -quiet 1 -count 2 </dev/zero >>/tmp/fossilconf.$pid || exit dd
53
	dd -quiet 1 -bs 1024 -count 1 -if /tmp/fossilconf.$pid \
54
		-trunc 0 -of $disk -oseek 127 || exit dd2
55
	exit 0
56
}
57
 
58
dd -quiet 1 -bs 1024 -count 1 -if $disk -iseek 127 |
59
	aux/zerotrunc >/tmp/fossilconf.$pid
60
 
61
if(! cmp -s <{sed 1q /tmp/fossilconf.$pid} <{echo fossil config}){
62
	echo 'config has bad header' >[1=2]
63
	exit badconfig
64
}
65
 
66
sed 1d /tmp/fossilconf.$pid
67
exit 0
68