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
32 %/*static char sccsid[] = "from: @(#)nfs_prot.x 1.2 87/10/12 Copyr 1987 Sun Micro";*/
33 %/*static char sccsid[] = "from: @(#)nfs_prot.x 2.1 88/08/01 4.0 RPCSRC";*/
34 %static const char rcsid[] =
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) {
301 * NFSv3 constants and types
303 const NFS3_FHSIZE = 64; /* maximum size in bytes of a file handle */
304 const NFS3_COOKIEVERFSIZE = 8; /* size of a cookie verifier for READDIR */
305 const NFS3_CREATEVERFSIZE = 8; /* size of the verifier used for CREATE */
306 const NFS3_WRITEVERFSIZE = 8; /* size of the verifier used for WRITE */
308 typedef unsigned hyper uint64;
310 typedef unsigned long uint32;
312 typedef string filename3<>;
313 typedef string nfspath3<>;
314 typedef uint64 fileid3;
315 typedef uint64 cookie3;
316 typedef opaque cookieverf3[NFS3_COOKIEVERFSIZE];
317 typedef opaque createverf3[NFS3_CREATEVERFSIZE];
318 typedef opaque writeverf3[NFS3_WRITEVERFSIZE];
321 typedef uint64 size3;
322 typedef uint64 offset3;
323 typedef uint32 mode3;
324 typedef uint32 count3;
346 NFS3ERR_NAMETOOLONG = 63,
347 NFS3ERR_NOTEMPTY = 66,
351 NFS3ERR_BADHANDLE = 10001,
352 NFS3ERR_NOT_SYNC = 10002,
353 NFS3ERR_BAD_COOKIE = 10003,
354 NFS3ERR_NOTSUPP = 10004,
355 NFS3ERR_TOOSMALL = 10005,
356 NFS3ERR_SERVERFAULT = 10006,
357 NFS3ERR_BADTYPE = 10007,
358 NFS3ERR_JUKEBOX = 10008
365 NF3REG = 1, /* regular file */
366 NF3DIR = 2, /* directory */
367 NF3BLK = 3, /* block special */
368 NF3CHR = 4, /* character special */
369 NF3LNK = 5, /* symbolic link */
370 NF3SOCK = 6, /* unix domain sockets */
371 NF3FIFO = 7 /* named pipe */
380 * File access handle (v3)
383 opaque data<NFS3_FHSIZE>;
396 * File attributes (v3)
399 ftype3 type; /* file type */
400 mode3 mode; /* protection mode bits */
401 uint32 nlink; /* # hard links */
402 uid3 uid; /* owner user id */
403 gid3 gid; /* owner group id */
404 size3 size; /* file size in bytes */
405 size3 used; /* prefered block size */
406 specdata3 rdev; /* special device # */
407 uint64 fsid; /* device # */
408 fileid3 fileid; /* inode # */
409 nfstime3 atime; /* time of last access */
410 nfstime3 mtime; /* time of last modification */
411 nfstime3 ctime; /* time of last change */
414 union post_op_attr switch (bool attributes_follow) {
427 union pre_op_attr switch (bool attributes_follow) {
439 union post_op_fh3 switch (bool handle_follows) {
447 * File attributes which can be set (v3)
451 SET_TO_SERVER_TIME = 1,
452 SET_TO_CLIENT_TIME = 2
455 union set_mode3 switch (bool set_it) {
462 union set_uid3 switch (bool set_it) {
469 union set_gid3 switch (bool set_it) {
476 union set_size3 switch (bool set_it) {
483 union set_atime switch (time_how set_it) {
484 case SET_TO_CLIENT_TIME:
490 union set_mtime switch (time_how set_it) {
491 case SET_TO_CLIENT_TIME:
507 * Arguments for directory operations (v3)
510 nfs_fh3 dir; /* directory file handle */
511 filename3 name; /* name (up to NFS_MAXNAMLEN bytes) */
515 * Arguments to getattr (v3).
517 struct GETATTR3args {
521 struct GETATTR3resok {
522 fattr3 obj_attributes;
525 union GETATTR3res switch (nfsstat3 status) {
533 * Arguments to setattr (v3).
535 union sattrguard3 switch (bool check) {
542 struct SETATTR3args {
544 sattr3 new_attributes;
548 struct SETATTR3resok {
552 struct SETATTR3resfail {
556 union SETATTR3res switch (nfsstat3 status) {
560 SETATTR3resfail resfail;
564 * Arguments to lookup (v3).
570 struct LOOKUP3resok {
572 post_op_attr obj_attributes;
573 post_op_attr dir_attributes;
576 struct LOOKUP3resfail {
577 post_op_attr dir_attributes;
580 union LOOKUP3res switch (nfsstat3 status) {
584 LOOKUP3resfail resfail;
588 * Arguments to access (v3).
590 const ACCESS3_READ = 0x0001;
591 const ACCESS3_LOOKUP = 0x0002;
592 const ACCESS3_MODIFY = 0x0004;
593 const ACCESS3_EXTEND = 0x0008;
594 const ACCESS3_DELETE = 0x0010;
595 const ACCESS3_EXECUTE = 0x0020;
602 struct ACCESS3resok {
603 post_op_attr obj_attributes;
607 struct ACCESS3resfail {
608 post_op_attr obj_attributes;
611 union ACCESS3res switch (nfsstat3 status) {
615 ACCESS3resfail resfail;
619 * Arguments to readlink (v3).
621 struct READLINK3args {
625 struct READLINK3resok {
626 post_op_attr symlink_attributes;
630 struct READLINK3resfail {
631 post_op_attr symlink_attributes;
634 union READLINK3res switch (nfsstat3 status) {
636 READLINK3resok resok;
638 READLINK3resfail resfail;
642 * Arguments to read (v3).
651 post_op_attr file_attributes;
657 struct READ3resfail {
658 post_op_attr file_attributes;
661 /* XXX: solaris 2.6 uses ``nfsstat'' here */
662 union READ3res switch (nfsstat3 status) {
666 READ3resfail resfail;
670 * Arguments to write (v3).
689 stable_how committed;
693 struct WRITE3resfail {
697 union WRITE3res switch (nfsstat3 status) {
701 WRITE3resfail resfail;
705 * Arguments to create (v3).
713 union createhow3 switch (createmode3 mode) {
716 sattr3 obj_attributes;
726 struct CREATE3resok {
728 post_op_attr obj_attributes;
732 struct CREATE3resfail {
736 union CREATE3res switch (nfsstat3 status) {
740 CREATE3resfail resfail;
744 * Arguments to mkdir (v3).
753 post_op_attr obj_attributes;
757 struct MKDIR3resfail {
761 union MKDIR3res switch (nfsstat3 status) {
765 MKDIR3resfail resfail;
769 * Arguments to symlink (v3).
771 struct symlinkdata3 {
772 sattr3 symlink_attributes;
773 nfspath3 symlink_data;
776 struct SYMLINK3args {
778 symlinkdata3 symlink;
781 struct SYMLINK3resok {
783 post_op_attr obj_attributes;
787 struct SYMLINK3resfail {
791 union SYMLINK3res switch (nfsstat3 status) {
795 SYMLINK3resfail resfail;
799 * Arguments to mknod (v3).
802 sattr3 dev_attributes;
806 union mknoddata3 switch (ftype3 type) {
812 sattr3 pipe_attributes;
824 post_op_attr obj_attributes;
828 struct MKNOD3resfail {
832 union MKNOD3res switch (nfsstat3 status) {
836 MKNOD3resfail resfail;
840 * Arguments to remove (v3).
846 struct REMOVE3resok {
850 struct REMOVE3resfail {
854 union REMOVE3res switch (nfsstat3 status) {
858 REMOVE3resfail resfail;
862 * Arguments to rmdir (v3).
872 struct RMDIR3resfail {
876 union RMDIR3res switch (nfsstat3 status) {
880 RMDIR3resfail resfail;
884 * Arguments to rename (v3).
891 struct RENAME3resok {
892 wcc_data fromdir_wcc;
896 struct RENAME3resfail {
897 wcc_data fromdir_wcc;
901 union RENAME3res switch (nfsstat3 status) {
905 RENAME3resfail resfail;
909 * Arguments to link (v3).
917 post_op_attr file_attributes;
918 wcc_data linkdir_wcc;
921 struct LINK3resfail {
922 post_op_attr file_attributes;
923 wcc_data linkdir_wcc;
926 union LINK3res switch (nfsstat3 status) {
930 LINK3resfail resfail;
934 * Arguments to readdir (v3).
936 struct READDIR3args {
939 cookieverf3 cookieverf;
955 struct READDIR3resok {
956 post_op_attr dir_attributes;
957 cookieverf3 cookieverf;
961 struct READDIR3resfail {
962 post_op_attr dir_attributes;
965 union READDIR3res switch (nfsstat3 status) {
969 READDIR3resfail resfail;
973 * Arguments to readdirplus (v3).
975 struct READDIRPLUS3args {
978 cookieverf3 cookieverf;
987 post_op_attr name_attributes;
988 post_op_fh3 name_handle;
989 entryplus3 *nextentry;
992 struct dirlistplus3 {
997 struct READDIRPLUS3resok {
998 post_op_attr dir_attributes;
999 cookieverf3 cookieverf;
1003 struct READDIRPLUS3resfail {
1004 post_op_attr dir_attributes;
1007 union READDIRPLUS3res switch (nfsstat3 status) {
1009 READDIRPLUS3resok resok;
1011 READDIRPLUS3resfail resfail;
1015 * Arguments to fsstat (v3).
1017 struct FSSTAT3args {
1021 struct FSSTAT3resok {
1022 post_op_attr obj_attributes;
1032 struct FSSTAT3resfail {
1033 post_op_attr obj_attributes;
1036 union FSSTAT3res switch (nfsstat3 status) {
1040 FSSTAT3resfail resfail;
1044 * Arguments to fsinfo (v3).
1046 const FSF3_LINK = 0x0001;
1047 const FSF3_SYMLINK = 0x0002;
1048 const FSF3_HOMOGENEOUS = 0x0008;
1049 const FSF3_CANSETTIME = 0x0010;
1051 struct FSINFO3args {
1055 struct FSINFO3resok {
1056 post_op_attr obj_attributes;
1065 nfstime3 time_delta;
1069 struct FSINFO3resfail {
1070 post_op_attr obj_attributes;
1073 union FSINFO3res switch (nfsstat3 status) {
1077 FSINFO3resfail resfail;
1081 * Arguments to pathconf (v3).
1083 struct PATHCONF3args {
1087 struct PATHCONF3resok {
1088 post_op_attr obj_attributes;
1092 bool chown_restricted;
1093 bool case_insensitive;
1094 bool case_preserving;
1097 struct PATHCONF3resfail {
1098 post_op_attr obj_attributes;
1101 union PATHCONF3res switch (nfsstat3 status) {
1103 PATHCONF3resok resok;
1105 PATHCONF3resfail resfail;
1109 * Arguments to commit (v3).
1111 struct COMMIT3args {
1117 struct COMMIT3resok {
1122 struct COMMIT3resfail {
1126 union COMMIT3res switch (nfsstat3 status) {
1130 COMMIT3resfail resfail;
1133 #endif /* WANT_NFS3 */
1136 * Remote file service routines
1138 program NFS_PROGRAM {
1139 version NFS_VERSION {
1141 NFSPROC_NULL(void) = 0;
1144 NFSPROC_GETATTR(nfs_fh) = 1;
1147 NFSPROC_SETATTR(sattrargs) = 2;
1150 NFSPROC_ROOT(void) = 3;
1153 NFSPROC_LOOKUP(diropargs) = 4;
1156 NFSPROC_READLINK(nfs_fh) = 5;
1159 NFSPROC_READ(readargs) = 6;
1162 NFSPROC_WRITECACHE(void) = 7;
1165 NFSPROC_WRITE(writeargs) = 8;
1168 NFSPROC_CREATE(createargs) = 9;
1171 NFSPROC_REMOVE(diropargs) = 10;
1174 NFSPROC_RENAME(renameargs) = 11;
1177 NFSPROC_LINK(linkargs) = 12;
1180 NFSPROC_SYMLINK(symlinkargs) = 13;
1183 NFSPROC_MKDIR(createargs) = 14;
1186 NFSPROC_RMDIR(diropargs) = 15;
1189 NFSPROC_READDIR(readdirargs) = 16;
1192 NFSPROC_STATFS(nfs_fh) = 17;
1196 program NFS3_PROGRAM {
1199 NFSPROC3_NULL(void) = 0;
1202 NFSPROC3_GETATTR(GETATTR3args) = 1;
1205 NFSPROC3_SETATTR(SETATTR3args) = 2;
1208 NFSPROC3_LOOKUP(LOOKUP3args) = 3;
1211 NFSPROC3_ACCESS(ACCESS3args) = 4;
1214 NFSPROC3_READLINK(READLINK3args) = 5;
1217 NFSPROC3_READ(READ3args) = 6;
1220 NFSPROC3_WRITE(WRITE3args) = 7;
1223 NFSPROC3_CREATE(CREATE3args) = 8;
1226 NFSPROC3_MKDIR(MKDIR3args) = 9;
1229 NFSPROC3_SYMLINK(SYMLINK3args) = 10;
1232 NFSPROC3_MKNOD(MKNOD3args) = 11;
1235 NFSPROC3_REMOVE(REMOVE3args) = 12;
1238 NFSPROC3_RMDIR(RMDIR3args) = 13;
1241 NFSPROC3_RENAME(RENAME3args) = 14;
1244 NFSPROC3_LINK(LINK3args) = 15;
1247 NFSPROC3_READDIR(READDIR3args) = 16;
1250 NFSPROC3_READDIRPLUS(READDIRPLUS3args) = 17;
1253 NFSPROC3_FSSTAT(FSSTAT3args) = 18;
1256 NFSPROC3_FSINFO(FSINFO3args) = 19;
1259 NFSPROC3_PATHCONF(PATHCONF3args) = 20;
1262 NFSPROC3_COMMIT(COMMIT3args) = 21;