xref: /illumos-gate/usr/src/uts/common/nfs/nfssys.h (revision 82584a069e2e3824df112a1249fa7818c01f9d49)
1 /*
2  * CDDL HEADER START
3  *
4  * The contents of this file are subject to the terms of the
5  * Common Development and Distribution License (the "License").
6  * You may not use this file except in compliance with the License.
7  *
8  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
9  * or http://www.opensolaris.org/os/licensing.
10  * See the License for the specific language governing permissions
11  * and limitations under the License.
12  *
13  * When distributing Covered Code, include this CDDL HEADER in each
14  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
15  * If applicable, add the following below this CDDL HEADER, with the
16  * fields enclosed by brackets "[]" replaced with your own identifying
17  * information: Portions Copyright [yyyy] [name of copyright owner]
18  *
19  * CDDL HEADER END
20  */
21 /*
22  * Copyright 2008 Sun Microsystems, Inc.  All rights reserved.
23  * Use is subject to license terms.
24  */
25 
26 /*	Copyright (c) 1983, 1984, 1985, 1986, 1987, 1988, 1989 AT&T	*/
27 /*	  All Rights Reserved	*/
28 
29 #ifndef	_NFS_NFSSYS_H
30 #define	_NFS_NFSSYS_H
31 
32 #ifdef	__cplusplus
33 extern "C" {
34 #endif
35 
36 /*
37  * Private definitions for the nfssys system call.
38  * Note: <nfs/export.h> and <nfs/nfs.h> must be included before
39  * this file.
40  */
41 
42 /*
43  * Flavors of nfssys call.  Note that OLD_mumble commands are no longer
44  * implemented, but the entries are kept as placeholders for binary
45  * compatibility.
46  */
47 enum nfssys_op	{ OLD_NFS_SVC, OLD_ASYNC_DAEMON, EXPORTFS, OLD_NFS_GETFH,
48     OLD_NFS_CNVT, NFS_REVAUTH, OLD_NFS_FH_TO_FID, OLD_LM_SVC, KILL_LOCKMGR,
49     LOG_FLUSH, SVCPOOL_CREATE, NFS_SVC, LM_SVC, SVCPOOL_WAIT, SVCPOOL_RUN,
50     NFS4_SVC, RDMA_SVC_INIT, NFS4_CLR_STATE, NFS_IDMAP,
51     NFS4_SVC_REQUEST_QUIESCE, NFS_GETFH, NFS4_DSS_SETPATHS,
52     NFS4_DSS_SETPATHS_SIZE, NFS4_EPHEMERAL_MOUNT_TO, MOUNTD_ARGS,
53     NFSCMD_ARGS };
54 
55 struct nfs_svc_args {
56 	int		fd;		/* Connection endpoint */
57 	char		*netid;		/* Identify transport */
58 	struct netbuf	addrmask;	/* Address mask for host */
59 	int		versmin;	/* Min protocol version to offer */
60 	int		versmax;	/* Max protocol version to offer */
61 	int		delegation;	/* NFSv4 delegation on/off? */
62 };
63 
64 #ifdef _SYSCALL32
65 struct nfs_svc_args32 {
66 	int32_t		fd;		/* Connection endpoint */
67 	caddr32_t	netid;		/* Identify transport */
68 	struct netbuf32	addrmask;	/* Address mask for host */
69 	int32_t		versmin;	/* Min protocol version to offer */
70 	int32_t		versmax;	/* Max protocol version to offer */
71 	int32_t		delegation;	/* NFSv4 delegation on/off? */
72 };
73 #endif
74 
75 struct exportfs_args {
76 	char		*dname;
77 	struct exportdata *uex;
78 };
79 
80 #ifdef _SYSCALL32
81 struct exportfs_args32 {
82 	caddr32_t	dname;
83 	caddr32_t	uex;
84 };
85 #endif
86 
87 struct nfs_getfh_args {
88 	char		*fname;
89 	int		vers;
90 	int		*lenp;
91 	char		*fhp;
92 };
93 
94 #ifdef _SYSCALL32
95 struct nfs_getfh_args32 {
96 	caddr32_t	fname;
97 	int32_t		vers;
98 	caddr32_t	lenp;
99 	caddr32_t	fhp;
100 };
101 #endif
102 
103 struct nfs_revauth_args {
104 	int		authtype;
105 	uid_t		uid;
106 };
107 
108 #ifdef _SYSCALL32
109 struct nfs_revauth_args32 {
110 	int32_t		authtype;
111 	uid32_t		uid;
112 };
113 #endif
114 
115 /*
116  * Arguments for establishing lock manager service.  If you change
117  * lm_svc_args, you should increment the version number.  Try to keep
118  * supporting one or more old versions of the args, so that old lockd's
119  * will work with new kernels.
120  */
121 
122 enum lm_fmly  { LM_INET, LM_INET6, LM_LOOPBACK };
123 enum lm_proto { LM_TCP, LM_UDP };
124 
125 struct lm_svc_args {
126 	int		version;	/* keep this first */
127 	int		fd;
128 	enum lm_fmly	n_fmly;		/* protocol family */
129 	enum lm_proto	n_proto;	/* protocol */
130 	dev_t		n_rdev;		/* device ID */
131 	int		debug;		/* debugging level */
132 	time_t		timout;		/* client handle life (asynch RPCs) */
133 	int		grace;		/* secs in grace period */
134 	time_t	retransmittimeout;	/* retransmission interval */
135 };
136 
137 #ifdef _SYSCALL32
138 struct lm_svc_args32 {
139 	int32_t		version;	/* keep this first */
140 	int32_t		fd;
141 	enum lm_fmly	n_fmly;		/* protocol family */
142 	enum lm_proto	n_proto;	/* protocol */
143 	dev32_t		n_rdev;		/* device ID */
144 	int32_t		debug;		/* debugging level */
145 	time32_t	timout;		/* client handle life (asynch RPCs) */
146 	int32_t		grace;		/* secs in grace period */
147 	time32_t	retransmittimeout;	/* retransmission interval */
148 };
149 #endif
150 
151 #define	LM_SVC_CUR_VERS	30		/* current lm_svc_args vers num */
152 
153 /*
154  * Arguments for nfslog flush service.
155  */
156 struct nfsl_flush_args {
157 	int		version;
158 	int		directive;
159 	char		*buff;		/* buffer to flush/rename */
160 	int		buff_len;	/* includes terminating '\0' */
161 };
162 
163 #define	NFSL_FLUSH_ARGS_VERS 1		/* current nfsl_flush_args vers num */
164 
165 #ifdef _SYSCALL32
166 struct nfsl_flush_args32 {
167 	int32_t		version;
168 	int32_t		directive;
169 	caddr32_t	buff;		/* buffer to flush/rename */
170 	int32_t		buff_len;	/* includes terminating '\0' */
171 };
172 #endif
173 
174 /*
175  * Arguments for initialising RDMA service.
176  */
177 struct rdma_svc_args {
178 	uint32_t	poolid;		/* Thread Pool ID */
179 	char		*netid;		/* Network Identifier */
180 	int		nfs_versmin;	/* Min NFS version to offer */
181 	int		nfs_versmax;	/* Max NFS version to offer */
182 	int		delegation;	/* NFSv4 delegation on/off? */
183 };
184 
185 #ifdef _SYSCALL32
186 struct rdma_svc_args32 {
187 	uint32_t	poolid;		/* Thread Pool ID */
188 	caddr32_t	netid;		/* Network Identifier */
189 	int32_t		nfs_versmin;	/* Min NFS version to offer */
190 	int32_t		nfs_versmax;	/* Max NFS version to offer */
191 	int32_t		delegation;	/* NFSv4 delegation on/off? */
192 };
193 #endif
194 
195 
196 #define	NFS4_CLRST_VERSION	1
197 struct nfs4clrst_args {
198 	int		vers;
199 	int		addr_type;
200 	void		*ap;
201 };
202 
203 #ifdef _SYSCALL32
204 struct nfs4clrst_args32 {
205 	int32_t		vers;
206 	int32_t		addr_type;
207 	caddr32_t	ap;
208 };
209 #endif
210 
211 struct nfsidmap_args {
212 	uint_t		state;	/* Flushes caches, set state up 1 or down 0 */
213 	uint_t		did;	/* Door id to upcall */
214 };
215 
216 #define	NFSL_ALL	0x01		/* Flush all buffers */
217 #define	NFSL_RENAME	0x02		/* Rename buffer(s) */
218 #define	NFSL_SYNC	0x04		/* Perform operation synchronously? */
219 
220 #ifdef _KERNEL
221 union nfssysargs {
222 	struct exportfs_args	*exportfs_args_u;	/* exportfs args */
223 	struct nfs_getfh_args	*nfs_getfh_args_u;	/* nfs_getfh args */
224 	struct nfs_svc_args	*nfs_svc_args_u;	/* nfs_svc args */
225 	struct rdma_svc_args	*rdma_svc_args_u;	/* rdma_svc args */
226 	struct nfs_revauth_args	*nfs_revauth_args_u;	/* nfs_revauth args */
227 	struct lm_svc_args	*lm_svc_args_u;		/* lm_svc args */
228 	/* kill_lockmgr args: none */
229 	struct nfsl_flush_args	*nfsl_flush_args_u;	/* nfsl_flush args */
230 	struct svcpool_args	*svcpool_args_u;	/* svcpool args */
231 	struct nfs4clrst_args   *nfs4clrst_u;		/* nfs4 clear state */
232 	struct nfsidmap_args	*nfsidmap_u;		/* nfsidmap */
233 };
234 
235 struct nfssysa {
236 	enum nfssys_op		opcode;	/* operation discriminator */
237 	union nfssysargs	arg;	/* syscall-specific arg pointer */
238 };
239 #define	nfssysarg_exportfs	arg.exportfs_args_u
240 #define	nfssysarg_getfh		arg.nfs_getfh_args_u
241 #define	nfssysarg_svc		arg.nfs_svc_args_u
242 #define	nfssysarg_rdmastart	arg.rdma_svc_args_u
243 #define	nfssysarg_revauth	arg.nfs_revauth_args_u
244 #define	nfssysarg_lmsvc		arg.lm_svc_args_u
245 #define	nfssysarg_nfslflush	arg.nfsl_flush_args_u
246 #define	nfssysarg_svcpool	arg.svcpool_args_u
247 #define	nfssysarg_nfs4clrst	arg.nfs4clrst_u
248 #define	nfssysarg_nfsidmap	arg.nfsidmap_u
249 
250 #ifdef _SYSCALL32
251 union nfssysargs32 {
252 	caddr32_t exportfs_args_u;	/* exportfs args */
253 	caddr32_t nfs_getfh_args_u;	/* nfs_getfh args */
254 	caddr32_t nfs_svc_args_u;	/* nfs_svc args */
255 	caddr32_t rdma_svc_args_u;	/* rdma_start args */
256 	caddr32_t nfs_revauth_args_u;	/* nfs_revauth args */
257 	caddr32_t lm_svc_args_u;	/* lm_svc args */
258 	/* kill_lockmgr args: none */
259 	caddr32_t nfsl_flush_args_u;	/* nfsl_flush args */
260 	caddr32_t svcpool_args_u;
261 	caddr32_t nfs4clrst_u;
262 };
263 struct nfssysa32 {
264 	enum nfssys_op		opcode;	/* operation discriminator */
265 	union nfssysargs32	arg;	/* syscall-specific arg pointer */
266 };
267 #endif /* _SYSCALL32 */
268 
269 #endif	/* _KERNEL */
270 
271 struct nfs4_svc_args {
272 	int		fd;		/* Connection endpoint */
273 	int		cmd;
274 	char		*netid;		/* Transport Identifier */
275 	char		*addr;		/* Universal Address */
276 	char		*protofmly;	/* Protocol Family */
277 	char		*proto;		/* Protocol, eg. "tcp" */
278 	struct netbuf	addrmask;	/* Address mask for host */
279 };
280 
281 #ifdef _SYSCALL32
282 struct nfs4_svc_args32 {
283 	int32_t		fd;
284 	int32_t		cmd;
285 	caddr32_t	netid;
286 	caddr32_t	addr;
287 	caddr32_t	protofmly;
288 	caddr32_t	proto;
289 	struct netbuf32	addrmask;
290 };
291 #endif
292 
293 #define	NFS4_KRPC_START	1
294 #define	NFS4_SETPORT	2
295 #define	NFS4_DQUERY	4
296 
297 /* DSS: distributed stable storage */
298 #define	NFS4_DSS_STATE_LEAF	"v4_state"
299 #define	NFS4_DSS_OLDSTATE_LEAF	"v4_oldstate"
300 #define	NFS4_DSS_DIR_MODE	0755
301 #define	NFS4_DSS_NVPAIR_NAME	"dss_pathname_array"
302 /* default storage dir */
303 #define	NFS4_DSS_VAR_DIR	"/var/nfs"
304 
305 #ifdef _KERNEL
306 
307 #include <sys/systm.h>		/* for rval_t typedef */
308 
309 extern int	nfssys(enum nfssys_op opcode, void *arg);
310 extern int	exportfs(struct exportfs_args *, model_t, cred_t *);
311 extern int	nfs_getfh(struct nfs_getfh_args *, model_t, cred_t *);
312 extern int	nfs_svc(struct nfs_svc_args *, model_t);
313 extern int	lm_svc(struct lm_svc_args *uap);
314 extern int	lm_shutdown(void);
315 extern int	nfsl_flush(struct nfsl_flush_args *, model_t);
316 extern int	nfs4_svc(struct nfs4_svc_args *, model_t);
317 extern int 	rdma_start(struct rdma_svc_args *);
318 extern void	rfs4_clear_client_state(struct nfs4clrst_args *);
319 extern void	nfs_idmap_args(struct nfsidmap_args *);
320 extern void	nfs4_ephemeral_set_mount_to(uint_t);
321 extern void	mountd_args(uint_t);
322 #endif
323 
324 #ifdef	__cplusplus
325 }
326 #endif
327 
328 #endif	/* _NFS_NFSSYS_H */
329