On Jan 19, 10:37am, Paul Goyette wrote: } On Sun, 19 Jan 2014, Christos Zoulas wrote: } > On Jan 19, 10:22am, p...@whooppee.com (Paul Goyette) wrote: } > } > | How about the following changes? } > } > You need to handle the regular open too, not justthe get (look for the } > other fd_clone) } } That's covered in cryptoopen() at line 1060 } } > | @@ -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). } } Handled indirectly. The MODULE_CMD_FINI calls config_cfdata_detach() } which attempts to detach each device instance. If a detach fails, then } config_cfdata_detach fails, and the unload will fail.
Does this mean that you'll end up with some device instances detached and not others? }-- End of excerpt from Paul Goyette