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