xref: /illumos-gate/usr/src/head/rpcsvc/mount.x (revision 24da5b34f49324ed742a340010ed5bd3d4e06625)
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 /* ident	"%Z%%M%	%I%	%E% SMI" */
23 
24 /*
25  * Copyright (c) 1988,1990-1992,1998 by Sun Microsystems, Inc.
26  * All rights reserved.
27  */
28 
29 /*
30  * Protocol description for the mount program
31  */
32 
33 const MNTPATHLEN = 1024;	/* maximum bytes in a pathname argument */
34 const MNTNAMLEN = 255;		/* maximum bytes in a name argument */
35 const FHSIZE = 32;		/* size in bytes of a v2 file handle */
36 const FHSIZE3 = 64;		/*  "   "    "   "  " v3  "     "    */
37 
38 /*
39  * The fhandle is the file handle that the server passes to the client.
40  * All file operations are done using the file handles to refer to a file
41  * or a directory. The file handle can contain whatever information the
42  * server needs to distinguish an individual file.
43  *
44  * Versions 1 and 2 of the protocol share a filehandle of 32 bytes.
45  *
46  * Version 3 supports a 64 byte filehandle that can be used only
47  * with version 3 of the NFS protocol.
48  */
49 
50 typedef opaque fhandle[FHSIZE];
51 typedef opaque fhandle3<FHSIZE3>;
52 
53 /*
54  * If a V2 status of zero is returned, the call completed successfully, and
55  * a file handle for the directory follows. A non-zero status indicates
56  * some sort of error. The status corresponds with UNIX error numbers.
57  */
58 union fhstatus switch (unsigned fhs_status) {
59 case 0:
60 	fhandle fhs_fhandle;
61 default:
62 	void;
63 };
64 
65 /*
66  * This #define is added for backwards compatability with applications
67  * which reference the old style fhstatus.  The second element of that
68  * structure was called fhs_fh, instead of the current fhs_fhandle.
69  */
70 %
71 %#define	fhs_fh	fhstatus_u.fhs_fhandle
72 
73 /*
74  * The following status codes are defined for the V3 mount service:
75  * Note that the precise enum encoding must be followed; the values
76  * are derived from existing implementation practice, and there is
77  * no good reason to disturb them.
78  */
79 enum mountstat3 {
80         MNT_OK= 0,              /* no error */
81         MNT3ERR_PERM=1,         /* Not owner */
82         MNT3ERR_NOENT=2,        /* No such file or directory */
83         MNT3ERR_IO=5,           /* I/O error */
84         MNT3ERR_ACCES=13,       /* Permission denied */
85         MNT3ERR_NOTDIR=20,      /* Not a directory*/
86         MNT3ERR_INVAL=22,       /* Invalid argument.*/
87         MNT3ERR_NAMETOOLONG=63, /* File name too long */
88         MNT3ERR_NOTSUPP=10004,  /* operation not supported */
89         MNT3ERR_SERVERFAULT=10006 /* An i/o or similar failure caused */
90                                 /* the server to abandon the request */
91                                 /* No attributes can be returned. The */
92                                 /* client should translate this into EIO */
93 };
94 
95 /*
96  * A V3 server returns a file handle and a list of the authentication
97  * flavors that the server will accept for this mount.  If the list
98  * is empty, AUTH_UNIX is required.  Otherwise, any of the flavors
99  * listed in auth_flavors<> may be used (but no others).
100  * The values of the authentication flavors are defined in the
101  * underlying RPC protocol.
102  */
103 struct mountres3_ok {
104 	fhandle3 fhandle;
105 	int auth_flavors<>;
106 };
107 
108 /*
109  * If a V3 status of MNT_OK is returned, the call completed successfully, and
110  * a file handle for the directory follows. Any other status indicates
111  * some sort of error.
112  */
113 
114 union mountres3 switch (mountstat3 fhs_status) {
115 case MNT_OK:
116         mountres3_ok mountinfo;
117 default:
118         void;
119 };
120 
121 /*
122  * The type dirpath is the pathname of a directory
123  */
124 typedef string dirpath<MNTPATHLEN>;
125 
126 /*
127  * The type name is used for arbitrary names (hostnames, groupnames)
128  */
129 typedef string name<MNTNAMLEN>;
130 
131 /*
132  * A list of who has what mounted. This information is
133  * strictly advisory, since there is no mechanism to
134  * enforce the removal of stale information. The strongest
135  * assertion that can be made is that if a hostname:directory
136  * pair appears in the list, the server has exported the
137  * directory to that client at some point since the server
138  * export data base was (re)initialized. Note also that there
139  * is no limit on the length of the information returned
140  * in this structure, and this may cause problems if the
141  * mount service is accessed via a connectionless transport.
142  *
143  * The ifdef will ensure that these are only carried over to
144  * mount.h - no xdr routines will be generated. We want to
145  * do these by hand, to avoid the recursive stack-blowing ones
146  * that rpcgen will generate.
147  */
148 #ifdef RPC_HDR
149 typedef struct mountbody *mountlist;
150 struct mountbody {
151 	name ml_hostname;
152 	dirpath ml_directory;
153 	mountlist ml_next;
154 };
155 #endif /* RPC_HDR */
156 
157 /*
158  * A list of netgroups
159  */
160 typedef struct groupnode *groups;
161 struct groupnode {
162 	name gr_name;
163 	groups gr_next;
164 };
165 
166 /*
167  * A list of what is exported and to whom
168  */
169 typedef struct exportnode *exports;
170 struct exportnode {
171 	dirpath ex_dir;
172 	groups ex_groups;
173 	exports ex_next;
174 };
175 
176 /*
177  * POSIX pathconf information
178  */
179 struct ppathcnf {
180 	int	pc_link_max;	/* max links allowed */
181 	short	pc_max_canon;	/* max line len for a tty */
182 	short	pc_max_input;	/* input a tty can eat all at once */
183 	short	pc_name_max;	/* max file name length (dir entry) */
184 	short	pc_path_max;	/* max path name length (/x/y/x/.. ) */
185 	short	pc_pipe_buf;	/* size of a pipe (bytes) */
186 	u_char	pc_vdisable;	/* safe char to turn off c_cc[i] */
187 	char	pc_xxx;		/* alignment padding; cc_t == char */
188 	short	pc_mask[2];	/* validity and boolean bits */
189 };
190 
191 program MOUNTPROG {
192 	/*
193 	 * Version one of the mount protocol communicates with version two
194 	 * of the NFS protocol. The only connecting point is the fhandle
195 	 * structure, which is the same for both protocols.
196 	 */
197 	version MOUNTVERS {
198 		/*
199 		 * Does no work. It is made available in all RPC services
200 		 * to allow server reponse testing and timing
201 		 */
202 		void
203 		MOUNTPROC_NULL(void) = 0;
204 
205 		/*
206 		 * If fhs_status is 0, then fhs_fhandle contains the
207 	 	 * file handle for the directory. This file handle may
208 		 * be used in the NFS protocol. This procedure also adds
209 		 * a new entry to the mount list for this client mounting
210 		 * the directory.
211 		 * Unix authentication required.
212 		 */
213 		fhstatus
214 		MOUNTPROC_MNT(dirpath) = 1;
215 
216 		/*
217 		 * Returns the list of remotely mounted filesystems. The
218 		 * mountlist contains one entry for each hostname and
219 		 * directory pair.
220 		 */
221 		mountlist
222 		MOUNTPROC_DUMP(void) = 2;
223 
224 		/*
225 		 * Removes the mount list entry for the directory
226 		 * Unix authentication required.
227 		 */
228 		void
229 		MOUNTPROC_UMNT(dirpath) = 3;
230 
231 		/*
232 		 * Removes all of the mount list entries for this client
233 		 * Unix authentication required.
234 		 */
235 		void
236 		MOUNTPROC_UMNTALL(void) = 4;
237 
238 		/*
239 		 * Returns a list of all the exported filesystems, and which
240 		 * machines are allowed to import it.
241 		 */
242 		exports
243 		MOUNTPROC_EXPORT(void)  = 5;
244 
245 		/*
246 		 * Identical to MOUNTPROC_EXPORT above
247 		 */
248 		exports
249 		MOUNTPROC_EXPORTALL(void) = 6;
250 	} = 1;
251 
252 	/*
253 	 * Version two of the mount protocol communicates with version two
254 	 * of the NFS protocol. It is identical to version one except for a
255 	 * new procedure call for posix.
256 	 */
257 	version MOUNTVERS_POSIX {
258 		/*
259 		 * Does no work. It is made available in all RPC services
260 		 * to allow server reponse testing and timing
261 		 */
262 		void
263 		MOUNTPROC_NULL(void) = 0;
264 
265 		/*
266 		 * If fhs_status is 0, then fhs_fhandle contains the
267 	 	 * file handle for the directory. This file handle may
268 		 * be used in the NFS protocol. This procedure also adds
269 		 * a new entry to the mount list for this client mounting
270 		 * the directory.
271 		 * Unix authentication required.
272 		 */
273 		fhstatus
274 		MOUNTPROC_MNT(dirpath) = 1;
275 
276 		/*
277 		 * Returns the list of remotely mounted filesystems. The
278 		 * mountlist contains one entry for each hostname and
279 		 * directory pair.
280 		 */
281 		mountlist
282 		MOUNTPROC_DUMP(void) = 2;
283 
284 		/*
285 		 * Removes the mount list entry for the directory
286 		 * Unix authentication required.
287 		 */
288 		void
289 		MOUNTPROC_UMNT(dirpath) = 3;
290 
291 		/*
292 		 * Removes all of the mount list entries for this client
293 		 * Unix authentication required.
294 		 */
295 		void
296 		MOUNTPROC_UMNTALL(void) = 4;
297 
298 		/*
299 		 * Returns a list of all the exported filesystems, and which
300 		 * machines are allowed to import it.
301 		 */
302 		exports
303 		MOUNTPROC_EXPORT(void)  = 5;
304 
305 		/*
306 		 * Identical to MOUNTPROC_EXPORT above
307 		 */
308 		exports
309 		MOUNTPROC_EXPORTALL(void) = 6;
310 
311 		/*
312 		 * Posix info over the wire isn't supported in NFS version 2
313 		 * so we get it here at mount time.
314 		 */
315 		ppathcnf
316 		MOUNTPROC_PATHCONF(dirpath) = 7;
317 	} = 2;
318 
319 	/*
320 	 * Version 3 of the mount protocol communicates with version 3
321 	 * of the NFS protocol. The only connecting point is the nfs_fh3
322 	 * structure, which is the same for both protocols.
323 	 *
324 	 * The only significant change over version 2 is that MOUNTPROC_MNT
325 	 * returns a longer filehandle (64 bytes instead of 32) as well
326 	 * as authentication information.  MOUNTPROC_PATHCONF is subsumed
327 	 * into V3 of the NFS protocol and MOUNTPROC_EXPORTALL is eliminated.
328 	 */
329 	version MOUNTVERS3 {
330 		/*
331 		 * Does no work. It is made available in all RPC services
332 		 * to allow server reponse testing and timing
333 		 */
334 		void
335 		MOUNTPROC_NULL(void) = 0;
336 
337 		/*
338 		 * Mount a file system.
339 		 *
340 		 * If mountres.fhs_status is NFS_OK, then mountres.mountinfo
341 		 * contains the file handle for the directory and
342 		 * a list of acceptable authentication flavors. This file
343 		 * handle may only be used in version 3 of the NFS protocol.
344 		 * This procedure also results in the server adding a new
345 		 * entry to its mount list recording that this client has
346 		 * mounted the directory. Unix authentication or better
347 		 * is required.
348 		 */
349 		mountres3
350 		MOUNTPROC_MNT(dirpath) = 1;
351 
352 		/*
353 		 * Returns the list of remotely mounted filesystems. The
354 		 * mountlist contains one entry for each hostname and
355 		 * directory pair.
356 		 */
357 		mountlist
358 		MOUNTPROC_DUMP(void) = 2;
359 
360 		/*
361 		 * Removes the mount list entry for the directory
362 		 * Unix authentication or better is required.
363 		 */
364 		void
365 		MOUNTPROC_UMNT(dirpath) = 3;
366 
367 		/*
368 		 * Removes all of the mount list entries for this client
369 		 * Unix authentication or better is required.
370 		 */
371 		void
372 		MOUNTPROC_UMNTALL(void) = 4;
373 
374 		/*
375 		 * Returns a list of all the exported filesystems, and which
376 		 * machines are allowed to import each one.
377 		 */
378 		exports
379 		MOUNTPROC_EXPORT(void)  = 5;
380 
381 	} = 3;
382 } = 100005;
383