nfs_syscalls.c revision 1.48.2.4 1 1.48.2.4 nathanw /* $NetBSD: nfs_syscalls.c,v 1.48.2.4 2002/01/08 00:34:33 nathanw Exp $ */
2 1.11 cgd
3 1.1 cgd /*
4 1.10 mycroft * Copyright (c) 1989, 1993
5 1.10 mycroft * The Regents of the University of California. All rights reserved.
6 1.1 cgd *
7 1.1 cgd * This code is derived from software contributed to Berkeley by
8 1.1 cgd * Rick Macklem at The University of Guelph.
9 1.1 cgd *
10 1.1 cgd * Redistribution and use in source and binary forms, with or without
11 1.1 cgd * modification, are permitted provided that the following conditions
12 1.1 cgd * are met:
13 1.1 cgd * 1. Redistributions of source code must retain the above copyright
14 1.1 cgd * notice, this list of conditions and the following disclaimer.
15 1.1 cgd * 2. Redistributions in binary form must reproduce the above copyright
16 1.1 cgd * notice, this list of conditions and the following disclaimer in the
17 1.1 cgd * documentation and/or other materials provided with the distribution.
18 1.1 cgd * 3. All advertising materials mentioning features or use of this software
19 1.1 cgd * must display the following acknowledgement:
20 1.1 cgd * This product includes software developed by the University of
21 1.1 cgd * California, Berkeley and its contributors.
22 1.1 cgd * 4. Neither the name of the University nor the names of its contributors
23 1.1 cgd * may be used to endorse or promote products derived from this software
24 1.1 cgd * without specific prior written permission.
25 1.1 cgd *
26 1.1 cgd * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
27 1.1 cgd * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
28 1.1 cgd * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
29 1.1 cgd * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
30 1.1 cgd * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
31 1.1 cgd * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
32 1.1 cgd * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
33 1.1 cgd * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
34 1.1 cgd * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
35 1.1 cgd * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
36 1.1 cgd * SUCH DAMAGE.
37 1.1 cgd *
38 1.19 fvdl * @(#)nfs_syscalls.c 8.5 (Berkeley) 3/30/95
39 1.1 cgd */
40 1.48.2.2 nathanw
41 1.48.2.2 nathanw #include <sys/cdefs.h>
42 1.48.2.4 nathanw __KERNEL_RCSID(0, "$NetBSD: nfs_syscalls.c,v 1.48.2.4 2002/01/08 00:34:33 nathanw Exp $");
43 1.28 thorpej
44 1.28 thorpej #include "fs_nfs.h"
45 1.43 bjh21 #include "opt_nfs.h"
46 1.30 thorpej #include "opt_nfsserver.h"
47 1.31 jonathan #include "opt_iso.h"
48 1.41 fvdl #include "opt_inet.h"
49 1.39 tsarna #include "opt_compat_netbsd.h"
50 1.1 cgd
51 1.7 mycroft #include <sys/param.h>
52 1.7 mycroft #include <sys/systm.h>
53 1.7 mycroft #include <sys/kernel.h>
54 1.7 mycroft #include <sys/file.h>
55 1.7 mycroft #include <sys/stat.h>
56 1.7 mycroft #include <sys/vnode.h>
57 1.7 mycroft #include <sys/mount.h>
58 1.48.2.1 nathanw #include <sys/lwp.h>
59 1.7 mycroft #include <sys/proc.h>
60 1.10 mycroft #include <sys/uio.h>
61 1.7 mycroft #include <sys/malloc.h>
62 1.7 mycroft #include <sys/buf.h>
63 1.7 mycroft #include <sys/mbuf.h>
64 1.7 mycroft #include <sys/socket.h>
65 1.7 mycroft #include <sys/socketvar.h>
66 1.39 tsarna #include <sys/signalvar.h>
67 1.7 mycroft #include <sys/domain.h>
68 1.7 mycroft #include <sys/protosw.h>
69 1.10 mycroft #include <sys/namei.h>
70 1.10 mycroft #include <sys/syslog.h>
71 1.18 christos #include <sys/filedesc.h>
72 1.39 tsarna #include <sys/kthread.h>
73 1.1 cgd
74 1.13 cgd #include <sys/syscallargs.h>
75 1.13 cgd
76 1.7 mycroft #include <netinet/in.h>
77 1.7 mycroft #include <netinet/tcp.h>
78 1.10 mycroft #ifdef ISO
79 1.10 mycroft #include <netiso/iso.h>
80 1.10 mycroft #endif
81 1.19 fvdl #include <nfs/xdr_subs.h>
82 1.10 mycroft #include <nfs/rpcv2.h>
83 1.19 fvdl #include <nfs/nfsproto.h>
84 1.7 mycroft #include <nfs/nfs.h>
85 1.19 fvdl #include <nfs/nfsm_subs.h>
86 1.7 mycroft #include <nfs/nfsrvcache.h>
87 1.10 mycroft #include <nfs/nfsmount.h>
88 1.10 mycroft #include <nfs/nfsnode.h>
89 1.10 mycroft #include <nfs/nqnfs.h>
90 1.10 mycroft #include <nfs/nfsrtt.h>
91 1.18 christos #include <nfs/nfs_var.h>
92 1.1 cgd
93 1.1 cgd /* Global defs. */
94 1.19 fvdl extern int32_t (*nfsrv3_procs[NFS_NPROCS]) __P((struct nfsrv_descript *,
95 1.19 fvdl struct nfssvc_sock *,
96 1.19 fvdl struct proc *, struct mbuf **));
97 1.1 cgd extern int nfs_numasync;
98 1.10 mycroft extern time_t nqnfsstarttime;
99 1.10 mycroft extern int nqsrv_writeslack;
100 1.10 mycroft extern int nfsrtton;
101 1.19 fvdl extern struct nfsstats nfsstats;
102 1.19 fvdl extern int nfsrvw_procrastinate;
103 1.47 chs struct nfssvc_sock *nfs_udpsock;
104 1.47 chs #ifdef ISO
105 1.47 chs struct nfssvc_sock *nfs_cltpsock;
106 1.47 chs #endif
107 1.41 fvdl #ifdef INET6
108 1.41 fvdl struct nfssvc_sock *nfs_udp6sock;
109 1.41 fvdl #endif
110 1.10 mycroft int nuidhash_max = NFS_MAXUIDHASH;
111 1.18 christos int nfsd_waiting = 0;
112 1.18 christos #ifdef NFSSERVER
113 1.10 mycroft static int nfs_numnfsd = 0;
114 1.10 mycroft static int notstarted = 1;
115 1.10 mycroft static int modify_flag = 0;
116 1.10 mycroft static struct nfsdrt nfsdrt;
117 1.18 christos #endif
118 1.1 cgd
119 1.1 cgd #define TRUE 1
120 1.1 cgd #define FALSE 0
121 1.1 cgd
122 1.24 thorpej #ifdef NFS
123 1.39 tsarna static struct proc *nfs_asyncdaemon[NFS_MAXASYNCDAEMON];
124 1.40 tsarna int nfs_niothreads = -1; /* == "0, and has never been set" */
125 1.23 thorpej #endif
126 1.19 fvdl
127 1.18 christos #ifdef NFSSERVER
128 1.19 fvdl static void nfsd_rt __P((int, struct nfsrv_descript *, int));
129 1.18 christos #endif
130 1.19 fvdl
131 1.1 cgd /*
132 1.1 cgd * NFS server system calls
133 1.1 cgd */
134 1.1 cgd
135 1.1 cgd
136 1.1 cgd /*
137 1.19 fvdl * Nfs server pseudo system call for the nfsd's
138 1.10 mycroft * Based on the flag value it either:
139 1.10 mycroft * - adds a socket to the selection list
140 1.10 mycroft * - remains in the kernel as an nfsd
141 1.10 mycroft * - remains in the kernel as an nfsiod
142 1.1 cgd */
143 1.18 christos int
144 1.48.2.1 nathanw sys_nfssvc(l, v, retval)
145 1.48.2.1 nathanw struct lwp *l;
146 1.15 thorpej void *v;
147 1.15 thorpej register_t *retval;
148 1.15 thorpej {
149 1.38 augustss struct sys_nfssvc_args /* {
150 1.13 cgd syscallarg(int) flag;
151 1.13 cgd syscallarg(caddr_t) argp;
152 1.15 thorpej } */ *uap = v;
153 1.48.2.1 nathanw struct proc *p = l->l_proc;
154 1.23 thorpej int error;
155 1.24 thorpej #ifdef NFS
156 1.10 mycroft struct nameidata nd;
157 1.18 christos struct nfsmount *nmp;
158 1.19 fvdl struct nfsd_cargs ncd;
159 1.19 fvdl #endif
160 1.18 christos #ifdef NFSSERVER
161 1.1 cgd struct file *fp;
162 1.10 mycroft struct mbuf *nam;
163 1.10 mycroft struct nfsd_args nfsdarg;
164 1.10 mycroft struct nfsd_srvargs nfsd_srvargs, *nsd = &nfsd_srvargs;
165 1.10 mycroft struct nfsd *nfsd;
166 1.10 mycroft struct nfssvc_sock *slp;
167 1.18 christos struct nfsuid *nuidp;
168 1.18 christos #endif
169 1.1 cgd
170 1.1 cgd /*
171 1.1 cgd * Must be super user
172 1.1 cgd */
173 1.19 fvdl error = suser(p->p_ucred, &p->p_acflag);
174 1.19 fvdl if(error)
175 1.1 cgd return (error);
176 1.12 mycroft while (nfssvc_sockhead_flag & SLP_INIT) {
177 1.19 fvdl nfssvc_sockhead_flag |= SLP_WANTINIT;
178 1.10 mycroft (void) tsleep((caddr_t)&nfssvc_sockhead, PSOCK, "nfsd init", 0);
179 1.10 mycroft }
180 1.13 cgd if (SCARG(uap, flag) & NFSSVC_BIOD) {
181 1.39 tsarna #if defined(NFS) && defined(COMPAT_14)
182 1.48.2.1 nathanw error = nfssvc_iod(l);
183 1.19 fvdl #else
184 1.10 mycroft error = ENOSYS;
185 1.19 fvdl #endif
186 1.13 cgd } else if (SCARG(uap, flag) & NFSSVC_MNTD) {
187 1.24 thorpej #ifndef NFS
188 1.10 mycroft error = ENOSYS;
189 1.19 fvdl #else
190 1.18 christos error = copyin(SCARG(uap, argp), (caddr_t)&ncd, sizeof (ncd));
191 1.18 christos if (error)
192 1.10 mycroft return (error);
193 1.10 mycroft NDINIT(&nd, LOOKUP, FOLLOW | LOCKLEAF, UIO_USERSPACE,
194 1.10 mycroft ncd.ncd_dirp, p);
195 1.19 fvdl error = namei(&nd);
196 1.19 fvdl if (error)
197 1.10 mycroft return (error);
198 1.10 mycroft if ((nd.ni_vp->v_flag & VROOT) == 0)
199 1.10 mycroft error = EINVAL;
200 1.10 mycroft nmp = VFSTONFS(nd.ni_vp->v_mount);
201 1.10 mycroft vput(nd.ni_vp);
202 1.10 mycroft if (error)
203 1.10 mycroft return (error);
204 1.27 fvdl if ((nmp->nm_iflag & NFSMNT_MNTD) &&
205 1.19 fvdl (SCARG(uap, flag) & NFSSVC_GOTAUTH) == 0)
206 1.10 mycroft return (0);
207 1.27 fvdl nmp->nm_iflag |= NFSMNT_MNTD;
208 1.13 cgd error = nqnfs_clientd(nmp, p->p_ucred, &ncd, SCARG(uap, flag),
209 1.48.2.1 nathanw SCARG(uap, argp), l);
210 1.24 thorpej #endif /* NFS */
211 1.13 cgd } else if (SCARG(uap, flag) & NFSSVC_ADDSOCK) {
212 1.10 mycroft #ifndef NFSSERVER
213 1.10 mycroft error = ENOSYS;
214 1.19 fvdl #else
215 1.18 christos error = copyin(SCARG(uap, argp), (caddr_t)&nfsdarg,
216 1.19 fvdl sizeof(nfsdarg));
217 1.18 christos if (error)
218 1.10 mycroft return (error);
219 1.35 thorpej /* getsock() will use the descriptor for us */
220 1.19 fvdl error = getsock(p->p_fd, nfsdarg.sock, &fp);
221 1.19 fvdl if (error)
222 1.10 mycroft return (error);
223 1.10 mycroft /*
224 1.10 mycroft * Get the client address for connected sockets.
225 1.10 mycroft */
226 1.10 mycroft if (nfsdarg.name == NULL || nfsdarg.namelen == 0)
227 1.10 mycroft nam = (struct mbuf *)0;
228 1.18 christos else {
229 1.18 christos error = sockargs(&nam, nfsdarg.name, nfsdarg.namelen,
230 1.19 fvdl MT_SONAME);
231 1.35 thorpej if (error) {
232 1.35 thorpej FILE_UNUSE(fp, NULL);
233 1.18 christos return (error);
234 1.35 thorpej }
235 1.18 christos }
236 1.10 mycroft error = nfssvc_addsock(fp, nam);
237 1.35 thorpej FILE_UNUSE(fp, NULL);
238 1.10 mycroft #endif /* !NFSSERVER */
239 1.10 mycroft } else {
240 1.10 mycroft #ifndef NFSSERVER
241 1.10 mycroft error = ENOSYS;
242 1.19 fvdl #else
243 1.18 christos error = copyin(SCARG(uap, argp), (caddr_t)nsd, sizeof (*nsd));
244 1.18 christos if (error)
245 1.10 mycroft return (error);
246 1.13 cgd if ((SCARG(uap, flag) & NFSSVC_AUTHIN) &&
247 1.19 fvdl ((nfsd = nsd->nsd_nfsd)) != NULL &&
248 1.19 fvdl (nfsd->nfsd_slp->ns_flag & SLP_VALID)) {
249 1.19 fvdl slp = nfsd->nfsd_slp;
250 1.10 mycroft
251 1.10 mycroft /*
252 1.10 mycroft * First check to see if another nfsd has already
253 1.10 mycroft * added this credential.
254 1.10 mycroft */
255 1.19 fvdl for (nuidp = NUIDHASH(slp,nsd->nsd_cr.cr_uid)->lh_first;
256 1.12 mycroft nuidp != 0; nuidp = nuidp->nu_hash.le_next) {
257 1.19 fvdl if (nuidp->nu_cr.cr_uid == nsd->nsd_cr.cr_uid &&
258 1.19 fvdl (!nfsd->nfsd_nd->nd_nam2 ||
259 1.19 fvdl netaddr_match(NU_NETFAM(nuidp),
260 1.19 fvdl &nuidp->nu_haddr, nfsd->nfsd_nd->nd_nam2)))
261 1.10 mycroft break;
262 1.10 mycroft }
263 1.19 fvdl if (nuidp) {
264 1.19 fvdl nfsrv_setcred(&nuidp->nu_cr,&nfsd->nfsd_nd->nd_cr);
265 1.19 fvdl nfsd->nfsd_nd->nd_flag |= ND_KERBFULL;
266 1.19 fvdl } else {
267 1.10 mycroft /*
268 1.10 mycroft * Nope, so we will.
269 1.10 mycroft */
270 1.10 mycroft if (slp->ns_numuids < nuidhash_max) {
271 1.10 mycroft slp->ns_numuids++;
272 1.10 mycroft nuidp = (struct nfsuid *)
273 1.10 mycroft malloc(sizeof (struct nfsuid), M_NFSUID,
274 1.10 mycroft M_WAITOK);
275 1.10 mycroft } else
276 1.10 mycroft nuidp = (struct nfsuid *)0;
277 1.10 mycroft if ((slp->ns_flag & SLP_VALID) == 0) {
278 1.10 mycroft if (nuidp)
279 1.10 mycroft free((caddr_t)nuidp, M_NFSUID);
280 1.10 mycroft } else {
281 1.10 mycroft if (nuidp == (struct nfsuid *)0) {
282 1.12 mycroft nuidp = slp->ns_uidlruhead.tqh_first;
283 1.12 mycroft LIST_REMOVE(nuidp, nu_hash);
284 1.12 mycroft TAILQ_REMOVE(&slp->ns_uidlruhead, nuidp,
285 1.12 mycroft nu_lru);
286 1.19 fvdl if (nuidp->nu_flag & NU_NAM)
287 1.19 fvdl m_freem(nuidp->nu_nam);
288 1.10 mycroft }
289 1.19 fvdl nuidp->nu_flag = 0;
290 1.48.2.4 nathanw crcvt(&nuidp->nu_cr, &nsd->nsd_cr);
291 1.10 mycroft if (nuidp->nu_cr.cr_ngroups > NGROUPS)
292 1.19 fvdl nuidp->nu_cr.cr_ngroups = NGROUPS;
293 1.10 mycroft nuidp->nu_cr.cr_ref = 1;
294 1.19 fvdl nuidp->nu_timestamp = nsd->nsd_timestamp;
295 1.19 fvdl nuidp->nu_expire = time.tv_sec + nsd->nsd_ttl;
296 1.19 fvdl /*
297 1.19 fvdl * and save the session key in nu_key.
298 1.19 fvdl */
299 1.32 perry memcpy(nuidp->nu_key, nsd->nsd_key,
300 1.32 perry sizeof(nsd->nsd_key));
301 1.19 fvdl if (nfsd->nfsd_nd->nd_nam2) {
302 1.19 fvdl struct sockaddr_in *saddr;
303 1.19 fvdl
304 1.19 fvdl saddr = mtod(nfsd->nfsd_nd->nd_nam2,
305 1.19 fvdl struct sockaddr_in *);
306 1.19 fvdl switch (saddr->sin_family) {
307 1.19 fvdl case AF_INET:
308 1.19 fvdl nuidp->nu_flag |= NU_INETADDR;
309 1.19 fvdl nuidp->nu_inetaddr =
310 1.19 fvdl saddr->sin_addr.s_addr;
311 1.19 fvdl break;
312 1.19 fvdl case AF_ISO:
313 1.19 fvdl default:
314 1.19 fvdl nuidp->nu_flag |= NU_NAM;
315 1.19 fvdl nuidp->nu_nam = m_copym(
316 1.19 fvdl nfsd->nfsd_nd->nd_nam2, 0,
317 1.19 fvdl M_COPYALL, M_WAIT);
318 1.19 fvdl break;
319 1.19 fvdl };
320 1.19 fvdl }
321 1.12 mycroft TAILQ_INSERT_TAIL(&slp->ns_uidlruhead, nuidp,
322 1.19 fvdl nu_lru);
323 1.12 mycroft LIST_INSERT_HEAD(NUIDHASH(slp, nsd->nsd_uid),
324 1.19 fvdl nuidp, nu_hash);
325 1.19 fvdl nfsrv_setcred(&nuidp->nu_cr,
326 1.19 fvdl &nfsd->nfsd_nd->nd_cr);
327 1.19 fvdl nfsd->nfsd_nd->nd_flag |= ND_KERBFULL;
328 1.10 mycroft }
329 1.10 mycroft }
330 1.10 mycroft }
331 1.13 cgd if ((SCARG(uap, flag) & NFSSVC_AUTHINFAIL) &&
332 1.13 cgd (nfsd = nsd->nsd_nfsd))
333 1.19 fvdl nfsd->nfsd_flag |= NFSD_AUTHFAIL;
334 1.48.2.1 nathanw error = nfssvc_nfsd(nsd, SCARG(uap, argp), l);
335 1.10 mycroft #endif /* !NFSSERVER */
336 1.10 mycroft }
337 1.10 mycroft if (error == EINTR || error == ERESTART)
338 1.10 mycroft error = 0;
339 1.10 mycroft return (error);
340 1.10 mycroft }
341 1.10 mycroft
342 1.10 mycroft #ifdef NFSSERVER
343 1.10 mycroft /*
344 1.10 mycroft * Adds a socket to the list for servicing by nfsds.
345 1.10 mycroft */
346 1.18 christos int
347 1.10 mycroft nfssvc_addsock(fp, mynam)
348 1.10 mycroft struct file *fp;
349 1.10 mycroft struct mbuf *mynam;
350 1.10 mycroft {
351 1.38 augustss struct mbuf *m;
352 1.38 augustss int siz;
353 1.38 augustss struct nfssvc_sock *slp;
354 1.38 augustss struct socket *so;
355 1.10 mycroft struct nfssvc_sock *tslp;
356 1.10 mycroft int error, s;
357 1.10 mycroft
358 1.1 cgd so = (struct socket *)fp->f_data;
359 1.10 mycroft tslp = (struct nfssvc_sock *)0;
360 1.10 mycroft /*
361 1.10 mycroft * Add it to the list, as required.
362 1.10 mycroft */
363 1.10 mycroft if (so->so_proto->pr_protocol == IPPROTO_UDP) {
364 1.41 fvdl #ifdef INET6
365 1.41 fvdl if (so->so_proto->pr_domain->dom_family == AF_INET6)
366 1.41 fvdl tslp = nfs_udp6sock;
367 1.41 fvdl else
368 1.41 fvdl #endif
369 1.10 mycroft tslp = nfs_udpsock;
370 1.10 mycroft if (tslp->ns_flag & SLP_VALID) {
371 1.10 mycroft m_freem(mynam);
372 1.10 mycroft return (EPERM);
373 1.10 mycroft }
374 1.10 mycroft #ifdef ISO
375 1.10 mycroft } else if (so->so_proto->pr_protocol == ISOPROTO_CLTP) {
376 1.10 mycroft tslp = nfs_cltpsock;
377 1.10 mycroft if (tslp->ns_flag & SLP_VALID) {
378 1.10 mycroft m_freem(mynam);
379 1.10 mycroft return (EPERM);
380 1.10 mycroft }
381 1.10 mycroft #endif /* ISO */
382 1.10 mycroft }
383 1.10 mycroft if (so->so_type == SOCK_STREAM)
384 1.19 fvdl siz = NFS_MAXPACKET + sizeof (u_long);
385 1.10 mycroft else
386 1.1 cgd siz = NFS_MAXPACKET;
387 1.19 fvdl error = soreserve(so, siz, siz);
388 1.19 fvdl if (error) {
389 1.10 mycroft m_freem(mynam);
390 1.10 mycroft return (error);
391 1.10 mycroft }
392 1.1 cgd
393 1.1 cgd /*
394 1.1 cgd * Set protocol specific options { for now TCP only } and
395 1.1 cgd * reserve some space. For datagram sockets, this can get called
396 1.1 cgd * repeatedly for the same socket, but that isn't harmful.
397 1.1 cgd */
398 1.10 mycroft if (so->so_type == SOCK_STREAM) {
399 1.1 cgd MGET(m, M_WAIT, MT_SOOPTS);
400 1.19 fvdl *mtod(m, int32_t *) = 1;
401 1.19 fvdl m->m_len = sizeof(int32_t);
402 1.1 cgd sosetopt(so, SOL_SOCKET, SO_KEEPALIVE, m);
403 1.1 cgd }
404 1.41 fvdl if ((so->so_proto->pr_domain->dom_family == AF_INET
405 1.41 fvdl #ifdef INET6
406 1.41 fvdl || so->so_proto->pr_domain->dom_family == AF_INET6
407 1.41 fvdl #endif
408 1.41 fvdl ) &&
409 1.10 mycroft so->so_proto->pr_protocol == IPPROTO_TCP) {
410 1.1 cgd MGET(m, M_WAIT, MT_SOOPTS);
411 1.19 fvdl *mtod(m, int32_t *) = 1;
412 1.19 fvdl m->m_len = sizeof(int32_t);
413 1.1 cgd sosetopt(so, IPPROTO_TCP, TCP_NODELAY, m);
414 1.1 cgd }
415 1.1 cgd so->so_rcv.sb_flags &= ~SB_NOINTR;
416 1.1 cgd so->so_rcv.sb_timeo = 0;
417 1.1 cgd so->so_snd.sb_flags &= ~SB_NOINTR;
418 1.1 cgd so->so_snd.sb_timeo = 0;
419 1.10 mycroft if (tslp)
420 1.10 mycroft slp = tslp;
421 1.10 mycroft else {
422 1.10 mycroft slp = (struct nfssvc_sock *)
423 1.10 mycroft malloc(sizeof (struct nfssvc_sock), M_NFSSVC, M_WAITOK);
424 1.32 perry memset((caddr_t)slp, 0, sizeof (struct nfssvc_sock));
425 1.12 mycroft TAILQ_INIT(&slp->ns_uidlruhead);
426 1.12 mycroft TAILQ_INSERT_TAIL(&nfssvc_sockhead, slp, ns_chain);
427 1.10 mycroft }
428 1.10 mycroft slp->ns_so = so;
429 1.10 mycroft slp->ns_nam = mynam;
430 1.10 mycroft fp->f_count++;
431 1.10 mycroft slp->ns_fp = fp;
432 1.14 mycroft s = splsoftnet();
433 1.10 mycroft so->so_upcallarg = (caddr_t)slp;
434 1.10 mycroft so->so_upcall = nfsrv_rcv;
435 1.29 matt so->so_rcv.sb_flags |= SB_UPCALL;
436 1.10 mycroft slp->ns_flag = (SLP_VALID | SLP_NEEDQ);
437 1.10 mycroft nfsrv_wakenfsd(slp);
438 1.10 mycroft splx(s);
439 1.10 mycroft return (0);
440 1.10 mycroft }
441 1.1 cgd
442 1.10 mycroft /*
443 1.10 mycroft * Called by nfssvc() for nfsds. Just loops around servicing rpc requests
444 1.10 mycroft * until it is killed by a signal.
445 1.10 mycroft */
446 1.18 christos int
447 1.48.2.1 nathanw nfssvc_nfsd(nsd, argp, l)
448 1.10 mycroft struct nfsd_srvargs *nsd;
449 1.10 mycroft caddr_t argp;
450 1.48.2.1 nathanw struct lwp *l;
451 1.10 mycroft {
452 1.38 augustss struct mbuf *m;
453 1.38 augustss int siz;
454 1.38 augustss struct nfssvc_sock *slp;
455 1.38 augustss struct socket *so;
456 1.38 augustss int *solockp;
457 1.19 fvdl struct nfsd *nfsd = nsd->nsd_nfsd;
458 1.19 fvdl struct nfsrv_descript *nd = NULL;
459 1.19 fvdl struct mbuf *mreq;
460 1.19 fvdl int error = 0, cacherep, s, sotype, writes_todo;
461 1.19 fvdl u_quad_t cur_usec;
462 1.48.2.1 nathanw struct proc *p = l->l_proc;
463 1.19 fvdl
464 1.19 fvdl #ifndef nolint
465 1.19 fvdl cacherep = RC_DOIT;
466 1.19 fvdl writes_todo = 0;
467 1.19 fvdl #endif
468 1.14 mycroft s = splsoftnet();
469 1.19 fvdl if (nfsd == (struct nfsd *)0) {
470 1.19 fvdl nsd->nsd_nfsd = nfsd = (struct nfsd *)
471 1.10 mycroft malloc(sizeof (struct nfsd), M_NFSD, M_WAITOK);
472 1.32 perry memset((caddr_t)nfsd, 0, sizeof (struct nfsd));
473 1.19 fvdl nfsd->nfsd_procp = p;
474 1.19 fvdl TAILQ_INSERT_TAIL(&nfsd_head, nfsd, nfsd_chain);
475 1.10 mycroft nfs_numnfsd++;
476 1.10 mycroft }
477 1.48.2.1 nathanw PHOLD(l);
478 1.1 cgd /*
479 1.10 mycroft * Loop getting rpc requests until SIGKILL.
480 1.1 cgd */
481 1.1 cgd for (;;) {
482 1.19 fvdl if ((nfsd->nfsd_flag & NFSD_REQINPROG) == 0) {
483 1.19 fvdl while (nfsd->nfsd_slp == (struct nfssvc_sock *)0 &&
484 1.12 mycroft (nfsd_head_flag & NFSD_CHECKSLP) == 0) {
485 1.19 fvdl nfsd->nfsd_flag |= NFSD_WAITING;
486 1.10 mycroft nfsd_waiting++;
487 1.19 fvdl error = tsleep((caddr_t)nfsd, PSOCK | PCATCH,
488 1.19 fvdl "nfsd", 0);
489 1.10 mycroft nfsd_waiting--;
490 1.10 mycroft if (error)
491 1.10 mycroft goto done;
492 1.10 mycroft }
493 1.19 fvdl if (nfsd->nfsd_slp == (struct nfssvc_sock *)0 &&
494 1.12 mycroft (nfsd_head_flag & NFSD_CHECKSLP) != 0) {
495 1.12 mycroft for (slp = nfssvc_sockhead.tqh_first; slp != 0;
496 1.12 mycroft slp = slp->ns_chain.tqe_next) {
497 1.10 mycroft if ((slp->ns_flag & (SLP_VALID | SLP_DOREC))
498 1.10 mycroft == (SLP_VALID | SLP_DOREC)) {
499 1.10 mycroft slp->ns_flag &= ~SLP_DOREC;
500 1.10 mycroft slp->ns_sref++;
501 1.19 fvdl nfsd->nfsd_slp = slp;
502 1.10 mycroft break;
503 1.10 mycroft }
504 1.10 mycroft }
505 1.12 mycroft if (slp == 0)
506 1.12 mycroft nfsd_head_flag &= ~NFSD_CHECKSLP;
507 1.10 mycroft }
508 1.19 fvdl if ((slp = nfsd->nfsd_slp) == (struct nfssvc_sock *)0)
509 1.10 mycroft continue;
510 1.10 mycroft if (slp->ns_flag & SLP_VALID) {
511 1.10 mycroft if (slp->ns_flag & SLP_DISCONN)
512 1.10 mycroft nfsrv_zapsock(slp);
513 1.10 mycroft else if (slp->ns_flag & SLP_NEEDQ) {
514 1.10 mycroft slp->ns_flag &= ~SLP_NEEDQ;
515 1.10 mycroft (void) nfs_sndlock(&slp->ns_solock,
516 1.10 mycroft (struct nfsreq *)0);
517 1.10 mycroft nfsrv_rcv(slp->ns_so, (caddr_t)slp,
518 1.10 mycroft M_WAIT);
519 1.10 mycroft nfs_sndunlock(&slp->ns_solock);
520 1.10 mycroft }
521 1.19 fvdl error = nfsrv_dorec(slp, nfsd, &nd);
522 1.19 fvdl cur_usec = (u_quad_t)time.tv_sec * 1000000 +
523 1.19 fvdl (u_quad_t)time.tv_usec;
524 1.19 fvdl if (error && slp->ns_tq.lh_first &&
525 1.19 fvdl slp->ns_tq.lh_first->nd_time <= cur_usec) {
526 1.19 fvdl error = 0;
527 1.19 fvdl cacherep = RC_DOIT;
528 1.19 fvdl writes_todo = 1;
529 1.19 fvdl } else
530 1.19 fvdl writes_todo = 0;
531 1.19 fvdl nfsd->nfsd_flag |= NFSD_REQINPROG;
532 1.1 cgd }
533 1.10 mycroft } else {
534 1.10 mycroft error = 0;
535 1.19 fvdl slp = nfsd->nfsd_slp;
536 1.10 mycroft }
537 1.10 mycroft if (error || (slp->ns_flag & SLP_VALID) == 0) {
538 1.19 fvdl if (nd) {
539 1.19 fvdl free((caddr_t)nd, M_NFSRVDESC);
540 1.19 fvdl nd = NULL;
541 1.19 fvdl }
542 1.19 fvdl nfsd->nfsd_slp = (struct nfssvc_sock *)0;
543 1.19 fvdl nfsd->nfsd_flag &= ~NFSD_REQINPROG;
544 1.10 mycroft nfsrv_slpderef(slp);
545 1.1 cgd continue;
546 1.1 cgd }
547 1.10 mycroft splx(s);
548 1.10 mycroft so = slp->ns_so;
549 1.10 mycroft sotype = so->so_type;
550 1.10 mycroft if (so->so_proto->pr_flags & PR_CONNREQUIRED)
551 1.10 mycroft solockp = &slp->ns_solock;
552 1.10 mycroft else
553 1.10 mycroft solockp = (int *)0;
554 1.19 fvdl if (nd) {
555 1.19 fvdl nd->nd_starttime = time;
556 1.19 fvdl if (nd->nd_nam2)
557 1.19 fvdl nd->nd_nam = nd->nd_nam2;
558 1.19 fvdl else
559 1.19 fvdl nd->nd_nam = slp->ns_nam;
560 1.19 fvdl
561 1.19 fvdl /*
562 1.19 fvdl * Check to see if authorization is needed.
563 1.19 fvdl */
564 1.19 fvdl if (nfsd->nfsd_flag & NFSD_NEEDAUTH) {
565 1.19 fvdl nfsd->nfsd_flag &= ~NFSD_NEEDAUTH;
566 1.19 fvdl nsd->nsd_haddr = mtod(nd->nd_nam,
567 1.19 fvdl struct sockaddr_in *)->sin_addr.s_addr;
568 1.19 fvdl nsd->nsd_authlen = nfsd->nfsd_authlen;
569 1.19 fvdl nsd->nsd_verflen = nfsd->nfsd_verflen;
570 1.19 fvdl if (!copyout(nfsd->nfsd_authstr,nsd->nsd_authstr,
571 1.19 fvdl nfsd->nfsd_authlen) &&
572 1.19 fvdl !copyout(nfsd->nfsd_verfstr, nsd->nsd_verfstr,
573 1.19 fvdl nfsd->nfsd_verflen) &&
574 1.33 mycroft !copyout((caddr_t)nsd, argp, sizeof (*nsd))) {
575 1.48.2.1 nathanw PRELE(l);
576 1.19 fvdl return (ENEEDAUTH);
577 1.33 mycroft }
578 1.19 fvdl cacherep = RC_DROPIT;
579 1.19 fvdl } else
580 1.19 fvdl cacherep = nfsrv_getcache(nd, slp, &mreq);
581 1.19 fvdl
582 1.19 fvdl /*
583 1.19 fvdl * Check for just starting up for NQNFS and send
584 1.19 fvdl * fake "try again later" replies to the NQNFS clients.
585 1.19 fvdl */
586 1.19 fvdl if (notstarted && nqnfsstarttime <= time.tv_sec) {
587 1.10 mycroft if (modify_flag) {
588 1.10 mycroft nqnfsstarttime = time.tv_sec + nqsrv_writeslack;
589 1.10 mycroft modify_flag = 0;
590 1.10 mycroft } else
591 1.10 mycroft notstarted = 0;
592 1.19 fvdl }
593 1.19 fvdl if (notstarted) {
594 1.19 fvdl if ((nd->nd_flag & ND_NQNFS) == 0)
595 1.10 mycroft cacherep = RC_DROPIT;
596 1.10 mycroft else if (nd->nd_procnum != NFSPROC_WRITE) {
597 1.10 mycroft nd->nd_procnum = NFSPROC_NOOP;
598 1.10 mycroft nd->nd_repstat = NQNFS_TRYLATER;
599 1.10 mycroft cacherep = RC_DOIT;
600 1.10 mycroft } else
601 1.10 mycroft modify_flag = 1;
602 1.19 fvdl } else if (nfsd->nfsd_flag & NFSD_AUTHFAIL) {
603 1.19 fvdl nfsd->nfsd_flag &= ~NFSD_AUTHFAIL;
604 1.10 mycroft nd->nd_procnum = NFSPROC_NOOP;
605 1.19 fvdl nd->nd_repstat = (NFSERR_AUTHERR | AUTH_TOOWEAK);
606 1.1 cgd cacherep = RC_DOIT;
607 1.19 fvdl }
608 1.10 mycroft }
609 1.10 mycroft
610 1.19 fvdl /*
611 1.19 fvdl * Loop to get all the write rpc relies that have been
612 1.19 fvdl * gathered together.
613 1.19 fvdl */
614 1.19 fvdl do {
615 1.34 sommerfe #ifdef DIAGNOSTIC
616 1.34 sommerfe int lockcount;
617 1.34 sommerfe #endif
618 1.19 fvdl switch (cacherep) {
619 1.19 fvdl case RC_DOIT:
620 1.34 sommerfe #ifdef DIAGNOSTIC
621 1.34 sommerfe /*
622 1.34 sommerfe * NFS server procs should neither release
623 1.34 sommerfe * locks already held, nor leave things
624 1.34 sommerfe * locked. Catch this sooner, rather than
625 1.34 sommerfe * later (when we try to relock something we
626 1.34 sommerfe * already have locked). Careful inspection
627 1.34 sommerfe * of the failing routine usually turns up the
628 1.34 sommerfe * lock leak.. once we know what it is..
629 1.34 sommerfe */
630 1.48.2.3 thorpej lockcount = l->l_locks;
631 1.34 sommerfe #endif
632 1.44 fvdl if (writes_todo || (!(nd->nd_flag & ND_NFSV3) &&
633 1.44 fvdl nd->nd_procnum == NFSPROC_WRITE &&
634 1.44 fvdl nfsrvw_procrastinate > 0 && !notstarted))
635 1.19 fvdl error = nfsrv_writegather(&nd, slp,
636 1.19 fvdl nfsd->nfsd_procp, &mreq);
637 1.19 fvdl else
638 1.19 fvdl error = (*(nfsrv3_procs[nd->nd_procnum]))(nd,
639 1.19 fvdl slp, nfsd->nfsd_procp, &mreq);
640 1.34 sommerfe #ifdef DIAGNOSTIC
641 1.48.2.3 thorpej if (l->l_locks != lockcount) {
642 1.34 sommerfe /*
643 1.34 sommerfe * If you see this panic, audit
644 1.34 sommerfe * nfsrv3_procs[nd->nd_procnum] for vnode
645 1.34 sommerfe * locking errors (usually, it's due to
646 1.34 sommerfe * forgetting to vput() something).
647 1.34 sommerfe */
648 1.46 matt #ifdef DEBUG
649 1.46 matt extern void printlockedvnodes(void);
650 1.46 matt printlockedvnodes();
651 1.46 matt #endif
652 1.46 matt printf("nfsd: locking botch in op %d"
653 1.46 matt " (before %d, after %d)\n",
654 1.46 matt nd ? nd->nd_procnum : -1,
655 1.48.2.3 thorpej lockcount, l->l_locks);
656 1.34 sommerfe }
657 1.34 sommerfe #endif
658 1.19 fvdl if (mreq == NULL)
659 1.19 fvdl break;
660 1.10 mycroft if (error) {
661 1.10 mycroft if (nd->nd_procnum != NQNFSPROC_VACATED)
662 1.10 mycroft nfsstats.srv_errs++;
663 1.19 fvdl nfsrv_updatecache(nd, FALSE, mreq);
664 1.19 fvdl if (nd->nd_nam2)
665 1.19 fvdl m_freem(nd->nd_nam2);
666 1.1 cgd break;
667 1.1 cgd }
668 1.10 mycroft nfsstats.srvrpccnt[nd->nd_procnum]++;
669 1.19 fvdl nfsrv_updatecache(nd, TRUE, mreq);
670 1.10 mycroft nd->nd_mrep = (struct mbuf *)0;
671 1.19 fvdl case RC_REPLY:
672 1.1 cgd m = mreq;
673 1.1 cgd siz = 0;
674 1.1 cgd while (m) {
675 1.1 cgd siz += m->m_len;
676 1.1 cgd m = m->m_next;
677 1.1 cgd }
678 1.1 cgd if (siz <= 0 || siz > NFS_MAXPACKET) {
679 1.21 christos printf("mbuf siz=%d\n",siz);
680 1.1 cgd panic("Bad nfs svc reply");
681 1.1 cgd }
682 1.10 mycroft m = mreq;
683 1.10 mycroft m->m_pkthdr.len = siz;
684 1.10 mycroft m->m_pkthdr.rcvif = (struct ifnet *)0;
685 1.1 cgd /*
686 1.10 mycroft * For stream protocols, prepend a Sun RPC
687 1.1 cgd * Record Mark.
688 1.1 cgd */
689 1.10 mycroft if (sotype == SOCK_STREAM) {
690 1.10 mycroft M_PREPEND(m, NFSX_UNSIGNED, M_WAIT);
691 1.17 cgd *mtod(m, u_int32_t *) = htonl(0x80000000 | siz);
692 1.10 mycroft }
693 1.10 mycroft if (solockp)
694 1.10 mycroft (void) nfs_sndlock(solockp, (struct nfsreq *)0);
695 1.10 mycroft if (slp->ns_flag & SLP_VALID)
696 1.19 fvdl error = nfs_send(so, nd->nd_nam2, m, NULL);
697 1.10 mycroft else {
698 1.10 mycroft error = EPIPE;
699 1.10 mycroft m_freem(m);
700 1.10 mycroft }
701 1.10 mycroft if (nfsrtton)
702 1.19 fvdl nfsd_rt(sotype, nd, cacherep);
703 1.19 fvdl if (nd->nd_nam2)
704 1.19 fvdl MFREE(nd->nd_nam2, m);
705 1.10 mycroft if (nd->nd_mrep)
706 1.10 mycroft m_freem(nd->nd_mrep);
707 1.10 mycroft if (error == EPIPE)
708 1.10 mycroft nfsrv_zapsock(slp);
709 1.10 mycroft if (solockp)
710 1.10 mycroft nfs_sndunlock(solockp);
711 1.10 mycroft if (error == EINTR || error == ERESTART) {
712 1.19 fvdl free((caddr_t)nd, M_NFSRVDESC);
713 1.10 mycroft nfsrv_slpderef(slp);
714 1.14 mycroft s = splsoftnet();
715 1.10 mycroft goto done;
716 1.1 cgd }
717 1.1 cgd break;
718 1.19 fvdl case RC_DROPIT:
719 1.10 mycroft if (nfsrtton)
720 1.19 fvdl nfsd_rt(sotype, nd, cacherep);
721 1.10 mycroft m_freem(nd->nd_mrep);
722 1.19 fvdl m_freem(nd->nd_nam2);
723 1.1 cgd break;
724 1.19 fvdl };
725 1.19 fvdl if (nd) {
726 1.19 fvdl FREE((caddr_t)nd, M_NFSRVDESC);
727 1.19 fvdl nd = NULL;
728 1.19 fvdl }
729 1.19 fvdl
730 1.19 fvdl /*
731 1.19 fvdl * Check to see if there are outstanding writes that
732 1.19 fvdl * need to be serviced.
733 1.19 fvdl */
734 1.19 fvdl cur_usec = (u_quad_t)time.tv_sec * 1000000 +
735 1.19 fvdl (u_quad_t)time.tv_usec;
736 1.19 fvdl s = splsoftclock();
737 1.19 fvdl if (slp->ns_tq.lh_first &&
738 1.19 fvdl slp->ns_tq.lh_first->nd_time <= cur_usec) {
739 1.19 fvdl cacherep = RC_DOIT;
740 1.19 fvdl writes_todo = 1;
741 1.19 fvdl } else
742 1.19 fvdl writes_todo = 0;
743 1.19 fvdl splx(s);
744 1.19 fvdl } while (writes_todo);
745 1.14 mycroft s = splsoftnet();
746 1.19 fvdl if (nfsrv_dorec(slp, nfsd, &nd)) {
747 1.19 fvdl nfsd->nfsd_flag &= ~NFSD_REQINPROG;
748 1.19 fvdl nfsd->nfsd_slp = NULL;
749 1.10 mycroft nfsrv_slpderef(slp);
750 1.10 mycroft }
751 1.1 cgd }
752 1.10 mycroft done:
753 1.48.2.1 nathanw PRELE(l);
754 1.19 fvdl TAILQ_REMOVE(&nfsd_head, nfsd, nfsd_chain);
755 1.10 mycroft splx(s);
756 1.19 fvdl free((caddr_t)nfsd, M_NFSD);
757 1.10 mycroft nsd->nsd_nfsd = (struct nfsd *)0;
758 1.10 mycroft if (--nfs_numnfsd == 0)
759 1.10 mycroft nfsrv_init(TRUE); /* Reinitialize everything */
760 1.1 cgd return (error);
761 1.1 cgd }
762 1.1 cgd
763 1.10 mycroft /*
764 1.10 mycroft * Shut down a socket associated with an nfssvc_sock structure.
765 1.10 mycroft * Should be called with the send lock set, if required.
766 1.10 mycroft * The trick here is to increment the sref at the start, so that the nfsds
767 1.10 mycroft * will stop using it and clear ns_flag at the end so that it will not be
768 1.10 mycroft * reassigned during cleanup.
769 1.10 mycroft */
770 1.18 christos void
771 1.10 mycroft nfsrv_zapsock(slp)
772 1.38 augustss struct nfssvc_sock *slp;
773 1.10 mycroft {
774 1.38 augustss struct nfsuid *nuidp, *nnuidp;
775 1.38 augustss struct nfsrv_descript *nwp, *nnwp;
776 1.10 mycroft struct socket *so;
777 1.10 mycroft struct file *fp;
778 1.10 mycroft struct mbuf *m;
779 1.19 fvdl int s;
780 1.10 mycroft
781 1.10 mycroft slp->ns_flag &= ~SLP_ALLFLAGS;
782 1.19 fvdl fp = slp->ns_fp;
783 1.19 fvdl if (fp) {
784 1.35 thorpej FILE_USE(fp);
785 1.10 mycroft slp->ns_fp = (struct file *)0;
786 1.10 mycroft so = slp->ns_so;
787 1.10 mycroft so->so_upcall = NULL;
788 1.29 matt so->so_upcallarg = NULL;
789 1.29 matt so->so_rcv.sb_flags &= ~SB_UPCALL;
790 1.10 mycroft soshutdown(so, 2);
791 1.10 mycroft closef(fp, (struct proc *)0);
792 1.10 mycroft if (slp->ns_nam)
793 1.10 mycroft MFREE(slp->ns_nam, m);
794 1.10 mycroft m_freem(slp->ns_raw);
795 1.10 mycroft m_freem(slp->ns_rec);
796 1.12 mycroft for (nuidp = slp->ns_uidlruhead.tqh_first; nuidp != 0;
797 1.12 mycroft nuidp = nnuidp) {
798 1.12 mycroft nnuidp = nuidp->nu_lru.tqe_next;
799 1.12 mycroft LIST_REMOVE(nuidp, nu_hash);
800 1.12 mycroft TAILQ_REMOVE(&slp->ns_uidlruhead, nuidp, nu_lru);
801 1.19 fvdl if (nuidp->nu_flag & NU_NAM)
802 1.19 fvdl m_freem(nuidp->nu_nam);
803 1.12 mycroft free((caddr_t)nuidp, M_NFSUID);
804 1.12 mycroft }
805 1.19 fvdl s = splsoftclock();
806 1.19 fvdl for (nwp = slp->ns_tq.lh_first; nwp; nwp = nnwp) {
807 1.19 fvdl nnwp = nwp->nd_tq.le_next;
808 1.19 fvdl LIST_REMOVE(nwp, nd_tq);
809 1.19 fvdl free((caddr_t)nwp, M_NFSRVDESC);
810 1.19 fvdl }
811 1.19 fvdl LIST_INIT(&slp->ns_tq);
812 1.19 fvdl splx(s);
813 1.10 mycroft }
814 1.10 mycroft }
815 1.10 mycroft
816 1.10 mycroft /*
817 1.10 mycroft * Derefence a server socket structure. If it has no more references and
818 1.10 mycroft * is no longer valid, you can throw it away.
819 1.10 mycroft */
820 1.10 mycroft void
821 1.10 mycroft nfsrv_slpderef(slp)
822 1.38 augustss struct nfssvc_sock *slp;
823 1.10 mycroft {
824 1.10 mycroft if (--(slp->ns_sref) == 0 && (slp->ns_flag & SLP_VALID) == 0) {
825 1.12 mycroft TAILQ_REMOVE(&nfssvc_sockhead, slp, ns_chain);
826 1.10 mycroft free((caddr_t)slp, M_NFSSVC);
827 1.10 mycroft }
828 1.10 mycroft }
829 1.10 mycroft
830 1.10 mycroft /*
831 1.10 mycroft * Initialize the data structures for the server.
832 1.10 mycroft * Handshake with any new nfsds starting up to avoid any chance of
833 1.10 mycroft * corruption.
834 1.10 mycroft */
835 1.10 mycroft void
836 1.10 mycroft nfsrv_init(terminating)
837 1.10 mycroft int terminating;
838 1.10 mycroft {
839 1.38 augustss struct nfssvc_sock *slp, *nslp;
840 1.10 mycroft
841 1.12 mycroft if (nfssvc_sockhead_flag & SLP_INIT)
842 1.10 mycroft panic("nfsd init");
843 1.12 mycroft nfssvc_sockhead_flag |= SLP_INIT;
844 1.10 mycroft if (terminating) {
845 1.12 mycroft for (slp = nfssvc_sockhead.tqh_first; slp != 0; slp = nslp) {
846 1.12 mycroft nslp = slp->ns_chain.tqe_next;
847 1.10 mycroft if (slp->ns_flag & SLP_VALID)
848 1.10 mycroft nfsrv_zapsock(slp);
849 1.12 mycroft TAILQ_REMOVE(&nfssvc_sockhead, slp, ns_chain);
850 1.12 mycroft free((caddr_t)slp, M_NFSSVC);
851 1.10 mycroft }
852 1.10 mycroft nfsrv_cleancache(); /* And clear out server cache */
853 1.26 fvdl } else
854 1.26 fvdl nfs_pub.np_valid = 0;
855 1.12 mycroft
856 1.12 mycroft TAILQ_INIT(&nfssvc_sockhead);
857 1.12 mycroft nfssvc_sockhead_flag &= ~SLP_INIT;
858 1.12 mycroft if (nfssvc_sockhead_flag & SLP_WANTINIT) {
859 1.12 mycroft nfssvc_sockhead_flag &= ~SLP_WANTINIT;
860 1.12 mycroft wakeup((caddr_t)&nfssvc_sockhead);
861 1.12 mycroft }
862 1.12 mycroft
863 1.12 mycroft TAILQ_INIT(&nfsd_head);
864 1.12 mycroft nfsd_head_flag &= ~NFSD_CHECKSLP;
865 1.12 mycroft
866 1.10 mycroft nfs_udpsock = (struct nfssvc_sock *)
867 1.10 mycroft malloc(sizeof (struct nfssvc_sock), M_NFSSVC, M_WAITOK);
868 1.32 perry memset((caddr_t)nfs_udpsock, 0, sizeof (struct nfssvc_sock));
869 1.12 mycroft TAILQ_INIT(&nfs_udpsock->ns_uidlruhead);
870 1.12 mycroft TAILQ_INSERT_HEAD(&nfssvc_sockhead, nfs_udpsock, ns_chain);
871 1.41 fvdl
872 1.41 fvdl #ifdef INET6
873 1.41 fvdl nfs_udp6sock = (struct nfssvc_sock *)
874 1.41 fvdl malloc(sizeof (struct nfssvc_sock), M_NFSSVC, M_WAITOK);
875 1.41 fvdl memset((caddr_t)nfs_udp6sock, 0, sizeof (struct nfssvc_sock));
876 1.41 fvdl TAILQ_INIT(&nfs_udp6sock->ns_uidlruhead);
877 1.41 fvdl TAILQ_INSERT_TAIL(&nfssvc_sockhead, nfs_udp6sock, ns_chain);
878 1.41 fvdl #endif
879 1.12 mycroft
880 1.47 chs #ifdef ISO
881 1.10 mycroft nfs_cltpsock = (struct nfssvc_sock *)
882 1.10 mycroft malloc(sizeof (struct nfssvc_sock), M_NFSSVC, M_WAITOK);
883 1.32 perry memset((caddr_t)nfs_cltpsock, 0, sizeof (struct nfssvc_sock));
884 1.12 mycroft TAILQ_INIT(&nfs_cltpsock->ns_uidlruhead);
885 1.12 mycroft TAILQ_INSERT_TAIL(&nfssvc_sockhead, nfs_cltpsock, ns_chain);
886 1.47 chs #endif
887 1.10 mycroft }
888 1.10 mycroft
889 1.10 mycroft /*
890 1.10 mycroft * Add entries to the server monitor log.
891 1.10 mycroft */
892 1.10 mycroft static void
893 1.19 fvdl nfsd_rt(sotype, nd, cacherep)
894 1.10 mycroft int sotype;
895 1.38 augustss struct nfsrv_descript *nd;
896 1.10 mycroft int cacherep;
897 1.10 mycroft {
898 1.38 augustss struct drt *rt;
899 1.10 mycroft
900 1.10 mycroft rt = &nfsdrt.drt[nfsdrt.pos];
901 1.10 mycroft if (cacherep == RC_DOIT)
902 1.10 mycroft rt->flag = 0;
903 1.10 mycroft else if (cacherep == RC_REPLY)
904 1.10 mycroft rt->flag = DRT_CACHEREPLY;
905 1.10 mycroft else
906 1.10 mycroft rt->flag = DRT_CACHEDROP;
907 1.10 mycroft if (sotype == SOCK_STREAM)
908 1.10 mycroft rt->flag |= DRT_TCP;
909 1.19 fvdl if (nd->nd_flag & ND_NQNFS)
910 1.10 mycroft rt->flag |= DRT_NQNFS;
911 1.19 fvdl else if (nd->nd_flag & ND_NFSV3)
912 1.19 fvdl rt->flag |= DRT_NFSV3;
913 1.10 mycroft rt->proc = nd->nd_procnum;
914 1.19 fvdl if (mtod(nd->nd_nam, struct sockaddr *)->sa_family == AF_INET)
915 1.19 fvdl rt->ipadr = mtod(nd->nd_nam, struct sockaddr_in *)->sin_addr.s_addr;
916 1.10 mycroft else
917 1.19 fvdl rt->ipadr = INADDR_ANY;
918 1.19 fvdl rt->resptime = ((time.tv_sec - nd->nd_starttime.tv_sec) * 1000000) +
919 1.19 fvdl (time.tv_usec - nd->nd_starttime.tv_usec);
920 1.10 mycroft rt->tstamp = time;
921 1.10 mycroft nfsdrt.pos = (nfsdrt.pos + 1) % NFSRTTLOGSIZ;
922 1.10 mycroft }
923 1.3 glass #endif /* NFSSERVER */
924 1.3 glass
925 1.24 thorpej #ifdef NFS
926 1.22 thorpej
927 1.22 thorpej int nfs_defect = 0;
928 1.1 cgd /*
929 1.39 tsarna * Asynchronous I/O threads for client nfs.
930 1.10 mycroft * They do read-ahead and write-behind operations on the block I/O cache.
931 1.10 mycroft * Never returns unless it fails or gets killed.
932 1.1 cgd */
933 1.39 tsarna
934 1.18 christos int
935 1.48.2.1 nathanw nfssvc_iod(l)
936 1.48.2.1 nathanw struct lwp *l;
937 1.1 cgd {
938 1.38 augustss struct buf *bp;
939 1.38 augustss int i, myiod;
940 1.22 thorpej struct nfsmount *nmp;
941 1.22 thorpej int error = 0;
942 1.48.2.1 nathanw struct proc *p = l->l_proc;
943 1.1 cgd
944 1.1 cgd /*
945 1.1 cgd * Assign my position or return error if too many already running
946 1.1 cgd */
947 1.1 cgd myiod = -1;
948 1.1 cgd for (i = 0; i < NFS_MAXASYNCDAEMON; i++)
949 1.39 tsarna if (nfs_asyncdaemon[i] == NULL) {
950 1.1 cgd myiod = i;
951 1.1 cgd break;
952 1.1 cgd }
953 1.1 cgd if (myiod == -1)
954 1.1 cgd return (EBUSY);
955 1.39 tsarna nfs_asyncdaemon[myiod] = p;
956 1.1 cgd nfs_numasync++;
957 1.48.2.1 nathanw PHOLD(l);
958 1.1 cgd /*
959 1.42 nathanw * Just loop around doing our stuff until SIGKILL
960 1.1 cgd */
961 1.1 cgd for (;;) {
962 1.22 thorpej while (((nmp = nfs_iodmount[myiod]) == NULL
963 1.22 thorpej || nmp->nm_bufq.tqh_first == NULL)
964 1.22 thorpej && error == 0) {
965 1.22 thorpej if (nmp)
966 1.22 thorpej nmp->nm_bufqiods--;
967 1.19 fvdl nfs_iodwant[myiod] = p;
968 1.22 thorpej nfs_iodmount[myiod] = NULL;
969 1.19 fvdl error = tsleep((caddr_t)&nfs_iodwant[myiod],
970 1.19 fvdl PWAIT | PCATCH, "nfsidl", 0);
971 1.19 fvdl }
972 1.45 chs while (nmp != NULL && (bp = nmp->nm_bufq.tqh_first) != NULL) {
973 1.19 fvdl /* Take one off the front of the list */
974 1.22 thorpej TAILQ_REMOVE(&nmp->nm_bufq, bp, b_freelist);
975 1.22 thorpej nmp->nm_bufqlen--;
976 1.22 thorpej if (nmp->nm_bufqwant && nmp->nm_bufqlen < 2 * nfs_numasync) {
977 1.22 thorpej nmp->nm_bufqwant = FALSE;
978 1.22 thorpej wakeup(&nmp->nm_bufq);
979 1.22 thorpej }
980 1.48 chs (void) nfs_doio(bp, NULL);
981 1.22 thorpej /*
982 1.22 thorpej * If there are more than one iod on this mount, then defect
983 1.22 thorpej * so that the iods can be shared out fairly between the mounts
984 1.22 thorpej */
985 1.22 thorpej if (nfs_defect && nmp->nm_bufqiods > 1) {
986 1.22 thorpej nfs_iodmount[myiod] = NULL;
987 1.22 thorpej nmp->nm_bufqiods--;
988 1.22 thorpej break;
989 1.22 thorpej }
990 1.19 fvdl }
991 1.45 chs if (error) {
992 1.45 chs break;
993 1.45 chs }
994 1.1 cgd }
995 1.48.2.1 nathanw PRELE(l);
996 1.45 chs if (nmp)
997 1.45 chs nmp->nm_bufqiods--;
998 1.45 chs nfs_iodwant[myiod] = NULL;
999 1.45 chs nfs_iodmount[myiod] = NULL;
1000 1.39 tsarna nfs_asyncdaemon[myiod] = NULL;
1001 1.33 mycroft nfs_numasync--;
1002 1.39 tsarna
1003 1.33 mycroft return (error);
1004 1.1 cgd }
1005 1.3 glass
1006 1.39 tsarna void
1007 1.39 tsarna start_nfsio(arg)
1008 1.39 tsarna void *arg;
1009 1.39 tsarna {
1010 1.39 tsarna nfssvc_iod(curproc);
1011 1.39 tsarna
1012 1.39 tsarna kthread_exit(0);
1013 1.39 tsarna }
1014 1.39 tsarna
1015 1.39 tsarna void
1016 1.39 tsarna nfs_getset_niothreads(set)
1017 1.39 tsarna int set;
1018 1.39 tsarna {
1019 1.39 tsarna int i, have, start;
1020 1.39 tsarna
1021 1.39 tsarna for (have = 0, i = 0; i < NFS_MAXASYNCDAEMON; i++)
1022 1.39 tsarna if (nfs_asyncdaemon[i] != NULL)
1023 1.39 tsarna have++;
1024 1.39 tsarna
1025 1.39 tsarna if (set) {
1026 1.39 tsarna /* clamp to sane range */
1027 1.39 tsarna nfs_niothreads = max(0, min(nfs_niothreads, NFS_MAXASYNCDAEMON));
1028 1.39 tsarna
1029 1.39 tsarna start = nfs_niothreads - have;
1030 1.39 tsarna
1031 1.39 tsarna while (start > 0) {
1032 1.39 tsarna kthread_create1(start_nfsio, NULL, NULL, "nfsio");
1033 1.39 tsarna start--;
1034 1.39 tsarna }
1035 1.39 tsarna
1036 1.39 tsarna for (i = 0; (start < 0) && (i < NFS_MAXASYNCDAEMON); i++)
1037 1.39 tsarna if (nfs_asyncdaemon[i] != NULL) {
1038 1.39 tsarna psignal(nfs_asyncdaemon[i], SIGKILL);
1039 1.39 tsarna start++;
1040 1.39 tsarna }
1041 1.39 tsarna } else {
1042 1.40 tsarna if (nfs_niothreads >= 0)
1043 1.40 tsarna nfs_niothreads = have;
1044 1.39 tsarna }
1045 1.39 tsarna }
1046 1.19 fvdl
1047 1.10 mycroft /*
1048 1.10 mycroft * Get an authorization string for the uid by having the mount_nfs sitting
1049 1.10 mycroft * on this mount point porpous out of the kernel and do it.
1050 1.10 mycroft */
1051 1.18 christos int
1052 1.19 fvdl nfs_getauth(nmp, rep, cred, auth_str, auth_len, verf_str, verf_len, key)
1053 1.38 augustss struct nfsmount *nmp;
1054 1.10 mycroft struct nfsreq *rep;
1055 1.10 mycroft struct ucred *cred;
1056 1.10 mycroft char **auth_str;
1057 1.10 mycroft int *auth_len;
1058 1.19 fvdl char *verf_str;
1059 1.19 fvdl int *verf_len;
1060 1.19 fvdl NFSKERBKEY_T key; /* return session key */
1061 1.10 mycroft {
1062 1.10 mycroft int error = 0;
1063 1.10 mycroft
1064 1.27 fvdl while ((nmp->nm_iflag & NFSMNT_WAITAUTH) == 0) {
1065 1.27 fvdl nmp->nm_iflag |= NFSMNT_WANTAUTH;
1066 1.10 mycroft (void) tsleep((caddr_t)&nmp->nm_authtype, PSOCK,
1067 1.10 mycroft "nfsauth1", 2 * hz);
1068 1.18 christos error = nfs_sigintr(nmp, rep, rep->r_procp);
1069 1.18 christos if (error) {
1070 1.27 fvdl nmp->nm_iflag &= ~NFSMNT_WANTAUTH;
1071 1.10 mycroft return (error);
1072 1.10 mycroft }
1073 1.10 mycroft }
1074 1.27 fvdl nmp->nm_iflag &= ~(NFSMNT_WAITAUTH | NFSMNT_WANTAUTH);
1075 1.10 mycroft nmp->nm_authstr = *auth_str = (char *)malloc(RPCAUTH_MAXSIZ, M_TEMP, M_WAITOK);
1076 1.19 fvdl nmp->nm_authlen = RPCAUTH_MAXSIZ;
1077 1.19 fvdl nmp->nm_verfstr = verf_str;
1078 1.19 fvdl nmp->nm_verflen = *verf_len;
1079 1.10 mycroft nmp->nm_authuid = cred->cr_uid;
1080 1.10 mycroft wakeup((caddr_t)&nmp->nm_authstr);
1081 1.3 glass
1082 1.10 mycroft /*
1083 1.10 mycroft * And wait for mount_nfs to do its stuff.
1084 1.10 mycroft */
1085 1.27 fvdl while ((nmp->nm_iflag & NFSMNT_HASAUTH) == 0 && error == 0) {
1086 1.10 mycroft (void) tsleep((caddr_t)&nmp->nm_authlen, PSOCK,
1087 1.10 mycroft "nfsauth2", 2 * hz);
1088 1.10 mycroft error = nfs_sigintr(nmp, rep, rep->r_procp);
1089 1.10 mycroft }
1090 1.27 fvdl if (nmp->nm_iflag & NFSMNT_AUTHERR) {
1091 1.27 fvdl nmp->nm_iflag &= ~NFSMNT_AUTHERR;
1092 1.10 mycroft error = EAUTH;
1093 1.10 mycroft }
1094 1.10 mycroft if (error)
1095 1.10 mycroft free((caddr_t)*auth_str, M_TEMP);
1096 1.10 mycroft else {
1097 1.10 mycroft *auth_len = nmp->nm_authlen;
1098 1.19 fvdl *verf_len = nmp->nm_verflen;
1099 1.32 perry memcpy((caddr_t)key, (caddr_t)nmp->nm_key, sizeof (key));
1100 1.10 mycroft }
1101 1.27 fvdl nmp->nm_iflag &= ~NFSMNT_HASAUTH;
1102 1.27 fvdl nmp->nm_iflag |= NFSMNT_WAITAUTH;
1103 1.27 fvdl if (nmp->nm_iflag & NFSMNT_WANTAUTH) {
1104 1.27 fvdl nmp->nm_iflag &= ~NFSMNT_WANTAUTH;
1105 1.10 mycroft wakeup((caddr_t)&nmp->nm_authtype);
1106 1.10 mycroft }
1107 1.19 fvdl return (error);
1108 1.19 fvdl }
1109 1.19 fvdl
1110 1.19 fvdl /*
1111 1.19 fvdl * Get a nickname authenticator and verifier.
1112 1.19 fvdl */
1113 1.19 fvdl int
1114 1.19 fvdl nfs_getnickauth(nmp, cred, auth_str, auth_len, verf_str, verf_len)
1115 1.19 fvdl struct nfsmount *nmp;
1116 1.19 fvdl struct ucred *cred;
1117 1.19 fvdl char **auth_str;
1118 1.19 fvdl int *auth_len;
1119 1.19 fvdl char *verf_str;
1120 1.19 fvdl int verf_len;
1121 1.19 fvdl {
1122 1.38 augustss struct nfsuid *nuidp;
1123 1.38 augustss u_int32_t *nickp, *verfp;
1124 1.19 fvdl struct timeval ktvin, ktvout;
1125 1.19 fvdl
1126 1.19 fvdl #ifdef DIAGNOSTIC
1127 1.19 fvdl if (verf_len < (4 * NFSX_UNSIGNED))
1128 1.19 fvdl panic("nfs_getnickauth verf too small");
1129 1.19 fvdl #endif
1130 1.19 fvdl for (nuidp = NMUIDHASH(nmp, cred->cr_uid)->lh_first;
1131 1.19 fvdl nuidp != 0; nuidp = nuidp->nu_hash.le_next) {
1132 1.19 fvdl if (nuidp->nu_cr.cr_uid == cred->cr_uid)
1133 1.19 fvdl break;
1134 1.19 fvdl }
1135 1.19 fvdl if (!nuidp || nuidp->nu_expire < time.tv_sec)
1136 1.19 fvdl return (EACCES);
1137 1.19 fvdl
1138 1.19 fvdl /*
1139 1.19 fvdl * Move to the end of the lru list (end of lru == most recently used).
1140 1.19 fvdl */
1141 1.19 fvdl TAILQ_REMOVE(&nmp->nm_uidlruhead, nuidp, nu_lru);
1142 1.19 fvdl TAILQ_INSERT_TAIL(&nmp->nm_uidlruhead, nuidp, nu_lru);
1143 1.19 fvdl
1144 1.19 fvdl nickp = (u_int32_t *)malloc(2 * NFSX_UNSIGNED, M_TEMP, M_WAITOK);
1145 1.19 fvdl *nickp++ = txdr_unsigned(RPCAKN_NICKNAME);
1146 1.19 fvdl *nickp = txdr_unsigned(nuidp->nu_nickname);
1147 1.19 fvdl *auth_str = (char *)nickp;
1148 1.19 fvdl *auth_len = 2 * NFSX_UNSIGNED;
1149 1.19 fvdl
1150 1.19 fvdl /*
1151 1.19 fvdl * Now we must encrypt the verifier and package it up.
1152 1.19 fvdl */
1153 1.19 fvdl verfp = (u_int32_t *)verf_str;
1154 1.19 fvdl *verfp++ = txdr_unsigned(RPCAKN_NICKNAME);
1155 1.19 fvdl if (time.tv_sec > nuidp->nu_timestamp.tv_sec ||
1156 1.19 fvdl (time.tv_sec == nuidp->nu_timestamp.tv_sec &&
1157 1.19 fvdl time.tv_usec > nuidp->nu_timestamp.tv_usec))
1158 1.19 fvdl nuidp->nu_timestamp = time;
1159 1.19 fvdl else
1160 1.19 fvdl nuidp->nu_timestamp.tv_usec++;
1161 1.19 fvdl ktvin.tv_sec = txdr_unsigned(nuidp->nu_timestamp.tv_sec);
1162 1.19 fvdl ktvin.tv_usec = txdr_unsigned(nuidp->nu_timestamp.tv_usec);
1163 1.19 fvdl
1164 1.19 fvdl /*
1165 1.19 fvdl * Now encrypt the timestamp verifier in ecb mode using the session
1166 1.19 fvdl * key.
1167 1.19 fvdl */
1168 1.19 fvdl #ifdef NFSKERB
1169 1.19 fvdl XXX
1170 1.19 fvdl #endif
1171 1.19 fvdl
1172 1.19 fvdl *verfp++ = ktvout.tv_sec;
1173 1.19 fvdl *verfp++ = ktvout.tv_usec;
1174 1.19 fvdl *verfp = 0;
1175 1.19 fvdl return (0);
1176 1.19 fvdl }
1177 1.19 fvdl
1178 1.19 fvdl /*
1179 1.19 fvdl * Save the current nickname in a hash list entry on the mount point.
1180 1.19 fvdl */
1181 1.19 fvdl int
1182 1.19 fvdl nfs_savenickauth(nmp, cred, len, key, mdp, dposp, mrep)
1183 1.38 augustss struct nfsmount *nmp;
1184 1.19 fvdl struct ucred *cred;
1185 1.19 fvdl int len;
1186 1.19 fvdl NFSKERBKEY_T key;
1187 1.19 fvdl struct mbuf **mdp;
1188 1.19 fvdl char **dposp;
1189 1.19 fvdl struct mbuf *mrep;
1190 1.19 fvdl {
1191 1.38 augustss struct nfsuid *nuidp;
1192 1.38 augustss u_int32_t *tl;
1193 1.38 augustss int32_t t1;
1194 1.19 fvdl struct mbuf *md = *mdp;
1195 1.19 fvdl struct timeval ktvin, ktvout;
1196 1.19 fvdl u_int32_t nick;
1197 1.19 fvdl char *dpos = *dposp, *cp2;
1198 1.19 fvdl int deltasec, error = 0;
1199 1.19 fvdl
1200 1.19 fvdl if (len == (3 * NFSX_UNSIGNED)) {
1201 1.19 fvdl nfsm_dissect(tl, u_int32_t *, 3 * NFSX_UNSIGNED);
1202 1.19 fvdl ktvin.tv_sec = *tl++;
1203 1.19 fvdl ktvin.tv_usec = *tl++;
1204 1.19 fvdl nick = fxdr_unsigned(u_int32_t, *tl);
1205 1.19 fvdl
1206 1.19 fvdl /*
1207 1.19 fvdl * Decrypt the timestamp in ecb mode.
1208 1.19 fvdl */
1209 1.19 fvdl #ifdef NFSKERB
1210 1.19 fvdl XXX
1211 1.19 fvdl #endif
1212 1.19 fvdl ktvout.tv_sec = fxdr_unsigned(long, ktvout.tv_sec);
1213 1.19 fvdl ktvout.tv_usec = fxdr_unsigned(long, ktvout.tv_usec);
1214 1.19 fvdl deltasec = time.tv_sec - ktvout.tv_sec;
1215 1.19 fvdl if (deltasec < 0)
1216 1.19 fvdl deltasec = -deltasec;
1217 1.19 fvdl /*
1218 1.19 fvdl * If ok, add it to the hash list for the mount point.
1219 1.19 fvdl */
1220 1.19 fvdl if (deltasec <= NFS_KERBCLOCKSKEW) {
1221 1.19 fvdl if (nmp->nm_numuids < nuidhash_max) {
1222 1.19 fvdl nmp->nm_numuids++;
1223 1.19 fvdl nuidp = (struct nfsuid *)
1224 1.19 fvdl malloc(sizeof (struct nfsuid), M_NFSUID,
1225 1.19 fvdl M_WAITOK);
1226 1.19 fvdl } else {
1227 1.19 fvdl nuidp = nmp->nm_uidlruhead.tqh_first;
1228 1.19 fvdl LIST_REMOVE(nuidp, nu_hash);
1229 1.19 fvdl TAILQ_REMOVE(&nmp->nm_uidlruhead, nuidp,
1230 1.19 fvdl nu_lru);
1231 1.19 fvdl }
1232 1.19 fvdl nuidp->nu_flag = 0;
1233 1.19 fvdl nuidp->nu_cr.cr_uid = cred->cr_uid;
1234 1.19 fvdl nuidp->nu_expire = time.tv_sec + NFS_KERBTTL;
1235 1.19 fvdl nuidp->nu_timestamp = ktvout;
1236 1.19 fvdl nuidp->nu_nickname = nick;
1237 1.32 perry memcpy(nuidp->nu_key, key, sizeof (key));
1238 1.19 fvdl TAILQ_INSERT_TAIL(&nmp->nm_uidlruhead, nuidp,
1239 1.19 fvdl nu_lru);
1240 1.19 fvdl LIST_INSERT_HEAD(NMUIDHASH(nmp, cred->cr_uid),
1241 1.19 fvdl nuidp, nu_hash);
1242 1.19 fvdl }
1243 1.19 fvdl } else
1244 1.19 fvdl nfsm_adv(nfsm_rndup(len));
1245 1.19 fvdl nfsmout:
1246 1.19 fvdl *mdp = md;
1247 1.19 fvdl *dposp = dpos;
1248 1.10 mycroft return (error);
1249 1.10 mycroft }
1250 1.24 thorpej #endif /* NFS */
1251