Total And Complete Wackyness

jmcmullan@linuxcare.com
11 Feb 2000 06:43:28 GMT


I've got a stumper for y'all, all against Kernel 2.2.x:

Assume you've got a removable media drive (/dev/rmbd)
that already has a kernel driver, and ``Widget X''.
Here's Widget X's properties:

*) Widget X physically looks like a piece of media for the
removate media block device (RMBD), but is _actually_
a bunch of electronics, memory, and some coils that rest
against the RMBD's read/write head.

*) Does all communication through sectors 0-13 of the RMBD

*) Has a device driver (call it /dev/widx) which
uses filp_open/block_read/block_write/filp_close/etc
to perform a communications protocol with
Widget X via the RMBD.

*) /dev/widx is a block device, and (while performing
it's wacky mechanations through the RMBD) looks
to userland like any another mkfs(8)able block device

Got me so far? Good. Well, here comes the rub - since
/dev/widx is a different major number from /dev/rmbd, you
can get into a state where Widget X is in the drive, you're
happily using /dev/widx, and BAM - somebody (supermount,
autofs, whatever) reads/writes from /dev/rmbd - totally
hosing your communications.

So, what I would _like_ to do is:

*) Change blk_dev[RMBD_MAJOR].request_fn to point to my
function that scans for the signature of a Widget X,
otherwise proceed as normally for /dev/rmbd

so that...

*) Whenever Widget X is inserted into the RMBD, I override the
file_operations and blk_dev[RMBD_MAJOR].request_fn
properties of /dev/rmbd to point to the Widget X functions...

but...

*) Still be able to use the /dev/rmbd block device functionality
from the Widget X comminications protocol code...

and...

*) When the Widget X is removed, undo the override and restore
/dev/rmbd to its original functionality

with the condition that...

*) I can't modify the /dev/rmbd kernel code, NOR include an entire
copy of the /dev/rmbd code into my driver (and all the nasty
state issues that would bring)

Have I bitten off more than I can chew, or is protocol layering
over block devices REALLY possible?

-- 
Jason McMullan, Senior Linux Consultant, Linuxcare, Inc.
412.422.8077 tel, 415.701.0792 fax
jmcmullan@linuxcare.com, http://www.linuxcare.com/
Linuxcare. Support for the revolution.

- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.rutgers.edu Please read the FAQ at http://www.tux.org/lkml/