Plan 9 from Bell Labs’s /usr/web/sources/contrib/anothy/bin/rc/9fs

Copyright © 2021 Plan 9 Foundation.
Distributed under the MIT License.
Download the Plan 9 distribution.


#!/bin/rc
# 9fs filesystem [mountpoint] - srv & mount filesystem, usually from plan 9

rfork e
switch($1){
case ''
	echo usage: 9fs service '[mountpoint]' >[1=2]
	exit usage

# Begin site-specific section {

# cwfs(4) on sophia, old ark.
case arkive
	srv -q tcp!sophia!54321 arkive /n/arkive
case arkivedump
	9fs arkive
	mount /srv/arkive /n/arkivedump dump
# Shortcut for 9srv
case 9srv
	srv -q tcp!9srv.net 9srv /n/9srv
# Our other is a fossil with snapshots (but no dumps).
case other
	9fs 9srv
	mount -cC /srv/9srv /n/other other/active
case othersnap
	9fs other
	mount -C /srv/9srv /n/othersnap other/snapshot
# That "other" has a bunch of CD/DVD images. Shortcut to mount.
case cd
	if(~ $#* 1)
		echo 'Please specify a cd image.' >[1=2]
	if not {
		9fs other
		9660srv 9660.^$user
		mount /srv/9660.^$user /n/^$2 /n/other/^$2^.iso
	}

# Cooperating unix hosts
case ssh:*
	if(test -e $home/lib/uname) {
		t=`{echo $1 | sed 's/^ssh://'}
		user=`{grep '^'$t'	' $home/lib/uname | sed 's/'$t'	+([^@]+)@.+$/\1/'}
		host=`{grep '^'$t'	' $home/lib/uname | sed 's/'$t'	+[^@]+@(.+)$/\1/'}
	}
	srvssh -u /1/bin/u9fs $host $t /n/$t

# snippet services
case *!snip
	srv -cnmq tcp!^`{echo $1 | sed 's/snip$/17037/'} $1 /n/$1

# A few shortcuts to third parties.

# CMU, for ppc mac builds.
case cmu
	srv -q tcp!spice.ugrad.cs.cmu.edu cmu /n/cmu
# LSUB, home of NIX
case lsub
	srv -nq tcp!sources.lsub.org lsub /n/lsub

# } End site-specific section

case kfs
	if(! test -f /srv/kfs)
		disk/kfs
	mount -c /srv/kfs /n/kfs
case dump
	mount /srv/boot /n/dump dump >[2]/dev/null ||
		mount /srv/boot /n/dump main/archive ||
		mount /srv/boot /n/dump dump	# again to print error
case snap
	mount /srv/boot /n/snap main/snapshot
#case other
#	mount -C /srv/boot /n/other other
case juke					# ye olde file server
	srv -q il!jukefs && mount /srv/il!jukefs /n/juke
case sources
	srv -nq tcp!sources.cs.bell-labs.com sources /n/sources
case sourcesdump
	9fs sources
	mount -n /srv/sources /n/sourcesdump main/archive
case sourcessnap
	9fs sources
	mount -n /srv/sources /n/sourcessnap main/snapshot
# arbitrary venti archives
case vac:*
	vacfs <{echo $1}
case *.vac
	if (test -e $1)
		score=$1
	if not if (! ~ $1 /* && test -e $home/lib/vac/$1)
		score=$home/lib/vac/$1
	if not if (! ~ $1 /* && test -e /lib/vac/$1)
		score=/lib/vac/$1
	if not {
		echo $0: $1: no such score file >[1=2]
		exit 'no score file'
	}
#	vacfs -m /n/`{basename $1 .vac} `{cat $score}
	vacfs -m /n/`{basename $1 .vac} $score
case wiki
	srv -m 'net!plan9.bell-labs.com!wiki' wiki /mnt/wiki
case *
	switch($#*){
	case 1
		srv -m $1
	case *
		srv -m $1 $1 $2
	}
}

Bell Labs OSI certified Powered by Plan 9

(Return to Plan 9 Home Page)

Copyright © 2021 Plan 9 Foundation. All Rights Reserved.
Comments to webmaster@9p.io.