Browse Source

Plan 9 from Bell Labs 2008-06-25

David du Colombier 13 years ago
parent
commit
ea9b5e5f99

+ 2 - 2
dist/replica/_plan9.db

@@ -5641,7 +5641,7 @@ rc/bin/start - 775 sys sys 945617209 120
 rc/bin/stock - 775 sys sys 1143126371 292
 rc/bin/stop - 775 sys sys 945617209 110
 rc/bin/tel - 775 sys sys 1161209756 128
-rc/bin/termrc - 775 sys sys 1207348859 2548
+rc/bin/termrc - 775 sys sys 1214313568 2610
 rc/bin/termrc.local - 775 sys sys 1210371721 425
 rc/bin/thesaurus - 775 sys sys 1205183987 422
 rc/bin/tlsclienttunnel - 775 sys sys 1024375633 153
@@ -7597,7 +7597,7 @@ sys/man/2/fversion - 664 sys sys 1196638940 1654
 sys/man/2/genrandom - 664 sys sys 1196638940 876
 sys/man/2/getcallerpc - 664 sys sys 1196638940 666
 sys/man/2/getenv - 664 sys sys 1196638937 685
-sys/man/2/getfcr - 664 sys sys 1196638940 2713
+sys/man/2/getfcr - 664 sys sys 1214338655 2652
 sys/man/2/getfields - 664 sys sys 1201889839 1749
 sys/man/2/getpid - 664 sys sys 1196638937 657
 sys/man/2/getuser - 664 sys sys 1196638937 641

+ 2 - 2
dist/replica/plan9.db

@@ -5641,7 +5641,7 @@ rc/bin/start - 775 sys sys 945617209 120
 rc/bin/stock - 775 sys sys 1143126371 292
 rc/bin/stop - 775 sys sys 945617209 110
 rc/bin/tel - 775 sys sys 1161209756 128
-rc/bin/termrc - 775 sys sys 1207348859 2548
+rc/bin/termrc - 775 sys sys 1214313568 2610
 rc/bin/termrc.local - 775 sys sys 1210371721 425
 rc/bin/thesaurus - 775 sys sys 1205183987 422
 rc/bin/tlsclienttunnel - 775 sys sys 1024375633 153
@@ -7597,7 +7597,7 @@ sys/man/2/fversion - 664 sys sys 1196638940 1654
 sys/man/2/genrandom - 664 sys sys 1196638940 876
 sys/man/2/getcallerpc - 664 sys sys 1196638940 666
 sys/man/2/getenv - 664 sys sys 1196638937 685
-sys/man/2/getfcr - 664 sys sys 1196638940 2713
+sys/man/2/getfcr - 664 sys sys 1214338655 2652
 sys/man/2/getfields - 664 sys sys 1201889839 1749
 sys/man/2/getpid - 664 sys sys 1196638937 657
 sys/man/2/getuser - 664 sys sys 1196638937 641

+ 2 - 0
dist/replica/plan9.log

@@ -19969,3 +19969,5 @@
 1214263804 65 d sys/src/games/mp3dec/audio_dummy.c - 664 sys sys 956186347 0
 1214263804 66 d sys/src/games/mp3dec/audio.h - 664 sys sys 956186249 0
 1214263804 67 d sys/src/games/mp3dec/audio.c - 664 sys sys 956186249 0
+1214317804 0 c rc/bin/termrc - 775 sys sys 1214313568 2610
+1214339404 0 c sys/man/2/getfcr - 664 sys sys 1214338655 2652

+ 16 - 14
rc/bin/termrc

@@ -24,7 +24,7 @@ if(test -e /rc/bin/termrc.local)
 	. /rc/bin/termrc.local
 
 # cs sets sysname (termrc.local may already have started it so check)
-if(! test -e /srv/cs)
+if(! test -e /srv/cs && ! test -e /net/cs)
 	ndb/cs -f $NDBFILE
 sysname=`{cat /dev/sysname}
 if (~ $#sysname 0 || ~ $sysname '') {
@@ -51,19 +51,21 @@ if(test -e /cfg/$sysname/termrc)
 if(test -e /net/ipifc/0/ctl && ! test -e /srv/dns)
 	ndb/dns -r
 
-# start timesync if it isn't running and we weren't told not to
-if(! ps|grep -s timesync)
-	if(! ~ $TIMESYNCARGS '')
-		aux/timesync $TIMESYNCARGS
-
-# add the loop-back device
-if(grep -s loopback /dev/drivers)
-	ip/ipconfig loopback /dev/null 127.1
-
-# set things up for vmware
-if(! ~ `{cat /dev/user} none)
-	if(test -e /bin/aux/vmware)
-		aux/vmware
+if(! ~ $terminal *vx32*){
+	# start timesync if it isn't running and we weren't told not to
+	if(! ps|grep -s timesync)
+		if(! ~ $TIMESYNCARGS '')
+			aux/timesync $TIMESYNCARGS
+	
+	# add the loop-back device
+	if(grep -s loopback /dev/drivers)
+		ip/ipconfig loopback /dev/null 127.1
+	
+	# set things up for vmware
+	if(! ~ `{cat /dev/user} none)
+		if(test -e /bin/aux/vmware)
+			aux/vmware
+}
 
 # query user if terminal isn't adequately configured yet
 if(~ $mouseport ask){

+ 94 - 0
sys/lib/backup/backup

@@ -0,0 +1,94 @@
+#!/bin/rc
+# backup [-n] [-d dev] [-s set] - backup venti arenas to disc set using dev
+#	and record that.  also print recent fossil dump scores.
+rfork ne
+cd /sys/lib/backup
+. funcs
+bind -a . /bin
+
+done=0
+while (~ $done 0 && ! ~ $#* 0 && ~ $1 -*) {
+	switch ($1) {
+	case -d;	rdev=$2; shift
+	case -n;	debug=yes		# don't dump; use with -s test
+	case -s;	set=$2 ; shift
+	case --;	done = 1		# no break in rc, alas
+	case -*
+		echo usage: $0 '[-n] [-d dev] [-s set]' >[1=2]
+		exit usage
+	}
+	shift
+}
+
+fn sigint sighup sigterm {
+	exit note
+}
+
+fn dobackuparenas {
+	if (~ $debug yes) {
+		echo pretending to backuparenas $*
+		shift
+		for (name)
+			dumpdone arena0 $name
+	}
+	if not
+		backuparenas $*
+}
+
+fn backupdisc {
+	echo please insert disc $disc of set $set into $rdev and press return to backup
+	echo -n $"*^': '
+	if (! ~ $debug yes)
+		junk=`{read}
+	if not
+		echo
+	dobackuparenas $rdev $*
+}
+
+fn backup1 {
+	progress=no
+	disc1trks=`{hoc -e $ntracks-$tracks}
+	disc1arenas=()
+	if (! ~ $disc1trks 0)
+		disc1arenas=`{sed $disc1trks^q arenas}
+	if (! ~ $#disc1arenas 0 && ! ~ $disc1trks 0 && backupdisc $disc1arenas){
+		tracks = `{hoc -e $tracks+$#disc1arenas}
+		if (test $tracks -ge $ntracks) {
+			disc=`{hoc -e $disc+1}
+			tracks=0
+		}
+		updprog
+
+		sed 1,$disc1trks^d arenas >morearenas
+		mv morearenas arenas
+		arenas=`{cat arenas}
+	}
+}
+
+cd $set
+tobackup $set >arenas
+quitonfailure $status
+
+arenas=`{cat arenas}
+if (~ $#arenas 0) {
+	echo no sealed arenas not yet on disc exist on $fs
+	exit ''
+}
+
+if (test -s disc)
+	.   disc
+if not
+	updprog
+
+if (! ~ $debug yes && ~ $set set1) {
+	9fs log
+	tail /sys/log/fs.archive | pr -h 'recent fossil dump scores' | lp 
+	echo fossil dump scores just printed.
+}
+
+progress=yes
+while (test $#arenas -gt 0 && ~ $progress yes) {
+	backup1
+	quitonfailure $status
+}
+exit ''

+ 33 - 0
sys/lib/backup/backuparenas

@@ -0,0 +1,33 @@
+#!/bin/rc
+# backuparenas dev name ... - dump arena `name' from $fs to blu-ray disc.
+#	assumes $set is set.
+rfork ne
+# tunable variables
+fs=yoshimi
+
+if (test -e /sys/lib/backup/funcs)
+	.   /sys/lib/backup/funcs
+
+exits=''
+fsroot=/n/$fs
+if (! test -e $fsroot/!THIS_IS_^`{echo $fs | tr a-z A-Z}^_MAIN) {
+	import $fs / $fsroot || exit
+}
+unmount /mnt/cd >[2]/dev/null
+cdfs -d $1 || exit
+shift
+
+cd $fsroot/dev/fs
+for (name) {
+	grep next /mnt/cd/ctl
+	if (! {venti/rdarena arena0 $name |
+	    pump -b 65536 -k 51200 >/mnt/cd/wd/$name})
+		exit
+	ls -l /mnt/cd
+	if (test -e '/env/fn#dumpdone' -a -e '/env/set')
+		dumpdone arena0 $name
+}
+echo 'remember to *not* remove /mnt/cd/wd' >[1=2]
+# don't remove /mnt/cd/wd, since that would finalize the disc
+# and bugger the permanent toc, at least on bd-r.
+exit ''

+ 23 - 0
sys/lib/backup/dupdisc

@@ -0,0 +1,23 @@
+#!/bin/rc
+# dupdisc indev outdev - duplicate all blu-ray disc data tracks
+rfork ne
+if (! ~ $#* 2 || ~ $1 $2 || ~ $1 /dev/* || ~ $2 /dev/*) {
+	echo usage: $0 indev outdev >[1=2]
+	exit usage
+}
+echo copying /dev/$1 tracks to /dev/$2
+sleep 2
+
+umount /mnt/cd		>[2]/dev/null
+cdfs -d /dev/$1 || exit
+cdfs -d /dev/$2 -m /n/copy || exit
+
+for (t in `{ls -p /mnt/cd | grep '^d'}) {
+	echo $t:
+	grep next /n/copy/ctl
+	pump -b 81920 -k 51200 </mnt/cd/$t >/n/copy/wd/$t
+	ls -l /n/copy
+}
+echo 'remember to *not* rm /mnt/cd/wd' >[1=2]
+# don't remove /mnt/cd/wd, since that would finalize the disc
+# and bugger the permanent toc, at least on bd-r.

+ 44 - 0
sys/lib/backup/funcs

@@ -0,0 +1,44 @@
+#!/bin/rc
+# funcs - rc functions and definitions common to dump scripts
+fn backupinit {
+	if (! ~ $backupinitdone yes) {
+		disc=1
+		tracks=0
+
+		# tunable parameters
+		set=set1
+		fs=yoshimi
+		trackbytes=1073741824	# twice the venti default on yoshimi
+		rdev=/dev/sdD0
+		discbytes=`{ls -l $rdev/data | awk '{print $6}'}
+		#ntracks=`{ hoc -e 'int('$discbytes/$trackbytes')' }
+		ntracks=45		# for BD dual-layer
+		backupinitdone=yes
+		backups=/sys/lib/backup
+	}
+}
+
+# assume we're in $backups/$set
+fn updprog {
+	echo 'disc='$disc 'tracks='$tracks >ndisc && mv ndisc disc
+}
+
+# assumes $set is set
+fn dumpdone {		# arena-part arena-name
+	@ {
+		cd $backups/$set
+		progress=yes
+		tracks = `{hoc -e $tracks+1}
+		updprog
+		if (~ $debug yes)
+			echo $2 >>fake	# pretend these are sealed
+		echo $2 >>ondisc
+	}
+}
+
+fn quitonfailure {	# exit-status
+	if (! ~ $1 '' 0 '|')
+		exit $1
+}
+
+backupinit

+ 4 - 0
sys/lib/backup/mkfile

@@ -0,0 +1,4 @@
+clean:V:
+	rm -f index
+setup:V:
+	mkdir set1

+ 19 - 0
sys/lib/backup/restore

@@ -0,0 +1,19 @@
+#!/bin/rc
+# restore [dev] - load venti with arenas on dev, stored one per track
+rfork ne
+if (test -e /sys/lib/backup/funcs)
+	.   /sys/lib/backup/funcs
+switch ($#*) {
+case 0
+case 1
+	rdev=$1
+case *
+	echo usage: $0 '[dev]' >[1=2]
+	exit usage
+}
+
+unmount /mnt/cd >[2]/dev/null
+cdfs -d $rdev || exit
+cd /mnt/cd
+for (track in d[0-9]*)
+	venti/wrarena $track

+ 47 - 0
sys/lib/backup/tobackup

@@ -0,0 +1,47 @@
+#!/bin/rc
+# tobackup [set] - print names of venti arenas needing to be dumped to disc set
+rfork e
+
+cd /sys/lib/backup
+. funcs
+
+switch ($#*) {
+case 0
+case 1
+	set=$1
+case *
+	echo usage: $0 '[set]' >[1=2]
+	exit usage
+}
+
+if (! test -d $set) {
+	echo $0: no backup set named $set in $backup >[1=2]
+	exit 'no backup set'
+}
+if (! hget -o index http://$fs/index) {
+	echo $0: 'can''t fetch venti index from' $fs >[1=2]
+	exit 'no venti index'
+}
+if (! test -s index) {
+	echo $0: 'empty venti index from' $fs >[1=2]
+	exit 'empty index'
+}
+
+cd $set
+awk '/^arena=/		{ name=$1 }
+	/ disk=sealed/	{ print name; name = "" }
+    ' ../index | sed 's/^arena=//' >nsealed
+>>sealed
+if (! cmp -s sealed nsealed)
+	cp nsealed sealed
+rm -f nsealed
+if (! test -s sealed)
+	exit ''
+
+>>fake
+if (test -s ondisc)
+	comm -23 <{sort -u sealed fake} <{sort -u ondisc}
+if not {				# first sealed arenas, dump all
+	cat sealed
+	chmod +a ondisc >>ondisc
+}

+ 3 - 4
sys/man/2/getfcr

@@ -94,15 +94,14 @@ exception bits; a
 .I setfsr
 clears them all.
 The exception bits defined here work on all architectures.
-By default, the initial state is equivalent to
+Where possible, the initial state is equivalent to
 .IP
 .EX
 setfcr(FPPDBL|FPRNR|FPINVAL|FPZDIV|FPOVFL);
 .EE
 .PP
-The default state of the floating point unit is fixed for a given
-architecture but is undefined across Plan 9: the default is
-to provide what the hardware does most efficiently.
+However, this may vary between architectures:
+the default is to provide what the hardware does most efficiently.
 Use these routines
 if you need guaranteed behavior.
 Also, gradual underflow is not available on some machines.