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

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

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

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

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

示例1: zpl_evict_inode

static voidzpl_evict_inode(struct inode *ip){	truncate_setsize(ip, 0);	clear_inode(ip);	zfs_inactive(ip);}
开发者ID:ColdCanuck,项目名称:zfs,代码行数:7,


示例2: ufs_setattr

int ufs_setattr(struct dentry *dentry, struct iattr *attr){	struct inode *inode = dentry->d_inode;	unsigned int ia_valid = attr->ia_valid;	int error;	error = inode_change_ok(inode, attr);	if (error)		return error;	if (ia_valid & ATTR_SIZE && attr->ia_size != inode->i_size) {		loff_t old_i_size = inode->i_size;		/* XXX(truncate): truncate_setsize should be called last */		truncate_setsize(inode, attr->ia_size);		error = ufs_truncate(inode, old_i_size);		if (error)			return error;	}	setattr_copy(inode, attr);	mark_inode_dirty(inode);	return 0;}
开发者ID:ANFS,项目名称:ANFS-kernel,代码行数:25,


示例3: orangefs_setattr_size

static int orangefs_setattr_size(struct inode *inode, struct iattr *iattr){	struct orangefs_inode_s *orangefs_inode = ORANGEFS_I(inode);	struct orangefs_kernel_op_s *new_op;	loff_t orig_size;	int ret = -EINVAL;	gossip_debug(GOSSIP_INODE_DEBUG,		     "%s: %pU: Handle is %pU | fs_id %d | size is %llu/n",		     __func__,		     get_khandle_from_ino(inode),		     &orangefs_inode->refn.khandle,		     orangefs_inode->refn.fs_id,		     iattr->ia_size);	/* Ensure that we have a up to date size, so we know if it changed. */	ret = orangefs_inode_getattr(inode, 0, 1);	if (ret == -ESTALE)		ret = -EIO;	if (ret) {		gossip_err("%s: orangefs_inode_getattr failed, ret:%d:./n",		    __func__, ret);		return ret;	}	orig_size = i_size_read(inode);	truncate_setsize(inode, iattr->ia_size);	new_op = op_alloc(ORANGEFS_VFS_OP_TRUNCATE);	if (!new_op)		return -ENOMEM;	new_op->upcall.req.truncate.refn = orangefs_inode->refn;	new_op->upcall.req.truncate.size = (__s64) iattr->ia_size;	ret = service_operation(new_op, __func__,				get_interruptible_flag(inode));	/*	 * the truncate has no downcall members to retrieve, but	 * the status value tells us if it went through ok or not	 */	gossip_debug(GOSSIP_INODE_DEBUG,		     "orangefs: orangefs_truncate got return value of %d/n",		     ret);	op_release(new_op);	if (ret != 0)		return ret;	if (orig_size != i_size_read(inode))		iattr->ia_valid |= ATTR_CTIME | ATTR_MTIME;	return ret;}
开发者ID:acton393,项目名称:linux,代码行数:56,


示例4: f2fs_setattr

int f2fs_setattr(struct dentry *dentry, struct iattr *attr){	struct inode *inode = dentry->d_inode;	struct f2fs_inode_info *fi = F2FS_I(inode);	int err;	err = inode_change_ok(inode, attr);	if (err)		return err;	if (attr->ia_valid & ATTR_SIZE) {		if (f2fs_encrypted_inode(inode) &&				f2fs_get_encryption_info(inode))			return -EACCES;		if (attr->ia_size <= i_size_read(inode)) {			truncate_setsize(inode, attr->ia_size);			err = f2fs_truncate(inode, true);			if (err)				return err;			f2fs_balance_fs(F2FS_I_SB(inode));		} else {			/*			 * do not trim all blocks after i_size if target size is			 * larger than i_size.			 */			truncate_setsize(inode, attr->ia_size);		}	}	__setattr_copy(inode, attr);	if (attr->ia_valid & ATTR_MODE) {		err = f2fs_acl_chmod(inode);		if (err || is_inode_flag_set(fi, FI_ACL_MODE)) {			inode->i_mode = fi->i_acl_mode;			clear_inode_flag(fi, FI_ACL_MODE);		}	}	mark_inode_dirty(inode);	return err;}
开发者ID:debbiche,项目名称:android_kernel_huawei_p8,代码行数:43,


示例5: zpl_evict_inode

static voidzpl_evict_inode(struct inode *ip){    fstrans_cookie_t cookie;    cookie = spl_fstrans_mark();    truncate_setsize(ip, 0);    clear_inode(ip);    zfs_inactive(ip);    spl_fstrans_unmark(cookie);}
开发者ID:koplover,项目名称:zfs,代码行数:11,


示例6: v9fs_vfs_setattr_dotl

int v9fs_vfs_setattr_dotl(struct dentry *dentry, struct iattr *iattr){	int retval;	struct v9fs_session_info *v9ses;	struct p9_fid *fid;	struct p9_iattr_dotl p9attr;	P9_DPRINTK(P9_DEBUG_VFS, "/n");	retval = inode_change_ok(dentry->d_inode, iattr);	if (retval)		return retval;	p9attr.valid = iattr->ia_valid;	p9attr.mode = iattr->ia_mode;	p9attr.uid = iattr->ia_uid;	p9attr.gid = iattr->ia_gid;	p9attr.size = iattr->ia_size;	p9attr.atime_sec = iattr->ia_atime.tv_sec;	p9attr.atime_nsec = iattr->ia_atime.tv_nsec;	p9attr.mtime_sec = iattr->ia_mtime.tv_sec;	p9attr.mtime_nsec = iattr->ia_mtime.tv_nsec;	retval = -EPERM;	v9ses = v9fs_dentry2v9ses(dentry);	fid = v9fs_fid_lookup(dentry);	if (IS_ERR(fid))		return PTR_ERR(fid);	/* Write all dirty data */	if (S_ISREG(dentry->d_inode->i_mode))		filemap_write_and_wait(dentry->d_inode->i_mapping);	retval = p9_client_setattr(fid, &p9attr);	if (retval < 0)		return retval;	if ((iattr->ia_valid & ATTR_SIZE) &&	    iattr->ia_size != i_size_read(dentry->d_inode))		truncate_setsize(dentry->d_inode, iattr->ia_size);	v9fs_invalidate_inode_attr(dentry->d_inode);	setattr_copy(dentry->d_inode, iattr);	mark_inode_dirty(dentry->d_inode);	if (iattr->ia_valid & ATTR_MODE) {		/* We also want to update ACL when we update mode bits */		retval = v9fs_acl_chmod(dentry);		if (retval < 0)			return retval;	}	return 0;}
开发者ID:ARMP,项目名称:android_kernel_lge_x3,代码行数:52,


示例7: hmfs_setattr

int hmfs_setattr(struct dentry *dentry, struct iattr *attr){	struct inode *inode = dentry->d_inode;	struct hmfs_inode_info *fi = HMFS_I(inode);	struct posix_acl *acl;	int err = 0, ilock;	struct hmfs_sb_info *sbi = HMFS_I_SB(inode);	err = inode_change_ok(inode, attr);	if (err)		return err;	ilock = mutex_lock_op(sbi);	inode_write_lock(inode);	if ((attr->ia_valid & ATTR_SIZE) && attr->ia_size != i_size_read(inode)) {		truncate_setsize(inode, attr->ia_size);		hmfs_truncate(inode);	}	__setattr_copy(inode, attr);	if (attr->ia_valid & ATTR_MODE) {		acl = hmfs_get_acl(inode, ACL_TYPE_ACCESS);		if (!acl || IS_ERR(acl)) {			err = PTR_ERR(acl);			goto out;		}		err = posix_acl_chmod(&acl, GFP_KERNEL, inode->i_mode);		err = hmfs_set_acl(inode, acl, ACL_TYPE_ACCESS);		if (err || is_inode_flag_set(fi, FI_ACL_MODE)) {			inode->i_mode = fi->i_acl_mode;			clear_inode_flag(fi, FI_ACL_MODE);		}	}out:	inode_write_unlock(inode);	mutex_unlock_op(sbi, ilock);	mark_inode_dirty(inode);	return err;}
开发者ID:timemath,项目名称:hmfs,代码行数:43,


示例8: affs_notify_change

intaffs_notify_change(struct dentry *dentry, struct iattr *attr){	struct inode *inode = d_inode(dentry);	int error;	pr_debug("notify_change(%lu,0x%x)/n", inode->i_ino, attr->ia_valid);	error = setattr_prepare(dentry, attr);	if (error)		goto out;	if (((attr->ia_valid & ATTR_UID) &&	      affs_test_opt(AFFS_SB(inode->i_sb)->s_flags, SF_SETUID)) ||	    ((attr->ia_valid & ATTR_GID) &&	      affs_test_opt(AFFS_SB(inode->i_sb)->s_flags, SF_SETGID)) ||	    ((attr->ia_valid & ATTR_MODE) &&	     (AFFS_SB(inode->i_sb)->s_flags &	      (AFFS_MOUNT_SF_SETMODE | AFFS_MOUNT_SF_IMMUTABLE)))) {		if (!affs_test_opt(AFFS_SB(inode->i_sb)->s_flags, SF_QUIET))			error = -EPERM;		goto out;	}	if ((attr->ia_valid & ATTR_SIZE) &&	    attr->ia_size != i_size_read(inode)) {		error = inode_newsize_ok(inode, attr->ia_size);		if (error)			return error;		truncate_setsize(inode, attr->ia_size);		affs_truncate(inode);	}	setattr_copy(inode, attr);	mark_inode_dirty(inode);	if (attr->ia_valid & ATTR_MODE)		affs_mode_to_prot(inode);out:	return error;}
开发者ID:BWhitten,项目名称:linux-stable,代码行数:42,


示例9: prlfs_inode_setattr

static int prlfs_inode_setattr(struct inode *inode, struct iattr *attr){	int ret = 0;#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,36)	ret = inode_setattr(inode, attr);#else	if ((attr->ia_valid & ATTR_SIZE &&			attr->ia_size != i_size_read(inode))) {		ret = inode_newsize_ok(inode, attr->ia_size);		if (ret)			goto out;		truncate_setsize(inode, attr->ia_size);	}	setattr_copy(inode, attr);	mark_inode_dirty(inode);out:#endif	return ret;}
开发者ID:cdelorme,项目名称:fedora_parallels_tools,代码行数:20,


示例10: f2fs_setattr

int f2fs_setattr(struct dentry *dentry, struct iattr *attr){	struct inode *inode = dentry->d_inode;	struct f2fs_inode_info *fi = F2FS_I(inode);	int err;	err = inode_change_ok(inode, attr);	if (err)		return err;	if (attr->ia_valid & ATTR_SIZE) {		if (f2fs_encrypted_inode(inode) &&				f2fs_get_encryption_info(inode))			return -EACCES;		if (attr->ia_size != i_size_read(inode)) {			truncate_setsize(inode, attr->ia_size);			f2fs_truncate(inode);			f2fs_balance_fs(F2FS_I_SB(inode));		} else {			/*			 * giving a chance to truncate blocks past EOF which			 * are fallocated with FALLOC_FL_KEEP_SIZE.			 */			f2fs_truncate(inode);		}	}	__setattr_copy(inode, attr);	if (attr->ia_valid & ATTR_MODE) {		err = f2fs_acl_chmod(inode);		if (err || is_inode_flag_set(fi, FI_ACL_MODE)) {			inode->i_mode = fi->i_acl_mode;			clear_inode_flag(fi, FI_ACL_MODE);		}	}	mark_inode_dirty(inode);	return err;}
开发者ID:Swapnil133609,项目名称:Zeus_sprout,代码行数:41,


示例11: jfs_setattr

int jfs_setattr(struct dentry *dentry, struct iattr *iattr){	struct inode *inode = d_inode(dentry);	int rc;	rc = setattr_prepare(dentry, iattr);	if (rc)		return rc;	if (is_quota_modification(inode, iattr)) {		rc = dquot_initialize(inode);		if (rc)			return rc;	}	if ((iattr->ia_valid & ATTR_UID && !uid_eq(iattr->ia_uid, inode->i_uid)) ||	    (iattr->ia_valid & ATTR_GID && !gid_eq(iattr->ia_gid, inode->i_gid))) {		rc = dquot_transfer(inode, iattr);		if (rc)			return rc;	}	if ((iattr->ia_valid & ATTR_SIZE) &&	    iattr->ia_size != i_size_read(inode)) {		inode_dio_wait(inode);		rc = inode_newsize_ok(inode, iattr->ia_size);		if (rc)			return rc;		truncate_setsize(inode, iattr->ia_size);		jfs_truncate(inode);	}	setattr_copy(inode, iattr);	mark_inode_dirty(inode);	if (iattr->ia_valid & ATTR_MODE)		rc = posix_acl_chmod(inode, inode->i_mode);	return rc;}
开发者ID:AshishNamdev,项目名称:linux,代码行数:40,


示例12: sysv_setattr

static int sysv_setattr(struct dentry *dentry, struct iattr *attr){	struct inode *inode = dentry->d_inode;	int error;	error = inode_change_ok(inode, attr);	if (error)		return error;	if ((attr->ia_valid & ATTR_SIZE) &&	    attr->ia_size != i_size_read(inode)) {		error = inode_newsize_ok(inode, attr->ia_size);		if (error)			return error;		truncate_setsize(inode, attr->ia_size);		sysv_truncate(inode);	}	setattr_copy(inode, attr);	mark_inode_dirty(inode);	return 0;}
开发者ID:383530895,项目名称:linux,代码行数:22,


示例13: hpfs_setattr

int hpfs_setattr(struct dentry *dentry, struct iattr *attr){	struct inode *inode = d_inode(dentry);	int error = -EINVAL;	hpfs_lock(inode->i_sb);	if (inode->i_ino == hpfs_sb(inode->i_sb)->sb_root)		goto out_unlock;	if ((attr->ia_valid & ATTR_UID) &&	    from_kuid(&init_user_ns, attr->ia_uid) >= 0x10000)		goto out_unlock;	if ((attr->ia_valid & ATTR_GID) &&	    from_kgid(&init_user_ns, attr->ia_gid) >= 0x10000)		goto out_unlock;	if ((attr->ia_valid & ATTR_SIZE) && attr->ia_size > inode->i_size)		goto out_unlock;	error = inode_change_ok(inode, attr);	if (error)		goto out_unlock;	if ((attr->ia_valid & ATTR_SIZE) &&	    attr->ia_size != i_size_read(inode)) {		error = inode_newsize_ok(inode, attr->ia_size);		if (error)			goto out_unlock;		truncate_setsize(inode, attr->ia_size);		hpfs_truncate(inode);	}	setattr_copy(inode, attr);	hpfs_write_inode(inode); out_unlock:	hpfs_unlock(inode->i_sb);	return error;}
开发者ID:020gzh,项目名称:linux,代码行数:39,


示例14: minix_setattr

static int minix_setattr(struct dentry *dentry, struct iattr *attr){	struct inode *inode = d_inode(dentry);	int error;	error = setattr_prepare(dentry, attr);	if (error)		return error;	if ((attr->ia_valid & ATTR_SIZE) &&	    attr->ia_size != i_size_read(inode)) {		error = inode_newsize_ok(inode, attr->ia_size);		if (error)			return error;		truncate_setsize(inode, attr->ia_size);		minix_truncate(inode);	}	setattr_copy(inode, attr);	mark_inode_dirty(inode);	return 0;}
开发者ID:AlexShiLucky,项目名称:linux,代码行数:23,


示例15: nilfs_setattr

int nilfs_setattr(struct dentry *dentry, struct iattr *iattr){	struct nilfs_transaction_info ti;	struct inode *inode = dentry->d_inode;	struct super_block *sb = inode->i_sb;	int err;	err = inode_change_ok(inode, iattr);	if (err)		return err;	err = nilfs_transaction_begin(sb, &ti, 0);	if (unlikely(err))		return err;	if ((iattr->ia_valid & ATTR_SIZE) &&	    iattr->ia_size != i_size_read(inode)) {		inode_dio_wait(inode);		truncate_setsize(inode, iattr->ia_size);		nilfs_truncate(inode);	}	setattr_copy(inode, iattr);	mark_inode_dirty(inode);	if (iattr->ia_valid & ATTR_MODE) {		err = nilfs_acl_chmod(inode);		if (unlikely(err))			goto out_err;	}	return nilfs_transaction_commit(sb);out_err:	nilfs_transaction_abort(sb);	return err;}
开发者ID:battahma,项目名称:cs444,代码行数:37,


示例16: xfs_setattr_size

//.........这里部分代码省略.........	/*	 * We are going to log the inode size change in this transaction so	 * any previous writes that are beyond the on disk EOF and the new	 * EOF that have not been written out need to be written here.  If we	 * do not write the data out, we expose ourselves to the null files	 * problem.	 *	 * Only flush from the on disk size to the smaller of the in memory	 * file size or the new size as that's the range we really care about	 * here and prevents waiting for other data not within the range we	 * care about here.	 */	if (oldsize != ip->i_d.di_size && newsize > ip->i_d.di_size) {		error = -filemap_write_and_wait_range(VFS_I(ip)->i_mapping,						      ip->i_d.di_size, newsize);		if (error)			return error;	}	/*	 * Wait for all direct I/O to complete.	 */	inode_dio_wait(inode);	error = -block_truncate_page(inode->i_mapping, newsize, xfs_get_blocks);	if (error)		return error;	tp = xfs_trans_alloc(mp, XFS_TRANS_SETATTR_SIZE);	error = xfs_trans_reserve(tp, &M_RES(mp)->tr_itruncate, 0, 0);	if (error)		goto out_trans_cancel;	truncate_setsize(inode, newsize);	commit_flags = XFS_TRANS_RELEASE_LOG_RES;	lock_flags |= XFS_ILOCK_EXCL;	xfs_ilock(ip, XFS_ILOCK_EXCL);	xfs_trans_ijoin(tp, ip, 0);	/*	 * Only change the c/mtime if we are changing the size or we are	 * explicitly asked to change it.  This handles the semantic difference	 * between truncate() and ftruncate() as implemented in the VFS.	 *	 * The regular truncate() case without ATTR_CTIME and ATTR_MTIME is a	 * special case where we need to update the times despite not having	 * these flags set.  For all other operations the VFS set these flags	 * explicitly if it wants a timestamp update.	 */	if (newsize != oldsize &&	    !(iattr->ia_valid & (ATTR_CTIME | ATTR_MTIME))) {		iattr->ia_ctime = iattr->ia_mtime =			current_fs_time(inode->i_sb);		iattr->ia_valid |= ATTR_CTIME | ATTR_MTIME;	}	/*	 * The first thing we do is set the size to new_size permanently on	 * disk.  This way we don't have to worry about anyone ever being able	 * to look at the data being freed even in the face of a crash.	 * What we're getting around here is the case where we free a block, it	 * is allocated to another file, it is written to, and then we crash.	 * If the new data gets written to the file but the log buffers
开发者ID:luyanseu,项目名称:linux,代码行数:67,


示例17: jffs2_do_setattr

//.........这里部分代码省略.........			 kfree(mdata);		return ret;	}	mutex_lock(&f->sem);	ivalid = iattr->ia_valid;	ri->magic = cpu_to_je16(JFFS2_MAGIC_BITMASK);	ri->nodetype = cpu_to_je16(JFFS2_NODETYPE_INODE);	ri->totlen = cpu_to_je32(sizeof(*ri) + mdatalen);	ri->hdr_crc = cpu_to_je32(crc32(0, ri, sizeof(struct jffs2_unknown_node)-4));	ri->ino = cpu_to_je32(inode->i_ino);	ri->version = cpu_to_je32(++f->highest_version);	ri->uid = cpu_to_je16((ivalid & ATTR_UID)?		from_kuid(&init_user_ns, iattr->ia_uid):i_uid_read(inode));	ri->gid = cpu_to_je16((ivalid & ATTR_GID)?		from_kgid(&init_user_ns, iattr->ia_gid):i_gid_read(inode));	if (ivalid & ATTR_MODE)		ri->mode = cpu_to_jemode(iattr->ia_mode);	else		ri->mode = cpu_to_jemode(inode->i_mode);	ri->isize = cpu_to_je32((ivalid & ATTR_SIZE)?iattr->ia_size:inode->i_size);	ri->atime = cpu_to_je32(I_SEC((ivalid & ATTR_ATIME)?iattr->ia_atime:inode->i_atime));	ri->mtime = cpu_to_je32(I_SEC((ivalid & ATTR_MTIME)?iattr->ia_mtime:inode->i_mtime));	ri->ctime = cpu_to_je32(I_SEC((ivalid & ATTR_CTIME)?iattr->ia_ctime:inode->i_ctime));	ri->offset = cpu_to_je32(0);	ri->csize = ri->dsize = cpu_to_je32(mdatalen);	ri->compr = JFFS2_COMPR_NONE;	if (ivalid & ATTR_SIZE && inode->i_size < iattr->ia_size) {		/* It's an extension. Make it a hole node */		ri->compr = JFFS2_COMPR_ZERO;		ri->dsize = cpu_to_je32(iattr->ia_size - inode->i_size);		ri->offset = cpu_to_je32(inode->i_size);	} else if (ivalid & ATTR_SIZE && !iattr->ia_size) {		/* For truncate-to-zero, treat it as deletion because		   it'll always be obsoleting all previous nodes */		alloc_type = ALLOC_DELETION;	}	ri->node_crc = cpu_to_je32(crc32(0, ri, sizeof(*ri)-8));	if (mdatalen)		ri->data_crc = cpu_to_je32(crc32(0, mdata, mdatalen));	else		ri->data_crc = cpu_to_je32(0);	new_metadata = jffs2_write_dnode(c, f, ri, mdata, mdatalen, alloc_type);	if (S_ISLNK(inode->i_mode))		kfree(mdata);	if (IS_ERR(new_metadata)) {		jffs2_complete_reservation(c);		jffs2_free_raw_inode(ri);		mutex_unlock(&f->sem);		return PTR_ERR(new_metadata);	}	/* It worked. Update the inode */	inode->i_atime = ITIME(je32_to_cpu(ri->atime));	inode->i_ctime = ITIME(je32_to_cpu(ri->ctime));	inode->i_mtime = ITIME(je32_to_cpu(ri->mtime));	inode->i_mode = jemode_to_cpu(ri->mode);	i_uid_write(inode, je16_to_cpu(ri->uid));	i_gid_write(inode, je16_to_cpu(ri->gid));	old_metadata = f->metadata;	if (ivalid & ATTR_SIZE && inode->i_size > iattr->ia_size)		jffs2_truncate_fragtree (c, &f->fragtree, iattr->ia_size);	if (ivalid & ATTR_SIZE && inode->i_size < iattr->ia_size) {		jffs2_add_full_dnode_to_inode(c, f, new_metadata);		inode->i_size = iattr->ia_size;		f->metadata = NULL;	} else {		f->metadata = new_metadata;	}	if (old_metadata) {		jffs2_mark_node_obsolete(c, old_metadata->raw);		jffs2_free_full_dnode(old_metadata);	}	jffs2_free_raw_inode(ri);	mutex_unlock(&f->sem);	jffs2_complete_reservation(c);	/* We have to do the truncate_setsize() without f->sem held, since	   some pages may be locked and waiting for it in readpage().	   We are protected from a simultaneous write() extending i_size	   back past iattr->ia_size, because do_truncate() holds the	   generic inode semaphore. */	if (ivalid & ATTR_SIZE && inode->i_size > iattr->ia_size) {		truncate_setsize(inode, iattr->ia_size);	}		return 0;}
开发者ID:coredmp95,项目名称:rtems-raspberry,代码行数:101,


示例18: unionfs_setattr

//.........这里部分代码省略.........	/* copyup if the file is on a read only branch */	if (is_robranch_super(dentry->d_sb, bstart)	    || __is_rdonly(lower_inode)) {		/* check if we have a branch to copy up to */		if (bstart <= 0) {			err = -EACCES;			goto out;		}		if (ia->ia_valid & ATTR_SIZE)			size = ia->ia_size;		else			size = i_size_read(inode);		/* copyup to next available branch */		for (bindex = bstart - 1; bindex >= 0; bindex--) {			err = copyup_dentry(parent->d_inode,					    dentry, bstart, bindex,					    dentry->d_name.name,					    dentry->d_name.len,					    NULL, size);			if (!err)				break;		}		if (err)			goto out;		/* get updated lower_dentry/inode after copyup */		lower_dentry = unionfs_lower_dentry(dentry);		lower_inode = unionfs_lower_inode(inode);		/*		 * check for whiteouts in writeable branch, and remove them		 * if necessary.		 */		if (lower_dentry) {			err = check_unlink_whiteout(dentry, lower_dentry,						    bindex);			if (err > 0) /* ignore if whiteout found and removed */				err = 0;		}	}	/*	 * If shrinking, first truncate upper level to cancel writing dirty	 * pages beyond the new eof; and also if its' maxbytes is more	 * limiting (fail with -EFBIG before making any change to the lower	 * level).  There is no need to vmtruncate the upper level	 * afterwards in the other cases: we fsstack_copy_inode_size from	 * the lower level.	 */	if (ia->ia_valid & ATTR_SIZE) {		err = inode_newsize_ok(inode, ia->ia_size);		if (err)			goto out;		truncate_setsize(inode, ia->ia_size);	}	/* notify the (possibly copied-up) lower inode */	/*	 * Note: we use lower_dentry->d_inode, because lower_inode may be	 * unlinked (no inode->i_sb and i_ino==0.  This happens if someone	 * tries to open(), unlink(), then ftruncate() a file.	 */	/* prepare our own lower struct iattr (with our own lower file) */	memcpy(&lower_ia, ia, sizeof(lower_ia));	if (ia->ia_valid & ATTR_FILE) {		lower_ia.ia_file = unionfs_lower_file(ia->ia_file);		BUG_ON(!lower_ia.ia_file); // XXX?	}	mutex_lock(&lower_dentry->d_inode->i_mutex);	err = notify_change(lower_dentry, &lower_ia);	mutex_unlock(&lower_dentry->d_inode->i_mutex);	if (err)		goto out;	/* get attributes from the first lower inode */	if (ibstart(inode) >= 0)		unionfs_copy_attr_all(inode, lower_inode);	/*	 * unionfs_copy_attr_all will copy the lower times to our inode if	 * the lower ones are newer (useful for cache coherency).  However,	 * ->setattr is the only place in which we may have to copy the	 * lower inode times absolutely, to support utimes(2).	 */	if (ia->ia_valid & ATTR_MTIME_SET)		inode->i_mtime = lower_inode->i_mtime;	if (ia->ia_valid & ATTR_CTIME)		inode->i_ctime = lower_inode->i_ctime;	if (ia->ia_valid & ATTR_ATIME_SET)		inode->i_atime = lower_inode->i_atime;	fsstack_copy_inode_size(inode, lower_inode);out:	if (!err)		unionfs_check_dentry(dentry);	unionfs_unlock_dentry(dentry);	unionfs_unlock_parent(dentry, parent);	unionfs_read_unlock(dentry->d_sb);out_err:	return err;}
开发者ID:rhamilton1415,项目名称:steamlink-sdk,代码行数:101,


示例19: diaryfs_setattr

static int diaryfs_setattr(struct dentry * dentry, struct iattr * attr) {	int err;	struct dentry * lower_dentry;	struct inode * inode;	struct inode * lower_inode; 	struct path lower_path; 	struct iattr lower_attr;	inode = dentry->d_inode;	/*	 * Check if the user has permission to change the inode. 	 * No check if this user can change the lower inode, that should	 * happen when calling notify_change on the lower node	 */	err = inode_change_ok(inode, attr);	if (err) 		goto out_err;	diaryfs_get_lower_path(dentry, &lower_path);	lower_dentry = lower_path.dentry;	lower_inode = diaryfs_lower_inode(inode); 	/* prepare the lower struct iattr with the lower file */	memcpy(&lower_attr, attr, sizeof(lower_attr));	if (attr->ia_valid & ATTR_FILE) 		lower_attr.ia_file = diaryfs_lower_file(attr->ia_file);	/*	 * If shrinking, first truncate upper level to cancel writing dirty	 * pages beyond the new eof. Also, if its maxbytes is more	 * limiting. There is no need to vmtruncate the upper level	 * afterwards in the other cases	 */	if (attr->ia_valid & ATTR_SIZE) {		err = inode_newsize_ok(inode, attr->ia_size);		if (err)			goto out;		truncate_setsize(inode, attr->ia_size);	}	/*	 * Mode changes for clearing setuid/setgid bits. Allow lower fs	 * to interpret this in its own way.	 */	if (lower_attr.ia_valid & (ATTR_KILL_SUID | ATTR_KILL_SGID))		lower_attr.ia_valid &= ~ATTR_MODE;	/*	 * Notify the lower inode	 * We used d_inode(lower_dentry) because lower_inode may be unlinked	 */	mutex_lock(&lower_dentry->d_inode->i_mutex);	err = notify_change(lower_dentry, &lower_attr, NULL);	mutex_unlock(&lower_dentry->d_inode->i_mutex);	if (err)		goto out;	/* get attrs from the lower inode */	fsstack_copy_attr_all(inode, lower_inode);out:	diaryfs_put_lower_path(dentry, &lower_path);out_err:	return err;}
开发者ID:jameswhang,项目名称:DiaryFS,代码行数:69,


示例20: ncp_notify_change

//.........这里部分代码省略.........                	info.attributes &= ~(aRONLY|aRENAMEINHIBIT|aDELETEINHIBIT);                else			info.attributes |=  (aRONLY|aRENAMEINHIBIT|aDELETEINHIBIT);#ifdef CONFIG_NCPFS_NFS_NS		if (ncp_is_nfs_extras(server, NCP_FINFO(inode)->volNumber)) {			result = ncp_modify_nfs_info(server,						     NCP_FINFO(inode)->volNumber,						     NCP_FINFO(inode)->dirEntNum,						     attr->ia_mode, 0);			if (result != 0)				goto out;			info.attributes &= ~(aSHARED | aSYSTEM);			{				/* mark partial success */				struct iattr tmpattr;								tmpattr.ia_valid = ATTR_MODE;				tmpattr.ia_mode = attr->ia_mode;				setattr_copy(inode, &tmpattr);				mark_inode_dirty(inode);			}		}#endif        }#endif	/* Do SIZE before attributes, otherwise mtime together with size does not work...	 */	if ((attr->ia_valid & ATTR_SIZE) != 0) {		int written;		ncp_dbg(1, "trying to change size to %llu/n", attr->ia_size);		if ((result = ncp_make_open(inode, O_WRONLY)) < 0) {			result = -EACCES;			goto out;		}		ncp_write_kernel(NCP_SERVER(inode), NCP_FINFO(inode)->file_handle,			  attr->ia_size, 0, "", &written);		/* According to ndir, the changes only take effect after		   closing the file */		ncp_inode_close(inode);		result = ncp_make_closed(inode);		if (result)			goto out;		if (attr->ia_size != i_size_read(inode)) {			truncate_setsize(inode, attr->ia_size);			mark_inode_dirty(inode);		}	}	if ((attr->ia_valid & ATTR_CTIME) != 0) {		info_mask |= (DM_CREATE_TIME | DM_CREATE_DATE);		ncp_date_unix2dos(attr->ia_ctime.tv_sec,			     &info.creationTime, &info.creationDate);	}	if ((attr->ia_valid & ATTR_MTIME) != 0) {		info_mask |= (DM_MODIFY_TIME | DM_MODIFY_DATE);		ncp_date_unix2dos(attr->ia_mtime.tv_sec,				  &info.modifyTime, &info.modifyDate);	}	if ((attr->ia_valid & ATTR_ATIME) != 0) {		__le16 dummy;		info_mask |= (DM_LAST_ACCESS_DATE);		ncp_date_unix2dos(attr->ia_atime.tv_sec,				  &dummy, &info.lastAccessDate);	}	if (info_mask != 0) {		result = ncp_modify_file_or_subdir_dos_info(NCP_SERVER(inode),				      inode, info_mask, &info);		if (result != 0) {			if (info_mask == (DM_CREATE_TIME | DM_CREATE_DATE)) {				/* NetWare seems not to allow this. I				   do not know why. So, just tell the				   user everything went fine. This is				   a terrible hack, but I do not know				   how to do this correctly. */				result = 0;			} else				goto out;		}#ifdef CONFIG_NCPFS_STRONG				if ((!result) && (info_mask & DM_ATTRIBUTES))			NCP_FINFO(inode)->nwattr = info.attributes;#endif	}	if (result)		goto out;	setattr_copy(inode, attr);	mark_inode_dirty(inode);out:	if (result > 0)		result = -EACCES;	return result;}
开发者ID:020gzh,项目名称:linux,代码行数:101,


示例21: xfs_setattr_size

intxfs_setattr_size(	struct xfs_inode	*ip,	struct iattr		*iattr,	int			flags){	struct xfs_mount	*mp = ip->i_mount;	struct inode		*inode = VFS_I(ip);	int			mask = iattr->ia_valid;	xfs_off_t		oldsize, newsize;	struct xfs_trans	*tp;	int			error;	uint			lock_flags;	uint			commit_flags = 0;	trace_xfs_setattr(ip);	if (mp->m_flags & XFS_MOUNT_RDONLY)		return XFS_ERROR(EROFS);	if (XFS_FORCED_SHUTDOWN(mp))		return XFS_ERROR(EIO);	error = -inode_change_ok(inode, iattr);	if (error)		return XFS_ERROR(error);	ASSERT(S_ISREG(ip->i_d.di_mode));	ASSERT((mask & (ATTR_MODE|ATTR_UID|ATTR_GID|ATTR_ATIME|ATTR_ATIME_SET|			ATTR_MTIME_SET|ATTR_KILL_SUID|ATTR_KILL_SGID|			ATTR_KILL_PRIV|ATTR_TIMES_SET)) == 0);	lock_flags = XFS_ILOCK_EXCL;	if (!(flags & XFS_ATTR_NOLOCK))		lock_flags |= XFS_IOLOCK_EXCL;	xfs_ilock(ip, lock_flags);	oldsize = inode->i_size;	newsize = iattr->ia_size;	if (newsize == 0 && oldsize == 0 && ip->i_d.di_nextents == 0) {		if (!(mask & (ATTR_CTIME|ATTR_MTIME)))			goto out_unlock;		xfs_iunlock(ip, lock_flags);		iattr->ia_valid &= ~ATTR_SIZE;		return xfs_setattr_nonsize(ip, iattr, 0);	}	error = xfs_qm_dqattach_locked(ip, 0);	if (error)		goto out_unlock;	if (newsize > oldsize) {		error = xfs_zero_eof(ip, newsize, oldsize);		if (error)			goto out_unlock;	}	xfs_iunlock(ip, XFS_ILOCK_EXCL);	lock_flags &= ~XFS_ILOCK_EXCL;	/*	 * We are going to log the inode size change in this transaction so	 * any previous writes that are beyond the on disk EOF and the new	 * EOF that have not been written out need to be written here.  If we	 * do not write the data out, we expose ourselves to the null files	 * problem.	 *	 * Only flush from the on disk size to the smaller of the in memory	 * file size or the new size as that's the range we really care about	 * here and prevents waiting for other data not within the range we	 * care about here.	 */	if (oldsize != ip->i_d.di_size && newsize > ip->i_d.di_size) {		error = xfs_flush_pages(ip, ip->i_d.di_size, newsize, 0,					FI_NONE);		if (error)			goto out_unlock;	}	inode_dio_wait(inode);	error = -block_truncate_page(inode->i_mapping, newsize, xfs_get_blocks);	if (error)		goto out_unlock;	tp = xfs_trans_alloc(mp, XFS_TRANS_SETATTR_SIZE);	error = xfs_trans_reserve(tp, 0, XFS_ITRUNCATE_LOG_RES(mp), 0,				 XFS_TRANS_PERM_LOG_RES,				 XFS_ITRUNCATE_LOG_COUNT);	if (error)		goto out_trans_cancel;	truncate_setsize(inode, newsize);	commit_flags = XFS_TRANS_RELEASE_LOG_RES;	lock_flags |= XFS_ILOCK_EXCL;	xfs_ilock(ip, XFS_ILOCK_EXCL);//.........这里部分代码省略.........
开发者ID:MiniBlu,项目名称:cm11_kernel_htc_msm8974a3ul,代码行数:101,


示例22: wrapfs_setattr

static int wrapfs_setattr(struct dentry *dentry, struct iattr *ia){	int err = 0;	struct dentry *lower_dentry;	struct inode *inode;	struct inode *lower_inode;	struct path lower_path;	struct iattr lower_ia;	inode = dentry->d_inode;	/*	 * Check if user has permission to change inode.  We don't check if	 * this user can change the lower inode: that should happen when	 * calling notify_change on the lower inode.	 */	err = inode_change_ok(inode, ia);	if (err)		goto out_err;	wrapfs_get_lower_path(dentry, &lower_path);	lower_dentry = lower_path.dentry;	lower_inode = wrapfs_lower_inode(inode);	/* prepare our own lower struct iattr (with the lower file) */	memcpy(&lower_ia, ia, sizeof(lower_ia));	if (ia->ia_valid & ATTR_FILE)		lower_ia.ia_file = wrapfs_lower_file(ia->ia_file);	/*	 * If shrinking, first truncate upper level to cancel writing dirty	 * pages beyond the new eof; and also if its' maxbytes is more	 * limiting (fail with -EFBIG before making any change to the lower	 * level).  There is no need to vmtruncate the upper level	 * afterwards in the other cases: we fsstack_copy_inode_size from	 * the lower level.	 */	if (ia->ia_valid & ATTR_SIZE) {		err = inode_newsize_ok(inode, ia->ia_size);		if (err)			goto out;		truncate_setsize(inode, ia->ia_size);	}	/*	 * mode change is for clearing setuid/setgid bits. Allow lower fs	 * to interpret this in its own way.	 */	if (lower_ia.ia_valid & (ATTR_KILL_SUID | ATTR_KILL_SGID))		lower_ia.ia_valid &= ~ATTR_MODE;	/* notify the (possibly copied-up) lower inode */	/*	 * Note: we use lower_dentry->d_inode, because lower_inode may be	 * unlinked (no inode->i_sb and i_ino==0.  This happens if someone	 * tries to open(), unlink(), then ftruncate() a file.	 */	mutex_lock(&lower_dentry->d_inode->i_mutex);	err = notify_change(lower_dentry, &lower_ia); /* note: lower_ia */	mutex_unlock(&lower_dentry->d_inode->i_mutex);	if (err)		goto out;	/* get attributes from the lower inode */	fsstack_copy_attr_all(inode, lower_inode);	/*	 * Not running fsstack_copy_inode_size(inode, lower_inode), because	 * VFS should update our inode size, and notify_change on	 * lower_inode should update its size.	 */out:	wrapfs_put_lower_path(dentry, &lower_path);out_err:	return err;}
开发者ID:abhishekShukla,项目名称:Linux-Stackable-File-System-,代码行数:76,


示例23: zpl_inode_delete

static voidzpl_inode_delete(struct inode *ip){	truncate_setsize(ip, 0);	clear_inode(ip);}
开发者ID:ColdCanuck,项目名称:zfs,代码行数:6,


示例24: xfs_setattr_size

//.........这里部分代码省略.........	 * EOF that have not been written out need to be written here.  If we	 * do not write the data out, we expose ourselves to the null files	 * problem.	 *	 * Only flush from the on disk size to the smaller of the in memory	 * file size or the new size as that's the range we really care about	 * here and prevents waiting for other data not within the range we	 * care about here.	 */	if (ip->i_size != ip->i_d.di_size && iattr->ia_size > ip->i_d.di_size) {		error = xfs_flush_pages(ip, ip->i_d.di_size, iattr->ia_size,					XBF_ASYNC, FI_NONE);		if (error)			goto out_unlock;	}	/*	 * Wait for all I/O to complete.	 */	xfs_ioend_wait(ip);	error = -block_truncate_page(inode->i_mapping, iattr->ia_size,				     xfs_get_blocks);	if (error)		goto out_unlock;	tp = xfs_trans_alloc(mp, XFS_TRANS_SETATTR_SIZE);	error = xfs_trans_reserve(tp, 0, XFS_ITRUNCATE_LOG_RES(mp), 0,				 XFS_TRANS_PERM_LOG_RES,				 XFS_ITRUNCATE_LOG_COUNT);	if (error)		goto out_trans_cancel;	truncate_setsize(inode, iattr->ia_size);	commit_flags = XFS_TRANS_RELEASE_LOG_RES;	lock_flags |= XFS_ILOCK_EXCL;	xfs_ilock(ip, XFS_ILOCK_EXCL);	xfs_trans_ijoin(tp, ip);	/*	 * Only change the c/mtime if we are changing the size or we are	 * explicitly asked to change it.  This handles the semantic difference	 * between truncate() and ftruncate() as implemented in the VFS.	 *	 * The regular truncate() case without ATTR_CTIME and ATTR_MTIME is a	 * special case where we need to update the times despite not having	 * these flags set.  For all other operations the VFS set these flags	 * explicitly if it wants a timestamp update.	 */	if (iattr->ia_size != ip->i_size &&	    (!(mask & (ATTR_CTIME | ATTR_MTIME)))) {		iattr->ia_ctime = iattr->ia_mtime =			current_fs_time(inode->i_sb);		mask |= ATTR_CTIME | ATTR_MTIME;	}	if (iattr->ia_size > ip->i_size) {		ip->i_d.di_size = iattr->ia_size;		ip->i_size = iattr->ia_size;	} else if (iattr->ia_size <= ip->i_size ||		   (iattr->ia_size == 0 && ip->i_d.di_nextents)) {		error = xfs_itruncate_data(&tp, ip, iattr->ia_size);		if (error)
开发者ID:AndroidDeveloperAlliance,项目名称:ZenKernel_Grouper,代码行数:67,


示例25: gfs2_write_begin

static int gfs2_write_begin(struct file *file, struct address_space *mapping,			    loff_t pos, unsigned len, unsigned flags,			    struct page **pagep, void **fsdata){	struct gfs2_inode *ip = GFS2_I(mapping->host);	struct gfs2_sbd *sdp = GFS2_SB(mapping->host);	struct gfs2_inode *m_ip = GFS2_I(sdp->sd_statfs_inode);	unsigned int data_blocks = 0, ind_blocks = 0, rblocks;	int alloc_required;	int error = 0;	struct gfs2_alloc *al;	pgoff_t index = pos >> PAGE_CACHE_SHIFT;	unsigned from = pos & (PAGE_CACHE_SIZE - 1);	unsigned to = from + len;	struct page *page;	gfs2_holder_init(ip->i_gl, LM_ST_EXCLUSIVE, 0, &ip->i_gh);	error = gfs2_glock_nq(&ip->i_gh);	if (unlikely(error))		goto out_uninit;	if (&ip->i_inode == sdp->sd_rindex) {		error = gfs2_glock_nq_init(m_ip->i_gl, LM_ST_EXCLUSIVE,					   GL_NOCACHE, &m_ip->i_gh);		if (unlikely(error)) {			gfs2_glock_dq(&ip->i_gh);			goto out_uninit;		}	}	alloc_required = gfs2_write_alloc_required(ip, pos, len);	if (alloc_required || gfs2_is_jdata(ip))		gfs2_write_calc_reserv(ip, len, &data_blocks, &ind_blocks);	if (alloc_required) {		al = gfs2_alloc_get(ip);		if (!al) {			error = -ENOMEM;			goto out_unlock;		}		error = gfs2_quota_lock_check(ip);		if (error)			goto out_alloc_put;		al->al_requested = data_blocks + ind_blocks;		error = gfs2_inplace_reserve(ip);		if (error)			goto out_qunlock;	}	rblocks = RES_DINODE + ind_blocks;	if (gfs2_is_jdata(ip))		rblocks += data_blocks ? data_blocks : 1;	if (ind_blocks || data_blocks)		rblocks += RES_STATFS + RES_QUOTA;	if (&ip->i_inode == sdp->sd_rindex)		rblocks += 2 * RES_STATFS;	error = gfs2_trans_begin(sdp, rblocks,				 PAGE_CACHE_SIZE/sdp->sd_sb.sb_bsize);	if (error)		goto out_trans_fail;	error = -ENOMEM;	flags |= AOP_FLAG_NOFS;	page = grab_cache_page_write_begin(mapping, index, flags);	*pagep = page;	if (unlikely(!page))		goto out_endtrans;	if (gfs2_is_stuffed(ip)) {		error = 0;		if (pos + len > sdp->sd_sb.sb_bsize - sizeof(struct gfs2_dinode)) {			error = gfs2_unstuff_dinode(ip, page);			if (error == 0)				goto prepare_write;		} else if (!PageUptodate(page)) {			error = stuffed_readpage(ip, page);		}		goto out;	}prepare_write:	error = block_prepare_write(page, from, to, gfs2_block_map);out:	if (error == 0)		return 0;	page_cache_release(page);	/*	 * XXX(truncate): the call below should probably be replaced with	 * a call to the gfs2-specific truncate blocks helper to actually	 * release disk blocks..	 */	if (pos + len > ip->i_inode.i_size)		truncate_setsize(&ip->i_inode, ip->i_inode.i_size);out_endtrans:	gfs2_trans_end(sdp);//.........这里部分代码省略.........
开发者ID:AdiPat,项目名称:android_kernel_tegra_n1,代码行数:101,


示例26: xfs_setattr_size

//.........这里部分代码省略.........	/*	 * We are going to log the inode size change in this transaction so	 * any previous writes that are beyond the on disk EOF and the new	 * EOF that have not been written out need to be written here.  If we	 * do not write the data out, we expose ourselves to the null files	 * problem. Note that this includes any block zeroing we did above;	 * otherwise those blocks may not be zeroed after a crash.	 */	if (did_zeroing ||	    (newsize > ip->i_d.di_size && oldsize != ip->i_d.di_size)) {		error = filemap_write_and_wait_range(VFS_I(ip)->i_mapping,						      ip->i_d.di_size, newsize);		if (error)			return error;	}	/*	 * We've already locked out new page faults, so now we can safely remove	 * pages from the page cache knowing they won't get refaulted until we	 * drop the XFS_MMAP_EXCL lock after the extent manipulations are	 * complete. The truncate_setsize() call also cleans partial EOF page	 * PTEs on extending truncates and hence ensures sub-page block size	 * filesystems are correctly handled, too.	 *	 * We have to do all the page cache truncate work outside the	 * transaction context as the "lock" order is page lock->log space	 * reservation as defined by extent allocation in the writeback path.	 * Hence a truncate can fail with ENOMEM from xfs_trans_alloc(), but	 * having already truncated the in-memory version of the file (i.e. made	 * user visible changes). There's not much we can do about this, except	 * to hope that the caller sees ENOMEM and retries the truncate	 * operation.	 */	truncate_setsize(inode, newsize);	error = xfs_trans_alloc(mp, &M_RES(mp)->tr_itruncate, 0, 0, 0, &tp);	if (error)		return error;	lock_flags |= XFS_ILOCK_EXCL;	xfs_ilock(ip, XFS_ILOCK_EXCL);	xfs_trans_ijoin(tp, ip, 0);	/*	 * Only change the c/mtime if we are changing the size or we are	 * explicitly asked to change it.  This handles the semantic difference	 * between truncate() and ftruncate() as implemented in the VFS.	 *	 * The regular truncate() case without ATTR_CTIME and ATTR_MTIME is a	 * special case where we need to update the times despite not having	 * these flags set.  For all other operations the VFS set these flags	 * explicitly if it wants a timestamp update.	 */	if (newsize != oldsize &&	    !(iattr->ia_valid & (ATTR_CTIME | ATTR_MTIME))) {		iattr->ia_ctime = iattr->ia_mtime =			current_fs_time(inode->i_sb);		iattr->ia_valid |= ATTR_CTIME | ATTR_MTIME;	}	/*	 * The first thing we do is set the size to new_size permanently on	 * disk.  This way we don't have to worry about anyone ever being able	 * to look at the data being freed even in the face of a crash.	 * What we're getting around here is the case where we free a block, it	 * is allocated to another file, it is written to, and then we crash.
开发者ID:gxt,项目名称:linux,代码行数:67,


示例27: sdcardfs_setattr

static int sdcardfs_setattr(struct dentry *dentry, struct iattr *ia){	int err = 0;	struct dentry *lower_dentry;	struct inode *inode;	struct inode *lower_inode;	struct path lower_path;	struct iattr lower_ia;	struct sdcardfs_sb_info *sbi = SDCARDFS_SB(dentry->d_sb);	struct dentry *parent;	int has_rw;	inode = dentry->d_inode;	/*	 * Check if user has permission to change inode.  We don't check if	 * this user can change the lower inode: that should happen when	 * calling notify_change on the lower inode.	 */	err = inode_change_ok(inode, ia);	/* no vfs_XXX operations required, cred overriding will be skipped. wj*/	if (!err) {		/* check the Android group ID */		has_rw = get_caller_has_rw_locked(sbi->pkgl_id, sbi->options.derive);		parent = dget_parent(dentry);		if(!check_caller_access_to_name(parent->d_inode, dentry->d_name.name,						sbi->options.derive, 1, has_rw))			err = -EACCES;		dput(parent);	} 	if (err)		goto out_err;	sdcardfs_get_lower_path(dentry, &lower_path);	lower_dentry = lower_path.dentry;	lower_inode = sdcardfs_lower_inode(inode);	/* prepare our own lower struct iattr (with the lower file) */	memcpy(&lower_ia, ia, sizeof(lower_ia));	if (ia->ia_valid & ATTR_FILE)		lower_ia.ia_file = sdcardfs_lower_file(ia->ia_file);	lower_ia.ia_valid &= ~(ATTR_UID | ATTR_GID | ATTR_MODE);	/*	 * If shrinking, first truncate upper level to cancel writing dirty	 * pages beyond the new eof; and also if its' maxbytes is more	 * limiting (fail with -EFBIG before making any change to the lower	 * level).  There is no need to vmtruncate the upper level	 * afterwards in the other cases: we fsstack_copy_inode_size from	 * the lower level.	 */	down_write(&current->mm->mmap_sem);	if (ia->ia_valid & ATTR_SIZE) {		err = inode_newsize_ok(inode, ia->ia_size);		if (err) {			up_write(&current->mm->mmap_sem);			goto out;		}		truncate_setsize(inode, ia->ia_size);	}	/*	 * mode change is for clearing setuid/setgid bits. Allow lower fs	 * to interpret this in its own way.	 */	if (lower_ia.ia_valid & (ATTR_KILL_SUID | ATTR_KILL_SGID))		lower_ia.ia_valid &= ~ATTR_MODE;	/* notify the (possibly copied-up) lower inode */	/*	 * Note: we use lower_dentry->d_inode, because lower_inode may be	 * unlinked (no inode->i_sb and i_ino==0.  This happens if someone	 * tries to open(), unlink(), then ftruncate() a file.	 */	mutex_lock(&lower_dentry->d_inode->i_mutex);	err = notify_change(lower_dentry, &lower_ia); /* note: lower_ia */	mutex_unlock(&lower_dentry->d_inode->i_mutex);	up_write(&current->mm->mmap_sem);	if (err)		goto out;	/* get attributes from the lower inode */	fsstack_copy_attr_all(inode, lower_inode);	/* update derived permission of the upper inode */	fix_derived_permission(inode);		/*	 * Not running fsstack_copy_inode_size(inode, lower_inode), because	 * VFS should update our inode size, and notify_change on	 * lower_inode should update its size.	 */out:	sdcardfs_put_lower_path(dentry, &lower_path);out_err:	return err;}
开发者ID:munjeni,项目名称:ntfs_android,代码行数:100,



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


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