Changeset View
Changeset View
Standalone View
Standalone View
sys/geom/eli/g_eli_ctl.c
Show First 20 Lines • Show All 168 Lines • ▼ Show 20 Lines | |||||
static struct g_eli_softc * | static struct g_eli_softc * | ||||
g_eli_find_device(struct g_class *mp, const char *prov) | g_eli_find_device(struct g_class *mp, const char *prov) | ||||
{ | { | ||||
struct g_eli_softc *sc; | struct g_eli_softc *sc; | ||||
struct g_geom *gp; | struct g_geom *gp; | ||||
struct g_provider *pp; | struct g_provider *pp; | ||||
struct g_consumer *cp; | struct g_consumer *cp; | ||||
if (strncmp(prov, _PATH_DEV, strlen(_PATH_DEV)) == 0) | |||||
prov += strlen(_PATH_DEV); | |||||
LIST_FOREACH(gp, &mp->geom, geom) { | LIST_FOREACH(gp, &mp->geom, geom) { | ||||
sc = gp->softc; | sc = gp->softc; | ||||
if (sc == NULL) | if (sc == NULL) | ||||
continue; | continue; | ||||
pp = LIST_FIRST(&gp->provider); | pp = LIST_FIRST(&gp->provider); | ||||
if (pp != NULL && strcmp(pp->name, prov) == 0) | if (pp != NULL && strcmp(pp->name, prov) == 0) | ||||
return (sc); | return (sc); | ||||
cp = LIST_FIRST(&gp->consumer); | cp = LIST_FIRST(&gp->consumer); | ||||
Show All 33 Lines | g_eli_ctl_detach(struct gctl_req *req, struct g_class *mp) | ||||
last = gctl_get_paraml(req, "last", sizeof(*last)); | last = gctl_get_paraml(req, "last", sizeof(*last)); | ||||
if (last == NULL) { | if (last == NULL) { | ||||
gctl_error(req, "No '%s' argument.", "last"); | gctl_error(req, "No '%s' argument.", "last"); | ||||
return; | return; | ||||
} | } | ||||
for (i = 0; i < *nargs; i++) { | for (i = 0; i < *nargs; i++) { | ||||
snprintf(param, sizeof(param), "arg%d", i); | snprintf(param, sizeof(param), "arg%d", i); | ||||
prov = gctl_get_asciiparam(req, param); | prov = gctl_get_devname(req, param); | ||||
if (prov == NULL) { | if (prov == NULL) | ||||
gctl_error(req, "No 'arg%d' argument.", i); | |||||
return; | return; | ||||
} | |||||
sc = g_eli_find_device(mp, prov); | sc = g_eli_find_device(mp, prov); | ||||
if (sc == NULL) { | if (sc == NULL) { | ||||
gctl_error(req, "No such device: %s.", prov); | gctl_error(req, "No such device: %s.", prov); | ||||
return; | return; | ||||
} | } | ||||
if (*last) { | if (*last) { | ||||
sc->sc_flags |= G_ELI_FLAG_RW_DETACH; | sc->sc_flags |= G_ELI_FLAG_RW_DETACH; | ||||
sc->sc_geom->access = g_eli_access; | sc->sc_geom->access = g_eli_access; | ||||
▲ Show 20 Lines • Show All 241 Lines • ▼ Show 20 Lines | g_eli_ctl_configure(struct gctl_req *req, struct g_class *mp) | ||||
if (!changed) { | if (!changed) { | ||||
gctl_error(req, "No option given."); | gctl_error(req, "No option given."); | ||||
return; | return; | ||||
} | } | ||||
for (i = 0; i < *nargs; i++) { | for (i = 0; i < *nargs; i++) { | ||||
snprintf(param, sizeof(param), "arg%d", i); | snprintf(param, sizeof(param), "arg%d", i); | ||||
prov = gctl_get_asciiparam(req, param); | prov = gctl_get_devname(req, param); | ||||
if (prov == NULL) { | if (prov == NULL) | ||||
gctl_error(req, "No 'arg%d' argument.", i); | |||||
return; | return; | ||||
} | |||||
sc = g_eli_find_device(mp, prov); | sc = g_eli_find_device(mp, prov); | ||||
if (sc == NULL) { | if (sc == NULL) { | ||||
/* | /* | ||||
* We ignore not attached providers, userland part will | * We ignore not attached providers, userland part will | ||||
* take care of them. | * take care of them. | ||||
*/ | */ | ||||
G_ELI_DEBUG(1, "Skipping configuration of not attached " | G_ELI_DEBUG(1, "Skipping configuration of not attached " | ||||
"provider %s.", prov); | "provider %s.", prov); | ||||
▲ Show 20 Lines • Show All 144 Lines • ▼ Show 20 Lines | g_eli_ctl_setkey(struct gctl_req *req, struct g_class *mp) | ||||
struct g_consumer *cp; | struct g_consumer *cp; | ||||
const char *name; | const char *name; | ||||
u_char *key, *mkeydst, *sector; | u_char *key, *mkeydst, *sector; | ||||
intmax_t *valp; | intmax_t *valp; | ||||
int keysize, nkey, error; | int keysize, nkey, error; | ||||
g_topology_assert(); | g_topology_assert(); | ||||
name = gctl_get_asciiparam(req, "arg0"); | name = gctl_get_devname(req, "arg0"); | ||||
if (name == NULL) { | if (name == NULL) | ||||
gctl_error(req, "No 'arg%u' argument.", 0); | |||||
return; | return; | ||||
} | |||||
key = gctl_get_param(req, "key", &keysize); | key = gctl_get_param(req, "key", &keysize); | ||||
if (key == NULL || keysize != G_ELI_USERKEYLEN) { | if (key == NULL || keysize != G_ELI_USERKEYLEN) { | ||||
gctl_error(req, "No '%s' argument.", "key"); | gctl_error(req, "No '%s' argument.", "key"); | ||||
return; | return; | ||||
} | } | ||||
sc = g_eli_find_device(mp, name); | sc = g_eli_find_device(mp, name); | ||||
if (sc == NULL) { | if (sc == NULL) { | ||||
gctl_error(req, "Provider %s is invalid.", name); | gctl_error(req, "Provider %s is invalid.", name); | ||||
▲ Show 20 Lines • Show All 91 Lines • ▼ Show 20 Lines | g_eli_ctl_delkey(struct gctl_req *req, struct g_class *mp) | ||||
size_t keysize; | size_t keysize; | ||||
int error, nkey, *all, *force; | int error, nkey, *all, *force; | ||||
u_int i; | u_int i; | ||||
g_topology_assert(); | g_topology_assert(); | ||||
nkey = 0; /* fixes causeless gcc warning */ | nkey = 0; /* fixes causeless gcc warning */ | ||||
name = gctl_get_asciiparam(req, "arg0"); | name = gctl_get_devname(req, "arg0"); | ||||
if (name == NULL) { | if (name == NULL) | ||||
gctl_error(req, "No 'arg%u' argument.", 0); | |||||
return; | return; | ||||
} | |||||
sc = g_eli_find_device(mp, name); | sc = g_eli_find_device(mp, name); | ||||
if (sc == NULL) { | if (sc == NULL) { | ||||
gctl_error(req, "Provider %s is invalid.", name); | gctl_error(req, "Provider %s is invalid.", name); | ||||
return; | return; | ||||
} | } | ||||
if (sc->sc_flags & G_ELI_FLAG_RO) { | if (sc->sc_flags & G_ELI_FLAG_RO) { | ||||
gctl_error(req, "Cannot delete keys for read-only provider."); | gctl_error(req, "Cannot delete keys for read-only provider."); | ||||
return; | return; | ||||
▲ Show 20 Lines • Show All 166 Lines • ▼ Show 20 Lines | if (*all) { | ||||
} | } | ||||
} else { | } else { | ||||
const char *prov; | const char *prov; | ||||
char param[16]; | char param[16]; | ||||
int i; | int i; | ||||
for (i = 0; i < *nargs; i++) { | for (i = 0; i < *nargs; i++) { | ||||
snprintf(param, sizeof(param), "arg%d", i); | snprintf(param, sizeof(param), "arg%d", i); | ||||
prov = gctl_get_asciiparam(req, param); | prov = gctl_get_devname(req, param); | ||||
if (prov == NULL) { | if (prov == NULL) | ||||
G_ELI_DEBUG(0, "No 'arg%d' argument.", i); | |||||
continue; | continue; | ||||
} | |||||
sc = g_eli_find_device(mp, prov); | sc = g_eli_find_device(mp, prov); | ||||
if (sc == NULL) { | if (sc == NULL) { | ||||
G_ELI_DEBUG(0, "No such provider: %s.", prov); | G_ELI_DEBUG(0, "No such provider: %s.", prov); | ||||
continue; | continue; | ||||
} | } | ||||
g_eli_suspend_one(sc, req); | g_eli_suspend_one(sc, req); | ||||
} | } | ||||
Show All 19 Lines | if (nargs == NULL) { | ||||
gctl_error(req, "No '%s' argument.", "nargs"); | gctl_error(req, "No '%s' argument.", "nargs"); | ||||
return; | return; | ||||
} | } | ||||
if (*nargs != 1) { | if (*nargs != 1) { | ||||
gctl_error(req, "Invalid number of arguments."); | gctl_error(req, "Invalid number of arguments."); | ||||
return; | return; | ||||
} | } | ||||
name = gctl_get_asciiparam(req, "arg0"); | name = gctl_get_devname(req, "arg0"); | ||||
if (name == NULL) { | if (name == NULL) | ||||
gctl_error(req, "No 'arg%u' argument.", 0); | |||||
return; | return; | ||||
} | |||||
key = gctl_get_param(req, "key", &keysize); | key = gctl_get_param(req, "key", &keysize); | ||||
if (key == NULL || keysize != G_ELI_USERKEYLEN) { | if (key == NULL || keysize != G_ELI_USERKEYLEN) { | ||||
gctl_error(req, "No '%s' argument.", "key"); | gctl_error(req, "No '%s' argument.", "key"); | ||||
return; | return; | ||||
} | } | ||||
sc = g_eli_find_device(mp, name); | sc = g_eli_find_device(mp, name); | ||||
if (sc == NULL) { | if (sc == NULL) { | ||||
gctl_error(req, "Provider %s is invalid.", name); | gctl_error(req, "Provider %s is invalid.", name); | ||||
▲ Show 20 Lines • Show All 130 Lines • ▼ Show 20 Lines | g_eli_ctl_kill(struct gctl_req *req, struct g_class *mp) | ||||
} else { | } else { | ||||
struct g_eli_softc *sc; | struct g_eli_softc *sc; | ||||
const char *prov; | const char *prov; | ||||
char param[16]; | char param[16]; | ||||
int i; | int i; | ||||
for (i = 0; i < *nargs; i++) { | for (i = 0; i < *nargs; i++) { | ||||
snprintf(param, sizeof(param), "arg%d", i); | snprintf(param, sizeof(param), "arg%d", i); | ||||
prov = gctl_get_asciiparam(req, param); | prov = gctl_get_devname(req, param); | ||||
if (prov == NULL) { | if (prov == NULL) | ||||
G_ELI_DEBUG(0, "No 'arg%d' argument.", i); | |||||
continue; | continue; | ||||
} | |||||
sc = g_eli_find_device(mp, prov); | sc = g_eli_find_device(mp, prov); | ||||
if (sc == NULL) { | if (sc == NULL) { | ||||
G_ELI_DEBUG(0, "No such provider: %s.", prov); | G_ELI_DEBUG(0, "No such provider: %s.", prov); | ||||
continue; | continue; | ||||
} | } | ||||
error = g_eli_kill_one(sc); | error = g_eli_kill_one(sc); | ||||
if (error != 0) | if (error != 0) | ||||
▲ Show 20 Lines • Show All 54 Lines • Show Last 20 Lines |