/* This function returns the scanned information on success and a negative error code on failure.  */
struct ubifs_scan_leb* ubifs_start_scan(const struct ubifs_info *c, int lnum, int offs, void *sbuf)
/* This function returns the scanned information on success and a negative error code on failure.  */
struct ubifs_scan_leb* ubifs_start_scan(const struct ubifs_info *c, int lnum, int offs, void *sbuf)
{
	struct ubifs_scan_leb *sleb;
	int err;
	dbg_scan("scan LEB %d:%d", lnum, offs);
	sleb = kzalloc(sizeof(struct ubifs_scan_leb), GFP_NOFS);
	if (!sleb)
		return ERR_PTR(-ENOMEM);
	sleb->lnum = lnum;
	INIT_LIST_HEAD(&sleb->nodes);
	sleb->buf = sbuf;
	err = ubifs_leb_read(c, lnum, sbuf + offs, offs, c->leb_size - offs, 0);
	if (err && err != -EBADMSG) {
		ubifs_err(c, "cannot read %d bytes from LEB %d:%d, error %d",
			  c->leb_size - offs, lnum, offs, err);
		kfree(sleb);
		return ERR_PTR(err);
	}
	return sleb;
}