1 | /* |
---|
2 | * Copyright (c) 1989, 1993 |
---|
3 | * The Regents of the University of California. All rights reserved. |
---|
4 | * |
---|
5 | * This code is derived from software contributed to Berkeley by |
---|
6 | * Rick Macklem at The University of Guelph. |
---|
7 | * |
---|
8 | * Redistribution and use in source and binary forms, with or without |
---|
9 | * modification, are permitted provided that the following conditions |
---|
10 | * are met: |
---|
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. |
---|
23 | * |
---|
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 |
---|
34 | * SUCH DAMAGE. |
---|
35 | * |
---|
36 | * @(#)nfs.h 8.1 (Berkeley) 6/10/93 |
---|
37 | * $Id$ |
---|
38 | */ |
---|
39 | |
---|
40 | #ifndef _NFS_NFS_H_ |
---|
41 | #define _NFS_NFS_H_ |
---|
42 | |
---|
43 | #include <nfs/rpcv2.h> |
---|
44 | |
---|
45 | /* |
---|
46 | * Tunable constants for nfs |
---|
47 | */ |
---|
48 | |
---|
49 | #define NFS_MAXIOVEC 34 |
---|
50 | #define NFS_TICKINTVL 5 /* Desired time for a tick (msec) */ |
---|
51 | #define NFS_HZ (hz / nfs_ticks) /* Ticks/sec */ |
---|
52 | #define NFS_TIMEO (1 * NFS_HZ) /* Default timeout = 1 second */ |
---|
53 | #define NFS_MINTIMEO (1 * NFS_HZ) /* Min timeout to use */ |
---|
54 | #define NFS_MAXTIMEO (60 * NFS_HZ) /* Max timeout to backoff to */ |
---|
55 | #define NFS_MINIDEMTIMEO (5 * NFS_HZ) /* Min timeout for non-idempotent ops*/ |
---|
56 | #define NFS_MAXREXMIT 100 /* Stop counting after this many */ |
---|
57 | #define NFS_MAXWINDOW 1024 /* Max number of outstanding requests */ |
---|
58 | #define NFS_RETRANS 10 /* Num of retrans for soft mounts */ |
---|
59 | #define NFS_MAXGRPS 16 /* Max. size of groups list */ |
---|
60 | #ifndef NFS_MINATTRTIMO |
---|
61 | #define NFS_MINATTRTIMO 5 /* Attribute cache timeout in sec */ |
---|
62 | #endif |
---|
63 | #ifndef NFS_MAXATTRTIMO |
---|
64 | #define NFS_MAXATTRTIMO 60 |
---|
65 | #endif |
---|
66 | #define NFS_WSIZE 8192 /* Def. write data size <= 8192 */ |
---|
67 | #define NFS_RSIZE 8192 /* Def. read data size <= 8192 */ |
---|
68 | #define NFS_READDIRSIZE 8192 /* Def. readdir size */ |
---|
69 | #define NFS_DEFRAHEAD 1 /* Def. read ahead # blocks */ |
---|
70 | #define NFS_MAXRAHEAD 4 /* Max. read ahead # blocks */ |
---|
71 | #define NFS_MAXUIDHASH 64 /* Max. # of hashed uid entries/mp */ |
---|
72 | #define NFS_MAXASYNCDAEMON 20 /* Max. number async_daemons runnable */ |
---|
73 | #define NFS_MAXGATHERDELAY 100 /* Max. write gather delay (msec) */ |
---|
74 | #ifndef NFS_GATHERDELAY |
---|
75 | #define NFS_GATHERDELAY 10 /* Default write gather delay (msec) */ |
---|
76 | #endif |
---|
77 | #define NFS_DIRBLKSIZ 4096 /* Must be a multiple of DIRBLKSIZ */ |
---|
78 | |
---|
79 | /* |
---|
80 | * Oddballs |
---|
81 | */ |
---|
82 | #define NMOD(a) ((a) % nfs_asyncdaemons) |
---|
83 | #define NFS_CMPFH(n, f, s) \ |
---|
84 | ((n)->n_fhsize == (s) && !bcmp((caddr_t)(n)->n_fhp, (caddr_t)(f), (s))) |
---|
85 | #define NFS_ISV3(v) (VFSTONFS((v)->v_mount)->nm_flag & NFSMNT_NFSV3) |
---|
86 | #define NFS_SRVMAXDATA(n) \ |
---|
87 | (((n)->nd_flag & ND_NFSV3) ? (((n)->nd_nam2) ? \ |
---|
88 | NFS_MAXDGRAMDATA : NFS_MAXDATA) : NFS_V2MAXDATA) |
---|
89 | |
---|
90 | /* |
---|
91 | * XXX |
---|
92 | * sys/buf.h should be edited to change B_APPENDWRITE --> B_NEEDCOMMIT, but |
---|
93 | * until then... |
---|
94 | * Same goes for sys/malloc.h, which needs M_NFSDIROFF, |
---|
95 | * M_NFSRVDESC and M_NFSBIGFH added. |
---|
96 | * The VA_EXCLUSIVE flag should be added for va_vaflags and set for an |
---|
97 | * exclusive create. |
---|
98 | * The B_INVAFTERWRITE flag should be set to whatever is required by the |
---|
99 | * buffer cache code to say "Invalidate the block after it is written back". |
---|
100 | */ |
---|
101 | #ifndef B_NEEDCOMMIT |
---|
102 | #define B_NEEDCOMMIT B_APPENDWRITE |
---|
103 | #endif |
---|
104 | #ifndef M_NFSRVDESC |
---|
105 | #define M_NFSRVDESC M_TEMP |
---|
106 | #endif |
---|
107 | #ifndef M_NFSDIROFF |
---|
108 | #define M_NFSDIROFF M_TEMP |
---|
109 | #endif |
---|
110 | #ifndef M_NFSBIGFH |
---|
111 | #define M_NFSBIGFH M_TEMP |
---|
112 | #endif |
---|
113 | #ifndef VA_EXCLUSIVE |
---|
114 | #define VA_EXCLUSIVE 0 |
---|
115 | #endif |
---|
116 | #ifdef __FreeBSD__ |
---|
117 | #define B_INVAFTERWRITE B_NOCACHE |
---|
118 | #else |
---|
119 | #define B_INVAFTERWRITE B_INVAL |
---|
120 | #endif |
---|
121 | |
---|
122 | /* |
---|
123 | * These ifdefs try to handle the differences between the various 4.4BSD-Lite |
---|
124 | * based vfs interfaces. |
---|
125 | * btw: NetBSD-current does have a VOP_LEASDE(), but I don't know how to |
---|
126 | * differentiate between NetBSD-1.0 and NetBSD-current, so.. |
---|
127 | * I also don't know about BSDi's 2.0 release. |
---|
128 | */ |
---|
129 | #if !defined(HAS_VOPLEASE) && !defined(__FreeBSD__) && !defined(__NetBSD__) |
---|
130 | #define HAS_VOPLEASE 1 |
---|
131 | #endif |
---|
132 | #if !defined(HAS_VOPREVOKE) && !defined(__FreeBSD__) && !defined(__NetBSD__) |
---|
133 | #define HAS_VOPREVOKE 1 |
---|
134 | #endif |
---|
135 | |
---|
136 | /* |
---|
137 | * The IO_METASYNC flag should be implemented for local file systems. |
---|
138 | * (Until then, it is nothin at all.) |
---|
139 | */ |
---|
140 | #ifndef IO_METASYNC |
---|
141 | #define IO_METASYNC 0 |
---|
142 | #endif |
---|
143 | |
---|
144 | /* |
---|
145 | * Set the attribute timeout based on how recently the file has been modified. |
---|
146 | */ |
---|
147 | #define NFS_ATTRTIMEO(np) \ |
---|
148 | ((((np)->n_flag & NMODIFIED) || \ |
---|
149 | (time.tv_sec - (np)->n_mtime) / 10 < NFS_MINATTRTIMO) ? NFS_MINATTRTIMO : \ |
---|
150 | ((time.tv_sec - (np)->n_mtime) / 10 > NFS_MAXATTRTIMO ? NFS_MAXATTRTIMO : \ |
---|
151 | (time.tv_sec - (np)->n_mtime) / 10)) |
---|
152 | |
---|
153 | /* |
---|
154 | * Expected allocation sizes for major data structures. If the actual size |
---|
155 | * of the structure exceeds these sizes, then malloc() will be allocating |
---|
156 | * almost twice the memory required. This is used in nfs_init() to warn |
---|
157 | * the sysadmin that the size of a structure should be reduced. |
---|
158 | * (These sizes are always a power of 2. If the kernel malloc() changes |
---|
159 | * to one that does not allocate space in powers of 2 size, then this all |
---|
160 | * becomes bunk!) |
---|
161 | */ |
---|
162 | #define NFS_NODEALLOC 256 |
---|
163 | #define NFS_MNTALLOC 512 |
---|
164 | #define NFS_SVCALLOC 256 |
---|
165 | #define NFS_UIDALLOC 128 |
---|
166 | |
---|
167 | /* |
---|
168 | * Structures for the nfssvc(2) syscall. Not that anyone but nfsd and mount_nfs |
---|
169 | * should ever try and use it. |
---|
170 | */ |
---|
171 | struct nfsd_args { |
---|
172 | int sock; /* Socket to serve */ |
---|
173 | caddr_t name; /* Client address for connection based sockets */ |
---|
174 | int namelen; /* Length of name */ |
---|
175 | }; |
---|
176 | |
---|
177 | struct nfsd_srvargs { |
---|
178 | struct nfsd *nsd_nfsd; /* Pointer to in kernel nfsd struct */ |
---|
179 | uid_t nsd_uid; /* Effective uid mapped to cred */ |
---|
180 | u_long nsd_haddr; /* Ip address of client */ |
---|
181 | struct ucred nsd_cr; /* Cred. uid maps to */ |
---|
182 | int nsd_authlen; /* Length of auth string (ret) */ |
---|
183 | u_char *nsd_authstr; /* Auth string (ret) */ |
---|
184 | int nsd_verflen; /* and the verfier */ |
---|
185 | u_char *nsd_verfstr; |
---|
186 | struct timeval nsd_timestamp; /* timestamp from verifier */ |
---|
187 | u_long nsd_ttl; /* credential ttl (sec) */ |
---|
188 | NFSKERBKEY_T nsd_key; /* Session key */ |
---|
189 | }; |
---|
190 | |
---|
191 | struct nfsd_cargs { |
---|
192 | char *ncd_dirp; /* Mount dir path */ |
---|
193 | uid_t ncd_authuid; /* Effective uid */ |
---|
194 | int ncd_authtype; /* Type of authenticator */ |
---|
195 | int ncd_authlen; /* Length of authenticator string */ |
---|
196 | u_char *ncd_authstr; /* Authenticator string */ |
---|
197 | int ncd_verflen; /* and the verifier */ |
---|
198 | u_char *ncd_verfstr; |
---|
199 | NFSKERBKEY_T ncd_key; /* Session key */ |
---|
200 | }; |
---|
201 | |
---|
202 | /* |
---|
203 | * Stats structure |
---|
204 | */ |
---|
205 | struct nfsstats { |
---|
206 | int attrcache_hits; |
---|
207 | int attrcache_misses; |
---|
208 | int lookupcache_hits; |
---|
209 | int lookupcache_misses; |
---|
210 | int direofcache_hits; |
---|
211 | int direofcache_misses; |
---|
212 | int biocache_reads; |
---|
213 | int read_bios; |
---|
214 | int read_physios; |
---|
215 | int biocache_writes; |
---|
216 | int write_bios; |
---|
217 | int write_physios; |
---|
218 | int biocache_readlinks; |
---|
219 | int readlink_bios; |
---|
220 | int biocache_readdirs; |
---|
221 | int readdir_bios; |
---|
222 | int rpccnt[NFS_NPROCS]; |
---|
223 | int rpcretries; |
---|
224 | int srvrpccnt[NFS_NPROCS]; |
---|
225 | int srvrpc_errs; |
---|
226 | int srv_errs; |
---|
227 | int rpcrequests; |
---|
228 | int rpctimeouts; |
---|
229 | int rpcunexpected; |
---|
230 | int rpcinvalid; |
---|
231 | int srvcache_inproghits; |
---|
232 | int srvcache_idemdonehits; |
---|
233 | int srvcache_nonidemdonehits; |
---|
234 | int srvcache_misses; |
---|
235 | int srvnqnfs_leases; |
---|
236 | int srvnqnfs_maxleases; |
---|
237 | int srvnqnfs_getleases; |
---|
238 | int srvvop_writes; |
---|
239 | }; |
---|
240 | |
---|
241 | /* |
---|
242 | * Flags for nfssvc() system call. |
---|
243 | */ |
---|
244 | #define NFSSVC_BIOD 0x002 |
---|
245 | #define NFSSVC_NFSD 0x004 |
---|
246 | #define NFSSVC_ADDSOCK 0x008 |
---|
247 | #define NFSSVC_AUTHIN 0x010 |
---|
248 | #define NFSSVC_GOTAUTH 0x040 |
---|
249 | #define NFSSVC_AUTHINFAIL 0x080 |
---|
250 | #define NFSSVC_MNTD 0x100 |
---|
251 | |
---|
252 | /* |
---|
253 | * fs.nfs sysctl(3) identifiers |
---|
254 | */ |
---|
255 | #define NFS_NFSSTATS 1 /* struct: struct nfsstats */ |
---|
256 | #define NFS_NFSPRIVPORT 2 /* int: prohibit nfs to resvports */ |
---|
257 | |
---|
258 | #define FS_NFS_NAMES { \ |
---|
259 | { 0, 0 }, \ |
---|
260 | { "nfsstats", CTLTYPE_STRUCT }, \ |
---|
261 | { "nfsprivport", CTLTYPE_INT }, \ |
---|
262 | } |
---|
263 | |
---|
264 | /* |
---|
265 | * The set of signals the interrupt an I/O in progress for NFSMNT_INT mounts. |
---|
266 | * What should be in this set is open to debate, but I believe that since |
---|
267 | * I/O system calls on ufs are never interrupted by signals the set should |
---|
268 | * be minimal. My reasoning is that many current programs that use signals |
---|
269 | * such as SIGALRM will not expect file I/O system calls to be interrupted |
---|
270 | * by them and break. |
---|
271 | */ |
---|
272 | #if defined(KERNEL) || defined(_KERNEL) |
---|
273 | |
---|
274 | struct uio; struct buf; struct vattr; struct nameidata; /* XXX */ |
---|
275 | |
---|
276 | #define NFSINT_SIGMASK (sigmask(SIGINT)|sigmask(SIGTERM)|sigmask(SIGKILL)| \ |
---|
277 | sigmask(SIGHUP)|sigmask(SIGQUIT)) |
---|
278 | |
---|
279 | /* |
---|
280 | * Socket errors ignored for connectionless sockets?? |
---|
281 | * For now, ignore them all |
---|
282 | */ |
---|
283 | #define NFSIGNORE_SOERROR(s, e) \ |
---|
284 | ((e) != EINTR && (e) != ERESTART && (e) != EWOULDBLOCK && \ |
---|
285 | ((s) & PR_CONNREQUIRED) == 0) |
---|
286 | |
---|
287 | /* |
---|
288 | * Nfs outstanding request list element |
---|
289 | */ |
---|
290 | struct nfsreq { |
---|
291 | TAILQ_ENTRY(nfsreq) r_chain; |
---|
292 | struct mbuf *r_mreq; |
---|
293 | struct mbuf *r_mrep; |
---|
294 | struct mbuf *r_md; |
---|
295 | caddr_t r_dpos; |
---|
296 | struct nfsmount *r_nmp; |
---|
297 | struct vnode *r_vp; |
---|
298 | u_long r_xid; |
---|
299 | int r_flags; /* flags on request, see below */ |
---|
300 | int r_retry; /* max retransmission count */ |
---|
301 | int r_rexmit; /* current retrans count */ |
---|
302 | int r_timer; /* tick counter on reply */ |
---|
303 | int r_procnum; /* NFS procedure number */ |
---|
304 | int r_rtt; /* RTT for rpc */ |
---|
305 | struct proc *r_procp; /* Proc that did I/O system call */ |
---|
306 | }; |
---|
307 | |
---|
308 | /* |
---|
309 | * Queue head for nfsreq's |
---|
310 | */ |
---|
311 | extern TAILQ_HEAD(nfs_reqq, nfsreq) nfs_reqq; |
---|
312 | |
---|
313 | /* Flag values for r_flags */ |
---|
314 | #define R_TIMING 0x01 /* timing request (in mntp) */ |
---|
315 | #define R_SENT 0x02 /* request has been sent */ |
---|
316 | #define R_SOFTTERM 0x04 /* soft mnt, too many retries */ |
---|
317 | #define R_INTR 0x08 /* intr mnt, signal pending */ |
---|
318 | #define R_SOCKERR 0x10 /* Fatal error on socket */ |
---|
319 | #define R_TPRINTFMSG 0x20 /* Did a tprintf msg. */ |
---|
320 | #define R_MUSTRESEND 0x40 /* Must resend request */ |
---|
321 | #define R_GETONEREP 0x80 /* Probe for one reply only */ |
---|
322 | |
---|
323 | /* |
---|
324 | * A list of nfssvc_sock structures is maintained with all the sockets |
---|
325 | * that require service by the nfsd. |
---|
326 | * The nfsuid structs hang off of the nfssvc_sock structs in both lru |
---|
327 | * and uid hash lists. |
---|
328 | */ |
---|
329 | #ifndef NFS_UIDHASHSIZ |
---|
330 | #define NFS_UIDHASHSIZ 29 /* Tune the size of nfssvc_sock with this */ |
---|
331 | #endif |
---|
332 | #define NUIDHASH(sock, uid) \ |
---|
333 | (&(sock)->ns_uidhashtbl[(uid) % NFS_UIDHASHSIZ]) |
---|
334 | #ifndef NFS_WDELAYHASHSIZ |
---|
335 | #define NFS_WDELAYHASHSIZ 16 /* and with this */ |
---|
336 | #endif |
---|
337 | #define NWDELAYHASH(sock, f) \ |
---|
338 | (&(sock)->ns_wdelayhashtbl[(*((u_long *)(f))) % NFS_WDELAYHASHSIZ]) |
---|
339 | #ifndef NFS_MUIDHASHSIZ |
---|
340 | #define NFS_MUIDHASHSIZ 63 /* Tune the size of nfsmount with this */ |
---|
341 | #endif |
---|
342 | #define NMUIDHASH(nmp, uid) \ |
---|
343 | (&(nmp)->nm_uidhashtbl[(uid) % NFS_MUIDHASHSIZ]) |
---|
344 | #define NFSNOHASH(fhsum) \ |
---|
345 | (&nfsnodehashtbl[(fhsum) & nfsnodehash]) |
---|
346 | |
---|
347 | /* |
---|
348 | * Network address hash list element |
---|
349 | */ |
---|
350 | union nethostaddr { |
---|
351 | u_long had_inetaddr; |
---|
352 | struct mbuf *had_nam; |
---|
353 | }; |
---|
354 | |
---|
355 | struct nfsuid { |
---|
356 | TAILQ_ENTRY(nfsuid) nu_lru; /* LRU chain */ |
---|
357 | LIST_ENTRY(nfsuid) nu_hash; /* Hash list */ |
---|
358 | int nu_flag; /* Flags */ |
---|
359 | union nethostaddr nu_haddr; /* Host addr. for dgram sockets */ |
---|
360 | struct ucred nu_cr; /* Cred uid mapped to */ |
---|
361 | int nu_expire; /* Expiry time (sec) */ |
---|
362 | struct timeval nu_timestamp; /* Kerb. timestamp */ |
---|
363 | u_long nu_nickname; /* Nickname on server */ |
---|
364 | NFSKERBKEY_T nu_key; /* and session key */ |
---|
365 | }; |
---|
366 | |
---|
367 | #define nu_inetaddr nu_haddr.had_inetaddr |
---|
368 | #define nu_nam nu_haddr.had_nam |
---|
369 | /* Bits for nu_flag */ |
---|
370 | #define NU_INETADDR 0x1 |
---|
371 | #define NU_NAM 0x2 |
---|
372 | #define NU_NETFAM(u) (((u)->nu_flag & NU_INETADDR) ? AF_INET : AF_ISO) |
---|
373 | |
---|
374 | struct nfssvc_sock { |
---|
375 | TAILQ_ENTRY(nfssvc_sock) ns_chain; /* List of all nfssvc_sock's */ |
---|
376 | TAILQ_HEAD(, nfsuid) ns_uidlruhead; |
---|
377 | struct file *ns_fp; |
---|
378 | struct socket *ns_so; |
---|
379 | struct mbuf *ns_nam; |
---|
380 | struct mbuf *ns_raw; |
---|
381 | struct mbuf *ns_rawend; |
---|
382 | struct mbuf *ns_rec; |
---|
383 | struct mbuf *ns_recend; |
---|
384 | struct mbuf *ns_frag; |
---|
385 | int ns_flag; |
---|
386 | int ns_solock; |
---|
387 | int ns_cc; |
---|
388 | int ns_reclen; |
---|
389 | int ns_numuids; |
---|
390 | u_long ns_sref; |
---|
391 | LIST_HEAD(, nfsrv_descript) ns_tq; /* Write gather lists */ |
---|
392 | LIST_HEAD(, nfsuid) ns_uidhashtbl[NFS_UIDHASHSIZ]; |
---|
393 | LIST_HEAD(nfsrvw_delayhash, nfsrv_descript) ns_wdelayhashtbl[NFS_WDELAYHASHSIZ]; |
---|
394 | }; |
---|
395 | |
---|
396 | /* Bits for "ns_flag" */ |
---|
397 | #define SLP_VALID 0x01 |
---|
398 | #define SLP_DOREC 0x02 |
---|
399 | #define SLP_NEEDQ 0x04 |
---|
400 | #define SLP_DISCONN 0x08 |
---|
401 | #define SLP_GETSTREAM 0x10 |
---|
402 | #define SLP_LASTFRAG 0x20 |
---|
403 | #define SLP_ALLFLAGS 0xff |
---|
404 | |
---|
405 | extern TAILQ_HEAD(nfssvc_sockhead, nfssvc_sock) nfssvc_sockhead; |
---|
406 | extern int nfssvc_sockhead_flag; |
---|
407 | #define SLP_INIT 0x01 |
---|
408 | #define SLP_WANTINIT 0x02 |
---|
409 | |
---|
410 | /* |
---|
411 | * One of these structures is allocated for each nfsd. |
---|
412 | */ |
---|
413 | struct nfsd { |
---|
414 | TAILQ_ENTRY(nfsd) nfsd_chain; /* List of all nfsd's */ |
---|
415 | int nfsd_flag; /* NFSD_ flags */ |
---|
416 | struct nfssvc_sock *nfsd_slp; /* Current socket */ |
---|
417 | int nfsd_authlen; /* Authenticator len */ |
---|
418 | u_char nfsd_authstr[RPCAUTH_MAXSIZ]; /* Authenticator data */ |
---|
419 | int nfsd_verflen; /* and the Verifier */ |
---|
420 | u_char nfsd_verfstr[RPCVERF_MAXSIZ]; |
---|
421 | struct proc *nfsd_procp; /* Proc ptr */ |
---|
422 | struct nfsrv_descript *nfsd_nd; /* Associated nfsrv_descript */ |
---|
423 | }; |
---|
424 | |
---|
425 | /* Bits for "nfsd_flag" */ |
---|
426 | #define NFSD_WAITING 0x01 |
---|
427 | #define NFSD_REQINPROG 0x02 |
---|
428 | #define NFSD_NEEDAUTH 0x04 |
---|
429 | #define NFSD_AUTHFAIL 0x08 |
---|
430 | |
---|
431 | /* |
---|
432 | * This structure is used by the server for describing each request. |
---|
433 | * Some fields are used only when write request gathering is performed. |
---|
434 | */ |
---|
435 | struct nfsrv_descript { |
---|
436 | u_quad_t nd_time; /* Write deadline (usec) */ |
---|
437 | off_t nd_off; /* Start byte offset */ |
---|
438 | off_t nd_eoff; /* and end byte offset */ |
---|
439 | LIST_ENTRY(nfsrv_descript) nd_hash; /* Hash list */ |
---|
440 | LIST_ENTRY(nfsrv_descript) nd_tq; /* and timer list */ |
---|
441 | LIST_HEAD(,nfsrv_descript) nd_coalesce; /* coalesced writes */ |
---|
442 | struct mbuf *nd_mrep; /* Request mbuf list */ |
---|
443 | struct mbuf *nd_md; /* Current dissect mbuf */ |
---|
444 | struct mbuf *nd_mreq; /* Reply mbuf list */ |
---|
445 | struct mbuf *nd_nam; /* and socket addr */ |
---|
446 | struct mbuf *nd_nam2; /* return socket addr */ |
---|
447 | caddr_t nd_dpos; /* Current dissect pos */ |
---|
448 | int nd_procnum; /* RPC # */ |
---|
449 | int nd_stable; /* storage type */ |
---|
450 | int nd_flag; /* nd_flag */ |
---|
451 | int nd_len; /* Length of this write */ |
---|
452 | int nd_repstat; /* Reply status */ |
---|
453 | u_long nd_retxid; /* Reply xid */ |
---|
454 | u_long nd_duration; /* Lease duration */ |
---|
455 | struct timeval nd_starttime; /* Time RPC initiated */ |
---|
456 | fhandle_t nd_fh; /* File handle */ |
---|
457 | struct ucred nd_cr; /* Credentials */ |
---|
458 | }; |
---|
459 | |
---|
460 | /* Bits for "nd_flag" */ |
---|
461 | #define ND_READ LEASE_READ |
---|
462 | #define ND_WRITE LEASE_WRITE |
---|
463 | #define ND_CHECK 0x04 |
---|
464 | #define ND_LEASE (ND_READ | ND_WRITE | ND_CHECK) |
---|
465 | #define ND_NFSV3 0x08 |
---|
466 | #define ND_NQNFS 0x10 |
---|
467 | #define ND_KERBNICK 0x20 |
---|
468 | #define ND_KERBFULL 0x40 |
---|
469 | #define ND_KERBAUTH (ND_KERBNICK | ND_KERBFULL) |
---|
470 | |
---|
471 | extern TAILQ_HEAD(nfsd_head, nfsd) nfsd_head; |
---|
472 | extern int nfsd_head_flag; |
---|
473 | #define NFSD_CHECKSLP 0x01 |
---|
474 | |
---|
475 | /* |
---|
476 | * These macros compare nfsrv_descript structures. |
---|
477 | */ |
---|
478 | #define NFSW_CONTIG(o, n) \ |
---|
479 | ((o)->nd_eoff >= (n)->nd_off && \ |
---|
480 | !bcmp((caddr_t)&(o)->nd_fh, (caddr_t)&(n)->nd_fh, NFSX_V3FH)) |
---|
481 | |
---|
482 | #define NFSW_SAMECRED(o, n) \ |
---|
483 | (((o)->nd_flag & ND_KERBAUTH) == ((n)->nd_flag & ND_KERBAUTH) && \ |
---|
484 | !bcmp((caddr_t)&(o)->nd_cr, (caddr_t)&(n)->nd_cr, \ |
---|
485 | sizeof (struct ucred))) |
---|
486 | |
---|
487 | int nfs_reply __P((struct nfsreq *)); |
---|
488 | int nfs_getreq __P((struct nfsrv_descript *,struct nfsd *,int)); |
---|
489 | int nfs_send __P((struct socket *,struct mbuf *,struct mbuf *,struct nfsreq *)); |
---|
490 | int nfs_rephead __P((int,struct nfsrv_descript *,struct nfssvc_sock *,int,int,u_quad_t *,struct mbuf **,struct mbuf **,caddr_t *)); |
---|
491 | int nfs_sndlock __P((int *,struct nfsreq *)); |
---|
492 | void nfs_sndunlock __P((int *flagp)); |
---|
493 | int nfs_disct __P((struct mbuf **,caddr_t *,int,int,caddr_t *)); |
---|
494 | int nfs_vinvalbuf __P((struct vnode *,int,struct ucred *,struct proc *,int)); |
---|
495 | int nfs_readrpc __P((struct vnode *,struct uio *,struct ucred *)); |
---|
496 | int nfs_writerpc __P((struct vnode *,struct uio *,struct ucred *,int *,int *)); |
---|
497 | int nfs_readdirrpc __P((register struct vnode *,struct uio *,struct ucred *)); |
---|
498 | int nfs_asyncio __P((struct buf *,struct ucred *)); |
---|
499 | int nfs_doio __P((struct buf *,struct ucred *,struct proc *)); |
---|
500 | int nfs_readlinkrpc __P((struct vnode *,struct uio *,struct ucred *)); |
---|
501 | int nfs_sigintr __P((struct nfsmount *,struct nfsreq *r,struct proc *)); |
---|
502 | int nfs_readdirplusrpc __P((struct vnode *,register struct uio *,struct ucred *)); |
---|
503 | int nfsm_disct __P((struct mbuf **,caddr_t *,int,int,caddr_t *)); |
---|
504 | void nfsm_srvfattr __P((struct nfsrv_descript *,struct vattr *,struct nfs_fattr *)); |
---|
505 | void nfsm_srvwcc __P((struct nfsrv_descript *,int,struct vattr *,int,struct vattr *,struct mbuf **,char **)); |
---|
506 | void nfsm_srvpostopattr __P((struct nfsrv_descript *,int,struct vattr *,struct mbuf **,char **)); |
---|
507 | int netaddr_match __P((int,union nethostaddr *,struct mbuf *)); |
---|
508 | int nfs_request __P((struct vnode *,struct mbuf *,int,struct proc *,struct ucred *,struct mbuf **,struct mbuf **,caddr_t *)); |
---|
509 | int nfs_loadattrcache __P((struct vnode **,struct mbuf **,caddr_t *,struct vattr *)); |
---|
510 | int nfs_namei __P((struct nameidata *,fhandle_t *,int,struct nfssvc_sock *,struct mbuf *,struct mbuf **,caddr_t *,struct vnode **,struct proc *,int)); |
---|
511 | void nfsm_adj __P((struct mbuf *,int,int)); |
---|
512 | int nfsm_mbuftouio __P((struct mbuf **,struct uio *,int,caddr_t *)); |
---|
513 | void nfsrv_initcache __P((void)); |
---|
514 | int nfs_getauth __P((struct nfsmount *,struct nfsreq *,struct ucred *,char **,int *,char *,int *,NFSKERBKEY_T)); |
---|
515 | int nfs_getnickauth __P((struct nfsmount *,struct ucred *,char **,int *,char *,int)); |
---|
516 | int nfs_savenickauth __P((struct nfsmount *,struct ucred *,int,NFSKERBKEY_T,struct mbuf **,char **,struct mbuf *)); |
---|
517 | int nfs_adv __P((struct mbuf **,caddr_t *,int,int)); |
---|
518 | void nfs_nhinit __P((void)); |
---|
519 | void nfs_timer __P((void*)); |
---|
520 | u_long nfs_hash __P((nfsfh_t *,int)); |
---|
521 | void nfsrv_slpderef __P((struct nfssvc_sock *slp)); |
---|
522 | int nfsrv_dorec __P((struct nfssvc_sock *,struct nfsd *,struct nfsrv_descript **)); |
---|
523 | void nfsrv_cleancache __P((void)); |
---|
524 | int nfsrv_getcache __P((struct nfsrv_descript *,struct nfssvc_sock *,struct mbuf **)); |
---|
525 | int nfs_init __P((void)); |
---|
526 | void nfsrv_updatecache __P((struct nfsrv_descript *,int,struct mbuf *)); |
---|
527 | int nfs_connect __P((struct nfsmount *,struct nfsreq *)); |
---|
528 | void nfs_disconnect __P((struct nfsmount *nmp)); |
---|
529 | int nfs_getattrcache __P((struct vnode *,struct vattr *)); |
---|
530 | int nfsm_strtmbuf __P((struct mbuf **,char **,char *,long)); |
---|
531 | int nfs_bioread __P((struct vnode *,struct uio *,int,struct ucred *, int getpages)); |
---|
532 | int nfsm_uiotombuf __P((struct uio *,struct mbuf **,int,caddr_t *)); |
---|
533 | void nfsrv_init __P((int)); |
---|
534 | void nfs_clearcommit __P((struct mount *)); |
---|
535 | int nfsrv_errmap __P((struct nfsrv_descript *, int)); |
---|
536 | void nfsrv_rcv __P((struct socket *so, caddr_t arg, int waitflag)); |
---|
537 | void nfsrvw_sort __P((gid_t [],int)); |
---|
538 | void nfsrv_setcred __P((struct ucred *,struct ucred *)); |
---|
539 | int nfs_writebp __P((struct buf *,int)); |
---|
540 | int nfsrv_object_create __P(( struct vnode * )); |
---|
541 | void nfsrv_wakenfsd __P((struct nfssvc_sock *slp)); |
---|
542 | int nfsrv_writegather __P((struct nfsrv_descript **, struct nfssvc_sock *, |
---|
543 | struct proc *, struct mbuf **)); |
---|
544 | int nfs_fsinfo __P((struct nfsmount *, struct vnode *, struct ucred *, |
---|
545 | struct proc *p)); |
---|
546 | |
---|
547 | int nfsrv3_access __P((struct nfsrv_descript *nfsd, struct nfssvc_sock *slp, |
---|
548 | struct proc *procp, struct mbuf **mrq)); |
---|
549 | int nfsrv_commit __P((struct nfsrv_descript *nfsd, struct nfssvc_sock *slp, |
---|
550 | struct proc *procp, struct mbuf **mrq)); |
---|
551 | int nfsrv_create __P((struct nfsrv_descript *nfsd, struct nfssvc_sock *slp, |
---|
552 | struct proc *procp, struct mbuf **mrq)); |
---|
553 | int nfsrv_fhtovp __P((fhandle_t *,int,struct vnode **, |
---|
554 | struct ucred *,struct nfssvc_sock *,struct mbuf *, |
---|
555 | int *,int)); |
---|
556 | int nfsrv_fsinfo __P((struct nfsrv_descript *nfsd, struct nfssvc_sock *slp, |
---|
557 | struct proc *procp, struct mbuf **mrq)); |
---|
558 | int nfsrv_getattr __P((struct nfsrv_descript *nfsd, struct nfssvc_sock *slp, |
---|
559 | struct proc *procp, struct mbuf **mrq)); |
---|
560 | int nfsrv_link __P((struct nfsrv_descript *nfsd, struct nfssvc_sock *slp, |
---|
561 | struct proc *procp, struct mbuf **mrq)); |
---|
562 | int nfsrv_lookup __P((struct nfsrv_descript *nfsd, struct nfssvc_sock *slp, |
---|
563 | struct proc *procp, struct mbuf **mrq)); |
---|
564 | int nfsrv_mkdir __P((struct nfsrv_descript *nfsd, struct nfssvc_sock *slp, |
---|
565 | struct proc *procp, struct mbuf **mrq)); |
---|
566 | int nfsrv_mknod __P((struct nfsrv_descript *nfsd, struct nfssvc_sock *slp, |
---|
567 | struct proc *procp, struct mbuf **mrq)); |
---|
568 | int nfsrv_noop __P((struct nfsrv_descript *nfsd, struct nfssvc_sock *slp, |
---|
569 | struct proc *procp, struct mbuf **mrq)); |
---|
570 | int nfsrv_null __P((struct nfsrv_descript *nfsd, struct nfssvc_sock *slp, |
---|
571 | struct proc *procp, struct mbuf **mrq)); |
---|
572 | int nfsrv_pathconf __P((struct nfsrv_descript *nfsd, |
---|
573 | struct nfssvc_sock *slp, struct proc *procp, |
---|
574 | struct mbuf **mrq)); |
---|
575 | int nfsrv_read __P((struct nfsrv_descript *nfsd, struct nfssvc_sock *slp, |
---|
576 | struct proc *procp, struct mbuf **mrq)); |
---|
577 | int nfsrv_readdir __P((struct nfsrv_descript *nfsd, struct nfssvc_sock *slp, |
---|
578 | struct proc *procp, struct mbuf **mrq)); |
---|
579 | int nfsrv_readdirplus __P((struct nfsrv_descript *nfsd, |
---|
580 | struct nfssvc_sock *slp, struct proc *procp, |
---|
581 | struct mbuf **mrq)); |
---|
582 | int nfsrv_readlink __P((struct nfsrv_descript *nfsd, |
---|
583 | struct nfssvc_sock *slp, struct proc *procp, |
---|
584 | struct mbuf **mrq)); |
---|
585 | int nfsrv_remove __P((struct nfsrv_descript *nfsd, struct nfssvc_sock *slp, |
---|
586 | struct proc *procp, struct mbuf **mrq)); |
---|
587 | int nfsrv_rename __P((struct nfsrv_descript *nfsd, struct nfssvc_sock *slp, |
---|
588 | struct proc *procp, struct mbuf **mrq)); |
---|
589 | int nfsrv_rmdir __P((struct nfsrv_descript *nfsd, struct nfssvc_sock *slp, |
---|
590 | struct proc *procp, struct mbuf **mrq)); |
---|
591 | int nfsrv_setattr __P((struct nfsrv_descript *nfsd, struct nfssvc_sock *slp, |
---|
592 | struct proc *procp, struct mbuf **mrq)); |
---|
593 | int nfsrv_statfs __P((struct nfsrv_descript *nfsd, struct nfssvc_sock *slp, |
---|
594 | struct proc *procp, struct mbuf **mrq)); |
---|
595 | int nfsrv_symlink __P((struct nfsrv_descript *nfsd, struct nfssvc_sock *slp, |
---|
596 | struct proc *procp, struct mbuf **mrq)); |
---|
597 | int nfsrv_write __P((struct nfsrv_descript *nfsd, struct nfssvc_sock *slp, |
---|
598 | struct proc *procp, struct mbuf **mrq)); |
---|
599 | |
---|
600 | #ifdef NFS_DEBUG |
---|
601 | |
---|
602 | extern int nfs_debug; |
---|
603 | #define NFS_DEBUG_ASYNCIO 1 /* asynchronous i/o */ |
---|
604 | #define NFS_DEBUG_WG 2 /* server write gathering */ |
---|
605 | #define NFS_DEBUG_RC 4 /* server request caching */ |
---|
606 | |
---|
607 | #define NFS_DPF(cat, args) \ |
---|
608 | do { \ |
---|
609 | if (nfs_debug & NFS_DEBUG_##cat) printf args; \ |
---|
610 | } while (0) |
---|
611 | |
---|
612 | #else |
---|
613 | |
---|
614 | #define NFS_DPF(cat, args) |
---|
615 | |
---|
616 | #endif |
---|
617 | |
---|
618 | #endif /* KERNEL */ |
---|
619 | |
---|
620 | #endif |
---|