- Remove bogus O_CREAT flag. We really don't want to create a file here.

PR:		bin/67793
  Submitted by:	Amir Shalem <amir@boom.org.il>

- Sync usage with manual page.

Approved by:	phk
MFC after:	1 week
This commit is contained in:
Pawel Jakub Dawidek 2005-02-03 13:12:17 +00:00
parent 72369c34ac
commit 45b727476b

View File

@ -137,11 +137,11 @@ usage(const char *reason)
p = getprogname();
fprintf(stderr, "Usage error: %s", reason);
fprintf(stderr, "Usage:\n");
fprintf(stderr, "\t%s attach dest [-l lockfile]\n", p);
fprintf(stderr, "\t%s attach dest [-l lockfile] [-p pass-phrase]\n", p);
fprintf(stderr, "\t%s detach dest\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);
fprintf(stderr, "\t%s init /dev/dest [-i] [-f filename] [-L lockfile] [-P pass-phrase]\n", p);
fprintf(stderr, "\t%s setkey dest [-n key] [-l lockfile] [-p pass-phrase] [-L new-lockfile] [-P new-pass-phrase]\n", p);
fprintf(stderr, "\t%s destroy dest [-n key] [-l lockfile] [-p pass-phrase] [-L lockfile]\n", p);
exit (1);
}
@ -799,13 +799,13 @@ main(int argc, char **argv)
}
if (doopen) {
dfd = open(dest, O_RDWR | O_CREAT, 0644);
if (dfd < 0) {
dfd = open(dest, O_RDWR);
if (dfd < 0 && dest[0] != '/') {
if (snprintf(buf, sizeof(buf), "%s%s",
_PATH_DEV, dest) >= (ssize_t)sizeof(buf))
errno = ENAMETOOLONG;
else
dfd = open(buf, O_RDWR | O_CREAT, 0644);
dfd = open(buf, O_RDWR);
}
if (dfd < 0)
err(1, "%s", dest);