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