Annotation of src/sys/sys/mount.h, Revision 1.38
1.38 ! mycroft 1: /* $NetBSD: mount.h,v 1.37 1995/01/08 22:53:28 cgd 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.
15: * 3. All advertising materials mentioning features or use of this software
16: * must display the following acknowledgement:
17: * This product includes software developed by the University of
18: * California, Berkeley and its contributors.
19: * 4. Neither the name of the University nor the names of its contributors
20: * may be used to endorse or promote products derived from this software
21: * without specific prior written permission.
22: *
23: * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
24: * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
25: * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
26: * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
27: * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
28: * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
29: * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
30: * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
31: * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
32: * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
33: * SUCH DAMAGE.
34: *
1.36 mycroft 35: * @(#)mount.h 8.15 (Berkeley) 7/14/94
1.1 cgd 36: */
37:
1.31 mycroft 38: #ifndef KERNEL
39: #include <sys/ucred.h>
40: #endif
1.27 cgd 41: #include <sys/queue.h>
1.7 mycroft 42:
1.35 cgd 43: typedef struct { int32_t val[2]; } fsid_t; /* file system id type */
1.1 cgd 44:
45: /*
46: * File identifier.
47: * These are unique per filesystem on a single machine.
48: */
49: #define MAXFIDSZ 16
50:
51: struct fid {
52: u_short fid_len; /* length of data in bytes */
53: u_short fid_reserved; /* force longword alignment */
54: char fid_data[MAXFIDSZ]; /* data (variable length) */
55: };
56:
57: /*
58: * file system statistics
59: */
60:
1.26 cgd 61: #define MFSNAMELEN 15 /* length of fs type name, not inc. null */
62: #define MNAMELEN 90 /* length of buffer for returned name */
1.1 cgd 63:
64: struct statfs {
1.26 cgd 65: short f_type; /* type of filesystem (unused; zero) */
1.1 cgd 66: short f_flags; /* copy of mount flags */
1.27 cgd 67: long f_bsize; /* fundamental file system block size */
68: long f_iosize; /* optimal transfer block size */
1.1 cgd 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 */
1.36 mycroft 75: uid_t f_owner; /* user that mounted the filesystem */
76: long f_spare[4]; /* spare for later */
1.26 cgd 77: char f_fstypename[MFSNAMELEN+1]; /* fs type name (inc. null) */
1.1 cgd 78: char f_mntonname[MNAMELEN]; /* directory on which mounted */
79: char f_mntfromname[MNAMELEN];/* mounted filesystem */
80: };
81:
82: /*
83: * File system types.
84: */
1.26 cgd 85: #define MOUNT_UFS "ufs" /* UNIX "Fast" Filesystem */
86: #define MOUNT_NFS "nfs" /* Network Filesystem */
87: #define MOUNT_MFS "mfs" /* Memory Filesystem */
88: #define MOUNT_MSDOS "msdos" /* MSDOS Filesystem */
1.31 mycroft 89: #define MOUNT_LFS "lfs" /* Log-based Filesystem */
90: #define MOUNT_LOFS "lofs" /* Loopback filesystem */
91: #define MOUNT_FDESC "fdesc" /* File Descriptor Filesystem */
92: #define MOUNT_PORTAL "portal" /* Portal Filesystem */
93: #define MOUNT_NULL "null" /* Minimal Filesystem Layer */
94: #define MOUNT_UMAP "umap" /* User/Group Identifier Remapping Filesystem */
95: #define MOUNT_KERNFS "kernfs" /* Kernel Information Filesystem */
96: #define MOUNT_PROCFS "procfs" /* /proc Filesystem */
97: #define MOUNT_AFS "afs" /* Andrew Filesystem */
98: #define MOUNT_CD9660 "cd9660" /* ISO9660 (aka CDROM) Filesystem */
99: #define MOUNT_UNION "union" /* Union (translucent) Filesystem */
1.36 mycroft 100: #define MOUNT_ADOSFS "adosfs" /* AmigaDOS Filesystem */
1.31 mycroft 101:
102: /*
103: * Structure per mounted file system. Each mounted file system has an
104: * array of operations and an instance record. The file systems are
105: * put on a doubly linked list.
1.1 cgd 106: */
1.27 cgd 107: LIST_HEAD(vnodelst, vnode);
108:
1.1 cgd 109: struct mount {
1.38 ! mycroft 110: CIRCLEQ_ENTRY(mount) mnt_list; /* mount list */
1.1 cgd 111: struct vfsops *mnt_op; /* operations on fs */
112: struct vnode *mnt_vnodecovered; /* vnode we mounted on */
1.27 cgd 113: struct vnodelst mnt_vnodelist; /* list of vnodes this mount */
1.1 cgd 114: int mnt_flag; /* flags */
1.31 mycroft 115: int mnt_maxsymlinklen; /* max size of short symlink */
1.1 cgd 116: struct statfs mnt_stat; /* cache of filesystem stats */
117: qaddr_t mnt_data; /* private data */
118: };
119:
120: /*
121: * Mount flags.
1.29 cgd 122: *
123: * Unmount uses MNT_FORCE flag.
1.1 cgd 124: */
125: #define MNT_RDONLY 0x00000001 /* read only filesystem */
126: #define MNT_SYNCHRONOUS 0x00000002 /* file system written synchronously */
127: #define MNT_NOEXEC 0x00000004 /* can't exec from filesystem */
128: #define MNT_NOSUID 0x00000008 /* don't honor setuid bits on fs */
129: #define MNT_NODEV 0x00000010 /* don't interpret special files */
1.18 cgd 130: #define MNT_UNION 0x00000020 /* union with underlying filesystem */
1.31 mycroft 131: #define MNT_ASYNC 0x00000040 /* file system written asynchronously */
1.15 deraadt 132:
1.1 cgd 133: /*
134: * exported mount flags.
135: */
1.31 mycroft 136: #define MNT_EXRDONLY 0x00000080 /* exported read only */
1.1 cgd 137: #define MNT_EXPORTED 0x00000100 /* file system is exported */
1.31 mycroft 138: #define MNT_DEFEXPORTED 0x00000200 /* exported to the world */
139: #define MNT_EXPORTANON 0x00000400 /* use anon uid mapping for everyone */
140: #define MNT_EXKERB 0x00000800 /* exported with Kerberos uid mapping */
1.1 cgd 141:
142: /*
143: * Flags set by internal operations.
144: */
145: #define MNT_LOCAL 0x00001000 /* filesystem is stored locally */
146: #define MNT_QUOTA 0x00002000 /* quotas are enabled on filesystem */
1.31 mycroft 147: #define MNT_ROOTFS 0x00004000 /* identifies the root filesystem */
1.1 cgd 148:
149: /*
150: * Mask of flags that are visible to statfs()
151: */
152: #define MNT_VISFLAGMASK 0x0000ffff
153:
154: /*
155: * filesystem control flags.
156: *
157: * MNT_MLOCK lock the mount entry so that name lookup cannot proceed
158: * past the mount point. This keeps the subtree stable during mounts
159: * and unmounts.
160: */
161: #define MNT_UPDATE 0x00010000 /* not a real mount, just an update */
1.31 mycroft 162: #define MNT_DELEXPORT 0x00020000 /* delete export host lists */
163: #define MNT_RELOAD 0x00040000 /* reload filesystem data */
164: #define MNT_FORCE 0x00080000 /* force unmount or readonly change */
1.1 cgd 165: #define MNT_MLOCK 0x00100000 /* lock so that subtree is stable */
166: #define MNT_MWAIT 0x00200000 /* someone is waiting for lock */
167: #define MNT_MPBUSY 0x00400000 /* scan of mount point in progress */
168: #define MNT_MPWANT 0x00800000 /* waiting for mount point */
169: #define MNT_UNMOUNT 0x01000000 /* unmount in progress */
1.31 mycroft 170: #define MNT_WANTRDWR 0x02000000 /* want upgrade to read/write */
1.1 cgd 171:
172: /*
173: * Operations supported on mounted file system.
174: */
175: #ifdef KERNEL
176: #ifdef __STDC__
177: struct nameidata;
1.31 mycroft 178: struct mbuf;
1.1 cgd 179: #endif
180:
181: struct vfsops {
1.26 cgd 182: char *vfs_name;
1.1 cgd 183: int (*vfs_mount) __P((struct mount *mp, char *path, caddr_t data,
184: struct nameidata *ndp, struct proc *p));
185: int (*vfs_start) __P((struct mount *mp, int flags,
186: struct proc *p));
187: int (*vfs_unmount) __P((struct mount *mp, int mntflags,
188: struct proc *p));
189: int (*vfs_root) __P((struct mount *mp, struct vnode **vpp));
1.20 cgd 190: int (*vfs_quotactl) __P((struct mount *mp, int cmds, uid_t uid,
1.1 cgd 191: caddr_t arg, struct proc *p));
192: int (*vfs_statfs) __P((struct mount *mp, struct statfs *sbp,
193: struct proc *p));
1.31 mycroft 194: int (*vfs_sync) __P((struct mount *mp, int waitfor,
195: struct ucred *cred, struct proc *p));
196: int (*vfs_vget) __P((struct mount *mp, ino_t ino,
197: struct vnode **vpp));
1.1 cgd 198: int (*vfs_fhtovp) __P((struct mount *mp, struct fid *fhp,
1.31 mycroft 199: struct mbuf *nam, struct vnode **vpp,
200: int *exflagsp, struct ucred **credanonp));
1.1 cgd 201: int (*vfs_vptofh) __P((struct vnode *vp, struct fid *fhp));
1.31 mycroft 202: int (*vfs_init) __P((void));
1.34 mycroft 203: int vfs_refcount;
1.1 cgd 204: };
205:
206: #define VFS_MOUNT(MP, PATH, DATA, NDP, P) \
207: (*(MP)->mnt_op->vfs_mount)(MP, PATH, DATA, NDP, P)
208: #define VFS_START(MP, FLAGS, P) (*(MP)->mnt_op->vfs_start)(MP, FLAGS, P)
209: #define VFS_UNMOUNT(MP, FORCE, P) (*(MP)->mnt_op->vfs_unmount)(MP, FORCE, P)
210: #define VFS_ROOT(MP, VPP) (*(MP)->mnt_op->vfs_root)(MP, VPP)
211: #define VFS_QUOTACTL(MP,C,U,A,P) (*(MP)->mnt_op->vfs_quotactl)(MP, C, U, A, P)
212: #define VFS_STATFS(MP, SBP, P) (*(MP)->mnt_op->vfs_statfs)(MP, SBP, P)
1.31 mycroft 213: #define VFS_SYNC(MP, WAIT, C, P) (*(MP)->mnt_op->vfs_sync)(MP, WAIT, C, P)
214: #define VFS_VGET(MP, INO, VPP) (*(MP)->mnt_op->vfs_vget)(MP, INO, VPP)
215: #define VFS_FHTOVP(MP, FIDP, NAM, VPP, EXFLG, CRED) \
216: (*(MP)->mnt_op->vfs_fhtovp)(MP, FIDP, NAM, VPP, EXFLG, CRED)
1.1 cgd 217: #define VFS_VPTOFH(VP, FIDP) (*(VP)->v_mount->mnt_op->vfs_vptofh)(VP, FIDP)
218: #endif /* KERNEL */
219:
220: /*
221: * Flags for various system call interfaces.
222: *
223: * waitfor flags to vfs_sync() and getfsstat()
224: */
225: #define MNT_WAIT 1
226: #define MNT_NOWAIT 2
227:
228: /*
229: * Generic file handle
230: */
231: struct fhandle {
232: fsid_t fh_fsid; /* File system id of mount point */
1.31 mycroft 233: struct fid fh_fid; /* File sys specific id */
1.1 cgd 234: };
235: typedef struct fhandle fhandle_t;
236:
1.31 mycroft 237: #ifdef KERNEL
238: #include <net/radix.h>
239: #include <sys/socket.h> /* XXX for AF_MAX */
240:
241: /*
242: * Network address lookup element
243: */
244: struct netcred {
245: struct radix_node netc_rnodes[2];
246: int netc_exflags;
247: struct ucred netc_anon;
248: };
249:
250: /*
251: * Network export information
252: */
253: struct netexport {
254: struct netcred ne_defexported; /* Default export */
255: struct radix_node_head *ne_rtable[AF_MAX+1]; /* Individual exports */
256: };
257: #endif /* KERNEL */
258:
1.1 cgd 259: /*
1.31 mycroft 260: * Export arguments for local filesystem mount calls.
1.17 ws 261: */
262: struct export_args {
1.31 mycroft 263: int ex_flags; /* export related flags */
264: uid_t ex_root; /* mapping for root uid */
265: struct ucred ex_anon; /* mapping for anonymous user */
266: struct sockaddr *ex_addr; /* net address to which exported */
267: int ex_addrlen; /* and the net address length */
268: struct sockaddr *ex_mask; /* mask of valid bits in saddr */
269: int ex_masklen; /* and the smask length */
1.17 ws 270: };
271:
272: /*
1.31 mycroft 273: * Arguments to mount UFS-based filesystems
1.1 cgd 274: */
275: struct ufs_args {
1.31 mycroft 276: char *fspec; /* block special device to mount */
277: struct export_args export; /* network export information */
1.1 cgd 278: };
279:
280: /*
281: * Arguments to mount MFS
282: */
283: struct mfs_args {
1.31 mycroft 284: char *fspec; /* name to export for statfs */
285: struct export_args export; /* if exported MFSes are supported */
286: caddr_t base; /* base of file system in memory */
287: u_long size; /* size of file system */
288: };
289:
290: /*
291: * Arguments to mount ISO 9660 filesystems.
292: */
293: struct iso_args {
294: char *fspec; /* block special device to mount */
295: struct export_args export; /* network export info */
296: int flags; /* mounting flags, see below */
1.1 cgd 297: };
1.31 mycroft 298: #define ISOFSMNT_NORRIP 0x00000001 /* disable Rock Ridge Ext.*/
299: #define ISOFSMNT_GENS 0x00000002 /* enable generation numbers */
300: #define ISOFSMNT_EXTATT 0x00000004 /* enable extended attributes */
1.1 cgd 301:
302: /*
303: * File Handle (32 bytes for version 2), variable up to 1024 for version 3
304: */
305: union nfsv2fh {
306: fhandle_t fh_generic;
307: u_char fh_bytes[32];
308: };
309: typedef union nfsv2fh nfsv2fh_t;
310:
311: /*
312: * Arguments to mount NFS
313: */
314: struct nfs_args {
315: struct sockaddr *addr; /* file server address */
1.31 mycroft 316: int addrlen; /* length of address */
1.1 cgd 317: int sotype; /* Socket type */
318: int proto; /* and Protocol */
319: nfsv2fh_t *fh; /* File handle to be mounted */
320: int flags; /* flags */
321: int wsize; /* write size in bytes */
322: int rsize; /* read size in bytes */
323: int timeo; /* initial timeout in .1 secs */
324: int retrans; /* times to retry send */
1.31 mycroft 325: int maxgrouplist; /* Max. size of group list */
326: int readahead; /* # of blocks to readahead */
327: int leaseterm; /* Term (sec) of lease */
328: int deadthresh; /* Retrans threshold */
1.1 cgd 329: char *hostname; /* server's name */
330: };
1.31 mycroft 331:
1.1 cgd 332: /*
333: * NFS mount option flags
334: */
1.31 mycroft 335: #define NFSMNT_SOFT 0x00000001 /* soft mount (hard is default) */
336: #define NFSMNT_WSIZE 0x00000002 /* set write size */
337: #define NFSMNT_RSIZE 0x00000004 /* set read size */
338: #define NFSMNT_TIMEO 0x00000008 /* set initial timeout */
339: #define NFSMNT_RETRANS 0x00000010 /* set number of request retries */
340: #define NFSMNT_MAXGRPS 0x00000020 /* set maximum grouplist size */
341: #define NFSMNT_INT 0x00000040 /* allow interrupts on hard mount */
342: #define NFSMNT_NOCONN 0x00000080 /* Don't Connect the socket */
343: #define NFSMNT_NQNFS 0x00000100 /* Use Nqnfs protocol */
344: #define NFSMNT_MYWRITE 0x00000200 /* Assume writes were mine */
345: #define NFSMNT_KERB 0x00000400 /* Use Kerberos authentication */
346: #define NFSMNT_DUMBTIMR 0x00000800 /* Don't estimate rtt dynamically */
347: #define NFSMNT_RDIRALOOK 0x00001000 /* Do lookup with readdir (nqnfs) */
348: #define NFSMNT_LEASETERM 0x00002000 /* set lease term (nqnfs) */
349: #define NFSMNT_READAHEAD 0x00004000 /* set read ahead */
350: #define NFSMNT_DEADTHRESH 0x00008000 /* set dead server retry thresh */
351: #define NFSMNT_NQLOOKLEASE 0x00010000 /* Get lease for lookup */
352: #define NFSMNT_RESVPORT 0x00020000 /* Allocate a reserved port */
353: #define NFSMNT_INTERNAL 0xffe00000 /* Bits set internally */
354: #define NFSMNT_MNTD 0x00200000 /* Mnt server for mnt point */
355: #define NFSMNT_DISMINPROG 0x00400000 /* Dismount in progress */
356: #define NFSMNT_DISMNT 0x00800000 /* Dismounted */
357: #define NFSMNT_SNDLOCK 0x01000000 /* Send socket lock */
358: #define NFSMNT_WANTSND 0x02000000 /* Want above */
359: #define NFSMNT_RCVLOCK 0x04000000 /* Rcv socket lock */
360: #define NFSMNT_WANTRCV 0x08000000 /* Want above */
361: #define NFSMNT_WAITAUTH 0x10000000 /* Wait for authentication */
362: #define NFSMNT_HASAUTH 0x20000000 /* Has authenticator */
363: #define NFSMNT_WANTAUTH 0x40000000 /* Wants an authenticator */
364: #define NFSMNT_AUTHERR 0x80000000 /* Authentication error */
1.17 ws 365:
366: /*
1.3 cgd 367: * Arguments to mount MSDOS filesystems.
368: */
1.14 cgd 369: struct msdosfs_args {
1.31 mycroft 370: char *fspec; /* blocks special holding the fs to mount */
371: struct export_args export; /* network export information */
372: uid_t uid; /* uid that owns msdosfs files */
373: gid_t gid; /* gid that owns msdosfs files */
374: mode_t mask; /* mask to be applied for msdosfs perms */
1.30 chopps 375: };
376:
377: /*
378: * Arguments to mount amigados filesystems.
379: */
380: struct adosfs_args {
1.31 mycroft 381: char *fspec; /* blocks special holding the fs to mount */
382: struct export_args export; /* network export information */
383: uid_t uid; /* uid that owns msdosfs files */
384: gid_t gid; /* gid that owns msdosfs files */
385: mode_t mask; /* mask to be applied for msdosfs perms */
1.3 cgd 386: };
387:
1.1 cgd 388: #ifdef KERNEL
389: /*
390: * exported vnode operations
391: */
1.31 mycroft 392: struct mount *getvfs __P((fsid_t *)); /* return vfs given fsid */
393: int vfs_export /* process mount export info */
394: __P((struct mount *, struct netexport *, struct export_args *));
395: struct netcred *vfs_export_lookup /* lookup host in fs export list */
396: __P((struct mount *, struct netexport *, struct mbuf *));
397: int vfs_lock __P((struct mount *)); /* lock a vfs */
398: int vfs_mountedon __P((struct vnode *));/* is a vfs mounted on vp */
399: void vfs_unlock __P((struct mount *)); /* unlock a vfs */
1.38 ! mycroft 400: void vfs_unmountall __P((void)); /* unmount all file systems */
! 401: extern CIRCLEQ_HEAD(mntlist, mount) mountlist; /* mounted filesystem list */
1.31 mycroft 402: extern struct vfsops *vfssw[]; /* filesystem type table */
403: extern int nvfssw;
1.1 cgd 404:
405: #else /* KERNEL */
406:
407: #include <sys/cdefs.h>
408:
409: __BEGIN_DECLS
410: int fstatfs __P((int, struct statfs *));
411: int getfh __P((const char *, fhandle_t *));
412: int getfsstat __P((struct statfs *, long, int));
413: int getmntinfo __P((struct statfs **, int));
1.26 cgd 414: int mount __P((char *, const char *, int, void *));
1.1 cgd 415: int statfs __P((const char *, struct statfs *));
416: int unmount __P((const char *, int));
417: __END_DECLS
418:
419: #endif /* KERNEL */
CVSweb <webmaster@jp.NetBSD.org>