Annotation of src/sys/sys/mount.h, Revision 1.163
1.163 ! pooka 1: /* $NetBSD: mount.h,v 1.162 2007/07/17 22:17:06 christos 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>
39: #if defined(_NETBSD_SOURCE)
1.76 wrstuden 40: #include <sys/stat.h>
1.102 bjh21 41: #endif /* _NETBSD_SOURCE */
1.31 mycroft 42: #endif
1.158 dsl 43: #include <sys/ucred.h>
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.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.150 pooka 86: #define MOUNT_PUFFS "puffs" /* Pass-to-Userspace filesystem */
1.154 dillo 87: #define MOUNT_HFS "hfs" /* Apple HFS+ Filesystem */
1.159 rumble 88: #define MOUNT_EFS "efs" /* SGI's Extent Filesystem */
1.31 mycroft 89:
90: /*
91: * Structure per mounted file system. Each mounted file system has an
92: * array of operations and an instance record. The file systems are
93: * put on a doubly linked list.
1.1 cgd 94: */
1.149 reinoud 95: TAILQ_HEAD(vnodelst, vnode);
1.27 cgd 96:
1.1 cgd 97: struct mount {
1.38 mycroft 98: CIRCLEQ_ENTRY(mount) mnt_list; /* mount list */
1.1 cgd 99: struct vfsops *mnt_op; /* operations on fs */
100: struct vnode *mnt_vnodecovered; /* vnode we mounted on */
1.78 fvdl 101: struct vnode *mnt_syncer; /* syncer vnode */
1.27 cgd 102: struct vnodelst mnt_vnodelist; /* list of vnodes this mount */
1.64 fvdl 103: struct lock mnt_lock; /* mount structure lock */
1.1 cgd 104: int mnt_flag; /* flags */
1.114 dbj 105: int mnt_iflag; /* internal flags */
1.87 chs 106: int mnt_fs_bshift; /* offset shift for lblkno */
107: int mnt_dev_bshift; /* shift for device sectors */
1.119 christos 108: struct statvfs mnt_stat; /* cache of filesystem stats */
1.97 soren 109: void *mnt_data; /* private data */
1.77 sommerfe 110: int mnt_wcnt; /* count of vfs_busy waiters */
1.134 christos 111: struct lwp *mnt_unmounter; /* who is unmounting */
1.156 hannken 112: struct simplelock mnt_slock; /* mutex for wcnt */
1.151 hannken 113: specificdata_reference
114: mnt_specdataref; /* subsystem specific data */
1.1 cgd 115: };
116:
117: /*
1.64 fvdl 118: * Sysctl CTL_VFS definitions.
119: *
120: * Second level identifier specifies which filesystem. Second level
121: * identifier VFS_GENERIC returns information about all filesystems.
1.70 thorpej 122: *
123: * Note the slightly non-flat nature of these sysctl numbers. Oh for
124: * a better sysctl interface.
1.64 fvdl 125: */
126: #define VFS_GENERIC 0 /* generic filesystem information */
127: #define VFS_MAXTYPENUM 1 /* int: highest defined fs type */
128: #define VFS_CONF 2 /* struct: vfsconf for filesystem given
129: as next argument */
1.80 fvdl 130: #define VFS_USERMOUNT 3 /* enable/disable fs mnt by non-root */
1.137 dogcow 131: #define VFS_MAGICLINKS 4 /* expand 'magic' symlinks */
132: #define VFSGEN_MAXID 5 /* number of valid vfs.generic ids */
1.70 thorpej 133:
1.140 christos 134: #ifndef _STANDALONE
1.70 thorpej 135: /*
1.90 jdolecek 136: * USE THE SAME NAMES AS MOUNT_*!
1.70 thorpej 137: *
1.90 jdolecek 138: * Only need to add new entry here if the filesystem actually supports
139: * sysctl(2).
1.70 thorpej 140: */
141: #define CTL_VFS_NAMES { \
142: { "generic", CTLTYPE_NODE }, \
143: { MOUNT_FFS, CTLTYPE_NODE }, \
144: { MOUNT_NFS, CTLTYPE_NODE }, \
145: { MOUNT_MFS, CTLTYPE_NODE }, \
146: { MOUNT_MSDOS, CTLTYPE_NODE }, \
147: { MOUNT_LFS, CTLTYPE_NODE }, \
148: { 0, 0 }, /* MOUNT_LOFS */ \
149: { MOUNT_FDESC, CTLTYPE_NODE }, \
150: { MOUNT_PORTAL, CTLTYPE_NODE }, \
151: { MOUNT_NULL, CTLTYPE_NODE }, \
152: { MOUNT_UMAP, CTLTYPE_NODE }, \
153: { MOUNT_KERNFS, CTLTYPE_NODE }, \
154: { MOUNT_PROCFS, CTLTYPE_NODE }, \
155: { MOUNT_AFS, CTLTYPE_NODE }, \
156: { MOUNT_CD9660, CTLTYPE_NODE }, \
157: { MOUNT_UNION, CTLTYPE_NODE }, \
158: { MOUNT_ADOSFS, CTLTYPE_NODE }, \
159: { MOUNT_EXT2FS, CTLTYPE_NODE }, \
160: { MOUNT_CODA, CTLTYPE_NODE }, \
161: { MOUNT_FILECORE, CTLTYPE_NODE }, \
1.81 jdolecek 162: { MOUNT_NTFS, CTLTYPE_NODE }, \
1.70 thorpej 163: }
164:
165: #define VFS_MAXID 20 /* number of valid vfs ids */
166:
167: #define CTL_VFSGENCTL_NAMES { \
168: { 0, 0 }, \
169: { "maxtypenum", CTLTYPE_INT }, \
170: { "conf", CTLTYPE_NODE }, /* Special */ \
1.80 fvdl 171: { "usermount", CTLTYPE_INT }, \
1.137 dogcow 172: { "magiclinks", CTLTYPE_INT }, \
1.70 thorpej 173: }
1.1 cgd 174:
175: /*
176: * Operations supported on mounted file system.
177: */
1.39 jtc 178: #ifdef _KERNEL
1.64 fvdl 179:
1.89 kleink 180: #if __STDC__
1.1 cgd 181: struct nameidata;
1.31 mycroft 182: struct mbuf;
1.63 thorpej 183: struct vnodeopv_desc;
1.141 elad 184: struct kauth_cred;
1.1 cgd 185: #endif
186:
1.150 pooka 187: #define VFS_PROTOS(fsname) \
188: int fsname##_mount(struct mount *, const char *, void *, \
1.160 dsl 189: size_t *, struct nameidata *, struct lwp *); \
1.150 pooka 190: int fsname##_start(struct mount *, int, struct lwp *); \
191: int fsname##_unmount(struct mount *, int, struct lwp *); \
192: int fsname##_root(struct mount *, struct vnode **); \
193: int fsname##_quotactl(struct mount *, int, uid_t, void *, \
194: struct lwp *); \
195: int fsname##_statvfs(struct mount *, struct statvfs *, \
196: struct lwp *); \
197: int fsname##_sync(struct mount *, int, struct kauth_cred *, \
198: struct lwp *); \
199: int fsname##_vget(struct mount *, ino_t, struct vnode **); \
200: int fsname##_fhtovp(struct mount *, struct fid *, struct vnode **); \
1.157 pooka 201: int fsname##_vptofh(struct vnode *, struct fid *, size_t *); \
1.150 pooka 202: void fsname##_init(void); \
203: void fsname##_reinit(void); \
204: void fsname##_done(void); \
205: int fsname##_mountroot(void); \
206: int fsname##_snapshot(struct mount *, struct vnode *, \
207: struct timespec *); \
208: int fsname##_extattrctl(struct mount *, int, struct vnode *, int, \
1.152 hannken 209: const char *, struct lwp *); \
210: int fsname##_suspendctl(struct mount *, int);
1.150 pooka 211:
1.160 dsl 212: #define VFS_MAX_MOUNT_DATA 8192
1.1 cgd 213: struct vfsops {
1.82 jdolecek 214: const char *vfs_name;
1.160 dsl 215: size_t vfs_min_mount_data;
1.127 perry 216: int (*vfs_mount) (struct mount *, const char *, void *,
1.160 dsl 217: size_t *, struct nameidata *, struct lwp *);
1.134 christos 218: int (*vfs_start) (struct mount *, int, struct lwp *);
219: int (*vfs_unmount) (struct mount *, int, struct lwp *);
1.127 perry 220: int (*vfs_root) (struct mount *, struct vnode **);
221: int (*vfs_quotactl) (struct mount *, int, uid_t, void *,
1.134 christos 222: struct lwp *);
1.127 perry 223: int (*vfs_statvfs) (struct mount *, struct statvfs *,
1.134 christos 224: struct lwp *);
1.141 elad 225: int (*vfs_sync) (struct mount *, int, struct kauth_cred *,
1.134 christos 226: struct lwp *);
1.127 perry 227: int (*vfs_vget) (struct mount *, ino_t, struct vnode **);
228: int (*vfs_fhtovp) (struct mount *, struct fid *,
229: struct vnode **);
1.143 martin 230: int (*vfs_vptofh) (struct vnode *, struct fid *, size_t *);
1.127 perry 231: void (*vfs_init) (void);
232: void (*vfs_reinit) (void);
233: void (*vfs_done) (void);
234: int (*vfs_mountroot)(void);
235: int (*vfs_snapshot) (struct mount *, struct vnode *,
236: struct timespec *);
237: int (*vfs_extattrctl) (struct mount *, int,
1.126 thorpej 238: struct vnode *, int, const char *,
1.134 christos 239: struct lwp *);
1.152 hannken 240: int (*vfs_suspendctl) (struct mount *, int);
1.88 jdolecek 241: const struct vnodeopv_desc * const *vfs_opv_descs;
1.34 mycroft 242: int vfs_refcount;
1.63 thorpej 243: LIST_ENTRY(vfsops) vfs_list;
1.1 cgd 244: };
245:
1.128 thorpej 246: #define VFS_ATTACH(vfs) __link_set_add_data(vfsops, vfs)
247:
1.160 dsl 248: #define VFS_MOUNT(MP, PATH, DATA, DATA_LEN, NDP, L) \
249: (*(MP)->mnt_op->vfs_mount)(MP, PATH, DATA, DATA_LEN, NDP, L)
1.134 christos 250: #define VFS_START(MP, FLAGS, L) (*(MP)->mnt_op->vfs_start)(MP, FLAGS, L)
251: #define VFS_UNMOUNT(MP, FORCE, L) (*(MP)->mnt_op->vfs_unmount)(MP, FORCE, L)
1.106 thorpej 252: #define VFS_ROOT(MP, VPP) (*(MP)->mnt_op->vfs_root)(MP, VPP)
1.134 christos 253: #define VFS_QUOTACTL(MP,C,U,A,L) (*(MP)->mnt_op->vfs_quotactl)(MP, C, U, A, L)
254: #define VFS_STATVFS(MP, SBP, L) (*(MP)->mnt_op->vfs_statvfs)(MP, SBP, L)
255: #define VFS_SYNC(MP, WAIT, C, L) (*(MP)->mnt_op->vfs_sync)(MP, WAIT, C, L)
256: #define VFS_VGET(MP, INO, VPP) (*(MP)->mnt_op->vfs_vget)(MP, INO, VPP)
1.106 thorpej 257: #define VFS_FHTOVP(MP, FIDP, VPP) (*(MP)->mnt_op->vfs_fhtovp)(MP, FIDP, VPP)
1.143 martin 258: #define VFS_VPTOFH(VP, FIDP, FIDSZP) (*(VP)->v_mount->mnt_op->vfs_vptofh)(VP, FIDP, FIDSZP)
1.122 hannken 259: #define VFS_SNAPSHOT(MP, VP, TS) (*(MP)->mnt_op->vfs_snapshot)(MP, VP, TS)
1.134 christos 260: #define VFS_EXTATTRCTL(MP, C, VP, AS, AN, L) \
261: (*(MP)->mnt_op->vfs_extattrctl)(MP, C, VP, AS, AN, L)
1.152 hannken 262: #define VFS_SUSPENDCTL(MP, C) (*(MP)->mnt_op->vfs_suspendctl)(MP, C)
1.1 cgd 263:
1.132 jmmv 264: struct vfs_hooks {
265: void (*vh_unmount)(struct mount *);
266: };
1.138 simonb 267: #define VFS_HOOKS_ATTACH(hooks) __link_set_add_data(vfs_hooks, hooks)
1.31 mycroft 268:
1.132 jmmv 269: void vfs_hooks_unmount(struct mount *);
1.31 mycroft 270:
1.39 jtc 271: #endif /* _KERNEL */
1.31 mycroft 272:
1.1 cgd 273: /*
1.31 mycroft 274: * Export arguments for local filesystem mount calls.
1.132 jmmv 275: *
276: * This structure is deprecated and is only provided for compatibility
277: * reasons with old binary utilities; several file systems expose an
278: * instance of this structure in their mount arguments structure, thus
279: * needing a padding in place of the old values. This definition cannot
280: * change in the future due to this reason.
1.133 jmmv 281: * XXX: This should be moved to the compat subtree but cannot be done
282: * until we can move the mount args structures themselves.
1.132 jmmv 283: *
284: * The current export_args structure can be found in nfs/nfs.h.
1.17 ws 285: */
1.133 jmmv 286: struct export_args30 {
1.31 mycroft 287: int ex_flags; /* export related flags */
288: uid_t ex_root; /* mapping for root uid */
1.92 christos 289: struct uucred ex_anon; /* mapping for anonymous user */
1.31 mycroft 290: struct sockaddr *ex_addr; /* net address to which exported */
291: int ex_addrlen; /* and the net address length */
292: struct sockaddr *ex_mask; /* mask of valid bits in saddr */
293: int ex_masklen; /* and the smask length */
1.58 fvdl 294: char *ex_indexfile; /* index file for WebNFS URLs */
1.17 ws 295: };
296:
1.160 dsl 297: struct mnt_export_args30 {
298: const char *fspec; /* Always NULL */
299: struct export_args30 eargs;
300: };
301:
1.39 jtc 302: #ifdef _KERNEL
1.99 thorpej 303: #include <sys/mallocvar.h>
304: MALLOC_DECLARE(M_MOUNT);
305:
1.1 cgd 306: /*
1.100 gmcgarry 307: * exported VFS interface (see vfssubr(9))
1.1 cgd 308: */
1.127 perry 309: struct mount *vfs_getvfs(fsid_t *); /* return vfs given fsid */
1.146 yamt 310: int vfs_composefh(struct vnode *, fhandle_t *, size_t *);
311: int vfs_composefh_alloc(struct vnode *, fhandle_t **);
312: void vfs_composefh_free(fhandle_t *);
1.145 yamt 313: int vfs_fhtovp(fhandle_t *, struct vnode **);
1.127 perry 314: int vfs_mountedon(struct vnode *);/* is a vfs mounted on vp */
315: int vfs_mountroot(void);
316: void vfs_shutdown(void); /* unmount and sync file systems */
1.134 christos 317: void vfs_unmountall(struct lwp *); /* unmount file systems */
1.127 perry 318: int vfs_busy(struct mount *, int, struct simplelock *);
1.129 christos 319: int vfs_rootmountalloc(const char *, const char *, struct mount **);
1.127 perry 320: void vfs_unbusy(struct mount *);
321: int vfs_attach(struct vfsops *);
322: int vfs_detach(struct vfsops *);
323: void vfs_reinit(void);
324: struct vfsops *vfs_getopsbyname(const char *);
1.63 thorpej 325:
1.127 perry 326: int vfs_stdextattrctl(struct mount *, int, struct vnode *,
1.134 christos 327: int, const char *, struct lwp *);
1.126 thorpej 328:
1.64 fvdl 329: extern CIRCLEQ_HEAD(mntlist, mount) mountlist; /* mounted filesystem list */
330: extern struct vfsops *vfssw[]; /* filesystem type table */
331: extern int nvfssw;
332: extern struct simplelock mountlist_slock;
1.65 thorpej 333: extern struct simplelock spechash_slock;
1.127 perry 334: long makefstype(const char *);
1.134 christos 335: int dounmount(struct mount *, int, struct lwp *);
1.160 dsl 336: int do_sys_mount(struct lwp *, struct vfsops *, const char *, const char *,
337: int, void *, enum uio_seg, size_t, register_t *);
1.127 perry 338: void vfsinit(void);
339: void vfs_opv_init(const struct vnodeopv_desc * const *);
340: void vfs_opv_free(const struct vnodeopv_desc * const *);
1.47 christos 341: #ifdef DEBUG
1.127 perry 342: void vfs_bufstats(void);
1.47 christos 343: #endif
1.63 thorpej 344:
1.151 hannken 345: int mount_specific_key_create(specificdata_key_t *, specificdata_dtor_t);
346: void mount_specific_key_delete(specificdata_key_t);
347: void mount_initspecific(struct mount *);
348: void mount_finispecific(struct mount *);
349: void * mount_getspecific(struct mount *, specificdata_key_t);
350: void mount_setspecific(struct mount *, specificdata_key_t, void *);
351:
1.63 thorpej 352: LIST_HEAD(vfs_list_head, vfsops);
353: extern struct vfs_list_head vfs_list;
1.101 christos 354:
1.39 jtc 355: #else /* _KERNEL */
1.1 cgd 356:
357: #include <sys/cdefs.h>
358:
359: __BEGIN_DECLS
1.143 martin 360: #if !defined(__LIBC12_SOURCE__) && !defined(_STANDALONE)
1.147 martin 361: int getfh(const char *, void *, size_t *)
1.143 martin 362: __RENAME(__getfh30);
363: #endif
364:
1.127 perry 365: int unmount(const char *, int);
1.102 bjh21 366: #if defined(_NETBSD_SOURCE)
1.139 christos 367: #ifndef __LIBC12_SOURCE__
1.161 dsl 368: int mount(const char *, const char *, int, void *, size_t) __RENAME(__mount50);
1.147 martin 369: int fhopen(const void *, size_t, int) __RENAME(__fhopen40);
370: int fhstat(const void *, size_t, struct stat *) __RENAME(__fhstat40);
1.139 christos 371: #endif
1.102 bjh21 372: #endif /* _NETBSD_SOURCE */
1.1 cgd 373: __END_DECLS
374:
1.39 jtc 375: #endif /* _KERNEL */
1.140 christos 376: #endif /* !_STANDALONE */
1.51 mikel 377:
378: #endif /* !_SYS_MOUNT_H_ */
CVSweb <webmaster@jp.NetBSD.org>