summaryrefslogtreecommitdiffstats
path: root/sbin/gbde
diff options
context:
space:
mode:
authorphk <phk@FreeBSD.org>2002-12-01 15:58:28 +0000
committerphk <phk@FreeBSD.org>2002-12-01 15:58:28 +0000
commit17f924ed6e6338c7f1c9f0763500a5f496f24fc9 (patch)
tree22cca1595b44016103993b62c767d5c483533549 /sbin/gbde
parent318b3f8c98133f07d68ac2d29a5b8dbe26f1c44f (diff)
downloadFreeBSD-src-17f924ed6e6338c7f1c9f0763500a5f496f24fc9.zip
FreeBSD-src-17f924ed6e6338c7f1c9f0763500a5f496f24fc9.tar.gz
Synchronize usage() with reality.
Semi-automatic handling of /dev prefix for device names. Sponsored by: DARPA & NAI Labs. Approved by: re (blanket)
Diffstat (limited to 'sbin/gbde')
-rw-r--r--sbin/gbde/gbde.c27
1 files changed, 19 insertions, 8 deletions
diff --git a/sbin/gbde/gbde.c b/sbin/gbde/gbde.c
index a634c9c..5fd50c1 100644
--- a/sbin/gbde/gbde.c
+++ b/sbin/gbde/gbde.c
@@ -41,6 +41,7 @@
#include <stdint.h>
#include <unistd.h>
#include <fcntl.h>
+#include <paths.h>
#include <strings.h>
#include <stdlib.h>
#include <err.h>
@@ -100,11 +101,11 @@ usage(const char *reason)
p = getprogname();
fprintf(stderr, "Usage error: %s", reason);
fprintf(stderr, "Usage:\n");
- fprintf(stderr, "\t%s attach dest -l filename\n", p);
+ fprintf(stderr, "\t%s attach dest [-l lockfile]\n", p);
fprintf(stderr, "\t%s detach dest\n", p);
- fprintf(stderr, "\t%s init dest [-i] [-f filename] -l filename\n", p);
- fprintf(stderr, "\t%s setkey dest [-n key] -l filename\n", p);
- fprintf(stderr, "\t%s destroy dest [-n key] -l filename\n", p);
+ fprintf(stderr, "\t%s init /dev/dest [-i] [-f filename] [-L lockfile]\n", p);
+ fprintf(stderr, "\t%s setkey dest [-n key] [-l lockfile] [-L lockfile]\n", p);
+ fprintf(stderr, "\t%s destroy dest [-n key] [-l lockfile] [-L lockfile]\n", p);
exit (1);
}
@@ -644,10 +645,11 @@ main(int argc, char **argv)
const char *l_opt, *L_opt;
const char *p_opt, *P_opt;
const char *f_opt;
- const char *dest;
- int i_opt, n_opt, ch, dfd, nkey, doopen;
+ char *dest;
+ int i_opt, n_opt, ch, dfd, doopen;
+ u_int nkey;
int i;
- char *q;
+ char *q, buf[BUFSIZ];
struct g_bde_key *gl;
struct g_bde_softc sc;
@@ -683,7 +685,7 @@ main(int argc, char **argv)
argc--;
argv++;
- dest = argv[1];
+ dest = strdup(argv[1]);
argc--;
argv++;
@@ -727,8 +729,17 @@ main(int argc, char **argv)
if (doopen) {
dfd = open(dest, O_RDWR | O_CREAT, 0644);
+ if (dfd < 0) {
+ sprintf(buf, "%s%s", _PATH_DEV, dest);
+ dfd = open(buf, O_RDWR | O_CREAT, 0644);
+ }
if (dfd < 0)
err(1, dest);
+ } else {
+ if (!memcmp(dest, _PATH_DEV, strlen(_PATH_DEV)))
+ strcpy(dest, dest + strlen(_PATH_DEV));
+ if (strchr(dest, '/'))
+ usage("\"dest\" argument must be geom-name\n");
}
memset(&sc, 0, sizeof sc);
OpenPOWER on IntegriCloud