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