]>
Commit | Line | Data |
---|---|---|
1c79356b A |
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.21 (Berkeley) 5/20/95 | |
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 fsid { 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_otype; /* TEMPORARY SHADOW COPY OF f_type */ | |
92 | short f_oflags; /* TEMPORARY SHADOW COPY OF f_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 | short f_reserved1; /* spare for later */ | |
103 | short f_type; /* type of filesystem */ | |
104 | long f_flags; /* copy of mount exported flags */ | |
105 | long f_reserved2[2]; /* reserved for future use */ | |
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 | #if COMPAT_GETFSSTAT | |
110 | char f_reserved3[0]; /* For alignment */ | |
111 | long f_reserved4[0]; /* For future use */ | |
112 | #else | |
113 | char f_reserved3; /* For alignment */ | |
114 | long f_reserved4[4]; /* For future use */ | |
115 | #endif | |
116 | }; | |
117 | ||
118 | /* | |
119 | * Structure per mounted file system. Each mounted file system has an | |
120 | * array of operations and an instance record. The file systems are | |
121 | * put on a doubly linked list. | |
122 | */ | |
123 | LIST_HEAD(vnodelst, vnode); | |
124 | ||
125 | struct mount { | |
126 | CIRCLEQ_ENTRY(mount) mnt_list; /* mount list */ | |
127 | struct vfsops *mnt_op; /* operations on fs */ | |
128 | struct vfsconf *mnt_vfc; /* configuration info */ | |
129 | struct vnode *mnt_vnodecovered; /* vnode we mounted on */ | |
130 | struct vnodelst mnt_vnodelist; /* list of vnodes this mount */ | |
131 | struct lock__bsd__ mnt_lock; /* mount structure lock */ | |
132 | int mnt_flag; /* flags */ | |
133 | int mnt_kern_flag; /* kernel only flags */ | |
134 | int mnt_maxsymlinklen; /* max size of short symlink */ | |
135 | struct statfs mnt_stat; /* cache of filesystem stats */ | |
136 | qaddr_t mnt_data; /* private data */ | |
137 | }; | |
138 | ||
139 | /* | |
140 | * User specifiable flags. | |
141 | * | |
142 | * Unmount uses MNT_FORCE flag. | |
143 | */ | |
144 | #define MNT_RDONLY 0x00000001 /* read only filesystem */ | |
145 | #define MNT_SYNCHRONOUS 0x00000002 /* file system written synchronously */ | |
146 | #define MNT_NOEXEC 0x00000004 /* can't exec from filesystem */ | |
147 | #define MNT_NOSUID 0x00000008 /* don't honor setuid bits on fs */ | |
148 | #define MNT_NODEV 0x00000010 /* don't interpret special files */ | |
149 | #define MNT_UNION 0x00000020 /* union with underlying filesystem */ | |
150 | #define MNT_ASYNC 0x00000040 /* file system written asynchronously */ | |
151 | #define MNT_DONTBROWSE 0x00100000 /* file system is not appropriate path to user data */ | |
152 | #define MNT_UNKNOWNPERMISSIONS 0x00200000 /* no known mapping for uid/gid in permissions information on disk */ | |
153 | #define MNT_AUTOMOUNTED 0x00400000 /* filesystem was mounted by automounter */ | |
154 | ||
155 | /* | |
156 | * NFS export related mount flags. | |
157 | */ | |
158 | #define MNT_EXRDONLY 0x00000080 /* exported read only */ | |
159 | #define MNT_EXPORTED 0x00000100 /* file system is exported */ | |
160 | #define MNT_DEFEXPORTED 0x00000200 /* exported to the world */ | |
161 | #define MNT_EXPORTANON 0x00000400 /* use anon uid mapping for everyone */ | |
162 | #define MNT_EXKERB 0x00000800 /* exported with Kerberos uid mapping */ | |
163 | ||
164 | /* | |
165 | * Flags set by internal operations. | |
166 | */ | |
167 | #define MNT_LOCAL 0x00001000 /* filesystem is stored locally */ | |
168 | #define MNT_QUOTA 0x00002000 /* quotas are enabled on filesystem */ | |
169 | #define MNT_ROOTFS 0x00004000 /* identifies the root filesystem */ | |
170 | #define MNT_DOVOLFS 0x00008000 /* FS supports volfs */ | |
171 | #define MNT_FIXEDSCRIPTENCODING 0x10000000 /* FS supports only fixed script encoding [HFS] */ | |
172 | ||
173 | /* | |
174 | * XXX I think that this could now become (~(MNT_CMDFLAGS)) | |
175 | * but the 'mount' program may need changing to handle this. | |
176 | */ | |
177 | #define MNT_VISFLAGMASK (MNT_RDONLY | MNT_SYNCHRONOUS | MNT_NOEXEC | \ | |
178 | MNT_NOSUID | MNT_NODEV | MNT_UNION | \ | |
179 | MNT_ASYNC | MNT_EXRDONLY | MNT_EXPORTED | \ | |
180 | MNT_DEFEXPORTED | MNT_EXPORTANON| MNT_EXKERB | \ | |
181 | MNT_LOCAL | MNT_QUOTA | \ | |
182 | MNT_ROOTFS | MNT_DOVOLFS | MNT_DONTBROWSE | \ | |
183 | MNT_UNKNOWNPERMISSIONS | MNT_AUTOMOUNTED | MNT_FIXEDSCRIPTENCODING ) | |
184 | /* | |
185 | * External filesystem command modifier flags. | |
186 | * Unmount can use the MNT_FORCE flag. | |
187 | * XXX These are not STATES and really should be somewhere else. | |
188 | * External filesystem control flags. | |
189 | */ | |
190 | #define MNT_UPDATE 0x00010000 /* not a real mount, just an update */ | |
191 | #define MNT_DELEXPORT 0x00020000 /* delete export host lists */ | |
192 | #define MNT_RELOAD 0x00040000 /* reload filesystem data */ | |
193 | #define MNT_FORCE 0x00080000 /* force unmount or readonly change */ | |
194 | #define MNT_CMDFLAGS (MNT_UPDATE|MNT_DELEXPORT|MNT_RELOAD|MNT_FORCE) | |
195 | ||
196 | /* | |
197 | * Internal filesystem control flags stored in mnt_kern_flag. | |
198 | * | |
199 | * MNTK_UNMOUNT locks the mount entry so that name lookup cannot proceed | |
200 | * past the mount point. This keeps the subtree stable during mounts | |
201 | * and unmounts. | |
202 | */ | |
203 | #define MNTK_UNMOUNT 0x01000000 /* unmount in progress */ | |
204 | #define MNTK_MWAIT 0x02000000 /* waiting for unmount to finish */ | |
205 | #define MNTK_WANTRDWR 0x04000000 /* upgrade to read/write requested */ | |
206 | #if REV_ENDIAN_FS | |
207 | #define MNT_REVEND 0x08000000 /* Reverse endian FS */ | |
208 | #endif /* REV_ENDIAN_FS */ | |
209 | /* | |
210 | * Sysctl CTL_VFS definitions. | |
211 | * | |
212 | * Second level identifier specifies which filesystem. Second level | |
213 | * identifier VFS_GENERIC returns information about all filesystems. | |
214 | */ | |
215 | #define VFS_GENERIC 0 /* generic filesystem information */ | |
216 | #define VFS_NUMMNTOPS 1 /* int: total num of vfs mount/unmount operations */ | |
217 | /* | |
218 | * Third level identifiers for VFS_GENERIC are given below; third | |
219 | * level identifiers for specific filesystems are given in their | |
220 | * mount specific header files. | |
221 | */ | |
222 | #define VFS_MAXTYPENUM 1 /* int: highest defined filesystem type */ | |
223 | #define VFS_CONF 2 /* struct: vfsconf for filesystem given | |
224 | as next argument */ | |
225 | /* | |
226 | * Flags for various system call interfaces. | |
227 | * | |
228 | * waitfor flags to vfs_sync() and getfsstat() | |
229 | */ | |
230 | #define MNT_WAIT 1 /* synchronously wait for I/O to complete */ | |
231 | #define MNT_NOWAIT 2 /* start all I/O, but do not wait for it */ | |
232 | ||
233 | /* | |
234 | * Generic file handle | |
235 | */ | |
236 | struct fhandle { | |
237 | fsid_t fh_fsid; /* File system id of mount point */ | |
238 | struct fid fh_fid; /* File sys specific id */ | |
239 | }; | |
240 | typedef struct fhandle fhandle_t; | |
241 | ||
242 | /* | |
243 | * Export arguments for local filesystem mount calls. | |
244 | */ | |
245 | struct export_args { | |
246 | int ex_flags; /* export related flags */ | |
247 | uid_t ex_root; /* mapping for root uid */ | |
248 | struct ucred ex_anon; /* mapping for anonymous user */ | |
249 | struct sockaddr *ex_addr; /* net address to which exported */ | |
250 | int ex_addrlen; /* and the net address length */ | |
251 | struct sockaddr *ex_mask; /* mask of valid bits in saddr */ | |
252 | int ex_masklen; /* and the smask length */ | |
253 | }; | |
254 | ||
255 | /* | |
256 | * Filesystem configuration information. One of these exists for each | |
257 | * type of filesystem supported by the kernel. These are searched at | |
258 | * mount time to identify the requested filesystem. | |
259 | */ | |
260 | struct vfsconf { | |
261 | struct vfsops *vfc_vfsops; /* filesystem operations vector */ | |
262 | char vfc_name[MFSNAMELEN]; /* filesystem type name */ | |
263 | int vfc_typenum; /* historic filesystem type number */ | |
264 | int vfc_refcount; /* number mounted of this type */ | |
265 | int vfc_flags; /* permanent flags */ | |
266 | int (*vfc_mountroot)(void); /* if != NULL, routine to mount root */ | |
267 | struct vfsconf *vfc_next; /* next in list */ | |
268 | }; | |
269 | ||
270 | #ifdef KERNEL | |
271 | ||
272 | extern int maxvfsconf; /* highest defined filesystem type */ | |
273 | extern struct vfsconf *vfsconf; /* head of list of filesystem types */ | |
274 | extern int maxvfsslots; /* Maximum slots available to be used */ | |
275 | extern int numused_vfsslots; /* number of slots already used */ | |
276 | ||
277 | int vfsconf_add __P((struct vfsconf *)); | |
278 | int vfsconf_del __P((char *)); | |
279 | ||
280 | /* | |
281 | * Operations supported on mounted file system. | |
282 | */ | |
283 | #ifdef __STDC__ | |
284 | struct nameidata; | |
285 | struct mbuf; | |
286 | #endif | |
287 | ||
288 | struct vfsops { | |
289 | int (*vfs_mount) __P((struct mount *mp, char *path, caddr_t data, | |
290 | struct nameidata *ndp, struct proc *p)); | |
291 | int (*vfs_start) __P((struct mount *mp, int flags, | |
292 | struct proc *p)); | |
293 | int (*vfs_unmount) __P((struct mount *mp, int mntflags, | |
294 | struct proc *p)); | |
295 | int (*vfs_root) __P((struct mount *mp, struct vnode **vpp)); | |
296 | int (*vfs_quotactl) __P((struct mount *mp, int cmds, uid_t uid, | |
297 | caddr_t arg, struct proc *p)); | |
298 | int (*vfs_statfs) __P((struct mount *mp, struct statfs *sbp, | |
299 | struct proc *p)); | |
300 | int (*vfs_sync) __P((struct mount *mp, int waitfor, | |
301 | struct ucred *cred, struct proc *p)); | |
302 | int (*vfs_vget) __P((struct mount *mp, void *ino, | |
303 | struct vnode **vpp)); | |
304 | int (*vfs_fhtovp) __P((struct mount *mp, struct fid *fhp, | |
305 | struct mbuf *nam, struct vnode **vpp, | |
306 | int *exflagsp, struct ucred **credanonp)); | |
307 | int (*vfs_vptofh) __P((struct vnode *vp, struct fid *fhp)); | |
308 | int (*vfs_init) __P((struct vfsconf *)); | |
309 | int (*vfs_sysctl) __P((int *, u_int, void *, size_t *, void *, | |
310 | size_t, struct proc *)); | |
311 | }; | |
312 | ||
313 | #define VFS_MOUNT(MP, PATH, DATA, NDP, P) \ | |
314 | (*(MP)->mnt_op->vfs_mount)(MP, PATH, DATA, NDP, P) | |
315 | #define VFS_START(MP, FLAGS, P) (*(MP)->mnt_op->vfs_start)(MP, FLAGS, P) | |
316 | #define VFS_UNMOUNT(MP, FORCE, P) (*(MP)->mnt_op->vfs_unmount)(MP, FORCE, P) | |
317 | #define VFS_ROOT(MP, VPP) (*(MP)->mnt_op->vfs_root)(MP, VPP) | |
318 | #define VFS_QUOTACTL(MP,C,U,A,P) (*(MP)->mnt_op->vfs_quotactl)(MP, C, U, A, P) | |
319 | #define VFS_STATFS(MP, SBP, P) (*(MP)->mnt_op->vfs_statfs)(MP, SBP, P) | |
320 | #define VFS_SYNC(MP, WAIT, C, P) (*(MP)->mnt_op->vfs_sync)(MP, WAIT, C, P) | |
321 | #define VFS_VGET(MP, INO, VPP) (*(MP)->mnt_op->vfs_vget)(MP, INO, VPP) | |
322 | #define VFS_FHTOVP(MP, FIDP, NAM, VPP, EXFLG, CRED) \ | |
323 | (*(MP)->mnt_op->vfs_fhtovp)(MP, FIDP, NAM, VPP, EXFLG, CRED) | |
324 | #define VFS_VPTOFH(VP, FIDP) (*(VP)->v_mount->mnt_op->vfs_vptofh)(VP, FIDP) | |
325 | ||
326 | /* | |
327 | * Network address lookup element | |
328 | */ | |
329 | struct netcred { | |
330 | struct radix_node netc_rnodes[2]; | |
331 | int netc_exflags; | |
332 | struct ucred netc_anon; | |
333 | }; | |
334 | ||
335 | /* | |
336 | * Network export information | |
337 | */ | |
338 | struct netexport { | |
339 | struct netcred ne_defexported; /* Default export */ | |
340 | struct radix_node_head *ne_rtable[AF_MAX+1]; /* Individual exports */ | |
341 | }; | |
342 | ||
343 | /* | |
344 | * exported vnode operations | |
345 | */ | |
346 | int vfs_busy __P((struct mount *, int, struct slock *, struct proc *)); | |
347 | int vfs_export __P((struct mount *, struct netexport *, | |
348 | struct export_args *)); | |
349 | struct netcred *vfs_export_lookup __P((struct mount *, struct netexport *, | |
350 | struct mbuf *)); | |
351 | void vfs_getnewfsid __P((struct mount *)); | |
352 | struct mount *vfs_getvfs __P((fsid_t *)); | |
353 | int vfs_mountedon __P((struct vnode *)); | |
354 | int vfs_mountroot __P((void)); | |
355 | int vfs_rootmountalloc __P((char *, char *, struct mount **)); | |
356 | void vfs_unbusy __P((struct mount *, struct proc *)); | |
357 | void vfs_unmountall __P((void)); | |
358 | extern CIRCLEQ_HEAD(mntlist, mount) mountlist; | |
359 | extern struct slock mountlist_slock; | |
360 | ||
361 | #else /* !KERNEL */ | |
362 | ||
363 | #include <sys/cdefs.h> | |
364 | ||
365 | __BEGIN_DECLS | |
366 | int fstatfs __P((int, struct statfs *)); | |
367 | int getfh __P((const char *, fhandle_t *)); | |
368 | int getfsstat __P((struct statfs *, long, int)); | |
369 | int getmntinfo __P((struct statfs **, int)); | |
370 | int mount __P((const char *, const char *, int, void *)); | |
371 | int statfs __P((const char *, struct statfs *)); | |
372 | int unmount __P((const char *, int)); | |
373 | __END_DECLS | |
374 | ||
375 | #endif /* KERNEL */ | |
376 | #endif /* !_SYS_MOUNT_H_ */ |