summaryrefslogtreecommitdiff
path: root/sys/dev/softraidvar.h
diff options
context:
space:
mode:
authorDamien Miller <djm@cvs.openbsd.org>2008-06-13 18:27:43 +0000
committerDamien Miller <djm@cvs.openbsd.org>2008-06-13 18:27:43 +0000
commit4b1dee732e806adbabd63ccb58438979ab3961d2 (patch)
treefe74e760fb6d6ca197f38cd0135e39a71b2bb1dd /sys/dev/softraidvar.h
parent5140c627386e49111aee94762e74525c9ae2d7db (diff)
rearrange on-disk structures to the top of the file, wrap kernel-only
parts in #ifdef _KERNEL; makes softraidvar.h usable from userland ok hshoexer@
Diffstat (limited to 'sys/dev/softraidvar.h')
-rw-r--r--sys/dev/softraidvar.h257
1 files changed, 128 insertions, 129 deletions
diff --git a/sys/dev/softraidvar.h b/sys/dev/softraidvar.h
index 9b4704b5ab5..6999078cd27 100644
--- a/sys/dev/softraidvar.h
+++ b/sys/dev/softraidvar.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: softraidvar.h,v 1.53 2008/06/12 18:21:04 hshoexer Exp $ */
+/* $OpenBSD: softraidvar.h,v 1.54 2008/06/13 18:27:42 djm Exp $ */
/*
* Copyright (c) 2006 Marco Peereboom <marco@peereboom.us>
* Copyright (c) 2008 Chris Kuethe <ckuethe@openbsd.org>
@@ -19,6 +19,130 @@
#ifndef SOFTRAIDVAR_H
#define SOFTRAIDVAR_H
+#define SR_UUID_MAX 4
+struct sr_uuid {
+ u_int32_t sui_id[SR_UUID_MAX];
+} __packed;
+
+#define SR_META_SIZE 32 /* save space at chunk beginning */
+#define SR_META_OFFSET 16 /* skip 8192 bytes at chunk beginning */
+#define SR_META_VERSION 1 /* bump when sr_metadata changes */
+struct sr_metadata {
+ /* do not change order of ssd_magic, ssd_version & ssd_checksum */
+ u_int64_t ssd_magic; /* magic id */
+#define SR_MAGIC 0x4d4152436372616dLLU
+ u_int8_t ssd_version; /* meta data version */
+ u_int8_t ssd_pad1[3];
+ u_int32_t ssd_flags; /* flags */
+
+ /* meta-data */
+ u_int32_t ssd_checksum; /* xor of the structure */
+ u_int32_t ssd_size; /* sizeof(sr_metadata) */
+ u_int32_t ssd_ondisk; /* on disk version counter */
+ u_int32_t ssd_pad2;
+ struct sr_uuid ssd_uuid; /* unique identifier */
+
+ /* virtual disk data */
+ u_int32_t ssd_vd_ver; /* vd structure version */
+ u_int32_t ssd_vd_size; /* vd structure size */
+ u_int32_t ssd_vd_volid; /* volume id */
+ u_int32_t ssd_vd_chk; /* vd structure xor */
+
+ /* chunk data */
+ u_int32_t ssd_chunk_ver; /* chunk structure version */
+ u_int32_t ssd_chunk_no; /* number of chunks */
+ u_int32_t ssd_chunk_size; /* chunk structure size */
+ u_int32_t ssd_chunk_id; /* chunk identifier */
+ u_int32_t ssd_chunk_chk; /* chunk structure xor */
+ u_int32_t ssd_pad3;
+
+ /* optional metadata */
+ u_int32_t ssd_opt_ver; /* optinal meta version */
+ u_int32_t ssd_opt_no; /* nr of optional md elements */
+ u_int32_t ssd_opt_size; /* sizeof optional metadata */
+ u_int32_t ssd_opt_chk; /* optional metadata xor */
+} __packed;
+
+#define SR_VOL_VERSION 2 /* bump when sr_vol_meta changes */
+struct sr_vol_meta {
+ u_int32_t svm_volid; /* volume id */
+ u_int32_t svm_status; /* use bioc_vol status */
+ u_int32_t svm_flags; /* flags */
+#define SR_VOL_DIRTY 0x01
+ u_int32_t svm_level; /* raid level */
+ int64_t svm_size; /* virt disk size in blocks */
+ char svm_devname[32];/* /dev/XXXXX */
+ char svm_vendor[8]; /* scsi vendor */
+ char svm_product[16];/* scsi product */
+ char svm_revision[4];/* scsi revision */
+ u_int32_t svm_no_chunk; /* number of chunks */
+ struct sr_uuid svm_uuid; /* volume unique identifier */
+
+ /* optional members */
+ u_int32_t svm_strip_size; /* strip size */
+} __packed;
+
+#define SR_CHUNK_VERSION 1 /* bump when sr_chunk_meta changes */
+struct sr_chunk_meta {
+ u_int32_t scm_volid; /* vd we belong to */
+ u_int32_t scm_chunk_id; /* chunk id */
+ u_int32_t scm_status; /* use bio bioc_disk status */
+ u_int32_t scm_pad1;
+ char scm_devname[32];/* /dev/XXXXX */
+ int64_t scm_size; /* size of partition in blocks*/
+ int64_t scm_coerced_size; /* coerced sz of part in blk*/
+ struct sr_uuid scm_uuid; /* unique identifier */
+} __packed;
+
+#define SR_CRYPTO_MAXKEYBYTES 32
+#define SR_CRYPTO_MAXKEYS 32
+#define SR_CRYPTO_KEYBITS 512 /* AES-XTS with 2 * 256 bit keys */
+#define SR_CRYPTO_KEYBYTES (SR_CRYPTO_KEYBITS >> 3)
+#define SR_CRYPTO_KDFHINTBYTES 256
+
+struct sr_crypto_genkdf {
+ u_int32_t len;
+ u_int32_t type;
+#define SR_CRYPTOKDFT_INVALID (0)
+#define SR_CRYPTOKDFT_PBKDF2 (1<<0)
+};
+
+struct sr_crypto_kdfinfo {
+ u_int32_t len;
+ u_int32_t flags;
+#define SR_CRYPTOKDF_INVALID (0)
+#define SR_CRYPTOKDF_KEY (1<<0)
+#define SR_CRYPTOKDF_HINT (1<<1)
+ u_int8_t maskkey[SR_CRYPTO_MAXKEYBYTES];
+ struct sr_crypto_genkdf kdfhint;
+};
+
+struct sr_crypto_metadata {
+ u_int32_t scm_alg;
+#define SR_CRYPTOA_AES_XTS_128 1
+#define SR_CRYPTOA_AES_XTS_256 2
+ u_int32_t scm_flags;
+#define SR_CRYPTOF_INVALID (0)
+#define SR_CRYPTOF_KEY (1<<0)
+#define SR_CRYPTOF_KDFHINT (1<<1)
+
+ u_int8_t scm_key[SR_CRYPTO_MAXKEYS][SR_CRYPTO_KEYBYTES];
+ u_int8_t scm_kdfhint[SR_CRYPTO_KDFHINTBYTES];
+};
+
+#define SR_OPT_VERSION 1 /* bump when sr_opt_meta changes */
+struct sr_opt_meta {
+ u_int32_t som_type;
+#define SR_OPT_INVALID 0x00
+#define SR_OPT_CRYPTO 0x01
+ u_int32_t som_pad;
+ union {
+ struct sr_crypto_metadata smm_crypto;
+ } som_meta;
+};
+
+#ifdef _KERNEL
+
#include <dev/biovar.h>
#include <sys/buf.h>
@@ -29,10 +153,6 @@
#include <scsi/scsi_disk.h>
#include <scsi/scsiconf.h>
-#ifdef CRYPTO
-#include <crypto/rijndael.h>
-#endif
-
#define DEVNAME(_s) ((_s)->sc_dev.dv_xname)
/* #define SR_DEBUG */
@@ -62,11 +182,6 @@ extern u_int32_t sr_debug;
/* forward define to prevent dependency goo */
struct sr_softc;
-#define SR_UUID_MAX 4
-struct sr_uuid {
- u_int32_t sui_id[SR_UUID_MAX];
-} __packed;
-
struct sr_ccb {
struct buf ccb_buf; /* MUST BE FIRST!! */
@@ -139,90 +254,14 @@ struct sr_raid1 {
};
/* CRYPTO */
-#ifdef CRYPTO
-#define SR_CRYPTO_MAXKEYS 32
-#define SR_CRYPTO_KEYBITS 512 /* AES-XTS with 2 * 256 bit keys */
-#define SR_CRYPTO_KEYBYTES (SR_CRYPTO_KEYBITS >> 3)
-#define SR_CRYPTO_KDFHINTBYTES 256
-
-struct sr_crypto_genkdf {
- u_int32_t len;
- u_int32_t type;
-#define SR_CRYPTOKDFT_INVALID (0)
-#define SR_CRYPTOKDFT_PBKDF2 (1<<0)
-};
-
-struct sr_crypto_kdfinfo {
- u_int32_t len;
- u_int32_t flags;
-#define SR_CRYPTOKDF_INVALID (0)
-#define SR_CRYPTOKDF_KEY (1<<0)
-#define SR_CRYPTOKDF_HINT (1<<1)
- u_int8_t maskkey[AES_MAXKEYBYTES];
- struct sr_crypto_genkdf kdfhint;
-};
-
-struct sr_crypto_metadata {
- u_int32_t scm_alg;
-#define SR_CRYPTOA_AES_XTS_128 1
-#define SR_CRYPTOA_AES_XTS_256 2
- u_int32_t scm_flags;
-#define SR_CRYPTOF_INVALID (0)
-#define SR_CRYPTOF_KEY (1<<0)
-#define SR_CRYPTOF_KDFHINT (1<<1)
-
- u_int8_t scm_key[SR_CRYPTO_MAXKEYS][SR_CRYPTO_KEYBYTES];
- u_int8_t scm_kdfhint[SR_CRYPTO_KDFHINTBYTES];
-};
-
#define SR_CRYPTO_NOWU 16
struct sr_crypto {
struct sr_crypto_metadata scr_meta;
u_int8_t scr_key[SR_CRYPTO_MAXKEYS][SR_CRYPTO_KEYBYTES];
- u_int8_t scr_maskkey[AES_MAXKEYBYTES];
+ u_int8_t scr_maskkey[SR_CRYPTO_MAXKEYBYTES];
u_int64_t scr_sid/*[SR_CRYPTO_MAXKEYS]*/;
};
-#endif /* CRYPTO */
-
-#define SR_META_SIZE 32 /* save space at chunk beginning */
-#define SR_META_OFFSET 16 /* skip 8192 bytes at chunk beginning */
-#define SR_META_VERSION 1 /* bump when sr_metadata changes */
-struct sr_metadata {
- /* do not change order of ssd_magic, ssd_version & ssd_checksum */
- u_int64_t ssd_magic; /* magic id */
-#define SR_MAGIC 0x4d4152436372616dLLU
- u_int8_t ssd_version; /* meta data version */
- u_int8_t ssd_pad1[3];
- u_int32_t ssd_flags; /* flags */
-
- /* meta-data */
- u_int32_t ssd_checksum; /* xor of the structure */
- u_int32_t ssd_size; /* sizeof(sr_metadata) */
- u_int32_t ssd_ondisk; /* on disk version counter */
- u_int32_t ssd_pad2;
- struct sr_uuid ssd_uuid; /* unique identifier */
-
- /* virtual disk data */
- u_int32_t ssd_vd_ver; /* vd structure version */
- u_int32_t ssd_vd_size; /* vd structure size */
- u_int32_t ssd_vd_volid; /* volume id */
- u_int32_t ssd_vd_chk; /* vd structure xor */
-
- /* chunk data */
- u_int32_t ssd_chunk_ver; /* chunk structure version */
- u_int32_t ssd_chunk_no; /* number of chunks */
- u_int32_t ssd_chunk_size; /* chunk structure size */
- u_int32_t ssd_chunk_id; /* chunk identifier */
- u_int32_t ssd_chunk_chk; /* chunk structure xor */
- u_int32_t ssd_pad3;
-
- /* optional metadata */
- u_int32_t ssd_opt_ver; /* optinal meta version */
- u_int32_t ssd_opt_no; /* nr of optional md elements */
- u_int32_t ssd_opt_size; /* sizeof optional metadata */
- u_int32_t ssd_opt_chk; /* optional metadata xor */
-} __packed;
struct sr_metadata_list {
struct sr_metadata *sml_metadata;
@@ -234,29 +273,6 @@ struct sr_metadata_list {
SLIST_HEAD(sr_metadata_list_head, sr_metadata_list);
-#define SR_OPT_VERSION 1 /* bump when sr_opt_meta changes */
-struct sr_opt_meta {
- u_int32_t som_type;
-#define SR_OPT_INVALID 0x00
-#define SR_OPT_CRYPTO 0x01
- u_int32_t som_pad;
- union {
- struct sr_crypto_metadata smm_crypto;
- } som_meta;
-};
-
-#define SR_CHUNK_VERSION 1 /* bump when sr_chunk_meta changes */
-struct sr_chunk_meta {
- u_int32_t scm_volid; /* vd we belong to */
- u_int32_t scm_chunk_id; /* chunk id */
- u_int32_t scm_status; /* use bio bioc_disk status */
- u_int32_t scm_pad1;
- char scm_devname[32];/* /dev/XXXXX */
- int64_t scm_size; /* size of partition in blocks*/
- int64_t scm_coerced_size; /* coerced sz of part in blk*/
- struct sr_uuid scm_uuid; /* unique identifier */
-} __packed;
-
struct sr_chunk {
struct sr_chunk_meta src_meta; /* chunk meta data */
@@ -273,25 +289,6 @@ struct sr_chunk {
SLIST_HEAD(sr_chunk_head, sr_chunk);
-#define SR_VOL_VERSION 2 /* bump when sr_vol_meta changes */
-struct sr_vol_meta {
- u_int32_t svm_volid; /* volume id */
- u_int32_t svm_status; /* use bioc_vol status */
- u_int32_t svm_flags; /* flags */
-#define SR_VOL_DIRTY 0x01
- u_int32_t svm_level; /* raid level */
- int64_t svm_size; /* virt disk size in blocks */
- char svm_devname[32];/* /dev/XXXXX */
- char svm_vendor[8]; /* scsi vendor */
- char svm_product[16];/* scsi product */
- char svm_revision[4];/* scsi revision */
- u_int32_t svm_no_chunk; /* number of chunks */
- struct sr_uuid svm_uuid; /* volume unique identifier */
-
- /* optional members */
- u_int32_t svm_strip_size; /* strip size */
-} __packed;
-
struct sr_volume {
struct sr_vol_meta sv_meta; /* meta data */
@@ -456,4 +453,6 @@ int sr_crypto_create_keys(struct sr_discipline *);
void sr_dump_mem(u_int8_t *, int);
#endif
+#endif /* _KERNEL */
+
#endif /* SOFTRAIDVAR_H */