/* This function prepares node at @node to be written to the media - it calculates node CRC and fills the common header.  */
void ubifs_prep_grp_node(struct ubifs_info *c, void *node, int len, int last)
/* This function prepares node at @node to be written to the media - it calculates node CRC and fills the common header.  */
void ubifs_prep_grp_node(struct ubifs_info *c, void *node, int len, int last)
{
	uint32_t crc;
	struct ubifs_ch *ch = node;
	unsigned long long sqnum = next_sqnum(c);
	ubifs_assert(len >= UBIFS_CH_SZ);
	ch->magic = cpu_to_le32(UBIFS_NODE_MAGIC);
	ch->len = cpu_to_le32(len);
	if (last)
		ch->group_type = UBIFS_LAST_OF_NODE_GROUP;
	else
		ch->group_type = UBIFS_IN_NODE_GROUP;
	ch->sqnum = cpu_to_le64(sqnum);
	ch->padding[0] = ch->padding[1] = 0;
	crc = crc32(UBIFS_CRC32_INIT, node + 8, len - 8);
	ch->crc = cpu_to_le32(crc);
}