Commit | Line | Data |
---|---|---|
2f5c161b RS |
1 | /* |
2 | Copyright (c) 2014, Ronnie Sahlberg | |
3 | All rights reserved. | |
4 | ||
5 | Redistribution and use in source and binary forms, with or without | |
6 | modification, are permitted provided that the following conditions are met: | |
7 | ||
8 | 1. Redistributions of source code must retain the above copyright notice, this | |
9 | list of conditions and the following disclaimer. | |
10 | 2. Redistributions in binary form must reproduce the above copyright notice, | |
11 | this list of conditions and the following disclaimer in the documentation | |
12 | and/or other materials provided with the distribution. | |
13 | ||
14 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND | |
15 | ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED | |
16 | WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE | |
17 | DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR | |
18 | ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES | |
19 | (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; | |
20 | LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND | |
21 | ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | |
22 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS | |
23 | SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | |
24 | ||
25 | The views and conclusions contained in the software and documentation are those | |
26 | of the authors and should not be interpreted as representing official policies, | |
27 | either expressed or implied, of the FreeBSD Project. | |
28 | */ | |
84004dbf | 29 | |
f38aacf8 RS |
30 | /* |
31 | * NFS v3 Definitions | |
32 | */ | |
84004dbf RS |
33 | const NFS3_FHSIZE = 64; /* Maximum bytes in a V3 file handle */ |
34 | const NFS3_WRITEVERFSIZE = 8; | |
35 | const NFS3_CREATEVERFSIZE = 8; | |
36 | const NFS3_COOKIEVERFSIZE = 8; | |
37 | ||
38 | typedef opaque cookieverf3[NFS3_COOKIEVERFSIZE]; | |
39 | ||
a0c4ea7d | 40 | typedef u_quad_t cookie3; |
84004dbf RS |
41 | |
42 | struct nfs_fh3 { | |
43 | opaque data<NFS3_FHSIZE>; | |
44 | }; | |
45 | ||
46 | typedef string filename3<>; | |
47 | ||
48 | struct diropargs3 { | |
49 | nfs_fh3 dir; | |
50 | filename3 name; | |
51 | }; | |
52 | ||
53 | enum ftype3 { | |
54 | NF3REG = 1, | |
55 | NF3DIR = 2, | |
56 | NF3BLK = 3, | |
57 | NF3CHR = 4, | |
58 | NF3LNK = 5, | |
59 | NF3SOCK = 6, | |
60 | NF3FIFO = 7 | |
61 | }; | |
62 | ||
c0ebf57b | 63 | typedef unsigned int mode3; |
84004dbf | 64 | |
c0ebf57b | 65 | typedef unsigned int uid3; |
84004dbf | 66 | |
c0ebf57b | 67 | typedef unsigned int gid3; |
84004dbf | 68 | |
a0c4ea7d | 69 | typedef u_quad_t size3; |
84004dbf | 70 | |
a0c4ea7d | 71 | typedef u_quad_t fileid3; |
84004dbf RS |
72 | |
73 | struct specdata3 { | |
c0ebf57b RS |
74 | unsigned int specdata1; |
75 | unsigned int specdata2; | |
84004dbf RS |
76 | }; |
77 | ||
78 | struct nfstime3 { | |
c0ebf57b RS |
79 | unsigned int seconds; |
80 | unsigned int nseconds; | |
84004dbf RS |
81 | }; |
82 | ||
83 | struct fattr3 { | |
c0ebf57b RS |
84 | ftype3 type; |
85 | mode3 mode; | |
86 | unsigned int nlink; | |
87 | uid3 uid; | |
88 | gid3 gid; | |
89 | size3 size; | |
90 | size3 used; | |
91 | specdata3 rdev; | |
a0c4ea7d | 92 | u_quad_t fsid; |
c0ebf57b RS |
93 | fileid3 fileid; |
94 | nfstime3 atime; | |
95 | nfstime3 mtime; | |
96 | nfstime3 ctime; | |
84004dbf RS |
97 | }; |
98 | ||
99 | union post_op_attr switch (bool attributes_follow) { | |
100 | case TRUE: | |
101 | fattr3 attributes; | |
102 | case FALSE: | |
103 | void; | |
104 | }; | |
105 | ||
106 | ||
107 | enum nfsstat3 { | |
108 | NFS3_OK = 0, | |
109 | NFS3ERR_PERM = 1, | |
110 | NFS3ERR_NOENT = 2, | |
111 | NFS3ERR_IO = 5, | |
112 | NFS3ERR_NXIO = 6, | |
113 | NFS3ERR_ACCES = 13, | |
114 | NFS3ERR_EXIST = 17, | |
115 | NFS3ERR_XDEV = 18, | |
116 | NFS3ERR_NODEV = 19, | |
117 | NFS3ERR_NOTDIR = 20, | |
118 | NFS3ERR_ISDIR = 21, | |
119 | NFS3ERR_INVAL = 22, | |
120 | NFS3ERR_FBIG = 27, | |
121 | NFS3ERR_NOSPC = 28, | |
122 | NFS3ERR_ROFS = 30, | |
123 | NFS3ERR_MLINK = 31, | |
124 | NFS3ERR_NAMETOOLONG = 63, | |
125 | NFS3ERR_NOTEMPTY = 66, | |
126 | NFS3ERR_DQUOT = 69, | |
127 | NFS3ERR_STALE = 70, | |
128 | NFS3ERR_REMOTE = 71, | |
129 | NFS3ERR_BADHANDLE = 10001, | |
130 | NFS3ERR_NOT_SYNC = 10002, | |
131 | NFS3ERR_BAD_COOKIE = 10003, | |
132 | NFS3ERR_NOTSUPP = 10004, | |
133 | NFS3ERR_TOOSMALL = 10005, | |
134 | NFS3ERR_SERVERFAULT = 10006, | |
135 | NFS3ERR_BADTYPE = 10007, | |
136 | NFS3ERR_JUKEBOX = 10008 | |
137 | }; | |
138 | ||
139 | enum stable_how { | |
140 | UNSTABLE = 0, | |
141 | DATA_SYNC = 1, | |
142 | FILE_SYNC = 2 | |
143 | }; | |
144 | ||
a0c4ea7d | 145 | typedef u_quad_t offset3; |
84004dbf | 146 | |
c0ebf57b | 147 | typedef unsigned int count3; |
84004dbf RS |
148 | |
149 | struct wcc_attr { | |
150 | size3 size; | |
151 | nfstime3 mtime; | |
152 | nfstime3 ctime; | |
153 | }; | |
154 | ||
155 | union pre_op_attr switch (bool attributes_follow) { | |
156 | case TRUE: | |
157 | wcc_attr attributes; | |
158 | case FALSE: | |
159 | void; | |
160 | }; | |
161 | ||
162 | struct wcc_data { | |
163 | pre_op_attr before; | |
164 | post_op_attr after; | |
165 | }; | |
166 | ||
167 | struct WRITE3args { | |
168 | nfs_fh3 file; | |
169 | offset3 offset; | |
170 | count3 count; | |
171 | stable_how stable; | |
172 | opaque data<>; | |
173 | }; | |
174 | ||
175 | typedef opaque writeverf3[NFS3_WRITEVERFSIZE]; | |
176 | ||
177 | struct WRITE3resok { | |
178 | wcc_data file_wcc; | |
179 | count3 count; | |
180 | stable_how committed; | |
181 | writeverf3 verf; | |
182 | }; | |
183 | ||
184 | struct WRITE3resfail { | |
185 | wcc_data file_wcc; | |
186 | }; | |
187 | ||
188 | union WRITE3res switch (nfsstat3 status) { | |
189 | case NFS3_OK: | |
190 | WRITE3resok resok; | |
191 | default: | |
192 | WRITE3resfail resfail; | |
193 | }; | |
194 | ||
195 | struct LOOKUP3args { | |
196 | diropargs3 what; | |
197 | }; | |
198 | ||
199 | struct LOOKUP3resok { | |
200 | nfs_fh3 object; | |
201 | post_op_attr obj_attributes; | |
202 | post_op_attr dir_attributes; | |
203 | }; | |
204 | ||
205 | struct LOOKUP3resfail { | |
206 | post_op_attr dir_attributes; | |
207 | }; | |
208 | ||
209 | ||
210 | ||
211 | union LOOKUP3res switch (nfsstat3 status) { | |
212 | case NFS3_OK: | |
213 | LOOKUP3resok resok; | |
214 | default: | |
215 | LOOKUP3resfail resfail; | |
216 | }; | |
217 | ||
218 | struct COMMIT3args { | |
219 | nfs_fh3 file; | |
220 | offset3 offset; | |
221 | count3 count; | |
222 | }; | |
223 | ||
224 | struct COMMIT3resok { | |
225 | wcc_data file_wcc; | |
226 | writeverf3 verf; | |
227 | }; | |
228 | ||
229 | struct COMMIT3resfail { | |
230 | wcc_data file_wcc; | |
231 | }; | |
232 | ||
233 | union COMMIT3res switch (nfsstat3 status) { | |
234 | case NFS3_OK: | |
235 | COMMIT3resok resok; | |
236 | default: | |
237 | COMMIT3resfail resfail; | |
238 | }; | |
239 | ||
240 | const ACCESS3_READ = 0x0001; | |
241 | const ACCESS3_LOOKUP = 0x0002; | |
242 | const ACCESS3_MODIFY = 0x0004; | |
243 | const ACCESS3_EXTEND = 0x0008; | |
244 | const ACCESS3_DELETE = 0x0010; | |
245 | const ACCESS3_EXECUTE = 0x0020; | |
246 | ||
247 | struct ACCESS3args { | |
c0ebf57b RS |
248 | nfs_fh3 object; |
249 | unsigned int access; | |
84004dbf RS |
250 | }; |
251 | ||
252 | struct ACCESS3resok { | |
c0ebf57b RS |
253 | post_op_attr obj_attributes; |
254 | unsigned int access; | |
84004dbf RS |
255 | }; |
256 | ||
257 | struct ACCESS3resfail { | |
258 | post_op_attr obj_attributes; | |
259 | }; | |
260 | ||
261 | union ACCESS3res switch (nfsstat3 status) { | |
262 | case NFS3_OK: | |
263 | ACCESS3resok resok; | |
264 | default: | |
265 | ACCESS3resfail resfail; | |
266 | }; | |
267 | ||
268 | struct GETATTR3args { | |
269 | nfs_fh3 object; | |
270 | }; | |
271 | ||
272 | struct GETATTR3resok { | |
273 | fattr3 obj_attributes; | |
274 | }; | |
275 | ||
276 | union GETATTR3res switch (nfsstat3 status) { | |
277 | case NFS3_OK: | |
278 | GETATTR3resok resok; | |
279 | default: | |
280 | void; | |
281 | }; | |
282 | ||
283 | ||
284 | ||
285 | enum time_how { | |
286 | DONT_CHANGE = 0, | |
287 | SET_TO_SERVER_TIME = 1, | |
288 | SET_TO_CLIENT_TIME = 2 | |
289 | }; | |
290 | ||
291 | union set_mode3 switch (bool set_it) { | |
292 | case TRUE: | |
293 | mode3 mode; | |
294 | default: | |
295 | void; | |
296 | }; | |
297 | ||
298 | union set_uid3 switch (bool set_it) { | |
299 | case TRUE: | |
300 | uid3 uid; | |
301 | default: | |
302 | void; | |
303 | }; | |
304 | ||
305 | union set_gid3 switch (bool set_it) { | |
306 | case TRUE: | |
307 | gid3 gid; | |
308 | default: | |
309 | void; | |
310 | }; | |
311 | ||
312 | union set_size3 switch (bool set_it) { | |
313 | case TRUE: | |
314 | size3 size; | |
315 | default: | |
316 | void; | |
317 | }; | |
318 | ||
319 | union set_atime switch (time_how set_it) { | |
320 | case SET_TO_CLIENT_TIME: | |
321 | nfstime3 atime; | |
322 | default: | |
323 | void; | |
324 | }; | |
325 | ||
326 | union set_mtime switch (time_how set_it) { | |
327 | case SET_TO_CLIENT_TIME: | |
328 | nfstime3 mtime; | |
329 | default: | |
330 | void; | |
331 | }; | |
332 | ||
333 | struct sattr3 { | |
334 | set_mode3 mode; | |
335 | set_uid3 uid; | |
336 | set_gid3 gid; | |
337 | set_size3 size; | |
338 | set_atime atime; | |
339 | set_mtime mtime; | |
340 | }; | |
341 | ||
342 | enum createmode3 { | |
343 | UNCHECKED = 0, | |
344 | GUARDED = 1, | |
345 | EXCLUSIVE = 2 | |
346 | }; | |
347 | ||
348 | ||
349 | typedef opaque createverf3[NFS3_CREATEVERFSIZE]; | |
350 | ||
351 | union createhow3 switch (createmode3 mode) { | |
352 | case UNCHECKED: | |
84004dbf | 353 | sattr3 obj_attributes; |
e0261457 RS |
354 | case GUARDED: |
355 | sattr3 g_obj_attributes; | |
84004dbf RS |
356 | case EXCLUSIVE: |
357 | createverf3 verf; | |
358 | }; | |
359 | ||
360 | struct CREATE3args { | |
361 | diropargs3 where; | |
362 | createhow3 how; | |
363 | }; | |
364 | ||
365 | union post_op_fh3 switch (bool handle_follows) { | |
366 | case TRUE: | |
367 | nfs_fh3 handle; | |
368 | case FALSE: | |
369 | void; | |
370 | }; | |
371 | ||
372 | struct CREATE3resok { | |
373 | post_op_fh3 obj; | |
374 | post_op_attr obj_attributes; | |
375 | wcc_data dir_wcc; | |
376 | }; | |
377 | ||
378 | struct CREATE3resfail { | |
379 | wcc_data dir_wcc; | |
380 | }; | |
381 | ||
382 | union CREATE3res switch (nfsstat3 status) { | |
383 | case NFS3_OK: | |
384 | CREATE3resok resok; | |
385 | default: | |
386 | CREATE3resfail resfail; | |
387 | }; | |
388 | ||
389 | struct REMOVE3args { | |
390 | diropargs3 object; | |
391 | }; | |
392 | ||
393 | struct REMOVE3resok { | |
394 | wcc_data dir_wcc; | |
395 | }; | |
396 | ||
397 | struct REMOVE3resfail { | |
398 | wcc_data dir_wcc; | |
399 | }; | |
400 | ||
401 | union REMOVE3res switch (nfsstat3 status) { | |
402 | case NFS3_OK: | |
403 | REMOVE3resok resok; | |
404 | default: | |
405 | REMOVE3resfail resfail; | |
406 | }; | |
407 | ||
408 | struct READ3args { | |
409 | nfs_fh3 file; | |
410 | offset3 offset; | |
411 | count3 count; | |
412 | }; | |
413 | ||
414 | struct READ3resok { | |
415 | post_op_attr file_attributes; | |
416 | count3 count; | |
417 | bool eof; | |
418 | opaque data<>; | |
419 | }; | |
420 | ||
421 | struct READ3resfail { | |
422 | post_op_attr file_attributes; | |
423 | }; | |
424 | ||
425 | union READ3res switch (nfsstat3 status) { | |
426 | case NFS3_OK: | |
427 | READ3resok resok; | |
428 | default: | |
429 | READ3resfail resfail; | |
430 | }; | |
431 | ||
432 | ||
433 | const FSF3_LINK = 0x0001; | |
434 | const FSF3_SYMLINK = 0x0002; | |
435 | const FSF3_HOMOGENEOUS = 0x0008; | |
436 | const FSF3_CANSETTIME = 0x0010; | |
437 | ||
438 | struct FSINFO3args { | |
439 | nfs_fh3 fsroot; | |
440 | }; | |
441 | ||
442 | struct FSINFO3resok { | |
443 | post_op_attr obj_attributes; | |
c0ebf57b RS |
444 | unsigned int rtmax; |
445 | unsigned int rtpref; | |
446 | unsigned int rtmult; | |
447 | unsigned int wtmax; | |
448 | unsigned int wtpref; | |
449 | unsigned int wtmult; | |
450 | unsigned int dtpref; | |
84004dbf RS |
451 | size3 maxfilesize; |
452 | nfstime3 time_delta; | |
c0ebf57b | 453 | unsigned int properties; |
84004dbf RS |
454 | }; |
455 | ||
456 | struct FSINFO3resfail { | |
457 | post_op_attr obj_attributes; | |
458 | }; | |
459 | ||
460 | union FSINFO3res switch (nfsstat3 status) { | |
461 | case NFS3_OK: | |
462 | FSINFO3resok resok; | |
463 | default: | |
464 | FSINFO3resfail resfail; | |
465 | }; | |
466 | ||
467 | ||
468 | struct FSSTAT3args { | |
469 | nfs_fh3 fsroot; | |
470 | }; | |
471 | ||
472 | struct FSSTAT3resok { | |
473 | post_op_attr obj_attributes; | |
474 | size3 tbytes; | |
475 | size3 fbytes; | |
476 | size3 abytes; | |
477 | size3 tfiles; | |
478 | size3 ffiles; | |
479 | size3 afiles; | |
c0ebf57b | 480 | unsigned int invarsec; |
84004dbf RS |
481 | }; |
482 | ||
483 | struct FSSTAT3resfail { | |
484 | post_op_attr obj_attributes; | |
485 | }; | |
486 | ||
487 | union FSSTAT3res switch (nfsstat3 status) { | |
488 | case NFS3_OK: | |
489 | FSSTAT3resok resok; | |
490 | default: | |
491 | FSSTAT3resfail resfail; | |
492 | }; | |
493 | ||
494 | struct PATHCONF3args { | |
495 | nfs_fh3 object; | |
496 | }; | |
497 | ||
498 | struct PATHCONF3resok { | |
499 | post_op_attr obj_attributes; | |
c0ebf57b RS |
500 | unsigned int linkmax; |
501 | unsigned int name_max; | |
84004dbf RS |
502 | bool no_trunc; |
503 | bool chown_restricted; | |
504 | bool case_insensitive; | |
505 | bool case_preserving; | |
506 | }; | |
507 | ||
508 | struct PATHCONF3resfail { | |
509 | post_op_attr obj_attributes; | |
510 | }; | |
511 | ||
512 | union PATHCONF3res switch (nfsstat3 status) { | |
513 | case NFS3_OK: | |
514 | PATHCONF3resok resok; | |
515 | default: | |
516 | PATHCONF3resfail resfail; | |
517 | }; | |
518 | ||
519 | typedef string nfspath3<>; | |
520 | ||
521 | struct symlinkdata3 { | |
522 | sattr3 symlink_attributes; | |
523 | nfspath3 symlink_data; | |
524 | }; | |
525 | ||
526 | struct SYMLINK3args { | |
527 | diropargs3 where; | |
528 | symlinkdata3 symlink; | |
529 | }; | |
530 | ||
531 | struct SYMLINK3resok { | |
532 | post_op_fh3 obj; | |
533 | post_op_attr obj_attributes; | |
534 | wcc_data dir_wcc; | |
535 | }; | |
536 | ||
537 | struct SYMLINK3resfail { | |
538 | wcc_data dir_wcc; | |
539 | }; | |
540 | ||
541 | union SYMLINK3res switch (nfsstat3 status) { | |
542 | case NFS3_OK: | |
543 | SYMLINK3resok resok; | |
544 | default: | |
545 | SYMLINK3resfail resfail; | |
546 | }; | |
547 | ||
548 | ||
549 | struct READLINK3args { | |
550 | nfs_fh3 symlink; | |
551 | }; | |
552 | ||
553 | struct READLINK3resok { | |
554 | post_op_attr symlink_attributes; | |
555 | nfspath3 data; | |
556 | }; | |
557 | ||
558 | struct READLINK3resfail { | |
559 | post_op_attr symlink_attributes; | |
560 | }; | |
561 | ||
562 | union READLINK3res switch (nfsstat3 status) { | |
563 | case NFS3_OK: | |
564 | READLINK3resok resok; | |
565 | default: | |
566 | READLINK3resfail resfail; | |
567 | }; | |
568 | ||
569 | ||
570 | struct devicedata3 { | |
571 | sattr3 dev_attributes; | |
572 | specdata3 spec; | |
573 | }; | |
574 | ||
575 | union mknoddata3 switch (ftype3 type) { | |
576 | case NF3CHR: | |
e0261457 | 577 | devicedata3 chr_device; |
84004dbf | 578 | case NF3BLK: |
e0261457 | 579 | devicedata3 blk_device; |
84004dbf | 580 | case NF3SOCK: |
e0261457 | 581 | sattr3 sock_attributes; |
84004dbf RS |
582 | case NF3FIFO: |
583 | sattr3 pipe_attributes; | |
584 | default: | |
585 | void; | |
586 | }; | |
587 | ||
588 | struct MKNOD3args { | |
589 | diropargs3 where; | |
590 | mknoddata3 what; | |
591 | }; | |
592 | ||
593 | struct MKNOD3resok { | |
594 | post_op_fh3 obj; | |
595 | post_op_attr obj_attributes; | |
596 | wcc_data dir_wcc; | |
597 | }; | |
598 | ||
599 | struct MKNOD3resfail { | |
600 | wcc_data dir_wcc; | |
601 | }; | |
602 | ||
603 | union MKNOD3res switch (nfsstat3 status) { | |
604 | case NFS3_OK: | |
605 | MKNOD3resok resok; | |
606 | default: | |
607 | MKNOD3resfail resfail; | |
608 | }; | |
609 | ||
610 | ||
611 | struct MKDIR3args { | |
612 | diropargs3 where; | |
613 | sattr3 attributes; | |
614 | }; | |
615 | ||
616 | struct MKDIR3resok { | |
617 | post_op_fh3 obj; | |
618 | post_op_attr obj_attributes; | |
619 | wcc_data dir_wcc; | |
620 | }; | |
621 | ||
622 | struct MKDIR3resfail { | |
623 | wcc_data dir_wcc; | |
624 | }; | |
625 | ||
626 | union MKDIR3res switch (nfsstat3 status) { | |
627 | case NFS3_OK: | |
628 | MKDIR3resok resok; | |
629 | default: | |
630 | MKDIR3resfail resfail; | |
631 | }; | |
632 | ||
633 | struct RMDIR3args { | |
634 | diropargs3 object; | |
635 | }; | |
636 | ||
637 | struct RMDIR3resok { | |
638 | wcc_data dir_wcc; | |
639 | }; | |
640 | ||
641 | struct RMDIR3resfail { | |
642 | wcc_data dir_wcc; | |
643 | }; | |
644 | ||
645 | union RMDIR3res switch (nfsstat3 status) { | |
646 | case NFS3_OK: | |
647 | RMDIR3resok resok; | |
648 | default: | |
649 | RMDIR3resfail resfail; | |
650 | }; | |
651 | ||
652 | struct RENAME3args { | |
653 | diropargs3 from; | |
654 | diropargs3 to; | |
655 | }; | |
656 | ||
657 | struct RENAME3resok { | |
658 | wcc_data fromdir_wcc; | |
659 | wcc_data todir_wcc; | |
660 | }; | |
661 | ||
662 | struct RENAME3resfail { | |
663 | wcc_data fromdir_wcc; | |
664 | wcc_data todir_wcc; | |
665 | }; | |
666 | ||
667 | union RENAME3res switch (nfsstat3 status) { | |
668 | case NFS3_OK: | |
669 | RENAME3resok resok; | |
670 | default: | |
671 | RENAME3resfail resfail; | |
672 | }; | |
673 | ||
674 | struct READDIRPLUS3args { | |
675 | nfs_fh3 dir; | |
676 | cookie3 cookie; | |
677 | cookieverf3 cookieverf; | |
678 | count3 dircount; | |
679 | count3 maxcount; | |
680 | }; | |
681 | ||
682 | struct entryplus3 { | |
683 | fileid3 fileid; | |
684 | filename3 name; | |
685 | cookie3 cookie; | |
686 | post_op_attr name_attributes; | |
687 | post_op_fh3 name_handle; | |
688 | entryplus3 *nextentry; | |
689 | }; | |
690 | ||
691 | struct dirlistplus3 { | |
692 | entryplus3 *entries; | |
693 | bool eof; | |
694 | }; | |
695 | ||
696 | struct READDIRPLUS3resok { | |
697 | post_op_attr dir_attributes; | |
698 | cookieverf3 cookieverf; | |
699 | dirlistplus3 reply; | |
700 | }; | |
701 | ||
702 | ||
703 | struct READDIRPLUS3resfail { | |
704 | post_op_attr dir_attributes; | |
705 | }; | |
706 | ||
707 | union READDIRPLUS3res switch (nfsstat3 status) { | |
708 | case NFS3_OK: | |
709 | READDIRPLUS3resok resok; | |
710 | default: | |
711 | READDIRPLUS3resfail resfail; | |
712 | }; | |
713 | ||
714 | struct READDIR3args { | |
715 | nfs_fh3 dir; | |
716 | cookie3 cookie; | |
717 | cookieverf3 cookieverf; | |
718 | count3 count; | |
719 | }; | |
720 | ||
721 | ||
722 | struct entry3 { | |
723 | fileid3 fileid; | |
724 | filename3 name; | |
725 | cookie3 cookie; | |
726 | entry3 *nextentry; | |
727 | }; | |
728 | ||
729 | struct dirlist3 { | |
730 | entry3 *entries; | |
731 | bool eof; | |
732 | }; | |
733 | ||
734 | struct READDIR3resok { | |
735 | post_op_attr dir_attributes; | |
736 | cookieverf3 cookieverf; | |
737 | dirlist3 reply; | |
738 | }; | |
739 | ||
740 | struct READDIR3resfail { | |
741 | post_op_attr dir_attributes; | |
742 | }; | |
743 | ||
744 | union READDIR3res switch (nfsstat3 status) { | |
745 | case NFS3_OK: | |
746 | READDIR3resok resok; | |
747 | default: | |
748 | READDIR3resfail resfail; | |
749 | }; | |
750 | ||
751 | struct LINK3args { | |
752 | nfs_fh3 file; | |
753 | diropargs3 link; | |
754 | }; | |
755 | ||
756 | struct LINK3resok { | |
757 | post_op_attr file_attributes; | |
758 | wcc_data linkdir_wcc; | |
759 | }; | |
760 | ||
761 | struct LINK3resfail { | |
762 | post_op_attr file_attributes; | |
763 | wcc_data linkdir_wcc; | |
764 | }; | |
765 | ||
766 | union LINK3res switch (nfsstat3 status) { | |
767 | case NFS3_OK: | |
768 | LINK3resok resok; | |
769 | default: | |
770 | LINK3resfail resfail; | |
771 | }; | |
772 | ||
773 | union sattrguard3 switch (bool check) { | |
774 | case TRUE: | |
775 | nfstime3 obj_ctime; | |
776 | case FALSE: | |
777 | void; | |
778 | }; | |
779 | ||
780 | struct SETATTR3args { | |
781 | nfs_fh3 object; | |
782 | sattr3 new_attributes; | |
783 | sattrguard3 guard; | |
784 | }; | |
785 | ||
786 | struct SETATTR3resok { | |
787 | wcc_data obj_wcc; | |
788 | }; | |
789 | ||
790 | struct SETATTR3resfail { | |
791 | wcc_data obj_wcc; | |
792 | }; | |
793 | ||
794 | union SETATTR3res switch (nfsstat3 status) { | |
795 | case NFS3_OK: | |
796 | SETATTR3resok resok; | |
797 | default: | |
798 | SETATTR3resfail resfail; | |
799 | }; | |
800 | ||
f38aacf8 RS |
801 | /* |
802 | * NFS v2 Definitions | |
803 | * We share many definitions from v3 | |
804 | */ | |
805 | const FHSIZE2 = 32; | |
806 | typedef opaque fhandle2[FHSIZE2]; | |
807 | ||
808 | enum ftype2 { | |
809 | NF2NON = 0, | |
810 | NF2REG = 1, | |
811 | NF2DIR = 2, | |
812 | NF2BLK = 3, | |
813 | NF2CHR = 4, | |
814 | NF2LNK = 5 | |
815 | }; | |
816 | ||
817 | struct fattr2 { | |
818 | ftype2 type; | |
819 | unsigned int mode; | |
820 | unsigned int nlink; | |
821 | unsigned int uid; | |
822 | unsigned int gid; | |
823 | unsigned int size; | |
824 | unsigned int blocksize; | |
825 | unsigned int rdev; | |
826 | unsigned int blocks; | |
827 | unsigned int fsid; | |
828 | unsigned int fileid; | |
829 | nfstime3 atime; | |
830 | nfstime3 mtime; | |
831 | nfstime3 ctime; | |
832 | }; | |
833 | ||
834 | struct sattr2 { | |
835 | unsigned int mode; | |
836 | unsigned int uid; | |
837 | unsigned int gid; | |
838 | unsigned int size; | |
839 | nfstime3 atime; | |
840 | nfstime3 mtime; | |
841 | }; | |
842 | ||
843 | const MAXNAMLEN2 = 255; | |
844 | typedef string filename2<MAXNAMLEN2>; | |
845 | ||
846 | const MAXPATHLEN2 = 1024; | |
847 | typedef string path2<MAXPATHLEN2>; | |
848 | ||
849 | const NFSMAXDATA2 = 8192; | |
850 | typedef opaque nfsdata2<NFSMAXDATA2>; | |
851 | ||
852 | const NFSCOOKIESIZE2 = 4; | |
853 | typedef opaque nfscookie2[NFSCOOKIESIZE2]; | |
854 | ||
855 | struct entry2 { | |
856 | unsigned int fileid; | |
857 | filename2 name; | |
858 | nfscookie2 cookie; | |
859 | entry2 *nextentry; | |
860 | }; | |
861 | ||
862 | struct diropargs2 { | |
863 | fhandle2 dir; | |
864 | filename2 name; | |
865 | }; | |
866 | ||
867 | struct GETATTR2args { | |
868 | fhandle2 fhandle; | |
869 | }; | |
870 | ||
871 | struct GETATTR2resok { | |
872 | fattr2 attributes; | |
873 | }; | |
874 | ||
875 | union GETATTR2res switch (nfsstat3 status) { | |
876 | case NFS3_OK: | |
877 | GETATTR2resok resok; | |
878 | default: | |
879 | void; | |
880 | }; | |
881 | ||
882 | struct SETATTR2args { | |
883 | fhandle2 fhandle; | |
884 | sattr2 attributes; | |
885 | }; | |
886 | ||
887 | struct SETATTR2resok { | |
888 | fattr2 attributes; | |
889 | }; | |
890 | ||
891 | union SETATTR2res switch (nfsstat3 status) { | |
892 | case NFS3_OK: | |
893 | SETATTR2resok resok; | |
894 | default: | |
895 | void; | |
896 | }; | |
897 | ||
898 | struct LOOKUP2args { | |
899 | diropargs2 what; | |
900 | }; | |
901 | ||
902 | struct LOOKUP2resok { | |
903 | fhandle2 file; | |
904 | fattr2 attributes; | |
905 | }; | |
906 | ||
907 | union LOOKUP2res switch (nfsstat3 status) { | |
908 | case NFS3_OK: | |
909 | LOOKUP2resok resok; | |
910 | default: | |
911 | void; | |
912 | }; | |
913 | ||
914 | struct READLINK2args { | |
915 | fhandle2 file; | |
916 | }; | |
917 | ||
918 | struct READLINK2resok { | |
919 | path2 data; | |
920 | }; | |
921 | ||
922 | union READLINK2res switch (nfsstat3 status) { | |
923 | case NFS3_OK: | |
924 | READLINK2resok resok; | |
925 | default: | |
926 | void; | |
927 | }; | |
928 | ||
929 | struct READ2args { | |
930 | fhandle2 file; | |
931 | unsigned int offset; | |
932 | unsigned int count; | |
933 | unsigned int totalcount; | |
934 | }; | |
935 | ||
936 | struct READ2resok { | |
937 | fattr2 attributes; | |
938 | nfsdata2 data; | |
939 | }; | |
940 | ||
941 | union READ2res switch (nfsstat3 status) { | |
942 | case NFS3_OK: | |
943 | READ2resok resok; | |
944 | default: | |
945 | void; | |
946 | }; | |
947 | ||
948 | struct WRITE2args { | |
949 | fhandle2 file; | |
950 | unsigned int beginoffset; | |
951 | unsigned int offset; | |
952 | unsigned int totalcount; | |
953 | nfsdata2 data; | |
954 | }; | |
955 | ||
956 | struct WRITE2resok { | |
957 | fattr2 attributes; | |
958 | }; | |
959 | ||
960 | union WRITE2res switch (nfsstat3 status) { | |
961 | case NFS3_OK: | |
962 | WRITE2resok resok; | |
963 | default: | |
964 | void; | |
965 | }; | |
966 | ||
967 | struct CREATE2args { | |
968 | diropargs2 where; | |
969 | sattr2 attributes; | |
970 | }; | |
971 | ||
972 | struct CREATE2resok { | |
973 | fhandle2 file; | |
974 | fattr2 attributes; | |
975 | }; | |
976 | ||
977 | union CREATE2res switch (nfsstat3 status) { | |
978 | case NFS3_OK: | |
979 | CREATE2resok resok; | |
980 | default: | |
981 | void; | |
982 | }; | |
983 | ||
984 | struct REMOVE2args { | |
985 | diropargs2 what; | |
986 | }; | |
987 | ||
988 | struct REMOVE2res { | |
989 | nfsstat3 status; | |
990 | }; | |
991 | ||
992 | struct RENAME2args { | |
993 | diropargs2 from; | |
994 | diropargs2 to; | |
995 | }; | |
996 | ||
997 | struct RENAME2res { | |
998 | nfsstat3 status; | |
999 | }; | |
1000 | ||
1001 | struct LINK2args { | |
1002 | fhandle2 from; | |
1003 | diropargs2 to; | |
1004 | }; | |
1005 | ||
1006 | struct LINK2res { | |
1007 | nfsstat3 status; | |
1008 | }; | |
1009 | ||
1010 | struct SYMLINK2args { | |
1011 | diropargs2 from; | |
1012 | path2 to; | |
1013 | sattr2 attributes; | |
1014 | }; | |
1015 | ||
1016 | struct SYMLINK2res { | |
1017 | nfsstat3 status; | |
1018 | }; | |
1019 | ||
1020 | struct MKDIR2args { | |
1021 | diropargs2 where; | |
1022 | sattr2 attributes; | |
1023 | }; | |
1024 | ||
1025 | struct MKDIR2resok { | |
1026 | fhandle2 file; | |
1027 | fattr2 attributes; | |
1028 | }; | |
1029 | ||
1030 | union MKDIR2res switch (nfsstat3 status) { | |
1031 | case NFS3_OK: | |
1032 | MKDIR2resok resok; | |
1033 | default: | |
1034 | void; | |
1035 | }; | |
1036 | ||
1037 | struct RMDIR2args { | |
1038 | diropargs2 what; | |
1039 | }; | |
1040 | ||
1041 | struct RMDIR2res { | |
1042 | nfsstat3 status; | |
1043 | }; | |
1044 | ||
1045 | struct READDIR2args { | |
1046 | fhandle2 dir; | |
1047 | nfscookie2 cookie; | |
1048 | unsigned int count; | |
1049 | }; | |
1050 | ||
1051 | struct READDIR2resok { | |
1052 | entry2 *entries; | |
1053 | bool eof; | |
1054 | }; | |
1055 | ||
1056 | union READDIR2res switch (nfsstat3 status) { | |
1057 | case NFS3_OK: | |
1058 | READDIR2resok resok; | |
1059 | default: | |
1060 | void; | |
1061 | }; | |
1062 | ||
1063 | struct STATFS2args { | |
1064 | fhandle2 dir; | |
1065 | }; | |
1066 | ||
1067 | struct STATFS2resok { | |
1068 | unsigned int tsize; | |
1069 | unsigned int bsize; | |
1070 | unsigned int blocks; | |
1071 | unsigned int bfree; | |
1072 | unsigned int bavail; | |
1073 | }; | |
1074 | ||
1075 | union STATFS2res switch (nfsstat3 status) { | |
1076 | case NFS3_OK: | |
1077 | STATFS2resok resok; | |
1078 | default: | |
1079 | void; | |
1080 | }; | |
1081 | ||
84004dbf | 1082 | program NFS_PROGRAM { |
f38aacf8 RS |
1083 | version NFS_V2 { |
1084 | void | |
1085 | NFS2_NULL(void) = 0; | |
1086 | ||
1087 | GETATTR2res | |
1088 | NFS2_GETATTR(GETATTR2args) = 1; | |
1089 | ||
1090 | SETATTR2res | |
1091 | NFS2_SETATTR(SETATTR2args) = 2; | |
1092 | ||
1093 | LOOKUP2res | |
1094 | NFS2_LOOKUP(LOOKUP2args) = 4; | |
1095 | ||
1096 | READLINK2res | |
1097 | NFS2_READLINK(READLINK2args) = 5; | |
1098 | ||
1099 | READ2res | |
1100 | NFS2_READ(READ2args) = 6; | |
1101 | ||
1102 | WRITE2res | |
1103 | NFS2_WRITE(WRITE2args) = 8; | |
1104 | ||
1105 | CREATE2res | |
1106 | NFS2_CREATE(CREATE2args) = 9; | |
1107 | ||
1108 | REMOVE2res | |
1109 | NFS2_REMOVE(REMOVE2args) = 10; | |
1110 | ||
1111 | RENAME2res | |
1112 | NFS2_RENAME(RENAME2args) = 11; | |
1113 | ||
1114 | LINK2res | |
1115 | NFS2_LINK(LINK2args) = 12; | |
1116 | ||
1117 | SYMLINK2res | |
1118 | NFS2_SYMLINK(SYMLINK2args) = 13; | |
1119 | ||
1120 | MKDIR2res | |
1121 | NFS2_MKDIR(MKDIR2args) = 14; | |
1122 | ||
1123 | RMDIR2res | |
1124 | NFS2_RMDIR(RMDIR2args) = 15; | |
1125 | ||
1126 | READDIR2res | |
1127 | NFS2_READDIR(READDIR2args) = 16; | |
1128 | ||
1129 | STATFS2res | |
1130 | NFS2_STATFS(STATFS2args) = 17; | |
1131 | } = 2; | |
1132 | ||
84004dbf RS |
1133 | version NFS_V3 { |
1134 | void | |
1135 | NFS3_NULL(void) = 0; | |
1136 | ||
1137 | GETATTR3res | |
1138 | NFS3_GETATTR(GETATTR3args) = 1; | |
1139 | ||
1140 | SETATTR3res | |
1141 | NFS3_SETATTR(SETATTR3args) = 2; | |
1142 | ||
1143 | LOOKUP3res | |
1144 | NFS3_LOOKUP(LOOKUP3args) = 3; | |
1145 | ||
1146 | ACCESS3res | |
1147 | NFS3_ACCESS(ACCESS3args) = 4; | |
1148 | ||
1149 | READLINK3res | |
1150 | NFS3_READLINK(READLINK3args) = 5; | |
1151 | ||
1152 | READ3res | |
1153 | NFS3_READ(READ3args) = 6; | |
1154 | ||
1155 | WRITE3res | |
1156 | NFS3_WRITE(WRITE3args) = 7; | |
1157 | ||
1158 | CREATE3res | |
1159 | NFS3_CREATE(CREATE3args) = 8; | |
1160 | ||
1161 | MKDIR3res | |
1162 | NFS3_MKDIR(MKDIR3args) = 9; | |
1163 | ||
1164 | SYMLINK3res | |
1165 | NFS3_SYMLINK(SYMLINK3args) = 10; | |
1166 | ||
1ec6b50a RS |
1167 | MKNOD3res |
1168 | NFS3_MKNOD(MKNOD3args) = 11; | |
84004dbf RS |
1169 | |
1170 | REMOVE3res | |
1171 | NFS3_REMOVE(REMOVE3args) = 12; | |
1172 | ||
1173 | RMDIR3res | |
1174 | NFS3_RMDIR(RMDIR3args) = 13; | |
1175 | ||
1176 | RENAME3res | |
1177 | NFS3_RENAME(RENAME3args) = 14; | |
1178 | ||
1179 | LINK3res | |
1180 | NFS3_LINK(LINK3args) = 15; | |
1181 | ||
1182 | READDIR3res | |
1183 | NFS3_READDIR(READDIR3args) = 16; | |
1184 | ||
1185 | READDIRPLUS3res | |
1186 | NFS3_READDIRPLUS(READDIRPLUS3args) = 17; | |
1187 | ||
1188 | FSSTAT3res | |
1189 | NFS3_FSSTAT(FSSTAT3args) = 18; | |
1190 | ||
1191 | FSINFO3res | |
1192 | NFS3_FSINFO(FSINFO3args) = 19; | |
1193 | ||
1194 | PATHCONF3res | |
1195 | NFS3_PATHCONF(PATHCONF3args) = 20; | |
1196 | ||
1197 | COMMIT3res | |
1198 | NFS3_COMMIT(COMMIT3args) = 21; | |
1199 | } = 3; | |
1200 | } = 100003; | |
3847f8f6 RS |
1201 | |
1202 | ||
1203 | ||
1204 | /* NFS ACL definitions based on wireshark souces and network traces */ | |
1205 | /* NFSACL interface. Uses same port/process as NFS */ | |
1206 | ||
1207 | enum nfsacl_type { | |
1208 | NFSACL_TYPE_USER_OBJ = 0x0001, | |
1209 | NFSACL_TYPE_USER = 0x0002, | |
1210 | NFSACL_TYPE_GROUP_OBJ = 0x0004, | |
1211 | NFSACL_TYPE_GROUP = 0x0008, | |
1212 | NFSACL_TYPE_CLASS_OBJ = 0x0010, | |
1213 | NFSACL_TYPE_CLASS = 0x0020, | |
1214 | NFSACL_TYPE_DEFAULT = 0x1000, | |
1215 | NFSACL_TYPE_DEFAULT_USER_OBJ = 0x1001, | |
1216 | NFSACL_TYPE_DEFAULT_USER = 0x1002, | |
1217 | NFSACL_TYPE_DEFAULT_GROUP_OBJ = 0x1004, | |
1218 | NFSACL_TYPE_DEFAULT_GROUP = 0x1008, | |
1219 | NFSACL_TYPE_DEFAULT_CLASS_OBJ = 0x1010, | |
1220 | NFSACL_TYPE_DEFAULT_OTHER_OBJ = 0x1020 | |
1221 | }; | |
1222 | ||
1223 | const NFSACL_PERM_READ = 0x04; | |
1224 | const NFSACL_PERM_WRITE = 0x02; | |
1225 | const NFSACL_PERM_EXEC = 0x01; | |
1226 | ||
1227 | struct nfsacl_ace { | |
1228 | enum nfsacl_type type; | |
c0ebf57b RS |
1229 | unsigned int id; |
1230 | unsigned int perm; | |
3847f8f6 RS |
1231 | }; |
1232 | ||
1233 | const NFSACL_MASK_ACL_ENTRY = 0x0001; | |
1234 | const NFSACL_MASK_ACL_COUNT = 0x0002; | |
1235 | const NFSACL_MASK_ACL_DEFAULT_ENTRY = 0x0004; | |
1236 | const NFSACL_MASK_ACL_DEFAULT_COUNT = 0x0008; | |
1237 | ||
1238 | struct GETACL3args { | |
c0ebf57b RS |
1239 | nfs_fh3 dir; |
1240 | unsigned int mask; | |
3847f8f6 RS |
1241 | }; |
1242 | ||
1243 | struct GETACL3resok { | |
c0ebf57b RS |
1244 | post_op_attr attr; |
1245 | unsigned int mask; | |
1246 | unsigned int ace_count; | |
1247 | struct nfsacl_ace ace<>; | |
1248 | unsigned int default_ace_count; | |
1249 | struct nfsacl_ace default_ace<>; | |
3847f8f6 RS |
1250 | }; |
1251 | ||
1252 | union GETACL3res switch (nfsstat3 status) { | |
1253 | case NFS3_OK: | |
1254 | GETACL3resok resok; | |
1255 | default: | |
1256 | void; | |
1257 | }; | |
1258 | ||
fa3c25be | 1259 | struct SETACL3args { |
c0ebf57b RS |
1260 | nfs_fh3 dir; |
1261 | unsigned int mask; | |
1262 | unsigned int ace_count; | |
1263 | struct nfsacl_ace ace<>; | |
1264 | unsigned int default_ace_count; | |
1265 | struct nfsacl_ace default_ace<>; | |
fa3c25be RS |
1266 | }; |
1267 | ||
1268 | struct SETACL3resok { | |
1269 | post_op_attr attr; | |
1270 | }; | |
1271 | ||
1272 | union SETACL3res switch (nfsstat3 status) { | |
1273 | case NFS3_OK: | |
1274 | SETACL3resok resok; | |
1275 | default: | |
1276 | void; | |
1277 | }; | |
1278 | ||
3847f8f6 RS |
1279 | program NFSACL_PROGRAM { |
1280 | version NFSACL_V3 { | |
1281 | void | |
1282 | NFSACL3_NULL(void) = 0; | |
1283 | ||
1284 | GETACL3res | |
1285 | NFSACL3_GETACL(GETACL3args) = 1; | |
fa3c25be RS |
1286 | |
1287 | SETACL3res | |
1288 | NFSACL3_SETACL(SETACL3args) = 2; | |
3847f8f6 RS |
1289 | } = 3; |
1290 | } = 100227; |