xref: /illumos-gate/usr/src/uts/common/nfs/nfs_cmd.h (revision 6523a3aa7f325d64841382707603be7a86e68147)
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 /*
23  * Copyright 2010 Sun Microsystems, Inc.  All rights reserved.
24  * Use is subject to license terms.
25  */
26 
27 /*	Copyright (c) 1983, 1984, 1985, 1986, 1987, 1988, 1989 AT&T	*/
28 /*	  All Rights Reserved	*/
29 
30 /*
31  * Copyright 2018 Nexenta Systems, Inc.
32  */
33 
34 #ifndef	_NFS_CMD_H
35 #define	_NFS_CMD_H
36 
37 #ifdef	__cplusplus
38 extern "C" {
39 #endif
40 
41 #include <sys/types.h>
42 #include <sys/param.h>
43 #include <sys/kiconv.h>
44 
45 #define	KICONV_MAX_CODENAME_LEN	63 /* copied from sys/kiconv.h */
46 
47 #define	NFSCMD_VERS_1	1
48 #define	NFSCMD_VERSION	NFSCMD_VERS_1
49 
50 typedef enum { NFSCMD_CHARMAP_LOOKUP, NFSCMD_ERROR } nfscmd_t;
51 typedef enum { NFSCMD_ERR_SUCCESS, NFSCMD_ERR_BADCMD, NFSCMD_ERR_NOTFOUND,
52     NFSCMD_ERR_FAIL, NFSCMD_ERR_DROP, NFSCMD_ERR_NOMEM } nfscmd_err_t;
53 #define	NFSCMD_ERR_RET	0x100000
54 
55 typedef struct nfscmd_arg {
56 	uint32_t	version;
57 	nfscmd_t	cmd;
58 	union {
59 		struct {
60 			char path[MAXPATHLEN];
61 			struct sockaddr addr;
62 		} charmap;
63 	} arg;
64 } nfscmd_arg_t;
65 
66 typedef struct nfscmd_res {
67 	uint32_t	version;
68 	uint32_t	cmd;
69 	nfscmd_err_t	error;
70 	union {
71 		struct {
72 		    char	codeset[KICONV_MAX_CODENAME_LEN + 1];
73 		    uint32_t	apply;
74 		} charmap;
75 	} result;
76 } nfscmd_res_t;
77 
78 #ifdef _KERNEL
79 
80 #define	NFSCMD_CONV_INBOUND	1
81 #define	NFSCMD_CONV_OUTBOUND	0
82 
83 extern int nfscmd_send(nfscmd_arg_t *, nfscmd_res_t *);
84 extern struct charset_cache *nfscmd_findmap(struct exportinfo *,
85     struct sockaddr *);
86 extern char *nfscmd_convname(struct sockaddr *, struct exportinfo *,
87     char *, int, size_t);
88 
89 extern char *nfscmd_convdirent(struct sockaddr *, struct exportinfo *, char *,
90     size_t, enum nfsstat3 *);
91 extern size_t nfscmd_convdirplus(struct sockaddr *, struct exportinfo *, char *,
92     size_t, size_t, char **);
93 extern size_t nfscmd_countents(char *, size_t);
94 extern size_t nfscmd_dropped_entrysize(struct dirent64 *, size_t, size_t);
95 
96 extern void nfscmd_init(void);
97 extern void nfscmd_fini(void);
98 
99 #endif
100 
101 #ifdef	__cplusplus
102 }
103 #endif
104 
105 #endif	/* _NFS_CMD_H */
106