xref: /freebsd/include/rpcsvc/mount.x (revision 0957b409)
1 /*-
2  * Copyright (c) 2010, Oracle America, Inc.
3  *
4  * Redistribution and use in source and binary forms, with or without
5  * modification, are permitted provided that the following conditions are
6  * met:
7  *
8  *     * Redistributions of source code must retain the above copyright
9  *       notice, this list of conditions and the following disclaimer.
10  *     * Redistributions in binary form must reproduce the above
11  *       copyright notice, this list of conditions and the following
12  *       disclaimer in the documentation and/or other materials
13  *       provided with the distribution.
14  *     * Neither the name of the "Oracle America, Inc." nor the names of its
15  *       contributors may be used to endorse or promote products derived
16  *       from this software without specific prior written permission.
17  *
18  *   THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
19  *   "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
20  *   LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
21  *   FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
22  *   COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
23  *   INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
24  *   DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
25  *   GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
26  *   INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
27  *   WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
28  *   NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
29  *   OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
30  */
31 
32 /*
33  * Protocol description for the mount program
34  */
35 
36 #ifndef RPC_HDR
37 %#ifndef lint
38 %/*static char sccsid[] = "from: @(#)mount.x 1.2 87/09/18 Copyr 1987 Sun Micro";*/
39 %/*static char sccsid[] = "from: @(#)mount.x	2.1 88/08/01 4.0 RPCSRC";*/
40 %#endif /* not lint */
41 %#include <sys/cdefs.h>
42 %__FBSDID("$FreeBSD$");
43 #endif
44 
45 const MNTPATHLEN = 1024;	/* maximum bytes in a pathname argument */
46 const MNTNAMLEN = 255;		/* maximum bytes in a name argument */
47 const FHSIZE = 32;		/* size in bytes of a file handle */
48 #ifdef WANT_NFS3
49 const FHSIZE3 = 64;		/* size in bytes of a file handle (v3) */
50 #endif
51 
52 /*
53  * The fhandle is the file handle that the server passes to the client.
54  * All file operations are done using the file handles to refer to a file
55  * or a directory. The file handle can contain whatever information the
56  * server needs to distinguish an individual file.
57  */
58 typedef opaque fhandle[FHSIZE];
59 #ifdef WANT_NFS3
60 typedef opaque fhandle3<FHSIZE3>;
61 #endif
62 
63 /*
64  * If a status of zero is returned, the call completed successfully, and
65  * a file handle for the directory follows. A non-zero status indicates
66  * some sort of error. The status corresponds with UNIX error numbers.
67  */
68 union fhstatus switch (unsigned fhs_status) {
69 case 0:
70 	fhandle fhs_fhandle;
71 default:
72 	void;
73 };
74 
75 #ifdef WANT_NFS3
76 /*
77  * Status codes returned by the version 3 mount call.
78  */
79 enum mountstat3 {
80 	MNT3_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,    /* Filename too long */
88 	MNT3ERR_NOTSUPP = 10004,     /* Operation not supported */
89 	MNT3ERR_SERVERFAULT = 10006  /* A failure on the server */
90 };
91 
92 struct mountres3_ok {
93 	fhandle3	fhandle;
94 	int		auth_flavors<>;
95 };
96 
97 union mountres3 switch (mountstat3 fhs_status) {
98 case 0:
99 	mountres3_ok	mountinfo;
100 default:
101 	void;
102 };
103 #endif
104 
105 /*
106  * The type dirpath is the pathname of a directory
107  */
108 typedef string dirpath<MNTPATHLEN>;
109 
110 /*
111  * The type name is used for arbitrary names (hostnames, groupnames)
112  */
113 typedef string name<MNTNAMLEN>;
114 
115 /*
116  * A list of who has what mounted
117  */
118 typedef struct mountbody *mountlist;
119 struct mountbody {
120 	name ml_hostname;
121 	dirpath ml_directory;
122 	mountlist ml_next;
123 };
124 
125 /*
126  * A list of netgroups
127  */
128 typedef struct groupnode *groups;
129 struct groupnode {
130 	name gr_name;
131 	groups gr_next;
132 };
133 
134 /*
135  * A list of what is exported and to whom
136  */
137 typedef struct exportnode *exports;
138 struct exportnode {
139 	dirpath ex_dir;
140 	groups ex_groups;
141 	exports ex_next;
142 };
143 
144 program MOUNTPROG {
145 	/*
146 	 * Version one of the mount protocol communicates with version two
147 	 * of the NFS protocol. Version three communicates with
148 	 * version three of the NFS protocol. The only connecting
149 	 * point is the fhandle structure, which is the same for both
150 	 * protocols.
151 	 */
152 	version MOUNTVERS {
153 		/*
154 		 * Does no work. It is made available in all RPC services
155 		 * to allow server response testing and timing
156 		 */
157 		void
158 		MOUNTPROC_NULL(void) = 0;
159 
160 		/*
161 		 * If fhs_status is 0, then fhs_fhandle contains the
162 	 	 * file handle for the directory. This file handle may
163 		 * be used in the NFS protocol. This procedure also adds
164 		 * a new entry to the mount list for this client mounting
165 		 * the directory.
166 		 * Unix authentication required.
167 		 */
168 		fhstatus
169 		MOUNTPROC_MNT(dirpath) = 1;
170 
171 		/*
172 		 * Returns the list of remotely mounted filesystems. The
173 		 * mountlist contains one entry for each hostname and
174 		 * directory pair.
175 		 */
176 		mountlist
177 		MOUNTPROC_DUMP(void) = 2;
178 
179 		/*
180 		 * Removes the mount list entry for the directory
181 		 * Unix authentication required.
182 		 */
183 		void
184 		MOUNTPROC_UMNT(dirpath) = 3;
185 
186 		/*
187 		 * Removes all of the mount list entries for this client
188 		 * Unix authentication required.
189 		 */
190 		void
191 		MOUNTPROC_UMNTALL(void) = 4;
192 
193 		/*
194 		 * Returns a list of all the exported filesystems, and which
195 		 * machines are allowed to import it.
196 		 */
197 		exports
198 		MOUNTPROC_EXPORT(void)  = 5;
199 
200 		/*
201 		 * Identical to MOUNTPROC_EXPORT above
202 		 */
203 		exports
204 		MOUNTPROC_EXPORTALL(void) = 6;
205 	} = 1;
206 #ifdef WANT_NFS3
207 	version MOUNTVERS3 {
208 		/*
209 		 * Does no work. It is made available in all RPC services
210 		 * to allow server response testing and timing
211 		 */
212 		void
213 		MOUNTPROC_NULL(void) = 0;
214 
215 		/*
216 		 * If mountres3.fhs_status is MNT3_OK, then
217 		 * mountres3.mountinfo contains the file handle for
218 		 * the directory and a list of acceptable
219 		 * authentication flavors.  This file handle may only
220 		 * be used in the NFS version 3 protocol.  This
221 		 * procedure also results in the server adding a new
222 		 * entry to its mount list recording that this client
223 		 * has mounted the directory. AUTH_UNIX authentication
224 		 * or better is required.
225 		 */
226 		mountres3
227 		MOUNTPROC_MNT(dirpath) = 1;
228 
229 		/*
230 		 * Returns the list of remotely mounted filesystems. The
231 		 * mountlist contains one entry for each hostname and
232 		 * directory pair.
233 		 */
234 		mountlist
235 		MOUNTPROC_DUMP(void) = 2;
236 
237 		/*
238 		 * Removes the mount list entry for the directory
239 		 * Unix authentication required.
240 		 */
241 		void
242 		MOUNTPROC_UMNT(dirpath) = 3;
243 
244 		/*
245 		 * Removes all of the mount list entries for this client
246 		 * Unix authentication required.
247 		 */
248 		void
249 		MOUNTPROC_UMNTALL(void) = 4;
250 
251 		/*
252 		 * Returns a list of all the exported filesystems, and which
253 		 * machines are allowed to import it.
254 		 */
255 		exports
256 		MOUNTPROC_EXPORT(void)  = 5;
257 	} = 3;
258 #endif
259 } = 100005;
260