I have patched the rtl_fifo module to support "multiple opens".  I hope
others will find this useful. Please try it and let me know what you
think.  I've attached a tarball of the sources, binaries and patches.
I've included the README here :

Multiple Open RTL Fifos

This patch allows a single user to open an rtl_fifo device more than
once.
The first user to open a device can continue to open it repeatedly, 
but any other user trying to open the device will get an "-EBUSY".
This is true until the first user closes all file descriptors to
the given fifo, after which another user may open it, etc.

This can be useful for coordinated sets of processes which all desire to
talk
to one device (per Rubini's Linux Device Drivers book).
It was originally created for C++ programming, where objects which
represent
different parts of a multifunction device don't share data, like file
descriptors.

The new code stores the user id of the first user to open the device in
the
user_open field of rt_fifo_struct (if the user is root, with a uid of 0,
we store -1, a nonzero uid). We keep track of the number of times that
user
opens that particular minor of the device in the fd_count field of 
rt_fifo_struct.
This was added to manipulate fd_count:
#define RTF_FD_COUNT(minor)     (RTF_ADDR(minor)->fd_count)
Only the functions rtf_open(), rtf_release() and rtf_create() were
modified to
accomodate the new code. The module usage count will be
incremented/decremented
on an open/close of any file descriptor to any fifo. The fifo device
suffers no
performance hit from this added functionality since it executes only
when fd's
to fifos are opened or closed.

A little tool "keep-daqcfg-open.c" is provided to help test the multiple
open
functionality.

The patch "rtl_fifo-multi.patch" was made and tested on RTLBETA-15 and
kernel 2.2.12, a patch for RTLBETA-16 is supplied too (but hasn't been
tested).

The rtl_fifo.c file here is pre-patched, but you can patch virgin
sources like
this:
patch -p1 rtl_fifo.c <rtl_fifo-multi.patch

The "verbose" version spits out messages which can be viewed with
'dmesg' every
time there is a status change. This is for testers/doubters.

Prepatched revisions of the source and compiled module are provided also
(for kernel 2.2.12, rltbeta15).

-- 
Steve Rosenbluth
Jim Henson's Creature Shop
2821 Burton St, Burbank CA 91505
(818) 953-3030

rtl_fifo-multi.tar.gz

Reply via email to