-/* $OpenBSD: softraid.c,v 1.346 2014/12/16 19:51:33 tedu Exp $ */
+/* $OpenBSD: softraid.c,v 1.347 2014/12/19 17:15:16 tedu Exp $ */
/*
* Copyright (c) 2007, 2008, 2009 Marco Peereboom <marco@peereboom.us>
* Copyright (c) 2008 Chris Kuethe <ckuethe@openbsd.org>
bufsize = (size > MAXPHYS) ? MAXPHYS : size;
if (flags == B_WRITE)
- bcopy(buf, dma_buf, bufsize);
+ memcpy(dma_buf, buf, bufsize);
bzero(&b, sizeof(b));
b.b_flags = flags | B_PHYS;
}
if (flags == B_READ)
- bcopy(dma_buf, buf, bufsize);
+ memcpy(buf, dma_buf, bufsize);
size -= bufsize;
buf += bufsize;
scm->scmi.scm_volid = 0;
strlcpy(scm->scmi.scm_devname, chunk->src_devname,
sizeof(scm->scmi.scm_devname));
- bcopy(&sm->ssdi.ssd_uuid, &scm->scmi.scm_uuid,
+ memcpy(&scm->scmi.scm_uuid, &sm->ssdi.ssd_uuid,
sizeof(scm->scmi.scm_uuid));
sr_checksum(sc, scm, &scm->scm_checksum,
sizeof(scm->scm_checksum));
restart:
sm->ssd_ondisk++;
sm->ssd_meta_flags = flags;
- bcopy(sm, m, sizeof(*m));
+ memcpy(m, sm, sizeof(*m));
/* Chunk metadata. */
cm = (struct sr_meta_chunk *)(m + 1);
for (i = 0; i < sm->ssdi.ssd_chunk_no; i++) {
src = sd->sd_vol.sv_chunks[i];
- bcopy(&src->src_meta, cm, sizeof(*cm));
+ memcpy(cm, &src->src_meta, sizeof(*cm));
cm++;
}
bzero(&omi->omi_som->som_checksum, MD5_DIGEST_LENGTH);
sr_checksum(sc, omi->omi_som, &omi->omi_som->som_checksum,
omi->omi_som->som_length);
- bcopy(omi->omi_som, omh, omi->omi_som->som_length);
+ memcpy(omh, omi->omi_som, omi->omi_som->som_length);
omh = (struct sr_meta_opt_hdr *)((u_int8_t *)omh +
omi->omi_som->som_length);
}
/* assume first chunk contains metadata */
if (got_meta == 0) {
sr_meta_opt_load(sc, sm, &sd->sd_meta_opt);
- bcopy(sm, sd->sd_meta, sizeof(*sd->sd_meta));
+ memcpy(sd->sd_meta, sm, sizeof(*sd->sd_meta));
got_meta = 1;
}
- bcopy(cp, &ch_entry->src_meta, sizeof(ch_entry->src_meta));
+ memcpy(&ch_entry->src_meta, cp, sizeof(ch_entry->src_meta));
no_disk++;
cp++;
omi->omi_som = malloc(omh->som_length, M_DEVBUF,
M_WAITOK | M_ZERO);
- bcopy((u_int8_t *)omh + SR_OLD_META_OPT_OFFSET,
- (u_int8_t *)omi->omi_som + sizeof(*omi->omi_som),
+ memcpy((u_int8_t *)omi->omi_som + sizeof(*omi->omi_som),
+ (u_int8_t *)omh + SR_OLD_META_OPT_OFFSET,
omh->som_length - sizeof(*omi->omi_som));
omi->omi_som->som_type = omh->som_type;
omi->omi_som->som_length = omh->som_length;
omh->som_length);
omi->omi_som = malloc(omh->som_length, M_DEVBUF,
M_WAITOK | M_ZERO);
- bcopy(omh, omi->omi_som, omh->som_length);
+ memcpy(omi->omi_som, omh, omh->som_length);
/* Validate checksum. */
- bcopy(&omi->omi_som->som_checksum, &checksum,
+ memcpy(&checksum, &omi->omi_som->som_checksum,
MD5_DIGEST_LENGTH);
bzero(&omi->omi_som->som_checksum, MD5_DIGEST_LENGTH);
sr_checksum(sc, omi->omi_som,
M_DEVBUF, M_WAITOK | M_ZERO);
bc->sbc_metadata = malloc(sizeof(struct sr_metadata),
M_DEVBUF, M_WAITOK | M_ZERO);
- bcopy(md, bc->sbc_metadata, sizeof(struct sr_metadata));
+ memcpy(bc->sbc_metadata, md, sizeof(struct sr_metadata));
bc->sbc_mm = rawdev;
SLIST_INSERT_HEAD(bch, bc, sbc_link);
rv = SR_META_CLAIMED;
bv->sbv_volid = bc->sbc_metadata->ssdi.ssd_volid;
bv->sbv_chunk_no = bc->sbc_metadata->ssdi.ssd_chunk_no;
bv->sbv_flags = bc->sbc_metadata->ssdi.ssd_vol_flags;
- bcopy(&bc->sbc_metadata->ssdi.ssd_uuid, &bv->sbv_uuid,
+ memcpy(&bv->sbv_uuid, &bc->sbc_metadata->ssdi.ssd_uuid,
sizeof(bc->sbc_metadata->ssdi.ssd_uuid));
SLIST_INIT(&bv->sbv_chunks);
hm->scmi.scm_coerced_size = bc->sbc_metadata->ssdi.ssd_size;
strlcpy(hm->scmi.scm_devname, devname,
sizeof(hm->scmi.scm_devname));
- bcopy(&bc->sbc_metadata->ssdi.ssd_uuid, &hm->scmi.scm_uuid,
+ memcpy(&hm->scmi.scm_uuid, &bc->sbc_metadata->ssdi.ssd_uuid,
sizeof(struct sr_uuid));
sr_checksum(sc, hm, &hm->scm_checksum,
for (i = 0; i < SR_MAX_BOOT_DISKS; i++) {
if (bcmp(rootduid, sbm->sbm_boot_duid[i],
sizeof(rootduid)) == 0) {
- bcopy(sbm->sbm_root_duid, rootduid,
+ memcpy(rootduid, sbm->sbm_root_duid,
sizeof(rootduid));
DNPRINTF(SR_D_MISC, "%s: root duid "
"mapped to %02hx%02hx%02hx%02hx"
DEVNAME(sc), devname);
goto unwind;
}
- bcopy(label.d_uid, ch_entry->src_duid, sizeof(ch_entry->src_duid));
+ memcpy(ch_entry->src_duid, label.d_uid, sizeof(ch_entry->src_duid));
/* Make sure this is a 512-byte/sector device. */
if (label.d_secsize != DEV_BSIZE) {
ch_entry->src_meta.scmi.scm_chunk_id =
md->ssdi.ssd_chunk_id;
if (d == 0) {
- bcopy(&md->ssdi.ssd_uuid, &uuid, sizeof uuid);
+ memcpy(&uuid, &md->ssdi.ssd_uuid, sizeof uuid);
expected = md->ssdi.ssd_chunk_no;
version = md->ssd_ondisk;
d++;
if (xs->datalen) {
copy_cnt = MIN(size, xs->datalen);
- bcopy(v, xs->data, copy_cnt);
+ memcpy(xs->data, v, copy_cnt);
}
}
stuffup:
if (sd && sd->sd_scsi_sense.error_code) {
xs->error = XS_SENSE;
- bcopy(&sd->sd_scsi_sense, &xs->sense, sizeof(xs->sense));
+ memcpy(&xs->sense, &sd->sd_scsi_sense, sizeof(xs->sense));
bzero(&sd->sd_scsi_sense, sizeof(sd->sd_scsi_sense));
} else {
xs->error = XS_DRIVER_STUFFUP;
sc->sc_status.bs_status = (rv ? BIO_STATUS_ERROR : BIO_STATUS_SUCCESS);
- bcopy(&sc->sc_status, &bio->bio_status, sizeof(struct bio_status));
+ memcpy(&bio->bio_status, &sc->sc_status, sizeof(struct bio_status));
rw_exit_write(&sc->sc_lock);
hm->scmi.scm_size = size;
hm->scmi.scm_coerced_size = size;
strlcpy(hm->scmi.scm_devname, devname, sizeof(hm->scmi.scm_devname));
- bcopy(&uuid, &hm->scmi.scm_uuid, sizeof(struct sr_uuid));
+ memcpy(&hm->scmi.scm_uuid, &uuid, sizeof(struct sr_uuid));
sr_checksum(sc, hm, &hm->scm_checksum,
sizeof(struct sr_meta_chunk_invariant));
sm->ssdi.ssd_version = SR_META_VERSION;
sm->ssd_ondisk = 0;
sm->ssdi.ssd_vol_flags = 0;
- bcopy(&uuid, &sm->ssdi.ssd_uuid, sizeof(struct sr_uuid));
+ memcpy(&sm->ssdi.ssd_uuid, &uuid, sizeof(struct sr_uuid));
sm->ssdi.ssd_chunk_no = 1;
sm->ssdi.ssd_volid = SR_HOTSPARE_VOLID;
sm->ssdi.ssd_level = SR_HOTSPARE_LEVEL;
open = 0; /* leave dev open from here on out */
/* Fix up chunk. */
- bcopy(label.d_uid, chunk->src_duid, sizeof(chunk->src_duid));
+ memcpy(chunk->src_duid, label.d_uid, sizeof(chunk->src_duid));
chunk->src_dev_mm = dev;
chunk->src_vn = vn;
sizeof(meta->scmi.scm_devname));
meta->scmi.scm_size = size;
meta->scmi.scm_coerced_size = csize;
- bcopy(&sd->sd_meta->ssdi.ssd_uuid, &meta->scmi.scm_uuid,
+ memcpy(&meta->scmi.scm_uuid, &sd->sd_meta->ssdi.ssd_uuid,
sizeof(meta->scmi.scm_uuid));
sr_checksum(sc, meta, &meta->scm_checksum,
sizeof(struct sr_meta_chunk_invariant));
if (copyin(bc->bc_dev_list, dt, bc->bc_dev_list_len) != 0)
goto unwind;
} else
- bcopy(bc->bc_dev_list, dt, bc->bc_dev_list_len);
+ memcpy(dt, bc->bc_dev_list, bc->bc_dev_list_len);
/* Initialise discipline. */
sd = malloc(sizeof(struct sr_discipline), M_DEVBUF, M_WAITOK | M_ZERO);
sr_error(sc, "failed to get DUID for softraid volume");
goto done;
}
- bcopy(dk->dk_label->d_uid, duid, sizeof(duid));
+ memcpy(duid, dk->dk_label->d_uid, sizeof(duid));
/* Ensure that boot storage area is large enough. */
if (sd->sd_meta->ssd_data_offset < (SR_BOOT_OFFSET + SR_BOOT_SIZE)) {
}
sbm = (struct sr_meta_boot *)omi->omi_som;
- bcopy(duid, sbm->sbm_root_duid, sizeof(sbm->sbm_root_duid));
+ memcpy(sbm->sbm_root_duid, duid, sizeof(sbm->sbm_root_duid));
bzero(&sbm->sbm_boot_duid, sizeof(sbm->sbm_boot_duid));
sbm->sbm_bootblk_size = bbs;
sbm->sbm_bootldr_size = bls;
continue;
if (i < SR_MAX_BOOT_DISKS)
- bcopy(chunk->src_duid, &sbm->sbm_boot_duid[i],
+ memcpy(&sbm->sbm_boot_duid[i], chunk->src_duid,
sizeof(sbm->sbm_boot_duid[i]));
/* Save boot blocks. */
DEVNAME(sd->sd_sc));
/* use latest sense data */
- bcopy(&sd->sd_scsi_sense, &xs->sense, sizeof(xs->sense));
+ memcpy(&xs->sense, &sd->sd_scsi_sense, sizeof(xs->sense));
/* clear sense data */
bzero(&sd->sd_scsi_sense, sizeof(sd->sd_scsi_sense));
*/
aes_xts_setkey(&ctx, my->srd->mds.mdd_crypto.scr_key[0], 64);
/* We encrypt DEV_BSIZE bytes at a time in my->buf */
- bcopy(((char *)addr) + i, my->buf, DEV_BSIZE);
+ memcpy(my->buf, ((char *)addr) + i, DEV_BSIZE);
/* Block number is the IV */
- bcopy(&key_blkno, &iv, sizeof(key_blkno));
+ memcpy(&iv, &key_blkno, sizeof(key_blkno));
aes_xts_reinit(&ctx, iv);
/* Encrypt DEV_BSIZE bytes, AES_XTS_BLOCKSIZE bytes at a time */
-/* $OpenBSD: softraid_crypto.c,v 1.115 2014/11/18 02:37:30 tedu Exp $ */
+/* $OpenBSD: softraid_crypto.c,v 1.116 2014/12/19 17:15:16 tedu Exp $ */
/*
* Copyright (c) 2007 Marco Peereboom <marco@peereboom.us>
* Copyright (c) 2008 Hans-Joerg Hoexer <hshoexer@openbsd.org>
if (data != NULL) {
/* Kernel already has mask key. */
- bcopy(data, sd->mds.mdd_crypto.scr_maskkey,
+ memcpy(sd->mds.mdd_crypto.scr_maskkey, data,
sizeof(sd->mds.mdd_crypto.scr_maskkey));
} else if (bc->bc_key_disk != NODEV) {
/* Read the mask key from the key disk. */
crwu->cr_uio.uio_iov->iov_len = xs->datalen;
if (xs->flags & SCSI_DATA_OUT) {
crwu->cr_uio.uio_iov->iov_base = crwu->cr_dmabuf;
- bcopy(xs->data, crwu->cr_uio.uio_iov->iov_base, xs->datalen);
+ memcpy(crwu->cr_uio.uio_iov->iov_base, xs->data, xs->datalen);
} else
crwu->cr_uio.uio_iov->iov_base = xs->data;
crd->crd_alg = sd->mds.mdd_crypto.scr_alg;
crd->crd_klen = sd->mds.mdd_crypto.scr_klen;
crd->crd_key = sd->mds.mdd_crypto.scr_key[0];
- bcopy(&blk, crd->crd_iv, sizeof(blk));
+ memcpy(crd->crd_iv, &blk, sizeof(blk));
}
return (crwu);
if (sizeof(sd->mds.mdd_crypto.scr_meta->scm_kdfhint) <
kdfinfo->genkdf.len)
goto out;
- bcopy(&kdfinfo->genkdf,
- sd->mds.mdd_crypto.scr_meta->scm_kdfhint,
- kdfinfo->genkdf.len);
+ memcpy(sd->mds.mdd_crypto.scr_meta->scm_kdfhint,
+ &kdfinfo->genkdf, kdfinfo->genkdf.len);
}
/* copy mask key to run-time meta data */
if (sizeof(sd->mds.mdd_crypto.scr_maskkey) <
sizeof(kdfinfo->maskkey))
goto out;
- bcopy(&kdfinfo->maskkey, sd->mds.mdd_crypto.scr_maskkey,
+ memcpy(sd->mds.mdd_crypto.scr_maskkey, &kdfinfo->maskkey,
sizeof(kdfinfo->maskkey));
}
sizeof(sd->mds.mdd_crypto.scr_key), check_digest);
/* Copy new encrypted key and HMAC to metadata. */
- bcopy(check_digest, sd->mds.mdd_crypto.scr_meta->chk_hmac_sha1.sch_mac,
+ memcpy(sd->mds.mdd_crypto.scr_meta->chk_hmac_sha1.sch_mac, check_digest,
sizeof(sd->mds.mdd_crypto.scr_meta->chk_hmac_sha1.sch_mac));
rv = 0; /* Success */
km->scmi.scm_size = 0;
km->scmi.scm_coerced_size = 0;
strlcpy(km->scmi.scm_devname, devname, sizeof(km->scmi.scm_devname));
- bcopy(&sd->sd_meta->ssdi.ssd_uuid, &km->scmi.scm_uuid,
+ memcpy(&km->scmi.scm_uuid, &sd->sd_meta->ssdi.ssd_uuid,
sizeof(struct sr_uuid));
sr_checksum(sc, km, &km->scm_checksum,
sm->ssdi.ssd_version = SR_META_VERSION;
sm->ssd_ondisk = 0;
sm->ssdi.ssd_vol_flags = 0;
- bcopy(&sd->sd_meta->ssdi.ssd_uuid, &sm->ssdi.ssd_uuid,
+ memcpy(&sm->ssdi.ssd_uuid, &sd->sd_meta->ssdi.ssd_uuid,
sizeof(struct sr_uuid));
sm->ssdi.ssd_chunk_no = 1;
sm->ssdi.ssd_volid = SR_KEYDISK_VOLID;
omi->omi_som->som_type = SR_OPT_KEYDISK;
omi->omi_som->som_length = sizeof(struct sr_meta_keydisk);
skm = (struct sr_meta_keydisk *)omi->omi_som;
- bcopy(sd->mds.mdd_crypto.scr_maskkey, &skm->skm_maskkey,
+ memcpy(&skm->skm_maskkey, sd->mds.mdd_crypto.scr_maskkey,
sizeof(skm->skm_maskkey));
SLIST_INSERT_HEAD(&fakesd->sd_meta_opt, omi, omi_link);
fakesd->sd_meta->ssdi.ssd_opt_no++;
key_disk->src_vn = vn;
key_disk->src_size = 0;
- bcopy((struct sr_meta_chunk *)(sm + 1), &key_disk->src_meta,
+ memcpy(&key_disk->src_meta, (struct sr_meta_chunk *)(sm + 1),
sizeof(key_disk->src_meta));
/* Read mask key from optional metadata. */
omh = omi->omi_som;
if (omh->som_type == SR_OPT_KEYDISK) {
skm = (struct sr_meta_keydisk *)omh;
- bcopy(&skm->skm_maskkey,
- sd->mds.mdd_crypto.scr_maskkey,
+ memcpy(sd->mds.mdd_crypto.scr_maskkey, &skm->skm_maskkey,
sizeof(sd->mds.mdd_crypto.scr_maskkey));
} else if (omh->som_type == SR_OPT_CRYPTO) {
/* Original keydisk format with key in crypto area. */
- bcopy(omh + sizeof(struct sr_meta_opt_hdr),
- sd->mds.mdd_crypto.scr_maskkey,
+ memcpy(sd->mds.mdd_crypto.scr_maskkey,
+ omh + sizeof(struct sr_meta_opt_hdr),
sizeof(sd->mds.mdd_crypto.scr_maskkey));
}
}