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