当前位置: 首页>>代码示例>>C++>>正文


C++ VOP_OPEN函数代码示例

本文整理汇总了C++中VOP_OPEN函数的典型用法代码示例。如果您正苦于以下问题:C++ VOP_OPEN函数的具体用法?C++ VOP_OPEN怎么用?C++ VOP_OPEN使用的例子?那么, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了VOP_OPEN函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: auto_open

/* ARGSUSED */
static int
auto_open(vnode_t **vpp, int flag, cred_t *cred, caller_context_t *ct)
{
	vnode_t *newvp;
	int error;

	AUTOFS_DPRINT((4, "auto_open: *vpp=%p\n", (void *)*vpp));

	error = auto_trigger_mount(*vpp, cred, &newvp);
	if (error)
		goto done;

	if (newvp != NULL) {
		/*
		 * Node is now mounted on.
		 */
		VN_RELE(*vpp);
		*vpp = newvp;
		error = VOP_ACCESS(*vpp, VREAD, 0, cred, ct);
		if (!error)
			error = VOP_OPEN(vpp, flag, cred, ct);
	}

done:
	AUTOFS_DPRINT((5, "auto_open: *vpp=%p error=%d\n", (void *)*vpp,
	    error));
	return (error);
}
开发者ID:apprisi,项目名称:illumos-gate,代码行数:29,代码来源:auto_vnops.c

示例2: ufs_extattr_enable_with_open

/*
 * Enable an EA using the passed filesystem, backing vnode, attribute name,
 * namespace, and proc.  Will perform a VOP_OPEN() on the vp, so expects vp
 * to be locked when passed in.  The vnode will be returned unlocked,
 * regardless of success/failure of the function.  As a result, the caller
 * will always need to vrele(), but not vput().
 */
static int
ufs_extattr_enable_with_open(struct ufsmount *ump, struct vnode *vp,
    int attrnamespace, const char *attrname, struct thread *td)
{
	int error;

	error = VOP_OPEN(vp, FREAD|FWRITE, td->td_ucred, td, NULL);
	if (error) {
		printf("ufs_extattr_enable_with_open.VOP_OPEN(): failed "
		    "with %d\n", error);
		VOP_UNLOCK(vp, 0);
		return (error);
	}

	error = VOP_ADD_WRITECOUNT(vp, 1);
	if (error != 0) {
		VOP_CLOSE(vp, FREAD | FWRITE, td->td_ucred, td);
		VOP_UNLOCK(vp, 0);
		return (error);
	}
	CTR3(KTR_VFS, "%s: vp %p v_writecount increased to %d", __func__, vp,
	    vp->v_writecount);

	vref(vp);

	VOP_UNLOCK(vp, 0);

	error = ufs_extattr_enable(ump, attrnamespace, attrname, vp, td);
	if (error != 0)
		vn_close(vp, FREAD|FWRITE, td->td_ucred, td);
	return (error);
}
开发者ID:markjdb,项目名称:freebsd-dev,代码行数:39,代码来源:ufs_extattr.c

示例3: cttyopen

/*ARGSUSED*/
int
cttyopen(dev_t dev, int flag, int mode, struct proc *p)
{
    struct vnode *ttyvp = cttyvp(p);
    int error;

    if (ttyvp == NULL)
        return (ENXIO);
    vn_lock(ttyvp, LK_EXCLUSIVE | LK_RETRY, p);
#ifdef PARANOID
    /*
     * Since group is tty and mode is 620 on most terminal lines
     * and since sessions protect terminals from processes outside
     * your session, this check is probably no longer necessary.
     * Since it inhibits setuid root programs that later switch
     * to another user from accessing /dev/tty, we have decided
     * to delete this test. (mckusick 5/93)
     */
    error = VOP_ACCESS(ttyvp,
                       (flag&FREAD ? VREAD : 0) | (flag&FWRITE ? VWRITE : 0), p->p_ucred, p);
    if (!error)
#endif /* PARANOID */
        error = VOP_OPEN(ttyvp, flag, NOCRED, p);
    VOP_UNLOCK(ttyvp, 0, p);
    return (error);
}
开发者ID:repos-holder,项目名称:openbsd-patches,代码行数:27,代码来源:tty_tty.c

示例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	int
cttyopen(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,代码来源:tty_tty.c

示例5: ufs_extattr_enable_with_open

/*
 * Enable an EA using the passed filesystem, backing vnode, attribute name,
 * namespace, and proc.  Will perform a VOP_OPEN() on the vp, so expects vp
 * to be locked when passed in.  The vnode will be returned unlocked,
 * regardless of success/failure of the function.  As a result, the caller
 * will always need to vrele(), but not vput().
 */
static int
ufs_extattr_enable_with_open(struct myfs_ufsmount *ump, struct vnode *vp,
    int attrnamespace, const char *attrname, struct thread *td)
{
	int error;

	error = VOP_OPEN(vp, FREAD|FWRITE, td->td_ucred, td, NULL);
	if (error) {
		printf("ufs_extattr_enable_with_open.VOP_OPEN(): failed "
		    "with %d\n", error);
		VOP_UNLOCK(vp, 0);
		return (error);
	}

	vp->v_writecount++;

	vref(vp);

	VOP_UNLOCK(vp, 0);

	error = ufs_extattr_enable(ump, attrnamespace, attrname, vp, td);
	if (error != 0)
		vn_close(vp, FREAD|FWRITE, td->td_ucred, td);
	return (error);
}
开发者ID:investigatorchic,项目名称:boing_acl,代码行数:32,代码来源:myfs_ufs_extattr.c

示例6: dev_lopen

/*
 * New Leaf driver open entry point.  We make a vnode and go through specfs
 * in order to obtain open close exclusions guarantees.  Note that we drop
 * OTYP_LYR if it was specified - we are going through specfs and it provides
 * last close semantics (FKLYR is provided to open(9E)).  Also, since
 * spec_open will drive attach via e_ddi_hold_devi_by_dev for a makespecvp
 * vnode with no SDIP_SET on the common snode, the dev_lopen caller no longer
 * needs to call ddi_hold_installed_driver.
 */
int
dev_lopen(dev_t *devp, int flag, int otype, struct cred *cred)
{
	struct vnode	*vp;
	int		error;
	struct vnode	*cvp;

	vp = makespecvp(*devp, (otype == OTYP_BLK) ? VBLK : VCHR);
	error = VOP_OPEN(&vp, flag | FKLYR, cred, NULL);
	if (error == 0) {
		/* Pick up the (possibly) new dev_t value. */
		*devp = vp->v_rdev;

		/*
		 * Place extra hold on the common vnode, which contains the
		 * open count, so that it is not destroyed by the VN_RELE of
		 * the shadow makespecvp vnode below.
		 */
		cvp = STOV(VTOCS(vp));
		VN_HOLD(cvp);
	}

	/* release the shadow makespecvp vnode. */
	VN_RELE(vp);
	return (error);
}
开发者ID:MatiasNAmendola,项目名称:AuroraUX-SunOS,代码行数:35,代码来源:driver.c

示例7: iso_mountroot

static int
iso_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,代码来源:cd9660_vfsops.c

示例8: rsmops_device_open

/*
 * This opens and closes the appropriate device with minor number -
 * hopefully, it will cause the driver to attach and register a controller
 * with us
 */
static vnode_t *
rsmops_device_open(const char *major_name, const minor_t minor_num)
{
	major_t maj;
	vnode_t *vp;
	int ret;

	if (minor_num == (minor_t)-1) {
		return (NULL);
	}

	maj = ddi_name_to_major((char *)major_name);
	if (maj == (major_t)-1) {
		return (NULL);
	}

	vp = makespecvp(makedevice(maj, minor_num), VCHR);

	ret = VOP_OPEN(&vp, FREAD|FWRITE, CRED(), NULL);
	if (ret == 0) {
		return (vp);
	} else {
		VN_RELE(vp);
		return (NULL);
	}
}
开发者ID:pcd1193182,项目名称:openzfs,代码行数:31,代码来源:rsmops.c

示例9: union_open

/*
 *	union_open:
 *
 *	run open VOP.  When opening the underlying vnode we have to mimic
 *	vn_open.  What we *really* need to do to avoid screwups if the
 *	open semantics change is to call vn_open().  For example, ufs blows
 *	up if you open a file but do not vmio it prior to writing.
 *
 * union_open(struct vnode *a_vp, int a_mode,
 *	      struct ucred *a_cred, struct thread *a_td)
 */
static int
union_open(struct vop_open_args *ap)
{
	struct union_node *un = VTOUNION(ap->a_vp);
	struct vnode *tvp;
	int mode = ap->a_mode;
	struct ucred *cred = ap->a_cred;
	struct thread *td = ap->a_td;
	int error = 0;
	int tvpisupper = 1;

	/*
	 * If there is an existing upper vp then simply open that.
	 * The upper vp takes precedence over the lower vp.  When opening
	 * a lower vp for writing copy it to the uppervp and then open the
	 * uppervp.
	 *
	 * At the end of this section tvp will be left locked.
	 */
	if ((tvp = union_lock_upper(un, td)) == NULLVP) {
		/*
		 * If the lower vnode is being opened for writing, then
		 * copy the file contents to the upper vnode and open that,
		 * otherwise can simply open the lower vnode.
		 */
		tvp = un->un_lowervp;
		if ((ap->a_mode & FWRITE) && (tvp->v_type == VREG)) {
			int docopy = !(mode & O_TRUNC);
			error = union_copyup(un, docopy, cred, td);
			tvp = union_lock_upper(un, td);
		} else {
			un->un_openl++;
			vref(tvp);
			vn_lock(tvp, LK_EXCLUSIVE | LK_RETRY);
			tvpisupper = 0;
		}
	}

	/*
	 * We are holding the correct vnode, open it.  Note
	 * that in DragonFly, VOP_OPEN is responsible for associating
	 * a VM object with the vnode if the vnode is mappable or the
	 * underlying filesystem uses buffer cache calls on it.
	 */
	if (error == 0)
		error = VOP_OPEN(tvp, mode, cred, NULL);

	/*
	 * Release any locks held
	 */
	if (tvpisupper) {
		if (tvp)
			union_unlock_upper(tvp, td);
	} else {
		vput(tvp);
	}
	return (error);
}
开发者ID:AhmadTux,项目名称:DragonFlyBSD,代码行数:69,代码来源:union_vnops.c

示例10: cnopen

int
cnopen(dev_t dev, int flag, int mode, struct lwp *l)
{
	dev_t cndev;
	int unit, error;

	unit = minor(dev);
	if (unit > 1)
		return ENODEV;

	if (cn_tab == NULL)
		return (0);

	/*
	 * always open the 'real' console device, so we don't get nailed
	 * later.  This follows normal device semantics; they always get
	 * open() calls.
	 */
	cndev = cn_tab->cn_dev;
#if NNULLCONS > 0
	if (cndev == NODEV) {
		nullconsattach(0);
	}
#else /* NNULLCONS > 0 */
	if (cndev == NODEV) {
		/*
		 * This is most likely an error in the console attach
		 * code. Panicking looks better than jumping into nowhere
		 * through cdevsw below....
		 */
		panic("cnopen: no console device");
	}
#endif /* NNULLCONS > 0 */
	if (dev == cndev) {
		/*
		 * This causes cnopen() to be called recursively, which
		 * is generally a bad thing.  It is often caused when
		 * dev == 0 and cn_dev has not been set, but was probably
		 * initialised to 0.
		 */
		panic("cnopen: cn_tab->cn_dev == dev");
	}
	if (cn_devvp[unit] != NULLVP)
		return 0;
	if ((error = cdevvp(cndev, &cn_devvp[unit])) != 0)
		printf("cnopen: unable to get vnode reference\n");
	error = vn_lock(cn_devvp[unit], LK_EXCLUSIVE | LK_RETRY);
	if (error == 0) {
		error = VOP_OPEN(cn_devvp[unit], flag, kauth_cred_get());
		VOP_UNLOCK(cn_devvp[unit]);
	}
	return error;
}
开发者ID:goroutines,项目名称:rumprun,代码行数:53,代码来源:cons.c

示例11: 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	int
cttyopen(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,代码来源:tty_tty.c

示例12: RUMP_VOP_OPEN

int
RUMP_VOP_OPEN(struct vnode *vp,
    int mode,
    struct kauth_cred *cred)
{
	int error;

	rump_schedule();
	error = VOP_OPEN(vp, mode, cred);
	rump_unschedule();

	return error;
}
开发者ID:ryo,项目名称:netbsd-src,代码行数:13,代码来源:rumpvnode_if.c

示例13: cttyopen

int
cttyopen(dev_t dev, int flag, int mode, struct proc *p)
{
	struct vnode *ttyvp = cttyvp(p);
	int error;

	if (ttyvp == NULL)
		return (ENXIO);
	vn_lock(ttyvp, LK_EXCLUSIVE | LK_RETRY, p);
	error = VOP_OPEN(ttyvp, flag, NOCRED);
	VOP_UNLOCK(ttyvp, 0);
	return (error);
}
开发者ID:darksoul42,项目名称:bitrig,代码行数:13,代码来源:tty_tty.c

示例14: xfs_file_open

STATIC int
xfs_file_open(
	struct inode	*inode,
	struct file	*filp)
{
	vnode_t		*vp = vn_from_inode(inode);
	int		error;

	if (!(filp->f_flags & O_LARGEFILE) && i_size_read(inode) > MAX_NON_LFS)
		return -EFBIG;
	VOP_OPEN(vp, NULL, error);
	return -error;
}
开发者ID:BackupTheBerlios,项目名称:arp2-svn,代码行数:13,代码来源:xfs_file.c

示例15: linvfs_open

STATIC int linvfs_open(
	struct inode *inode,
	struct file *filp)
{
	vnode_t *vp = LINVFS_GET_VP(inode);
	vnode_t *newvp;
	int	error;

	ASSERT(vp);

	VOP_OPEN(vp, &newvp, 0, get_current_cred(), error);

	return -error;
}
开发者ID:crossmeta,项目名称:sgi,代码行数:14,代码来源:xfs_file.c


注:本文中的VOP_OPEN函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。