您当前的位置:首页 > IT编程 > C++
| C语言 | Java | VB | VC | python | Android | TensorFlow | C++ | oracle | 学术与代码 | cnn卷积神经网络 | gnn | 图像修复 | Keras | 数据集 | Neo4j | 自然语言处理 | 深度学习 | 医学CAD | 医学影像 | 超参数 | pointnet | pytorch | 异常检测 | Transformers | 情感分类 | 知识图谱 |

自学教程:C++ vn_lock函数代码示例

51自学网 2021-06-03 09:46:24
  C++
这篇教程C++ vn_lock函数代码示例写得很实用,希望能帮到您。

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

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

示例1: ext2_reload

/* * Reload all incore data for a filesystem (used after running fsck on * the root filesystem and finding things to fix). The filesystem must * be mounted read-only. * * Things to do to update the mount: *	1) invalidate all cached meta-data. *	2) re-read superblock from disk. *	3) invalidate all cluster summary information. *	4) invalidate all inactive vnodes. *	5) invalidate all cached file data. *	6) re-read inode data for all active vnodes. * XXX we are missing some steps, in particular # 3, this has to be reviewed. */static intext2_reload(struct mount *mp, struct thread *td){	struct vnode *vp, *mvp, *devvp;	struct inode *ip;	struct buf *bp;	struct ext2fs *es;	struct m_ext2fs *fs;	struct csum *sump;	int error, i;	int32_t *lp;	if ((mp->mnt_flag & MNT_RDONLY) == 0)		return (EINVAL);	/*	 * Step 1: invalidate all cached meta-data.	 */	devvp = VFSTOEXT2(mp)->um_devvp;	vn_lock(devvp, LK_EXCLUSIVE | LK_RETRY);	if (vinvalbuf(devvp, 0, 0, 0) != 0)		panic("ext2_reload: dirty1");	VOP_UNLOCK(devvp, 0);	/*	 * Step 2: re-read superblock from disk.	 * constants have been adjusted for ext2	 */	if ((error = bread(devvp, SBLOCK, SBSIZE, NOCRED, &bp)) != 0)		return (error);	es = (struct ext2fs *)bp->b_data;	if (ext2_check_sb_compat(es, devvp->v_rdev, 0) != 0) {		brelse(bp);		return (EIO);		/* XXX needs translation */	}	fs = VFSTOEXT2(mp)->um_e2fs;	bcopy(bp->b_data, fs->e2fs, sizeof(struct ext2fs));	if((error = compute_sb_data(devvp, es, fs)) != 0) {		brelse(bp);		return (error);	}#ifdef UNKLAR	if (fs->fs_sbsize < SBSIZE)		bp->b_flags |= B_INVAL;#endif	brelse(bp);	/*	 * Step 3: invalidate all cluster summary information.	 */	if (fs->e2fs_contigsumsize > 0) {		lp = fs->e2fs_maxcluster;		sump = fs->e2fs_clustersum;		for (i = 0; i < fs->e2fs_gcount; i++, sump++) {			*lp++ = fs->e2fs_contigsumsize;			sump->cs_init = 0;			bzero(sump->cs_sum, fs->e2fs_contigsumsize + 1);		}	}loop:	MNT_VNODE_FOREACH_ALL(vp, mp, mvp) {		/*		 * Step 4: invalidate all cached file data.		 */		if (vget(vp, LK_EXCLUSIVE | LK_INTERLOCK, td)) {			MNT_VNODE_FOREACH_ALL_ABORT(mp, mvp);			goto loop;		}		if (vinvalbuf(vp, 0, 0, 0))			panic("ext2_reload: dirty2");		/*		 * Step 5: re-read inode data for all active vnodes.		 */		ip = VTOI(vp);		error = bread(devvp, fsbtodb(fs, ino_to_fsba(fs, ip->i_number)),		    (int)fs->e2fs_bsize, NOCRED, &bp);		if (error) {			VOP_UNLOCK(vp, 0);			vrele(vp);			MNT_VNODE_FOREACH_ALL_ABORT(mp, mvp);			return (error);		}		ext2_ei2i((struct ext2fs_dinode *) ((char *)bp->b_data +		    EXT2_INODE_SIZE(fs) * ino_to_fsbo(fs, ip->i_number)), ip);//.........这里部分代码省略.........
开发者ID:Eastsideboy,项目名称:freebsd,代码行数:101,


示例2: hfs_mount

inthfs_mount(struct mount *mp, const char *path, void *data, size_t *data_len){	struct lwp *l = curlwp;	struct hfs_args *args = data;	struct vnode *devvp;	struct hfsmount *hmp;	int error = 0;	int update;	mode_t accessmode;	if (args == NULL)		return EINVAL;	if (*data_len < sizeof *args)		return EINVAL;#ifdef HFS_DEBUG		printf("vfsop = hfs_mount()/n");#endif /* HFS_DEBUG */		if (mp->mnt_flag & MNT_GETARGS) {		hmp = VFSTOHFS(mp);		if (hmp == NULL)			return EIO;		args->fspec = NULL;		*data_len = sizeof *args;		return 0;	}	if (data == NULL)		return EINVAL;/* FIXME: For development ONLY - disallow remounting for now */#if 0	update = mp->mnt_flag & MNT_UPDATE;#else	update = 0;#endif	/* Check arguments */	if (args->fspec != NULL) {		/*		 * Look up the name and verify that it's sane.		 */		error = namei_simple_user(args->fspec,					NSM_FOLLOW_NOEMULROOT, &devvp);		if (error != 0)			return error;			if (!update) {			/*			 * Be sure this is a valid block device			 */			if (devvp->v_type != VBLK)				error = ENOTBLK;			else if (bdevsw_lookup(devvp->v_rdev) == NULL)				error = ENXIO;		} else {			/*			 * Be sure we're still naming the same device			 * used for our initial mount			 */			hmp = VFSTOHFS(mp);			if (devvp != hmp->hm_devvp)				error = EINVAL;		}	} else {		if (update) {			/* Use the extant mount */			hmp = VFSTOHFS(mp);			devvp = hmp->hm_devvp;			vref(devvp);		} else {			/* New mounts must have a filename for the device */			return EINVAL;		}	}		/*	 * If mount by non-root, then verify that user has necessary	 * permissions on the device.	 *	 * Permission to update a mount is checked higher, so here we presume	 * updating the mount is okay (for example, as far as securelevel goes)	 * which leaves us with the normal check.	 */	if (error == 0) {		accessmode = VREAD;		if (update ?			(mp->mnt_iflag & IMNT_WANTRDWR) != 0 :			(mp->mnt_flag & MNT_RDONLY) == 0)			accessmode |= VWRITE;		vn_lock(devvp, LK_EXCLUSIVE | LK_RETRY);		error = kauth_authorize_system(l->l_cred, KAUTH_SYSTEM_MOUNT,		    KAUTH_REQ_SYSTEM_MOUNT_DEVICE, mp, devvp,		    KAUTH_ARG(accessmode));		VOP_UNLOCK(devvp);	}//.........这里部分代码省略.........
开发者ID:eyberg,项目名称:rumpkernel-netbsd-src,代码行数:101,


示例3: fusefs_link

intfusefs_link(void *v){	struct vop_link_args *ap = v;	struct vnode *dvp = ap->a_dvp;	struct vnode *vp = ap->a_vp;	struct componentname *cnp = ap->a_cnp;	struct proc *p = cnp->cn_proc;	struct fusefs_mnt *fmp;	struct fusefs_node *ip;	struct fusefs_node *dip;	struct fusebuf *fbuf;	int error = 0;	if (vp->v_type == VDIR) {		VOP_ABORTOP(dvp, cnp);		error = EISDIR;		goto out2;	}	if (dvp->v_mount != vp->v_mount) {		VOP_ABORTOP(dvp, cnp);		error = EXDEV;		goto out2;	}	if (dvp != vp && (error = vn_lock(vp, LK_EXCLUSIVE, p))) {		VOP_ABORTOP(dvp, cnp);		goto out2;	}	ip = VTOI(vp);	dip = VTOI(dvp);	fmp = (struct fusefs_mnt *)ip->ufs_ino.i_ump;	if (!fmp->sess_init || (fmp->undef_op & UNDEF_LINK))		goto out1;	fbuf = fb_setup(cnp->cn_namelen + 1, dip->ufs_ino.i_number,	    FBT_LINK, p);	fbuf->fb_io_ino = ip->ufs_ino.i_number;	memcpy(fbuf->fb_dat, cnp->cn_nameptr, cnp->cn_namelen);	fbuf->fb_dat[cnp->cn_namelen] = '/0';	error = fb_queue(fmp->dev, fbuf);	if (error) {		if (error == ENOSYS)			fmp->undef_op |= UNDEF_LINK;		fb_delete(fbuf);		goto out1;	}	fb_delete(fbuf);	VN_KNOTE(vp, NOTE_LINK);	VN_KNOTE(dvp, NOTE_WRITE);out1:	if (dvp != vp)		VOP_UNLOCK(vp, 0);out2:	vput(dvp);	return (error);}
开发者ID:appleorange1,项目名称:bitrig,代码行数:64,


示例4: ufs_rename

//.........这里部分代码省略.........		if (fvp->v_type == VDIR) {			/*			 * Linked directories are impossible, so we must			 * have lost the race.  Pretend that the rename			 * completed before the lookup.			 */			error = ENOENT;			goto abortit;		}		/* Release destination completely. */		VOP_ABORTOP(tdvp, tcnp);		vput(tdvp);		vput(tvp);		/*		 * Delete source.  There is another race now that everything		 * is unlocked, but this doesn't cause any new complications.		 * relookup() may find a file that is unrelated to the		 * original one, or it may fail.  Too bad.		 */		vrele(fvp);		fcnp->cn_flags &= ~MODMASK;		fcnp->cn_flags |= LOCKPARENT | LOCKLEAF;		if ((fcnp->cn_flags & SAVESTART) == 0)			panic("ufs_rename: lost from startdir");		fcnp->cn_nameiop = DELETE;		if ((error = vfs_relookup(fdvp, &fvp, fcnp)) != 0)			return (error);		/* relookup did vrele() */		vrele(fdvp);		return (VOP_REMOVE(fdvp, fvp, fcnp));	}	if ((error = vn_lock(fvp, LK_EXCLUSIVE, p)) != 0)		goto abortit;	/* fvp, tdvp, tvp now locked */	dp = VTOI(fdvp);	ip = VTOI(fvp);	if ((nlink_t) DIP(ip, nlink) >= LINK_MAX) {		VOP_UNLOCK(fvp, 0);		error = EMLINK;		goto abortit;	}	if ((DIP(ip, flags) & (IMMUTABLE | APPEND)) ||	    (DIP(dp, flags) & APPEND)) {		VOP_UNLOCK(fvp, 0);		error = EPERM;		goto abortit;	}	if ((DIP(ip, mode) & IFMT) == IFDIR) {		error = VOP_ACCESS(fvp, VWRITE, tcnp->cn_cred);		if (!error && tvp)			error = VOP_ACCESS(tvp, VWRITE, tcnp->cn_cred);		if (error) {			VOP_UNLOCK(fvp, 0);			error = EACCES;			goto abortit;		}		/*		 * Avoid ".", "..", and aliases of "." for obvious reasons.		 */		if ((fcnp->cn_namelen == 1 && fcnp->cn_nameptr[0] == '.') ||		    dp == ip ||		    (fcnp->cn_flags & ISDOTDOT) ||		    (tcnp->cn_flags & ISDOTDOT) ||
开发者ID:sofuture,项目名称:bitrig,代码行数:67,


示例5: msdosfs_mountfs

intmsdosfs_mountfs(struct vnode *devvp, struct mount *mp, struct proc *p,                struct msdosfs_args *argp){    struct msdosfsmount *pmp;    struct buf *bp;    dev_t dev = devvp->v_rdev;    union bootsector *bsp;    struct byte_bpb33 *b33;    struct byte_bpb50 *b50;    struct byte_bpb710 *b710;    extern struct vnode *rootvp;    u_int8_t SecPerClust;    int	ronly, error, bmapsiz;    uint32_t fat_max_clusters;    /*     * Disallow multiple mounts of the same device.     * Disallow mounting of a device that is currently in use     * (except for root, which might share swap device for miniroot).     * Flush out any old buffers remaining from a previous use.     */    if ((error = vfs_mountedon(devvp)) != 0)        return (error);    if (vcount(devvp) > 1 && devvp != rootvp)        return (EBUSY);    vn_lock(devvp, LK_EXCLUSIVE | LK_RETRY, p);    error = vinvalbuf(devvp, V_SAVE, p->p_ucred, p, 0, 0);    VOP_UNLOCK(devvp, 0, p);    if (error)        return (error);    ronly = (mp->mnt_flag & MNT_RDONLY) != 0;    error = VOP_OPEN(devvp, ronly ? FREAD : FREAD|FWRITE, FSCRED, p);    if (error)        return (error);    bp  = NULL; /* both used in error_exit */    pmp = NULL;    /*     * Read the boot sector of the filesystem, and then check the     * boot signature.  If not a dos boot sector then error out.     */    if ((error = bread(devvp, 0, 4096, NOCRED, &bp)) != 0)        goto error_exit;    bp->b_flags |= B_AGE;    bsp = (union bootsector *)bp->b_data;    b33 = (struct byte_bpb33 *)bsp->bs33.bsBPB;    b50 = (struct byte_bpb50 *)bsp->bs50.bsBPB;    b710 = (struct byte_bpb710 *)bsp->bs710.bsPBP;    pmp = malloc(sizeof *pmp, M_MSDOSFSMNT, M_WAITOK | M_ZERO);    pmp->pm_mountp = mp;    /*     * Compute several useful quantities from the bpb in the     * bootsector.  Copy in the dos 5 variant of the bpb then fix up     * the fields that are different between dos 5 and dos 3.3.     */    SecPerClust = b50->bpbSecPerClust;    pmp->pm_BytesPerSec = getushort(b50->bpbBytesPerSec);    pmp->pm_ResSectors = getushort(b50->bpbResSectors);    pmp->pm_FATs = b50->bpbFATs;    pmp->pm_RootDirEnts = getushort(b50->bpbRootDirEnts);    pmp->pm_Sectors = getushort(b50->bpbSectors);    pmp->pm_FATsecs = getushort(b50->bpbFATsecs);    pmp->pm_SecPerTrack = getushort(b50->bpbSecPerTrack);    pmp->pm_Heads = getushort(b50->bpbHeads);    pmp->pm_Media = b50->bpbMedia;    /* Determine the number of DEV_BSIZE blocks in a MSDOSFS sector */    pmp->pm_BlkPerSec = pmp->pm_BytesPerSec / DEV_BSIZE;    if (!pmp->pm_BytesPerSec || !SecPerClust || pmp->pm_SecPerTrack > 64) {        error = EFTYPE;        goto error_exit;    }    if (pmp->pm_Sectors == 0) {        pmp->pm_HiddenSects = getulong(b50->bpbHiddenSecs);        pmp->pm_HugeSectors = getulong(b50->bpbHugeSectors);    } else {        pmp->pm_HiddenSects = getushort(b33->bpbHiddenSecs);        pmp->pm_HugeSectors = pmp->pm_Sectors;    }    if (pmp->pm_RootDirEnts == 0) {        if (pmp->pm_Sectors || pmp->pm_FATsecs ||                getushort(b710->bpbFSVers)) {            error = EINVAL;            goto error_exit;        }        pmp->pm_fatmask = FAT32_MASK;        pmp->pm_fatmult = 4;        pmp->pm_fatdiv = 1;        pmp->pm_FATsecs = getulong(b710->bpbBigFATsecs);        if (getushort(b710->bpbExtFlags) & FATMIRROR)            pmp->pm_curfat = getushort(b710->bpbExtFlags) & FATNUM;        else//.........这里部分代码省略.........
开发者ID:7shi,项目名称:openbsd-loongson-vc,代码行数:101,


示例6: quotaon

/* * Q_QUOTAON - set up a quota file for a particular filesystem. */intquotaon(struct thread *td, struct mount *mp, int type, void *fname){	struct ufsmount *ump;	struct vnode *vp, **vpp;	struct vnode *mvp;	struct dquot *dq;	int error, flags;	struct nameidata nd;	error = priv_check(td, PRIV_UFS_QUOTAON);	if (error != 0) {		vfs_unbusy(mp);		return (error);	}	if ((mp->mnt_flag & MNT_RDONLY) != 0) {		vfs_unbusy(mp);		return (EROFS);	}	ump = VFSTOUFS(mp);	dq = NODQUOT;	NDINIT(&nd, LOOKUP, FOLLOW, UIO_USERSPACE, fname, td);	flags = FREAD | FWRITE;	vfs_ref(mp);	vfs_unbusy(mp);	error = vn_open(&nd, &flags, 0, NULL);	if (error != 0) {		vfs_rel(mp);		return (error);	}	NDFREE(&nd, NDF_ONLY_PNBUF);	vp = nd.ni_vp;	error = vfs_busy(mp, MBF_NOWAIT);	vfs_rel(mp);	if (error == 0) {		if (vp->v_type != VREG) {			error = EACCES;			vfs_unbusy(mp);		}	}	if (error != 0) {		VOP_UNLOCK(vp, 0);		(void) vn_close(vp, FREAD|FWRITE, td->td_ucred, td);		return (error);	}	UFS_LOCK(ump);	if ((ump->um_qflags[type] & (QTF_OPENING|QTF_CLOSING)) != 0) {		UFS_UNLOCK(ump);		VOP_UNLOCK(vp, 0);		(void) vn_close(vp, FREAD|FWRITE, td->td_ucred, td);		vfs_unbusy(mp);		return (EALREADY);	}	ump->um_qflags[type] |= QTF_OPENING|QTF_CLOSING;	UFS_UNLOCK(ump);	if ((error = dqopen(vp, ump, type)) != 0) {		VOP_UNLOCK(vp, 0);		UFS_LOCK(ump);		ump->um_qflags[type] &= ~(QTF_OPENING|QTF_CLOSING);		UFS_UNLOCK(ump);		(void) vn_close(vp, FREAD|FWRITE, td->td_ucred, td);		vfs_unbusy(mp);		return (error);	}	VOP_UNLOCK(vp, 0);	MNT_ILOCK(mp);	mp->mnt_flag |= MNT_QUOTA;	MNT_IUNLOCK(mp);	vpp = &ump->um_quotas[type];	if (*vpp != vp)		quotaoff1(td, mp, type);	/*	 * When the directory vnode containing the quota file is	 * inactivated, due to the shared lookup of the quota file	 * vput()ing the dvp, the qsyncvp() call for the containing	 * directory would try to acquire the quota lock exclusive.	 * At the same time, lookup already locked the quota vnode	 * shared.  Mark the quota vnode lock as allowing recursion	 * and automatically converting shared locks to exclusive.	 *	 * Also mark quota vnode as system.	 */	vn_lock(vp, LK_EXCLUSIVE | LK_RETRY);	vp->v_vflag |= VV_SYSTEM;	VN_LOCK_AREC(vp);	VN_LOCK_DSHARE(vp);	VOP_UNLOCK(vp, 0);	*vpp = vp;	/*	 * Save the credential of the process that turned on quotas.	 * Set up the time limits for this quota.//.........这里部分代码省略.........
开发者ID:2trill2spill,项目名称:freebsd,代码行数:101,


示例7: quotaoff1

/* * Main code to turn off disk quotas for a filesystem. Does not change * flags. */static intquotaoff1(struct thread *td, struct mount *mp, int type){	struct vnode *vp;	struct vnode *qvp, *mvp;	struct ufsmount *ump;	struct dquot *dq;	struct inode *ip;	struct ucred *cr;	int error;	ump = VFSTOUFS(mp);	UFS_LOCK(ump);	KASSERT((ump->um_qflags[type] & QTF_CLOSING) != 0,		("quotaoff1: flags are invalid"));	if ((qvp = ump->um_quotas[type]) == NULLVP) {		UFS_UNLOCK(ump);		return (0);	}	cr = ump->um_cred[type];	UFS_UNLOCK(ump);	/*	 * Search vnodes associated with this mount point,	 * deleting any references to quota file being closed.	 */again:	MNT_VNODE_FOREACH_ALL(vp, mp, mvp) {		if (vp->v_type == VNON) {			VI_UNLOCK(vp);			continue;		}		if (vget(vp, LK_EXCLUSIVE | LK_INTERLOCK, td)) {			MNT_VNODE_FOREACH_ALL_ABORT(mp, mvp);			goto again;		}		ip = VTOI(vp);		dq = ip->i_dquot[type];		ip->i_dquot[type] = NODQUOT;		dqrele(vp, dq);		VOP_UNLOCK(vp, 0);		vrele(vp);	}	error = dqflush(qvp);	if (error != 0)		return (error);	/*	 * Clear um_quotas before closing the quota vnode to prevent	 * access to the closed vnode from dqget/dqsync	 */	UFS_LOCK(ump);	ump->um_quotas[type] = NULLVP;	ump->um_cred[type] = NOCRED;	UFS_UNLOCK(ump);	vn_lock(qvp, LK_EXCLUSIVE | LK_RETRY);	qvp->v_vflag &= ~VV_SYSTEM;	VOP_UNLOCK(qvp, 0);	error = vn_close(qvp, FREAD|FWRITE, td->td_ucred, td);	crfree(cr);	return (error);}
开发者ID:2trill2spill,项目名称:freebsd,代码行数:70,


示例8: dqget

/* * Obtain a dquot structure for the specified identifier and quota file * reading the information from the file if necessary. */static intdqget(struct vnode *vp, u_long id, struct ufsmount *ump, int type,    struct dquot **dqp){	uint8_t buf[sizeof(struct dqblk64)];	off_t base, recsize;	struct dquot *dq, *dq1;	struct dqhash *dqh;	struct vnode *dqvp;	struct iovec aiov;	struct uio auio;	int dqvplocked, error;#ifdef DEBUG_VFS_LOCKS	if (vp != NULLVP)		ASSERT_VOP_ELOCKED(vp, "dqget");#endif	if (vp != NULLVP && *dqp != NODQUOT) {		return (0);	}	/* XXX: Disallow negative id values to prevent the	* creation of 100GB+ quota data files.	*/	if ((int)id < 0)		return (EINVAL);	UFS_LOCK(ump);	dqvp = ump->um_quotas[type];	if (dqvp == NULLVP || (ump->um_qflags[type] & QTF_CLOSING)) {		*dqp = NODQUOT;		UFS_UNLOCK(ump);		return (EINVAL);	}	vref(dqvp);	UFS_UNLOCK(ump);	error = 0;	dqvplocked = 0;	/*	 * Check the cache first.	 */	dqh = DQHASH(dqvp, id);	DQH_LOCK();	dq = dqhashfind(dqh, id, dqvp);	if (dq != NULL) {		DQH_UNLOCK();hfound:		DQI_LOCK(dq);		DQI_WAIT(dq, PINOD+1, "dqget");		DQI_UNLOCK(dq);		if (dq->dq_ump == NULL) {			dqrele(vp, dq);			dq = NODQUOT;			error = EIO;		}		*dqp = dq;		if (dqvplocked)			vput(dqvp);		else			vrele(dqvp);		return (error);	}	/*	 * Quota vnode lock is before DQ_LOCK. Acquire dqvp lock there	 * since new dq will appear on the hash chain DQ_LOCKed.	 */	if (vp != dqvp) {		DQH_UNLOCK();		vn_lock(dqvp, LK_SHARED | LK_RETRY);		dqvplocked = 1;		DQH_LOCK();		/*		 * Recheck the cache after sleep for quota vnode lock.		 */		dq = dqhashfind(dqh, id, dqvp);		if (dq != NULL) {			DQH_UNLOCK();			goto hfound;		}	}	/*	 * Not in cache, allocate a new one or take it from the	 * free list.	 */	if (TAILQ_FIRST(&dqfreelist) == NODQUOT &&	    numdquot < MAXQUOTAS * desiredvnodes)		desireddquot += DQUOTINC;	if (numdquot < desireddquot) {		numdquot++;		DQH_UNLOCK();		dq1 = malloc(sizeof *dq1, M_DQUOT, M_WAITOK | M_ZERO);		mtx_init(&dq1->dq_lock, "dqlock", NULL, MTX_DEF);		DQH_LOCK();//.........这里部分代码省略.........
开发者ID:2trill2spill,项目名称:freebsd,代码行数:101,


示例9: dqsync

/* * Update the disk quota in the quota file. */static intdqsync(struct vnode *vp, struct dquot *dq){	uint8_t buf[sizeof(struct dqblk64)];	off_t base, recsize;	struct vnode *dqvp;	struct iovec aiov;	struct uio auio;	int error;	struct mount *mp;	struct ufsmount *ump;#ifdef DEBUG_VFS_LOCKS	if (vp != NULL)		ASSERT_VOP_ELOCKED(vp, "dqsync");#endif	mp = NULL;	error = 0;	if (dq == NODQUOT)		panic("dqsync: dquot");	if ((ump = dq->dq_ump) == NULL)		return (0);	UFS_LOCK(ump);	if ((dqvp = ump->um_quotas[dq->dq_type]) == NULLVP) {		if (vp == NULL) {			UFS_UNLOCK(ump);			return (0);		} else			panic("dqsync: file");	}	vref(dqvp);	UFS_UNLOCK(ump);	DQI_LOCK(dq);	if ((dq->dq_flags & DQ_MOD) == 0) {		DQI_UNLOCK(dq);		vrele(dqvp);		return (0);	}	DQI_UNLOCK(dq);	(void) vn_start_secondary_write(dqvp, &mp, V_WAIT);	if (vp != dqvp)		vn_lock(dqvp, LK_EXCLUSIVE | LK_RETRY);	DQI_LOCK(dq);	DQI_WAIT(dq, PINOD+2, "dqsync");	if ((dq->dq_flags & DQ_MOD) == 0)		goto out;	dq->dq_flags |= DQ_LOCK;	DQI_UNLOCK(dq);	/*	 * Write the quota record to the quota file, performing any	 * necessary conversions.  See dqget() for additional details.	 */	if (ump->um_qflags[dq->dq_type] & QTF_64BIT) {		dq_dqb64(dq, (struct dqblk64 *)buf);		recsize = sizeof(struct dqblk64);		base = sizeof(struct dqhdr64);	} else {		dq_dqb32(dq, (struct dqblk32 *)buf);		recsize = sizeof(struct dqblk32);		base = 0;	}	auio.uio_iov = &aiov;	auio.uio_iovcnt = 1;	aiov.iov_base = buf;	aiov.iov_len = recsize;	auio.uio_resid = recsize;	auio.uio_offset = base + dq->dq_id * recsize;	auio.uio_segflg = UIO_SYSSPACE;	auio.uio_rw = UIO_WRITE;	auio.uio_td = (struct thread *)0;	error = VOP_WRITE(dqvp, &auio, 0, dq->dq_ump->um_cred[dq->dq_type]);	if (auio.uio_resid && error == 0)		error = EIO;	DQI_LOCK(dq);	DQI_WAKEUP(dq);	dq->dq_flags &= ~DQ_MOD;out:	DQI_UNLOCK(dq);	if (vp != dqvp)		vput(dqvp);	else		vrele(dqvp);	vn_finished_secondary_write(mp);	return (error);}
开发者ID:2trill2spill,项目名称:freebsd,代码行数:95,


示例10: nwfs_lookup

//.........这里部分代码省略.........		if (NWCMPF(&dnp->n_parent, &nmp->n_rootent)) {			fid = nmp->n_rootent;			fap = NULL;			notfound = 0;		} else {			error = nwfs_lookupnp(nmp, dnp->n_parent, td, &npp);			if (error) {				return error;			}			fid = dnp->n_parent;			fap = &fattr;			/*np = *npp;*/			notfound = ncp_obtain_info(nmp, npp->n_dosfid,			    0, NULL, fap, td, cnp->cn_cred);		}	} else {		fap = &fattr;		notfound = ncp_lookup(dvp, cnp->cn_namelen, cnp->cn_nameptr,			fap, td, cnp->cn_cred);		fid.f_id = fap->dirEntNum;		if (cnp->cn_namelen == 1 && cnp->cn_nameptr[0] == '.') {			fid.f_parent = dnp->n_fid.f_parent;		} else			fid.f_parent = dnp->n_fid.f_id;		NCPVNDEBUG("call to ncp_lookup returned=%d/n",notfound);	}	if (notfound && notfound < 0x80 )		return (notfound);	/* hard error */	if (notfound) { /* entry not found */		/* Handle RENAME or CREATE case... */		if ((nameiop == NAMEI_CREATE || nameiop == NAMEI_RENAME) && wantparent) {			if (!lockparent)				vn_unlock(dvp);			return (EJUSTRETURN);		}		return ENOENT;	}/* else {		NCPVNDEBUG("Found entry %s with id=%d/n", fap->entryName, fap->dirEntNum);	}*/	/* handle DELETE case ... */	if (nameiop == NAMEI_DELETE) { 	/* delete last component */		error = VOP_EACCESS(dvp, VWRITE, cnp->cn_cred);		if (error) return (error);		if (NWCMPF(&dnp->n_fid, &fid)) {	/* we found ourselfs */			vref(dvp);			*vpp = dvp;			return 0;		}		error = nwfs_nget(mp, fid, fap, dvp, &vp);		if (error) return (error);		*vpp = vp;		if (!lockparent) vn_unlock(dvp);		return (0);	}	if (nameiop == NAMEI_RENAME && wantparent) {		error = VOP_EACCESS(dvp, VWRITE, cnp->cn_cred);		if (error) return (error);		if (NWCMPF(&dnp->n_fid, &fid)) return EISDIR;		error = nwfs_nget(mp, fid, fap, dvp, &vp);		if (error) return (error);		*vpp = vp;		if (!lockparent)			vn_unlock(dvp);		return (0);	}	if (flags & CNP_ISDOTDOT) {		vn_unlock(dvp);	/* race to get the inode */		error = nwfs_nget(mp, fid, NULL, NULL, &vp);		if (error) {			vn_lock(dvp, LK_EXCLUSIVE | LK_RETRY);			return (error);		}		if (lockparent) {			error = vn_lock(dvp, LK_EXCLUSIVE | LK_FAILRECLAIM);			if (error) {				vput(vp);				return (error);			}		}		*vpp = vp;	} else if (NWCMPF(&dnp->n_fid, &fid)) {		vref(dvp);		*vpp = dvp;	} else {		error = nwfs_nget(mp, fid, fap, dvp, &vp);		if (error) return (error);		*vpp = vp;		NCPVNDEBUG("lookup: getnewvp!/n");		if (!lockparent)			vn_unlock(dvp);	}#if 0	/* XXX MOVE TO NREMOVE */	if ((cnp->cn_flags & CNP_MAKEENTRY)) {		VTONW(*vpp)->n_ctime = VTONW(*vpp)->n_vattr.va_ctime.tv_sec;		/* XXX */	}#endif	return (0);}
开发者ID:mihaicarabas,项目名称:dragonfly,代码行数:101,


示例11: ufs_extattr_get

/* * Real work associated with retrieving a named attribute--assumes that * the attribute lock has already been grabbed. */static intufs_extattr_get(struct vnode *vp, int attrnamespace, const char *name,    struct uio *uio, size_t *size, struct ucred *cred, struct thread *td){	struct ufs_extattr_list_entry *attribute;	struct ufs_extattr_header ueh;	struct iovec local_aiov;	struct uio local_aio;	struct mount *mp = vp->v_mount;	struct ufsmount *ump = VFSTOUFS(mp);	struct inode *ip = VTOI(vp);	off_t base_offset;	size_t len, old_len;	int error = 0;	if (!(ump->um_extattr.uepm_flags & UFS_EXTATTR_UEPM_STARTED))		return (EOPNOTSUPP);	if (strlen(name) == 0)		return (EINVAL);	error = extattr_check_cred(vp, attrnamespace, cred, td, VREAD);	if (error)		return (error);	attribute = ufs_extattr_find_attr(ump, attrnamespace, name);	if (!attribute)		return (ENOATTR);	/*	 * Allow only offsets of zero to encourage the read/replace	 * extended attribute semantic.  Otherwise we can't guarantee	 * atomicity, as we don't provide locks for extended attributes.	 */	if (uio != NULL && uio->uio_offset != 0)		return (ENXIO);	/*	 * Find base offset of header in file based on file header size, and	 * data header size + maximum data size, indexed by inode number.	 */	base_offset = sizeof(struct ufs_extattr_fileheader) +	    ip->i_number * (sizeof(struct ufs_extattr_header) +	    attribute->uele_fileheader.uef_size);	/*	 * Read in the data header to see if the data is defined, and if so	 * how much.	 */	bzero(&ueh, sizeof(struct ufs_extattr_header));	local_aiov.iov_base = (caddr_t) &ueh;	local_aiov.iov_len = sizeof(struct ufs_extattr_header);	local_aio.uio_iov = &local_aiov;	local_aio.uio_iovcnt = 1;	local_aio.uio_rw = UIO_READ;	local_aio.uio_segflg = UIO_SYSSPACE;	local_aio.uio_td = td;	local_aio.uio_offset = base_offset;	local_aio.uio_resid = sizeof(struct ufs_extattr_header);		/*	 * Acquire locks.	 *	 * Don't need to get a lock on the backing file if the getattr is	 * being applied to the backing file, as the lock is already held.	 */	if (attribute->uele_backing_vnode != vp)		vn_lock(attribute->uele_backing_vnode, LK_SHARED | LK_RETRY);	error = VOP_READ(attribute->uele_backing_vnode, &local_aio,	    IO_NODELOCKED, ump->um_extattr.uepm_ucred);	if (error)		goto vopunlock_exit;	/* Defined? */	if ((ueh.ueh_flags & UFS_EXTATTR_ATTR_FLAG_INUSE) == 0) {		error = ENOATTR;		goto vopunlock_exit;	}	/* Valid for the current inode generation? */	if (ueh.ueh_i_gen != ip->i_gen) {		/*		 * The inode itself has a different generation number		 * than the attribute data.  For now, the best solution		 * is to coerce this to undefined, and let it get cleaned		 * up by the next write or extattrctl clean.		 */		printf("ufs_extattr_get (%s): inode number inconsistency (%d, %ju)/n",		    mp->mnt_stat.f_mntonname, ueh.ueh_i_gen, (uintmax_t)ip->i_gen);		error = ENOATTR;		goto vopunlock_exit;	}	/* Local size consistency check. */	if (ueh.ueh_len > attribute->uele_fileheader.uef_size) {//.........这里部分代码省略.........
开发者ID:markjdb,项目名称:freebsd-dev,代码行数:101,


示例12: fdesc_allocvp

intfdesc_allocvp(fdntype ftype, unsigned fd_fd, int ix, struct mount *mp,    struct vnode **vpp){	struct fdescmount *fmp;	struct fdhashhead *fc;	struct fdescnode *fd, *fd2;	struct vnode *vp, *vp2;	struct thread *td;	int error = 0;	td = curthread;	fc = FD_NHASH(ix);loop:	mtx_lock(&fdesc_hashmtx);	/*	 * If a forced unmount is progressing, we need to drop it. The flags are	 * protected by the hashmtx.	 */	fmp = (struct fdescmount *)mp->mnt_data;	if (fmp == NULL || fmp->flags & FMNT_UNMOUNTF) {		mtx_unlock(&fdesc_hashmtx);		return (-1);	}	LIST_FOREACH(fd, fc, fd_hash) {		if (fd->fd_ix == ix && fd->fd_vnode->v_mount == mp) {			/* Get reference to vnode in case it's being free'd */			vp = fd->fd_vnode;			VI_LOCK(vp);			mtx_unlock(&fdesc_hashmtx);			if (vget(vp, LK_EXCLUSIVE | LK_INTERLOCK, td))				goto loop;			*vpp = vp;			return (0);		}	}	mtx_unlock(&fdesc_hashmtx);	fd = malloc(sizeof(struct fdescnode), M_TEMP, M_WAITOK);	error = getnewvnode("fdescfs", mp, &fdesc_vnodeops, &vp);	if (error) {		free(fd, M_TEMP);		return (error);	}	vn_lock(vp, LK_EXCLUSIVE | LK_RETRY);	vp->v_data = fd;	fd->fd_vnode = vp;	fd->fd_type = ftype;	fd->fd_fd = fd_fd;	fd->fd_ix = ix;	error = insmntque1(vp, mp, fdesc_insmntque_dtr, NULL);	if (error != 0) {		*vpp = NULLVP;		return (error);	}	/* Make sure that someone didn't beat us when inserting the vnode. */	mtx_lock(&fdesc_hashmtx);	/*	 * If a forced unmount is progressing, we need to drop it. The flags are	 * protected by the hashmtx.	 */	fmp = (struct fdescmount *)mp->mnt_data;	if (fmp == NULL || fmp->flags & FMNT_UNMOUNTF) {		mtx_unlock(&fdesc_hashmtx);		vgone(vp);		vput(vp);		*vpp = NULLVP;		return (-1);	}	LIST_FOREACH(fd2, fc, fd_hash) {		if (fd2->fd_ix == ix && fd2->fd_vnode->v_mount == mp) {			/* Get reference to vnode in case it's being free'd */			vp2 = fd2->fd_vnode;			VI_LOCK(vp2);			mtx_unlock(&fdesc_hashmtx);			error = vget(vp2, LK_EXCLUSIVE | LK_INTERLOCK, td);			/* Someone beat us, dec use count and wait for reclaim */			vgone(vp);			vput(vp);			/* If we didn't get it, return no vnode. */			if (error)				vp2 = NULLVP;			*vpp = vp2;			return (error);		}	}	/* If we came here, we can insert it safely. */	LIST_INSERT_HEAD(fc, fd, fd_hash);	mtx_unlock(&fdesc_hashmtx);	*vpp = vp;	return (0);}
开发者ID:hmatyschok,项目名称:MeshBSD,代码行数:97,


示例13: readdir_with_callback

intreaddir_with_callback(struct file *fp, off_t *off, u_long nbytes,    int (*appendfunc)(void *, struct dirent *), void *arg){	struct dirent *bdp;	caddr_t inp, buf;	int buflen;	struct uio auio;	struct iovec aiov;	int eofflag = 0;	int error, len, reclen;	off_t newoff = *off;	struct vnode *vp;	struct vattr va;			if ((fp->f_flag & FREAD) == 0)		return (EBADF);	vp = (struct vnode *)fp->f_data;	if (vp->v_type != VDIR)		return (EINVAL);	if ((error = VOP_GETATTR(vp, &va, fp->f_cred, curproc)) != 0)		return (error);	buflen = min(MAXBSIZE, nbytes);	buflen = max(buflen, va.va_blocksize);	buf = malloc(buflen, M_TEMP, M_WAITOK);	error = vn_lock(vp, LK_EXCLUSIVE | LK_RETRY, curproc);	if (error) {		free(buf, M_TEMP, 0);		return (error);	}again:	aiov.iov_base = buf;	aiov.iov_len = buflen;	auio.uio_iov = &aiov;	auio.uio_iovcnt = 1;	auio.uio_rw = UIO_READ;	auio.uio_segflg = UIO_SYSSPACE;	auio.uio_procp = curproc;	auio.uio_resid = buflen;	auio.uio_offset = newoff;	error = VOP_READDIR(vp, &auio, fp->f_cred, &eofflag);	*off = auio.uio_offset;	if (error)		goto out;	if ((len = buflen - auio.uio_resid) <= 0)		goto eof;		inp = buf;	for (; len > 0; len -= reclen, inp += reclen) {		bdp = (struct dirent *)inp;		reclen = bdp->d_reclen;		if (len < reclen)			break;		if (reclen & 3) {			error = EFAULT;			goto out;		}		/* Skip holes */		if (bdp->d_fileno != 0) {			if ((error = (*appendfunc) (arg, bdp)) != 0) {				if (error == ENOMEM)					error = 0;				break;			}		}	}	if (len <= 0 && !eofflag)		goto again;eof:out:	VOP_UNLOCK(vp, 0, curproc);	free(buf, M_TEMP, 0);	return (error);}
开发者ID:orumin,项目名称:openbsd-efivars,代码行数:87,


示例14: fdesc_lookup

/* * vp is the current namei directory * ndp is the name to locate in that directory... */static intfdesc_lookup(struct vop_lookup_args *ap){	struct vnode **vpp = ap->a_vpp;	struct vnode *dvp = ap->a_dvp;	struct componentname *cnp = ap->a_cnp;	char *pname = cnp->cn_nameptr;	struct thread *td = cnp->cn_thread;	struct file *fp;	struct fdesc_get_ino_args arg;	cap_rights_t rights;	int nlen = cnp->cn_namelen;	u_int fd, fd1;	int error;	struct vnode *fvp;	if ((cnp->cn_flags & ISLASTCN) &&	    (cnp->cn_nameiop == DELETE || cnp->cn_nameiop == RENAME)) {		error = EROFS;		goto bad;	}	if (cnp->cn_namelen == 1 && *pname == '.') {		*vpp = dvp;		VREF(dvp);		return (0);	}	if (VTOFDESC(dvp)->fd_type != Froot) {		error = ENOTDIR;		goto bad;	}	fd = 0;	/* the only time a leading 0 is acceptable is if it's "0" */	if (*pname == '0' && nlen != 1) {		error = ENOENT;		goto bad;	}	while (nlen--) {		if (*pname < '0' || *pname > '9') {			error = ENOENT;			goto bad;		}		fd1 = 10 * fd + *pname++ - '0';		if (fd1 < fd) {			error = ENOENT;			goto bad;		}		fd = fd1;	}	/*	 * No rights to check since 'fp' isn't actually used.	 */	if ((error = fget(td, fd, cap_rights_init(&rights), &fp)) != 0)		goto bad;	/* Check if we're looking up ourselves. */	if (VTOFDESC(dvp)->fd_ix == FD_DESC + fd) {		/*		 * In case we're holding the last reference to the file, the dvp		 * will be re-acquired.		 */		vhold(dvp);		VOP_UNLOCK(dvp, 0);		fdrop(fp, td);		/* Re-aquire the lock afterwards. */		vn_lock(dvp, LK_RETRY | LK_EXCLUSIVE);		vdrop(dvp);		fvp = dvp;		if ((dvp->v_iflag & VI_DOOMED) != 0)			error = ENOENT;	} else {		/*		 * Unlock our root node (dvp) when doing this, since we might		 * deadlock since the vnode might be locked by another thread		 * and the root vnode lock will be obtained afterwards (in case		 * we're looking up the fd of the root vnode), which will be the		 * opposite lock order. Vhold the root vnode first so we don't		 * lose it.		 */		arg.ftype = Fdesc;		arg.fd_fd = fd;		arg.ix = FD_DESC + fd;		arg.fp = fp;		arg.td = td;		error = vn_vget_ino_gen(dvp, fdesc_get_ino_alloc, &arg,		    LK_EXCLUSIVE, &fvp);	}		if (error)		goto bad;	*vpp = fvp;	return (0);//.........这里部分代码省略.........
开发者ID:hmatyschok,项目名称:MeshBSD,代码行数:101,


示例15: msdosfs_mount

/* * mp - path - addr in user space of mount point (ie /usr or whatever) * data - addr in user space of mount params including the name of the block * special file to treat as a filesystem. */intmsdosfs_mount(struct mount *mp, const char *path, void *data,              struct nameidata *ndp, struct proc *p){    struct vnode *devvp;	  /* vnode for blk device to mount */    struct msdosfs_args args; /* will hold data from mount request */    /* msdosfs specific mount control block */    struct msdosfsmount *pmp = NULL;    size_t size;    int error, flags;    mode_t accessmode;    error = copyin(data, &args, sizeof(struct msdosfs_args));    if (error)        return (error);    /*     * If updating, check whether changing from read-only to     * read/write; if there is no device name, that's all we do.     */    if (mp->mnt_flag & MNT_UPDATE) {        pmp = VFSTOMSDOSFS(mp);        error = 0;        if (!(pmp->pm_flags & MSDOSFSMNT_RONLY) && (mp->mnt_flag & MNT_RDONLY)) {            flags = WRITECLOSE;            if (mp->mnt_flag & MNT_FORCE)                flags |= FORCECLOSE;            error = vflush(mp, NULLVP, flags);        }        if (!error && (mp->mnt_flag & MNT_RELOAD))            /* not yet implemented */            error = EOPNOTSUPP;        if (error)            return (error);        if ((pmp->pm_flags & MSDOSFSMNT_RONLY) && (mp->mnt_flag & MNT_WANTRDWR)) {            /*             * If upgrade to read-write by non-root, then verify             * that user has necessary permissions on the device.             */            if (suser(p, 0) != 0) {                devvp = pmp->pm_devvp;                vn_lock(devvp, LK_EXCLUSIVE | LK_RETRY, p);                error = VOP_ACCESS(devvp, VREAD | VWRITE,                                   p->p_ucred, p);                if (error) {                    VOP_UNLOCK(devvp, 0, p);                    return (error);                }                VOP_UNLOCK(devvp, 0, p);            }            pmp->pm_flags &= ~MSDOSFSMNT_RONLY;        }        if (args.fspec == 0) {#ifdef	__notyet__		/* doesn't work correctly with current mountd	XXX */            if (args.flags & MSDOSFSMNT_MNTOPT) {                pmp->pm_flags &= ~MSDOSFSMNT_MNTOPT;                pmp->pm_flags |= args.flags & MSDOSFSMNT_MNTOPT;                if (pmp->pm_flags & MSDOSFSMNT_NOWIN95)                    pmp->pm_flags |= MSDOSFSMNT_SHORTNAME;            }#endif            /*             * Process export requests.             */            return (vfs_export(mp, &pmp->pm_export,                               &args.export_info));        }    }    /*     * Not an update, or updating the name: look up the name     * and verify that it refers to a sensible block device.     */    NDINIT(ndp, LOOKUP, FOLLOW, UIO_USERSPACE, args.fspec, p);    if ((error = namei(ndp)) != 0)        return (error);    devvp = ndp->ni_vp;    if (devvp->v_type != VBLK) {        vrele(devvp);        return (ENOTBLK);    }    if (major(devvp->v_rdev) >= nblkdev) {        vrele(devvp);        return (ENXIO);    }    /*     * If mount by non-root, then verify that user has necessary     * permissions on the device.     */    if (suser(p, 0) != 0) {        accessmode = VREAD;        if ((mp->mnt_flag & MNT_RDONLY) == 0)            accessmode |= VWRITE;        vn_lock(devvp, LK_EXCLUSIVE | LK_RETRY, p);        error = VOP_ACCESS(devvp, accessmode, p->p_ucred, p);        if (error) {//.........这里部分代码省略.........
开发者ID:7shi,项目名称:openbsd-loongson-vc,代码行数:101,


示例16: osi_VM_TryToSmush

/* Try to invalidate pages, for "fs flush" or "fs flushv"; or * try to free pages, when deleting a file. * * Locking:  the vcache entry's lock is held.  It may be dropped and  * re-obtained. * * Since we drop and re-obtain the lock, we can't guarantee that there won't * be some pages around when we return, newly created by concurrent activity. */voidosi_VM_TryToSmush(struct vcache *avc, afs_ucred_t *acred, int sync){    struct vnode *vp;    int tries, code;    int islocked;    SPLVAR;    vp = AFSTOV(avc);    VI_LOCK(vp);    if (vp->v_iflag & VI_DOOMED) {	VI_UNLOCK(vp);	USERPRI;	return;    }    VI_UNLOCK(vp);    islocked = VOP_ISLOCKED(vp);    if (islocked == LK_EXCLOTHER)	panic("Trying to Smush over someone else's lock");    else if (islocked == LK_SHARED) {	afs_warn("Trying to Smush with a shared lock");	vn_lock(vp, LK_UPGRADE);    } else if (!islocked)	vn_lock(vp, LK_EXCLUSIVE);    if (vp->v_bufobj.bo_object != NULL) {	VM_OBJECT_LOCK(vp->v_bufobj.bo_object);	/*	 * Do we really want OBJPC_SYNC?  OBJPC_INVAL would be	 * faster, if invalidation is really what we are being	 * asked to do.  (It would make more sense, too, since	 * otherwise this function is practically identical to	 * osi_VM_StoreAllSegments().)  -GAW	 */	/*	 * Dunno.  We no longer resemble osi_VM_StoreAllSegments,	 * though maybe that's wrong, now.  And OBJPC_SYNC is the	 * common thing in 70 file systems, it seems.  Matt.	 */	vm_object_page_clean(vp->v_bufobj.bo_object, 0, 0, OBJPC_SYNC);	VM_OBJECT_UNLOCK(vp->v_bufobj.bo_object);    }    tries = 5;    code = osi_vinvalbuf(vp, V_SAVE, PCATCH, 0);    while (code && (tries > 0)) {	afs_warn("TryToSmush retrying vinvalbuf");	code = osi_vinvalbuf(vp, V_SAVE, PCATCH, 0);	--tries;    }    if (islocked == LK_SHARED)	vn_lock(vp, LK_DOWNGRADE);    else if (!islocked)	VOP_UNLOCK(vp, 0);    USERPRI;}
开发者ID:SimonWilkinson,项目名称:openafs,代码行数:70,


示例17: fusefs_rename

intfusefs_rename(void *v){	struct vop_rename_args *ap = v;	struct vnode *tvp = ap->a_tvp;	struct vnode *tdvp = ap->a_tdvp;	struct vnode *fvp = ap->a_fvp;	struct vnode *fdvp = ap->a_fdvp;	struct componentname *tcnp = ap->a_tcnp;	struct componentname *fcnp = ap->a_fcnp;	struct proc *p = fcnp->cn_proc;	struct fusefs_node *ip, *dp;	struct fusefs_mnt *fmp;	struct fusebuf *fbuf;	int error = 0;#ifdef DIAGNOSTIC	if ((tcnp->cn_flags & HASBUF) == 0 ||	    (fcnp->cn_flags & HASBUF) == 0)		panic("fusefs_rename: no name");#endif	/*	 * Check for cross-device rename.	 */	if ((fvp->v_mount != tdvp->v_mount) ||	    (tvp && (fvp->v_mount != tvp->v_mount))) {		error = EXDEV;abortit:		VOP_ABORTOP(tdvp, tcnp); /* XXX, why not in NFS? */		if (tdvp == tvp)			vrele(tdvp);		else			vput(tdvp);		if (tvp)			vput(tvp);		VOP_ABORTOP(fdvp, fcnp); /* XXX, why not in NFS? */		vrele(fdvp);		vrele(fvp);		return (error);	}	/*	 * If source and dest are the same, do nothing.	 */	if (tvp == fvp) {		error = 0;		goto abortit;	}	if ((error = vn_lock(fvp, LK_EXCLUSIVE | LK_RETRY, p)) != 0)		goto abortit;	dp = VTOI(fdvp);	ip = VTOI(fvp);	fmp = (struct fusefs_mnt *)ip->ufs_ino.i_ump;	/*	 * Be sure we are not renaming ".", "..", or an alias of ".". This	 * leads to a crippled directory tree.  It's pretty tough to do a	 * "ls" or "pwd" with the "." directory entry missing, and "cd .."	 * doesn't work if the ".." entry is missing.	 */	if (ip->vtype == VDIR) {		/*		 * Avoid ".", "..", and aliases of "." for obvious reasons.		 */		if ((fcnp->cn_namelen == 1 && fcnp->cn_nameptr[0] == '.') ||		    dp == ip ||		    (fcnp->cn_flags & ISDOTDOT) ||		    (tcnp->cn_flags & ISDOTDOT)) {			VOP_UNLOCK(fvp, 0);			error = EINVAL;			goto abortit;		}	}	VN_KNOTE(fdvp, NOTE_WRITE);	/* XXX right place? */	if (!fmp->sess_init || (fmp->undef_op & UNDEF_RENAME)) {		error = ENOSYS;		VOP_UNLOCK(fvp, 0);		goto abortit;	}	fbuf = fb_setup(fcnp->cn_namelen + tcnp->cn_namelen + 2,	    dp->ufs_ino.i_number, FBT_RENAME, p);	memcpy(fbuf->fb_dat, fcnp->cn_nameptr, fcnp->cn_namelen);	fbuf->fb_dat[fcnp->cn_namelen] = '/0';	memcpy(fbuf->fb_dat + fcnp->cn_namelen + 1, tcnp->cn_nameptr,	    tcnp->cn_namelen);	fbuf->fb_dat[fcnp->cn_namelen + tcnp->cn_namelen + 1] = '/0';	fbuf->fb_io_ino = VTOI(tdvp)->ufs_ino.i_number;	error = fb_queue(fmp->dev, fbuf);	if (error) {		if (error == ENOSYS) {			fmp->undef_op |= UNDEF_RENAME;		}		fb_delete(fbuf);//.........这里部分代码省略.........
开发者ID:appleorange1,项目名称:bitrig,代码行数:101,


示例18: msdosfs_mount

/* * mp - path - addr in user space of mount point (ie /usr or whatever) * data - addr in user space of mount params including the name of the block * special file to treat as a filesystem. */static intmsdosfs_mount(struct mount *mp, char *path, caddr_t data, struct ucred *cred){	struct vnode *devvp;	  /* vnode for blk device to mount */	struct msdosfs_args args; /* will hold data from mount request */	/* msdosfs specific mount control block */	struct msdosfsmount *pmp = NULL;	size_t size;	int error, flags;	mode_t accessmode;	struct nlookupdata nd;	error = copyin(data, (caddr_t)&args, sizeof(struct msdosfs_args));	if (error)		return (error);	if (args.magic != MSDOSFS_ARGSMAGIC)		args.flags = 0;	/*	 * If updating, check whether changing from read-only to	 * read/write; if there is no device name, that's all we do.	 */	if (mp->mnt_flag & MNT_UPDATE) {		pmp = VFSTOMSDOSFS(mp);		error = 0;		if (!(pmp->pm_flags & MSDOSFSMNT_RONLY) && (mp->mnt_flag & MNT_RDONLY)) {			flags = WRITECLOSE;			if (mp->mnt_flag & MNT_FORCE)				flags |= FORCECLOSE;			error = vflush(mp, 0, flags);			if (error == 0) {				devvp = pmp->pm_devvp;				vn_lock(devvp, LK_EXCLUSIVE | LK_RETRY);				VOP_OPEN(devvp, FREAD, FSCRED, NULL);				VOP_CLOSE(devvp, FREAD|FWRITE, NULL);				vn_unlock(devvp);				pmp->pm_flags |= MSDOSFSMNT_RONLY;			}		}		if (!error && (mp->mnt_flag & MNT_RELOAD))			/* not yet implemented */			error = EOPNOTSUPP;		if (error)			return (error);		if ((pmp->pm_flags & MSDOSFSMNT_RONLY) && (mp->mnt_kern_flag & MNTK_WANTRDWR)) {			/*			 * If upgrade to read-write by non-root, then verify			 * that user has necessary permissions on the device.			 */			devvp = pmp->pm_devvp;			vn_lock(devvp, LK_EXCLUSIVE | LK_RETRY);			if (cred->cr_uid != 0) {				error = VOP_EACCESS(devvp, VREAD | VWRITE, cred);				if (error) {					vn_unlock(devvp);					return (error);				}			}			VOP_OPEN(devvp, FREAD|FWRITE, FSCRED, NULL);			VOP_CLOSE(devvp, FREAD, NULL);			vn_unlock(devvp);			pmp->pm_flags &= ~MSDOSFSMNT_RONLY;		}		if (args.fspec == NULL) {#ifdef	__notyet__		/* doesn't work correctly with current mountd	XXX */			if (args.flags & MSDOSFSMNT_MNTOPT) {				pmp->pm_flags &= ~MSDOSFSMNT_MNTOPT;				pmp->pm_flags |= args.flags & MSDOSFSMNT_MNTOPT;				if (pmp->pm_flags & MSDOSFSMNT_NOWIN95)					pmp->pm_flags |= MSDOSFSMNT_SHORTNAME;			}#endif			/*			 * Process export requests.			 */			return (vfs_export(mp, &pmp->pm_export, &args.export));		}	}
开发者ID:kusumi,项目名称:DragonFlyBSD,代码行数:82,


示例19: ufs_link

/* * link vnode call */intufs_link(void *v){	struct vop_link_args *ap = v;	struct vnode *dvp = ap->a_dvp;	struct vnode *vp = ap->a_vp;	struct componentname *cnp = ap->a_cnp;	struct proc *p = cnp->cn_proc;	struct inode *ip;	struct direct newdir;	int error;#ifdef DIAGNOSTIC	if ((cnp->cn_flags & HASBUF) == 0)		panic("ufs_link: no name");#endif	if (vp->v_type == VDIR) {		VOP_ABORTOP(dvp, cnp);		error = EPERM;		goto out2;	}	if (dvp->v_mount != vp->v_mount) {		VOP_ABORTOP(dvp, cnp);		error = EXDEV;		goto out2;	}	if (dvp != vp && (error = vn_lock(vp, LK_EXCLUSIVE, p))) {		VOP_ABORTOP(dvp, cnp);		goto out2;	}	ip = VTOI(vp);	if ((nlink_t) DIP(ip, nlink) >= LINK_MAX) {		VOP_ABORTOP(dvp, cnp);		error = EMLINK;		goto out1;	}	if (DIP(ip, flags) & (IMMUTABLE | APPEND)) {		VOP_ABORTOP(dvp, cnp);		error = EPERM;		goto out1;	}	ip->i_effnlink++;	DIP_ADD(ip, nlink, 1);	ip->i_flag |= IN_CHANGE;	if (DOINGSOFTDEP(vp))		softdep_change_linkcnt(ip, 0);	if ((error = UFS_UPDATE(ip, !DOINGSOFTDEP(vp))) == 0) {		ufs_makedirentry(ip, cnp, &newdir);		error = ufs_direnter(dvp, vp, &newdir, cnp, NULL);	}	if (error) {		ip->i_effnlink--;		DIP_ADD(ip, nlink, -1);		ip->i_flag |= IN_CHANGE;		if (DOINGSOFTDEP(vp))			softdep_change_linkcnt(ip, 0);	}	pool_put(&namei_pool, cnp->cn_pnbuf);	VN_KNOTE(vp, NOTE_LINK);	VN_KNOTE(dvp, NOTE_WRITE);out1:	if (dvp != vp)		VOP_UNLOCK(vp, 0);out2:	vput(dvp);	return (error);}
开发者ID:sofuture,项目名称:bitrig,代码行数:70,


示例20: ufs_extattr_set

/* * Real work associated with setting a vnode's extended attributes; * assumes that the attribute lock has already been grabbed. */static intufs_extattr_set(struct vnode *vp, int attrnamespace, const char *name,    struct uio *uio, struct ucred *cred, struct thread *td){	struct ufs_extattr_list_entry *attribute;	struct ufs_extattr_header ueh;	struct iovec local_aiov;	struct uio local_aio;	struct mount *mp = vp->v_mount;	struct ufsmount *ump = VFSTOUFS(mp);	struct inode *ip = VTOI(vp);	off_t base_offset;	int error = 0, ioflag;	if (vp->v_mount->mnt_flag & MNT_RDONLY)		return (EROFS);	if (!(ump->um_extattr.uepm_flags & UFS_EXTATTR_UEPM_STARTED))		return (EOPNOTSUPP);	if (!ufs_extattr_valid_attrname(attrnamespace, name))		return (EINVAL);	error = extattr_check_cred(vp, attrnamespace, cred, td, VWRITE);	if (error)		return (error);	attribute = ufs_extattr_find_attr(ump, attrnamespace, name);	if (!attribute)		return (ENOATTR);	/*	 * Early rejection of invalid offsets/length.	 * Reject: any offset but 0 (replace)	 *	 Any size greater than attribute size limit 	 */	if (uio->uio_offset != 0 ||	    uio->uio_resid > attribute->uele_fileheader.uef_size)		return (ENXIO);	/*	 * Find base offset of header in file based on file header size, and	 * data header size + maximum data size, indexed by inode number.	 */	base_offset = sizeof(struct ufs_extattr_fileheader) +	    ip->i_number * (sizeof(struct ufs_extattr_header) +	    attribute->uele_fileheader.uef_size);	/*	 * Write out a data header for the data.	 */	ueh.ueh_len = uio->uio_resid;	ueh.ueh_flags = UFS_EXTATTR_ATTR_FLAG_INUSE;	ueh.ueh_i_gen = ip->i_gen;	local_aiov.iov_base = (caddr_t) &ueh;	local_aiov.iov_len = sizeof(struct ufs_extattr_header);	local_aio.uio_iov = &local_aiov;	local_aio.uio_iovcnt = 1;	local_aio.uio_rw = UIO_WRITE;	local_aio.uio_segflg = UIO_SYSSPACE;	local_aio.uio_td = td;	local_aio.uio_offset = base_offset;	local_aio.uio_resid = sizeof(struct ufs_extattr_header);	/*	 * Acquire locks.	 *	 * Don't need to get a lock on the backing file if the setattr is	 * being applied to the backing file, as the lock is already held.	 */	if (attribute->uele_backing_vnode != vp)		vn_lock(attribute->uele_backing_vnode, LK_EXCLUSIVE | LK_RETRY);	ioflag = IO_NODELOCKED;	if (ufs_extattr_sync)		ioflag |= IO_SYNC;	error = VOP_WRITE(attribute->uele_backing_vnode, &local_aio, ioflag,	    ump->um_extattr.uepm_ucred);	if (error)		goto vopunlock_exit;	if (local_aio.uio_resid != 0) {		error = ENXIO;		goto vopunlock_exit;	}	/*	 * Write out user data.	 */	uio->uio_offset = base_offset + sizeof(struct ufs_extattr_header);	ioflag = IO_NODELOCKED;	if (ufs_extattr_sync)		ioflag |= IO_SYNC;	error = VOP_WRITE(attribute->uele_backing_vnode, uio, ioflag,	    ump->um_extattr.uepm_ucred);vopunlock_exit://.........这里部分代码省略.........
开发者ID:markjdb,项目名称:freebsd-dev,代码行数:101,


示例21: ext2_mount

/* * VFS Operations. * * mount system call */static intext2_mount(struct mount *mp){	struct vfsoptlist *opts;	struct vnode *devvp;	struct thread *td;	struct ext2mount *ump = NULL;	struct m_ext2fs *fs;	struct nameidata nd, *ndp = &nd;	accmode_t accmode;	char *path, *fspec;	int error, flags, len;	td = curthread;	opts = mp->mnt_optnew;	if (vfs_filteropt(opts, ext2_opts))		return (EINVAL);	vfs_getopt(opts, "fspath", (void **)&path, NULL);	/* Double-check the length of path.. */	if (strlen(path) >= MAXMNTLEN)		return (ENAMETOOLONG);	fspec = NULL;	error = vfs_getopt(opts, "from", (void **)&fspec, &len);	if (!error && fspec[len - 1] != '/0')		return (EINVAL);	/*	 * If updating, check whether changing from read-only to	 * read/write; if there is no device name, that's all we do.	 */	if (mp->mnt_flag & MNT_UPDATE) {		ump = VFSTOEXT2(mp);		fs = ump->um_e2fs; 		error = 0;		if (fs->e2fs_ronly == 0 &&		    vfs_flagopt(opts, "ro", NULL, 0)) {			error = VFS_SYNC(mp, MNT_WAIT);			if (error)				return (error);			flags = WRITECLOSE;			if (mp->mnt_flag & MNT_FORCE)				flags |= FORCECLOSE;			error = ext2_flushfiles(mp, flags, td);			if ( error == 0 && fs->e2fs_wasvalid && ext2_cgupdate(ump, MNT_WAIT) == 0) {				fs->e2fs->e2fs_state |= E2FS_ISCLEAN;				ext2_sbupdate(ump, MNT_WAIT);			}			fs->e2fs_ronly = 1;			vfs_flagopt(opts, "ro", &mp->mnt_flag, MNT_RDONLY);			DROP_GIANT();			g_topology_lock();			g_access(ump->um_cp, 0, -1, 0);			g_topology_unlock();			PICKUP_GIANT();		}		if (!error && (mp->mnt_flag & MNT_RELOAD))			error = ext2_reload(mp, td);		if (error)			return (error);		devvp = ump->um_devvp;		if (fs->e2fs_ronly && !vfs_flagopt(opts, "ro", NULL, 0)) {			if (ext2_check_sb_compat(fs->e2fs, devvp->v_rdev, 0))				return (EPERM);			/*			 * If upgrade to read-write by non-root, then verify			 * that user has necessary permissions on the device.			 */			vn_lock(devvp, LK_EXCLUSIVE | LK_RETRY);			error = VOP_ACCESS(devvp, VREAD | VWRITE,			    td->td_ucred, td);			if (error)				error = priv_check(td, PRIV_VFS_MOUNT_PERM);			if (error) {				VOP_UNLOCK(devvp, 0);				return (error);			}			VOP_UNLOCK(devvp, 0);			DROP_GIANT();			g_topology_lock();			error = g_access(ump->um_cp, 0, 1, 0);			g_topology_unlock();			PICKUP_GIANT();			if (error)				return (error);			if ((fs->e2fs->e2fs_state & E2FS_ISCLEAN) == 0 ||			    (fs->e2fs->e2fs_state & E2FS_ERRORS)) {				if (mp->mnt_flag & MNT_FORCE) {					printf("WARNING: %s was not properly dismounted/n", fs->e2fs_fsmnt);				} else {//.........这里部分代码省略.........
开发者ID:Eastsideboy,项目名称:freebsd,代码行数:101,


示例22: ufs_extattr_rm

/* * Real work associated with removing an extended attribute from a vnode. * Assumes the attribute lock has already been grabbed. */static intufs_extattr_rm(struct vnode *vp, int attrnamespace, const char *name,    struct ucred *cred, struct thread *td){	struct ufs_extattr_list_entry *attribute;	struct ufs_extattr_header ueh;	struct iovec local_aiov;	struct uio local_aio;	struct mount *mp = vp->v_mount;	struct ufsmount *ump = VFSTOUFS(mp);	struct inode *ip = VTOI(vp);	off_t base_offset;	int error = 0, ioflag;	if (vp->v_mount->mnt_flag & MNT_RDONLY)  		return (EROFS);	if (!(ump->um_extattr.uepm_flags & UFS_EXTATTR_UEPM_STARTED))		return (EOPNOTSUPP);	if (!ufs_extattr_valid_attrname(attrnamespace, name))		return (EINVAL);	error = extattr_check_cred(vp, attrnamespace, cred, td, VWRITE);	if (error)		return (error);	attribute = ufs_extattr_find_attr(ump, attrnamespace, name);	if (!attribute)		return (ENOATTR);	/*	 * Find base offset of header in file based on file header size, and	 * data header size + maximum data size, indexed by inode number.	 */	base_offset = sizeof(struct ufs_extattr_fileheader) +	    ip->i_number * (sizeof(struct ufs_extattr_header) +	    attribute->uele_fileheader.uef_size);	/*	 * Check to see if currently defined.	 */	bzero(&ueh, sizeof(struct ufs_extattr_header));	local_aiov.iov_base = (caddr_t) &ueh;	local_aiov.iov_len = sizeof(struct ufs_extattr_header);	local_aio.uio_iov = &local_aiov;	local_aio.uio_iovcnt = 1;	local_aio.uio_rw = UIO_READ;	local_aio.uio_segflg = UIO_SYSSPACE;	local_aio.uio_td = td;	local_aio.uio_offset = base_offset;	local_aio.uio_resid = sizeof(struct ufs_extattr_header);	/*	 * Don't need to get the lock on the backing vnode if the vnode we're	 * modifying is it, as we already hold the lock.	 */	if (attribute->uele_backing_vnode != vp)		vn_lock(attribute->uele_backing_vnode, LK_EXCLUSIVE | LK_RETRY);	error = VOP_READ(attribute->uele_backing_vnode, &local_aio,	    IO_NODELOCKED, ump->um_extattr.uepm_ucred);	if (error)		goto vopunlock_exit;	/* Defined? */	if ((ueh.ueh_flags & UFS_EXTATTR_ATTR_FLAG_INUSE) == 0) {		error = ENOATTR;		goto vopunlock_exit;	}	/* Valid for the current inode generation? */	if (ueh.ueh_i_gen != ip->i_gen) {		/*		 * The inode itself has a different generation number than		 * the attribute data.  For now, the best solution is to		 * coerce this to undefined, and let it get cleaned up by		 * the next write or extattrctl clean.		 */		printf("ufs_extattr_rm (%s): inode number inconsistency (%d, %jd)/n",		    mp->mnt_stat.f_mntonname, ueh.ueh_i_gen, (intmax_t)ip->i_gen);		error = ENOATTR;		goto vopunlock_exit;	}	/* Flag it as not in use. */	ueh.ueh_flags = 0;	ueh.ueh_len = 0;	local_aiov.iov_base = (caddr_t) &ueh;	local_aiov.iov_len = sizeof(struct ufs_extattr_header);	local_aio.uio_iov = &local_aiov;	local_aio.uio_iovcnt = 1;	local_aio.uio_rw = UIO_WRITE;	local_aio.uio_segflg = UIO_SYSSPACE;	local_aio.uio_td = td;	local_aio.uio_offset = base_offset;//.........这里部分代码省略.........
开发者ID:markjdb,项目名称:freebsd-dev,代码行数:101,


示例23: ext2_sync

/* * Go through the disk queues to initiate sandbagged IO; * go through the inodes to write those that have been modified; * initiate the writing of the super block if it has been modified. * * Note: we are always called with the filesystem marked `MPBUSY'. */static intext2_sync(struct mount *mp, int waitfor){	struct vnode *mvp, *vp;	struct thread *td;	struct inode *ip;	struct ext2mount *ump = VFSTOEXT2(mp);	struct m_ext2fs *fs;	int error, allerror = 0;	td = curthread;	fs = ump->um_e2fs;	if (fs->e2fs_fmod != 0 && fs->e2fs_ronly != 0) {		/* XXX */		printf("fs = %s/n", fs->e2fs_fsmnt);		panic("ext2_sync: rofs mod");	}	/*	 * Write back each (modified) inode.	 */loop:	MNT_VNODE_FOREACH_ALL(vp, mp, mvp) {		if (vp->v_type == VNON) {			VI_UNLOCK(vp);			continue;		}		ip = VTOI(vp);		if ((ip->i_flag &		    (IN_ACCESS | IN_CHANGE | IN_MODIFIED | IN_UPDATE)) == 0 &&		    (vp->v_bufobj.bo_dirty.bv_cnt == 0 ||		    waitfor == MNT_LAZY)) {			VI_UNLOCK(vp);			continue;		}		error = vget(vp, LK_EXCLUSIVE | LK_NOWAIT | LK_INTERLOCK, td);		if (error) {			if (error == ENOENT) {				MNT_VNODE_FOREACH_ALL_ABORT(mp, mvp);				goto loop;			}			continue;		}		if ((error = VOP_FSYNC(vp, waitfor, td)) != 0)			allerror = error;		VOP_UNLOCK(vp, 0);		vrele(vp);	}	/*	 * Force stale filesystem control information to be flushed.	 */	if (waitfor != MNT_LAZY) {		vn_lock(ump->um_devvp, LK_EXCLUSIVE | LK_RETRY);		if ((error = VOP_FSYNC(ump->um_devvp, waitfor, td)) != 0)			allerror = error;		VOP_UNLOCK(ump->um_devvp, 0);	}	/*	 * Write back modified superblock.	 */	if (fs->e2fs_fmod != 0) {		fs->e2fs_fmod = 0;		fs->e2fs->e2fs_wtime = time_second;		if ((error = ext2_cgupdate(ump, waitfor)) != 0)			allerror = error;	}	return (allerror);}
开发者ID:Eastsideboy,项目名称:freebsd,代码行数:76,


示例24: ufs_extattr_enable

/* * Enable a named attribute on the specified filesystem; provide an * unlocked backing vnode to hold the attribute data. */static intufs_extattr_enable(struct ufsmount *ump, int attrnamespace,    const char *attrname, struct vnode *backing_vnode, struct thread *td){	struct ufs_extattr_list_entry *attribute;	struct iovec aiov;	struct uio auio;	int error = 0;	if (!ufs_extattr_valid_attrname(attrnamespace, attrname))		return (EINVAL);	if (backing_vnode->v_type != VREG)		return (EINVAL);	attribute = malloc(sizeof(struct ufs_extattr_list_entry),	    M_UFS_EXTATTR, M_WAITOK);	if (!(ump->um_extattr.uepm_flags & UFS_EXTATTR_UEPM_STARTED)) {		error = EOPNOTSUPP;		goto free_exit;	}	if (ufs_extattr_find_attr(ump, attrnamespace, attrname)) {		error = EEXIST;		goto free_exit;	}	strncpy(attribute->uele_attrname, attrname,	    UFS_EXTATTR_MAXEXTATTRNAME);	attribute->uele_attrnamespace = attrnamespace;	bzero(&attribute->uele_fileheader,	    sizeof(struct ufs_extattr_fileheader));		attribute->uele_backing_vnode = backing_vnode;	auio.uio_iov = &aiov;	auio.uio_iovcnt = 1;	aiov.iov_base = (caddr_t) &attribute->uele_fileheader;	aiov.iov_len = sizeof(struct ufs_extattr_fileheader);	auio.uio_resid = sizeof(struct ufs_extattr_fileheader);	auio.uio_offset = (off_t) 0;	auio.uio_segflg = UIO_SYSSPACE;	auio.uio_rw = UIO_READ;	auio.uio_td = td;	vn_lock(backing_vnode, LK_SHARED | LK_RETRY);	error = VOP_READ(backing_vnode, &auio, IO_NODELOCKED,	    ump->um_extattr.uepm_ucred);	if (error)		goto unlock_free_exit;	if (auio.uio_resid != 0) {		printf("ufs_extattr_enable: malformed attribute header/n");		error = EINVAL;		goto unlock_free_exit;	}	if (attribute->uele_fileheader.uef_magic != UFS_EXTATTR_MAGIC) {		printf("ufs_extattr_enable: invalid attribute header magic/n");		error = EINVAL;		goto unlock_free_exit;	}	if (attribute->uele_fileheader.uef_version != UFS_EXTATTR_VERSION) {		printf("ufs_extattr_enable: incorrect attribute header "		    "version/n");		error = EINVAL;		goto unlock_free_exit;	}	ASSERT_VOP_LOCKED(backing_vnode, "ufs_extattr_enable");	LIST_INSERT_HEAD(&ump->um_extattr.uepm_list, attribute,	    uele_entries);	VOP_UNLOCK(backing_vnode, 0);	return (0);unlock_free_exit:	VOP_UNLOCK(backing_vnode, 0);free_exit:	free(attribute, M_UFS_EXTATTR);	return (error);}
开发者ID:markjdb,项目名称:freebsd-dev,代码行数:89,


示例25: smbfs_readvnode

intsmbfs_readvnode(struct vnode *vp, struct uio *uiop, struct ucred *cred){	struct smbmount *smp = VFSTOSMBFS(vp->v_mount);	struct smbnode *np = VTOSMB(vp);	struct thread *td;	struct vattr vattr;	struct smb_cred *scred;	int error, lks;	/*	 * Protect against method which is not supported for now	 */	if (uiop->uio_segflg == UIO_NOCOPY)		return EOPNOTSUPP;	if (vp->v_type != VREG && vp->v_type != VDIR) {		SMBFSERR("vn types other than VREG or VDIR are unsupported !/n");		return EIO;	}	if (uiop->uio_resid == 0)		return 0;	if (uiop->uio_offset < 0)		return EINVAL;/*	if (uiop->uio_offset + uiop->uio_resid > smp->nm_maxfilesize)		return EFBIG;*/	td = uiop->uio_td;	if (vp->v_type == VDIR) {		lks = LK_EXCLUSIVE;	/* lockstatus(vp->v_vnlock); */		if (lks == LK_SHARED)			vn_lock(vp, LK_UPGRADE | LK_RETRY);		error = smbfs_readvdir(vp, uiop, cred);		if (lks == LK_SHARED)			vn_lock(vp, LK_DOWNGRADE | LK_RETRY);		return error;	}/*	biosize = SSTOCN(smp->sm_share)->sc_txmax;*/	if (np->n_flag & NMODIFIED) {		smbfs_attr_cacheremove(vp);		error = VOP_GETATTR(vp, &vattr, cred);		if (error)			return error;		np->n_mtime.tv_sec = vattr.va_mtime.tv_sec;	} else {		error = VOP_GETATTR(vp, &vattr, cred);		if (error)			return error;		if (np->n_mtime.tv_sec != vattr.va_mtime.tv_sec) {			error = smbfs_vinvalbuf(vp, td);			if (error)				return error;			np->n_mtime.tv_sec = vattr.va_mtime.tv_sec;		}	}	scred = smbfs_malloc_scred();	smb_makescred(scred, td, cred);	error = smb_read(smp->sm_share, np->n_fid, uiop, scred);	smbfs_free_scred(scred);	return (error);}
开发者ID:ChaosJohn,项目名称:freebsd,代码行数:61,



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


C++ vn_open函数代码示例
C++ vn_close函数代码示例
万事OK自学网:51自学网_软件自学网_CAD自学网自学excel、自学PS、自学CAD、自学C语言、自学css3实例,是一个通过网络自主学习工作技能的自学平台,网友喜欢的软件自学网站。