/* This function returns %0 on success and a negative error code on failure.  */
static int add_node(struct ubifs_info *c, void *buf, int *lnum, int *offs, void *node)
/* This function returns %0 on success and a negative error code on failure.  */
static int add_node(struct ubifs_info *c, void *buf, int *lnum, int *offs, void *node)
{
	struct ubifs_ch *ch = node;
	int len = le32_to_cpu(ch->len), remains = c->leb_size - *offs;
	if (len > remains) {
		int sz = ALIGN(*offs, c->min_io_size), err;
		ubifs_pad(c, buf + *offs, sz - *offs);
		err = ubifs_leb_change(c, *lnum, buf, sz);
		if (err)
			return err;
		*lnum = ubifs_next_log_lnum(c, *lnum);
		*offs = 0;
	}
	memcpy(buf + *offs, node, len);
	*offs += ALIGN(len, 8);
	return 0;
}