Commit | Line | Data |
---|---|---|
a2907882 KM |
1 | /* |
2 | * Copyright (c) 1989 The Regents of the University of California. | |
3 | * 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 are permitted | |
9 | * provided that the above copyright notice and this paragraph are | |
10 | * duplicated in all such forms and that any documentation, | |
11 | * advertising materials, and other materials related to such | |
12 | * distribution and use acknowledge that the software was developed | |
13 | * by the University of California, Berkeley. The name of the | |
14 | * University may not be used to endorse or promote products derived | |
15 | * from this software without specific prior written permission. | |
16 | * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR | |
17 | * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED | |
18 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. | |
19 | * | |
fe53c871 | 20 | * @(#)nfs_vnops.c 7.22 (Berkeley) %G% |
a2907882 KM |
21 | */ |
22 | ||
23 | /* | |
24 | * vnode op calls for sun nfs version 2 | |
25 | */ | |
26 | ||
27 | #include "machine/pte.h" | |
28 | #include "machine/mtpr.h" | |
29 | #include "strings.h" | |
30 | #include "param.h" | |
31 | #include "user.h" | |
32 | #include "proc.h" | |
33 | #include "mount.h" | |
34 | #include "buf.h" | |
35 | #include "vm.h" | |
36c3043b | 36 | #include "../ufs/dir.h" |
a2907882 KM |
37 | #include "malloc.h" |
38 | #include "mbuf.h" | |
39 | #include "uio.h" | |
40 | #include "ucred.h" | |
41 | #include "namei.h" | |
42 | #include "errno.h" | |
43 | #include "file.h" | |
44 | #include "conf.h" | |
45 | #include "vnode.h" | |
46 | #include "../ufs/inode.h" | |
9238aa59 | 47 | #include "map.h" |
a2907882 KM |
48 | #include "nfsv2.h" |
49 | #include "nfs.h" | |
50 | #include "nfsnode.h" | |
51 | #include "nfsmount.h" | |
52 | #include "xdr_subs.h" | |
53 | #include "nfsm_subs.h" | |
9238aa59 | 54 | #include "nfsiom.h" |
a2907882 KM |
55 | |
56 | /* Defs */ | |
57 | #define TRUE 1 | |
58 | #define FALSE 0 | |
59 | ||
60 | /* Global vars */ | |
61 | int nfs_lookup(), | |
62 | nfs_create(), | |
f67785e5 | 63 | nfs_mknod(), |
a2907882 KM |
64 | nfs_open(), |
65 | nfs_close(), | |
66 | nfs_access(), | |
67 | nfs_getattr(), | |
68 | nfs_setattr(), | |
69 | nfs_read(), | |
70 | nfs_write(), | |
71 | vfs_noop(), | |
72 | vfs_nullop(), | |
73 | nfs_remove(), | |
74 | nfs_link(), | |
75 | nfs_rename(), | |
76 | nfs_mkdir(), | |
77 | nfs_rmdir(), | |
78 | nfs_symlink(), | |
79 | nfs_readdir(), | |
80 | nfs_readlink(), | |
81 | nfs_abortop(), | |
82 | nfs_lock(), | |
83 | nfs_unlock(), | |
84 | nfs_bmap(), | |
85 | nfs_strategy(), | |
9238aa59 | 86 | nfs_fsync(), |
8c7139ba | 87 | nfs_inactive(), |
d002709d KM |
88 | nfs_reclaim(), |
89 | nfs_print(); | |
a2907882 KM |
90 | |
91 | struct vnodeops nfsv2_vnodeops = { | |
d002709d KM |
92 | nfs_lookup, /* lookup */ |
93 | nfs_create, /* create */ | |
94 | nfs_mknod, /* mknod */ | |
95 | nfs_open, /* open */ | |
96 | nfs_close, /* close */ | |
97 | nfs_access, /* access */ | |
98 | nfs_getattr, /* getattr */ | |
99 | nfs_setattr, /* setattr */ | |
100 | nfs_read, /* read */ | |
101 | nfs_write, /* write */ | |
102 | vfs_noop, /* ioctl */ | |
103 | vfs_noop, /* select */ | |
104 | vfs_noop, /* mmap */ | |
105 | nfs_fsync, /* fsync */ | |
106 | vfs_nullop, /* seek */ | |
107 | nfs_remove, /* remove */ | |
108 | nfs_link, /* link */ | |
109 | nfs_rename, /* rename */ | |
110 | nfs_mkdir, /* mkdir */ | |
111 | nfs_rmdir, /* rmdir */ | |
112 | nfs_symlink, /* symlink */ | |
113 | nfs_readdir, /* readdir */ | |
114 | nfs_readlink, /* readlink */ | |
115 | nfs_abortop, /* abortop */ | |
116 | nfs_inactive, /* inactive */ | |
117 | nfs_reclaim, /* reclaim */ | |
118 | nfs_lock, /* lock */ | |
119 | nfs_unlock, /* unlock */ | |
120 | nfs_bmap, /* bmap */ | |
121 | nfs_strategy, /* strategy */ | |
122 | nfs_print, /* print */ | |
a2907882 KM |
123 | }; |
124 | ||
125 | /* Special device vnode ops */ | |
8a1675f3 KM |
126 | int spec_lookup(), |
127 | spec_open(), | |
128 | spec_read(), | |
129 | spec_write(), | |
130 | spec_strategy(), | |
d002709d | 131 | spec_bmap(), |
8a1675f3 KM |
132 | spec_ioctl(), |
133 | spec_select(), | |
134 | spec_close(), | |
135 | spec_badop(), | |
136 | spec_nullop(); | |
a2907882 | 137 | |
8a1675f3 | 138 | struct vnodeops spec_nfsv2nodeops = { |
9106dc18 KM |
139 | spec_lookup, /* lookup */ |
140 | spec_badop, /* create */ | |
141 | spec_badop, /* mknod */ | |
142 | spec_open, /* open */ | |
143 | spec_close, /* close */ | |
144 | nfs_access, /* access */ | |
145 | nfs_getattr, /* getattr */ | |
146 | nfs_setattr, /* setattr */ | |
147 | spec_read, /* read */ | |
148 | spec_write, /* write */ | |
149 | spec_ioctl, /* ioctl */ | |
150 | spec_select, /* select */ | |
151 | spec_badop, /* mmap */ | |
152 | spec_nullop, /* fsync */ | |
153 | spec_badop, /* seek */ | |
154 | spec_badop, /* remove */ | |
155 | spec_badop, /* link */ | |
156 | spec_badop, /* rename */ | |
157 | spec_badop, /* mkdir */ | |
158 | spec_badop, /* rmdir */ | |
159 | spec_badop, /* symlink */ | |
160 | spec_badop, /* readdir */ | |
161 | spec_badop, /* readlink */ | |
162 | spec_badop, /* abortop */ | |
163 | nfs_inactive, /* inactive */ | |
164 | nfs_reclaim, /* reclaim */ | |
165 | nfs_lock, /* lock */ | |
166 | nfs_unlock, /* unlock */ | |
d002709d | 167 | spec_bmap, /* bmap */ |
9106dc18 | 168 | spec_strategy, /* strategy */ |
d002709d | 169 | nfs_print, /* print */ |
a2907882 KM |
170 | }; |
171 | ||
172 | extern u_long nfs_procids[NFS_NPROCS]; | |
173 | extern u_long nfs_prog, nfs_vers; | |
a2907882 | 174 | extern char nfsiobuf[MAXPHYS+NBPG]; |
9238aa59 | 175 | struct map nfsmap[NFS_MSIZ]; |
a2907882 | 176 | enum vtype v_type[NFLNK+1]; |
9238aa59 | 177 | struct buf nfs_bqueue; /* Queue head for nfsiod's */ |
ffe6f482 KM |
178 | int nfs_asyncdaemons = 0; |
179 | struct proc *nfs_iodwant[MAX_ASYNCDAEMON]; | |
9238aa59 | 180 | static int nfsmap_want = 0; |
a2907882 KM |
181 | |
182 | /* | |
183 | * nfs null call from vfs. | |
184 | */ | |
185 | nfs_null(vp, cred) | |
186 | struct vnode *vp; | |
187 | struct ucred *cred; | |
188 | { | |
13576453 KM |
189 | caddr_t bpos, dpos; |
190 | u_long xid; | |
191 | int error = 0; | |
192 | struct mbuf *mreq, *mrep, *md, *mb; | |
a2907882 KM |
193 | |
194 | nfsm_reqhead(nfs_procids[NFSPROC_NULL], cred, 0); | |
195 | nfsm_request(vp); | |
196 | nfsm_reqdone; | |
197 | return (error); | |
198 | } | |
199 | ||
200 | /* | |
201 | * nfs access vnode op. | |
202 | * Essentially just get vattr and then imitate iaccess() | |
203 | */ | |
204 | nfs_access(vp, mode, cred) | |
205 | struct vnode *vp; | |
206 | int mode; | |
207 | register struct ucred *cred; | |
208 | { | |
209 | register struct vattr *vap; | |
210 | register gid_t *gp; | |
211 | struct vattr vattr; | |
212 | register int i; | |
213 | int error; | |
214 | ||
215 | /* | |
216 | * If you're the super-user, | |
217 | * you always get access. | |
218 | */ | |
219 | if (cred->cr_uid == 0) | |
220 | return (0); | |
221 | vap = &vattr; | |
9238aa59 RM |
222 | if (error = nfs_getattr(vp, vap, cred)) |
223 | return (error); | |
a2907882 KM |
224 | /* |
225 | * Access check is based on only one of owner, group, public. | |
226 | * If not owner, then check group. If not a member of the | |
227 | * group, then check public access. | |
228 | */ | |
229 | if (cred->cr_uid != vap->va_uid) { | |
230 | mode >>= 3; | |
231 | gp = cred->cr_groups; | |
232 | for (i = 0; i < cred->cr_ngroups; i++, gp++) | |
233 | if (vap->va_gid == *gp) | |
234 | goto found; | |
235 | mode >>= 3; | |
236 | found: | |
237 | ; | |
238 | } | |
239 | if ((vap->va_mode & mode) != 0) | |
240 | return (0); | |
241 | return (EACCES); | |
242 | } | |
243 | ||
244 | /* | |
245 | * nfs open vnode op | |
246 | * Just check to see if the type is ok | |
247 | */ | |
13576453 | 248 | /* ARGSUSED */ |
a2907882 KM |
249 | nfs_open(vp, mode, cred) |
250 | struct vnode *vp; | |
251 | int mode; | |
252 | struct ucred *cred; | |
253 | { | |
254 | register enum vtype vtyp; | |
255 | ||
256 | vtyp = vp->v_type; | |
257 | if (vtyp == VREG || vtyp == VDIR || vtyp == VLNK) | |
258 | return (0); | |
259 | else | |
260 | return (EACCES); | |
261 | } | |
262 | ||
263 | /* | |
264 | * nfs close vnode op | |
9238aa59 | 265 | * For reg files, invalidate any buffer cache entries. |
a2907882 | 266 | */ |
13576453 | 267 | /* ARGSUSED */ |
a2907882 KM |
268 | nfs_close(vp, fflags, cred) |
269 | register struct vnode *vp; | |
270 | int fflags; | |
271 | struct ucred *cred; | |
272 | { | |
13576453 | 273 | register struct nfsnode *np = VTONFS(vp); |
ffe6f482 | 274 | int error = 0; |
a2907882 | 275 | |
fe53c871 | 276 | if (vp->v_type == VREG && ((np->n_flag & NMODIFIED) || |
ffe6f482 | 277 | ((np->n_flag & NBUFFERED) && np->n_sillyrename))) { |
8a1675f3 | 278 | nfs_lock(vp); |
ffe6f482 | 279 | np->n_flag &= ~(NMODIFIED|NBUFFERED); |
e8540f59 | 280 | vinvalbuf(vp, TRUE); |
ffe6f482 KM |
281 | if (np->n_flag & NWRITEERR) { |
282 | np->n_flag &= ~NWRITEERR; | |
e8540f59 | 283 | error = np->n_error; |
ffe6f482 | 284 | } |
8a1675f3 | 285 | nfs_unlock(vp); |
9238aa59 | 286 | } |
a2907882 KM |
287 | return (error); |
288 | } | |
289 | ||
290 | /* | |
291 | * nfs getattr call from vfs. | |
292 | */ | |
293 | nfs_getattr(vp, vap, cred) | |
13576453 KM |
294 | register struct vnode *vp; |
295 | struct vattr *vap; | |
a2907882 KM |
296 | struct ucred *cred; |
297 | { | |
13576453 KM |
298 | register caddr_t cp; |
299 | register long t1; | |
300 | caddr_t bpos, dpos; | |
301 | u_long xid; | |
302 | int error = 0; | |
303 | struct mbuf *mreq, *mrep, *md, *mb, *mb2; | |
a2907882 KM |
304 | |
305 | /* First look in the cache.. */ | |
306 | if (nfs_getattrcache(vp, vap) == 0) | |
307 | return (0); | |
308 | nfsstats.rpccnt[NFSPROC_GETATTR]++; | |
309 | nfsm_reqhead(nfs_procids[NFSPROC_GETATTR], cred, NFSX_FH); | |
310 | nfsm_fhtom(vp); | |
311 | nfsm_request(vp); | |
312 | nfsm_loadattr(vp, vap); | |
313 | nfsm_reqdone; | |
314 | return (error); | |
315 | } | |
316 | ||
317 | /* | |
318 | * nfs setattr call. | |
319 | */ | |
320 | nfs_setattr(vp, vap, cred) | |
13576453 | 321 | register struct vnode *vp; |
a2907882 KM |
322 | register struct vattr *vap; |
323 | struct ucred *cred; | |
324 | { | |
9238aa59 | 325 | register struct nfsv2_sattr *sp; |
13576453 KM |
326 | register caddr_t cp; |
327 | register long t1; | |
328 | caddr_t bpos, dpos; | |
329 | u_long xid; | |
330 | int error = 0; | |
331 | struct mbuf *mreq, *mrep, *md, *mb, *mb2; | |
00b72154 | 332 | struct nfsnode *np; |
a2907882 KM |
333 | |
334 | nfsstats.rpccnt[NFSPROC_SETATTR]++; | |
335 | nfsm_reqhead(nfs_procids[NFSPROC_SETATTR], cred, NFSX_FH+NFSX_SATTR); | |
336 | nfsm_fhtom(vp); | |
9238aa59 | 337 | nfsm_build(sp, struct nfsv2_sattr *, NFSX_SATTR); |
a2907882 | 338 | if (vap->va_mode == 0xffff) |
9238aa59 | 339 | sp->sa_mode = VNOVAL; |
a2907882 | 340 | else |
9238aa59 | 341 | sp->sa_mode = vtonfs_mode(vp->v_type, vap->va_mode); |
a2907882 | 342 | if (vap->va_uid == 0xffff) |
9238aa59 | 343 | sp->sa_uid = VNOVAL; |
a2907882 | 344 | else |
9238aa59 | 345 | sp->sa_uid = txdr_unsigned(vap->va_uid); |
a2907882 | 346 | if (vap->va_gid == 0xffff) |
9238aa59 | 347 | sp->sa_gid = VNOVAL; |
a2907882 | 348 | else |
9238aa59 RM |
349 | sp->sa_gid = txdr_unsigned(vap->va_gid); |
350 | sp->sa_size = txdr_unsigned(vap->va_size); | |
00b72154 KM |
351 | if (vap->va_size != VNOVAL) { |
352 | np = VTONFS(vp); | |
353 | if (np->n_flag & NMODIFIED) { | |
354 | np->n_flag &= ~NMODIFIED; | |
fe53c871 | 355 | vinvalbuf(vp, TRUE); |
00b72154 KM |
356 | } |
357 | } | |
e8540f59 KM |
358 | sp->sa_atime.tv_sec = txdr_unsigned(vap->va_atime.tv_sec); |
359 | sp->sa_atime.tv_usec = txdr_unsigned(vap->va_flags); | |
9238aa59 | 360 | txdr_time(&vap->va_mtime, &sp->sa_mtime); |
a2907882 KM |
361 | nfsm_request(vp); |
362 | nfsm_loadattr(vp, (struct vattr *)0); | |
363 | /* should we fill in any vap fields ?? */ | |
364 | nfsm_reqdone; | |
365 | return (error); | |
366 | } | |
367 | ||
368 | /* | |
369 | * nfs lookup call, one step at a time... | |
370 | * First look in cache | |
371 | * If not found, unlock the directory nfsnode and do the rpc | |
372 | */ | |
373 | nfs_lookup(vp, ndp) | |
374 | register struct vnode *vp; | |
375 | register struct nameidata *ndp; | |
376 | { | |
377 | register struct vnode *vdp; | |
13576453 KM |
378 | register u_long *p; |
379 | register caddr_t cp; | |
380 | register long t1, t2; | |
381 | caddr_t bpos, dpos, cp2; | |
382 | u_long xid; | |
383 | struct mbuf *mreq, *mrep, *md, *mb, *mb2; | |
a2907882 KM |
384 | struct vnode *newvp; |
385 | long len; | |
386 | nfsv2fh_t *fhp; | |
387 | struct nfsnode *np; | |
13576453 | 388 | int lockparent, wantparent, flag, error = 0; |
a2907882 KM |
389 | |
390 | ndp->ni_dvp = vp; | |
391 | ndp->ni_vp = NULL; | |
392 | if (vp->v_type != VDIR) | |
393 | return (ENOTDIR); | |
394 | lockparent = ndp->ni_nameiop & LOCKPARENT; | |
395 | flag = ndp->ni_nameiop & OPFLAG; | |
396 | wantparent = ndp->ni_nameiop & (LOCKPARENT|WANTPARENT); | |
ffe6f482 | 397 | if ((error = cache_lookup(ndp)) && error != ENOENT) { |
9238aa59 RM |
398 | struct vattr vattr; |
399 | int vpid; | |
400 | ||
8a1675f3 KM |
401 | if (vp == ndp->ni_rdir && ndp->ni_isdotdot) |
402 | panic("nfs_lookup: .. through root"); | |
403 | vdp = ndp->ni_vp; | |
9238aa59 | 404 | vpid = vdp->v_id; |
a2907882 | 405 | /* |
9238aa59 RM |
406 | * See the comment starting `Step through' in ufs/ufs_lookup.c |
407 | * for an explanation of the locking protocol | |
a2907882 KM |
408 | */ |
409 | if (vp == vdp) { | |
36c3043b | 410 | VREF(vdp); |
8a1675f3 | 411 | error = 0; |
a2907882 KM |
412 | } else if (ndp->ni_isdotdot) { |
413 | nfs_unlock(vp); | |
8a1675f3 | 414 | error = vget(vdp); |
a2907882 | 415 | } else { |
8a1675f3 | 416 | error = vget(vdp); |
a2907882 KM |
417 | nfs_unlock(vp); |
418 | } | |
8a1675f3 KM |
419 | if (!error) { |
420 | if (vpid == vdp->v_id && | |
421 | !nfs_getattr(vdp, &vattr, ndp->ni_cred)) { | |
422 | nfsstats.lookupcache_hits++; | |
423 | return (0); | |
424 | } else { | |
425 | nfs_nput(vdp); | |
426 | } | |
9238aa59 | 427 | } |
9238aa59 | 428 | ndp->ni_vp = (struct vnode *)0; |
e8540f59 KM |
429 | } else |
430 | nfs_unlock(vp); | |
ffe6f482 | 431 | error = 0; |
a2907882 | 432 | nfsstats.lookupcache_misses++; |
a2907882 KM |
433 | nfsstats.rpccnt[NFSPROC_LOOKUP]++; |
434 | len = ndp->ni_namelen; | |
435 | nfsm_reqhead(nfs_procids[NFSPROC_LOOKUP], ndp->ni_cred, NFSX_FH+NFSX_UNSIGNED+nfsm_rndup(len)); | |
436 | nfsm_fhtom(vp); | |
437 | nfsm_strtom(ndp->ni_ptr, len, NFS_MAXNAMLEN); | |
438 | nfsm_request(vp); | |
439 | nfsmout: | |
440 | if (error) { | |
e8540f59 KM |
441 | if (lockparent || (flag != CREATE && flag != RENAME) || |
442 | *ndp->ni_next != 0) | |
443 | nfs_lock(vp); | |
a2907882 KM |
444 | return (ENOENT); |
445 | } | |
446 | nfsm_disect(fhp,nfsv2fh_t *,NFSX_FH); | |
447 | ||
448 | /* | |
449 | * Handle DELETE and RENAME cases... | |
450 | */ | |
451 | if (flag == DELETE && *ndp->ni_next == 0) { | |
452 | if (!bcmp(VTONFS(vp)->n_fh.fh_bytes, (caddr_t)fhp, NFSX_FH)) { | |
36c3043b | 453 | VREF(vp); |
a2907882 KM |
454 | newvp = vp; |
455 | np = VTONFS(vp); | |
456 | } else { | |
457 | if (error = nfs_nget(vp->v_mount, fhp, &np)) { | |
e8540f59 | 458 | nfs_lock(vp); |
a2907882 KM |
459 | m_freem(mrep); |
460 | return (error); | |
461 | } | |
462 | newvp = NFSTOV(np); | |
463 | } | |
f67785e5 KM |
464 | if (error = |
465 | nfs_loadattrcache(&newvp, &md, &dpos, (struct vattr *)0)) { | |
e8540f59 | 466 | nfs_lock(vp); |
a2907882 KM |
467 | if (newvp != vp) |
468 | nfs_nput(newvp); | |
469 | else | |
36c3043b | 470 | vrele(vp); |
a2907882 KM |
471 | m_freem(mrep); |
472 | return (error); | |
473 | } | |
a2907882 | 474 | ndp->ni_vp = newvp; |
e8540f59 KM |
475 | if (lockparent || vp == newvp) |
476 | nfs_lock(vp); | |
a2907882 KM |
477 | m_freem(mrep); |
478 | return (0); | |
479 | } | |
480 | ||
481 | if (flag == RENAME && wantparent && *ndp->ni_next == 0) { | |
482 | if (!bcmp(VTONFS(vp)->n_fh.fh_bytes, (caddr_t)fhp, NFSX_FH)) { | |
e8540f59 | 483 | nfs_lock(vp); |
a2907882 KM |
484 | m_freem(mrep); |
485 | return (EISDIR); | |
486 | } | |
487 | if (error = nfs_nget(vp->v_mount, fhp, &np)) { | |
e8540f59 | 488 | nfs_lock(vp); |
a2907882 KM |
489 | m_freem(mrep); |
490 | return (error); | |
491 | } | |
492 | newvp = NFSTOV(np); | |
f67785e5 KM |
493 | if (error = |
494 | nfs_loadattrcache(&newvp, &md, &dpos, (struct vattr *)0)) { | |
e8540f59 | 495 | nfs_lock(vp); |
36c3043b | 496 | nfs_nput(newvp); |
a2907882 KM |
497 | m_freem(mrep); |
498 | return (error); | |
499 | } | |
500 | ndp->ni_vp = newvp; | |
e8540f59 KM |
501 | if (lockparent) |
502 | nfs_lock(vp); | |
a2907882 KM |
503 | return (0); |
504 | } | |
505 | ||
506 | if (!bcmp(VTONFS(vp)->n_fh.fh_bytes, (caddr_t)fhp, NFSX_FH)) { | |
36c3043b | 507 | VREF(vp); |
a2907882 KM |
508 | newvp = vp; |
509 | np = VTONFS(vp); | |
510 | } else if (ndp->ni_isdotdot) { | |
a2907882 KM |
511 | if (error = nfs_nget(vp->v_mount, fhp, &np)) { |
512 | nfs_lock(vp); | |
513 | m_freem(mrep); | |
514 | return (error); | |
515 | } | |
a2907882 KM |
516 | newvp = NFSTOV(np); |
517 | } else { | |
518 | if (error = nfs_nget(vp->v_mount, fhp, &np)) { | |
e8540f59 | 519 | nfs_lock(vp); |
a2907882 KM |
520 | m_freem(mrep); |
521 | return (error); | |
522 | } | |
523 | newvp = NFSTOV(np); | |
524 | } | |
f67785e5 | 525 | if (error = nfs_loadattrcache(&newvp, &md, &dpos, (struct vattr *)0)) { |
e8540f59 | 526 | nfs_lock(vp); |
a2907882 KM |
527 | if (newvp != vp) |
528 | nfs_nput(newvp); | |
529 | else | |
36c3043b | 530 | vrele(vp); |
a2907882 KM |
531 | m_freem(mrep); |
532 | return (error); | |
533 | } | |
534 | m_freem(mrep); | |
a2907882 | 535 | |
e8540f59 KM |
536 | if (vp == newvp || (lockparent && *ndp->ni_next == '\0')) |
537 | nfs_lock(vp); | |
a2907882 | 538 | ndp->ni_vp = newvp; |
a2907882 KM |
539 | if (error == 0 && ndp->ni_makeentry) |
540 | cache_enter(ndp); | |
a2907882 KM |
541 | return (error); |
542 | } | |
543 | ||
544 | /* | |
545 | * nfs readlink call | |
546 | */ | |
547 | nfs_readlink(vp, uiop, cred) | |
13576453 | 548 | register struct vnode *vp; |
a2907882 KM |
549 | struct uio *uiop; |
550 | struct ucred *cred; | |
551 | { | |
13576453 KM |
552 | register u_long *p; |
553 | register caddr_t cp; | |
554 | register long t1; | |
555 | caddr_t bpos, dpos, cp2; | |
556 | u_long xid; | |
557 | int error = 0; | |
558 | struct mbuf *mreq, *mrep, *md, *mb, *mb2; | |
a2907882 KM |
559 | long len; |
560 | ||
561 | nfsstats.rpccnt[NFSPROC_READLINK]++; | |
562 | nfsm_reqhead(nfs_procids[NFSPROC_READLINK], cred, NFSX_FH); | |
563 | nfsm_fhtom(vp); | |
564 | nfsm_request(vp); | |
565 | nfsm_strsiz(len, NFS_MAXPATHLEN); | |
566 | nfsm_mtouio(uiop, len); | |
567 | nfsm_reqdone; | |
568 | return (error); | |
569 | } | |
570 | ||
571 | /* | |
572 | * nfs read call | |
573 | */ | |
f8428623 | 574 | nfs_readrpc(vp, uiop, cred) |
13576453 | 575 | register struct vnode *vp; |
a2907882 | 576 | struct uio *uiop; |
a2907882 KM |
577 | struct ucred *cred; |
578 | { | |
13576453 KM |
579 | register u_long *p; |
580 | register caddr_t cp; | |
581 | register long t1; | |
582 | caddr_t bpos, dpos, cp2; | |
583 | u_long xid; | |
584 | int error = 0; | |
585 | struct mbuf *mreq, *mrep, *md, *mb, *mb2; | |
a2907882 KM |
586 | struct nfsmount *nmp; |
587 | long len, retlen, tsiz; | |
588 | ||
589 | nmp = vfs_to_nfs(vp->v_mount); | |
590 | tsiz = uiop->uio_resid; | |
a2907882 KM |
591 | while (tsiz > 0) { |
592 | nfsstats.rpccnt[NFSPROC_READ]++; | |
593 | len = (tsiz > nmp->nm_rsize) ? nmp->nm_rsize : tsiz; | |
594 | nfsm_reqhead(nfs_procids[NFSPROC_READ], cred, NFSX_FH+NFSX_UNSIGNED*3); | |
595 | nfsm_fhtom(vp); | |
596 | nfsm_build(p, u_long *, NFSX_UNSIGNED*3); | |
f8428623 | 597 | *p++ = txdr_unsigned(uiop->uio_offset); |
a2907882 KM |
598 | *p++ = txdr_unsigned(len); |
599 | *p = 0; | |
600 | nfsm_request(vp); | |
601 | nfsm_loadattr(vp, (struct vattr *)0); | |
602 | nfsm_strsiz(retlen, nmp->nm_rsize); | |
603 | nfsm_mtouio(uiop, retlen); | |
604 | m_freem(mrep); | |
a2907882 KM |
605 | if (retlen < len) |
606 | tsiz = 0; | |
607 | else | |
608 | tsiz -= len; | |
609 | } | |
610 | nfsmout: | |
a2907882 KM |
611 | return (error); |
612 | } | |
613 | ||
614 | /* | |
615 | * nfs write call | |
616 | */ | |
f8428623 | 617 | nfs_writerpc(vp, uiop, cred) |
13576453 | 618 | register struct vnode *vp; |
a2907882 | 619 | struct uio *uiop; |
a2907882 KM |
620 | struct ucred *cred; |
621 | { | |
13576453 KM |
622 | register u_long *p; |
623 | register caddr_t cp; | |
624 | register long t1; | |
625 | caddr_t bpos, dpos; | |
626 | u_long xid; | |
627 | int error = 0; | |
628 | struct mbuf *mreq, *mrep, *md, *mb, *mb2; | |
a2907882 KM |
629 | struct nfsmount *nmp; |
630 | long len, tsiz; | |
a2907882 KM |
631 | |
632 | nmp = vfs_to_nfs(vp->v_mount); | |
633 | tsiz = uiop->uio_resid; | |
a2907882 KM |
634 | while (tsiz > 0) { |
635 | nfsstats.rpccnt[NFSPROC_WRITE]++; | |
636 | len = (tsiz > nmp->nm_wsize) ? nmp->nm_wsize : tsiz; | |
637 | nfsm_reqhead(nfs_procids[NFSPROC_WRITE], cred, | |
638 | NFSX_FH+NFSX_UNSIGNED*4); | |
639 | nfsm_fhtom(vp); | |
640 | nfsm_build(p, u_long *, NFSX_UNSIGNED*4); | |
f8428623 | 641 | *(p+1) = txdr_unsigned(uiop->uio_offset); |
a2907882 KM |
642 | *(p+3) = txdr_unsigned(len); |
643 | nfsm_uiotom(uiop, len); | |
644 | nfsm_request(vp); | |
645 | nfsm_loadattr(vp, (struct vattr *)0); | |
646 | m_freem(mrep); | |
647 | tsiz -= len; | |
a2907882 KM |
648 | } |
649 | nfsmout: | |
a2907882 KM |
650 | return (error); |
651 | } | |
652 | ||
f67785e5 KM |
653 | /* |
654 | * nfs mknod call | |
655 | * This call is currently not supported. | |
656 | */ | |
657 | /* ARGSUSED */ | |
658 | nfs_mknod(ndp, vap, cred) | |
659 | struct nameidata *ndp; | |
660 | struct ucred *cred; | |
661 | struct vattr *vap; | |
662 | { | |
663 | ||
664 | nfs_abortop(ndp); | |
665 | return (EOPNOTSUPP); | |
666 | } | |
667 | ||
a2907882 KM |
668 | /* |
669 | * nfs file create call | |
670 | */ | |
671 | nfs_create(ndp, vap) | |
672 | register struct nameidata *ndp; | |
673 | register struct vattr *vap; | |
674 | { | |
9238aa59 | 675 | register struct nfsv2_sattr *sp; |
13576453 KM |
676 | register u_long *p; |
677 | register caddr_t cp; | |
678 | register long t1, t2; | |
679 | caddr_t bpos, dpos, cp2; | |
680 | u_long xid; | |
681 | int error = 0; | |
682 | struct mbuf *mreq, *mrep, *md, *mb, *mb2; | |
a2907882 KM |
683 | |
684 | nfsstats.rpccnt[NFSPROC_CREATE]++; | |
685 | nfsm_reqhead(nfs_procids[NFSPROC_CREATE], ndp->ni_cred, | |
686 | NFSX_FH+NFSX_UNSIGNED+nfsm_rndup(ndp->ni_dent.d_namlen)+NFSX_SATTR); | |
687 | nfsm_fhtom(ndp->ni_dvp); | |
688 | nfsm_strtom(ndp->ni_dent.d_name, ndp->ni_dent.d_namlen, NFS_MAXNAMLEN); | |
9238aa59 RM |
689 | nfsm_build(sp, struct nfsv2_sattr *, NFSX_SATTR); |
690 | sp->sa_mode = vtonfs_mode(VREG, vap->va_mode); | |
691 | sp->sa_uid = txdr_unsigned(ndp->ni_cred->cr_uid); | |
692 | sp->sa_gid = txdr_unsigned(ndp->ni_cred->cr_gid); | |
693 | sp->sa_size = txdr_unsigned(0); | |
a2907882 | 694 | /* or should these be VNOVAL ?? */ |
9238aa59 RM |
695 | txdr_time(&vap->va_atime, &sp->sa_atime); |
696 | txdr_time(&vap->va_mtime, &sp->sa_mtime); | |
a2907882 KM |
697 | nfsm_request(ndp->ni_dvp); |
698 | nfsm_mtofh(ndp->ni_dvp, ndp->ni_vp); | |
699 | nfsm_reqdone; | |
700 | nfs_nput(ndp->ni_dvp); | |
701 | return (error); | |
702 | } | |
703 | ||
704 | /* | |
705 | * nfs file remove call | |
ffe6f482 KM |
706 | * To try and make nfs semantics closer to vfs semantics, a file that has |
707 | * other references to the vnode is renamed instead of removed and then | |
708 | * removed later on the last close. | |
709 | * Unfortunately you must flush the buffer cache and cmap to get rid of | |
710 | * all extraneous vnode references before you check the reference cnt. | |
711 | * 1 - If the file could have blocks in the buffer cache | |
712 | * flush them out and invalidate them | |
713 | * mpurge the vnode to flush out cmap references | |
714 | * (This is necessary to update the vnode ref cnt as well as sensible | |
715 | * for actual removes, to free up the buffers) | |
1f7e9641 | 716 | * 2 - If v_usecount > 1 |
ffe6f482 KM |
717 | * If a rename is not already in the works |
718 | * call nfs_sillyrename() to set it up | |
719 | * else | |
720 | * do the remove rpc | |
a2907882 KM |
721 | */ |
722 | nfs_remove(ndp) | |
723 | register struct nameidata *ndp; | |
724 | { | |
ffe6f482 KM |
725 | register struct vnode *vp = ndp->ni_vp; |
726 | register struct nfsnode *np = VTONFS(ndp->ni_vp); | |
13576453 KM |
727 | register u_long *p; |
728 | register caddr_t cp; | |
729 | register long t1, t2; | |
730 | caddr_t bpos, dpos; | |
731 | u_long xid; | |
732 | int error = 0; | |
733 | struct mbuf *mreq, *mrep, *md, *mb, *mb2; | |
a2907882 | 734 | |
ffe6f482 KM |
735 | if (vp->v_type == VREG) { |
736 | if (np->n_flag & (NMODIFIED|NBUFFERED)) { | |
737 | np->n_flag &= ~(NMODIFIED|NBUFFERED); | |
fe53c871 | 738 | vinvalbuf(vp, TRUE); |
ffe6f482 | 739 | } |
e8540f59 KM |
740 | if (np->n_flag & NPAGEDON) { |
741 | np->n_flag &= ~NPAGEDON; | |
ffe6f482 | 742 | mpurge(vp); /* In case cmap entries still ref it */ |
e8540f59 | 743 | } |
ffe6f482 | 744 | } |
1f7e9641 | 745 | if (vp->v_usecount > 1) { |
ffe6f482 KM |
746 | if (!np->n_sillyrename) |
747 | error = nfs_sillyrename(ndp, REMOVE); | |
748 | } else { | |
a2907882 KM |
749 | nfsstats.rpccnt[NFSPROC_REMOVE]++; |
750 | nfsm_reqhead(nfs_procids[NFSPROC_REMOVE], ndp->ni_cred, | |
751 | NFSX_FH+NFSX_UNSIGNED+nfsm_rndup(ndp->ni_dent.d_namlen)); | |
752 | nfsm_fhtom(ndp->ni_dvp); | |
753 | nfsm_strtom(ndp->ni_dent.d_name, ndp->ni_dent.d_namlen, NFS_MAXNAMLEN); | |
754 | nfsm_request(ndp->ni_dvp); | |
755 | nfsm_reqdone; | |
e8540f59 KM |
756 | /* |
757 | * Kludge City: If the first reply to the remove rpc is lost.. | |
758 | * the reply to the retransmitted request will be ENOENT | |
759 | * since the file was in fact removed | |
760 | * Therefore, we cheat and return success. | |
761 | */ | |
762 | if (error == ENOENT) | |
763 | error = 0; | |
a2907882 KM |
764 | } |
765 | if (ndp->ni_dvp == ndp->ni_vp) | |
36c3043b | 766 | vrele(ndp->ni_vp); |
a2907882 | 767 | else |
36c3043b KM |
768 | nfs_nput(ndp->ni_vp); |
769 | nfs_nput(ndp->ni_dvp); | |
a2907882 KM |
770 | return (error); |
771 | } | |
772 | ||
773 | /* | |
774 | * nfs file remove rpc called from nfs_inactive | |
775 | */ | |
776 | nfs_removeit(ndp) | |
777 | register struct nameidata *ndp; | |
778 | { | |
13576453 KM |
779 | register u_long *p; |
780 | register caddr_t cp; | |
781 | register long t1, t2; | |
782 | caddr_t bpos, dpos; | |
783 | u_long xid; | |
784 | int error = 0; | |
785 | struct mbuf *mreq, *mrep, *md, *mb, *mb2; | |
a2907882 KM |
786 | |
787 | nfsstats.rpccnt[NFSPROC_REMOVE]++; | |
788 | nfsm_reqhead(nfs_procids[NFSPROC_REMOVE], ndp->ni_cred, | |
789 | NFSX_FH+NFSX_UNSIGNED+nfsm_rndup(ndp->ni_dent.d_namlen)); | |
790 | nfsm_fhtom(ndp->ni_dvp); | |
791 | nfsm_strtom(ndp->ni_dent.d_name, ndp->ni_dent.d_namlen, NFS_MAXNAMLEN); | |
792 | nfsm_request(ndp->ni_dvp); | |
793 | nfsm_reqdone; | |
794 | return (error); | |
795 | } | |
796 | ||
797 | /* | |
798 | * nfs file rename call | |
799 | */ | |
800 | nfs_rename(sndp, tndp) | |
801 | register struct nameidata *sndp, *tndp; | |
802 | { | |
13576453 KM |
803 | register u_long *p; |
804 | register caddr_t cp; | |
805 | register long t1, t2; | |
806 | caddr_t bpos, dpos; | |
807 | u_long xid; | |
808 | int error = 0; | |
809 | struct mbuf *mreq, *mrep, *md, *mb, *mb2; | |
a2907882 KM |
810 | |
811 | nfsstats.rpccnt[NFSPROC_RENAME]++; | |
812 | nfsm_reqhead(nfs_procids[NFSPROC_RENAME], tndp->ni_cred, | |
813 | (NFSX_FH+NFSX_UNSIGNED)*2+nfsm_rndup(sndp->ni_dent.d_namlen)+ | |
814 | nfsm_rndup(tndp->ni_dent.d_namlen)); /* or sndp->ni_cred?*/ | |
815 | nfsm_fhtom(sndp->ni_dvp); | |
816 | nfsm_strtom(sndp->ni_dent.d_name,sndp->ni_dent.d_namlen,NFS_MAXNAMLEN); | |
817 | nfsm_fhtom(tndp->ni_dvp); | |
818 | nfsm_strtom(tndp->ni_dent.d_name,tndp->ni_dent.d_namlen,NFS_MAXNAMLEN); | |
819 | nfsm_request(sndp->ni_dvp); | |
820 | nfsm_reqdone; | |
a2907882 KM |
821 | if (sndp->ni_vp->v_type == VDIR) { |
822 | if (tndp->ni_vp != NULL && tndp->ni_vp->v_type == VDIR) | |
823 | cache_purge(tndp->ni_dvp); | |
824 | cache_purge(sndp->ni_dvp); | |
825 | } | |
a2907882 KM |
826 | nfs_abortop(sndp); |
827 | nfs_abortop(tndp); | |
828 | return (error); | |
829 | } | |
830 | ||
831 | /* | |
832 | * nfs file rename rpc called from above | |
833 | */ | |
834 | nfs_renameit(sndp, tndp) | |
835 | register struct nameidata *sndp, *tndp; | |
836 | { | |
13576453 KM |
837 | register u_long *p; |
838 | register caddr_t cp; | |
839 | register long t1, t2; | |
840 | caddr_t bpos, dpos; | |
841 | u_long xid; | |
842 | int error = 0; | |
843 | struct mbuf *mreq, *mrep, *md, *mb, *mb2; | |
a2907882 KM |
844 | |
845 | nfsstats.rpccnt[NFSPROC_RENAME]++; | |
846 | nfsm_reqhead(nfs_procids[NFSPROC_RENAME], tndp->ni_cred, | |
847 | (NFSX_FH+NFSX_UNSIGNED)*2+nfsm_rndup(sndp->ni_dent.d_namlen)+ | |
848 | nfsm_rndup(tndp->ni_dent.d_namlen)); /* or sndp->ni_cred?*/ | |
849 | nfsm_fhtom(sndp->ni_dvp); | |
850 | nfsm_strtom(sndp->ni_dent.d_name,sndp->ni_dent.d_namlen,NFS_MAXNAMLEN); | |
851 | nfsm_fhtom(tndp->ni_dvp); | |
852 | nfsm_strtom(tndp->ni_dent.d_name,tndp->ni_dent.d_namlen,NFS_MAXNAMLEN); | |
853 | nfsm_request(sndp->ni_dvp); | |
854 | nfsm_reqdone; | |
855 | return (error); | |
856 | } | |
857 | ||
858 | /* | |
859 | * nfs hard link create call | |
860 | */ | |
861 | nfs_link(vp, ndp) | |
13576453 | 862 | register struct vnode *vp; |
a2907882 KM |
863 | register struct nameidata *ndp; |
864 | { | |
13576453 KM |
865 | register u_long *p; |
866 | register caddr_t cp; | |
867 | register long t1, t2; | |
868 | caddr_t bpos, dpos; | |
869 | u_long xid; | |
870 | int error = 0; | |
871 | struct mbuf *mreq, *mrep, *md, *mb, *mb2; | |
a2907882 | 872 | |
36c3043b KM |
873 | if (ndp->ni_dvp != vp) |
874 | nfs_lock(vp); | |
a2907882 KM |
875 | nfsstats.rpccnt[NFSPROC_LINK]++; |
876 | nfsm_reqhead(nfs_procids[NFSPROC_LINK], ndp->ni_cred, | |
877 | NFSX_FH*2+NFSX_UNSIGNED+nfsm_rndup(ndp->ni_dent.d_namlen)); | |
878 | nfsm_fhtom(vp); | |
879 | nfsm_fhtom(ndp->ni_dvp); | |
880 | nfsm_strtom(ndp->ni_dent.d_name, ndp->ni_dent.d_namlen, NFS_MAXNAMLEN); | |
881 | nfsm_request(vp); | |
882 | nfsm_reqdone; | |
36c3043b KM |
883 | if (ndp->ni_dvp != vp) |
884 | nfs_unlock(vp); | |
a2907882 KM |
885 | nfs_nput(ndp->ni_dvp); |
886 | return (error); | |
887 | } | |
888 | ||
889 | /* | |
890 | * nfs symbolic link create call | |
891 | */ | |
892 | nfs_symlink(ndp, vap, nm) | |
893 | struct nameidata *ndp; | |
894 | struct vattr *vap; | |
895 | char *nm; /* is this the path ?? */ | |
896 | { | |
9238aa59 | 897 | register struct nfsv2_sattr *sp; |
13576453 KM |
898 | register u_long *p; |
899 | register caddr_t cp; | |
900 | register long t1, t2; | |
901 | caddr_t bpos, dpos; | |
902 | u_long xid; | |
903 | int error = 0; | |
904 | struct mbuf *mreq, *mrep, *md, *mb, *mb2; | |
a2907882 KM |
905 | |
906 | nfsstats.rpccnt[NFSPROC_SYMLINK]++; | |
907 | nfsm_reqhead(nfs_procids[NFSPROC_SYMLINK], ndp->ni_cred, | |
908 | NFSX_FH+NFSX_UNSIGNED+nfsm_rndup(ndp->ni_dent.d_namlen)+NFSX_UNSIGNED); | |
909 | nfsm_fhtom(ndp->ni_dvp); | |
910 | nfsm_strtom(ndp->ni_dent.d_name, ndp->ni_dent.d_namlen, NFS_MAXNAMLEN); | |
911 | nfsm_strtom(nm, strlen(nm), NFS_MAXPATHLEN); | |
9238aa59 RM |
912 | nfsm_build(sp, struct nfsv2_sattr *, NFSX_SATTR); |
913 | sp->sa_mode = vtonfs_mode(VLNK, vap->va_mode); | |
914 | sp->sa_uid = txdr_unsigned(ndp->ni_cred->cr_uid); | |
915 | sp->sa_gid = txdr_unsigned(ndp->ni_cred->cr_gid); | |
916 | sp->sa_size = txdr_unsigned(VNOVAL); | |
917 | txdr_time(&vap->va_atime, &sp->sa_atime); /* or VNOVAL ?? */ | |
918 | txdr_time(&vap->va_mtime, &sp->sa_mtime); /* or VNOVAL ?? */ | |
a2907882 KM |
919 | nfsm_request(ndp->ni_dvp); |
920 | nfsm_reqdone; | |
921 | nfs_nput(ndp->ni_dvp); | |
922 | return (error); | |
923 | } | |
924 | ||
925 | /* | |
926 | * nfs make dir call | |
927 | */ | |
928 | nfs_mkdir(ndp, vap) | |
13576453 | 929 | register struct nameidata *ndp; |
a2907882 KM |
930 | struct vattr *vap; |
931 | { | |
9238aa59 | 932 | register struct nfsv2_sattr *sp; |
13576453 KM |
933 | register u_long *p; |
934 | register caddr_t cp; | |
935 | register long t1, t2; | |
936 | caddr_t bpos, dpos, cp2; | |
937 | u_long xid; | |
938 | int error = 0; | |
939 | struct mbuf *mreq, *mrep, *md, *mb, *mb2; | |
a2907882 KM |
940 | |
941 | nfsstats.rpccnt[NFSPROC_MKDIR]++; | |
942 | nfsm_reqhead(nfs_procids[NFSPROC_MKDIR], ndp->ni_cred, | |
943 | NFSX_FH+NFSX_UNSIGNED+nfsm_rndup(ndp->ni_dent.d_namlen)+NFSX_SATTR); | |
944 | nfsm_fhtom(ndp->ni_dvp); | |
945 | nfsm_strtom(ndp->ni_dent.d_name, ndp->ni_dent.d_namlen, NFS_MAXNAMLEN); | |
9238aa59 RM |
946 | nfsm_build(sp, struct nfsv2_sattr *, NFSX_SATTR); |
947 | sp->sa_mode = vtonfs_mode(VDIR, vap->va_mode); | |
948 | sp->sa_uid = txdr_unsigned(ndp->ni_cred->cr_uid); | |
949 | sp->sa_gid = txdr_unsigned(ndp->ni_cred->cr_gid); | |
950 | sp->sa_size = txdr_unsigned(VNOVAL); | |
951 | txdr_time(&vap->va_atime, &sp->sa_atime); /* or VNOVAL ?? */ | |
952 | txdr_time(&vap->va_mtime, &sp->sa_mtime); /* or VNOVAL ?? */ | |
a2907882 KM |
953 | nfsm_request(ndp->ni_dvp); |
954 | nfsm_mtofh(ndp->ni_dvp, ndp->ni_vp); | |
955 | nfsm_reqdone; | |
a2907882 KM |
956 | nfs_nput(ndp->ni_dvp); |
957 | return (error); | |
958 | } | |
959 | ||
960 | /* | |
961 | * nfs remove directory call | |
962 | */ | |
963 | nfs_rmdir(ndp) | |
964 | register struct nameidata *ndp; | |
965 | { | |
13576453 KM |
966 | register u_long *p; |
967 | register caddr_t cp; | |
968 | register long t1, t2; | |
969 | caddr_t bpos, dpos; | |
970 | u_long xid; | |
971 | int error = 0; | |
972 | struct mbuf *mreq, *mrep, *md, *mb, *mb2; | |
a2907882 KM |
973 | |
974 | if (ndp->ni_dvp == ndp->ni_vp) { | |
975 | vrele(ndp->ni_dvp); | |
976 | nfs_nput(ndp->ni_dvp); | |
977 | return (EINVAL); | |
978 | } | |
a2907882 KM |
979 | nfsstats.rpccnt[NFSPROC_RMDIR]++; |
980 | nfsm_reqhead(nfs_procids[NFSPROC_RMDIR], ndp->ni_cred, | |
981 | NFSX_FH+NFSX_UNSIGNED+nfsm_rndup(ndp->ni_dent.d_namlen)); | |
982 | nfsm_fhtom(ndp->ni_dvp); | |
983 | nfsm_strtom(ndp->ni_dent.d_name, ndp->ni_dent.d_namlen, NFS_MAXNAMLEN); | |
984 | nfsm_request(ndp->ni_dvp); | |
985 | nfsm_reqdone; | |
9238aa59 RM |
986 | cache_purge(ndp->ni_dvp); |
987 | cache_purge(ndp->ni_vp); | |
9238aa59 RM |
988 | nfs_nput(ndp->ni_vp); |
989 | nfs_nput(ndp->ni_dvp); | |
a2907882 KM |
990 | return (error); |
991 | } | |
992 | ||
993 | /* | |
994 | * nfs readdir call | |
995 | * Although cookie is defined as opaque, I translate it to/from net byte | |
996 | * order so that it looks more sensible. This appears consistent with the | |
997 | * Ultrix implementation of NFS. | |
998 | */ | |
f8428623 | 999 | nfs_readdir(vp, uiop, cred) |
13576453 | 1000 | register struct vnode *vp; |
a2907882 | 1001 | struct uio *uiop; |
a2907882 KM |
1002 | struct ucred *cred; |
1003 | { | |
1004 | register long len; | |
1005 | register struct direct *dp; | |
13576453 KM |
1006 | register u_long *p; |
1007 | register caddr_t cp; | |
1008 | register long t1; | |
1009 | caddr_t bpos, dpos, cp2; | |
1010 | u_long xid; | |
1011 | int error = 0; | |
1012 | struct mbuf *mreq, *mrep, *md, *mb, *mb2; | |
a2907882 KM |
1013 | struct mbuf *md2; |
1014 | caddr_t dpos2; | |
1015 | int siz; | |
574a968b | 1016 | int more_dirs; |
a2907882 KM |
1017 | off_t off, savoff; |
1018 | struct direct *savdp; | |
1019 | ||
a2907882 KM |
1020 | nfsstats.rpccnt[NFSPROC_READDIR]++; |
1021 | nfsm_reqhead(nfs_procids[NFSPROC_READDIR], cred, xid); | |
1022 | nfsm_fhtom(vp); | |
1023 | nfsm_build(p, u_long *, 2*NFSX_UNSIGNED); | |
f8428623 | 1024 | *p++ = txdr_unsigned(uiop->uio_offset); |
a2907882 KM |
1025 | *p = txdr_unsigned(uiop->uio_resid); |
1026 | nfsm_request(vp); | |
1027 | siz = 0; | |
1028 | nfsm_disect(p, u_long *, NFSX_UNSIGNED); | |
1029 | more_dirs = fxdr_unsigned(int, *p); | |
1030 | ||
1031 | /* Save the position so that we can do nfsm_mtouio() later */ | |
1032 | dpos2 = dpos; | |
1033 | md2 = md; | |
1034 | ||
1035 | /* loop thru the dir entries, doctoring them to 4bsd form */ | |
13576453 KM |
1036 | savoff = off = 0; |
1037 | savdp = dp = NULL; | |
a2907882 KM |
1038 | while (more_dirs && siz < uiop->uio_resid) { |
1039 | savoff = off; /* Hold onto offset and dp */ | |
1040 | savdp = dp; | |
1041 | nfsm_disecton(p, u_long *, 2*NFSX_UNSIGNED); | |
1042 | dp = (struct direct *)p; | |
1043 | dp->d_ino = fxdr_unsigned(u_long, *p++); | |
1044 | len = fxdr_unsigned(int, *p); | |
1045 | if (len <= 0 || len > NFS_MAXNAMLEN) { | |
1046 | error = EBADRPC; | |
1047 | m_freem(mrep); | |
1048 | goto nfsmout; | |
1049 | } | |
1050 | dp->d_namlen = (u_short)len; | |
1051 | len = nfsm_rndup(len); | |
1052 | nfsm_adv(len); | |
1053 | nfsm_disecton(p, u_long *, 2*NFSX_UNSIGNED); | |
1054 | off = fxdr_unsigned(off_t, *p); | |
1055 | *p++ = 0; /* Ensures null termination of name */ | |
1056 | more_dirs = fxdr_unsigned(int, *p); | |
1057 | dp->d_reclen = len+4*NFSX_UNSIGNED; | |
1058 | siz += dp->d_reclen; | |
1059 | } | |
1060 | /* | |
1061 | * If at end of rpc data, get the eof boolean | |
1062 | */ | |
574a968b | 1063 | if (!more_dirs) |
a2907882 | 1064 | nfsm_disecton(p, u_long *, NFSX_UNSIGNED); |
a2907882 KM |
1065 | /* |
1066 | * If there is too much to fit in the data buffer, use savoff and | |
1067 | * savdp to trim off the last record. | |
1068 | * --> we are not at eof | |
1069 | */ | |
1070 | if (siz > uiop->uio_resid) { | |
a2907882 KM |
1071 | off = savoff; |
1072 | siz -= dp->d_reclen; | |
1073 | dp = savdp; | |
1074 | } | |
1075 | if (siz > 0) { | |
a2907882 KM |
1076 | md = md2; |
1077 | dpos = dpos2; | |
1078 | nfsm_mtouio(uiop, siz); | |
f8428623 | 1079 | uiop->uio_offset = off; |
a2907882 KM |
1080 | } |
1081 | nfsm_reqdone; | |
a2907882 KM |
1082 | return (error); |
1083 | } | |
1084 | ||
1085 | /* | |
1086 | * nfs statfs call | |
1087 | * (Actually a vfsop, not a vnode op) | |
1088 | */ | |
1089 | nfs_statfs(mp, sbp) | |
1090 | struct mount *mp; | |
1091 | register struct statfs *sbp; | |
1092 | { | |
13576453 | 1093 | register struct vnode *vp; |
9238aa59 | 1094 | register struct nfsv2_statfs *sfp; |
13576453 KM |
1095 | register caddr_t cp; |
1096 | register long t1; | |
1097 | caddr_t bpos, dpos, cp2; | |
1098 | u_long xid; | |
1099 | int error = 0; | |
1100 | struct mbuf *mreq, *mrep, *md, *mb, *mb2; | |
9238aa59 | 1101 | struct nfsmount *nmp; |
a2907882 KM |
1102 | struct ucred *cred; |
1103 | struct nfsnode *np; | |
a2907882 KM |
1104 | |
1105 | nmp = vfs_to_nfs(mp); | |
1106 | if (error = nfs_nget(mp, &nmp->nm_fh, &np)) | |
1107 | return (error); | |
1108 | vp = NFSTOV(np); | |
1109 | nfsstats.rpccnt[NFSPROC_STATFS]++; | |
1110 | cred = crget(); | |
1111 | cred->cr_ngroups = 1; | |
1112 | nfsm_reqhead(nfs_procids[NFSPROC_STATFS], cred, NFSX_FH); | |
1113 | nfsm_fhtom(vp); | |
1114 | nfsm_request(vp); | |
9238aa59 | 1115 | nfsm_disect(sfp, struct nfsv2_statfs *, NFSX_STATFS); |
a2907882 | 1116 | sbp->f_type = MOUNT_NFS; |
e8540f59 | 1117 | sbp->f_flags = nmp->nm_flag; |
9238aa59 RM |
1118 | sbp->f_bsize = fxdr_unsigned(long, sfp->sf_tsize); |
1119 | sbp->f_fsize = fxdr_unsigned(long, sfp->sf_bsize); | |
1120 | sbp->f_blocks = fxdr_unsigned(long, sfp->sf_blocks); | |
1121 | sbp->f_bfree = fxdr_unsigned(long, sfp->sf_bfree); | |
1122 | sbp->f_bavail = fxdr_unsigned(long, sfp->sf_bavail); | |
0b9c4686 KM |
1123 | sbp->f_files = 0; |
1124 | sbp->f_ffree = 0; | |
e8540f59 KM |
1125 | sbp->f_fsid.val[0] = mp->m_fsid.val[0]; |
1126 | sbp->f_fsid.val[1] = mp->m_fsid.val[1]; | |
a2907882 KM |
1127 | bcopy(nmp->nm_path, sbp->f_mntonname, MNAMELEN); |
1128 | bcopy(nmp->nm_host, sbp->f_mntfromname, MNAMELEN); | |
1129 | nfsm_reqdone; | |
1130 | nfs_nput(vp); | |
1131 | crfree(cred); | |
1132 | return (error); | |
1133 | } | |
1134 | ||
13576453 | 1135 | static char hextoasc[] = "0123456789abcdef"; |
a2907882 KM |
1136 | |
1137 | /* | |
1138 | * Silly rename. To make the NFS filesystem that is stateless look a little | |
1139 | * more like the "ufs" a remove of an active vnode is translated to a rename | |
1140 | * to a funny looking filename that is removed by nfs_inactive on the | |
1141 | * nfsnode. There is the potential for another process on a different client | |
1142 | * to create the same funny name between the nfs_lookitup() fails and the | |
1143 | * nfs_rename() completes, but... | |
1144 | */ | |
1145 | nfs_sillyrename(ndp, flag) | |
13576453 | 1146 | register struct nameidata *ndp; |
a2907882 KM |
1147 | int flag; |
1148 | { | |
1149 | register struct nfsnode *np; | |
1150 | register struct sillyrename *sp; | |
1151 | register struct nameidata *tndp; | |
1152 | int error; | |
1153 | short pid; | |
1154 | ||
1155 | np = VTONFS(ndp->ni_dvp); | |
ffe6f482 | 1156 | cache_purge(ndp->ni_dvp); |
a2907882 | 1157 | MALLOC(sp, struct sillyrename *, sizeof (struct sillyrename), |
9238aa59 | 1158 | M_TEMP, M_WAITOK); |
a2907882 KM |
1159 | sp->s_flag = flag; |
1160 | bcopy((caddr_t)&np->n_fh, (caddr_t)&sp->s_fh, NFSX_FH); | |
1161 | np = VTONFS(ndp->ni_vp); | |
1162 | tndp = &sp->s_namei; | |
1163 | tndp->ni_cred = crdup(ndp->ni_cred); | |
1164 | ||
1165 | /* Fudge together a funny name */ | |
1166 | pid = u.u_procp->p_pid; | |
1167 | bcopy(".nfsAxxxx4.4", tndp->ni_dent.d_name, 13); | |
1168 | tndp->ni_dent.d_namlen = 12; | |
13576453 KM |
1169 | tndp->ni_dent.d_name[8] = hextoasc[pid & 0xf]; |
1170 | tndp->ni_dent.d_name[7] = hextoasc[(pid >> 4) & 0xf]; | |
1171 | tndp->ni_dent.d_name[6] = hextoasc[(pid >> 8) & 0xf]; | |
1172 | tndp->ni_dent.d_name[5] = hextoasc[(pid >> 12) & 0xf]; | |
a2907882 KM |
1173 | |
1174 | /* Try lookitups until we get one that isn't there */ | |
1175 | while (nfs_lookitup(ndp->ni_dvp, tndp, (nfsv2fh_t *)0) == 0) { | |
1176 | tndp->ni_dent.d_name[4]++; | |
1177 | if (tndp->ni_dent.d_name[4] > 'z') { | |
1178 | error = EINVAL; | |
1179 | goto bad; | |
1180 | } | |
1181 | } | |
1182 | if (error = nfs_renameit(ndp, tndp)) | |
1183 | goto bad; | |
1184 | nfs_lookitup(ndp->ni_dvp, tndp, &np->n_fh); | |
1185 | np->n_sillyrename = sp; | |
1186 | return (0); | |
1187 | bad: | |
9238aa59 | 1188 | crfree(tndp->ni_cred); |
a2907882 KM |
1189 | free((caddr_t)sp, M_TEMP); |
1190 | return (error); | |
1191 | } | |
1192 | ||
1193 | /* | |
1194 | * Look up a file name for silly rename stuff. | |
1195 | * Just like nfs_lookup() except that it doesn't load returned values | |
1196 | * into the nfsnode table. | |
1197 | * If fhp != NULL it copies the returned file handle out | |
1198 | */ | |
1199 | nfs_lookitup(vp, ndp, fhp) | |
1200 | register struct vnode *vp; | |
1201 | register struct nameidata *ndp; | |
1202 | nfsv2fh_t *fhp; | |
1203 | { | |
13576453 KM |
1204 | register u_long *p; |
1205 | register caddr_t cp; | |
1206 | register long t1, t2; | |
1207 | caddr_t bpos, dpos, cp2; | |
1208 | u_long xid; | |
1209 | int error = 0; | |
1210 | struct mbuf *mreq, *mrep, *md, *mb, *mb2; | |
a2907882 KM |
1211 | long len; |
1212 | ||
1213 | nfsstats.rpccnt[NFSPROC_LOOKUP]++; | |
1214 | ndp->ni_dvp = vp; | |
1215 | ndp->ni_vp = NULL; | |
1216 | len = ndp->ni_dent.d_namlen; | |
1217 | nfsm_reqhead(nfs_procids[NFSPROC_LOOKUP], ndp->ni_cred, NFSX_FH+NFSX_UNSIGNED+nfsm_rndup(len)); | |
1218 | nfsm_fhtom(vp); | |
1219 | nfsm_strtom(ndp->ni_dent.d_name, len, NFS_MAXNAMLEN); | |
1220 | nfsm_request(vp); | |
1221 | if (fhp != NULL) { | |
1222 | nfsm_disect(cp, caddr_t, NFSX_FH); | |
1223 | bcopy(cp, (caddr_t)fhp, NFSX_FH); | |
1224 | } | |
1225 | nfsm_reqdone; | |
1226 | return (error); | |
1227 | } | |
1228 | ||
1229 | /* | |
1230 | * Kludge City.. | |
1231 | * - make nfs_bmap() essentially a no-op that does no translation | |
1232 | * - do nfs_strategy() by faking physical I/O with nfs_readit/nfs_writeit | |
1233 | * after mapping the physical addresses into Kernel Virtual space in the | |
1234 | * nfsiobuf area. | |
1235 | * (Maybe I could use the process's page mapping, but I was concerned that | |
1236 | * Kernel Write might not be enabled and also figured copyout() would do | |
1237 | * a lot more work than bcopy() and also it currently happens in the | |
1238 | * context of the swapper process (2). | |
1239 | */ | |
1240 | nfs_bmap(vp, bn, vpp, bnp) | |
1241 | struct vnode *vp; | |
1242 | daddr_t bn; | |
1243 | struct vnode **vpp; | |
1244 | daddr_t *bnp; | |
1245 | { | |
1246 | if (vpp != NULL) | |
1247 | *vpp = vp; | |
1248 | if (bnp != NULL) | |
1249 | *bnp = bn * btodb(vp->v_mount->m_bsize); | |
1250 | return (0); | |
1251 | } | |
1252 | ||
1253 | /* | |
9238aa59 RM |
1254 | * Strategy routine for phys. i/o |
1255 | * If the biod's are running, queue a request | |
1256 | * otherwise just call nfs_doio() to get it done | |
a2907882 KM |
1257 | */ |
1258 | nfs_strategy(bp) | |
1259 | register struct buf *bp; | |
9238aa59 RM |
1260 | { |
1261 | register struct buf *dp; | |
ffe6f482 | 1262 | register int i; |
9238aa59 RM |
1263 | struct proc *rp; |
1264 | int error = 0; | |
ffe6f482 | 1265 | int fnd = 0; |
9238aa59 RM |
1266 | |
1267 | /* | |
1268 | * If an i/o daemon is waiting | |
1269 | * queue the request, wake it up and wait for completion | |
1270 | * otherwise just do it ourselves | |
1271 | */ | |
ffe6f482 KM |
1272 | for (i = 0; i < nfs_asyncdaemons; i++) { |
1273 | if (rp = nfs_iodwant[i]) { | |
1274 | /* | |
1275 | * Ensure that the async_daemon is still waiting here | |
1276 | */ | |
1277 | if (rp->p_stat != SSLEEP || | |
1278 | rp->p_wchan != ((caddr_t)&nfs_iodwant[i])) { | |
1279 | nfs_iodwant[i] = (struct proc *)0; | |
1280 | continue; | |
1281 | } | |
1282 | dp = &nfs_bqueue; | |
1283 | if (dp->b_actf == NULL) { | |
1284 | dp->b_actl = bp; | |
1285 | bp->b_actf = dp; | |
1286 | } else { | |
1287 | dp->b_actf->b_actl = bp; | |
1288 | bp->b_actf = dp->b_actf; | |
1289 | } | |
1290 | dp->b_actf = bp; | |
1291 | bp->b_actl = dp; | |
1292 | fnd++; | |
1293 | nfs_iodwant[i] = (struct proc *)0; | |
1294 | wakeup((caddr_t)&nfs_iodwant[i]); | |
1295 | break; | |
9238aa59 | 1296 | } |
ffe6f482 KM |
1297 | } |
1298 | if (!fnd) | |
9238aa59 RM |
1299 | error = nfs_doio(bp); |
1300 | return (error); | |
1301 | } | |
1302 | ||
1303 | /* | |
1304 | * Fun and games with i/o | |
1305 | * Essentially play ubasetup() and disk interrupt service routine by | |
1306 | * mapping the data buffer into kernel virtual space and doing the | |
1307 | * nfs read or write rpc's from it. | |
1308 | * If the biod's are not running, this is just called from nfs_strategy(), | |
1309 | * otherwise it is called by the biod's to do what would normally be | |
1310 | * partially disk interrupt driven. | |
1311 | */ | |
1312 | nfs_doio(bp) | |
1313 | register struct buf *bp; | |
a2907882 KM |
1314 | { |
1315 | register struct pte *pte, *ppte; | |
1316 | register caddr_t vaddr; | |
1317 | register struct uio *uiop; | |
a2907882 | 1318 | register struct vnode *vp; |
ffe6f482 | 1319 | struct nfsnode *np; |
9238aa59 RM |
1320 | struct ucred *cr; |
1321 | int npf, npf2; | |
1322 | int reg; | |
1323 | caddr_t vbase; | |
a2907882 KM |
1324 | unsigned v; |
1325 | struct proc *rp; | |
1326 | int o, error; | |
a2907882 KM |
1327 | struct uio uio; |
1328 | struct iovec io; | |
1329 | ||
1330 | vp = bp->b_vp; | |
a2907882 KM |
1331 | uiop = &uio; |
1332 | uiop->uio_iov = &io; | |
1333 | uiop->uio_iovcnt = 1; | |
a2907882 | 1334 | uiop->uio_segflg = UIO_SYSSPACE; |
e8540f59 | 1335 | |
a2907882 | 1336 | /* |
9238aa59 RM |
1337 | * For phys i/o, map the b_addr into kernel virtual space using |
1338 | * the Nfsiomap pte's | |
1339 | * Also, add a temporary b_rcred for reading using the process's uid | |
1340 | * and a guess at a group | |
a2907882 | 1341 | */ |
9238aa59 | 1342 | if (bp->b_flags & B_PHYS) { |
ffe6f482 | 1343 | VTONFS(vp)->n_flag |= NPAGEDON; |
9238aa59 RM |
1344 | bp->b_rcred = cr = crget(); |
1345 | rp = (bp->b_flags & B_DIRTY) ? &proc[2] : bp->b_proc; | |
1346 | cr->cr_uid = rp->p_uid; | |
1347 | cr->cr_gid = 0; /* Anything ?? */ | |
1348 | cr->cr_ngroups = 1; | |
e8540f59 KM |
1349 | o = (int)bp->b_un.b_addr & PGOFSET; |
1350 | npf2 = npf = btoc(bp->b_bcount + o); | |
1351 | ||
9238aa59 RM |
1352 | /* |
1353 | * Get some mapping page table entries | |
1354 | */ | |
1355 | while ((reg = rmalloc(nfsmap, (long)npf)) == 0) { | |
1356 | nfsmap_want++; | |
1357 | sleep((caddr_t)&nfsmap_want, PZERO-1); | |
1358 | } | |
1359 | reg--; | |
e8540f59 KM |
1360 | if (bp->b_flags & B_PAGET) |
1361 | pte = &Usrptmap[btokmx((struct pte *)bp->b_un.b_addr)]; | |
9238aa59 | 1362 | else { |
e8540f59 | 1363 | v = btop(bp->b_un.b_addr); |
9238aa59 RM |
1364 | if (bp->b_flags & B_UAREA) |
1365 | pte = &rp->p_addr[v]; | |
1366 | else | |
1367 | pte = vtopte(rp, v); | |
1368 | } | |
e8540f59 | 1369 | |
9238aa59 RM |
1370 | /* |
1371 | * Play vmaccess() but with the Nfsiomap page table | |
1372 | */ | |
1373 | ppte = &Nfsiomap[reg]; | |
1374 | vbase = vaddr = &nfsiobuf[reg*NBPG]; | |
1375 | while (npf != 0) { | |
1376 | mapin(ppte, (u_int)vaddr, pte->pg_pfnum, (int)(PG_V|PG_KW)); | |
a2907882 | 1377 | #if defined(tahoe) |
9238aa59 | 1378 | mtpr(P1DC, vaddr); |
a2907882 | 1379 | #endif |
9238aa59 RM |
1380 | ppte++; |
1381 | pte++; | |
1382 | vaddr += NBPG; | |
1383 | --npf; | |
1384 | } | |
e8540f59 KM |
1385 | |
1386 | /* | |
1387 | * And do the i/o rpc | |
1388 | */ | |
9238aa59 | 1389 | io.iov_base = vbase+o; |
e8540f59 | 1390 | io.iov_len = uiop->uio_resid = bp->b_bcount; |
589be24d | 1391 | uiop->uio_offset = bp->b_blkno * DEV_BSIZE; |
e8540f59 KM |
1392 | if (bp->b_flags & B_READ) { |
1393 | uiop->uio_rw = UIO_READ; | |
1394 | nfsstats.read_physios++; | |
1395 | bp->b_error = error = nfs_readrpc(vp, uiop, bp->b_rcred); | |
1396 | } else { | |
1397 | uiop->uio_rw = UIO_WRITE; | |
1398 | nfsstats.write_physios++; | |
1399 | bp->b_error = error = nfs_writerpc(vp, uiop, bp->b_wcred); | |
ffe6f482 | 1400 | } |
e8540f59 KM |
1401 | |
1402 | /* | |
1403 | * Finally, release pte's used by physical i/o | |
1404 | */ | |
9238aa59 RM |
1405 | crfree(cr); |
1406 | rmfree(nfsmap, (long)npf2, (long)++reg); | |
1407 | if (nfsmap_want) { | |
1408 | nfsmap_want = 0; | |
1409 | wakeup((caddr_t)&nfsmap_want); | |
1410 | } | |
e8540f59 KM |
1411 | } else { |
1412 | if (bp->b_flags & B_READ) { | |
1413 | io.iov_len = uiop->uio_resid = bp->b_bcount; | |
589be24d | 1414 | uiop->uio_offset = bp->b_blkno * DEV_BSIZE; |
e8540f59 KM |
1415 | io.iov_base = bp->b_un.b_addr; |
1416 | uiop->uio_rw = UIO_READ; | |
1417 | nfsstats.read_bios++; | |
1418 | bp->b_error = error = nfs_readrpc(vp, uiop, bp->b_rcred); | |
1419 | } else { | |
1420 | io.iov_len = uiop->uio_resid = bp->b_dirtyend | |
1421 | - bp->b_dirtyoff; | |
589be24d | 1422 | uiop->uio_offset = (bp->b_blkno * DEV_BSIZE) |
e8540f59 KM |
1423 | + bp->b_dirtyoff; |
1424 | io.iov_base = bp->b_un.b_addr + bp->b_dirtyoff; | |
1425 | uiop->uio_rw = UIO_WRITE; | |
1426 | nfsstats.write_bios++; | |
1427 | bp->b_error = error = nfs_writerpc(vp, uiop, bp->b_wcred); | |
1428 | if (error) { | |
1429 | np = VTONFS(vp); | |
1430 | np->n_error = error; | |
1431 | np->n_flag |= NWRITEERR; | |
1432 | } | |
1433 | bp->b_dirtyoff = bp->b_dirtyend = 0; | |
1434 | } | |
9238aa59 | 1435 | } |
e8540f59 KM |
1436 | if (error) |
1437 | bp->b_flags |= B_ERROR; | |
1438 | bp->b_resid = uiop->uio_resid; | |
a2907882 | 1439 | biodone(bp); |
9238aa59 RM |
1440 | return (error); |
1441 | } | |
1442 | ||
1443 | /* | |
1444 | * Flush all the blocks associated with a vnode. | |
1445 | * Walk through the buffer pool and push any dirty pages | |
1446 | * associated with the vnode. | |
1447 | */ | |
13576453 | 1448 | /* ARGSUSED */ |
f8428623 | 1449 | nfs_fsync(vp, fflags, cred, waitfor) |
9238aa59 RM |
1450 | register struct vnode *vp; |
1451 | int fflags; | |
1452 | struct ucred *cred; | |
f8428623 | 1453 | int waitfor; |
9238aa59 RM |
1454 | { |
1455 | register struct nfsnode *np = VTONFS(vp); | |
e8540f59 | 1456 | int error = 0; |
9238aa59 | 1457 | |
9238aa59 RM |
1458 | if (np->n_flag & NMODIFIED) { |
1459 | np->n_flag &= ~NMODIFIED; | |
e8540f59 | 1460 | vflushbuf(vp, waitfor == MNT_WAIT ? B_SYNC : 0); |
9238aa59 | 1461 | } |
e8540f59 KM |
1462 | if (!error && (np->n_flag & NWRITEERR)) |
1463 | error = np->n_error; | |
a2907882 KM |
1464 | return (error); |
1465 | } | |
d002709d KM |
1466 | |
1467 | /* | |
1468 | * Print out the contents of an nfsnode. | |
1469 | */ | |
1470 | nfs_print(vp) | |
1471 | struct vnode *vp; | |
1472 | { | |
1473 | register struct nfsnode *np = VTONFS(vp); | |
1474 | ||
1475 | printf("tag VT_NFS, fileid %d fsid 0x%x%s\n", | |
1476 | np->n_vattr.va_fileid, np->n_vattr.va_fsid, | |
1477 | (np->n_flag & NLOCKED) ? " (LOCKED)" : ""); | |
1478 | } |