shithub: riscv

ref: f8ddcb23b9dd969875dd4e961591700c79b7d5f7
dir: /sys/lib/backup/funcs/

View raw version
#!/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=pie
		arenas=/dev/sde0/arena0	# on $fs
		rdev=/dev/sdE1		# on terminal with bd burner

		blocksize=8192
		arenasize=1073741824 # twice the venti default, on yoshimi & pie
		# trackbytes=$arenasize
		# 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
		path=(/bin $backups .)
	}
}

# 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
}

# caller sets arenabase first
fn arenastart {		# arena#
	bytes =  `{ echo $arenabase' + ('$1' * '$arenasize')' | bc }
	blocks = `{ echo $bytes' / '$blocksize | bc }
	echo $blocks
}

backupinit