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