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