Annotation of src/sys/sys/mount.h, Revision 1.141.2.1
1.141.2.1! chap 1: /* $NetBSD: mount.h,v 1.142 2006/06/17 07:06:50 yamt Exp $ */
1.33 cgd 2:
1.1 cgd 3: /*
1.31 mycroft 4: * Copyright (c) 1989, 1991, 1993
5: * The Regents of the University of California. All rights reserved.
1.1 cgd 6: *
7: * Redistribution and use in source and binary forms, with or without
8: * modification, are permitted provided that the following conditions
9: * are met:
10: * 1. Redistributions of source code must retain the above copyright
11: * notice, this list of conditions and the following disclaimer.
12: * 2. Redistributions in binary form must reproduce the above copyright
13: * notice, this list of conditions and the following disclaimer in the
14: * documentation and/or other materials provided with the distribution.
1.111 agc 15: * 3. Neither the name of the University nor the names of its contributors
1.1 cgd 16: * may be used to endorse or promote products derived from this software
17: * without specific prior written permission.
18: *
19: * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
20: * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
21: * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
22: * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
23: * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
24: * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
25: * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
26: * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
27: * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
28: * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
29: * SUCH DAMAGE.
30: *
1.64 fvdl 31: * @(#)mount.h 8.21 (Berkeley) 5/20/95
1.1 cgd 32: */
33:
1.51 mikel 34: #ifndef _SYS_MOUNT_H_
35: #define _SYS_MOUNT_H_
1.104 martin 36:
1.39 jtc 37: #ifndef _KERNEL
1.102 bjh21 38: #include <sys/featuretest.h>
1.31 mycroft 39: #include <sys/ucred.h>
1.102 bjh21 40: #if defined(_NETBSD_SOURCE)
1.76 wrstuden 41: #include <sys/stat.h>
1.102 bjh21 42: #endif /* _NETBSD_SOURCE */
1.31 mycroft 43: #endif
1.119 christos 44: #include <sys/fstypes.h>
1.27 cgd 45: #include <sys/queue.h>
1.64 fvdl 46: #include <sys/lock.h>
1.119 christos 47: #include <sys/statvfs.h>
1.1 cgd 48:
49: /*
50: * file system statistics
51: */
52:
1.42 cgd 53: #define MFSNAMELEN 16 /* length of fs type name, including nul */
1.26 cgd 54: #define MNAMELEN 90 /* length of buffer for returned name */
1.1 cgd 55:
56: /*
57: * File system types.
58: */
1.44 mycroft 59: #define MOUNT_FFS "ffs" /* UNIX "Fast" Filesystem */
60: #define MOUNT_UFS MOUNT_FFS /* for compatibility */
1.26 cgd 61: #define MOUNT_NFS "nfs" /* Network Filesystem */
62: #define MOUNT_MFS "mfs" /* Memory Filesystem */
63: #define MOUNT_MSDOS "msdos" /* MSDOS Filesystem */
1.31 mycroft 64: #define MOUNT_LFS "lfs" /* Log-based Filesystem */
65: #define MOUNT_FDESC "fdesc" /* File Descriptor Filesystem */
66: #define MOUNT_PORTAL "portal" /* Portal Filesystem */
67: #define MOUNT_NULL "null" /* Minimal Filesystem Layer */
1.79 wrstuden 68: #define MOUNT_OVERLAY "overlay" /* Minimal Overlay Filesystem Layer */
1.31 mycroft 69: #define MOUNT_UMAP "umap" /* User/Group Identifier Remapping Filesystem */
70: #define MOUNT_KERNFS "kernfs" /* Kernel Information Filesystem */
71: #define MOUNT_PROCFS "procfs" /* /proc Filesystem */
72: #define MOUNT_AFS "afs" /* Andrew Filesystem */
73: #define MOUNT_CD9660 "cd9660" /* ISO9660 (aka CDROM) Filesystem */
74: #define MOUNT_UNION "union" /* Union (translucent) Filesystem */
1.36 mycroft 75: #define MOUNT_ADOSFS "adosfs" /* AmigaDOS Filesystem */
1.66 kleink 76: #define MOUNT_EXT2FS "ext2fs" /* Second Extended Filesystem */
1.69 rvb 77: #define MOUNT_CFS "coda" /* Coda Filesystem */
1.125 christos 78: #define MOUNT_CODA MOUNT_CFS /* Coda Filesystem */
1.68 mark 79: #define MOUNT_FILECORE "filecore" /* Acorn Filecore Filesystem */
1.75 christos 80: #define MOUNT_NTFS "ntfs" /* Windows/NT Filesystem */
1.93 deberg 81: #define MOUNT_SMBFS "smbfs" /* CIFS (SMB) */
1.125 christos 82: #define MOUNT_PTYFS "ptyfs" /* Pseudo tty filesystem */
1.130 jmmv 83: #define MOUNT_TMPFS "tmpfs" /* Efficient memory file-system */
1.135 reinoud 84: #define MOUNT_UDF "udf" /* UDF CD/DVD filesystem */
1.136 tsutsui 85: #define MOUNT_SYSVBFS "sysvbfs" /* System V Boot Filesystem */
1.31 mycroft 86:
87: /*
88: * Structure per mounted file system. Each mounted file system has an
89: * array of operations and an instance record. The file systems are
90: * put on a doubly linked list.
1.1 cgd 91: */
1.27 cgd 92: LIST_HEAD(vnodelst, vnode);
93:
1.1 cgd 94: struct mount {
1.38 mycroft 95: CIRCLEQ_ENTRY(mount) mnt_list; /* mount list */
1.1 cgd 96: struct vfsops *mnt_op; /* operations on fs */
97: struct vnode *mnt_vnodecovered; /* vnode we mounted on */
1.78 fvdl 98: struct vnode *mnt_syncer; /* syncer vnode */
1.27 cgd 99: struct vnodelst mnt_vnodelist; /* list of vnodes this mount */
1.64 fvdl 100: struct lock mnt_lock; /* mount structure lock */
1.1 cgd 101: int mnt_flag; /* flags */
1.114 dbj 102: int mnt_iflag; /* internal flags */
1.87 chs 103: int mnt_fs_bshift; /* offset shift for lblkno */
104: int mnt_dev_bshift; /* shift for device sectors */
1.119 christos 105: struct statvfs mnt_stat; /* cache of filesystem stats */
1.97 soren 106: void *mnt_data; /* private data */
1.77 sommerfe 107: int mnt_wcnt; /* count of vfs_busy waiters */
1.134 christos 108: struct lwp *mnt_unmounter; /* who is unmounting */
1.115 hannken 109: int mnt_writeopcountupper; /* upper writeops in progress */
110: int mnt_writeopcountlower; /* lower writeops in progress */
1.121 pk 111: struct simplelock mnt_slock; /* mutex for wcnt and
112: writeops counters */
1.123 hannken 113: struct mount *mnt_leaf; /* leaf fs we mounted on */
1.1 cgd 114: };
115:
116: /*
1.64 fvdl 117: * Sysctl CTL_VFS definitions.
118: *
119: * Second level identifier specifies which filesystem. Second level
120: * identifier VFS_GENERIC returns information about all filesystems.
1.70 thorpej 121: *
122: * Note the slightly non-flat nature of these sysctl numbers. Oh for
123: * a better sysctl interface.
1.64 fvdl 124: */
125: #define VFS_GENERIC 0 /* generic filesystem information */
126: #define VFS_MAXTYPENUM 1 /* int: highest defined fs type */
127: #define VFS_CONF 2 /* struct: vfsconf for filesystem given
128: as next argument */
1.80 fvdl 129: #define VFS_USERMOUNT 3 /* enable/disable fs mnt by non-root */
1.137 dogcow 130: #define VFS_MAGICLINKS 4 /* expand 'magic' symlinks */
131: #define VFSGEN_MAXID 5 /* number of valid vfs.generic ids */
1.70 thorpej 132:
1.140 christos 133: #ifndef _STANDALONE
1.70 thorpej 134: /*
1.90 jdolecek 135: * USE THE SAME NAMES AS MOUNT_*!
1.70 thorpej 136: *
1.90 jdolecek 137: * Only need to add new entry here if the filesystem actually supports
138: * sysctl(2).
1.70 thorpej 139: */
140: #define CTL_VFS_NAMES { \
141: { "generic", CTLTYPE_NODE }, \
142: { MOUNT_FFS, CTLTYPE_NODE }, \
143: { MOUNT_NFS, CTLTYPE_NODE }, \
144: { MOUNT_MFS, CTLTYPE_NODE }, \
145: { MOUNT_MSDOS, CTLTYPE_NODE }, \
146: { MOUNT_LFS, CTLTYPE_NODE }, \
147: { 0, 0 }, /* MOUNT_LOFS */ \
148: { MOUNT_FDESC, CTLTYPE_NODE }, \
149: { MOUNT_PORTAL, CTLTYPE_NODE }, \
150: { MOUNT_NULL, CTLTYPE_NODE }, \
151: { MOUNT_UMAP, CTLTYPE_NODE }, \
152: { MOUNT_KERNFS, CTLTYPE_NODE }, \
153: { MOUNT_PROCFS, CTLTYPE_NODE }, \
154: { MOUNT_AFS, CTLTYPE_NODE }, \
155: { MOUNT_CD9660, CTLTYPE_NODE }, \
156: { MOUNT_UNION, CTLTYPE_NODE }, \
157: { MOUNT_ADOSFS, CTLTYPE_NODE }, \
158: { MOUNT_EXT2FS, CTLTYPE_NODE }, \
159: { MOUNT_CODA, CTLTYPE_NODE }, \
160: { MOUNT_FILECORE, CTLTYPE_NODE }, \
1.81 jdolecek 161: { MOUNT_NTFS, CTLTYPE_NODE }, \
1.70 thorpej 162: }
163:
164: #define VFS_MAXID 20 /* number of valid vfs ids */
165:
166: #define CTL_VFSGENCTL_NAMES { \
167: { 0, 0 }, \
168: { "maxtypenum", CTLTYPE_INT }, \
169: { "conf", CTLTYPE_NODE }, /* Special */ \
1.80 fvdl 170: { "usermount", CTLTYPE_INT }, \
1.137 dogcow 171: { "magiclinks", CTLTYPE_INT }, \
1.70 thorpej 172: }
1.1 cgd 173:
174: /*
175: * Operations supported on mounted file system.
176: */
1.39 jtc 177: #ifdef _KERNEL
1.64 fvdl 178:
1.89 kleink 179: #if __STDC__
1.1 cgd 180: struct nameidata;
1.31 mycroft 181: struct mbuf;
1.63 thorpej 182: struct vnodeopv_desc;
1.141 elad 183: struct kauth_cred;
1.1 cgd 184: #endif
185:
186: struct vfsops {
1.82 jdolecek 187: const char *vfs_name;
1.127 perry 188: int (*vfs_mount) (struct mount *, const char *, void *,
1.134 christos 189: struct nameidata *, struct lwp *);
190: int (*vfs_start) (struct mount *, int, struct lwp *);
191: int (*vfs_unmount) (struct mount *, int, struct lwp *);
1.127 perry 192: int (*vfs_root) (struct mount *, struct vnode **);
193: int (*vfs_quotactl) (struct mount *, int, uid_t, void *,
1.134 christos 194: struct lwp *);
1.127 perry 195: int (*vfs_statvfs) (struct mount *, struct statvfs *,
1.134 christos 196: struct lwp *);
1.141 elad 197: int (*vfs_sync) (struct mount *, int, struct kauth_cred *,
1.134 christos 198: struct lwp *);
1.127 perry 199: int (*vfs_vget) (struct mount *, ino_t, struct vnode **);
200: int (*vfs_fhtovp) (struct mount *, struct fid *,
201: struct vnode **);
202: int (*vfs_vptofh) (struct vnode *, struct fid *);
203: void (*vfs_init) (void);
204: void (*vfs_reinit) (void);
205: void (*vfs_done) (void);
206: int (*vfs_mountroot)(void);
207: int (*vfs_snapshot) (struct mount *, struct vnode *,
208: struct timespec *);
209: int (*vfs_extattrctl) (struct mount *, int,
1.126 thorpej 210: struct vnode *, int, const char *,
1.134 christos 211: struct lwp *);
1.88 jdolecek 212: const struct vnodeopv_desc * const *vfs_opv_descs;
1.34 mycroft 213: int vfs_refcount;
1.63 thorpej 214: LIST_ENTRY(vfsops) vfs_list;
1.1 cgd 215: };
216:
1.128 thorpej 217: #define VFS_ATTACH(vfs) __link_set_add_data(vfsops, vfs)
218:
1.134 christos 219: #define VFS_MOUNT(MP, PATH, DATA, NDP, L) \
220: (*(MP)->mnt_op->vfs_mount)(MP, PATH, DATA, NDP, L)
221: #define VFS_START(MP, FLAGS, L) (*(MP)->mnt_op->vfs_start)(MP, FLAGS, L)
222: #define VFS_UNMOUNT(MP, FORCE, L) (*(MP)->mnt_op->vfs_unmount)(MP, FORCE, L)
1.106 thorpej 223: #define VFS_ROOT(MP, VPP) (*(MP)->mnt_op->vfs_root)(MP, VPP)
1.134 christos 224: #define VFS_QUOTACTL(MP,C,U,A,L) (*(MP)->mnt_op->vfs_quotactl)(MP, C, U, A, L)
225: #define VFS_STATVFS(MP, SBP, L) (*(MP)->mnt_op->vfs_statvfs)(MP, SBP, L)
226: #define VFS_SYNC(MP, WAIT, C, L) (*(MP)->mnt_op->vfs_sync)(MP, WAIT, C, L)
227: #define VFS_VGET(MP, INO, VPP) (*(MP)->mnt_op->vfs_vget)(MP, INO, VPP)
1.106 thorpej 228: #define VFS_FHTOVP(MP, FIDP, VPP) (*(MP)->mnt_op->vfs_fhtovp)(MP, FIDP, VPP)
1.1 cgd 229: #define VFS_VPTOFH(VP, FIDP) (*(VP)->v_mount->mnt_op->vfs_vptofh)(VP, FIDP)
1.122 hannken 230: #define VFS_SNAPSHOT(MP, VP, TS) (*(MP)->mnt_op->vfs_snapshot)(MP, VP, TS)
1.134 christos 231: #define VFS_EXTATTRCTL(MP, C, VP, AS, AN, L) \
232: (*(MP)->mnt_op->vfs_extattrctl)(MP, C, VP, AS, AN, L)
1.1 cgd 233:
1.132 jmmv 234: struct vfs_hooks {
235: void (*vh_unmount)(struct mount *);
236: };
1.138 simonb 237: #define VFS_HOOKS_ATTACH(hooks) __link_set_add_data(vfs_hooks, hooks)
1.31 mycroft 238:
1.132 jmmv 239: void vfs_hooks_unmount(struct mount *);
1.31 mycroft 240:
1.39 jtc 241: #endif /* _KERNEL */
1.31 mycroft 242:
1.1 cgd 243: /*
1.31 mycroft 244: * Export arguments for local filesystem mount calls.
1.132 jmmv 245: *
246: * This structure is deprecated and is only provided for compatibility
247: * reasons with old binary utilities; several file systems expose an
248: * instance of this structure in their mount arguments structure, thus
249: * needing a padding in place of the old values. This definition cannot
250: * change in the future due to this reason.
1.133 jmmv 251: * XXX: This should be moved to the compat subtree but cannot be done
252: * until we can move the mount args structures themselves.
1.132 jmmv 253: *
254: * The current export_args structure can be found in nfs/nfs.h.
1.17 ws 255: */
1.133 jmmv 256: struct export_args30 {
1.31 mycroft 257: int ex_flags; /* export related flags */
258: uid_t ex_root; /* mapping for root uid */
1.92 christos 259: struct uucred ex_anon; /* mapping for anonymous user */
1.31 mycroft 260: struct sockaddr *ex_addr; /* net address to which exported */
261: int ex_addrlen; /* and the net address length */
262: struct sockaddr *ex_mask; /* mask of valid bits in saddr */
263: int ex_masklen; /* and the smask length */
1.58 fvdl 264: char *ex_indexfile; /* index file for WebNFS URLs */
1.17 ws 265: };
266:
1.39 jtc 267: #ifdef _KERNEL
1.99 thorpej 268: #include <sys/mallocvar.h>
269: MALLOC_DECLARE(M_MOUNT);
270:
1.1 cgd 271: /*
1.100 gmcgarry 272: * exported VFS interface (see vfssubr(9))
1.1 cgd 273: */
1.127 perry 274: struct mount *vfs_getvfs(fsid_t *); /* return vfs given fsid */
1.141.2.1! chap 275: int vfs_composefh(struct vnode *, fhandle_t *);
1.127 perry 276: int vfs_mountedon(struct vnode *);/* is a vfs mounted on vp */
277: int vfs_mountroot(void);
278: void vfs_shutdown(void); /* unmount and sync file systems */
1.134 christos 279: void vfs_unmountall(struct lwp *); /* unmount file systems */
1.127 perry 280: int vfs_busy(struct mount *, int, struct simplelock *);
1.129 christos 281: int vfs_rootmountalloc(const char *, const char *, struct mount **);
1.127 perry 282: void vfs_unbusy(struct mount *);
283: int vfs_attach(struct vfsops *);
284: int vfs_detach(struct vfsops *);
285: void vfs_reinit(void);
286: struct vfsops *vfs_getopsbyname(const char *);
1.63 thorpej 287:
1.127 perry 288: int vfs_stdextattrctl(struct mount *, int, struct vnode *,
1.134 christos 289: int, const char *, struct lwp *);
1.126 thorpej 290:
1.64 fvdl 291: extern CIRCLEQ_HEAD(mntlist, mount) mountlist; /* mounted filesystem list */
292: extern struct vfsops *vfssw[]; /* filesystem type table */
293: extern int nvfssw;
294: extern struct simplelock mountlist_slock;
1.65 thorpej 295: extern struct simplelock spechash_slock;
1.127 perry 296: long makefstype(const char *);
1.134 christos 297: int dounmount(struct mount *, int, struct lwp *);
1.127 perry 298: void vfsinit(void);
299: void vfs_opv_init(const struct vnodeopv_desc * const *);
300: void vfs_opv_free(const struct vnodeopv_desc * const *);
1.47 christos 301: #ifdef DEBUG
1.127 perry 302: void vfs_bufstats(void);
1.47 christos 303: #endif
1.63 thorpej 304:
305: LIST_HEAD(vfs_list_head, vfsops);
306: extern struct vfs_list_head vfs_list;
1.101 christos 307:
1.39 jtc 308: #else /* _KERNEL */
1.1 cgd 309:
310: #include <sys/cdefs.h>
311:
312: __BEGIN_DECLS
1.127 perry 313: int getfh(const char *, fhandle_t *);
314: int mount(const char *, const char *, int, void *);
315: int unmount(const char *, int);
1.102 bjh21 316: #if defined(_NETBSD_SOURCE)
1.127 perry 317: int fhopen(const fhandle_t *, int);
1.139 christos 318: #ifndef __LIBC12_SOURCE__
319: int fhstat(const fhandle_t *, struct stat *) __RENAME(__fhstat30);
320: #endif
1.102 bjh21 321: #endif /* _NETBSD_SOURCE */
1.1 cgd 322: __END_DECLS
323:
1.39 jtc 324: #endif /* _KERNEL */
1.140 christos 325: #endif /* !_STANDALONE */
1.51 mikel 326:
327: #endif /* !_SYS_MOUNT_H_ */
CVSweb <webmaster@jp.NetBSD.org>