/* This function writes orphan nodes for all the orphans to commit. On success, %0 is returned, otherwise a negative error code is returned.  */
static int write_orph_nodes(struct ubifs_info *c, int atomic)
/* This function writes orphan nodes for all the orphans to commit. On success, %0 is returned, otherwise a negative error code is returned.  */
static int write_orph_nodes(struct ubifs_info *c, int atomic)
{
	int err;
	while (c->cmt_orphans > 0) {
		err = write_orph_node(c, atomic);
		if (err)
			return err;
	}
	if (atomic) {
		int lnum;
		for (lnum = c->ohead_lnum + 1; lnum <= c->orph_last; lnum++) {
			err = ubifs_leb_unmap(c, lnum);
			if (err)
				return err;
		}
	}
	return 0;
}