tech-kern archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
Re: dump to cgdNb device
Date: Wed, 15 Jun 2016 23:49:55 +0100
From: Alexander Nasonov <alnsn%yandex.ru@localhost>
I setup an encrypted disk cgd1 (aes-cbc 256 on top of wd0g, disklabel
verification) with a dump device cgd1b but I can't dump to it (I enter
ddb and type sync to dump). It prints "device bad".
[...]
Is it expected to work at all?
I have not witnessed it working. But I would like it to work!
By a quick skim of cgddump and dk_dump, it looks likely that the
missing part is a definition for cgddkdriver.d_dumpblocks. Here's a
candidate definition that you might try, attached. (Not tested, not
even compile-tested, caveat lector, &c.)
static int
cgd_dumpblocks(device_t dev, void *va, daddr_t blkno, int nblk)
{
struct cgd_softc *sc;
struct dk_softc *dksc;
struct disk_geom *dg;
struct disklabel *lp;
size_t nbytes;
void *buf;
int error;
/* Try to get the cgd device state. */
sc = device_private(dev);
if (sc == NULL)
/* No cgd device: give up. */
return ENXIO;
/* Extract the disk parameters: geometry, disklabel. */
dksc = &sc->sc_dksc;
dg = &dksc->sc_dkdev.dk_geom;
lp = dksc->sc_dkdev.dk_label;
/*
* Compute the number of bytes in this request, which dk_dump
* has `helpfully' converted to a number of blocks for us.
*/
nbytes = nblk*lp->d_secsize;
/* Try to acquire a buffer to store the ciphertext. */
buf = cgd_getdata(dksc, nbytes);
if (buf == NULL)
/* Out of memory: give up. */
return ENOMEM;
/* Encrypt the caller's data into the temporary buffer. */
cgd_cipher(sc, buf, va, nbytes, blkno, dg->dg_secsize,
CGD_CIPHER_ENCRYPT);
/* Pass it on to the underlying disk device. */
error = bdev_dump(sc->sc_tdev, blkno, buf, nbytes);
/* Release the buffer. */
cgd_putdata(dksc, buf);
/* Return any error from the underlying disk device. */
return error;
}
Home |
Main Index |
Thread Index |
Old Index