xref: /titanic_50/usr/src/uts/common/nfs/nfsid_map.h (revision 174bc6499d233e329ecd3d98a880a7b07df16bfa)
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 2009 Sun Microsystems, Inc.  All rights reserved.
23  * Use is subject to license terms.
24  */
25 
26 #ifndef _NFSID_MAP_H
27 #define	_NFSID_MAP_H
28 
29 #ifndef _KERNEL
30 #include <stddef.h>
31 #endif
32 #include <sys/sysmacros.h>
33 #include <sys/types.h>
34 
35 /*
36  * NFSv4 id mapping daemon
37  *
38  * This daemon is used by the kernel to map strings in the form
39  * "user@dns_domain" from an integer form or vice-versa.  The daemon
40  * uses the system configured name services for the mapping.
41  *
42  * The status results determines if a mapping was successful.
43  *
44  * The mapping is cached in the kernel, so that expensive upcalls are
45  * reduced to a minimum.
46  */
47 
48 #ifdef	__cplusplus
49 extern "C" {
50 #endif
51 
52 /*
53  * mapid commands
54  */
55 #define	NFSMAPID_STR_UID	1
56 #define	NFSMAPID_UID_STR	2
57 #define	NFSMAPID_STR_GID	3
58 #define	NFSMAPID_GID_STR	4
59 #define	NFSMAPID_SRV_NETINFO	5
60 
61 /*
62  * We are passing in arguments in a variable length struct
63  * similar to a dirent_t. We break apart a utf8string into
64  * its components and allocate a struct long enough to hold
65  * the string and a NUL terminator.  The caller must ensure the
66  * terminator is set.
67  */
68 struct mapid_arg {
69 	uint_t	cmd;
70 	union {
71 		uid_t		uid;
72 		gid_t		gid;
73 		int		len;
74 	} u_arg;
75 	char str[1];
76 };
77 typedef struct mapid_arg mapid_arg_t;
78 
79 /*
80  * The actual required size of the args, rounded up to a 64 bit boundary
81  */
82 #define	MAPID_ARG_LEN(str_length)	\
83 	((offsetof(mapid_arg_t, str[0]) + 1 + (str_length) + 7) & ~ 7)
84 
85 /*
86  * Return status codes
87  */
88 #define	NFSMAPID_OK		0
89 
90 /*
91  * numeric string is mapped to its literal number
92  */
93 #define	NFSMAPID_NUMSTR		1
94 
95 /*
96  * Value cannot be mapped, badly formed string
97  */
98 #define	NFSMAPID_UNMAPPABLE	2
99 
100 /*
101  * Caller provided invalid arguments
102  */
103 #define	NFSMAPID_INVALID	3
104 
105 /*
106  * Internal error in daemon e.g. out of memory, can't return result
107  */
108 #define	NFSMAPID_INTERNAL	4
109 
110 /*
111  * Incorrect domain used
112  */
113 #define	NFSMAPID_BADDOMAIN	5
114 
115 /*
116  * Out of range uid/gid
117  */
118 #define	NFSMAPID_BADID		6
119 
120 /*
121  * User or group cannot be found in nameservice
122  */
123 #define	NFSMAPID_NOTFOUND	7
124 
125 /*
126  * Similar to the arguments, the result is variable length.
127  * The returner must ensure the string terminator is set.
128  */
129 struct mapid_res {
130 	uint_t	status;
131 	union {
132 		uid_t		uid;
133 		gid_t		gid;
134 		int		len;
135 	} u_res;
136 	char str[1];
137 };
138 typedef struct mapid_res mapid_res_t;
139 
140 /*
141  * The actual required size of the result, rounded up to a 64 bit boundary
142  */
143 #define	MAPID_RES_LEN(str_length)	\
144 	((offsetof(mapid_res_t, str[0]) + 1 + (str_length) + 7) & ~ 7)
145 
146 /*
147  * Support for referral name resolution by the NFS client
148  */
149 typedef struct refd_door_args {
150 	int		cmd;		/* NFS4_FS_LOCATIONS/NFS4_SRV_NETINFO */
151 	int		xdr_len;	/* Length of xdr Buffer */
152 	char		xdr_arg[1];	/* Buffer holding xdr encoded data */
153 } refd_door_args_t;
154 
155 typedef struct refd_door_res {
156 	int		res_status;
157 	int		xdr_len;
158 	char		xdr_res[1];
159 } refd_door_res_t;
160 
161 #ifdef _SYSCALL32
162 typedef struct refd_door_args32 {
163 	int32_t		cmd;
164 	int32_t		xdr_len;
165 	char		xdr_arg[1];
166 } refd_door_args32_t;
167 
168 typedef struct 	refd_door_res32 {
169 	int32_t		res_status;
170 	int32_t		xdr_len;
171 	char		xdr_res[1];
172 } refd_door_res32_t;
173 #endif
174 
175 #ifdef	__cplusplus
176 }
177 #endif
178 
179 #endif /* _NFSID_MAP_H */
180