Changeset View
Changeset View
Standalone View
Standalone View
head/sys/opencrypto/cryptodev.c
Show First 20 Lines • Show All 1,493 Lines • ▼ Show 20 Lines | |||||
cryptoioctl(struct cdev *dev, u_long cmd, caddr_t data, int flag, struct thread *td) | cryptoioctl(struct cdev *dev, u_long cmd, caddr_t data, int flag, struct thread *td) | ||||
{ | { | ||||
struct file *f; | struct file *f; | ||||
struct fcrypt *fcr; | struct fcrypt *fcr; | ||||
int fd, error; | int fd, error; | ||||
switch (cmd) { | switch (cmd) { | ||||
case CRIOGET: | case CRIOGET: | ||||
error = falloc_noinstall(td, &f); | |||||
if (error) | |||||
break; | |||||
fcr = malloc(sizeof(struct fcrypt), M_XDATA, M_WAITOK | M_ZERO); | fcr = malloc(sizeof(struct fcrypt), M_XDATA, M_WAITOK | M_ZERO); | ||||
TAILQ_INIT(&fcr->csessions); | TAILQ_INIT(&fcr->csessions); | ||||
mtx_init(&fcr->lock, "fcrypt", NULL, MTX_DEF); | mtx_init(&fcr->lock, "fcrypt", NULL, MTX_DEF); | ||||
error = falloc(td, &f, &fd, 0); | finit(f, FREAD | FWRITE, DTYPE_CRYPTO, fcr, &cryptofops); | ||||
error = finstall(td, f, &fd, 0, NULL); | |||||
if (error) { | if (error) { | ||||
mtx_destroy(&fcr->lock); | mtx_destroy(&fcr->lock); | ||||
free(fcr, M_XDATA); | free(fcr, M_XDATA); | ||||
return (error); | } else | ||||
} | *(uint32_t *)data = fd; | ||||
/* falloc automatically provides an extra reference to 'f'. */ | |||||
finit(f, FREAD | FWRITE, DTYPE_CRYPTO, fcr, &cryptofops); | |||||
*(u_int32_t *)data = fd; | |||||
fdrop(f, td); | fdrop(f, td); | ||||
break; | break; | ||||
case CRIOFINDDEV: | case CRIOFINDDEV: | ||||
error = cryptodev_find((struct crypt_find_op *)data); | error = cryptodev_find((struct crypt_find_op *)data); | ||||
break; | break; | ||||
case CRIOASYMFEAT: | case CRIOASYMFEAT: | ||||
error = crypto_getfeat((int *)data); | error = crypto_getfeat((int *)data); | ||||
break; | break; | ||||
▲ Show 20 Lines • Show All 49 Lines • Show Last 20 Lines |