summaryrefslogtreecommitdiffstats
path: root/sbin/gvinum
diff options
context:
space:
mode:
authorle <le@FreeBSD.org>2004-08-04 00:23:00 +0000
committerle <le@FreeBSD.org>2004-08-04 00:23:00 +0000
commit072b47a3452b8160616033be766acbcad399f1a3 (patch)
treed236ac1baef824a317c571956527bc962268bf3f /sbin/gvinum
parent66da0a565ef1cb0f45d19cef019e4b8022408ecf (diff)
downloadFreeBSD-src-072b47a3452b8160616033be766acbcad399f1a3.zip
FreeBSD-src-072b47a3452b8160616033be766acbcad399f1a3.tar.gz
Allow 'create <filename>'.
Diffstat (limited to 'sbin/gvinum')
-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 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();
OpenPOWER on IntegriCloud