FreeBSD/sys/geom/virstor/g_virstor.c
/*
 * "stop" verb from userland
 */
"stop" verb from userland
" stop " verb from userland
static void
virstor_ctl_stop(struct gctl_req *req, struct g_class *cp)
{
	int *force, *nargs;
	int i;
	nargs = gctl_get_paraml(req, "nargs", sizeof *nargs);
	if (nargs == NULL) {
		gctl_error(req, "Error fetching argument '%s'", "nargs");
		return;
	}
	if (*nargs < 1) {
		gctl_error(req, "Invalid number of arguments");
		return;
	}
	force = gctl_get_paraml(req, "force", sizeof *force);
	if (force == NULL) {
		gctl_error(req, "Error fetching argument '%s'", "force");
		return;
	}
	g_topology_lock();
	for (i = 0; i < *nargs; i++) {
		char param[8];
		const char *name;
		struct g_virstor_softc *sc;
		int error;
		sprintf(param, "arg%d", i);
		name = gctl_get_asciiparam(req, param);
		if (name == NULL) {
			gctl_error(req, "No 'arg%d' argument", i);
			g_topology_unlock();
			return;
		}
		sc = virstor_find_geom(cp, name);
		if (sc == NULL) {
			gctl_error(req, "Don't know anything about '%s'", name);
			g_topology_unlock();
			return;
		}
		LOG_MSG(LVL_INFO, "Stopping %s by the userland command",
		    sc->geom->name);
		update_metadata(sc);
		if ((error = virstor_geom_destroy(sc, TRUE, TRUE)) != 0) {
			LOG_MSG(LVL_ERROR, "Cannot destroy %s: %d",
			    sc->geom->name, error);
		}
	}
	g_topology_unlock();
}
static void virstor_ctl_stop ( struct gctl_req * req , struct g_class * cp ) { int * force , * nargs ; int i ; nargs = gctl_get_paraml ( req , " " , sizeof * nargs ) ; if ( nargs == NULL ) { gctl_error ( req , " " , " " ) ; return ; } if ( * nargs < 1 ) { gctl_error ( req , " " ) ; return ; } force = gctl_get_paraml ( req , " " , sizeof * force ) ; if ( force == NULL ) { gctl_error ( req , " " , " " ) ; return ; } g_topology_lock ( ) ; for ( i = 0 ; i < * nargs ; i ++ ) { char param [ 8 ] ; const char * name ; struct g_virstor_softc * sc ; int error ; sprintf ( param , " " , i ) ; name = gctl_get_asciiparam ( req , param ) ; if ( name == NULL ) { gctl_error ( req , " " , i ) ; g_topology_unlock ( ) ; return ; } sc = virstor_find_geom ( cp , name ) ; if ( sc == NULL ) { gctl_error ( req , " " , name ) ; g_topology_unlock ( ) ; return ; } LOG_MSG ( LVL_INFO , " " , sc -> geom -> name ) ; update_metadata ( sc ) ; if ( ( error = virstor_geom_destroy ( sc , TRUE , TRUE ) ) != 0 ) { LOG_MSG ( LVL_ERROR , " " , sc -> geom -> name , error ) ; } } g_topology_unlock ( ) ; }
"stop" verb from userland
" stop " verb from userland