FreeBSD/sbin/geom/class/virstor/geom_virstor.c
/* Called by geom(8) via gvirstor_main() to dump metadata information */
Called by geom(8) via gvirstor_main() to dump metadata information
Called by geom ( 8 ) via gvirstor_main () to dump metadata information
static void
virstor_dump(struct gctl_req *req)
{
	struct g_virstor_metadata md;
	u_char tmpmd[512];	
	const char *name;
	char param[16];
	int nargs, error, i;
	assert(sizeof(tmpmd) >= sizeof(md));
	nargs = gctl_get_int(req, "nargs");
	if (nargs < 1) {
		gctl_error(req, "Too few arguments.");
		return;
	}
	for (i = 0; i < nargs; i++) {
		snprintf(param, sizeof(param), "arg%u", i);
		name = gctl_get_ascii(req, "%s", param);
		error = g_metadata_read(name, (u_char *) & tmpmd, sizeof(tmpmd),
		    G_VIRSTOR_MAGIC);
		if (error != 0) {
			fprintf(stderr, "Can't read metadata from %s: %s.\n",
			    name, strerror(error));
			gctl_error(req,
			    "Not fully done (error reading metadata).");
			continue;
		}
		virstor_metadata_decode((u_char *) & tmpmd, &md);
		printf("Metadata on %s:\n", name);
		virstor_metadata_dump(&md);
		printf("\n");
	}
}
static void virstor_dump ( struct gctl_req * req ) { struct g_virstor_metadata md ; u_char tmpmd [ 512 ] ; const char * name ; char param [ 16 ] ; int nargs , error , i ; assert ( sizeof ( tmpmd ) >= sizeof ( md ) ) ; nargs = gctl_get_int ( req , " " ) ; if ( nargs < 1 ) { gctl_error ( req , " " ) ; return ; } for ( i = 0 ; i < nargs ; i ++ ) { snprintf ( param , sizeof ( param ) , " " , i ) ; name = gctl_get_ascii ( req , " " , param ) ; error = g_metadata_read ( name , ( u_char * ) & tmpmd , sizeof ( tmpmd ) , G_VIRSTOR_MAGIC ) ; if ( error != 0 ) { fprintf ( stderr , " \n " , name , strerror ( error ) ) ; gctl_error ( req , " " ) ; continue ; } virstor_metadata_decode ( ( u_char * ) & tmpmd , & md ) ; printf ( " \n " , name ) ; virstor_metadata_dump ( & md ) ; printf ( " \n " ) ; } }
Called by geom(8) via gvirstor_main() to dump metadata information
Called by geom ( 8 ) via gvirstor_main () to dump metadata information
/* temporary buffer */