1 /* minimal spec for dsniff's decode_mountd(). */
2 
3 /*
4  * Copyright (c) 1988,1990,1991,1992 by Sun Microsystems, Inc.
5  */
6 
7 /*
8  * Protocol description for the mount program
9  */
10 
11 const MNTPATHLEN = 1024;	/* maximum bytes in a pathname argument */
12 const MNTNAMLEN = 255;		/* maximum bytes in a name argument */
13 const FHSIZE = 32;		/* size in bytes of a v2 file handle */
14 const FHSIZE3 = 64;		/*  "   "    "   "  " v3  "     "    */
15 
16 /*
17  * The fhandle is the file handle that the server passes to the client.
18  * All file operations are done using the file handles to refer to a file
19  * or a directory. The file handle can contain whatever information the
20  * server needs to distinguish an individual file.
21  *
22  * Versions 1 and 2 of the protocol share a filehandle of 32 bytes.
23  *
24  * Version 3 supports a 64 byte filehandle that can be used only
25  * with version 3 of the NFS protocol.
26  */
27 
28 typedef opaque fhandle[FHSIZE];
29 typedef opaque fhandle3<FHSIZE3>;
30 
31 /*
32  * If a V2 status of zero is returned, the call completed successfully, and
33  * a file handle for the directory follows. A non-zero status indicates
34  * some sort of error. The status corresponds with UNIX error numbers.
35  */
36 union fhstatus switch (unsigned fhs_status) {
37 case 0:
38 	fhandle fhs_fhandle;
39 default:
40 	void;
41 };
42 
43 /*
44  * This #define is added for backwards compatability with applications
45  * which reference the old style fhstatus.  The second element of that
46  * structure was called fhs_fh, instead of the current fhs_fhandle.
47  */
48 %
49 %#define	fhs_fh	fhstatus_u.fhs_fhandle
50 
51 /*
52  * The following status codes are defined for the V3 mount service:
53  * Note that the precise enum encoding must be followed; the values
54  * are derived from existing implementation practice, and there is
55  * no good reason to disturb them.
56  */
57 enum mountstat3 {
58         MNT_OK= 0,              /* no error */
59         MNT3ERR_PERM=1,         /* Not owner */
60         MNT3ERR_NOENT=2,        /* No such file or directory */
61         MNT3ERR_IO=5,           /* I/O error */
62         MNT3ERR_ACCES=13,       /* Permission denied */
63         MNT3ERR_NOTDIR=20,      /* Not a directory*/
64         MNT3ERR_INVAL=22,       /* Invalid argument.*/
65         MNT3ERR_NAMETOOLONG=63, /* File name too long */
66         MNT3ERR_NOTSUPP=10004,  /* operation not supported */
67         MNT3ERR_SERVERFAULT=10006 /* An i/o or similar failure caused */
68                                 /* the server to abandon the request */
69                                 /* No attributes can be returned. The */
70                                 /* client should translate this into EIO */
71 };
72 
73 /*
74  * A V3 server returns a file handle and a list of the authentication
75  * flavors that the server will accept for this mount.  If the list
76  * is empty, AUTH_UNIX is required.  Otherwise, any of the flavors
77  * listed in auth_flavors<> may be used (but no others).
78  * The values of the authentication flavors are defined in the
79  * underlying RPC protocol.
80  */
81 struct mountres3_ok {
82 	fhandle3 fhandle;
83 	int auth_flavors<>;
84 };
85 
86 /*
87  * If a V3 status of MNT_OK is returned, the call completed successfully, and
88  * a file handle for the directory follows. Any other status indicates
89  * some sort of error.
90  */
91 
92 union mountres3 switch (mountstat3 fhs_status) {
93 case MNT_OK:
94         mountres3_ok mountinfo;
95 default:
96         void;
97 };
98 
99 /*
100  * The type dirpath is the pathname of a directory
101  */
102 typedef string dirpath<MNTPATHLEN>;
103 
104 program MOUNTPROG {
105 	/*
106 	 * Version one of the mount protocol communicates with version two
107 	 * of the NFS protocol. The only connecting point is the fhandle
108 	 * structure, which is the same for both protocols.
109 	 */
110 	version MOUNTVERS {
111 		/*
112 		 * Does no work. It is made available in all RPC services
113 		 * to allow server reponse testing and timing
114 		 */
115 		void
116 		MOUNTPROC_NULL(void) = 0;
117 
118 		/*
119 		 * If fhs_status is 0, then fhs_fhandle contains the
120 	 	 * file handle for the directory. This file handle may
121 		 * be used in the NFS protocol. This procedure also adds
122 		 * a new entry to the mount list for this client mounting
123 		 * the directory.
124 		 * Unix authentication required.
125 		 */
126 		fhstatus
127 		MOUNTPROC_MNT(dirpath) = 1;
128 	} = 1;
129 
130 	/*
131 	 * Version two of the mount protocol communicates with version two
132 	 * of the NFS protocol. It is identical to version one except for a
133 	 * new procedure call for posix.
134 	 */
135 	version MOUNTVERS_POSIX {
136 		/*
137 		 * Does no work. It is made available in all RPC services
138 		 * to allow server reponse testing and timing
139 		 */
140 		void
141 		MOUNTPROC_NULL(void) = 0;
142 
143 		/*
144 		 * If fhs_status is 0, then fhs_fhandle contains the
145 	 	 * file handle for the directory. This file handle may
146 		 * be used in the NFS protocol. This procedure also adds
147 		 * a new entry to the mount list for this client mounting
148 		 * the directory.
149 		 * Unix authentication required.
150 		 */
151 		fhstatus
152 		MOUNTPROC_MNT(dirpath) = 1;
153 	} = 2;
154 
155 	/*
156 	 * Version 3 of the mount protocol communicates with version 3
157 	 * of the NFS protocol. The only connecting point is the nfs_fh3
158 	 * structure, which is the same for both protocols.
159 	 *
160 	 * The only significant change over version 2 is that MOUNTPROC_MNT
161 	 * returns a longer filehandle (64 bytes instead of 32) as well
162 	 * as authentication information.  MOUNTPROC_PATHCONF is subsumed
163 	 * into V3 of the NFS protocol and MOUNTPROC_EXPORTALL is eliminated.
164 	 */
165 	version MOUNTVERS3 {
166 		/*
167 		 * Does no work. It is made available in all RPC services
168 		 * to allow server reponse testing and timing
169 		 */
170 		void
171 		MOUNTPROC_NULL(void) = 0;
172 
173 		/*
174 		 * Mount a file system.
175 		 *
176 		 * If mountres.fhs_status is NFS_OK, then mountres.mountinfo
177 		 * contains the file handle for the directory and
178 		 * a list of acceptable authentication flavors. This file
179 		 * handle may only be used in version 3 of the NFS protocol.
180 		 * This procedure also results in the server adding a new
181 		 * entry to its mount list recording that this client has
182 		 * mounted the directory. Unix authentication or better
183 		 * is required.
184 		 */
185 		mountres3
186 		MOUNTPROC_MNT(dirpath) = 1;
187 	} = 3;
188 } = 100005;
189