FreeBSD/sys/geom/virstor/g_virstor.c
/*
 * Utility function: read metadata & decode. Wants topology lock to be
 * held.
 */
Utility function: read metadata & decode. Wants topology lock to be
held.
Utility function : read metadata & decode . Wants topology lock to be held .
static int
read_metadata(struct g_consumer *cp, struct g_virstor_metadata *md)
{
	struct g_provider *pp;
	char *buf;
	int error;
	g_topology_assert();
	error = g_access(cp, 1, 0, 0);
	if (error != 0)
		return (error);
	pp = cp->provider;
	g_topology_unlock();
	buf = g_read_data(cp, pp->mediasize - pp->sectorsize, pp->sectorsize,
	    &error);
	g_topology_lock();
	g_access(cp, -1, 0, 0);
	if (buf == NULL)
		return (error);
	virstor_metadata_decode(buf, md);
	g_free(buf);
	return (0);
}
static int read_metadata ( struct g_consumer * cp , struct g_virstor_metadata * md ) { struct g_provider * pp ; char * buf ; int error ; g_topology_assert ( ) ; error = g_access ( cp , 1 , 0 , 0 ) ; if ( error != 0 ) return ( error ) ; pp = cp -> provider ; g_topology_unlock ( ) ; buf = g_read_data ( cp , pp -> mediasize - pp -> sectorsize , pp -> sectorsize , & error ) ; g_topology_lock ( ) ; g_access ( cp , -1 , 0 , 0 ) ; if ( buf == NULL ) return ( error ) ; virstor_metadata_decode ( buf , md ) ; g_free ( buf ) ; return ( 0 ) ; }
Utility function: read metadata & decode.
Utility function : read metadata & decode .