/* This function works exactly like ubi_leb_read_sg(). But instead of storing the read data into a buffer it writes to an UBI scatter gather list.  */
int ubi_leb_read_sg(struct ubi_volume_desc *desc, int lnum, struct ubi_sgl *sgl, int offset, int len, int check)
/* This function works exactly like ubi_leb_read_sg(). But instead of storing the read data into a buffer it writes to an UBI scatter gather list.  */
int ubi_leb_read_sg(struct ubi_volume_desc *desc, int lnum, struct ubi_sgl *sgl, int offset, int len, int check)
{
	struct ubi_volume *vol = desc->vol;
	struct ubi_device *ubi = vol->ubi;
	int err, vol_id = vol->vol_id;
	dbg_gen("read %d bytes from LEB %d:%d:%d", len, vol_id, lnum, offset);
	err = leb_read_sanity_check(desc, lnum, offset, len);
	if (err < 0)
		return err;
	if (len == 0)
		return 0;
	err = ubi_eba_read_leb_sg(ubi, vol, sgl, lnum, offset, len, check);
	if (err && mtd_is_eccerr(err) && vol->vol_type == UBI_STATIC_VOLUME) {
		ubi_warn(ubi, "mark volume %d as corrupted", vol_id);
		vol->corrupted = 1;
	}
	return err;
}