From 072b47a3452b8160616033be766acbcad399f1a3 Mon Sep 17 00:00:00 2001 From: le Date: Wed, 4 Aug 2004 00:23:00 +0000 Subject: Allow 'create '. --- sbin/gvinum/gvinum.c | 61 ++++++++++++++++++++++++++++++---------------------- 1 file changed, 35 insertions(+), 26 deletions(-) (limited to 'sbin/gvinum') diff --git a/sbin/gvinum/gvinum.c b/sbin/gvinum/gvinum.c index 2757afd..176c7c3 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(); -- cgit v1.1