xref: /illumos-gate/usr/src/uts/common/rpcsvc/autofs_prot.x (revision 598f4ceed9327d2d6c2325dd67cae3aa06f7fea6)
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 %#pragma ident	"%Z%%M%	%I%	%E% SMI"
27 %
28 %#include <sys/vfs.h>
29 %#include <sys/dirent.h>
30 %#include <sys/types.h>
31 %#include <sys/types32.h>
32 %
33 %#define	xdr_dev_t xdr_u_int
34 %#define	xdr_bool_t xdr_bool
35 %
36 /*
37  * Autofs/automountd communication protocol.
38  */
39 
40 const AUTOFS_MAXPATHLEN		= 1024;
41 const AUTOFS_MAXCOMPONENTLEN	= 255;
42 const AUTOFS_MAXOPTSLEN		= 1024;
43 const AUTOFS_DAEMONCOOKIE	= 100000;
44 
45 /*
46  * Action Status
47  * Automountd replies to autofs indicating whether the operation is done,
48  * or further action needs to be taken by autofs.
49  */
50 enum autofs_stat {
51 	AUTOFS_ACTION=0,	/* list of actions included */
52 	AUTOFS_DONE=1		/* no further action required by kernel */
53 };
54 
55 /*
56  * Used by autofs to either create a link, or mount a new filesystem.
57  */
58 enum autofs_action {
59 	AUTOFS_MOUNT_RQ=0,	/* mount request */
60 	AUTOFS_LINK_RQ=1,	/* link create */
61 	AUTOFS_NONE=2		/* no action */
62 };
63 
64 enum autofs_res {
65 	AUTOFS_OK=0,
66 	AUTOFS_NOENT=2,
67 	AUTOFS_ECOMM=5,
68 	AUTOFS_NOMEM=12,
69 	AUTOFS_NOTDIR=20,
70 	AUTOFS_SHUTDOWN=1000
71 };
72 
73 /*
74  * Lookup/Mount request.
75  * Argument structure passed to both autofs_lookup() and autofs_mount().
76  * autofs_lookup():
77  *	Query automountd if 'path/subdir/name' exists in 'map'
78  * autofs_mount():
79  *	Request automountd to mount the map entry associated with
80  *	'path/subdir/name' in 'map' given 'opts' options.
81  */
82 struct autofs_lookupargs {
83 	string	map<AUTOFS_MAXPATHLEN>;		/* context or map name */
84 	string	path<AUTOFS_MAXPATHLEN>;	/* mountpoint */
85 	string	name<AUTOFS_MAXCOMPONENTLEN>;	/* entry we're looking for */
86 	string	subdir<AUTOFS_MAXPATHLEN>;	/* subdir within map */
87 	string	opts<AUTOFS_MAXOPTSLEN>;
88 	bool_t	isdirect;			/* direct mountpoint? */
89 	uid_t	uid;				/* uid of caller */
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 	uid_t	uid;			/* uid of caller */
236 };
237 
238 struct autofsrddir {
239 	u_int	rddir_offset;		/* last offset in list */
240 	u_int	rddir_size;		/* size in bytes of entries */
241 	bool_t	rddir_eof;		/* TRUE if last entry in result */
242 	struct dirent64 *rddir_entries;	/* variable number of entries */
243 };
244 
245 /*
246  * AUTOFS readdir result.
247  */
248 struct autofs_rddirres {
249 	enum autofs_res rd_status;
250 	u_int rd_bufsize;		/* autofs request size (not xdr'ed) */
251 	struct autofsrddir rd_rddir;
252 };
253