FreeBSD/Linux Kernel Cross Reference
sys/sys/mount.h
1 /*
2 * Copyright (c) 1989, 1991, 1993
3 * The Regents of the University of California. All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
7 * are met:
8 * 1. Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer.
10 * 2. Redistributions in binary form must reproduce the above copyright
11 * notice, this list of conditions and the following disclaimer in the
12 * documentation and/or other materials provided with the distribution.
13 * 3. All advertising materials mentioning features or use of this software
14 * must display the following acknowledgement:
15 * This product includes software developed by the University of
16 * California, Berkeley and its contributors.
17 * 4. Neither the name of the University nor the names of its contributors
18 * may be used to endorse or promote products derived from this software
19 * without specific prior written permission.
20 *
21 * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
22 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
23 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
24 * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
25 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
26 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
27 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
28 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
29 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
30 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
31 * SUCH DAMAGE.
32 *
33 * @(#)mount.h 8.21 (Berkeley) 5/20/95
34 * $FreeBSD$
35 */
36
37 #ifndef _SYS_MOUNT_H_
38 #define _SYS_MOUNT_H_
39
40 #include <sys/ucred.h>
41 #include <sys/queue.h>
42 #include <sys/lock.h>
43
44 typedef struct fsid { int32_t val[2]; } fsid_t; /* file system id type */
45
46 /*
47 * File identifier.
48 * These are unique per filesystem on a single machine.
49 */
50 #define MAXFIDSZ 16
51
52 struct fid {
53 u_short fid_len; /* length of data in bytes */
54 u_short fid_reserved; /* force longword alignment */
55 char fid_data[MAXFIDSZ]; /* data (variable length) */
56 };
57
58 /*
59 * file system statistics
60 */
61
62 #define MFSNAMELEN 16 /* length of fs type name, including null */
63 #define MNAMELEN 90 /* length of buffer for returned name */
64
65 struct statfs {
66 long f_spare2; /* placeholder */
67 long f_bsize; /* fundamental file system block size */
68 long f_iosize; /* optimal transfer block size */
69 long f_blocks; /* total data blocks in file system */
70 long f_bfree; /* free blocks in fs */
71 long f_bavail; /* free blocks avail to non-superuser */
72 long f_files; /* total file nodes in file system */
73 long f_ffree; /* free file nodes in fs */
74 fsid_t f_fsid; /* file system id */
75 uid_t f_owner; /* user that mounted the filesystem */
76 int f_type; /* type of filesystem */
77 int f_flags; /* copy of mount exported flags */
78 long f_syncwrites; /* count of sync writes since mount */
79 long f_asyncwrites; /* count of async writes since mount */
80 char f_fstypename[MFSNAMELEN]; /* fs type name */
81 char f_mntonname[MNAMELEN]; /* directory on which mounted */
82 char f_mntfromname[MNAMELEN];/* mounted filesystem */
83 };
84
85 /*
86 * Structure per mounted file system. Each mounted file system has an
87 * array of operations and an instance record. The file systems are
88 * put on a doubly linked list.
89 */
90 LIST_HEAD(vnodelst, vnode);
91
92 struct mount {
93 CIRCLEQ_ENTRY(mount) mnt_list; /* mount list */
94 struct vfsops *mnt_op; /* operations on fs */
95 struct vfsconf *mnt_vfc; /* configuration info */
96 struct vnode *mnt_vnodecovered; /* vnode we mounted on */
97 struct vnode *mnt_syncer; /* syncer vnode */
98 struct vnodelst mnt_vnodelist; /* list of vnodes this mount */
99 struct lock mnt_lock; /* mount structure lock */
100 int mnt_flag; /* flags shared with user */
101 int mnt_kern_flag; /* kernel only flags */
102 int mnt_maxsymlinklen; /* max size of short symlink */
103 struct statfs mnt_stat; /* cache of filesystem stats */
104 qaddr_t mnt_data; /* private data */
105 time_t mnt_time; /* last time written*/
106 };
107
108 /*
109 * User specifiable flags.
110 */
111 #define MNT_RDONLY 0x00000001 /* read only filesystem */
112 #define MNT_SYNCHRONOUS 0x00000002 /* file system written synchronously */
113 #define MNT_NOEXEC 0x00000004 /* can't exec from filesystem */
114 #define MNT_NOSUID 0x00000008 /* don't honor setuid bits on fs */
115 #define MNT_NODEV 0x00000010 /* don't interpret special files */
116 #define MNT_UNION 0x00000020 /* union with underlying filesystem */
117 #define MNT_ASYNC 0x00000040 /* file system written asynchronously */
118 #define MNT_SUIDDIR 0x00100000 /* special handling of SUID on dirs */
119 #define MNT_SOFTDEP 0x00200000 /* soft updates being done */
120 #define MNT_NOSYMFOLLOW 0x00400000 /* do not follow symlinks */
121 #define MNT_NOATIME 0x10000000 /* disable update of file access time */
122 #define MNT_NOCLUSTERR 0x40000000 /* disable cluster read */
123 #define MNT_NOCLUSTERW 0x80000000 /* disable cluster write */
124
125 /*
126 * NFS export related mount flags.
127 */
128 #define MNT_EXRDONLY 0x00000080 /* exported read only */
129 #define MNT_EXPORTED 0x00000100 /* file system is exported */
130 #define MNT_DEFEXPORTED 0x00000200 /* exported to the world */
131 #define MNT_EXPORTANON 0x00000400 /* use anon uid mapping for everyone */
132 #define MNT_EXKERB 0x00000800 /* exported with Kerberos uid mapping */
133 #define MNT_EXPUBLIC 0x20000000 /* public export (WebNFS) */
134
135 /*
136 * Flags set by internal operations,
137 * but visible to the user.
138 * XXX some of these are not quite right.. (I've never seen the root flag set)
139 */
140 #define MNT_LOCAL 0x00001000 /* filesystem is stored locally */
141 #define MNT_QUOTA 0x00002000 /* quotas are enabled on filesystem */
142 #define MNT_ROOTFS 0x00004000 /* identifies the root filesystem */
143 #define MNT_USER 0x00008000 /* mounted by a user */
144
145 /*
146 * Mask of flags that are visible to statfs()
147 * XXX I think that this could now become (~(MNT_CMDFLAGS))
148 * but the 'mount' program may need changing to handle this.
149 * XXX MNT_EXPUBLIC is presently left out. I don't know why.
150 */
151 #define MNT_VISFLAGMASK (MNT_RDONLY | MNT_SYNCHRONOUS | MNT_NOEXEC | \
152 MNT_NOSUID | MNT_NODEV | MNT_UNION | \
153 MNT_ASYNC | MNT_EXRDONLY | MNT_EXPORTED | \
154 MNT_DEFEXPORTED | MNT_EXPORTANON| MNT_EXKERB | \
155 MNT_LOCAL | MNT_USER | MNT_QUOTA | \
156 MNT_ROOTFS | MNT_NOATIME | MNT_NOCLUSTERR| \
157 MNT_NOCLUSTERW | MNT_SUIDDIR | MNT_SOFTDEP \
158 /* | MNT_EXPUBLIC */)
159 /*
160 * External filesystem command modifier flags.
161 * Unmount can use the MNT_FORCE flag.
162 * XXX These are not STATES and really should be somewhere else.
163 */
164 #define MNT_UPDATE 0x00010000 /* not a real mount, just an update */
165 #define MNT_DELEXPORT 0x00020000 /* delete export host lists */
166 #define MNT_RELOAD 0x00040000 /* reload filesystem data */
167 #define MNT_FORCE 0x00080000 /* force unmount or readonly change */
168 #define MNT_CMDFLAGS (MNT_UPDATE|MNT_DELEXPORT|MNT_RELOAD|MNT_FORCE)
169 /*
170 * Internal filesystem control flags stored in mnt_kern_flag.
171 *
172 * MNTK_UNMOUNT locks the mount entry so that name lookup cannot proceed
173 * past the mount point. This keeps the subtree stable during mounts
174 * and unmounts.
175 */
176 #define MNTK_UNMOUNT 0x01000000 /* unmount in progress */
177 #define MNTK_MWAIT 0x02000000 /* waiting for unmount to finish */
178 #define MNTK_WANTRDWR 0x04000000 /* upgrade to read/write requested */
179
180 /*
181 * Sysctl CTL_VFS definitions.
182 *
183 * Second level identifier specifies which filesystem. Second level
184 * identifier VFS_VFSCONF returns information about all filesystems.
185 * Second level identifier VFS_GENERIC is non-terminal.
186 */
187 #define VFS_VFSCONF 0 /* get configured filesystems */
188 #define VFS_GENERIC 0 /* generic filesystem information */
189 /*
190 * Third level identifiers for VFS_GENERIC are given below; third
191 * level identifiers for specific filesystems are given in their
192 * mount specific header files.
193 */
194 #define VFS_MAXTYPENUM 1 /* int: highest defined filesystem type */
195 #define VFS_CONF 2 /* struct: vfsconf for filesystem given
196 as next argument */
197
198 /*
199 * Flags for various system call interfaces.
200 *
201 * waitfor flags to vfs_sync() and getfsstat()
202 */
203 #define MNT_WAIT 1 /* synchronously wait for I/O to complete */
204 #define MNT_NOWAIT 2 /* start all I/O, but do not wait for it */
205 #define MNT_LAZY 3 /* push data not written by filesystem syncer */
206
207 /*
208 * Generic file handle
209 */
210 struct fhandle {
211 fsid_t fh_fsid; /* File system id of mount point */
212 struct fid fh_fid; /* File sys specific id */
213 };
214 typedef struct fhandle fhandle_t;
215
216 /*
217 * Export arguments for local filesystem mount calls.
218 */
219 struct export_args {
220 int ex_flags; /* export related flags */
221 uid_t ex_root; /* mapping for root uid */
222 struct ucred ex_anon; /* mapping for anonymous user */
223 struct sockaddr *ex_addr; /* net address to which exported */
224 int ex_addrlen; /* and the net address length */
225 struct sockaddr *ex_mask; /* mask of valid bits in saddr */
226 int ex_masklen; /* and the smask length */
227 char *ex_indexfile; /* index file for WebNFS URLs */
228 };
229
230 /*
231 * Structure holding information for a publicly exported filesystem
232 * (WebNFS). Currently the specs allow just for one such filesystem.
233 */
234 struct nfs_public {
235 int np_valid; /* Do we hold valid information */
236 fhandle_t np_handle; /* Filehandle for pub fs (internal) */
237 struct mount *np_mount; /* Mountpoint of exported fs */
238 char *np_index; /* Index file */
239 };
240
241 /*
242 * Filesystem configuration information. One of these exists for each
243 * type of filesystem supported by the kernel. These are searched at
244 * mount time to identify the requested filesystem.
245 */
246 struct vfsconf {
247 struct vfsops *vfc_vfsops; /* filesystem operations vector */
248 char vfc_name[MFSNAMELEN]; /* filesystem type name */
249 int vfc_typenum; /* historic filesystem type number */
250 int vfc_refcount; /* number mounted of this type */
251 int vfc_flags; /* permanent flags */
252 struct vfsconf *vfc_next; /* next in list */
253 };
254
255 struct ovfsconf {
256 void *vfc_vfsops;
257 char vfc_name[32];
258 int vfc_index;
259 int vfc_refcount;
260 int vfc_flags;
261 };
262
263 /*
264 * NB: these flags refer to IMPLEMENTATION properties, not properties of
265 * any actual mounts; i.e., it does not make sense to change the flags.
266 */
267 #define VFCF_STATIC 0x00010000 /* statically compiled into kernel */
268 #define VFCF_NETWORK 0x00020000 /* may get data over the network */
269 #define VFCF_READONLY 0x00040000 /* writes are not implemented */
270 #define VFCF_SYNTHETIC 0x00080000 /* data does not represent real files */
271 #define VFCF_LOOPBACK 0x00100000 /* aliases some other mounted FS */
272 #define VFCF_UNICODE 0x00200000 /* stores file names as Unicode*/
273
274 #ifdef KERNEL
275
276 #ifdef MALLOC_DECLARE
277 MALLOC_DECLARE(M_MOUNT);
278 #endif
279 extern int maxvfsconf; /* highest defined filesystem type */
280 extern int nfs_mount_type; /* vfc_typenum for nfs, or -1 */
281 extern struct vfsconf *vfsconf; /* head of list of filesystem types */
282
283 /*
284 * Operations supported on mounted file system.
285 */
286 #ifdef __STDC__
287 struct nameidata;
288 struct mbuf;
289 #endif
290
291 struct vfsops {
292 int (*vfs_mount) __P((struct mount *mp, char *path, caddr_t data,
293 struct nameidata *ndp, struct proc *p));
294 int (*vfs_start) __P((struct mount *mp, int flags,
295 struct proc *p));
296 int (*vfs_unmount) __P((struct mount *mp, int mntflags,
297 struct proc *p));
298 int (*vfs_root) __P((struct mount *mp, struct vnode **vpp));
299 int (*vfs_quotactl) __P((struct mount *mp, int cmds, uid_t uid,
300 caddr_t arg, struct proc *p));
301 int (*vfs_statfs) __P((struct mount *mp, struct statfs *sbp,
302 struct proc *p));
303 int (*vfs_sync) __P((struct mount *mp, int waitfor,
304 struct ucred *cred, struct proc *p));
305 int (*vfs_vget) __P((struct mount *mp, ino_t ino,
306 struct vnode **vpp));
307 int (*vfs_fhtovp) __P((struct mount *mp, struct fid *fhp,
308 struct sockaddr *nam, struct vnode **vpp,
309 int *exflagsp, struct ucred **credanonp));
310 int (*vfs_vptofh) __P((struct vnode *vp, struct fid *fhp));
311 int (*vfs_init) __P((struct vfsconf *));
312 int (*vfs_uninit) __P((struct vfsconf *));
313 struct sysctl_oid *vfs_oid;
314 };
315
316 #define VFS_MOUNT(MP, PATH, DATA, NDP, P) \
317 (*(MP)->mnt_op->vfs_mount)(MP, PATH, DATA, NDP, P)
318 #define VFS_START(MP, FLAGS, P) (*(MP)->mnt_op->vfs_start)(MP, FLAGS, P)
319 #define VFS_UNMOUNT(MP, FORCE, P) (*(MP)->mnt_op->vfs_unmount)(MP, FORCE, P)
320 #define VFS_ROOT(MP, VPP) (*(MP)->mnt_op->vfs_root)(MP, VPP)
321 #define VFS_QUOTACTL(MP,C,U,A,P) (*(MP)->mnt_op->vfs_quotactl)(MP, C, U, A, P)
322 #define VFS_STATFS(MP, SBP, P) (*(MP)->mnt_op->vfs_statfs)(MP, SBP, P)
323 #define VFS_SYNC(MP, WAIT, C, P) (*(MP)->mnt_op->vfs_sync)(MP, WAIT, C, P)
324 #define VFS_VGET(MP, INO, VPP) (*(MP)->mnt_op->vfs_vget)(MP, INO, VPP)
325 #define VFS_FHTOVP(MP, FIDP, NAM, VPP, EXFLG, CRED) \
326 (*(MP)->mnt_op->vfs_fhtovp)(MP, FIDP, NAM, VPP, EXFLG, CRED)
327 #define VFS_VPTOFH(VP, FIDP) (*(VP)->v_mount->mnt_op->vfs_vptofh)(VP, FIDP)
328
329 #if defined(VFS_LKM) && !defined(KLD_MODULE)
330 #include <sys/conf.h>
331 #include <sys/exec.h>
332 #include <sys/sysent.h>
333 #include <sys/lkm.h>
334
335 #define VFS_SET(vfsops, fsname, flags) \
336 static struct vfsconf _fs_vfsconf = { \
337 &vfsops, \
338 #fsname, \
339 -1, \
340 0, \
341 flags, \
342 }; \
343 extern struct linker_set MODVNOPS; \
344 MOD_VFS(fsname,&MODVNOPS,&_fs_vfsconf); \
345 int \
346 fsname ## _mod(struct lkm_table *lkmtp, int cmd, int ver); \
347 int \
348 fsname ## _mod(struct lkm_table *lkmtp, int cmd, int ver) { \
349 MOD_DISPATCH(fsname, \
350 lkmtp, cmd, ver, lkm_nullcmd, lkm_nullcmd, lkm_nullcmd); } \
351 struct __hack
352
353 #else
354
355 #include <sys/module.h>
356
357 #define VFS_SET(vfsops, fsname, flags) \
358 static struct vfsconf fsname ## _vfsconf = { \
359 &vfsops, \
360 #fsname, \
361 -1, \
362 0, \
363 flags \
364 }; \
365 static moduledata_t fsname ## _mod = { \
366 #fsname, \
367 vfs_modevent, \
368 & fsname ## _vfsconf \
369 }; \
370 DECLARE_MODULE(fsname, fsname ## _mod, SI_SUB_VFS, SI_ORDER_MIDDLE)
371
372 #endif /* VFS_LKM */
373
374 #include <net/radix.h>
375
376 #define AF_MAX 33 /* XXX */
377
378 /*
379 * Network address lookup element
380 */
381 struct netcred {
382 struct radix_node netc_rnodes[2];
383 int netc_exflags;
384 struct ucred netc_anon;
385 };
386
387 /*
388 * Network export information
389 */
390 struct netexport {
391 struct netcred ne_defexported; /* Default export */
392 struct radix_node_head *ne_rtable[AF_MAX+1]; /* Individual exports */
393 };
394
395 extern char *mountrootfsname;
396
397 /*
398 * exported vnode operations
399 */
400 int dounmount __P((struct mount *, int, struct proc *));
401 int vfs_setpublicfs /* set publicly exported fs */
402 __P((struct mount *, struct netexport *, struct export_args *));
403 int vfs_lock __P((struct mount *)); /* lock a vfs */
404 void vfs_msync __P((struct mount *, int));
405 void vfs_unlock __P((struct mount *)); /* unlock a vfs */
406 int vfs_busy __P((struct mount *, int, struct simplelock *, struct proc *));
407 int vfs_export /* process mount export info */
408 __P((struct mount *, struct netexport *, struct export_args *));
409 struct netcred *vfs_export_lookup /* lookup host in fs export list */
410 __P((struct mount *, struct netexport *, struct sockaddr *));
411 int vfs_allocate_syncvnode __P((struct mount *));
412 void vfs_getnewfsid __P((struct mount *));
413 struct mount *vfs_getvfs __P((fsid_t *)); /* return vfs given fsid */
414 int vfs_modevent __P((module_t, int, void *));
415 int vfs_mountedon __P((struct vnode *)); /* is a vfs mounted on vp */
416 int vfs_rootmountalloc __P((char *, char *, struct mount **));
417 void vfs_unbusy __P((struct mount *, struct proc *));
418 void vfs_unmountall __P((void));
419 int vfs_register __P((struct vfsconf *));
420 int vfs_unregister __P((struct vfsconf *));
421 extern CIRCLEQ_HEAD(mntlist, mount) mountlist; /* mounted filesystem list */
422 extern struct simplelock mountlist_slock;
423 extern struct nfs_public nfs_pub;
424
425 #else /* !KERNEL */
426
427 #include <sys/cdefs.h>
428
429 __BEGIN_DECLS
430 int fstatfs __P((int, struct statfs *));
431 int getfh __P((const char *, fhandle_t *));
432 int getfsstat __P((struct statfs *, long, int));
433 int getmntinfo __P((struct statfs **, int));
434 int mount __P((const char *, const char *, int, void *));
435 int statfs __P((const char *, struct statfs *));
436 int unmount __P((const char *, int));
437
438 /* C library stuff */
439 void endvfsent __P((void));
440 struct ovfsconf *getvfsbyname __P((const char *));
441 struct ovfsconf *getvfsbytype __P((int));
442 struct ovfsconf *getvfsent __P((void));
443 #define getvfsbyname new_getvfsbyname
444 int new_getvfsbyname __P((const char *, struct vfsconf *));
445 void setvfsent __P((int));
446 int vfsisloadable __P((const char *));
447 int vfsload __P((const char *));
448 __END_DECLS
449
450 #endif /* KERNEL */
451
452 #endif /* !_SYS_MOUNT_H_ */
Cache object: b3142a9ceb9b8aae8588aab18fece688
|