/* This function returns the number of orphans that can be written in the available space.  */
static int avail_orphs(struct ubifs_info *c)
/* This function returns the number of orphans that can be written in the available space.  */
static int avail_orphs(struct ubifs_info *c)
{
	int avail_lebs, avail, gap;
	avail_lebs = c->orph_lebs - (c->ohead_lnum - c->orph_first) - 1;
	avail = avail_lebs *
	       ((c->leb_size - UBIFS_ORPH_NODE_SZ) / sizeof(__le64));
	gap = c->leb_size - c->ohead_offs;
	if (gap >= UBIFS_ORPH_NODE_SZ + sizeof(__le64))
		avail += (gap - UBIFS_ORPH_NODE_SZ) / sizeof(__le64);
	return avail;
}