Emmanuel Dreyfus <m...@netbsd.org> wrote: > Perhaps the right way is to add a FSSIOBUSY ioctl that would > use mutex_tryenter and return EBUSY if the device is in use?
I propose the change below, so that we can find an available /dev/fss* device without hanging: --- sys/dev/fss.c.orig +++ sys/dev/fss.c @@ -427,8 +427,17 @@ mutex_exit(&sc->sc_slock); error = 0; break; + case FSSIOBUSY: + if (mutex_tryenter(&sc->sc_slock) == 0) { + error = EBUSY; + break; + } + error = (sc->sc_flags & FSS_ACTIVE) ? EBUSY : 0; + mutex_exit(&sc->sc_slock); + break; + default: error = EINVAL; break; } --- sys/dev/fssvar.h.orig +++ sys/dev/fssvar.h @@ -56,8 +56,10 @@ #define FSSIOCGET _IOR('F', 1, struct fss_get) /* Status */ #define FSSIOCCLR _IO('F', 2) /* Unconfigure */ #define FSSIOFSET _IOW('F', 3, int) /* Set flags */ #define FSSIOFGET _IOR('F', 4, int) /* Get flags */ +#define FSSIOBUSY _IO('F', 6) /* Is busy? */ + #ifdef _KERNEL #include <compat/sys/time_types.h> struct fss_set50 { -- Emmanuel Dreyfus http://hcpnet.free.fr/pubz m...@netbsd.org