/* This function is the same as 'write_node()' but it does not assume the buffer it is writing is a node, so it does not prepare it (which means initializing common header and calculating CRC).  */
static int write_head(struct ubifs_info *c, int jhead, void *buf, int len, int *lnum, int *offs, int sync)
/* This function is the same as 'write_node()' but it does not assume the buffer it is writing is a node, so it does not prepare it (which means initializing common header and calculating CRC).  */
static int write_head(struct ubifs_info *c, int jhead, void *buf, int len, int *lnum, int *offs, int sync)
{
	int err;
	struct ubifs_wbuf *wbuf = &c->jheads[jhead].wbuf;
	ubifs_assert(jhead != GCHD);
	*lnum = c->jheads[jhead].wbuf.lnum;
	*offs = c->jheads[jhead].wbuf.offs + c->jheads[jhead].wbuf.used;
	dbg_jnl("jhead %s, LEB %d:%d, len %d",
		dbg_jhead(jhead), *lnum, *offs, len);
	err = ubifs_wbuf_write_nolock(wbuf, buf, len);
	if (err)
		return err;
	if (sync)
		err = ubifs_wbuf_sync_nolock(wbuf);
	return err;
}