2 * Copyright (c) 1994, 1995, 1996
3 * The Regents of the University of California. All rights reserved.
5 * This code is derived from software contributed to Berkeley by
6 * Rick Macklem at The University of Guelph.
8 * Redistribution and use in source and binary forms, with or without
9 * modification, are permitted provided that the following conditions
11 * 1. Redistributions of source code must retain the above copyright
12 * notice, this list of conditions and the following disclaimer.
13 * 2. Redistributions in binary form must reproduce the above copyright
14 * notice, this list of conditions and the following disclaimer in the
15 * documentation and/or other materials provided with the distribution.
16 * 3. All advertising materials mentioning features or use of this software
17 * must display the following acknowledgement:
18 * This product includes software developed by the University of
19 * California, Berkeley and its contributors.
20 * 4. Neither the name of the University nor the names of its contributors
21 * may be used to endorse or promote products derived from this software
22 * without specific prior written permission.
24 * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
25 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
26 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
27 * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
28 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
29 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
30 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
31 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
32 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
33 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
36 * @(#)nfsv2.h 7.11 (Berkeley) 9/30/92
40 * nfs definitions as per the version 2 specs
44 * Constants as defined in the Sun NFS Version 2 spec.
45 * "NFS: Network File System Protocol Specification" RFC1094
49 #define NFS_PROG 100003
51 #define NFS_MAXDGRAMDATA 8192
52 #define NFS_MAXDATA 32768
53 #define NFS_MAXPATHLEN 1024
54 #define NFS_MAXNAMLEN 255
56 #define NFS_MAXPKTHDR 404
57 #define NFS_MAXPACKET (NFS_MAXPKTHDR+NFS_MAXDATA)
58 #define NFS_MINPACKET 20
59 #define NFS_FABLKSIZE 512 /* Size in bytes of a block wrt fa_blocks */
61 /* Stat numbers for rpc returns */
64 #define NFSERR_NOENT 2
67 #define NFSERR_ACCES 13
68 #define NFSERR_EXIST 17
69 #define NFSERR_NODEV 19
70 #define NFSERR_NOTDIR 20
71 #define NFSERR_ISDIR 21
72 #define NFSERR_FBIG 27
73 #define NFSERR_NOSPC 28
74 #define NFSERR_ROFS 30
75 #define NFSERR_NAMETOL 63
76 #define NFSERR_NOTEMPTY 66
77 #define NFSERR_DQUOT 69
78 #define NFSERR_STALE 70
79 #define NFSERR_WFLUSH 99
81 /* Sizes in bytes of various nfs rpc components */
83 #define NFSX_UNSIGNED 4
84 #define NFSX_NFSFATTR 68
85 #define NFSX_NQFATTR 92
86 #define NFSX_NFSSATTR 32
87 #define NFSX_NQSATTR 44
89 #define NFSX_NFSSTATFS 20
90 #define NFSX_NQSTATFS 28
91 #define NFSX_FATTR(isnq) ((isnq) ? NFSX_NQFATTR : NFSX_NFSFATTR)
92 #define NFSX_SATTR(isnq) ((isnq) ? NFSX_NQSATTR : NFSX_NFSSATTR)
93 #define NFSX_STATFS(isnq) ((isnq) ? NFSX_NQSTATFS : NFSX_NFSSTATFS)
95 /* nfs rpc procedure numbers */
96 #define NFSPROC_NULL 0
97 #define NFSPROC_GETATTR 1
98 #define NFSPROC_SETATTR 2
99 #define NFSPROC_NOOP 3
100 #define NFSPROC_ROOT NFSPROC_NOOP /* Obsolete */
101 #define NFSPROC_LOOKUP 4
102 #define NFSPROC_READLINK 5
103 #define NFSPROC_READ 6
104 #define NFSPROC_WRITECACHE NFSPROC_NOOP /* Obsolete */
105 #define NFSPROC_WRITE 8
106 #define NFSPROC_CREATE 9
107 #define NFSPROC_REMOVE 10
108 #define NFSPROC_RENAME 11
109 #define NFSPROC_LINK 12
110 #define NFSPROC_SYMLINK 13
111 #define NFSPROC_MKDIR 14
112 #define NFSPROC_RMDIR 15
113 #define NFSPROC_READDIR 16
114 #define NFSPROC_STATFS 17
117 #define NQNFSPROC_READDIRLOOK 18
118 #define NQNFSPROC_GETLEASE 19
119 #define NQNFSPROC_VACATED 20
120 #define NQNFSPROC_EVICTED 21
121 #define NQNFSPROC_ACCESS 22
123 #define NFS_NPROCS 23
124 /* Conversion macros */
125 extern int vttoif_tab
[];
126 #define vtonfs_mode(t,m) \
127 txdr_unsigned(((t) == VFIFO) ? MAKEIMODE(VCHR, (m)) : \
129 #define nfstov_mode(a) (fxdr_unsigned(u_short, (a))&07777)
130 #define vtonfs_type(a) txdr_unsigned(nfs_type[((int32_t)(a))])
131 #define nfstov_type(a) ntov_type[fxdr_unsigned(u_int32_t,(a))&0x7]
135 NFNON
=0, NFREG
=1, NFDIR
=2, NFBLK
=3, NFCHR
=4, NFLNK
=5
138 /* Structs for common parts of the rpc's */
150 * File attributes and setable attributes. These structures cover both
151 * NFS version 2 and the NQNFS protocol. Note that the union is only
152 * used to that one pointer can refer to both variants. These structures
153 * go out on the wire and must be densely packed, so no quad data types
154 * are used. (all fields are int32_t or u_int32_t's or structures of same)
155 * NB: You can't do sizeof(struct nfsv2_fattr), you must use the
156 * NFSX_FATTR(isnq) macro.
166 u_int32_t nfsfa_size
;
167 u_int32_t nfsfa_blocksize
;
168 u_int32_t nfsfa_rdev
;
169 u_int32_t nfsfa_blocks
;
170 u_int32_t nfsfa_fsid
;
171 u_int32_t nfsfa_fileid
;
172 struct nfsv2_time nfsfa_atime
;
173 struct nfsv2_time nfsfa_mtime
;
174 struct nfsv2_time nfsfa_ctime
;
178 u_int32_t nqfa_qsize
[2];
180 u_int32_t nqfa_blocksize
;
183 u_int32_t nqfa_qbytes
[2];
186 u_int32_t nqfa_fileid
;
187 struct nqnfs_time nqfa_atime
;
188 struct nqnfs_time nqfa_mtime
;
189 struct nqnfs_time nqfa_ctime
;
190 u_int32_t nqfa_flags
;
193 u_int32_t nqfa_qfilerev
[2];
199 /* and some ugly defines for accessing union components */
200 #define fa_nfssize fa_un.fa_nfsv2.nfsfa_size
201 #define fa_nfsblocksize fa_un.fa_nfsv2.nfsfa_blocksize
202 #define fa_nfsrdev fa_un.fa_nfsv2.nfsfa_rdev
203 #define fa_nfsblocks fa_un.fa_nfsv2.nfsfa_blocks
204 #define fa_nfsfsid fa_un.fa_nfsv2.nfsfa_fsid
205 #define fa_nfsfileid fa_un.fa_nfsv2.nfsfa_fileid
206 #define fa_nfsatime fa_un.fa_nfsv2.nfsfa_atime
207 #define fa_nfsmtime fa_un.fa_nfsv2.nfsfa_mtime
208 #define fa_nfsctime fa_un.fa_nfsv2.nfsfa_ctime
209 #define fa_nqsize fa_un.fa_nqnfs.nqfa_size
210 #define fa_nqblocksize fa_un.fa_nqnfs.nqfa_blocksize
211 #define fa_nqrdev fa_un.fa_nqnfs.nqfa_rdev
212 #define fa_nqbytes fa_un.fa_nqnfs.nqfa_bytes
213 #define fa_nqfsid fa_un.fa_nqnfs.nqfa_fsid
214 #define fa_nqfileid fa_un.fa_nqnfs.nqfa_fileid
215 #define fa_nqatime fa_un.fa_nqnfs.nqfa_atime
216 #define fa_nqmtime fa_un.fa_nqnfs.nqfa_mtime
217 #define fa_nqctime fa_un.fa_nqnfs.nqfa_ctime
218 #define fa_nqflags fa_un.fa_nqnfs.nqfa_flags
219 #define fa_nqgen fa_un.fa_nqnfs.nqfa_gen
220 #define fa_nqfilerev fa_un.fa_nqnfs.nqfa_filerev
228 u_int32_t nfssa_size
;
229 struct nfsv2_time nfssa_atime
;
230 struct nfsv2_time nfssa_mtime
;
234 u_int32_t nqsa_qsize
[2];
236 struct nqnfs_time nqsa_atime
;
237 struct nqnfs_time nqsa_mtime
;
238 u_int32_t nqsa_flags
;
244 /* and some ugly defines for accessing the unions */
245 #define sa_nfssize sa_un.sa_nfsv2.nfssa_size
246 #define sa_nfsatime sa_un.sa_nfsv2.nfssa_atime
247 #define sa_nfsmtime sa_un.sa_nfsv2.nfssa_mtime
248 #define sa_nqsize sa_un.sa_nqnfs.nqsa_size
249 #define sa_nqatime sa_un.sa_nqnfs.nqsa_atime
250 #define sa_nqmtime sa_un.sa_nqnfs.nqsa_mtime
251 #define sa_nqflags sa_un.sa_nqnfs.nqsa_flags
252 #define sa_nqrdev sa_un.sa_nqnfs.nqsa_rdev
254 struct nfsv2_statfs
{
260 u_int32_t sf_files
; /* Nqnfs only */
261 u_int32_t sf_ffree
; /* ditto */