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

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

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

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

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

示例1: fscrypt_get_encryption_info

/** * 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, struct inode *dir,			      umode_t mode){	int err;	struct inode *inode;	struct ubifs_inode *ui;	bool encrypted = false;	if (ubifs_crypt_is_encrypted(dir)) {		err = fscrypt_get_encryption_info(dir);		if (err) {			ubifs_err(c, "fscrypt_get_encryption_info failed: %i", err);			return ERR_PTR(err);		}		if (!fscrypt_has_encryption_key(dir))			return ERR_PTR(-EPERM);		encrypted = true;	}	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 =			 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;		encrypted = false;		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,//.........这里部分代码省略.........
开发者ID:SantoshShilimkar,项目名称:linux,代码行数:101,


示例2: ubifs_read_superblock

/** * ubifs_read_superblock - read superblock. * @c: UBIFS file-system description object * * This function finds, reads and checks the superblock. If an empty UBI volume * is being mounted, this function creates default superblock. Returns zero in * case of success, and a negative error code in case of failure. */int ubifs_read_superblock(struct ubifs_info *c){	int err, sup_flags;	struct ubifs_sb_node *sup;	if (c->empty) {		err = create_default_filesystem(c);		if (err)			return err;	}	sup = ubifs_read_sb_node(c);	if (IS_ERR(sup))		return PTR_ERR(sup);	c->fmt_version = le32_to_cpu(sup->fmt_version);	c->ro_compat_version = le32_to_cpu(sup->ro_compat_version);	/*	 * The software supports all previous versions but not future versions,	 * due to the unavailability of time-travelling equipment.	 */	if (c->fmt_version > UBIFS_FORMAT_VERSION) {		ubifs_assert(!c->ro_media || c->ro_mount);		if (!c->ro_mount ||		    c->ro_compat_version > UBIFS_RO_COMPAT_VERSION) {			ubifs_err(c, "on-flash format version is w%d/r%d, but software only supports up to version w%d/r%d",				  c->fmt_version, c->ro_compat_version,				  UBIFS_FORMAT_VERSION,				  UBIFS_RO_COMPAT_VERSION);			if (c->ro_compat_version <= UBIFS_RO_COMPAT_VERSION) {				ubifs_msg(c, "only R/O mounting is possible");				err = -EROFS;			} else				err = -EINVAL;			goto out;		}		/*		 * The FS is mounted R/O, and the media format is		 * R/O-compatible with the UBIFS implementation, so we can		 * mount.		 */		c->rw_incompat = 1;	}	if (c->fmt_version < 3) {		ubifs_err(c, "on-flash format version %d is not supported",			  c->fmt_version);		err = -EINVAL;		goto out;	}	switch (sup->key_hash) {	case UBIFS_KEY_HASH_R5:		c->key_hash = key_r5_hash;		c->key_hash_type = UBIFS_KEY_HASH_R5;		break;	case UBIFS_KEY_HASH_TEST:		c->key_hash = key_test_hash;		c->key_hash_type = UBIFS_KEY_HASH_TEST;		break;	};	c->key_fmt = sup->key_fmt;	switch (c->key_fmt) {	case UBIFS_SIMPLE_KEY_FMT:		c->key_len = UBIFS_SK_LEN;		break;	default:		ubifs_err(c, "unsupported key format");		err = -EINVAL;		goto out;	}	c->leb_cnt       = le32_to_cpu(sup->leb_cnt);	c->max_leb_cnt   = le32_to_cpu(sup->max_leb_cnt);	c->max_bud_bytes = le64_to_cpu(sup->max_bud_bytes);	c->log_lebs      = le32_to_cpu(sup->log_lebs);	c->lpt_lebs      = le32_to_cpu(sup->lpt_lebs);	c->orph_lebs     = le32_to_cpu(sup->orph_lebs);	c->jhead_cnt     = le32_to_cpu(sup->jhead_cnt) + NONDATA_JHEADS_CNT;	c->fanout        = le32_to_cpu(sup->fanout);	c->lsave_cnt     = le32_to_cpu(sup->lsave_cnt);	c->rp_size       = le64_to_cpu(sup->rp_size);	c->rp_uid        = make_kuid(&init_user_ns, le32_to_cpu(sup->rp_uid));	c->rp_gid        = make_kgid(&init_user_ns, le32_to_cpu(sup->rp_gid));	sup_flags        = le32_to_cpu(sup->flags);	if (!c->mount_opts.override_compr)		c->default_compr = le16_to_cpu(sup->default_compr);//.........这里部分代码省略.........
开发者ID:020gzh,项目名称:linux,代码行数:101,


示例3: ubifs_create

static int ubifs_create(struct inode *dir, struct dentry *dentry, umode_t 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 %#hx 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;}/** * 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 * properly by means of saving full directory entry name in the private field * of the file description object. * * This means that UBIFS cannot support NFS which requires full * 'seekdir()'/'telldir()' support.//.........这里部分代码省略.........
开发者ID:AnwariJr,项目名称:Zenfone-Kernel,代码行数:101,


示例4: ubifs_read_node_wbuf

/** * ubifs_read_node_wbuf - read node from the media or write-buffer. * @wbuf: wbuf to check for un-written data * @buf: buffer to read to * @type: node type * @len: node length * @lnum: logical eraseblock number * @offs: offset within the logical eraseblock * * This function reads a node of known type and length, checks it and stores * in @buf. If the node partially or fully sits in the write-buffer, this * function takes data from the buffer, otherwise it reads the flash media. * Returns zero in case of success, %-EUCLEAN if CRC mismatched and a negative * error code in case of failure. */int ubifs_read_node_wbuf(struct ubifs_wbuf *wbuf, void *buf, int type, int len,			 int lnum, int offs){	const struct ubifs_info *c = wbuf->c;	int err, rlen, overlap;	struct ubifs_ch *ch = buf;	dbg_io("LEB %d:%d, %s, length %d, jhead %s", lnum, offs,	       dbg_ntype(type), len, dbg_jhead(wbuf->jhead));	ubifs_assert(wbuf && lnum >= 0 && lnum < c->leb_cnt && offs >= 0);	ubifs_assert(!(offs & 7) && offs < c->leb_size);	ubifs_assert(type >= 0 && type < UBIFS_NODE_TYPES_CNT);	spin_lock(&wbuf->lock);	overlap = (lnum == wbuf->lnum && offs + len > wbuf->offs);	if (!overlap) {		/* We may safely unlock the write-buffer and read the data */		spin_unlock(&wbuf->lock);		return ubifs_read_node(c, buf, type, len, lnum, offs);	}	/* Don't read under wbuf */	rlen = wbuf->offs - offs;	if (rlen < 0)		rlen = 0;	/* Copy the rest from the write-buffer */	memcpy(buf + rlen, wbuf->buf + offs + rlen - wbuf->offs, len - rlen);	spin_unlock(&wbuf->lock);	if (rlen > 0) {		/* Read everything that goes before write-buffer */		err = ubi_read(c->ubi, lnum, buf, offs, rlen);		if (err && err != -EBADMSG) {			ubifs_err("failed to read node %d from LEB %d:%d, "				  "error %d", type, lnum, offs, err);			dbg_dump_stack();			return err;		}	}	if (type != ch->node_type) {		ubifs_err("bad node type (%d but expected %d)",			  ch->node_type, type);		goto out;	}	err = ubifs_check_node(c, buf, lnum, offs, 0, 0);	if (err) {		ubifs_err("expected node type %d", type);		return err;	}	rlen = le32_to_cpu(ch->len);	if (rlen != len) {		ubifs_err("bad node length %d, expected %d", rlen, len);		goto out;	}	return 0;out:	ubifs_err("bad node at LEB %d:%d", lnum, offs);	dbg_dump_node(c, buf);	dbg_dump_stack();	return -EINVAL;}
开发者ID:rrowicki,项目名称:Chrono_Kernel-1,代码行数:82,


示例5: do_readpage

static int do_readpage(struct ubifs_info *c, struct inode *inode, struct page *page){	void *addr;	int err = 0, i;	unsigned int block, beyond;	struct ubifs_data_node *dn;	loff_t i_size = inode->i_size;	dbg_gen("ino %lu, pg %lu, i_size %lld",		inode->i_ino, page->index, i_size);	addr = kmap(page);	block = page->index << UBIFS_BLOCKS_PER_PAGE_SHIFT;	beyond = (i_size + UBIFS_BLOCK_SIZE - 1) >> UBIFS_BLOCK_SHIFT;	if (block >= beyond) {		/* Reading beyond inode */		memset(addr, 0, PAGE_CACHE_SIZE);		goto out;	}	dn = kmalloc(UBIFS_MAX_DATA_NODE_SZ, GFP_NOFS);	if (!dn) {		err = -ENOMEM;		goto error;	}	i = 0;	while (1) {		int ret;		if (block >= beyond) {			/* Reading beyond inode */			err = -ENOENT;			memset(addr, 0, UBIFS_BLOCK_SIZE);		} else {			ret = read_block(inode, addr, block, dn);			if (ret) {				err = ret;				if (err != -ENOENT)					break;			} else if (block + 1 == beyond) {				int dlen = le32_to_cpu(dn->size);				int ilen = i_size & (UBIFS_BLOCK_SIZE - 1);				if (ilen && ilen < dlen)					memset(addr + ilen, 0, dlen - ilen);			}		}		if (++i >= UBIFS_BLOCKS_PER_PAGE)			break;		block += 1;		addr += UBIFS_BLOCK_SIZE;	}	if (err) {		if (err == -ENOENT) {			/* Not found, so it must be a hole */			dbg_gen("hole");			goto out_free;		}		ubifs_err("cannot read page %lu of inode %lu, error %d",			  page->index, inode->i_ino, err);		goto error;	}out_free:	kfree(dn);out:	return 0;error:	kfree(dn);	return err;}
开发者ID:OpenInkpot-archive,项目名称:uboot-n516,代码行数:74,


示例6: ubifs_wbuf_sync_nolock

/** * ubifs_wbuf_sync_nolock - synchronize write-buffer. * @wbuf: write-buffer to synchronize * * This function synchronizes write-buffer @buf and returns zero in case of * success or a negative error code in case of failure. * * Note, although write-buffers are of @c->max_write_size, this function does * not necessarily writes all @c->max_write_size bytes to the flash. Instead, * if the write-buffer is only partially filled with data, only the used part * of the write-buffer (aligned on @c->min_io_size boundary) is synchronized. * This way we waste less space. */int ubifs_wbuf_sync_nolock(struct ubifs_wbuf *wbuf){	struct ubifs_info *c = wbuf->c;	int err, dirt, sync_len;	cancel_wbuf_timer_nolock(wbuf);	if (!wbuf->used || wbuf->lnum == -1)		/* Write-buffer is empty or not seeked */		return 0;	dbg_io("LEB %d:%d, %d bytes, jhead %s",	       wbuf->lnum, wbuf->offs, wbuf->used, dbg_jhead(wbuf->jhead));	ubifs_assert(!(wbuf->avail & 7));	ubifs_assert(wbuf->offs + wbuf->size <= c->leb_size);	ubifs_assert(wbuf->size >= c->min_io_size);	ubifs_assert(wbuf->size <= c->max_write_size);	ubifs_assert(wbuf->size % c->min_io_size == 0);	ubifs_assert(!c->ro_media && !c->ro_mount);	if (c->leb_size - wbuf->offs >= c->max_write_size)		ubifs_assert(!((wbuf->offs + wbuf->size) % c->max_write_size));	if (c->ro_error)		return -EROFS;	/*	 * Do not write whole write buffer but write only the minimum necessary	 * amount of min. I/O units.	 */	sync_len = ALIGN(wbuf->used, c->min_io_size);	dirt = sync_len - wbuf->used;	if (dirt)		ubifs_pad(c, wbuf->buf + wbuf->used, dirt);	err = ubi_leb_write(c->ubi, wbuf->lnum, wbuf->buf, wbuf->offs,			    sync_len, wbuf->dtype);	if (err) {		ubifs_err("cannot write %d bytes to LEB %d:%d",			  sync_len, wbuf->lnum, wbuf->offs);		dbg_dump_stack();		return err;	}	spin_lock(&wbuf->lock);	wbuf->offs += sync_len;	/*	 * Now @wbuf->offs is not necessarily aligned to @c->max_write_size.	 * But our goal is to optimize writes and make sure we write in	 * @c->max_write_size chunks and to @c->max_write_size-aligned offset.	 * Thus, if @wbuf->offs is not aligned to @c->max_write_size now, make	 * sure that @wbuf->offs + @wbuf->size is aligned to	 * @c->max_write_size. This way we make sure that after next	 * write-buffer flush we are again at the optimal offset (aligned to	 * @c->max_write_size).	 */	if (c->leb_size - wbuf->offs < c->max_write_size)		wbuf->size = c->leb_size - wbuf->offs;	else if (wbuf->offs & (c->max_write_size - 1))		wbuf->size = ALIGN(wbuf->offs, c->max_write_size) - wbuf->offs;	else		wbuf->size = c->max_write_size;	wbuf->avail = wbuf->size;	wbuf->used = 0;	wbuf->next_ino = 0;	spin_unlock(&wbuf->lock);	if (wbuf->sync_callback)		err = wbuf->sync_callback(c, wbuf->lnum,					  c->leb_size - wbuf->offs, dirt);	return err;}
开发者ID:rrowicki,项目名称:Chrono_Kernel-1,代码行数:82,


示例7: mount_ubifs

/** * mount_ubifs - mount UBIFS file-system. * @c: UBIFS file-system description object * * This function mounts UBIFS file system. Returns zero in case of success and * a negative error code in case of failure. * * Note, the function does not de-allocate resources it it fails half way * through, and the caller has to do this instead. */static int mount_ubifs(struct ubifs_info *c){	struct super_block *sb = c->vfs_sb;	int err, mounted_read_only = (sb->s_flags & MS_RDONLY);	long long x;	size_t sz;	err = init_constants_early(c);	if (err)		return err;	err = ubifs_debugging_init(c);	if (err)		return err;	err = check_volume_empty(c);	if (err)		goto out_free;	if (c->empty && (mounted_read_only || c->ro_media)) {		/*		 * This UBI volume is empty, and read-only, or the file system		 * is mounted read-only - we cannot format it.		 */		ubifs_err("can't format empty UBI volume: read-only %s",			  c->ro_media ? "UBI volume" : "mount");		err = -EROFS;		goto out_free;	}	if (c->ro_media && !mounted_read_only) {		ubifs_err("cannot mount read-write - read-only media");		err = -EROFS;		goto out_free;	}	/*	 * The requirement for the buffer is that it should fit indexing B-tree	 * height amount of integers. We assume the height if the TNC tree will	 * never exceed 64.	 */	err = -ENOMEM;	c->bottom_up_buf = kmalloc(BOTTOM_UP_HEIGHT * sizeof(int), GFP_KERNEL);	if (!c->bottom_up_buf)		goto out_free;	c->sbuf = vmalloc(c->leb_size);	if (!c->sbuf)		goto out_free;	/*	 * We have to check all CRCs, even for data nodes, when we mount the FS	 * (specifically, when we are replaying).	 */	c->always_chk_crc = 1;	err = ubifs_read_superblock(c);	if (err)		goto out_free;	/*	 * Make sure the compressor which is set as default in the superblock	 * or overridden by mount options is actually compiled in.	 */	if (!ubifs_compr_present(c->default_compr)) {		ubifs_err("'compressor /"%s/" is not compiled in",			  ubifs_compr_name(c->default_compr));		goto out_free;	}	dbg_failure_mode_registration(c);	err = init_constants_sb(c);	if (err)		goto out_free;	sz = ALIGN(c->max_idx_node_sz, c->min_io_size);	sz = ALIGN(sz + c->max_idx_node_sz, c->min_io_size);	c->cbuf = kmalloc(sz, GFP_NOFS);	if (!c->cbuf) {		err = -ENOMEM;		goto out_free;	}	sprintf(c->bgt_name, BGT_NAME_PATTERN, c->vi.ubi_num, c->vi.vol_id);	err = ubifs_read_master(c);	if (err)		goto out_master;//.........这里部分代码省略.........
开发者ID:0s4l,项目名称:u-boot-xlnx,代码行数:101,


示例8: ubifs_fill_super

static int ubifs_fill_super(struct super_block *sb, void *data, int silent){	struct ubi_volume_desc *ubi = sb->s_fs_info;	struct ubifs_info *c;	struct inode *root;	int err;	c = kzalloc(sizeof(struct ubifs_info), GFP_KERNEL);	if (!c)		return -ENOMEM;	spin_lock_init(&c->cnt_lock);	spin_lock_init(&c->cs_lock);	spin_lock_init(&c->buds_lock);	spin_lock_init(&c->space_lock);	spin_lock_init(&c->orphan_lock);	init_rwsem(&c->commit_sem);	mutex_init(&c->lp_mutex);	mutex_init(&c->tnc_mutex);	mutex_init(&c->log_mutex);	mutex_init(&c->mst_mutex);	mutex_init(&c->umount_mutex);	init_waitqueue_head(&c->cmt_wq);	c->buds = RB_ROOT;	c->old_idx = RB_ROOT;	c->size_tree = RB_ROOT;	c->orph_tree = RB_ROOT;	INIT_LIST_HEAD(&c->infos_list);	INIT_LIST_HEAD(&c->idx_gc);	INIT_LIST_HEAD(&c->replay_list);	INIT_LIST_HEAD(&c->replay_buds);	INIT_LIST_HEAD(&c->uncat_list);	INIT_LIST_HEAD(&c->empty_list);	INIT_LIST_HEAD(&c->freeable_list);	INIT_LIST_HEAD(&c->frdi_idx_list);	INIT_LIST_HEAD(&c->unclean_leb_list);	INIT_LIST_HEAD(&c->old_buds);	INIT_LIST_HEAD(&c->orph_list);	INIT_LIST_HEAD(&c->orph_new);	c->highest_inum = UBIFS_FIRST_INO;	c->lhead_lnum = c->ltail_lnum = UBIFS_LOG_LNUM;	ubi_get_volume_info(ubi, &c->vi);	ubi_get_device_info(c->vi.ubi_num, &c->di);	/* Re-open the UBI device in read-write mode */	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_free;	}	c->vfs_sb = sb;	sb->s_fs_info = c;	sb->s_magic = UBIFS_SUPER_MAGIC;	sb->s_blocksize = UBIFS_BLOCK_SIZE;	sb->s_blocksize_bits = UBIFS_BLOCK_SHIFT;	sb->s_dev = c->vi.cdev;	sb->s_maxbytes = c->max_inode_sz = key_max_inode_size(c);	if (c->max_inode_sz > MAX_LFS_FILESIZE)		sb->s_maxbytes = c->max_inode_sz = MAX_LFS_FILESIZE;	if (c->rw_incompat) {		ubifs_err("the file-system is not R/W-compatible");		ubifs_msg("on-flash format version is w%d/r%d, but software "			  "only supports up to version w%d/r%d", c->fmt_version,			  c->ro_compat_version, UBIFS_FORMAT_VERSION,			  UBIFS_RO_COMPAT_VERSION);		return -EROFS;	}	mutex_lock(&c->umount_mutex);	err = mount_ubifs(c);	if (err) {		ubifs_assert(err < 0);		goto out_unlock;	}	/* Read the root inode */	root = ubifs_iget(sb, UBIFS_ROOT_INO);	if (IS_ERR(root)) {		err = PTR_ERR(root);		goto out_umount;	}	sb->s_root = NULL;	mutex_unlock(&c->umount_mutex);	return 0;out_umount:	ubifs_umount(c);out_unlock:	mutex_unlock(&c->umount_mutex);	ubi_close_volume(c->ubi);out_free:	kfree(c);	return err;//.........这里部分代码省略.........
开发者ID:0s4l,项目名称:u-boot-xlnx,代码行数:101,


示例9: 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,


示例10: init_constants_early

/** * init_constants_early - initialize UBIFS constants. * @c: UBIFS file-system description object * * This function initialize UBIFS constants which do not need the superblock to * be read. It also checks that the UBI volume satisfies basic UBIFS * requirements. Returns zero in case of success and a negative error code in * case of failure. */static int init_constants_early(struct ubifs_info *c){	if (c->vi.corrupted) {		ubifs_warn("UBI volume is corrupted - read-only mode");		c->ro_media = 1;	}	if (c->di.ro_mode) {		ubifs_msg("read-only UBI device");		c->ro_media = 1;	}	if (c->vi.vol_type == UBI_STATIC_VOLUME) {		ubifs_msg("static UBI volume - read-only mode");		c->ro_media = 1;	}	c->leb_cnt = c->vi.size;	c->leb_size = c->vi.usable_leb_size;	c->half_leb_size = c->leb_size / 2;	c->min_io_size = c->di.min_io_size;	c->min_io_shift = fls(c->min_io_size) - 1;	if (c->leb_size < UBIFS_MIN_LEB_SZ) {		ubifs_err("too small LEBs (%d bytes), min. is %d bytes",			  c->leb_size, UBIFS_MIN_LEB_SZ);		return -EINVAL;	}	if (c->leb_cnt < UBIFS_MIN_LEB_CNT) {		ubifs_err("too few LEBs (%d), min. is %d",			  c->leb_cnt, UBIFS_MIN_LEB_CNT);		return -EINVAL;	}	if (!is_power_of_2(c->min_io_size)) {		ubifs_err("bad min. I/O size %d", c->min_io_size);		return -EINVAL;	}	/*	 * UBIFS aligns all node to 8-byte boundary, so to make function in	 * io.c simpler, assume minimum I/O unit size to be 8 bytes if it is	 * less than 8.	 */	if (c->min_io_size < 8) {		c->min_io_size = 8;		c->min_io_shift = 3;	}	c->ref_node_alsz = ALIGN(UBIFS_REF_NODE_SZ, c->min_io_size);	c->mst_node_alsz = ALIGN(UBIFS_MST_NODE_SZ, c->min_io_size);	/*	 * Initialize node length ranges which are mostly needed for node	 * length validation.	 */	c->ranges[UBIFS_PAD_NODE].len  = UBIFS_PAD_NODE_SZ;	c->ranges[UBIFS_SB_NODE].len   = UBIFS_SB_NODE_SZ;	c->ranges[UBIFS_MST_NODE].len  = UBIFS_MST_NODE_SZ;	c->ranges[UBIFS_REF_NODE].len  = UBIFS_REF_NODE_SZ;	c->ranges[UBIFS_TRUN_NODE].len = UBIFS_TRUN_NODE_SZ;	c->ranges[UBIFS_CS_NODE].len   = UBIFS_CS_NODE_SZ;	c->ranges[UBIFS_INO_NODE].min_len  = UBIFS_INO_NODE_SZ;	c->ranges[UBIFS_INO_NODE].max_len  = UBIFS_MAX_INO_NODE_SZ;	c->ranges[UBIFS_ORPH_NODE].min_len =				UBIFS_ORPH_NODE_SZ + sizeof(__le64);	c->ranges[UBIFS_ORPH_NODE].max_len = c->leb_size;	c->ranges[UBIFS_DENT_NODE].min_len = UBIFS_DENT_NODE_SZ;	c->ranges[UBIFS_DENT_NODE].max_len = UBIFS_MAX_DENT_NODE_SZ;	c->ranges[UBIFS_XENT_NODE].min_len = UBIFS_XENT_NODE_SZ;	c->ranges[UBIFS_XENT_NODE].max_len = UBIFS_MAX_XENT_NODE_SZ;	c->ranges[UBIFS_DATA_NODE].min_len = UBIFS_DATA_NODE_SZ;	c->ranges[UBIFS_DATA_NODE].max_len = UBIFS_MAX_DATA_NODE_SZ;	/*	 * Minimum indexing node size is amended later when superblock is	 * read and the key length is known.	 */	c->ranges[UBIFS_IDX_NODE].min_len = UBIFS_IDX_NODE_SZ + UBIFS_BRANCH_SZ;	/*	 * Maximum indexing node size is amended later when superblock is	 * read and the fanout is known.	 */	c->ranges[UBIFS_IDX_NODE].max_len = INT_MAX;	/*	 * Initialize dead and dark LEB space watermarks. See gc.c for comments	 * about these values.	 */	c->dead_wm = ALIGN(MIN_WRITE_SZ, c->min_io_size);//.........这里部分代码省略.........
开发者ID:0s4l,项目名称:u-boot-xlnx,代码行数:101,


示例11: ubifs_init

int __init ubifs_init(void){	int err;	BUILD_BUG_ON(sizeof(struct ubifs_ch) != 24);	/* Make sure node sizes are 8-byte aligned */	BUILD_BUG_ON(UBIFS_CH_SZ        & 7);	BUILD_BUG_ON(UBIFS_INO_NODE_SZ  & 7);	BUILD_BUG_ON(UBIFS_DENT_NODE_SZ & 7);	BUILD_BUG_ON(UBIFS_XENT_NODE_SZ & 7);	BUILD_BUG_ON(UBIFS_DATA_NODE_SZ & 7);	BUILD_BUG_ON(UBIFS_TRUN_NODE_SZ & 7);	BUILD_BUG_ON(UBIFS_SB_NODE_SZ   & 7);	BUILD_BUG_ON(UBIFS_MST_NODE_SZ  & 7);	BUILD_BUG_ON(UBIFS_REF_NODE_SZ  & 7);	BUILD_BUG_ON(UBIFS_CS_NODE_SZ   & 7);	BUILD_BUG_ON(UBIFS_ORPH_NODE_SZ & 7);	BUILD_BUG_ON(UBIFS_MAX_DENT_NODE_SZ & 7);	BUILD_BUG_ON(UBIFS_MAX_XENT_NODE_SZ & 7);	BUILD_BUG_ON(UBIFS_MAX_DATA_NODE_SZ & 7);	BUILD_BUG_ON(UBIFS_MAX_INO_NODE_SZ  & 7);	BUILD_BUG_ON(UBIFS_MAX_NODE_SZ      & 7);	BUILD_BUG_ON(MIN_WRITE_SZ           & 7);	/* Check min. node size */	BUILD_BUG_ON(UBIFS_INO_NODE_SZ  < MIN_WRITE_SZ);	BUILD_BUG_ON(UBIFS_DENT_NODE_SZ < MIN_WRITE_SZ);	BUILD_BUG_ON(UBIFS_XENT_NODE_SZ < MIN_WRITE_SZ);	BUILD_BUG_ON(UBIFS_TRUN_NODE_SZ < MIN_WRITE_SZ);	BUILD_BUG_ON(UBIFS_MAX_DENT_NODE_SZ > UBIFS_MAX_NODE_SZ);	BUILD_BUG_ON(UBIFS_MAX_XENT_NODE_SZ > UBIFS_MAX_NODE_SZ);	BUILD_BUG_ON(UBIFS_MAX_DATA_NODE_SZ > UBIFS_MAX_NODE_SZ);	BUILD_BUG_ON(UBIFS_MAX_INO_NODE_SZ  > UBIFS_MAX_NODE_SZ);	/* Defined node sizes */	BUILD_BUG_ON(UBIFS_SB_NODE_SZ  != 4096);	BUILD_BUG_ON(UBIFS_MST_NODE_SZ != 512);	BUILD_BUG_ON(UBIFS_INO_NODE_SZ != 160);	BUILD_BUG_ON(UBIFS_REF_NODE_SZ != 64);	/*	 * We use 2 bit wide bit-fields to store compression type, which should	 * be amended if more compressors are added. The bit-fields are:	 * @compr_type in 'struct ubifs_inode', @default_compr in	 * 'struct ubifs_info' and @compr_type in 'struct ubifs_mount_opts'.	 */	BUILD_BUG_ON(UBIFS_COMPR_TYPES_CNT > 4);	/*	 * We require that PAGE_CACHE_SIZE is greater-than-or-equal-to	 * UBIFS_BLOCK_SIZE. It is assumed that both are powers of 2.	 */	if (PAGE_CACHE_SIZE < UBIFS_BLOCK_SIZE) {		ubifs_err("VFS page cache size is %u bytes, but UBIFS requires"			  " at least 4096 bytes",			  (unsigned int)PAGE_CACHE_SIZE);		return -EINVAL;	}	err = -ENOMEM;	err = ubifs_compressors_init();	if (err)		goto out_shrinker;	return 0;out_shrinker:	return err;}
开发者ID:0s4l,项目名称:u-boot-xlnx,代码行数:73,


示例12: ubifs_get_sb

static int ubifs_get_sb(struct file_system_type *fs_type, int flags,			const char *name, void *data, struct vfsmount *mnt){	struct ubi_volume_desc *ubi;	struct ubi_volume_info vi;	struct super_block *sb;	int err;	dbg_gen("name %s, flags %#x", name, flags);	/*	 * Get UBI device number and volume ID. Mount it read-only so far	 * because this might be a new mount point, and UBI allows only one	 * read-write user at a time.	 */	ubi = open_ubi(name, UBI_READONLY);	if (IS_ERR(ubi)) {		ubifs_err("cannot open /"%s/", error %d",			  name, (int)PTR_ERR(ubi));		return PTR_ERR(ubi);	}	ubi_get_volume_info(ubi, &vi);	dbg_gen("opened ubi%d_%d", vi.ubi_num, vi.vol_id);	sb = sget(fs_type, &sb_test, &sb_set, &vi.cdev);	if (IS_ERR(sb)) {		err = PTR_ERR(sb);		goto out_close;	}	if (sb->s_root) {		/* A new mount point for already mounted UBIFS */		dbg_gen("this ubi volume is already mounted");		if ((flags ^ sb->s_flags) & MS_RDONLY) {			err = -EBUSY;			goto out_deact;		}	} else {		sb->s_flags = flags;		/*		 * Pass 'ubi' to 'fill_super()' in sb->s_fs_info where it is		 * replaced by 'c'.		 */		sb->s_fs_info = ubi;		err = ubifs_fill_super(sb, data, flags & MS_SILENT ? 1 : 0);		if (err)			goto out_deact;		/* We do not support atime */		sb->s_flags |= MS_ACTIVE | MS_NOATIME;	}	/* 'fill_super()' opens ubi again so we must close it here */	ubi_close_volume(ubi);	ubifs_sb = sb;	return 0;out_deact:	up_write(&sb->s_umount);out_close:	ubi_close_volume(ubi);	return err;}
开发者ID:0s4l,项目名称:u-boot-xlnx,代码行数:64,


示例13: 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,


示例14: 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:OpenInkpot-archive,项目名称:uboot-n516,代码行数:88,


示例15: ubifs_read_superblock

/** * ubifs_read_superblock - read superblock. * @c: UBIFS file-system description object * * This function finds, reads and checks the superblock. If an empty UBI volume * is being mounted, this function creates default superblock. Returns zero in * case of success, and a negative error code in case of failure. */int ubifs_read_superblock(struct ubifs_info *c){	int err, sup_flags;	struct ubifs_sb_node *sup;	if (c->empty) {		err = create_default_filesystem(c);		if (err)			return err;	}	sup = ubifs_read_sb_node(c);	if (IS_ERR(sup))		return PTR_ERR(sup);	/*	 * The software supports all previous versions but not future versions,	 * due to the unavailability of time-travelling equipment.	 */	c->fmt_version = le32_to_cpu(sup->fmt_version);	if (c->fmt_version > UBIFS_FORMAT_VERSION) {		ubifs_err("on-flash format version is %d, but software only "			  "supports up to version %d", c->fmt_version,			  UBIFS_FORMAT_VERSION);		err = -EINVAL;		goto out;	}	if (c->fmt_version < 3) {		ubifs_err("on-flash format version %d is not supported",			  c->fmt_version);		err = -EINVAL;		goto out;	}	switch (sup->key_hash) {	case UBIFS_KEY_HASH_R5:		c->key_hash = key_r5_hash;		c->key_hash_type = UBIFS_KEY_HASH_R5;		break;	case UBIFS_KEY_HASH_TEST:		c->key_hash = key_test_hash;		c->key_hash_type = UBIFS_KEY_HASH_TEST;		break;	};	c->key_fmt = sup->key_fmt;	switch (c->key_fmt) {	case UBIFS_SIMPLE_KEY_FMT:		c->key_len = UBIFS_SK_LEN;		break;	default:		ubifs_err("unsupported key format");		err = -EINVAL;		goto out;	}	c->leb_cnt       = le32_to_cpu(sup->leb_cnt);	c->max_leb_cnt   = le32_to_cpu(sup->max_leb_cnt);	c->max_bud_bytes = le64_to_cpu(sup->max_bud_bytes);	c->log_lebs      = le32_to_cpu(sup->log_lebs);	c->lpt_lebs      = le32_to_cpu(sup->lpt_lebs);	c->orph_lebs     = le32_to_cpu(sup->orph_lebs);	c->jhead_cnt     = le32_to_cpu(sup->jhead_cnt) + NONDATA_JHEADS_CNT;	c->fanout        = le32_to_cpu(sup->fanout);	c->lsave_cnt     = le32_to_cpu(sup->lsave_cnt);	c->rp_size       = le64_to_cpu(sup->rp_size);	c->rp_uid        = le32_to_cpu(sup->rp_uid);	c->rp_gid        = le32_to_cpu(sup->rp_gid);	sup_flags        = le32_to_cpu(sup->flags);	if (!c->mount_opts.override_compr)		c->default_compr = le16_to_cpu(sup->default_compr);	c->vfs_sb->s_time_gran = le32_to_cpu(sup->time_gran);	memcpy(&c->uuid, &sup->uuid, 16);	c->big_lpt = !!(sup_flags & UBIFS_FLG_BIGLPT);	/* Automatically increase file system size to the maximum size */	c->old_leb_cnt = c->leb_cnt;	if (c->leb_cnt < c->vi.size && c->leb_cnt < c->max_leb_cnt) {		c->leb_cnt = min_t(int, c->max_leb_cnt, c->vi.size);		if (c->vfs_sb->s_flags & MS_RDONLY)			dbg_mnt("Auto resizing (ro) from %d LEBs to %d LEBs",				c->old_leb_cnt,	c->leb_cnt);		else {			dbg_mnt("Auto resizing (sb) from %d LEBs to %d LEBs",				c->old_leb_cnt, c->leb_cnt);			sup->leb_cnt = cpu_to_le32(c->leb_cnt);			err = ubifs_write_sb_node(c, sup);			if (err)//.........这里部分代码省略.........
开发者ID:458941968,项目名称:mini2440-kernel-2.6.29,代码行数:101,


示例16: 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:OpenInkpot-archive,项目名称:uboot-n516,代码行数:89,


示例17: 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;}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;	/*	 * 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 = ubifs_budget_space(c, &req);	if (err)		return err;	err = ubifs_budget_space(c, &ino_req);	if (err) {		ubifs_release_budget(c, &req);		return err;	}	inode = ubifs_new_inode(c, dir, mode);	if (IS_ERR(inode)) {		err = PTR_ERR(inode);		goto out_budg;	}	ui = ubifs_inode(inode);	if (whiteout) {		init_special_inode(inode, inode->i_mode, WHITEOUT_DEV);		ubifs_assert(inode->i_op == &ubifs_file_inode_operations);	}	err = ubifs_init_security(dir, inode, &dentry->d_name);//.........这里部分代码省略.........
开发者ID:acton393,项目名称:linux,代码行数:101,


示例18: ubifs_check_node

/** * ubifs_check_node - check node. * @c: UBIFS file-system description object * @buf: node to check * @lnum: logical eraseblock number * @offs: offset within the logical eraseblock * @quiet: print no messages * @must_chk_crc: indicates whether to always check the CRC * * This function checks node magic number and CRC checksum. This function also * validates node length to prevent UBIFS from becoming crazy when an attacker * feeds it a file-system image with incorrect nodes. For example, too large * node length in the common header could cause UBIFS to read memory outside of * allocated buffer when checking the CRC checksum. * * This function may skip data nodes CRC checking if @c->no_chk_data_crc is * true, which is controlled by corresponding UBIFS mount option. However, if * @must_chk_crc is true, then @c->no_chk_data_crc is ignored and CRC is * checked. Similarly, if @c->mounting or @c->remounting_rw is true (we are * mounting or re-mounting to R/W mode), @c->no_chk_data_crc is ignored and CRC * is checked. This is because during mounting or re-mounting from R/O mode to * R/W mode we may read journal nodes (when replying the journal or doing the * recovery) and the journal nodes may potentially be corrupted, so checking is * required. * * This function returns zero in case of success and %-EUCLEAN in case of bad * CRC or magic. */int ubifs_check_node(const struct ubifs_info *c, const void *buf, int lnum,		     int offs, int quiet, int must_chk_crc){	int err = -EINVAL, type, node_len;	uint32_t crc, node_crc, magic;	const struct ubifs_ch *ch = buf;	ubifs_assert(lnum >= 0 && lnum < c->leb_cnt && offs >= 0);	ubifs_assert(!(offs & 7) && offs < c->leb_size);	magic = le32_to_cpu(ch->magic);	if (magic != UBIFS_NODE_MAGIC) {		if (!quiet)			ubifs_err("bad magic %#08x, expected %#08x",				  magic, UBIFS_NODE_MAGIC);		err = -EUCLEAN;		goto out;	}	type = ch->node_type;	if (type < 0 || type >= UBIFS_NODE_TYPES_CNT) {		if (!quiet)			ubifs_err("bad node type %d", type);		goto out;	}	node_len = le32_to_cpu(ch->len);	if (node_len + offs > c->leb_size)		goto out_len;	if (c->ranges[type].max_len == 0) {		if (node_len != c->ranges[type].len)			goto out_len;	} else if (node_len < c->ranges[type].min_len ||		   node_len > c->ranges[type].max_len)		goto out_len;	if (!must_chk_crc && type == UBIFS_DATA_NODE && !c->mounting &&	    !c->remounting_rw && c->no_chk_data_crc)		return 0;	crc = crc32(UBIFS_CRC32_INIT, buf + 8, node_len - 8);	node_crc = le32_to_cpu(ch->crc);	if (crc != node_crc) {		if (!quiet)			ubifs_err("bad CRC: calculated %#08x, read %#08x",				  crc, node_crc);		err = -EUCLEAN;		goto out;	}	return 0;out_len:	if (!quiet)		ubifs_err("bad node length %d", node_len);out:	if (!quiet) {		ubifs_err("bad node at LEB %d:%d", lnum, offs);		dbg_dump_node(c, buf);		dbg_dump_stack();	}	return err;}
开发者ID:rrowicki,项目名称:Chrono_Kernel-1,代码行数:92,


示例19: 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:119-org,项目名称:hi3518-osdrv,代码行数:87,


示例20: ubifs_wbuf_write_nolock

//.........这里部分代码省略.........	if (wbuf->used) {		/*		 * The node is large enough and does not fit entirely within		 * current available space. We have to fill and flush		 * write-buffer and switch to the next max. write unit.		 */		dbg_io("flush jhead %s wbuf to LEB %d:%d",		       dbg_jhead(wbuf->jhead), wbuf->lnum, wbuf->offs);		memcpy(wbuf->buf + wbuf->used, buf, wbuf->avail);		err = ubi_leb_write(c->ubi, wbuf->lnum, wbuf->buf, wbuf->offs,				    wbuf->size, wbuf->dtype);		if (err)			goto out;		wbuf->offs += wbuf->size;		len -= wbuf->avail;		aligned_len -= wbuf->avail;		written += wbuf->avail;	} else if (wbuf->offs & (c->max_write_size - 1)) {		/*		 * The write-buffer offset is not aligned to		 * @c->max_write_size and @wbuf->size is less than		 * @c->max_write_size. Write @wbuf->size bytes to make sure the		 * following writes are done in optimal @c->max_write_size		 * chunks.		 */		dbg_io("write %d bytes to LEB %d:%d",		       wbuf->size, wbuf->lnum, wbuf->offs);		err = ubi_leb_write(c->ubi, wbuf->lnum, buf, wbuf->offs,				    wbuf->size, wbuf->dtype);		if (err)			goto out;		wbuf->offs += wbuf->size;		len -= wbuf->size;		aligned_len -= wbuf->size;		written += wbuf->size;	}	/*	 * The remaining data may take more whole max. write units, so write the	 * remains multiple to max. write unit size directly to the flash media.	 * We align node length to 8-byte boundary because we anyway flash wbuf	 * if the remaining space is less than 8 bytes.	 */	n = aligned_len >> c->max_write_shift;	if (n) {		n <<= c->max_write_shift;		dbg_io("write %d bytes to LEB %d:%d", n, wbuf->lnum,		       wbuf->offs);		err = ubi_leb_write(c->ubi, wbuf->lnum, buf + written,				    wbuf->offs, n, wbuf->dtype);		if (err)			goto out;		wbuf->offs += n;		aligned_len -= n;		len -= n;		written += n;	}	spin_lock(&wbuf->lock);	if (aligned_len)		/*		 * And now we have what's left and what does not take whole		 * max. write unit, so write it to the write-buffer and we are		 * done.		 */		memcpy(wbuf->buf, buf + written, len);	if (c->leb_size - wbuf->offs >= c->max_write_size)		wbuf->size = c->max_write_size;	else		wbuf->size = c->leb_size - wbuf->offs;	wbuf->avail = wbuf->size - aligned_len;	wbuf->used = aligned_len;	wbuf->next_ino = 0;	spin_unlock(&wbuf->lock);exit:	if (wbuf->sync_callback) {		int free = c->leb_size - wbuf->offs - wbuf->used;		err = wbuf->sync_callback(c, wbuf->lnum, free, 0);		if (err)			goto out;	}	if (wbuf->used)		new_wbuf_timer_nolock(wbuf);	return 0;out:	ubifs_err("cannot write %d bytes to LEB %d:%d, error %d",		  len, wbuf->lnum, wbuf->offs, err);	dbg_dump_node(c, buf);	dbg_dump_stack();	dbg_dump_leb(c, wbuf->lnum);	return err;}
开发者ID:rrowicki,项目名称:Chrono_Kernel-1,代码行数:101,


示例21: ubifs_start_scan

/** * ubifs_scan - scan a logical eraseblock. * @c: UBIFS file-system description object * @lnum: logical eraseblock number * @offs: offset to start at (usually zero) * @sbuf: scan buffer (must be of @c->leb_size bytes in size) * @quiet: print no messages * * This function scans LEB number @lnum and returns complete information about * its contents. Returns the scanned information in case of success and, * %-EUCLEAN if the LEB neads recovery, and other negative error codes in case * of failure. * * If @quiet is non-zero, this function does not print large and scary * error messages and flash dumps in case of errors. */struct ubifs_scan_leb *ubifs_scan(const struct ubifs_info *c, int lnum,				  int offs, void *sbuf, int quiet){	void *buf = sbuf + offs;	int err, len = c->leb_size - offs;	struct ubifs_scan_leb *sleb;	sleb = ubifs_start_scan(c, lnum, offs, sbuf);	if (IS_ERR(sleb))		return sleb;	while (len >= 8) {		struct ubifs_ch *ch = buf;		int node_len, ret;		dbg_scan("look at LEB %d:%d (%d bytes left)",			 lnum, offs, len);		cond_resched();		ret = ubifs_scan_a_node(c, buf, len, lnum, offs, quiet);		if (ret > 0) {			/* Padding bytes or a valid padding node */			offs += ret;			buf += ret;			len -= ret;			continue;		}		if (ret == SCANNED_EMPTY_SPACE)			/* Empty space is checked later */			break;		switch (ret) {		case SCANNED_GARBAGE:			ubifs_err(c, "garbage");			goto corrupted;		case SCANNED_A_NODE:			break;		case SCANNED_A_CORRUPT_NODE:		case SCANNED_A_BAD_PAD_NODE:			ubifs_err(c, "bad node");			goto corrupted;		default:			ubifs_err(c, "unknown");			err = -EINVAL;			goto error;		}		err = ubifs_add_snod(c, sleb, buf, offs);		if (err)			goto error;		node_len = ALIGN(le32_to_cpu(ch->len), 8);		offs += node_len;		buf += node_len;		len -= node_len;	}	if (offs % c->min_io_size) {		if (!quiet)			ubifs_err(c, "empty space starts at non-aligned offset %d",				  offs);		goto corrupted;	}	ubifs_end_scan(c, sleb, lnum, offs);	for (; len > 4; offs += 4, buf = buf + 4, len -= 4)		if (*(uint32_t *)buf != 0xffffffff)			break;	for (; len; offs++, buf++, len--)		if (*(uint8_t *)buf != 0xff) {			if (!quiet)				ubifs_err(c, "corrupt empty space at LEB %d:%d",					  lnum, offs);			goto corrupted;		}	return sleb;corrupted:	if (!quiet) {		ubifs_scanned_corruption(c, lnum, offs, buf);//.........这里部分代码省略.........
开发者ID:krzk,项目名称:linux,代码行数:101,


示例22: do_readpage

static int do_readpage(struct ubifs_info *c, struct inode *inode,		       struct page *page, int last_block_size){	void *addr;	int err = 0, i;	unsigned int block, beyond;	struct ubifs_data_node *dn;	loff_t i_size = inode->i_size;	dbg_gen("ino %lu, pg %lu, i_size %lld",		inode->i_ino, page->index, i_size);	addr = kmap(page);	block = page->index << UBIFS_BLOCKS_PER_PAGE_SHIFT;	beyond = (i_size + UBIFS_BLOCK_SIZE - 1) >> UBIFS_BLOCK_SHIFT;	if (block >= beyond) {		/* Reading beyond inode */		memset(addr, 0, PAGE_CACHE_SIZE);		goto out;	}	dn = kmalloc(UBIFS_MAX_DATA_NODE_SZ, GFP_NOFS);	if (!dn)		return -ENOMEM;	i = 0;	while (1) {		int ret;		if (block >= beyond) {			/* Reading beyond inode */			err = -ENOENT;			memset(addr, 0, UBIFS_BLOCK_SIZE);		} else {			/*			 * Reading last block? Make sure to not write beyond			 * the requested size in the destination buffer.			 */			if (((block + 1) == beyond) || last_block_size) {				void *buff;				int dlen;				/*				 * We need to buffer the data locally for the				 * last block. This is to not pad the				 * destination area to a multiple of				 * UBIFS_BLOCK_SIZE.				 */				buff = malloc(UBIFS_BLOCK_SIZE);				if (!buff) {					printf("%s: Error, malloc fails!/n",					       __func__);					err = -ENOMEM;					break;				}				/* Read block-size into temp buffer */				ret = read_block(inode, buff, block, dn);				if (ret) {					err = ret;					if (err != -ENOENT) {						free(buff);						break;					}				}				if (last_block_size)					dlen = last_block_size;				else					dlen = le32_to_cpu(dn->size);				/* Now copy required size back to dest */				memcpy(addr, buff, dlen);				free(buff);			} else {				ret = read_block(inode, addr, block, dn);				if (ret) {					err = ret;					if (err != -ENOENT)						break;				}			}		}		if (++i >= UBIFS_BLOCKS_PER_PAGE)			break;		block += 1;		addr += UBIFS_BLOCK_SIZE;	}	if (err) {		if (err == -ENOENT) {			/* Not found, so it must be a hole */			dbg_gen("hole");			goto out_free;		}		ubifs_err("cannot read page %lu of inode %lu, error %d",			  page->index, inode->i_ino, err);		goto error;	}//.........这里部分代码省略.........
开发者ID:lubing521,项目名称:lm3s-u-boot,代码行数:101,


示例23: validate_sb

/** * validate_sb - validate superblock node. * @c: UBIFS file-system description object * @sup: superblock node * * This function validates superblock node @sup. Since most of data was read * from the superblock and stored in @c, the function validates fields in @c * instead. Returns zero in case of success and %-EINVAL in case of validation * failure. */static int validate_sb(struct ubifs_info *c, struct ubifs_sb_node *sup){	long long max_bytes;	int err = 1, min_leb_cnt;	if (!c->key_hash) {		err = 2;		goto failed;	}	if (sup->key_fmt != UBIFS_SIMPLE_KEY_FMT) {		err = 3;		goto failed;	}	if (le32_to_cpu(sup->min_io_size) != c->min_io_size) {		ubifs_err(c, "min. I/O unit mismatch: %d in superblock, %d real",			  le32_to_cpu(sup->min_io_size), c->min_io_size);		goto failed;	}	if (le32_to_cpu(sup->leb_size) != c->leb_size) {		ubifs_err(c, "LEB size mismatch: %d in superblock, %d real",			  le32_to_cpu(sup->leb_size), c->leb_size);		goto failed;	}	if (c->log_lebs < UBIFS_MIN_LOG_LEBS ||	    c->lpt_lebs < UBIFS_MIN_LPT_LEBS ||	    c->orph_lebs < UBIFS_MIN_ORPH_LEBS ||	    c->main_lebs < UBIFS_MIN_MAIN_LEBS) {		err = 4;		goto failed;	}	/*	 * Calculate minimum allowed amount of main area LEBs. This is very	 * similar to %UBIFS_MIN_LEB_CNT, but we take into account real what we	 * have just read from the superblock.	 */	min_leb_cnt = UBIFS_SB_LEBS + UBIFS_MST_LEBS + c->log_lebs;	min_leb_cnt += c->lpt_lebs + c->orph_lebs + c->jhead_cnt + 6;	if (c->leb_cnt < min_leb_cnt || c->leb_cnt > c->vi.size) {		ubifs_err(c, "bad LEB count: %d in superblock, %d on UBI volume, %d minimum required",			  c->leb_cnt, c->vi.size, min_leb_cnt);		goto failed;	}	if (c->max_leb_cnt < c->leb_cnt) {		ubifs_err(c, "max. LEB count %d less than LEB count %d",			  c->max_leb_cnt, c->leb_cnt);		goto failed;	}	if (c->main_lebs < UBIFS_MIN_MAIN_LEBS) {		ubifs_err(c, "too few main LEBs count %d, must be at least %d",			  c->main_lebs, UBIFS_MIN_MAIN_LEBS);		goto failed;	}	max_bytes = (long long)c->leb_size * UBIFS_MIN_BUD_LEBS;	if (c->max_bud_bytes < max_bytes) {		ubifs_err(c, "too small journal (%lld bytes), must be at least %lld bytes",			  c->max_bud_bytes, max_bytes);		goto failed;	}	max_bytes = (long long)c->leb_size * c->main_lebs;	if (c->max_bud_bytes > max_bytes) {		ubifs_err(c, "too large journal size (%lld bytes), only %lld bytes available in the main area",			  c->max_bud_bytes, max_bytes);		goto failed;	}	if (c->jhead_cnt < NONDATA_JHEADS_CNT + 1 ||	    c->jhead_cnt > NONDATA_JHEADS_CNT + UBIFS_MAX_JHEADS) {		err = 9;		goto failed;	}	if (c->fanout < UBIFS_MIN_FANOUT ||	    ubifs_idx_node_sz(c, c->fanout) > c->leb_size) {		err = 10;		goto failed;	}	if (c->lsave_cnt < 0 || (c->lsave_cnt > DEFAULT_LSAVE_CNT &&	    c->lsave_cnt > c->max_leb_cnt - UBIFS_SB_LEBS - UBIFS_MST_LEBS -	    c->log_lebs - c->lpt_lebs - c->orph_lebs)) {//.........这里部分代码省略.........
开发者ID:020gzh,项目名称:linux,代码行数:101,


示例24: dbg_gen

static struct dentry *ubifs_lookup(struct inode *dir, struct dentry *dentry,				   struct nameidata *nd){	int err;	union ubifs_key key;	struct inode *inode = NULL;	struct ubifs_dent_node *dent;	struct ubifs_info *c = dir->i_sb->s_fs_info;	dbg_gen("'%.*s' in dir ino %lu",		dentry->d_name.len, dentry->d_name.name, dir->i_ino);	if (dentry->d_name.len > UBIFS_MAX_NLEN)		return ERR_PTR(-ENAMETOOLONG);	dent = kmalloc(UBIFS_MAX_DENT_NODE_SZ, GFP_NOFS);	if (!dent)		return ERR_PTR(-ENOMEM);	dent_key_init(c, &key, dir->i_ino, &dentry->d_name);	err = ubifs_tnc_lookup_nm(c, &key, dent, &dentry->d_name);	if (err) {		if (err == -ENOENT) {			dbg_gen("not found");			goto done;		}		goto out;	}	if (dbg_check_name(c, dent, &dentry->d_name)) {		err = -EINVAL;		goto out;	}	inode = ubifs_iget(dir->i_sb, le64_to_cpu(dent->inum));	if (IS_ERR(inode)) {		/*		 * This should not happen. Probably the file-system needs		 * checking.		 */		err = PTR_ERR(inode);		ubifs_err("dead directory entry '%.*s', error %d",			  dentry->d_name.len, dentry->d_name.name, err);		ubifs_ro_mode(c, err);		goto out;	}done:	kfree(dent);	/*	 * Note, d_splice_alias() would be required instead if we supported	 * NFS.	 */	d_add(dentry, inode);	return NULL;out:	kfree(dent);	return ERR_PTR(err);}
开发者ID:AnwariJr,项目名称:Zenfone-Kernel,代码行数:61,


示例25: ubifs_budget_space

/** * ubifs_budget_space - ensure there is enough space to complete an operation. * @c: UBIFS file-system description object * @req: budget request * * This function allocates budget for an operation. It uses pessimistic * approximation of how much flash space the operation needs. The goal of this * function is to make sure UBIFS always has flash space to flush all dirty * pages, dirty inodes, and dirty znodes (liability). This function may force * commit, garbage-collection or write-back. Returns zero in case of success, * %-ENOSPC if there is no free space and other negative error codes in case of * failures. */int ubifs_budget_space(struct ubifs_info *c, struct ubifs_budget_req *req){	int uninitialized_var(cmt_retries), uninitialized_var(wb_retries);	int err, idx_growth, data_growth, dd_growth, retried = 0;	ubifs_assert(req->new_page <= 1);	ubifs_assert(req->dirtied_page <= 1);	ubifs_assert(req->new_dent <= 1);	ubifs_assert(req->mod_dent <= 1);	ubifs_assert(req->new_ino <= 1);	ubifs_assert(req->new_ino_d <= UBIFS_MAX_INO_DATA);	ubifs_assert(req->dirtied_ino <= 4);	ubifs_assert(req->dirtied_ino_d <= UBIFS_MAX_INO_DATA * 4);	ubifs_assert(!(req->new_ino_d & 7));	ubifs_assert(!(req->dirtied_ino_d & 7));	data_growth = calc_data_growth(c, req);	dd_growth = calc_dd_growth(c, req);	if (!data_growth && !dd_growth)		return 0;	idx_growth = calc_idx_growth(c, req);again:	spin_lock(&c->space_lock);	ubifs_assert(c->budg_idx_growth >= 0);	ubifs_assert(c->budg_data_growth >= 0);	ubifs_assert(c->budg_dd_growth >= 0);	if (unlikely(c->nospace) && (c->nospace_rp || !can_use_rp(c))) {		dbg_budg("no space");		spin_unlock(&c->space_lock);		return -ENOSPC;	}	c->budg_idx_growth += idx_growth;	c->budg_data_growth += data_growth;	c->budg_dd_growth += dd_growth;	err = do_budget_space(c);	if (likely(!err)) {		req->idx_growth = idx_growth;		req->data_growth = data_growth;		req->dd_growth = dd_growth;		spin_unlock(&c->space_lock);		return 0;	}	/* Restore the old values */	c->budg_idx_growth -= idx_growth;	c->budg_data_growth -= data_growth;	c->budg_dd_growth -= dd_growth;	spin_unlock(&c->space_lock);	if (req->fast) {		dbg_budg("no space for fast budgeting");		return err;	}	err = make_free_space(c);	cond_resched();	if (err == -EAGAIN) {		dbg_budg("try again");		goto again;	} else if (err == -ENOSPC) {		if (!retried) {			retried = 1;			dbg_budg("-ENOSPC, but anyway try once again");			goto again;		}		dbg_budg("FS is full, -ENOSPC");		c->nospace = 1;		if (can_use_rp(c) || c->rp_size == 0)			c->nospace_rp = 1;		smp_wmb();	} else		ubifs_err("cannot budget space, error %d", err);	return err;}
开发者ID:AppEngine,项目名称:linux-2.6,代码行数:91,


示例26: ubifs_link

//.........这里部分代码省略.........	struct inode *inode;	struct ubifs_inode *dir_ui = ubifs_inode(dir);	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 };	/*	 * Budget request settings: new inode, new direntry and changing parent	 * directory inode.	 */	dbg_gen("dent '%.*s', mode %#hx 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, S_IFDIR | mode);	if (IS_ERR(inode)) {		err = PTR_ERR(inode);		goto out_budg;	}	mutex_lock(&dir_ui->ui_mutex);	insert_inode_hash(inode);	inc_nlink(inode);	inc_nlink(dir);	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) {		ubifs_err("cannot create directory, error %d", err);		goto out_cancel;	}	mutex_unlock(&dir_ui->ui_mutex);	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(dir);	mutex_unlock(&dir_ui->ui_mutex);	make_bad_inode(inode);	iput(inode);out_budg:	ubifs_release_budget(c, &req);	return err;}static int ubifs_mknod(struct inode *dir, struct dentry *dentry,		       umode_t mode, dev_t rdev){	struct inode *inode;	struct ubifs_inode *ui;	struct ubifs_inode *dir_ui = ubifs_inode(dir);	struct ubifs_info *c = dir->i_sb->s_fs_info;	union ubifs_dev_desc *dev = NULL;	int sz_change = CALC_DENT_SIZE(dentry->d_name.len);	int err, devlen = 0;	struct ubifs_budget_req req = { .new_ino = 1, .new_dent = 1,					.new_ino_d = ALIGN(devlen, 8),
开发者ID:AnwariJr,项目名称:Zenfone-Kernel,代码行数:67,


示例27: ubifs_link

//.........这里部分代码省略.........	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, S_IFDIR | 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);	insert_inode_hash(inode);	inc_nlink(inode);	inc_nlink(dir);	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) {		ubifs_err(c, "cannot create directory, error %d", err);		goto out_cancel;	}	mutex_unlock(&dir_ui->ui_mutex);	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(dir);	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);	return err;}static int ubifs_mknod(struct inode *dir, struct dentry *dentry,		       umode_t mode, dev_t rdev){	struct inode *inode;	struct ubifs_inode *ui;	struct ubifs_inode *dir_ui = ubifs_inode(dir);	struct ubifs_info *c = dir->i_sb->s_fs_info;	union ubifs_dev_desc *dev = NULL;
开发者ID:SantoshShilimkar,项目名称:linux,代码行数:67,



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


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