Annotation of src/sys/sys/mount.h, Revision 1.152
1.152 ! hannken 1: /* $NetBSD: mount.h,v 1.151 2006/11/17 17:05:18 hannken 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.151 hannken 48: #include <sys/specificdata.h>
1.1 cgd 49:
50: /*
51: * file system statistics
52: */
53:
1.42 cgd 54: #define MFSNAMELEN 16 /* length of fs type name, including nul */
1.26 cgd 55: #define MNAMELEN 90 /* length of buffer for returned name */
1.1 cgd 56:
57: /*
58: * File system types.
59: */
1.44 mycroft 60: #define MOUNT_FFS "ffs" /* UNIX "Fast" Filesystem */
61: #define MOUNT_UFS MOUNT_FFS /* for compatibility */
1.26 cgd 62: #define MOUNT_NFS "nfs" /* Network Filesystem */
63: #define MOUNT_MFS "mfs" /* Memory Filesystem */
64: #define MOUNT_MSDOS "msdos" /* MSDOS Filesystem */
1.31 mycroft 65: #define MOUNT_LFS "lfs" /* Log-based Filesystem */
66: #define MOUNT_FDESC "fdesc" /* File Descriptor Filesystem */
67: #define MOUNT_PORTAL "portal" /* Portal Filesystem */
68: #define MOUNT_NULL "null" /* Minimal Filesystem Layer */
1.79 wrstuden 69: #define MOUNT_OVERLAY "overlay" /* Minimal Overlay Filesystem Layer */
1.31 mycroft 70: #define MOUNT_UMAP "umap" /* User/Group Identifier Remapping Filesystem */
71: #define MOUNT_KERNFS "kernfs" /* Kernel Information Filesystem */
72: #define MOUNT_PROCFS "procfs" /* /proc Filesystem */
73: #define MOUNT_AFS "afs" /* Andrew Filesystem */
74: #define MOUNT_CD9660 "cd9660" /* ISO9660 (aka CDROM) Filesystem */
75: #define MOUNT_UNION "union" /* Union (translucent) Filesystem */
1.36 mycroft 76: #define MOUNT_ADOSFS "adosfs" /* AmigaDOS Filesystem */
1.66 kleink 77: #define MOUNT_EXT2FS "ext2fs" /* Second Extended Filesystem */
1.69 rvb 78: #define MOUNT_CFS "coda" /* Coda Filesystem */
1.125 christos 79: #define MOUNT_CODA MOUNT_CFS /* Coda Filesystem */
1.68 mark 80: #define MOUNT_FILECORE "filecore" /* Acorn Filecore Filesystem */
1.75 christos 81: #define MOUNT_NTFS "ntfs" /* Windows/NT Filesystem */
1.93 deberg 82: #define MOUNT_SMBFS "smbfs" /* CIFS (SMB) */
1.125 christos 83: #define MOUNT_PTYFS "ptyfs" /* Pseudo tty filesystem */
1.130 jmmv 84: #define MOUNT_TMPFS "tmpfs" /* Efficient memory file-system */
1.135 reinoud 85: #define MOUNT_UDF "udf" /* UDF CD/DVD filesystem */
1.136 tsutsui 86: #define MOUNT_SYSVBFS "sysvbfs" /* System V Boot Filesystem */
1.150 pooka 87: #define MOUNT_PUFFS "puffs" /* Pass-to-Userspace filesystem */
1.31 mycroft 88:
89: /*
90: * Structure per mounted file system. Each mounted file system has an
91: * array of operations and an instance record. The file systems are
92: * put on a doubly linked list.
1.1 cgd 93: */
1.149 reinoud 94: TAILQ_HEAD(vnodelst, vnode);
1.27 cgd 95:
1.1 cgd 96: struct mount {
1.38 mycroft 97: CIRCLEQ_ENTRY(mount) mnt_list; /* mount list */
1.1 cgd 98: struct vfsops *mnt_op; /* operations on fs */
99: struct vnode *mnt_vnodecovered; /* vnode we mounted on */
1.78 fvdl 100: struct vnode *mnt_syncer; /* syncer vnode */
1.27 cgd 101: struct vnodelst mnt_vnodelist; /* list of vnodes this mount */
1.64 fvdl 102: struct lock mnt_lock; /* mount structure lock */
1.1 cgd 103: int mnt_flag; /* flags */
1.114 dbj 104: int mnt_iflag; /* internal flags */
1.87 chs 105: int mnt_fs_bshift; /* offset shift for lblkno */
106: int mnt_dev_bshift; /* shift for device sectors */
1.119 christos 107: struct statvfs mnt_stat; /* cache of filesystem stats */
1.97 soren 108: void *mnt_data; /* private data */
1.77 sommerfe 109: int mnt_wcnt; /* count of vfs_busy waiters */
1.134 christos 110: struct lwp *mnt_unmounter; /* who is unmounting */
1.115 hannken 111: int mnt_writeopcountupper; /* upper writeops in progress */
112: int mnt_writeopcountlower; /* lower writeops in progress */
1.121 pk 113: struct simplelock mnt_slock; /* mutex for wcnt and
114: writeops counters */
1.123 hannken 115: struct mount *mnt_leaf; /* leaf fs we mounted on */
1.151 hannken 116: specificdata_reference
117: mnt_specdataref; /* subsystem specific data */
1.1 cgd 118: };
119:
120: /*
1.64 fvdl 121: * Sysctl CTL_VFS definitions.
122: *
123: * Second level identifier specifies which filesystem. Second level
124: * identifier VFS_GENERIC returns information about all filesystems.
1.70 thorpej 125: *
126: * Note the slightly non-flat nature of these sysctl numbers. Oh for
127: * a better sysctl interface.
1.64 fvdl 128: */
129: #define VFS_GENERIC 0 /* generic filesystem information */
130: #define VFS_MAXTYPENUM 1 /* int: highest defined fs type */
131: #define VFS_CONF 2 /* struct: vfsconf for filesystem given
132: as next argument */
1.80 fvdl 133: #define VFS_USERMOUNT 3 /* enable/disable fs mnt by non-root */
1.137 dogcow 134: #define VFS_MAGICLINKS 4 /* expand 'magic' symlinks */
135: #define VFSGEN_MAXID 5 /* number of valid vfs.generic ids */
1.70 thorpej 136:
1.140 christos 137: #ifndef _STANDALONE
1.70 thorpej 138: /*
1.90 jdolecek 139: * USE THE SAME NAMES AS MOUNT_*!
1.70 thorpej 140: *
1.90 jdolecek 141: * Only need to add new entry here if the filesystem actually supports
142: * sysctl(2).
1.70 thorpej 143: */
144: #define CTL_VFS_NAMES { \
145: { "generic", CTLTYPE_NODE }, \
146: { MOUNT_FFS, CTLTYPE_NODE }, \
147: { MOUNT_NFS, CTLTYPE_NODE }, \
148: { MOUNT_MFS, CTLTYPE_NODE }, \
149: { MOUNT_MSDOS, CTLTYPE_NODE }, \
150: { MOUNT_LFS, CTLTYPE_NODE }, \
151: { 0, 0 }, /* MOUNT_LOFS */ \
152: { MOUNT_FDESC, CTLTYPE_NODE }, \
153: { MOUNT_PORTAL, CTLTYPE_NODE }, \
154: { MOUNT_NULL, CTLTYPE_NODE }, \
155: { MOUNT_UMAP, CTLTYPE_NODE }, \
156: { MOUNT_KERNFS, CTLTYPE_NODE }, \
157: { MOUNT_PROCFS, CTLTYPE_NODE }, \
158: { MOUNT_AFS, CTLTYPE_NODE }, \
159: { MOUNT_CD9660, CTLTYPE_NODE }, \
160: { MOUNT_UNION, CTLTYPE_NODE }, \
161: { MOUNT_ADOSFS, CTLTYPE_NODE }, \
162: { MOUNT_EXT2FS, CTLTYPE_NODE }, \
163: { MOUNT_CODA, CTLTYPE_NODE }, \
164: { MOUNT_FILECORE, CTLTYPE_NODE }, \
1.81 jdolecek 165: { MOUNT_NTFS, CTLTYPE_NODE }, \
1.70 thorpej 166: }
167:
168: #define VFS_MAXID 20 /* number of valid vfs ids */
169:
170: #define CTL_VFSGENCTL_NAMES { \
171: { 0, 0 }, \
172: { "maxtypenum", CTLTYPE_INT }, \
173: { "conf", CTLTYPE_NODE }, /* Special */ \
1.80 fvdl 174: { "usermount", CTLTYPE_INT }, \
1.137 dogcow 175: { "magiclinks", CTLTYPE_INT }, \
1.70 thorpej 176: }
1.1 cgd 177:
178: /*
179: * Operations supported on mounted file system.
180: */
1.39 jtc 181: #ifdef _KERNEL
1.64 fvdl 182:
1.89 kleink 183: #if __STDC__
1.1 cgd 184: struct nameidata;
1.31 mycroft 185: struct mbuf;
1.63 thorpej 186: struct vnodeopv_desc;
1.141 elad 187: struct kauth_cred;
1.1 cgd 188: #endif
189:
1.150 pooka 190: #define VFS_PROTOS(fsname) \
191: int fsname##_mount(struct mount *, const char *, void *, \
192: struct nameidata *, struct lwp *); \
193: int fsname##_start(struct mount *, int, struct lwp *); \
194: int fsname##_unmount(struct mount *, int, struct lwp *); \
195: int fsname##_root(struct mount *, struct vnode **); \
196: int fsname##_quotactl(struct mount *, int, uid_t, void *, \
197: struct lwp *); \
198: int fsname##_statvfs(struct mount *, struct statvfs *, \
199: struct lwp *); \
200: int fsname##_sync(struct mount *, int, struct kauth_cred *, \
201: struct lwp *); \
202: int fsname##_vget(struct mount *, ino_t, struct vnode **); \
203: int fsname##_fhtovp(struct mount *, struct fid *, struct vnode **); \
204: int fsname##_vptofh(struct vnode *, struct fid *); \
205: void fsname##_init(void); \
206: void fsname##_reinit(void); \
207: void fsname##_done(void); \
208: int fsname##_mountroot(void); \
209: int fsname##_snapshot(struct mount *, struct vnode *, \
210: struct timespec *); \
211: int fsname##_extattrctl(struct mount *, int, struct vnode *, int, \
1.152 ! hannken 212: const char *, struct lwp *); \
! 213: int fsname##_suspendctl(struct mount *, int);
1.150 pooka 214:
1.1 cgd 215: struct vfsops {
1.82 jdolecek 216: const char *vfs_name;
1.127 perry 217: int (*vfs_mount) (struct mount *, const char *, void *,
1.134 christos 218: struct nameidata *, struct lwp *);
219: int (*vfs_start) (struct mount *, int, struct lwp *);
220: int (*vfs_unmount) (struct mount *, int, struct lwp *);
1.127 perry 221: int (*vfs_root) (struct mount *, struct vnode **);
222: int (*vfs_quotactl) (struct mount *, int, uid_t, void *,
1.134 christos 223: struct lwp *);
1.127 perry 224: int (*vfs_statvfs) (struct mount *, struct statvfs *,
1.134 christos 225: struct lwp *);
1.141 elad 226: int (*vfs_sync) (struct mount *, int, struct kauth_cred *,
1.134 christos 227: struct lwp *);
1.127 perry 228: int (*vfs_vget) (struct mount *, ino_t, struct vnode **);
229: int (*vfs_fhtovp) (struct mount *, struct fid *,
230: struct vnode **);
1.143 martin 231: int (*vfs_vptofh) (struct vnode *, struct fid *, size_t *);
1.127 perry 232: void (*vfs_init) (void);
233: void (*vfs_reinit) (void);
234: void (*vfs_done) (void);
235: int (*vfs_mountroot)(void);
236: int (*vfs_snapshot) (struct mount *, struct vnode *,
237: struct timespec *);
238: int (*vfs_extattrctl) (struct mount *, int,
1.126 thorpej 239: struct vnode *, int, const char *,
1.134 christos 240: struct lwp *);
1.152 ! hannken 241: int (*vfs_suspendctl) (struct mount *, int);
1.88 jdolecek 242: const struct vnodeopv_desc * const *vfs_opv_descs;
1.34 mycroft 243: int vfs_refcount;
1.63 thorpej 244: LIST_ENTRY(vfsops) vfs_list;
1.1 cgd 245: };
246:
1.128 thorpej 247: #define VFS_ATTACH(vfs) __link_set_add_data(vfsops, vfs)
248:
1.134 christos 249: #define VFS_MOUNT(MP, PATH, DATA, NDP, L) \
250: (*(MP)->mnt_op->vfs_mount)(MP, PATH, DATA, NDP, L)
251: #define VFS_START(MP, FLAGS, L) (*(MP)->mnt_op->vfs_start)(MP, FLAGS, L)
252: #define VFS_UNMOUNT(MP, FORCE, L) (*(MP)->mnt_op->vfs_unmount)(MP, FORCE, L)
1.106 thorpej 253: #define VFS_ROOT(MP, VPP) (*(MP)->mnt_op->vfs_root)(MP, VPP)
1.134 christos 254: #define VFS_QUOTACTL(MP,C,U,A,L) (*(MP)->mnt_op->vfs_quotactl)(MP, C, U, A, L)
255: #define VFS_STATVFS(MP, SBP, L) (*(MP)->mnt_op->vfs_statvfs)(MP, SBP, L)
256: #define VFS_SYNC(MP, WAIT, C, L) (*(MP)->mnt_op->vfs_sync)(MP, WAIT, C, L)
257: #define VFS_VGET(MP, INO, VPP) (*(MP)->mnt_op->vfs_vget)(MP, INO, VPP)
1.106 thorpej 258: #define VFS_FHTOVP(MP, FIDP, VPP) (*(MP)->mnt_op->vfs_fhtovp)(MP, FIDP, VPP)
1.143 martin 259: #define VFS_VPTOFH(VP, FIDP, FIDSZP) (*(VP)->v_mount->mnt_op->vfs_vptofh)(VP, FIDP, FIDSZP)
1.122 hannken 260: #define VFS_SNAPSHOT(MP, VP, TS) (*(MP)->mnt_op->vfs_snapshot)(MP, VP, TS)
1.134 christos 261: #define VFS_EXTATTRCTL(MP, C, VP, AS, AN, L) \
262: (*(MP)->mnt_op->vfs_extattrctl)(MP, C, VP, AS, AN, L)
1.152 ! hannken 263: #define VFS_SUSPENDCTL(MP, C) (*(MP)->mnt_op->vfs_suspendctl)(MP, C)
1.1 cgd 264:
1.132 jmmv 265: struct vfs_hooks {
266: void (*vh_unmount)(struct mount *);
267: };
1.138 simonb 268: #define VFS_HOOKS_ATTACH(hooks) __link_set_add_data(vfs_hooks, hooks)
1.31 mycroft 269:
1.132 jmmv 270: void vfs_hooks_unmount(struct mount *);
1.31 mycroft 271:
1.39 jtc 272: #endif /* _KERNEL */
1.31 mycroft 273:
1.1 cgd 274: /*
1.31 mycroft 275: * Export arguments for local filesystem mount calls.
1.132 jmmv 276: *
277: * This structure is deprecated and is only provided for compatibility
278: * reasons with old binary utilities; several file systems expose an
279: * instance of this structure in their mount arguments structure, thus
280: * needing a padding in place of the old values. This definition cannot
281: * change in the future due to this reason.
1.133 jmmv 282: * XXX: This should be moved to the compat subtree but cannot be done
283: * until we can move the mount args structures themselves.
1.132 jmmv 284: *
285: * The current export_args structure can be found in nfs/nfs.h.
1.17 ws 286: */
1.133 jmmv 287: struct export_args30 {
1.31 mycroft 288: int ex_flags; /* export related flags */
289: uid_t ex_root; /* mapping for root uid */
1.92 christos 290: struct uucred ex_anon; /* mapping for anonymous user */
1.31 mycroft 291: struct sockaddr *ex_addr; /* net address to which exported */
292: int ex_addrlen; /* and the net address length */
293: struct sockaddr *ex_mask; /* mask of valid bits in saddr */
294: int ex_masklen; /* and the smask length */
1.58 fvdl 295: char *ex_indexfile; /* index file for WebNFS URLs */
1.17 ws 296: };
297:
1.39 jtc 298: #ifdef _KERNEL
1.99 thorpej 299: #include <sys/mallocvar.h>
300: MALLOC_DECLARE(M_MOUNT);
301:
1.1 cgd 302: /*
1.100 gmcgarry 303: * exported VFS interface (see vfssubr(9))
1.1 cgd 304: */
1.127 perry 305: struct mount *vfs_getvfs(fsid_t *); /* return vfs given fsid */
1.146 yamt 306: int vfs_composefh(struct vnode *, fhandle_t *, size_t *);
307: int vfs_composefh_alloc(struct vnode *, fhandle_t **);
308: void vfs_composefh_free(fhandle_t *);
1.145 yamt 309: int vfs_fhtovp(fhandle_t *, struct vnode **);
1.127 perry 310: int vfs_mountedon(struct vnode *);/* is a vfs mounted on vp */
311: int vfs_mountroot(void);
312: void vfs_shutdown(void); /* unmount and sync file systems */
1.134 christos 313: void vfs_unmountall(struct lwp *); /* unmount file systems */
1.127 perry 314: int vfs_busy(struct mount *, int, struct simplelock *);
1.129 christos 315: int vfs_rootmountalloc(const char *, const char *, struct mount **);
1.127 perry 316: void vfs_unbusy(struct mount *);
317: int vfs_attach(struct vfsops *);
318: int vfs_detach(struct vfsops *);
319: void vfs_reinit(void);
320: struct vfsops *vfs_getopsbyname(const char *);
1.63 thorpej 321:
1.127 perry 322: int vfs_stdextattrctl(struct mount *, int, struct vnode *,
1.134 christos 323: int, const char *, struct lwp *);
1.152 ! hannken 324: int vfs_stdsuspendctl(struct mount *, int);
1.126 thorpej 325:
1.64 fvdl 326: extern CIRCLEQ_HEAD(mntlist, mount) mountlist; /* mounted filesystem list */
327: extern struct vfsops *vfssw[]; /* filesystem type table */
328: extern int nvfssw;
329: extern struct simplelock mountlist_slock;
1.65 thorpej 330: extern struct simplelock spechash_slock;
1.127 perry 331: long makefstype(const char *);
1.134 christos 332: int dounmount(struct mount *, int, struct lwp *);
1.127 perry 333: void vfsinit(void);
334: void vfs_opv_init(const struct vnodeopv_desc * const *);
335: void vfs_opv_free(const struct vnodeopv_desc * const *);
1.47 christos 336: #ifdef DEBUG
1.127 perry 337: void vfs_bufstats(void);
1.47 christos 338: #endif
1.63 thorpej 339:
1.151 hannken 340: int mount_specific_key_create(specificdata_key_t *, specificdata_dtor_t);
341: void mount_specific_key_delete(specificdata_key_t);
342: void mount_initspecific(struct mount *);
343: void mount_finispecific(struct mount *);
344: void * mount_getspecific(struct mount *, specificdata_key_t);
345: void mount_setspecific(struct mount *, specificdata_key_t, void *);
346:
1.145 yamt 347: /*
348: * syscall helpers
349: */
350:
1.148 yamt 351: int vfs_copyinfh_alloc(const void *, size_t, fhandle_t **);
1.145 yamt 352: void vfs_copyinfh_free(fhandle_t *);
353:
1.148 yamt 354: struct stat;
355: int dofhopen(struct lwp *, const void *, size_t, int, register_t *);
356: int dofhstat(struct lwp *, const void *, size_t, struct stat *, register_t *);
357: int dofhstatvfs(struct lwp *, const void *, size_t, struct statvfs *, int,
358: register_t *);
359:
1.63 thorpej 360: LIST_HEAD(vfs_list_head, vfsops);
361: extern struct vfs_list_head vfs_list;
1.101 christos 362:
1.39 jtc 363: #else /* _KERNEL */
1.1 cgd 364:
365: #include <sys/cdefs.h>
366:
367: __BEGIN_DECLS
1.143 martin 368: #if !defined(__LIBC12_SOURCE__) && !defined(_STANDALONE)
1.147 martin 369: int getfh(const char *, void *, size_t *)
1.143 martin 370: __RENAME(__getfh30);
371: #endif
372:
1.127 perry 373: int mount(const char *, const char *, int, void *);
374: int unmount(const char *, int);
1.102 bjh21 375: #if defined(_NETBSD_SOURCE)
1.139 christos 376: #ifndef __LIBC12_SOURCE__
1.147 martin 377: int fhopen(const void *, size_t, int) __RENAME(__fhopen40);
378: int fhstat(const void *, size_t, struct stat *) __RENAME(__fhstat40);
1.139 christos 379: #endif
1.102 bjh21 380: #endif /* _NETBSD_SOURCE */
1.1 cgd 381: __END_DECLS
382:
1.39 jtc 383: #endif /* _KERNEL */
1.140 christos 384: #endif /* !_STANDALONE */
1.51 mikel 385:
386: #endif /* !_SYS_MOUNT_H_ */
CVSweb <webmaster@jp.NetBSD.org>