1*4882a593Smuzhiyun.. SPDX-License-Identifier: GPL-2.0 2*4882a593Smuzhiyun 3*4882a593Smuzhiyun==================================================================== 4*4882a593SmuzhiyunMiscellaneous Device control operations for the autofs kernel module 5*4882a593Smuzhiyun==================================================================== 6*4882a593Smuzhiyun 7*4882a593SmuzhiyunThe problem 8*4882a593Smuzhiyun=========== 9*4882a593Smuzhiyun 10*4882a593SmuzhiyunThere is a problem with active restarts in autofs (that is to say 11*4882a593Smuzhiyunrestarting autofs when there are busy mounts). 12*4882a593Smuzhiyun 13*4882a593SmuzhiyunDuring normal operation autofs uses a file descriptor opened on the 14*4882a593Smuzhiyundirectory that is being managed in order to be able to issue control 15*4882a593Smuzhiyunoperations. Using a file descriptor gives ioctl operations access to 16*4882a593Smuzhiyunautofs specific information stored in the super block. The operations 17*4882a593Smuzhiyunare things such as setting an autofs mount catatonic, setting the 18*4882a593Smuzhiyunexpire timeout and requesting expire checks. As is explained below, 19*4882a593Smuzhiyuncertain types of autofs triggered mounts can end up covering an autofs 20*4882a593Smuzhiyunmount itself which prevents us being able to use open(2) to obtain a 21*4882a593Smuzhiyunfile descriptor for these operations if we don't already have one open. 22*4882a593Smuzhiyun 23*4882a593SmuzhiyunCurrently autofs uses "umount -l" (lazy umount) to clear active mounts 24*4882a593Smuzhiyunat restart. While using lazy umount works for most cases, anything that 25*4882a593Smuzhiyunneeds to walk back up the mount tree to construct a path, such as 26*4882a593Smuzhiyungetcwd(2) and the proc file system /proc/<pid>/cwd, no longer works 27*4882a593Smuzhiyunbecause the point from which the path is constructed has been detached 28*4882a593Smuzhiyunfrom the mount tree. 29*4882a593Smuzhiyun 30*4882a593SmuzhiyunThe actual problem with autofs is that it can't reconnect to existing 31*4882a593Smuzhiyunmounts. Immediately one thinks of just adding the ability to remount 32*4882a593Smuzhiyunautofs file systems would solve it, but alas, that can't work. This is 33*4882a593Smuzhiyunbecause autofs direct mounts and the implementation of "on demand mount 34*4882a593Smuzhiyunand expire" of nested mount trees have the file system mounted directly 35*4882a593Smuzhiyunon top of the mount trigger directory dentry. 36*4882a593Smuzhiyun 37*4882a593SmuzhiyunFor example, there are two types of automount maps, direct (in the kernel 38*4882a593Smuzhiyunmodule source you will see a third type called an offset, which is just 39*4882a593Smuzhiyuna direct mount in disguise) and indirect. 40*4882a593Smuzhiyun 41*4882a593SmuzhiyunHere is a master map with direct and indirect map entries:: 42*4882a593Smuzhiyun 43*4882a593Smuzhiyun /- /etc/auto.direct 44*4882a593Smuzhiyun /test /etc/auto.indirect 45*4882a593Smuzhiyun 46*4882a593Smuzhiyunand the corresponding map files:: 47*4882a593Smuzhiyun 48*4882a593Smuzhiyun /etc/auto.direct: 49*4882a593Smuzhiyun 50*4882a593Smuzhiyun /automount/dparse/g6 budgie:/autofs/export1 51*4882a593Smuzhiyun /automount/dparse/g1 shark:/autofs/export1 52*4882a593Smuzhiyun and so on. 53*4882a593Smuzhiyun 54*4882a593Smuzhiyun/etc/auto.indirect:: 55*4882a593Smuzhiyun 56*4882a593Smuzhiyun g1 shark:/autofs/export1 57*4882a593Smuzhiyun g6 budgie:/autofs/export1 58*4882a593Smuzhiyun and so on. 59*4882a593Smuzhiyun 60*4882a593SmuzhiyunFor the above indirect map an autofs file system is mounted on /test and 61*4882a593Smuzhiyunmounts are triggered for each sub-directory key by the inode lookup 62*4882a593Smuzhiyunoperation. So we see a mount of shark:/autofs/export1 on /test/g1, for 63*4882a593Smuzhiyunexample. 64*4882a593Smuzhiyun 65*4882a593SmuzhiyunThe way that direct mounts are handled is by making an autofs mount on 66*4882a593Smuzhiyuneach full path, such as /automount/dparse/g1, and using it as a mount 67*4882a593Smuzhiyuntrigger. So when we walk on the path we mount shark:/autofs/export1 "on 68*4882a593Smuzhiyuntop of this mount point". Since these are always directories we can 69*4882a593Smuzhiyunuse the follow_link inode operation to trigger the mount. 70*4882a593Smuzhiyun 71*4882a593SmuzhiyunBut, each entry in direct and indirect maps can have offsets (making 72*4882a593Smuzhiyunthem multi-mount map entries). 73*4882a593Smuzhiyun 74*4882a593SmuzhiyunFor example, an indirect mount map entry could also be:: 75*4882a593Smuzhiyun 76*4882a593Smuzhiyun g1 \ 77*4882a593Smuzhiyun / shark:/autofs/export5/testing/test \ 78*4882a593Smuzhiyun /s1 shark:/autofs/export/testing/test/s1 \ 79*4882a593Smuzhiyun /s2 shark:/autofs/export5/testing/test/s2 \ 80*4882a593Smuzhiyun /s1/ss1 shark:/autofs/export1 \ 81*4882a593Smuzhiyun /s2/ss2 shark:/autofs/export2 82*4882a593Smuzhiyun 83*4882a593Smuzhiyunand a similarly a direct mount map entry could also be:: 84*4882a593Smuzhiyun 85*4882a593Smuzhiyun /automount/dparse/g1 \ 86*4882a593Smuzhiyun / shark:/autofs/export5/testing/test \ 87*4882a593Smuzhiyun /s1 shark:/autofs/export/testing/test/s1 \ 88*4882a593Smuzhiyun /s2 shark:/autofs/export5/testing/test/s2 \ 89*4882a593Smuzhiyun /s1/ss1 shark:/autofs/export2 \ 90*4882a593Smuzhiyun /s2/ss2 shark:/autofs/export2 91*4882a593Smuzhiyun 92*4882a593SmuzhiyunOne of the issues with version 4 of autofs was that, when mounting an 93*4882a593Smuzhiyunentry with a large number of offsets, possibly with nesting, we needed 94*4882a593Smuzhiyunto mount and umount all of the offsets as a single unit. Not really a 95*4882a593Smuzhiyunproblem, except for people with a large number of offsets in map entries. 96*4882a593SmuzhiyunThis mechanism is used for the well known "hosts" map and we have seen 97*4882a593Smuzhiyuncases (in 2.4) where the available number of mounts are exhausted or 98*4882a593Smuzhiyunwhere the number of privileged ports available is exhausted. 99*4882a593Smuzhiyun 100*4882a593SmuzhiyunIn version 5 we mount only as we go down the tree of offsets and 101*4882a593Smuzhiyunsimilarly for expiring them which resolves the above problem. There is 102*4882a593Smuzhiyunsomewhat more detail to the implementation but it isn't needed for the 103*4882a593Smuzhiyunsake of the problem explanation. The one important detail is that these 104*4882a593Smuzhiyunoffsets are implemented using the same mechanism as the direct mounts 105*4882a593Smuzhiyunabove and so the mount points can be covered by a mount. 106*4882a593Smuzhiyun 107*4882a593SmuzhiyunThe current autofs implementation uses an ioctl file descriptor opened 108*4882a593Smuzhiyunon the mount point for control operations. The references held by the 109*4882a593Smuzhiyundescriptor are accounted for in checks made to determine if a mount is 110*4882a593Smuzhiyunin use and is also used to access autofs file system information held 111*4882a593Smuzhiyunin the mount super block. So the use of a file handle needs to be 112*4882a593Smuzhiyunretained. 113*4882a593Smuzhiyun 114*4882a593Smuzhiyun 115*4882a593SmuzhiyunThe Solution 116*4882a593Smuzhiyun============ 117*4882a593Smuzhiyun 118*4882a593SmuzhiyunTo be able to restart autofs leaving existing direct, indirect and 119*4882a593Smuzhiyunoffset mounts in place we need to be able to obtain a file handle 120*4882a593Smuzhiyunfor these potentially covered autofs mount points. Rather than just 121*4882a593Smuzhiyunimplement an isolated operation it was decided to re-implement the 122*4882a593Smuzhiyunexisting ioctl interface and add new operations to provide this 123*4882a593Smuzhiyunfunctionality. 124*4882a593Smuzhiyun 125*4882a593SmuzhiyunIn addition, to be able to reconstruct a mount tree that has busy mounts, 126*4882a593Smuzhiyunthe uid and gid of the last user that triggered the mount needs to be 127*4882a593Smuzhiyunavailable because these can be used as macro substitution variables in 128*4882a593Smuzhiyunautofs maps. They are recorded at mount request time and an operation 129*4882a593Smuzhiyunhas been added to retrieve them. 130*4882a593Smuzhiyun 131*4882a593SmuzhiyunSince we're re-implementing the control interface, a couple of other 132*4882a593Smuzhiyunproblems with the existing interface have been addressed. First, when 133*4882a593Smuzhiyuna mount or expire operation completes a status is returned to the 134*4882a593Smuzhiyunkernel by either a "send ready" or a "send fail" operation. The 135*4882a593Smuzhiyun"send fail" operation of the ioctl interface could only ever send 136*4882a593SmuzhiyunENOENT so the re-implementation allows user space to send an actual 137*4882a593Smuzhiyunstatus. Another expensive operation in user space, for those using 138*4882a593Smuzhiyunvery large maps, is discovering if a mount is present. Usually this 139*4882a593Smuzhiyuninvolves scanning /proc/mounts and since it needs to be done quite 140*4882a593Smuzhiyunoften it can introduce significant overhead when there are many entries 141*4882a593Smuzhiyunin the mount table. An operation to lookup the mount status of a mount 142*4882a593Smuzhiyunpoint dentry (covered or not) has also been added. 143*4882a593Smuzhiyun 144*4882a593SmuzhiyunCurrent kernel development policy recommends avoiding the use of the 145*4882a593Smuzhiyunioctl mechanism in favor of systems such as Netlink. An implementation 146*4882a593Smuzhiyunusing this system was attempted to evaluate its suitability and it was 147*4882a593Smuzhiyunfound to be inadequate, in this case. The Generic Netlink system was 148*4882a593Smuzhiyunused for this as raw Netlink would lead to a significant increase in 149*4882a593Smuzhiyuncomplexity. There's no question that the Generic Netlink system is an 150*4882a593Smuzhiyunelegant solution for common case ioctl functions but it's not a complete 151*4882a593Smuzhiyunreplacement probably because its primary purpose in life is to be a 152*4882a593Smuzhiyunmessage bus implementation rather than specifically an ioctl replacement. 153*4882a593SmuzhiyunWhile it would be possible to work around this there is one concern 154*4882a593Smuzhiyunthat lead to the decision to not use it. This is that the autofs 155*4882a593Smuzhiyunexpire in the daemon has become far to complex because umount 156*4882a593Smuzhiyuncandidates are enumerated, almost for no other reason than to "count" 157*4882a593Smuzhiyunthe number of times to call the expire ioctl. This involves scanning 158*4882a593Smuzhiyunthe mount table which has proved to be a big overhead for users with 159*4882a593Smuzhiyunlarge maps. The best way to improve this is try and get back to the 160*4882a593Smuzhiyunway the expire was done long ago. That is, when an expire request is 161*4882a593Smuzhiyunissued for a mount (file handle) we should continually call back to 162*4882a593Smuzhiyunthe daemon until we can't umount any more mounts, then return the 163*4882a593Smuzhiyunappropriate status to the daemon. At the moment we just expire one 164*4882a593Smuzhiyunmount at a time. A Generic Netlink implementation would exclude this 165*4882a593Smuzhiyunpossibility for future development due to the requirements of the 166*4882a593Smuzhiyunmessage bus architecture. 167*4882a593Smuzhiyun 168*4882a593Smuzhiyun 169*4882a593Smuzhiyunautofs Miscellaneous Device mount control interface 170*4882a593Smuzhiyun==================================================== 171*4882a593Smuzhiyun 172*4882a593SmuzhiyunThe control interface is opening a device node, typically /dev/autofs. 173*4882a593Smuzhiyun 174*4882a593SmuzhiyunAll the ioctls use a common structure to pass the needed parameter 175*4882a593Smuzhiyuninformation and return operation results:: 176*4882a593Smuzhiyun 177*4882a593Smuzhiyun struct autofs_dev_ioctl { 178*4882a593Smuzhiyun __u32 ver_major; 179*4882a593Smuzhiyun __u32 ver_minor; 180*4882a593Smuzhiyun __u32 size; /* total size of data passed in 181*4882a593Smuzhiyun * including this struct */ 182*4882a593Smuzhiyun __s32 ioctlfd; /* automount command fd */ 183*4882a593Smuzhiyun 184*4882a593Smuzhiyun /* Command parameters */ 185*4882a593Smuzhiyun union { 186*4882a593Smuzhiyun struct args_protover protover; 187*4882a593Smuzhiyun struct args_protosubver protosubver; 188*4882a593Smuzhiyun struct args_openmount openmount; 189*4882a593Smuzhiyun struct args_ready ready; 190*4882a593Smuzhiyun struct args_fail fail; 191*4882a593Smuzhiyun struct args_setpipefd setpipefd; 192*4882a593Smuzhiyun struct args_timeout timeout; 193*4882a593Smuzhiyun struct args_requester requester; 194*4882a593Smuzhiyun struct args_expire expire; 195*4882a593Smuzhiyun struct args_askumount askumount; 196*4882a593Smuzhiyun struct args_ismountpoint ismountpoint; 197*4882a593Smuzhiyun }; 198*4882a593Smuzhiyun 199*4882a593Smuzhiyun char path[0]; 200*4882a593Smuzhiyun }; 201*4882a593Smuzhiyun 202*4882a593SmuzhiyunThe ioctlfd field is a mount point file descriptor of an autofs mount 203*4882a593Smuzhiyunpoint. It is returned by the open call and is used by all calls except 204*4882a593Smuzhiyunthe check for whether a given path is a mount point, where it may 205*4882a593Smuzhiyunoptionally be used to check a specific mount corresponding to a given 206*4882a593Smuzhiyunmount point file descriptor, and when requesting the uid and gid of the 207*4882a593Smuzhiyunlast successful mount on a directory within the autofs file system. 208*4882a593Smuzhiyun 209*4882a593SmuzhiyunThe union is used to communicate parameters and results of calls made 210*4882a593Smuzhiyunas described below. 211*4882a593Smuzhiyun 212*4882a593SmuzhiyunThe path field is used to pass a path where it is needed and the size field 213*4882a593Smuzhiyunis used account for the increased structure length when translating the 214*4882a593Smuzhiyunstructure sent from user space. 215*4882a593Smuzhiyun 216*4882a593SmuzhiyunThis structure can be initialized before setting specific fields by using 217*4882a593Smuzhiyunthe void function call init_autofs_dev_ioctl(``struct autofs_dev_ioctl *``). 218*4882a593Smuzhiyun 219*4882a593SmuzhiyunAll of the ioctls perform a copy of this structure from user space to 220*4882a593Smuzhiyunkernel space and return -EINVAL if the size parameter is smaller than 221*4882a593Smuzhiyunthe structure size itself, -ENOMEM if the kernel memory allocation fails 222*4882a593Smuzhiyunor -EFAULT if the copy itself fails. Other checks include a version check 223*4882a593Smuzhiyunof the compiled in user space version against the module version and a 224*4882a593Smuzhiyunmismatch results in a -EINVAL return. If the size field is greater than 225*4882a593Smuzhiyunthe structure size then a path is assumed to be present and is checked to 226*4882a593Smuzhiyunensure it begins with a "/" and is NULL terminated, otherwise -EINVAL is 227*4882a593Smuzhiyunreturned. Following these checks, for all ioctl commands except 228*4882a593SmuzhiyunAUTOFS_DEV_IOCTL_VERSION_CMD, AUTOFS_DEV_IOCTL_OPENMOUNT_CMD and 229*4882a593SmuzhiyunAUTOFS_DEV_IOCTL_CLOSEMOUNT_CMD the ioctlfd is validated and if it is 230*4882a593Smuzhiyunnot a valid descriptor or doesn't correspond to an autofs mount point 231*4882a593Smuzhiyunan error of -EBADF, -ENOTTY or -EINVAL (not an autofs descriptor) is 232*4882a593Smuzhiyunreturned. 233*4882a593Smuzhiyun 234*4882a593Smuzhiyun 235*4882a593SmuzhiyunThe ioctls 236*4882a593Smuzhiyun========== 237*4882a593Smuzhiyun 238*4882a593SmuzhiyunAn example of an implementation which uses this interface can be seen 239*4882a593Smuzhiyunin autofs version 5.0.4 and later in file lib/dev-ioctl-lib.c of the 240*4882a593Smuzhiyundistribution tar available for download from kernel.org in directory 241*4882a593Smuzhiyun/pub/linux/daemons/autofs/v5. 242*4882a593Smuzhiyun 243*4882a593SmuzhiyunThe device node ioctl operations implemented by this interface are: 244*4882a593Smuzhiyun 245*4882a593Smuzhiyun 246*4882a593SmuzhiyunAUTOFS_DEV_IOCTL_VERSION 247*4882a593Smuzhiyun------------------------ 248*4882a593Smuzhiyun 249*4882a593SmuzhiyunGet the major and minor version of the autofs device ioctl kernel module 250*4882a593Smuzhiyunimplementation. It requires an initialized struct autofs_dev_ioctl as an 251*4882a593Smuzhiyuninput parameter and sets the version information in the passed in structure. 252*4882a593SmuzhiyunIt returns 0 on success or the error -EINVAL if a version mismatch is 253*4882a593Smuzhiyundetected. 254*4882a593Smuzhiyun 255*4882a593Smuzhiyun 256*4882a593SmuzhiyunAUTOFS_DEV_IOCTL_PROTOVER_CMD and AUTOFS_DEV_IOCTL_PROTOSUBVER_CMD 257*4882a593Smuzhiyun------------------------------------------------------------------ 258*4882a593Smuzhiyun 259*4882a593SmuzhiyunGet the major and minor version of the autofs protocol version understood 260*4882a593Smuzhiyunby loaded module. This call requires an initialized struct autofs_dev_ioctl 261*4882a593Smuzhiyunwith the ioctlfd field set to a valid autofs mount point descriptor 262*4882a593Smuzhiyunand sets the requested version number in version field of struct args_protover 263*4882a593Smuzhiyunor sub_version field of struct args_protosubver. These commands return 264*4882a593Smuzhiyun0 on success or one of the negative error codes if validation fails. 265*4882a593Smuzhiyun 266*4882a593Smuzhiyun 267*4882a593SmuzhiyunAUTOFS_DEV_IOCTL_OPENMOUNT and AUTOFS_DEV_IOCTL_CLOSEMOUNT 268*4882a593Smuzhiyun---------------------------------------------------------- 269*4882a593Smuzhiyun 270*4882a593SmuzhiyunObtain and release a file descriptor for an autofs managed mount point 271*4882a593Smuzhiyunpath. The open call requires an initialized struct autofs_dev_ioctl with 272*4882a593Smuzhiyunthe path field set and the size field adjusted appropriately as well 273*4882a593Smuzhiyunas the devid field of struct args_openmount set to the device number of 274*4882a593Smuzhiyunthe autofs mount. The device number can be obtained from the mount options 275*4882a593Smuzhiyunshown in /proc/mounts. The close call requires an initialized struct 276*4882a593Smuzhiyunautofs_dev_ioct with the ioctlfd field set to the descriptor obtained 277*4882a593Smuzhiyunfrom the open call. The release of the file descriptor can also be done 278*4882a593Smuzhiyunwith close(2) so any open descriptors will also be closed at process exit. 279*4882a593SmuzhiyunThe close call is included in the implemented operations largely for 280*4882a593Smuzhiyuncompleteness and to provide for a consistent user space implementation. 281*4882a593Smuzhiyun 282*4882a593Smuzhiyun 283*4882a593SmuzhiyunAUTOFS_DEV_IOCTL_READY_CMD and AUTOFS_DEV_IOCTL_FAIL_CMD 284*4882a593Smuzhiyun-------------------------------------------------------- 285*4882a593Smuzhiyun 286*4882a593SmuzhiyunReturn mount and expire result status from user space to the kernel. 287*4882a593SmuzhiyunBoth of these calls require an initialized struct autofs_dev_ioctl 288*4882a593Smuzhiyunwith the ioctlfd field set to the descriptor obtained from the open 289*4882a593Smuzhiyuncall and the token field of struct args_ready or struct args_fail set 290*4882a593Smuzhiyunto the wait queue token number, received by user space in the foregoing 291*4882a593Smuzhiyunmount or expire request. The status field of struct args_fail is set to 292*4882a593Smuzhiyunthe errno of the operation. It is set to 0 on success. 293*4882a593Smuzhiyun 294*4882a593Smuzhiyun 295*4882a593SmuzhiyunAUTOFS_DEV_IOCTL_SETPIPEFD_CMD 296*4882a593Smuzhiyun------------------------------ 297*4882a593Smuzhiyun 298*4882a593SmuzhiyunSet the pipe file descriptor used for kernel communication to the daemon. 299*4882a593SmuzhiyunNormally this is set at mount time using an option but when reconnecting 300*4882a593Smuzhiyunto a existing mount we need to use this to tell the autofs mount about 301*4882a593Smuzhiyunthe new kernel pipe descriptor. In order to protect mounts against 302*4882a593Smuzhiyunincorrectly setting the pipe descriptor we also require that the autofs 303*4882a593Smuzhiyunmount be catatonic (see next call). 304*4882a593Smuzhiyun 305*4882a593SmuzhiyunThe call requires an initialized struct autofs_dev_ioctl with the 306*4882a593Smuzhiyunioctlfd field set to the descriptor obtained from the open call and 307*4882a593Smuzhiyunthe pipefd field of struct args_setpipefd set to descriptor of the pipe. 308*4882a593SmuzhiyunOn success the call also sets the process group id used to identify the 309*4882a593Smuzhiyuncontrolling process (eg. the owning automount(8) daemon) to the process 310*4882a593Smuzhiyungroup of the caller. 311*4882a593Smuzhiyun 312*4882a593Smuzhiyun 313*4882a593SmuzhiyunAUTOFS_DEV_IOCTL_CATATONIC_CMD 314*4882a593Smuzhiyun------------------------------ 315*4882a593Smuzhiyun 316*4882a593SmuzhiyunMake the autofs mount point catatonic. The autofs mount will no longer 317*4882a593Smuzhiyunissue mount requests, the kernel communication pipe descriptor is released 318*4882a593Smuzhiyunand any remaining waits in the queue released. 319*4882a593Smuzhiyun 320*4882a593SmuzhiyunThe call requires an initialized struct autofs_dev_ioctl with the 321*4882a593Smuzhiyunioctlfd field set to the descriptor obtained from the open call. 322*4882a593Smuzhiyun 323*4882a593Smuzhiyun 324*4882a593SmuzhiyunAUTOFS_DEV_IOCTL_TIMEOUT_CMD 325*4882a593Smuzhiyun---------------------------- 326*4882a593Smuzhiyun 327*4882a593SmuzhiyunSet the expire timeout for mounts within an autofs mount point. 328*4882a593Smuzhiyun 329*4882a593SmuzhiyunThe call requires an initialized struct autofs_dev_ioctl with the 330*4882a593Smuzhiyunioctlfd field set to the descriptor obtained from the open call. 331*4882a593Smuzhiyun 332*4882a593Smuzhiyun 333*4882a593SmuzhiyunAUTOFS_DEV_IOCTL_REQUESTER_CMD 334*4882a593Smuzhiyun------------------------------ 335*4882a593Smuzhiyun 336*4882a593SmuzhiyunReturn the uid and gid of the last process to successfully trigger a the 337*4882a593Smuzhiyunmount on the given path dentry. 338*4882a593Smuzhiyun 339*4882a593SmuzhiyunThe call requires an initialized struct autofs_dev_ioctl with the path 340*4882a593Smuzhiyunfield set to the mount point in question and the size field adjusted 341*4882a593Smuzhiyunappropriately. Upon return the uid field of struct args_requester contains 342*4882a593Smuzhiyunthe uid and gid field the gid. 343*4882a593Smuzhiyun 344*4882a593SmuzhiyunWhen reconstructing an autofs mount tree with active mounts we need to 345*4882a593Smuzhiyunre-connect to mounts that may have used the original process uid and 346*4882a593Smuzhiyungid (or string variations of them) for mount lookups within the map entry. 347*4882a593SmuzhiyunThis call provides the ability to obtain this uid and gid so they may be 348*4882a593Smuzhiyunused by user space for the mount map lookups. 349*4882a593Smuzhiyun 350*4882a593Smuzhiyun 351*4882a593SmuzhiyunAUTOFS_DEV_IOCTL_EXPIRE_CMD 352*4882a593Smuzhiyun--------------------------- 353*4882a593Smuzhiyun 354*4882a593SmuzhiyunIssue an expire request to the kernel for an autofs mount. Typically 355*4882a593Smuzhiyunthis ioctl is called until no further expire candidates are found. 356*4882a593Smuzhiyun 357*4882a593SmuzhiyunThe call requires an initialized struct autofs_dev_ioctl with the 358*4882a593Smuzhiyunioctlfd field set to the descriptor obtained from the open call. In 359*4882a593Smuzhiyunaddition an immediate expire that's independent of the mount timeout, 360*4882a593Smuzhiyunand a forced expire that's independent of whether the mount is busy, 361*4882a593Smuzhiyuncan be requested by setting the how field of struct args_expire to 362*4882a593SmuzhiyunAUTOFS_EXP_IMMEDIATE or AUTOFS_EXP_FORCED, respectively . If no 363*4882a593Smuzhiyunexpire candidates can be found the ioctl returns -1 with errno set to 364*4882a593SmuzhiyunEAGAIN. 365*4882a593Smuzhiyun 366*4882a593SmuzhiyunThis call causes the kernel module to check the mount corresponding 367*4882a593Smuzhiyunto the given ioctlfd for mounts that can be expired, issues an expire 368*4882a593Smuzhiyunrequest back to the daemon and waits for completion. 369*4882a593Smuzhiyun 370*4882a593SmuzhiyunAUTOFS_DEV_IOCTL_ASKUMOUNT_CMD 371*4882a593Smuzhiyun------------------------------ 372*4882a593Smuzhiyun 373*4882a593SmuzhiyunChecks if an autofs mount point is in use. 374*4882a593Smuzhiyun 375*4882a593SmuzhiyunThe call requires an initialized struct autofs_dev_ioctl with the 376*4882a593Smuzhiyunioctlfd field set to the descriptor obtained from the open call and 377*4882a593Smuzhiyunit returns the result in the may_umount field of struct args_askumount, 378*4882a593Smuzhiyun1 for busy and 0 otherwise. 379*4882a593Smuzhiyun 380*4882a593Smuzhiyun 381*4882a593SmuzhiyunAUTOFS_DEV_IOCTL_ISMOUNTPOINT_CMD 382*4882a593Smuzhiyun--------------------------------- 383*4882a593Smuzhiyun 384*4882a593SmuzhiyunCheck if the given path is a mountpoint. 385*4882a593Smuzhiyun 386*4882a593SmuzhiyunThe call requires an initialized struct autofs_dev_ioctl. There are two 387*4882a593Smuzhiyunpossible variations. Both use the path field set to the path of the mount 388*4882a593Smuzhiyunpoint to check and the size field adjusted appropriately. One uses the 389*4882a593Smuzhiyunioctlfd field to identify a specific mount point to check while the other 390*4882a593Smuzhiyunvariation uses the path and optionally in.type field of struct args_ismountpoint 391*4882a593Smuzhiyunset to an autofs mount type. The call returns 1 if this is a mount point 392*4882a593Smuzhiyunand sets out.devid field to the device number of the mount and out.magic 393*4882a593Smuzhiyunfield to the relevant super block magic number (described below) or 0 if 394*4882a593Smuzhiyunit isn't a mountpoint. In both cases the device number (as returned 395*4882a593Smuzhiyunby new_encode_dev()) is returned in out.devid field. 396*4882a593Smuzhiyun 397*4882a593SmuzhiyunIf supplied with a file descriptor we're looking for a specific mount, 398*4882a593Smuzhiyunnot necessarily at the top of the mounted stack. In this case the path 399*4882a593Smuzhiyunthe descriptor corresponds to is considered a mountpoint if it is itself 400*4882a593Smuzhiyuna mountpoint or contains a mount, such as a multi-mount without a root 401*4882a593Smuzhiyunmount. In this case we return 1 if the descriptor corresponds to a mount 402*4882a593Smuzhiyunpoint and also returns the super magic of the covering mount if there 403*4882a593Smuzhiyunis one or 0 if it isn't a mountpoint. 404*4882a593Smuzhiyun 405*4882a593SmuzhiyunIf a path is supplied (and the ioctlfd field is set to -1) then the path 406*4882a593Smuzhiyunis looked up and is checked to see if it is the root of a mount. If a 407*4882a593Smuzhiyuntype is also given we are looking for a particular autofs mount and if 408*4882a593Smuzhiyuna match isn't found a fail is returned. If the located path is the 409*4882a593Smuzhiyunroot of a mount 1 is returned along with the super magic of the mount 410*4882a593Smuzhiyunor 0 otherwise. 411