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
29 * @(#)nfs_prot.x 1.2 87/10/12 Copyr 1987 Sun Micro
30 * @(#)nfs_prot.x 2.1 88/08/01 4.0 RPCSRC
31 * $FreeBSD: src/include/rpcsvc/nfs_prot.x,v 1.7 1999/08/27 23:45:08 peter Exp $
32 * $DragonFly: src/include/rpcsvc/nfs_prot.x,v 1.2 2003/06/17 04:25:58 dillon Exp $
35 const NFS_PORT = 2049;
36 const NFS_MAXDATA = 8192;
37 const NFS_MAXPATHLEN = 1024;
38 const NFS_MAXNAMLEN = 255;
39 const NFS_FHSIZE = 32;
40 const NFS_COOKIESIZE = 4;
41 const NFS_FIFO_DEV = -1; /* size kludge for named pipes */
46 const NFSMODE_FMT = 0170000; /* type of file */
47 const NFSMODE_DIR = 0040000; /* directory */
48 const NFSMODE_CHR = 0020000; /* character special */
49 const NFSMODE_BLK = 0060000; /* block special */
50 const NFSMODE_REG = 0100000; /* regular */
51 const NFSMODE_LNK = 0120000; /* symbolic link */
52 const NFSMODE_SOCK = 0140000; /* socket */
53 const NFSMODE_FIFO = 0010000; /* fifo */
59 NFS_OK= 0, /* no error */
60 NFSERR_PERM=1, /* Not owner */
61 NFSERR_NOENT=2, /* No such file or directory */
62 NFSERR_IO=5, /* I/O error */
63 NFSERR_NXIO=6, /* No such device or address */
64 NFSERR_ACCES=13, /* Permission denied */
65 NFSERR_EXIST=17, /* File exists */
66 NFSERR_NODEV=19, /* No such device */
67 NFSERR_NOTDIR=20, /* Not a directory*/
68 NFSERR_ISDIR=21, /* Is a directory */
69 NFSERR_FBIG=27, /* File too large */
70 NFSERR_NOSPC=28, /* No space left on device */
71 NFSERR_ROFS=30, /* Read-only file system */
72 NFSERR_NAMETOOLONG=63, /* File name too long */
73 NFSERR_NOTEMPTY=66, /* Directory not empty */
74 NFSERR_DQUOT=69, /* Disc quota exceeded */
75 NFSERR_STALE=70, /* Stale NFS file handle */
76 NFSERR_WFLUSH=99 /* write cache flushed */
83 NFNON = 0, /* non-file */
84 NFREG = 1, /* regular file */
85 NFDIR = 2, /* directory */
86 NFBLK = 3, /* block special */
87 NFCHR = 4, /* character special */
88 NFLNK = 5, /* symbolic link */
89 NFSOCK = 6, /* unix domain sockets */
90 NFBAD = 7, /* unused */
91 NFFIFO = 8 /* named pipe */
98 opaque data[NFS_FHSIZE];
114 ftype type; /* file type */
115 unsigned mode; /* protection mode bits */
116 unsigned nlink; /* # hard links */
117 unsigned uid; /* owner user id */
118 unsigned gid; /* owner group id */
119 unsigned size; /* file size in bytes */
120 unsigned blocksize; /* prefered block size */
121 unsigned rdev; /* special device # */
122 unsigned blocks; /* Kb of disk used by file */
123 unsigned fsid; /* device # */
124 unsigned fileid; /* inode # */
125 nfstime atime; /* time of last access */
126 nfstime mtime; /* time of last modification */
127 nfstime ctime; /* time of last change */
131 * File attributes which can be set
134 unsigned mode; /* protection mode bits */
135 unsigned uid; /* owner user id */
136 unsigned gid; /* owner group id */
137 unsigned size; /* file size in bytes */
138 nfstime atime; /* time of last access */
139 nfstime mtime; /* time of last modification */
143 typedef string filename<NFS_MAXNAMLEN>;
144 typedef string nfspath<NFS_MAXPATHLEN>;
147 * Reply status with file attributes
149 union attrstat switch (nfsstat status) {
162 * Arguments for directory operations
165 nfs_fh dir; /* directory file handle */
166 filename name; /* name (up to NFS_MAXNAMLEN bytes) */
175 * Results from directory operation
177 union diropres switch (nfsstat status) {
184 union readlinkres switch (nfsstat status) {
192 * Arguments to remote read
195 nfs_fh file; /* handle for file */
196 unsigned offset; /* byte offset in file */
197 unsigned count; /* immediate read count */
198 unsigned totalcount; /* total read count (from this offset)*/
202 * Status OK portion of remote read reply
205 fattr attributes; /* attributes, need for pagin*/
206 opaque data<NFS_MAXDATA>;
209 union readres switch (nfsstat status) {
217 * Arguments to remote write
220 nfs_fh file; /* handle for file */
221 unsigned beginoffset; /* beginning byte offset in file */
222 unsigned offset; /* current byte offset in file */
223 unsigned totalcount; /* total write count (to this offset)*/
224 opaque data<NFS_MAXDATA>;
249 typedef opaque nfscookie[NFS_COOKIESIZE];
252 * Arguments to readdir
255 nfs_fh dir; /* directory handle */
257 unsigned count; /* number of directory bytes to read */
272 union readdirres switch (nfsstat status) {
280 unsigned tsize; /* preferred transfer size in bytes */
281 unsigned bsize; /* fundamental file system block size */
282 unsigned blocks; /* total blocks in file system */
283 unsigned bfree; /* free blocks in fs */
284 unsigned bavail; /* free blocks avail to non-superuser */
287 union statfsres switch (nfsstat status) {
297 * NFSv3 constants and types
299 const NFS3_FHSIZE = 64; /* maximum size in bytes of a file handle */
300 const NFS3_COOKIEVERFSIZE = 8; /* size of a cookie verifier for READDIR */
301 const NFS3_CREATEVERFSIZE = 8; /* size of the verifier used for CREATE */
302 const NFS3_WRITEVERFSIZE = 8; /* size of the verifier used for WRITE */
304 typedef unsigned hyper uint64;
306 typedef unsigned long uint32;
308 typedef string filename3<>;
309 typedef string nfspath3<>;
310 typedef uint64 fileid3;
311 typedef uint64 cookie3;
312 typedef opaque cookieverf3[NFS3_COOKIEVERFSIZE];
313 typedef opaque createverf3[NFS3_CREATEVERFSIZE];
314 typedef opaque writeverf3[NFS3_WRITEVERFSIZE];
317 typedef uint64 size3;
318 typedef uint64 offset3;
319 typedef uint32 mode3;
320 typedef uint32 count3;
342 NFS3ERR_NAMETOOLONG = 63,
343 NFS3ERR_NOTEMPTY = 66,
347 NFS3ERR_BADHANDLE = 10001,
348 NFS3ERR_NOT_SYNC = 10002,
349 NFS3ERR_BAD_COOKIE = 10003,
350 NFS3ERR_NOTSUPP = 10004,
351 NFS3ERR_TOOSMALL = 10005,
352 NFS3ERR_SERVERFAULT = 10006,
353 NFS3ERR_BADTYPE = 10007,
354 NFS3ERR_JUKEBOX = 10008
361 NF3REG = 1, /* regular file */
362 NF3DIR = 2, /* directory */
363 NF3BLK = 3, /* block special */
364 NF3CHR = 4, /* character special */
365 NF3LNK = 5, /* symbolic link */
366 NF3SOCK = 6, /* unix domain sockets */
367 NF3FIFO = 7 /* named pipe */
376 * File access handle (v3)
379 opaque data<NFS3_FHSIZE>;
392 * File attributes (v3)
395 ftype3 type; /* file type */
396 mode3 mode; /* protection mode bits */
397 uint32 nlink; /* # hard links */
398 uid3 uid; /* owner user id */
399 gid3 gid; /* owner group id */
400 size3 size; /* file size in bytes */
401 size3 used; /* prefered block size */
402 specdata3 rdev; /* special device # */
403 uint64 fsid; /* device # */
404 fileid3 fileid; /* inode # */
405 nfstime3 atime; /* time of last access */
406 nfstime3 mtime; /* time of last modification */
407 nfstime3 ctime; /* time of last change */
410 union post_op_attr switch (bool attributes_follow) {
423 union pre_op_attr switch (bool attributes_follow) {
435 union post_op_fh3 switch (bool handle_follows) {
443 * File attributes which can be set (v3)
447 SET_TO_SERVER_TIME = 1,
448 SET_TO_CLIENT_TIME = 2
451 union set_mode3 switch (bool set_it) {
458 union set_uid3 switch (bool set_it) {
465 union set_gid3 switch (bool set_it) {
472 union set_size3 switch (bool set_it) {
479 union set_atime switch (time_how set_it) {
480 case SET_TO_CLIENT_TIME:
486 union set_mtime switch (time_how set_it) {
487 case SET_TO_CLIENT_TIME:
503 * Arguments for directory operations (v3)
506 nfs_fh3 dir; /* directory file handle */
507 filename3 name; /* name (up to NFS_MAXNAMLEN bytes) */
511 * Arguments to getattr (v3).
513 struct GETATTR3args {
517 struct GETATTR3resok {
518 fattr3 obj_attributes;
521 union GETATTR3res switch (nfsstat3 status) {
529 * Arguments to setattr (v3).
531 union sattrguard3 switch (bool check) {
538 struct SETATTR3args {
540 sattr3 new_attributes;
544 struct SETATTR3resok {
548 struct SETATTR3resfail {
552 union SETATTR3res switch (nfsstat3 status) {
556 SETATTR3resfail resfail;
560 * Arguments to lookup (v3).
566 struct LOOKUP3resok {
568 post_op_attr obj_attributes;
569 post_op_attr dir_attributes;
572 struct LOOKUP3resfail {
573 post_op_attr dir_attributes;
576 union LOOKUP3res switch (nfsstat3 status) {
580 LOOKUP3resfail resfail;
584 * Arguments to access (v3).
586 const ACCESS3_READ = 0x0001;
587 const ACCESS3_LOOKUP = 0x0002;
588 const ACCESS3_MODIFY = 0x0004;
589 const ACCESS3_EXTEND = 0x0008;
590 const ACCESS3_DELETE = 0x0010;
591 const ACCESS3_EXECUTE = 0x0020;
598 struct ACCESS3resok {
599 post_op_attr obj_attributes;
603 struct ACCESS3resfail {
604 post_op_attr obj_attributes;
607 union ACCESS3res switch (nfsstat3 status) {
611 ACCESS3resfail resfail;
615 * Arguments to readlink (v3).
617 struct READLINK3args {
621 struct READLINK3resok {
622 post_op_attr symlink_attributes;
626 struct READLINK3resfail {
627 post_op_attr symlink_attributes;
630 union READLINK3res switch (nfsstat3 status) {
632 READLINK3resok resok;
634 READLINK3resfail resfail;
638 * Arguments to read (v3).
647 post_op_attr file_attributes;
653 struct READ3resfail {
654 post_op_attr file_attributes;
657 /* XXX: solaris 2.6 uses ``nfsstat'' here */
658 union READ3res switch (nfsstat3 status) {
662 READ3resfail resfail;
666 * Arguments to write (v3).
685 stable_how committed;
689 struct WRITE3resfail {
693 union WRITE3res switch (nfsstat3 status) {
697 WRITE3resfail resfail;
701 * Arguments to create (v3).
709 union createhow3 switch (createmode3 mode) {
712 sattr3 obj_attributes;
722 struct CREATE3resok {
724 post_op_attr obj_attributes;
728 struct CREATE3resfail {
732 union CREATE3res switch (nfsstat3 status) {
736 CREATE3resfail resfail;
740 * Arguments to mkdir (v3).
749 post_op_attr obj_attributes;
753 struct MKDIR3resfail {
757 union MKDIR3res switch (nfsstat3 status) {
761 MKDIR3resfail resfail;
765 * Arguments to symlink (v3).
767 struct symlinkdata3 {
768 sattr3 symlink_attributes;
769 nfspath3 symlink_data;
772 struct SYMLINK3args {
774 symlinkdata3 symlink;
777 struct SYMLINK3resok {
779 post_op_attr obj_attributes;
783 struct SYMLINK3resfail {
787 union SYMLINK3res switch (nfsstat3 status) {
791 SYMLINK3resfail resfail;
795 * Arguments to mknod (v3).
798 sattr3 dev_attributes;
802 union mknoddata3 switch (ftype3 type) {
808 sattr3 pipe_attributes;
820 post_op_attr obj_attributes;
824 struct MKNOD3resfail {
828 union MKNOD3res switch (nfsstat3 status) {
832 MKNOD3resfail resfail;
836 * Arguments to remove (v3).
842 struct REMOVE3resok {
846 struct REMOVE3resfail {
850 union REMOVE3res switch (nfsstat3 status) {
854 REMOVE3resfail resfail;
858 * Arguments to rmdir (v3).
868 struct RMDIR3resfail {
872 union RMDIR3res switch (nfsstat3 status) {
876 RMDIR3resfail resfail;
880 * Arguments to rename (v3).
887 struct RENAME3resok {
888 wcc_data fromdir_wcc;
892 struct RENAME3resfail {
893 wcc_data fromdir_wcc;
897 union RENAME3res switch (nfsstat3 status) {
901 RENAME3resfail resfail;
905 * Arguments to link (v3).
913 post_op_attr file_attributes;
914 wcc_data linkdir_wcc;
917 struct LINK3resfail {
918 post_op_attr file_attributes;
919 wcc_data linkdir_wcc;
922 union LINK3res switch (nfsstat3 status) {
926 LINK3resfail resfail;
930 * Arguments to readdir (v3).
932 struct READDIR3args {
935 cookieverf3 cookieverf;
951 struct READDIR3resok {
952 post_op_attr dir_attributes;
953 cookieverf3 cookieverf;
957 struct READDIR3resfail {
958 post_op_attr dir_attributes;
961 union READDIR3res switch (nfsstat3 status) {
965 READDIR3resfail resfail;
969 * Arguments to readdirplus (v3).
971 struct READDIRPLUS3args {
974 cookieverf3 cookieverf;
983 post_op_attr name_attributes;
984 post_op_fh3 name_handle;
985 entryplus3 *nextentry;
988 struct dirlistplus3 {
993 struct READDIRPLUS3resok {
994 post_op_attr dir_attributes;
995 cookieverf3 cookieverf;
999 struct READDIRPLUS3resfail {
1000 post_op_attr dir_attributes;
1003 union READDIRPLUS3res switch (nfsstat3 status) {
1005 READDIRPLUS3resok resok;
1007 READDIRPLUS3resfail resfail;
1011 * Arguments to fsstat (v3).
1013 struct FSSTAT3args {
1017 struct FSSTAT3resok {
1018 post_op_attr obj_attributes;
1028 struct FSSTAT3resfail {
1029 post_op_attr obj_attributes;
1032 union FSSTAT3res switch (nfsstat3 status) {
1036 FSSTAT3resfail resfail;
1040 * Arguments to fsinfo (v3).
1042 const FSF3_LINK = 0x0001;
1043 const FSF3_SYMLINK = 0x0002;
1044 const FSF3_HOMOGENEOUS = 0x0008;
1045 const FSF3_CANSETTIME = 0x0010;
1047 struct FSINFO3args {
1051 struct FSINFO3resok {
1052 post_op_attr obj_attributes;
1061 nfstime3 time_delta;
1065 struct FSINFO3resfail {
1066 post_op_attr obj_attributes;
1069 union FSINFO3res switch (nfsstat3 status) {
1073 FSINFO3resfail resfail;
1077 * Arguments to pathconf (v3).
1079 struct PATHCONF3args {
1083 struct PATHCONF3resok {
1084 post_op_attr obj_attributes;
1088 bool chown_restricted;
1089 bool case_insensitive;
1090 bool case_preserving;
1093 struct PATHCONF3resfail {
1094 post_op_attr obj_attributes;
1097 union PATHCONF3res switch (nfsstat3 status) {
1099 PATHCONF3resok resok;
1101 PATHCONF3resfail resfail;
1105 * Arguments to commit (v3).
1107 struct COMMIT3args {
1113 struct COMMIT3resok {
1118 struct COMMIT3resfail {
1122 union COMMIT3res switch (nfsstat3 status) {
1126 COMMIT3resfail resfail;
1129 #endif /* WANT_NFS3 */
1132 * Remote file service routines
1134 program NFS_PROGRAM {
1135 version NFS_VERSION {
1137 NFSPROC_NULL(void) = 0;
1140 NFSPROC_GETATTR(nfs_fh) = 1;
1143 NFSPROC_SETATTR(sattrargs) = 2;
1146 NFSPROC_ROOT(void) = 3;
1149 NFSPROC_LOOKUP(diropargs) = 4;
1152 NFSPROC_READLINK(nfs_fh) = 5;
1155 NFSPROC_READ(readargs) = 6;
1158 NFSPROC_WRITECACHE(void) = 7;
1161 NFSPROC_WRITE(writeargs) = 8;
1164 NFSPROC_CREATE(createargs) = 9;
1167 NFSPROC_REMOVE(diropargs) = 10;
1170 NFSPROC_RENAME(renameargs) = 11;
1173 NFSPROC_LINK(linkargs) = 12;
1176 NFSPROC_SYMLINK(symlinkargs) = 13;
1179 NFSPROC_MKDIR(createargs) = 14;
1182 NFSPROC_RMDIR(diropargs) = 15;
1185 NFSPROC_READDIR(readdirargs) = 16;
1188 NFSPROC_STATFS(nfs_fh) = 17;
1192 program NFS3_PROGRAM {
1195 NFSPROC3_NULL(void) = 0;
1198 NFSPROC3_GETATTR(GETATTR3args) = 1;
1201 NFSPROC3_SETATTR(SETATTR3args) = 2;
1204 NFSPROC3_LOOKUP(LOOKUP3args) = 3;
1207 NFSPROC3_ACCESS(ACCESS3args) = 4;
1210 NFSPROC3_READLINK(READLINK3args) = 5;
1213 NFSPROC3_READ(READ3args) = 6;
1216 NFSPROC3_WRITE(WRITE3args) = 7;
1219 NFSPROC3_CREATE(CREATE3args) = 8;
1222 NFSPROC3_MKDIR(MKDIR3args) = 9;
1225 NFSPROC3_SYMLINK(SYMLINK3args) = 10;
1228 NFSPROC3_MKNOD(MKNOD3args) = 11;
1231 NFSPROC3_REMOVE(REMOVE3args) = 12;
1234 NFSPROC3_RMDIR(RMDIR3args) = 13;
1237 NFSPROC3_RENAME(RENAME3args) = 14;
1240 NFSPROC3_LINK(LINK3args) = 15;
1243 NFSPROC3_READDIR(READDIR3args) = 16;
1246 NFSPROC3_READDIRPLUS(READDIRPLUS3args) = 17;
1249 NFSPROC3_FSSTAT(FSSTAT3args) = 18;
1252 NFSPROC3_FSINFO(FSINFO3args) = 19;
1255 NFSPROC3_PATHCONF(PATHCONF3args) = 20;
1258 NFSPROC3_COMMIT(COMMIT3args) = 21;