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

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

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

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

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

示例1: ext2_inode_by_name

//.........这里部分代码省略.........		goto out;	dquot_initialize(dir);	inode = ext2_new_inode (dir, S_IFLNK | S_IRWXUGO);	err = PTR_ERR(inode);	if (IS_ERR(inode))		goto out;	if (l > sizeof (EXT2_I(inode)->i_data)) {		/* slow symlink */		inode->i_op = &ext2_symlink_inode_operations;		if (test_opt(inode->i_sb, NOBH))			inode->i_mapping->a_ops = &ext2_nobh_aops;		else			inode->i_mapping->a_ops = &ext2_aops;		err = page_symlink(inode, symname, l);		if (err)			goto out_fail;	} else {		/* fast symlink */		inode->i_op = &ext2_fast_symlink_inode_operations;		memcpy((char*)(EXT2_I(inode)->i_data),symname,l);		inode->i_size = l-1;	}	mark_inode_dirty(inode);	err = ext2_add_nondir(dentry, inode);out:	return err;out_fail:	inode_dec_link_count(inode);	unlock_new_inode(inode);	iput (inode);	goto out;}static int ext2_link (struct dentry * old_dentry, struct inode * dir,	struct dentry *dentry){	struct inode *inode = old_dentry->d_inode;	int err;	if (inode->i_nlink >= EXT2_LINK_MAX)		return -EMLINK;	dquot_initialize(dir);	inode->i_ctime = CURRENT_TIME_SEC;	inode_inc_link_count(inode);	ihold(inode);	err = ext2_add_link(dentry, inode);	if (!err) {		d_instantiate(dentry, inode);		return 0;	}	inode_dec_link_count(inode);	iput(inode);	return err;}static int ext2_mkdir(struct inode * dir, struct dentry * dentry, int mode){	struct inode * inode;
开发者ID:Ale1ster,项目名称:kerneldir,代码行数:67,


示例2: iget_locked

struct inode *bfs_iget(struct super_block *sb, unsigned long ino){	struct bfs_inode *di;	struct inode *inode;	struct buffer_head *bh;	int block, off;	inode = iget_locked(sb, ino);	if (!inode)		return ERR_PTR(-ENOMEM);	if (!(inode->i_state & I_NEW))		return inode;	if ((ino < BFS_ROOT_INO) || (ino > BFS_SB(inode->i_sb)->si_lasti)) {		printf("Bad inode number %s:%08lx/n", inode->i_sb->s_id, ino);		goto error;	}	block = (ino - BFS_ROOT_INO) / BFS_INODES_PER_BLOCK + 1;	bh = sb_bread(inode->i_sb, block);	if (!bh) {		printf("Unable to read inode %s:%08lx/n", inode->i_sb->s_id,									ino);		goto error;	}	off = (ino - BFS_ROOT_INO) % BFS_INODES_PER_BLOCK;	di = (struct bfs_inode *)bh->b_data + off;	inode->i_mode = 0x0000FFFF & le32_to_cpu(di->i_mode);	if (le32_to_cpu(di->i_vtype) == BFS_VDIR) {		inode->i_mode |= S_IFDIR;		inode->i_op = &bfs_dir_inops;		inode->i_fop = &bfs_dir_operations;	} else if (le32_to_cpu(di->i_vtype) == BFS_VREG) {		inode->i_mode |= S_IFREG;		inode->i_op = &bfs_file_inops;		inode->i_fop = &bfs_file_operations;		inode->i_mapping->a_ops = &bfs_aops;	}	BFS_I(inode)->i_sblock =  le32_to_cpu(di->i_sblock);	BFS_I(inode)->i_eblock =  le32_to_cpu(di->i_eblock);	BFS_I(inode)->i_dsk_ino = le16_to_cpu(di->i_ino);	i_uid_write(inode, le32_to_cpu(di->i_uid));	i_gid_write(inode,  le32_to_cpu(di->i_gid));	set_nlink(inode, le32_to_cpu(di->i_nlink));	inode->i_size = BFS_FILESIZE(di);	inode->i_blocks = BFS_FILEBLOCKS(di);	inode->i_atime.tv_sec =  le32_to_cpu(di->i_atime);	inode->i_mtime.tv_sec =  le32_to_cpu(di->i_mtime);	inode->i_ctime.tv_sec =  le32_to_cpu(di->i_ctime);	inode->i_atime.tv_nsec = 0;	inode->i_mtime.tv_nsec = 0;	inode->i_ctime.tv_nsec = 0;	brelse(bh);	unlock_new_inode(inode);	return inode;error:	iget_failed(inode);	return ERR_PTR(-EIO);}
开发者ID:Lyude,项目名称:linux,代码行数:64,


示例3: BEFS_SB

//.........这里部分代码省略.........	}	raw_inode = (befs_inode *) bh->b_data;	befs_dump_inode(sb, raw_inode);	if (befs_check_inode(sb, raw_inode, inode->i_ino) != BEFS_OK) {		befs_error(sb, "Bad inode: %lu", inode->i_ino);		goto unacquire_bh;	}	inode->i_mode = (umode_t) fs32_to_cpu(sb, raw_inode->mode);	/*	 * set uid and gid.  But since current BeOS is single user OS, so	 * you can change by "uid" or "gid" options.	 */	inode->i_uid = befs_sb->mount_opts.use_uid ?		befs_sb->mount_opts.uid :		make_kuid(&init_user_ns, fs32_to_cpu(sb, raw_inode->uid));	inode->i_gid = befs_sb->mount_opts.use_gid ?		befs_sb->mount_opts.gid :		make_kgid(&init_user_ns, fs32_to_cpu(sb, raw_inode->gid));	set_nlink(inode, 1);	/*	 * BEFS's time is 64 bits, but current VFS is 32 bits...	 * BEFS don't have access time. Nor inode change time. VFS	 * doesn't have creation time.	 * Also, the lower 16 bits of the last_modified_time and	 * create_time are just a counter to help ensure uniqueness	 * for indexing purposes. (PFD, page 54)	 */	inode->i_mtime.tv_sec =	    fs64_to_cpu(sb, raw_inode->last_modified_time) >> 16;	inode->i_mtime.tv_nsec = 0;   /* lower 16 bits are not a time */	inode->i_ctime = inode->i_mtime;	inode->i_atime = inode->i_mtime;	befs_ino->i_inode_num = fsrun_to_cpu(sb, raw_inode->inode_num);	befs_ino->i_parent = fsrun_to_cpu(sb, raw_inode->parent);	befs_ino->i_attribute = fsrun_to_cpu(sb, raw_inode->attributes);	befs_ino->i_flags = fs32_to_cpu(sb, raw_inode->flags);	if (S_ISLNK(inode->i_mode) && !(befs_ino->i_flags & BEFS_LONG_SYMLINK)){		inode->i_size = 0;		inode->i_blocks = befs_sb->block_size / VFS_BLOCK_SIZE;		strlcpy(befs_ino->i_data.symlink, raw_inode->data.symlink,			BEFS_SYMLINK_LEN);	} else {		int num_blks;		befs_ino->i_data.ds =		    fsds_to_cpu(sb, &raw_inode->data.datastream);		num_blks = befs_count_blocks(sb, &befs_ino->i_data.ds);		inode->i_blocks =		    num_blks * (befs_sb->block_size / VFS_BLOCK_SIZE);		inode->i_size = befs_ino->i_data.ds.size;	}	inode->i_mapping->a_ops = &befs_aops;	if (S_ISREG(inode->i_mode)) {		inode->i_fop = &generic_ro_fops;	} else if (S_ISDIR(inode->i_mode)) {		inode->i_op = &befs_dir_inode_operations;		inode->i_fop = &befs_dir_operations;	} else if (S_ISLNK(inode->i_mode)) {		if (befs_ino->i_flags & BEFS_LONG_SYMLINK) {			inode->i_op = &page_symlink_inode_operations;			inode_nohighmem(inode);			inode->i_mapping->a_ops = &befs_symlink_aops;		} else {			inode->i_link = befs_ino->i_data.symlink;			inode->i_op = &simple_symlink_inode_operations;		}	} else {		befs_error(sb, "Inode %lu is not a regular file, "			   "directory or symlink. THAT IS WRONG! BeFS has no "			   "on disk special files", inode->i_ino);		goto unacquire_bh;	}	brelse(bh);	befs_debug(sb, "<--- %s", __func__);	unlock_new_inode(inode);	return inode;unacquire_bh:	brelse(bh);unacquire_none:	iget_failed(inode);	befs_debug(sb, "<--- %s - Bad inode", __func__);	return ERR_PTR(-EIO);}
开发者ID:asmalldev,项目名称:linux,代码行数:101,


示例4: gfs2_iget

struct inode *gfs2_inode_lookup(struct super_block *sb, unsigned int type,				u64 no_addr, u64 no_formal_ino, int non_block){	struct inode *inode;	struct gfs2_inode *ip;	struct gfs2_glock *io_gl = NULL;	int error;	inode = gfs2_iget(sb, no_addr, non_block);	ip = GFS2_I(inode);	if (!inode)		return ERR_PTR(-ENOBUFS);	if (inode->i_state & I_NEW) {		struct gfs2_sbd *sdp = GFS2_SB(inode);		ip->i_no_formal_ino = no_formal_ino;		error = gfs2_glock_get(sdp, no_addr, &gfs2_inode_glops, CREATE, &ip->i_gl);		if (unlikely(error))			goto fail;		ip->i_gl->gl_object = ip;		error = gfs2_glock_get(sdp, no_addr, &gfs2_iopen_glops, CREATE, &io_gl);		if (unlikely(error))			goto fail_put;		set_bit(GIF_INVALID, &ip->i_flags);		error = gfs2_glock_nq_init(io_gl, LM_ST_SHARED, GL_EXACT, &ip->i_iopen_gh);		if (unlikely(error))			goto fail_iopen;		ip->i_iopen_gh.gh_gl->gl_object = ip;		gfs2_glock_put(io_gl);		io_gl = NULL; 		if (type == DT_UNKNOWN) {			/* Inode glock must be locked already */			error = gfs2_inode_refresh(GFS2_I(inode));			if (error)				goto fail_refresh;		} else {			inode->i_mode = DT2IF(type);		}		gfs2_set_iop(inode);		unlock_new_inode(inode);	}	return inode;fail_refresh:	ip->i_iopen_gh.gh_gl->gl_object = NULL;	gfs2_glock_dq_uninit(&ip->i_iopen_gh);fail_iopen:	if (io_gl)		gfs2_glock_put(io_gl);fail_put:	ip->i_gl->gl_object = NULL;	gfs2_glock_put(ip->i_gl);fail:	iget_failed(inode);	return ERR_PTR(error);}
开发者ID:Addision,项目名称:LVS,代码行数:64,


示例5: F2FS_I_SB

static struct inode *f2fs_new_inode(struct inode *dir, umode_t mode){	struct f2fs_sb_info *sbi = F2FS_I_SB(dir);	nid_t ino;	struct inode *inode;	bool nid_free = false;	int err;	inode = new_inode(dir->i_sb);	if (!inode)		return ERR_PTR(-ENOMEM);	f2fs_lock_op(sbi);	if (!alloc_nid(sbi, &ino)) {		f2fs_unlock_op(sbi);		err = -ENOSPC;		goto fail;	}	f2fs_unlock_op(sbi);	inode_init_owner(inode, dir, mode);	inode->i_ino = ino;	inode->i_blocks = 0;	inode->i_mtime = inode->i_atime = inode->i_ctime = CURRENT_TIME;	inode->i_generation = sbi->s_next_generation++;	err = insert_inode_locked(inode);	if (err) {		err = -EINVAL;		nid_free = true;		goto out;	}	/* If the directory encrypted, then we should encrypt the inode. */	if (f2fs_encrypted_inode(dir) && f2fs_may_encrypt(inode))		f2fs_set_encrypted_inode(inode);	if (f2fs_may_inline_data(inode))		set_inode_flag(F2FS_I(inode), FI_INLINE_DATA);	if (f2fs_may_inline_dentry(inode))		set_inode_flag(F2FS_I(inode), FI_INLINE_DENTRY);	stat_inc_inline_inode(inode);	stat_inc_inline_dir(inode);	trace_f2fs_new_inode(inode, 0);	mark_inode_dirty(inode);	return inode;out:	clear_nlink(inode);	unlock_new_inode(inode);fail:	trace_f2fs_new_inode(inode, err);	make_bad_inode(inode);	iput(inode);	if (nid_free)		alloc_nid_failed(sbi, ino);	return ERR_PTR(err);}
开发者ID:ItsAnilSingh,项目名称:android_kernel_samsung_logan2g,代码行数:61,


示例6: iget5_locked

static struct inode *sdcardfskk_iget(struct super_block *sb,				 struct inode *lower_inode){	struct sdcardfskk_inode_info *info;	struct inode *inode; /* the new inode to return */	int err;	inode = iget5_locked(sb, /* our superblock */			     /*			      * hashval: we use inode number, but we can			      * also use "(unsigned long)lower_inode"			      * instead.			      */			     lower_inode->i_ino, /* hashval */			     sdcardfskk_inode_test,	/* inode comparison function */			     sdcardfskk_inode_set, /* inode init function */			     lower_inode); /* data passed to test+set fxns */	if (!inode) {		err = -EACCES;		iput(lower_inode);		return ERR_PTR(err);	}	/* if found a cached inode, then just return it */	if (!(inode->i_state & I_NEW))		return inode;	/* initialize new inode */	info = SDCARDFSKK_I(inode);	inode->i_ino = lower_inode->i_ino;	if (!igrab(lower_inode)) {		err = -ESTALE;		return ERR_PTR(err);	}	sdcardfskk_set_lower_inode(inode, lower_inode);	inode->i_version++;	/* use different set of inode ops for symlinks & directories */	if (S_ISDIR(lower_inode->i_mode))		inode->i_op = &sdcardfskk_dir_iops;	else if (S_ISLNK(lower_inode->i_mode))		inode->i_op = &sdcardfskk_symlink_iops;	else		inode->i_op = &sdcardfskk_main_iops;	/* use different set of file ops for directories */	if (S_ISDIR(lower_inode->i_mode))		inode->i_fop = &sdcardfskk_dir_fops;	else		inode->i_fop = &sdcardfskk_main_fops;	inode->i_mapping->a_ops = &sdcardfskk_aops;	inode->i_atime.tv_sec = 0;	inode->i_atime.tv_nsec = 0;	inode->i_mtime.tv_sec = 0;	inode->i_mtime.tv_nsec = 0;	inode->i_ctime.tv_sec = 0;	inode->i_ctime.tv_nsec = 0;	/* properly initialize special inodes */	if (S_ISBLK(lower_inode->i_mode) || S_ISCHR(lower_inode->i_mode) ||	    S_ISFIFO(lower_inode->i_mode) || S_ISSOCK(lower_inode->i_mode))		init_special_inode(inode, lower_inode->i_mode,				   lower_inode->i_rdev);	/* all well, copy inode attributes, don't need to hold i_mutex here */	sdcardfskk_copy_inode_attr(inode, lower_inode);	fsstack_copy_inode_size(inode, lower_inode);	fix_derived_permission(inode);	unlock_new_inode(inode);	return inode;}
开发者ID:sms200207,项目名称:arter97-kernel-unofficial,代码行数:76,


示例7: afs_iget

/* * inode retrieval */inline int afs_iget(struct super_block *sb, struct afs_fid *fid,		    struct inode **_inode){	struct afs_iget_data data = { .fid = *fid };	struct afs_super_info *as;	struct afs_vnode *vnode;	struct inode *inode;	int ret;	_enter(",{%u,%u,%u},,", fid->vid, fid->vnode, fid->unique);	as = sb->s_fs_info;	data.volume = as->volume;	inode = iget5_locked(sb, fid->vnode, afs_iget5_test, afs_iget5_set,			     &data);	if (!inode) {		_leave(" = -ENOMEM");		return -ENOMEM;	}	vnode = AFS_FS_I(inode);	/* deal with an existing inode */	if (!(inode->i_state & I_NEW)) {		ret = afs_vnode_fetch_status(vnode);		if (ret==0)			*_inode = inode;		else			iput(inode);		_leave(" = %d", ret);		return ret;	}#ifdef AFS_CACHING_SUPPORT	/* set up caching before reading the status, as fetch-status reads the	 * first page of symlinks to see if they're really mntpts */	cachefs_acquire_cookie(vnode->volume->cache,			       NULL,			       vnode,			       &vnode->cache);#endif	/* okay... it's a new inode */	inode->i_flags |= S_NOATIME;	vnode->flags |= AFS_VNODE_CHANGED;	ret = afs_inode_fetch_status(inode);	if (ret<0)		goto bad_inode;	/* success */	unlock_new_inode(inode);	*_inode = inode;	_leave(" = 0 [CB { v=%u x=%lu t=%u }]",	       vnode->cb_version,	       vnode->cb_timeout.timo_jif,	       vnode->cb_type);	return 0;	/* failure */ bad_inode:	make_bad_inode(inode);	unlock_new_inode(inode);	iput(inode);	_leave(" = %d [bad]", ret);	return ret;} /* end afs_iget() */
开发者ID:qwerty1023,项目名称:wive-rtnl-firmware,代码行数:72,


示例8: OMFS_SB

struct inode *omfs_iget(struct super_block *sb, ino_t ino){	struct omfs_sb_info *sbi = OMFS_SB(sb);	struct omfs_inode *oi;	struct buffer_head *bh;	u64 ctime;	unsigned long nsecs;	struct inode *inode;	inode = iget_locked(sb, ino);	if (!inode)		return ERR_PTR(-ENOMEM);	if (!(inode->i_state & I_NEW))		return inode;	bh = omfs_bread(inode->i_sb, ino);	if (!bh)		goto iget_failed;	oi = (struct omfs_inode *)bh->b_data;	/* check self */	if (ino != be64_to_cpu(oi->i_head.h_self))		goto fail_bh;	inode->i_uid = sbi->s_uid;	inode->i_gid = sbi->s_gid;	ctime = be64_to_cpu(oi->i_ctime);	nsecs = do_div(ctime, 1000) * 1000L;	inode->i_atime.tv_sec = ctime;	inode->i_mtime.tv_sec = ctime;	inode->i_ctime.tv_sec = ctime;	inode->i_atime.tv_nsec = nsecs;	inode->i_mtime.tv_nsec = nsecs;	inode->i_ctime.tv_nsec = nsecs;	inode->i_mapping->a_ops = &omfs_aops;	switch (oi->i_type) {	case OMFS_DIR:		inode->i_mode = S_IFDIR | (S_IRWXUGO & ~sbi->s_dmask);		inode->i_op = &omfs_dir_inops;		inode->i_fop = &omfs_dir_operations;		inode->i_size = sbi->s_sys_blocksize;		inc_nlink(inode);		break;	case OMFS_FILE:		inode->i_mode = S_IFREG | (S_IRWXUGO & ~sbi->s_fmask);		inode->i_fop = &omfs_file_operations;		inode->i_size = be64_to_cpu(oi->i_size);		break;	}	brelse(bh);	unlock_new_inode(inode);	return inode;fail_bh:	brelse(bh);iget_failed:	iget_failed(inode);	return ERR_PTR(-EIO);}
开发者ID:aexon,项目名称:DORIMANX_LG_STOCK_LP_KERNEL,代码行数:63,


示例9: ilookup5

//.........这里部分代码省略.........	if (!sbi->por_doing && inode->i_nlink == 0) {		ret = -ENOENT;		goto bad_inode;	}make_now:	if (ino == F2FS_NODE_INO(sbi)) {		inode->i_mapping->a_ops = &f2fs_node_aops;		mapping_set_gfp_mask(inode->i_mapping, GFP_F2FS_ZERO);	} else if (ino == F2FS_META_INO(sbi)) {		inode->i_mapping->a_ops = &f2fs_meta_aops;		mapping_set_gfp_mask(inode->i_mapping, GFP_F2FS_ZERO);	} else if (S_ISREG(inode->i_mode)) {		inode->i_op = &f2fs_file_inode_operations;		inode->i_fop = &f2fs_file_operations;		inode->i_mapping->a_ops = &f2fs_dblock_aops;	} else if (S_ISDIR(inode->i_mode)) {		inode->i_op = &f2fs_dir_inode_operations;		inode->i_fop = &f2fs_dir_operations;		inode->i_mapping->a_ops = &f2fs_dblock_aops;		mapping_set_gfp_mask(inode->i_mapping, GFP_HIGHUSER_MOVABLE |				__GFP_ZERO);	} else if (S_ISLNK(inode->i_mode)) {		inode->i_op = &f2fs_symlink_inode_operations;		inode->i_mapping->a_ops = &f2fs_dblock_aops;	} else if (S_ISCHR(inode->i_mode) || S_ISBLK(inode->i_mode) ||			S_ISFIFO(inode->i_mode) || S_ISSOCK(inode->i_mode)) {		inode->i_op = &f2fs_special_inode_operations;		init_special_inode(inode, inode->i_mode, inode->i_rdev);	} else {		ret = -EIO;		goto bad_inode;	}	unlock_new_inode(inode);	return inode;bad_inode:	iget_failed(inode);	return ERR_PTR(ret);}void update_inode(struct inode *inode, struct page *node_page){	struct f2fs_node *rn;	struct f2fs_inode *ri;	wait_on_page_writeback(node_page);	rn = page_address(node_page);	ri = &(rn->i);	ri->i_mode = cpu_to_le16(inode->i_mode);	ri->i_advise = F2FS_I(inode)->i_advise;	ri->i_uid = cpu_to_le32(i_uid_read(inode));	ri->i_gid = cpu_to_le32(i_gid_read(inode));	ri->i_links = cpu_to_le32(inode->i_nlink);	ri->i_size = cpu_to_le64(i_size_read(inode));	ri->i_blocks = cpu_to_le64(inode->i_blocks);	set_raw_extent(&F2FS_I(inode)->ext, &ri->i_ext);	ri->i_atime = cpu_to_le64(inode->i_atime.tv_sec);	ri->i_ctime = cpu_to_le64(inode->i_ctime.tv_sec);	ri->i_mtime = cpu_to_le64(inode->i_mtime.tv_sec);	ri->i_atime_nsec = cpu_to_le32(inode->i_atime.tv_nsec);	ri->i_ctime_nsec = cpu_to_le32(inode->i_ctime.tv_nsec);
开发者ID:AdrianHuang,项目名称:linux-3.8.13,代码行数:67,


示例10: f2fs_inode_by_name

//.........这里部分代码省略.........		err = f2fs_fname_crypto_alloc_buffer(inode, len, &disk_link);		if (err)			goto err_out;		err = f2fs_fname_usr_to_disk(inode, &istr, &disk_link);		if (err < 0)			goto err_out;		p_len = encrypted_symlink_data_len(disk_link.len) + 1;		if (p_len > dir->i_sb->s_blocksize) {			err = -ENAMETOOLONG;			goto err_out;		}		sd = kzalloc(p_len, GFP_NOFS);		if (!sd) {			err = -ENOMEM;			goto err_out;		}		memcpy(sd->encrypted_path, disk_link.name, disk_link.len);		sd->len = cpu_to_le16(disk_link.len);		p_str = (char *)sd;	} else {		p_len = len + 1;		p_str = (char *)symname;	}	err = page_symlink(inode, p_str, p_len);err_out:	d_instantiate(dentry, inode);	unlock_new_inode(inode);	/*	 * Let's flush symlink data in order to avoid broken symlink as much as	 * possible. Nevertheless, fsyncing is the best way, but there is no	 * way to get a file descriptor in order to flush that.	 *	 * Note that, it needs to do dir->fsync to make this recoverable.	 * If the symlink path is stored into inline_data, there is no	 * performance regression.	 */	if (!err)		filemap_write_and_wait_range(inode->i_mapping, 0, p_len - 1);	if (IS_DIRSYNC(dir))		f2fs_sync_fs(sbi->sb, 1);	kfree(sd);	f2fs_fname_crypto_free_buffer(&disk_link);	return err;out:	handle_failed_inode(inode);	return err;}static int f2fs_mkdir(struct inode *dir, struct dentry *dentry, int mode){	struct f2fs_sb_info *sbi = F2FS_I_SB(dir);	struct inode *inode;	int err;	f2fs_balance_fs(sbi);
开发者ID:ItsAnilSingh,项目名称:android_kernel_samsung_logan2g,代码行数:66,


示例11: lock_kernel

struct dentry *hpfs_lookup(struct inode *dir, struct dentry *dentry, struct nameidata *nd){    const char *name = dentry->d_name.name;    unsigned len = dentry->d_name.len;    struct quad_buffer_head qbh;    struct hpfs_dirent *de;    ino_t ino;    int err;    struct inode *result = NULL;    struct hpfs_inode_info *hpfs_result;    lock_kernel();    if ((err = hpfs_chk_name((char *)name, &len))) {        if (err == -ENAMETOOLONG) {            unlock_kernel();            return ERR_PTR(-ENAMETOOLONG);        }        goto end_add;    }    /*     * '.' and '..' will never be passed here.     */    de = map_dirent(dir, hpfs_i(dir)->i_dno, (char *) name, len, NULL, &qbh);    /*     * This is not really a bailout, just means file not found.     */    if (!de) goto end;    /*     * Get inode number, what we're after.     */    ino = de->fnode;    /*     * Go find or make an inode.     */    result = iget_locked(dir->i_sb, ino);    if (!result) {        hpfs_error(dir->i_sb, "hpfs_lookup: can't get inode");        goto bail1;    }    if (result->i_state & I_NEW) {        hpfs_init_inode(result);        if (de->directory)            hpfs_read_inode(result);        else if (de->ea_size && hpfs_sb(dir->i_sb)->sb_eas)            hpfs_read_inode(result);        else {            result->i_mode |= S_IFREG;            result->i_mode &= ~0111;            result->i_op = &hpfs_file_iops;            result->i_fop = &hpfs_file_ops;            result->i_nlink = 1;        }        unlock_new_inode(result);    }    hpfs_result = hpfs_i(result);    if (!de->directory) hpfs_result->i_parent_dir = dir->i_ino;    hpfs_decide_conv(result, (char *)name, len);    if (de->has_acl || de->has_xtd_perm) if (!(dir->i_sb->s_flags & MS_RDONLY)) {        hpfs_error(result->i_sb, "ACLs or XPERM found. This is probably HPFS386. This driver doesn't support it now. Send me some info on these structures");        goto bail1;    }    /*     * Fill in the info from the directory if this is a newly created     * inode.     */    if (!result->i_ctime.tv_sec) {        if (!(result->i_ctime.tv_sec = local_to_gmt(dir->i_sb, de->creation_date)))            result->i_ctime.tv_sec = 1;        result->i_ctime.tv_nsec = 0;        result->i_mtime.tv_sec = local_to_gmt(dir->i_sb, de->write_date);        result->i_mtime.tv_nsec = 0;        result->i_atime.tv_sec = local_to_gmt(dir->i_sb, de->read_date);        result->i_atime.tv_nsec = 0;        hpfs_result->i_ea_size = de->ea_size;        if (!hpfs_result->i_ea_mode && de->read_only)            result->i_mode &= ~0222;        if (!de->directory) {            if (result->i_size == -1) {                result->i_size = de->file_size;                result->i_data.a_ops = &hpfs_aops;                hpfs_i(result)->mmu_private = result->i_size;            /*             * i_blocks should count the fnode and any anodes.             * We count 1 for the fnode and don't bother about             * anodes -- the disk heads are on the directory band             * and we want them to stay there.             */                result->i_blocks = 1 + ((result->i_size + 511) >> 9);//.........这里部分代码省略.........
开发者ID:274914765,项目名称:C,代码行数:101,


示例12: nilfs_sufile_read

/** * nilfs_sufile_read - read or get sufile inode * @sb: super block instance * @susize: size of a segment usage entry * @raw_inode: on-disk sufile inode * @inodep: buffer to store the inode */int nilfs_sufile_read(struct super_block *sb, size_t susize,		      struct nilfs_inode *raw_inode, struct inode **inodep){	struct inode *sufile;	struct nilfs_sufile_info *sui;	struct buffer_head *header_bh;	struct nilfs_sufile_header *header;	void *kaddr;	int err;	if (susize > sb->s_blocksize) {		printk(KERN_ERR		       "NILFS: too large segment usage size: %zu bytes./n",		       susize);		return -EINVAL;	} else if (susize < NILFS_MIN_SEGMENT_USAGE_SIZE) {		printk(KERN_ERR		       "NILFS: too small segment usage size: %zu bytes./n",		       susize);		return -EINVAL;	}	sufile = nilfs_iget_locked(sb, NULL, NILFS_SUFILE_INO);	if (unlikely(!sufile))		return -ENOMEM;	if (!(sufile->i_state & I_NEW))		goto out;	err = nilfs_mdt_init(sufile, NILFS_MDT_GFP, sizeof(*sui));	if (err)		goto failed;	nilfs_mdt_set_entry_size(sufile, susize,				 sizeof(struct nilfs_sufile_header));	err = nilfs_read_inode_common(sufile, raw_inode);	if (err)		goto failed;	err = nilfs_sufile_get_header_block(sufile, &header_bh);	if (err)		goto failed;	sui = NILFS_SUI(sufile);	kaddr = kmap_atomic(header_bh->b_page, KM_USER0);	header = kaddr + bh_offset(header_bh);	sui->ncleansegs = le64_to_cpu(header->sh_ncleansegs);	kunmap_atomic(kaddr, KM_USER0);	brelse(header_bh);	sui->allocmax = nilfs_sufile_get_nsegments(sufile) - 1;	sui->allocmin = 0;	unlock_new_inode(sufile); out:	*inodep = sufile;	return 0; failed:	iget_failed(sufile);	return err;}
开发者ID:nilfs-dev,项目名称:nilfs2-kmod-centos6,代码行数:68,


示例13: iget_locked

struct inode *qnx4_iget(struct super_block *sb, unsigned long ino){	struct buffer_head *bh;	struct qnx4_inode_entry *raw_inode;	int block;	struct qnx4_inode_entry *qnx4_inode;	struct inode *inode;	inode = iget_locked(sb, ino);	if (!inode)		return ERR_PTR(-ENOMEM);	if (!(inode->i_state & I_NEW))		return inode;	qnx4_inode = qnx4_raw_inode(inode);	inode->i_mode = 0;	QNX4DEBUG(("Reading inode : [%d]/n", ino));	if (!ino) {		printk(KERN_ERR "qnx4: bad inode number on dev %s: %lu is "				"out of range/n",		       sb->s_id, ino);		iget_failed(inode);		return ERR_PTR(-EIO);	}	block = ino / QNX4_INODES_PER_BLOCK;	if (!(bh = sb_bread(sb, block))) {		printk("qnx4: major problem: unable to read inode from dev "		       "%s/n", sb->s_id);		iget_failed(inode);		return ERR_PTR(-EIO);	}	raw_inode = ((struct qnx4_inode_entry *) bh->b_data) +	    (ino % QNX4_INODES_PER_BLOCK);	inode->i_mode    = le16_to_cpu(raw_inode->di_mode);	inode->i_uid     = (uid_t)le16_to_cpu(raw_inode->di_uid);	inode->i_gid     = (gid_t)le16_to_cpu(raw_inode->di_gid);	inode->i_nlink   = le16_to_cpu(raw_inode->di_nlink);	inode->i_size    = le32_to_cpu(raw_inode->di_size);	inode->i_mtime.tv_sec   = le32_to_cpu(raw_inode->di_mtime);	inode->i_mtime.tv_nsec = 0;	inode->i_atime.tv_sec   = le32_to_cpu(raw_inode->di_atime);	inode->i_atime.tv_nsec = 0;	inode->i_ctime.tv_sec   = le32_to_cpu(raw_inode->di_ctime);	inode->i_ctime.tv_nsec = 0;	inode->i_blocks  = le32_to_cpu(raw_inode->di_first_xtnt.xtnt_size);	memcpy(qnx4_inode, raw_inode, QNX4_DIR_ENTRY_SIZE);	if (S_ISREG(inode->i_mode)) {		inode->i_op = &qnx4_file_inode_operations;		inode->i_fop = &qnx4_file_operations;		inode->i_mapping->a_ops = &qnx4_aops;		qnx4_i(inode)->mmu_private = inode->i_size;	} else if (S_ISDIR(inode->i_mode)) {		inode->i_op = &qnx4_dir_inode_operations;		inode->i_fop = &qnx4_dir_operations;	} else if (S_ISLNK(inode->i_mode)) {		inode->i_op = &page_symlink_inode_operations;		inode->i_mapping->a_ops = &qnx4_aops;		qnx4_i(inode)->mmu_private = inode->i_size;	} else {		printk(KERN_ERR "qnx4: bad inode %lu on dev %s/n",			ino, sb->s_id);		iget_failed(inode);		brelse(bh);		return ERR_PTR(-EIO);	}	brelse(bh);	unlock_new_inode(inode);	return inode;}
开发者ID:Tigrouzen,项目名称:k1099,代码行数:73,


示例14: ecryptfs_lookup_interpose

/** * ecryptfs_lookup_interpose - Dentry interposition for a lookup */static int ecryptfs_lookup_interpose(struct dentry *dentry,				     struct dentry *lower_dentry,				     struct inode *dir_inode){	struct inode *inode, *lower_inode = lower_dentry->d_inode;	struct ecryptfs_dentry_info *dentry_info;	struct vfsmount *lower_mnt;	int rc = 0;	dentry_info = kmem_cache_alloc(ecryptfs_dentry_info_cache, GFP_KERNEL);	if (!dentry_info) {		printk(KERN_ERR "%s: Out of memory whilst attempting "		       "to allocate ecryptfs_dentry_info struct/n",			__func__);		dput(lower_dentry);		return -ENOMEM;	}	lower_mnt = mntget(ecryptfs_dentry_to_lower_mnt(dentry->d_parent));	fsstack_copy_attr_atime(dir_inode, lower_dentry->d_parent->d_inode);	BUG_ON(!lower_dentry->d_count);	ecryptfs_set_dentry_private(dentry, dentry_info);	ecryptfs_set_dentry_lower(dentry, lower_dentry);	ecryptfs_set_dentry_lower_mnt(dentry, lower_mnt);	if (!lower_dentry->d_inode) {		/* We want to add because we couldn't find in lower */		d_add(dentry, NULL);		return 0;	}	inode = __ecryptfs_get_inode(lower_inode, dir_inode->i_sb);	if (IS_ERR(inode)) {		printk(KERN_ERR "%s: Error interposing; rc = [%ld]/n",		       __func__, PTR_ERR(inode));		return PTR_ERR(inode);	}	if (S_ISREG(inode->i_mode)) {		rc = ecryptfs_i_size_read(dentry, inode);		if (rc) {			make_bad_inode(inode);			return rc;		}	}#ifdef CONFIG_SDP	if (S_ISDIR(inode->i_mode) && dentry) {	    if(IS_UNDER_ROOT(dentry)) {	        struct ecryptfs_mount_crypt_stat *mount_crypt_stat  =	                &ecryptfs_superblock_to_private(inode->i_sb)->mount_crypt_stat;	        printk("Lookup a directoy under root directory of current partition./n");	        if(is_chamber_directory(mount_crypt_stat, (char *)dentry->d_name.name)) {	            /*	             * When this directory is under ROOT directory and the name is registered	             * as Chamber.	             */	            printk("This is a chamber directory/n");	            set_chamber_flag(inode);	        }	    } else if(IS_SENSITIVE_DENTRY(dentry->d_parent)) {	        /*	         * When parent directory is sensitive	         */	        struct ecryptfs_crypt_stat *crypt_stat =	                &ecryptfs_inode_to_private(inode)->crypt_stat;	        printk("Parent %s is sensitive. so this directory is sensitive too/n",	                dentry->d_parent->d_name.name);	        crypt_stat->flags |= ECRYPTFS_DEK_IS_SENSITIVE;	    }	}#endif	if (inode->i_state & I_NEW)		unlock_new_inode(inode);	d_add(dentry, inode);	return rc;}
开发者ID:sawdoctor,项目名称:Googy-Max-N4-Kernel,代码行数:83,


示例15: hpfs_fill_super

//.........这里部分代码省略.........	}	if (le32_to_cpu(spareblock->hotfixes_used) || le32_to_cpu(spareblock->n_spares_used)) {		if (errs >= 2) {			printk("HPFS: Hotfixes not supported here, try chkdsk/n");			mark_dirty(s, 0);			goto bail4;		}		hpfs_error(s, "hotfixes not supported here, try chkdsk");		if (errs == 0) printk("HPFS: Proceeding, but your filesystem will be probably corrupted by this driver.../n");		else printk("HPFS: This driver may read bad files or crash when operating on disk with hotfixes./n");	}	if (le32_to_cpu(spareblock->n_dnode_spares) != le32_to_cpu(spareblock->n_dnode_spares_free)) {		if (errs >= 2) {			printk("HPFS: Spare dnodes used, try chkdsk/n");			mark_dirty(s, 0);			goto bail4;		}		hpfs_error(s, "warning: spare dnodes used, try chkdsk");		if (errs == 0) printk("HPFS: Proceeding, but your filesystem could be corrupted if you delete files or directories/n");	}	if (chk) {		unsigned a;		if (le32_to_cpu(superblock->dir_band_end) - le32_to_cpu(superblock->dir_band_start) + 1 != le32_to_cpu(superblock->n_dir_band) ||		    le32_to_cpu(superblock->dir_band_end) < le32_to_cpu(superblock->dir_band_start) || le32_to_cpu(superblock->n_dir_band) > 0x4000) {			hpfs_error(s, "dir band size mismatch: dir_band_start==%08x, dir_band_end==%08x, n_dir_band==%08x",				le32_to_cpu(superblock->dir_band_start), le32_to_cpu(superblock->dir_band_end), le32_to_cpu(superblock->n_dir_band));			goto bail4;		}		a = sbi->sb_dirband_size;		sbi->sb_dirband_size = 0;		if (hpfs_chk_sectors(s, le32_to_cpu(superblock->dir_band_start), le32_to_cpu(superblock->n_dir_band), "dir_band") ||		    hpfs_chk_sectors(s, le32_to_cpu(superblock->dir_band_bitmap), 4, "dir_band_bitmap") ||		    hpfs_chk_sectors(s, le32_to_cpu(superblock->bitmaps), 4, "bitmaps")) {			mark_dirty(s, 0);			goto bail4;		}		sbi->sb_dirband_size = a;	} else printk("HPFS: You really don't want any checks? You are crazy.../n");	/* Load code page table */	if (le32_to_cpu(spareblock->n_code_pages))		if (!(sbi->sb_cp_table = hpfs_load_code_page(s, le32_to_cpu(spareblock->code_page_dir))))			printk("HPFS: Warning: code page support is disabled/n");	brelse(bh2);	brelse(bh1);	brelse(bh0);	root = iget_locked(s, sbi->sb_root);	if (!root)		goto bail0;	hpfs_init_inode(root);	hpfs_read_inode(root);	unlock_new_inode(root);	s->s_root = d_alloc_root(root);	if (!s->s_root) {		iput(root);		goto bail0;	}	/*	 * find the root directory's . pointer & finish filling in the inode	 */	root_dno = hpfs_fnode_dno(s, sbi->sb_root);	if (root_dno)		de = map_dirent(root, root_dno, "/001/001", 2, NULL, &qbh);	if (!de)		hpfs_error(s, "unable to find root dir");	else {		root->i_atime.tv_sec = local_to_gmt(s, le32_to_cpu(de->read_date));		root->i_atime.tv_nsec = 0;		root->i_mtime.tv_sec = local_to_gmt(s, le32_to_cpu(de->write_date));		root->i_mtime.tv_nsec = 0;		root->i_ctime.tv_sec = local_to_gmt(s, le32_to_cpu(de->creation_date));		root->i_ctime.tv_nsec = 0;		hpfs_i(root)->i_ea_size = le16_to_cpu(de->ea_size);		hpfs_i(root)->i_parent_dir = root->i_ino;		if (root->i_size == -1)			root->i_size = 2048;		if (root->i_blocks == -1)			root->i_blocks = 5;		hpfs_brelse4(&qbh);	}	hpfs_unlock(s);	return 0;bail4:	brelse(bh2);bail3:	brelse(bh1);bail2:	brelse(bh0);bail1:bail0:	hpfs_unlock(s);	kfree(sbi->sb_bmp_dir);	kfree(sbi->sb_cp_table);	s->s_fs_info = NULL;	kfree(sbi);	return -EINVAL;}
开发者ID:perkarom,项目名称:SGS3-Sourcedrops,代码行数:101,


示例16: KERNEL_VERSION

/** * This is called when vfs failed to locate dentry in the cache. The * job of this function is to allocate inode and link it to dentry. * [dentry] contains the name to be looked in the [parent] directory. * Failure to locate the name is not a "hard" error, in this case NULL * inode is added to [dentry] and vfs should proceed trying to create * the entry via other means. NULL(or "positive" pointer) ought to be * returned in case of success and "negative" pointer on error */static struct dentry *sf_lookup(struct inode *parent, struct dentry *dentry#if LINUX_VERSION_CODE >= KERNEL_VERSION(3, 6, 0)                                , unsigned int flags#elif LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 0)                                , struct nameidata *nd#endif                               ){    int err;    struct sf_inode_info *sf_i, *sf_new_i;    struct sf_glob_info *sf_g;    SHFLSTRING *path;    struct inode *inode;    ino_t ino;    SHFLFSOBJINFO fsinfo;    TRACE();    sf_g = GET_GLOB_INFO(parent->i_sb);    sf_i = GET_INODE_INFO(parent);    BUG_ON(!sf_g);    BUG_ON(!sf_i);    err = sf_path_from_dentry(__func__, sf_g, sf_i, dentry, &path);    if (err)        goto fail0;    err = sf_stat(__func__, sf_g, path, &fsinfo, 1);    if (err)    {        if (err == -ENOENT)        {            /* -ENOENT: add NULL inode to dentry so it later can be               created via call to create/mkdir/open */            kfree(path);            inode = NULL;        }        else            goto fail1;    }    else    {        sf_new_i = kmalloc(sizeof(*sf_new_i), GFP_KERNEL);        if (!sf_new_i)        {            LogRelFunc(("could not allocate memory for new inode info/n"));            err = -ENOMEM;            goto fail1;        }        sf_new_i->handle = SHFL_HANDLE_NIL;        sf_new_i->force_reread = 0;        ino = iunique(parent->i_sb, 1);#if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 4, 25)        inode = iget_locked(parent->i_sb, ino);#else        inode = iget(parent->i_sb, ino);#endif        if (!inode)        {            LogFunc(("iget failed/n"));            err = -ENOMEM;          /* XXX: ??? */            goto fail2;        }        SET_INODE_INFO(inode, sf_new_i);        sf_init_inode(sf_g, inode, &fsinfo);        sf_new_i->path = path;#if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 4, 25)        unlock_new_inode(inode);#endif    }    sf_i->force_restat = 0;    dentry->d_time = jiffies;#if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 38)    d_set_d_op(dentry, &sf_dentry_ops);#else    dentry->d_op = &sf_dentry_ops;#endif    d_add(dentry, inode);    return NULL;fail2:    kfree(sf_new_i);fail1:    kfree(path);fail0://.........这里部分代码省略.........
开发者ID:ailispaw,项目名称:vboxguest,代码行数:101,


示例17: SUPER_INFO

//.........这里部分代码省略.........	inode_index = inode->i_ino /		(EFS_BLOCKSIZE / sizeof(struct efs_dinode));	block = sb->fs_start + sb->first_block + 		(sb->group_size * (inode_index / sb->inode_blocks)) +		(inode_index % sb->inode_blocks);	offset = (inode->i_ino %			(EFS_BLOCKSIZE / sizeof(struct efs_dinode))) *		sizeof(struct efs_dinode);	bh = sb_bread(inode->i_sb, block);	if (!bh) {		printk(KERN_WARNING "EFS: bread() failed at block %d/n", block);		goto read_inode_error;	}	efs_inode = (struct efs_dinode *) (bh->b_data + offset);    	inode->i_mode  = be16_to_cpu(efs_inode->di_mode);	inode->i_nlink = be16_to_cpu(efs_inode->di_nlink);	inode->i_uid   = (uid_t)be16_to_cpu(efs_inode->di_uid);	inode->i_gid   = (gid_t)be16_to_cpu(efs_inode->di_gid);	inode->i_size  = be32_to_cpu(efs_inode->di_size);	inode->i_atime.tv_sec = be32_to_cpu(efs_inode->di_atime);	inode->i_mtime.tv_sec = be32_to_cpu(efs_inode->di_mtime);	inode->i_ctime.tv_sec = be32_to_cpu(efs_inode->di_ctime);	inode->i_atime.tv_nsec = inode->i_mtime.tv_nsec = inode->i_ctime.tv_nsec = 0;	/* this is the number of blocks in the file */	if (inode->i_size == 0) {		inode->i_blocks = 0;	} else {		inode->i_blocks = ((inode->i_size - 1) >> EFS_BLOCKSIZE_BITS) + 1;	}	rdev = be16_to_cpu(efs_inode->di_u.di_dev.odev);	if (rdev == 0xffff) {		rdev = be32_to_cpu(efs_inode->di_u.di_dev.ndev);		if (sysv_major(rdev) > 0xfff)			device = 0;		else			device = MKDEV(sysv_major(rdev), sysv_minor(rdev));	} else		device = old_decode_dev(rdev);	/* get the number of extents for this object */	in->numextents = be16_to_cpu(efs_inode->di_numextents);	in->lastextent = 0;	/* copy the extents contained within the inode to memory */	for(i = 0; i < EFS_DIRECTEXTENTS; i++) {		extent_copy(&(efs_inode->di_u.di_extents[i]), &(in->extents[i]));		if (i < in->numextents && in->extents[i].cooked.ex_magic != 0) {			printk(KERN_WARNING "EFS: extent %d has bad magic number in inode %lu/n", i, inode->i_ino);			brelse(bh);			goto read_inode_error;		}	}	brelse(bh);   #ifdef DEBUG	printk(KERN_DEBUG "EFS: efs_iget(): inode %lu, extents %d, mode %o/n",		inode->i_ino, in->numextents, inode->i_mode);#endif	switch (inode->i_mode & S_IFMT) {		case S_IFDIR: 			inode->i_op = &efs_dir_inode_operations; 			inode->i_fop = &efs_dir_operations; 			break;		case S_IFREG:			inode->i_fop = &generic_ro_fops;			inode->i_data.a_ops = &efs_aops;			break;		case S_IFLNK:			inode->i_op = &page_symlink_inode_operations;			inode->i_data.a_ops = &efs_symlink_aops;			break;		case S_IFCHR:		case S_IFBLK:		case S_IFIFO:			init_special_inode(inode, inode->i_mode, device);			break;		default:			printk(KERN_WARNING "EFS: unsupported inode mode %o/n", inode->i_mode);			goto read_inode_error;			break;	}	unlock_new_inode(inode);	return inode;        read_inode_error:	printk(KERN_WARNING "EFS: failed to read inode %lu/n", inode->i_ino);	iget_failed(inode);	return ERR_PTR(-EIO);}
开发者ID:CSCLOG,项目名称:beaglebone,代码行数:101,


示例18: sf_read_super_aux

//.........这里部分代码省略.........    }    sf_i->handle = SHFL_HANDLE_NIL;    sf_i->path = kmalloc(sizeof(SHFLSTRING) + 1, GFP_KERNEL);    if (!sf_i->path)    {        err = -ENOMEM;        LogRelFunc(("could not allocate memory for root inode path/n"));        goto fail2;    }    sf_i->path->u16Length = 1;    sf_i->path->u16Size = 2;    sf_i->path->String.utf8[0] = '/';    sf_i->path->String.utf8[1] = 0;    err = sf_stat(__func__, sf_g, sf_i->path, &fsinfo, 0);    if (err)    {        LogFunc(("could not stat root of share/n"));        goto fail3;    }    sb->s_magic = 0xface;    sb->s_blocksize = 1024;#if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 4, 3)    /* Required for seek/sendfile.     *     * Must by less than or equal to INT64_MAX despite the fact that the     * declaration of this variable is unsigned long long. See determination     * of 'loff_t max' in fs/read_write.c / do_sendfile(). I don't know the     * correct limit but MAX_LFS_FILESIZE (8TB-1 on 32-bit boxes) takes the     * page cache into account and is the suggested limit. */# if defined MAX_LFS_FILESIZE    sb->s_maxbytes = MAX_LFS_FILESIZE;# else    sb->s_maxbytes = 0x7fffffffffffffffULL;# endif#endif    sb->s_op = &sf_super_ops;#if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 4, 25)    iroot = iget_locked(sb, 0);#else    iroot = iget(sb, 0);#endif    if (!iroot)    {        err = -ENOMEM;  /* XXX */        LogFunc(("could not get root inode/n"));        goto fail3;    }    if (sf_init_backing_dev(sf_g))    {        err = -EINVAL;        LogFunc(("could not init bdi/n"));#if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 4, 25)        unlock_new_inode(iroot);#endif        goto fail4;    }    sf_init_inode(sf_g, iroot, &fsinfo);    SET_INODE_INFO(iroot, sf_i);#if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 4, 25)    unlock_new_inode(iroot);#endif    droot = d_alloc_root(iroot);    if (!droot)    {        err = -ENOMEM;  /* XXX */        LogFunc(("d_alloc_root failed/n"));        goto fail5;    }    sb->s_root = droot;    SET_GLOB_INFO(sb, sf_g);    return 0;fail5:    sf_done_backing_dev(sf_g);fail4:    iput(iroot);fail3:    kfree(sf_i->path);fail2:    kfree(sf_i);fail1:    sf_glob_free(sf_g);fail0:    return err;}
开发者ID:quiquetux,项目名称:jokte-ba-as,代码行数:101,


示例19: romfs_dev_read

/* * get a romfs inode based on its position in the image (which doubles as the * inode number) */static struct inode *romfs_iget(struct super_block *sb, unsigned long pos){	struct romfs_inode_info *inode;	struct romfs_inode ri;	struct inode *i;	unsigned long nlen;	unsigned nextfh;	int ret;	umode_t mode;	/* we might have to traverse a chain of "hard link" file entries to get	 * to the actual file */	for (;;) {		ret = romfs_dev_read(sb, pos, &ri, sizeof(ri));		if (ret < 0)			goto error;		/* XXX: do romfs_checksum here too (with name) */		nextfh = be32_to_cpu(ri.next);		if ((nextfh & ROMFH_TYPE) != ROMFH_HRD)			break;		pos = be32_to_cpu(ri.spec) & ROMFH_MASK;	}	/* determine the length of the filename */	nlen = romfs_dev_strnlen(sb, pos + ROMFH_SIZE, ROMFS_MAXFN);	if (IS_ERR_VALUE(nlen))		goto eio;	/* get an inode for this image position */	i = iget_locked(sb, pos);	if (!i)		return ERR_PTR(-ENOMEM);	if (!(i->i_state & I_NEW))		return i;	/* precalculate the data offset */	inode = ROMFS_I(i);	inode->i_metasize = (ROMFH_SIZE + nlen + 1 + ROMFH_PAD) & ROMFH_MASK;	inode->i_dataoffset = pos + inode->i_metasize;	i->i_nlink = 1;		/* Hard to decide.. */	i->i_size = be32_to_cpu(ri.size);	i->i_mtime.tv_sec = i->i_atime.tv_sec = i->i_ctime.tv_sec = 0;	i->i_mtime.tv_nsec = i->i_atime.tv_nsec = i->i_ctime.tv_nsec = 0;	/* set up mode and ops */	mode = romfs_modemap[nextfh & ROMFH_TYPE];	switch (nextfh & ROMFH_TYPE) {	case ROMFH_DIR:		i->i_size = ROMFS_I(i)->i_metasize;		i->i_op = &romfs_dir_inode_operations;		i->i_fop = &romfs_dir_operations;		if (nextfh & ROMFH_EXEC)			mode |= S_IXUGO;		break;	case ROMFH_REG:		i->i_fop = &romfs_ro_fops;		i->i_data.a_ops = &romfs_aops;		if (i->i_sb->s_mtd)			i->i_data.backing_dev_info =				i->i_sb->s_mtd->backing_dev_info;		if (nextfh & ROMFH_EXEC)			mode |= S_IXUGO;		break;	case ROMFH_SYM:		i->i_op = &page_symlink_inode_operations;		i->i_data.a_ops = &romfs_aops;		mode |= S_IRWXUGO;		break;	default:		/* depending on MBZ for sock/fifos */		nextfh = be32_to_cpu(ri.spec);		init_special_inode(i, mode, MKDEV(nextfh >> 16,						  nextfh & 0xffff));		break;	}	i->i_mode = mode;	unlock_new_inode(i);	return i;eio:	ret = -EIO;error:	printk(KERN_ERR "ROMFS: read error for inode 0x%lx/n", pos);	return ERR_PTR(ret);}
开发者ID:Astinj,项目名称:linux_samsung_ics_real,代码行数:97,


示例20: ilookup5

struct inode *nilfs_ilookup(struct super_block *sb, struct nilfs_root *root,			    unsigned long ino){	struct nilfs_iget_args args = {		.ino = ino, .root = root, .cno = 0, .for_gc = 0	};	return ilookup5(sb, ino, nilfs_iget_test, &args);}struct inode *nilfs_iget_locked(struct super_block *sb, struct nilfs_root *root,				unsigned long ino){	struct nilfs_iget_args args = {		.ino = ino, .root = root, .cno = 0, .for_gc = 0	};	return iget5_locked(sb, ino, nilfs_iget_test, nilfs_iget_set, &args);}struct inode *nilfs_iget(struct super_block *sb, struct nilfs_root *root,			 unsigned long ino){	struct inode *inode;	int err;	inode = nilfs_iget_locked(sb, root, ino);	if (unlikely(!inode))		return ERR_PTR(-ENOMEM);	if (!(inode->i_state & I_NEW))		return inode;	err = __nilfs_read_inode(sb, root, ino, inode);	if (unlikely(err)) {		iget_failed(inode);		return ERR_PTR(err);	}	unlock_new_inode(inode);	return inode;}struct inode *nilfs_iget_for_gc(struct super_block *sb, unsigned long ino,				__u64 cno){	struct nilfs_iget_args args = {		.ino = ino, .root = NULL, .cno = cno, .for_gc = 1	};	struct inode *inode;	int err;	inode = iget5_locked(sb, ino, nilfs_iget_test, nilfs_iget_set, &args);	if (unlikely(!inode))		return ERR_PTR(-ENOMEM);	if (!(inode->i_state & I_NEW))		return inode;	err = nilfs_init_gcinode(inode);	if (unlikely(err)) {		iget_failed(inode);		return ERR_PTR(err);	}	unlock_new_inode(inode);	return inode;}void nilfs_write_inode_common(struct inode *inode,			      struct nilfs_inode *raw_inode, int has_bmap){	struct nilfs_inode_info *ii = NILFS_I(inode);	raw_inode->i_mode = cpu_to_le16(inode->i_mode);	raw_inode->i_uid = cpu_to_le32(i_uid_read(inode));	raw_inode->i_gid = cpu_to_le32(i_gid_read(inode));	raw_inode->i_links_count = cpu_to_le16(inode->i_nlink);	raw_inode->i_size = cpu_to_le64(inode->i_size);	raw_inode->i_ctime = cpu_to_le64(inode->i_ctime.tv_sec);	raw_inode->i_mtime = cpu_to_le64(inode->i_mtime.tv_sec);	raw_inode->i_ctime_nsec = cpu_to_le32(inode->i_ctime.tv_nsec);	raw_inode->i_mtime_nsec = cpu_to_le32(inode->i_mtime.tv_nsec);	raw_inode->i_blocks = cpu_to_le64(inode->i_blocks);	raw_inode->i_flags = cpu_to_le32(ii->i_flags);	raw_inode->i_generation = cpu_to_le32(inode->i_generation);	if (NILFS_ROOT_METADATA_FILE(inode->i_ino)) {		struct the_nilfs *nilfs = inode->i_sb->s_fs_info;		/* zero-fill unused portion in the case of super root block */		raw_inode->i_xattr = 0;		raw_inode->i_pad = 0;		memset((void *)raw_inode + sizeof(*raw_inode), 0,		       nilfs->ns_inode_size - sizeof(*raw_inode));	}	if (has_bmap)		nilfs_bmap_write(ii->i_bmap, raw_inode);	else if (S_ISCHR(inode->i_mode) || S_ISBLK(inode->i_mode))		raw_inode->i_device_code =			cpu_to_le64(huge_encode_dev(inode->i_rdev));	/* When extending inode, nilfs->ns_inode_size should be checked//.........这里部分代码省略.........
开发者ID:battahma,项目名称:cs444,代码行数:101,



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


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