xref: /netbsd-src/sys/nfs/nfsmount.h (revision 9fbd88883c38d0c0fbfcbe66d76fe6b0fab3f9de)
1 /*	$NetBSD: nfsmount.h,v 1.21 2001/09/15 16:13:02 chs Exp $	*/
2 
3 /*
4  * Copyright (c) 1989, 1993
5  *	The Regents of the University of California.  All rights reserved.
6  *
7  * This code is derived from software contributed to Berkeley by
8  * Rick Macklem at The University of Guelph.
9  *
10  * Redistribution and use in source and binary forms, with or without
11  * modification, are permitted provided that the following conditions
12  * are met:
13  * 1. Redistributions of source code must retain the above copyright
14  *    notice, this list of conditions and the following disclaimer.
15  * 2. Redistributions in binary form must reproduce the above copyright
16  *    notice, this list of conditions and the following disclaimer in the
17  *    documentation and/or other materials provided with the distribution.
18  * 3. All advertising materials mentioning features or use of this software
19  *    must display the following acknowledgement:
20  *	This product includes software developed by the University of
21  *	California, Berkeley and its contributors.
22  * 4. Neither the name of the University nor the names of its contributors
23  *    may be used to endorse or promote products derived from this software
24  *    without specific prior written permission.
25  *
26  * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
27  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
28  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
29  * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
30  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
31  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
32  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
33  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
34  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
35  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
36  * SUCH DAMAGE.
37  *
38  *	@(#)nfsmount.h	8.3 (Berkeley) 3/30/95
39  */
40 
41 
42 #ifndef _NFS_NFSMOUNT_H_
43 #define _NFS_NFSMOUNT_H_
44 
45 /*
46  * Arguments to mount NFS
47  */
48 #define NFS_ARGSVERSION	3		/* change when nfs_args changes */
49 struct nfs_args {
50 	int		version;	/* args structure version number */
51 	struct sockaddr	*addr;		/* file server address */
52 	int		addrlen;	/* length of address */
53 	int		sotype;		/* Socket type */
54 	int		proto;		/* and Protocol */
55 	u_char		*fh;		/* File handle to be mounted */
56 	int		fhsize;		/* Size, in bytes, of fh */
57 	int		flags;		/* flags */
58 	int		wsize;		/* write size in bytes */
59 	int		rsize;		/* read size in bytes */
60 	int		readdirsize;	/* readdir size in bytes */
61 	int		timeo;		/* initial timeout in .1 secs */
62 	int		retrans;	/* times to retry send */
63 	int		maxgrouplist;	/* Max. size of group list */
64 	int		readahead;	/* # of blocks to readahead */
65 	int		leaseterm;	/* Term (sec) of lease */
66 	int		deadthresh;	/* Retrans threshold */
67 	char		*hostname;	/* server's name */
68 };
69 
70 /*
71  * NFS mount option flags (nm_flag)
72  */
73 #define	NFSMNT_SOFT		0x00000001  /* soft mount (hard is default) */
74 #define	NFSMNT_WSIZE		0x00000002  /* set write size */
75 #define	NFSMNT_RSIZE		0x00000004  /* set read size */
76 #define	NFSMNT_TIMEO		0x00000008  /* set initial timeout */
77 #define	NFSMNT_RETRANS		0x00000010  /* set number of request retries */
78 #define	NFSMNT_MAXGRPS		0x00000020  /* set maximum grouplist size */
79 #define	NFSMNT_INT		0x00000040  /* allow interrupts on hard mount */
80 #define	NFSMNT_NOCONN		0x00000080  /* Don't Connect the socket */
81 #define	NFSMNT_NQNFS		0x00000100  /* Use Nqnfs protocol */
82 #define	NFSMNT_NFSV3		0x00000200  /* Use NFS Version 3 protocol */
83 #define	NFSMNT_KERB		0x00000400  /* Use Kerberos authentication */
84 #define	NFSMNT_DUMBTIMR		0x00000800  /* Don't estimate rtt dynamically */
85 #define	NFSMNT_LEASETERM	0x00001000  /* set lease term (nqnfs) */
86 #define	NFSMNT_READAHEAD	0x00002000  /* set read ahead */
87 #define	NFSMNT_DEADTHRESH	0x00004000  /* set dead server retry thresh */
88 #define	NFSMNT_RESVPORT		0x00008000  /* Allocate a reserved port */
89 #define	NFSMNT_RDIRPLUS		0x00010000  /* Use Readdirplus for V3 */
90 #define	NFSMNT_READDIRSIZE	0x00020000  /* Set readdir size */
91 #define NFSMNT_XLATECOOKIE	0x00040000  /* 32<->64 dir cookie xlation */
92 
93 /*
94  * NFS internal flags (nm_iflag) */
95 
96 #define NFSMNT_HASWRITEVERF	0x00000001  /* Has write verifier for V3 */
97 #define NFSMNT_GOTPATHCONF	0x00000002  /* Got the V3 pathconf info */
98 #define NFSMNT_GOTFSINFO	0x00000004  /* Got the V3 fsinfo */
99 #define	NFSMNT_MNTD		0x00000008  /* Mnt server for mnt point */
100 #define	NFSMNT_DISMINPROG	0x00000010  /* Dismount in progress */
101 #define	NFSMNT_DISMNT		0x00000020  /* Dismounted */
102 #define	NFSMNT_SNDLOCK		0x00000040  /* Send socket lock */
103 #define	NFSMNT_WANTSND		0x00000080  /* Want above */
104 #define	NFSMNT_RCVLOCK		0x00000100  /* Rcv socket lock */
105 #define	NFSMNT_WANTRCV		0x00000200  /* Want above */
106 #define	NFSMNT_WAITAUTH		0x00000400  /* Wait for authentication */
107 #define	NFSMNT_HASAUTH		0x00000800  /* Has authenticator */
108 #define	NFSMNT_WANTAUTH		0x00001000  /* Wants an authenticator */
109 #define	NFSMNT_AUTHERR		0x00002000  /* Authentication error */
110 #define NFSMNT_SWAPCOOKIE	0x00004000  /* XDR encode dir cookies */
111 
112 #ifdef _KERNEL
113 /*
114  * Mount structure.
115  * One allocated on every NFS mount.
116  * Holds NFS specific information for mount.
117  */
118 struct	nfsmount {
119 	int	nm_flag;		/* Flags for soft/hard... */
120 	struct	mount *nm_mountp;	/* Vfs structure for this filesystem */
121 	int	nm_numgrps;		/* Max. size of groupslist */
122 	struct vnode *nm_vnode;
123 	struct	socket *nm_so;		/* Rpc socket */
124 	int	nm_sotype;		/* Type of socket */
125 	int	nm_soproto;		/* and protocol */
126 	int	nm_soflags;		/* pr_flags for socket protocol */
127 	struct	mbuf *nm_nam;		/* Addr of server */
128 	int	nm_timeo;		/* Init timer for NFSMNT_DUMBTIMR */
129 	int	nm_retry;		/* Max retries */
130 	int	nm_srtt[4];		/* Timers for rpcs */
131 	int	nm_sdrtt[4];
132 	int	nm_sent;		/* Request send count */
133 	int	nm_cwnd;		/* Request send window */
134 	int	nm_timeouts;		/* Request timeouts */
135 	int	nm_deadthresh;		/* Threshold of timeouts-->dead server*/
136 	int	nm_rsize;		/* Max size of read rpc */
137 	int	nm_wsize;		/* Max size of write rpc */
138 	int	nm_readdirsize;		/* Size of a readdir rpc */
139 	int	nm_readahead;		/* Num. of blocks to readahead */
140 	int	nm_leaseterm;		/* Term (sec) for NQNFS lease */
141 	CIRCLEQ_HEAD(, nfsnode) nm_timerhead; /* Head of lease timer queue */
142 	struct vnode *nm_inprog;	/* Vnode in prog by nqnfs_clientd() */
143 	uid_t	nm_authuid;		/* Uid for authenticator */
144 	int	nm_authtype;		/* Authenticator type */
145 	int	nm_authlen;		/* and length */
146 	char	*nm_authstr;		/* Authenticator string */
147 	char	*nm_verfstr;		/* and the verifier */
148 	int	nm_verflen;
149 	u_char	nm_verf[NFSX_V3WRITEVERF]; /* V3 write verifier */
150 	NFSKERBKEY_T nm_key;		/* and the session key */
151 	int	nm_numuids;		/* Number of nfsuid mappings */
152 	TAILQ_HEAD(, nfsuid) nm_uidlruhead; /* Lists of nfsuid mappings */
153 	LIST_HEAD(, nfsuid) nm_uidhashtbl[NFS_MUIDHASHSIZ];
154 	TAILQ_HEAD(, buf) nm_bufq;      /* async io buffer queue */
155 	short	nm_bufqlen;		/* number of buffers in queue */
156 	short	nm_bufqwant;		/* process wants to add to the queue */
157 	int	nm_bufqiods;		/* number of iods processing queue */
158 	u_int64_t nm_maxfilesize;	/* maximum file size */
159 	int	nm_iflag;		/* internal flags */
160 	int	nm_waiters;		/* number of waiting listeners.. */
161 };
162 
163 /*
164  * Convert mount ptr to nfsmount ptr.
165  */
166 #define VFSTONFS(mp)	((struct nfsmount *)((mp)->mnt_data))
167 
168 /*
169  * Prototypes for NFS mount operations
170  */
171 int	nfs_mount __P((struct mount *mp, const char *path, void *data,
172 		struct nameidata *ndp, struct proc *p));
173 int	mountnfs __P((struct nfs_args *argp, struct mount *mp,
174 		struct mbuf *nam, const char *pth, const char *hst,
175 		struct vnode **vpp, struct proc *p));
176 int	nfs_mountroot __P((void));
177 void	nfs_decode_args __P((struct nfsmount *, struct nfs_args *));
178 int	nfs_start __P((struct mount *mp, int flags, struct proc *p));
179 int	nfs_unmount __P((struct mount *mp, int mntflags, struct proc *p));
180 int	nfs_root __P((struct mount *mp, struct vnode **vpp));
181 int	nfs_quotactl __P((struct mount *mp, int cmds, uid_t uid, caddr_t arg,
182 		struct proc *p));
183 int	nfs_statfs __P((struct mount *mp, struct statfs *sbp, struct proc *p));
184 int	nfs_sync __P((struct mount *mp, int waitfor, struct ucred *cred,
185 		struct proc *p));
186 int	nfs_vget __P((struct mount *, ino_t, struct vnode **));
187 int	nfs_fhtovp __P((struct mount *mp, struct fid *fhp, struct vnode **vpp));
188 int	nfs_checkexp __P((struct mount *mp, struct mbuf *nam, int *exflagsp,
189 		struct ucred **credanonp));
190 int	nfs_vptofh __P((struct vnode *vp, struct fid *fhp));
191 int	nfs_fsinfo __P((struct nfsmount *, struct vnode *, struct ucred *,
192 			struct proc *));
193 void	nfs_vfs_init __P((void));
194 void	nfs_vfs_reinit __P((void));
195 void	nfs_vfs_done __P((void));
196 
197 /*
198  * Prototypes for miscellaneous exported NFS functions.
199  */
200 void	nfs_init __P((void));
201 
202 #endif /* _KERNEL */
203 
204 #endif
205