/* This function returns %0 on success and a negative error code on failure.  */
static int recover_head(struct ubifs_info *c, int lnum, int offs, void *sbuf)
/* This function returns %0 on success and a negative error code on failure.  */
static int recover_head(struct ubifs_info *c, int lnum, int offs, void *sbuf)
{
	int len = c->max_write_size, err;
	if (offs + len > c->leb_size)
		len = c->leb_size - offs;
	if (!len)
		return 0;
	err = ubifs_leb_read(c, lnum, sbuf, offs, len, 1);
	if (err || !is_empty(sbuf, len)) {
		dbg_rcvry("cleaning head at %d:%d", lnum, offs);
		if (offs == 0)
			return ubifs_leb_unmap(c, lnum);
		err = ubifs_leb_read(c, lnum, sbuf, 0, offs, 1);
		if (err)
			return err;
		return ubifs_leb_change(c, lnum, sbuf, offs);
	}
	return 0;
}