]> git.lizzy.rs Git - plan9front.git/blob - rc/bin/9fs
import E script from bell labs
[plan9front.git] / rc / bin / 9fs
1 #!/bin/rc
2 # 9fs filesystem [mountpoint] - srv & mount filesystem, usually from plan 9
3
4 rfork e
5 switch($1){
6 case ''
7         echo usage: 9fs service '[mountpoint]' >[1=2]
8         exit usage
9 case 9fat esp pidos dos
10         if(~ $#2 1)
11                 part=`{ls $2 >[2]/dev/null}
12         if not if(~ $1 pidos)
13                 part=`{ls /dev/sdM*/dos >[2]/dev/null}
14         if not
15                 part=`{ls /dev/fs/$1 /dev/sd*/$1 >[2]/dev/null}
16         if(~ $#part 0) {
17                 echo 'no '$1' partition found' >[1=2]
18                 exit no.$1
19         }
20         part=$part(1)
21         
22         if(! test -f /srv/dos)
23                 dossrv >/dev/null </dev/null >[2]/dev/null
24         
25         unmount /n/$1 >/dev/null >[2]/dev/null
26         mount -c /srv/dos /n/$1 $part
27         if(~ $1 9fat){
28                 unmount /n/9 >/dev/null >[2]/dev/null
29                 mount -c /srv/dos /n/9 $part
30         }
31 case kfs
32         if(! test -f /srv/kfs)
33                 disk/kfs
34         mount -c /srv/kfs /n/kfs
35 case dump
36         mount /srv/boot /n/dump dump >[2]/dev/null ||
37                 mount /srv/boot /n/dump main/archive ||
38                 mount /srv/boot /n/dump dump    # again to print error
39 case snap
40         mount /srv/boot /n/snap main/snapshot
41 case other
42         mount -C /srv/boot /n/other other
43 case juke                                       # ye olde file server
44         srv -q il!jukefs && mount /srv/il!jukefs /n/juke
45 case sources
46         srv -nqC tcp!sources.cs.bell-labs.com sources /n/sources
47 case sourcesdump
48         9fs sources
49         mount -nC /srv/sources /n/sourcesdump main/archive
50 case sourcessnap
51         9fs sources
52         mount -nC /srv/sources /n/sourcessnap main/snapshot
53 case atom
54         srv -nq tcp!atom.9atom.org atom && mount -nC /srv/atom /n/atom atom
55 case atomdump
56         9fs atom && mount -nC /srv/atom /n/atomdump atomdump
57 # arbitrary venti archives
58 case vac:*
59         vacfs <{echo $1}
60 case *.vac
61         if (test -e $1)
62                 score=$1
63         if not if (! ~ $1 /* && test -e $home/lib/vac/$1)
64                 score=$home/lib/vac/$1
65         if not if (! ~ $1 /* && test -e /lib/vac/$1)
66                 score=/lib/vac/$1
67         if not {
68                 echo $0: $1: no such score file >[1=2]
69                 exit 'no score file'
70         }
71         vacfs -m /n/`{basename $1 .vac} `{cat $score}
72 case wiki
73         srv -m 'net!plan9.bell-labs.com!wiki' wiki /mnt/wiki
74 case ingenic
75         ftpfs -qKm /n/ingenic -a $user@$sysname ftp.ingenic.com
76 case kernel
77         ftpfs -qKm /n/kernel -a $user@sysname ftp.kernel.org
78 case qrstuv
79         srv -nqmC tcp!fs.9paste.net qrstuv
80 case *
81         switch($#*){
82         case 1
83                 srv -m $1
84         case *
85                 srv -m $1 $1 $2
86         }
87 }