2 * Copyright (c) 1999, 2000, 2001 Boris Popov
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
8 * 1. Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer.
10 * 2. Redistributions in binary form must reproduce the above copyright
11 * notice, this list of conditions and the following disclaimer in the
12 * documentation and/or other materials provided with the distribution.
13 * 3. All advertising materials mentioning features or use of this software
14 * must display the following acknowledgement:
15 * This product includes software developed by Boris Popov.
16 * 4. Neither the name of the author nor the names of any co-contributors
17 * may be used to endorse or promote products derived from this software
18 * without specific prior written permission.
20 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
21 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
22 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
23 * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
24 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
25 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
26 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
27 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
28 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
29 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
34 #include <sys/param.h>
35 #include <sys/systm.h>
36 #include <sys/namei.h>
37 #include <sys/kernel.h>
40 #include <sys/fcntl.h>
41 #include <sys/mount.h>
42 #include <sys/unistd.h>
43 #include <sys/vnode.h>
46 #include <vm/vm_extern.h>
48 #include <machine/mutex.h>
50 #include <netncp/ncp.h>
51 #include <netncp/ncp_conn.h>
52 #include <netncp/ncp_subr.h>
53 #include <netncp/nwerror.h>
54 #include <netncp/ncp_nls.h>
56 #include <fs/nwfs/nwfs.h>
57 #include <fs/nwfs/nwfs_node.h>
58 #include <fs/nwfs/nwfs_subr.h>
61 * Prototypes for NWFS vnode operations
63 static vop_create_t nwfs_create;
64 static vop_mknod_t nwfs_mknod;
65 static vop_open_t nwfs_open;
66 static vop_close_t nwfs_close;
67 static vop_access_t nwfs_access;
68 static vop_getattr_t nwfs_getattr;
69 static vop_setattr_t nwfs_setattr;
70 static vop_read_t nwfs_read;
71 static vop_write_t nwfs_write;
72 static vop_fsync_t nwfs_fsync;
73 static vop_remove_t nwfs_remove;
74 static vop_link_t nwfs_link;
75 static vop_lookup_t nwfs_lookup;
76 static vop_rename_t nwfs_rename;
77 static vop_mkdir_t nwfs_mkdir;
78 static vop_rmdir_t nwfs_rmdir;
79 static vop_symlink_t nwfs_symlink;
80 static vop_readdir_t nwfs_readdir;
81 static vop_strategy_t nwfs_strategy;
82 static vop_print_t nwfs_print;
83 static vop_pathconf_t nwfs_pathconf;
85 /* Global vfs data structures for nwfs */
86 struct vop_vector nwfs_vnodeops = {
87 .vop_default = &default_vnodeops,
89 .vop_access = nwfs_access,
90 .vop_close = nwfs_close,
91 .vop_create = nwfs_create,
92 .vop_fsync = nwfs_fsync,
93 .vop_getattr = nwfs_getattr,
94 .vop_getpages = nwfs_getpages,
95 .vop_inactive = nwfs_inactive,
96 .vop_ioctl = nwfs_ioctl,
97 .vop_link = nwfs_link,
98 .vop_lookup = nwfs_lookup,
99 .vop_mkdir = nwfs_mkdir,
100 .vop_mknod = nwfs_mknod,
101 .vop_open = nwfs_open,
102 .vop_pathconf = nwfs_pathconf,
103 .vop_print = nwfs_print,
104 .vop_putpages = nwfs_putpages,
105 .vop_read = nwfs_read,
106 .vop_readdir = nwfs_readdir,
107 .vop_reclaim = nwfs_reclaim,
108 .vop_remove = nwfs_remove,
109 .vop_rename = nwfs_rename,
110 .vop_rmdir = nwfs_rmdir,
111 .vop_setattr = nwfs_setattr,
112 .vop_strategy = nwfs_strategy,
113 .vop_symlink = nwfs_symlink,
114 .vop_write = nwfs_write,
118 * nwfs_access vnode op
122 struct vop_access_args /* {
125 struct ucred *a_cred;
129 struct vnode *vp = ap->a_vp;
131 struct nwmount *nmp = VTONWFS(vp);
134 if ((ap->a_accmode & VWRITE) && (vp->v_mount->mnt_flag & MNT_RDONLY)) {
135 switch (vp->v_type) {
136 case VREG: case VDIR: case VLNK:
142 mpmode = vp->v_type == VREG ? nmp->m.file_mode :
144 return (vaccess(vp->v_type, mpmode, nmp->m.uid,
145 nmp->m.gid, ap->a_accmode, ap->a_cred, NULL));
153 struct vop_open_args /* {
156 struct ucred *a_cred;
160 struct vnode *vp = ap->a_vp;
161 int mode = ap->a_mode;
162 struct nwnode *np = VTONW(vp);
163 struct ncp_open_info no;
164 struct nwmount *nmp = VTONWFS(vp);
168 NCPVNDEBUG("%s,%d\n", np->n_name, np->opened);
169 if (vp->v_type != VREG && vp->v_type != VDIR) {
170 NCPFATAL("open vtype = %d\n", vp->v_type);
173 if (vp->v_type == VDIR) return 0; /* nothing to do now */
174 if (np->n_flag & NMODIFIED) {
175 if ((error = nwfs_vinvalbuf(vp, ap->a_td)) == EINTR)
178 error = VOP_GETATTR(vp, &vattr, ap->a_cred);
179 if (error) return (error);
180 np->n_mtime = vattr.va_mtime.tv_sec;
182 error = VOP_GETATTR(vp, &vattr, ap->a_cred);
183 if (error) return (error);
184 if (np->n_mtime != vattr.va_mtime.tv_sec) {
185 if ((error = nwfs_vinvalbuf(vp, ap->a_td)) == EINTR)
187 np->n_mtime = vattr.va_mtime.tv_sec;
195 if ((vp->v_mount->mnt_flag & MNT_RDONLY) == 0)
197 error = ncp_open_create_file_or_subdir(nmp, vp, 0, NULL, OC_MODE_OPEN,
198 0, nwm, &no, ap->a_td, ap->a_cred);
203 error = ncp_open_create_file_or_subdir(nmp, vp, 0, NULL, OC_MODE_OPEN, 0,
204 nwm, &no, ap->a_td, ap->a_cred);
209 np->n_origfh = no.origfh;
217 struct vop_close_args /* {
218 struct vnodeop_desc *a_desc;
221 struct ucred *a_cred;
225 struct vnode *vp = ap->a_vp;
226 struct nwnode *np = VTONW(vp);
229 NCPVNDEBUG("name=%s,pid=%d,c=%d\n", np->n_name, ap->a_td->td_proc->p_pid,
232 if (vp->v_type == VDIR) return 0; /* nothing to do now */
234 mtx_lock(&vp->v_interlock);
235 if (np->opened == 0) {
236 mtx_unlock(&vp->v_interlock);
239 mtx_unlock(&vp->v_interlock);
240 error = nwfs_vinvalbuf(vp, ap->a_td);
241 mtx_lock(&vp->v_interlock);
242 if (np->opened == 0) {
243 mtx_unlock(&vp->v_interlock);
246 if (--np->opened == 0) {
247 mtx_unlock(&vp->v_interlock);
248 error = ncp_close_file(NWFSTOCONN(VTONWFS(vp)), &np->n_fh,
249 ap->a_td, ap->a_cred);
251 mtx_unlock(&vp->v_interlock);
257 * nwfs_getattr call from vfs.
261 struct vop_getattr_args /* {
264 struct ucred *a_cred;
267 struct vnode *vp = ap->a_vp;
268 struct nwnode *np = VTONW(vp);
269 struct vattr *va=ap->a_vap;
270 struct nwmount *nmp = VTONWFS(vp);
271 struct thread *td = curthread;
272 struct nw_entry_info fattr;
276 NCPVNDEBUG("%lx:%d: '%s' %d\n", (long)vp, nmp->n_volume, np->n_name, (vp->v_vflag & VV_ROOT) != 0);
277 error = nwfs_attr_cachelookup(vp, va);
278 if (!error) return 0;
279 NCPVNDEBUG("not in cache\n");
280 oldsize = np->n_size;
281 if (np->n_flag & NVOLUME) {
282 error = ncp_obtain_info(nmp, np->n_fid.f_id, 0, NULL, &fattr,
285 error = ncp_obtain_info(nmp, np->n_fid.f_parent, np->n_nmlen,
286 np->n_name, &fattr, td, ap->a_cred);
289 NCPVNDEBUG("error %d\n", error);
292 nwfs_attr_cacheenter(vp, &fattr);
295 np->n_size = oldsize;
299 * nwfs_setattr call from vfs.
303 struct vop_setattr_args /* {
306 struct ucred *a_cred;
309 struct vnode *vp = ap->a_vp;
310 struct nwnode *np = VTONW(vp);
311 struct vattr *vap = ap->a_vap;
316 if (vap->va_flags != VNOVAL)
319 * Disallow write attempts if the filesystem is mounted read-only.
321 if ((vap->va_uid != (uid_t)VNOVAL || vap->va_gid != (gid_t)VNOVAL ||
322 vap->va_atime.tv_sec != VNOVAL || vap->va_mtime.tv_sec != VNOVAL ||
323 vap->va_mode != (mode_t)VNOVAL) &&(vp->v_mount->mnt_flag & MNT_RDONLY))
325 if (vap->va_size != VNOVAL) {
326 switch (vp->v_type) {
331 * Disallow write attempts if the filesystem is
334 if (vp->v_mount->mnt_flag & MNT_RDONLY)
336 vnode_pager_setsize(vp, (u_long)vap->va_size);
338 np->n_size = vap->va_size;
344 error = ncp_setattr(vp, vap, ap->a_cred, curthread);
345 if (error && vap->va_size != VNOVAL) {
347 vnode_pager_setsize(vp, (u_long)tsize);
349 np->n_atime = 0; /* invalidate cache */
350 VOP_GETATTR(vp, vap, ap->a_cred);
351 np->n_mtime = vap->va_mtime.tv_sec;
359 struct vop_read_args /* {
363 struct ucred *a_cred;
366 struct vnode *vp = ap->a_vp;
367 struct uio *uio=ap->a_uio;
369 NCPVNDEBUG("nwfs_read:\n");
371 if (vp->v_type != VREG && vp->v_type != VDIR)
373 error = nwfs_readvnode(vp, uio, ap->a_cred);
379 struct vop_write_args /* {
383 struct ucred *a_cred;
386 struct vnode *vp = ap->a_vp;
387 struct uio *uio = ap->a_uio;
390 NCPVNDEBUG("%d,ofs=%d,sz=%d\n", vp->v_type, (int)uio->uio_offset, uio->uio_resid);
392 if (vp->v_type != VREG)
394 error = nwfs_writevnode(vp, uio, ap->a_cred, ap->a_ioflag);
399 * Create a regular file. On entry the directory to contain the file being
400 * created is locked. We must release before we return. We must also free
401 * the pathname buffer pointed at by cnp->cn_pnbuf, always on error, or
402 * only if the SAVESTART bit in cn_flags is clear on success.
406 struct vop_create_args /* {
408 struct vnode **a_vpp;
409 struct componentname *a_cnp;
413 struct vnode *dvp = ap->a_dvp;
414 struct vattr *vap = ap->a_vap;
415 struct vnode **vpp=ap->a_vpp;
416 struct componentname *cnp = ap->a_cnp;
417 struct vnode *vp = (struct vnode *)0;
418 int error = 0, fmode;
421 struct ncp_open_info no;
422 struct nwmount *nmp=VTONWFS(dvp);
428 if (vap->va_type == VSOCK)
430 if ((error = VOP_GETATTR(dvp, &vattr, cnp->cn_cred)))
432 fmode = AR_READ | AR_WRITE;
433 /* if (vap->va_vaflags & VA_EXCLUSIVE)
434 fmode |= AR_DENY_READ | AR_DENY_WRITE;*/
436 error = ncp_open_create_file_or_subdir(nmp, dvp, cnp->cn_namelen, cnp->cn_nameptr,
437 OC_MODE_CREATE | OC_MODE_OPEN | OC_MODE_REPLACE,
438 0, fmode, &no, cnp->cn_thread, cnp->cn_cred);
440 error = ncp_close_file(NWFSTOCONN(nmp), &no.fh, cnp->cn_thread, cnp->cn_cred);
441 fid.f_parent = VTONW(dvp)->n_fid.f_id;
442 fid.f_id = no.fattr.dirEntNum;
443 error = nwfs_nget(VTOVFS(dvp), fid, &no.fattr, dvp, &vp);
449 if (cnp->cn_flags & MAKEENTRY)
450 cache_enter(dvp, vp, cnp);
456 * nwfs_remove call. It isn't possible to emulate UFS behaivour because
457 * NetWare doesn't allow delete/rename operations on an opened file.
461 struct vop_remove_args /* {
462 struct vnodeop_desc *a_desc;
463 struct vnode * a_dvp;
465 struct componentname * a_cnp;
468 struct vnode *vp = ap->a_vp;
469 struct vnode *dvp = ap->a_dvp;
470 struct componentname *cnp = ap->a_cnp;
471 struct nwnode *np = VTONW(vp);
472 struct nwmount *nmp = VTONWFS(vp);
475 if (vp->v_type == VDIR || np->opened || vrefcnt(vp) != 1)
478 error = ncp_DeleteNSEntry(nmp, VTONW(dvp)->n_fid.f_id,
479 cnp->cn_namelen, cnp->cn_nameptr, cnp->cn_thread, cnp->cn_cred);
481 np->n_flag |= NSHOULDFREE;
482 else if (error == 0x899c)
488 * nwfs_file rename call
492 struct vop_rename_args /* {
493 struct vnode *a_fdvp;
495 struct componentname *a_fcnp;
496 struct vnode *a_tdvp;
498 struct componentname *a_tcnp;
501 struct vnode *fvp = ap->a_fvp;
502 struct vnode *tvp = ap->a_tvp;
503 struct vnode *fdvp = ap->a_fdvp;
504 struct vnode *tdvp = ap->a_tdvp;
505 struct componentname *tcnp = ap->a_tcnp;
506 struct componentname *fcnp = ap->a_fcnp;
507 struct nwmount *nmp=VTONWFS(fvp);
508 u_int16_t oldtype = 6;
511 /* Check for cross-device rename */
512 if ((fvp->v_mount != tdvp->v_mount) ||
513 (tvp && (fvp->v_mount != tvp->v_mount))) {
518 if (tvp && vrefcnt(tvp) > 1) {
522 if (fvp->v_type == VDIR) {
523 oldtype |= NW_TYPE_SUBDIR;
524 } else if (fvp->v_type == VREG) {
525 oldtype |= NW_TYPE_FILE;
530 if (tvp && tvp != fvp) {
531 error = ncp_DeleteNSEntry(nmp, VTONW(tdvp)->n_fid.f_id,
532 tcnp->cn_namelen, tcnp->cn_nameptr,
533 tcnp->cn_thread, tcnp->cn_cred);
534 if (error == 0x899c) error = EACCES;
538 error = ncp_nsrename(NWFSTOCONN(nmp), nmp->n_volume, nmp->name_space,
539 oldtype, &nmp->m.nls,
540 VTONW(fdvp)->n_fid.f_id, fcnp->cn_nameptr, fcnp->cn_namelen,
541 VTONW(tdvp)->n_fid.f_id, tcnp->cn_nameptr, tcnp->cn_namelen,
542 tcnp->cn_thread, tcnp->cn_cred);
546 if (fvp->v_type == VDIR) {
547 if (tvp != NULL && tvp->v_type == VDIR)
552 nwfs_attr_cacheremove(fdvp);
553 nwfs_attr_cacheremove(tdvp);
554 nwfs_attr_cacheremove(fvp);
565 nwfs_attr_cacheremove(tvp);
567 * Kludge: Map ENOENT => 0 assuming that it is a reply to a retry.
575 * nwfs hard link create call
576 * Netware filesystems don't know what links are.
580 struct vop_link_args /* {
581 struct vnode *a_tdvp;
583 struct componentname *a_cnp;
590 * nwfs_symlink link create call
591 * Netware filesystems don't know what symlinks are.
595 struct vop_symlink_args /* {
597 struct vnode **a_vpp;
598 struct componentname *a_cnp;
606 static int nwfs_mknod(ap)
607 struct vop_mknod_args /* {
618 struct vop_mkdir_args /* {
620 struct vnode **a_vpp;
621 struct componentname *a_cnp;
625 struct vnode *dvp = ap->a_dvp;
626 /* struct vattr *vap = ap->a_vap;*/
627 struct componentname *cnp = ap->a_cnp;
628 int len=cnp->cn_namelen;
629 struct ncp_open_info no;
630 struct vnode *newvp = (struct vnode *)0;
634 char *name=cnp->cn_nameptr;
636 if ((error = VOP_GETATTR(dvp, &vattr, cnp->cn_cred)))
638 if ((name[0] == '.') && ((len == 1) || ((len == 2) && (name[1] == '.')))) {
641 if (ncp_open_create_file_or_subdir(VTONWFS(dvp), dvp, cnp->cn_namelen,
642 cnp->cn_nameptr, OC_MODE_CREATE, aDIR, 0xffff,
643 &no, cnp->cn_thread, cnp->cn_cred) != 0) {
649 fid.f_parent = VTONW(dvp)->n_fid.f_id;
650 fid.f_id = no.fattr.dirEntNum;
651 error = nwfs_nget(VTOVFS(dvp), fid, &no.fattr, dvp, &newvp);
653 newvp->v_type = VDIR;
661 * nwfs_remove directory call
665 struct vop_rmdir_args /* {
668 struct componentname *a_cnp;
671 struct vnode *vp = ap->a_vp;
672 struct vnode *dvp = ap->a_dvp;
673 struct componentname *cnp = ap->a_cnp;
674 struct nwnode *np = VTONW(vp);
675 struct nwmount *nmp = VTONWFS(vp);
676 struct nwnode *dnp = VTONW(dvp);
682 error = ncp_DeleteNSEntry(nmp, dnp->n_fid.f_id,
683 cnp->cn_namelen, cnp->cn_nameptr, cnp->cn_thread, cnp->cn_cred);
685 np->n_flag |= NSHOULDFREE;
686 else if (error == NWE_DIR_NOT_EMPTY)
688 dnp->n_flag |= NMODIFIED;
689 nwfs_attr_cacheremove(dvp);
700 struct vop_readdir_args /* {
703 struct ucred *a_cred;
709 struct vnode *vp = ap->a_vp;
710 struct uio *uio = ap->a_uio;
713 if (vp->v_type != VDIR)
715 if (ap->a_ncookies) {
716 printf("nwfs_readdir: no support for cookies now...");
720 error = nwfs_readvnode(vp, uio, ap->a_cred);
726 struct vop_fsync_args /* {
727 struct vnodeop_desc *a_desc;
729 struct ucred * a_cred;
734 /* return (nfs_flush(ap->a_vp, ap->a_cred, ap->a_waitfor, ap->a_td, 1));*/
741 struct vop_print_args /* {
745 struct vnode *vp = ap->a_vp;
746 struct nwnode *np = VTONW(vp);
748 printf("\tnwfs node: name = '%s', fid = %d, pfid = %d\n",
749 np->n_name, np->n_fid.f_id, np->n_fid.f_parent);
753 static int nwfs_pathconf (ap)
754 struct vop_pathconf_args /* {
760 int name=ap->a_name, error=0;
761 register_t *retval=ap->a_retval;
768 *retval=NCP_MAX_FILENAME; /* XXX from nwfsnode */
771 *retval=NCP_MAXPATHLEN; /* XXX from nwfsnode */
779 static int nwfs_strategy (ap)
780 struct vop_strategy_args /* {
784 struct buf *bp=ap->a_bp;
789 if (bp->b_flags & B_ASYNC)
790 td = (struct thread *)0;
792 td = curthread; /* XXX */
793 if (bp->b_iocmd == BIO_READ)
798 * If the op is asynchronous and an i/o daemon is waiting
799 * queue the request, wake it up and wait for completion
800 * otherwise just do it ourselves.
802 if ((bp->b_flags & B_ASYNC) == 0 )
803 (void)nwfs_doio(ap->a_vp, bp, cr, td);
809 * How to keep the brain busy ...
810 * Currently lookup routine can make two lookup for vnode. This can be
811 * avoided by reorg the code.
815 struct vop_lookup_args /* {
816 struct vnodeop_desc *a_desc;
818 struct vnode **a_vpp;
819 struct componentname *a_cnp;
822 struct componentname *cnp = ap->a_cnp;
823 struct vnode *dvp = ap->a_dvp;
824 struct vnode **vpp = ap->a_vpp;
825 int flags = cnp->cn_flags;
828 struct mount *mp = dvp->v_mount;
829 struct nwnode *dnp, *npp;
830 struct nw_entry_info fattr, *fap;
832 int nameiop=cnp->cn_nameiop, islastcn;
833 int error = 0, notfound;
834 struct thread *td = cnp->cn_thread;
835 char _name[cnp->cn_namelen+1];
836 bcopy(cnp->cn_nameptr, _name, cnp->cn_namelen);
837 _name[cnp->cn_namelen]=0;
839 if (dvp->v_type != VDIR)
841 if ((flags & ISDOTDOT) && (dvp->v_vflag & VV_ROOT)) {
842 printf("nwfs_lookup: invalid '..'\n");
846 NCPVNDEBUG("%d '%s' in '%s' id=d\n", nameiop, _name,
847 VTONW(dvp)->n_name/*, VTONW(dvp)->n_name*/);
849 islastcn = flags & ISLASTCN;
850 if (islastcn && (mp->mnt_flag & MNT_RDONLY) && (nameiop != LOOKUP))
852 if ((error = VOP_ACCESS(dvp, VEXEC, cnp->cn_cred, td)))
857 printf("dvp %d:%d:%d\n", (int)mp, (int)dvp->v_vflag & VV_ROOT, (int)flags & ISDOTDOT);
859 error = ncp_pathcheck(cnp->cn_nameptr, cnp->cn_namelen, &nmp->m.nls,
860 (nameiop == CREATE || nameiop == RENAME) && (nmp->m.nls.opt & NWHP_NOSTRICT) == 0);
864 error = cache_lookup(dvp, vpp, cnp);
865 NCPVNDEBUG("cache_lookup returned %d\n", error);
868 if (error) { /* name was found */
872 if (!VOP_GETATTR(vp, &vattr, cnp->cn_cred) &&
873 vattr.va_ctime.tv_sec == VTONW(vp)->n_ctime) {
874 if (nameiop != LOOKUP && islastcn)
875 cnp->cn_flags |= SAVENAME;
876 NCPVNDEBUG("use cached vnode");
886 /* not in cache, so ... */
890 if (flags & ISDOTDOT) {
891 if (NWCMPF(&dnp->n_parent, &nmp->n_rootent)) {
892 fid = nmp->n_rootent;
896 error = nwfs_lookupnp(nmp, dnp->n_parent, td, &npp);
903 notfound = ncp_obtain_info(nmp, npp->n_dosfid,
904 0, NULL, fap, td, cnp->cn_cred);
908 notfound = ncp_lookup(dvp, cnp->cn_namelen, cnp->cn_nameptr,
909 fap, td, cnp->cn_cred);
910 fid.f_id = fap->dirEntNum;
911 if (cnp->cn_namelen == 1 && cnp->cn_nameptr[0] == '.') {
912 fid.f_parent = dnp->n_fid.f_parent;
914 fid.f_parent = dnp->n_fid.f_id;
915 NCPVNDEBUG("call to ncp_lookup returned=%d\n", notfound);
917 if (notfound && notfound < 0x80 )
918 return (notfound); /* hard error */
919 if (notfound) { /* entry not found */
920 /* Handle RENAME or CREATE case... */
921 if ((nameiop == CREATE || nameiop == RENAME) && islastcn) {
922 cnp->cn_flags |= SAVENAME;
923 return (EJUSTRETURN);
927 NCPVNDEBUG("Found entry %s with id=%d\n", fap->entryName, fap->dirEntNum);
929 /* handle DELETE case ... */
930 if (nameiop == DELETE && islastcn) { /* delete last component */
931 error = VOP_ACCESS(dvp, VWRITE, cnp->cn_cred, cnp->cn_thread);
932 if (error) return (error);
933 if (NWCMPF(&dnp->n_fid, &fid)) { /* we found ourselfs */
938 error = nwfs_nget(mp, fid, fap, dvp, &vp);
939 if (error) return (error);
941 cnp->cn_flags |= SAVENAME; /* I free it later */
944 if (nameiop == RENAME && islastcn) {
945 error = VOP_ACCESS(dvp, VWRITE, cnp->cn_cred, cnp->cn_thread);
946 if (error) return (error);
947 if (NWCMPF(&dnp->n_fid, &fid)) return EISDIR;
948 error = nwfs_nget(mp, fid, fap, dvp, &vp);
949 if (error) return (error);
951 cnp->cn_flags |= SAVENAME;
954 if (flags & ISDOTDOT) {
955 VOP_UNLOCK(dvp, 0); /* race to get the inode */
956 error = nwfs_nget(mp, fid, NULL, NULL, &vp);
957 vn_lock(dvp, LK_EXCLUSIVE | LK_RETRY);
961 } else if (NWCMPF(&dnp->n_fid, &fid)) {
965 error = nwfs_nget(mp, fid, fap, dvp, &vp);
966 if (error) return (error);
968 NCPVNDEBUG("lookup: getnewvp!\n");
970 if ((cnp->cn_flags & MAKEENTRY)/* && !islastcn*/) {
971 VTONW(*vpp)->n_ctime = VTONW(*vpp)->n_vattr.va_ctime.tv_sec;
972 cache_enter(dvp, *vpp, cnp);