2 * Sun RPC is a product of Sun Microsystems, Inc. and is provided for
3 * unrestricted use provided that this legend is included on all tape
4 * media and as a part of the software program in whole or part. Users
5 * may copy or modify Sun RPC without charge, but are not authorized
6 * to license or distribute it to anyone else except as part of a product or
7 * program developed by the user.
9 * SUN RPC IS PROVIDED AS IS WITH NO WARRANTIES OF ANY KIND INCLUDING THE
10 * WARRANTIES OF DESIGN, MERCHANTIBILITY AND FITNESS FOR A PARTICULAR
11 * PURPOSE, OR ARISING FROM A COURSE OF DEALING, USAGE OR TRADE PRACTICE.
13 * Sun RPC is provided with no support and without any obligation on the
14 * part of Sun Microsystems, Inc. to assist in its use, correction,
15 * modification or enhancement.
17 * SUN MICROSYSTEMS, INC. SHALL HAVE NO LIABILITY WITH RESPECT TO THE
18 * INFRINGEMENT OF COPYRIGHTS, TRADE SECRETS OR ANY PATENTS BY SUN RPC
19 * OR ANY PART THEREOF.
21 * In no event will Sun Microsystems, Inc. be liable for any lost revenue
22 * or profits or other special, indirect and consequential damages, even if
23 * Sun has been advised of the possibility of such damages.
25 * Sun Microsystems, Inc.
27 * Mountain View, California 94043
31 %#include <sys/cdefs.h>
33 %/*static char sccsid[] = "from: @(#)nfs_prot.x 1.2 87/10/12 Copyr 1987 Sun Micro";*/
34 %/*static char sccsid[] = "from: @(#)nfs_prot.x 2.1 88/08/01 4.0 RPCSRC";*/
35 %__RCSID("$NetBSD: nfs_prot.x,v 1.6 2003/09/21 15:35:46 yamt Exp $");
36 %#endif /* not __lint__ */
39 const NFS_PORT = 2049;
40 const NFS_MAXDATA = 8192;
41 const NFS_MAXPATHLEN = 1024;
42 const NFS_MAXNAMLEN = 255;
43 const NFS_FHSIZE = 32;
44 const NFS_COOKIESIZE = 4;
45 const NFS_FIFO_DEV = -1; /* size kludge for named pipes */
50 const NFSMODE_FMT = 0170000; /* type of file */
51 const NFSMODE_DIR = 0040000; /* directory */
52 const NFSMODE_CHR = 0020000; /* character special */
53 const NFSMODE_BLK = 0060000; /* block special */
54 const NFSMODE_REG = 0100000; /* regular */
55 const NFSMODE_LNK = 0120000; /* symbolic link */
56 const NFSMODE_SOCK = 0140000; /* socket */
57 const NFSMODE_FIFO = 0010000; /* fifo */
63 NFS_OK= 0, /* no error */
64 NFSERR_PERM=1, /* Not owner */
65 NFSERR_NOENT=2, /* No such file or directory */
66 NFSERR_IO=5, /* I/O error */
67 NFSERR_NXIO=6, /* No such device or address */
68 NFSERR_ACCES=13, /* Permission denied */
69 NFSERR_EXIST=17, /* File exists */
70 NFSERR_NODEV=19, /* No such device */
71 NFSERR_NOTDIR=20, /* Not a directory*/
72 NFSERR_ISDIR=21, /* Is a directory */
73 NFSERR_FBIG=27, /* File too large */
74 NFSERR_NOSPC=28, /* No space left on device */
75 NFSERR_ROFS=30, /* Read-only file system */
76 NFSERR_NAMETOOLONG=63, /* File name too long */
77 NFSERR_NOTEMPTY=66, /* Directory not empty */
78 NFSERR_DQUOT=69, /* Disc quota exceeded */
79 NFSERR_STALE=70, /* Stale NFS file handle */
80 NFSERR_WFLUSH=99 /* write cache flushed */
87 NFNON = 0, /* non-file */
88 NFREG = 1, /* regular file */
89 NFDIR = 2, /* directory */
90 NFBLK = 3, /* block special */
91 NFCHR = 4, /* character special */
92 NFLNK = 5, /* symbolic link */
93 NFSOCK = 6, /* unix domain sockets */
94 NFBAD = 7, /* unused */
95 NFFIFO = 8 /* named pipe */
102 opaque data[NFS_FHSIZE];
118 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 nfstime atime; /* time of last access */
130 nfstime mtime; /* time of last modification */
131 nfstime ctime; /* time of last change */
135 * File attributes which can be set
138 unsigned mode; /* protection mode bits */
139 unsigned uid; /* owner user id */
140 unsigned gid; /* owner group id */
141 unsigned size; /* file size in bytes */
142 nfstime atime; /* time of last access */
143 nfstime mtime; /* time of last modification */
147 typedef string filename<NFS_MAXNAMLEN>;
148 typedef string nfspath<NFS_MAXPATHLEN>;
151 * Reply status with file attributes
153 union attrstat switch (nfsstat status) {
166 * Arguments for directory operations
169 nfs_fh dir; /* directory file handle */
170 filename name; /* name (up to NFS_MAXNAMLEN bytes) */
179 * Results from directory operation
181 union diropres switch (nfsstat status) {
188 union readlinkres switch (nfsstat status) {
196 * Arguments to remote read
199 nfs_fh file; /* handle for file */
200 unsigned offset; /* byte offset in file */
201 unsigned count; /* immediate read count */
202 unsigned totalcount; /* total read count (from this offset)*/
206 * Status OK portion of remote read reply
209 fattr attributes; /* attributes, need for pagin*/
210 opaque data<NFS_MAXDATA>;
213 union readres switch (nfsstat status) {
221 * Arguments to remote write
224 nfs_fh file; /* handle for file */
225 unsigned beginoffset; /* beginning byte offset in file */
226 unsigned offset; /* current byte offset in file */
227 unsigned totalcount; /* total write count (to this offset)*/
228 opaque data<NFS_MAXDATA>;
253 typedef opaque nfscookie[NFS_COOKIESIZE];
256 * Arguments to readdir
259 nfs_fh dir; /* directory handle */
261 unsigned count; /* number of directory bytes to read */
276 union readdirres switch (nfsstat status) {
284 unsigned tsize; /* preferred transfer size in bytes */
285 unsigned bsize; /* fundamental file system block size */
286 unsigned blocks; /* total blocks in file system */
287 unsigned bfree; /* free blocks in fs */
288 unsigned bavail; /* free blocks avail to non-superuser */
291 union statfsres switch (nfsstat status) {
299 * NFSv3 constants and types
301 const NFS3_FHSIZE = 64; /* maximum size in bytes of a file handle */
302 const NFS3_COOKIEVERFSIZE = 8; /* size of a cookie verifier for READDIR */
303 const NFS3_CREATEVERFSIZE = 8; /* size of the verifier used for CREATE */
304 const NFS3_WRITEVERFSIZE = 8; /* size of the verifier used for WRITE */
306 typedef string filename3<>;
307 typedef string nfspath3<>;
308 typedef u_int64_t fileid3;
309 typedef u_int64_t cookie3;
310 typedef opaque cookieverf3[NFS3_COOKIEVERFSIZE];
311 typedef opaque createverf3[NFS3_CREATEVERFSIZE];
312 typedef opaque writeverf3[NFS3_WRITEVERFSIZE];
313 typedef u_int32_t uid3;
314 typedef u_int32_t gid3;
315 typedef u_int64_t size3;
316 typedef u_int64_t offset3;
317 typedef u_int32_t mode3;
318 typedef u_int32_t count3;
340 NFS3ERR_NAMETOOLONG = 63,
341 NFS3ERR_NOTEMPTY = 66,
345 NFS3ERR_BADHANDLE = 10001,
346 NFS3ERR_NOT_SYNC = 10002,
347 NFS3ERR_BAD_COOKIE = 10003,
348 NFS3ERR_NOTSUPP = 10004,
349 NFS3ERR_TOOSMALL = 10005,
350 NFS3ERR_SERVERFAULT = 10006,
351 NFS3ERR_BADTYPE = 10007,
352 NFS3ERR_JUKEBOX = 10008
359 NF3REG = 1, /* regular file */
360 NF3DIR = 2, /* directory */
361 NF3BLK = 3, /* block special */
362 NF3CHR = 4, /* character special */
363 NF3LNK = 5, /* symbolic link */
364 NF3SOCK = 6, /* unix domain sockets */
365 NF3FIFO = 7 /* named pipe */
374 * File access handle (v3)
377 opaque data<NFS3_FHSIZE>;
390 * File attributes (v3)
393 ftype3 type; /* file type */
394 mode3 mode; /* protection mode bits */
395 u_int32_t nlink; /* # hard links */
396 uid3 uid; /* owner user id */
397 gid3 gid; /* owner group id */
398 size3 size; /* file size in bytes */
399 size3 used; /* prefered block size */
400 specdata3 rdev; /* special device # */
401 u_int64_t fsid; /* device # */
402 fileid3 fileid; /* inode # */
403 nfstime3 atime; /* time of last access */
404 nfstime3 mtime; /* time of last modification */
405 nfstime3 ctime; /* time of last change */
408 union post_op_attr switch (bool attributes_follow) {
421 union pre_op_attr switch (bool attributes_follow) {
433 union post_op_fh3 switch (bool handle_follows) {
441 * File attributes which can be set (v3)
445 SET_TO_SERVER_TIME = 1,
446 SET_TO_CLIENT_TIME = 2
449 union set_mode3 switch (bool set_it) {
456 union set_uid3 switch (bool set_it) {
463 union set_gid3 switch (bool set_it) {
470 union set_size3 switch (bool set_it) {
477 union set_atime switch (time_how set_it) {
478 case SET_TO_CLIENT_TIME:
484 union set_mtime switch (time_how set_it) {
485 case SET_TO_CLIENT_TIME:
501 * Arguments for directory operations (v3)
504 nfs_fh3 dir; /* directory file handle */
505 filename3 name; /* name (up to NFS_MAXNAMLEN bytes) */
509 * Arguments to getattr (v3).
511 struct GETATTR3args {
515 struct GETATTR3resok {
516 fattr3 obj_attributes;
519 union GETATTR3res switch (nfsstat3 status) {
527 * Arguments to setattr (v3).
529 union sattrguard3 switch (bool check) {
536 struct SETATTR3args {
538 sattr3 new_attributes;
542 struct SETATTR3resok {
546 struct SETATTR3resfail {
550 union SETATTR3res switch (nfsstat3 status) {
554 SETATTR3resfail resfail;
558 * Arguments to lookup (v3).
564 struct LOOKUP3resok {
566 post_op_attr obj_attributes;
567 post_op_attr dir_attributes;
570 struct LOOKUP3resfail {
571 post_op_attr dir_attributes;
574 union LOOKUP3res switch (nfsstat3 status) {
578 LOOKUP3resfail resfail;
582 * Arguments to access (v3).
584 const ACCESS3_READ = 0x0001;
585 const ACCESS3_LOOKUP = 0x0002;
586 const ACCESS3_MODIFY = 0x0004;
587 const ACCESS3_EXTEND = 0x0008;
588 const ACCESS3_DELETE = 0x0010;
589 const ACCESS3_EXECUTE = 0x0020;
596 struct ACCESS3resok {
597 post_op_attr obj_attributes;
601 struct ACCESS3resfail {
602 post_op_attr obj_attributes;
605 union ACCESS3res switch (nfsstat3 status) {
609 ACCESS3resfail resfail;
613 * Arguments to readlink (v3).
615 struct READLINK3args {
619 struct READLINK3resok {
620 post_op_attr symlink_attributes;
624 struct READLINK3resfail {
625 post_op_attr symlink_attributes;
628 union READLINK3res switch (nfsstat3 status) {
630 READLINK3resok resok;
632 READLINK3resfail resfail;
636 * Arguments to read (v3).
645 post_op_attr file_attributes;
651 struct READ3resfail {
652 post_op_attr file_attributes;
655 /* XXX: solaris 2.6 uses ``nfsstat'' here */
656 union READ3res switch (nfsstat3 status) {
660 READ3resfail resfail;
664 * Arguments to write (v3).
683 stable_how committed;
687 struct WRITE3resfail {
691 union WRITE3res switch (nfsstat3 status) {
695 WRITE3resfail resfail;
699 * Arguments to create (v3).
707 union createhow3 switch (createmode3 mode) {
710 sattr3 obj_attributes;
720 struct CREATE3resok {
722 post_op_attr obj_attributes;
726 struct CREATE3resfail {
730 union CREATE3res switch (nfsstat3 status) {
734 CREATE3resfail resfail;
738 * Arguments to mkdir (v3).
747 post_op_attr obj_attributes;
751 struct MKDIR3resfail {
755 union MKDIR3res switch (nfsstat3 status) {
759 MKDIR3resfail resfail;
763 * Arguments to symlink (v3).
765 struct symlinkdata3 {
766 sattr3 symlink_attributes;
767 nfspath3 symlink_data;
770 struct SYMLINK3args {
772 symlinkdata3 symlink;
775 struct SYMLINK3resok {
777 post_op_attr obj_attributes;
781 struct SYMLINK3resfail {
785 union SYMLINK3res switch (nfsstat3 status) {
789 SYMLINK3resfail resfail;
793 * Arguments to mknod (v3).
796 sattr3 dev_attributes;
800 union mknoddata3 switch (ftype3 type) {
806 sattr3 pipe_attributes;
818 post_op_attr obj_attributes;
822 struct MKNOD3resfail {
826 union MKNOD3res switch (nfsstat3 status) {
830 MKNOD3resfail resfail;
834 * Arguments to remove (v3).
840 struct REMOVE3resok {
844 struct REMOVE3resfail {
848 union REMOVE3res switch (nfsstat3 status) {
852 REMOVE3resfail resfail;
856 * Arguments to rmdir (v3).
866 struct RMDIR3resfail {
870 union RMDIR3res switch (nfsstat3 status) {
874 RMDIR3resfail resfail;
878 * Arguments to rename (v3).
885 struct RENAME3resok {
886 wcc_data fromdir_wcc;
890 struct RENAME3resfail {
891 wcc_data fromdir_wcc;
895 union RENAME3res switch (nfsstat3 status) {
899 RENAME3resfail resfail;
903 * Arguments to link (v3).
911 post_op_attr file_attributes;
912 wcc_data linkdir_wcc;
915 struct LINK3resfail {
916 post_op_attr file_attributes;
917 wcc_data linkdir_wcc;
920 union LINK3res switch (nfsstat3 status) {
924 LINK3resfail resfail;
928 * Arguments to readdir (v3).
930 struct READDIR3args {
933 cookieverf3 cookieverf;
949 struct READDIR3resok {
950 post_op_attr dir_attributes;
951 cookieverf3 cookieverf;
955 struct READDIR3resfail {
956 post_op_attr dir_attributes;
959 union READDIR3res switch (nfsstat3 status) {
963 READDIR3resfail resfail;
967 * Arguments to readdirplus (v3).
969 struct READDIRPLUS3args {
972 cookieverf3 cookieverf;
981 post_op_attr name_attributes;
982 post_op_fh3 name_handle;
983 entryplus3 *nextentry;
986 struct dirlistplus3 {
991 struct READDIRPLUS3resok {
992 post_op_attr dir_attributes;
993 cookieverf3 cookieverf;
997 struct READDIRPLUS3resfail {
998 post_op_attr dir_attributes;
1001 union READDIRPLUS3res switch (nfsstat3 status) {
1003 READDIRPLUS3resok resok;
1005 READDIRPLUS3resfail resfail;
1009 * Arguments to fsstat (v3).
1011 struct FSSTAT3args {
1015 struct FSSTAT3resok {
1016 post_op_attr obj_attributes;
1026 struct FSSTAT3resfail {
1027 post_op_attr obj_attributes;
1030 union FSSTAT3res switch (nfsstat3 status) {
1034 FSSTAT3resfail resfail;
1038 * Arguments to fsinfo (v3).
1040 const FSF3_LINK = 0x0001;
1041 const FSF3_SYMLINK = 0x0002;
1042 const FSF3_HOMOGENEOUS = 0x0008;
1043 const FSF3_CANSETTIME = 0x0010;
1045 struct FSINFO3args {
1049 struct FSINFO3resok {
1050 post_op_attr obj_attributes;
1059 nfstime3 time_delta;
1060 u_int32_t properties;
1063 struct FSINFO3resfail {
1064 post_op_attr obj_attributes;
1067 union FSINFO3res switch (nfsstat3 status) {
1071 FSINFO3resfail resfail;
1075 * Arguments to pathconf (v3).
1077 struct PATHCONF3args {
1081 struct PATHCONF3resok {
1082 post_op_attr obj_attributes;
1086 bool chown_restricted;
1087 bool case_insensitive;
1088 bool case_preserving;
1091 struct PATHCONF3resfail {
1092 post_op_attr obj_attributes;
1095 union PATHCONF3res switch (nfsstat3 status) {
1097 PATHCONF3resok resok;
1099 PATHCONF3resfail resfail;
1103 * Arguments to commit (v3).
1105 struct COMMIT3args {
1111 struct COMMIT3resok {
1116 struct COMMIT3resfail {
1120 union COMMIT3res switch (nfsstat3 status) {
1124 COMMIT3resfail resfail;
1128 * Remote file service routines
1130 program NFS_PROGRAM {
1131 version NFS_VERSION {
1133 NFSPROC_NULL(void) = 0;
1136 NFSPROC_GETATTR(nfs_fh) = 1;
1139 NFSPROC_SETATTR(sattrargs) = 2;
1142 NFSPROC_ROOT(void) = 3;
1145 NFSPROC_LOOKUP(diropargs) = 4;
1148 NFSPROC_READLINK(nfs_fh) = 5;
1151 NFSPROC_READ(readargs) = 6;
1154 NFSPROC_WRITECACHE(void) = 7;
1157 NFSPROC_WRITE(writeargs) = 8;
1160 NFSPROC_CREATE(createargs) = 9;
1163 NFSPROC_REMOVE(diropargs) = 10;
1166 NFSPROC_RENAME(renameargs) = 11;
1169 NFSPROC_LINK(linkargs) = 12;
1172 NFSPROC_SYMLINK(symlinkargs) = 13;
1175 NFSPROC_MKDIR(createargs) = 14;
1178 NFSPROC_RMDIR(diropargs) = 15;
1181 NFSPROC_READDIR(readdirargs) = 16;
1184 NFSPROC_STATFS(nfs_fh) = 17;
1188 NFSPROC3_NULL(void) = 0;
1191 NFSPROC3_GETATTR(GETATTR3args) = 1;
1194 NFSPROC3_SETATTR(SETATTR3args) = 2;
1197 NFSPROC3_LOOKUP(LOOKUP3args) = 3;
1200 NFSPROC3_ACCESS(ACCESS3args) = 4;
1203 NFSPROC3_READLINK(READLINK3args) = 5;
1206 NFSPROC3_READ(READ3args) = 6;
1209 NFSPROC3_WRITE(WRITE3args) = 7;
1212 NFSPROC3_CREATE(CREATE3args) = 8;
1215 NFSPROC3_MKDIR(MKDIR3args) = 9;
1218 NFSPROC3_SYMLINK(SYMLINK3args) = 10;
1221 NFSPROC3_MKNOD(MKNOD3args) = 11;
1224 NFSPROC3_REMOVE(REMOVE3args) = 12;
1227 NFSPROC3_RMDIR(RMDIR3args) = 13;
1230 NFSPROC3_RENAME(RENAME3args) = 14;
1233 NFSPROC3_LINK(LINK3args) = 15;
1236 NFSPROC3_READDIR(READDIR3args) = 16;
1239 NFSPROC3_READDIRPLUS(READDIRPLUS3args) = 17;
1242 NFSPROC3_FSSTAT(FSSTAT3args) = 18;
1245 NFSPROC3_FSINFO(FSINFO3args) = 19;
1248 NFSPROC3_PATHCONF(PATHCONF3args) = 20;
1251 NFSPROC3_COMMIT(COMMIT3args) = 21;