xref: /original-bsd/sys/sys/mount.h (revision 72b8f354)
1 /*
2  * Copyright (c) 1989 The Regents of the University of California.
3  * All rights reserved.
4  *
5  * %sccs.include.redist.c%
6  *
7  *	@(#)mount.h	7.16 (Berkeley) 06/28/90
8  */
9 
10 typedef quad fsid_t;			/* file system id type */
11 
12 /*
13  * File identifier.
14  * These are unique per filesystem on a single machine.
15  */
16 #define	MAXFIDSZ	16
17 
18 struct fid {
19 	u_short		fid_len;		/* length of data in bytes */
20 	u_short		fid_reserved;		/* force longword alignment */
21 	char		fid_data[MAXFIDSZ];	/* data (variable length) */
22 };
23 
24 /*
25  * file system statistics
26  */
27 
28 #define MNAMELEN 90	/* length of buffer for returned name */
29 
30 struct statfs {
31 	short	f_type;			/* type of filesystem (see below) */
32 	short	f_flags;		/* copy of mount flags */
33 	long	f_fsize;		/* fundamental file system block size */
34 	long	f_bsize;		/* optimal transfer block size */
35 	long	f_blocks;		/* total data blocks in file system */
36 	long	f_bfree;		/* free blocks in fs */
37 	long	f_bavail;		/* free blocks avail to non-superuser */
38 	long	f_files;		/* total file nodes in file system */
39 	long	f_ffree;		/* free file nodes in fs */
40 	fsid_t	f_fsid;			/* file system id */
41 	long	f_spare[9];		/* spare for later */
42 	char	f_mntonname[MNAMELEN];	/* directory on which mounted */
43 	char	f_mntfromname[MNAMELEN];/* mounted filesystem */
44 };
45 /*
46  * File system types.
47  */
48 #define	MOUNT_NONE	0
49 #define	MOUNT_UFS	1
50 #define	MOUNT_NFS	2
51 #define	MOUNT_MFS	3
52 #define	MOUNT_PC	4
53 #define	MOUNT_MAXTYPE	4
54 
55 /*
56  * Structure per mounted file system.
57  * Each mounted file system has an array of
58  * operations and an instance record.
59  * The file systems are put on a doubly linked list.
60  */
61 struct mount {
62 	struct mount	*mnt_next;		/* next in mount list */
63 	struct mount	*mnt_prev;		/* prev in mount list */
64 	struct vfsops	*mnt_op;		/* operations on fs */
65 	struct vnode	*mnt_vnodecovered;	/* vnode we mounted on */
66 	struct vnode	*mnt_mounth;		/* list of vnodes this mount */
67 	int		mnt_flag;		/* flags */
68 	uid_t		mnt_exroot;		/* exported mapping for uid 0 */
69 	struct statfs	mnt_stat;		/* cache of filesystem stats */
70 	qaddr_t		mnt_data;		/* private data */
71 };
72 
73 /*
74  * Mount flags.
75  */
76 #define	MNT_RDONLY	0x00000001	/* read only filesystem */
77 #define	MNT_SYNCHRONOUS	0x00000002	/* file system written synchronously */
78 #define	MNT_NOEXEC	0x00000004	/* can't exec from filesystem */
79 #define	MNT_NOSUID	0x00000008	/* don't honor setuid bits on fs */
80 #define	MNT_NODEV	0x00000010	/* don't interpret special files */
81 /*
82  * exported mount flags.
83  */
84 #define	MNT_EXPORTED	0x00000100	/* file system is exported */
85 #define	MNT_EXRDONLY	0x00000200	/* exported read only */
86 /*
87  * Flags set by internal operations.
88  */
89 #define	MNT_LOCAL	0x00001000	/* filesystem is stored locally */
90 #define	MNT_QUOTA	0x00002000	/* quotas are enabled on filesystem */
91 /*
92  * Mask of flags that are visible to statfs()
93  */
94 #define	MNT_VISFLAGMASK	0x0000ffff
95 /*
96  * filesystem control flags.
97  *
98  * MNT_MLOCK lock the mount entry so that name lookup cannot proceed
99  * past the mount point.  This keeps the subtree stable during mounts
100  * and unmounts.
101  */
102 #define	MNT_UPDATE	0x00010000	/* not a real mount, just an update */
103 #define	MNT_MLOCK	0x00100000	/* lock so that subtree is stable */
104 #define	MNT_MWAIT	0x00200000	/* someone is waiting for lock */
105 #define MNT_MPBUSY	0x00400000	/* scan of mount point in progress */
106 #define MNT_MPWANT	0x00800000	/* waiting for mount point */
107 #define MNT_UNMOUNT	0x01000000	/* unmount in progress */
108 
109 /*
110  * Operations supported on mounted file system.
111  */
112 struct vfsops {
113 	int	(*vfs_mount)(	/* mp, path, data, ndp */ );
114 	int	(*vfs_start)(	/* mp, flags */ );
115 	int	(*vfs_unmount)(	/* mp, forcibly */ );
116 	int	(*vfs_root)(	/* mp, vpp */ );
117 	int	(*vfs_quotactl)(/* mp, cmd, uid, arg */ );
118 	int	(*vfs_statfs)(	/* mp, sbp */ );
119 	int	(*vfs_sync)(	/* mp, waitfor */ );
120 	int	(*vfs_fhtovp)(	/* mp, fidp, vpp */ );
121 	int	(*vfs_vptofh)(	/* vp, fidp */ );
122 	int	(*vfs_init)(	/* */ );
123 };
124 
125 #define VFS_MOUNT(MP, PATH, DATA, NDP) \
126 	(*(MP)->mnt_op->vfs_mount)(MP, PATH, DATA, NDP)
127 #define VFS_START(MP, FLAGS)	  (*(MP)->mnt_op->vfs_start)(MP, FLAGS)
128 #define VFS_UNMOUNT(MP, FORCIBLY) (*(MP)->mnt_op->vfs_unmount)(MP, FORCIBLY)
129 #define VFS_ROOT(MP, VPP)	  (*(MP)->mnt_op->vfs_root)(MP, VPP)
130 #define VFS_QUOTACTL(MP, C, U, A) (*(MP)->mnt_op->vfs_quotactl)(MP, C, U, A)
131 #define VFS_STATFS(MP, SBP)	  (*(MP)->mnt_op->vfs_statfs)(MP, SBP)
132 #define VFS_SYNC(MP, WAITFOR)	  (*(MP)->mnt_op->vfs_sync)(MP, WAITFOR)
133 #define VFS_FHTOVP(MP, FIDP, VPP) (*(MP)->mnt_op->vfs_fhtovp)(MP, FIDP, VPP)
134 #define	VFS_VPTOFH(VP, FIDP)	  (*(VP)->v_mount->mnt_op->vfs_vptofh)(VP, FIDP)
135 
136 /*
137  * Flags for various system call interfaces.
138  *
139  * forcibly flags for vfs_umount().
140  * waitfor flags to vfs_sync() and getfsstat()
141  */
142 #define MNT_FORCE	1
143 #define MNT_NOFORCE	2
144 #define MNT_WAIT	1
145 #define MNT_NOWAIT	2
146 
147 /*
148  * Generic file handle
149  */
150 struct fhandle {
151 	fsid_t	fh_fsid;	/* File system id of mount point */
152 	struct	fid fh_fid;	/* Id of file */
153 };
154 typedef struct fhandle	fhandle_t;
155 
156 /*
157  * Arguments to mount UFS
158  */
159 struct ufs_args {
160 	char	*fspec;		/* block special device to mount */
161 	int	exflags;	/* export related flags */
162 	uid_t	exroot;		/* mapping for root uid */
163 };
164 
165 #ifdef MFS
166 /*
167  * Arguments to mount MFS
168  */
169 struct mfs_args {
170 	char	*name;		/* name to export for statfs */
171 	caddr_t	base;		/* base address of file system in memory */
172 	u_long size;		/* size of file system */
173 };
174 #endif MFS
175 
176 #ifdef NFS
177 /*
178  * File Handle (32 bytes for version 2), variable up to 1024 for version 3
179  */
180 union nfsv2fh {
181 	fhandle_t	fh_generic;
182 	u_char		fh_bytes[32];
183 };
184 typedef union nfsv2fh nfsv2fh_t;
185 
186 /*
187  * Arguments to mount NFS
188  */
189 struct nfs_args {
190 	struct sockaddr		*addr;		/* file server address */
191 	int			sotype;		/* Socket type */
192 	int			proto;		/* and Protocol */
193 	nfsv2fh_t		*fh;		/* File handle to be mounted */
194 	int			flags;		/* flags */
195 	int			wsize;		/* write size in bytes */
196 	int			rsize;		/* read size in bytes */
197 	int			timeo;		/* initial timeout in .1 secs */
198 	int			retrans;	/* times to retry send */
199 	char			*hostname;	/* server's name */
200 };
201 /*
202  * NFS mount option flags
203  */
204 #define	NFSMNT_SOFT	0x0001	/* soft mount (hard is default) */
205 #define	NFSMNT_WSIZE	0x0002	/* set write size */
206 #define	NFSMNT_RSIZE	0x0004	/* set read size */
207 #define	NFSMNT_TIMEO	0x0008	/* set initial timeout */
208 #define	NFSMNT_RETRANS	0x0010	/* set number of request retrys */
209 #define	NFSMNT_HOSTNAME	0x0020	/* set hostname for error printf */
210 #define	NFSMNT_INT	0x0040	/* allow interrupts on hard mount */
211 #define	NFSMNT_NOCONN	0x0080	/* Don't Connect the socket */
212 #define	NFSMNT_SCKLOCK	0x0100	/* Lock socket against others */
213 #define	NFSMNT_WANTSCK	0x0200	/* Want a socket lock */
214 #define	NFSMNT_SPONGY	0x0400	/* spongy mount (soft for stat and lookup) */
215 #define	NFSMNT_LOCKBITS	(NFSMNT_SCKLOCK | NFSMNT_WANTSCK)
216 #endif NFS
217 
218 #ifdef KERNEL
219 /*
220  * exported vnode operations
221  */
222 extern void	vfs_remove();		/* remove a vfs from mounted vfs list */
223 extern int	vfs_lock();		/* lock a vfs */
224 extern void	vfs_unlock();		/* unlock a vfs */
225 extern struct	mount *getvfs();	/* return vfs given fsid */
226 extern struct	mount *rootfs;		/* ptr to root mount structure */
227 extern struct	vfsops *vfssw[];	/* mount filesystem type switch table */
228 #endif
229