On Jan 19, 10:22am, paul%whooppee.com@localhost (Paul Goyette) wrote:
-- Subject: Re: CVS commit: src/sys/opencrypto
| How about the following changes?
You need to handle the regular open too, not justthe get (look for the
other fd_clone)
| @@ -143,6 +143,8 @@ static int cryptoread(dev_t dev, struct
| static int cryptowrite(dev_t dev, struct uio *uio, int ioflag);
| static int cryptoselect(dev_t dev, int rw, struct lwp *l);
|
| +static int crypto_refcount = 0; /* Prevent detaching while in use */
| +
| /* Declaration of cloned-device (per-ctxt) entrypoints */
| static int cryptof_read(struct file *, off_t *, struct uio *,
| kauth_cred_t, int);
| @@ -262,6 +264,7 @@ cryptof_ioctl(struct file *fp, u_long cm
| */
| criofcr->sesn = 1;
| criofcr->requestid = 1;
| + crypto_refcount++;
| mutex_exit(&crypto_mtx);
| (void)fd_clone(criofp, criofd, (FREAD|FWRITE),
| &cryptofops, criofcr);
| @@ -951,6 +954,7 @@ cryptof_close(struct file *fp)
| }
| seldestroy(&fcr->sinfo);
| fp->f_data = NULL;
| + crypto_refcount--;
| mutex_exit(&crypto_mtx);
|
| pool_put(&fcrpl, fcr);
| @@ -1080,6 +1084,7 @@ cryptoopen(dev_t dev, int flag, int mode
| */
| fcr->sesn = 1;
| fcr->requestid = 1;
| + crypto_refcount++;
| mutex_exit(&crypto_mtx);
| return fd_clone(fp, fd, flag, &cryptofops, fcr);
| }
| @@ -2109,6 +2114,10 @@ int crypto_detach(device_t, int);
It is not just the detach we need to handle, it is the module unload too
(look for FINI).