Changeset View
Changeset View
Standalone View
Standalone View
head/sys/geom/eli/g_eli_ctl.c
Show First 20 Lines • Show All 114 Lines • ▼ Show 20 Lines | if (*detach && *readonly) { | ||||
return; | return; | ||||
} | } | ||||
name = gctl_get_asciiparam(req, "arg0"); | name = gctl_get_asciiparam(req, "arg0"); | ||||
if (name == NULL) { | if (name == NULL) { | ||||
gctl_error(req, "No 'arg%u' argument.", 0); | gctl_error(req, "No 'arg%u' argument.", 0); | ||||
return; | return; | ||||
} | } | ||||
if (strncmp(name, "/dev/", strlen("/dev/")) == 0) | if (strncmp(name, _PATH_DEV, strlen(_PATH_DEV)) == 0) | ||||
name += strlen("/dev/"); | name += strlen(_PATH_DEV); | ||||
pp = g_provider_by_name(name); | pp = g_provider_by_name(name); | ||||
if (pp == NULL) { | if (pp == NULL) { | ||||
gctl_error(req, "Provider %s is invalid.", name); | gctl_error(req, "Provider %s is invalid.", name); | ||||
return; | return; | ||||
} | } | ||||
error = g_eli_read_metadata(mp, pp, &md); | error = g_eli_read_metadata(mp, pp, &md); | ||||
if (error != 0) { | if (error != 0) { | ||||
gctl_error(req, "Cannot read metadata from %s (error=%d).", | gctl_error(req, "Cannot read metadata from %s (error=%d).", | ||||
▲ Show 20 Lines • Show All 48 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, "/dev/", strlen("/dev/")) == 0) | if (strncmp(prov, _PATH_DEV, strlen(_PATH_DEV)) == 0) | ||||
prov += strlen("/dev/"); | 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 20 Lines • Show All 169 Lines • ▼ Show 20 Lines | g_eli_ctl_onetime(struct gctl_req *req, struct g_class *mp) | ||||
/* Not important here. */ | /* Not important here. */ | ||||
bzero(md.md_hash, sizeof(md.md_hash)); | bzero(md.md_hash, sizeof(md.md_hash)); | ||||
name = gctl_get_asciiparam(req, "arg0"); | name = gctl_get_asciiparam(req, "arg0"); | ||||
if (name == NULL) { | if (name == NULL) { | ||||
gctl_error(req, "No 'arg%u' argument.", 0); | gctl_error(req, "No 'arg%u' argument.", 0); | ||||
return; | return; | ||||
} | } | ||||
if (strncmp(name, "/dev/", strlen("/dev/")) == 0) | if (strncmp(name, _PATH_DEV, strlen(_PATH_DEV)) == 0) | ||||
name += strlen("/dev/"); | name += strlen(_PATH_DEV); | ||||
pp = g_provider_by_name(name); | pp = g_provider_by_name(name); | ||||
if (pp == NULL) { | if (pp == NULL) { | ||||
gctl_error(req, "Provider %s is invalid.", name); | gctl_error(req, "Provider %s is invalid.", name); | ||||
return; | return; | ||||
} | } | ||||
sectorsize = gctl_get_paraml(req, "sectorsize", sizeof(*sectorsize)); | sectorsize = gctl_get_paraml(req, "sectorsize", sizeof(*sectorsize)); | ||||
if (sectorsize == NULL) { | if (sectorsize == NULL) { | ||||
▲ Show 20 Lines • Show All 847 Lines • Show Last 20 Lines |