|
|
1.1 root 1: /*
2: * Copyright (c) 2000 Apple Computer, Inc. All rights reserved.
3: *
4: * @APPLE_LICENSE_HEADER_START@
5: *
6: * The contents of this file constitute Original Code as defined in and
7: * are subject to the Apple Public Source License Version 1.1 (the
8: * "License"). You may not use this file except in compliance with the
9: * License. Please obtain a copy of the License at
10: * http://www.apple.com/publicsource and read it before using this file.
11: *
12: * This Original Code and all software distributed under the License are
13: * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
14: * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
15: * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
16: * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT. Please see the
17: * License for the specific language governing rights and limitations
18: * under the License.
19: *
20: * @APPLE_LICENSE_HEADER_END@
21: */
22: /* Copyright (c) 1995 NeXT Computer, Inc. All Rights Reserved */
23: /*
24: * Copyright (c) 1989, 1993
25: * The Regents of the University of California. All rights reserved.
26: *
27: * This code is derived from software contributed to Berkeley by
28: * Rick Macklem at The University of Guelph.
29: *
30: * Redistribution and use in source and binary forms, with or without
31: * modification, are permitted provided that the following conditions
32: * are met:
33: * 1. Redistributions of source code must retain the above copyright
34: * notice, this list of conditions and the following disclaimer.
35: * 2. Redistributions in binary form must reproduce the above copyright
36: * notice, this list of conditions and the following disclaimer in the
37: * documentation and/or other materials provided with the distribution.
38: * 3. All advertising materials mentioning features or use of this software
39: * must display the following acknowledgement:
40: * This product includes software developed by the University of
41: * California, Berkeley and its contributors.
42: * 4. Neither the name of the University nor the names of its contributors
43: * may be used to endorse or promote products derived from this software
44: * without specific prior written permission.
45: *
46: * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
47: * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
48: * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
49: * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
50: * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
51: * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
52: * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
53: * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
54: * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
55: * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
56: * SUCH DAMAGE.
57: *
58: * @(#)nfsproto.h 8.2 (Berkeley) 3/30/95
59: * FreeBSD-Id: nfsproto.h,v 1.3 1997/02/22 09:42:50 peter Exp $
60: */
61:
62: #ifndef _NFS_NFSPROTO_H_
63: #define _NFS_NFSPROTO_H_
64:
65: /*
66: * nfs definitions as per the Version 2 and 3 specs
67: */
68:
69: /*
70: * Constants as defined in the Sun NFS Version 2 and 3 specs.
71: * "NFS: Network File System Protocol Specification" RFC1094
72: * and in the "NFS: Network File System Version 3 Protocol
73: * Specification"
74: */
75:
76: /* Only define these if nfs_prot.h hasn't been included */
77: #ifndef NFS_PROGRAM
78:
79: #define NFS_PORT 2049
80: #define NFS_PROG 100003
81: #define NFS_VER2 2
82: #define NFS_VER3 3
83: #define NFS_V2MAXDATA 8192
84: #define NFS_MAXDGRAMDATA 16384
85: #define NFS_MAXDATA 32768
86: #define NFS_MAXPATHLEN 1024
87: #define NFS_MAXNAMLEN 255
88: #define NFS_MAXPKTHDR 404
89: #define NFS_MAXPACKET (NFS_MAXPKTHDR + NFS_MAXDATA)
90: #define NFS_MINPACKET 20
91: #define NFS_FABLKSIZE 512 /* Size in bytes of a block wrt fa_blocks */
92:
93: /* Stat numbers for rpc returns (version 2 and 3) */
94: #define NFS_OK 0
95: #define NFSERR_PERM 1
96: #define NFSERR_NOENT 2
97: #define NFSERR_IO 5
98: #define NFSERR_NXIO 6
99: #define NFSERR_ACCES 13
100: #define NFSERR_EXIST 17
101: #define NFSERR_XDEV 18 /* Version 3 only */
102: #define NFSERR_NODEV 19
103: #define NFSERR_NOTDIR 20
104: #define NFSERR_ISDIR 21
105: #define NFSERR_INVAL 22 /* Version 3 only */
106: #define NFSERR_FBIG 27
107: #define NFSERR_NOSPC 28
108: #define NFSERR_ROFS 30
109: #define NFSERR_MLINK 31 /* Version 3 only */
110: #define NFSERR_NAMETOL 63
111: #define NFSERR_NOTEMPTY 66
112: #define NFSERR_DQUOT 69
113: #define NFSERR_STALE 70
114: #define NFSERR_REMOTE 71 /* Version 3 only */
115: #define NFSERR_WFLUSH 99 /* Version 2 only */
116: #define NFSERR_BADHANDLE 10001 /* The rest Version 3 only */
117: #define NFSERR_NOT_SYNC 10002
118: #define NFSERR_BAD_COOKIE 10003
119: #define NFSERR_NOTSUPP 10004
120: #define NFSERR_TOOSMALL 10005
121: #define NFSERR_SERVERFAULT 10006
122: #define NFSERR_BADTYPE 10007
123: #define NFSERR_JUKEBOX 10008
124: #define NFSERR_TRYLATER NFSERR_JUKEBOX
125: #define NFSERR_STALEWRITEVERF 30001 /* Fake return for nfs_commit() */
126:
127: #define NFSERR_RETVOID 0x20000000 /* Return void, not error */
128: #define NFSERR_AUTHERR 0x40000000 /* Mark an authentication error */
129: #define NFSERR_RETERR 0x80000000 /* Mark an error return for V3 */
130:
131: #endif /* !NFS_PROGRAM */
132:
133: /* Sizes in bytes of various nfs rpc components */
134: #define NFSX_UNSIGNED 4
135:
136: /* specific to NFS Version 2 */
137: #define NFSX_V2FH 32
138: #define NFSX_V2FATTR 68
139: #define NFSX_V2SATTR 32
140: #define NFSX_V2COOKIE 4
141: #define NFSX_V2STATFS 20
142:
143: /* specific to NFS Version 3 */
144: #define NFSX_V3FH (sizeof (fhandle_t)) /* size this server uses */
145: #define NFSX_V3FHMAX 64 /* max. allowed by protocol */
146: #define NFSX_V3FATTR 84
147: #define NFSX_V3SATTR 60 /* max. all fields filled in */
148: #define NFSX_V3SRVSATTR (sizeof (struct nfsv3_sattr))
149: #define NFSX_V3POSTOPATTR (NFSX_V3FATTR + NFSX_UNSIGNED)
150: #define NFSX_V3WCCDATA (NFSX_V3POSTOPATTR + 8 * NFSX_UNSIGNED)
151: #define NFSX_V3COOKIEVERF 8
152: #define NFSX_V3WRITEVERF 8
153: #define NFSX_V3CREATEVERF 8
154: #define NFSX_V3STATFS 52
155: #define NFSX_V3FSINFO 48
156: #define NFSX_V3PATHCONF 24
157:
158: /* variants for both versions */
159: #define NFSX_FH(v3) ((v3) ? (NFSX_V3FHMAX + NFSX_UNSIGNED) : \
160: NFSX_V2FH)
161: #define NFSX_SRVFH(v3) ((v3) ? NFSX_V3FH : NFSX_V2FH)
162: #define NFSX_FATTR(v3) ((v3) ? NFSX_V3FATTR : NFSX_V2FATTR)
163: #define NFSX_PREOPATTR(v3) ((v3) ? (7 * NFSX_UNSIGNED) : 0)
164: #define NFSX_POSTOPATTR(v3) ((v3) ? (NFSX_V3FATTR + NFSX_UNSIGNED) : 0)
165: #define NFSX_POSTOPORFATTR(v3) ((v3) ? (NFSX_V3FATTR + NFSX_UNSIGNED) : \
166: NFSX_V2FATTR)
167: #define NFSX_WCCDATA(v3) ((v3) ? NFSX_V3WCCDATA : 0)
168: #define NFSX_WCCORFATTR(v3) ((v3) ? NFSX_V3WCCDATA : NFSX_V2FATTR)
169: #define NFSX_SATTR(v3) ((v3) ? NFSX_V3SATTR : NFSX_V2SATTR)
170: #define NFSX_COOKIEVERF(v3) ((v3) ? NFSX_V3COOKIEVERF : 0)
171: #define NFSX_WRITEVERF(v3) ((v3) ? NFSX_V3WRITEVERF : 0)
172: #define NFSX_READDIR(v3) ((v3) ? (5 * NFSX_UNSIGNED) : \
173: (2 * NFSX_UNSIGNED))
174: #define NFSX_STATFS(v3) ((v3) ? NFSX_V3STATFS : NFSX_V2STATFS)
175:
176: /* Only define these if nfs_prot.h hasn't been included */
177: #ifndef NFS_PROGRAM
178:
179: /* nfs rpc procedure numbers (before version mapping) */
180: #define NFSPROC_NULL 0
181: #define NFSPROC_GETATTR 1
182: #define NFSPROC_SETATTR 2
183: #define NFSPROC_LOOKUP 3
184: #define NFSPROC_ACCESS 4
185: #define NFSPROC_READLINK 5
186: #define NFSPROC_READ 6
187: #define NFSPROC_WRITE 7
188: #define NFSPROC_CREATE 8
189: #define NFSPROC_MKDIR 9
190: #define NFSPROC_SYMLINK 10
191: #define NFSPROC_MKNOD 11
192: #define NFSPROC_REMOVE 12
193: #define NFSPROC_RMDIR 13
194: #define NFSPROC_RENAME 14
195: #define NFSPROC_LINK 15
196: #define NFSPROC_READDIR 16
197: #define NFSPROC_READDIRPLUS 17
198: #define NFSPROC_FSSTAT 18
199: #define NFSPROC_FSINFO 19
200: #define NFSPROC_PATHCONF 20
201: #define NFSPROC_COMMIT 21
202:
203: #endif /* !NFS_PROGRAM */
204:
205: /* And leasing (nqnfs) procedure numbers (must be last) */
206: #define NQNFSPROC_GETLEASE 22
207: #define NQNFSPROC_VACATED 23
208: #define NQNFSPROC_EVICTED 24
209:
210: #define NFSPROC_NOOP 25
211: #define NFS_NPROCS 26
212:
213: /* Actual Version 2 procedure numbers */
214: #define NFSV2PROC_NULL 0
215: #define NFSV2PROC_GETATTR 1
216: #define NFSV2PROC_SETATTR 2
217: #define NFSV2PROC_NOOP 3
218: #define NFSV2PROC_ROOT NFSV2PROC_NOOP /* Obsolete */
219: #define NFSV2PROC_LOOKUP 4
220: #define NFSV2PROC_READLINK 5
221: #define NFSV2PROC_READ 6
222: #define NFSV2PROC_WRITECACHE NFSV2PROC_NOOP /* Obsolete */
223: #define NFSV2PROC_WRITE 8
224: #define NFSV2PROC_CREATE 9
225: #define NFSV2PROC_REMOVE 10
226: #define NFSV2PROC_RENAME 11
227: #define NFSV2PROC_LINK 12
228: #define NFSV2PROC_SYMLINK 13
229: #define NFSV2PROC_MKDIR 14
230: #define NFSV2PROC_RMDIR 15
231: #define NFSV2PROC_READDIR 16
232: #define NFSV2PROC_STATFS 17
233:
234: /*
235: * Constants used by the Version 3 protocol for various RPCs
236: */
237: #define NFSV3SATTRTIME_DONTCHANGE 0
238: #define NFSV3SATTRTIME_TOSERVER 1
239: #define NFSV3SATTRTIME_TOCLIENT 2
240:
241: #define NFSV3ACCESS_READ 0x01
242: #define NFSV3ACCESS_LOOKUP 0x02
243: #define NFSV3ACCESS_MODIFY 0x04
244: #define NFSV3ACCESS_EXTEND 0x08
245: #define NFSV3ACCESS_DELETE 0x10
246: #define NFSV3ACCESS_EXECUTE 0x20
247:
248: #define NFSV3WRITE_UNSTABLE 0
249: #define NFSV3WRITE_DATASYNC 1
250: #define NFSV3WRITE_FILESYNC 2
251:
252: #define NFSV3CREATE_UNCHECKED 0
253: #define NFSV3CREATE_GUARDED 1
254: #define NFSV3CREATE_EXCLUSIVE 2
255:
256: #define NFSV3FSINFO_LINK 0x01
257: #define NFSV3FSINFO_SYMLINK 0x02
258: #define NFSV3FSINFO_HOMOGENEOUS 0x08
259: #define NFSV3FSINFO_CANSETTIME 0x10
260:
261: /* Conversion macros */
262: #define vtonfsv2_mode(t,m) \
263: txdr_unsigned(((t) == VFIFO) ? MAKEIMODE(VCHR, (m)) : \
264: MAKEIMODE((t), (m)))
265: #define vtonfsv3_mode(m) txdr_unsigned((m) & 07777)
266: #define nfstov_mode(a) (fxdr_unsigned(u_short, (a))&07777)
267: #define vtonfsv2_type(a) txdr_unsigned(nfsv2_type[((long)(a))])
268: #define vtonfsv3_type(a) txdr_unsigned(nfsv3_type[((long)(a))])
269: #define nfsv2tov_type(a) nv2tov_type[fxdr_unsigned(u_long,(a))&0x7]
270: #define nfsv3tov_type(a) nv3tov_type[fxdr_unsigned(u_long,(a))&0x7]
271:
272: /* Only define these if nfs_prot.h hasn't been included */
273: #ifndef NFS_PROGRAM
274:
275: /* File types */
276: typedef enum { NFNON=0, NFREG=1, NFDIR=2, NFBLK=3, NFCHR=4, NFLNK=5,
277: NFSOCK=6, NFFIFO=7 } nfstype;
278: #endif /* !NFS_PROGRAM */
279:
280: /* Structs for common parts of the rpc's */
281: /*
282: * File Handle (32 bytes for version 2), variable up to 64 for version 3.
283: * File Handles of up to NFS_SMALLFH in size are stored directly in the
284: * nfs node, whereas larger ones are malloc'd. (This never happens when
285: * NFS_SMALLFH is set to 64.)
286: * NFS_SMALLFH should be in the range of 32 to 64 and be divisible by 4.
287: */
288: #ifndef NFS_SMALLFH
289: #define NFS_SMALLFH 64
290: #endif
291: union nfsfh {
292: fhandle_t fh_generic;
293: u_char fh_bytes[NFS_SMALLFH];
294: };
295: typedef union nfsfh nfsfh_t;
296:
297: struct nfsv2_time {
298: u_long nfsv2_sec;
299: u_long nfsv2_usec;
300: };
301: typedef struct nfsv2_time nfstime2;
302:
303: struct nfsv3_time {
304: u_long nfsv3_sec;
305: u_long nfsv3_nsec;
306: };
307: typedef struct nfsv3_time nfstime3;
308:
309: /*
310: * Quads are defined as arrays of 2 longs to ensure dense packing for the
311: * protocol and to facilitate xdr conversion.
312: */
313: struct nfs_uquad {
314: u_long nfsuquad[2];
315: };
316: typedef struct nfs_uquad nfsuint64;
317:
318: /*
319: * Used to convert between two u_longs and a u_quad_t.
320: */
321: union nfs_quadconvert {
322: u_long lval[2];
323: u_quad_t qval;
324: };
325: typedef union nfs_quadconvert nfsquad_t;
326:
327: /*
328: * NFS Version 3 special file number.
329: */
330: struct nfsv3_spec {
331: u_long specdata1;
332: u_long specdata2;
333: };
334: typedef struct nfsv3_spec nfsv3spec;
335:
336: /*
337: * File attributes and setable attributes. These structures cover both
338: * NFS version 2 and the version 3 protocol. Note that the union is only
339: * used so that one pointer can refer to both variants. These structures
340: * go out on the wire and must be densely packed, so no quad data types
341: * are used. (all fields are longs or u_longs or structures of same)
342: * NB: You can't do sizeof(struct nfs_fattr), you must use the
343: * NFSX_FATTR(v3) macro.
344: */
345: struct nfs_fattr {
346: u_long fa_type;
347: u_long fa_mode;
348: u_long fa_nlink;
349: u_long fa_uid;
350: u_long fa_gid;
351: union {
352: struct {
353: u_long nfsv2fa_size;
354: u_long nfsv2fa_blocksize;
355: u_long nfsv2fa_rdev;
356: u_long nfsv2fa_blocks;
357: u_long nfsv2fa_fsid;
358: u_long nfsv2fa_fileid;
359: nfstime2 nfsv2fa_atime;
360: nfstime2 nfsv2fa_mtime;
361: nfstime2 nfsv2fa_ctime;
362: } fa_nfsv2;
363: struct {
364: nfsuint64 nfsv3fa_size;
365: nfsuint64 nfsv3fa_used;
366: nfsv3spec nfsv3fa_rdev;
367: nfsuint64 nfsv3fa_fsid;
368: nfsuint64 nfsv3fa_fileid;
369: nfstime3 nfsv3fa_atime;
370: nfstime3 nfsv3fa_mtime;
371: nfstime3 nfsv3fa_ctime;
372: } fa_nfsv3;
373: } fa_un;
374: };
375:
376: /* and some ugly defines for accessing union components */
377: #define fa2_size fa_un.fa_nfsv2.nfsv2fa_size
378: #define fa2_blocksize fa_un.fa_nfsv2.nfsv2fa_blocksize
379: #define fa2_rdev fa_un.fa_nfsv2.nfsv2fa_rdev
380: #define fa2_blocks fa_un.fa_nfsv2.nfsv2fa_blocks
381: #define fa2_fsid fa_un.fa_nfsv2.nfsv2fa_fsid
382: #define fa2_fileid fa_un.fa_nfsv2.nfsv2fa_fileid
383: #define fa2_atime fa_un.fa_nfsv2.nfsv2fa_atime
384: #define fa2_mtime fa_un.fa_nfsv2.nfsv2fa_mtime
385: #define fa2_ctime fa_un.fa_nfsv2.nfsv2fa_ctime
386: #define fa3_size fa_un.fa_nfsv3.nfsv3fa_size
387: #define fa3_used fa_un.fa_nfsv3.nfsv3fa_used
388: #define fa3_rdev fa_un.fa_nfsv3.nfsv3fa_rdev
389: #define fa3_fsid fa_un.fa_nfsv3.nfsv3fa_fsid
390: #define fa3_fileid fa_un.fa_nfsv3.nfsv3fa_fileid
391: #define fa3_atime fa_un.fa_nfsv3.nfsv3fa_atime
392: #define fa3_mtime fa_un.fa_nfsv3.nfsv3fa_mtime
393: #define fa3_ctime fa_un.fa_nfsv3.nfsv3fa_ctime
394:
395: struct nfsv2_sattr {
396: u_long sa_mode;
397: u_long sa_uid;
398: u_long sa_gid;
399: u_long sa_size;
400: nfstime2 sa_atime;
401: nfstime2 sa_mtime;
402: };
403:
404: /*
405: * NFS Version 3 sattr structure for the new node creation case.
406: */
407: struct nfsv3_sattr {
408: u_long sa_modetrue;
409: u_long sa_mode;
410: u_long sa_uidtrue;
411: u_long sa_uid;
412: u_long sa_gidtrue;
413: u_long sa_gid;
414: u_long sa_sizefalse;
415: u_long sa_atimetype;
416: u_long sa_mtimetype;
417: };
418:
419: struct nfs_statfs {
420: union {
421: struct {
422: u_long nfsv2sf_tsize;
423: u_long nfsv2sf_bsize;
424: u_long nfsv2sf_blocks;
425: u_long nfsv2sf_bfree;
426: u_long nfsv2sf_bavail;
427: } sf_nfsv2;
428: struct {
429: nfsuint64 nfsv3sf_tbytes;
430: nfsuint64 nfsv3sf_fbytes;
431: nfsuint64 nfsv3sf_abytes;
432: nfsuint64 nfsv3sf_tfiles;
433: nfsuint64 nfsv3sf_ffiles;
434: nfsuint64 nfsv3sf_afiles;
435: u_long nfsv3sf_invarsec;
436: } sf_nfsv3;
437: } sf_un;
438: };
439:
440: #define sf_tsize sf_un.sf_nfsv2.nfsv2sf_tsize
441: #define sf_bsize sf_un.sf_nfsv2.nfsv2sf_bsize
442: #define sf_blocks sf_un.sf_nfsv2.nfsv2sf_blocks
443: #define sf_bfree sf_un.sf_nfsv2.nfsv2sf_bfree
444: #define sf_bavail sf_un.sf_nfsv2.nfsv2sf_bavail
445: #define sf_tbytes sf_un.sf_nfsv3.nfsv3sf_tbytes
446: #define sf_fbytes sf_un.sf_nfsv3.nfsv3sf_fbytes
447: #define sf_abytes sf_un.sf_nfsv3.nfsv3sf_abytes
448: #define sf_tfiles sf_un.sf_nfsv3.nfsv3sf_tfiles
449: #define sf_ffiles sf_un.sf_nfsv3.nfsv3sf_ffiles
450: #define sf_afiles sf_un.sf_nfsv3.nfsv3sf_afiles
451: #define sf_invarsec sf_un.sf_nfsv3.nfsv3sf_invarsec
452:
453: struct nfsv3_fsinfo {
454: u_long fs_rtmax;
455: u_long fs_rtpref;
456: u_long fs_rtmult;
457: u_long fs_wtmax;
458: u_long fs_wtpref;
459: u_long fs_wtmult;
460: u_long fs_dtpref;
461: nfsuint64 fs_maxfilesize;
462: nfstime3 fs_timedelta;
463: u_long fs_properties;
464: };
465:
466: struct nfsv3_pathconf {
467: u_long pc_linkmax;
468: u_long pc_namemax;
469: u_long pc_notrunc;
470: u_long pc_chownrestricted;
471: u_long pc_caseinsensitive;
472: u_long pc_casepreserving;
473: };
474:
475: #endif
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.