summaryrefslogtreecommitdiff
path: root/usr/src/uts/common/nfs/nfsid_map.h
blob: 197970d4d2ac73dca7562a160624097d37e3ffd8 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
/*
 * CDDL HEADER START
 *
 * The contents of this file are subject to the terms of the
 * Common Development and Distribution License (the "License").
 * You may not use this file except in compliance with the License.
 *
 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
 * or http://www.opensolaris.org/os/licensing.
 * See the License for the specific language governing permissions
 * and limitations under the License.
 *
 * When distributing Covered Code, include this CDDL HEADER in each
 * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
 * If applicable, add the following below this CDDL HEADER, with the
 * fields enclosed by brackets "[]" replaced with your own identifying
 * information: Portions Copyright [yyyy] [name of copyright owner]
 *
 * CDDL HEADER END
 */
/*
 * Copyright 2009 Sun Microsystems, Inc.  All rights reserved.
 * Use is subject to license terms.
 */

#ifndef _NFSID_MAP_H
#define	_NFSID_MAP_H

#ifndef _KERNEL
#include <stddef.h>
#endif
#include <sys/sysmacros.h>
#include <sys/types.h>

/*
 * NFSv4 id mapping daemon
 *
 * This daemon is used by the kernel to map strings in the form
 * "user@dns_domain" from an integer form or vice-versa.  The daemon
 * uses the system configured name services for the mapping.
 *
 * The status results determines if a mapping was successful.
 *
 * The mapping is cached in the kernel, so that expensive upcalls are
 * reduced to a minimum.
 */

#ifdef	__cplusplus
extern "C" {
#endif

/*
 * mapid commands
 */
#define	NFSMAPID_STR_UID	1
#define	NFSMAPID_UID_STR	2
#define	NFSMAPID_STR_GID	3
#define	NFSMAPID_GID_STR	4
#define	NFSMAPID_SRV_NETINFO	5

/*
 * We are passing in arguments in a variable length struct
 * similar to a dirent_t. We break apart a utf8string into
 * its components and allocate a struct long enough to hold
 * the string and a NUL terminator.  The caller must ensure the
 * terminator is set.
 */
struct mapid_arg {
	uint_t	cmd;
	union {
		uid_t		uid;
		gid_t		gid;
		int		len;
	} u_arg;
	char str[1];
};
typedef struct mapid_arg mapid_arg_t;

/*
 * The actual required size of the args, rounded up to a 64 bit boundary
 */
#define	MAPID_ARG_LEN(str_length)	\
	((offsetof(mapid_arg_t, str[0]) + 1 + (str_length) + 7) & ~ 7)

/*
 * Return status codes
 */
#define	NFSMAPID_OK		0

/*
 * numeric string is mapped to its literal number
 */
#define	NFSMAPID_NUMSTR		1

/*
 * Value cannot be mapped, badly formed string
 */
#define	NFSMAPID_UNMAPPABLE	2

/*
 * Caller provided invalid arguments
 */
#define	NFSMAPID_INVALID	3

/*
 * Internal error in daemon e.g. out of memory, can't return result
 */
#define	NFSMAPID_INTERNAL	4

/*
 * Incorrect domain used
 */
#define	NFSMAPID_BADDOMAIN	5

/*
 * Out of range uid/gid
 */
#define	NFSMAPID_BADID		6

/*
 * User or group cannot be found in nameservice
 */
#define	NFSMAPID_NOTFOUND	7

/*
 * Similar to the arguments, the result is variable length.
 * The returner must ensure the string terminator is set.
 */
struct mapid_res {
	uint_t	status;
	union {
		uid_t		uid;
		gid_t		gid;
		int		len;
	} u_res;
	char str[1];
};
typedef struct mapid_res mapid_res_t;

/*
 * The actual required size of the result, rounded up to a 64 bit boundary
 */
#define	MAPID_RES_LEN(str_length)	\
	((offsetof(mapid_res_t, str[0]) + 1 + (str_length) + 7) & ~ 7)

/*
 * Support for referral name resolution by the NFS client
 */
typedef struct refd_door_args {
	int		cmd;		/* NFS4_FS_LOCATIONS/NFS4_SRV_NETINFO */
	int		xdr_len;	/* Length of xdr Buffer */
	char		xdr_arg[1];	/* Buffer holding xdr encoded data */
} refd_door_args_t;

typedef struct refd_door_res {
	int		res_status;
	int		xdr_len;
	char		xdr_res[1];
} refd_door_res_t;

#ifdef _SYSCALL32
typedef struct refd_door_args32 {
	int32_t		cmd;
	int32_t		xdr_len;
	char		xdr_arg[1];
} refd_door_args32_t;

typedef struct 	refd_door_res32 {
	int32_t		res_status;
	int32_t		xdr_len;
	char		xdr_res[1];
} refd_door_res32_t;
#endif

#ifdef	__cplusplus
}
#endif

#endif /* _NFSID_MAP_H */