Changeset View
Changeset View
Standalone View
Standalone View
sys/geom/virstor/g_virstor.c
Show First 20 Lines • Show All 222 Lines • ▼ Show 20 Lines | virstor_ctl_stop(struct gctl_req *req, struct g_class *cp) | ||||
g_topology_lock(); | g_topology_lock(); | ||||
for (i = 0; i < *nargs; i++) { | for (i = 0; i < *nargs; i++) { | ||||
char param[8]; | char param[8]; | ||||
const char *name; | const char *name; | ||||
struct g_virstor_softc *sc; | struct g_virstor_softc *sc; | ||||
int error; | int error; | ||||
snprintf(param, sizeof(param), "arg%d", i); | snprintf(param, sizeof(param), "arg%d", i); | ||||
name = gctl_get_asciiparam(req, param); | name = gctl_get_devname(req, param); | ||||
if (name == NULL) { | if (name == NULL) { | ||||
gctl_error(req, "No 'arg%d' argument", i); | |||||
g_topology_unlock(); | g_topology_unlock(); | ||||
return; | return; | ||||
} | } | ||||
sc = virstor_find_geom(cp, name); | sc = virstor_find_geom(cp, name); | ||||
if (sc == NULL) { | if (sc == NULL) { | ||||
gctl_error(req, "Don't know anything about '%s'", name); | gctl_error(req, "Don't know anything about '%s'", name); | ||||
g_topology_unlock(); | g_topology_unlock(); | ||||
return; | return; | ||||
▲ Show 20 Lines • Show All 42 Lines • ▼ Show 20 Lines | virstor_ctl_add(struct gctl_req *req, struct g_class *cp) | ||||
} | } | ||||
hardcode = gctl_get_paraml(req, "hardcode", sizeof(*hardcode)); | hardcode = gctl_get_paraml(req, "hardcode", sizeof(*hardcode)); | ||||
if (hardcode == NULL) { | if (hardcode == NULL) { | ||||
gctl_error(req, "Error fetching argument '%s'", "hardcode"); | gctl_error(req, "Error fetching argument '%s'", "hardcode"); | ||||
return; | return; | ||||
} | } | ||||
/* Find "our" geom */ | /* Find "our" geom */ | ||||
geom_name = gctl_get_asciiparam(req, "arg0"); | geom_name = gctl_get_devname(req, "arg0"); | ||||
if (geom_name == NULL) { | if (geom_name == NULL) | ||||
gctl_error(req, "Error fetching argument '%s'", "geom_name (arg0)"); | |||||
return; | return; | ||||
} | |||||
sc = virstor_find_geom(cp, geom_name); | sc = virstor_find_geom(cp, geom_name); | ||||
if (sc == NULL) { | if (sc == NULL) { | ||||
gctl_error(req, "Don't know anything about '%s'", geom_name); | gctl_error(req, "Don't know anything about '%s'", geom_name); | ||||
return; | return; | ||||
} | } | ||||
if (virstor_valid_components(sc) != sc->n_components) { | if (virstor_valid_components(sc) != sc->n_components) { | ||||
LOG_MSG(LVL_ERROR, "Cannot add components to incomplete " | LOG_MSG(LVL_ERROR, "Cannot add components to incomplete " | ||||
▲ Show 20 Lines • Show All 228 Lines • ▼ Show 20 Lines | if (nargs == NULL) { | ||||
gctl_error(req, "Error fetching argument '%s'", "nargs"); | gctl_error(req, "Error fetching argument '%s'", "nargs"); | ||||
return; | return; | ||||
} | } | ||||
if (*nargs < 2) { | if (*nargs < 2) { | ||||
gctl_error(req, "Invalid number of arguments"); | gctl_error(req, "Invalid number of arguments"); | ||||
return; | return; | ||||
} | } | ||||
/* Find "our" geom */ | /* Find "our" geom */ | ||||
geom_name = gctl_get_asciiparam(req, "arg0"); | geom_name = gctl_get_devname(req, "arg0"); | ||||
if (geom_name == NULL) { | if (geom_name == NULL) | ||||
gctl_error(req, "Error fetching argument '%s'", | |||||
"geom_name (arg0)"); | |||||
return; | return; | ||||
} | |||||
sc = virstor_find_geom(cp, geom_name); | sc = virstor_find_geom(cp, geom_name); | ||||
if (sc == NULL) { | if (sc == NULL) { | ||||
gctl_error(req, "Don't know anything about '%s'", geom_name); | gctl_error(req, "Don't know anything about '%s'", geom_name); | ||||
return; | return; | ||||
} | } | ||||
if (virstor_valid_components(sc) != sc->n_components) { | if (virstor_valid_components(sc) != sc->n_components) { | ||||
LOG_MSG(LVL_ERROR, "Cannot remove components from incomplete " | LOG_MSG(LVL_ERROR, "Cannot remove components from incomplete " | ||||
"virstor %s", sc->geom->name); | "virstor %s", sc->geom->name); | ||||
gctl_error(req, "Virstor %s is incomplete", sc->geom->name); | gctl_error(req, "Virstor %s is incomplete", sc->geom->name); | ||||
return; | return; | ||||
} | } | ||||
removed = 0; | removed = 0; | ||||
for (i = 1; i < *nargs; i++) { | for (i = 1; i < *nargs; i++) { | ||||
char param[8]; | char param[8]; | ||||
const char *prov_name; | const char *prov_name; | ||||
int j, found; | int j, found; | ||||
struct g_virstor_component *newcomp, *compbak; | struct g_virstor_component *newcomp, *compbak; | ||||
snprintf(param, sizeof(param), "arg%d", i); | snprintf(param, sizeof(param), "arg%d", i); | ||||
prov_name = gctl_get_asciiparam(req, param); | prov_name = gctl_get_devname(req, param); | ||||
if (prov_name == NULL) { | if (prov_name == NULL) | ||||
gctl_error(req, "Error fetching argument '%s'", param); | |||||
return; | return; | ||||
} | |||||
if (strncmp(prov_name, _PATH_DEV, sizeof(_PATH_DEV) - 1) == 0) | |||||
prov_name += sizeof(_PATH_DEV) - 1; | |||||
found = -1; | found = -1; | ||||
for (j = 0; j < sc->n_components; j++) { | for (j = 0; j < sc->n_components; j++) { | ||||
if (strcmp(sc->components[j].gcons->provider->name, | if (strcmp(sc->components[j].gcons->provider->name, | ||||
prov_name) == 0) { | prov_name) == 0) { | ||||
found = j; | found = j; | ||||
break; | break; | ||||
} | } | ||||
▲ Show 20 Lines • Show All 1,295 Lines • Show Last 20 Lines |