source: rtems/c/src/exec/librpc/src/rpc/PSD.doc/nfs.rfc.ms @ df49c60

4.104.114.84.95
Last change on this file since df49c60 was df49c60, checked in by Joel Sherrill <joel.sherrill@…>, on 06/12/00 at 15:00:15

Merged from 4.5.0-beta3a

  • Property mode set to 100644
File size: 41.0 KB
Line 
1.\"
2.\" Must use  --  tbl  --  with this one
3.\"
4.\" @(#)nfs.rfc.ms      2.2 88/08/05 4.0 RPCSRC
5.de BT
6.if \\n%=1 .tl ''- % -''
7..
8.ND
9.\" prevent excess underlining in nroff
10.if n .fp 2 R
11.OH 'Network File System: Version 2 Protocol Specification''Page %'
12.EH 'Page %''Network File System: Version 2 Protocol Specification'
13.if \\n%=1 .bp
14.SH
15\&Network File System: Version 2 Protocol Specification
16.IX NFS "" "" "" PAGE MAJOR
17.IX "Network File System" "" "" "" PAGE MAJOR
18.IX NFS "version-2 protocol specification"
19.IX "Network File System" "version-2 protocol specification"
20.LP
21.NH 0
22\&Status of this Standard
23.LP
24Note: This document specifies a protocol that Sun Microsystems, Inc.,
25and others are using.  It specifies it in standard ARPA RFC form.
26.NH 1
27\&Introduction
28.IX NFS introduction
29.LP
30The Sun Network Filesystem (NFS) protocol provides transparent remote
31access to shared filesystems over local area networks.  The NFS
32protocol is designed to be machine, operating system, network architecture,
33and transport protocol independent.  This independence is
34achieved through the use of Remote Procedure Call (RPC) primitives
35built on top of an External Data Representation (XDR).  Implementations
36exist for a variety of machines, from personal computers to
37supercomputers.
38.LP
39The supporting mount protocol allows the server to hand out remote
40access privileges to a restricted set of clients.  It performs the
41operating system-specific functions that allow, for example, to
42attach remote directory trees to some local file system.
43.NH 2
44\&Remote Procedure Call
45.IX "Remote Procedure Call"
46.LP
47Sun's remote procedure call specification provides a procedure-
48oriented interface to remote services.  Each server supplies a
49program that is a set of procedures.  NFS is one such "program".
50The combination of host address, program number, and procedure
51number specifies one remote service procedure.  RPC does not depend
52on services provided by specific protocols, so it can be used with
53any underlying transport protocol.  See the
54.I "Remote Procedure Calls: Protocol Specification"
55chapter of this manual.
56.NH 2
57\&External Data Representation
58.IX "External Data Representation"
59.LP
60The External Data Representation (XDR) standard provides a common
61way of representing a set of data types over a network. 
62The NFS
63Protocol Specification is written using the RPC data description
64language. 
65For more information, see the
66.I " External Data Representation Standard: Protocol Specification." 
67Sun provides implementations of XDR and
68RPC,  but NFS does not require their use.  Any software that
69provides equivalent functionality can be used, and if the encoding
70is exactly the same it can interoperate with other implementations
71of NFS.
72.NH 2
73\&Stateless Servers
74.IX "stateless servers"
75.IX servers stateless
76.LP
77The NFS protocol is stateless.  That is, a server does not need to
78maintain any extra state information about any of its clients in
79order to function correctly.  Stateless servers have a distinct
80advantage over stateful servers in the event of a failure.  With
81stateless servers, a client need only retry a request until the
82server responds; it does not even need to know that the server has
83crashed, or the network temporarily went down.  The client of a
84stateful server, on the other hand, needs to either detect a server
85crash and rebuild the server's state when it comes back up, or
86cause client operations to fail.
87.LP
88This may not sound like an important issue, but it affects the
89protocol in some unexpected ways.  We feel that it is worth a bit
90of extra complexity in the protocol to be able to write very simple
91servers that do not require fancy crash recovery.
92.LP
93On the other hand, NFS deals with objects such as files and
94directories that inherently have state -- what good would a file be
95if it did not keep its contents intact?  The goal is to not
96introduce any extra state in the protocol itself.  Another way to
97simplify recovery is by making operations "idempotent" whenever
98possible (so that they can potentially be repeated).
99.NH 1
100\&NFS Protocol Definition
101.IX NFS "protocol definition"
102.IX NFS protocol
103.LP
104Servers have been known to change over time, and so can the
105protocol that they use. So RPC provides a version number with each
106RPC request. This RFC describes version two of the NFS protocol.
107Even in the second version, there are various obsolete procedures
108and parameters, which will be removed in later versions. An RFC
109for version three of the NFS protocol is currently under
110preparation.
111.NH 2
112\&File System Model
113.IX filesystem model
114.LP
115NFS assumes a file system that is hierarchical, with directories as
116all but the bottom-level files.  Each entry in a directory (file,
117directory, device, etc.)  has a string name.  Different operating
118systems may have restrictions on the depth of the tree or the names
119used, as well as using different syntax to represent the "pathname",
120which is the concatenation of all the "components" (directory and
121file names) in the name.  A "file system" is a tree on a single
122server (usually a single disk or physical partition) with a specified
123"root".  Some operating systems provide a "mount" operation to make
124all file systems appear as a single tree, while others maintain a
125"forest" of file systems.  Files are unstructured streams of
126uninterpreted bytes.  Version 3 of NFS uses a slightly more general
127file system model.
128.LP
129NFS looks up one component of a pathname at a time.  It may not be
130obvious why it does not just take the whole pathname, traipse down
131the directories, and return a file handle when it is done.  There are
132several good reasons not to do this.  First, pathnames need
133separators between the directory components, and different operating
134systems use different separators.  We could define a Network Standard
135Pathname Representation, but then every pathname would have to be
136parsed and converted at each end.  Other issues are discussed in
137\fINFS Implementation Issues\fP below.
138.LP
139Although files and directories are similar objects in many ways,
140different procedures are used to read directories and files.  This
141provides a network standard format for representing directories.  The
142same argument as above could have been used to justify a procedure
143that returns only one directory entry per call.  The problem is
144efficiency.  Directories can contain many entries, and a remote call
145to return each would be just too slow.
146.NH 2
147\&RPC Information
148.IX NFS "RPC information"
149.IP \fIAuthentication\fP
150The   NFS  service uses
151.I AUTH_UNIX ,
152.I AUTH_DES ,
153or
154.I AUTH_SHORT
155style
156authentication, except in  the  NULL procedure where   
157.I AUTH_NONE
158is also allowed.
159.IP "\fITransport Protocols\fP"
160NFS currently is supported on UDP/IP only. 
161.IP "\fIPort Number\fP"
162The NFS protocol currently uses the UDP port number 2049.  This is
163not an officially assigned port, so  later versions of the protocol
164use the \*QPortmapping\*U facility of RPC.
165.NH 2
166\&Sizes of XDR Structures
167.IX "XDR structure sizes"
168.LP
169These are the sizes, given in decimal bytes, of various XDR
170structures used in the protocol:
171.DS
172/* \fIThe maximum number of bytes of data in a READ or WRITE request\fP  */
173const MAXDATA = 8192;
174
175/* \fIThe maximum number of bytes in a pathname argument\fP */
176const MAXPATHLEN = 1024;
177
178/* \fIThe maximum number of bytes in a file name argument\fP */
179const MAXNAMLEN = 255;
180
181/* \fIThe size in bytes of the opaque "cookie" passed by READDIR\fP */
182const COOKIESIZE  = 4;
183
184/* \fIThe size in bytes of the opaque file handle\fP */
185const FHSIZE = 32;
186.DE
187.NH 2
188\&Basic Data Types
189.IX "NFS data types"
190.IX NFS "basic data types"
191.LP
192The following XDR  definitions are basic  structures and types used
193in other structures described further on.
194.KS
195.NH 3
196\&stat
197.IX "NFS data types" stat "" \fIstat\fP
198.DS
199enum stat {
200        NFS_OK = 0,
201        NFSERR_PERM=1,
202        NFSERR_NOENT=2,
203        NFSERR_IO=5,
204        NFSERR_NXIO=6,
205        NFSERR_ACCES=13,
206        NFSERR_EXIST=17,
207        NFSERR_NODEV=19,
208        NFSERR_NOTDIR=20,
209        NFSERR_ISDIR=21,
210        NFSERR_FBIG=27,
211        NFSERR_NOSPC=28,
212        NFSERR_ROFS=30,
213        NFSERR_NAMETOOLONG=63,
214        NFSERR_NOTEMPTY=66,
215        NFSERR_DQUOT=69,
216        NFSERR_STALE=70,
217        NFSERR_WFLUSH=99
218};
219.DE
220.KE
221.LP
222The
223.I stat
224type  is returned with every  procedure's  results.   A
225value of
226.I NFS_OK
227indicates that the  call completed successfully and
228the  results are  valid.  The  other  values indicate  some kind of
229error  occurred on the  server  side  during the servicing   of the
230procedure.  The error values are derived from UNIX error numbers.
231.IP \fBNFSERR_PERM\fP:
232Not owner.  The caller does not have correct ownership
233to perform the requested operation.
234.IP \fBNFSERR_NOENT\fP:
235No such file or directory.    The file or directory
236specified does not exist.
237.IP \fBNFSERR_IO\fP:
238Some sort of hard  error occurred when the operation was
239in progress.  This could be a disk error, for example.
240.IP \fBNFSERR_NXIO\fP:
241No such device or address.
242.IP \fBNFSERR_ACCES\fP:
243Permission  denied.  The  caller does  not  have the
244correct permission to perform the requested operation.
245.IP \fBNFSERR_EXIST\fP:
246File exists.  The file specified already exists.
247.IP \fBNFSERR_NODEV\fP:
248No such device.
249.IP \fBNFSERR_NOTDIR\fP:
250Not   a  directory.    The  caller  specified   a
251non-directory in a directory operation.
252.IP \fBNFSERR_ISDIR\fP:
253Is a directory.  The caller specified  a directory in
254a non- directory operation.
255.IP \fBNFSERR_FBIG\fP:
256File too large.   The  operation caused a file to grow
257beyond the server's limit.
258.IP \fBNFSERR_NOSPC\fP:
259No space left on  device.   The operation caused the
260server's filesystem to reach its limit.
261.IP \fBNFSERR_ROFS\fP:
262Read-only filesystem.  Write attempted on a read-only filesystem.
263.IP \fBNFSERR_NAMETOOLONG\fP:
264File name   too   long.  The file  name  in  an operation was too long.
265.IP \fBNFSERR_NOTEMPTY\fP:
266Directory   not empty.  Attempted  to   remove  a
267directory that was not empty.
268.IP \fBNFSERR_DQUOT\fP:
269Disk quota exceeded.  The client's disk  quota on the
270server has been exceeded.
271.IP \fBNFSERR_STALE\fP:
272The  "fhandle" given in   the arguments was invalid.
273That is, the file referred to by that file handle no longer exists,
274or access to it has been revoked.
275.IP \fBNFSERR_WFLUSH\fP:
276The server's  write cache  used  in the
277.I WRITECACHE
278call got flushed to disk.
279.LP
280.KS
281.NH 3
282\&ftype
283.IX "NFS data types" ftype "" \fIftype\fP
284.DS
285enum ftype {
286        NFNON = 0,
287        NFREG = 1,
288        NFDIR = 2,
289        NFBLK = 3,
290        NFCHR = 4,
291        NFLNK = 5
292};
293.DE
294.KE
295The enumeration
296.I ftype
297gives the type of a file.  The type
298.I NFNON
299indicates a non-file,
300.I NFREG
301is a regular file,
302.I NFDIR
303is a directory,
304.I NFBLK
305is a block-special device,
306.I NFCHR
307is a character-special device, and
308.I NFLNK
309is a symbolic link.
310.KS
311.NH 3
312\&fhandle
313.IX "NFS data types" fhandle "" \fIfhandle\fP
314.DS
315typedef opaque fhandle[FHSIZE];
316.DE
317.KE
318The
319.I fhandle
320is the file handle passed between the server and the client. 
321All file operations are done using file handles to refer to a file or
322directory.  The file handle can contain whatever information the server
323needs to distinguish an individual file.
324.KS
325.NH 3
326\&timeval
327.IX "NFS data types" timeval "" \fItimeval\fP
328.DS
329struct timeval {
330        unsigned int seconds;
331        unsigned int useconds;
332};
333.DE
334.KE
335The
336.I timeval
337structure is the number of seconds and microseconds
338since midnight January 1, 1970, Greenwich Mean Time.  It is used to
339pass time and date information.
340.KS
341.NH 3
342\&fattr
343.IX "NFS data types" fattr "" \fIfattr\fP
344.DS
345struct fattr {
346        ftype        type;
347        unsigned int mode;
348        unsigned int nlink;
349        unsigned int uid;
350        unsigned int gid;
351        unsigned int size;
352        unsigned int blocksize;
353        unsigned int rdev;
354        unsigned int blocks;
355        unsigned int fsid;
356        unsigned int fileid;
357        timeval      atime;
358        timeval      mtime;
359        timeval      ctime;
360};
361.DE
362.KE
363The
364.I fattr
365structure contains the attributes of a file; "type" is the type of
366the file; "nlink" is the number of hard links to the file (the number
367of different names for the same file); "uid" is the user
368identification number of the owner of the file; "gid" is the group
369identification number of the group of the file; "size" is the size in
370bytes of the file; "blocksize" is the size in bytes of a block of the
371file; "rdev" is the device number of the file if it is type
372.I NFCHR
373or
374.I NFBLK ;
375"blocks" is the number of blocks the file takes up on disk; "fsid" is
376the file system identifier for the filesystem containing the file;
377"fileid" is a number that uniquely identifies the file within its
378filesystem; "atime" is the time when the file was last accessed for
379either read or write; "mtime" is the time when the file data was last
380modified (written); and "ctime" is the time when the status of the
381file was last changed.  Writing to the file also changes "ctime" if
382the size of the file changes.
383.LP
384"mode" is the access mode encoded as a set of bits.  Notice that the
385file type is specified both in the mode bits and in the file type.
386This is really a bug in the protocol and will be fixed in future
387versions.  The descriptions given below specify the bit positions
388using octal numbers.
389.TS
390box tab (&) ;
391cfI cfI
392lfL l .
393Bit&Description
394_
3950040000&This is a directory; "type" field should be NFDIR.
3960020000&This is a character special file; "type" field should be NFCHR.
3970060000&This is a block special file; "type" field should be NFBLK.
3980100000&This is a regular file; "type" field should be NFREG.
3990120000&This is a symbolic link file;  "type" field should be NFLNK.
4000140000&This is a named socket; "type" field should be NFNON.
4010004000&Set user id on execution.
4020002000&Set group id on execution.
4030001000&Save swapped text even after use.
4040000400&Read permission for owner.
4050000200&Write permission for owner.
4060000100&Execute and search permission for owner.
4070000040&Read permission for group.
4080000020&Write permission for group.
4090000010&Execute and search permission for group.
4100000004&Read permission for others.
4110000002&Write permission for others.
4120000001&Execute and search permission for others.
413.TE
414.KS
415Notes:
416.IP
417The bits are  the same as the mode   bits returned  by  the
418.I stat(2)
419system call in the UNIX system.  The file  type is  specified  both in
420the mode  bits  and in  the file type.   This   is fixed  in future
421versions.
422.IP
423The "rdev" field in the attributes structure is an operating system
424specific device specifier.  It  will be  removed and generalized in
425the next revision of the protocol.
426.KE
427.LP
428.KS
429.NH 3
430\&sattr
431.IX "NFS data types" sattr "" \fIsattr\fP
432.DS
433struct sattr {
434        unsigned int mode;
435        unsigned int uid;
436        unsigned int gid;
437        unsigned int size;
438        timeval      atime;
439        timeval      mtime;
440};
441.DE
442.KE
443The
444.I sattr
445structure contains the file attributes which can be set
446from the client.  The fields are the same as for 
447.I fattr
448above.  A "size" of zero  means the file should be  truncated.
449A value of -1 indicates a field that should be ignored.
450.LP
451.KS
452.NH 3
453\&filename
454.IX "NFS data types" filename "" \fIfilename\fP
455.DS
456typedef string filename<MAXNAMLEN>;
457.DE
458.KE
459The type
460.I filename
461is used for  passing file names  or  pathname components.
462.LP
463.KS
464.NH 3
465\&path
466.IX "NFS data types" path "" \fIpath\fP
467.DS
468typedef string path<MAXPATHLEN>;
469.DE
470.KE
471The type
472.I path
473is a pathname.  The server considers it as a string
474with no internal structure,  but to the client  it is the name of a
475node in a filesystem tree.
476.LP
477.KS
478.NH 3
479\&attrstat
480.IX "NFS data types" attrstat "" \fIattrstat\fP
481.DS
482union attrstat switch (stat status) {
483        case NFS_OK:
484                fattr attributes;
485        default:
486                void;
487};
488.DE
489.KE
490The
491.I attrstat
492structure is a common procedure result.  It contains
493a  "status" and,  if  the call   succeeded,   it also contains  the
494attributes of the file on which the operation was done.
495.LP
496.KS
497.NH 3
498\&diropargs
499.IX "NFS data types" diropargs "" \fIdiropargs\fP
500.DS
501struct diropargs {
502        fhandle  dir;
503        filename name;
504};
505.DE
506.KE
507The 
508.I diropargs
509structure is used  in  directory  operations.  The
510"fhandle" "dir" is the directory in  which to find the file "name".
511A directory operation is one in which the directory is affected.
512.LP
513.KS
514.NH 3
515\&diropres
516.IX "NFS data types" diropres "" \fIdiropres\fP
517.DS
518union diropres switch (stat status) {
519        case NFS_OK:
520                struct {
521                        fhandle file;
522                        fattr   attributes;
523                } diropok;
524        default:
525                void;
526};
527.DE
528.KE
529The results of a directory operation  are returned  in a
530.I diropres
531structure.  If the call succeeded, a new file handle "file" and the
532"attributes" associated with that file are  returned along with the
533"status".
534.NH 2
535\&Server Procedures
536.IX "NFS server procedures" "" "" "" PAGE MAJOR
537.LP
538The  protocol definition  is given as   a  set  of  procedures with
539arguments  and results defined using the   RPC  language.   A brief
540description of the function of each procedure should provide enough
541information to allow implementation.
542.LP
543All of  the procedures  in   the NFS  protocol  are assumed  to  be
544synchronous.   When a procedure  returns to the  client, the client
545can assume that the operation has completed and any data associated
546with the request is  now on stable storage.  For  example, a client
547.I WRITE
548request   may  cause  the   server  to  update  data  blocks,
549filesystem information blocks (such as indirect  blocks),  and file
550attribute  information (size  and  modify  times).  When  the
551.I WRITE
552returns to the client, it can assume  that the write  is safe, even
553in case of  a server  crash, and  it can discard the  data written.
554This is a very important part  of the statelessness  of the server.
555If the server waited to flush data from remote requests, the client
556would have to  save those requests so that  it could resend them in
557case of a server crash.
558.ie t .DS
559.el .DS L
560
561.ft I
562/*
563* Remote file service routines
564*/
565.ft CW
566program NFS_PROGRAM {
567        version NFS_VERSION {
568                void        NFSPROC_NULL(void)              = 0;
569                attrstat    NFSPROC_GETATTR(fhandle)        = 1;
570                attrstat    NFSPROC_SETATTR(sattrargs)      = 2;
571                void        NFSPROC_ROOT(void)              = 3;
572                diropres    NFSPROC_LOOKUP(diropargs)       = 4;
573                readlinkres NFSPROC_READLINK(fhandle)       = 5;
574                readres     NFSPROC_READ(readargs)          = 6;
575                void        NFSPROC_WRITECACHE(void)        = 7;
576                attrstat    NFSPROC_WRITE(writeargs)        = 8;
577                diropres    NFSPROC_CREATE(createargs)      = 9;
578                stat        NFSPROC_REMOVE(diropargs)       = 10;
579                stat        NFSPROC_RENAME(renameargs)      = 11;
580                stat        NFSPROC_LINK(linkargs)          = 12;
581                stat        NFSPROC_SYMLINK(symlinkargs)    = 13;
582                diropres    NFSPROC_MKDIR(createargs)       = 14;
583                stat        NFSPROC_RMDIR(diropargs)        = 15;
584                readdirres  NFSPROC_READDIR(readdirargs)    = 16;
585                statfsres   NFSPROC_STATFS(fhandle)         = 17;
586        } = 2;
587} = 100003;
588.DE
589.KS
590.NH 3
591\&Do Nothing
592.IX "NFS server procedures" NFSPROC_NULL() "" \fINFSPROC_NULL()\fP
593.DS
594void
595NFSPROC_NULL(void) = 0;
596.DE
597.KE
598This procedure does no work.   It is made available  in  all RPC
599services to allow server response testing and timing.
600.KS
601.NH 3
602\&Get File Attributes
603.IX "NFS server procedures" NFSPROC_GETATTR() "" \fINFSPROC_GETATTR()\fP
604.DS
605attrstat
606NFSPROC_GETATTR (fhandle) = 1;
607.DE
608.KE
609If the reply  status is
610.I NFS_OK ,
611then  the reply attributes contains
612the attributes for the file given by the input fhandle.
613.KS
614.NH 3
615\&Set File Attributes
616.IX "NFS server procedures" NFSPROC_SETATTR() "" \fINFSPROC_SETATTR()\fP
617.DS
618struct sattrargs {
619        fhandle file;
620        sattr attributes;
621        };
622
623attrstat
624NFSPROC_SETATTR (sattrargs) = 2;
625.DE
626.KE
627The  "attributes" argument  contains fields which are either  -1 or
628are  the  new value for  the  attributes of  "file".   If the reply
629status is
630.I NFS_OK ,
631then the  reply attributes have the attributes of
632the file after the "SETATTR" operation has completed.
633.LP
634Note: The use of -1 to indicate an unused field in "attributes" is
635changed in the next version of the protocol.
636.KS
637.NH 3
638\&Get Filesystem Root
639.IX "NFS server procedures" NFSPROC_ROOT "" \fINFSPROC_ROOT\fP
640.DS
641void
642NFSPROC_ROOT(void) = 3;
643.DE
644.KE
645Obsolete.  This procedure  is no longer used   because  finding the
646root file handle of a filesystem requires moving  pathnames between
647client  and server.  To  do  this right we would  have  to define a
648network standard representation of pathnames.  Instead, the
649function  of  looking up  the   root  file handle  is  done  by the
650.I MNTPROC_MNT()
651procedure.    (See the
652.I "Mount Protocol Definition"
653later in this chapter for details).
654.KS
655.NH 3
656\&Look Up File Name
657.IX "NFS server procedures" NFSPROC_LOOKUP() "" \fINFSPROC_LOOKUP()\fP
658.DS
659diropres
660NFSPROC_LOOKUP(diropargs) = 4;
661.DE
662.KE
663If  the reply "status"  is
664.I NFS_OK ,
665then the reply  "file" and reply
666"attributes" are the file handle and attributes for the file "name"
667in the directory given by "dir" in the argument.
668.KS
669.NH 3
670\&Read From Symbolic Link
671.IX "NFS server procedures" NFSPROC_READLINK() "" \fINFSPROC_READLINK()\fP
672.DS
673union readlinkres switch (stat status) {
674        case NFS_OK:
675                path data;
676        default:
677                void;
678};
679
680readlinkres
681NFSPROC_READLINK(fhandle) = 5;
682.DE
683.KE
684If "status" has the value
685.I NFS_OK ,
686then the reply "data" is the data in
687the symbolic link given by the file referred to by the fhandle argument.
688.LP
689Note:  since   NFS always  parses pathnames    on the  client, the
690pathname in  a symbolic  link may  mean something  different (or be
691meaningless) on a different client or on the server if  a different
692pathname syntax is used.
693.KS
694.NH 3
695\&Read From File
696.IX "NFS server procedures" NFSPROC_READ "" \fINFSPROC_READ\fP
697.DS
698struct readargs {
699        fhandle file;
700        unsigned offset;
701        unsigned count;
702        unsigned totalcount;
703};
704
705union readres switch (stat status) {
706        case NFS_OK:
707                fattr attributes;
708                opaque data<NFS_MAXDATA>;
709        default:
710                void;
711};
712
713readres
714NFSPROC_READ(readargs) = 6;
715.DE
716.KE
717Returns  up  to  "count" bytes of   "data" from  the file  given by
718"file", starting at "offset" bytes from  the beginning of the file.
719The first byte of the file is  at offset zero.  The file attributes
720after the read takes place are returned in "attributes".
721.LP
722Note: The  argument "totalcount" is  unused, and is removed in the
723next protocol revision.
724.KS
725.NH 3
726\&Write to Cache
727.IX "NFS server procedures" NFSPROC_WRITECACHE() "" \fINFSPROC_WRITECACHE()\fP
728.DS
729void
730NFSPROC_WRITECACHE(void) = 7;
731.DE
732.KE
733To be used in the next protocol revision.
734.KS
735.NH 3
736\&Write to File
737.IX "NFS server procedures" NFSPROC_WRITE() "" \fINFSPROC_WRITE()\fP
738.DS
739struct writeargs {
740        fhandle file;         
741        unsigned beginoffset; 
742        unsigned offset;       
743        unsigned totalcount;   
744        opaque data<NFS_MAXDATA>;
745};
746
747attrstat       
748NFSPROC_WRITE(writeargs) = 8;
749.DE
750.KE
751Writes   "data" beginning  "offset"  bytes  from the  beginning  of
752"file".  The first byte  of  the file is at  offset  zero.  If  the
753reply "status" is NFS_OK, then  the reply "attributes" contains the
754attributes  of the file after the  write has  completed.  The write
755operation is atomic.  Data from this  call to
756.I WRITE
757will not be mixed with data from another client's calls.
758.LP
759Note: The arguments "beginoffset" and "totalcount" are ignored and
760are removed in the next protocol revision.
761.KS
762.NH 3
763\&Create File
764.IX "NFS server procedures" NFSPROC_CREATE() "" \fINFSPROC_CREATE()\fP
765.DS
766struct createargs {
767        diropargs where;
768        sattr attributes;
769};
770
771diropres
772NFSPROC_CREATE(createargs) = 9;
773.DE
774.KE
775The file "name" is created  in the directory given  by "dir".   The
776initial  attributes of the  new file  are given by "attributes".  A
777reply "status"  of NFS_OK indicates that the  file was created, and
778reply "file"   and   reply "attributes"  are    its file handle and
779attributes.   Any  other reply  "status"  means that  the operation
780failed and no file was created.
781.LP
782Note: This  routine should pass  an exclusive create flag, meaning
783"create the file only if it is not already there".
784.KS
785.NH 3
786\&Remove File
787.IX "NFS server procedures" NFSPROC_REMOVE() "" \fINFSPROC_REMOVE()\fP
788.DS
789stat
790NFSPROC_REMOVE(diropargs) = 10;
791.DE
792.KE
793The file "name" is  removed from the directory  given by "dir".   A
794reply of NFS_OK means the directory entry was removed.
795.LP
796Note: possibly non-idempotent operation.
797.KS
798.NH 3
799\&Rename File
800.IX "NFS server procedures" NFSPROC_RENAME() "" \fINFSPROC_RENAME()\fP
801.DS
802struct renameargs {
803        diropargs from;
804        diropargs to;
805};
806
807stat
808NFSPROC_RENAME(renameargs) = 11;
809.DE
810.KE
811The existing file "from.name" in  the directory given by "from.dir"
812is renamed to "to.name" in the directory given by "to.dir".  If the
813reply  is
814.I NFS_OK ,
815the file was  renamed.  The 
816RENAME 
817operation is
818atomic on the server; it cannot be interrupted in the middle.
819.LP
820Note: possibly non-idempotent operation.
821.KS
822.NH 3
823\&Create Link to File
824.IX "NFS server procedures" NFSPROC_LINK() "" \fINFSPROC_LINK()\fP
825.DS
826struct linkargs {
827        fhandle from;
828        diropargs to;
829};
830
831stat
832NFSPROC_LINK(linkargs) = 12;
833.DE
834.KE
835Creates the  file "to.name"  in the directory  given   by "to.dir",
836which is a hard link to the existing file given  by "from".  If the
837return value is
838.I NFS_OK ,
839a link was created.  Any other return value
840indicates an error, and the link was not created.
841.LP
842A hard link should have the property that changes  to either of the
843linked files are reflected in both files.  When a hard link is made
844to a  file, the attributes  for  the file should  have  a value for
845"nlink" that is one greater than the value before the link.
846.LP
847Note: possibly non-idempotent operation.
848.KS
849.NH 3
850\&Create Symbolic Link
851.IX "NFS server procedures" NFSPROC_SYMLINK() "" \fINFSPROC_SYMLINK()\fP
852.DS
853struct symlinkargs {
854        diropargs from;
855        path to;
856        sattr attributes;
857};
858
859stat
860NFSPROC_SYMLINK(symlinkargs) = 13;
861.DE
862.KE
863Creates the  file "from.name" with  ftype 
864.I NFLNK
865in  the  directory
866given by "from.dir".   The new file contains  the pathname "to" and
867has initial attributes given by "attributes".  If  the return value
868is
869.I NFS_OK ,
870a link was created.  Any other return value indicates an
871error, and the link was not created.
872.LP
873A symbolic  link is  a pointer to another file.   The name given in
874"to" is  not interpreted by  the server, only stored in  the  newly
875created file.  When the client references a file that is a symbolic
876link, the contents of the symbolic  link are normally transparently
877reinterpreted  as a pathname  to substitute.   A
878.I READLINK
879operation returns the data to the client for interpretation.
880.LP
881Note:  On UNIX servers the attributes are never used, since
882symbolic links always have mode 0777.
883.KS
884.NH 3
885\&Create Directory
886.IX "NFS server procedures" NFSPROC_MKDIR() "" \fINFSPROC_MKDIR()\fP
887.DS
888diropres
889NFSPROC_MKDIR (createargs) = 14;
890.DE
891.KE
892The new directory "where.name" is created in the directory given by
893"where.dir".  The initial attributes of the new directory are given
894by "attributes".  A reply "status" of NFS_OK indicates that the new
895directory was created, and reply "file" and  reply "attributes" are
896its file  handle and attributes.  Any  other  reply "status"  means
897that the operation failed and no directory was created.
898.LP
899Note: possibly non-idempotent operation.
900.KS
901.NH 3
902\&Remove Directory
903.IX "NFS server procedures" NFSPROC_RMDIR() "" \fINFSPROC_RMDIR()\fP
904.DS
905stat
906NFSPROC_RMDIR(diropargs) = 15;
907.DE
908.KE
909The existing empty directory "name" in the directory given by "dir"
910is removed.  If the reply is
911.I NFS_OK ,
912the directory was removed.
913.LP
914Note: possibly non-idempotent operation.
915.KS
916.NH 3
917\&Read From Directory
918.IX "NFS server procedures" NFSPROC_READDIR() "" \fINFSPROC_READDIR()\fP
919.DS
920struct readdirargs {
921        fhandle dir;           
922        nfscookie cookie;
923        unsigned count;         
924};
925
926struct entry {
927        unsigned fileid;
928        filename name;
929        nfscookie cookie;
930        entry *nextentry;
931};
932
933union readdirres switch (stat status) {
934        case NFS_OK:
935                struct {
936                        entry *entries;
937                        bool eof;
938                } readdirok;
939        default:
940                void;
941};
942
943readdirres
944NFSPROC_READDIR (readdirargs) = 16;
945.DE
946.KE
947Returns a variable number of  directory entries,  with a total size
948of up to "count" bytes, from the directory given  by "dir".  If the
949returned  value of "status"  is
950.I NFS_OK ,
951then  it  is followed  by a
952variable  number  of "entry"s.    Each "entry" contains  a "fileid"
953which consists of a  unique number  to identify the  file within  a
954filesystem,  the  "name" of the  file, and a "cookie" which   is an
955opaque pointer to the next entry in  the  directory.  The cookie is
956used  in the next 
957.I READDIR
958call to get more  entries  starting at a
959given point in  the directory.  The  special cookie zero (all  bits
960zero) can be used to get the entries starting  at the  beginning of
961the directory.  The "fileid" field should be the same number as the
962"fileid" in the the  attributes of the  file.  (See the
963.I "Basic Data Types"
964section.)
965The "eof" flag has a value of
966.I TRUE
967if there are no more entries in the directory.
968.KS
969.NH 3
970\&Get Filesystem Attributes
971.IX "NFS server procedures" NFSPROC_STATFS() "" \fINFSPROC_STATFS()\fP
972.DS
973union statfsres (stat status) {
974        case NFS_OK:
975                struct {
976                        unsigned tsize;
977                        unsigned bsize;
978                        unsigned blocks;
979                        unsigned bfree;
980                        unsigned bavail;
981                } info;
982        default:
983                void;
984};
985
986statfsres
987NFSPROC_STATFS(fhandle) = 17;
988.DE
989.KE
990If the  reply "status"  is
991.I NFS_OK ,
992then the  reply "info" gives the
993attributes for the filesystem that contains file referred to by the
994input fhandle.  The attribute fields contain the following values:
995.IP tsize:   
996The optimum transfer size of the server in bytes.  This is
997the number  of bytes the server  would like to have in the
998data part of READ and WRITE requests.
999.IP bsize:   
1000The block size in bytes of the filesystem.
1001.IP blocks: 
1002The total number of "bsize" blocks on the filesystem.
1003.IP bfree:   
1004The number of free "bsize" blocks on the filesystem.
1005.IP bavail: 
1006The number of  "bsize" blocks  available to non-privileged users.
1007.LP
1008Note: This call does not  work well if a  filesystem has  variable
1009size blocks.
1010.NH 1
1011\&NFS Implementation Issues
1012.IX NFS implementation
1013.LP
1014The NFS protocol is designed to be operating system independent, but
1015since this version was designed in a UNIX environment, many
1016operations have semantics similar to the operations of the UNIX file
1017system.  This section discusses some of the implementation-specific
1018semantic issues.
1019.NH 2
1020\&Server/Client Relationship
1021.IX NFS "server/client relationship"
1022.LP
1023The NFS protocol is designed to allow servers to be as simple and
1024general as possible.  Sometimes the simplicity of the server can be a
1025problem, if the client wants to implement complicated filesystem
1026semantics.
1027.LP
1028For example, some operating systems allow removal of open files.  A
1029process can open a file and, while it is open, remove it from the
1030directory.  The file can be read and written as long as the process
1031keeps it open, even though the file has no name in the filesystem.
1032It is impossible for a stateless server to implement these semantics.
1033The client can do some tricks such as renaming the file on remove,
1034and only removing it on close.  We believe that the server provides
1035enough functionality to implement most file system semantics on the
1036client.
1037.LP
1038Every NFS client can also potentially be a server, and remote and
1039local mounted filesystems can be freely intermixed.  This leads to
1040some interesting problems when a client travels down the directory
1041tree of a remote filesystem and reaches the mount point on the server
1042for another remote filesystem.  Allowing the server to follow the
1043second remote mount would require loop detection, server lookup, and
1044user revalidation.  Instead, we decided not to let clients cross a
1045server's mount point.  When a client does a LOOKUP on a directory on
1046which the server has mounted a filesystem, the client sees the
1047underlying directory instead of the mounted directory.  A client can
1048do remote mounts that match the server's mount points to maintain the
1049server's view.
1050.LP
1051.NH 2
1052\&Pathname Interpretation
1053.IX NFS "pathname interpretation"
1054.LP
1055There are a few complications to the rule that pathnames are always
1056parsed on the client.  For example, symbolic links could have
1057different interpretations on different clients.  Another common
1058problem for non-UNIX implementations is the special interpretation of
1059the pathname ".."  to mean the parent of a given directory.  The next
1060revision of the protocol uses an explicit flag to indicate the parent
1061instead.
1062.NH 2
1063\&Permission Issues
1064.IX NFS "permission issues"
1065.LP
1066The NFS protocol, strictly speaking, does not define the permission
1067checking used  by servers.  However,  it is  expected that a server
1068will do normal operating system permission checking using
1069.I AUTH_UNIX
1070style authentication as the basis of its protection mechanism.  The
1071server gets the client's effective "uid", effective "gid", and groups
1072on each call and uses them to check permission.  There are various
1073problems with this method that can been resolved in interesting ways.
1074.LP
1075Using "uid" and "gid" implies that the client and server share the
1076same "uid" list.  Every server and client pair must have the same
1077mapping from user to "uid" and from group to "gid".  Since every
1078client can also be a server, this tends to imply that the whole
1079network shares the same "uid/gid" space.
1080.I AUTH_DES
1081(and the  next
1082revision of the NFS protocol) uses string names instead of numbers,
1083but there are still complex problems to be solved.
1084.LP
1085Another problem arises due to the usually stateful open operation.
1086Most operating systems check permission at open time, and then check
1087that the file is open on each read and write request.  With stateless
1088servers, the server has no idea that the file is open and must do
1089permission checking on each read and write call.  On a local
1090filesystem, a user can open a file and then change the permissions so
1091that no one is allowed to touch it, but will still be able to write
1092to the file because it is open.  On a remote filesystem, by contrast,
1093the write would fail.  To get around this problem, the server's
1094permission checking algorithm should allow the owner of a file to
1095access it regardless of the permission setting.
1096.LP
1097A similar problem has to do with paging in from a file over the
1098network.  The operating system usually checks for execute permission
1099before opening a file for demand paging, and then reads blocks from
1100the open file.  The file may not have read permission, but after it
1101is opened it doesn't matter.  An NFS server can not tell the
1102difference between a normal file read and a demand page-in read.  To
1103make this work, the server allows reading of files if the "uid" given
1104in the call has execute or read permission on the file.
1105.LP
1106In most operating systems, a particular user (on the user ID zero)
1107has access to all files no matter what permission and ownership they
1108have.  This "super-user" permission may not be allowed on the server,
1109since anyone who can become super-user on their workstation could
1110gain access to all remote files.  The UNIX server by default maps
1111user id 0 to -2 before doing its access checking.  This works except
1112for NFS root filesystems, where super-user access cannot be avoided.
1113.NH 2
1114\&Setting RPC Parameters
1115.IX NFS "setting RPC parameters"
1116.LP
1117Various file system parameters and options should be set at mount
1118time.  The mount protocol is described in the appendix below.  For
1119example, "Soft" mounts as well as "Hard" mounts are usually both
1120provided.  Soft mounted file systems return errors when RPC
1121operations fail (after a given number of optional retransmissions),
1122while hard mounted file systems continue to retransmit forever.
1123Clients and servers may need to keep caches of recent operations to
1124help avoid problems with non-idempotent operations.
1125.NH 1
1126\&Mount Protocol Definition
1127.IX "mount protocol" "" "" "" PAGE MAJOR
1128.sp 1
1129.NH 2
1130\&Introduction
1131.IX "mount protocol" introduction
1132.LP
1133The mount protocol is separate from, but related to, the NFS
1134protocol.  It provides operating system specific services to get the
1135NFS off the ground -- looking up server path names, validating user
1136identity, and checking access permissions.  Clients use the mount
1137protocol to get the first file handle, which allows them entry into a
1138remote filesystem.
1139.LP
1140The mount protocol is kept separate from the NFS protocol to make it
1141easy to plug in new access checking and validation methods without
1142changing the NFS server protocol.
1143.LP
1144Notice that the protocol definition implies stateful servers because
1145the server maintains a list of client's mount requests.  The mount
1146list information is not critical for the correct functioning of
1147either the client or the server.  It is intended for advisory use
1148only, for example, to warn possible clients when a server is going
1149down.
1150.LP
1151Version one of the mount protocol is used with version two of the NFS
1152protocol.  The only connecting point is the
1153.I fhandle
1154structure, which is the same for both protocols.
1155.NH 2
1156\&RPC Information
1157.IX "mount protocol"  "RPC information"
1158.IP \fIAuthentication\fP
1159The mount service uses
1160.I AUTH_UNIX
1161and
1162.I AUTH_DES
1163style authentication only.
1164.IP "\fITransport Protocols\fP"
1165The mount service is currently supported on UDP/IP only.
1166.IP "\fIPort Number\fP"
1167Consult the server's portmapper, described in the chapter
1168.I "Remote Procedure Calls: Protocol Specification",
1169to  find  the  port number on which the mount service is registered.
1170.NH 2
1171\&Sizes of XDR Structures
1172.IX "mount protocol" "XDR structure sizes"
1173.LP
1174These  are  the sizes,   given  in  decimal   bytes, of various XDR
1175structures used in the protocol:
1176.DS
1177/* \fIThe maximum number of bytes in a pathname argument\fP */
1178const MNTPATHLEN = 1024;
1179
1180/* \fIThe maximum number of bytes in a name argument\fP */
1181const MNTNAMLEN = 255;
1182
1183/* \fIThe size in bytes of the opaque file handle\fP */
1184const FHSIZE = 32;
1185.DE
1186.NH 2
1187\&Basic Data Types
1188.IX "mount protocol" "basic data types"
1189.IX "mount data types"
1190.LP
1191This section presents the data  types used by  the  mount protocol.
1192In many cases they are similar to the types used in NFS.
1193.KS
1194.NH 3
1195\&fhandle
1196.IX "mount data types" fhandle "" \fIfhandle\fP
1197.DS
1198typedef opaque fhandle[FHSIZE];
1199.DE
1200.KE
1201The type
1202.I fhandle
1203is the file handle that the server passes to the
1204client.  All file operations are done  using file handles  to refer
1205to a  file  or directory.   The  file handle  can  contain whatever
1206information the server needs to distinguish an individual file.
1207.LP
1208This  is the  same as the "fhandle" XDR definition in version 2 of
1209the NFS protocol;  see
1210.I "Basic Data Types"
1211in the definition of the NFS protocol, above.
1212.KS
1213.NH 3
1214\&fhstatus
1215.IX "mount data types" fhstatus "" \fIfhstatus\fP
1216.DS
1217union fhstatus switch (unsigned status) {
1218        case 0:
1219                fhandle directory;
1220        default:
1221                void;
1222};
1223.DE
1224.KE
1225The type
1226.I fhstatus
1227is a union.  If a "status" of zero is returned,
1228the  call completed   successfully, and  a  file handle   for   the
1229"directory"  follows.  A  non-zero  status indicates  some  sort of
1230error.  In this case the status is a UNIX error number.
1231.KS
1232.NH 3
1233\&dirpath
1234.IX "mount data types" dirpath "" \fIdirpath\fP
1235.DS
1236typedef string dirpath<MNTPATHLEN>;
1237.DE
1238.KE
1239The type
1240.I dirpath
1241is a server pathname of a directory.
1242.KS
1243.NH 3
1244\&name
1245.IX "mount data types" name "" \fIname\fP
1246.DS
1247typedef string name<MNTNAMLEN>;
1248.DE
1249.KE
1250The type
1251.I name
1252is an arbitrary string used for various names.
1253.NH 2
1254\&Server Procedures
1255.IX "mount server procedures"
1256.LP
1257The following sections define the RPC procedures  supplied by a
1258mount server.
1259.ie t .DS
1260.el .DS L
1261.ft I
1262/*
1263* Protocol description for the mount program
1264*/
1265.ft CW
1266
1267program MOUNTPROG {
1268.ft I
1269/*
1270* Version 1 of the mount protocol used with
1271* version 2 of the NFS protocol.
1272*/
1273.ft CW
1274        version MOUNTVERS {
1275                void        MOUNTPROC_NULL(void)    = 0;
1276                fhstatus    MOUNTPROC_MNT(dirpath)  = 1;
1277                mountlist   MOUNTPROC_DUMP(void)    = 2;
1278                void        MOUNTPROC_UMNT(dirpath) = 3;
1279                void        MOUNTPROC_UMNTALL(void) = 4;
1280                exportlist  MOUNTPROC_EXPORT(void)  = 5;
1281        } = 1;
1282} = 100005;
1283.DE
1284.KS
1285.NH 3
1286\&Do Nothing
1287.IX "mount server procedures" MNTPROC_NULL() "" \fIMNTPROC_NULL()\fP
1288.DS
1289void
1290MNTPROC_NULL(void) = 0;
1291.DE
1292.KE
1293This  procedure does no work.  It   is  made  available in all  RPC
1294services to allow server response testing and timing.
1295.KS
1296.NH 3
1297\&Add Mount Entry
1298.IX "mount server procedures" MNTPROC_MNT() "" \fIMNTPROC_MNT()\fP
1299.DS
1300fhstatus
1301MNTPROC_MNT(dirpath) = 1;
1302.DE
1303.KE
1304If the reply "status" is 0, then the reply "directory" contains the
1305file handle for the directory "dirname".  This file handle may be
1306used in the NFS protocol.  This procedure also adds a new entry to
1307the mount list for this client mounting "dirname".
1308.KS
1309.NH 3
1310\&Return Mount Entries
1311.IX "mount server procedures" MNTPROC_DUMP() "" \fIMNTPROC_DUMP()\fP
1312.DS
1313struct *mountlist {
1314        name      hostname;
1315        dirpath   directory;
1316        mountlist nextentry;
1317};
1318
1319mountlist
1320MNTPROC_DUMP(void) = 2;
1321.DE
1322.KE
1323Returns  the list of  remote mounted filesystems.   The "mountlist"
1324contains one entry for each "hostname" and "directory" pair.
1325.KS
1326.NH 3
1327\&Remove Mount Entry
1328.IX "mount server procedures" MNTPROC_UMNT() "" \fIMNTPROC_UMNT()\fP
1329.DS
1330void
1331MNTPROC_UMNT(dirpath) = 3;
1332.DE
1333.KE
1334Removes the mount list entry for the input "dirpath".
1335.KS
1336.NH 3
1337\&Remove All Mount Entries
1338.IX "mount server procedures" MNTPROC_UMNTALL() "" \fIMNTPROC_UMNTALL()\fP
1339.DS
1340void
1341MNTPROC_UMNTALL(void) = 4;
1342.DE
1343.KE
1344Removes all of the mount list entries for this client.
1345.KS
1346.NH 3
1347\&Return Export List
1348.IX "mount server procedures" MNTPROC_EXPORT() "" \fIMNTPROC_EXPORT()\fP
1349.DS
1350struct *groups {
1351        name grname;
1352        groups grnext;
1353};
1354
1355struct *exportlist {
1356        dirpath filesys;
1357        groups groups;
1358        exportlist next;
1359};
1360
1361exportlist
1362MNTPROC_EXPORT(void) = 5;
1363.DE
1364.KE
1365Returns a variable number of export list entries.  Each entry
1366contains a filesystem name and a list of groups that are allowed to
1367import it.  The filesystem name is in "filesys", and the group name
1368is in the list "groups".
1369.LP
1370Note:  The exportlist should contain
1371more information about the status of the filesystem, such as a
1372read-only flag.
Note: See TracBrowser for help on using the repository browser.