1 /* 2 * Copyright (c) 1989, 1991 The Regents of the University of California. 3 * All rights reserved. 4 * 5 * %sccs.include.redist.c% 6 * 7 * @(#)mount.h 7.40 (Berkeley) 08/11/92 8 */ 9 10 #ifndef KERNEL 11 #include <sys/ucred.h> 12 #endif 13 14 typedef struct { long val[2]; } fsid_t; /* file system id type */ 15 16 /* 17 * File identifier. 18 * These are unique per filesystem on a single machine. 19 */ 20 #define MAXFIDSZ 16 21 22 struct fid { 23 u_short fid_len; /* length of data in bytes */ 24 u_short fid_reserved; /* force longword alignment */ 25 char fid_data[MAXFIDSZ]; /* data (variable length) */ 26 }; 27 28 /* 29 * file system statistics 30 */ 31 32 #define MNAMELEN 90 /* length of buffer for returned name */ 33 34 struct statfs { 35 short f_type; /* type of filesystem (see below) */ 36 short f_flags; /* copy of mount flags */ 37 long f_bsize; /* fundamental file system block size */ 38 long f_iosize; /* optimal transfer block size */ 39 long f_blocks; /* total data blocks in file system */ 40 long f_bfree; /* free blocks in fs */ 41 long f_bavail; /* free blocks avail to non-superuser */ 42 long f_files; /* total file nodes in file system */ 43 long f_ffree; /* free file nodes in fs */ 44 fsid_t f_fsid; /* file system id */ 45 long f_spare[9]; /* spare for later */ 46 char f_mntonname[MNAMELEN]; /* directory on which mounted */ 47 char f_mntfromname[MNAMELEN];/* mounted filesystem */ 48 }; 49 50 /* 51 * File system types. 52 */ 53 #define MOUNT_NONE 0 54 #define MOUNT_UFS 1 55 #define MOUNT_NFS 2 56 #define MOUNT_MFS 3 57 #define MOUNT_PC 4 58 #define MOUNT_LFS 5 59 #define MOUNT_LOFS 6 60 #define MOUNT_FDESC 7 61 #define MOUNT_PORTAL 8 62 #define MOUNT_NULL 9 63 #define MOUNT_UMAP 10 64 #define MOUNT_KERNFS 11 65 #define MOUNT_MAXTYPE 11 66 67 #define INITMOUNTNAMES { \ 68 "none", /* 0 MOUNT_NONE */ \ 69 "ufs", /* 1 MOUNT_UFS */ \ 70 "nfs", /* 2 MOUNT_NFS */ \ 71 "mfs", /* 3 MOUNT_MFS */ \ 72 "pc", /* 4 MOUNT_PC */ \ 73 "lfs", /* 5 MOUNT_LFS */ \ 74 "lofs", /* 6 MOUNT_LOFS */ \ 75 "fdesc", /* 7 MOUNT_FDESC */ \ 76 "portal", /* 8 MOUNT_PORTAL */ \ 77 "null", /* 9 MOUNT_NULL */ \ 78 "umap", /* 10 MOUNT_UMAP */ \ 79 "kernfs", /* 11 MOUNT_KERNFS */ \ 80 0, /* 12 MOUNT_SPARE */ \ 81 } 82 83 /* 84 * Structure per mounted file system. Each mounted file system has an 85 * array of operations and an instance record. The file systems are 86 * put on a doubly linked list. 87 */ 88 struct mount { 89 struct mount *mnt_next; /* next in mount list */ 90 struct mount *mnt_prev; /* prev in mount list */ 91 struct vfsops *mnt_op; /* operations on fs */ 92 struct vnode *mnt_vnodecovered; /* vnode we mounted on */ 93 struct vnode *mnt_mounth; /* list of vnodes this mount */ 94 int mnt_flag; /* flags */ 95 int mnt_maxsymlinklen; /* max size of short symlink */ 96 struct statfs mnt_stat; /* cache of filesystem stats */ 97 qaddr_t mnt_data; /* private data */ 98 }; 99 100 /* 101 * Mount flags. 102 */ 103 #define MNT_RDONLY 0x00000001 /* read only filesystem */ 104 #define MNT_SYNCHRONOUS 0x00000002 /* file system written synchronously */ 105 #define MNT_NOEXEC 0x00000004 /* can't exec from filesystem */ 106 #define MNT_NOSUID 0x00000008 /* don't honor setuid bits on fs */ 107 #define MNT_NODEV 0x00000010 /* don't interpret special files */ 108 #define MNT_UNION 0x00000020 /* union with underlying filesystem */ 109 110 /* 111 * exported mount flags. 112 */ 113 #define MNT_EXRDONLY 0x00000080 /* exported read only */ 114 #define MNT_EXPORTED 0x00000100 /* file system is exported */ 115 #define MNT_DEFEXPORTED 0x00000200 /* exported to the world */ 116 #define MNT_EXPORTANON 0x00000400 /* use anon uid mapping for everyone */ 117 #define MNT_EXKERB 0x00000800 /* exported with Kerberos uid mapping */ 118 119 /* 120 * Flags set by internal operations. 121 */ 122 #define MNT_LOCAL 0x00001000 /* filesystem is stored locally */ 123 #define MNT_QUOTA 0x00002000 /* quotas are enabled on filesystem */ 124 125 /* 126 * Mask of flags that are visible to statfs() 127 */ 128 #define MNT_VISFLAGMASK 0x0000ffff 129 130 /* 131 * filesystem control flags. 132 * 133 * MNT_MLOCK lock the mount entry so that name lookup cannot proceed 134 * past the mount point. This keeps the subtree stable during mounts 135 * and unmounts. 136 */ 137 #define MNT_UPDATE 0x00010000 /* not a real mount, just an update */ 138 #define MNT_DELEXPORT 0x00020000 /* delete export host lists */ 139 #define MNT_MLOCK 0x00100000 /* lock so that subtree is stable */ 140 #define MNT_MWAIT 0x00200000 /* someone is waiting for lock */ 141 #define MNT_MPBUSY 0x00400000 /* scan of mount point in progress */ 142 #define MNT_MPWANT 0x00800000 /* waiting for mount point */ 143 #define MNT_UNMOUNT 0x01000000 /* unmount in progress */ 144 145 /* 146 * Operations supported on mounted file system. 147 */ 148 #ifdef KERNEL 149 #ifdef __STDC__ 150 struct nameidata; 151 struct mbuf; 152 #endif 153 154 struct vfsops { 155 int (*vfs_mount) __P((struct mount *mp, char *path, caddr_t data, 156 struct nameidata *ndp, struct proc *p)); 157 int (*vfs_start) __P((struct mount *mp, int flags, 158 struct proc *p)); 159 int (*vfs_unmount) __P((struct mount *mp, int mntflags, 160 struct proc *p)); 161 int (*vfs_root) __P((struct mount *mp, struct vnode **vpp)); 162 int (*vfs_quotactl) __P((struct mount *mp, int cmds, uid_t uid, 163 caddr_t arg, struct proc *p)); 164 int (*vfs_statfs) __P((struct mount *mp, struct statfs *sbp, 165 struct proc *p)); 166 int (*vfs_sync) __P((struct mount *mp, int waitfor, 167 struct ucred *cred, struct proc *p)); 168 int (*vfs_vget) __P((struct mount *mp, ino_t ino, 169 struct vnode **vpp)); 170 int (*vfs_fhtovp) __P((struct mount *mp, struct fid *fhp, 171 struct mbuf *nam, struct vnode **vpp, 172 int *exflagsp, struct ucred **credanonp)); 173 int (*vfs_vptofh) __P((struct vnode *vp, struct fid *fhp)); 174 int (*vfs_init) __P((void)); 175 }; 176 177 #define VFS_MOUNT(MP, PATH, DATA, NDP, P) \ 178 (*(MP)->mnt_op->vfs_mount)(MP, PATH, DATA, NDP, P) 179 #define VFS_START(MP, FLAGS, P) (*(MP)->mnt_op->vfs_start)(MP, FLAGS, P) 180 #define VFS_UNMOUNT(MP, FORCE, P) (*(MP)->mnt_op->vfs_unmount)(MP, FORCE, P) 181 #define VFS_ROOT(MP, VPP) (*(MP)->mnt_op->vfs_root)(MP, VPP) 182 #define VFS_QUOTACTL(MP,C,U,A,P) (*(MP)->mnt_op->vfs_quotactl)(MP, C, U, A, P) 183 #define VFS_STATFS(MP, SBP, P) (*(MP)->mnt_op->vfs_statfs)(MP, SBP, P) 184 #define VFS_SYNC(MP, WAIT, C, P) (*(MP)->mnt_op->vfs_sync)(MP, WAIT, C, P) 185 #define VFS_VGET(MP, INO, VPP) (*(MP)->mnt_op->vfs_vget)(MP, INO, VPP) 186 #define VFS_FHTOVP(MP, FIDP, NAM, VPP, EXFLG, CRED) \ 187 (*(MP)->mnt_op->vfs_fhtovp)(MP, FIDP, NAM, VPP, EXFLG, CRED) 188 #define VFS_VPTOFH(VP, FIDP) (*(VP)->v_mount->mnt_op->vfs_vptofh)(VP, FIDP) 189 #endif /* KERNEL */ 190 191 /* 192 * Flags for various system call interfaces. 193 * 194 * forcibly flags for vfs_umount(). 195 * waitfor flags to vfs_sync() and getfsstat() 196 */ 197 #define MNT_FORCE 1 198 #define MNT_NOFORCE 2 199 #define MNT_WAIT 1 200 #define MNT_NOWAIT 2 201 202 /* 203 * Generic file handle 204 */ 205 struct fhandle { 206 fsid_t fh_fsid; /* File system id of mount point */ 207 struct fid fh_fid; /* File sys specific id */ 208 }; 209 typedef struct fhandle fhandle_t; 210 211 #ifdef KERNEL 212 #include <net/radix.h> 213 214 /* 215 * Network address lookup element 216 */ 217 struct netcred { 218 struct radix_node netc_rnodes[2]; 219 int netc_exflags; 220 struct ucred netc_anon; 221 }; 222 #endif /* KERNEL */ 223 224 /* 225 * Arguments to mount UFS-based filesystems 226 */ 227 struct ufs_args { 228 char *fspec; /* block special device to mount */ 229 int exflags; /* export related flags */ 230 uid_t exroot; /* mapping for root uid */ 231 struct ucred anon; /* mapping for anonymous user */ 232 struct sockaddr *saddr;/* net address to which exported */ 233 int slen; /* and the net address length */ 234 struct sockaddr *smask;/* mask of valid bits in saddr */ 235 int msklen; /* and the smask length */ 236 }; 237 238 #ifdef MFS 239 /* 240 * Arguments to mount MFS 241 */ 242 struct mfs_args { 243 char *name; /* name to export for statfs */ 244 caddr_t base; /* base address of file system in memory */ 245 u_long size; /* size of file system */ 246 }; 247 #endif /* MFS */ 248 249 #ifdef NFS 250 /* 251 * File Handle (32 bytes for version 2), variable up to 1024 for version 3 252 */ 253 union nfsv2fh { 254 fhandle_t fh_generic; 255 u_char fh_bytes[32]; 256 }; 257 typedef union nfsv2fh nfsv2fh_t; 258 259 /* 260 * Arguments to mount NFS 261 */ 262 struct nfs_args { 263 struct sockaddr *addr; /* file server address */ 264 int addrlen; /* length of address */ 265 int sotype; /* Socket type */ 266 int proto; /* and Protocol */ 267 nfsv2fh_t *fh; /* File handle to be mounted */ 268 int flags; /* flags */ 269 int wsize; /* write size in bytes */ 270 int rsize; /* read size in bytes */ 271 int timeo; /* initial timeout in .1 secs */ 272 int retrans; /* times to retry send */ 273 int maxgrouplist; /* Max. size of group list */ 274 int readahead; /* # of blocks to readahead */ 275 int leaseterm; /* Term (sec) of lease */ 276 int deadthresh; /* Retrans threshold */ 277 char *hostname; /* server's name */ 278 }; 279 280 281 /* 282 * NFS mount option flags 283 */ 284 #define NFSMNT_SOFT 0x00000001 /* soft mount (hard is default) */ 285 #define NFSMNT_WSIZE 0x00000002 /* set write size */ 286 #define NFSMNT_RSIZE 0x00000004 /* set read size */ 287 #define NFSMNT_TIMEO 0x00000008 /* set initial timeout */ 288 #define NFSMNT_RETRANS 0x00000010 /* set number of request retrys */ 289 #define NFSMNT_MAXGRPS 0x00000020 /* set maximum grouplist size */ 290 #define NFSMNT_INT 0x00000040 /* allow interrupts on hard mount */ 291 #define NFSMNT_NOCONN 0x00000080 /* Don't Connect the socket */ 292 #define NFSMNT_NQNFS 0x00000100 /* Use Nqnfs protocol */ 293 #define NFSMNT_MYWRITE 0x00000200 /* Assume writes were mine */ 294 #define NFSMNT_KERB 0x00000400 /* Use Kerberos authentication */ 295 #define NFSMNT_DUMBTIMR 0x00000800 /* Don't estimate rtt dynamically */ 296 #define NFSMNT_RDIRALOOK 0x00001000 /* Do lookup with readdir (nqnfs) */ 297 #define NFSMNT_LEASETERM 0x00002000 /* set lease term (nqnfs) */ 298 #define NFSMNT_READAHEAD 0x00004000 /* set read ahead */ 299 #define NFSMNT_DEADTHRESH 0x00008000 /* set dead server retry thresh */ 300 #define NFSMNT_NQLOOKLEASE 0x00010000 /* Get lease for lookup */ 301 #define NFSMNT_RESVPORT 0x00020000 /* Allocate a reserved port */ 302 #define NFSMNT_INTERNAL 0xffe00000 /* Bits set internally */ 303 #define NFSMNT_MNTD 0x00200000 /* Mnt server for mnt point */ 304 #define NFSMNT_DISMINPROG 0x00400000 /* Dismount in progress */ 305 #define NFSMNT_DISMNT 0x00800000 /* Dismounted */ 306 #define NFSMNT_SNDLOCK 0x01000000 /* Send socket lock */ 307 #define NFSMNT_WANTSND 0x02000000 /* Want above */ 308 #define NFSMNT_RCVLOCK 0x04000000 /* Rcv socket lock */ 309 #define NFSMNT_WANTRCV 0x08000000 /* Want above */ 310 #define NFSMNT_WAITAUTH 0x10000000 /* Wait for authentication */ 311 #define NFSMNT_HASAUTH 0x20000000 /* Has authenticator */ 312 #define NFSMNT_WANTAUTH 0x40000000 /* Wants an authenticator */ 313 #define NFSMNT_AUTHERR 0x80000000 /* Authentication error */ 314 #endif /* NFS */ 315 316 #ifdef KERNEL 317 /* 318 * exported vnode operations 319 */ 320 void vfs_remove __P((struct mount *mp)); /* remove a vfs from mount list */ 321 int vfs_lock __P((struct mount *mp)); /* lock a vfs */ 322 void vfs_unlock __P((struct mount *mp)); /* unlock a vfs */ 323 struct mount *getvfs __P((fsid_t *fsid)); /* return vfs given fsid */ 324 extern struct mount *rootfs; /* ptr to root mount structure */ 325 extern struct vfsops *vfssw[]; /* mount filesystem type table */ 326 327 #else /* KERNEL */ 328 329 #include <sys/cdefs.h> 330 331 __BEGIN_DECLS 332 int fstatfs __P((int, struct statfs *)); 333 int getfh __P((const char *, fhandle_t *)); 334 int getfsstat __P((struct statfs *, long, int)); 335 int getmntinfo __P((struct statfs **, int)); 336 int mount __P((int, const char *, int, void *)); 337 int statfs __P((const char *, struct statfs *)); 338 int unmount __P((const char *, int)); 339 __END_DECLS 340 341 #endif /* KERNEL */ 342