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

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

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

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

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

示例1: ubifs_jnl_write_2_inodes

/** * ubifs_jnl_write_2_inodes - write 2 inodes to the journal. * @c: UBIFS file-system description object * @inode1: first inode to write * @inode2: second inode to write * @sync: non-zero if the write-buffer has to be synchronized * * This function writes 2 inodes @inode1 and @inode2 to the journal (to the * base head - first @inode1, then @inode2). Returns zero in case of success * and a negative error code in case of failure. */int ubifs_jnl_write_2_inodes(struct ubifs_info *c, const struct inode *inode1,                             const struct inode *inode2, int sync){    int err, len1, len2, aligned_len, aligned_len1, lnum, offs;    struct ubifs_ino_node *ino;    union ubifs_key key;    dbg_jnl("ino %lu, ino %lu", inode1->i_ino, inode2->i_ino);    ubifs_assert(inode1->i_nlink > 0);    ubifs_assert(inode2->i_nlink > 0);    len1 = UBIFS_INO_NODE_SZ + ubifs_inode(inode1)->data_len;    len2 = UBIFS_INO_NODE_SZ + ubifs_inode(inode2)->data_len;    aligned_len1 = ALIGN(len1, 8);    aligned_len = aligned_len1 + ALIGN(len2, 8);    ino = kmalloc(aligned_len, GFP_NOFS);    if (!ino)        return -ENOMEM;    /* Make reservation before allocating sequence numbers */    err = make_reservation(c, BASEHD, aligned_len);    if (err)        goto out_free;    pack_inode(c, ino, inode1, 0, 0);    pack_inode(c, (void *)ino + aligned_len1, inode2, 1, 0);    err = write_head(c, BASEHD, ino, aligned_len, &lnum, &offs, 0);    if (!sync && !err) {        struct ubifs_wbuf *wbuf = &c->jheads[BASEHD].wbuf;        ubifs_wbuf_add_ino_nolock(wbuf, inode1->i_ino);        ubifs_wbuf_add_ino_nolock(wbuf, inode2->i_ino);    }    release_head(c, BASEHD);    if (err)        goto out_ro;    ino_key_init(c, &key, inode1->i_ino);    err = ubifs_tnc_add(c, &key, lnum, offs, len1);    if (err)        goto out_ro;    ino_key_init(c, &key, inode2->i_ino);    err = ubifs_tnc_add(c, &key, lnum, offs + aligned_len1, len2);    if (err)        goto out_ro;    finish_reservation(c);    kfree(ino);    return 0;out_ro:    ubifs_ro_mode(c, err);    finish_reservation(c);out_free:    kfree(ino);    return err;}
开发者ID:heroistired,项目名称:jzcode-x11,代码行数:71,


示例2: validate_inode

/** * validate_inode - validate inode. * @c: UBIFS file-system description object * @inode: the inode to validate * * This is a helper function for 'ubifs_iget()' which validates various fields * of a newly built inode to make sure they contain sane values and prevent * possible vulnerabilities. Returns zero if the inode is all right and * a non-zero error code if not. */static int validate_inode(struct ubifs_info *c, const struct inode *inode){	int err;	const struct ubifs_inode *ui = ubifs_inode(inode);	if (inode->i_size > c->max_inode_sz) {		ubifs_err("inode is too large (%lld)",			  (long long)inode->i_size);		return 1;	}	if (ui->compr_type < 0 || ui->compr_type >= UBIFS_COMPR_TYPES_CNT) {		ubifs_err("unknown compression type %d", ui->compr_type);		return 2;	}	if (ui->data_len < 0 || ui->data_len > UBIFS_MAX_INO_DATA)		return 4;	if (!ubifs_compr_present(ui->compr_type)) {		ubifs_warn("inode %lu uses '%s' compression, but it was not "			   "compiled in", inode->i_ino,			   ubifs_compr_name(ui->compr_type));	}	err = dbg_check_dir_size(c, inode);	return err;}
开发者ID:0s4l,项目名称:u-boot-xlnx,代码行数:38,


示例3: ubifs_set_inode_flags

/** * ubifs_set_inode_flags - set VFS inode flags. * @inode: VFS inode to set flags for * * This function propagates flags from UBIFS inode object to VFS inode object. */void ubifs_set_inode_flags(struct inode *inode){	unsigned int flags = ubifs_inode(inode)->flags;	inode->i_flags &= ~(S_SYNC | S_APPEND | S_IMMUTABLE | S_DIRSYNC);	if (flags & UBIFS_SYNC_FL)		inode->i_flags |= S_SYNC;	if (flags & UBIFS_APPEND_FL)		inode->i_flags |= S_APPEND;	if (flags & UBIFS_IMMUTABLE_FL)		inode->i_flags |= S_IMMUTABLE;	if (flags & UBIFS_DIRSYNC_FL)		inode->i_flags |= S_DIRSYNC;}
开发者ID:CSCLOG,项目名称:beaglebone,代码行数:20,


示例4: read_block

static int read_block(struct inode *inode, void *addr, unsigned int block,		      struct ubifs_data_node *dn){	struct ubifs_info *c = inode->i_sb->s_fs_info;	int err, len, out_len;	union ubifs_key key;	unsigned int dlen;	data_key_init(c, &key, inode->i_ino, block);	err = ubifs_tnc_lookup(c, &key, dn);	if (err) {		if (err == -ENOENT)			/* Not found, so it must be a hole */			memset(addr, 0, UBIFS_BLOCK_SIZE);		return err;	}	ubifs_assert(le64_to_cpu(dn->ch.sqnum) > ubifs_inode(inode)->creat_sqnum);	len = le32_to_cpu(dn->size);	if (len <= 0 || len > UBIFS_BLOCK_SIZE)		goto dump;	dlen = le32_to_cpu(dn->ch.len) - UBIFS_DATA_NODE_SZ;	out_len = UBIFS_BLOCK_SIZE;	err = ubifs_decompress(&dn->data, dlen, addr, &out_len,			       le16_to_cpu(dn->compr_type));	if (err || len != out_len)		goto dump;	/*	 * Data length can be less than a full block, even for blocks that are	 * not the last in the file (e.g., as a result of making a hole and	 * appending data). Ensure that the remainder is zeroed out.	 */	if (len < UBIFS_BLOCK_SIZE)		memset(addr + len, 0, UBIFS_BLOCK_SIZE - len);	return 0;dump:	ubifs_err("bad data node (block %u, inode %lu)",		  block, inode->i_ino);	dbg_dump_node(c, dn);	return -EINVAL;}
开发者ID:dhs-shine,项目名称:sprd_project,代码行数:46,


示例5: inherit_flags

/** * inherit_flags - inherit flags of the parent inode. * @dir: parent inode * @mode: new inode mode flags * * This is a helper function for 'ubifs_new_inode()' which inherits flag of the * parent directory inode @dir. UBIFS inodes inherit the following flags: * o %UBIFS_COMPR_FL, which is useful to switch compression on/of on *   sub-directory basis; * o %UBIFS_SYNC_FL - useful for the same reasons; * o %UBIFS_DIRSYNC_FL - similar, but relevant only to directories. * * This function returns the inherited flags. */static int inherit_flags(const struct inode *dir, umode_t mode){	int flags;	const struct ubifs_inode *ui = ubifs_inode(dir);	if (!S_ISDIR(dir->i_mode))		/*		 * The parent is not a directory, which means that an extended		 * attribute inode is being created. No flags.		 */		return 0;	flags = ui->flags & (UBIFS_COMPR_FL | UBIFS_SYNC_FL | UBIFS_DIRSYNC_FL);	if (!S_ISDIR(mode))		/* The "DIRSYNC" flag only applies to directories */		flags &= ~UBIFS_DIRSYNC_FL;	return flags;}
开发者ID:DenisLug,项目名称:mptcp,代码行数:32,


示例6: ubifs_create

static int ubifs_create(struct inode *dir, struct dentry *dentry, umode_t mode,			bool excl){	struct inode *inode;	struct ubifs_info *c = dir->i_sb->s_fs_info;	struct ubifs_budget_req req = { .new_ino = 1, .new_dent = 1,					.dirtied_ino = 1 };	struct ubifs_inode *dir_ui = ubifs_inode(dir);	struct fscrypt_name nm;	int err, sz_change;	/*	 * Budget request settings: new inode, new direntry, changing the	 * parent directory inode.	 */	dbg_gen("dent '%pd', mode %#hx in dir ino %lu",		dentry, mode, dir->i_ino);	err = ubifs_budget_space(c, &req);	if (err)		return err;	err = fscrypt_setup_filename(dir, &dentry->d_name, 0, &nm);	if (err)		goto out_budg;	sz_change = CALC_DENT_SIZE(fname_len(&nm));	inode = ubifs_new_inode(c, dir, mode);	if (IS_ERR(inode)) {		err = PTR_ERR(inode);		goto out_fname;	}	err = ubifs_init_security(dir, inode, &dentry->d_name);	if (err)		goto out_inode;	mutex_lock(&dir_ui->ui_mutex);	dir->i_size += sz_change;	dir_ui->ui_size = dir->i_size;	dir->i_mtime = dir->i_ctime = inode->i_ctime;	err = ubifs_jnl_update(c, dir, &nm, inode, 0, 0);	if (err)		goto out_cancel;	mutex_unlock(&dir_ui->ui_mutex);	ubifs_release_budget(c, &req);	fscrypt_free_filename(&nm);	insert_inode_hash(inode);	d_instantiate(dentry, inode);	return 0;out_cancel:	dir->i_size -= sz_change;	dir_ui->ui_size = dir->i_size;	mutex_unlock(&dir_ui->ui_mutex);out_inode:	make_bad_inode(inode);	iput(inode);out_fname:	fscrypt_free_filename(&nm);out_budg:	ubifs_release_budget(c, &req);	ubifs_err(c, "cannot create regular file, error %d", err);	return err;}static int do_tmpfile(struct inode *dir, struct dentry *dentry,		      umode_t mode, struct inode **whiteout){	struct inode *inode;	struct ubifs_info *c = dir->i_sb->s_fs_info;	struct ubifs_budget_req req = { .new_ino = 1, .new_dent = 1};	struct ubifs_budget_req ino_req = { .dirtied_ino = 1 };	struct ubifs_inode *ui, *dir_ui = ubifs_inode(dir);	int err, instantiated = 0;	struct fscrypt_name nm;	/*	 * Budget request settings: new dirty inode, new direntry,	 * budget for dirtied inode will be released via writeback.	 */	dbg_gen("dent '%pd', mode %#hx in dir ino %lu",		dentry, mode, dir->i_ino);	err = fscrypt_setup_filename(dir, &dentry->d_name, 0, &nm);	if (err)		return err;	err = ubifs_budget_space(c, &req);	if (err) {		fscrypt_free_filename(&nm);		return err;	}	err = ubifs_budget_space(c, &ino_req);	if (err) {//.........这里部分代码省略.........
开发者ID:SantoshShilimkar,项目名称:linux,代码行数:101,


示例7: new_inode

/** * ubifs_new_inode - allocate new UBIFS inode object. * @c: UBIFS file-system description object * @dir: parent directory inode * @mode: inode mode flags * * This function finds an unused inode number, allocates new inode and * initializes it. Returns new inode in case of success and an error code in * case of failure. */struct inode *ubifs_new_inode(struct ubifs_info *c, const struct inode *dir,			      umode_t mode){	struct inode *inode;	struct ubifs_inode *ui;	inode = new_inode(c->vfs_sb);	ui = ubifs_inode(inode);	if (!inode)		return ERR_PTR(-ENOMEM);	/*	 * Set 'S_NOCMTIME' to prevent VFS form updating [mc]time of inodes and	 * marking them dirty in file write path (see 'file_update_time()').	 * UBIFS has to fully control "clean <-> dirty" transitions of inodes	 * to make budgeting work.	 */	inode->i_flags |= S_NOCMTIME;	inode_init_owner(inode, dir, mode);	inode->i_mtime = inode->i_atime = inode->i_ctime =			 ubifs_current_time(inode);	inode->i_mapping->nrpages = 0;	switch (mode & S_IFMT) {	case S_IFREG:		inode->i_mapping->a_ops = &ubifs_file_address_operations;		inode->i_op = &ubifs_file_inode_operations;		inode->i_fop = &ubifs_file_operations;		break;	case S_IFDIR:		inode->i_op  = &ubifs_dir_inode_operations;		inode->i_fop = &ubifs_dir_operations;		inode->i_size = ui->ui_size = UBIFS_INO_NODE_SZ;		break;	case S_IFLNK:		inode->i_op = &ubifs_symlink_inode_operations;		break;	case S_IFSOCK:	case S_IFIFO:	case S_IFBLK:	case S_IFCHR:		inode->i_op  = &ubifs_file_inode_operations;		break;	default:		BUG();	}	ui->flags = inherit_flags(dir, mode);	ubifs_set_inode_flags(inode);	if (S_ISREG(mode))		ui->compr_type = c->default_compr;	else		ui->compr_type = UBIFS_COMPR_NONE;	ui->synced_i_size = 0;	spin_lock(&c->cnt_lock);	/* Inode number overflow is currently not supported */	if (c->highest_inum >= INUM_WARN_WATERMARK) {		if (c->highest_inum >= INUM_WATERMARK) {			spin_unlock(&c->cnt_lock);			ubifs_err(c, "out of inode numbers");			make_bad_inode(inode);			iput(inode);			return ERR_PTR(-EINVAL);		}		ubifs_warn(c, "running out of inode numbers (current %lu, max %u)",			   (unsigned long)c->highest_inum, INUM_WATERMARK);	}	inode->i_ino = ++c->highest_inum;	/*	 * The creation sequence number remains with this inode for its	 * lifetime. All nodes for this inode have a greater sequence number,	 * and so it is possible to distinguish obsolete nodes belonging to a	 * previous incarnation of the same inode number - for example, for the	 * purpose of rebuilding the index.	 */	ui->creat_sqnum = ++c->max_sqnum;	spin_unlock(&c->cnt_lock);	return inode;}
开发者ID:DenisLug,项目名称:mptcp,代码行数:92,


示例8: unlock_2_inodes

/** * unlock_2_inodes - a wrapper for unlocking two UBIFS inodes. * @inode1: first inode * @inode2: second inode */static void unlock_2_inodes(struct inode *inode1, struct inode *inode2){	mutex_unlock(&ubifs_inode(inode2)->ui_mutex);	mutex_unlock(&ubifs_inode(inode1)->ui_mutex);}
开发者ID:DenisLug,项目名称:mptcp,代码行数:10,


示例9: ubifs_link

static int ubifs_link(struct dentry *old_dentry, struct inode *dir,		      struct dentry *dentry){	struct ubifs_info *c = dir->i_sb->s_fs_info;	struct inode *inode = d_inode(old_dentry);	struct ubifs_inode *ui = ubifs_inode(inode);	struct ubifs_inode *dir_ui = ubifs_inode(dir);	int err, sz_change = CALC_DENT_SIZE(dentry->d_name.len);	struct ubifs_budget_req req = { .new_dent = 1, .dirtied_ino = 2,				.dirtied_ino_d = ALIGN(ui->data_len, 8) };	/*	 * Budget request settings: new direntry, changing the target inode,	 * changing the parent inode.	 */	dbg_gen("dent '%pd' to ino %lu (nlink %d) in dir ino %lu",		dentry, inode->i_ino,		inode->i_nlink, dir->i_ino);	ubifs_assert(mutex_is_locked(&dir->i_mutex));	ubifs_assert(mutex_is_locked(&inode->i_mutex));	err = dbg_check_synced_i_size(c, inode);	if (err)		return err;	err = ubifs_budget_space(c, &req);	if (err)		return err;	lock_2_inodes(dir, inode);	inc_nlink(inode);	ihold(inode);	inode->i_ctime = ubifs_current_time(inode);	dir->i_size += sz_change;	dir_ui->ui_size = dir->i_size;	dir->i_mtime = dir->i_ctime = inode->i_ctime;	err = ubifs_jnl_update(c, dir, &dentry->d_name, inode, 0, 0);	if (err)		goto out_cancel;	unlock_2_inodes(dir, inode);	ubifs_release_budget(c, &req);	d_instantiate(dentry, inode);	return 0;out_cancel:	dir->i_size -= sz_change;	dir_ui->ui_size = dir->i_size;	drop_nlink(inode);	unlock_2_inodes(dir, inode);	ubifs_release_budget(c, &req);	iput(inode);	return err;}static int ubifs_unlink(struct inode *dir, struct dentry *dentry){	struct ubifs_info *c = dir->i_sb->s_fs_info;	struct inode *inode = d_inode(dentry);	struct ubifs_inode *dir_ui = ubifs_inode(dir);	int sz_change = CALC_DENT_SIZE(dentry->d_name.len);	int err, budgeted = 1;	struct ubifs_budget_req req = { .mod_dent = 1, .dirtied_ino = 2 };	unsigned int saved_nlink = inode->i_nlink;	/*	 * Budget request settings: deletion direntry, deletion inode (+1 for	 * @dirtied_ino), changing the parent directory inode. If budgeting	 * fails, go ahead anyway because we have extra space reserved for	 * deletions.	 */	dbg_gen("dent '%pd' from ino %lu (nlink %d) in dir ino %lu",		dentry, inode->i_ino,		inode->i_nlink, dir->i_ino);	ubifs_assert(mutex_is_locked(&dir->i_mutex));	ubifs_assert(mutex_is_locked(&inode->i_mutex));	err = dbg_check_synced_i_size(c, inode);	if (err)		return err;	err = ubifs_budget_space(c, &req);	if (err) {		if (err != -ENOSPC)			return err;		budgeted = 0;	}	lock_2_inodes(dir, inode);	inode->i_ctime = ubifs_current_time(dir);	drop_nlink(inode);	dir->i_size -= sz_change;	dir_ui->ui_size = dir->i_size;	dir->i_mtime = dir->i_ctime = inode->i_ctime;	err = ubifs_jnl_update(c, dir, &dentry->d_name, inode, 1, 0);	if (err)		goto out_cancel;	unlock_2_inodes(dir, inode);//.........这里部分代码省略.........
开发者ID:DenisLug,项目名称:mptcp,代码行数:101,


示例10: ubifs_create

static int ubifs_create(struct inode *dir, struct dentry *dentry, umode_t mode,			bool excl){	struct inode *inode;	struct ubifs_info *c = dir->i_sb->s_fs_info;	int err, sz_change = CALC_DENT_SIZE(dentry->d_name.len);	struct ubifs_budget_req req = { .new_ino = 1, .new_dent = 1,					.dirtied_ino = 1 };	struct ubifs_inode *dir_ui = ubifs_inode(dir);	/*	 * Budget request settings: new inode, new direntry, changing the	 * parent directory inode.	 */	dbg_gen("dent '%pd', mode %#hx in dir ino %lu",		dentry, mode, dir->i_ino);	err = ubifs_budget_space(c, &req);	if (err)		return err;	inode = ubifs_new_inode(c, dir, mode);	if (IS_ERR(inode)) {		err = PTR_ERR(inode);		goto out_budg;	}	err = ubifs_init_security(dir, inode, &dentry->d_name);	if (err)		goto out_inode;	mutex_lock(&dir_ui->ui_mutex);	dir->i_size += sz_change;	dir_ui->ui_size = dir->i_size;	dir->i_mtime = dir->i_ctime = inode->i_ctime;	err = ubifs_jnl_update(c, dir, &dentry->d_name, inode, 0, 0);	if (err)		goto out_cancel;	mutex_unlock(&dir_ui->ui_mutex);	ubifs_release_budget(c, &req);	insert_inode_hash(inode);	d_instantiate(dentry, inode);	return 0;out_cancel:	dir->i_size -= sz_change;	dir_ui->ui_size = dir->i_size;	mutex_unlock(&dir_ui->ui_mutex);out_inode:	make_bad_inode(inode);	iput(inode);out_budg:	ubifs_release_budget(c, &req);	ubifs_err(c, "cannot create regular file, error %d", err);	return err;}/** * vfs_dent_type - get VFS directory entry type. * @type: UBIFS directory entry type * * This function converts UBIFS directory entry type into VFS directory entry * type. */static unsigned int vfs_dent_type(uint8_t type){	switch (type) {	case UBIFS_ITYPE_REG:		return DT_REG;	case UBIFS_ITYPE_DIR:		return DT_DIR;	case UBIFS_ITYPE_LNK:		return DT_LNK;	case UBIFS_ITYPE_BLK:		return DT_BLK;	case UBIFS_ITYPE_CHR:		return DT_CHR;	case UBIFS_ITYPE_FIFO:		return DT_FIFO;	case UBIFS_ITYPE_SOCK:		return DT_SOCK;	default:		BUG();	}	return 0;}/* * The classical Unix view for directory is that it is a linear array of * (name, inode number) entries. Linux/VFS assumes this model as well. * Particularly, 'readdir()' call wants us to return a directory entry offset * which later may be used to continue 'readdir()'ing the directory or to * 'seek()' to that specific direntry. Obviously UBIFS does not really fit this * model because directory entries are identified by keys, which may collide. * * UBIFS uses directory entry hash value for directory offsets, so * 'seekdir()'/'telldir()' may not always work because of possible key * collisions. But UBIFS guarantees that consecutive 'readdir()' calls work//.........这里部分代码省略.........
开发者ID:DenisLug,项目名称:mptcp,代码行数:101,


示例11: lock_2_inodes

/** * lock_2_inodes - a wrapper for locking two UBIFS inodes. * @inode1: first inode * @inode2: second inode * * We do not implement any tricks to guarantee strict lock ordering, because * VFS has already done it for us on the @i_mutex. So this is just a simple * wrapper function. */static void lock_2_inodes(struct inode *inode1, struct inode *inode2){	mutex_lock_nested(&ubifs_inode(inode1)->ui_mutex, WB_MUTEX_1);	mutex_lock_nested(&ubifs_inode(inode2)->ui_mutex, WB_MUTEX_2);}
开发者ID:DenisLug,项目名称:mptcp,代码行数:14,


示例12: ubifs_create

static int ubifs_create(struct inode *dir, struct dentry *dentry, int mode,			struct nameidata *nd){	struct inode *inode;	struct ubifs_info *c = dir->i_sb->s_fs_info;	int err, sz_change = CALC_DENT_SIZE(dentry->d_name.len);	struct ubifs_budget_req req = { .new_ino = 1, .new_dent = 1,					.dirtied_ino = 1 };	struct ubifs_inode *dir_ui = ubifs_inode(dir);	/*	 * Budget request settings: new inode, new direntry, changing the	 * parent directory inode.	 */	dbg_gen("dent '%.*s', mode %#x in dir ino %lu",		dentry->d_name.len, dentry->d_name.name, mode, dir->i_ino);	err = ubifs_budget_space(c, &req);	if (err)		return err;	inode = ubifs_new_inode(c, dir, mode);	if (IS_ERR(inode)) {		err = PTR_ERR(inode);		goto out_budg;	}	mutex_lock(&dir_ui->ui_mutex);	dir->i_size += sz_change;	dir_ui->ui_size = dir->i_size;	dir->i_mtime = dir->i_ctime = inode->i_ctime;	err = ubifs_jnl_update(c, dir, &dentry->d_name, inode, 0, 0);	if (err)		goto out_cancel;	mutex_unlock(&dir_ui->ui_mutex);	ubifs_release_budget(c, &req);	insert_inode_hash(inode);	d_instantiate(dentry, inode);	return 0;out_cancel:	dir->i_size -= sz_change;	dir_ui->ui_size = dir->i_size;	mutex_unlock(&dir_ui->ui_mutex);	make_bad_inode(inode);	iput(inode);out_budg:	ubifs_release_budget(c, &req);	ubifs_err("cannot create regular file, error %d", err);	return err;}static unsigned int vfs_dent_type(uint8_t type){	switch (type) {	case UBIFS_ITYPE_REG:		return DT_REG;	case UBIFS_ITYPE_DIR:		return DT_DIR;	case UBIFS_ITYPE_LNK:		return DT_LNK;	case UBIFS_ITYPE_BLK:		return DT_BLK;	case UBIFS_ITYPE_CHR:		return DT_CHR;	case UBIFS_ITYPE_FIFO:		return DT_FIFO;	case UBIFS_ITYPE_SOCK:		return DT_SOCK;	default:		BUG();	}	return 0;}static int ubifs_readdir(struct file *file, void *dirent, filldir_t filldir){	int err, over = 0;	struct qstr nm;	union ubifs_key key;	struct ubifs_dent_node *dent;	struct inode *dir = file->f_path.dentry->d_inode;	struct ubifs_info *c = dir->i_sb->s_fs_info;	dbg_gen("dir ino %lu, f_pos %#llx", dir->i_ino, file->f_pos);	if (file->f_pos > UBIFS_S_KEY_HASH_MASK || file->f_pos == 2)		/*		 * The directory was seek'ed to a senseless position or there		 * are no more entries.		 */		return 0;	/* File positions 0 and 1 correspond to "." and ".." */	if (file->f_pos == 0) {		ubifs_assert(!file->private_data);		over = filldir(dirent, ".", 1, 0, dir->i_ino, DT_DIR);		if (over)//.........这里部分代码省略.........
开发者ID:flwh,项目名称:Alcatel_OT_985_kernel,代码行数:101,


示例13: ubifs_link

static int ubifs_link(struct dentry *old_dentry, struct inode *dir,		      struct dentry *dentry){	struct ubifs_info *c = dir->i_sb->s_fs_info;	struct inode *inode = d_inode(old_dentry);	struct ubifs_inode *ui = ubifs_inode(inode);	struct ubifs_inode *dir_ui = ubifs_inode(dir);	int err, sz_change = CALC_DENT_SIZE(dentry->d_name.len);	struct ubifs_budget_req req = { .new_dent = 1, .dirtied_ino = 2,				.dirtied_ino_d = ALIGN(ui->data_len, 8) };	struct fscrypt_name nm;	/*	 * Budget request settings: new direntry, changing the target inode,	 * changing the parent inode.	 */	dbg_gen("dent '%pd' to ino %lu (nlink %d) in dir ino %lu",		dentry, inode->i_ino,		inode->i_nlink, dir->i_ino);	ubifs_assert(inode_is_locked(dir));	ubifs_assert(inode_is_locked(inode));	if (ubifs_crypt_is_encrypted(dir) &&	    !fscrypt_has_permitted_context(dir, inode))		return -EPERM;	err = fscrypt_setup_filename(dir, &dentry->d_name, 0, &nm);	if (err)		return err;	err = dbg_check_synced_i_size(c, inode);	if (err)		goto out_fname;	err = ubifs_budget_space(c, &req);	if (err)		goto out_fname;	lock_2_inodes(dir, inode);	/* Handle O_TMPFILE corner case, it is allowed to link a O_TMPFILE. */	if (inode->i_nlink == 0)		ubifs_delete_orphan(c, inode->i_ino);	inc_nlink(inode);	ihold(inode);	inode->i_ctime = current_time(inode);	dir->i_size += sz_change;	dir_ui->ui_size = dir->i_size;	dir->i_mtime = dir->i_ctime = inode->i_ctime;	err = ubifs_jnl_update(c, dir, &nm, inode, 0, 0);	if (err)		goto out_cancel;	unlock_2_inodes(dir, inode);	ubifs_release_budget(c, &req);	d_instantiate(dentry, inode);	fscrypt_free_filename(&nm);	return 0;out_cancel:	dir->i_size -= sz_change;	dir_ui->ui_size = dir->i_size;	drop_nlink(inode);	if (inode->i_nlink == 0)		ubifs_add_orphan(c, inode->i_ino);	unlock_2_inodes(dir, inode);	ubifs_release_budget(c, &req);	iput(inode);out_fname:	fscrypt_free_filename(&nm);	return err;}static int ubifs_unlink(struct inode *dir, struct dentry *dentry){	struct ubifs_info *c = dir->i_sb->s_fs_info;	struct inode *inode = d_inode(dentry);	struct ubifs_inode *dir_ui = ubifs_inode(dir);	int err, sz_change, budgeted = 1;	struct ubifs_budget_req req = { .mod_dent = 1, .dirtied_ino = 2 };	unsigned int saved_nlink = inode->i_nlink;	struct fscrypt_name nm;	/*	 * Budget request settings: deletion direntry, deletion inode (+1 for	 * @dirtied_ino), changing the parent directory inode. If budgeting	 * fails, go ahead anyway because we have extra space reserved for	 * deletions.	 */	dbg_gen("dent '%pd' from ino %lu (nlink %d) in dir ino %lu",		dentry, inode->i_ino,		inode->i_nlink, dir->i_ino);	if (ubifs_crypt_is_encrypted(dir)) {		err = fscrypt_get_encryption_info(dir);		if (err && err != -ENOKEY)			return err;//.........这里部分代码省略.........
开发者ID:SantoshShilimkar,项目名称:linux,代码行数:101,


示例14: dbg_gen

struct inode *ubifs_iget(struct super_block *sb, unsigned long inum){	int err;	union ubifs_key key;	struct ubifs_ino_node *ino;	struct ubifs_info *c = sb->s_fs_info;	struct inode *inode;	struct ubifs_inode *ui;	int i;	dbg_gen("inode %lu", inum);	/*	 * U-Boot special handling of locked down inodes via recovery	 * e.g. ubifs_recover_size()	 */	for (i = 0; i < INODE_LOCKED_MAX; i++) {		/*		 * Exit on last entry (NULL), inode not found in list		 */		if (inodes_locked_down[i] == NULL)			break;		if (inodes_locked_down[i]->i_ino == inum) {			/*			 * We found the locked down inode in our array,			 * so just return this pointer instead of creating			 * a new one.			 */			return inodes_locked_down[i];		}	}	inode = iget_locked(sb, inum);	if (!inode)		return ERR_PTR(-ENOMEM);	if (!(inode->i_state & I_NEW))		return inode;	ui = ubifs_inode(inode);	ino = kmalloc(UBIFS_MAX_INO_NODE_SZ, GFP_NOFS);	if (!ino) {		err = -ENOMEM;		goto out;	}	ino_key_init(c, &key, inode->i_ino);	err = ubifs_tnc_lookup(c, &key, ino);	if (err)		goto out_ino;	inode->i_flags |= (S_NOCMTIME | S_NOATIME);	inode->i_nlink = le32_to_cpu(ino->nlink);	inode->i_uid   = le32_to_cpu(ino->uid);	inode->i_gid   = le32_to_cpu(ino->gid);	inode->i_atime.tv_sec  = (int64_t)le64_to_cpu(ino->atime_sec);	inode->i_atime.tv_nsec = le32_to_cpu(ino->atime_nsec);	inode->i_mtime.tv_sec  = (int64_t)le64_to_cpu(ino->mtime_sec);	inode->i_mtime.tv_nsec = le32_to_cpu(ino->mtime_nsec);	inode->i_ctime.tv_sec  = (int64_t)le64_to_cpu(ino->ctime_sec);	inode->i_ctime.tv_nsec = le32_to_cpu(ino->ctime_nsec);	inode->i_mode = le32_to_cpu(ino->mode);	inode->i_size = le64_to_cpu(ino->size);	ui->data_len    = le32_to_cpu(ino->data_len);	ui->flags       = le32_to_cpu(ino->flags);	ui->compr_type  = le16_to_cpu(ino->compr_type);	ui->creat_sqnum = le64_to_cpu(ino->creat_sqnum);	ui->synced_i_size = ui->ui_size = inode->i_size;	err = validate_inode(c, inode);	if (err)		goto out_invalid;	if ((inode->i_mode & S_IFMT) == S_IFLNK) {		if (ui->data_len <= 0 || ui->data_len > UBIFS_MAX_INO_DATA) {			err = 12;			goto out_invalid;		}		ui->data = kmalloc(ui->data_len + 1, GFP_NOFS);		if (!ui->data) {			err = -ENOMEM;			goto out_ino;		}		memcpy(ui->data, ino->data, ui->data_len);		((char *)ui->data)[ui->data_len] = '/0';	}	kfree(ino);	inode->i_state &= ~(I_LOCK | I_NEW);	return inode;out_invalid:	ubifs_err("inode %lu validation failed, error %d", inode->i_ino, err);	dbg_dump_node(c, ino);	dbg_dump_inode(c, inode);	err = -EINVAL;out_ino:	kfree(ino);//.........这里部分代码省略.........
开发者ID:0s4l,项目名称:u-boot-xlnx,代码行数:101,


示例15: setflags

static int setflags(struct inode *inode, int flags){	int oldflags, err, release;	struct ubifs_inode *ui = ubifs_inode(inode);	struct ubifs_info *c = inode->i_sb->s_fs_info;	struct ubifs_budget_req req = { .dirtied_ino = 1,					.dirtied_ino_d = ui->data_len };	err = ubifs_budget_space(c, &req);	if (err)		return err;	/*	 * The IMMUTABLE and APPEND_ONLY flags can only be changed by	 * the relevant capability.	 */	mutex_lock(&ui->ui_mutex);	oldflags = ubifs2ioctl(ui->flags);	if ((flags ^ oldflags) & (FS_APPEND_FL | FS_IMMUTABLE_FL)) {		if (!capable(CAP_LINUX_IMMUTABLE)) {			err = -EPERM;			goto out_unlock;		}	}	ui->flags = ioctl2ubifs(flags);	ubifs_set_inode_flags(inode);	inode->i_ctime = ubifs_current_time(inode);	release = ui->dirty;	mark_inode_dirty_sync(inode);	mutex_unlock(&ui->ui_mutex);	if (release)		ubifs_release_budget(c, &req);	if (IS_SYNC(inode))		err = write_inode_now(inode, 1);	return err;out_unlock:	ubifs_err("can't modify inode %lu attributes", inode->i_ino);	mutex_unlock(&ui->ui_mutex);	ubifs_release_budget(c, &req);	return err;}long ubifs_ioctl(struct file *file, unsigned int cmd, unsigned long arg){	int flags, err;	struct inode *inode = file->f_path.dentry->d_inode;	switch (cmd) {	case FS_IOC_GETFLAGS:		flags = ubifs2ioctl(ubifs_inode(inode)->flags);		dbg_gen("get flags: %#x, i_flags %#x", flags, inode->i_flags);		return put_user(flags, (int __user *) arg);	case FS_IOC_SETFLAGS: {		if (IS_RDONLY(inode))			return -EROFS;		if (!inode_owner_or_capable(inode))			return -EACCES;		if (get_user(flags, (int __user *) arg))			return -EFAULT;		if (!S_ISDIR(inode->i_mode))			flags &= ~FS_DIRSYNC_FL;		/*		 * Make sure the file-system is read-write and make sure it		 * will not become read-only while we are changing the flags.		 */		err = mnt_want_write(file->f_path.mnt);		if (err)			return err;		dbg_gen("set flags: %#x, i_flags %#x", flags, inode->i_flags);		err = setflags(inode, flags);		mnt_drop_write(file->f_path.mnt);		return err;	}	default:		return -ENOTTY;	}}
开发者ID:CSCLOG,项目名称:beaglebone,代码行数:87,


示例16: ubifs_load

int ubifs_load(char *filename, u32 addr, u32 size){	struct ubifs_info *c = ubifs_sb->s_fs_info;	unsigned long inum;	struct inode *inode;	struct page page;	int err = 0;	int i;	int count;	char link_name[64];	struct ubifs_inode *ui;	c->ubi = ubi_open_volume(c->vi.ubi_num, c->vi.vol_id, UBI_READONLY);	inum = ubifs_findfile(ubifs_sb, filename);	if (!inum) {		err = -1;		goto out;	}	/*	 * Read file inode	 */	inode = ubifs_iget(ubifs_sb, inum);	if (IS_ERR(inode)) {		printf("%s: Error reading inode %ld!/n", __func__, inum);		err = PTR_ERR(inode);		goto out;	}	/*	 * Check for symbolic link	 */	ui = ubifs_inode(inode);	if (((inode->i_mode & S_IFMT) == S_IFLNK) && ui->data_len) {		memcpy(link_name, ui->data, ui->data_len);		printf("%s is linked to %s!/n", filename, link_name);		ubifs_iput(inode);		/*		 * Now we have the "real" filename, call ubifs_load()		 * again (recursive call) to load this file instead		 */		return ubifs_load(link_name, addr, size);	}	/*	 * If no size was specified or if size bigger than filesize	 * set size to filesize	 */	if ((size == 0) || (size > inode->i_size))		size = inode->i_size;	count = (size + UBIFS_BLOCK_SIZE - 1) >> UBIFS_BLOCK_SHIFT;	printf("Loading file '%s' to addr 0x%08x with size %d (0x%08x).../n",	       filename, addr, size, size);	page.addr = (void *)addr;	page.index = 0;	page.inode = inode;	for (i = 0; i < count; i++) {		err = do_readpage(c, inode, &page);		if (err)			break;		page.addr += PAGE_SIZE;		page.index++;	}	if (err)		printf("Error reading file '%s'/n", filename);	else		printf("Done/n");	ubifs_iput(inode);out:	ubi_close_volume(c->ubi);	return err;}
开发者ID:OpenInkpot-archive,项目名称:uboot-n516,代码行数:79,


示例17: ubifs_printdir

static int ubifs_printdir(struct file *file, void *dirent){	int err, over = 0;	struct qstr nm;	union ubifs_key key;	struct ubifs_dent_node *dent;	struct inode *dir = file->f_path.dentry->d_inode;	struct ubifs_info *c = dir->i_sb->s_fs_info;	dbg_gen("dir ino %lu, f_pos %#llx", dir->i_ino, file->f_pos);	if (file->f_pos > UBIFS_S_KEY_HASH_MASK || file->f_pos == 2)		/*		 * The directory was seek'ed to a senseless position or there		 * are no more entries.		 */		return 0;	if (file->f_pos == 1) {		/* Find the first entry in TNC and save it */		lowest_dent_key(c, &key, dir->i_ino);		nm.name = NULL;		dent = ubifs_tnc_next_ent(c, &key, &nm);		if (IS_ERR(dent)) {			err = PTR_ERR(dent);			goto out;		}		file->f_pos = key_hash_flash(c, &dent->key);		file->private_data = dent;	}	dent = file->private_data;	if (!dent) {		/*		 * The directory was seek'ed to and is now readdir'ed.		 * Find the entry corresponding to @file->f_pos or the		 * closest one.		 */		dent_key_init_hash(c, &key, dir->i_ino, file->f_pos);		nm.name = NULL;		dent = ubifs_tnc_next_ent(c, &key, &nm);		if (IS_ERR(dent)) {			err = PTR_ERR(dent);			goto out;		}		file->f_pos = key_hash_flash(c, &dent->key);		file->private_data = dent;	}	while (1) {		dbg_gen("feed '%s', ino %llu, new f_pos %#x",			dent->name, (unsigned long long)le64_to_cpu(dent->inum),			key_hash_flash(c, &dent->key));		ubifs_assert(le64_to_cpu(dent->ch.sqnum) > ubifs_inode(dir)->creat_sqnum);		nm.len = le16_to_cpu(dent->nlen);		over = filldir(c, (char *)dent->name, nm.len,			       le64_to_cpu(dent->inum), dent->type);		if (over)			return 0;		/* Switch to the next entry */		key_read(c, &dent->key, &key);		nm.name = (char *)dent->name;		dent = ubifs_tnc_next_ent(c, &key, &nm);		if (IS_ERR(dent)) {			err = PTR_ERR(dent);			goto out;		}		kfree(file->private_data);		file->f_pos = key_hash_flash(c, &dent->key);		file->private_data = dent;		cond_resched();	}out:	if (err != -ENOENT) {		ubifs_err("cannot find next direntry, error %d", err);		return err;	}	kfree(file->private_data);	file->private_data = NULL;	file->f_pos = 2;	return 0;}
开发者ID:dhs-shine,项目名称:sprd_project,代码行数:88,


示例18: ubifs_finddir

static int ubifs_finddir(struct super_block *sb, char *dirname,			 unsigned long root_inum, unsigned long *inum){	int err;	struct qstr nm;	union ubifs_key key;	struct ubifs_dent_node *dent;	struct ubifs_info *c;	struct file *file;	struct dentry *dentry;	struct inode *dir;	file = kzalloc(sizeof(struct file), 0);	dentry = kzalloc(sizeof(struct dentry), 0);	dir = kzalloc(sizeof(struct inode), 0);	if (!file || !dentry || !dir) {		printf("%s: Error, no memory for malloc!/n", __func__);		err = -ENOMEM;		goto out;	}	dir->i_sb = sb;	file->f_path.dentry = dentry;	file->f_path.dentry->d_parent = dentry;	file->f_path.dentry->d_inode = dir;	file->f_path.dentry->d_inode->i_ino = root_inum;	c = sb->s_fs_info;	dbg_gen("dir ino %lu, f_pos %#llx", dir->i_ino, file->f_pos);	/* Find the first entry in TNC and save it */	lowest_dent_key(c, &key, dir->i_ino);	nm.name = NULL;	dent = ubifs_tnc_next_ent(c, &key, &nm);	if (IS_ERR(dent)) {		err = PTR_ERR(dent);		goto out;	}	file->f_pos = key_hash_flash(c, &dent->key);	file->private_data = dent;	while (1) {		dbg_gen("feed '%s', ino %llu, new f_pos %#x",			dent->name, (unsigned long long)le64_to_cpu(dent->inum),			key_hash_flash(c, &dent->key));		ubifs_assert(le64_to_cpu(dent->ch.sqnum) > ubifs_inode(dir)->creat_sqnum);		nm.len = le16_to_cpu(dent->nlen);		if ((strncmp(dirname, (char *)dent->name, nm.len) == 0) &&		    (strlen(dirname) == nm.len)) {			*inum = le64_to_cpu(dent->inum);			return 1;		}		/* Switch to the next entry */		key_read(c, &dent->key, &key);		nm.name = (char *)dent->name;		dent = ubifs_tnc_next_ent(c, &key, &nm);		if (IS_ERR(dent)) {			err = PTR_ERR(dent);			goto out;		}		kfree(file->private_data);		file->f_pos = key_hash_flash(c, &dent->key);		file->private_data = dent;		cond_resched();	}out:	if (err != -ENOENT) {		ubifs_err("cannot find next direntry, error %d", err);		return err;	}	if (file)		free(file);	if (dentry)		free(dentry);	if (dir)		free(dir);	if (file->private_data)		kfree(file->private_data);	file->private_data = NULL;	file->f_pos = 2;	return 0;}
开发者ID:dhs-shine,项目名称:sprd_project,代码行数:89,


示例19: ubifs_findfile

static unsigned long ubifs_findfile(struct super_block *sb, char *filename){	int ret;	char *next;	char fpath[128];	char symlinkpath[128];	char *name = fpath;	unsigned long root_inum = 1;	unsigned long inum;	int symlink_count = 0; /* Don't allow symlink recursion */	char link_name[64];	strcpy(fpath, filename);	/* Remove all leading slashes */	while (*name == '/')		name++;	/*	 * Handle root-direcoty ('/')	 */	inum = root_inum;	if (!name || *name == '/0')		return inum;	for (;;) {		struct inode *inode;		struct ubifs_inode *ui;		/* Extract the actual part from the pathname.  */		next = strchr(name, '/');		if (next) {			/* Remove all leading slashes.  */			while (*next == '/')				*(next++) = '/0';		}		ret = ubifs_finddir(sb, name, root_inum, &inum);		if (!ret)			return 0;		inode = ubifs_iget(sb, inum);		if (!inode)			return 0;		ui = ubifs_inode(inode);		if ((inode->i_mode & S_IFMT) == S_IFLNK) {			char buf[128];			/* We have some sort of symlink recursion, bail out */			if (symlink_count++ > 8) {				printf("Symlink recursion, aborting/n");				return 0;			}			memcpy(link_name, ui->data, ui->data_len);			link_name[ui->data_len] = '/0';			if (link_name[0] == '/') {				/* Absolute path, redo everything without				 * the leading slash */				next = name = link_name + 1;				root_inum = 1;				continue;			}			/* Relative to cur dir */			sprintf(buf, "%s/%s",					link_name, next == NULL ? "" : next);			memcpy(symlinkpath, buf, sizeof(buf));			next = name = symlinkpath;			continue;		}		/*		 * Check if directory with this name exists		 */		/* Found the node!  */		if (!next || *next == '/0')			return inum;		root_inum = inum;		name = next;	}	return 0;}
开发者ID:dhs-shine,项目名称:sprd_project,代码行数:86,


示例20: ubifs_part_load

int ubifs_part_load(char *filename, u32 addr, u32 offset, u32 size){    struct ubifs_info *c = ubifs_sb->s_fs_info;    unsigned long inum=0;    struct inode *inode=NULL;    struct page page;    int err = 0;    int i=0;    int count=0;	int last_block_size = 0;    char link_name[64];    struct ubifs_inode *ui=NULL;        if(offset % PAGE_SIZE != 0)    {        printf("%s: offset(0x%x) should align to page size(0x%x), at %d/n", __func__, offset, PAGE_SIZE, __LINE__);        return 1;    }    c->ubi = ubi_open_volume(c->vi.ubi_num, c->vi.vol_id, UBI_READONLY);    if (IS_ERR(c->ubi)) {        err = PTR_ERR(c->ubi);        goto out_no_close;    }    inum = ubifs_findfile(ubifs_sb, filename);    if (!inum) {        err = -1;        goto out;    }    /*    * Read file inode    */    inode = ubifs_iget(ubifs_sb, inum);    if (IS_ERR(inode)) {        printf("%s: Error reading inode %ld!/n", __func__, inum);        err = PTR_ERR(inode);        goto out;    }    /*    * Check for symbolic link    */    ui = ubifs_inode(inode);    if (((inode->i_mode & S_IFMT) == S_IFLNK) && ui->data_len) {        memcpy(link_name, ui->data, ui->data_len);        link_name[ui->data_len] = '/0';        printf("%s is linked to %s!/n", filename, link_name);        ubifs_iput(inode);        /*         * Now we have the "real" filename, call ubifs_load()         * again (recursive call) to load this file instead         */        return ubifs_part_load(link_name, addr, offset, size);    }    /*    * If no size was specified or if size bigger than filesize    * set size to filesize    */    if ((size == 0) || (size > inode->i_size))        size = inode->i_size;    count = (size + UBIFS_BLOCK_SIZE - 1) >> UBIFS_BLOCK_SHIFT;    printf("Loading file '%s' to addr 0x%08x with size %d (0x%08x).../n",        filename, addr, size, size);    page.addr = (void *)addr;    page.index = (offset / PAGE_SIZE);    page.inode = inode;    //offset    for (i = 0; i < count; i++) {		/*		 * Make sure to not read beyond the requested size		 */		if (((i + 1) == count) && (size < inode->i_size))			last_block_size = size - (i * PAGE_SIZE);        err = do_readpage(c, inode, &page, last_block_size);        if (err)            break;        page.addr += PAGE_SIZE;        page.index++;    }    if (err)        printf("Error reading file '%s'/n", filename);    else        printf("Done/n");    ubifs_iput(inode);out:    ubi_close_volume(c->ubi);out_no_close:	return err;}
开发者ID:Scorpio92,项目名称:mstar6a918,代码行数:99,



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


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