Plan 9 from Bell Labs’s /usr/web/sources/contrib/someone/root/rc/bin/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

# main fs
case dump
	9fs boot && mount -C /srv/boot /n/dump main/archive
case snap
	9fs boot && mount -C /srv/boot /n/snap main/snapshot
case other
	9fs boot && mount -C /srv/boot /n/other other
# arbitrary venti archives
case vac:*
	vacfs <{echo $1}
case vac.*
	vacfs -m /n/$1 <{echo $1 | sed 's/vac\./vac:/'}
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}

# old file servers
case kfs
	if(! test -f /srv/kfs)
		disk/kfs
	mount -cC /srv/kfs /n/kfs
case juke					# ye olde file server
	srv -q il!jukefs && mount /srv/il!jukefs /n/juke

# the outside world
case sources
#	9fs 9p.io && bind /n/9p.io /n/sources # if you have an account
	srv -nqC tcp!9p.io sources /n/sources
#	bind /n/sources/plan9 /n/p9
case sourcesdump
	9fs sources && mount -C /srv/sources /n/sourcesdump main/archive
case sourcessnap
	9fs sources && mount -C /srv/sources /n/sourcessnap main/snapshot
case wiki
	srv -qC 'tcp!9p.io!wiki' wiki /mnt/wiki
	echo using 9p.io instead of plan9.bell-labs.com
case p9f
	srv -qC 'tcp!p9f.org!wiki' wiki /mnt/wiki

# general case
case *
	switch($#*){
	case 1
		exec srv -m $1
	case *
		exec srv -m $1 $1 $2
	}
}

# only special cases recognised above get here
switch($#*){
case 1
	;
case 2
	bind /n/$1 $2
case *
	usage
}

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.