Changeset View
Changeset View
Standalone View
Standalone View
head/sys/geom/eli/g_eli_ctl.c
Show First 20 Lines • Show All 371 Lines • ▼ Show 20 Lines | g_eli_ctl_configure(struct gctl_req *req, struct g_class *mp) | ||||
struct g_eli_softc *sc; | struct g_eli_softc *sc; | ||||
struct g_eli_metadata md; | struct g_eli_metadata md; | ||||
struct g_provider *pp; | struct g_provider *pp; | ||||
struct g_consumer *cp; | struct g_consumer *cp; | ||||
char param[16]; | char param[16]; | ||||
const char *prov; | const char *prov; | ||||
u_char *sector; | u_char *sector; | ||||
int *nargs, *boot, *noboot, *trim, *notrim, *geliboot, *nogeliboot; | int *nargs, *boot, *noboot, *trim, *notrim, *geliboot, *nogeliboot; | ||||
int *displaypass, *nodisplaypass; | |||||
int zero, error, changed; | int zero, error, changed; | ||||
u_int i; | u_int i; | ||||
g_topology_assert(); | g_topology_assert(); | ||||
changed = 0; | changed = 0; | ||||
zero = 0; | zero = 0; | ||||
▲ Show 20 Lines • Show All 41 Lines • ▼ Show 20 Lines | if (nogeliboot == NULL) | ||||
nogeliboot = &zero; | nogeliboot = &zero; | ||||
if (*geliboot && *nogeliboot) { | if (*geliboot && *nogeliboot) { | ||||
gctl_error(req, "Options -g and -G are mutually exclusive."); | gctl_error(req, "Options -g and -G are mutually exclusive."); | ||||
return; | return; | ||||
} | } | ||||
if (*geliboot || *nogeliboot) | if (*geliboot || *nogeliboot) | ||||
changed = 1; | changed = 1; | ||||
displaypass = gctl_get_paraml(req, "displaypass", sizeof(*displaypass)); | |||||
if (displaypass == NULL) | |||||
displaypass = &zero; | |||||
nodisplaypass = gctl_get_paraml(req, "nodisplaypass", sizeof(*nodisplaypass)); | |||||
if (nodisplaypass == NULL) | |||||
nodisplaypass = &zero; | |||||
if (*displaypass && *nodisplaypass) { | |||||
gctl_error(req, "Options -d and -D are mutually exclusive."); | |||||
return; | |||||
} | |||||
if (*displaypass || *nodisplaypass) | |||||
changed = 1; | |||||
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_asciiparam(req, param); | ||||
▲ Show 20 Lines • Show All 42 Lines • ▼ Show 20 Lines | if (*geliboot && (sc->sc_flags & G_ELI_FLAG_GELIBOOT)) { | ||||
prov); | prov); | ||||
continue; | continue; | ||||
} else if (*nogeliboot && !(sc->sc_flags & G_ELI_FLAG_GELIBOOT)) { | } else if (*nogeliboot && !(sc->sc_flags & G_ELI_FLAG_GELIBOOT)) { | ||||
G_ELI_DEBUG(1, "GELIBOOT flag not configured for %s.", | G_ELI_DEBUG(1, "GELIBOOT flag not configured for %s.", | ||||
prov); | prov); | ||||
continue; | continue; | ||||
} | } | ||||
if (*displaypass && (sc->sc_flags & G_ELI_FLAG_GELIDISPLAYPASS)) { | |||||
G_ELI_DEBUG(1, "GELIDISPLAYPASS flag already configured for %s.", | |||||
prov); | |||||
continue; | |||||
} else if (*nodisplaypass && | |||||
!(sc->sc_flags & G_ELI_FLAG_GELIDISPLAYPASS)) { | |||||
G_ELI_DEBUG(1, "GELIDISPLAYPASS flag not configured for %s.", | |||||
prov); | |||||
continue; | |||||
} | |||||
if (!(sc->sc_flags & G_ELI_FLAG_ONETIME)) { | if (!(sc->sc_flags & G_ELI_FLAG_ONETIME)) { | ||||
/* | /* | ||||
* ONETIME providers don't write metadata to | * ONETIME providers don't write metadata to | ||||
* disk, so don't try reading it. This means | * disk, so don't try reading it. This means | ||||
* we're bit-flipping uninitialized memory in md | * we're bit-flipping uninitialized memory in md | ||||
* below, but that's OK; we don't do anything | * below, but that's OK; we don't do anything | ||||
* with it later. | * with it later. | ||||
*/ | */ | ||||
Show All 25 Lines | for (i = 0; i < *nargs; i++) { | ||||
} | } | ||||
if (*geliboot) { | if (*geliboot) { | ||||
md.md_flags |= G_ELI_FLAG_GELIBOOT; | md.md_flags |= G_ELI_FLAG_GELIBOOT; | ||||
sc->sc_flags |= G_ELI_FLAG_GELIBOOT; | sc->sc_flags |= G_ELI_FLAG_GELIBOOT; | ||||
} else if (*nogeliboot) { | } else if (*nogeliboot) { | ||||
md.md_flags &= ~G_ELI_FLAG_GELIBOOT; | md.md_flags &= ~G_ELI_FLAG_GELIBOOT; | ||||
sc->sc_flags &= ~G_ELI_FLAG_GELIBOOT; | sc->sc_flags &= ~G_ELI_FLAG_GELIBOOT; | ||||
} | |||||
if (*displaypass) { | |||||
md.md_flags |= G_ELI_FLAG_GELIDISPLAYPASS; | |||||
sc->sc_flags |= G_ELI_FLAG_GELIDISPLAYPASS; | |||||
} else if (*nodisplaypass) { | |||||
md.md_flags &= ~G_ELI_FLAG_GELIDISPLAYPASS; | |||||
sc->sc_flags &= ~G_ELI_FLAG_GELIDISPLAYPASS; | |||||
} | } | ||||
if (sc->sc_flags & G_ELI_FLAG_ONETIME) { | if (sc->sc_flags & G_ELI_FLAG_ONETIME) { | ||||
/* There's no metadata on disk so we are done here. */ | /* There's no metadata on disk so we are done here. */ | ||||
continue; | continue; | ||||
} | } | ||||
sector = malloc(pp->sectorsize, M_ELI, M_WAITOK | M_ZERO); | sector = malloc(pp->sectorsize, M_ELI, M_WAITOK | M_ZERO); | ||||
▲ Show 20 Lines • Show All 587 Lines • Show Last 20 Lines |