aboutsummaryrefslogtreecommitdiff
path: root/sbin/gvinum/gvinum.c
diff options
context:
space:
mode:
authorLukas Ertl <le@FreeBSD.org>2004-08-04 00:23:00 +0000
committerLukas Ertl <le@FreeBSD.org>2004-08-04 00:23:00 +0000
commit5c1accc9ab7329eea70e62ca3e2b653d0f5de194 (patch)
treed236ac1baef824a317c571956527bc962268bf3f /sbin/gvinum/gvinum.c
parentb11ef345eb75b53ada6784470f52cbc2252e5b54 (diff)
downloadsrc-5c1accc9ab7329eea70e62ca3e2b653d0f5de194.tar.gz
src-5c1accc9ab7329eea70e62ca3e2b653d0f5de194.zip
Allow 'create <filename>'.
Notes
Notes: svn path=/head/; revision=133097
Diffstat (limited to 'sbin/gvinum/gvinum.c')
-rw-r--r--sbin/gvinum/gvinum.c61
1 files changed, 35 insertions, 26 deletions
diff --git a/sbin/gvinum/gvinum.c b/sbin/gvinum/gvinum.c
index 2757afdef85d..176c7c3d8aa7 100644
--- a/sbin/gvinum/gvinum.c
+++ b/sbin/gvinum/gvinum.c
@@ -155,32 +155,41 @@ gvinum_create(int argc, char **argv)
char original[BUFSIZ], tmpfile[20], *token[GV_MAXARGS];
char plex[GV_MAXPLEXNAME], volume[GV_MAXVOLNAME];
- snprintf(tmpfile, sizeof(tmpfile), "/tmp/gvinum.XXXXXX");
-
- if ((fd = mkstemp(tmpfile)) == -1) {
- warn("temporary file not accessible");
- return;
- }
- if ((tmp = fdopen(fd, "w")) == NULL) {
- warn("can't open '%s' for writing", tmpfile);
- return;
- }
- printconfig(tmp, "# ");
- fclose(tmp);
-
- ed = getenv("EDITOR");
- if (ed == NULL)
- ed = _PATH_VI;
-
- snprintf(commandline, sizeof(commandline), "%s %s", ed, tmpfile);
- status = system(commandline);
- if (status != 0) {
- warn("couldn't exec %s; status: %d", ed, status);
- return;
- }
-
- if ((tmp = fopen(tmpfile, "r")) == NULL) {
- warn("can't open '%s' for reading", tmpfile);
+ if (argc == 2) {
+ if ((tmp = fopen(argv[1], "r")) == NULL) {
+ warn("can't open '%s' for reading", argv[1]);
+ return;
+ }
+ } else {
+ snprintf(tmpfile, sizeof(tmpfile), "/tmp/gvinum.XXXXXX");
+
+ if ((fd = mkstemp(tmpfile)) == -1) {
+ warn("temporary file not accessible");
+ return;
+ }
+ if ((tmp = fdopen(fd, "w")) == NULL) {
+ warn("can't open '%s' for writing", tmpfile);
+ return;
+ }
+ printconfig(tmp, "# ");
+ fclose(tmp);
+
+ ed = getenv("EDITOR");
+ if (ed == NULL)
+ ed = _PATH_VI;
+
+ snprintf(commandline, sizeof(commandline), "%s %s", ed,
+ tmpfile);
+ status = system(commandline);
+ if (status != 0) {
+ warn("couldn't exec %s; status: %d", ed, status);
+ return;
+ }
+
+ if ((tmp = fopen(tmpfile, "r")) == NULL) {
+ warn("can't open '%s' for reading", tmpfile);
+ return;
+ }
}
req = gctl_get_handle();