Subversion Repositories planix.SVN

Rev

Rev 2 | Details | Compare with Previous | Last modification | View Log | RSS feed

Rev Author Line No. Line
2 - 1
#!/bin/rc
2
# restore arena# [dev] - load venti with arenas on dev, stored one per track
3
#	starting with arena#.  must have run fmtarenas before restoring
4
#	the first arena in the partition.
5
#	this must be run on the venti server, without venti running on the
6
#	affected arena partition(s).
7
rfork ne
8
if (test -e /sys/lib/backup/funcs)
9
	.   /sys/lib/backup/funcs
10
switch ($#*) {
11
case 1
12
case 2
13
	rdev=$2
14
case *
15
	echo usage: $0 arena-num '[dev]' >[1=2]
16
	exit usage
17
}
18
starena=$1
19
if (! ~ $starena [0-9] [0-9][0-9] [0-9][0-9][0-9]) {
20
	echo $0: bad starting arena: $starena >[1=2]
21
	exit bad-arena-num
22
}
23
 
24
# clear any dregs from a previous run
25
unmount /mnt/cd >[2]/dev/null
26
sleep 1
27
kill cdfs | rc
28
sleep 1
29
cdfs -d $rdev || exit
30
cd /mnt/cd
31
 
32
#for (track in d[0-9]*)
33
#	venti/wrarena $track	# slow; takes about 12½ mins. per GB
34
 
35
arena = $starena
36
# set arenabase for arenastart
37
arenabase = `{ venti/printarenapart $arenas | sed -e 's/.*arenabase=//' -e 1q }
38
kill printarenapart | rc		# printarenapart leaves a process behind
39
# echo arenabase $arenabase
40
 
41
skipping=yes
42
for (track in d[0-9]*) {
43
	if (~ track 'd[0-9]*') {
44
		echo $0: no tracks in /mnt/cd >[1=2]
45
		exit no-tracks
46
	}
47
	if (~ $skipping yes) {
48
		# verify that first track is the expected one
49
		type=`{file $track}
50
		switch ($"type) {
51
		case *': venti arena'
52
			name=`{ venti/printarena $track >[2=1] |
53
				sed -e 's/.*name=([^ =]+).*/\1/' -e 1q }
54
		case *
55
			name=NOT-A-VENTI-ARENA
56
		}
57
		kill printarena | rc	# printarena leaves a process behind
58
 
59
		echo -n first track is $"name'; is that right? '
60
		switch (`{read}) {
61
		case [yY]*
62
			skipping=no
63
		case skip
64
			skipping=yes
65
		case *
66
			echo aborting, arena is unchanged. >[1=2]
67
			exit 'wrong track'
68
		}
69
	}
70
 
71
	if (! ~ $skipping yes) {
72
		# copy each track into its slot in the arena partition
73
		venti/printarena $track >[2=1] | sed 1q | tr -d '\12'
74
		kill printarena | rc	# printarena leaves a process behind
75
 
76
		off = `{arenastart $arena}
77
		# echo -n writing $track to $arenas at 8K-block offset $off:
78
		sleep 3
79
		echo
80
		# argh!  something (cdfs?) appends 60K of *stuff* to each
81
		# arena on optical disc.  restrain dd.
82
		count=`{ echo $arenasize/$blocksize | bc }
83
		pump -i 1048576 -o 65536 -d 10 <$track |
84
			dd -quiet 1 -count $count -bs $blocksize -of $arenas \
85
				-oseek $off
86
		arena = `{hoc -e $arena+1}
87
	}
88
}
89
# when all done, must run venti/checkarenas, fmtisect, fmtbloom, fmtindex,
90
# and (the big one) venti/buildindex -b /cfg/pie/venti.conf