1 /* @(#)nfs_prot.x 2.1 88/08/01 4.0 RPCSRC */
4 * Sun RPC is a product of Sun Microsystems, Inc. and is provided for
5 * unrestricted use provided that this legend is included on all tape
6 * media and as a part of the software program in whole or part. Users
7 * may copy or modify Sun RPC without charge, but are not authorized
8 * to license or distribute it to anyone else except as part of a product or
9 * program developed by the user.
11 * SUN RPC IS PROVIDED AS IS WITH NO WARRANTIES OF ANY KIND INCLUDING THE
12 * WARRANTIES OF DESIGN, MERCHANTIBILITY AND FITNESS FOR A PARTICULAR
13 * PURPOSE, OR ARISING FROM A COURSE OF DEALING, USAGE OR TRADE PRACTICE.
15 * Sun RPC is provided with no support and without any obligation on the
16 * part of Sun Microsystems, Inc. to assist in its use, correction,
17 * modification or enhancement.
19 * SUN MICROSYSTEMS, INC. SHALL HAVE NO LIABILITY WITH RESPECT TO THE
20 * INFRINGEMENT OF COPYRIGHTS, TRADE SECRETS OR ANY PATENTS BY SUN RPC
21 * OR ANY PART THEREOF.
23 * In no event will Sun Microsystems, Inc. be liable for any lost revenue
24 * or profits or other special, indirect and consequential damages, even if
25 * Sun has been advised of the possibility of such damages.
27 * Sun Microsystems, Inc.
29 * Mountain View, California 94043
33 * nfs_prot.x 1.2 87/10/12
34 * Copyright 1987 Sun Microsystems, Inc.
36 const NFS_PORT = 2049;
37 const NFS_MAXDATA = 8192;
38 const NFS_MAXPATHLEN = 1024;
39 const NFS_MAXNAMLEN = 255;
40 const NFS_FHSIZE = 32;
41 const NFS_COOKIESIZE = 4;
42 const NFS_FIFO_DEV = -1; /* size kludge for named pipes */
47 const NFSMODE_FMT = 0170000; /* type of file */
48 const NFSMODE_DIR = 0040000; /* directory */
49 const NFSMODE_CHR = 0020000; /* character special */
50 const NFSMODE_BLK = 0060000; /* block special */
51 const NFSMODE_REG = 0100000; /* regular */
52 const NFSMODE_LNK = 0120000; /* symbolic link */
53 const NFSMODE_SOCK = 0140000; /* socket */
54 const NFSMODE_FIFO = 0010000; /* fifo */
60 NFS_OK= 0, /* no error */
61 NFSERR_PERM=1, /* Not owner */
62 NFSERR_NOENT=2, /* No such file or directory */
63 NFSERR_IO=5, /* I/O error */
64 NFSERR_NXIO=6, /* No such device or address */
65 NFSERR_ACCES=13, /* Permission denied */
66 NFSERR_EXIST=17, /* File exists */
67 NFSERR_NODEV=19, /* No such device */
68 NFSERR_NOTDIR=20, /* Not a directory*/
69 NFSERR_ISDIR=21, /* Is a directory */
70 NFSERR_FBIG=27, /* File too large */
71 NFSERR_NOSPC=28, /* No space left on device */
72 NFSERR_ROFS=30, /* Read-only file system */
73 NFSERR_NAMETOOLONG=63, /* File name too long */
74 NFSERR_NOTEMPTY=66, /* Directory not empty */
75 NFSERR_DQUOT=69, /* Disc quota exceeded */
76 NFSERR_STALE=70, /* Stale NFS file handle */
77 NFSERR_WFLUSH=99 /* write cache flushed */
84 NFNON = 0, /* non-file */
85 NFREG = 1, /* regular file */
86 NFDIR = 2, /* directory */
87 NFBLK = 3, /* block special */
88 NFCHR = 4, /* character special */
89 NFLNK = 5, /* symbolic link */
90 NFSOCK = 6, /* unix domain sockets */
91 NFBAD = 7, /* unused */
92 NFFIFO = 8 /* named pipe */
99 opaque data[NFS_FHSIZE];
115 ftype type; /* file type */
116 unsigned mode; /* protection mode bits */
117 unsigned nlink; /* # hard links */
118 unsigned uid; /* owner user id */
119 unsigned gid; /* owner group id */
120 unsigned size; /* file size in bytes */
121 unsigned blocksize; /* preferred block size */
122 unsigned rdev; /* special device # */
123 unsigned blocks; /* Kb of disk used by file */
124 unsigned fsid; /* device # */
125 unsigned fileid; /* inode # */
126 nfstime atime; /* time of last access */
127 nfstime mtime; /* time of last modification */
128 nfstime ctime; /* time of last change */
132 * File attributes which can be set
135 unsigned mode; /* protection mode bits */
136 unsigned uid; /* owner user id */
137 unsigned gid; /* owner group id */
138 unsigned size; /* file size in bytes */
139 nfstime atime; /* time of last access */
140 nfstime mtime; /* time of last modification */
144 typedef string filename<NFS_MAXNAMLEN>;
145 typedef string nfspath<NFS_MAXPATHLEN>;
148 * Reply status with file attributes
150 union attrstat switch (nfsstat status) {
163 * Arguments for directory operations
166 nfs_fh dir; /* directory file handle */
167 filename name; /* name (up to NFS_MAXNAMLEN bytes) */
176 * Results from directory operation
178 union diropres switch (nfsstat status) {
185 union readlinkres switch (nfsstat status) {
193 * Arguments to remote read
196 nfs_fh file; /* handle for file */
197 unsigned offset; /* byte offset in file */
198 unsigned count; /* immediate read count */
199 unsigned totalcount; /* total read count (from this offset)*/
203 * Status OK portion of remote read reply
206 fattr attributes; /* attributes, need for pagin*/
207 opaque data<NFS_MAXDATA>;
210 union readres switch (nfsstat status) {
218 * Arguments to remote write
221 nfs_fh file; /* handle for file */
222 unsigned beginoffset; /* beginning byte offset in file */
223 unsigned offset; /* current byte offset in file */
224 unsigned totalcount; /* total write count (to this offset)*/
225 opaque data<NFS_MAXDATA>;
250 typedef opaque nfscookie[NFS_COOKIESIZE];
253 * Arguments to readdir
256 nfs_fh dir; /* directory handle */
258 unsigned count; /* number of directory bytes to read */
273 union readdirres switch (nfsstat status) {
281 unsigned tsize; /* preferred transfer size in bytes */
282 unsigned bsize; /* fundamental file system block size */
283 unsigned blocks; /* total blocks in file system */
284 unsigned bfree; /* free blocks in fs */
285 unsigned bavail; /* free blocks avail to non-superuser */
288 union statfsres switch (nfsstat status) {
296 * Remote file service routines
298 program NFS_PROGRAM {
299 version NFS_VERSION {
301 NFSPROC_NULL(void) = 0;
304 NFSPROC_GETATTR(nfs_fh) = 1;
307 NFSPROC_SETATTR(sattrargs) = 2;
310 NFSPROC_ROOT(void) = 3;
313 NFSPROC_LOOKUP(diropargs) = 4;
316 NFSPROC_READLINK(nfs_fh) = 5;
319 NFSPROC_READ(readargs) = 6;
322 NFSPROC_WRITECACHE(void) = 7;
325 NFSPROC_WRITE(writeargs) = 8;
328 NFSPROC_CREATE(createargs) = 9;
331 NFSPROC_REMOVE(diropargs) = 10;
334 NFSPROC_RENAME(renameargs) = 11;
337 NFSPROC_LINK(linkargs) = 12;
340 NFSPROC_SYMLINK(symlinkargs) = 13;
343 NFSPROC_MKDIR(createargs) = 14;
346 NFSPROC_RMDIR(diropargs) = 15;
349 NFSPROC_READDIR(readdirargs) = 16;
352 NFSPROC_STATFS(nfs_fh) = 17;