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