scsi adapter module over block device - need help

Dmitry Filippov filippovd20 at gmail.com
Sat Oct 6 09:28:19 EDT 2012


Hi all,

i'm just learning kernel and not experienced in writing code for it.
I'm going to write kernel module in studying purposes and i hope
someone from you could help me with it and in best case guide me
through overall process.

I want to write module that implements SCSI-disk logic, keeping its
data on block device. For example partition of existing disk. So i
want to pass the name of block device as parameter to my module while
loading to kernel.

So it will be some kind of virtual(pseudo) scsi device that appears in
/dev as scsi disk and in fact some block device as backend. I want it
to be as simple as possible... keeping just essential parts... and it
is not intended to be some kind of production driver... i want it to
be just as simple as sbull from LDD)))

As from my point of view there are 2 major parts, with which i'm
completely not confident and doesn't know from where to start...
1. scsi subsystem... so how to write my module to interact with scsi
subsystem in this case and to not reinvent the wheel. using scsi
kernel API as much as possible.
i have found interesting thing in kernel source scsi_debug module...
which represent scsi disk and have ram as backend (so some kind of
sbull but with scsi). However i got overwhelmed with its code. It is
very difficult for me to sort out with it by my own... maybe someone
can help?

2. module code interaction with existing block device... that is i
completely don't understand how to achieve. ok.. i have device name in
kernel space... whats then? how i can access this device?
so how i can write some adapter for existing device and transit some
writes/reads and other fops from my device to existing... I saw same
questions on forums... and the only answer is to use sys_write... or
vfs_write... to existing block device node... if it is most
simple/correct way?

i hope someone could help me sort out in those things eventually.
Really need your help!

thanks in advance,
-Dmitry Filippov



More information about the Kernelnewbies mailing list