1*4882a593Smuzhiyun.. SPDX-License-Identifier: GPL-2.0 2*4882a593Smuzhiyun 3*4882a593Smuzhiyun==================== 4*4882a593SmuzhiyunkAFS: AFS FILESYSTEM 5*4882a593Smuzhiyun==================== 6*4882a593Smuzhiyun 7*4882a593Smuzhiyun.. Contents: 8*4882a593Smuzhiyun 9*4882a593Smuzhiyun - Overview. 10*4882a593Smuzhiyun - Usage. 11*4882a593Smuzhiyun - Mountpoints. 12*4882a593Smuzhiyun - Dynamic root. 13*4882a593Smuzhiyun - Proc filesystem. 14*4882a593Smuzhiyun - The cell database. 15*4882a593Smuzhiyun - Security. 16*4882a593Smuzhiyun - The @sys substitution. 17*4882a593Smuzhiyun 18*4882a593Smuzhiyun 19*4882a593SmuzhiyunOverview 20*4882a593Smuzhiyun======== 21*4882a593Smuzhiyun 22*4882a593SmuzhiyunThis filesystem provides a fairly simple secure AFS filesystem driver. It is 23*4882a593Smuzhiyununder development and does not yet provide the full feature set. The features 24*4882a593Smuzhiyunit does support include: 25*4882a593Smuzhiyun 26*4882a593Smuzhiyun (*) Security (currently only AFS kaserver and KerberosIV tickets). 27*4882a593Smuzhiyun 28*4882a593Smuzhiyun (*) File reading and writing. 29*4882a593Smuzhiyun 30*4882a593Smuzhiyun (*) Automounting. 31*4882a593Smuzhiyun 32*4882a593Smuzhiyun (*) Local caching (via fscache). 33*4882a593Smuzhiyun 34*4882a593SmuzhiyunIt does not yet support the following AFS features: 35*4882a593Smuzhiyun 36*4882a593Smuzhiyun (*) pioctl() system call. 37*4882a593Smuzhiyun 38*4882a593Smuzhiyun 39*4882a593SmuzhiyunCompilation 40*4882a593Smuzhiyun=========== 41*4882a593Smuzhiyun 42*4882a593SmuzhiyunThe filesystem should be enabled by turning on the kernel configuration 43*4882a593Smuzhiyunoptions:: 44*4882a593Smuzhiyun 45*4882a593Smuzhiyun CONFIG_AF_RXRPC - The RxRPC protocol transport 46*4882a593Smuzhiyun CONFIG_RXKAD - The RxRPC Kerberos security handler 47*4882a593Smuzhiyun CONFIG_AFS - The AFS filesystem 48*4882a593Smuzhiyun 49*4882a593SmuzhiyunAdditionally, the following can be turned on to aid debugging:: 50*4882a593Smuzhiyun 51*4882a593Smuzhiyun CONFIG_AF_RXRPC_DEBUG - Permit AF_RXRPC debugging to be enabled 52*4882a593Smuzhiyun CONFIG_AFS_DEBUG - Permit AFS debugging to be enabled 53*4882a593Smuzhiyun 54*4882a593SmuzhiyunThey permit the debugging messages to be turned on dynamically by manipulating 55*4882a593Smuzhiyunthe masks in the following files:: 56*4882a593Smuzhiyun 57*4882a593Smuzhiyun /sys/module/af_rxrpc/parameters/debug 58*4882a593Smuzhiyun /sys/module/kafs/parameters/debug 59*4882a593Smuzhiyun 60*4882a593Smuzhiyun 61*4882a593SmuzhiyunUsage 62*4882a593Smuzhiyun===== 63*4882a593Smuzhiyun 64*4882a593SmuzhiyunWhen inserting the driver modules the root cell must be specified along with a 65*4882a593Smuzhiyunlist of volume location server IP addresses:: 66*4882a593Smuzhiyun 67*4882a593Smuzhiyun modprobe rxrpc 68*4882a593Smuzhiyun modprobe kafs rootcell=cambridge.redhat.com:172.16.18.73:172.16.18.91 69*4882a593Smuzhiyun 70*4882a593SmuzhiyunThe first module is the AF_RXRPC network protocol driver. This provides the 71*4882a593SmuzhiyunRxRPC remote operation protocol and may also be accessed from userspace. See: 72*4882a593Smuzhiyun 73*4882a593Smuzhiyun Documentation/networking/rxrpc.rst 74*4882a593Smuzhiyun 75*4882a593SmuzhiyunThe second module is the kerberos RxRPC security driver, and the third module 76*4882a593Smuzhiyunis the actual filesystem driver for the AFS filesystem. 77*4882a593Smuzhiyun 78*4882a593SmuzhiyunOnce the module has been loaded, more modules can be added by the following 79*4882a593Smuzhiyunprocedure:: 80*4882a593Smuzhiyun 81*4882a593Smuzhiyun echo add grand.central.org 18.9.48.14:128.2.203.61:130.237.48.87 >/proc/fs/afs/cells 82*4882a593Smuzhiyun 83*4882a593SmuzhiyunWhere the parameters to the "add" command are the name of a cell and a list of 84*4882a593Smuzhiyunvolume location servers within that cell, with the latter separated by colons. 85*4882a593Smuzhiyun 86*4882a593SmuzhiyunFilesystems can be mounted anywhere by commands similar to the following:: 87*4882a593Smuzhiyun 88*4882a593Smuzhiyun mount -t afs "%cambridge.redhat.com:root.afs." /afs 89*4882a593Smuzhiyun mount -t afs "#cambridge.redhat.com:root.cell." /afs/cambridge 90*4882a593Smuzhiyun mount -t afs "#root.afs." /afs 91*4882a593Smuzhiyun mount -t afs "#root.cell." /afs/cambridge 92*4882a593Smuzhiyun 93*4882a593SmuzhiyunWhere the initial character is either a hash or a percent symbol depending on 94*4882a593Smuzhiyunwhether you definitely want a R/W volume (percent) or whether you'd prefer a 95*4882a593SmuzhiyunR/O volume, but are willing to use a R/W volume instead (hash). 96*4882a593Smuzhiyun 97*4882a593SmuzhiyunThe name of the volume can be suffixes with ".backup" or ".readonly" to 98*4882a593Smuzhiyunspecify connection to only volumes of those types. 99*4882a593Smuzhiyun 100*4882a593SmuzhiyunThe name of the cell is optional, and if not given during a mount, then the 101*4882a593Smuzhiyunnamed volume will be looked up in the cell specified during modprobe. 102*4882a593Smuzhiyun 103*4882a593SmuzhiyunAdditional cells can be added through /proc (see later section). 104*4882a593Smuzhiyun 105*4882a593Smuzhiyun 106*4882a593SmuzhiyunMountpoints 107*4882a593Smuzhiyun=========== 108*4882a593Smuzhiyun 109*4882a593SmuzhiyunAFS has a concept of mountpoints. In AFS terms, these are specially formatted 110*4882a593Smuzhiyunsymbolic links (of the same form as the "device name" passed to mount). kAFS 111*4882a593Smuzhiyunpresents these to the user as directories that have a follow-link capability 112*4882a593Smuzhiyun(ie: symbolic link semantics). If anyone attempts to access them, they will 113*4882a593Smuzhiyunautomatically cause the target volume to be mounted (if possible) on that site. 114*4882a593Smuzhiyun 115*4882a593SmuzhiyunAutomatically mounted filesystems will be automatically unmounted approximately 116*4882a593Smuzhiyuntwenty minutes after they were last used. Alternatively they can be unmounted 117*4882a593Smuzhiyundirectly with the umount() system call. 118*4882a593Smuzhiyun 119*4882a593SmuzhiyunManually unmounting an AFS volume will cause any idle submounts upon it to be 120*4882a593Smuzhiyunculled first. If all are culled, then the requested volume will also be 121*4882a593Smuzhiyununmounted, otherwise error EBUSY will be returned. 122*4882a593Smuzhiyun 123*4882a593SmuzhiyunThis can be used by the administrator to attempt to unmount the whole AFS tree 124*4882a593Smuzhiyunmounted on /afs in one go by doing:: 125*4882a593Smuzhiyun 126*4882a593Smuzhiyun umount /afs 127*4882a593Smuzhiyun 128*4882a593Smuzhiyun 129*4882a593SmuzhiyunDynamic Root 130*4882a593Smuzhiyun============ 131*4882a593Smuzhiyun 132*4882a593SmuzhiyunA mount option is available to create a serverless mount that is only usable 133*4882a593Smuzhiyunfor dynamic lookup. Creating such a mount can be done by, for example:: 134*4882a593Smuzhiyun 135*4882a593Smuzhiyun mount -t afs none /afs -o dyn 136*4882a593Smuzhiyun 137*4882a593SmuzhiyunThis creates a mount that just has an empty directory at the root. Attempting 138*4882a593Smuzhiyunto look up a name in this directory will cause a mountpoint to be created that 139*4882a593Smuzhiyunlooks up a cell of the same name, for example:: 140*4882a593Smuzhiyun 141*4882a593Smuzhiyun ls /afs/grand.central.org/ 142*4882a593Smuzhiyun 143*4882a593Smuzhiyun 144*4882a593SmuzhiyunProc Filesystem 145*4882a593Smuzhiyun=============== 146*4882a593Smuzhiyun 147*4882a593SmuzhiyunThe AFS modules creates a "/proc/fs/afs/" directory and populates it: 148*4882a593Smuzhiyun 149*4882a593Smuzhiyun (*) A "cells" file that lists cells currently known to the afs module and 150*4882a593Smuzhiyun their usage counts:: 151*4882a593Smuzhiyun 152*4882a593Smuzhiyun [root@andromeda ~]# cat /proc/fs/afs/cells 153*4882a593Smuzhiyun USE NAME 154*4882a593Smuzhiyun 3 cambridge.redhat.com 155*4882a593Smuzhiyun 156*4882a593Smuzhiyun (*) A directory per cell that contains files that list volume location 157*4882a593Smuzhiyun servers, volumes, and active servers known within that cell:: 158*4882a593Smuzhiyun 159*4882a593Smuzhiyun [root@andromeda ~]# cat /proc/fs/afs/cambridge.redhat.com/servers 160*4882a593Smuzhiyun USE ADDR STATE 161*4882a593Smuzhiyun 4 172.16.18.91 0 162*4882a593Smuzhiyun [root@andromeda ~]# cat /proc/fs/afs/cambridge.redhat.com/vlservers 163*4882a593Smuzhiyun ADDRESS 164*4882a593Smuzhiyun 172.16.18.91 165*4882a593Smuzhiyun [root@andromeda ~]# cat /proc/fs/afs/cambridge.redhat.com/volumes 166*4882a593Smuzhiyun USE STT VLID[0] VLID[1] VLID[2] NAME 167*4882a593Smuzhiyun 1 Val 20000000 20000001 20000002 root.afs 168*4882a593Smuzhiyun 169*4882a593Smuzhiyun 170*4882a593SmuzhiyunThe Cell Database 171*4882a593Smuzhiyun================= 172*4882a593Smuzhiyun 173*4882a593SmuzhiyunThe filesystem maintains an internal database of all the cells it knows and the 174*4882a593SmuzhiyunIP addresses of the volume location servers for those cells. The cell to which 175*4882a593Smuzhiyunthe system belongs is added to the database when modprobe is performed by the 176*4882a593Smuzhiyun"rootcell=" argument or, if compiled in, using a "kafs.rootcell=" argument on 177*4882a593Smuzhiyunthe kernel command line. 178*4882a593Smuzhiyun 179*4882a593SmuzhiyunFurther cells can be added by commands similar to the following:: 180*4882a593Smuzhiyun 181*4882a593Smuzhiyun echo add CELLNAME VLADDR[:VLADDR][:VLADDR]... >/proc/fs/afs/cells 182*4882a593Smuzhiyun echo add grand.central.org 18.9.48.14:128.2.203.61:130.237.48.87 >/proc/fs/afs/cells 183*4882a593Smuzhiyun 184*4882a593SmuzhiyunNo other cell database operations are available at this time. 185*4882a593Smuzhiyun 186*4882a593Smuzhiyun 187*4882a593SmuzhiyunSecurity 188*4882a593Smuzhiyun======== 189*4882a593Smuzhiyun 190*4882a593SmuzhiyunSecure operations are initiated by acquiring a key using the klog program. A 191*4882a593Smuzhiyunvery primitive klog program is available at: 192*4882a593Smuzhiyun 193*4882a593Smuzhiyun https://people.redhat.com/~dhowells/rxrpc/klog.c 194*4882a593Smuzhiyun 195*4882a593SmuzhiyunThis should be compiled by:: 196*4882a593Smuzhiyun 197*4882a593Smuzhiyun make klog LDLIBS="-lcrypto -lcrypt -lkrb4 -lkeyutils" 198*4882a593Smuzhiyun 199*4882a593SmuzhiyunAnd then run as:: 200*4882a593Smuzhiyun 201*4882a593Smuzhiyun ./klog 202*4882a593Smuzhiyun 203*4882a593SmuzhiyunAssuming it's successful, this adds a key of type RxRPC, named for the service 204*4882a593Smuzhiyunand cell, eg: "afs@<cellname>". This can be viewed with the keyctl program or 205*4882a593Smuzhiyunby cat'ing /proc/keys:: 206*4882a593Smuzhiyun 207*4882a593Smuzhiyun [root@andromeda ~]# keyctl show 208*4882a593Smuzhiyun Session Keyring 209*4882a593Smuzhiyun -3 --alswrv 0 0 keyring: _ses.3268 210*4882a593Smuzhiyun 2 --alswrv 0 0 \_ keyring: _uid.0 211*4882a593Smuzhiyun 111416553 --als--v 0 0 \_ rxrpc: afs@CAMBRIDGE.REDHAT.COM 212*4882a593Smuzhiyun 213*4882a593SmuzhiyunCurrently the username, realm, password and proposed ticket lifetime are 214*4882a593Smuzhiyuncompiled in to the program. 215*4882a593Smuzhiyun 216*4882a593SmuzhiyunIt is not required to acquire a key before using AFS facilities, but if one is 217*4882a593Smuzhiyunnot acquired then all operations will be governed by the anonymous user parts 218*4882a593Smuzhiyunof the ACLs. 219*4882a593Smuzhiyun 220*4882a593SmuzhiyunIf a key is acquired, then all AFS operations, including mounts and automounts, 221*4882a593Smuzhiyunmade by a possessor of that key will be secured with that key. 222*4882a593Smuzhiyun 223*4882a593SmuzhiyunIf a file is opened with a particular key and then the file descriptor is 224*4882a593Smuzhiyunpassed to a process that doesn't have that key (perhaps over an AF_UNIX 225*4882a593Smuzhiyunsocket), then the operations on the file will be made with key that was used to 226*4882a593Smuzhiyunopen the file. 227*4882a593Smuzhiyun 228*4882a593Smuzhiyun 229*4882a593SmuzhiyunThe @sys Substitution 230*4882a593Smuzhiyun===================== 231*4882a593Smuzhiyun 232*4882a593SmuzhiyunThe list of up to 16 @sys substitutions for the current network namespace can 233*4882a593Smuzhiyunbe configured by writing a list to /proc/fs/afs/sysname:: 234*4882a593Smuzhiyun 235*4882a593Smuzhiyun [root@andromeda ~]# echo foo amd64_linux_26 >/proc/fs/afs/sysname 236*4882a593Smuzhiyun 237*4882a593Smuzhiyunor cleared entirely by writing an empty list:: 238*4882a593Smuzhiyun 239*4882a593Smuzhiyun [root@andromeda ~]# echo >/proc/fs/afs/sysname 240*4882a593Smuzhiyun 241*4882a593SmuzhiyunThe current list for current network namespace can be retrieved by:: 242*4882a593Smuzhiyun 243*4882a593Smuzhiyun [root@andromeda ~]# cat /proc/fs/afs/sysname 244*4882a593Smuzhiyun foo 245*4882a593Smuzhiyun amd64_linux_26 246*4882a593Smuzhiyun 247*4882a593SmuzhiyunWhen @sys is being substituted for, each element of the list is tried in the 248*4882a593Smuzhiyunorder given. 249*4882a593Smuzhiyun 250*4882a593SmuzhiyunBy default, the list will contain one item that conforms to the pattern 251*4882a593Smuzhiyun"<arch>_linux_26", amd64 being the name for x86_64. 252