diff options
author | le <le@FreeBSD.org> | 2006-03-23 19:58:43 +0000 |
---|---|---|
committer | le <le@FreeBSD.org> | 2006-03-23 19:58:43 +0000 |
commit | 80efd8a6c8402b6ec3055526640e188d257ad82d (patch) | |
tree | ebf356ea4a6858242ffdfeb11c641e7b4306871d /sys/geom/vinum | |
parent | 925eb76ba3564d403af4210dfa40dde20fa1726c (diff) | |
download | FreeBSD-src-80efd8a6c8402b6ec3055526640e188d257ad82d.zip FreeBSD-src-80efd8a6c8402b6ec3055526640e188d257ad82d.tar.gz |
Implement the 'resetconfig' command.
PR: kern/94835
Submitted by: Ulf Lilleengen <lulf@stud.ntnu.no>
Diffstat (limited to 'sys/geom/vinum')
-rw-r--r-- | sys/geom/vinum/geom_vinum.c | 3 | ||||
-rw-r--r-- | sys/geom/vinum/geom_vinum.h | 1 | ||||
-rw-r--r-- | sys/geom/vinum/geom_vinum_rm.c | 39 |
3 files changed, 43 insertions, 0 deletions
diff --git a/sys/geom/vinum/geom_vinum.c b/sys/geom/vinum/geom_vinum.c index dfb0452..7e045d9 100644 --- a/sys/geom/vinum/geom_vinum.c +++ b/sys/geom/vinum/geom_vinum.c @@ -396,6 +396,9 @@ gv_config(struct gctl_req *req, struct g_class *mp, char const *verb) } else if (!strcmp(verb, "rename")) { gv_rename(gp, req); + + } else if (!strcmp(verb, "resetconfig")) { + gv_resetconfig(gp, req); } else if (!strcmp(verb, "start")) { gv_start_obj(gp, req); diff --git a/sys/geom/vinum/geom_vinum.h b/sys/geom/vinum/geom_vinum.h index 1a31b3b..0e272ce 100644 --- a/sys/geom/vinum/geom_vinum.h +++ b/sys/geom/vinum/geom_vinum.h @@ -57,6 +57,7 @@ void gv_rename(struct g_geom *, struct gctl_req *); /* geom_vinum_rm.c */ void gv_remove(struct g_geom *, struct gctl_req *); +int gv_resetconfig(struct g_geom *, struct gctl_req *); int gv_rm_sd(struct gv_softc *sc, struct gctl_req *req, struct gv_sd *s, int flags); diff --git a/sys/geom/vinum/geom_vinum_rm.c b/sys/geom/vinum/geom_vinum_rm.c index eb188b7..7d25b82 100644 --- a/sys/geom/vinum/geom_vinum_rm.c +++ b/sys/geom/vinum/geom_vinum_rm.c @@ -125,6 +125,45 @@ gv_remove(struct g_geom *gp, struct gctl_req *req) gv_save_config_all(sc); } +/* Resets configuration */ +int +gv_resetconfig(struct g_geom *gp, struct gctl_req *req) +{ + struct gv_softc *sc; + struct gv_drive *d, *d2; + struct gv_volume *v, *v2; + struct gv_plex *p, *p2; + struct gv_sd *s, *s2; + int flags; + + d = NULL; + d2 = NULL; + p = NULL; + p2 = NULL; + s = NULL; + s2 = NULL; + flags = GV_FLAG_R; + sc = gp->softc; + /* First loop through to make sure no volumes are up */ + LIST_FOREACH_SAFE(v, &sc->volumes, volume, v2) { + if (gv_is_open(v->geom)) { + gctl_error(req, "volume '%s' is busy", v->name); + return (-1); + } + } + /* Then if not, we remove everything. */ + LIST_FOREACH_SAFE(v, &sc->volumes, volume, v2) + gv_rm_vol(sc, req, v, flags); + LIST_FOREACH_SAFE(p, &sc->plexes, plex, p2) + gv_rm_plex(sc, req, p, flags); + LIST_FOREACH_SAFE(s, &sc->subdisks, sd, s2) + gv_rm_sd(sc, req, s, flags); + LIST_FOREACH_SAFE(d, &sc->drives, drive, d2) + gv_rm_drive(sc, req, d, flags); + gv_save_config_all(sc); + return (0); +} + /* Remove a volume. */ static int gv_rm_vol(struct gv_softc *sc, struct gctl_req *req, struct gv_volume *v, int flags) |