这篇教程C++ vn_unlock函数代码示例写得很实用,希望能帮到您。
本文整理汇总了C++中vn_unlock函数的典型用法代码示例。如果您正苦于以下问题:C++ vn_unlock函数的具体用法?C++ vn_unlock怎么用?C++ vn_unlock使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。 在下文中一共展示了vn_unlock函数的22个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。 示例1: cttyopen/* * This opens /dev/tty. Because multiple opens of /dev/tty only * generate a single open to the actual tty, the file modes are * locked to FREAD|FWRITE. */static intcttyopen(struct dev_open_args *ap){ struct proc *p = curproc; struct vnode *ttyvp; int error; KKASSERT(p);retry: if ((ttyvp = cttyvp(p)) == NULL) return (ENXIO); if (ttyvp->v_flag & VCTTYISOPEN) return (0); /* * Messy interlock, don't let the vnode go away while we try to * lock it and check for race after we might have blocked. */ vhold(ttyvp); vn_lock(ttyvp, LK_EXCLUSIVE | LK_RETRY); if (ttyvp != cttyvp(p) || (ttyvp->v_flag & VCTTYISOPEN)) { kprintf("Warning: cttyopen: race avoided/n"); vn_unlock(ttyvp); vdrop(ttyvp); goto retry; } vsetflags(ttyvp, VCTTYISOPEN); error = VOP_OPEN(ttyvp, FREAD|FWRITE, ap->a_cred, NULL); if (error) vclrflags(ttyvp, VCTTYISOPEN); vn_unlock(ttyvp); vdrop(ttyvp); return(error);}
开发者ID:AhmadTux,项目名称:DragonFlyBSD,代码行数:39,
示例2: iso_mountrootstatic intiso_mountroot(struct mount *mp){ struct iso_args args; struct vnode *rootvp; int error; if ((error = bdevvp(rootdev, &rootvp))) { kprintf("iso_mountroot: can't find rootvp/n"); return (error); } args.flags = ISOFSMNT_ROOT; vn_lock(rootvp, LK_EXCLUSIVE | LK_RETRY); error = VOP_OPEN(rootvp, FREAD, FSCRED, NULL); vn_unlock(rootvp); if (error) return (error); args.ssector = iso_get_ssector(rootdev); vn_lock(rootvp, LK_EXCLUSIVE | LK_RETRY); VOP_CLOSE(rootvp, FREAD, NULL); vn_unlock(rootvp); if (bootverbose) kprintf("iso_mountroot(): using session at block %d/n", args.ssector); if ((error = iso_mountfs(rootvp, mp, &args)) != 0) return (error); cd9660_statfs(mp, &mp->mnt_stat, proc0.p_ucred); return (0);}
开发者ID:mihaicarabas,项目名称:dragonfly,代码行数:34,
示例3: vop_compat_nresolve/* * vop_compat_resolve { struct nchandle *a_nch, struct vnode *dvp } * XXX STOPGAP FUNCTION * * XXX OLD API ROUTINE! WHEN ALL VFSs HAVE BEEN CLEANED UP THIS PROCEDURE * WILL BE REMOVED. This procedure exists for all VFSs which have not * yet implemented VOP_NRESOLVE(). It converts VOP_NRESOLVE() into a * vop_old_lookup() and does appropriate translations. * * Resolve a ncp for VFSs which do not support the VOP. Eventually all * VFSs will support this VOP and this routine can be removed, since * VOP_NRESOLVE() is far less complex then the older LOOKUP/CACHEDLOOKUP * API. * * A locked ncp is passed in to be resolved. The NCP is resolved by * figuring out the vnode (if any) and calling cache_setvp() to attach the * vnode to the entry. If the entry represents a non-existant node then * cache_setvp() is called with a NULL vnode to resolve the entry into a * negative cache entry. No vnode locks are retained and the * ncp is left locked on return. * * The ncp will NEVER represent "", "." or "..", or contain any slashes. * * There is a potential directory and vnode interlock. The lock order * requirement is: namecache, governing directory, resolved vnode. */intvop_compat_nresolve(struct vop_nresolve_args *ap){ int error; struct vnode *dvp; struct vnode *vp; struct nchandle *nch; struct namecache *ncp; struct componentname cnp; nch = ap->a_nch; /* locked namecache node */ ncp = nch->ncp; dvp = ap->a_dvp; /* * UFS currently stores all sorts of side effects, including a loop * variable, in the directory inode. That needs to be fixed and the * other VFS's audited before we can switch to LK_SHARED. */ if ((error = vget(dvp, LK_EXCLUSIVE)) != 0) { kprintf("[diagnostic] vop_compat_resolve: EAGAIN on ncp %p %s/n", ncp, ncp->nc_name); return(EAGAIN); } bzero(&cnp, sizeof(cnp)); cnp.cn_nameiop = NAMEI_LOOKUP; cnp.cn_flags = 0; cnp.cn_nameptr = ncp->nc_name; cnp.cn_namelen = ncp->nc_nlen; cnp.cn_cred = ap->a_cred; cnp.cn_td = curthread; /* XXX */ /* * vop_old_lookup() always returns vp locked. dvp may or may not be * left locked depending on CNP_PDIRUNLOCK. */ error = vop_old_lookup(ap->a_head.a_ops, dvp, &vp, &cnp); if (error == 0) vn_unlock(vp); if ((cnp.cn_flags & CNP_PDIRUNLOCK) == 0) vn_unlock(dvp); if ((ncp->nc_flag & NCF_UNRESOLVED) == 0) { /* was resolved by another process while we were unlocked */ if (error == 0) vrele(vp); } else if (error == 0) { KKASSERT(vp != NULL); cache_setvp(nch, vp); vrele(vp); } else if (error == ENOENT) { KKASSERT(vp == NULL); if (cnp.cn_flags & CNP_ISWHITEOUT) ncp->nc_flag |= NCF_WHITEOUT; cache_setvp(nch, NULL); } vrele(dvp); return (error);}
开发者ID:madhavsuresh,项目名称:DragonFlyBSD,代码行数:85,
示例4: cttyopen/* * This opens /dev/tty. Because multiple opens of /dev/tty only * generate a single open to the actual tty, the file modes are * locked to FREAD|FWRITE. */static intcttyopen(struct dev_open_args *ap){ struct proc *p = curproc; struct vnode *ttyvp; int error; KKASSERT(p);retry: if ((ttyvp = cttyvp(p)) == NULL) return (ENXIO); if (ttyvp->v_flag & VCTTYISOPEN) return (0); /* * Messy interlock, don't let the vnode go away while we try to * lock it and check for race after we might have blocked. * * WARNING! The device open (devfs_spec_open()) temporarily * releases the vnode lock on ttyvp when issuing the * dev_dopen(), which means that the VCTTYISOPEn flag * can race during the VOP_OPEN(). * * If something does race we have to undo our potentially * extra open. */ vhold(ttyvp); vn_lock(ttyvp, LK_EXCLUSIVE | LK_RETRY); if (ttyvp != cttyvp(p) || (ttyvp->v_flag & VCTTYISOPEN)) { kprintf("Warning: cttyopen: race-1 avoided/n"); vn_unlock(ttyvp); vdrop(ttyvp); goto retry; } error = VOP_OPEN(ttyvp, FREAD|FWRITE, ap->a_cred, NULL); /* * Race against ctty close or change. This case has been validated * and occurs every so often during synth builds. */ if (ttyvp != cttyvp(p) || (ttyvp->v_flag & VCTTYISOPEN)) { if (error == 0) VOP_CLOSE(ttyvp, FREAD|FWRITE, NULL); vn_unlock(ttyvp); vdrop(ttyvp); goto retry; } if (error == 0) vsetflags(ttyvp, VCTTYISOPEN); vn_unlock(ttyvp); vdrop(ttyvp); return(error);}
开发者ID:kusumi,项目名称:DragonFlyBSD,代码行数:58,
示例5: devfs_spec_readstatic intdevfs_spec_read(struct vop_read_args *ap){ struct devfs_node *node; struct vnode *vp; struct uio *uio; cdev_t dev; int error; vp = ap->a_vp; dev = vp->v_rdev; uio = ap->a_uio; node = DEVFS_NODE(vp); if (dev == NULL) /* device was revoked */ return (EBADF); if (uio->uio_resid == 0) return (0); vn_unlock(vp); error = dev_dread(dev, uio, ap->a_ioflag, NULL); vn_lock(vp, LK_EXCLUSIVE | LK_RETRY); if (node) nanotime(&node->atime); return (error);}
开发者ID:mihaicarabas,项目名称:dragonfly,代码行数:28,
示例6: union_mkdir/* * union_mkdir(struct vnode *a_dvp, struct vnode **a_vpp, * struct componentname *a_cnp, struct vattr *a_vap) */static intunion_mkdir(struct vop_old_mkdir_args *ap){ struct union_node *dun = VTOUNION(ap->a_dvp); struct componentname *cnp = ap->a_cnp; struct thread *td = cnp->cn_td; struct vnode *upperdvp; int error = EROFS; if ((upperdvp = union_lock_upper(dun, td)) != NULLVP) { struct vnode *vp; error = VOP_MKDIR(upperdvp, &vp, cnp, ap->a_vap); union_unlock_upper(upperdvp, td); if (error == 0) { vn_unlock(vp); UDEBUG(("ALLOCVP-2 FROM %p REFS %d/n", vp, vp->v_sysref.refcnt)); error = union_allocvp(ap->a_vpp, ap->a_dvp->v_mount, ap->a_dvp, NULLVP, cnp, vp, NULLVP, 1); UDEBUG(("ALLOCVP-2B FROM %p REFS %d/n", *ap->a_vpp, vp->v_sysref.refcnt)); } } return (error);}
开发者ID:AhmadTux,项目名称:DragonFlyBSD,代码行数:29,
示例7: union_create/* * union_create: * * a_dvp is locked on entry and remains locked on return. a_vpp is returned * locked if no error occurs, otherwise it is garbage. * * union_create(struct vnode *a_dvp, struct vnode **a_vpp, * struct componentname *a_cnp, struct vattr *a_vap) */static intunion_create(struct vop_old_create_args *ap){ struct union_node *dun = VTOUNION(ap->a_dvp); struct componentname *cnp = ap->a_cnp; struct thread *td = cnp->cn_td; struct vnode *dvp; int error = EROFS; if ((dvp = union_lock_upper(dun, td)) != NULL) { struct vnode *vp; struct mount *mp; error = VOP_CREATE(dvp, &vp, cnp, ap->a_vap); if (error == 0) { mp = ap->a_dvp->v_mount; vn_unlock(vp); UDEBUG(("ALLOCVP-1 FROM %p REFS %d/n", vp, vp->v_sysref.refcnt)); error = union_allocvp(ap->a_vpp, mp, NULLVP, NULLVP, cnp, vp, NULLVP, 1); UDEBUG(("ALLOCVP-2B FROM %p REFS %d/n", *ap->a_vpp, vp->v_sysref.refcnt)); } union_unlock_upper(dvp, td); } return (error);}
开发者ID:AhmadTux,项目名称:DragonFlyBSD,代码行数:35,
示例8: tmpfs_nlookupdotdotstatic inttmpfs_nlookupdotdot(struct vop_nlookupdotdot_args *v){ struct vnode *dvp = v->a_dvp; struct vnode **vpp = v->a_vpp; struct tmpfs_node *dnode = VP_TO_TMPFS_NODE(dvp); struct ucred *cred = v->a_cred; struct mount *mp; int error; *vpp = NULL; mp = dvp->v_mount; /* Check accessibility of requested node as a first step. */ error = VOP_ACCESS(dvp, VEXEC, cred); if (error != 0) return error; if (dnode->tn_dir.tn_parent != NULL) { /* Allocate a new vnode on the matching entry. */ error = tmpfs_alloc_vp(dvp->v_mount, dnode->tn_dir.tn_parent, LK_EXCLUSIVE | LK_RETRY, vpp); if (*vpp) vn_unlock(*vpp); } return (*vpp == NULL) ? ENOENT : 0;}
开发者ID:wan721,项目名称:DragonFlyBSD,代码行数:29,
示例9: devfs_spec_write/* * Vnode op for write * * spec_write(struct vnode *a_vp, struct uio *a_uio, int a_ioflag, * struct ucred *a_cred) */static intdevfs_spec_write(struct vop_write_args *ap){ struct devfs_node *node; struct vnode *vp; struct uio *uio; cdev_t dev; int error; vp = ap->a_vp; dev = vp->v_rdev; uio = ap->a_uio; node = DEVFS_NODE(vp); KKASSERT(uio->uio_segflg != UIO_NOCOPY); if (dev == NULL) /* device was revoked */ return (EBADF); vn_unlock(vp); error = dev_dwrite(dev, uio, ap->a_ioflag, NULL); vn_lock(vp, LK_EXCLUSIVE | LK_RETRY); if (node) { nanotime(&node->atime); nanotime(&node->mtime); } return (error);}
开发者ID:mihaicarabas,项目名称:dragonfly,代码行数:36,
示例10: puffs_vnop_remove/* * XXX: can't use callremove now because can't catch setbacks with * it due to lack of a pnode argument. */static intpuffs_vnop_remove(struct vop_nremove_args *ap){ PUFFS_MSG_VARS(vn, remove); struct vnode *dvp = ap->a_dvp; struct vnode *vp; struct puffs_node *dpn = VPTOPP(dvp); struct puffs_node *pn; struct nchandle *nch = ap->a_nch; struct namecache *ncp = nch->ncp; struct ucred *cred = ap->a_cred; struct mount *mp = dvp->v_mount; struct puffs_mount *pmp = MPTOPUFFSMP(mp); int error; if (!EXISTSOP(pmp, REMOVE)) return EOPNOTSUPP; error = vget(dvp, LK_EXCLUSIVE); if (error != 0) { DPRINTF(("puffs_vnop_remove: EAGAIN on parent vnode %p %s/n", dvp, ncp->nc_name)); return EAGAIN; } error = cache_vget(nch, cred, LK_EXCLUSIVE, &vp); if (error != 0) { DPRINTF(("puffs_vnop_remove: cache_vget error: %p %s/n", dvp, ncp->nc_name)); return EAGAIN; } if (vp->v_type == VDIR) { error = EISDIR; goto out; } pn = VPTOPP(vp); PUFFS_MSG_ALLOC(vn, remove); remove_msg->pvnr_cookie_targ = VPTOPNC(vp); puffs_makecn(&remove_msg->pvnr_cn, &remove_msg->pvnr_cn_cred, ncp, cred); puffs_msg_setinfo(park_remove, PUFFSOP_VN, PUFFS_VN_REMOVE, VPTOPNC(dvp)); puffs_msg_enqueue(pmp, park_remove); error = puffs_msg_wait2(pmp, park_remove, dpn, pn); PUFFS_MSG_RELEASE(remove); error = checkerr(pmp, error, __func__);out: vput(dvp); vn_unlock(vp); if (error == 0) cache_unlink(nch); vrele(vp); return error;}
开发者ID:wan721,项目名称:DragonFlyBSD,代码行数:63,
示例11: union_access/* * Check access permission on the union vnode. * The access check being enforced is to check * against both the underlying vnode, and any * copied vnode. This ensures that no additional * file permissions are given away simply because * the user caused an implicit file copy. * * union_access(struct vnode *a_vp, int a_mode, * struct ucred *a_cred, struct thread *a_td) */static intunion_access(struct vop_access_args *ap){ struct union_node *un = VTOUNION(ap->a_vp); struct thread *td = ap->a_td; int error = EACCES; struct vnode *vp; /* * Disallow write attempts on filesystems mounted read-only. */ if ((ap->a_mode & VWRITE) && (ap->a_vp->v_mount->mnt_flag & MNT_RDONLY)) { switch (ap->a_vp->v_type) { case VREG: case VDIR: case VLNK: return (EROFS); default: break; } } if ((vp = union_lock_upper(un, td)) != NULLVP) { ap->a_head.a_ops = *vp->v_ops; ap->a_vp = vp; error = vop_access_ap(ap); union_unlock_upper(vp, td); return(error); } if ((vp = un->un_lowervp) != NULLVP) { vn_lock(vp, LK_EXCLUSIVE | LK_RETRY); ap->a_head.a_ops = *vp->v_ops; ap->a_vp = vp; /* * Remove VWRITE from a_mode if our mount point is RW, because * we want to allow writes and lowervp may be read-only. */ if ((un->un_vnode->v_mount->mnt_flag & MNT_RDONLY) == 0) ap->a_mode &= ~VWRITE; error = vop_access_ap(ap); if (error == 0) { struct union_mount *um; um = MOUNTTOUNIONMOUNT(un->un_vnode->v_mount); if (um->um_op == UNMNT_BELOW) { ap->a_cred = um->um_cred; error = vop_access_ap(ap); } } vn_unlock(vp); } return(error);}
开发者ID:AhmadTux,项目名称:DragonFlyBSD,代码行数:69,
示例12: tmpfs_nresolvestatic inttmpfs_nresolve(struct vop_nresolve_args *v){ struct vnode *dvp = v->a_dvp; struct vnode *vp = NULL; struct namecache *ncp = v->a_nch->ncp; struct tmpfs_node *tnode; struct mount *mp; struct tmpfs_dirent *de; struct tmpfs_node *dnode; int error; mp = dvp->v_mount; dnode = VP_TO_TMPFS_DIR(dvp); TMPFS_NODE_LOCK_SH(dnode); de = tmpfs_dir_lookup(dnode, NULL, ncp); if (de == NULL) { error = ENOENT; } else { /* * Allocate a vnode for the node we found. */ tnode = de->td_node; error = tmpfs_alloc_vp(dvp->v_mount, tnode, LK_EXCLUSIVE | LK_RETRY, &vp); if (error) goto out; KKASSERT(vp); }out: TMPFS_NODE_UNLOCK(dnode); if ((dnode->tn_status & TMPFS_NODE_ACCESSED) == 0) { TMPFS_NODE_LOCK(dnode); dnode->tn_status |= TMPFS_NODE_ACCESSED; TMPFS_NODE_UNLOCK(dnode); } /* * Store the result of this lookup in the cache. Avoid this if the * request was for creation, as it does not improve timings on * emprical tests. */ if (vp) { vn_unlock(vp); cache_setvp(v->a_nch, vp); vrele(vp); } else if (error == ENOENT) { cache_setvp(v->a_nch, NULL); } return (error);}
开发者ID:wan721,项目名称:DragonFlyBSD,代码行数:55,
示例13: vn_write/* * MPSAFE */static intvn_write(struct file *fp, struct uio *uio, struct ucred *cred, int flags){ struct ccms_lock ccms_lock; struct vnode *vp; int error, ioflag; KASSERT(uio->uio_td == curthread, ("uio_td %p is not p %p", uio->uio_td, curthread)); vp = (struct vnode *)fp->f_data; ioflag = IO_UNIT; if (vp->v_type == VREG && ((fp->f_flag & O_APPEND) || (flags & O_FAPPEND))) { ioflag |= IO_APPEND; } if (flags & O_FBLOCKING) { /* ioflag &= ~IO_NDELAY; */ } else if (flags & O_FNONBLOCKING) { ioflag |= IO_NDELAY; } else if (fp->f_flag & FNONBLOCK) { ioflag |= IO_NDELAY; } if (flags & O_FBUFFERED) { /* ioflag &= ~IO_DIRECT; */ } else if (flags & O_FUNBUFFERED) { ioflag |= IO_DIRECT; } else if (fp->f_flag & O_DIRECT) { ioflag |= IO_DIRECT; } if (flags & O_FASYNCWRITE) { /* ioflag &= ~IO_SYNC; */ } else if (flags & O_FSYNCWRITE) { ioflag |= IO_SYNC; } else if (fp->f_flag & O_FSYNC) { ioflag |= IO_SYNC; } if (vp->v_mount && (vp->v_mount->mnt_flag & MNT_SYNCHRONOUS)) ioflag |= IO_SYNC; if ((flags & O_FOFFSET) == 0) uio->uio_offset = vn_get_fpf_offset(fp); vn_lock(vp, LK_EXCLUSIVE | LK_RETRY); ioflag |= sequential_heuristic(uio, fp); ccms_lock_get_uio(&vp->v_ccms, &ccms_lock, uio); error = VOP_WRITE(vp, uio, ioflag, cred); ccms_lock_put(&vp->v_ccms, &ccms_lock); fp->f_nextoff = uio->uio_offset; vn_unlock(vp); if ((flags & O_FOFFSET) == 0) vn_set_fpf_offset(fp, uio->uio_offset); return (error);}
开发者ID:AhmadTux,项目名称:DragonFlyBSD,代码行数:57,
示例14: hammer_close_devicestatic voidhammer_close_device(struct vnode **devvpp, int ronly){ if (*devvpp) { vn_lock(*devvpp, LK_EXCLUSIVE | LK_RETRY); vinvalbuf(*devvpp, ronly ? 0 : V_SAVE, 0, 0); VOP_CLOSE(*devvpp, (ronly ? FREAD : FREAD|FWRITE), NULL); vn_unlock(*devvpp); vrele(*devvpp); *devvpp = NULL; }}
开发者ID:victoredwardocallaghan,项目名称:DragonFlyBSD,代码行数:12,
示例15: vn_close/* * Vnode close call * * MPSAFE */intvn_close(struct vnode *vp, int flags){ int error; error = vn_lock(vp, LK_EXCLUSIVE | LK_RETRY); if (error == 0) { error = VOP_CLOSE(vp, flags); vn_unlock(vp); } vrele(vp); return (error);}
开发者ID:AhmadTux,项目名称:DragonFlyBSD,代码行数:18,
示例16: devfs_vop_nlookupdotdotstatic intdevfs_vop_nlookupdotdot(struct vop_nlookupdotdot_args *ap){ struct devfs_node *dnode = DEVFS_NODE(ap->a_dvp); *ap->a_vpp = NULL; if (!devfs_node_is_accessible(dnode)) return ENOENT; lockmgr(&devfs_lock, LK_EXCLUSIVE); if (dnode->parent != NULL) { devfs_allocv(ap->a_vpp, dnode->parent); vn_unlock(*ap->a_vpp); } lockmgr(&devfs_lock, LK_RELEASE); return ((*ap->a_vpp == NULL) ? ENOENT : 0);}
开发者ID:mihaicarabas,项目名称:dragonfly,代码行数:18,
示例17: nlookup_done/* * Cleanup a nlookupdata structure after we are through with it. This may * be called on any nlookupdata structure initialized with nlookup_init(). * Calling nlookup_done() is mandatory in all cases except where nlookup_init() * returns an error, even if as a consumer you believe you have taken all * dynamic elements out of the nlookupdata structure. */voidnlookup_done(struct nlookupdata *nd){ if (nd->nl_nch.ncp) { if (nd->nl_flags & NLC_NCPISLOCKED) { nd->nl_flags &= ~NLC_NCPISLOCKED; cache_unlock(&nd->nl_nch); } if (nd->nl_flags & NLC_NCDIR) { cache_drop_ncdir(&nd->nl_nch); nd->nl_flags &= ~NLC_NCDIR; } else { cache_drop(&nd->nl_nch); /* NULL's out the nch */ } } if (nd->nl_rootnch.ncp) cache_drop_and_cache(&nd->nl_rootnch); if (nd->nl_jailnch.ncp) cache_drop_and_cache(&nd->nl_jailnch); if ((nd->nl_flags & NLC_HASBUF) && nd->nl_path) { objcache_put(namei_oc, nd->nl_path); nd->nl_path = NULL; } if (nd->nl_cred) { if ((nd->nl_flags & NLC_BORROWCRED) == 0) crfree(nd->nl_cred); nd->nl_cred = NULL; nd->nl_flags &= ~NLC_BORROWCRED; } if (nd->nl_open_vp) { if (nd->nl_flags & NLC_LOCKVP) { vn_unlock(nd->nl_open_vp); nd->nl_flags &= ~NLC_LOCKVP; } vn_close(nd->nl_open_vp, nd->nl_vp_fmode, NULL); nd->nl_open_vp = NULL; } if (nd->nl_dvp) { vrele(nd->nl_dvp); nd->nl_dvp = NULL; } nd->nl_flags = 0; /* clear remaining flags (just clear everything) */}
开发者ID:kusumi,项目名称:DragonFlyBSD,代码行数:50,
示例18: hammer_setup_devicestatic inthammer_setup_device(struct vnode **devvpp, const char *dev_path, int ronly){ int error; struct nlookupdata nd; /* * Get the device vnode */ if (*devvpp == NULL) { error = nlookup_init(&nd, dev_path, UIO_SYSSPACE, NLC_FOLLOW); if (error == 0) error = nlookup(&nd); if (error == 0) error = cache_vref(&nd.nl_nch, nd.nl_cred, devvpp); nlookup_done(&nd); } else { error = 0; } if (error == 0) { if (vn_isdisk(*devvpp, &error)) { error = vfs_mountedon(*devvpp); } } if (error == 0 && vcount(*devvpp) > 0) error = EBUSY; if (error == 0) { vn_lock(*devvpp, LK_EXCLUSIVE | LK_RETRY); error = vinvalbuf(*devvpp, V_SAVE, 0, 0); if (error == 0) { error = VOP_OPEN(*devvpp, (ronly ? FREAD : FREAD|FWRITE), FSCRED, NULL); } vn_unlock(*devvpp); } if (error && *devvpp) { vrele(*devvpp); *devvpp = NULL; } return (error);}
开发者ID:victoredwardocallaghan,项目名称:DragonFlyBSD,代码行数:43,
示例19: nwfs_readdir/* * nwfs_readdir call * * nwfs_readdir(struct vnode *a_vp, struct uio *a_uio, struct ucred *a_cred, * int *a_eofflag, off_t *a_cookies, int a_ncookies) */static intnwfs_readdir(struct vop_readdir_args *ap){ struct vnode *vp = ap->a_vp; struct uio *uio = ap->a_uio; int error; if (vp->v_type != VDIR) return (EPERM); if (ap->a_ncookies) { kprintf("nwfs_readdir: no support for cookies now..."); return (EOPNOTSUPP); } error = vn_lock(vp, LK_EXCLUSIVE | LK_RETRY | LK_FAILRECLAIM); if (error) return (error); error = nwfs_readvnode(vp, uio, ap->a_cred); vn_unlock(vp); return error;}
开发者ID:mihaicarabas,项目名称:dragonfly,代码行数:26,
示例20: vn_opendiskintvn_opendisk(const char *devname, int fmode, struct vnode **vpp){ struct vnode *vp; int error; if (strncmp(devname, "/dev/", 5) == 0) devname += 5; if ((vp = getsynthvnode(devname)) == NULL) { error = ENODEV; } else { error = VOP_OPEN(vp, fmode, proc0.p_ucred, NULL); vn_unlock(vp); if (error) { vrele(vp); vp = NULL; } } *vpp = vp; return (error);}
开发者ID:AhmadTux,项目名称:DragonFlyBSD,代码行数:21,
示例21: union_inactive/* * union_inactive: * * Called with the vnode locked. We are expected to unlock the vnode. * * union_inactive(struct vnode *a_vp, struct thread *a_td) */static intunion_inactive(struct vop_inactive_args *ap){ struct vnode *vp = ap->a_vp; /*struct thread *td = ap->a_td;*/ struct union_node *un = VTOUNION(vp); struct vnode **vpp; /* * Do nothing (and _don't_ bypass). * Wait to vrele lowervp until reclaim, * so that until then our union_node is in the * cache and reusable. * * NEEDSWORK: Someday, consider inactive'ing * the lowervp and then trying to reactivate it * with capabilities (v_id) * like they do in the name lookup cache code. * That's too much work for now. */ if (un->un_dircache != 0) { for (vpp = un->un_dircache; *vpp != NULLVP; vpp++) vrele(*vpp); kfree (un->un_dircache, M_TEMP); un->un_dircache = 0; }#if 0 if ((un->un_flags & UN_ULOCK) && un->un_uppervp) { un->un_flags &= ~UN_ULOCK; vn_unlock(un->un_uppervp); }#endif if ((un->un_flags & UN_CACHED) == 0) vgone_vxlocked(vp); return (0);}
开发者ID:AhmadTux,项目名称:DragonFlyBSD,代码行数:47,
示例22: vop_compat_nlookupdotdot/* * vop_compat_nlookupdotdot { struct vnode *a_dvp, * struct vnode **a_vpp, * struct ucred *a_cred } * * Lookup the vnode representing the parent directory of the specified * directory vnode. a_dvp should not be locked. If no error occurs *a_vpp * will contained the parent vnode, locked and refd, else *a_vpp will be NULL. * * This function is designed to aid NFS server-side operations and is * used by cache_fromdvp() to create a consistent, connected namecache * topology. * * As part of the NEW API work, VFSs will first split their CNP_ISDOTDOT * code out from their *_lookup() and create *_nlookupdotdot(). Then as time * permits VFSs will implement the remaining *_n*() calls and finally get * rid of their *_lookup() call. */intvop_compat_nlookupdotdot(struct vop_nlookupdotdot_args *ap){ struct componentname cnp; int error; /* * UFS currently stores all sorts of side effects, including a loop * variable, in the directory inode. That needs to be fixed and the * other VFS's audited before we can switch to LK_SHARED. */ *ap->a_vpp = NULL; if ((error = vget(ap->a_dvp, LK_EXCLUSIVE)) != 0) return (error); if (ap->a_dvp->v_type != VDIR) { vput(ap->a_dvp); return (ENOTDIR); } bzero(&cnp, sizeof(cnp)); cnp.cn_nameiop = NAMEI_LOOKUP; cnp.cn_flags = CNP_ISDOTDOT; cnp.cn_nameptr = ".."; cnp.cn_namelen = 2; cnp.cn_cred = ap->a_cred; cnp.cn_td = curthread; /* XXX */ /* * vop_old_lookup() always returns vp locked. dvp may or may not be * left locked depending on CNP_PDIRUNLOCK. */ error = vop_old_lookup(ap->a_head.a_ops, ap->a_dvp, ap->a_vpp, &cnp); if (error == 0) vn_unlock(*ap->a_vpp); if (cnp.cn_flags & CNP_PDIRUNLOCK) vrele(ap->a_dvp); else vput(ap->a_dvp); return (error);}
开发者ID:juanfra684,项目名称:DragonFlyBSD,代码行数:58,
注:本文中的vn_unlock函数示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 C++ vnic_dev_cmd函数代码示例 C++ vn_rdwr函数代码示例 |