diff options
author | Ted Unangst <tedu@cvs.openbsd.org> | 2011-07-08 01:17:59 +0000 |
---|---|---|
committer | Ted Unangst <tedu@cvs.openbsd.org> | 2011-07-08 01:17:59 +0000 |
commit | 1f3b181998b8d4f819e845f3154339a04ed1c4a7 (patch) | |
tree | 97272d6f4fb8834b7cf64882ebf720d392b807ad /sbin/bioctl/bioctl.c | |
parent | 578f8d9d863edfa8128a6ee30bf317c1856e2136 (diff) |
add basic config support for creating aoe disks. ok marco
Diffstat (limited to 'sbin/bioctl/bioctl.c')
-rw-r--r-- | sbin/bioctl/bioctl.c | 73 |
1 files changed, 65 insertions, 8 deletions
diff --git a/sbin/bioctl/bioctl.c b/sbin/bioctl/bioctl.c index c88d2fffc6e..b7cd053ded0 100644 --- a/sbin/bioctl/bioctl.c +++ b/sbin/bioctl/bioctl.c @@ -1,4 +1,4 @@ -/* $OpenBSD: bioctl.c,v 1.100 2011/07/04 04:52:34 tedu Exp $ */ +/* $OpenBSD: bioctl.c,v 1.101 2011/07/08 01:17:58 tedu Exp $ */ /* * Copyright (c) 2004, 2005 Marco Peereboom @@ -691,12 +691,57 @@ bio_blink(char *enclosure, int target, int blinktype) close(bioh); } +struct sr_aoe_config * +create_aoe(u_int16_t level, char *dev_list) +{ + static struct sr_aoe_config sac; + char *nic; + char *dsteaddr; + char *shelf; + char *slot; + struct ether_addr *eaddr; + const char *errstr; + + nic = dsteaddr = slot = shelf = 0; + + memset(&sac, 0, sizeof(sac)); + nic = dev_list; + dsteaddr = strchr(nic, ','); + if (!dsteaddr) + goto invalid; + *dsteaddr++ = '\0'; + shelf = strchr(dsteaddr, ','); + if (!shelf) + goto invalid; + *shelf++ = '\0'; + slot = strchr(shelf, ','); + if (!slot) + goto invalid; + *slot++ = '\0'; + strlcpy(sac.nic, nic, sizeof(sac.nic)); + eaddr = ether_aton(dsteaddr); + if (!eaddr) + goto invalid; + sac.dsteaddr = *eaddr; + sac.shelf = htons(strtonum(shelf, 0, 0xfffe, &errstr)); + if (errstr) + goto invalid; + sac.slot = strtonum(slot, 0, 0xfe, &errstr); + if (errstr) + goto invalid; + + return &sac; +invalid: + errx(1, "invalid AOE dev list: use nic,dsteaddr,shelf,slot"); +} + void bio_createraid(u_int16_t level, char *dev_list, char *key_disk) { struct bioc_createraid create; struct sr_crypto_kdfinfo kdfinfo; struct sr_crypto_kdf_pbkdf2 kdfhint; + struct sr_aoe_config *sac; struct stat sb; int rv, no_dev, fd; dev_t *dt; @@ -705,12 +750,18 @@ bio_createraid(u_int16_t level, char *dev_list, char *key_disk) if (!dev_list) errx(1, "no devices specified"); - dt = (dev_t *)malloc(BIOC_CRMAXLEN); - if (!dt) - err(1, "not enough memory for dev_t list"); - memset(dt, 0, BIOC_CRMAXLEN); - - no_dev = bio_parse_devlist(dev_list, dt); + if (level == 'a') { + sac = create_aoe(level, dev_list); + no_dev = 0; + dt = NULL; + } else { + dt = (dev_t *)malloc(BIOC_CRMAXLEN); + if (!dt) + err(1, "not enough memory for dev_t list"); + memset(dt, 0, BIOC_CRMAXLEN); + + no_dev = bio_parse_devlist(dev_list, dt); + } switch (level) { case 0: @@ -729,6 +780,8 @@ bio_createraid(u_int16_t level, char *dev_list, char *key_disk) case 'c': min_disks = 1; break; + case 'a': + break; default: errx(1, "unsupported raid level"); } @@ -748,7 +801,11 @@ bio_createraid(u_int16_t level, char *dev_list, char *key_disk) create.bc_flags = BIOC_SCDEVT | cflags; create.bc_key_disk = NODEV; - if (level == 'C' && key_disk == NULL) { + if (level == 'a') { + create.bc_opaque = sac; + create.bc_opaque_size = sizeof(*sac); + create.bc_opaque_flags = BIOC_SOIN; + } else if (level == 'C' && key_disk == NULL) { memset(&kdfinfo, 0, sizeof(kdfinfo)); memset(&kdfhint, 0, sizeof(kdfhint)); |