]>
Commit | Line | Data |
---|---|---|
1 | /* | |
2 | * Copyright (c) 2000-2002 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, 1995 | |
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 | * @(#)nfs.h 8.4 (Berkeley) 5/1/95 | |
59 | * FreeBSD-Id: nfs.h,v 1.32 1997/10/12 20:25:38 phk Exp $ | |
60 | */ | |
61 | ||
62 | #ifndef _NFS_NFS_H_ | |
63 | #define _NFS_NFS_H_ | |
64 | ||
65 | #include <sys/appleapiopts.h> | |
66 | ||
67 | #ifdef __APPLE_API_PRIVATE | |
68 | /* | |
69 | * Tunable constants for nfs | |
70 | */ | |
71 | ||
72 | #define NFS_MAXIOVEC 34 | |
73 | #define NFS_TICKINTVL 5 /* Desired time for a tick (msec) */ | |
74 | #define NFS_HZ (hz / nfs_ticks) /* Ticks/sec */ | |
75 | #define NFS_TIMEO (1 * NFS_HZ) /* Default timeout = 1 second */ | |
76 | #define NFS_MINTIMEO (1 * NFS_HZ) /* Min timeout to use */ | |
77 | #define NFS_MAXTIMEO (60 * NFS_HZ) /* Max timeout to backoff to */ | |
78 | #define NFS_MINIDEMTIMEO (5 * NFS_HZ) /* Min timeout for non-idempotent ops*/ | |
79 | #define NFS_MAXREXMIT 100 /* Stop counting after this many */ | |
80 | #define NFS_MAXWINDOW 1024 /* Max number of outstanding requests */ | |
81 | #define NFS_RETRANS 10 /* Num of retrans for soft mounts */ | |
82 | #define NFS_MAXGRPS 16 /* Max. size of groups list */ | |
83 | #ifndef NFS_MINATTRTIMO | |
84 | #define NFS_MINATTRTIMO 5 /* Attribute cache timeout in sec */ | |
85 | #endif | |
86 | #ifndef NFS_MAXATTRTIMO | |
87 | #define NFS_MAXATTRTIMO 60 | |
88 | #endif | |
89 | #define NFS_WSIZE 8192 /* Def. write data size <= 8192 */ | |
90 | #define NFS_RSIZE 8192 /* Def. read data size <= 8192 */ | |
91 | #define NFS_READDIRSIZE 8192 /* Def. readdir size */ | |
92 | #define NFS_DEFRAHEAD 1 /* Def. read ahead # blocks */ | |
93 | #define NFS_MAXRAHEAD 4 /* Max. read ahead # blocks */ | |
94 | #define NFS_MAXUIDHASH 64 /* Max. # of hashed uid entries/mp */ | |
95 | #define NFS_MAXASYNCDAEMON 20 /* Max. number async_daemons runnable */ | |
96 | #define NFS_MAXGATHERDELAY 100 /* Max. write gather delay (msec) */ | |
97 | #ifndef NFS_GATHERDELAY | |
98 | #define NFS_GATHERDELAY 10 /* Default write gather delay (msec) */ | |
99 | #endif | |
100 | #define NFS_DIRBLKSIZ 4096 /* Must be a multiple of DIRBLKSIZ */ | |
101 | ||
102 | /* | |
103 | * Oddballs | |
104 | */ | |
105 | #define NMOD(a) ((a) % nfs_asyncdaemons) | |
106 | #define NFS_CMPFH(n, f, s) \ | |
107 | ((n)->n_fhsize == (s) && !bcmp((caddr_t)(n)->n_fhp, (caddr_t)(f), (s))) | |
108 | #define NFS_ISV3(v) (VFSTONFS((v)->v_mount)->nm_flag & NFSMNT_NFSV3) | |
109 | #define NFS_SRVMAXDATA(n) \ | |
110 | (((n)->nd_flag & ND_NFSV3) ? (((n)->nd_nam2) ? \ | |
111 | NFS_MAXDGRAMDATA : NFS_MAXDATA) : NFS_V2MAXDATA) | |
112 | ||
113 | /* | |
114 | * XXX | |
115 | * The B_INVAFTERWRITE flag should be set to whatever is required by the | |
116 | * buffer cache code to say "Invalidate the block after it is written back". | |
117 | */ | |
118 | #ifdef __FreeBSD__ | |
119 | #define B_INVAFTERWRITE B_NOCACHE | |
120 | #else | |
121 | #define B_INVAFTERWRITE B_INVAL | |
122 | #endif | |
123 | ||
124 | /* | |
125 | * The IO_METASYNC flag should be implemented for local file systems. | |
126 | * (Until then, it is nothin at all.) | |
127 | */ | |
128 | #ifndef IO_METASYNC | |
129 | #define IO_METASYNC 0 | |
130 | #endif | |
131 | ||
132 | /* | |
133 | * Set the attribute timeout based on how recently the file has been modified. | |
134 | */ | |
135 | #define NFS_ATTRTIMEO(np) \ | |
136 | ((((np)->n_flag & NMODIFIED) || \ | |
137 | (time.tv_sec - (np)->n_mtime) / 10 < NFS_MINATTRTIMO) ? NFS_MINATTRTIMO : \ | |
138 | ((time.tv_sec - (np)->n_mtime) / 10 > NFS_MAXATTRTIMO ? NFS_MAXATTRTIMO : \ | |
139 | (time.tv_sec - (np)->n_mtime) / 10)) | |
140 | ||
141 | /* | |
142 | * Expected allocation sizes for major data structures. If the actual size | |
143 | * of the structure exceeds these sizes, then malloc() will be allocating | |
144 | * almost twice the memory required. This is used in nfs_init() to warn | |
145 | * the sysadmin that the size of a structure should be reduced. | |
146 | * (These sizes are always a power of 2. If the kernel malloc() changes | |
147 | * to one that does not allocate space in powers of 2 size, then this all | |
148 | * becomes bunk!). | |
149 | * Note that some of these structures come out of there own nfs zones. | |
150 | */ | |
151 | #define NFS_NODEALLOC 512 | |
152 | #define NFS_MNTALLOC 512 | |
153 | #define NFS_SVCALLOC 256 | |
154 | #define NFS_UIDALLOC 128 | |
155 | ||
156 | /* | |
157 | * Arguments to mount NFS | |
158 | */ | |
159 | #define NFS_ARGSVERSION 3 /* change when nfs_args changes */ | |
160 | struct nfs_args { | |
161 | int version; /* args structure version number */ | |
162 | struct sockaddr *addr; /* file server address */ | |
163 | int addrlen; /* length of address */ | |
164 | int sotype; /* Socket type */ | |
165 | int proto; /* and Protocol */ | |
166 | u_char *fh; /* File handle to be mounted */ | |
167 | int fhsize; /* Size, in bytes, of fh */ | |
168 | int flags; /* flags */ | |
169 | int wsize; /* write size in bytes */ | |
170 | int rsize; /* read size in bytes */ | |
171 | int readdirsize; /* readdir size in bytes */ | |
172 | int timeo; /* initial timeout in .1 secs */ | |
173 | int retrans; /* times to retry send */ | |
174 | int maxgrouplist; /* Max. size of group list */ | |
175 | int readahead; /* # of blocks to readahead */ | |
176 | int leaseterm; /* Term (sec) of lease */ | |
177 | int deadthresh; /* Retrans threshold */ | |
178 | char *hostname; /* server's name */ | |
179 | }; | |
180 | ||
181 | /* | |
182 | * NFS mount option flags | |
183 | */ | |
184 | #define NFSMNT_SOFT 0x00000001 /* soft mount (hard is default) */ | |
185 | #define NFSMNT_WSIZE 0x00000002 /* set write size */ | |
186 | #define NFSMNT_RSIZE 0x00000004 /* set read size */ | |
187 | #define NFSMNT_TIMEO 0x00000008 /* set initial timeout */ | |
188 | #define NFSMNT_RETRANS 0x00000010 /* set number of request retries */ | |
189 | #define NFSMNT_MAXGRPS 0x00000020 /* set maximum grouplist size */ | |
190 | #define NFSMNT_INT 0x00000040 /* allow interrupts on hard mount */ | |
191 | #define NFSMNT_NOCONN 0x00000080 /* Don't Connect the socket */ | |
192 | #define NFSMNT_NQNFS 0x00000100 /* Use Nqnfs protocol */ | |
193 | #define NFSMNT_NFSV3 0x00000200 /* Use NFS Version 3 protocol */ | |
194 | #define NFSMNT_KERB 0x00000400 /* Use Kerberos authentication */ | |
195 | #define NFSMNT_DUMBTIMR 0x00000800 /* Don't estimate rtt dynamically */ | |
196 | #define NFSMNT_LEASETERM 0x00001000 /* set lease term (nqnfs) */ | |
197 | #define NFSMNT_READAHEAD 0x00002000 /* set read ahead */ | |
198 | #define NFSMNT_DEADTHRESH 0x00004000 /* set dead server retry thresh */ | |
199 | #define NFSMNT_RESVPORT 0x00008000 /* Allocate a reserved port */ | |
200 | #define NFSMNT_RDIRPLUS 0x00010000 /* Use Readdirplus for V3 */ | |
201 | #define NFSMNT_READDIRSIZE 0x00020000 /* Set readdir size */ | |
202 | #define NFSMNT_INTERNAL 0xfffc0000 /* Bits set internally */ | |
203 | #define NFSMNT_HASWRITEVERF 0x00040000 /* Has write verifier for V3 */ | |
204 | #define NFSMNT_GOTPATHCONF 0x00080000 /* Got the V3 pathconf info */ | |
205 | #define NFSMNT_GOTFSINFO 0x00100000 /* Got the V3 fsinfo */ | |
206 | #define NFSMNT_MNTD 0x00200000 /* Mnt server for mnt point */ | |
207 | #define NFSMNT_DISMINPROG 0x00400000 /* Dismount in progress */ | |
208 | #define NFSMNT_DISMNT 0x00800000 /* Dismounted */ | |
209 | #define NFSMNT_SNDLOCK 0x01000000 /* Send socket lock */ | |
210 | #define NFSMNT_WANTSND 0x02000000 /* Want above */ | |
211 | #define NFSMNT_RCVLOCK 0x04000000 /* Rcv socket lock */ | |
212 | #define NFSMNT_WANTRCV 0x08000000 /* Want above */ | |
213 | #define NFSMNT_WAITAUTH 0x10000000 /* Wait for authentication */ | |
214 | #define NFSMNT_HASAUTH 0x20000000 /* Has authenticator */ | |
215 | #define NFSMNT_WANTAUTH 0x40000000 /* Wants an authenticator */ | |
216 | #define NFSMNT_AUTHERR 0x80000000 /* Authentication error */ | |
217 | ||
218 | /* | |
219 | * Structures for the nfssvc(2) syscall. Not that anyone but nfsd and mount_nfs | |
220 | * should ever try and use it. | |
221 | */ | |
222 | struct nfsd_args { | |
223 | int sock; /* Socket to serve */ | |
224 | caddr_t name; /* Client addr for connection based sockets */ | |
225 | int namelen; /* Length of name */ | |
226 | }; | |
227 | ||
228 | struct nfsd_srvargs { | |
229 | struct nfsd *nsd_nfsd; /* Pointer to in kernel nfsd struct */ | |
230 | uid_t nsd_uid; /* Effective uid mapped to cred */ | |
231 | u_long nsd_haddr; /* Ip address of client */ | |
232 | struct ucred nsd_cr; /* Cred. uid maps to */ | |
233 | int nsd_authlen; /* Length of auth string (ret) */ | |
234 | u_char *nsd_authstr; /* Auth string (ret) */ | |
235 | int nsd_verflen; /* and the verfier */ | |
236 | u_char *nsd_verfstr; | |
237 | struct timeval nsd_timestamp; /* timestamp from verifier */ | |
238 | u_long nsd_ttl; /* credential ttl (sec) */ | |
239 | NFSKERBKEY_T nsd_key; /* Session key */ | |
240 | }; | |
241 | ||
242 | struct nfsd_cargs { | |
243 | char *ncd_dirp; /* Mount dir path */ | |
244 | uid_t ncd_authuid; /* Effective uid */ | |
245 | int ncd_authtype; /* Type of authenticator */ | |
246 | int ncd_authlen; /* Length of authenticator string */ | |
247 | u_char *ncd_authstr; /* Authenticator string */ | |
248 | int ncd_verflen; /* and the verifier */ | |
249 | u_char *ncd_verfstr; | |
250 | NFSKERBKEY_T ncd_key; /* Session key */ | |
251 | }; | |
252 | ||
253 | /* | |
254 | * XXX to allow amd to include nfs.h without nfsproto.h | |
255 | */ | |
256 | #ifdef NFS_NPROCS | |
257 | /* | |
258 | * Stats structure | |
259 | */ | |
260 | struct nfsstats { | |
261 | int attrcache_hits; | |
262 | int attrcache_misses; | |
263 | int lookupcache_hits; | |
264 | int lookupcache_misses; | |
265 | int direofcache_hits; | |
266 | int direofcache_misses; | |
267 | int biocache_reads; | |
268 | int read_bios; | |
269 | int read_physios; | |
270 | int biocache_writes; | |
271 | int write_bios; | |
272 | int write_physios; | |
273 | int biocache_readlinks; | |
274 | int readlink_bios; | |
275 | int biocache_readdirs; | |
276 | int readdir_bios; | |
277 | int rpccnt[NFS_NPROCS]; | |
278 | int rpcretries; | |
279 | int srvrpccnt[NFS_NPROCS]; | |
280 | int srvrpc_errs; | |
281 | int srv_errs; | |
282 | int rpcrequests; | |
283 | int rpctimeouts; | |
284 | int rpcunexpected; | |
285 | int rpcinvalid; | |
286 | int srvcache_inproghits; | |
287 | int srvcache_idemdonehits; | |
288 | int srvcache_nonidemdonehits; | |
289 | int srvcache_misses; | |
290 | int srvnqnfs_leases; | |
291 | int srvnqnfs_maxleases; | |
292 | int srvnqnfs_getleases; | |
293 | int srvvop_writes; | |
294 | int pageins; | |
295 | int pageouts; | |
296 | }; | |
297 | #endif | |
298 | ||
299 | /* | |
300 | * Flags for nfssvc() system call. | |
301 | */ | |
302 | #define NFSSVC_BIOD 0x002 | |
303 | #define NFSSVC_NFSD 0x004 | |
304 | #define NFSSVC_ADDSOCK 0x008 | |
305 | #define NFSSVC_AUTHIN 0x010 | |
306 | #define NFSSVC_GOTAUTH 0x040 | |
307 | #define NFSSVC_AUTHINFAIL 0x080 | |
308 | #define NFSSVC_MNTD 0x100 | |
309 | ||
310 | /* | |
311 | * fs.nfs sysctl(3) identifiers | |
312 | */ | |
313 | #define NFS_NFSSTATS 1 /* struct: struct nfsstats */ | |
314 | #define NFS_NFSPRIVPORT 2 /* int: prohibit nfs to resvports */ | |
315 | ||
316 | #define FS_NFS_NAMES { \ | |
317 | { 0, 0 }, \ | |
318 | { "nfsstats", CTLTYPE_STRUCT }, \ | |
319 | { "nfsprivport", CTLTYPE_INT }, \ | |
320 | } | |
321 | ||
322 | #ifndef NFS_MUIDHASHSIZ | |
323 | #define NFS_MUIDHASHSIZ 63 /* Tune the size of nfsmount with this */ | |
324 | #endif | |
325 | #ifndef NFS_WDELAYHASHSIZ | |
326 | #define NFS_WDELAYHASHSIZ 16 /* and with this */ | |
327 | #endif | |
328 | ||
329 | /* | |
330 | * The set of signals the interrupt an I/O in progress for NFSMNT_INT mounts. | |
331 | * What should be in this set is open to debate, but I believe that since | |
332 | * I/O system calls on ufs are never interrupted by signals the set should | |
333 | * be minimal. My reasoning is that many current programs that use signals | |
334 | * such as SIGALRM will not expect file I/O system calls to be interrupted | |
335 | * by them and break. | |
336 | */ | |
337 | #ifdef KERNEL | |
338 | ||
339 | #ifdef MALLOC_DECLARE | |
340 | MALLOC_DECLARE(M_NFSREQ); | |
341 | MALLOC_DECLARE(M_NFSMNT); | |
342 | MALLOC_DECLARE(M_NFSDIROFF); | |
343 | MALLOC_DECLARE(M_NFSRVDESC); | |
344 | MALLOC_DECLARE(M_NFSUID); | |
345 | MALLOC_DECLARE(M_NQLEASE); | |
346 | MALLOC_DECLARE(M_NFSD); | |
347 | MALLOC_DECLARE(M_NFSBIGFH); | |
348 | #endif | |
349 | ||
350 | struct uio; struct buf; struct vattr; struct nameidata; /* XXX */ | |
351 | ||
352 | #define NFSINT_SIGMASK (sigmask(SIGINT)|sigmask(SIGTERM)|sigmask(SIGKILL)| \ | |
353 | sigmask(SIGHUP)|sigmask(SIGQUIT)) | |
354 | ||
355 | /* | |
356 | * Socket errors ignored for connectionless sockets?? | |
357 | * For now, ignore them all | |
358 | */ | |
359 | #define NFSIGNORE_SOERROR(s, e) \ | |
360 | ((e) != EINTR && (e) != ERESTART && (e) != EWOULDBLOCK && \ | |
361 | ((s) & PR_CONNREQUIRED) == 0) | |
362 | ||
363 | /* | |
364 | * Nfs outstanding request list element | |
365 | */ | |
366 | struct nfsreq { | |
367 | TAILQ_ENTRY(nfsreq) r_chain; | |
368 | struct mbuf *r_mreq; | |
369 | struct mbuf *r_mrep; | |
370 | struct mbuf *r_md; | |
371 | caddr_t r_dpos; | |
372 | struct nfsmount *r_nmp; | |
373 | struct vnode *r_vp; | |
374 | u_long r_xid; | |
375 | int r_flags; /* flags on request, see below */ | |
376 | int r_retry; /* max retransmission count */ | |
377 | int r_rexmit; /* current retrans count */ | |
378 | int r_timer; /* tick counter on reply */ | |
379 | u_int32_t r_procnum; /* NFS procedure number */ | |
380 | int r_rtt; /* RTT for rpc */ | |
381 | struct proc *r_procp; /* Proc that did I/O system call */ | |
382 | }; | |
383 | ||
384 | /* | |
385 | * Queue head for nfsreq's | |
386 | */ | |
387 | extern TAILQ_HEAD(nfs_reqq, nfsreq) nfs_reqq; | |
388 | ||
389 | /* Flag values for r_flags */ | |
390 | #define R_TIMING 0x01 /* timing request (in mntp) */ | |
391 | #define R_SENT 0x02 /* request has been sent */ | |
392 | #define R_SOFTTERM 0x04 /* soft mnt, too many retries */ | |
393 | #define R_INTR 0x08 /* intr mnt, signal pending */ | |
394 | #define R_SOCKERR 0x10 /* Fatal error on socket */ | |
395 | #define R_TPRINTFMSG 0x20 /* Did a tprintf msg. */ | |
396 | #define R_MUSTRESEND 0x40 /* Must resend request */ | |
397 | #define R_GETONEREP 0x80 /* Probe for one reply only */ | |
398 | ||
399 | /* | |
400 | * A list of nfssvc_sock structures is maintained with all the sockets | |
401 | * that require service by the nfsd. | |
402 | * The nfsuid structs hang off of the nfssvc_sock structs in both lru | |
403 | * and uid hash lists. | |
404 | */ | |
405 | #ifndef NFS_UIDHASHSIZ | |
406 | #define NFS_UIDHASHSIZ 29 /* Tune the size of nfssvc_sock with this */ | |
407 | #endif | |
408 | #define NUIDHASH(sock, uid) \ | |
409 | (&(sock)->ns_uidhashtbl[(uid) % NFS_UIDHASHSIZ]) | |
410 | #define NWDELAYHASH(sock, f) \ | |
411 | (&(sock)->ns_wdelayhashtbl[(*((u_long *)(f))) % NFS_WDELAYHASHSIZ]) | |
412 | #define NMUIDHASH(nmp, uid) \ | |
413 | (&(nmp)->nm_uidhashtbl[(uid) % NFS_MUIDHASHSIZ]) | |
414 | #define NFSNOHASH(fhsum) \ | |
415 | (&nfsnodehashtbl[(fhsum) & nfsnodehash]) | |
416 | ||
417 | /* | |
418 | * Network address hash list element | |
419 | */ | |
420 | union nethostaddr { | |
421 | u_long had_inetaddr; | |
422 | struct mbuf *had_nam; | |
423 | }; | |
424 | ||
425 | struct nfsuid { | |
426 | TAILQ_ENTRY(nfsuid) nu_lru; /* LRU chain */ | |
427 | LIST_ENTRY(nfsuid) nu_hash; /* Hash list */ | |
428 | int nu_flag; /* Flags */ | |
429 | union nethostaddr nu_haddr; /* Host addr. for dgram sockets */ | |
430 | struct ucred nu_cr; /* Cred uid mapped to */ | |
431 | int nu_expire; /* Expiry time (sec) */ | |
432 | struct timeval nu_timestamp; /* Kerb. timestamp */ | |
433 | u_long nu_nickname; /* Nickname on server */ | |
434 | NFSKERBKEY_T nu_key; /* and session key */ | |
435 | }; | |
436 | ||
437 | #define nu_inetaddr nu_haddr.had_inetaddr | |
438 | #define nu_nam nu_haddr.had_nam | |
439 | /* Bits for nu_flag */ | |
440 | #define NU_INETADDR 0x1 | |
441 | #define NU_NAM 0x2 | |
442 | #define NU_NETFAM(u) (((u)->nu_flag & NU_INETADDR) ? AF_INET : AF_ISO) | |
443 | ||
444 | #ifdef notyet | |
445 | /* XXX CSM 12/2/97 When/if we merge queue.h */ | |
446 | struct nfsrv_rec { | |
447 | STAILQ_ENTRY(nfsrv_rec) nr_link; | |
448 | struct sockaddr *nr_address; | |
449 | struct mbuf *nr_packet; | |
450 | }; | |
451 | #endif | |
452 | ||
453 | struct nfssvc_sock { | |
454 | TAILQ_ENTRY(nfssvc_sock) ns_chain; /* List of all nfssvc_sock's */ | |
455 | TAILQ_HEAD(, nfsuid) ns_uidlruhead; | |
456 | struct file *ns_fp; | |
457 | struct socket *ns_so; | |
458 | struct mbuf *ns_nam; | |
459 | struct mbuf *ns_raw; | |
460 | struct mbuf *ns_rawend; | |
461 | struct mbuf *ns_rec; | |
462 | struct mbuf *ns_recend; | |
463 | struct mbuf *ns_frag; | |
464 | int ns_flag; | |
465 | int ns_solock; | |
466 | int ns_cc; | |
467 | int ns_reclen; | |
468 | int ns_numuids; | |
469 | u_long ns_sref; | |
470 | LIST_HEAD(, nfsrv_descript) ns_tq; /* Write gather lists */ | |
471 | LIST_HEAD(, nfsuid) ns_uidhashtbl[NFS_UIDHASHSIZ]; | |
472 | LIST_HEAD(nfsrvw_delayhash, nfsrv_descript) ns_wdelayhashtbl[NFS_WDELAYHASHSIZ]; | |
473 | }; | |
474 | ||
475 | /* Bits for "ns_flag" */ | |
476 | #define SLP_VALID 0x01 | |
477 | #define SLP_DOREC 0x02 | |
478 | #define SLP_NEEDQ 0x04 | |
479 | #define SLP_DISCONN 0x08 | |
480 | #define SLP_GETSTREAM 0x10 | |
481 | #define SLP_LASTFRAG 0x20 | |
482 | #define SLP_ALLFLAGS 0xff | |
483 | ||
484 | extern TAILQ_HEAD(nfssvc_sockhead, nfssvc_sock) nfssvc_sockhead; | |
485 | extern int nfssvc_sockhead_flag; | |
486 | #define SLP_INIT 0x01 | |
487 | #define SLP_WANTINIT 0x02 | |
488 | ||
489 | /* | |
490 | * One of these structures is allocated for each nfsd. | |
491 | */ | |
492 | struct nfsd { | |
493 | TAILQ_ENTRY(nfsd) nfsd_chain; /* List of all nfsd's */ | |
494 | int nfsd_flag; /* NFSD_ flags */ | |
495 | struct nfssvc_sock *nfsd_slp; /* Current socket */ | |
496 | int nfsd_authlen; /* Authenticator len */ | |
497 | u_char nfsd_authstr[RPCAUTH_MAXSIZ]; /* Authenticator data */ | |
498 | int nfsd_verflen; /* and the Verifier */ | |
499 | u_char nfsd_verfstr[RPCVERF_MAXSIZ]; | |
500 | struct proc *nfsd_procp; /* Proc ptr */ | |
501 | struct nfsrv_descript *nfsd_nd; /* Associated nfsrv_descript */ | |
502 | }; | |
503 | ||
504 | /* Bits for "nfsd_flag" */ | |
505 | #define NFSD_WAITING 0x01 | |
506 | #define NFSD_REQINPROG 0x02 | |
507 | #define NFSD_NEEDAUTH 0x04 | |
508 | #define NFSD_AUTHFAIL 0x08 | |
509 | ||
510 | /* | |
511 | * This structure is used by the server for describing each request. | |
512 | * Some fields are used only when write request gathering is performed. | |
513 | */ | |
514 | struct nfsrv_descript { | |
515 | u_quad_t nd_time; /* Write deadline (usec) */ | |
516 | off_t nd_off; /* Start byte offset */ | |
517 | off_t nd_eoff; /* and end byte offset */ | |
518 | LIST_ENTRY(nfsrv_descript) nd_hash; /* Hash list */ | |
519 | LIST_ENTRY(nfsrv_descript) nd_tq; /* and timer list */ | |
520 | LIST_HEAD(,nfsrv_descript) nd_coalesce; /* coalesced writes */ | |
521 | struct mbuf *nd_mrep; /* Request mbuf list */ | |
522 | struct mbuf *nd_md; /* Current dissect mbuf */ | |
523 | struct mbuf *nd_mreq; /* Reply mbuf list */ | |
524 | struct mbuf *nd_nam; /* and socket addr */ | |
525 | struct mbuf *nd_nam2; /* return socket addr */ | |
526 | caddr_t nd_dpos; /* Current dissect pos */ | |
527 | u_int32_t nd_procnum; /* RPC # */ | |
528 | int nd_stable; /* storage type */ | |
529 | int nd_flag; /* nd_flag */ | |
530 | int nd_len; /* Length of this write */ | |
531 | int nd_repstat; /* Reply status */ | |
532 | u_long nd_retxid; /* Reply xid */ | |
533 | u_long nd_duration; /* Lease duration */ | |
534 | struct timeval nd_starttime; /* Time RPC initiated */ | |
535 | fhandle_t nd_fh; /* File handle */ | |
536 | struct ucred nd_cr; /* Credentials */ | |
537 | }; | |
538 | ||
539 | /* Bits for "nd_flag" */ | |
540 | #define ND_READ LEASE_READ | |
541 | #define ND_WRITE LEASE_WRITE | |
542 | #define ND_CHECK 0x04 | |
543 | #define ND_LEASE (ND_READ | ND_WRITE | ND_CHECK) | |
544 | #define ND_NFSV3 0x08 | |
545 | #define ND_NQNFS 0x10 | |
546 | #define ND_KERBNICK 0x20 | |
547 | #define ND_KERBFULL 0x40 | |
548 | #define ND_KERBAUTH (ND_KERBNICK | ND_KERBFULL) | |
549 | ||
550 | extern TAILQ_HEAD(nfsd_head, nfsd) nfsd_head; | |
551 | extern int nfsd_head_flag; | |
552 | #define NFSD_CHECKSLP 0x01 | |
553 | ||
554 | /* | |
555 | * These macros compare nfsrv_descript structures. | |
556 | */ | |
557 | #define NFSW_CONTIG(o, n) \ | |
558 | ((o)->nd_eoff >= (n)->nd_off && \ | |
559 | !bcmp((caddr_t)&(o)->nd_fh, (caddr_t)&(n)->nd_fh, NFSX_V3FH)) | |
560 | ||
561 | #define NFSW_SAMECRED(o, n) \ | |
562 | (((o)->nd_flag & ND_KERBAUTH) == ((n)->nd_flag & ND_KERBAUTH) && \ | |
563 | !bcmp((caddr_t)&(o)->nd_cr, (caddr_t)&(n)->nd_cr, \ | |
564 | sizeof (struct ucred))) | |
565 | ||
566 | /* | |
567 | * Defines for WebNFS | |
568 | */ | |
569 | ||
570 | #define WEBNFS_ESC_CHAR '%' | |
571 | #define WEBNFS_SPECCHAR_START 0x80 | |
572 | ||
573 | #define WEBNFS_NATIVE_CHAR 0x80 | |
574 | /* | |
575 | * .. | |
576 | * Possibly more here in the future. | |
577 | */ | |
578 | ||
579 | /* | |
580 | * Macro for converting escape characters in WebNFS pathnames. | |
581 | * Should really be in libkern. | |
582 | */ | |
583 | ||
584 | #define HEXTOC(c) \ | |
585 | ((c) >= 'a' ? ((c) - ('a' - 10)) : \ | |
586 | ((c) >= 'A' ? ((c) - ('A' - 10)) : ((c) - '0'))) | |
587 | #define HEXSTRTOI(p) \ | |
588 | ((HEXTOC(p[0]) << 4) + HEXTOC(p[1])) | |
589 | ||
590 | #define NFSDIAG 0 | |
591 | #if NFSDIAG | |
592 | ||
593 | extern int nfs_debug; | |
594 | #define NFS_DEBUG_ASYNCIO 1 /* asynchronous i/o */ | |
595 | #define NFS_DEBUG_WG 2 /* server write gathering */ | |
596 | #define NFS_DEBUG_RC 4 /* server request caching */ | |
597 | #define NFS_DEBUG_SILLY 8 /* nfs_sillyrename (.nfsXXX aka turd files) */ | |
598 | #define NFS_DEBUG_DUP 16 /* debug duplicate requests */ | |
599 | #define NFS_DEBUG_ATTR 32 | |
600 | ||
601 | #define NFS_DPF(cat, args) \ | |
602 | do { \ | |
603 | if (nfs_debug & NFS_DEBUG_##cat) kprintf args; \ | |
604 | } while (0) | |
605 | ||
606 | #else | |
607 | ||
608 | #define NFS_DPF(cat, args) | |
609 | ||
610 | #endif /* NFSDIAG */ | |
611 | ||
612 | int nfs_init __P((struct vfsconf *vfsp)); | |
613 | int nfs_reply __P((struct nfsreq *)); | |
614 | int nfs_getreq __P((struct nfsrv_descript *,struct nfsd *,int)); | |
615 | int nfs_send __P((struct socket *, struct mbuf *, struct mbuf *, | |
616 | struct nfsreq *)); | |
617 | int nfs_rephead __P((int, struct nfsrv_descript *, struct nfssvc_sock *, | |
618 | int, int, u_quad_t *, struct mbuf **, struct mbuf **, | |
619 | caddr_t *)); | |
620 | int nfs_sndlock __P((int *, struct nfsreq *)); | |
621 | void nfs_sndunlock __P((int *flagp)); | |
622 | int nfs_disct __P((struct mbuf **, caddr_t *, int, int, caddr_t *)); | |
623 | int nfs_vinvalbuf __P((struct vnode *, int, struct ucred *, struct proc *, | |
624 | int)); | |
625 | int nfs_readrpc __P((struct vnode *, struct uio *, struct ucred *)); | |
626 | int nfs_writerpc __P((struct vnode *, struct uio *, struct ucred *, int *, | |
627 | int *)); | |
628 | int nfs_readdirrpc __P((struct vnode *, struct uio *, struct ucred *)); | |
629 | int nfs_asyncio __P((struct buf *, struct ucred *)); | |
630 | int nfs_doio __P((struct buf *, struct ucred *, struct proc *)); | |
631 | int nfs_readlinkrpc __P((struct vnode *, struct uio *, struct ucred *)); | |
632 | int nfs_sigintr __P((struct nfsmount *, struct nfsreq *, struct proc *)); | |
633 | int nfs_readdirplusrpc __P((struct vnode *, struct uio *, struct ucred *)); | |
634 | int nfsm_disct __P((struct mbuf **, caddr_t *, int, int, caddr_t *)); | |
635 | void nfsm_srvfattr __P((struct nfsrv_descript *, struct vattr *, | |
636 | struct nfs_fattr *)); | |
637 | void nfsm_srvwcc __P((struct nfsrv_descript *, int, struct vattr *, int, | |
638 | struct vattr *, struct mbuf **, char **)); | |
639 | void nfsm_srvpostopattr __P((struct nfsrv_descript *, int, struct vattr *, | |
640 | struct mbuf **, char **)); | |
641 | int netaddr_match __P((int, union nethostaddr *, struct mbuf *)); | |
642 | int nfs_request __P((struct vnode *, struct mbuf *, int, struct proc *, | |
643 | struct ucred *, struct mbuf **, struct mbuf **, | |
644 | caddr_t *, u_int64_t *)); | |
645 | int nfs_loadattrcache __P((struct vnode **, struct mbuf **, caddr_t *, | |
646 | struct vattr *, int, u_int64_t *)); | |
647 | int nfs_namei __P((struct nameidata *, fhandle_t *, int, | |
648 | struct nfssvc_sock *, struct mbuf *, struct mbuf **, | |
649 | caddr_t *, struct vnode **, struct proc *, int, int)); | |
650 | void nfsm_adj __P((struct mbuf *, int, int)); | |
651 | int nfsm_mbuftouio __P((struct mbuf **, struct uio *, int, caddr_t *)); | |
652 | void nfsrv_initcache __P((void)); | |
653 | int nfs_getauth __P((struct nfsmount *, struct nfsreq *, struct ucred *, | |
654 | char **, int *, char *, int *, NFSKERBKEY_T)); | |
655 | int nfs_getnickauth __P((struct nfsmount *, struct ucred *, char **, | |
656 | int *, char *, int)); | |
657 | int nfs_savenickauth __P((struct nfsmount *, struct ucred *, int, | |
658 | NFSKERBKEY_T, struct mbuf **, char **, | |
659 | struct mbuf *)); | |
660 | int nfs_adv __P((struct mbuf **, caddr_t *, int, int)); | |
661 | void nfs_nhinit __P((void)); | |
662 | void nfs_timer __P((void*)); | |
663 | u_long nfs_hash __P((nfsfh_t *, int)); | |
664 | int nfsrv_dorec __P((struct nfssvc_sock *, struct nfsd *, | |
665 | struct nfsrv_descript **)); | |
666 | int nfsrv_getcache __P((struct nfsrv_descript *, struct nfssvc_sock *, | |
667 | struct mbuf **)); | |
668 | void nfsrv_updatecache __P((struct nfsrv_descript *, int, struct mbuf *)); | |
669 | void nfsrv_cleancache __P((void)); | |
670 | int nfs_connect __P((struct nfsmount *, struct nfsreq *)); | |
671 | void nfs_disconnect __P((struct nfsmount *)); | |
672 | int nfs_getattrcache __P((struct vnode *, struct vattr *)); | |
673 | int nfsm_strtmbuf __P((struct mbuf **, char **, char *, long)); | |
674 | int nfs_bioread __P((struct vnode *, struct uio *, int, struct ucred *, | |
675 | int)); | |
676 | int nfsm_uiotombuf __P((struct uio *, struct mbuf **, int, caddr_t *)); | |
677 | void nfsrv_init __P((int)); | |
678 | void nfs_clearcommit __P((struct mount *)); | |
679 | int nfsrv_errmap __P((struct nfsrv_descript *, int)); | |
680 | void nfsrvw_sort __P((gid_t *, int)); | |
681 | void nfsrv_setcred __P((struct ucred *, struct ucred *)); | |
682 | int nfs_writebp __P((struct buf *, int)); | |
683 | int nfsrv_object_create __P((struct vnode *)); | |
684 | void nfsrv_wakenfsd __P((struct nfssvc_sock *slp)); | |
685 | int nfsrv_writegather __P((struct nfsrv_descript **, struct nfssvc_sock *, | |
686 | struct proc *, struct mbuf **)); | |
687 | int nfs_fsinfo __P((struct nfsmount *, struct vnode *, struct ucred *, | |
688 | struct proc *p)); | |
689 | ||
690 | int nfsrv3_access __P((struct nfsrv_descript *nfsd, | |
691 | struct nfssvc_sock *slp, | |
692 | struct proc *procp, struct mbuf **mrq)); | |
693 | int nfsrv_commit __P((struct nfsrv_descript *nfsd, struct nfssvc_sock *slp, | |
694 | struct proc *procp, struct mbuf **mrq)); | |
695 | int nfsrv_create __P((struct nfsrv_descript *nfsd, struct nfssvc_sock *slp, | |
696 | struct proc *procp, struct mbuf **mrq)); | |
697 | int nfsrv_fhtovp __P((fhandle_t *, int, struct vnode **, struct ucred *, | |
698 | struct nfssvc_sock *, struct mbuf *, int *, | |
699 | int, int)); | |
700 | int nfsrv_setpublicfs __P((struct mount *, struct netexport *, | |
701 | struct export_args *)); | |
702 | int nfs_ispublicfh __P((fhandle_t *)); | |
703 | int nfsrv_fsinfo __P((struct nfsrv_descript *nfsd, struct nfssvc_sock *slp, | |
704 | struct proc *procp, struct mbuf **mrq)); | |
705 | int nfsrv_getattr __P((struct nfsrv_descript *nfsd, struct nfssvc_sock *slp, | |
706 | struct proc *procp, struct mbuf **mrq)); | |
707 | int nfsrv_link __P((struct nfsrv_descript *nfsd, struct nfssvc_sock *slp, | |
708 | struct proc *procp, struct mbuf **mrq)); | |
709 | int nfsrv_lookup __P((struct nfsrv_descript *nfsd, struct nfssvc_sock *slp, | |
710 | struct proc *procp, struct mbuf **mrq)); | |
711 | int nfsrv_mkdir __P((struct nfsrv_descript *nfsd, struct nfssvc_sock *slp, | |
712 | struct proc *procp, struct mbuf **mrq)); | |
713 | int nfsrv_mknod __P((struct nfsrv_descript *nfsd, struct nfssvc_sock *slp, | |
714 | struct proc *procp, struct mbuf **mrq)); | |
715 | int nfsrv_noop __P((struct nfsrv_descript *nfsd, struct nfssvc_sock *slp, | |
716 | struct proc *procp, struct mbuf **mrq)); | |
717 | int nfsrv_null __P((struct nfsrv_descript *nfsd, struct nfssvc_sock *slp, | |
718 | struct proc *procp, struct mbuf **mrq)); | |
719 | int nfsrv_pathconf __P((struct nfsrv_descript *nfsd, | |
720 | struct nfssvc_sock *slp, struct proc *procp, | |
721 | struct mbuf **mrq)); | |
722 | int nfsrv_read __P((struct nfsrv_descript *nfsd, struct nfssvc_sock *slp, | |
723 | struct proc *procp, struct mbuf **mrq)); | |
724 | int nfsrv_readdir __P((struct nfsrv_descript *nfsd, | |
725 | struct nfssvc_sock *slp, | |
726 | struct proc *procp, struct mbuf **mrq)); | |
727 | int nfsrv_readdirplus __P((struct nfsrv_descript *nfsd, | |
728 | struct nfssvc_sock *slp, struct proc *procp, | |
729 | struct mbuf **mrq)); | |
730 | int nfsrv_readlink __P((struct nfsrv_descript *nfsd, | |
731 | struct nfssvc_sock *slp, struct proc *procp, | |
732 | struct mbuf **mrq)); | |
733 | int nfsrv_remove __P((struct nfsrv_descript *nfsd, struct nfssvc_sock *slp, | |
734 | struct proc *procp, struct mbuf **mrq)); | |
735 | int nfsrv_rename __P((struct nfsrv_descript *nfsd, struct nfssvc_sock *slp, | |
736 | struct proc *procp, struct mbuf **mrq)); | |
737 | int nfsrv_rmdir __P((struct nfsrv_descript *nfsd, struct nfssvc_sock *slp, | |
738 | struct proc *procp, struct mbuf **mrq)); | |
739 | int nfsrv_setattr __P((struct nfsrv_descript *nfsd, | |
740 | struct nfssvc_sock *slp, | |
741 | struct proc *procp, struct mbuf **mrq)); | |
742 | int nfsrv_statfs __P((struct nfsrv_descript *nfsd, | |
743 | struct nfssvc_sock *slp, | |
744 | struct proc *procp, struct mbuf **mrq)); | |
745 | int nfsrv_symlink __P((struct nfsrv_descript *nfsd, | |
746 | struct nfssvc_sock *slp, | |
747 | struct proc *procp, struct mbuf **mrq)); | |
748 | int nfsrv_write __P((struct nfsrv_descript *nfsd, struct nfssvc_sock *slp, | |
749 | struct proc *procp, struct mbuf **mrq)); | |
750 | void nfsrv_rcv __P((struct socket *so, caddr_t arg, int waitflag)); | |
751 | void nfsrv_slpderef __P((struct nfssvc_sock *slp)); | |
752 | ||
753 | /* | |
754 | * NFSTRACE points were changed to FSDBG (KERNEL_DEBUG) | |
755 | * But some of this code may prove useful someday... | |
756 | */ | |
757 | #undef NFSDIAG | |
758 | #if NFSDIAG | |
759 | ||
760 | extern int nfstraceindx; | |
761 | #define NFSTBUFSIZ 8912 | |
762 | struct nfstracerec { uint i1, i2, i3, i4; }; | |
763 | extern struct nfstracerec nfstracebuf[NFSTBUFSIZ]; | |
764 | extern uint nfstracemask; /* 32 bits - trace points over 31 are unconditional */ | |
765 | ||
766 | /* 0x0000000f nfs_getattrcache trace points */ | |
767 | #define NFSTRC_GAC_MISS 0x00 /* 0x00000001 cache miss */ | |
768 | #define NFSTRC_GAC_HIT 0x01 /* 0x00000002 cache hit */ | |
769 | #define NFSTRC_GAC_NP 0x02 /* 0x00000004 np size mismatch - vp... */ | |
770 | /* 0x00000038 nfs_loadattrcache trace points */ | |
771 | #define NFSTRC_LAC 0x03 /* 0x00000008 function entry point - vp */ | |
772 | #define NFSTRC_LAC_INIT 0x04 /* 0x00000010 new vp & init n_mtime - vp */ | |
773 | #define NFSTRC_LAC_NP 0x05 /* 0x00000020 np size mismatch - vp... */ | |
774 | /* 0x000000c0 nfs_getattr trace points */ | |
775 | #define NFSTRC_GA_INV 0x06 /* 0x00000040 times mismatch - vp */ | |
776 | #define NFSTRC_GA_INV1 0x07 /* 0x00000080 invalidate ok - vp */ | |
777 | /* 0x00000100 vmp_invalidate trace points */ | |
778 | #define NFSTRC_VMP_INV 0x08 /* 0x00000100 function entry point - vmp */ | |
779 | /* 0x00000200 nfs_request trace points */ | |
780 | #define NFSTRC_REQ 0x09 /* 0x00000200 - alternates vp and procnum */ | |
781 | /* 0x00000c00 vmp_push_range trace points */ | |
782 | #define NFSTRC_VPR 0xa /* 0x00000400 entry point - vp... */ | |
783 | #define NFSTRC_VPR_DONE 0xb /* 0x00000800 tail exit - error # */ | |
784 | /* 0x00003000 nfs_doio trace points */ | |
785 | #define NFSTRC_DIO 0xc /* 0x00001000 entry point - vp */ | |
786 | #define NFSTRC_DIO_DONE 0xd /* 0x00002000 exit points - vp */ | |
787 | /* 0x000fc000 congestion window trace points */ | |
788 | #define NFSTRC_CWND_INIT 0xe | |
789 | #define NFSTRC_CWND_REPLY 0xf | |
790 | #define NFSTRC_CWND_TIMER 0x10 | |
791 | #define NFSTRC_CWND_REQ1 0x11 | |
792 | #define NFSTRC_CWND_REQ2 0x12 | |
793 | #define NFSTRC_CWND_SOFT 0x13 | |
794 | /* 0xfff00000 nfs_rcvlock & nfs_rcvunlock trace points */ | |
795 | #define NFSTRC_ECONN 0x14 | |
796 | #define NFSTRC_RCVERR 0x15 | |
797 | #define NFSTRC_REQFREE 0x16 | |
798 | #define NFSTRC_NOTMINE 0x17 | |
799 | #define NFSTRC_6 0x18 | |
800 | #define NFSTRC_7 0x19 | |
801 | #define NFSTRC_RCVLCKINTR 0x1a | |
802 | #define NFSTRC_RCVALREADY 0x1b | |
803 | #define NFSTRC_RCVLCKW 0x1c /* 0x10000000 seeking recieve lock (waiting) */ | |
804 | #define NFSTRC_RCVLCK 0x1d /* 0x20000000 getting recieve lock */ | |
805 | #define NFSTRC_RCVUNLW 0x1e /* 0x40000000 releasing rcv lock w/ wakeup */ | |
806 | #define NFSTRC_RCVUNL 0x1f /* 0x80000000 releasing rcv lock w/o wakeup */ | |
807 | /* trace points beyond 31 are on if any of above points are on */ | |
808 | #define NFSTRC_GA_INV2 0x20 /* nfs_getattr invalidate - error# */ | |
809 | #define NFSTRC_VBAD 0x21 | |
810 | #define NFSTRC_REQERR 0x22 | |
811 | #define NFSTRC_RPCERR 0x23 | |
812 | #define NFSTRC_DISSECTERR 0x24 | |
813 | #define NFSTRC_CONTINUE 0xff /* continuation record for previous entry */ | |
814 | ||
815 | #define NFSTRACEX(a1, a2, a3, a4) \ | |
816 | ( \ | |
817 | nfstracebuf[nfstraceindx].i1 = (uint)(a1), \ | |
818 | nfstracebuf[nfstraceindx].i2 = (uint)(a2), \ | |
819 | nfstracebuf[nfstraceindx].i3 = (uint)(a3), \ | |
820 | nfstracebuf[nfstraceindx].i4 = (uint)(a4), \ | |
821 | nfstraceindx = (nfstraceindx + 1) % NFSTBUFSIZ, \ | |
822 | 1 \ | |
823 | ) | |
824 | ||
825 | #define NFSTRACE(cnst, fptr) \ | |
826 | ( \ | |
827 | (nfstracemask && ((cnst) > 31 || nfstracemask & 1<<(cnst))) ? \ | |
828 | NFSTRACEX((cnst), (fptr), current_thread(), \ | |
829 | clock_get_system_value().tv_nsec) : \ | |
830 | 0 \ | |
831 | ) | |
832 | ||
833 | #define NFSTRACE4(cnst, fptr, a2, a3, a4) \ | |
834 | ( \ | |
835 | NFSTRACE(cnst,fptr) ? \ | |
836 | NFSTRACEX(NFSTRC_CONTINUE, a2, a3, a4) : \ | |
837 | 0 \ | |
838 | ) | |
839 | ||
840 | #else /* NFSDIAG */ | |
841 | ||
842 | #define NFSTRACE(cnst, fptr) | |
843 | #define NFSTRACE4(cnst, fptr, a2, a3, a4) | |
844 | ||
845 | #endif /* NFSDIAG */ | |
846 | ||
847 | #endif /* KERNEL */ | |
848 | #endif /* __APPLE_API_PRIVATE */ | |
849 | ||
850 | #endif |