]>
Commit | Line | Data |
---|---|---|
91447636 A |
1 | /* |
2 | * Copyright (c) 2000-2005 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_INTERNAL_H_ | |
59 | #define _SYS_MOUNT_INTERNAL_H_ | |
60 | ||
61 | #include <sys/appleapiopts.h> | |
62 | #ifndef KERNEL | |
63 | #include <sys/ucred.h> | |
64 | #else | |
65 | #include <sys/kernel_types.h> | |
66 | #include <sys/namei.h> | |
67 | #endif | |
68 | #include <sys/queue.h> | |
69 | #include <sys/lock.h> | |
70 | #include <net/radix.h> | |
71 | #include <sys/socket.h> /* XXX for AF_MAX */ | |
72 | #include <sys/vfs_context.h> /* XXX for AF_MAX */ | |
73 | #include <sys/mount.h> | |
74 | #include <sys/cdefs.h> | |
75 | ||
76 | /* | |
77 | * Structure per mounted file system. Each mounted file system has an | |
78 | * array of operations and an instance record. The file systems are | |
79 | * put on a doubly linked list. | |
80 | */ | |
81 | TAILQ_HEAD(vnodelst, vnode); | |
82 | ||
83 | struct mount { | |
84 | TAILQ_ENTRY(mount) mnt_list; /* mount list */ | |
85 | int32_t mnt_count; /* reference on the mount */ | |
86 | lck_mtx_t mnt_mlock; /* mutex that protects mount point */ | |
87 | struct vfsops *mnt_op; /* operations on fs */ | |
88 | struct vfstable *mnt_vtable; /* configuration info */ | |
89 | struct vnode *mnt_vnodecovered; /* vnode we mounted on */ | |
90 | struct vnodelst mnt_vnodelist; /* list of vnodes this mount */ | |
91 | struct vnodelst mnt_workerqueue; /* list of vnodes this mount */ | |
92 | struct vnodelst mnt_newvnodes; /* list of vnodes this mount */ | |
93 | int mnt_flag; /* flags */ | |
94 | int mnt_kern_flag; /* kernel only flags */ | |
95 | int mnt_lflag; /* mount life cycle flags */ | |
96 | int mnt_maxsymlinklen; /* max size of short symlink */ | |
97 | struct vfsstatfs mnt_vfsstat; /* cache of filesystem stats */ | |
98 | qaddr_t mnt_data; /* private data */ | |
99 | /* Cached values of the IO constraints for the device */ | |
100 | u_int32_t mnt_maxreadcnt; /* Max. byte count for read */ | |
101 | u_int32_t mnt_maxwritecnt; /* Max. byte count for write */ | |
102 | u_int32_t mnt_segreadcnt; /* Max. segment count for read */ | |
103 | u_int32_t mnt_segwritecnt; /* Max. segment count for write */ | |
104 | u_int32_t mnt_maxsegreadsize; /* Max. segment read size */ | |
105 | u_int32_t mnt_maxsegwritesize; /* Max. segment write size */ | |
106 | u_int32_t mnt_devblocksize; /* the underlying device block size */ | |
107 | lck_rw_t mnt_rwlock; /* mutex readwrite lock */ | |
108 | lck_mtx_t mnt_renamelock; /* mutex that serializes renames that change shape of tree */ | |
109 | vnode_t mnt_devvp; /* the device mounted on for local file systems */ | |
110 | int32_t mnt_crossref; /* refernces to cover lookups crossing into mp */ | |
111 | int32_t mnt_iterref; /* refernces to cover iterations; drained makes it -ve */ | |
112 | ||
113 | /* XXX 3762912 hack to support HFS filesystem 'owner' */ | |
114 | uid_t mnt_fsowner; | |
115 | gid_t mnt_fsgroup; | |
116 | }; | |
117 | ||
118 | /* XXX 3762912 hack to support HFS filesystem 'owner' */ | |
119 | #define vfs_setowner(_mp, _uid, _gid) do {(_mp)->mnt_fsowner = (_uid); (_mp)->mnt_fsgroup = (_gid); } while (0) | |
120 | ||
121 | ||
122 | /* mount point to which dead vps point to */ | |
123 | extern struct mount * dead_mountp; | |
124 | ||
125 | /* | |
126 | * Internal filesystem control flags stored in mnt_kern_flag. | |
127 | * | |
128 | * MNTK_UNMOUNT locks the mount entry so that name lookup cannot proceed | |
129 | * past the mount point. This keeps the subtree stable during mounts | |
130 | * and unmounts. | |
131 | * | |
132 | * Note: We are counting down on new bit assignments. This is | |
133 | * because the bits here were broken out from the high bits | |
134 | * of the mount flags. | |
135 | */ | |
136 | #define MNTK_LOCK_LOCAL 0x00100000 /* advisory locking is done above the VFS itself */ | |
137 | #define MNTK_VIRTUALDEV 0x00200000 /* mounted on a virtual device i.e. a disk image */ | |
138 | #define MNTK_ROOTDEV 0x00400000 /* this filesystem resides on the same device as the root */ | |
139 | #define MNTK_UNMOUNT 0x01000000 /* unmount in progress */ | |
140 | #define MNTK_MWAIT 0x02000000 /* waiting for unmount to finish */ | |
141 | #define MNTK_WANTRDWR 0x04000000 /* upgrade to read/write requested */ | |
142 | #if REV_ENDIAN_FS | |
143 | #define MNT_REVEND 0x08000000 /* Reverse endian FS */ | |
144 | #endif /* REV_ENDIAN_FS */ | |
145 | #define MNTK_FRCUNMOUNT 0x10000000 /* Forced unmount wanted. */ | |
146 | #define MNTK_AUTH_OPAQUE 0x20000000 /* authorisation decisions are not made locally */ | |
147 | #define MNTK_AUTH_OPAQUE_ACCESS 0x40000000 /* VNOP_ACCESS is reliable for remote auth */ | |
148 | #define MNTK_EXTENDED_SECURITY 0x80000000 /* extended security supported */ | |
149 | ||
150 | #define MNT_LBUSY 0x00000001 /* mount is busy */ | |
151 | #define MNT_LUNMOUNT 0x00000002 /* mount in unmount */ | |
152 | #define MNT_LFORCE 0x00000004 /* mount in forced unmount */ | |
153 | #define MNT_LDRAIN 0x00000008 /* mount in drain */ | |
154 | #define MNT_LITER 0x00000010 /* mount in iteration */ | |
155 | #define MNT_LNEWVN 0x00000020 /* mount has new vnodes created */ | |
156 | #define MNT_LWAIT 0x00000040 /* wait for unmount op */ | |
157 | #define MNT_LITERWAIT 0x00000080 /* mount in iteration */ | |
158 | #define MNT_LDEAD 0x00000100 /* mount already unmounted*/ | |
159 | ||
160 | ||
161 | /* | |
162 | * Generic file handle | |
163 | */ | |
164 | #define NFS_MAX_FH_SIZE 64 | |
165 | #define NFSV2_MAX_FH_SIZE 32 | |
166 | struct fhandle { | |
167 | int fh_len; /* length of file handle */ | |
168 | unsigned char fh_data[NFS_MAX_FH_SIZE]; /* file handle value */ | |
169 | }; | |
170 | typedef struct fhandle fhandle_t; | |
171 | ||
172 | ||
173 | ||
174 | /* | |
175 | * Filesystem configuration information. One of these exists for each | |
176 | * type of filesystem supported by the kernel. These are searched at | |
177 | * mount time to identify the requested filesystem. | |
178 | */ | |
179 | struct vfstable { | |
180 | /* THE FOLLOWING SHOULD KEEP THE SAME FOR user compat with sysctl */ | |
181 | struct vfsops *vfc_vfsops; /* filesystem operations vector */ | |
182 | char vfc_name[MFSNAMELEN]; /* filesystem type name */ | |
183 | int vfc_typenum; /* historic filesystem type number */ | |
184 | int vfc_refcount; /* number mounted of this type */ | |
185 | int vfc_flags; /* permanent flags */ | |
186 | int (*vfc_mountroot)(mount_t, vnode_t, vfs_context_t); /* if != NULL, routine to mount root */ | |
187 | struct vfstable *vfc_next; /* next in list */ | |
188 | /* Till the above we SHOULD KEEP THE SAME FOR user compat with sysctl */ | |
189 | int vfc_threadsafe; /* FS is thread & premeption safe */ | |
190 | lck_mtx_t vfc_lock; /* for non-threaded file systems */ | |
191 | int vfc_vfsflags; /* for optional types */ | |
192 | void * vfc_descptr; /* desc table allocated address */ | |
193 | int vfc_descsize; /* size allocated for desc table */ | |
194 | int vfc_64bitready; /* The file system is ready for 64bit */ | |
195 | }; | |
196 | ||
197 | #define VFC_VFSLOCALARGS 0x02 | |
198 | #define VFC_VFSGENERICARGS 0x04 | |
199 | #define VFC_VFSNATIVEXATTR 0x10 | |
200 | ||
201 | ||
202 | extern int maxvfsconf; /* highest defined filesystem type */ | |
203 | extern struct vfstable *vfsconf; /* head of list of filesystem types */ | |
204 | extern int maxvfsslots; /* Maximum slots available to be used */ | |
205 | extern int numused_vfsslots; /* number of slots already used */ | |
206 | ||
207 | /* the following two are xnu private */ | |
208 | struct vfstable * vfstable_add(struct vfstable *); | |
209 | int vfstable_del(struct vfstable *); | |
210 | ||
211 | ||
212 | struct vfsmount_args { | |
213 | union { | |
214 | struct { | |
215 | char * mnt_fspec; | |
216 | void * mnt_fsdata; | |
217 | } mnt_localfs_args; | |
218 | struct { | |
219 | void * mnt_fsdata; /* FS specific */ | |
220 | } mnt_remotefs_args; | |
221 | } mountfs_args; | |
222 | }; | |
223 | ||
224 | ||
225 | /* | |
226 | * LP64 version of statfs structure. | |
227 | * NOTE - must be kept in sync with struct statfs in mount.h | |
228 | */ | |
229 | #if __DARWIN_ALIGN_NATURAL | |
230 | #pragma options align=natural | |
231 | #endif | |
232 | ||
233 | struct user_statfs { | |
234 | short f_otype; /* TEMPORARY SHADOW COPY OF f_type */ | |
235 | short f_oflags; /* TEMPORARY SHADOW COPY OF f_flags */ | |
236 | user_long_t f_bsize; /* fundamental file system block size */ | |
237 | user_long_t f_iosize; /* optimal transfer block size */ | |
238 | user_long_t f_blocks; /* total data blocks in file system */ | |
239 | user_long_t f_bfree; /* free blocks in fs */ | |
240 | user_long_t f_bavail; /* free blocks avail to non-superuser */ | |
241 | user_long_t f_files; /* total file nodes in file system */ | |
242 | user_long_t f_ffree; /* free file nodes in fs */ | |
243 | fsid_t f_fsid; /* file system id */ | |
244 | uid_t f_owner; /* user that mounted the filesystem */ | |
245 | short f_reserved1; /* spare for later */ | |
246 | short f_type; /* type of filesystem */ | |
247 | user_long_t f_flags; /* copy of mount exported flags */ | |
248 | user_long_t f_reserved2[2]; /* reserved for future use */ | |
249 | char f_fstypename[MFSNAMELEN]; /* fs type name */ | |
250 | char f_mntonname[MNAMELEN]; /* directory on which mounted */ | |
251 | char f_mntfromname[MNAMELEN];/* mounted filesystem */ | |
252 | #if COMPAT_GETFSSTAT | |
253 | char f_reserved3[0]; /* For alignment */ | |
254 | user_long_t f_reserved4[0]; /* For future use */ | |
255 | #else | |
256 | char f_reserved3; /* For alignment */ | |
257 | user_long_t f_reserved4[4]; /* For future use */ | |
258 | #endif | |
259 | }; | |
260 | ||
261 | #if __DARWIN_ALIGN_NATURAL | |
262 | #pragma options align=reset | |
263 | #endif | |
264 | ||
265 | __BEGIN_DECLS | |
266 | ||
267 | extern TAILQ_HEAD(mntlist, mount) mountlist; | |
268 | void mount_list_lock(void); | |
269 | void mount_list_unlock(void); | |
270 | void mount_lock_init(mount_t); | |
271 | void mount_lock_destroy(mount_t); | |
272 | void mount_lock(mount_t); | |
273 | void mount_unlock(mount_t); | |
274 | void mount_lock_renames(mount_t); | |
275 | void mount_unlock_renames(mount_t); | |
276 | void mount_ref(mount_t, int); | |
277 | void mount_drop(mount_t, int); | |
278 | ||
279 | /* vfs_rootmountalloc should be kept as a private api */ | |
280 | errno_t vfs_rootmountalloc(const char *, const char *, mount_t *mpp); | |
281 | errno_t vfs_init_io_attributes(vnode_t, mount_t); | |
282 | ||
283 | int vfs_mountroot(void); | |
284 | void vfs_unmountall(void); | |
285 | int safedounmount(struct mount *, int, struct proc *); | |
286 | int dounmount(struct mount *, int, struct proc *); | |
287 | ||
288 | /* xnuy internal api */ | |
289 | void mount_dropcrossref(mount_t, vnode_t, int); | |
290 | int validfsnode(mount_t); | |
291 | mount_t mount_lookupby_volfsid(int, int); | |
292 | mount_t mount_list_lookupby_fsid(fsid_t *, int, int); | |
293 | int mount_iterref(mount_t, int); | |
294 | int mount_isdrained(mount_t, int); | |
295 | void mount_iterdrop(mount_t); | |
296 | void mount_iterdrain(mount_t); | |
297 | void mount_iterreset(mount_t); | |
298 | ||
299 | __END_DECLS | |
300 | ||
301 | #endif /* !_SYS_MOUNT_INTERNAL_H_ */ |