home *** CD-ROM | disk | FTP | other *** search
/ InfoMagic Internet Tools 1993 July / Internet Tools.iso / iso9660 / ip / nfs / spec < prev    next >
Encoding:
Text File  |  1988-11-25  |  76.1 KB  |  2,711 lines

  1. Here is an ascii version of the NFS version 3 protocol specification.
  2.  
  3. =========================================================================
  4. CUT HERE
  5. =========================================================================
  6.  
  7.  
  8.  
  9.         Sun Network Filesystem 
  10.         Protocol Specification
  11.  
  12.  
  13.         Comments to:     sun!nfs3
  14.                 nfs3@SUN.COM
  15.  
  16.         Sun Microsystems, Inc.
  17.         2550 Garcia Ave.
  18.         Mountain View, CA 94043
  19.  
  20.  
  21. Introduction
  22.  
  23. The Sun Network Filesystem (NFS) protocol provides transparent remote 
  24. access to shared filesystems over local area networks. The NFS protocol 
  25. is designed to be machine, operating system, network architecture, 
  26. and transport protocol independent. This independence is achieved 
  27. through the use of Remote Procedure Call (RPC) primitives built on 
  28. top of an External Data Representation (XDR).
  29.  
  30. The supporting MOUNT protocol [reference] allows the server to grant 
  31. remote access privileges to a restricted set of clients.
  32.  
  33. In this protocol specification the term "server" refers to 
  34. a machine that provides resources to the network; a "client" is 
  35. a machine that accesses resources over the network; a "user" is 
  36. a person "logged in" at a client; an "application" is 
  37. a program that executes on a client; and a "workstation" is 
  38. a client machine that typically supports one user at a time.
  39.  
  40. Remote Procedure Call
  41.  
  42. Sun's Remote Procedure Call specification [RFC 1050] provides 
  43. a clean, procedure oriented interface to remote services. Each 
  44. server supplies a program which is a set of procedures. Servers can 
  45. support multiple versions of a program by using different protocol 
  46. version numbers. The combination of host address, program number, 
  47. version number and procedure number specify one remote service procedure.
  48.  
  49. External Data Representation
  50.  
  51. The Sun External Data Representation (XDR) specification [RFC 1014] 
  52. provides a standard way of representing a set of data types on a network. 
  53. This takes care of the problem of different byte orders, structure 
  54. alignment, and data type representation on different, communicating 
  55. machines.
  56.  
  57. In this document we use the XDR Data Definition Language [RFC 1014] 
  58. to specify the parameters and results to each of the RPC service procedures 
  59. that a NFS server provides. The XDR definition language is similar 
  60. to declarations in the C programming language. A few new constructs 
  61. have been added. The notation:
  62.  
  63.  
  64. string name[SIZE];
  65. string data<DSIZE>;
  66.  
  67.  
  68. defines "name", which is a fixed size block of SIZE bytes, 
  69. and "data", which is a variable size block of up to DSIZE bytes.
  70. This same notation is used to indicate fixed length arrays and 
  71. arrays with a variable number of elements up to a fixed maximum.
  72.  
  73. The discriminated union definition:
  74.  
  75. union switch (enum status) {
  76.     NFS_OK:
  77.         struct {
  78.             filename file1;
  79.             filename file2;
  80.             integer  count;
  81.         }
  82.  
  83.  
  84.  
  85.  
  86.  
  87.     NFS_ERROR:
  88.         struct {
  89.             errstat error;
  90.             integer errno;
  91.         }
  92.     default:
  93.         void v;
  94. }
  95.  
  96. defines a structure where the first thing over the network is an enumeration 
  97. type called status. If the value of status is NFS_OK, the next thing 
  98. on the network will be the structure containing file1, file2, and 
  99. count. If the value of status is neither NFS_OK nor NFS_ERROR then 
  100. there is no more data to look at.
  101.  
  102. The XDR type hyper is an 8 byte integer. It is used in the same way 
  103. as the integer type. For example:
  104.  
  105. hyper    foo;
  106. unsigned hyper    bar;
  107.  
  108. "foo" is an 8 byte signed value, while "bar" is an 
  109. 8 byte unsigned value.
  110.  
  111.  
  112.  
  113.  
  114. Authentication and Permission Checking
  115.  
  116. The RPC protocol includes a slot for authentication parameters on 
  117. every call. The contents of the authentication parameters 
  118. are determined by the "flavor" of authentication used by the server 
  119. and client. A server may support several different flavors of authentication 
  120. at once. The flavor called AUTH_NONE provides null authentication, 
  121. that is, no authentication information is passed. The AUTH_UNIX flavor 
  122. passes uid, gid, and groups with each call. The AUTH_DES flavor provides 
  123. DES encrypted authentication parameters based on a network-wide name.
  124.  
  125. The NFS server does permission checking by assuming the identity of 
  126. the caller before servicing a remote request. For example, using AUTH_UNIX 
  127. flavor authentication the server gets the client's effective uid, 
  128. effective gid and groups on each call, and uses them to check permission. 
  129. Using uid and gids implies that the client and server either share 
  130. the same uid list or do local uid mapping. Every server and client 
  131. pair must have the same mapping from user to uid and from group to 
  132. gid.
  133.  
  134. The AUTH_DES style of authentication provides a network name that 
  135. is encrypted using DES encryption and public keys. Again, the server 
  136. and client must agree on the identity of a particular name on the 
  137. network, but the name to identity mapping is more operating system 
  138. independent then the uid and gid mapping in AUTH_UNIX. Also, because 
  139. the authentication parameters are encrypted a malicious user must 
  140. know another user's network password to masquerade as that user. Similarly, 
  141. the server returns a verifier that is also encrypted so that masquerading 
  142. as a server requires knowing a network password.
  143.  
  144. The GETRESINFO and NULL procedures require no authentication. 
  145. Clients can use the  MOUNT protocol to find out which authentication 
  146. flavors are required for other NFS procedures.
  147.  
  148.  
  149.  
  150. Philosophy
  151.  
  152. Because the NFS protocol is designed to be operating system independent 
  153. it does not exactly match the semantics of any existing system. Server 
  154. implementations are expected to make a "best effort" at supporting 
  155. the protocol. If a server cannot support a particular protocol procedure 
  156. it should return the NFSERR_OPNOTSUP error that indicates that the 
  157. operation is not supported. For example, many operating systems do 
  158. not support the notion of a "hard link". A server that cannot 
  159. support hard links should return NFSERR_OPNOTSUP in response to a 
  160. LINK or UNLINK request. In some cases a server can support most of 
  161. the semantics described by the protocol but not all. For example, 
  162. the ctime field in the fattr structure gives the time that 
  163. a file's attributes were last modified. Many systems do not keep this 
  164. information around. In this case, rather than not support the GETATTR 
  165. operation, a server should fake it by returning the last modified 
  166. time in place of ctime.
  167.  
  168.  
  169.  
  170.  
  171.  
  172.  
  173. NFS servers are dumb and NFS clients are smart. It is the clients 
  174. that do the work required to convert the generalized file access that 
  175. servers provide into a file access method which is useful to applications 
  176. and users. In the LINK example given above, a UNIX(R) client that 
  177. received an NFSERR_OPNOTSUP from a server would do the recovery 
  178. necessary to either make it look to the application like the link 
  179. request had succeeded or return an reasonable error.
  180.  
  181. The NFS protocol assumes a stateless server implementation. Statelessness 
  182. means that the server does not need to maintain state about any of 
  183. its clients in order to function correctly. Stateless servers have 
  184. a distinct advantage over stateful servers in the event of a crash. 
  185. With stateless servers, a client need only retry a request until the 
  186. server responds, the client does not even need to know that the server 
  187. has crashed.
  188.  
  189. This is not to say that servers are not allowed to maintain state 
  190. about client operations, but that the state held by servers is not 
  191. required for correct operation. In many cases servers will maintain 
  192. state about previous operations to increase performance. For example, 
  193. a client READ request might trigger a read-ahead of the next block 
  194. of the file into the server's data cache in the hope that the client 
  195. is doing a sequential read and the next client READ request will be 
  196. satisfied from the cache instead of from the disk. The read-ahead 
  197. block is not necessary for correct server behavior, but it increases 
  198. the server's performance.
  199.  
  200. All of the procedures in the NFS protocol except WRITECACHE are assumed 
  201. to be synchronous. When a procedure returns to the client, the client 
  202. can assume that the operation has completed and any modified data 
  203. associated with the request is now on stable storage. For example, 
  204. a client WRITE request may cause the server to update data blocks, 
  205. filesystem information blocks, and file attribute information (size 
  206. and modify times). When the WRITE operation completes, the client 
  207. can assume that the write data is safe and discard it. This is a very 
  208. important part of the statelessness of the server. If the server did 
  209. not flush dirty data before returning to the client, the client would 
  210. have no way of knowing when it was safe to discard modified data.
  211.  
  212. The LOOKUP procedure is used by the client to traverse multi-segment 
  213. file names (pathnames). Each call to LOOKUP is used to resolve one 
  214. segment of a pathname. There are two reasons for restricting LOOKUP 
  215. to a single segment: because it is hard to standardize a common format 
  216. for hierarchical file names; and because the client and server may 
  217. have different mappings of pathnames to filesystems. This implies 
  218. that either the client must break the path name at filesystem attachment 
  219. points, or the server must know about the client's filesystem attachment 
  220. points.
  221.  
  222. Clients can do as much or as little caching as they want. The protocol 
  223. does not have any explicit support for client cache consistency.
  224.  
  225.  
  226.  
  227.  
  228. Changes for Version 3
  229.  
  230. Version 3 of the NFS protocol supports these new procedures: GETRESINFO
  231. returns information about server resources, ACCESS provides access 
  232. permission checking, CREATEUNIQ creates a uniquely named file on 
  233. the server, ZERO punches holes in files, LINKAGE maps file handles 
  234. from one RPC service to another, STOREATTR stores extended attribute 
  235. values. The ROOT, MKDIR and RMDIR procedures have been removed, 
  236. and the WRITECACHE procedure is now fully supported. All procedures 
  237. that affect the attributes of a file or directory now return the new 
  238. attributes after the operation has completed.
  239.  
  240. Below is a list of the important changes between version 2 and version 
  241. 3 of the protocol.
  242.  
  243. Port Number
  244.     The port number is now registered with the Portmap service 
  245.     and can change if a server crashes. The client should consult 
  246.     the server's portmap service when in doubt about the validity 
  247.     of the port number (e.g. after a timeout or network addressing 
  248.     error.)
  249.  
  250. Fhandle size
  251.     The file handle is variable length up to 1024 bytes instead 
  252.     of a fixed array of 32 bytes.
  253.  
  254.  
  255.  
  256.  
  257.  
  258.  
  259. MAXDATA
  260.     The maximum size of a data transfer used in the READ, WRITE, 
  261.     WRITECACHE and READDIR procedures is now set by values in the 
  262.     GETFSINFO return structure.
  263.  
  264. Error return
  265.     The error return on all calls now includes both an error number 
  266.     and a string. If the client does not understand the number it 
  267.     can print the string.
  268.  
  269. File type
  270.     The file type now includes NFSPEC for special files. The NFSPEC 
  271.     type also includes a subtype string that can be used to define 
  272.     new file types.
  273.  
  274. File name
  275.     The file name is now composed of a name string and an extension 
  276.     string. The extension string can be used to extend the name 
  277.     space. Predefined extensions are provided to support version 
  278.     numbering and Macintosh forked files.
  279.  
  280. File attributes
  281.     The rdev and blocksize fields have been removed and the mode field 
  282.     no longer contains file type information. Remove and system 
  283.     permission bits were added for owner, group and other. The user 
  284.     and group fields are strings instead of unsigned integers. The 
  285.     size and fileno fields are 8 byte unsigned instead of 4 bytes. 
  286.     The blocks field name has been changed to used, and it now returns 
  287.     the total number of bytes used by the file. It is also an 8 byte 
  288.     unsigned value.
  289.  
  290. Set file attributes
  291.     The set file attributes uses a boolean for each field to tell 
  292.     whether to set that field. The time fields can be set to either 
  293.     the server's current time or a time supplied by the client.
  294.  
  295. Extended attributes
  296.     The GETATTR and SETATTR operations now have an optional counted 
  297.     array of key/value strings that can be used to extend the 
  298.     standard set of attributes. The key string identifies the syntax 
  299.     and semantics of the value string.
  300.  
  301. Lookup
  302.     The lookup arguments now include a boolean "parent" used 
  303.     to request the parent directory fhandle instead of passing the 
  304.     well known filename "..". The lookup return structure includes 
  305.     a boolean that is TRUE if the fhandle returned is a mount point 
  306.     for another filesystem on the server.
  307.  
  308. Read
  309.     The reply structure includes a boolean that is TRUE if end-of-file 
  310.     was encountered on the read. This allows the server to return less 
  311.     data than the client requested.
  312.  
  313. Write cache
  314.     Allows the client to write file data into the server's data cache 
  315.     then flush all data to disk synchronously with the last WRITECACHE 
  316.     request.
  317.  
  318. Write
  319.     Removed the beginoffset and totalcount fields from the write 
  320.     arguments. The reply now includes a count so that the server 
  321.     can write less than the requested amount of data.
  322.  
  323.  
  324.  
  325.  
  326.  
  327.  
  328.  
  329. Create, remove, rename, mkdir, rmdir, link, symlink
  330.     Added an exclusive flag to allow creation of a name that 
  331.     already exists in the server's filesystem. If the exclusive 
  332.     flag is FALSE the arguments must also include the file handle 
  333.     of the existing target name. This allows the server to do 
  334.     real idempotent creation operations by comparing the file 
  335.     handle in the arguments against the file handle of the target 
  336.     file, and returning an error if they do not match.
  337.  
  338. Create
  339.     Create can now be used to make files directories and special files. 
  340.     Only the permission bits can be set in the initial attributes of 
  341.     the file.
  342.  
  343. Remove
  344.     Remove can now be used to remove all filesystem objects.
  345.  
  346. Readdir
  347.     The readdir arguments now include a boolean to request all names in 
  348.     the directory, including normally hidden names.
  349.  
  350. fsinfo
  351.     Added new fields to the reply structure for file counts, directory 
  352.     block size, initial timeout, read size, write size, illegal 
  353.     characters, an array that tells which procedures are supported 
  354.     and how long they take to service, a flags field with bits that 
  355.     tell whether the server supports special filesystem functions 
  356.     like version numbers and record files, and a variable length 
  357.     array of extended attributes.
  358.  
  359.  
  360.  
  361.  
  362.  
  363. RPC Information
  364.  
  365. Authentication
  366.     The NFS service uses AUTH_NONE in the GETRESINFO and NULL 
  367.     procedures. Consult the PORTMAP service or use the GETRESINFO 
  368.     procedure to determine authentication requirements for other 
  369.     NFS procedures.
  370.  
  371. Constants
  372.     These are the RPC constants needed to call the NFS service. 
  373.     They are given in decimal.
  374.  
  375.     PROGRAM     100003
  376.     VERSION     3
  377.  
  378. Port Number
  379.     Consult Portmap service for NFS port number. The RPC port number 
  380.     may change if the server crashes and restarts.
  381.  
  382.  
  383.  
  384.  
  385.  
  386. Sizes
  387.  
  388. These are the sizes, given in decimal bytes, of various XDR structures 
  389. used in the protocol.
  390.  
  391. MAXPATHLEN 1024
  392.     The maximum number of bytes in a pathname argument.
  393.  
  394. MAXFILENAMELEN 256
  395.     The maximum number of bytes in a file name argument.
  396.  
  397. MAXNAMEEXT 32
  398.     The maximum number of bytes in a file name extension string.
  399.  
  400. MAXNAMELEN 128
  401.     The maximum number of bytes in a user name or group name.
  402.  
  403. MAXERRLEN 128
  404.     The maximum length in bytes of the error string returned on a failed 
  405.     call.
  406.  
  407. MAXFHSIZE 1024
  408.     The maximum size in bytes of the opaque file handle.
  409.  
  410. COOKIESIZE 4
  411.     The size in bytes of the opaque "cookie" passed by READDIR.
  412.  
  413. MAXEXATTR 64
  414.     Maximum number of extended attribute key-value pairs.
  415.  
  416. MAXKEYLEN 32
  417.     The size in bytes of the key string in a key-value pair.
  418.  
  419. MAXVALLEN 256
  420.     The size in bytes of the value string in a key-value pair.
  421.  
  422.  
  423.  
  424.  
  425.  
  426.  
  427. MAXTYPELEN 32
  428.     The maximum size in bytes of the subtype string in the "ftype" 
  429.     structure.
  430.  
  431. MAXBADCHAR 256
  432.     Maximum number of illegal filename characters returned by GETFSINFO.
  433.  
  434.  
  435.  
  436.  
  437.  
  438.  
  439. Basic Data Types
  440.  
  441. The following XDR definitions are basic definitions that are used 
  442. in other structures later on.
  443.  
  444. stat
  445.  
  446.     enum stat {
  447.         NFS_OK = 0,
  448.         NFS_ERROR=1
  449.     };
  450.  
  451. The stat type is returned with every procedure's results. A value 
  452. of NFS_OK indicates that the call completed successfully and the results 
  453. are valid. A value of NFS_ERROR indicates that some error occurred 
  454. on the call. In this case a errinfo structure is returned.
  455.  
  456.  
  457. errinfo
  458.  
  459.     struct errinfo {
  460.         unsigned    error;
  461.         string        errstr<NFS_MAXERRLEN>;
  462.     };
  463.  
  464. The errinfo structure contains the error information associated with 
  465. a failed request. The error can either be one of the predefined errors 
  466. below or an error that is specific to a particular server. In either 
  467. case the error string should contain an error message that can be 
  468. printed by the client.
  469.  
  470.  
  471.  
  472. Predefined Error Numbers
  473.  
  474. NFSERR_UNKNOWN = 1
  475.     Unknown error. The server could not map an error indication 
  476.     into a standard NFS error number, refer to the error string.
  477.  
  478. NFSERR_NOENT = 2
  479.     No such file or directory. The file or directory name 
  480.     specified does not exist.
  481.  
  482. NFSERR_IO = 3
  483.     I/O error. A hard error (e.g. disk error) occurred when 
  484.     the operation was in progress.
  485.  
  486. NFSERR_BADTYPE = 4
  487.     File type not supported. The file type is not supported by 
  488.     the server.
  489.  
  490. NFSERR_ACCESS = 5
  491.     Permission denied. The caller does not have the correct permission 
  492.     to perform the requested operation.
  493.  
  494. NFSERR_EXIST = 6
  495.     File exists. The file specified already exists.
  496.  
  497. NFSERR_BADOFFSET = 7
  498.     Illegal file offset. The offset given in a READ, WRITE, ZERO, 
  499.     or WRITECACHE call does not make sense.
  500.  
  501. NFSERR_NOTDIR = 8
  502.     Not a directory. The caller specified a non-directory 
  503.     in a directory operation.
  504.  
  505. NFSERR_ISDIR = 9
  506.     Is a directory. The caller specified a directory in a 
  507.     non-directory operation.
  508.  
  509. NFSERR_FBIG = 10
  510.     File too large. The operation caused a file to grow beyond 
  511.     the server's limit.
  512.  
  513. NFSERR_NOSPC = 11
  514.     No space left on device. The operation caused the server's 
  515.     filesystem to reach its limit.
  516.  
  517.  
  518.  
  519.  
  520.  
  521.  
  522. NFSERR_ROFS = 12
  523.     Read-only filesystem. Write attempted on a read-only filesystem.
  524.  
  525. NFSERR_NAMETOOLONG = 13
  526.     File name too long. The file name in an operation was too long.
  527.  
  528. NFSERR_NOTEMPTY = 14
  529.     Directory not empty. Attempt to remove a directory that was 
  530.     not empty.
  531.  
  532. NFSERR_DQUOT = 15
  533.     Disk quota exceeded. The client's disk quota on the server has been 
  534.     exceeded.
  535.  
  536. NFSERR_STALE = 16
  537.     Invalid file handle. The fhandle given in the arguments was invalid. 
  538.     The file referred to by that file handle no longer exists or access 
  539.     to it has been revoked.
  540.  
  541. NFSERR_WFLUSH = 17
  542.     The client data from a set of WRITECACHE requests could 
  543.     not be flushed to disk.
  544.  
  545. NFSERR_NOTSYMLINK = 18
  546.     The file is not a symbolic link. The fhandle passed in a READLINK 
  547.     request did not refer to a symbolic link file.
  548.  
  549. NFSERR_NOTREG = 19
  550.     Not a regular file. An operation was attempted on an object whose 
  551.     filetype was not NFREG.
  552.  
  553. NFSERR_OPNOTSUP = 20
  554.     Operation not supported. The server does not support this 
  555.     NFS operation.
  556.  
  557. NFSSERR_DUPREQ = 21
  558.     Might be a duplicate request. The server has detected what might be 
  559.     a duplicate request.
  560.  
  561. NFSERR_NOTFILE = 22
  562.     Not a file. A file operation was attempted on a non-file (e.g. WRITE 
  563.     on a directory.)
  564.  
  565. NFSERR_PRIV = 23
  566.     Privileged operation. The caller does not have the correct identity 
  567.     to perform the requested privileged operation.
  568.  
  569. NFSERR_NOTOWNER = 24
  570.     Not owner. The operation was not allowed because the caller does not 
  571.     own the target of the operation.
  572.  
  573. NFSERR_BADCOOKIE = 25
  574.     Bad opaque cookie. A cookie passed in the READDIR request 
  575.     was invalid.
  576.  
  577. NFSERR_BADCHAR = 26
  578.     Bad character. String contains an illegal character.
  579.  
  580. NFSERR_BADNAME = 27
  581.     Illegal file name. The fname given is illegal on the server.
  582.  
  583. NFSERR_BADATTR = 28
  584.     Illegal attribute. One of the attributes passed in a 
  585.     SETATTR call is not supported by the server.
  586.  
  587. NFSERR_BADTYPE = 29
  588.     Illegal file type. The file type specified in a CREATE 
  589.     operation is not supported by the server.
  590.  
  591. NFSERR_JUKEBOX = 30
  592.     Slow down, buddy. The server has detected a retransmission 
  593.     of a request that is already in progress.
  594.  
  595.  
  596.  
  597.  
  598.  
  599.  
  600. NFSERR_SOFTLIMIT = 31
  601.     Soft resource limit exceeded. Operation succeeded, but a 
  602.     soft resource limit was exceeded.
  603.  
  604. NFSERR_HARDLIMIT = 32
  605.     Hard resource limit reached. Operation failed because a 
  606.     hard resource limit was reached.
  607.  
  608.  
  609. ftype
  610.     enum filetype {
  611.         NFREG =    1,
  612.         NFDIR =    2,
  613.         NFLNK =    3,
  614.         NFSPEC =4,
  615.     };
  616.  
  617.     union ftype switch (filetype type) {
  618.         NFSPEC:
  619.             string    spectype<MAXSPECTYPE>;
  620.         default:
  621.             void    v;
  622.     };
  623.  
  624.     The union ftype gives the type of a file. The type NFREG 
  625.     is a regular file, NFDIR is a directory, NFLNK is a symbolic link. 
  626.     The NFSPEC type is used for special file types such as record files, 
  627.     devices and named pipes. It includes a sub-type identifier string 
  628.     that encodes the type of the object. The predefined special file 
  629.     subtypes are given below.
  630.  
  631.     UNX:BLCK:major#:minor#
  632.         UNIX style block device. The major# and minor# fields 
  633.         are character strings that represent decimal numbers 
  634.         defining the major and minor device numbers 
  635.         (e.g. UNX:BLCK:25:8).
  636.  
  637.     UNX:CHAR:major#:minor#
  638.         UNIX style character device. The major# and minor# 
  639.         fields are character strings that represent decimal 
  640.         numbers defining the major and minor device numbers.
  641.  
  642.     UNX:SOCK
  643.         UNIX style named socket.
  644.  
  645.     UNX:FIFO
  646.         UNIX style named pipe.
  647.  
  648.     MAC:DATA
  649.         Macintosh data fork.
  650.  
  651.     MAC:FIND
  652.         Macintosh finder info fork.
  653.  
  654.     MAC:RESR
  655.         Macintosh resource fork.
  656.  
  657.     REC:FIXD:record-size
  658.         Fixed length record file. The record-size field is 
  659.         a character string that represents the decimal number 
  660.         of bytes in a record.
  661.  
  662.     REC:VAR
  663.         Variable length record file.
  664.  
  665.  
  666. fhandle
  667.  
  668.     typedef opaque fhandle<MAXFHSIZE>;
  669.  
  670.     The fhandle is the file handle that the server passes to 
  671.     the client. All file operations are done using file handles 
  672.     to refer to a file or directory. The file handle contain all 
  673.     of the information the server needs to distinguish an individual 
  674.     file, while, to the client, the fhandle is opaque. 
  675.  
  676.  
  677.  
  678.  
  679.  
  680.     The client can store fhandles for use in a later request, and 
  681.     can compare two fhandles from the same server for equality by doing 
  682.     a byte by byte comparison, but cannot otherwise interpret 
  683.     the contents of fhandles. If two fhandles from the same server are 
  684.     equal they must refer to the same file, but if they are not equal 
  685.     no conclusions can be drawn. Servers should try to maintain a one
  686.     to on e correspondence between fhandles and files, but they are 
  687.     not required to. Clients should use fhandle comparison only to 
  688.     improve performance, not for correct behavior.
  689.  
  690.     Servers can revoke the access provided by an fhandle at any time. 
  691.     If the fhandle passed in a call refers to an object that no longer 
  692.     exists on the server or access for that fhandle has been revoked 
  693.     the NFSERR_STALE error will be returned.
  694.  
  695.  
  696. nfsdata
  697.  
  698.     typedef opaque nfsdata
  699.  
  700.     The nfsdata type is used by the READ, WRITE, WRITECACHE 
  701.     and READDIR operations to define the data portion of a request 
  702.     or reply. The maximum size allowed by the protocol is limited 
  703.     by what XDR and underlying transports will allow, but the 
  704.     actual size allowed in a given operation is determined by 
  705.     values returned by the server in the GETFSINFO reply. Consult 
  706.     the procedure descriptions for details.
  707.  
  708.  
  709.  
  710. fileid
  711.  
  712.     typedef unsigned hyper fileid;
  713.  
  714.     The fileid is returned by the server in response to a 
  715.     GETATTR or READDIR request. It is a number which uniquely 
  716.     identifies the file within a filesystem. Client applications 
  717.     can use this value to compare two files in the same filesystem 
  718.     for equality.
  719.  
  720.  
  721.  
  722. filesize
  723.  
  724.     typedef unsigned hyper filesize;
  725.  
  726.     The filesize type is used for counts of bytes in files and 
  727.     directories.
  728.  
  729.  
  730.  
  731. fileoffset
  732.  
  733.     typedef unsigned hyper fileoffset;
  734.  
  735.     The fileoffset type is used for byte offsets into files.
  736.  
  737.  
  738.  
  739. position
  740.  
  741.     struct position {
  742.         boolean        append;
  743.         fileoffset    offset;
  744.     }
  745.  
  746.     Position is used to specify the location of data in a file. 
  747.     The value of offset specifies a byte offset in a file. 
  748.     If append is TRUE the server will return the error 
  749.     NFSERR_BADOFFSET if offset does not match the current size 
  750.     of the file.
  751.  
  752.  
  753.  
  754. timeval
  755.  
  756.     struct timeval {
  757.         unsigned    seconds;
  758.         unsigned    useconds;
  759.     };
  760.  
  761.     The timeval structure gives the number of seconds and 
  762.     microseconds since midnight January 1, 1970 Greenwich Mean 
  763.     Time. It is used to pass time and date information. The 
  764.     times associated with files are all server times except in 
  765.     the case of a SETATTR operation where the client explicitly 
  766.     sets the file times to client time.
  767.  
  768.  
  769.  
  770. permbits
  771.  
  772.     typedef unsigned permbits;
  773.  
  774.     Permbits encodes access permission as a set of bits. Some 
  775.     of the permission bits don't make sense on the server 
  776.     (e.g. execute permission) and are provided only for client 
  777.     use. A bit value of one means that the operation corresponding 
  778.     to that bit position is allowed. The descriptions given below 
  779.     specify the bit positions using hexadecimal numbers.
  780.  
  781.  
  782.  
  783.  
  784.  
  785.  
  786.         40000    Hidden.
  787.  
  788.         20000    Read permission for system.
  789.  
  790.         10000    Write permission for system.
  791.  
  792.         08000    Execute permission for system on a file.
  793.  
  794.         08000    Lookup permission for system on a directory.
  795.  
  796.         04000    Remove permission for owner.
  797.  
  798.         02000    Remove permission for group.
  799.  
  800.         01000    Remove permission for others.
  801.  
  802.         00800    Set user id on execution.
  803.  
  804.         00400    Set group id on execution.
  805.  
  806.         00200    Save swapped text.
  807.  
  808.         00100    Read permission for owner.
  809.  
  810.         00080    Write permission for owner.
  811.  
  812.         00040    Execute permission for owner on a file.
  813.  
  814.         00040    Lookup permission for owner on a directory.
  815.  
  816.         00020    Read permission for group.
  817.  
  818.         00010    Write permission for group.
  819.  
  820.         00008    Execute permission for group on a file.
  821.  
  822.         00008    Lookup permission for group on a directory.
  823.  
  824.         00004    Read permission for others.
  825.  
  826.         00002    Write permission for others.
  827.  
  828.         00001    Execute permission for others on a file.
  829.  
  830.         00001    Lookup permission for others on a directory.
  831.  
  832.  
  833.  
  834. name
  835.  
  836.     typedef    string        name<MAXNAMELEN>;
  837.  
  838.     The name string is used for both user names and group names 
  839.     in the sattr and fattr structures. The interpretation 
  840.     of the name string is determined by a "type field" of the string, 
  841.     delimeted by a ":" character. The predefined type string "ID" 
  842.     specifies an ASCII encoding of a non-negative identifier number. 
  843.     For example:
  844.  
  845.         ID:1229
  846.         ID:2
  847.         ID:12345
  848.  
  849.  
  850.  
  851.     As standards for mapping user and group identity in a network 
  852.     evolve, other name type strings and name interpretations will 
  853.     be defined.
  854.  
  855.  
  856.  
  857. keystr, valstr and keyval
  858.  
  859.     typedef    string        keystr<MAXKEYLEN>;
  860.     typedef    string        valstr<MAXVALLEN>;
  861.  
  862.     struct keyval {
  863.         keystr    key;
  864.         valstr    value;
  865.     };
  866.  
  867.     The keyval type is used to provide a hook for extending 
  868.     the attributes of files and filesystems. The key string 
  869.     is used to identify and determine how to interpret the 
  870.     value string.
  871.  
  872.  
  873. fattr
  874.  
  875.     struct fattr {
  876.         ftype        type;
  877.  
  878.  
  879.  
  880.  
  881.  
  882.         permbits    perm;
  883.         unsigned    nlink;
  884.         name        user;
  885.         name        group;
  886.         filesize    size;
  887.         filesize    used;
  888.         fileid        fileno;
  889.         timeval    atime;
  890.         timeval    mtime;
  891.         timeval    ctime;
  892.         timeval    btime;
  893.     };
  894.  
  895.  
  896.     The fattr structure contains the basic attributes of a file. 
  897.     All servers should support this set of attributes even if they 
  898.     have to fake some of the fields. Type is the type of the file. 
  899.     Nlink is the number of hard links to the file, that is, the number 
  900.     of different names for the same file. User is the user name 
  901.     of the owner of the file. Group is the group name of the 
  902.     group of the file. Size is the size in bytes of the file. Used 
  903.     is the number of byte of disk space that the file actually uses. 
  904.     File no is a number which uniquely identifies the file within its 
  905.     filesystem. Atime is the time when the file data was last 
  906.     accessed for either read or write. Mtime is the time when 
  907.     the file data was last modified (written). Ctime is the 
  908.     time when the attributes of the file was last changed. Btime 
  909.     is the time the file was created (born). Servers that do not 
  910.     support a creation time should return the value of ctime for 
  911.     the btime field.
  912.  
  913.  
  914. sattr
  915.  
  916.     enum settime {
  917.         NONE=0,
  918.         SERVER=1,
  919.         CLIENT=2,
  920.     };
  921.  
  922.     struct sattr {
  923.         union switch (boolean set_size) {
  924.             TRUE:        filesize size;
  925.         };
  926.         union switch (boolean set_perm) {
  927.             TRUE:        permbits perm;
  928.         };
  929.         union switch (boolean set_user) {
  930.             TRUE:        name user;
  931.         };
  932.         union switch (boolean set_group) {
  933.             TRUE:        name group;
  934.         };
  935.         union switch (settime set_atime) {
  936.             CLIENT:    timeval    atime;
  937.         };
  938.         union switch (settime set_mtime) {
  939.             CLIENT:    timeval    mtime;
  940.         };
  941.         union switch (settime set_ctime) {
  942.             CLIENT:    timeval    ctime;
  943.         };
  944.     };
  945.  
  946.     The sattr structure contains the file attributes that can 
  947.     be set from the client. The fields are the same as the 
  948.     similarly named fields in the fattr structure above. The 
  949.     booleans set_perm, set_user, set_group and set_size tell 
  950.     whether the perm, user, group and size 
  951.     attributes should be set. The enumerations set_atime, set_m
  952.     time and set_ctime tell whether the time 
  953.  
  954.  
  955.  
  956.  
  957.  
  958.     attributes atime, mtime and ctime should 
  959.     be set to current server time (SERVER), to a time supplied 
  960.     by the client (CLIENT), or not set at all (NONE).
  961.  
  962.  
  963. filename
  964.  
  965.     struct filename {
  966.         string        name<MAXNAMLEN>;
  967.         string        extension<MAXNAMEEXT>;
  968.     };
  969.  
  970.     The filename is used for passing file names and pathname 
  971.     components. The name field contains the string which is 
  972.     the name of a single component of a path. The extension specifies 
  973.     an extension to the name, such as which version the name 
  974.     refers to.  A NULL extension string means that no name 
  975.     extension should be used.  There is no structure defined by 
  976.     the NFS protocol in the name portion of a filename.
  977.  
  978.     The predefined extension strings for version numbered files 
  979.     are given below. In these strings the "<num>" field represents 
  980.     the string encoding of a positive decimal number (e.g. "23").
  981.  
  982.         VER:FST        The first (oldest) version of a name.
  983.  
  984.         VER:CUR        The current (youngest) version of a name.
  985.  
  986.         VER:NXT:<num>    The next version after <num>.
  987.  
  988.         VER:PRE:<num>    The previous version before <num>.
  989.  
  990.         VER:NUM:<num>    The version <num>.
  991.  
  992.  
  993.  
  994.     The predefined extension strings for Macintosh forked files 
  995.     are given below.
  996.  
  997.         MAC:RES        Macintosh resource fork.
  998.  
  999.         MAC:DAT        Macintosh data fork.
  1000.  
  1001.         MAC:FND        Macintosh finder info fork.
  1002.  
  1003.  
  1004.     Other name extension strings may be defined to support 
  1005.     other special file features. Servers that don't support a 
  1006.     file extension will return the error NFSERR_BADNAME.
  1007.  
  1008.  
  1009. path
  1010.  
  1011.     typedef string path<MAXPATHLEN>;
  1012.  
  1013.     The type path is a string which is treated as opaque data 
  1014.     by the server but can be used by the client to hold a pathname.
  1015.  
  1016.  
  1017.  
  1018.  
  1019. attrstat
  1020.  
  1021.     union attrstat switch (stat status) {
  1022.         case NFS_OK:
  1023.             fattr    attributes;
  1024.         case NFS_ERROR:
  1025.             errinfo    errinfo;
  1026.     };
  1027.  
  1028.     The attrstat structure is returned result as the result of 
  1029.     a SETATTR operation. It contains a status and, if the call 
  1030.     succeeded, the attributes of the file on which the operation 
  1031.     was done; otherwise it contains error information.
  1032.  
  1033.  
  1034.  
  1035. diropargs
  1036.  
  1037.     typedef struct {
  1038.         fhandle        dir;
  1039.         filename    name;
  1040.     } diropargs;
  1041.  
  1042.     The diropargs structure is used in directory operations. 
  1043.     The fhandle dir is the directory in which to find the file name. 
  1044.     A directory operation is one in which the directory is effected, 
  1045.     for example: CREATE, REMOVE or LINK.
  1046.  
  1047.  
  1048.  
  1049. diropres
  1050.  
  1051.     union diropres switch (stat status) {
  1052.         case NFS_OK:
  1053.  
  1054.  
  1055.  
  1056.  
  1057.  
  1058.             struct diropokres {
  1059.                 fhandle    targ;
  1060.                 fattr    targattr;
  1061.                 fattr    dirattr;
  1062.             } ok;
  1063.         case NFS_ERROR:
  1064.             errinfo    errinfo;
  1065.     };
  1066.  
  1067.     The results of a directory operation are returned in a diropres 
  1068.     structure. If the call succeeded a new file handle and the 
  1069.     attributes of both the parent directory and the target file 
  1070.     are returned along with the status.
  1071.  
  1072.  
  1073.  
  1074. rmtarget
  1075.  
  1076.     union rmtarget switch (boolean exclusive) {
  1077.         FALSE:
  1078.             fhandle    targetfh;
  1079.     };
  1080.  
  1081.     The rmtarget structure is used in calls that may destroy a file 
  1082.     or directory such as CREATE and LINK. An exclusive flag 
  1083.     value of TRUE means that if an object already exists with the same 
  1084.     name as the target of the operation it should not be destroyed. 
  1085.     If the exclusive flag is FALSE it means that the target 
  1086.     of the operation should be destroyed if it exists. In this case the 
  1087.     fhandle of the target is also included so the server can check that 
  1088.     the correct target is being destroyed. For example, if a client 
  1089.     wants to create a file in a single NFS operation but the file to 
  1090.     be created already exists, the client would do a CREATE operation 
  1091.     with exclusive set to FALSE and targetfh set to the fhandle of the 
  1092.     existing file.
  1093.  
  1094.     When the server detects an incorrect value for targetfh
  1095.     the error value NFSERR_EXISTS error is returned. It is then up to 
  1096.     the client to decide whether to retry the operation with a new value 
  1097.     for the  target fhandle or to give up.
  1098.  
  1099.  
  1100.  
  1101.  
  1102.  
  1103.  
  1104. Server Procedures
  1105.  
  1106. The following sections define the RPC procedures that are supplied 
  1107. by a NFS server. The RPC procedure number is given at the top of the 
  1108. page along with the name and version. The SYNOPSIS field has the format:
  1109.  
  1110.  
  1111.  
  1112.     <proc #>. <proc name>( <arguments> ) returns ( <results> )
  1113.         <argument declarations>
  1114.         <results declarations>
  1115.  
  1116.  
  1117.  
  1118.     In the first line, <proc name> is the name of the procedure, 
  1119.     <arguments> is a list of the names of the arguments, <results> 
  1120.     is a list of the names of the results. The following lines give 
  1121.     the XDR argument declarations and results declarations. The 
  1122.     DESCRIPTION field tells what the procedure is expected to do and 
  1123.     how its arguments and results are used. The ERRORS section lists 
  1124.     the errors returned for specific types of failures. If there is 
  1125.     no error return listed in this section for a particular error 
  1126.     condition it is up to the server to return the error code that 
  1127.     most closely describes the error. The IMPLEMENTATION field gives 
  1128.     information about how the procedure is expected to work and how 
  1129.     it should be used by clients.
  1130.  
  1131.  
  1132.  
  1133.  
  1134.  
  1135.  
  1136. Procedure -1        GETRESINFO        Version 3
  1137.  
  1138.  
  1139.  
  1140. Get Resource Information
  1141.  
  1142. SYNOPSIS
  1143.  
  1144. -1. NFSPROC_GETRESINFO( resources, keys ) returns ( resinfo )
  1145.  
  1146.  
  1147.     const    MAXRESNAME = 256;
  1148.     const    MAXRESOURCES = 1024;
  1149.     const    MAXINFO = 1024;
  1150.  
  1151.     string        resource<MAXRESNAME>;
  1152.  
  1153.     resource    resources<MAXRESOURCES>;
  1154.     keystr        keys<MAXINFO>;
  1155.  
  1156.     union resinfo switch (unsigned integer error) {
  1157.         case 0:
  1158.             resinfo        *next;
  1159.             resource    resname;
  1160.             keyval        info<MAXINFO>;
  1161.         default:
  1162.             string        errstr<MAXERRLEN>;
  1163.     }
  1164.  
  1165.  
  1166.  
  1167. DESCRIPTION
  1168.  
  1169. GETRESINFO returns information about resources provided by the NFS 
  1170. server. If the array of resources names, resources, is zero 
  1171. length information about all known resources will be returned, otherwise 
  1172. only information about the given resource names will be returned. 
  1173. Likewise, if the array of key strings, keys, is zero length 
  1174. all key/value pairs will be returned, otherwise on the key/value pairs 
  1175. corresponding to the given keys strings will be returned.
  1176.  
  1177. If error is zero, a list resource names and resource information 
  1178. follows, otherwise, errstr is a string which gives human 
  1179. readable information about the error that occured.
  1180.  
  1181. GETRESINFO is provided as a way for servers to advertise the resources 
  1182. that they supply. Resource names are arbitrary strings with no 
  1183. interpretation. The key/value array associated with a resource name 
  1184. give information about that resource. Some key values are predefined, 
  1185. others will be added to the protocol as needed. (The predefined keys 
  1186. and their values are TBD.)
  1187.  
  1188.  
  1189. IMPLEMENTATION
  1190.  
  1191. If a key or resource name is given that the server does not understand 
  1192. no entry for that resource name or key string will be returned. It 
  1193. is up to the client to match the request strings against the reply 
  1194. strings.
  1195.  
  1196.  
  1197.  
  1198.  
  1199.  
  1200. Procedure 0            NULL            Version 3
  1201.  
  1202.  
  1203. Do Nothing
  1204.  
  1205.  
  1206. SYNOPSIS
  1207.  
  1208. 0. NFSPROC_NULL( ) returns ( )
  1209.  
  1210.  
  1211. DESCRIPTION
  1212.  
  1213. This procedure does no work. It is made available in all RPC services 
  1214. to allow server response testing and timing.
  1215.  
  1216.  
  1217. IMPLEMENTATION
  1218.  
  1219. It is important that this procedure do no work at all so that it can 
  1220. be used to measure the overhead of processing a service request.
  1221.  
  1222.  
  1223.  
  1224.  
  1225.  
  1226. Procedure 1            GETATTR            Version 3
  1227.  
  1228.  
  1229. Get File Attributes
  1230.  
  1231.  
  1232. SYNOPSIS
  1233.  
  1234. 1. NFSPROC_GETATTR( file, exkeys ) returns ( reply )
  1235.  
  1236.     fhandle        file;
  1237.     keystr            exkeys<MAXEXATTR>;
  1238.  
  1239.     union getattrreply switch (stat status) {
  1240.         case NFS_OK:
  1241.             fattr        attributes;
  1242.             keyval        exattr<MAXEXATTR>;
  1243.         case NFS_ERROR:
  1244.             errinfo    errinfo;
  1245.     }reply;
  1246.  
  1247.  
  1248. DESCRIPTION
  1249.  
  1250. File is the file or directory whose attributes are to be 
  1251. returned. Exkeys is an optional array of extended attribute 
  1252. key strings to be returned in addition to the standard attributes 
  1253. (see the section on the exattr structure for more information 
  1254. on extended types.) If reply.status is NFS_OK then reply.attribu
  1255. tes contains the attributes for file, and exattr is 
  1256. a counted array of key/value strings that correspond to the keys 
  1257. in exkeys. The key string identifies the syntax and semantics of 
  1258. the value string. Extended attributes requested in the exkeys array 
  1259. that are not supported by the server will not be returned. If reply.status 
  1260. is NFS_ERROR then reply.errinfo contains error information.
  1261.  
  1262.  
  1263. IMPLEMENTATION
  1264.  
  1265. The attributes of filesystem objects is the point of most disagreement 
  1266. between different operating systems. Servers should make a best attempt 
  1267. to support the attributes in the fattr structure so that 
  1268. clients can count on this as a common ground.
  1269.  
  1270. The extended attributes are provided as a way to extend the standard 
  1271. attributes between cooperating clients and servers. The name space 
  1272. of extended attribute key strings is left open. It is expected that 
  1273. new attributes that arise that are of general use among a broad range 
  1274. of implementations will be given a general name, and will be included 
  1275. in future revisions of this specification. Attributes that are only 
  1276. used among a restricted set of implementations (e.g. used by a single 
  1277. vendor) should be given names that are not likely to conflict with 
  1278. other restricted names (e.g. <vendor name>.<attribute name>).
  1279.  
  1280. Since GETATTR returns attributes that are both set and stored 
  1281. (see SETATTR and STOREATTR descriptions for more information) the 
  1282. client needs a way to distinguish between them. The GETFSINFO procedure 
  1283. returns an array, setkeys, of the extended attribute keys 
  1284. that can be set with a SETATTR call.
  1285.  
  1286.  
  1287.  
  1288.  
  1289.  
  1290. Procedure 2            SETATTR            Version 3
  1291.  
  1292.  
  1293.  
  1294. Set File Attributes
  1295.  
  1296.  
  1297. SYNOPSIS
  1298.  
  1299. 2. NFSPROC_SETATTR( file, ctime, newattr, exattr ) returns ( reply )
  1300.  
  1301.  
  1302.  
  1303.     fhandle    file;
  1304.     timeval    ctime
  1305.     sattr        newattr;
  1306.     keyval        exattr<MAXEXATTR>;
  1307.  
  1308.     attrstat    reply;
  1309.  
  1310.  
  1311. DESCRIPTION
  1312.  
  1313. The newattr argument contains booleans and enumerations 
  1314. that indicate which attributes of file to set  (see the 
  1315. section on sattr for more details). The exattr 
  1316. argument is an array of key/value pairs that encode the extended 
  1317. attributes to be set. The ctime argument is the current ctime value 
  1318. from the attributes of file. If reply.status is 
  1319. NFS_OK, reply.attributes has the attributes of the file aft
  1320. er the SETATTR operation has completed. If reply.status is 
  1321. NFS_ERROR then reply.errinfo contains error information. 
  1322. An error return NFSERR_DUPREQ means that the argument ctime did 
  1323. not match the ctime of file on the server.
  1324.  
  1325.  
  1326. IMPLEMENTATION
  1327.  
  1328. The ctime argument is included to allow servers to detect duplicated 
  1329. SETATTR requests and report them back to the client using the NFSERR_DUPREQ. 
  1330. This error can occur for two reasons: 1) the SETATTR request was duplicated 
  1331. before arriving at the server; 2) that attributes of file changed 
  1332. between when the client last got attributes for file from the server 
  1333. and when the SETATTR operation was attempted by the server. The client 
  1334. can recover from this error by getting fresh attributes from the server 
  1335. and sending a new SETATTR request using the new ctime. The client 
  1336. can optionally check the attributes to avoid the second SETATTR request 
  1337. if the new attributes show that case 1 occurred and the attributes 
  1338. have already been set.
  1339.  
  1340. The newattr.size field changes the size of a file. A value 
  1341. of 0 causes the file to be truncated, a value less than the current 
  1342. size of file causes data from the end of the file to be 
  1343. discarded, and a size greater than the current size of file causes 
  1344. zeroed data bytes to be added to the end of file. To extend a file 
  1345. with "holes" (data that doesn't take up disk space) the client 
  1346. should use the ZERO procedure.
  1347.  
  1348. The extended attributes are assumed to cause  side effects on the 
  1349. use of file. For example, and extended attribute "access-list" 
  1350. might limit file access to users on the access list. Attributes that 
  1351. do not cause side effects, but are stored by the server and returned 
  1352. in a GETATTR request, are set using the STOREATTR procedure.
  1353.  
  1354. If server and client times differ, programs that compare client time 
  1355. to file times can break. A time maintenance protocol should be used 
  1356. to limit client/server time skew.
  1357.  
  1358.  
  1359.  
  1360.  
  1361.  
  1362. Procedure 3            STOREATTR            Version 3
  1363.  
  1364.  
  1365. Store File Attributes
  1366.  
  1367.  
  1368. SYNOPSIS
  1369.  
  1370. 3. NFSPROC_STOREATTR( file, exattr ) returns ( reply )
  1371.  
  1372.     fhandle    file;
  1373.     keyval        exattr<<MAXEXATTR>;
  1374.  
  1375.     attrstat    reply;
  1376.  
  1377. DESCRIPTION
  1378.  
  1379. The exattr argument is an array of key/value pairs that 
  1380. encode the extended attributes to be stored. If reply.status is 
  1381. NFS_OK, reply.attributes has the attributes of the file aft
  1382. er the STOREATTR operation has completed. If reply.status is 
  1383. NFS_ERROR then reply.errinfo contains error information. 
  1384.  
  1385.  
  1386. IMPLEMENTATION
  1387.  
  1388. The extended attributes do not cause side effects on the use of file, 
  1389. they are just stored by the server and returned on a GETATTR request. 
  1390. To set extended attributes that do cause side effects the SETATTR 
  1391. procedure should be used.
  1392.  
  1393.  
  1394.  
  1395.  
  1396.  
  1397. Procedure 4            ACCESS                Version 3
  1398.  
  1399.  
  1400. Check Access Permission
  1401.  
  1402. SYNOPSIS
  1403.  
  1404. 4. NFSPROC_ACCESS( object ) returns ( reply )
  1405.  
  1406.     fhandle    object;
  1407.  
  1408.     #define    SEARCH        01
  1409.     #define    WRITE        02
  1410.     #define    READ        04
  1411.     #define    CHANGE        08
  1412.     #define    REMOVE        10
  1413.  
  1414.     union accessres switch (stat status) {
  1415.         case NFS_OK:
  1416.             unsigned    allowed;
  1417.         case NFS_ERROR:
  1418.             errinfo    errinfo;
  1419.     } reply;
  1420.  
  1421.  
  1422. DESCRIPTION
  1423.  
  1424. Check what type of access is allowed on object. If reply.status 
  1425. is NFS_OK then allowed encodes the type of access allowed 
  1426. using the bit encodings defined by the hexadecimal numbers SEARCH, 
  1427. WRITE, READ, CHANGE and REMOVE. A bit value of 1 means the corresponding 
  1428. access type is allowed. SEARCH access means that the directory file 
  1429. handle object can be used as the argument to a LOOKUP operation 
  1430. (this only makes sense if object is a directory,) WRITE 
  1431. access means the data in object can be changed, READ access 
  1432. means the data in object can be accessed, CHANGE means the 
  1433. attributes of object can be changed using the SETATTR 
  1434. or STOREATTR procedures, and REMOVE means that object can 
  1435. be removed.
  1436.  
  1437. If reply.status is NFS_ERROR then reply.errinfo contains 
  1438. error information.
  1439.  
  1440.  
  1441. IMPLEMENTATION
  1442.  
  1443. The ACCESS operation is provided to allow clients to do access checking 
  1444. before doing a series of operations. This is useful in operating systems 
  1445. (such as UNIX) where permission checking is done only when a file 
  1446. or directory is opened.
  1447.  
  1448. The information returned by the server in response to an ACCESS call 
  1449. is not permanent. The server can revoke access permission at any time.
  1450.  
  1451.  
  1452.  
  1453.  
  1454.  
  1455. Procedure 5            INACTIVE            Version3
  1456.  
  1457. Advise of Inactive File Handle
  1458.  
  1459. SYNOPSIS
  1460.  
  1461. 2. NFSPROC_INACTIVE( object ) returns ( reply )
  1462.  
  1463.     fhandle    object;
  1464.  
  1465.     union closeres switch (stat status) {
  1466.         case NFS_ERROR:
  1467.             errinfo    errinfo;
  1468.     } reply;
  1469.  
  1470.  
  1471. DESCRIPTION
  1472.  
  1473. Advise the server that object is no longer in use. This 
  1474. procedure is used by the client to inform the server that the fhandle obje
  1475. ct is not longer in use. This allows the server to free any resources 
  1476. associated with object.
  1477.  
  1478. If reply.status is NFS_ERROR then reply.errinfo contains 
  1479. error information.
  1480.  
  1481.  
  1482. IMPLEMENTATION
  1483.  
  1484. The INACTIVE operation is advisory only. The server can not rely on 
  1485. the client doing a INACTIVE for every fhandle since file handles may 
  1486. be lost due to client crashes. Clients should make a best effort to 
  1487. send a INACTIVE every time a file handle is thrown away.
  1488.  
  1489.  
  1490.  
  1491.  
  1492.  
  1493. Procedure 6            LOOKUP                Version 3
  1494.  
  1495.  
  1496. Lookup File Name
  1497.  
  1498. SYNOPSIS
  1499.  
  1500. 6. NFSPROC_LOOKUP( which ) returns ( reply )
  1501.  
  1502.  
  1503.     struct lookupargs {
  1504.         fhandle    dir;
  1505.         union switch ( boolean parent ) {
  1506.             case FALSE:
  1507.                 filename    name;
  1508.         };
  1509.     } which;
  1510.  
  1511.     union lookupres switch (stat status) {
  1512.         case NFS_OK:
  1513.             struct lookupokres {
  1514.                 fhandle    file;
  1515.                 filename    realname;
  1516.                 fattr        attributes;
  1517.                 boolean    mountpt;
  1518.             } ok;
  1519.         case NFS_ERROR:
  1520.             errinfo errinfo;
  1521.     } reply;
  1522.  
  1523.  
  1524. DESCRIPTION
  1525.  
  1526. If reply.status is NFS_OK, reply.ok.file and reply.ok.
  1527. attributes are the file handle and attributes for the file which.name 
  1528. in the directory given by which.dir, and reply.ok.realname
  1529. is the real name of the file. name and realname may be different if, 
  1530. for example, name includes a "next version number" extension string 
  1531. (see the filename structure definition for more information.) The 
  1532. boolean reply.ok.mountpt is TRUE if this is a mount point for a 
  1533. filesystem on the server.  If which.parent is TRUE then file, attributes 
  1534. and mountpt refer to the parent directory of which.dir. If which.dir 
  1535. is the root directory of a filesystem it is its own parent. If reply.
  1536. status is NFS_ERROR then reply.errinfo contains error information.
  1537.  
  1538.  
  1539. IMPLEMENTATION
  1540.  
  1541. The case where which.name refers to a mount point on the 
  1542. server two different replies are possible. The server can return either 
  1543. the file handle for the underlying directory that is mounted on, or 
  1544. the file handle of the root of the mounted directory. Returning the 
  1545. file handle of the underlying directory forces the client to use the 
  1546. MOUNT service to access the mounted directory, which insures that 
  1547. MOUNT access checking can be done on the server. On the other hand, 
  1548. for servers that don't care about MOUNT access checking returning 
  1549. the fhandle of the mounted directory provides the client access to 
  1550. all exported filesystems. 
  1551.  
  1552. The mountpt boolean is provided so that the client can tell 
  1553. when a mount point is reached that the sever will not cross. In this 
  1554. case the client can use the MOUNT protocol to duplicate the server's 
  1555. mounted filesystem at this mount point.
  1556.  
  1557.  
  1558. ERRORS
  1559.  
  1560.     NFSERR_NOENT    Which.name does not exist in which.dir.
  1561.  
  1562.     NFSERR_NOTDIR    Which.dir is not a directory.
  1563.  
  1564.     NFSERR_NAMETOOLONG    Which.name contains too many characters.
  1565.  
  1566.  
  1567.  
  1568.  
  1569.  
  1570. Procedure 7            READ                Version 3
  1571.  
  1572.  
  1573. Read From File
  1574.  
  1575.  
  1576. SYNOPSIS
  1577.  
  1578. 7. NFSPROC_READ( file, location, count , totalcount ) returns ( reply )
  1579.  
  1580.  
  1581.     fhandle        file;
  1582.     fileoffset    location;
  1583.     unsigned        count;
  1584.     unsigned        totalcount;
  1585.  
  1586.     union readres switch (stat status) {
  1587.         case NFS_OK:
  1588.             struct readokres {
  1589.                 nfsdata        data;
  1590.                 boolean        eof;
  1591.                 fattr            attributes;
  1592.             } ok;
  1593.         case NFS_ERROR:
  1594.             errinfo    errinfo;
  1595.     } reply;
  1596.  
  1597.  
  1598. DESCRIPTION
  1599.  
  1600. Returns up to count bytes of data from location in file. File 
  1601. must be either a regular (ftype NFREG) or special (ftype NFSPEC) file. 
  1602. When reading from a regular file location is the byte offset into file 
  1603. from which data should be read. A byte offset of zero mean read data 
  1604. starting at the beginning of the file.
  1605.  
  1606. If reply.status is NFS_OK reply.ok.attributes is the attributes of 
  1607. the file following the read, reply.ok.data is the counted data read 
  1608. from the file, and reply.ok.eof indicates whether end-of-file was 
  1609. encountered on the read. If reply.status is NFS_ERROR then reply.errinfo 
  1610. contains error information.
  1611.  
  1612.  
  1613. IMPLEMENTATION
  1614.  
  1615. The server has the option of returning fewer than count bytes of data. 
  1616. Count must be less than or equal to the value of the rsize field in the 
  1617. GETFSINFO reply structure (see GETFSINFO procedure for more details) 
  1618. for the filesystem which contains file.
  1619.  
  1620. The totalcount argument is provided as a hint to the server 
  1621. that more read operations will follow. Totalcount should be set to 
  1622. the number of bytes beyond location+count that the client intends 
  1623. to read.
  1624.  
  1625. If the ftype of file is NFSPEC the READ operation might 
  1626. not be supported by the server. If it is supported the location 
  1627. argument encodes what to read in file.
  1628.  
  1629.  
  1630. ERRORS
  1631.  
  1632.     NFSERR_NOTFILE    File is not a file type that can be read.
  1633.  
  1634.     NFSERR_BADOFFSET    The location given does not make sense.
  1635.  
  1636.  
  1637.  
  1638.  
  1639.  
  1640. Procedure 8            WRITE                Version 3
  1641.  
  1642.  
  1643. Write to File
  1644.  
  1645.  
  1646. SYNOPSIS
  1647.  
  1648. 8. NFSPROC_WRITE( file, location, data ) returns ( reply )
  1649.  
  1650.  
  1651.     fhandle        file;
  1652.     position        location;
  1653.     nfsdata        data;
  1654.  
  1655.     union writeres switch (stat status) {
  1656.         case NFS_OK:
  1657.             struct writeokres {
  1658.                 unsigned        count;
  1659.                 fattr            attributes;
  1660.             } ok;
  1661.         case NFS_ERROR:
  1662.             errinfo    errinfo;
  1663.     } reply;
  1664.  
  1665.  
  1666. DESCRIPTION
  1667.  
  1668. Write data to location in file. File must be either a regular 
  1669. (ftype NFREG) or special (ftype NFSPEC) file. When writing to a regular 
  1670. file location.offset is the byte offset into file at which data should 
  1671. be written. A byte offset of zero mean write data starting at the 
  1672. beginning of the file. If location.append is TRUE data is written at the 
  1673. current end of file only if location.offset matches the current maximum 
  1674. offset into the file.
  1675.  
  1676. If reply.status is NFS_OK reply.ok.attributes is the attributes of the 
  1677. file after the write operation has completed. If reply.status is NFS_ERROR 
  1678. then the call failed and reply.errinfo contains error information.
  1679.  
  1680. The server has the option of accepting only a portion of data. 
  1681. In this case reply.ok.count is the number of bytes of data 
  1682. that were written starting at offset in file. The size 
  1683. of data must be less than or equal to the value of the wsize 
  1684. field in the GETFSINFO reply structure (see GETFSINFO procedure 
  1685. for more details) for the filesystem which contains file.
  1686.  
  1687.  
  1688. IMPLEMENTATION
  1689.  
  1690. If the ftype of file is NFSPEC the WRITE operation might 
  1691. not be supported by the server. If it is supported the location 
  1692. argument encodes where to write in file.
  1693.  
  1694. Append mode writes are only guaranteed in a single WRITE operation. 
  1695. If a client does multiple append mode WRITE requests, the data written 
  1696. may not be contiguous.
  1697.  
  1698.  
  1699. ERRORS
  1700.  
  1701.     NFSERR_ISDIR        File is a directory. Writing is not allowed 
  1702.                 on directories.
  1703.  
  1704.     NFSERR_FBIG        The WRITE operation would cause file to 
  1705.                 become too large.
  1706.  
  1707.     NFSERR_ROFS        The filesystem that contains file is 
  1708.                 read-only.
  1709.  
  1710.     NFSERR_NOSPC        The filesystem that contains file is full.
  1711.  
  1712.     NFSERR_NOTFILE        File is not a file type that can be written.
  1713.  
  1714.     NFSERR_BADOFFSET    The location given does not make sense.
  1715.  
  1716.  
  1717.  
  1718.  
  1719.  
  1720.  
  1721. Procedure 9             WRITECACHE            Version 3
  1722.  
  1723.  
  1724. Write to Cache
  1725.  
  1726.  
  1727. SYNOPSIS
  1728.  
  1729. 9. NFSPROC_WRITECACHE(file, flush, beg inoffset, totalcount, offset, data)
  1730.    returns ( reply )
  1731.  
  1732.     fhandle        file;
  1733.     boolean        flush;
  1734.     fileoffset    beginoffset;
  1735.     unsigned    totalcount;
  1736.     fileoffset    offset;
  1737.     nfsdata        data;
  1738.  
  1739.     union writecacheres switch (stat status) {
  1740.         case NFS_OK:
  1741.             unsigned count;
  1742.             union switch (boolean flushed) {
  1743.                 case TRUE:
  1744.                     fattr        attributes;
  1745.                 case FALSE:
  1746.                     unsigned    flushct;
  1747.                     errinfo    flusherr;
  1748.             } ok;
  1749.         case NFS_ERROR:
  1750.             errinfo    errinfo;
  1751.     } reply;
  1752.  
  1753.  
  1754. DESCRIPTION
  1755.  
  1756. Writes data into the server's data cache for a regular (ftype NFREG) file. 
  1757. Beginoffset and totalcount describe the offset and size, in bytes, of 
  1758. the entire piece of data to be written. These values will be the same 
  1759. across a set of WRITECACHE operations. Each of the WRITECACHE operations 
  1760. in a set will have different values for offset and data. Offset is the byte 
  1761. offset into file where data should be written.
  1762.  
  1763. The boolean flush, if TRUE, causes the server to flush a whole data set. 
  1764. That is, commit to disk the data from several WRITECACHE 
  1765. operations, whose offset values fall between beginoffset and 
  1766. beginoffset+totalcount. If the server's attempt to flush totalcount 
  1767. bytes of data starting at beginoffset bytes into the file is successful 
  1768. the server will return reply.flushed TRUE.
  1769.  
  1770. If reply.status is NFS_OK and reply.flushed is 
  1771. TRUE reply.ok.attributes is the attributes of the file following 
  1772. the write of the cached data. If reply.flushed is FALSE reply.ok.flushct 
  1773. is the number of consecutive bytes that actually got written starting 
  1774. at beginoffset, which may be less than totalcount, and reply.ok.flusherr 
  1775. contains error information about the write operation that failed. If 
  1776. reply.status is NFS_ERROR then the call failed and reply.errinfo contains 
  1777. error information.
  1778.  
  1779. The server has the option of accepting only a portion of data.  
  1780. In this case reply.ok.count is the number of bytes of data 
  1781. that were cached starting at offset in file. The size of data must 
  1782. be less than or equal to the value of the wsize field in the 
  1783. GETFSINFO reply structure (see GETFSINFO procedure for more details) 
  1784. for the filesystem which contains file. In addition, totalcount must 
  1785. be less than or equal to the wcsize field in the GETFSINFO reply.
  1786.  
  1787.  
  1788. IMPLEMENTATION
  1789.  
  1790. The WRITECACHE operation is provided for performance only. Servers 
  1791. are not required to support it.
  1792.  
  1793. Clients can use the WRITECACHE operation to group consecutive WRITE 
  1794. operations without incurring the overhead of flushing each chunk of 
  1795. data through to disk on the server. The client takes responsibility 
  1796. for recovering from server errors by holding on to data that has been 
  1797. written with WRITECAHE until a successful flush has occurred. This way, 
  1798. to recover from an error the client can either retry the set of 
  1799. WRITECACHE operations or use WRITE operations to insure that the data 
  1800. is safely on the servers disk.
  1801.  
  1802. The server may pre-flush cached data to disk to free up cache space. 
  1803. If this happens the server can either return an error in response 
  1804. to the flush request and force the client to resend everything, or 
  1805. keep track of data that has already been flushed when the flush request 
  1806. comes along. This way, if the server can account for all data as either 
  1807. in the cache or already flushed the flush request can return success.
  1808.  
  1809.  
  1810. ERRORS
  1811.  
  1812.     NFSERR_WFLUSH    Cached data for file had to be discarded.
  1813.  
  1814.     NFSERR_ISDIR    File is a directory. Writing is not allowed 
  1815.             on directories.
  1816.  
  1817.     NFSERR_FBIG    The WRITE operation would cause file to 
  1818.             become too large.
  1819.  
  1820.     NFSERR_ROFS    The filesystem that contains file is read-only.
  1821.  
  1822.  
  1823.  
  1824.  
  1825.  
  1826. Procedure 10                ZERO            Version 3
  1827.  
  1828.  
  1829. Zero Data in File
  1830.  
  1831.  
  1832. SYNOPSIS
  1833.  
  1834.  
  1835. 10. NFSPROC_ZERO( file, location, count ) returns ( reply )
  1836.  
  1837.     fhandle        file;
  1838.     position    location;
  1839.     filesize    size;
  1840.  
  1841.     union zerores switch (stat status) {
  1842.         case NFS_OK:
  1843.             struct zerookres {
  1844.                 unsigned    count;
  1845.                 fattr        attributes;
  1846.             } ok;
  1847.         case NFS_ERROR:
  1848.             errinfo    errinfo;
  1849.     } reply;
  1850.  
  1851.  
  1852. DESCRIPTION
  1853.  
  1854. Zero up to count bytes of data starting at location in file. File 
  1855. must be either a regular (ftype NFREG) or record (ftype NFREC) file. 
  1856. When zeroing a regular file location.offset is the byte offset into 
  1857. file at which data should be zeroed. A byte offset of zero mean zero 
  1858. data starting at the beginning of the file. If location.append is TRUE 
  1859. and location.offset matches the offset of the current end of file, 
  1860. data is zeroed starting at the current end of file.
  1861.  
  1862. If reply.status is NFS_OK reply.ok.attributes is the attributes of the 
  1863. file following the operation. If reply.status is NFS_ERROR then the 
  1864. call failed and reply.errinfo contains error information.
  1865.  
  1866. The server has the option of zeroing less than count bytes. In this 
  1867. case reply.ok.count is the number of bytes that were zeroed starting 
  1868. at loaction.offset in file.
  1869.  
  1870.  
  1871. IMPLEMENTATION
  1872.  
  1873. The ZERO operation is provided as an optimization for those servers 
  1874. whose operating systems can support files with holes. The server should 
  1875. implement the ZERO operation by punching holes in files if possible. 
  1876. If the server cannot support holes in files it is up to the implementor 
  1877. whether to support the ZERO operation by writing zero bytes to the 
  1878. file or not to support the operation at all.
  1879.  
  1880. A ZERO operation with location.append set to TRUE or location.offset+size 
  1881. greater that the size of file should cause the size of file to change.
  1882.  
  1883.  
  1884. ERRORS
  1885.  
  1886.     NFSERR_ISDIR    File is a directory. Writing is not allowed 
  1887.             on directories.
  1888.  
  1889.     NFSERR_FBIG    The WRITE operation would cause file to 
  1890.             become too large.
  1891.  
  1892.     NFSERR_ROFS    The filesystem that contains file is read-only.
  1893.  
  1894.     NFSERR_NOSPC    The filesystem that contains file is full.
  1895.  
  1896.     NFSERR_NOTFILE    File is not a file type that can be zeroed.
  1897.  
  1898.     NFSERR_BADOFFSET    The location given does not make sense.
  1899.  
  1900.  
  1901.  
  1902.  
  1903.  
  1904. Procedure 11            Create                Version 3
  1905.  
  1906.  
  1907. Create a File or Directory
  1908.  
  1909.  
  1910. SYNOPSIS
  1911.  
  1912. 11. NFSPROC_CREATE( where, type, perm, rmtarg ) returns ( reply )
  1913.  
  1914.     diropargs        where;
  1915.     ftype            type;
  1916.     permbits        perm;
  1917.     rmtarget        rmtarg;
  1918.  
  1919.     diropres        reply;
  1920.  
  1921.  
  1922. DESCRIPTION
  1923.  
  1924. The CREATE operation is used to create files and directories. Where.dir 
  1925. is the directory in which the create will take place, where.name 
  1926. is the name of the object to be created, type is the type of the object 
  1927. and perm gives the initial permission bits of the object. If 
  1928. rmtarg.exclusive is FALSE this is a non-exclusive create request, that 
  1929. is, the target name already exists and it will be destroyed in the 
  1930. operation. In this case rmtarg.targetfh must match the fhandle of the 
  1931. target of the create operation or it will fail.
  1932.  
  1933. If reply.status is NFS_OK reply.ok.targ is the fhandle of the new object, 
  1934. reply.ok.targattr is the attributes of the object and reply.ok.dirattr 
  1935. is the attributes of where.dir after the create operation has completed. 
  1936. If reply.status is NFS_ERROR then the call failed and reply.errinfo 
  1937. contains error information.
  1938.  
  1939.  
  1940. IMPLEMENTATION
  1941.  
  1942. The rmtarg argument is provided to allow servers to detect 
  1943. duplicate requests. If the client is doing an exclusive operation 
  1944. and the target name already exists the server should return NFSERR_EXIST. 
  1945. If the client is doing a non-exclusive operation and rmtarg.targetfh 
  1946. does not match the fhandle for the target name the server should 
  1947. return NFSERR_DUPREQ. If the client is doing a non-exclusive create 
  1948. and the target name does not exist the server should do the operation 
  1949. as if it were exclusive.
  1950.  
  1951. Clients should use the LOOKUP procedure to get the fhandle for the 
  1952. target name. If the LOOKUP fails because the name does not exist the 
  1953. client should set rmtarg.exclusive to TRUE. Clients can 
  1954. recover from NFSERR_DUPREQ by using the LOOKUP operation to get a 
  1955. new fhandle for the target name and resending the request.
  1956.  
  1957.  
  1958. ERRORS
  1959.  
  1960.     NFSERR_NOTDIR    Where.dir is not a directory.
  1961.  
  1962.     NFSERR_NAMETOOLONG    Where.name contains too many characters.
  1963.  
  1964.     NFSERR_ROFS    The filesystem that contains where.dir is 
  1965.             read-only.
  1966.  
  1967.     NFSERR_NOSPC    The filesystem that contains where.dir is 
  1968.             full.
  1969.  
  1970.     NFSERR_EXIST    Where.name already exists in where.dir. 
  1971.             This error can occur only if rmtarg.exclusive 
  1972.             is TRUE.
  1973.  
  1974.     NFSERR_DUPREQ    Duplicate request. This error occurs only if 
  1975.             rmtarg.exclusive is FALSE and rmtarg.targetfh 
  1976.             does not match the fhandle for where.name.
  1977.  
  1978.  
  1979.  
  1980.  
  1981.  
  1982. PROCEDURE 12            REMOVE                Version 3
  1983.  
  1984.  
  1985.  
  1986. Remove a File or Directory
  1987.  
  1988.  
  1989. SYNOPSIS
  1990.  
  1991. 12. NFSPROC_REMOVE( target, targetfh ) returns ( reply )
  1992.  
  1993.     diropargs    target;
  1994.     fhandle        targetfh;
  1995.  
  1996.     attrstat    reply;
  1997.  
  1998.  
  1999. DESCRIPTION
  2000.  
  2001. Remove the object target.name from directory target.dir.Targetfh must 
  2002. match the file handle of the object on the server when the remove 
  2003. operation occurs or the operation will fail. If reply.status is NFS_OK 
  2004. reply.attributes is the attributes of the directory target.dir after 
  2005. the remove operation has completed. If reply.status is NFS_ERROR then 
  2006. the call failed and reply.errinfo contains error information.
  2007.  
  2008.  
  2009. IMPLEMENTATION
  2010.  
  2011. The server should return no error if the target.name does not exist and 
  2012. targetfh does not exist. This should only occur if the target name has 
  2013. already been removed.
  2014.  
  2015. Some servers will allow removal of non-empty directories.
  2016.  
  2017.  
  2018. ERRORS
  2019.  
  2020.     NFSERR_NOENT    Target.name does not exist in target.dir.
  2021.  
  2022.     NFSERR_NOTDIR    Target.dir is not a directory.
  2023.  
  2024.     NFSERR_NAMETOOLONG    Target.name contains too many characters.
  2025.  
  2026.     NFSERR_ROFS    The filesystem that contains Target.dir is 
  2027.             read-only.
  2028.  
  2029.     NFSERR_NOTEMPTY    The server will only remove empty directories 
  2030.             and target.name is a directory that is not empty.
  2031.  
  2032.  
  2033.  
  2034.  
  2035.  
  2036.  
  2037. Procedure 13            RENAME                Version 3
  2038.  
  2039.  
  2040. Rename File or Directory
  2041.  
  2042.  
  2043. SYNOPSIS
  2044.  
  2045. 13. NFSPROC_RENAME( from, to, rmtarg ) returns ( reply )
  2046.  
  2047.     diropargs    from;
  2048.     diropargs    to;
  2049.     rmtarget    rmtarg;
  2050.  
  2051.     union renameres switch (stat status) {
  2052.         case NFS_OK:
  2053.             struct renameresok {
  2054.                 fattr        fromattr;
  2055.                 diropokres    to;
  2056.             } ok;
  2057.         case NFS_ERROR:
  2058.             errinfo    errinfo;
  2059.     } reply;
  2060.  
  2061.  
  2062. DESCRIPTION
  2063.  
  2064. Rename the object from.name in directory from.dir to to.name in 
  2065. directory to.dir. If rmtarg.exclusive is FALSE this is a non-exclusive 
  2066. rename request, that is, to.name already exists in to.dir and will 
  2067. be destroyed in the operation. In this case rmtarg.targetfh must match 
  2068. the fhandle of the target of the rename operation or it will fail.
  2069.  
  2070. If reply.status is NFS_OK reply.ok.to.targ is the fhandle of the 
  2071. renamed object, reply.ok.to.targattr is the attributes of the object, 
  2072. reply.ok.to.dirattr is the attributes of to.dir after the rename 
  2073. operation has completed and reply.ok.fromattr is the attributes of from.dir 
  2074. after the rename operation has completed. If reply.status is NFS_ERROR 
  2075. then the call failed and reply.errinfo contains error information.
  2076.  
  2077.  
  2078. IMPLEMENTATION
  2079.  
  2080. The rmtarg argument is provided to allow servers to detect 
  2081. duplicate requests. If the client is doing an exclusive operation 
  2082. and the target name already exists the server should return NFSERR_EXIST. 
  2083. If the client is doing a non-exclusive operation and rmtarg.targetfh 
  2084. does not match the fhandle for the target name the server should 
  2085. return NFSERR_DUPREQ. If the client is doing a non-exclusive create 
  2086. and the target name does not exist the server should do the operation 
  2087. as if it were exclusive.
  2088.  
  2089. Clients should use the LOOKUP procedure to get the fhandle for the 
  2090. target name. If the LOOKUP fails because the name does not exist the 
  2091. client should set rmtarg.exclusive to TRUE. Clients can 
  2092. recover from NFSERR_DUPREQ by using the LOOKUP operation to get a 
  2093. new fhandle for the target name and resending the request.
  2094.  
  2095. The rename operation should be atomic on the server.
  2096.  
  2097.  
  2098. ERRORS
  2099.  
  2100.     NFSERR_NOTDIR    From.dir or to.dir is not a 
  2101.             directory.
  2102.  
  2103.     NFSERR_NAMETOOLONG    From.name or to.name contains 
  2104.                 too many characters.
  2105.  
  2106.     NFSERR_ROFS    The filesystem that contains From.dir or to.dir 
  2107.             is read-only.
  2108.  
  2109.     NFSERR_NOSPC    The filesystem that contains to.dir is 
  2110.             full.
  2111.  
  2112.     NFSERR_EXIST    To.name already exists in to.dir. 
  2113.             This error can occur only if rmtarg.exclusive is 
  2114.             TRUE.
  2115.  
  2116.     NFSERR_DUPREQ    Duplicate request. This error occurs only if 
  2117.             rmtarg.exclusive is FALSE and rmtarg.targetfh 
  2118.             does not match the fhandle for to.name.
  2119.  
  2120.  
  2121.  
  2122.  
  2123.  
  2124.  
  2125. Procedure 14            LINK                Version 3
  2126.  
  2127.  
  2128. Create Link to an object
  2129.  
  2130.  
  2131. SYNOPSIS
  2132.  
  2133. 14. NFSPROC_LINK( from, to, rmtarg ) returns ( reply )
  2134.  
  2135.     fhandle        from;
  2136.     diropargs    to;
  2137.     rmtarget    rmtarg;
  2138.  
  2139.     diropres    reply;
  2140.  
  2141.  
  2142. DESCRIPTION
  2143. Create a hard link from the object from to to.name in 
  2144. directory to.dir. If rmtarg.exclusive is FALSE 
  2145. this is a non-exclusive link request, that is, to.name already 
  2146. exists in to.dir and will be destroyed in the operation. 
  2147. In this case rmtarg.targetfh must match the fhandle of the 
  2148. target of the link operation or it will fail.
  2149.  
  2150. If reply.status is NFS_OK reply.ok.targ is the 
  2151. fhandle of the new object, reply.ok.targattr is the attributes 
  2152. of the object and reply.ok.dirattr is the attributes of to.dir 
  2153. after the symlink operation has completed. If reply.status is 
  2154. NFS_ERROR then the call failed and reply.errinfo contains 
  2155. error information.
  2156.  
  2157.  
  2158. IMPLEMENTATION
  2159.  
  2160. A hard link should have the property that changes to any of the linked 
  2161. files are reflected in all of the linked files. When a hard link is 
  2162. made to a file, the attributes for the file should have a value for nlink 
  2163. which is one greater than the value before the LINK.
  2164.  
  2165. The rmtarg argument is provided to allow servers to detect 
  2166. duplicate requests. If the client is doing an exclusive operation 
  2167. and the target name already exists the server should return NFSERR_EXIST. 
  2168. If the client is doing a non-exclusive operation and rmtarg.targetfh 
  2169. does not match the fhandle for the target name the server should 
  2170. return NFSERR_DUPREQ. If the client is doing a non-exclusive create 
  2171. and the target name does not exist the server should do the operation 
  2172. as if it were exclusive.
  2173.  
  2174. Clients should use the LOOKUP procedure to get the fhandle for the 
  2175. target name. If the LOOKUP fails because the name does not exist the 
  2176. client should set rmtarg.exclusive to TRUE. Clients can 
  2177. recover from NFSERR_DUPREQ by using the LOOKUP operation to get a 
  2178. new fhandle for the target name and resending the request.
  2179.  
  2180.  
  2181. ERRORS
  2182.  
  2183.     NFSERR_NOTDIR    From.dir or to.dir is not a 
  2184.             directory.
  2185.  
  2186.     NFSERR_NAMETOOLONG    From.name or to.name contains 
  2187.                 too many characters.
  2188.  
  2189.     NFSERR_ROFS    The filesystem that contains From.dir or to.dir 
  2190.             is read-only.
  2191.  
  2192.     NFSERR_NOSPC    The filesystem that contains to.dir is 
  2193.             full.
  2194.  
  2195.     NFSERR_EXIST    To.name already exists in to.dir. 
  2196.             This error can occur if rmtarg.exclusive is TRUE 
  2197.             or if rmtarg.exclusive is FALSE and rmtarg.targetfh 
  2198.             does not match the fhandle for to.name.
  2199.  
  2200.  
  2201.  
  2202.  
  2203.  
  2204.  
  2205. Procedure 15            SYMLINK                Version 3
  2206.  
  2207.  
  2208. Create Symbolic Link
  2209.  
  2210.  
  2211. SYNOPSIS
  2212.  
  2213. 15. NFSPROC_SYMLINK( where, data, perm, rmtarg ) returns ( reply )
  2214.  
  2215.     diropargs    where;
  2216.     path        data;
  2217.     permbits    perm;
  2218.     rmtarget    rmtarg;
  2219.  
  2220.     diropres    reply;
  2221.  
  2222.  
  2223. DESCRIPTION
  2224.  
  2225. Creates the symbolic link file where.name with ftype NFLNK 
  2226. in the directory where.dir. The new file contains the pathname data 
  2227. and has initial permission bits given by perm. If rmtarg.exclusive 
  2228. is FALSE this is a non-exclusive symlink request, that is, where.name 
  2229. already exists in where.dir and will be destroyed in the operation. 
  2230. In this case rmtarg.targetfh must match the fhandle of the target of 
  2231. the symlink operation or it will fail.
  2232.  
  2233. If reply.status is NFS_OK reply.ok.targ is the fhandle of the new 
  2234. object, reply.ok.targattr is the attributes of the object and 
  2235. reply.ok.dirattr is the attributes of where.dir after the symlink 
  2236. operation has completed. If reply.status is NFS_ERROR then the call 
  2237. failed and reply.errinfo contains error information.
  2238.  
  2239.  
  2240. IMPLEMENTATION
  2241.  
  2242. A symbolic link is a pointer to another file. The data is 
  2243. not interpreted by the server, just stored in the file created by 
  2244. the SYMLINK call. A READLINK operation returns the data to 
  2245. the client for interpretation. If different implementations want to 
  2246. share access to symbolic links they must agree on the interpretation 
  2247. of the data in the symbolic link.
  2248.  
  2249. Symbolic links are a filesystem object that are not supported by many 
  2250. operating systems. The operations on symbolic links are therefore 
  2251. not combined with the operations on regular files, though they are 
  2252. very similar. This allows servers to return an NFSERR_OPNOTSUP if 
  2253. symbolic links are not supported, and it allows clients to recover 
  2254. easily.
  2255.  
  2256. Servers that do not have support for symbolic links in their operating 
  2257. systems could implement them by using regular files to hold the symlink 
  2258. path. This special data file can be marked by setting some unique 
  2259. combination of file attributes that will never occur on a regular 
  2260. data file. When attributes for this file are returned to the client 
  2261. they should have the type filed set to NFLNK.
  2262.  
  2263. Clients can use a similar trick to implement symbolic links if the 
  2264. server does not support them. In this case the client must check the 
  2265. attributes returned by the server and if the type is NFREG and some 
  2266. unique set of attributes is set change the type field to NFLNK.
  2267.  
  2268.  
  2269. ERRORS
  2270.  
  2271.     NFSERR_NOTDIR    Where.dir is not a directory.
  2272.  
  2273.     NFSERR_NAMETOOLONG    Where.name contains too many characters.
  2274.  
  2275.     NFSERR_ROFS    The filesystem that contains where.dir is 
  2276.             read-only.
  2277.  
  2278.     NFSERR_NOSPC    The filesystem that contains where.dir is 
  2279.             full.
  2280.  
  2281.     NFSERR_EXIST    Where.name already exists in where.dir. 
  2282.             This error can occur if rmtarg.exclusive is 
  2283.             TRUE or if rmtarg.exclusive is FALSE and 
  2284.             rmtarg.targetfh does not match the fhandle for 
  2285.             where.name.
  2286.  
  2287.  
  2288.  
  2289.  
  2290.  
  2291.  
  2292.  
  2293. Procedure 16            READLINK            Version 3
  2294.  
  2295.  
  2296. Read From Symbolic Link
  2297.  
  2298.  
  2299. SYNOPSIS
  2300.  
  2301. 16. NFSPROC_READLINK( file ) returns ( reply )
  2302.  
  2303.     fhandle file;
  2304.  
  2305.     union readlinkres switch (stat status) {
  2306.         case NFS_OK:
  2307.             path data;
  2308.         case NFS_ERROR:
  2309.             errinfo errinfo;
  2310.     } reply;
  2311.  
  2312.  
  2313. DESCRIPTION
  2314.  
  2315. If status has the value NFS_OK then reply.data is 
  2316. the data in the symbolic link given by file. The data is 
  2317. an ASCII string which is opaque to the server. If reply.status is 
  2318. NFS_ERROR then reply.errinfo contains error information.
  2319.  
  2320.  
  2321. IMPLEMENTATION
  2322.  
  2323. A symbolic link is a pointer to another file. The data is 
  2324. not interpreted by the server, just stored in the file created by 
  2325. the SYMLINK call. A READLINK operation returns the data to 
  2326. the client for interpretation. If different implementations want to 
  2327. share access to symbolic links they must agree on the interpretation 
  2328. of the data in the symbolic link.
  2329.  
  2330. The READLINK operation is only allowed on objects of type NFLNK.
  2331.  
  2332. For more information see SYMLINK.
  2333.  
  2334.  
  2335. ERRORS
  2336.  
  2337.     NFSERR_NOTSYMLINK    File is not a symbolic link (ftype NFLNK).
  2338.  
  2339.  
  2340.  
  2341.  
  2342.  
  2343.  
  2344. Procedure 17            CREATEUNIQ            Version 3
  2345.  
  2346.  
  2347. Create a Uniquely Named Object
  2348.  
  2349.  
  2350. SYNOPSIS
  2351.  
  2352. 17. NFSPROC_CREATEUNIQ( where, type, perm ) returns ( reply )
  2353.  
  2354.     fhandle        where;
  2355.     ftype        type;
  2356.     permbits    perm;
  2357.  
  2358.     union createuniqres switch (stat status) {
  2359.         case NFS_OK:
  2360.             struct {
  2361.                 filename    uniqname;
  2362.                 diropokres    to;
  2363.             } ok;
  2364.         case NFS_ERROR:
  2365.             errinfo    errinfo;
  2366.     } reply;
  2367.  
  2368.  
  2369. DESCRIPTION
  2370.  
  2371. The CREATEUNIQ operation is used to create uniquely named objects. Where 
  2372. is the directory in which the new object will be created, type is the 
  2373. type of the object and perm gives the initial permission bits of the object. 
  2374.  
  2375. If reply.status is NFS_OK reply.ok.uniqname is the unique name of 
  2376. the new object, reply.ok.to.targ is the fhandle of the new object, 
  2377. reply.ok.to.targattr is the attributes of the object and 
  2378. reply.ok.to.dirattr is the attributes of where after the create 
  2379. operation has completed. If reply.status is NFS_ERROR then the call 
  2380. failed and reply.errinfo contains error information.
  2381.  
  2382.  
  2383. IMPLEMENTATION
  2384.  
  2385. The CREATEUNIQ operation should be atomic on the server. It allows 
  2386. clients to create files and directories on the server without having 
  2387. to recover from naming errors (e.g. NFSERR_BADNAME) and 
  2388. name creation races with other clients. This is useful, for example, 
  2389. in creating temporary files where the name does not matter.
  2390.  
  2391.  
  2392. ERRORS
  2393.  
  2394.     NFSERR_NOTDIR    Where is not a directory.
  2395.  
  2396.     NFSERR_ROFS    The filesystem that contains where is read-only.
  2397.  
  2398.     NFSERR_NOSPC    The filesystem that contains where is full.
  2399.  
  2400.  
  2401.  
  2402.  
  2403.  
  2404.  
  2405. Procedure 18            READDIR                Version 3
  2406.  
  2407.  
  2408. Read From Directory
  2409.  
  2410.  
  2411. SYNOPSIS
  2412.  
  2413. 18. NFSPROC_READDIR( dir, cookie, count, allvers ) returns ( reply )
  2414.  
  2415.     fhandle        dir;
  2416.     opaque        cookie<COOKIESIZE>;
  2417.     unsigne        count;
  2418.     boolean        all;
  2419.  
  2420.     struct entry {
  2421.         fileid        fileno;
  2422.         filename    name;
  2423.         nfscookie    cookie;
  2424.         entry        *nextentry;
  2425.     };
  2426.  
  2427.     union readdirres switch (stat status) {
  2428.         case NFS_OK:
  2429.             struct dirlist {
  2430.                 entry *entries;
  2431.                 boolean eof;
  2432.             } ok;
  2433.         case NFS_ERROR:
  2434.             errinfo errinfo;
  2435.     } reply;
  2436.  
  2437.  
  2438. DESCRIPTION
  2439.  
  2440. Returns a variable number of directory entries, with a total XDR encoded 
  2441. size of up to count bytes, from the directory dir. 
  2442. If all is TRUE entries for every name will be returned. 
  2443. Each entry contains a fileno which is a unique 
  2444. number to identify the file within a filesystem, the name of 
  2445. the file, and a cookie which is an opaque identifier 
  2446. of the next entry in the directory. The cookie is 
  2447. used in the next READDIR call to get more entries starting at a given 
  2448. point in the directory. The special cookie zero (all bits 
  2449. zero) can be used to get the entries starting at the beginning of 
  2450. the directory. The fileno field should be the 
  2451. same number as the fileno field in the the attributes of 
  2452. the file. The eof flag has a value of TRUE if there are 
  2453. no more entries in the directory.
  2454.  
  2455. If the returned value of reply.status is NFS_OK then it 
  2456. is followed by a variable number of entries. If reply.status is 
  2457. NFS_ERROR then the call failed and reply.errinfo contains 
  2458. error information.
  2459.  
  2460.  
  2461. IMPLEMENTATION
  2462.  
  2463. The server has the option of returning fewer than count bytes 
  2464. of XDR encoded entries. Count must be less than or equal 
  2465. to the value of the dirsize field in the GETFSINFO reply 
  2466. structure (see GETFSINFO procedure for more details) for the filesystem 
  2467. which contains dir.
  2468.  
  2469. Directory entry cookies may become invalid if the directory is modified. 
  2470. The client should be careful to avoid holding directory entry cookies 
  2471. across operation that modify the directory contents, such as REMOVE 
  2472. and CREATE.
  2473.  
  2474. If all is FALSE only the current version of version numbered 
  2475. files, the data fork of Macintosh files, and files with the permbit 
  2476. "Hidden" set to zero should be returned.
  2477.  
  2478. Since UNIX clients impart a special meaning to the fileno 
  2479. value zero, UNIX clients should be careful to map zero filenos to 
  2480. some other value, and servers of UNIX clients should try to avoid 
  2481. sending zero filenos.
  2482.  
  2483.  
  2484. ERRORS
  2485.  
  2486.     NFSERR_NOTDIR    Dir is not a directory.
  2487.  
  2488.     NFSERR_BADCOOKIE    Cookie is no longer valid.
  2489.  
  2490.  
  2491.  
  2492.  
  2493.  
  2494.  
  2495. Procedure 19            LINKAGE                Version 3
  2496.  
  2497.  
  2498.  
  2499. Map File Handle
  2500.  
  2501.  
  2502. SYNOPSIS
  2503.  
  2504. 19. NFSPROC_LINKAGE( fh, prognum, vers ) returns ( reply )
  2505.  
  2506.     fhandle    fh;
  2507.     unsigned    prognum;
  2508.     unsigned    vers;
  2509.  
  2510.     union linkageres switch (stat status) {
  2511.         case NFS_OK:
  2512.             fhandle    newfh;
  2513.         case NFS_ERROR:
  2514.             errinfo errinfo;
  2515.     } reply;
  2516.  
  2517.  
  2518. DESCRIPTION
  2519.  
  2520. LINKAGE provides a way of tying together different RPC services that 
  2521. use file handles. The prognum and vers arguments 
  2522. identify an RPC based service program number and version number. If 
  2523. reply.status is NFS_OK then reply.newfh is an fhandle that 
  2524. refers to the same object as fh and is in a form that the 
  2525. new service will understand.  If reply.status is NFS_ERROR 
  2526. then the call failed and reply.errinfo contains error information.
  2527.  
  2528.  
  2529. IMPLEMENTATION
  2530.  
  2531. In order for a service to implement the LINKAGE operation it must 
  2532. know the contents of the file handles used by the target service. 
  2533. The intent is that all services that refer to files use file handles, 
  2534. and that they all support the linkage service.
  2535.  
  2536. The reason that LINKAGE is necessary is that different services may 
  2537. encode different information in their file handles. In order for services 
  2538. that deal with files to cooperate there has to be a way to translate 
  2539. one file handle into another. An example of cooperating services is 
  2540. NFS and LOCK.
  2541.  
  2542.  
  2543.  
  2544.  
  2545.  
  2546.  
  2547. Procedure 20            GETFSATTR            Version 3
  2548.  
  2549.  
  2550. Get Filesystem Attributes
  2551.  
  2552.  
  2553. SYNOPSIS
  2554.  
  2555. 20. NFSPROC_GETFSATTR( file ) returns ( reply )
  2556.  
  2557.     fhandle    file;
  2558.  
  2559.     union fsattrres switch (stat status) {
  2560.         case NFS_OK:
  2561.             struct fsattrokres {
  2562.                 hyper        bytes;
  2563.                 hyper        bfree;
  2564.                 hyper        bavail;
  2565.                 hyper        files;
  2566.                 hyper        ffree;
  2567.                 hyper        favail;
  2568.                 timeval    stime;
  2569.             } ok;
  2570.         case NFS_ERROR:
  2571.             errinfo errinfo;
  2572.     } reply;
  2573.  
  2574.  
  2575. DESCRIPTION
  2576.  
  2577. If reply.status is NFS_OK then reply.ok gives the attributes for the 
  2578. filesystem that contains file. The attribute fields contain the 
  2579. following values:
  2580.  
  2581.     bytes    The total number of bytes in the filesystem.
  2582.  
  2583.     bfree    The number of free bytes in the filesystem.
  2584.  
  2585.     bavail    The number of bytes available to non-privileged users.
  2586.  
  2587.     files    The total number of file slots on the filesystem.
  2588.  
  2589.     ffree    The number of free file slots on the filesystem.
  2590.  
  2591.     favail    The number of file slots available to non-privileged users.
  2592.  
  2593.     stime    The server's current time of day.
  2594.  
  2595.  
  2596.  
  2597.  
  2598.  
  2599.  
  2600.  
  2601. Procedure 21            GETFSINFO            Version 3
  2602.  
  2603.  
  2604.  
  2605. Get Filesystem Information
  2606.  
  2607.  
  2608. SYNOPSIS
  2609.  
  2610. 21. NFSPROC_GETFSINFO( file ) returns ( reply )
  2611.  
  2612.     fhandle    file;
  2613.  
  2614.     union fsinfores switch (stat status) {
  2615.         case NFS_OK:
  2616.             struct fsinfookres {
  2617.                 unsigned    rsize;
  2618.                 unsigned    wsize;
  2619.                 unsigned    wcsize;
  2620.                 unsigned    nmsize;
  2621.                 unsigned    dirsize;
  2622.                 unsigned    timeo;
  2623.                 unsigned    flags;
  2624.                 integer    procinfo[NUMPROCS];
  2625.                 keystr        setkeys<MAXEXATTR>;
  2626.                 string        badch<MAXBADCHARS>;
  2627.                 keyval        exattr<MAXEXATTR>;
  2628.             } ok;
  2629.         case NFS_ERROR:
  2630.             errinfo    errinfo;
  2631.     } reply;
  2632.  
  2633.  
  2634. DESCRIPTION
  2635.  
  2636. If reply.status is NFS_OK then reply.ok gives information for the 
  2637. filesystem that contains file. The reply fields contain the following 
  2638. values:
  2639.  
  2640.     rsize    The maximum number of bytes that the server will return 
  2641.         on a READ or READDIR request.
  2642.  
  2643.     wsize    The maximum number of bytes that the server will accept 
  2644.         on a WRITE request.
  2645.  
  2646.     wcsize    The maximum totalcount, in bytes, that the server will 
  2647.         accept on a WRITECACHE request.
  2648.  
  2649.     nmsize    The maximum number of bytes in a file or directory name 
  2650.         in the filesystem.
  2651.  
  2652.     dirsize    The recomended directory read size in bytes.
  2653.  
  2654.     timeo    The initial timeout in .1 sec. expected before retransmission 
  2655.         of a request.
  2656.  
  2657.     flags    Boolean bits (defined below) that tell what services are 
  2658.         supported on the filesystem.
  2659.  
  2660.         readonly    0001    Read only access allowed.
  2661.  
  2662.         version        0002    Version numbers supported.
  2663.  
  2664.         record        0004    Record files supported.
  2665.  
  2666.         unixspec    0008    UNIX style special files supported.
  2667.  
  2668.         unixpipe    0010    UNIX style named pipes supported.
  2669.  
  2670.         unixsock    0020    UNIX style named sockets supported.
  2671.  
  2672.         link        0040    Hard links supported.
  2673.  
  2674.         symlink        0080    Symbolic links supported.
  2675.  
  2676.  
  2677.     procinfo    The estimated worst case time in milliseconds 
  2678.             required to process each request. The array is 
  2679.             indexed by procedure number. A time of -1 means 
  2680.             the procedure is not supported.
  2681.  
  2682.     setkeys        The extended attribute keys which can be set with 
  2683.             a SETATTR operation.
  2684.  
  2685.     badch    The characters that are not allowed in a file name.
  2686.  
  2687.     exattr    Optional array of key/value string pairs whcih can be used 
  2688.         for extended filesystem attributes. The predefined extended 
  2689.         attributes are given below.
  2690.  
  2691.     Key    Value    Description
  2692.  
  2693.     FSTYPE        The underlying filesystem type.
  2694.         BSD    Berkeley UNIX fast filesystem.
  2695.         DOS    MS-DOS filesystem.
  2696.         MAC    Macintosh filesystem.
  2697.         SYV    System V filesystem.
  2698.  
  2699.  
  2700. IMPLEMENTATION
  2701.  
  2702. The extended attributes are provided as a way to extend the standard 
  2703. attributes between cooperating clients and servers. The name space 
  2704. of extended attribute key strings is left open. It is expected that 
  2705. new attributes that arise that are of general use among a broad range 
  2706. of implementations will be given a general name, and will be included 
  2707. in future revisions of this specification. Attributes that are only 
  2708. used among a restricted set of implementations (e.g. used by a single 
  2709. vendor) should be given names that are not likely to conflict with 
  2710. other restricted names (e.g. <vendor name>.<attribute name>).
  2711.