NFS - Minor compile fix
[dragonfly.git] / sys / vfs / nfs / nfs.h
CommitLineData
984263bc
MD
1/*
2 * Copyright (c) 1989, 1993, 1995
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.4 (Berkeley) 5/1/95
37 * $FreeBSD: src/sys/nfs/nfs.h,v 1.53.2.5 2002/02/20 01:35:34 iedowse Exp $
67863d04 38 * $DragonFly: src/sys/vfs/nfs/nfs.h,v 1.21 2008/09/17 21:44:24 dillon Exp $
984263bc
MD
39 */
40
41#ifndef _NFS_NFS_H_
42#define _NFS_NFS_H_
43
44#ifdef _KERNEL
45#include "opt_nfs.h"
46#endif
47
8684e6f9
MD
48#include <sys/mutex.h>
49
984263bc
MD
50/*
51 * Tunable constants for nfs
52 */
53
54#define NFS_MAXIOVEC 34
55#define NFS_TICKINTVL 5 /* Desired time for a tick (msec) */
56#define NFS_HZ (hz / nfs_ticks) /* Ticks/sec */
57#define NFS_TIMEO (1 * NFS_HZ) /* Default timeout = 1 second */
58#define NFS_MINTIMEO (1 * NFS_HZ) /* Min timeout to use */
59#define NFS_MAXTIMEO (60 * NFS_HZ) /* Max timeout to backoff to */
60#define NFS_MINIDEMTIMEO (5 * NFS_HZ) /* Min timeout for non-idempotent ops*/
61#define NFS_MAXREXMIT 100 /* Stop counting after this many */
62#define NFS_MAXWINDOW 1024 /* Max number of outstanding requests */
63#define NFS_RETRANS 10 /* Num of retrans for soft mounts */
64#define NFS_MAXGRPS 16 /* Max. size of groups list */
65#ifndef NFS_MINATTRTIMO
66#define NFS_MINATTRTIMO 3 /* VREG attrib cache timeout in sec */
97100839
MD
67#endif
68#ifndef NFS_DEFATTRTIMO
69#define NFS_DEFATTRTIMO 10 /* VREG attrib cache timeout in sec */
984263bc
MD
70#endif
71#ifndef NFS_MAXATTRTIMO
72#define NFS_MAXATTRTIMO 60
73#endif
74#ifndef NFS_MINDIRATTRTIMO
75#define NFS_MINDIRATTRTIMO 30 /* VDIR attrib cache timeout in sec */
76#endif
77#ifndef NFS_MAXDIRATTRTIMO
78#define NFS_MAXDIRATTRTIMO 60
79#endif
e07fef60
MD
80#ifndef NFS_DEADTHRESH
81#define NFS_DEADTHRESH NFS_NEVERDEAD
82#endif
83#define NFS_NEVERDEAD 9
984263bc
MD
84#define NFS_WSIZE 8192 /* Def. write data size <= 8192 */
85#define NFS_RSIZE 8192 /* Def. read data size <= 8192 */
86#define NFS_READDIRSIZE 8192 /* Def. readdir size */
f88ac120
MD
87#define NFS_DEFRAHEAD 4 /* Def. read ahead # blocks */
88#define NFS_MAXRAHEAD 32 /* Max. read ahead # blocks */
984263bc 89#define NFS_MAXUIDHASH 64 /* Max. # of hashed uid entries/mp */
f88ac120 90#define NFS_MAXASYNCDAEMON 64 /* Max. number async_daemons runnable */
984263bc
MD
91#define NFS_MAXGATHERDELAY 100 /* Max. write gather delay (msec) */
92#ifndef NFS_GATHERDELAY
2cb16efc 93#define NFS_GATHERDELAY 20 /* Default write gather delay (msec) */
984263bc
MD
94#endif
95#define NFS_DIRBLKSIZ 4096 /* Must be a multiple of DIRBLKSIZ */
96#ifdef _KERNEL
97#define DIRBLKSIZ 512 /* XXX we used to use ufs's DIRBLKSIZ */
98#endif
99
100/*
101 * Oddballs
102 */
103#define NMOD(a) ((a) % nfs_asyncdaemons)
104#define NFS_CMPFH(n, f, s) \
105 ((n)->n_fhsize == (s) && !bcmp((caddr_t)(n)->n_fhp, (caddr_t)(f), (s)))
106#define NFS_ISV3(v) (VFSTONFS((v)->v_mount)->nm_flag & NFSMNT_NFSV3)
107#define NFS_SRVMAXDATA(n) \
108 (((n)->nd_flag & ND_NFSV3) ? (((n)->nd_nam2) ? \
109 NFS_MAXDGRAMDATA : NFS_MAXDATA) : NFS_V2MAXDATA)
110
984263bc
MD
111/*
112 * The IO_METASYNC flag should be implemented for local file systems.
113 * (Until then, it is nothin at all.)
114 */
115#ifndef IO_METASYNC
116#define IO_METASYNC 0
117#endif
118
119/*
120 * Arguments to mount NFS
121 */
122#define NFS_ARGSVERSION 3 /* change when nfs_args changes */
123struct nfs_args {
124 int version; /* args structure version number */
125 struct sockaddr *addr; /* file server address */
126 int addrlen; /* length of address */
127 int sotype; /* Socket type */
128 int proto; /* and Protocol */
129 u_char *fh; /* File handle to be mounted */
130 int fhsize; /* Size, in bytes, of fh */
131 int flags; /* flags */
132 int wsize; /* write size in bytes */
133 int rsize; /* read size in bytes */
134 int readdirsize; /* readdir size in bytes */
135 int timeo; /* initial timeout in .1 secs */
136 int retrans; /* times to retry send */
137 int maxgrouplist; /* Max. size of group list */
138 int readahead; /* # of blocks to readahead */
e07fef60 139 int unused01; /* Term (sec) of lease */
984263bc
MD
140 int deadthresh; /* Retrans threshold */
141 char *hostname; /* server's name */
142 int acregmin; /* cache attrs for reg files min time */
143 int acregmax; /* cache attrs for reg files max time */
144 int acdirmin; /* cache attrs for dirs min time */
145 int acdirmax; /* cache attrs for dirs max time */
146};
147
148/*
149 * NFS mount option flags
150 */
151#define NFSMNT_SOFT 0x00000001 /* soft mount (hard is default) */
152#define NFSMNT_WSIZE 0x00000002 /* set write size */
153#define NFSMNT_RSIZE 0x00000004 /* set read size */
154#define NFSMNT_TIMEO 0x00000008 /* set initial timeout */
155#define NFSMNT_RETRANS 0x00000010 /* set number of request retries */
156#define NFSMNT_MAXGRPS 0x00000020 /* set maximum grouplist size */
157#define NFSMNT_INT 0x00000040 /* allow interrupts on hard mount */
158#define NFSMNT_NOCONN 0x00000080 /* Don't Connect the socket */
e07fef60 159#define NFSMNT_UNUSED0100 0x00000100
984263bc
MD
160#define NFSMNT_NFSV3 0x00000200 /* Use NFS Version 3 protocol */
161#define NFSMNT_KERB 0x00000400 /* Use Kerberos authentication */
162#define NFSMNT_DUMBTIMR 0x00000800 /* Don't estimate rtt dynamically */
e07fef60 163#define NFSMNT_UNUSED1000 0x00001000 /* set lease term (nqnfs) */
984263bc
MD
164#define NFSMNT_READAHEAD 0x00002000 /* set read ahead */
165#define NFSMNT_DEADTHRESH 0x00004000 /* set dead server retry thresh */
166#define NFSMNT_RESVPORT 0x00008000 /* Allocate a reserved port */
167#define NFSMNT_RDIRPLUS 0x00010000 /* Use Readdirplus for V3 */
168#define NFSMNT_READDIRSIZE 0x00020000 /* Set readdir size */
169#define NFSMNT_ACREGMIN 0x00040000
170#define NFSMNT_ACREGMAX 0x00080000
171#define NFSMNT_ACDIRMIN 0x00100000
172#define NFSMNT_ACDIRMAX 0x00200000
173
174#define NFSSTA_HASWRITEVERF 0x00040000 /* Has write verifier for V3 */
175#define NFSSTA_GOTPATHCONF 0x00080000 /* Got the V3 pathconf info */
176#define NFSSTA_GOTFSINFO 0x00100000 /* Got the V3 fsinfo */
177#define NFSSTA_MNTD 0x00200000 /* Mnt server for mnt point */
178#define NFSSTA_DISMINPROG 0x00400000 /* Dismount in progress */
179#define NFSSTA_DISMNT 0x00800000 /* Dismounted */
8684e6f9
MD
180#define NFSSTA_UNUSED24 0x01000000
181#define NFSSTA_UNUSED25 0x02000000
182#define NFSSTA_UNUSED26 0x04000000
183#define NFSSTA_UNUSED27 0x08000000
984263bc
MD
184#define NFSSTA_WAITAUTH 0x10000000 /* Wait for authentication */
185#define NFSSTA_HASAUTH 0x20000000 /* Has authenticator */
186#define NFSSTA_WANTAUTH 0x40000000 /* Wants an authenticator */
187#define NFSSTA_AUTHERR 0x80000000 /* Authentication error */
188
189/*
190 * Structures for the nfssvc(2) syscall. Not that anyone but nfsd and mount_nfs
191 * should ever try and use it.
192 */
193struct nfsd_args {
194 int sock; /* Socket to serve */
195 caddr_t name; /* Client addr for connection based sockets */
196 int namelen; /* Length of name */
197};
198
199struct nfsd_srvargs {
200 struct nfsd *nsd_nfsd; /* Pointer to in kernel nfsd struct */
201 uid_t nsd_uid; /* Effective uid mapped to cred */
202 u_int32_t nsd_haddr; /* Ip address of client */
203 struct ucred nsd_cr; /* Cred. uid maps to */
204 u_int nsd_authlen; /* Length of auth string (ret) */
205 u_char *nsd_authstr; /* Auth string (ret) */
206 u_int nsd_verflen; /* and the verfier */
207 u_char *nsd_verfstr;
208 struct timeval nsd_timestamp; /* timestamp from verifier */
209 u_int32_t nsd_ttl; /* credential ttl (sec) */
210 NFSKERBKEY_T nsd_key; /* Session key */
211};
212
213struct nfsd_cargs {
214 char *ncd_dirp; /* Mount dir path */
215 uid_t ncd_authuid; /* Effective uid */
216 int ncd_authtype; /* Type of authenticator */
217 u_int ncd_authlen; /* Length of authenticator string */
218 u_char *ncd_authstr; /* Authenticator string */
219 u_int ncd_verflen; /* and the verifier */
220 u_char *ncd_verfstr;
221 NFSKERBKEY_T ncd_key; /* Session key */
222};
223
224/*
225 * XXX to allow amd to include nfs.h without nfsproto.h
226 */
227#ifdef NFS_NPROCS
228/*
229 * Stats structure
230 */
231struct nfsstats {
232 int attrcache_hits;
233 int attrcache_misses;
234 int lookupcache_hits;
235 int lookupcache_misses;
236 int direofcache_hits;
237 int direofcache_misses;
238 int biocache_reads;
239 int read_bios;
240 int read_physios;
241 int biocache_writes;
242 int write_bios;
243 int write_physios;
244 int biocache_readlinks;
245 int readlink_bios;
246 int biocache_readdirs;
247 int readdir_bios;
248 int rpccnt[NFS_NPROCS];
249 int rpcretries;
250 int srvrpccnt[NFS_NPROCS];
251 int srvrpc_errs;
252 int srv_errs;
253 int rpcrequests;
254 int rpctimeouts;
255 int rpcunexpected;
256 int rpcinvalid;
257 int srvcache_inproghits;
258 int srvcache_idemdonehits;
259 int srvcache_nonidemdonehits;
260 int srvcache_misses;
261 int srvnqnfs_leases;
262 int srvnqnfs_maxleases;
263 int srvnqnfs_getleases;
264 int srvvop_writes;
265 int accesscache_hits;
266 int accesscache_misses;
267};
268#endif
269
270/*
271 * Flags for nfssvc() system call.
272 */
273#define NFSSVC_BIOD 0x002
274#define NFSSVC_NFSD 0x004
275#define NFSSVC_ADDSOCK 0x008
276#define NFSSVC_AUTHIN 0x010
277#define NFSSVC_GOTAUTH 0x040
278#define NFSSVC_AUTHINFAIL 0x080
279#define NFSSVC_MNTD 0x100
280
281/*
282 * fs.nfs sysctl(3) identifiers
283 */
284#define NFS_NFSSTATS 1 /* struct: struct nfsstats */
285#define NFS_NFSPRIVPORT 2 /* int: prohibit nfs to resvports */
286
287#define FS_NFS_NAMES { \
288 { 0, 0 }, \
289 { "nfsstats", CTLTYPE_STRUCT }, \
290 { "nfsprivport", CTLTYPE_INT }, \
291}
292
293#ifdef _KERNEL
294
295#ifdef MALLOC_DECLARE
296MALLOC_DECLARE(M_NFSREQ);
297MALLOC_DECLARE(M_NFSDIROFF);
298MALLOC_DECLARE(M_NFSRVDESC);
299MALLOC_DECLARE(M_NFSUID);
984263bc
MD
300MALLOC_DECLARE(M_NFSD);
301MALLOC_DECLARE(M_NFSBIGFH);
302MALLOC_DECLARE(M_NFSHASH);
303#endif
304
305#ifdef ZONE_INTERRUPT
306extern vm_zone_t nfsmount_zone;
307#endif
308
f786cc86 309extern struct callout nfs_timer_handle;
a482a28a 310extern int nfs_async;
984263bc 311
fad57d0e
MD
312struct uio;
313struct buf;
81b5c339 314struct bio;
fad57d0e
MD
315struct vattr;
316struct nlookupdata;
984263bc
MD
317
318/*
319 * The set of signals the interrupt an I/O in progress for NFSMNT_INT mounts.
320 * What should be in this set is open to debate, but I believe that since
321 * I/O system calls on ufs are never interrupted by signals the set should
322 * be minimal. My reasoning is that many current programs that use signals
323 * such as SIGALRM will not expect file I/O system calls to be interrupted
324 * by them and break.
325 */
326#define NFSINT_SIGMASK(set) \
327 (SIGISMEMBER(set, SIGINT) || SIGISMEMBER(set, SIGTERM) || \
328 SIGISMEMBER(set, SIGHUP) || SIGISMEMBER(set, SIGKILL) || \
329 SIGISMEMBER(set, SIGQUIT))
330
331/*
332 * Socket errors ignored for connectionless sockets??
333 * For now, ignore them all
334 */
335#define NFSIGNORE_SOERROR(s, e) \
336 ((e) != EINTR && (e) != ERESTART && (e) != EWOULDBLOCK && \
337 ((s) & PR_CONNREQUIRED) == 0)
338
339/*
340 * Nfs outstanding request list element
341 */
342struct nfsreq {
343 TAILQ_ENTRY(nfsreq) r_chain;
8684e6f9 344 struct mtx_link r_link;
984263bc
MD
345 struct mbuf *r_mreq;
346 struct mbuf *r_mrep;
347 struct mbuf *r_md;
348 caddr_t r_dpos;
349 struct nfsmount *r_nmp;
350 struct vnode *r_vp;
351 u_int32_t r_xid;
352 int r_flags; /* flags on request, see below */
353 int r_retry; /* max retransmission count */
354 int r_rexmit; /* current retrans count */
355 int r_timer; /* tick counter on reply */
356 u_int32_t r_procnum; /* NFS procedure number */
357 int r_rtt; /* RTT for rpc */
dadab5e9 358 struct thread *r_td; /* Thread that did I/O system call */
8684e6f9
MD
359 struct mbuf *r_mrest;
360 struct mbuf *r_mheadend;
361 struct mbuf **r_mrp;
362 struct mbuf **r_mdp;
363 caddr_t *r_dposp;
364 int r_mrest_len;
365 int r_failed_auth;
366 NFSKERBKEY_T r_key;
367 struct ucred *r_cred;
984263bc
MD
368};
369
370/*
e21aec5b 371 * Flag values for r_flags
984263bc 372 */
54938b92
MD
373#define R_TIMING 0x0001 /* timing request (in mntp) */
374#define R_SENT 0x0002 /* request has been sent */
375#define R_SOFTTERM 0x0004 /* soft mnt, too many retries */
376#define R_INTR 0x0008 /* intr mnt, signal pending */
377#define R_SOCKERR 0x0010 /* Fatal error on socket */
378#define R_TPRINTFMSG 0x0020 /* Did a tprintf msg. */
379#define R_MUSTRESEND 0x0040 /* Must resend request */
380#define R_GETONEREP 0x0080 /* Probe for one reply only */
381#define R_MASKTIMER 0x0100 /* Timer should ignore this req */
91f46891 382#define R_LOCKED 0x0200 /* Locked by the timer */
984263bc
MD
383
384/*
385 * A list of nfssvc_sock structures is maintained with all the sockets
386 * that require service by the nfsd.
387 * The nfsuid structs hang off of the nfssvc_sock structs in both lru
388 * and uid hash lists.
389 */
390#ifndef NFS_UIDHASHSIZ
391#define NFS_UIDHASHSIZ 29 /* Tune the size of nfssvc_sock with this */
392#endif
393#define NUIDHASH(sock, uid) \
394 (&(sock)->ns_uidhashtbl[(uid) % NFS_UIDHASHSIZ])
395#ifndef NFS_WDELAYHASHSIZ
396#define NFS_WDELAYHASHSIZ 16 /* and with this */
397#endif
398#define NWDELAYHASH(sock, f) \
399 (&(sock)->ns_wdelayhashtbl[(*((u_int32_t *)(f))) % NFS_WDELAYHASHSIZ])
400#ifndef NFS_MUIDHASHSIZ
401#define NFS_MUIDHASHSIZ 63 /* Tune the size of nfsmount with this */
402#endif
403#define NMUIDHASH(nmp, uid) \
404 (&(nmp)->nm_uidhashtbl[(uid) % NFS_MUIDHASHSIZ])
405#define NFSNOHASH(fhsum) \
406 (&nfsnodehashtbl[(fhsum) & nfsnodehash])
407
408/*
409 * Network address hash list element
410 */
411union nethostaddr {
412 u_int32_t had_inetaddr;
413 struct sockaddr *had_nam;
414};
415
416struct nfsuid {
417 TAILQ_ENTRY(nfsuid) nu_lru; /* LRU chain */
418 LIST_ENTRY(nfsuid) nu_hash; /* Hash list */
419 int nu_flag; /* Flags */
420 union nethostaddr nu_haddr; /* Host addr. for dgram sockets */
421 struct ucred nu_cr; /* Cred uid mapped to */
422 int nu_expire; /* Expiry time (sec) */
423 struct timeval nu_timestamp; /* Kerb. timestamp */
424 u_int32_t nu_nickname; /* Nickname on server */
425 NFSKERBKEY_T nu_key; /* and session key */
426};
427
428#define nu_inetaddr nu_haddr.had_inetaddr
429#define nu_nam nu_haddr.had_nam
430/* Bits for nu_flag */
431#define NU_INETADDR 0x1
432#define NU_NAM 0x2
433#define NU_NETFAM(u) (((u)->nu_flag & NU_INETADDR) ? AF_INET : AF_ISO)
434
435struct nfsrv_rec {
436 STAILQ_ENTRY(nfsrv_rec) nr_link;
437 struct sockaddr *nr_address;
438 struct mbuf *nr_packet;
439};
440
441struct nfssvc_sock {
442 TAILQ_ENTRY(nfssvc_sock) ns_chain; /* List of all nfssvc_sock's */
443 TAILQ_HEAD(, nfsuid) ns_uidlruhead;
444 struct file *ns_fp;
445 struct socket *ns_so;
446 struct sockaddr *ns_nam;
447 struct mbuf *ns_raw;
448 struct mbuf *ns_rawend;
449 STAILQ_HEAD(, nfsrv_rec) ns_rec;
450 struct mbuf *ns_frag;
52553028 451 int ns_numrec;
984263bc 452 int ns_flag;
8684e6f9 453 struct mtx ns_solock;
984263bc
MD
454 int ns_cc;
455 int ns_reclen;
456 int ns_numuids;
457 u_int32_t ns_sref;
458 LIST_HEAD(, nfsrv_descript) ns_tq; /* Write gather lists */
459 LIST_HEAD(, nfsuid) ns_uidhashtbl[NFS_UIDHASHSIZ];
460 LIST_HEAD(nfsrvw_delayhash, nfsrv_descript) ns_wdelayhashtbl[NFS_WDELAYHASHSIZ];
461};
462
463/* Bits for "ns_flag" */
464#define SLP_VALID 0x01
465#define SLP_DOREC 0x02
466#define SLP_NEEDQ 0x04
467#define SLP_DISCONN 0x08
468#define SLP_GETSTREAM 0x10
469#define SLP_LASTFRAG 0x20
470#define SLP_ALLFLAGS 0xff
471
472extern TAILQ_HEAD(nfssvc_sockhead, nfssvc_sock) nfssvc_sockhead;
473extern int nfssvc_sockhead_flag;
49433307 474extern TAILQ_HEAD(nfsmount_head, nfsmount) nfs_mountq;
e21aec5b 475
984263bc
MD
476#define SLP_INIT 0x01
477#define SLP_WANTINIT 0x02
478
479/*
480 * One of these structures is allocated for each nfsd.
481 */
482struct nfsd {
483 TAILQ_ENTRY(nfsd) nfsd_chain; /* List of all nfsd's */
484 int nfsd_flag; /* NFSD_ flags */
485 struct nfssvc_sock *nfsd_slp; /* Current socket */
486 int nfsd_authlen; /* Authenticator len */
487 u_char nfsd_authstr[RPCAUTH_MAXSIZ]; /* Authenticator data */
488 int nfsd_verflen; /* and the Verifier */
489 u_char nfsd_verfstr[RPCVERF_MAXSIZ];
dadab5e9 490 struct thread *nfsd_td; /* thread ptr */
984263bc
MD
491 struct nfsrv_descript *nfsd_nd; /* Associated nfsrv_descript */
492};
493
494/* Bits for "nfsd_flag" */
495#define NFSD_WAITING 0x01
496#define NFSD_REQINPROG 0x02
497#define NFSD_NEEDAUTH 0x04
498#define NFSD_AUTHFAIL 0x08
499
5a9187cb
MD
500/* Bits for loadattrcache */
501#define NFS_LATTR_NOSHRINK 0x01
502#define NFS_LATTR_NOMTIMECHECK 0x02
503
984263bc
MD
504/*
505 * This structure is used by the server for describing each request.
506 * Some fields are used only when write request gathering is performed.
507 */
508struct nfsrv_descript {
509 u_quad_t nd_time; /* Write deadline (usec) */
510 off_t nd_off; /* Start byte offset */
511 off_t nd_eoff; /* and end byte offset */
512 LIST_ENTRY(nfsrv_descript) nd_hash; /* Hash list */
513 LIST_ENTRY(nfsrv_descript) nd_tq; /* and timer list */
514 LIST_HEAD(,nfsrv_descript) nd_coalesce; /* coalesced writes */
515 struct mbuf *nd_mrep; /* Request mbuf list */
516 struct mbuf *nd_md; /* Current dissect mbuf */
517 struct mbuf *nd_mreq; /* Reply mbuf list */
518 struct sockaddr *nd_nam; /* and socket addr */
519 struct sockaddr *nd_nam2; /* return socket addr */
520 caddr_t nd_dpos; /* Current dissect pos */
521 u_int32_t nd_procnum; /* RPC # */
522 int nd_stable; /* storage type */
523 int nd_flag; /* nd_flag */
524 int nd_len; /* Length of this write */
525 int nd_repstat; /* Reply status */
526 u_int32_t nd_retxid; /* Reply xid */
984263bc
MD
527 struct timeval nd_starttime; /* Time RPC initiated */
528 fhandle_t nd_fh; /* File handle */
529 struct ucred nd_cr; /* Credentials */
530};
531
532/* Bits for "nd_flag" */
e07fef60
MD
533#define ND_READ 0x01
534#define ND_WRITE 0x02
984263bc 535#define ND_CHECK 0x04
984263bc 536#define ND_NFSV3 0x08
e07fef60 537#define ND_UNUSED010 0x10
984263bc
MD
538#define ND_KERBNICK 0x20
539#define ND_KERBFULL 0x40
540#define ND_KERBAUTH (ND_KERBNICK | ND_KERBFULL)
541
542extern TAILQ_HEAD(nfsd_head, nfsd) nfsd_head;
543extern int nfsd_head_flag;
52553028 544extern int nfsd_waiting;
984263bc
MD
545#define NFSD_CHECKSLP 0x01
546
547/*
548 * These macros compare nfsrv_descript structures.
549 */
550#define NFSW_CONTIG(o, n) \
551 ((o)->nd_eoff >= (n)->nd_off && \
552 !bcmp((caddr_t)&(o)->nd_fh, (caddr_t)&(n)->nd_fh, NFSX_V3FH))
553
554#define NFSW_SAMECRED(o, n) \
555 (((o)->nd_flag & ND_KERBAUTH) == ((n)->nd_flag & ND_KERBAUTH) && \
556 !bcmp((caddr_t)&(o)->nd_cr, (caddr_t)&(n)->nd_cr, \
557 sizeof (struct ucred)))
558
559/*
560 * Defines for WebNFS
561 */
562
563#define WEBNFS_ESC_CHAR '%'
564#define WEBNFS_SPECCHAR_START 0x80
565
566#define WEBNFS_NATIVE_CHAR 0x80
567/*
568 * ..
569 * Possibly more here in the future.
570 */
571
572/*
573 * Macro for converting escape characters in WebNFS pathnames.
574 * Should really be in libkern.
575 */
576
577#define HEXTOC(c) \
578 ((c) >= 'a' ? ((c) - ('a' - 10)) : \
579 ((c) >= 'A' ? ((c) - ('A' - 10)) : ((c) - '0')))
580#define HEXSTRTOI(p) \
581 ((HEXTOC(p[0]) << 4) + HEXTOC(p[1]))
582
583#ifdef NFS_DEBUG
584
585extern int nfs_debug;
586#define NFS_DEBUG_ASYNCIO 1 /* asynchronous i/o */
587#define NFS_DEBUG_WG 2 /* server write gathering */
588#define NFS_DEBUG_RC 4 /* server request caching */
589
590#define NFS_DPF(cat, args) \
591 do { \
086c1d7e 592 if (nfs_debug & NFS_DEBUG_##cat) kprintf args; \
984263bc
MD
593 } while (0)
594
595#else
596
597#define NFS_DPF(cat, args)
598
599#endif
600
a6ee311a
RG
601u_quad_t nfs_curusec (void);
602int nfs_init (struct vfsconf *vfsp);
603int nfs_uninit (struct vfsconf *vfsp);
604int nfs_reply (struct nfsreq *);
605int nfs_getreq (struct nfsrv_descript *,struct nfsd *,int);
606int nfs_send (struct socket *, struct sockaddr *, struct mbuf *,
607 struct nfsreq *);
608int nfs_rephead (int, struct nfsrv_descript *, struct nfssvc_sock *,
e07fef60 609 int, struct mbuf **, struct mbuf **, caddr_t *);
a6ee311a
RG
610int nfs_sndlock (struct nfsreq *);
611void nfs_sndunlock (struct nfsreq *);
612int nfs_slplock (struct nfssvc_sock *, int);
613void nfs_slpunlock (struct nfssvc_sock *);
614int nfs_disct (struct mbuf **, caddr_t *, int, int, caddr_t *);
87de5057 615int nfs_vinvalbuf (struct vnode *, int, int);
a6ee311a
RG
616int nfs_readrpc (struct vnode *, struct uio *);
617int nfs_writerpc (struct vnode *, struct uio *, int *, int *);
618int nfs_commit (struct vnode *vp, u_quad_t offset, int cnt,
619 struct thread *td);
620int nfs_readdirrpc (struct vnode *, struct uio *);
81b5c339
MD
621int nfs_asyncio (struct vnode *vp, struct bio *, struct thread *);
622int nfs_doio (struct vnode *vp, struct bio *, struct thread *);
a6ee311a
RG
623int nfs_readlinkrpc (struct vnode *, struct uio *);
624int nfs_sigintr (struct nfsmount *, struct nfsreq *, struct thread *);
625int nfs_readdirplusrpc (struct vnode *, struct uio *);
626int nfsm_disct (struct mbuf **, caddr_t *, int, int, caddr_t *);
627void nfsm_srvfattr (struct nfsrv_descript *, struct vattr *,
628 struct nfs_fattr *);
629void nfsm_srvwcc (struct nfsrv_descript *, int, struct vattr *, int,
630 struct vattr *, struct mbuf **, char **);
631void nfsm_srvpostopattr (struct nfsrv_descript *, int, struct vattr *,
632 struct mbuf **, char **);
633int netaddr_match (int, union nethostaddr *, struct sockaddr *);
634int nfs_request (struct vnode *, struct mbuf *, int, struct thread *,
984263bc 635 struct ucred *, struct mbuf **, struct mbuf **,
a6ee311a 636 caddr_t *);
8684e6f9
MD
637int nfs_request_setup(struct vnode *vp, struct mbuf *mrest, int procnum,
638 struct thread *td, struct ucred *cred, struct nfsreq **repp);
639int nfs_request_auth(struct nfsreq *rep);
640int nfs_request_try(struct nfsreq *rep);
641int nfs_request_waitreply(struct nfsreq *rep);
642int nfs_request_processreply(struct nfsreq *rep, int error);
643
644
645
646
a6ee311a
RG
647int nfs_loadattrcache (struct vnode **, struct mbuf **, caddr_t *,
648 struct vattr *, int);
fad57d0e
MD
649int nfs_namei (struct nlookupdata *, struct ucred *, int,
650 struct vnode **, struct vnode **, fhandle_t *, int,
651 struct nfssvc_sock *, struct sockaddr *, struct mbuf **,
652 caddr_t *, struct vnode **, struct thread *, int, int);
a6ee311a
RG
653void nfsm_adj (struct mbuf *, int, int);
654int nfsm_mbuftouio (struct mbuf **, struct uio *, int, caddr_t *);
655void nfsrv_initcache (void);
656int nfs_getauth (struct nfsmount *, struct nfsreq *, struct ucred *,
657 char **, int *, char *, int *, NFSKERBKEY_T);
658int nfs_getnickauth (struct nfsmount *, struct ucred *, char **,
659 int *, char *, int);
660int nfs_savenickauth (struct nfsmount *, struct ucred *, int,
984263bc 661 NFSKERBKEY_T, struct mbuf **, char **,
a6ee311a
RG
662 struct mbuf *);
663int nfs_adv (struct mbuf **, caddr_t *, int, int);
664void nfs_nhinit (void);
665int nfs_nmcancelreqs (struct nfsmount *);
666void nfs_timer (void*);
667int nfsrv_dorec (struct nfssvc_sock *, struct nfsd *,
668 struct nfsrv_descript **);
669int nfsrv_getcache (struct nfsrv_descript *, struct nfssvc_sock *,
670 struct mbuf **);
671void nfsrv_updatecache (struct nfsrv_descript *, int, struct mbuf *);
672void nfsrv_cleancache (void);
673int nfs_connect (struct nfsmount *, struct nfsreq *);
674void nfs_disconnect (struct nfsmount *);
675void nfs_safedisconnect (struct nfsmount *);
676int nfs_getattrcache (struct vnode *, struct vattr *);
677int nfsm_strtmbuf (struct mbuf **, char **, const char *, long);
678int nfs_bioread (struct vnode *, struct uio *, int);
679int nfsm_uiotombuf (struct uio *, struct mbuf **, int, caddr_t *);
680void nfsrv_init (int);
681void nfs_clearcommit (struct mount *);
682int nfsrv_errmap (struct nfsrv_descript *, int);
683void nfsrvw_sort (gid_t *, int);
684void nfsrv_setcred (struct ucred *, struct ucred *);
a6ee311a 685int nfsrv_object_create (struct vnode *);
52553028 686void nfsrv_wakenfsd (struct nfssvc_sock *slp, int nparallel);
a6ee311a
RG
687int nfsrv_writegather (struct nfsrv_descript **, struct nfssvc_sock *,
688 struct thread *, struct mbuf **);
689int nfs_fsinfo (struct nfsmount *, struct vnode *, struct thread *p);
690
691int nfsrv3_access (struct nfsrv_descript *nfsd,
984263bc 692 struct nfssvc_sock *slp,
a6ee311a
RG
693 struct thread *td, struct mbuf **mrq);
694int nfsrv_commit (struct nfsrv_descript *nfsd, struct nfssvc_sock *slp,
695 struct thread *td, struct mbuf **mrq);
696int nfsrv_create (struct nfsrv_descript *nfsd, struct nfssvc_sock *slp,
697 struct thread *td, struct mbuf **mrq);
67863d04
MD
698int nfsrv_fhtovp (fhandle_t *, int, struct mount **, struct vnode **,
699 struct ucred *, struct nfssvc_sock *,
700 struct sockaddr *, int *, int, int);
a6ee311a
RG
701int nfsrv_setpublicfs (struct mount *, struct netexport *,
702 struct export_args *);
703int nfs_ispublicfh (fhandle_t *);
704int nfsrv_fsinfo (struct nfsrv_descript *nfsd, struct nfssvc_sock *slp,
705 struct thread *td, struct mbuf **mrq);
706int nfsrv_getattr (struct nfsrv_descript *nfsd, struct nfssvc_sock *slp,
707 struct thread *td, struct mbuf **mrq);
708int nfsrv_link (struct nfsrv_descript *nfsd, struct nfssvc_sock *slp,
709 struct thread *td, struct mbuf **mrq);
710int nfsrv_lookup (struct nfsrv_descript *nfsd, struct nfssvc_sock *slp,
711 struct thread *td, struct mbuf **mrq);
712int nfsrv_mkdir (struct nfsrv_descript *nfsd, struct nfssvc_sock *slp,
713 struct thread *td, struct mbuf **mrq);
714int nfsrv_mknod (struct nfsrv_descript *nfsd, struct nfssvc_sock *slp,
715 struct thread *td, struct mbuf **mrq);
716int nfsrv_noop (struct nfsrv_descript *nfsd, struct nfssvc_sock *slp,
717 struct thread *td, struct mbuf **mrq);
718int nfsrv_null (struct nfsrv_descript *nfsd, struct nfssvc_sock *slp,
719 struct thread *td, struct mbuf **mrq);
720int nfsrv_pathconf (struct nfsrv_descript *nfsd,
dadab5e9 721 struct nfssvc_sock *slp, struct thread *td,
a6ee311a
RG
722 struct mbuf **mrq);
723int nfsrv_read (struct nfsrv_descript *nfsd, struct nfssvc_sock *slp,
724 struct thread *td, struct mbuf **mrq);
725int nfsrv_readdir (struct nfsrv_descript *nfsd,
984263bc 726 struct nfssvc_sock *slp,
a6ee311a
RG
727 struct thread *td, struct mbuf **mrq);
728int nfsrv_readdirplus (struct nfsrv_descript *nfsd,
dadab5e9 729 struct nfssvc_sock *slp, struct thread *td,
a6ee311a
RG
730 struct mbuf **mrq);
731int nfsrv_readlink (struct nfsrv_descript *nfsd,
dadab5e9 732 struct nfssvc_sock *slp, struct thread *td,
a6ee311a
RG
733 struct mbuf **mrq);
734int nfsrv_remove (struct nfsrv_descript *nfsd, struct nfssvc_sock *slp,
735 struct thread *td, struct mbuf **mrq);
736int nfsrv_rename (struct nfsrv_descript *nfsd, struct nfssvc_sock *slp,
737 struct thread *td, struct mbuf **mrq);
738int nfsrv_rmdir (struct nfsrv_descript *nfsd, struct nfssvc_sock *slp,
739 struct thread *td, struct mbuf **mrq);
740int nfsrv_setattr (struct nfsrv_descript *nfsd,
984263bc 741 struct nfssvc_sock *slp,
a6ee311a
RG
742 struct thread *td, struct mbuf **mrq);
743int nfsrv_statfs (struct nfsrv_descript *nfsd,
984263bc 744 struct nfssvc_sock *slp,
a6ee311a
RG
745 struct thread *td, struct mbuf **mrq);
746int nfsrv_symlink (struct nfsrv_descript *nfsd,
984263bc 747 struct nfssvc_sock *slp,
a6ee311a
RG
748 struct thread *td, struct mbuf **mrq);
749int nfsrv_write (struct nfsrv_descript *nfsd, struct nfssvc_sock *slp,
750 struct thread *td, struct mbuf **mrq);
751void nfsrv_rcv (struct socket *so, void *arg, int waitflag);
752void nfsrv_slpderef (struct nfssvc_sock *slp);
753int nfs_meta_setsize (struct vnode *vp, struct thread *td, u_quad_t nsize);
e07fef60
MD
754int nfs_clientd(struct nfsmount *nmp, struct ucred *cred,
755 struct nfsd_cargs *ncd, int flag, caddr_t argp,
756 struct thread *td);
757
984263bc
MD
758
759#endif /* _KERNEL */
760
761#endif