Changeset View
Changeset View
Standalone View
Standalone View
sys/geom/stripe/g_stripe.c
Show First 20 Lines • Show All 1,057 Lines • ▼ Show 20 Lines | g_stripe_ctl_create(struct gctl_req *req, struct g_class *mp) | ||||
} | } | ||||
if (*nargs <= 2) { | if (*nargs <= 2) { | ||||
gctl_error(req, "Too few arguments."); | gctl_error(req, "Too few arguments."); | ||||
return; | return; | ||||
} | } | ||||
strlcpy(md.md_magic, G_STRIPE_MAGIC, sizeof(md.md_magic)); | strlcpy(md.md_magic, G_STRIPE_MAGIC, sizeof(md.md_magic)); | ||||
md.md_version = G_STRIPE_VERSION; | md.md_version = G_STRIPE_VERSION; | ||||
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; | ||||
} | |||||
strlcpy(md.md_name, name, sizeof(md.md_name)); | strlcpy(md.md_name, name, sizeof(md.md_name)); | ||||
md.md_id = arc4random(); | md.md_id = arc4random(); | ||||
md.md_no = 0; | md.md_no = 0; | ||||
md.md_all = *nargs - 1; | md.md_all = *nargs - 1; | ||||
stripesize = gctl_get_paraml(req, "stripesize", sizeof(*stripesize)); | stripesize = gctl_get_paraml(req, "stripesize", sizeof(*stripesize)); | ||||
if (stripesize == NULL) { | if (stripesize == NULL) { | ||||
gctl_error(req, "No '%s' argument.", "stripesize"); | gctl_error(req, "No '%s' argument.", "stripesize"); | ||||
return; | return; | ||||
Show All 19 Lines | g_stripe_ctl_create(struct gctl_req *req, struct g_class *mp) | ||||
sc = gp->softc; | sc = gp->softc; | ||||
sb = sbuf_new_auto(); | sb = sbuf_new_auto(); | ||||
sbuf_printf(sb, "Can't attach disk(s) to %s:", gp->name); | sbuf_printf(sb, "Can't attach disk(s) to %s:", gp->name); | ||||
for (attached = 0, no = 1; no < *nargs; no++) { | for (attached = 0, no = 1; no < *nargs; no++) { | ||||
snprintf(param, sizeof(param), "arg%u", no); | snprintf(param, sizeof(param), "arg%u", no); | ||||
pp = gctl_get_provider(req, param); | pp = gctl_get_provider(req, param); | ||||
if (pp == NULL) { | if (pp == NULL) { | ||||
name = gctl_get_asciiparam(req, param); | name = gctl_get_devname(req, param); | ||||
MPASS(name != NULL); | MPASS(name != NULL); | ||||
sbuf_printf(sb, " %s", name); | sbuf_printf(sb, " %s", name); | ||||
continue; | continue; | ||||
} | } | ||||
if (g_stripe_add_disk(sc, pp, no - 1) != 0) { | if (g_stripe_add_disk(sc, pp, no - 1) != 0) { | ||||
G_STRIPE_DEBUG(1, "Disk %u (%s) not attached to %s.", | G_STRIPE_DEBUG(1, "Disk %u (%s) not attached to %s.", | ||||
no, pp->name, gp->name); | no, pp->name, gp->name); | ||||
sbuf_printf(sb, " %s", pp->name); | sbuf_printf(sb, " %s", pp->name); | ||||
▲ Show 20 Lines • Show All 48 Lines • ▼ Show 20 Lines | g_stripe_ctl_destroy(struct gctl_req *req, struct g_class *mp) | ||||
force = gctl_get_paraml(req, "force", sizeof(*force)); | force = gctl_get_paraml(req, "force", sizeof(*force)); | ||||
if (force == NULL) { | if (force == NULL) { | ||||
gctl_error(req, "No '%s' argument.", "force"); | gctl_error(req, "No '%s' argument.", "force"); | ||||
return; | return; | ||||
} | } | ||||
for (i = 0; i < (u_int)*nargs; i++) { | for (i = 0; i < (u_int)*nargs; i++) { | ||||
snprintf(param, sizeof(param), "arg%u", i); | snprintf(param, sizeof(param), "arg%u", i); | ||||
name = gctl_get_asciiparam(req, param); | name = gctl_get_devname(req, param); | ||||
if (name == NULL) { | if (name == NULL) | ||||
gctl_error(req, "No 'arg%u' argument.", i); | |||||
return; | return; | ||||
} | |||||
sc = g_stripe_find_device(mp, name); | sc = g_stripe_find_device(mp, name); | ||||
if (sc == NULL) { | if (sc == NULL) { | ||||
gctl_error(req, "No such device: %s.", name); | gctl_error(req, "No such device: %s.", name); | ||||
return; | return; | ||||
} | } | ||||
error = g_stripe_destroy(sc, *force); | error = g_stripe_destroy(sc, *force); | ||||
if (error != 0) { | if (error != 0) { | ||||
gctl_error(req, "Cannot destroy device %s (error=%d).", | gctl_error(req, "Cannot destroy device %s (error=%d).", | ||||
▲ Show 20 Lines • Show All 79 Lines • Show Last 20 Lines |