summaryrefslogtreecommitdiff
path: root/sbin/bioctl
diff options
context:
space:
mode:
authorHans-Joerg Hoexer <hshoexer@cvs.openbsd.org>2008-06-14 18:40:51 +0000
committerHans-Joerg Hoexer <hshoexer@cvs.openbsd.org>2008-06-14 18:40:51 +0000
commitc24cac3d7d863fe994810581cd1e0cbc88ed65c1 (patch)
tree267572d44f5d851b24c03c5ab37ea3f687764b6e /sbin/bioctl
parente96f082fe7aa596575191d8ca8fdf0d8a5d7ad78 (diff)
Provide a status field for operations on the bc_opaque data. Now we're
able to distinguish cleanly an failing ioctl (ie. return value -1) from trying to retrieve a KDF hint from a not yet initialized volume. ok marco djm
Diffstat (limited to 'sbin/bioctl')
-rw-r--r--sbin/bioctl/bioctl.c11
1 files changed, 7 insertions, 4 deletions
diff --git a/sbin/bioctl/bioctl.c b/sbin/bioctl/bioctl.c
index aff172a0d94..c956e2f0ef6 100644
--- a/sbin/bioctl/bioctl.c
+++ b/sbin/bioctl/bioctl.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: bioctl.c,v 1.68 2008/06/14 17:04:50 djm Exp $ */
+/* $OpenBSD: bioctl.c,v 1.69 2008/06/14 18:40:50 hshoexer Exp $ */
/*
* Copyright (c) 2004, 2005 Marco Peereboom
@@ -664,11 +664,13 @@ bio_createraid(u_int16_t level, char *dev_list)
create.bc_opaque_flags = BIOC_SOOUT;
/* try to get KDF hint */
- if ((rv = ioctl(devh, BIOCCREATERAID, &create)) == 0) {
+ if (ioctl(devh, BIOCCREATERAID, &create) == -1)
+ err(1, "ioctl");
+
+ if (create.bc_opaque_status == BIOC_SOINOUT_OK) {
bio_kdf_derive(&kdfinfo, &kdfhint);
memset(&kdfhint, 0, sizeof(kdfhint));
- } else {
- /* XXX this will kill the keys in case of an error */
+ } else {
bio_kdf_generate(&kdfinfo);
/* no auto assembling */
create.bc_flags |= BIOC_SCNOAUTOASSEMBLE;
@@ -681,6 +683,7 @@ bio_createraid(u_int16_t level, char *dev_list)
rv = ioctl(devh, BIOCCREATERAID, &create);
memset(&kdfinfo, 0, sizeof(kdfinfo));
+ memset(&create, 0, sizeof(create));
if (rv == -1) {
if (errno == EPERM)
errx(1, "Incorrect passphrase");