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, MERCHANTABILITY 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 $
34 const NFS_PORT = 2049;
35 const NFS_MAXDATA = 8192;
36 const NFS_MAXPATHLEN = 1024;
37 const NFS_MAXNAMLEN = 255;
38 const NFS_FHSIZE = 32;
39 const NFS_COOKIESIZE = 4;
40 const NFS_FIFO_DEV = -1; /* size kludge for named pipes */
45 const NFSMODE_FMT = 0170000; /* type of file */
46 const NFSMODE_DIR = 0040000; /* directory */
47 const NFSMODE_CHR = 0020000; /* character special */
48 const NFSMODE_BLK = 0060000; /* block special */
49 const NFSMODE_REG = 0100000; /* regular */
50 const NFSMODE_LNK = 0120000; /* symbolic link */
51 const NFSMODE_SOCK = 0140000; /* socket */
52 const NFSMODE_FIFO = 0010000; /* fifo */
58 NFS_OK= 0, /* no error */
59 NFSERR_PERM=1, /* Not owner */
60 NFSERR_NOENT=2, /* No such file or directory */
61 NFSERR_IO=5, /* I/O error */
62 NFSERR_NXIO=6, /* No such device or address */
63 NFSERR_ACCES=13, /* Permission denied */
64 NFSERR_EXIST=17, /* File exists */
65 NFSERR_NODEV=19, /* No such device */
66 NFSERR_NOTDIR=20, /* Not a directory*/
67 NFSERR_ISDIR=21, /* Is a directory */
68 NFSERR_FBIG=27, /* File too large */
69 NFSERR_NOSPC=28, /* No space left on device */
70 NFSERR_ROFS=30, /* Read-only file system */
71 NFSERR_NAMETOOLONG=63, /* File name too long */
72 NFSERR_NOTEMPTY=66, /* Directory not empty */
73 NFSERR_DQUOT=69, /* Disc quota exceeded */
74 NFSERR_STALE=70, /* Stale NFS file handle */
75 NFSERR_WFLUSH=99 /* write cache flushed */
82 NFNON = 0, /* non-file */
83 NFREG = 1, /* regular file */
84 NFDIR = 2, /* directory */
85 NFBLK = 3, /* block special */
86 NFCHR = 4, /* character special */
87 NFLNK = 5, /* symbolic link */
88 NFSOCK = 6, /* unix domain sockets */
89 NFBAD = 7, /* unused */
90 NFFIFO = 8 /* named pipe */
97 opaque data[NFS_FHSIZE];
113 ftype type; /* file type */
114 unsigned mode; /* protection mode bits */
115 unsigned nlink; /* # hard links */
116 unsigned uid; /* owner user id */
117 unsigned gid; /* owner group id */
118 unsigned size; /* file size in bytes */
119 unsigned blocksize; /* prefered block size */
120 unsigned rdev; /* special device # */
121 unsigned blocks; /* Kb of disk used by file */
122 unsigned fsid; /* device # */
123 unsigned fileid; /* inode # */
124 nfstime atime; /* time of last access */
125 nfstime mtime; /* time of last modification */
126 nfstime ctime; /* time of last change */
130 * File attributes which can be set
133 unsigned mode; /* protection mode bits */
134 unsigned uid; /* owner user id */
135 unsigned gid; /* owner group id */
136 unsigned size; /* file size in bytes */
137 nfstime atime; /* time of last access */
138 nfstime mtime; /* time of last modification */
142 typedef string filename<NFS_MAXNAMLEN>;
143 typedef string nfspath<NFS_MAXPATHLEN>;
146 * Reply status with file attributes
148 union attrstat switch (nfsstat status) {
161 * Arguments for directory operations
164 nfs_fh dir; /* directory file handle */
165 filename name; /* name (up to NFS_MAXNAMLEN bytes) */
174 * Results from directory operation
176 union diropres switch (nfsstat status) {
183 union readlinkres switch (nfsstat status) {
191 * Arguments to remote read
194 nfs_fh file; /* handle for file */
195 unsigned offset; /* byte offset in file */
196 unsigned count; /* immediate read count */
197 unsigned totalcount; /* total read count (from this offset)*/
201 * Status OK portion of remote read reply
204 fattr attributes; /* attributes, need for pagin*/
205 opaque data<NFS_MAXDATA>;
208 union readres switch (nfsstat status) {
216 * Arguments to remote write
219 nfs_fh file; /* handle for file */
220 unsigned beginoffset; /* beginning byte offset in file */
221 unsigned offset; /* current byte offset in file */
222 unsigned totalcount; /* total write count (to this offset)*/
223 opaque data<NFS_MAXDATA>;
248 typedef opaque nfscookie[NFS_COOKIESIZE];
251 * Arguments to readdir
254 nfs_fh dir; /* directory handle */
256 unsigned count; /* number of directory bytes to read */
271 union readdirres switch (nfsstat status) {
279 unsigned tsize; /* preferred transfer size in bytes */
280 unsigned bsize; /* fundamental file system block size */
281 unsigned blocks; /* total blocks in file system */
282 unsigned bfree; /* free blocks in fs */
283 unsigned bavail; /* free blocks avail to non-superuser */
286 union statfsres switch (nfsstat status) {
296 * NFSv3 constants and types
298 const NFS3_FHSIZE = 64; /* maximum size in bytes of a file handle */
299 const NFS3_COOKIEVERFSIZE = 8; /* size of a cookie verifier for READDIR */
300 const NFS3_CREATEVERFSIZE = 8; /* size of the verifier used for CREATE */
301 const NFS3_WRITEVERFSIZE = 8; /* size of the verifier used for WRITE */
303 typedef unsigned hyper uint64;
305 typedef unsigned long uint32;
307 typedef string filename3<>;
308 typedef string nfspath3<>;
309 typedef uint64 fileid3;
310 typedef uint64 cookie3;
311 typedef opaque cookieverf3[NFS3_COOKIEVERFSIZE];
312 typedef opaque createverf3[NFS3_CREATEVERFSIZE];
313 typedef opaque writeverf3[NFS3_WRITEVERFSIZE];
316 typedef uint64 size3;
317 typedef uint64 offset3;
318 typedef uint32 mode3;
319 typedef uint32 count3;
341 NFS3ERR_NAMETOOLONG = 63,
342 NFS3ERR_NOTEMPTY = 66,
346 NFS3ERR_BADHANDLE = 10001,
347 NFS3ERR_NOT_SYNC = 10002,
348 NFS3ERR_BAD_COOKIE = 10003,
349 NFS3ERR_NOTSUPP = 10004,
350 NFS3ERR_TOOSMALL = 10005,
351 NFS3ERR_SERVERFAULT = 10006,
352 NFS3ERR_BADTYPE = 10007,
353 NFS3ERR_JUKEBOX = 10008
360 NF3REG = 1, /* regular file */
361 NF3DIR = 2, /* directory */
362 NF3BLK = 3, /* block special */
363 NF3CHR = 4, /* character special */
364 NF3LNK = 5, /* symbolic link */
365 NF3SOCK = 6, /* unix domain sockets */
366 NF3FIFO = 7 /* named pipe */
375 * File access handle (v3)
378 opaque data<NFS3_FHSIZE>;
391 * File attributes (v3)
394 ftype3 type; /* file type */
395 mode3 mode; /* protection mode bits */
396 uint32 nlink; /* # hard links */
397 uid3 uid; /* owner user id */
398 gid3 gid; /* owner group id */
399 size3 size; /* file size in bytes */
400 size3 used; /* prefered block size */
401 specdata3 rdev; /* special device # */
402 uint64 fsid; /* device # */
403 fileid3 fileid; /* inode # */
404 nfstime3 atime; /* time of last access */
405 nfstime3 mtime; /* time of last modification */
406 nfstime3 ctime; /* time of last change */
409 union post_op_attr switch (bool attributes_follow) {
422 union pre_op_attr switch (bool attributes_follow) {
434 union post_op_fh3 switch (bool handle_follows) {
442 * File attributes which can be set (v3)
446 SET_TO_SERVER_TIME = 1,
447 SET_TO_CLIENT_TIME = 2
450 union set_mode3 switch (bool set_it) {
457 union set_uid3 switch (bool set_it) {
464 union set_gid3 switch (bool set_it) {
471 union set_size3 switch (bool set_it) {
478 union set_atime switch (time_how set_it) {
479 case SET_TO_CLIENT_TIME:
485 union set_mtime switch (time_how set_it) {
486 case SET_TO_CLIENT_TIME:
502 * Arguments for directory operations (v3)
505 nfs_fh3 dir; /* directory file handle */
506 filename3 name; /* name (up to NFS_MAXNAMLEN bytes) */
510 * Arguments to getattr (v3).
512 struct GETATTR3args {
516 struct GETATTR3resok {
517 fattr3 obj_attributes;
520 union GETATTR3res switch (nfsstat3 status) {
528 * Arguments to setattr (v3).
530 union sattrguard3 switch (bool check) {
537 struct SETATTR3args {
539 sattr3 new_attributes;
543 struct SETATTR3resok {
547 struct SETATTR3resfail {
551 union SETATTR3res switch (nfsstat3 status) {
555 SETATTR3resfail resfail;
559 * Arguments to lookup (v3).
565 struct LOOKUP3resok {
567 post_op_attr obj_attributes;
568 post_op_attr dir_attributes;
571 struct LOOKUP3resfail {
572 post_op_attr dir_attributes;
575 union LOOKUP3res switch (nfsstat3 status) {
579 LOOKUP3resfail resfail;
583 * Arguments to access (v3).
585 const ACCESS3_READ = 0x0001;
586 const ACCESS3_LOOKUP = 0x0002;
587 const ACCESS3_MODIFY = 0x0004;
588 const ACCESS3_EXTEND = 0x0008;
589 const ACCESS3_DELETE = 0x0010;
590 const ACCESS3_EXECUTE = 0x0020;
597 struct ACCESS3resok {
598 post_op_attr obj_attributes;
602 struct ACCESS3resfail {
603 post_op_attr obj_attributes;
606 union ACCESS3res switch (nfsstat3 status) {
610 ACCESS3resfail resfail;
614 * Arguments to readlink (v3).
616 struct READLINK3args {
620 struct READLINK3resok {
621 post_op_attr symlink_attributes;
625 struct READLINK3resfail {
626 post_op_attr symlink_attributes;
629 union READLINK3res switch (nfsstat3 status) {
631 READLINK3resok resok;
633 READLINK3resfail resfail;
637 * Arguments to read (v3).
646 post_op_attr file_attributes;
652 struct READ3resfail {
653 post_op_attr file_attributes;
656 /* XXX: solaris 2.6 uses ``nfsstat'' here */
657 union READ3res switch (nfsstat3 status) {
661 READ3resfail resfail;
665 * Arguments to write (v3).
684 stable_how committed;
688 struct WRITE3resfail {
692 union WRITE3res switch (nfsstat3 status) {
696 WRITE3resfail resfail;
700 * Arguments to create (v3).
708 union createhow3 switch (createmode3 mode) {
711 sattr3 obj_attributes;
721 struct CREATE3resok {
723 post_op_attr obj_attributes;
727 struct CREATE3resfail {
731 union CREATE3res switch (nfsstat3 status) {
735 CREATE3resfail resfail;
739 * Arguments to mkdir (v3).
748 post_op_attr obj_attributes;
752 struct MKDIR3resfail {
756 union MKDIR3res switch (nfsstat3 status) {
760 MKDIR3resfail resfail;
764 * Arguments to symlink (v3).
766 struct symlinkdata3 {
767 sattr3 symlink_attributes;
768 nfspath3 symlink_data;
771 struct SYMLINK3args {
773 symlinkdata3 symlink;
776 struct SYMLINK3resok {
778 post_op_attr obj_attributes;
782 struct SYMLINK3resfail {
786 union SYMLINK3res switch (nfsstat3 status) {
790 SYMLINK3resfail resfail;
794 * Arguments to mknod (v3).
797 sattr3 dev_attributes;
801 union mknoddata3 switch (ftype3 type) {
807 sattr3 pipe_attributes;
819 post_op_attr obj_attributes;
823 struct MKNOD3resfail {
827 union MKNOD3res switch (nfsstat3 status) {
831 MKNOD3resfail resfail;
835 * Arguments to remove (v3).
841 struct REMOVE3resok {
845 struct REMOVE3resfail {
849 union REMOVE3res switch (nfsstat3 status) {
853 REMOVE3resfail resfail;
857 * Arguments to rmdir (v3).
867 struct RMDIR3resfail {
871 union RMDIR3res switch (nfsstat3 status) {
875 RMDIR3resfail resfail;
879 * Arguments to rename (v3).
886 struct RENAME3resok {
887 wcc_data fromdir_wcc;
891 struct RENAME3resfail {
892 wcc_data fromdir_wcc;
896 union RENAME3res switch (nfsstat3 status) {
900 RENAME3resfail resfail;
904 * Arguments to link (v3).
912 post_op_attr file_attributes;
913 wcc_data linkdir_wcc;
916 struct LINK3resfail {
917 post_op_attr file_attributes;
918 wcc_data linkdir_wcc;
921 union LINK3res switch (nfsstat3 status) {
925 LINK3resfail resfail;
929 * Arguments to readdir (v3).
931 struct READDIR3args {
934 cookieverf3 cookieverf;
950 struct READDIR3resok {
951 post_op_attr dir_attributes;
952 cookieverf3 cookieverf;
956 struct READDIR3resfail {
957 post_op_attr dir_attributes;
960 union READDIR3res switch (nfsstat3 status) {
964 READDIR3resfail resfail;
968 * Arguments to readdirplus (v3).
970 struct READDIRPLUS3args {
973 cookieverf3 cookieverf;
982 post_op_attr name_attributes;
983 post_op_fh3 name_handle;
984 entryplus3 *nextentry;
987 struct dirlistplus3 {
992 struct READDIRPLUS3resok {
993 post_op_attr dir_attributes;
994 cookieverf3 cookieverf;
998 struct READDIRPLUS3resfail {
999 post_op_attr dir_attributes;
1002 union READDIRPLUS3res switch (nfsstat3 status) {
1004 READDIRPLUS3resok resok;
1006 READDIRPLUS3resfail resfail;
1010 * Arguments to fsstat (v3).
1012 struct FSSTAT3args {
1016 struct FSSTAT3resok {
1017 post_op_attr obj_attributes;
1027 struct FSSTAT3resfail {
1028 post_op_attr obj_attributes;
1031 union FSSTAT3res switch (nfsstat3 status) {
1035 FSSTAT3resfail resfail;
1039 * Arguments to fsinfo (v3).
1041 const FSF3_LINK = 0x0001;
1042 const FSF3_SYMLINK = 0x0002;
1043 const FSF3_HOMOGENEOUS = 0x0008;
1044 const FSF3_CANSETTIME = 0x0010;
1046 struct FSINFO3args {
1050 struct FSINFO3resok {
1051 post_op_attr obj_attributes;
1060 nfstime3 time_delta;
1064 struct FSINFO3resfail {
1065 post_op_attr obj_attributes;
1068 union FSINFO3res switch (nfsstat3 status) {
1072 FSINFO3resfail resfail;
1076 * Arguments to pathconf (v3).
1078 struct PATHCONF3args {
1082 struct PATHCONF3resok {
1083 post_op_attr obj_attributes;
1087 bool chown_restricted;
1088 bool case_insensitive;
1089 bool case_preserving;
1092 struct PATHCONF3resfail {
1093 post_op_attr obj_attributes;
1096 union PATHCONF3res switch (nfsstat3 status) {
1098 PATHCONF3resok resok;
1100 PATHCONF3resfail resfail;
1104 * Arguments to commit (v3).
1106 struct COMMIT3args {
1112 struct COMMIT3resok {
1117 struct COMMIT3resfail {
1121 union COMMIT3res switch (nfsstat3 status) {
1125 COMMIT3resfail resfail;
1128 #endif /* WANT_NFS3 */
1131 * Remote file service routines
1133 program NFS_PROGRAM {
1134 version NFS_VERSION {
1136 NFSPROC_NULL(void) = 0;
1139 NFSPROC_GETATTR(nfs_fh) = 1;
1142 NFSPROC_SETATTR(sattrargs) = 2;
1145 NFSPROC_ROOT(void) = 3;
1148 NFSPROC_LOOKUP(diropargs) = 4;
1151 NFSPROC_READLINK(nfs_fh) = 5;
1154 NFSPROC_READ(readargs) = 6;
1157 NFSPROC_WRITECACHE(void) = 7;
1160 NFSPROC_WRITE(writeargs) = 8;
1163 NFSPROC_CREATE(createargs) = 9;
1166 NFSPROC_REMOVE(diropargs) = 10;
1169 NFSPROC_RENAME(renameargs) = 11;
1172 NFSPROC_LINK(linkargs) = 12;
1175 NFSPROC_SYMLINK(symlinkargs) = 13;
1178 NFSPROC_MKDIR(createargs) = 14;
1181 NFSPROC_RMDIR(diropargs) = 15;
1184 NFSPROC_READDIR(readdirargs) = 16;
1187 NFSPROC_STATFS(nfs_fh) = 17;
1191 program NFS3_PROGRAM {
1194 NFSPROC3_NULL(void) = 0;
1197 NFSPROC3_GETATTR(GETATTR3args) = 1;
1200 NFSPROC3_SETATTR(SETATTR3args) = 2;
1203 NFSPROC3_LOOKUP(LOOKUP3args) = 3;
1206 NFSPROC3_ACCESS(ACCESS3args) = 4;
1209 NFSPROC3_READLINK(READLINK3args) = 5;
1212 NFSPROC3_READ(READ3args) = 6;
1215 NFSPROC3_WRITE(WRITE3args) = 7;
1218 NFSPROC3_CREATE(CREATE3args) = 8;
1221 NFSPROC3_MKDIR(MKDIR3args) = 9;
1224 NFSPROC3_SYMLINK(SYMLINK3args) = 10;
1227 NFSPROC3_MKNOD(MKNOD3args) = 11;
1230 NFSPROC3_REMOVE(REMOVE3args) = 12;
1233 NFSPROC3_RMDIR(RMDIR3args) = 13;
1236 NFSPROC3_RENAME(RENAME3args) = 14;
1239 NFSPROC3_LINK(LINK3args) = 15;
1242 NFSPROC3_READDIR(READDIR3args) = 16;
1245 NFSPROC3_READDIRPLUS(READDIRPLUS3args) = 17;
1248 NFSPROC3_FSSTAT(FSSTAT3args) = 18;
1251 NFSPROC3_FSINFO(FSINFO3args) = 19;
1254 NFSPROC3_PATHCONF(PATHCONF3args) = 20;
1257 NFSPROC3_COMMIT(COMMIT3args) = 21;