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.29 (Berkeley) 12/19/91 8 */ 9 10 typedef struct { long val[2]; } fsid_t; /* file system id type */ 11 12 /* 13 * File identifier. 14 * These are unique per filesystem on a single machine. 15 */ 16 #define MAXFIDSZ 16 17 18 struct fid { 19 u_short fid_len; /* length of data in bytes */ 20 u_short fid_reserved; /* force longword alignment */ 21 char fid_data[MAXFIDSZ]; /* data (variable length) */ 22 }; 23 24 /* 25 * file system statistics 26 */ 27 28 #define MNAMELEN 90 /* length of buffer for returned name */ 29 30 struct statfs { 31 short f_type; /* type of filesystem (see below) */ 32 short f_flags; /* copy of mount flags */ 33 long f_bsize; /* fundamental file system block size */ 34 long f_iosize; /* optimal transfer block size */ 35 long f_blocks; /* total data blocks in file system */ 36 long f_bfree; /* free blocks in fs */ 37 long f_bavail; /* free blocks avail to non-superuser */ 38 long f_files; /* total file nodes in file system */ 39 long f_ffree; /* free file nodes in fs */ 40 fsid_t f_fsid; /* file system id */ 41 long f_spare[9]; /* spare for later */ 42 char f_mntonname[MNAMELEN]; /* directory on which mounted */ 43 char f_mntfromname[MNAMELEN];/* mounted filesystem */ 44 }; 45 46 /* 47 * File system types. 48 */ 49 #define MOUNT_NONE 0 50 #define MOUNT_UFS 1 51 #define MOUNT_NFS 2 52 #define MOUNT_MFS 3 53 #define MOUNT_PC 4 54 #define MOUNT_LFS 5 55 #define MOUNT_MAXTYPE 5 56 57 /* 58 * Structure per mounted file system. Each mounted file system has an 59 * array of operations and an instance record. The file systems are 60 * put on a doubly linked list. 61 */ 62 struct mount { 63 struct mount *mnt_next; /* next in mount list */ 64 struct mount *mnt_prev; /* prev in mount list */ 65 struct vfsops *mnt_op; /* operations on fs */ 66 struct vnode *mnt_vnodecovered; /* vnode we mounted on */ 67 struct vnode *mnt_mounth; /* list of vnodes this mount */ 68 int mnt_flag; /* flags */ 69 uid_t mnt_exroot; /* XXX - deprecated */ 70 struct statfs mnt_stat; /* cache of filesystem stats */ 71 qaddr_t mnt_data; /* private data */ 72 }; 73 74 /* 75 * Mount flags. 76 */ 77 #define MNT_RDONLY 0x00000001 /* read only filesystem */ 78 #define MNT_SYNCHRONOUS 0x00000002 /* file system written synchronously */ 79 #define MNT_NOEXEC 0x00000004 /* can't exec from filesystem */ 80 #define MNT_NOSUID 0x00000008 /* don't honor setuid bits on fs */ 81 #define MNT_NODEV 0x00000010 /* don't interpret special files */ 82 83 /* 84 * exported mount flags. 85 */ 86 #define MNT_EXRDONLY 0x00000080 /* exported read only */ 87 #define MNT_EXPORTED 0x00000100 /* file system is exported */ 88 #define MNT_DEFEXPORTED 0x00000200 /* exported to the world */ 89 #define MNT_EXPORTANON 0x00000400 /* use anon uid mapping for everyone */ 90 #define MNT_EXKERB 0x00000800 /* exported with Kerberos uid mapping */ 91 92 /* 93 * Flags set by internal operations. 94 */ 95 #define MNT_LOCAL 0x00001000 /* filesystem is stored locally */ 96 #define MNT_QUOTA 0x00002000 /* quotas are enabled on filesystem */ 97 98 /* 99 * Mask of flags that are visible to statfs() 100 */ 101 #define MNT_VISFLAGMASK 0x0000ffff 102 103 /* 104 * filesystem control flags. 105 * 106 * MNT_MLOCK lock the mount entry so that name lookup cannot proceed 107 * past the mount point. This keeps the subtree stable during mounts 108 * and unmounts. 109 */ 110 #define MNT_UPDATE 0x00010000 /* not a real mount, just an update */ 111 #define MNT_DELEXPORT 0x00020000 /* delete export host lists */ 112 #define MNT_MLOCK 0x00100000 /* lock so that subtree is stable */ 113 #define MNT_MWAIT 0x00200000 /* someone is waiting for lock */ 114 #define MNT_MPBUSY 0x00400000 /* scan of mount point in progress */ 115 #define MNT_MPWANT 0x00800000 /* waiting for mount point */ 116 #define MNT_UNMOUNT 0x01000000 /* unmount in progress */ 117 118 /* 119 * Operations supported on mounted file system. 120 */ 121 #ifdef KERNEL 122 #ifdef __STDC__ 123 struct nameidata; 124 #endif 125 126 struct vfsops { 127 int (*vfs_mount) __P((struct mount *mp, char *path, caddr_t data, 128 struct nameidata *ndp, struct proc *p)); 129 int (*vfs_start) __P((struct mount *mp, int flags, 130 struct proc *p)); 131 int (*vfs_unmount) __P((struct mount *mp, int mntflags, 132 struct proc *p)); 133 int (*vfs_root) __P((struct mount *mp, struct vnode **vpp)); 134 /* int uid, should be uid_t */ 135 int (*vfs_quotactl) __P((struct mount *mp, int cmds, u_int uid, 136 caddr_t arg, struct proc *p)); 137 int (*vfs_statfs) __P((struct mount *mp, struct statfs *sbp, 138 struct proc *p)); 139 int (*vfs_sync) __P((struct mount *mp, int waitfor)); 140 int (*vfs_fhtovp) __P((struct mount *mp, struct fid *fhp, 141 struct vnode **vpp)); 142 int (*vfs_vptofh) __P((struct vnode *vp, struct fid *fhp)); 143 int (*vfs_init) __P((void)); 144 }; 145 146 #define VFS_MOUNT(MP, PATH, DATA, NDP, P) \ 147 (*(MP)->mnt_op->vfs_mount)(MP, PATH, DATA, NDP, P) 148 #define VFS_START(MP, FLAGS, P) (*(MP)->mnt_op->vfs_start)(MP, FLAGS, P) 149 #define VFS_UNMOUNT(MP, FORCE, P) (*(MP)->mnt_op->vfs_unmount)(MP, FORCE, P) 150 #define VFS_ROOT(MP, VPP) (*(MP)->mnt_op->vfs_root)(MP, VPP) 151 #define VFS_QUOTACTL(MP,C,U,A,P) (*(MP)->mnt_op->vfs_quotactl)(MP, C, U, A, P) 152 #define VFS_STATFS(MP, SBP, P) (*(MP)->mnt_op->vfs_statfs)(MP, SBP, P) 153 #define VFS_SYNC(MP, WAITFOR) (*(MP)->mnt_op->vfs_sync)(MP, WAITFOR) 154 #define VFS_FHTOVP(MP, FIDP, VPP) (*(MP)->mnt_op->vfs_fhtovp)(MP, FIDP, VPP) 155 #define VFS_VPTOFH(VP, FIDP) (*(VP)->v_mount->mnt_op->vfs_vptofh)(VP, FIDP) 156 #endif /* KERNEL */ 157 158 /* 159 * Flags for various system call interfaces. 160 * 161 * forcibly flags for vfs_umount(). 162 * waitfor flags to vfs_sync() and getfsstat() 163 */ 164 #define MNT_FORCE 1 165 #define MNT_NOFORCE 2 166 #define MNT_WAIT 1 167 #define MNT_NOWAIT 2 168 169 /* 170 * Generic file handle 171 */ 172 struct fhandle { 173 fsid_t fh_fsid; /* File system id of mount point */ 174 struct fid fh_fid; /* Id of file */ 175 }; 176 typedef struct fhandle fhandle_t; 177 178 /* 179 * Arguments to mount UFS-based filesystems 180 */ 181 #ifndef KERNEL 182 #include <sys/ucred.h> 183 #endif 184 struct ufs_args { 185 char *fspec; /* block special device to mount */ 186 int exflags; /* export related flags */ 187 uid_t exroot; /* mapping for root uid */ 188 struct ucred anon; /* mapping for anonymous user */ 189 struct sockaddr *saddr;/* net address to which exported */ 190 int slen; /* and the net address length */ 191 struct sockaddr *smask;/* mask of valid bits in saddr */ 192 int msklen; /* and the smask length */ 193 }; 194 195 #ifdef MFS 196 /* 197 * Arguments to mount MFS 198 */ 199 struct mfs_args { 200 char *name; /* name to export for statfs */ 201 caddr_t base; /* base address of file system in memory */ 202 u_long size; /* size of file system */ 203 }; 204 #endif /* MFS */ 205 206 #ifdef NFS 207 /* 208 * File Handle (32 bytes for version 2), variable up to 1024 for version 3 209 */ 210 union nfsv2fh { 211 fhandle_t fh_generic; 212 u_char fh_bytes[32]; 213 }; 214 typedef union nfsv2fh nfsv2fh_t; 215 216 /* 217 * Arguments to mount NFS 218 */ 219 struct nfs_args { 220 struct sockaddr *addr; /* file server address */ 221 int sotype; /* Socket type */ 222 int proto; /* and Protocol */ 223 nfsv2fh_t *fh; /* File handle to be mounted */ 224 int flags; /* flags */ 225 int wsize; /* write size in bytes */ 226 int rsize; /* read size in bytes */ 227 int timeo; /* initial timeout in .1 secs */ 228 int retrans; /* times to retry send */ 229 char *hostname; /* server's name */ 230 }; 231 232 /* 233 * NFS mount option flags 234 */ 235 #define NFSMNT_SOFT 0x0001 /* soft mount (hard is default) */ 236 #define NFSMNT_WSIZE 0x0002 /* set write size */ 237 #define NFSMNT_RSIZE 0x0004 /* set read size */ 238 #define NFSMNT_TIMEO 0x0008 /* set initial timeout */ 239 #define NFSMNT_RETRANS 0x0010 /* set number of request retrys */ 240 #define NFSMNT_HOSTNAME 0x0020 /* set hostname for error printf */ 241 #define NFSMNT_INT 0x0040 /* allow interrupts on hard mount */ 242 #define NFSMNT_NOCONN 0x0080 /* Don't Connect the socket */ 243 #define NFSMNT_SCKLOCK 0x0100 /* Lock socket against others */ 244 #define NFSMNT_WANTSCK 0x0200 /* Want a socket lock */ 245 #define NFSMNT_SPONGY 0x0400 /* spongy mount (soft for stat and lookup) */ 246 #define NFSMNT_COMPRESS 0x0800 /* Compress nfs rpc xdr */ 247 #define NFSMNT_LOCKBITS (NFSMNT_SCKLOCK | NFSMNT_WANTSCK) 248 #endif /* NFS */ 249 250 #ifdef KERNEL 251 /* 252 * exported vnode operations 253 */ 254 void vfs_remove __P((struct mount *mp)); /* remove a vfs from mount list */ 255 int vfs_lock __P((struct mount *mp)); /* lock a vfs */ 256 void vfs_unlock __P((struct mount *mp)); /* unlock a vfs */ 257 struct mount *getvfs __P((fsid_t *fsid)); /* return vfs given fsid */ 258 extern struct mount *rootfs; /* ptr to root mount structure */ 259 extern struct vfsops *vfssw[]; /* mount filesystem type table */ 260 261 #else /* KERNEL */ 262 263 #include <sys/cdefs.h> 264 265 __BEGIN_DECLS 266 int fstatfs __P((int, struct statfs *)); 267 int getfh __P((const char *, fhandle_t *)); 268 int getfsstat __P((struct statfs *, long, int)); 269 int getmntinfo __P((struct statfs **, int)); 270 int mount __P((int, const char *, int, void *)); 271 int statfs __P((const char *, struct statfs *)); 272 int unmount __P((const char *, int)); 273 __END_DECLS 274 275 #endif /* KERNEL */ 276