|
|
1.1 ! root 1: /* ! 2: * Copyright (c) 2000 Apple Computer, Inc. All rights reserved. ! 3: * ! 4: * @APPLE_LICENSE_HEADER_START@ ! 5: * ! 6: * The contents of this file constitute Original Code as defined in and ! 7: * are subject to the Apple Public Source License Version 1.1 (the ! 8: * "License"). You may not use this file except in compliance with the ! 9: * License. Please obtain a copy of the License at ! 10: * http://www.apple.com/publicsource and read it before using this file. ! 11: * ! 12: * This Original Code and all software distributed under the License are ! 13: * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER ! 14: * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, ! 15: * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, ! 16: * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT. Please see the ! 17: * License for the specific language governing rights and limitations ! 18: * under the License. ! 19: * ! 20: * @APPLE_LICENSE_HEADER_END@ ! 21: */ ! 22: /* Copyright (c) 1995 NeXT Computer, Inc. All Rights Reserved */ ! 23: /* ! 24: * Copyright (c) 1989, 1991, 1993 ! 25: * The Regents of the University of California. All rights reserved. ! 26: * ! 27: * Redistribution and use in source and binary forms, with or without ! 28: * modification, are permitted provided that the following conditions ! 29: * are met: ! 30: * 1. Redistributions of source code must retain the above copyright ! 31: * notice, this list of conditions and the following disclaimer. ! 32: * 2. Redistributions in binary form must reproduce the above copyright ! 33: * notice, this list of conditions and the following disclaimer in the ! 34: * documentation and/or other materials provided with the distribution. ! 35: * 3. All advertising materials mentioning features or use of this software ! 36: * must display the following acknowledgement: ! 37: * This product includes software developed by the University of ! 38: * California, Berkeley and its contributors. ! 39: * 4. Neither the name of the University nor the names of its contributors ! 40: * may be used to endorse or promote products derived from this software ! 41: * without specific prior written permission. ! 42: * ! 43: * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND ! 44: * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE ! 45: * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ! 46: * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE ! 47: * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL ! 48: * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS ! 49: * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) ! 50: * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT ! 51: * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY ! 52: * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF ! 53: * SUCH DAMAGE. ! 54: * ! 55: * @(#)mount.h 8.15 (Berkeley) 7/14/94 ! 56: */ ! 57: ! 58: #ifndef _SYS_MOUNT_H_ ! 59: #define _SYS_MOUNT_H_ ! 60: ! 61: #ifndef KERNEL ! 62: #include <sys/ucred.h> ! 63: #endif ! 64: #include <sys/queue.h> ! 65: #include <sys/lock.h> ! 66: #include <net/radix.h> ! 67: #include <sys/socket.h> /* XXX for AF_MAX */ ! 68: ! 69: typedef struct { int32_t val[2]; } fsid_t; /* file system id type */ ! 70: ! 71: /* ! 72: * File identifier. ! 73: * These are unique per filesystem on a single machine. ! 74: */ ! 75: #define MAXFIDSZ 16 ! 76: ! 77: struct fid { ! 78: u_short fid_len; /* length of data in bytes */ ! 79: u_short fid_reserved; /* force longword alignment */ ! 80: char fid_data[MAXFIDSZ]; /* data (variable length) */ ! 81: }; ! 82: ! 83: /* ! 84: * file system statistics ! 85: */ ! 86: ! 87: #define MFSNAMELEN 15 /* length of fs type name, not inc. null */ ! 88: #define MNAMELEN 90 /* length of buffer for returned name */ ! 89: ! 90: struct statfs { ! 91: short f_type; /* filesystem type number */ ! 92: short f_flags; /* copy of mount flags */ ! 93: long f_bsize; /* fundamental file system block size */ ! 94: long f_iosize; /* optimal transfer block size */ ! 95: long f_blocks; /* total data blocks in file system */ ! 96: long f_bfree; /* free blocks in fs */ ! 97: long f_bavail; /* free blocks avail to non-superuser */ ! 98: long f_files; /* total file nodes in file system */ ! 99: long f_ffree; /* free file nodes in fs */ ! 100: fsid_t f_fsid; /* file system id */ ! 101: uid_t f_owner; /* user that mounted the filesystem */ ! 102: long f_spare[4]; /* spare for later */ ! 103: char f_fstypename[MFSNAMELEN]; /* fs type name */ ! 104: char f_mntonname[MNAMELEN]; /* directory on which mounted */ ! 105: char f_mntfromname[MNAMELEN];/* mounted filesystem */ ! 106: }; ! 107: ! 108: /* ! 109: * Structure per mounted file system. Each mounted file system has an ! 110: * array of operations and an instance record. The file systems are ! 111: * put on a doubly linked list. ! 112: */ ! 113: LIST_HEAD(vnodelst, vnode); ! 114: ! 115: struct mount { ! 116: CIRCLEQ_ENTRY(mount) mnt_list; /* mount list */ ! 117: struct vfsops *mnt_op; /* operations on fs */ ! 118: struct vfsconf *mnt_vfc; /* configuration info */ ! 119: struct vnode *mnt_vnodecovered; /* vnode we mounted on */ ! 120: struct vnodelst mnt_vnodelist; /* list of vnodes this mount */ ! 121: struct lock__bsd__ mnt_lock; /* mount structure lock */ ! 122: int mnt_flag; /* flags */ ! 123: int mnt_maxsymlinklen; /* max size of short symlink */ ! 124: struct statfs mnt_stat; /* cache of filesystem stats */ ! 125: qaddr_t mnt_data; /* private data */ ! 126: }; ! 127: ! 128: /* ! 129: * Mount flags. ! 130: * ! 131: * Unmount uses MNT_FORCE flag. ! 132: */ ! 133: #define MNT_RDONLY 0x00000001 /* read only filesystem */ ! 134: #define MNT_SYNCHRONOUS 0x00000002 /* file system written synchronously */ ! 135: #define MNT_NOEXEC 0x00000004 /* can't exec from filesystem */ ! 136: #define MNT_NOSUID 0x00000008 /* don't honor setuid bits on fs */ ! 137: #define MNT_NODEV 0x00000010 /* don't interpret special files */ ! 138: #define MNT_UNION 0x00000020 /* union with underlying filesystem */ ! 139: #define MNT_ASYNC 0x00000040 /* file system written asynchronously */ ! 140: ! 141: /* ! 142: * exported mount flags. ! 143: */ ! 144: #define MNT_EXRDONLY 0x00000080 /* exported read only */ ! 145: #define MNT_EXPORTED 0x00000100 /* file system is exported */ ! 146: #define MNT_DEFEXPORTED 0x00000200 /* exported to the world */ ! 147: #define MNT_EXPORTANON 0x00000400 /* use anon uid mapping for everyone */ ! 148: #define MNT_EXKERB 0x00000800 /* exported with Kerberos uid mapping */ ! 149: ! 150: /* ! 151: * Flags set by internal operations. ! 152: */ ! 153: #define MNT_LOCAL 0x00001000 /* filesystem is stored locally */ ! 154: #define MNT_QUOTA 0x00002000 /* quotas are enabled on filesystem */ ! 155: #define MNT_ROOTFS 0x00004000 /* identifies the root filesystem */ ! 156: #define MNT_DOVOLFS 0x00008000 /* FS supports volfs */ ! 157: ! 158: /* ! 159: * Mask of flags that are visible to statfs() ! 160: */ ! 161: #define MNT_VISFLAGMASK 0x0000ffff ! 162: ! 163: /* ! 164: * External filesystem control flags. ! 165: */ ! 166: #define MNT_UPDATE 0x00010000 /* not a real mount, just an update */ ! 167: #define MNT_DELEXPORT 0x00020000 /* delete export host lists */ ! 168: #define MNT_RELOAD 0x00040000 /* reload filesystem data */ ! 169: #define MNT_FORCE 0x00080000 /* force unmount or readonly change */ ! 170: /* ! 171: * Internal filesystem control flags. ! 172: * ! 173: * MNT_UNMOUNT locks the mount entry so that name lookup cannot proceed ! 174: * past the mount point. This keeps the subtree stable during mounts ! 175: * and unmounts. ! 176: */ ! 177: #define MNT_UNMOUNT 0x01000000 /* unmount in progress */ ! 178: #define MNT_MWAIT 0x02000000 /* waiting for unmount to finish */ ! 179: #define MNT_WANTRDWR 0x04000000 /* upgrade to read/write requested */ ! 180: #if REV_ENDIAN_FS ! 181: #define MNT_REVEND 0x08000000 /* Reverse endian FS */ ! 182: #endif /* REV_ENDIAN_FS */ ! 183: #define MNT_ROMANONLY 0x10000000 /* FS supports roman names only [HFS] */ ! 184: ! 185: /* ! 186: * Sysctl CTL_VFS definitions. ! 187: * ! 188: * Second level identifier specifies which filesystem. Second level ! 189: * identifier VFS_GENERIC returns information about all filesystems. ! 190: */ ! 191: #define VFS_GENERIC 0 /* generic filesystem information */ ! 192: #define VFS_NUMMNTOPS 1 /* int: total num of vfs mount/unmount operations */ ! 193: /* ! 194: * Third level identifiers for VFS_GENERIC are given below; third ! 195: * level identifiers for specific filesystems are given in their ! 196: * mount specific header files. ! 197: */ ! 198: #define VFS_MAXTYPENUM 1 /* int: highest defined filesystem type */ ! 199: #define VFS_CONF 2 /* struct: vfsconf for filesystem given ! 200: as next argument */ ! 201: /* ! 202: * Flags for various system call interfaces. ! 203: * ! 204: * waitfor flags to vfs_sync() and getfsstat() ! 205: */ ! 206: #define MNT_WAIT 1 ! 207: #define MNT_NOWAIT 2 ! 208: ! 209: /* ! 210: * Generic file handle ! 211: */ ! 212: struct fhandle { ! 213: fsid_t fh_fsid; /* File system id of mount point */ ! 214: struct fid fh_fid; /* File sys specific id */ ! 215: }; ! 216: typedef struct fhandle fhandle_t; ! 217: ! 218: /* ! 219: * Export arguments for local filesystem mount calls. ! 220: */ ! 221: struct export_args { ! 222: int ex_flags; /* export related flags */ ! 223: uid_t ex_root; /* mapping for root uid */ ! 224: struct ucred ex_anon; /* mapping for anonymous user */ ! 225: struct sockaddr *ex_addr; /* net address to which exported */ ! 226: int ex_addrlen; /* and the net address length */ ! 227: struct sockaddr *ex_mask; /* mask of valid bits in saddr */ ! 228: int ex_masklen; /* and the smask length */ ! 229: }; ! 230: ! 231: /* ! 232: * Filesystem configuration information. One of these exists for each ! 233: * type of filesystem supported by the kernel. These are searched at ! 234: * mount time to identify the requested filesystem. ! 235: */ ! 236: struct vfsconf { ! 237: struct vfsops *vfc_vfsops; /* filesystem operations vector */ ! 238: char vfc_name[MFSNAMELEN]; /* filesystem type name */ ! 239: int vfc_typenum; /* historic filesystem type number */ ! 240: int vfc_refcount; /* number mounted of this type */ ! 241: int vfc_flags; /* permanent flags */ ! 242: int (*vfc_mountroot)(void); /* if != NULL, routine to mount root */ ! 243: struct vfsconf *vfc_next; /* next in list */ ! 244: }; ! 245: ! 246: #ifdef KERNEL ! 247: ! 248: extern int maxvfsconf; /* highest defined filesystem type */ ! 249: extern struct vfsconf *vfsconf; /* head of list of filesystem types */ ! 250: extern int maxvfsslots; /* Maximum slots available to be used */ ! 251: extern int numused_vfsslots; /* number of slots already used */ ! 252: ! 253: int vfsconf_add __P((struct vfsconf *)); ! 254: int vfsconf_del __P((char *)); ! 255: ! 256: /* ! 257: * Operations supported on mounted file system. ! 258: */ ! 259: #ifdef __STDC__ ! 260: struct nameidata; ! 261: struct mbuf; ! 262: #endif ! 263: ! 264: struct vfsops { ! 265: int (*vfs_mount) __P((struct mount *mp, char *path, caddr_t data, ! 266: struct nameidata *ndp, struct proc *p)); ! 267: int (*vfs_start) __P((struct mount *mp, int flags, ! 268: struct proc *p)); ! 269: int (*vfs_unmount) __P((struct mount *mp, int mntflags, ! 270: struct proc *p)); ! 271: int (*vfs_root) __P((struct mount *mp, struct vnode **vpp)); ! 272: int (*vfs_quotactl) __P((struct mount *mp, int cmds, uid_t uid, ! 273: caddr_t arg, struct proc *p)); ! 274: int (*vfs_statfs) __P((struct mount *mp, struct statfs *sbp, ! 275: struct proc *p)); ! 276: int (*vfs_sync) __P((struct mount *mp, int waitfor, ! 277: struct ucred *cred, struct proc *p)); ! 278: int (*vfs_vget) __P((struct mount *mp, void *ino, ! 279: struct vnode **vpp)); ! 280: int (*vfs_fhtovp) __P((struct mount *mp, struct fid *fhp, ! 281: struct mbuf *nam, struct vnode **vpp, ! 282: int *exflagsp, struct ucred **credanonp)); ! 283: int (*vfs_vptofh) __P((struct vnode *vp, struct fid *fhp)); ! 284: int (*vfs_init) __P((struct vfsconf *)); ! 285: int (*vfs_sysctl) __P((int *, u_int, void *, size_t *, void *, ! 286: size_t, struct proc *)); ! 287: }; ! 288: ! 289: #define VFS_MOUNT(MP, PATH, DATA, NDP, P) \ ! 290: (*(MP)->mnt_op->vfs_mount)(MP, PATH, DATA, NDP, P) ! 291: #define VFS_START(MP, FLAGS, P) (*(MP)->mnt_op->vfs_start)(MP, FLAGS, P) ! 292: #define VFS_UNMOUNT(MP, FORCE, P) (*(MP)->mnt_op->vfs_unmount)(MP, FORCE, P) ! 293: #define VFS_ROOT(MP, VPP) (*(MP)->mnt_op->vfs_root)(MP, VPP) ! 294: #define VFS_QUOTACTL(MP,C,U,A,P) (*(MP)->mnt_op->vfs_quotactl)(MP, C, U, A, P) ! 295: #define VFS_STATFS(MP, SBP, P) (*(MP)->mnt_op->vfs_statfs)(MP, SBP, P) ! 296: #define VFS_SYNC(MP, WAIT, C, P) (*(MP)->mnt_op->vfs_sync)(MP, WAIT, C, P) ! 297: #define VFS_VGET(MP, INO, VPP) (*(MP)->mnt_op->vfs_vget)(MP, INO, VPP) ! 298: #define VFS_FHTOVP(MP, FIDP, NAM, VPP, EXFLG, CRED) \ ! 299: (*(MP)->mnt_op->vfs_fhtovp)(MP, FIDP, NAM, VPP, EXFLG, CRED) ! 300: #define VFS_VPTOFH(VP, FIDP) (*(VP)->v_mount->mnt_op->vfs_vptofh)(VP, FIDP) ! 301: ! 302: /* ! 303: * Network address lookup element ! 304: */ ! 305: struct netcred { ! 306: struct radix_node netc_rnodes[2]; ! 307: int netc_exflags; ! 308: struct ucred netc_anon; ! 309: }; ! 310: ! 311: /* ! 312: * Network export information ! 313: */ ! 314: struct netexport { ! 315: struct netcred ne_defexported; /* Default export */ ! 316: struct radix_node_head *ne_rtable[AF_MAX+1]; /* Individual exports */ ! 317: }; ! 318: ! 319: /* ! 320: * exported vnode operations ! 321: */ ! 322: int vfs_busy __P((struct mount *, int, struct slock *, struct proc *)); ! 323: int vfs_export __P((struct mount *, struct netexport *, ! 324: struct export_args *)); ! 325: struct netcred *vfs_export_lookup __P((struct mount *, struct netexport *, ! 326: struct mbuf *)); ! 327: void vfs_getnewfsid __P((struct mount *)); ! 328: struct mount *vfs_getvfs __P((fsid_t *)); ! 329: int vfs_mountedon __P((struct vnode *)); ! 330: int vfs_mountroot __P((void)); ! 331: int vfs_rootmountalloc __P((char *, char *, struct mount **)); ! 332: void vfs_unbusy __P((struct mount *, struct proc *)); ! 333: void vfs_unmountall __P((void)); ! 334: extern CIRCLEQ_HEAD(mntlist, mount) mountlist; ! 335: extern struct slock mountlist_slock; ! 336: ! 337: #else /* !KERNEL */ ! 338: ! 339: #include <sys/cdefs.h> ! 340: ! 341: __BEGIN_DECLS ! 342: int fstatfs __P((int, struct statfs *)); ! 343: int getfh __P((const char *, fhandle_t *)); ! 344: int getfsstat __P((struct statfs *, long, int)); ! 345: int getmntinfo __P((struct statfs **, int)); ! 346: int mount __P((const char *, const char *, int, void *)); ! 347: int statfs __P((const char *, struct statfs *)); ! 348: int unmount __P((const char *, int)); ! 349: __END_DECLS ! 350: ! 351: #endif /* KERNEL */ ! 352: #endif /* !_SYS_MOUNT_H_ */
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.