/* This function writes a node to the orphan head from the orphan buffer. If atomic is not zero, then the write is done atomically. On success, %0 is returned, otherwise a negative error code is returned.  */
static int do_write_orph_node(struct ubifs_info *c, int len, int atomic)
/* This function writes a node to the orphan head from the orphan buffer. If atomic is not zero, then the write is done atomically. On success, %0 is returned, otherwise a negative error code is returned.  */
static int do_write_orph_node(struct ubifs_info *c, int len, int atomic)
{
	int err = 0;
	if (atomic) {
		ubifs_assert(c->ohead_offs == 0);
		ubifs_prepare_node(c, c->orph_buf, len, 1);
		len = ALIGN(len, c->min_io_size);
		err = ubifs_leb_change(c, c->ohead_lnum, c->orph_buf, len,
				       UBI_SHORTTERM);
	} else {
		if (c->ohead_offs == 0) {
			err = ubifs_leb_unmap(c, c->ohead_lnum);
			if (err)
				return err;
		}
		err = ubifs_write_node(c, c->orph_buf, len, c->ohead_lnum,
				       c->ohead_offs, UBI_SHORTTERM);
	}
	return err;
}