xref: /freebsd/include/rpcsvc/mount.x (revision 5ca8e32633c4ffbbcd6762e5888b6a4ba0708c6c)
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 const MNTPATHLEN = 1024;	/* maximum bytes in a pathname argument */
37 const MNTNAMLEN = 255;		/* maximum bytes in a name argument */
38 const FHSIZE = 32;		/* size in bytes of a file handle */
39 #ifdef WANT_NFS3
40 const FHSIZE3 = 64;		/* size in bytes of a file handle (v3) */
41 #endif
42 
43 /*
44  * The fhandle is the file handle that the server passes to the client.
45  * All file operations are done using the file handles to refer to a file
46  * or a directory. The file handle can contain whatever information the
47  * server needs to distinguish an individual file.
48  */
49 typedef opaque fhandle[FHSIZE];
50 #ifdef WANT_NFS3
51 typedef opaque fhandle3<FHSIZE3>;
52 #endif
53 
54 /*
55  * If a status of zero is returned, the call completed successfully, and
56  * a file handle for the directory follows. A non-zero status indicates
57  * some sort of error. The status corresponds with UNIX error numbers.
58  */
59 union fhstatus switch (unsigned fhs_status) {
60 case 0:
61 	fhandle fhs_fhandle;
62 default:
63 	void;
64 };
65 
66 #ifdef WANT_NFS3
67 /*
68  * Status codes returned by the version 3 mount call.
69  */
70 enum mountstat3 {
71 	MNT3_OK = 0,                 /* no error */
72 	MNT3ERR_PERM = 1,            /* Not owner */
73 	MNT3ERR_NOENT = 2,           /* No such file or directory */
74 	MNT3ERR_IO = 5,              /* I/O error */
75 	MNT3ERR_ACCES = 13,          /* Permission denied */
76 	MNT3ERR_NOTDIR = 20,         /* Not a directory */
77 	MNT3ERR_INVAL = 22,          /* Invalid argument */
78 	MNT3ERR_NAMETOOLONG = 63,    /* Filename too long */
79 	MNT3ERR_NOTSUPP = 10004,     /* Operation not supported */
80 	MNT3ERR_SERVERFAULT = 10006  /* A failure on the server */
81 };
82 
83 struct mountres3_ok {
84 	fhandle3	fhandle;
85 	int		auth_flavors<>;
86 };
87 
88 union mountres3 switch (mountstat3 fhs_status) {
89 case 0:
90 	mountres3_ok	mountinfo;
91 default:
92 	void;
93 };
94 #endif
95 
96 /*
97  * The type dirpath is the pathname of a directory
98  */
99 typedef string dirpath<MNTPATHLEN>;
100 
101 /*
102  * The type name is used for arbitrary names (hostnames, groupnames)
103  */
104 typedef string name<MNTNAMLEN>;
105 
106 /*
107  * A list of who has what mounted
108  */
109 typedef struct mountbody *mountlist;
110 struct mountbody {
111 	name ml_hostname;
112 	dirpath ml_directory;
113 	mountlist ml_next;
114 };
115 
116 /*
117  * A list of netgroups
118  */
119 typedef struct groupnode *groups;
120 struct groupnode {
121 	name gr_name;
122 	groups gr_next;
123 };
124 
125 /*
126  * A list of what is exported and to whom
127  */
128 typedef struct exportnode *exports;
129 struct exportnode {
130 	dirpath ex_dir;
131 	groups ex_groups;
132 	exports ex_next;
133 };
134 
135 program MOUNTPROG {
136 	/*
137 	 * Version one of the mount protocol communicates with version two
138 	 * of the NFS protocol. Version three communicates with
139 	 * version three of the NFS protocol. The only connecting
140 	 * point is the fhandle structure, which is the same for both
141 	 * protocols.
142 	 */
143 	version MOUNTVERS {
144 		/*
145 		 * Does no work. It is made available in all RPC services
146 		 * to allow server response testing and timing
147 		 */
148 		void
149 		MOUNTPROC_NULL(void) = 0;
150 
151 		/*
152 		 * If fhs_status is 0, then fhs_fhandle contains the
153 	 	 * file handle for the directory. This file handle may
154 		 * be used in the NFS protocol. This procedure also adds
155 		 * a new entry to the mount list for this client mounting
156 		 * the directory.
157 		 * Unix authentication required.
158 		 */
159 		fhstatus
160 		MOUNTPROC_MNT(dirpath) = 1;
161 
162 		/*
163 		 * Returns the list of remotely mounted filesystems. The
164 		 * mountlist contains one entry for each hostname and
165 		 * directory pair.
166 		 */
167 		mountlist
168 		MOUNTPROC_DUMP(void) = 2;
169 
170 		/*
171 		 * Removes the mount list entry for the directory
172 		 * Unix authentication required.
173 		 */
174 		void
175 		MOUNTPROC_UMNT(dirpath) = 3;
176 
177 		/*
178 		 * Removes all of the mount list entries for this client
179 		 * Unix authentication required.
180 		 */
181 		void
182 		MOUNTPROC_UMNTALL(void) = 4;
183 
184 		/*
185 		 * Returns a list of all the exported filesystems, and which
186 		 * machines are allowed to import it.
187 		 */
188 		exports
189 		MOUNTPROC_EXPORT(void)  = 5;
190 
191 		/*
192 		 * Identical to MOUNTPROC_EXPORT above
193 		 */
194 		exports
195 		MOUNTPROC_EXPORTALL(void) = 6;
196 	} = 1;
197 #ifdef WANT_NFS3
198 	version MOUNTVERS3 {
199 		/*
200 		 * Does no work. It is made available in all RPC services
201 		 * to allow server response testing and timing
202 		 */
203 		void
204 		MOUNTPROC_NULL(void) = 0;
205 
206 		/*
207 		 * If mountres3.fhs_status is MNT3_OK, then
208 		 * mountres3.mountinfo contains the file handle for
209 		 * the directory and a list of acceptable
210 		 * authentication flavors.  This file handle may only
211 		 * be used in the NFS version 3 protocol.  This
212 		 * procedure also results in the server adding a new
213 		 * entry to its mount list recording that this client
214 		 * has mounted the directory. AUTH_UNIX authentication
215 		 * or better is required.
216 		 */
217 		mountres3
218 		MOUNTPROC_MNT(dirpath) = 1;
219 
220 		/*
221 		 * Returns the list of remotely mounted filesystems. The
222 		 * mountlist contains one entry for each hostname and
223 		 * directory pair.
224 		 */
225 		mountlist
226 		MOUNTPROC_DUMP(void) = 2;
227 
228 		/*
229 		 * Removes the mount list entry for the directory
230 		 * Unix authentication required.
231 		 */
232 		void
233 		MOUNTPROC_UMNT(dirpath) = 3;
234 
235 		/*
236 		 * Removes all of the mount list entries for this client
237 		 * Unix authentication required.
238 		 */
239 		void
240 		MOUNTPROC_UMNTALL(void) = 4;
241 
242 		/*
243 		 * Returns a list of all the exported filesystems, and which
244 		 * machines are allowed to import it.
245 		 */
246 		exports
247 		MOUNTPROC_EXPORT(void)  = 5;
248 	} = 3;
249 #endif
250 } = 100005;
251