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