xref: /original-bsd/sys/sys/mount.h (revision 09b04dfe)
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.15 (Berkeley) 06/21/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	*mnt_next;		/* next in mount list */
73 	struct mount	*mnt_prev;		/* prev in mount list */
74 	struct vfsops	*mnt_op;		/* operations on fs */
75 	struct vnode	*mnt_vnodecovered;	/* vnode we mounted on */
76 	struct vnode	*mnt_mounth;		/* list of vnodes this mount */
77 	int		mnt_flag;		/* flags */
78 	uid_t		mnt_exroot;		/* exported mapping for uid 0 */
79 	struct statfs	mnt_stat;		/* cache of filesystem stats */
80 	qaddr_t		mnt_data;		/* private data */
81 };
82 
83 /*
84  * Mount flags.
85  */
86 #define	MNT_RDONLY	0x00000001	/* read only filesystem */
87 #define	MNT_SYNCHRONOUS	0x00000002	/* file system written synchronously */
88 #define	MNT_NOEXEC	0x00000004	/* can't exec from filesystem */
89 #define	MNT_NOSUID	0x00000008	/* don't honor setuid bits on fs */
90 #define	MNT_NODEV	0x00000010	/* don't interpret special files */
91 /*
92  * exported mount flags.
93  */
94 #define	MNT_EXPORTED	0x00000100	/* file system is exported */
95 #define	MNT_EXRDONLY	0x00000200	/* exported read only */
96 /*
97  * Flags set by internal operations.
98  */
99 #define	MNT_LOCAL	0x00001000	/* filesystem is stored locally */
100 #define	MNT_QUOTA	0x00002000	/* quotas are enabled on filesystem */
101 /*
102  * Mask of flags that are visible to statfs()
103  */
104 #define	MNT_VISFLAGMASK	0x0000ffff
105 /*
106  * filesystem control flags.
107  *
108  * MNT_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	MNT_UPDATE	0x00010000	/* not a real mount, just an update */
113 #define	MNT_MLOCK	0x00100000	/* lock so that subtree is stable */
114 #define	MNT_MWAIT	0x00200000	/* someone is waiting for lock */
115 #define MNT_MPBUSY	0x00400000	/* scan of mount point in progress */
116 #define MNT_MPWANT	0x00800000	/* waiting for mount point */
117 #define MNT_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)->mnt_op->vfs_mount)(MP, PATH, DATA, NDP)
137 #define VFS_START(MP, FLAGS)	  (*(MP)->mnt_op->vfs_start)(MP, FLAGS)
138 #define VFS_UNMOUNT(MP, FORCIBLY) (*(MP)->mnt_op->vfs_unmount)(MP, FORCIBLY)
139 #define VFS_ROOT(MP, VPP)	  (*(MP)->mnt_op->vfs_root)(MP, VPP)
140 #define VFS_QUOTACTL(MP, C, U, A) (*(MP)->mnt_op->vfs_quotactl)(MP, C, U, A)
141 #define VFS_STATFS(MP, SBP)	  (*(MP)->mnt_op->vfs_statfs)(MP, SBP)
142 #define VFS_SYNC(MP, WAITFOR)	  (*(MP)->mnt_op->vfs_sync)(MP, WAITFOR)
143 #define VFS_FHTOVP(MP, FIDP, VPP) (*(MP)->mnt_op->vfs_fhtovp)(MP, FIDP, VPP)
144 #define	VFS_VPTOFH(VP, FIDP)	  (*(VP)->v_mount->mnt_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		*addr;		/* file server address */
201 	int			sotype;		/* Socket type */
202 	int			proto;		/* and Protocol */
203 	nfsv2fh_t		*fh;		/* File handle to be mounted */
204 	int			flags;		/* flags */
205 	int			wsize;		/* write size in bytes */
206 	int			rsize;		/* read size in bytes */
207 	int			timeo;		/* initial timeout in .1 secs */
208 	int			retrans;	/* times to retry send */
209 	char			*hostname;	/* server's name */
210 };
211 /*
212  * NFS mount option flags
213  */
214 #define	NFSMNT_SOFT	0x0001	/* soft mount (hard is default) */
215 #define	NFSMNT_WSIZE	0x0002	/* set write size */
216 #define	NFSMNT_RSIZE	0x0004	/* set read size */
217 #define	NFSMNT_TIMEO	0x0008	/* set initial timeout */
218 #define	NFSMNT_RETRANS	0x0010	/* set number of request retrys */
219 #define	NFSMNT_HOSTNAME	0x0020	/* set hostname for error printf */
220 #define	NFSMNT_INT	0x0040	/* allow interrupts on hard mount */
221 #define	NFSMNT_NOCONN	0x0080	/* Don't Connect the socket */
222 #define	NFSMNT_SCKLOCK	0x0100	/* Lock socket against others */
223 #define	NFSMNT_WANTSCK	0x0200	/* Want a socket lock */
224 #define	NFSMNT_SPONGY	0x0400	/* spongy mount (soft for stat and lookup) */
225 #define	NFSMNT_LOCKBITS	(NFSMNT_SCKLOCK | NFSMNT_WANTSCK)
226 #endif NFS
227 
228 #ifdef KERNEL
229 /*
230  * exported vnode operations
231  */
232 extern void	vfs_remove();		/* remove a vfs from mounted vfs list */
233 extern int	vfs_lock();		/* lock a vfs */
234 extern void	vfs_unlock();		/* unlock a vfs */
235 extern struct	mount *getvfs();	/* return vfs given fsid */
236 extern struct	mount *rootfs;		/* ptr to root mount structure */
237 extern struct	vfsops *vfssw[];	/* mount filesystem type switch table */
238 #endif
239