xref: /titanic_44/usr/src/uts/common/rpcsvc/autofs_prot.x (revision 4496171313bed39e96f21bc2f9faf2868e267ae3)
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 2006 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 };
90 
91 /*
92  * Symbolic link information.
93  */
94 struct linka {
95 	string	dir<AUTOFS_MAXPATHLEN>;		/* original name */
96 	string	link<AUTOFS_MAXPATHLEN>;	/* link (new) name */
97 };
98 
99 /*
100  * We don't define netbuf in RPCL, we include the header file that
101  * includes it, and implement the xdr function ourselves.
102  */
103 
104 /*
105  * Autofs Mount specific information - used to mount a new
106  * autofs filesystem.
107  */
108 struct autofs_args {
109 	struct netbuf	addr;		/* daemon address */
110 	string path<AUTOFS_MAXPATHLEN>;	/* autofs mountpoint */
111 	string opts<AUTOFS_MAXOPTSLEN>;	/* default mount options */
112 	string map<AUTOFS_MAXPATHLEN>;	/* name of map */
113 	string subdir<AUTOFS_MAXPATHLEN>; /* subdir within map */
114 	string key<AUTOFS_MAXCOMPONENTLEN>; /* used in direct mounts only */
115 	int		mount_to;	/* time in sec the fs is to remain */
116 					/* mounted after last reference */
117 	int		rpc_to;		/* timeout for rpc calls */
118 	int		direct;		/* 1 = direct mount */
119 };
120 
121 %#ifdef _SYSCALL32
122 %/*
123 % * This is an LP64 representation of the ILP32 autofs_args data structure
124 % * for use by autofs_mount which may receive the data structure "raw"
125 % * from a 32-bit program without being processed by XDR.  rpcgen doesn't
126 % * need to see this structure since RPC/XDR only deals with the "native"
127 % * version of autofs_args.  If this isn't hidden from rpcgen then it will
128 % * insist on generating unnecessary code to deal with it.
129 % */
130 %struct autofs_args32 {
131 %	struct netbuf32	addr;		/* daemon address */
132 %	caddr32_t	path;		/* autofs mountpoint */
133 %	caddr32_t	opts;		/* default mount options */
134 %	caddr32_t	map;		/* name of map */
135 %	caddr32_t	subdir;		/* subdir within map */
136 %	caddr32_t	key;		/* used in direct mounts */
137 %	int32_t		mount_to;	/* time in sec the fs is to remain */
138 %					/* mounted after last reference */
139 %	int32_t		rpc_to;		/* timeout for rpc calls */
140 %	int32_t		direct;		/* 1 = direct mount */
141 %};
142 %#endif	/* _SYSCALL32 */
143 
144 /*
145  * Contains the necessary information to notify autofs to
146  * perfom either a new mount or create a symbolic link.
147  */
148 union action_list_entry switch (autofs_action action) {
149 case AUTOFS_MOUNT_RQ:
150 	struct mounta mounta;
151 case AUTOFS_LINK_RQ:
152 	struct linka linka;
153 default:
154 	void;
155 };
156 
157 /*
158  * List of actions that need to be performed by autofs to
159  * finish the requested operation.
160  */
161 struct action_list {
162 	action_list_entry action;
163 	action_list *next;
164 };
165 
166 union mount_result_type switch (autofs_stat status) {
167 case AUTOFS_ACTION:
168 	action_list *list;
169 case AUTOFS_DONE:
170 	int error;
171 default:
172 	void;
173 };
174 
175 /*
176  * Result from mount operation.
177  */
178 struct autofs_mountres {
179 	mount_result_type mr_type;
180 	int mr_verbose;
181 };
182 
183 union lookup_result_type switch (autofs_action action) {
184 case AUTOFS_LINK_RQ:
185 	struct linka lt_linka;
186 case AUTOFS_MOUNT_RQ:
187 	void;
188 default:
189 	void;
190 };
191 
192 /*
193  * Result from lookup operation.
194  */
195 struct autofs_lookupres {
196 	enum autofs_res lu_res;
197 	lookup_result_type lu_type;
198 	int lu_verbose;
199 };
200 
201 /*
202  * Unmount operation request
203  * Automountd will issue unmount system call for the
204  * given fstype on the given mntpnt.
205  */
206 
207 struct umntrequest {
208 	bool_t isdirect;			/* direct mount? */
209 	string mntresource<AUTOFS_MAXPATHLEN>;	/* mntpnt source */
210 	string mntpnt<AUTOFS_MAXPATHLEN>;	/* mntpnt to unmount */
211 	string fstype<AUTOFS_MAXCOMPONENTLEN>;	/* filesystem type to umount */
212 	string mntopts<AUTOFS_MAXOPTSLEN>;	/* mntpnt options */
213 	struct umntrequest *next;		/* next unmount */
214 };
215 
216 /*
217  * Unmount operation result
218  * status = 0 if unmount was successful,
219  * otherwise status = errno.
220  */
221 struct umntres {
222 	int status;
223 };
224 
225 /*
226  * AUTOFS readdir request
227  * Request list of entries in 'rda_map' map starting at the given
228  * offset 'rda_offset', for 'rda_count' bytes.
229  */
230 struct autofs_rddirargs {
231 	string	rda_map<AUTOFS_MAXPATHLEN>;
232 	u_int	rda_offset;		/* starting offset */
233 	u_int	rda_count;		/* total size requested */
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