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.32 (Berkeley) 05/31/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_MAXTYPE 8 63 64 /* 65 * Structure per mounted file system. Each mounted file system has an 66 * array of operations and an instance record. The file systems are 67 * put on a doubly linked list. 68 */ 69 struct mount { 70 struct mount *mnt_next; /* next in mount list */ 71 struct mount *mnt_prev; /* prev in mount list */ 72 struct vfsops *mnt_op; /* operations on fs */ 73 struct vnode *mnt_vnodecovered; /* vnode we mounted on */ 74 struct vnode *mnt_mounth; /* list of vnodes this mount */ 75 int mnt_flag; /* flags */ 76 struct statfs mnt_stat; /* cache of filesystem stats */ 77 qaddr_t mnt_data; /* private data */ 78 }; 79 80 /* 81 * Mount flags. 82 */ 83 #define MNT_RDONLY 0x00000001 /* read only filesystem */ 84 #define MNT_SYNCHRONOUS 0x00000002 /* file system written synchronously */ 85 #define MNT_NOEXEC 0x00000004 /* can't exec from filesystem */ 86 #define MNT_NOSUID 0x00000008 /* don't honor setuid bits on fs */ 87 #define MNT_NODEV 0x00000010 /* don't interpret special files */ 88 89 /* 90 * exported mount flags. 91 */ 92 #define MNT_EXRDONLY 0x00000080 /* exported read only */ 93 #define MNT_EXPORTED 0x00000100 /* file system is exported */ 94 #define MNT_DEFEXPORTED 0x00000200 /* exported to the world */ 95 #define MNT_EXPORTANON 0x00000400 /* use anon uid mapping for everyone */ 96 #define MNT_EXKERB 0x00000800 /* exported with Kerberos uid mapping */ 97 98 /* 99 * Flags set by internal operations. 100 */ 101 #define MNT_LOCAL 0x00001000 /* filesystem is stored locally */ 102 #define MNT_QUOTA 0x00002000 /* quotas are enabled on filesystem */ 103 104 /* 105 * Mask of flags that are visible to statfs() 106 */ 107 #define MNT_VISFLAGMASK 0x0000ffff 108 109 /* 110 * filesystem control flags. 111 * 112 * MNT_MLOCK lock the mount entry so that name lookup cannot proceed 113 * past the mount point. This keeps the subtree stable during mounts 114 * and unmounts. 115 */ 116 #define MNT_UPDATE 0x00010000 /* not a real mount, just an update */ 117 #define MNT_DELEXPORT 0x00020000 /* delete export host lists */ 118 #define MNT_MLOCK 0x00100000 /* lock so that subtree is stable */ 119 #define MNT_MWAIT 0x00200000 /* someone is waiting for lock */ 120 #define MNT_MPBUSY 0x00400000 /* scan of mount point in progress */ 121 #define MNT_MPWANT 0x00800000 /* waiting for mount point */ 122 #define MNT_UNMOUNT 0x01000000 /* unmount in progress */ 123 124 /* 125 * Operations supported on mounted file system. 126 */ 127 #ifdef KERNEL 128 #ifdef __STDC__ 129 struct nameidata; 130 #endif 131 132 struct vfsops { 133 int (*vfs_mount) __P((struct mount *mp, char *path, caddr_t data, 134 struct nameidata *ndp, struct proc *p)); 135 int (*vfs_start) __P((struct mount *mp, int flags, 136 struct proc *p)); 137 int (*vfs_unmount) __P((struct mount *mp, int mntflags, 138 struct proc *p)); 139 int (*vfs_root) __P((struct mount *mp, struct vnode **vpp)); 140 /* int uid, should be uid_t */ 141 int (*vfs_quotactl) __P((struct mount *mp, int cmds, u_int uid, 142 caddr_t arg, struct proc *p)); 143 int (*vfs_statfs) __P((struct mount *mp, struct statfs *sbp, 144 struct proc *p)); 145 int (*vfs_sync) __P((struct mount *mp, int waitfor)); 146 int (*vfs_fhtovp) __P((struct mount *mp, struct fid *fhp, 147 int setgen, struct vnode **vpp)); 148 int (*vfs_vptofh) __P((struct vnode *vp, struct fid *fhp)); 149 int (*vfs_init) __P((void)); 150 }; 151 152 #define VFS_MOUNT(MP, PATH, DATA, NDP, P) \ 153 (*(MP)->mnt_op->vfs_mount)(MP, PATH, DATA, NDP, P) 154 #define VFS_START(MP, FLAGS, P) (*(MP)->mnt_op->vfs_start)(MP, FLAGS, P) 155 #define VFS_UNMOUNT(MP, FORCE, P) (*(MP)->mnt_op->vfs_unmount)(MP, FORCE, P) 156 #define VFS_ROOT(MP, VPP) (*(MP)->mnt_op->vfs_root)(MP, VPP) 157 #define VFS_QUOTACTL(MP,C,U,A,P) (*(MP)->mnt_op->vfs_quotactl)(MP, C, U, A, P) 158 #define VFS_STATFS(MP, SBP, P) (*(MP)->mnt_op->vfs_statfs)(MP, SBP, P) 159 #define VFS_SYNC(MP, WAITFOR) (*(MP)->mnt_op->vfs_sync)(MP, WAITFOR) 160 #define VFS_FHTOVP(MP, FIDP, SG, VPP) \ 161 (*(MP)->mnt_op->vfs_fhtovp)(MP, FIDP, SG, VPP) 162 #define VFS_VPTOFH(VP, FIDP) (*(VP)->v_mount->mnt_op->vfs_vptofh)(VP, FIDP) 163 #endif /* KERNEL */ 164 165 /* 166 * Flags for various system call interfaces. 167 * 168 * forcibly flags for vfs_umount(). 169 * waitfor flags to vfs_sync() and getfsstat() 170 */ 171 #define MNT_FORCE 1 172 #define MNT_NOFORCE 2 173 #define MNT_WAIT 1 174 #define MNT_NOWAIT 2 175 176 /* 177 * Generic file handle 178 */ 179 struct fhandle { 180 fsid_t fh_fsid; /* File system id of mount point */ 181 struct fid fh_fid; /* File sys specific id */ 182 }; 183 typedef struct fhandle fhandle_t; 184 185 /* 186 * Network address hash list element 187 */ 188 union nethostaddr { 189 u_long had_inetaddr; 190 struct mbuf *had_nam; 191 }; 192 193 struct netaddrhash { 194 struct netaddrhash *neth_next; 195 struct ucred neth_anon; 196 u_short neth_family; 197 union nethostaddr neth_haddr; 198 union nethostaddr neth_hmask; 199 int neth_exflags; 200 }; 201 #define neth_inetaddr neth_haddr.had_inetaddr 202 #define neth_inetmask neth_hmask.had_inetaddr 203 #define neth_nam neth_haddr.had_nam 204 #define neth_msk neth_hmask.had_nam 205 206 /* 207 * Network address hashing defs. 208 */ 209 #define NETHASHSZ 8 /* Must be a power of 2 <= 256 */ 210 #define NETMASK_HASH NETHASHSZ /* Last hash table element is for networks */ 211 #define NETADDRHASH(a) \ 212 (((a)->sa_family == AF_INET) ? ((a)->sa_data[5] & (NETHASHSZ - 1)) : \ 213 (((a)->sa_family == AF_ISO) ? iso_addrhash(a) : 0)) 214 215 /* 216 * Arguments to mount UFS-based filesystems 217 */ 218 struct ufs_args { 219 char *fspec; /* block special device to mount */ 220 int exflags; /* export related flags */ 221 uid_t exroot; /* mapping for root uid */ 222 struct ucred anon; /* mapping for anonymous user */ 223 struct sockaddr *saddr;/* net address to which exported */ 224 int slen; /* and the net address length */ 225 struct sockaddr *smask;/* mask of valid bits in saddr */ 226 int msklen; /* and the smask length */ 227 }; 228 229 #ifdef MFS 230 /* 231 * Arguments to mount MFS 232 */ 233 struct mfs_args { 234 char *name; /* name to export for statfs */ 235 caddr_t base; /* base address of file system in memory */ 236 u_long size; /* size of file system */ 237 }; 238 #endif /* MFS */ 239 240 #ifdef NFS 241 /* 242 * File Handle (32 bytes for version 2), variable up to 1024 for version 3 243 */ 244 union nfsv2fh { 245 fhandle_t fh_generic; 246 u_char fh_bytes[32]; 247 }; 248 typedef union nfsv2fh nfsv2fh_t; 249 250 /* 251 * Arguments to mount NFS 252 */ 253 struct nfs_args { 254 struct sockaddr *addr; /* file server address */ 255 int addrlen; /* length of address */ 256 int sotype; /* Socket type */ 257 int proto; /* and Protocol */ 258 nfsv2fh_t *fh; /* File handle to be mounted */ 259 int flags; /* flags */ 260 int wsize; /* write size in bytes */ 261 int rsize; /* read size in bytes */ 262 int timeo; /* initial timeout in .1 secs */ 263 int retrans; /* times to retry send */ 264 int maxgrouplist; /* Max. size of group list */ 265 int readahead; /* # of blocks to readahead */ 266 int leaseterm; /* Term (sec) of lease */ 267 int deadthresh; /* Retrans threshold */ 268 char *hostname; /* server's name */ 269 }; 270 271 272 /* 273 * NFS mount option flags 274 */ 275 #define NFSMNT_SOFT 0x00000001 /* soft mount (hard is default) */ 276 #define NFSMNT_WSIZE 0x00000002 /* set write size */ 277 #define NFSMNT_RSIZE 0x00000004 /* set read size */ 278 #define NFSMNT_TIMEO 0x00000008 /* set initial timeout */ 279 #define NFSMNT_RETRANS 0x00000010 /* set number of request retrys */ 280 #define NFSMNT_MAXGRPS 0x00000020 /* set maximum grouplist size */ 281 #define NFSMNT_INT 0x00000040 /* allow interrupts on hard mount */ 282 #define NFSMNT_NOCONN 0x00000080 /* Don't Connect the socket */ 283 #define NFSMNT_NQNFS 0x00000100 /* Use Nqnfs protocol */ 284 #define NFSMNT_MYWRITE 0x00000200 /* Assume writes were mine */ 285 #define NFSMNT_KERB 0x00000400 /* Use Kerberos authentication */ 286 #define NFSMNT_DUMBTIMR 0x00000800 /* Don't estimate rtt dynamically */ 287 #define NFSMNT_RDIRALOOK 0x00001000 /* Do lookup with readdir (nqnfs) */ 288 #define NFSMNT_LEASETERM 0x00002000 /* set lease term (nqnfs) */ 289 #define NFSMNT_READAHEAD 0x00004000 /* set read ahead */ 290 #define NFSMNT_DEADTHRESH 0x00008000 /* set dead server retry thresh */ 291 #define NFSMNT_NQLOOKLEASE 0x00010000 /* Get lease for lookup */ 292 #define NFSMNT_RESVPORT 0x00020000 /* Allocate a reserved port */ 293 #define NFSMNT_INTERNAL 0xffe00000 /* Bits set internally */ 294 #define NFSMNT_MNTD 0x00200000 /* Mnt server for mnt point */ 295 #define NFSMNT_DISMINPROG 0x00400000 /* Dismount in progress */ 296 #define NFSMNT_DISMNT 0x00800000 /* Dismounted */ 297 #define NFSMNT_SNDLOCK 0x01000000 /* Send socket lock */ 298 #define NFSMNT_WANTSND 0x02000000 /* Want above */ 299 #define NFSMNT_RCVLOCK 0x04000000 /* Rcv socket lock */ 300 #define NFSMNT_WANTRCV 0x08000000 /* Want above */ 301 #define NFSMNT_WAITAUTH 0x10000000 /* Wait for authentication */ 302 #define NFSMNT_HASAUTH 0x20000000 /* Has authenticator */ 303 #define NFSMNT_WANTAUTH 0x40000000 /* Wants an authenticator */ 304 #define NFSMNT_AUTHERR 0x80000000 /* Authentication error */ 305 #endif /* NFS */ 306 307 #ifdef KERNEL 308 /* 309 * exported vnode operations 310 */ 311 void vfs_remove __P((struct mount *mp)); /* remove a vfs from mount list */ 312 int vfs_lock __P((struct mount *mp)); /* lock a vfs */ 313 void vfs_unlock __P((struct mount *mp)); /* unlock a vfs */ 314 struct mount *getvfs __P((fsid_t *fsid)); /* return vfs given fsid */ 315 extern struct mount *rootfs; /* ptr to root mount structure */ 316 extern struct vfsops *vfssw[]; /* mount filesystem type table */ 317 318 #else /* KERNEL */ 319 320 #include <sys/cdefs.h> 321 322 __BEGIN_DECLS 323 int fstatfs __P((int, struct statfs *)); 324 int getfh __P((const char *, fhandle_t *)); 325 int getfsstat __P((struct statfs *, long, int)); 326 int getmntinfo __P((struct statfs **, int)); 327 int mount __P((int, const char *, int, void *)); 328 int statfs __P((const char *, struct statfs *)); 329 int unmount __P((const char *, int)); 330 __END_DECLS 331 332 #endif /* KERNEL */ 333