xref: /original-bsd/sys/sys/mount.h (revision d54be081)
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.22 (Berkeley) 06/03/91
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 /*
47  * File system types.
48  */
49 #define	MOUNT_NONE	0
50 #define	MOUNT_UFS	1
51 #define	MOUNT_NFS	2
52 #define	MOUNT_MFS	3
53 #define	MOUNT_PC	4
54 #define	MOUNT_MAXTYPE	4
55 
56 /*
57  * Structure per mounted file system.
58  * Each mounted file system has an array of
59  * operations and an instance record.
60  * The file systems are put on a doubly linked list.
61  */
62 struct mount {
63 	struct mount	*mnt_next;		/* next in mount list */
64 	struct mount	*mnt_prev;		/* prev in mount list */
65 	struct vfsops	*mnt_op;		/* operations on fs */
66 	struct vnode	*mnt_vnodecovered;	/* vnode we mounted on */
67 	struct vnode	*mnt_mounth;		/* list of vnodes this mount */
68 	int		mnt_flag;		/* flags */
69 	uid_t		mnt_exroot;		/* exported mapping for uid 0 */
70 	struct statfs	mnt_stat;		/* cache of filesystem stats */
71 	qaddr_t		mnt_data;		/* private data */
72 };
73 
74 /*
75  * Mount flags.
76  */
77 #define	MNT_RDONLY	0x00000001	/* read only filesystem */
78 #define	MNT_SYNCHRONOUS	0x00000002	/* file system written synchronously */
79 #define	MNT_NOEXEC	0x00000004	/* can't exec from filesystem */
80 #define	MNT_NOSUID	0x00000008	/* don't honor setuid bits on fs */
81 #define	MNT_NODEV	0x00000010	/* don't interpret special files */
82 
83 /*
84  * exported mount flags.
85  */
86 #define	MNT_EXPORTED	0x00000100	/* file system is exported */
87 #define	MNT_EXRDONLY	0x00000200	/* exported read only */
88 
89 /*
90  * Flags set by internal operations.
91  */
92 #define	MNT_LOCAL	0x00001000	/* filesystem is stored locally */
93 #define	MNT_QUOTA	0x00002000	/* quotas are enabled on filesystem */
94 
95 /*
96  * Mask of flags that are visible to statfs()
97  */
98 #define	MNT_VISFLAGMASK	0x0000ffff
99 
100 /*
101  * filesystem control flags.
102  *
103  * MNT_MLOCK lock the mount entry so that name lookup cannot proceed
104  * past the mount point.  This keeps the subtree stable during mounts
105  * and unmounts.
106  */
107 #define	MNT_UPDATE	0x00010000	/* not a real mount, just an update */
108 #define	MNT_MLOCK	0x00100000	/* lock so that subtree is stable */
109 #define	MNT_MWAIT	0x00200000	/* someone is waiting for lock */
110 #define MNT_MPBUSY	0x00400000	/* scan of mount point in progress */
111 #define MNT_MPWANT	0x00800000	/* waiting for mount point */
112 #define MNT_UNMOUNT	0x01000000	/* unmount in progress */
113 
114 /*
115  * Operations supported on mounted file system.
116  */
117 #ifdef KERNEL
118 #ifdef __STDC__
119 struct nameidata;
120 #endif
121 
122 struct vfsops {
123 	int	(*vfs_mount)	__P((struct mount *mp, char *path, caddr_t data,
124 				    struct nameidata *ndp, struct proc *p));
125 	int	(*vfs_start)	__P((struct mount *mp, int flags,
126 				    struct proc *p));
127 	int	(*vfs_unmount)	__P((struct mount *mp, int mntflags,
128 				    struct proc *p));
129 	int	(*vfs_root)	__P((struct mount *mp, struct vnode **vpp));
130 			/* int uid,		should be uid_t */
131 	int	(*vfs_quotactl)	__P((struct mount *mp, int cmds, int uid,
132 				    caddr_t arg, struct proc *p));
133 	int	(*vfs_statfs)	__P((struct mount *mp, struct statfs *sbp,
134 				    struct proc *p));
135 	int	(*vfs_sync)	__P((struct mount *mp, int waitfor));
136 	int	(*vfs_fhtovp)	__P((struct mount *mp, struct fid *fhp,
137 				    struct vnode **vpp));
138 	int	(*vfs_vptofh)	__P((struct vnode *vp, struct fid *fhp));
139 	int	(*vfs_init)	__P(());
140 };
141 
142 #define VFS_MOUNT(MP, PATH, DATA, NDP, P) \
143 	(*(MP)->mnt_op->vfs_mount)(MP, PATH, DATA, NDP, P)
144 #define VFS_START(MP, FLAGS, P)	  (*(MP)->mnt_op->vfs_start)(MP, FLAGS, P)
145 #define VFS_UNMOUNT(MP, FORCE, P) (*(MP)->mnt_op->vfs_unmount)(MP, FORCE, P)
146 #define VFS_ROOT(MP, VPP)	  (*(MP)->mnt_op->vfs_root)(MP, VPP)
147 #define VFS_QUOTACTL(MP,C,U,A,P)  (*(MP)->mnt_op->vfs_quotactl)(MP, C, U, A, P)
148 #define VFS_STATFS(MP, SBP, P)	  (*(MP)->mnt_op->vfs_statfs)(MP, SBP, P)
149 #define VFS_SYNC(MP, WAITFOR)	  (*(MP)->mnt_op->vfs_sync)(MP, WAITFOR)
150 #define VFS_FHTOVP(MP, FIDP, VPP) (*(MP)->mnt_op->vfs_fhtovp)(MP, FIDP, VPP)
151 #define	VFS_VPTOFH(VP, FIDP)	  (*(VP)->v_mount->mnt_op->vfs_vptofh)(VP, FIDP)
152 #endif /* KERNEL */
153 
154 /*
155  * Flags for various system call interfaces.
156  *
157  * forcibly flags for vfs_umount().
158  * waitfor flags to vfs_sync() and getfsstat()
159  */
160 #define MNT_FORCE	1
161 #define MNT_NOFORCE	2
162 #define MNT_WAIT	1
163 #define MNT_NOWAIT	2
164 
165 /*
166  * Generic file handle
167  */
168 struct fhandle {
169 	fsid_t	fh_fsid;	/* File system id of mount point */
170 	struct	fid fh_fid;	/* Id of file */
171 };
172 typedef struct fhandle	fhandle_t;
173 
174 /*
175  * Arguments to mount UFS
176  */
177 struct ufs_args {
178 	char	*fspec;		/* block special device to mount */
179 	int	exflags;	/* export related flags */
180 	uid_t	exroot;		/* mapping for root uid */
181 };
182 
183 #ifdef MFS
184 /*
185  * Arguments to mount MFS
186  */
187 struct mfs_args {
188 	char	*name;		/* name to export for statfs */
189 	caddr_t	base;		/* base address of file system in memory */
190 	u_long size;		/* size of file system */
191 };
192 #endif MFS
193 
194 #ifdef NFS
195 /*
196  * File Handle (32 bytes for version 2), variable up to 1024 for version 3
197  */
198 union nfsv2fh {
199 	fhandle_t	fh_generic;
200 	u_char		fh_bytes[32];
201 };
202 typedef union nfsv2fh nfsv2fh_t;
203 
204 /*
205  * Arguments to mount NFS
206  */
207 struct nfs_args {
208 	struct sockaddr	*addr;		/* file server address */
209 	int		sotype;		/* Socket type */
210 	int		proto;		/* and Protocol */
211 	nfsv2fh_t	*fh;		/* File handle to be mounted */
212 	int		flags;		/* flags */
213 	int		wsize;		/* write size in bytes */
214 	int		rsize;		/* read size in bytes */
215 	int		timeo;		/* initial timeout in .1 secs */
216 	int		retrans;	/* times to retry send */
217 	char		*hostname;	/* server's name */
218 };
219 /*
220  * NFS mount option flags
221  */
222 #define	NFSMNT_SOFT	0x0001	/* soft mount (hard is default) */
223 #define	NFSMNT_WSIZE	0x0002	/* set write size */
224 #define	NFSMNT_RSIZE	0x0004	/* set read size */
225 #define	NFSMNT_TIMEO	0x0008	/* set initial timeout */
226 #define	NFSMNT_RETRANS	0x0010	/* set number of request retrys */
227 #define	NFSMNT_HOSTNAME	0x0020	/* set hostname for error printf */
228 #define	NFSMNT_INT	0x0040	/* allow interrupts on hard mount */
229 #define	NFSMNT_NOCONN	0x0080	/* Don't Connect the socket */
230 #define	NFSMNT_SCKLOCK	0x0100	/* Lock socket against others */
231 #define	NFSMNT_WANTSCK	0x0200	/* Want a socket lock */
232 #define	NFSMNT_SPONGY	0x0400	/* spongy mount (soft for stat and lookup) */
233 #define	NFSMNT_COMPRESS	0x0800	/* Compress nfs rpc xdr */
234 #define	NFSMNT_LOCKBITS	(NFSMNT_SCKLOCK | NFSMNT_WANTSCK)
235 #endif NFS
236 
237 #ifdef KERNEL
238 /*
239  * exported vnode operations
240  */
241 void	vfs_remove __P((struct mount *mp)); /* remove a vfs from mount list */
242 int	vfs_lock __P((struct mount *mp));   /* lock a vfs */
243 void	vfs_unlock __P((struct mount *mp)); /* unlock a vfs */
244 struct	mount *getvfs __P((fsid_t *fsid));  /* return vfs given fsid */
245 struct	mount *rootfs;			    /* ptr to root mount structure */
246 struct	vfsops *vfssw[];		    /* mount filesystem type table */
247 
248 #else /* KERNEL */
249 
250 #include <sys/cdefs.h>
251 
252 __BEGIN_DECLS
253 int	fstatfs __P((int, struct statfs *));
254 int	getfh __P((const char *, fhandle_t *));
255 int	getfsstat __P((struct statfs *, long, int));
256 int	getmntinfo __P((struct statfs **, int));
257 int	mount __P((int, const char *, int, void *));
258 int	statfs __P((const char *, struct statfs *));
259 int	unmount __P((const char *, int));
260 __END_DECLS
261 
262 #endif /* KERNEL */
263