FreeBSD/sys/geom/vinum/geom_vinum_drive.c
/* Write out the gvinum header. */
Write out the gvinum header.
Write out the gvinum header .
int
gv_write_header(struct g_consumer *cp, struct gv_hdr *m_hdr)
{
	uint8_t d_hdr[GV_HDR_LEN];
	int off, ret;
#define GV_SET64BE(field)					\
	do {							\
		*((uint64_t *)&d_hdr[off]) = htobe64(field);	\
		off += 8;					\
	} while (0)
	KASSERT(m_hdr != NULL, ("gv_write_header: null m_hdr"));
	off = 0;
	memset(d_hdr, 0, GV_HDR_LEN);
	GV_SET64BE(m_hdr->magic);
	GV_SET64BE(m_hdr->config_length);
	off = 16;
	bcopy(m_hdr->label.sysname, d_hdr + off, GV_HOSTNAME_LEN);
	off += GV_HOSTNAME_LEN;
	bcopy(m_hdr->label.name, d_hdr + off, GV_MAXDRIVENAME);
	off += GV_MAXDRIVENAME;
	GV_SET64BE(m_hdr->label.date_of_birth.tv_sec);
	GV_SET64BE(m_hdr->label.date_of_birth.tv_usec);
	GV_SET64BE(m_hdr->label.last_update.tv_sec);
	GV_SET64BE(m_hdr->label.last_update.tv_usec);
	GV_SET64BE(m_hdr->label.drive_size);
	ret = g_write_data(cp, GV_HDR_OFFSET, d_hdr, GV_HDR_LEN);
	return (ret);
}
int gv_write_header ( struct g_consumer * cp , struct gv_hdr * m_hdr ) { uint8_t d_hdr [ GV_HDR_LEN ] ; int off , ret ; #define GV_SET64BE ( field ) 					\
	do {							\
		*((uint64_t *)&d_hdr[off]) = htobe64(field);	\
		off += 8;					\
	} while (0) KASSERT ( m_hdr != NULL , ( " " ) ) ; off = 0 ; memset ( d_hdr , 0 , GV_HDR_LEN ) ; GV_SET64BE ( m_hdr -> magic ) ; GV_SET64BE ( m_hdr -> config_length ) ; off = 16 ; bcopy ( m_hdr -> label . sysname , d_hdr + off , GV_HOSTNAME_LEN ) ; off += GV_HOSTNAME_LEN ; bcopy ( m_hdr -> label . name , d_hdr + off , GV_MAXDRIVENAME ) ; off += GV_MAXDRIVENAME ; GV_SET64BE ( m_hdr -> label . date_of_birth . tv_sec ) ; GV_SET64BE ( m_hdr -> label . date_of_birth . tv_usec ) ; GV_SET64BE ( m_hdr -> label . last_update . tv_sec ) ; GV_SET64BE ( m_hdr -> label . last_update . tv_usec ) ; GV_SET64BE ( m_hdr -> label . drive_size ) ; ret = g_write_data ( cp , GV_HDR_OFFSET , d_hdr , GV_HDR_LEN ) ; return ( ret ) ; }
Write out the gvinum header.
Write out the gvinum header .