xref: /original-bsd/sys/sys/mount.h (revision 188f7363)
1 /*
2  * Copyright (c) 1989 The Regents of the University of California.
3  * All rights reserved.
4  *
5  * Redistribution and use in source and binary forms are permitted
6  * provided that the above copyright notice and this paragraph are
7  * duplicated in all such forms and that any documentation,
8  * advertising materials, and other materials related to such
9  * distribution and use acknowledge that the software was developed
10  * by the University of California, Berkeley.  The name of the
11  * University may not be used to endorse or promote products derived
12  * from this software without specific prior written permission.
13  * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR
14  * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
15  * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
16  *
17  *	@(#)mount.h	7.12 (Berkeley) 05/02/90
18  */
19 
20 typedef quad fsid_t;			/* file system id type */
21 
22 /*
23  * File identifier.
24  * These are unique per filesystem on a single machine.
25  */
26 #define	MAXFIDSZ	16
27 
28 struct fid {
29 	u_short		fid_len;		/* length of data in bytes */
30 	u_short		fid_reserved;		/* force longword alignment */
31 	char		fid_data[MAXFIDSZ];	/* data (variable length) */
32 };
33 
34 /*
35  * file system statistics
36  */
37 
38 #define MNAMELEN 90	/* length of buffer for returned name */
39 
40 struct statfs {
41 	short	f_type;			/* type of filesystem (see below) */
42 	short	f_flags;		/* copy of mount flags */
43 	long	f_fsize;		/* fundamental file system block size */
44 	long	f_bsize;		/* optimal transfer block size */
45 	long	f_blocks;		/* total data blocks in file system */
46 	long	f_bfree;		/* free blocks in fs */
47 	long	f_bavail;		/* free blocks avail to non-superuser */
48 	long	f_files;		/* total file nodes in file system */
49 	long	f_ffree;		/* free file nodes in fs */
50 	fsid_t	f_fsid;			/* file system id */
51 	long	f_spare[9];		/* spare for later */
52 	char	f_mntonname[MNAMELEN];	/* directory on which mounted */
53 	char	f_mntfromname[MNAMELEN];/* mounted filesystem */
54 };
55 /*
56  * File system types.
57  */
58 #define	MOUNT_NONE	0
59 #define	MOUNT_UFS	1
60 #define	MOUNT_NFS	2
61 #define	MOUNT_MFS	3
62 #define	MOUNT_PC	4
63 #define	MOUNT_MAXTYPE	4
64 
65 /*
66  * Structure per mounted file system.
67  * Each mounted file system has an array of
68  * operations and an instance record.
69  * The file systems are put on a doubly linked list.
70  */
71 struct mount {
72 	struct mount	*m_next;		/* next in mount list */
73 	struct mount	*m_prev;		/* prev in mount list */
74 	struct vfsops	*m_op;			/* operations on fs */
75 	struct vnode	*m_vnodecovered;	/* vnode we mounted on */
76 	struct vnode	*m_mounth;		/* list of vnodes this mount */
77 	int		m_flag;			/* flags */
78 	uid_t		m_exroot;		/* exported mapping for uid 0 */
79 	struct statfs	m_stat;			/* cache of filesystem stats */
80 	qaddr_t		m_data;			/* private data */
81 };
82 
83 /*
84  * Mount flags.
85  */
86 #define	M_RDONLY	0x00000001	/* read only filesystem */
87 #define	M_SYNCHRONOUS	0x00000002	/* file system written synchronously */
88 #define	M_NOEXEC	0x00000004	/* can't exec from filesystem */
89 #define	M_NOSUID	0x00000008	/* don't honor setuid bits on fs */
90 #define	M_NODEV		0x00000010	/* don't interpret special files */
91 /*
92  * exported mount flags.
93  */
94 #define	M_EXPORTED	0x00000100	/* file system is exported */
95 #define	M_EXRDONLY	0x00000200	/* exported read only */
96 /*
97  * Flags set by internal operations.
98  */
99 #define	M_LOCAL		0x00001000	/* filesystem is stored locally */
100 #define	M_QUOTA		0x00002000	/* quotas are enabled on filesystem */
101 /*
102  * Mask of flags that are visible to statfs()
103  */
104 #define	M_VISFLAGMASK	0x0000ffff
105 /*
106  * filesystem control flags.
107  *
108  * M_MLOCK lock the mount entry so that name lookup cannot proceed
109  * past the mount point.  This keeps the subtree stable during mounts
110  * and unmounts.
111  */
112 #define	M_UPDATE	0x00010000	/* not a real mount, just an update */
113 #define	M_MLOCK		0x00100000	/* lock so that subtree is stable */
114 #define	M_MWAIT		0x00200000	/* someone is waiting for lock */
115 #define M_MPBUSY	0x00400000	/* scan of mount point in progress */
116 #define M_MPWANT	0x00800000	/* waiting for mount point */
117 #define M_UNMOUNT	0x01000000	/* unmount in progress */
118 
119 /*
120  * Operations supported on mounted file system.
121  */
122 struct vfsops {
123 	int	(*vfs_mount)(	/* mp, path, data, ndp */ );
124 	int	(*vfs_start)(	/* mp, flags */ );
125 	int	(*vfs_unmount)(	/* mp, forcibly */ );
126 	int	(*vfs_root)(	/* mp, vpp */ );
127 	int	(*vfs_quotactl)(/* mp, cmd, uid, arg */ );
128 	int	(*vfs_statfs)(	/* mp, sbp */ );
129 	int	(*vfs_sync)(	/* mp, waitfor */ );
130 	int	(*vfs_fhtovp)(	/* mp, fidp, vpp */ );
131 	int	(*vfs_vptofh)(	/* vp, fidp */ );
132 	int	(*vfs_init)(	/* */ );
133 };
134 
135 #define VFS_MOUNT(MP, PATH, DATA, NDP) \
136 	(*(MP)->m_op->vfs_mount)(MP, PATH, DATA, NDP)
137 #define VFS_START(MP, FLAGS)	  (*(MP)->m_op->vfs_start)(MP, FLAGS)
138 #define VFS_UNMOUNT(MP, FORCIBLY) (*(MP)->m_op->vfs_unmount)(MP, FORCIBLY)
139 #define VFS_ROOT(MP, VPP)	  (*(MP)->m_op->vfs_root)(MP, VPP)
140 #define VFS_QUOTACTL(MP, C, U, A) (*(MP)->m_op->vfs_quotactl)(MP, C, U, A)
141 #define VFS_STATFS(MP, SBP)	  (*(MP)->m_op->vfs_statfs)(MP, SBP)
142 #define VFS_SYNC(MP, WAITFOR)	  (*(MP)->m_op->vfs_sync)(MP, WAITFOR)
143 #define VFS_FHTOVP(MP, FIDP, VPP) (*(MP)->m_op->vfs_fhtovp)(MP, FIDP, VPP)
144 #define	VFS_VPTOFH(VP, FIDP)	  (*(VP)->v_mount->m_op->vfs_vptofh)(VP, FIDP)
145 
146 /*
147  * Flags for various system call interfaces.
148  *
149  * forcibly flags for vfs_umount().
150  * waitfor flags to vfs_sync() and getfsstat()
151  */
152 #define MNT_FORCE	1
153 #define MNT_NOFORCE	2
154 #define MNT_WAIT	1
155 #define MNT_NOWAIT	2
156 
157 /*
158  * Generic file handle
159  */
160 struct fhandle {
161 	fsid_t	fh_fsid;	/* File system id of mount point */
162 	struct	fid fh_fid;	/* Id of file */
163 };
164 typedef struct fhandle	fhandle_t;
165 
166 /*
167  * Arguments to mount UFS
168  */
169 struct ufs_args {
170 	char	*fspec;		/* block special device to mount */
171 	int	exflags;	/* export related flags */
172 	uid_t	exroot;		/* mapping for root uid */
173 };
174 
175 #ifdef MFS
176 /*
177  * Arguments to mount MFS
178  */
179 struct mfs_args {
180 	char	*name;		/* name to export for statfs */
181 	caddr_t	base;		/* base address of file system in memory */
182 	u_long size;		/* size of file system */
183 };
184 #endif MFS
185 
186 #ifdef NFS
187 /*
188  * File Handle (32 bytes for version 2), variable up to 1024 for version 3
189  */
190 union nfsv2fh {
191 	fhandle_t	fh_generic;
192 	u_char		fh_bytes[32];
193 };
194 typedef union nfsv2fh nfsv2fh_t;
195 
196 /*
197  * Arguments to mount NFS
198  */
199 struct nfs_args {
200 	struct sockaddr_in	*addr;		/* file server address */
201 	nfsv2fh_t		*fh;		/* File handle to be mounted */
202 	int			flags;		/* flags */
203 	int			wsize;		/* write size in bytes */
204 	int			rsize;		/* read size in bytes */
205 	int			timeo;		/* initial timeout in .1 secs */
206 	int			retrans;	/* times to retry send */
207 	char			*hostname;	/* server's name */
208 };
209 /*
210  * NFS mount option flags
211  */
212 #define	NFSMNT_SOFT	0x001	/* soft mount (hard is default) */
213 #define	NFSMNT_WSIZE	0x002	/* set write size */
214 #define	NFSMNT_RSIZE	0x004	/* set read size */
215 #define	NFSMNT_TIMEO	0x008	/* set initial timeout */
216 #define	NFSMNT_RETRANS	0x010	/* set number of request retrys */
217 #define	NFSMNT_HOSTNAME	0x020	/* set hostname for error printf */
218 #define	NFSMNT_INT	0x040	/* allow interrupts on hard mount */
219 #endif NFS
220 
221 #ifdef KERNEL
222 /*
223  * exported vnode operations
224  */
225 extern void	vfs_remove();		/* remove a vfs from mounted vfs list */
226 extern int	vfs_lock();		/* lock a vfs */
227 extern void	vfs_unlock();		/* unlock a vfs */
228 extern struct	mount *getvfs();	/* return vfs given fsid */
229 extern struct	mount *rootfs;		/* ptr to root mount structure */
230 extern struct	vfsops *vfssw[];	/* mount filesystem type switch table */
231 #endif
232