1 /* 2 * Copyright (c) 1989, 1991, 1993 3 * The Regents of the University of California. All rights reserved. 4 * 5 * %sccs.include.redist.c% 6 * 7 * @(#)mount.h 8.1 (Berkeley) 06/02/93 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 * Unmount uses MNT_FORCE flag. 104 */ 105 #define MNT_RDONLY 0x00000001 /* read only filesystem */ 106 #define MNT_SYNCHRONOUS 0x00000002 /* file system written synchronously */ 107 #define MNT_NOEXEC 0x00000004 /* can't exec from filesystem */ 108 #define MNT_NOSUID 0x00000008 /* don't honor setuid bits on fs */ 109 #define MNT_NODEV 0x00000010 /* don't interpret special files */ 110 #define MNT_UNION 0x00000020 /* union with underlying filesystem */ 111 112 /* 113 * exported mount flags. 114 */ 115 #define MNT_EXRDONLY 0x00000080 /* exported read only */ 116 #define MNT_EXPORTED 0x00000100 /* file system is exported */ 117 #define MNT_DEFEXPORTED 0x00000200 /* exported to the world */ 118 #define MNT_EXPORTANON 0x00000400 /* use anon uid mapping for everyone */ 119 #define MNT_EXKERB 0x00000800 /* exported with Kerberos uid mapping */ 120 121 /* 122 * Flags set by internal operations. 123 */ 124 #define MNT_LOCAL 0x00001000 /* filesystem is stored locally */ 125 #define MNT_QUOTA 0x00002000 /* quotas are enabled on filesystem */ 126 127 /* 128 * Mask of flags that are visible to statfs() 129 */ 130 #define MNT_VISFLAGMASK 0x0000ffff 131 132 /* 133 * filesystem control flags. 134 * 135 * MNT_MLOCK lock the mount entry so that name lookup cannot proceed 136 * past the mount point. This keeps the subtree stable during mounts 137 * and unmounts. 138 */ 139 #define MNT_UPDATE 0x00010000 /* not a real mount, just an update */ 140 #define MNT_DELEXPORT 0x00020000 /* delete export host lists */ 141 #define MNT_RELOAD 0x00040000 /* reload filesystem data */ 142 #define MNT_FORCE 0x00080000 /* force unmount or readonly change */ 143 #define MNT_MLOCK 0x00100000 /* lock so that subtree is stable */ 144 #define MNT_MWAIT 0x00200000 /* someone is waiting for lock */ 145 #define MNT_MPBUSY 0x00400000 /* scan of mount point in progress */ 146 #define MNT_MPWANT 0x00800000 /* waiting for mount point */ 147 #define MNT_UNMOUNT 0x01000000 /* unmount in progress */ 148 #define MNT_WANTRDWR 0x02000000 /* want upgrade to read/write */ 149 150 /* 151 * Operations supported on mounted file system. 152 */ 153 #ifdef KERNEL 154 #ifdef __STDC__ 155 struct nameidata; 156 struct mbuf; 157 #endif 158 159 struct vfsops { 160 int (*vfs_mount) __P((struct mount *mp, char *path, caddr_t data, 161 struct nameidata *ndp, struct proc *p)); 162 int (*vfs_start) __P((struct mount *mp, int flags, 163 struct proc *p)); 164 int (*vfs_unmount) __P((struct mount *mp, int mntflags, 165 struct proc *p)); 166 int (*vfs_root) __P((struct mount *mp, struct vnode **vpp)); 167 int (*vfs_quotactl) __P((struct mount *mp, int cmds, uid_t uid, 168 caddr_t arg, struct proc *p)); 169 int (*vfs_statfs) __P((struct mount *mp, struct statfs *sbp, 170 struct proc *p)); 171 int (*vfs_sync) __P((struct mount *mp, int waitfor, 172 struct ucred *cred, struct proc *p)); 173 int (*vfs_vget) __P((struct mount *mp, ino_t ino, 174 struct vnode **vpp)); 175 int (*vfs_fhtovp) __P((struct mount *mp, struct fid *fhp, 176 struct mbuf *nam, struct vnode **vpp, 177 int *exflagsp, struct ucred **credanonp)); 178 int (*vfs_vptofh) __P((struct vnode *vp, struct fid *fhp)); 179 int (*vfs_init) __P((void)); 180 }; 181 182 #define VFS_MOUNT(MP, PATH, DATA, NDP, P) \ 183 (*(MP)->mnt_op->vfs_mount)(MP, PATH, DATA, NDP, P) 184 #define VFS_START(MP, FLAGS, P) (*(MP)->mnt_op->vfs_start)(MP, FLAGS, P) 185 #define VFS_UNMOUNT(MP, FORCE, P) (*(MP)->mnt_op->vfs_unmount)(MP, FORCE, P) 186 #define VFS_ROOT(MP, VPP) (*(MP)->mnt_op->vfs_root)(MP, VPP) 187 #define VFS_QUOTACTL(MP,C,U,A,P) (*(MP)->mnt_op->vfs_quotactl)(MP, C, U, A, P) 188 #define VFS_STATFS(MP, SBP, P) (*(MP)->mnt_op->vfs_statfs)(MP, SBP, P) 189 #define VFS_SYNC(MP, WAIT, C, P) (*(MP)->mnt_op->vfs_sync)(MP, WAIT, C, P) 190 #define VFS_VGET(MP, INO, VPP) (*(MP)->mnt_op->vfs_vget)(MP, INO, VPP) 191 #define VFS_FHTOVP(MP, FIDP, NAM, VPP, EXFLG, CRED) \ 192 (*(MP)->mnt_op->vfs_fhtovp)(MP, FIDP, NAM, VPP, EXFLG, CRED) 193 #define VFS_VPTOFH(VP, FIDP) (*(VP)->v_mount->mnt_op->vfs_vptofh)(VP, FIDP) 194 #endif /* KERNEL */ 195 196 /* 197 * Flags for various system call interfaces. 198 * 199 * waitfor flags to vfs_sync() and getfsstat() 200 */ 201 #define MNT_WAIT 1 202 #define MNT_NOWAIT 2 203 204 /* 205 * Generic file handle 206 */ 207 struct fhandle { 208 fsid_t fh_fsid; /* File system id of mount point */ 209 struct fid fh_fid; /* File sys specific id */ 210 }; 211 typedef struct fhandle fhandle_t; 212 213 #ifdef KERNEL 214 #include <net/radix.h> 215 216 /* 217 * Network address lookup element 218 */ 219 struct netcred { 220 struct radix_node netc_rnodes[2]; 221 int netc_exflags; 222 struct ucred netc_anon; 223 }; 224 #endif /* KERNEL */ 225 226 /* 227 * Arguments to mount UFS-based filesystems 228 */ 229 struct ufs_args { 230 char *fspec; /* block special device to mount */ 231 int exflags; /* export related flags */ 232 uid_t exroot; /* mapping for root uid */ 233 struct ucred anon; /* mapping for anonymous user */ 234 struct sockaddr *saddr;/* net address to which exported */ 235 int slen; /* and the net address length */ 236 struct sockaddr *smask;/* mask of valid bits in saddr */ 237 int msklen; /* and the smask length */ 238 }; 239 240 #ifdef MFS 241 /* 242 * Arguments to mount MFS 243 */ 244 struct mfs_args { 245 char *name; /* name to export for statfs */ 246 caddr_t base; /* base address of file system in memory */ 247 u_long size; /* size of file system */ 248 }; 249 #endif /* MFS */ 250 251 #ifdef NFS 252 /* 253 * File Handle (32 bytes for version 2), variable up to 1024 for version 3 254 */ 255 union nfsv2fh { 256 fhandle_t fh_generic; 257 u_char fh_bytes[32]; 258 }; 259 typedef union nfsv2fh nfsv2fh_t; 260 261 /* 262 * Arguments to mount NFS 263 */ 264 struct nfs_args { 265 struct sockaddr *addr; /* file server address */ 266 int addrlen; /* length of address */ 267 int sotype; /* Socket type */ 268 int proto; /* and Protocol */ 269 nfsv2fh_t *fh; /* File handle to be mounted */ 270 int flags; /* flags */ 271 int wsize; /* write size in bytes */ 272 int rsize; /* read size in bytes */ 273 int timeo; /* initial timeout in .1 secs */ 274 int retrans; /* times to retry send */ 275 int maxgrouplist; /* Max. size of group list */ 276 int readahead; /* # of blocks to readahead */ 277 int leaseterm; /* Term (sec) of lease */ 278 int deadthresh; /* Retrans threshold */ 279 char *hostname; /* server's name */ 280 }; 281 282 283 /* 284 * NFS mount option flags 285 */ 286 #define NFSMNT_SOFT 0x00000001 /* soft mount (hard is default) */ 287 #define NFSMNT_WSIZE 0x00000002 /* set write size */ 288 #define NFSMNT_RSIZE 0x00000004 /* set read size */ 289 #define NFSMNT_TIMEO 0x00000008 /* set initial timeout */ 290 #define NFSMNT_RETRANS 0x00000010 /* set number of request retrys */ 291 #define NFSMNT_MAXGRPS 0x00000020 /* set maximum grouplist size */ 292 #define NFSMNT_INT 0x00000040 /* allow interrupts on hard mount */ 293 #define NFSMNT_NOCONN 0x00000080 /* Don't Connect the socket */ 294 #define NFSMNT_NQNFS 0x00000100 /* Use Nqnfs protocol */ 295 #define NFSMNT_MYWRITE 0x00000200 /* Assume writes were mine */ 296 #define NFSMNT_KERB 0x00000400 /* Use Kerberos authentication */ 297 #define NFSMNT_DUMBTIMR 0x00000800 /* Don't estimate rtt dynamically */ 298 #define NFSMNT_RDIRALOOK 0x00001000 /* Do lookup with readdir (nqnfs) */ 299 #define NFSMNT_LEASETERM 0x00002000 /* set lease term (nqnfs) */ 300 #define NFSMNT_READAHEAD 0x00004000 /* set read ahead */ 301 #define NFSMNT_DEADTHRESH 0x00008000 /* set dead server retry thresh */ 302 #define NFSMNT_NQLOOKLEASE 0x00010000 /* Get lease for lookup */ 303 #define NFSMNT_RESVPORT 0x00020000 /* Allocate a reserved port */ 304 #define NFSMNT_INTERNAL 0xffe00000 /* Bits set internally */ 305 #define NFSMNT_MNTD 0x00200000 /* Mnt server for mnt point */ 306 #define NFSMNT_DISMINPROG 0x00400000 /* Dismount in progress */ 307 #define NFSMNT_DISMNT 0x00800000 /* Dismounted */ 308 #define NFSMNT_SNDLOCK 0x01000000 /* Send socket lock */ 309 #define NFSMNT_WANTSND 0x02000000 /* Want above */ 310 #define NFSMNT_RCVLOCK 0x04000000 /* Rcv socket lock */ 311 #define NFSMNT_WANTRCV 0x08000000 /* Want above */ 312 #define NFSMNT_WAITAUTH 0x10000000 /* Wait for authentication */ 313 #define NFSMNT_HASAUTH 0x20000000 /* Has authenticator */ 314 #define NFSMNT_WANTAUTH 0x40000000 /* Wants an authenticator */ 315 #define NFSMNT_AUTHERR 0x80000000 /* Authentication error */ 316 #endif /* NFS */ 317 318 #ifdef KERNEL 319 /* 320 * exported vnode operations 321 */ 322 void vfs_remove __P((struct mount *mp)); /* remove a vfs from mount list */ 323 int vfs_lock __P((struct mount *mp)); /* lock a vfs */ 324 void vfs_unlock __P((struct mount *mp)); /* unlock a vfs */ 325 struct mount *getvfs __P((fsid_t *fsid)); /* return vfs given fsid */ 326 extern struct mount *rootfs; /* ptr to root mount structure */ 327 extern struct vfsops *vfssw[]; /* mount filesystem type table */ 328 329 #else /* KERNEL */ 330 331 #include <sys/cdefs.h> 332 333 __BEGIN_DECLS 334 int fstatfs __P((int, struct statfs *)); 335 int getfh __P((const char *, fhandle_t *)); 336 int getfsstat __P((struct statfs *, long, int)); 337 int getmntinfo __P((struct statfs **, int)); 338 int mount __P((int, const char *, int, void *)); 339 int statfs __P((const char *, struct statfs *)); 340 int unmount __P((const char *, int)); 341 __END_DECLS 342 343 #endif /* KERNEL */ 344