diff options
author | Lukas Ertl <le@FreeBSD.org> | 2006-03-23 19:58:43 +0000 |
---|---|---|
committer | Lukas Ertl <le@FreeBSD.org> | 2006-03-23 19:58:43 +0000 |
commit | 7b5264faa147a421cb39387cc8b78cfdb3a2a4d2 (patch) | |
tree | ebf356ea4a6858242ffdfeb11c641e7b4306871d /sbin/gvinum/gvinum.c | |
parent | ddd14ad4fb98179e5feaa0ab84ec43e7cd77624f (diff) | |
download | src-7b5264faa147a421cb39387cc8b78cfdb3a2a4d2.tar.gz src-7b5264faa147a421cb39387cc8b78cfdb3a2a4d2.zip |
Implement the 'resetconfig' command.
PR: kern/94835
Submitted by: Ulf Lilleengen <lulf@stud.ntnu.no>
Notes
Notes:
svn path=/head/; revision=157052
Diffstat (limited to 'sbin/gvinum/gvinum.c')
-rw-r--r-- | sbin/gvinum/gvinum.c | 41 |
1 files changed, 41 insertions, 0 deletions
diff --git a/sbin/gvinum/gvinum.c b/sbin/gvinum/gvinum.c index 23a21b92ca29..ea33b75e1adc 100644 --- a/sbin/gvinum/gvinum.c +++ b/sbin/gvinum/gvinum.c @@ -61,6 +61,7 @@ void gvinum_move(int, char **); void gvinum_parityop(int, char **, int); void gvinum_printconfig(int, char **); void gvinum_rename(int, char **); +void gvinum_resetconfig(void); void gvinum_rm(int, char **); void gvinum_saveconfig(void); void gvinum_setstate(int, char **); @@ -349,6 +350,8 @@ gvinum_help(void) " Change the name of the specified object.\n" "rebuildparity plex [-f]\n" " Rebuild the parity blocks of a RAID-5 plex.\n" + "resetconfig\n" + " Reset the complete gvinum configuration\n" "rm [-r] volume | plex | subdisk | drive\n" " Remove an object.\n" "saveconfig\n" @@ -729,6 +732,42 @@ gvinum_rm(int argc, char **argv) } void +gvinum_resetconfig(void) +{ + struct gctl_req *req; + const char *errstr; + char reply[32]; + + if (!isatty(STDIN_FILENO)) { + warn("Please enter this command from a tty device\n"); + return; + } + printf(" WARNING! This command will completely wipe out your gvinum" + "configuration.\n" + " All data will be lost. If you really want to do this," + " enter the text\n\n" + " NO FUTURE\n" + " Enter text -> "); + fgets(reply, sizeof(reply), stdin); + if (strcmp(reply, "NO FUTURE\n")) { + printf("\n No change\n"); + return; + } + req = gctl_get_handle(); + gctl_ro_param(req, "class", -1, "VINUM"); + gctl_ro_param(req, "verb", -1, "resetconfig"); + errstr = gctl_issue(req); + if (errstr != NULL) { + warnx("can't reset config: %s", errstr); + gctl_free(req); + return; + } + gctl_free(req); + gvinum_list(0, NULL); + printf("gvinum configuration obliterated\n"); +} + +void gvinum_saveconfig(void) { struct gctl_req *req; @@ -846,6 +885,8 @@ parseline(int argc, char **argv) gvinum_printconfig(argc, argv); else if (!strcmp(argv[0], "rename")) gvinum_rename(argc, argv); + else if (!strcmp(argv[0], "resetconfig")) + gvinum_resetconfig(); else if (!strcmp(argv[0], "rm")) gvinum_rm(argc, argv); else if (!strcmp(argv[0], "saveconfig")) |