xref: /illumos-gate/usr/src/cmd/fs.d/nfs/lib/webnfs.x (revision 2a8bcb4efb45d99ac41c94a75c396b362c414f7f)
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  * Copyright 1996-1999, 2003 Sun Microsystems, Inc.  All rights reserved.
24  * Use is subject to license terms.
25  */
26 
27 const WNL_PORT          = 2049;
28 const WNL_MAXDATA       = 8192;
29 const WNL_MAXNAMLEN	= 255;
30 const WNL_FHSIZE	= 32;
31 const WNL_FIFO_DEV	= -1;	/* size kludge for named pipes */
32 
33 /*
34  * Indicator for native path semantics.
35  */
36 const WNL_NATIVEPATH	= 0x80;
37 
38 /*
39  * Indicator for security negotiation.
40  */
41 const WNL_SEC_NEGO	= 0x81;
42 
43 /*
44  * File types
45  */
46 const WNLMODE_FMT  = 0170000;	/* type of file */
47 const WNLMODE_DIR  = 0040000;	/* directory */
48 const WNLMODE_CHR  = 0020000;	/* character special */
49 const WNLMODE_BLK  = 0060000;	/* block special */
50 const WNLMODE_REG  = 0100000;	/* regular */
51 const WNLMODE_LNK  = 0120000;	/* symbolic link */
52 const WNLMODE_SOCK = 0140000;	/* socket */
53 const WNLMODE_FIFO = 0010000;	/* fifo */
54 
55 /*
56  * Error status
57  */
58 enum wnl_stat {
59 	WNL_OK= 0,		/* no error */
60 	WNLERR_PERM=1,		/* Not owner */
61 	WNLERR_NOENT=2,		/* No such file or directory */
62 	WNLERR_IO=5,		/* I/O error */
63 	WNLERR_NXIO=6,		/* No such device or address */
64 	WNLERR_ACCES=13,	/* Permission denied */
65 	WNLERR_EXIST=17,	/* File exists */
66 	WNLERR_XDEV=18,		/* Cross-device link */
67 	WNLERR_NODEV=19,	/* No such device */
68 	WNLERR_NOTDIR=20,	/* Not a directory*/
69 	WNLERR_ISDIR=21,	/* Is a directory */
70 	WNLERR_INVAL=22,	/* Invalid argument */
71 	WNLERR_FBIG=27,		/* File too large */
72 	WNLERR_NOSPC=28,	/* No space left on device */
73 	WNLERR_ROFS=30,		/* Read-only file system */
74 	WNLERR_OPNOTSUPP=45,	/* Operation not supported */
75 	WNLERR_NAMETOOLONG=63,	/* File name too long */
76 	WNLERR_NOTEMPTY=66,	/* Directory not empty */
77 	WNLERR_DQUOT=69,	/* Disc quota exceeded */
78 	WNLERR_STALE=70,	/* Stale WNL file handle */
79 	WNLERR_REMOTE=71,	/* Object is remote */
80 	WNLERR_WFLUSH=72	/* write cache flushed */
81 };
82 
83 /*
84  * File types
85  */
86 enum wnl_ftype {
87 	WNL_NON = 0,	/* non-file */
88 	WNL_REG = 1,	/* regular file */
89 	WNL_DIR = 2,	/* directory */
90 	WNL_BLK = 3,	/* block special */
91 	WNL_CHR = 4,	/* character special */
92 	WNL_LNK = 5,	/* symbolic link */
93 	WNL_SOCK = 6,	/* unix domain sockets */
94 	WNL_BAD = 7,	/* unused */
95 	WNL_FIFO = 8 	/* named pipe */
96 };
97 
98 /*
99  * File access handle
100  */
101 struct wnl_fh {
102 	opaque data[WNL_FHSIZE];
103 };
104 
105 /*
106  * Timeval
107  */
108 struct wnl_time {
109 	unsigned seconds;
110 	unsigned useconds;
111 };
112 
113 
114 /*
115  * File attributes
116  */
117 struct wnl_fattr {
118 	wnl_ftype type;		/* file type */
119 	unsigned mode;		/* protection mode bits */
120 	unsigned nlink;		/* # hard links */
121 	unsigned uid;		/* owner user id */
122 	unsigned gid;		/* owner group id */
123 	unsigned size;		/* file size in bytes */
124 	unsigned blocksize;	/* prefered block size */
125 	unsigned rdev;		/* special device # */
126 	unsigned blocks;	/* Kb of disk used by file */
127 	unsigned fsid;		/* device # */
128 	unsigned fileid;	/* inode # */
129 	wnl_time	atime;		/* time of last access */
130 	wnl_time	mtime;		/* time of last modification */
131 	wnl_time	ctime;		/* time of last change */
132 };
133 
134 typedef string wnl_filename<WNL_MAXNAMLEN>;
135 
136 /*
137  * Arguments for directory operations
138  */
139 struct wnl_diropargs {
140 	wnl_fh	dir;	/* directory file handle */
141 	wnl_filename name;		/* name (up to WNL_MAXNAMLEN bytes) */
142 };
143 
144 struct wnl_diropokres {
145 	wnl_fh file;
146 	wnl_fattr attributes;
147 };
148 
149 /*
150  * Results from directory operation
151  */
152 union wnl_diropres switch (wnl_stat status) {
153 case WNL_OK:
154 	wnl_diropokres wnl_diropres;
155 default:
156 	void;
157 };
158 
159 /*
160  * Version 3 declarations and definitions.
161  */
162 
163 /*
164  * Sizes
165  */
166 const WNL3_FHSIZE         = 64;
167 
168 /*
169  * Basic data types
170  */
171 typedef unsigned hyper	wnl_uint64;
172 typedef hyper		wnl_int64;
173 typedef unsigned int	wnl_uint32;
174 typedef string		wnl_filename3<>;
175 typedef wnl_uint64	wnl_fileid3;
176 typedef wnl_uint32	wnl_uid3;
177 typedef wnl_uint32	wnl_gid3;
178 typedef wnl_uint64	wnl_size3;
179 typedef wnl_uint32	wnl_mode3;
180 
181 /*
182  * Error status
183  */
184 enum wnl_stat3 {
185 	WNL3_OK = 0,
186 	WNL3ERR_PERM = 1,
187 	WNL3ERR_NOENT = 2,
188 	WNL3ERR_IO = 5,
189 	WNL3ERR_NXIO = 6,
190 	WNL3ERR_ACCES = 13,
191 	WNL3ERR_EXIST = 17,
192 	WNL3ERR_XDEV = 18,
193 	WNL3ERR_NODEV = 19,
194 	WNL3ERR_NOTDIR = 20,
195 	WNL3ERR_ISDIR = 21,
196 	WNL3ERR_INVAL = 22,
197 	WNL3ERR_FBIG = 27,
198 	WNL3ERR_NOSPC = 28,
199 	WNL3ERR_ROFS = 30,
200 	WNL3ERR_MLINK = 31,
201 	WNL3ERR_NAMETOOLONG = 63,
202 	WNL3ERR_NOTEMPTY = 66,
203 	WNL3ERR_DQUOT = 69,
204 	WNL3ERR_STALE = 70,
205 	WNL3ERR_REMOTE = 71,
206 	WNL3ERR_BADHANDLE = 10001,
207 	WNL3ERR_NOT_SYNC = 10002,
208 	WNL3ERR_BAD_COOKIE = 10003,
209 	WNL3ERR_NOTSUPP = 10004,
210 	WNL3ERR_TOOSMALL = 10005,
211 	WNL3ERR_SERVERFAULT = 10006,
212 	WNL3ERR_BADTYPE = 10007,
213 	WNL3ERR_JUKEBOX = 10008
214 };
215 
216 /*
217  * File types
218  */
219 enum wnl_ftype3 {
220 	WNL_3REG = 1,
221 	WNL_3DIR = 2,
222 	WNL_3BLK = 3,
223 	WNL_3CHR = 4,
224 	WNL_3LNK = 5,
225 	WNL_3SOCK = 6,
226 	WNL_3FIFO = 7
227 };
228 
229 struct wnl_specdata3 {
230 	wnl_uint32	specdata1;
231 	wnl_uint32	specdata2;
232 };
233 
234 /*
235  * File access handle
236  */
237 struct wnl_fh3 {
238 	opaque data<WNL3_FHSIZE>;
239 };
240 
241 /*
242  * Timeval
243  */
244 struct wnl_time3 {
245 	wnl_uint32 seconds;
246 	wnl_uint32 nseconds;
247 };
248 
249 /*
250  * File attributes
251  */
252 struct wnl_fattr3 {
253 	wnl_ftype3	  type;
254 	wnl_mode3	  mode;
255 	wnl_uint32	  nlink;
256 	wnl_uid3	  uid;
257 	wnl_gid3	  gid;
258 	wnl_size3	  size;
259 	wnl_size3	  used;
260 	wnl_specdata3 rdev;
261 	wnl_uint64	  fsid;
262 	wnl_fileid3	  fileid;
263 	wnl_time3  atime;
264 	wnl_time3  mtime;
265 	wnl_time3  ctime;
266 };
267 
268 /*
269  * File attributes
270  */
271 union wnl_post_op_attr switch (bool attributes_follow) {
272 case TRUE:
273 	wnl_fattr3 attributes;
274 case FALSE:
275 	void;
276 };
277 
278 union wln_post_op_fh3 switch (bool handle_follows) {
279 case TRUE:
280 	wnl_fh3 handle;
281 case FALSE:
282 	void;
283 };
284 
285 struct wnl_diropargs3 {
286 	wnl_fh3   dir;
287 	wnl_filename3 name;
288 };
289 
290 /*
291  * LOOKUP: Lookup wnl_filename
292  */
293 struct WNL_LOOKUP3args {
294 	wnl_diropargs3 what;
295 };
296 
297 struct WNL_LOOKUP3resok {
298 	wnl_fh3		object;
299 	wnl_post_op_attr	obj_attributes;
300 	wnl_post_op_attr	dir_attributes;
301 };
302 
303 struct WNL_LOOKUP3resfail {
304 	wnl_post_op_attr	dir_attributes;
305 };
306 
307 union WNL_LOOKUP3res switch (wnl_stat3 status) {
308 case WNL3_OK:
309 	WNL_LOOKUP3resok	res_ok;
310 default:
311 	WNL_LOOKUP3resfail	res_fail;
312 };
313 
314 const MAX_FLAVORS	= 128;
315 
316 struct snego_t {
317 	int cnt;
318 	int array[MAX_FLAVORS];
319 };
320 
321 enum snego_stat {
322 	/* default flavor invalid and a flavor has been negotiated */
323 	SNEGO_SUCCESS = 0,
324 
325 	/* default flavor valid, no need to negotiate flavors */
326 	SNEGO_DEF_VALID = 1,
327 
328 	/* array size too small */
329 	SNEGO_ARRAY_TOO_SMALL = 2,
330 
331 	SNEGO_FAILURE = 3
332 };
333 
334 /*
335  * Remote file service routines
336  */
337 program WNL_PROGRAM {
338 	version WNL_V2 {
339 		void
340 		WNLPROC_NULL(void) = 0;
341 
342 		wnl_diropres
343 		WNLPROC_LOOKUP(wnl_diropargs) = 4;
344 	} = 2;
345 
346 	version WNL_V3 {
347 		void
348 		WNLPROC3_NULL(void) = 0;
349 
350 		WNL_LOOKUP3res
351 		WNLPROC3_LOOKUP(WNL_LOOKUP3args) = 3;
352 	} = 3;
353 
354 	version WNL_V4 {
355 		void
356 		WNLPROC4_NULL(void) = 0;
357 	} = 4;
358 
359 } = 100003;
360