1 /* @(#)nfs_prot.x 2.1 88/08/01 4.0 RPCSRC */
4 * nfs_prot.x 1.2 87/10/12
5 * Copyright 1987 Sun Microsystems, Inc.
7 * Redistribution and use in source and binary forms, with or without
8 * modification, are permitted provided that the following conditions are
11 * * Redistributions of source code must retain the above copyright
12 * notice, this list of conditions and the following disclaimer.
13 * * Redistributions in binary form must reproduce the above
14 * copyright notice, this list of conditions and the following
15 * disclaimer in the documentation and/or other materials
16 * provided with the distribution.
17 * * Neither the name of Sun Microsystems, Inc. nor the names of its
18 * contributors may be used to endorse or promote products derived
19 * from this software without specific prior written permission.
21 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
22 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
23 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
24 * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
25 * COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
26 * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
27 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
28 * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
29 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
30 * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
31 * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
32 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
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; /* preferred 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) {
294 * Remote file service routines
296 program NFS_PROGRAM {
297 version NFS_VERSION {
299 NFSPROC_NULL(void) = 0;
302 NFSPROC_GETATTR(nfs_fh) = 1;
305 NFSPROC_SETATTR(sattrargs) = 2;
308 NFSPROC_ROOT(void) = 3;
311 NFSPROC_LOOKUP(diropargs) = 4;
314 NFSPROC_READLINK(nfs_fh) = 5;
317 NFSPROC_READ(readargs) = 6;
320 NFSPROC_WRITECACHE(void) = 7;
323 NFSPROC_WRITE(writeargs) = 8;
326 NFSPROC_CREATE(createargs) = 9;
329 NFSPROC_REMOVE(diropargs) = 10;
332 NFSPROC_RENAME(renameargs) = 11;
335 NFSPROC_LINK(linkargs) = 12;
338 NFSPROC_SYMLINK(symlinkargs) = 13;
341 NFSPROC_MKDIR(createargs) = 14;
344 NFSPROC_RMDIR(diropargs) = 15;
347 NFSPROC_READDIR(readdirargs) = 16;
350 NFSPROC_STATFS(nfs_fh) = 17;