xref: /illumos-gate/usr/src/uts/common/rpcsvc/autofs_prot.x (revision 9164a50bf932130cbb5097a16f6986873ce0e6e5)
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 2007 Sun Microsystems, Inc.  All rights reserved.
23 % * Use is subject to license terms.
24 % */
25 %
26 %#include <sys/vfs.h>
27 %#include <sys/dirent.h>
28 %#include <sys/types.h>
29 %#include <sys/types32.h>
30 %
31 %#define	xdr_dev_t xdr_u_int
32 %#define	xdr_bool_t xdr_bool
33 %
34 /*
35  * Autofs/automountd communication protocol.
36  */
37 
38 const AUTOFS_MAXPATHLEN		= 1024;
39 const AUTOFS_MAXCOMPONENTLEN	= 255;
40 const AUTOFS_MAXOPTSLEN		= 1024;
41 const AUTOFS_DAEMONCOOKIE	= 100000;
42 
43 /*
44  * Action Status
45  * Automountd replies to autofs indicating whether the operation is done,
46  * or further action needs to be taken by autofs.
47  */
48 enum autofs_stat {
49 	AUTOFS_ACTION=0,	/* list of actions included */
50 	AUTOFS_DONE=1		/* no further action required by kernel */
51 };
52 
53 /*
54  * Used by autofs to either create a link, or mount a new filesystem.
55  */
56 enum autofs_action {
57 	AUTOFS_MOUNT_RQ=0,	/* mount request */
58 	AUTOFS_LINK_RQ=1,	/* link create */
59 	AUTOFS_NONE=2		/* no action */
60 };
61 
62 enum autofs_res {
63 	AUTOFS_OK=0,
64 	AUTOFS_NOENT=2,
65 	AUTOFS_ECOMM=5,
66 	AUTOFS_NOMEM=12,
67 	AUTOFS_NOTDIR=20,
68 	AUTOFS_SHUTDOWN=1000
69 };
70 
71 /*
72  * Lookup/Mount request.
73  * Argument structure passed to both autofs_lookup() and autofs_mount().
74  * autofs_lookup():
75  *	Query automountd if 'path/subdir/name' exists in 'map'
76  * autofs_mount():
77  *	Request automountd to mount the map entry associated with
78  *	'path/subdir/name' in 'map' given 'opts' options.
79  */
80 struct autofs_lookupargs {
81 	string	map<AUTOFS_MAXPATHLEN>;		/* context or map name */
82 	string	path<AUTOFS_MAXPATHLEN>;	/* mountpoint */
83 	string	name<AUTOFS_MAXCOMPONENTLEN>;	/* entry we're looking for */
84 	string	subdir<AUTOFS_MAXPATHLEN>;	/* subdir within map */
85 	string	opts<AUTOFS_MAXOPTSLEN>;
86 	bool_t	isdirect;			/* direct mountpoint? */
87 	uid_t	uid;				/* uid of caller */
88 };
89 
90 /*
91  * Symbolic link information.
92  */
93 struct linka {
94 	string	dir<AUTOFS_MAXPATHLEN>;		/* original name */
95 	string	link<AUTOFS_MAXPATHLEN>;	/* link (new) name */
96 };
97 
98 /*
99  * We don't define netbuf in RPCL, we include the header file that
100  * includes it, and implement the xdr function ourselves.
101  */
102 
103 /*
104  * Autofs Mount specific information - used to mount a new
105  * autofs filesystem.
106  */
107 struct autofs_args {
108 	struct netbuf	addr;		/* daemon address */
109 	string path<AUTOFS_MAXPATHLEN>;	/* autofs mountpoint */
110 	string opts<AUTOFS_MAXOPTSLEN>;	/* default mount options */
111 	string map<AUTOFS_MAXPATHLEN>;	/* name of map */
112 	string subdir<AUTOFS_MAXPATHLEN>; /* subdir within map */
113 	string key<AUTOFS_MAXCOMPONENTLEN>; /* used in direct mounts only */
114 	int		mount_to;	/* time in sec the fs is to remain */
115 					/* mounted after last reference */
116 	int		rpc_to;		/* timeout for rpc calls */
117 	int		direct;		/* 1 = direct mount */
118 };
119 
120 %#ifdef _SYSCALL32
121 %/*
122 % * This is an LP64 representation of the ILP32 autofs_args data structure
123 % * for use by autofs_mount which may receive the data structure "raw"
124 % * from a 32-bit program without being processed by XDR.  rpcgen doesn't
125 % * need to see this structure since RPC/XDR only deals with the "native"
126 % * version of autofs_args.  If this isn't hidden from rpcgen then it will
127 % * insist on generating unnecessary code to deal with it.
128 % */
129 %struct autofs_args32 {
130 %	struct netbuf32	addr;		/* daemon address */
131 %	caddr32_t	path;		/* autofs mountpoint */
132 %	caddr32_t	opts;		/* default mount options */
133 %	caddr32_t	map;		/* name of map */
134 %	caddr32_t	subdir;		/* subdir within map */
135 %	caddr32_t	key;		/* used in direct mounts */
136 %	int32_t		mount_to;	/* time in sec the fs is to remain */
137 %					/* mounted after last reference */
138 %	int32_t		rpc_to;		/* timeout for rpc calls */
139 %	int32_t		direct;		/* 1 = direct mount */
140 %};
141 %#endif	/* _SYSCALL32 */
142 
143 /*
144  * Contains the necessary information to notify autofs to
145  * perfom either a new mount or create a symbolic link.
146  */
147 union action_list_entry switch (autofs_action action) {
148 case AUTOFS_MOUNT_RQ:
149 	struct mounta mounta;
150 case AUTOFS_LINK_RQ:
151 	struct linka linka;
152 default:
153 	void;
154 };
155 
156 /*
157  * List of actions that need to be performed by autofs to
158  * finish the requested operation.
159  */
160 struct action_list {
161 	action_list_entry action;
162 	action_list *next;
163 };
164 
165 union mount_result_type switch (autofs_stat status) {
166 case AUTOFS_ACTION:
167 	action_list *list;
168 case AUTOFS_DONE:
169 	int error;
170 default:
171 	void;
172 };
173 
174 /*
175  * Result from mount operation.
176  */
177 struct autofs_mountres {
178 	mount_result_type mr_type;
179 	int mr_verbose;
180 };
181 
182 union lookup_result_type switch (autofs_action action) {
183 case AUTOFS_LINK_RQ:
184 	struct linka lt_linka;
185 case AUTOFS_MOUNT_RQ:
186 	void;
187 default:
188 	void;
189 };
190 
191 /*
192  * Result from lookup operation.
193  */
194 struct autofs_lookupres {
195 	enum autofs_res lu_res;
196 	lookup_result_type lu_type;
197 	int lu_verbose;
198 };
199 
200 /*
201  * Unmount operation request
202  * Automountd will issue unmount system call for the
203  * given fstype on the given mntpnt.
204  */
205 
206 struct umntrequest {
207 	bool_t isdirect;			/* direct mount? */
208 	string mntresource<AUTOFS_MAXPATHLEN>;	/* mntpnt source */
209 	string mntpnt<AUTOFS_MAXPATHLEN>;	/* mntpnt to unmount */
210 	string fstype<AUTOFS_MAXCOMPONENTLEN>;	/* filesystem type to umount */
211 	string mntopts<AUTOFS_MAXOPTSLEN>;	/* mntpnt options */
212 	struct umntrequest *next;		/* next unmount */
213 };
214 
215 /*
216  * Unmount operation result
217  * status = 0 if unmount was successful,
218  * otherwise status = errno.
219  */
220 struct umntres {
221 	int status;
222 };
223 
224 /*
225  * AUTOFS readdir request
226  * Request list of entries in 'rda_map' map starting at the given
227  * offset 'rda_offset', for 'rda_count' bytes.
228  */
229 struct autofs_rddirargs {
230 	string	rda_map<AUTOFS_MAXPATHLEN>;
231 	u_int	rda_offset;		/* starting offset */
232 	u_int	rda_count;		/* total size requested */
233 	uid_t	uid;			/* uid of caller */
234 };
235 
236 struct autofsrddir {
237 	u_int	rddir_offset;		/* last offset in list */
238 	u_int	rddir_size;		/* size in bytes of entries */
239 	bool_t	rddir_eof;		/* TRUE if last entry in result */
240 	struct dirent64 *rddir_entries;	/* variable number of entries */
241 };
242 
243 /*
244  * AUTOFS readdir result.
245  */
246 struct autofs_rddirres {
247 	enum autofs_res rd_status;
248 	u_int rd_bufsize;		/* autofs request size (not xdr'ed) */
249 	struct autofsrddir rd_rddir;
250 };
251