Boris
Boris

Reputation: 3243

Reading from a block device in kernel space

I am writing a kernel module and need to perform reads from an existing block device. (/dev/something).

Does anyone know of any other modules that do these that I can use as reference ?

Any pointers would be welcome

(Linux.2.6.30)

Upvotes: 3

Views: 3110

Answers (2)

Boolean
Boolean

Reputation: 14664

You can look at any hard disk device driver.

Upvotes: 0

Dipstick
Dipstick

Reputation: 10119

If you really absolutely must then use the filp_open, filp_close, vfs_read and vfs_write functions.

The description for for filp_open states "This is the helper to open a file from kernelspace if you really have to. But in generally you should not do this, so please move along, nothing to see here.."

There is an excellent article "Driving Me Nuts - Things You Never Should Do in the Kernel" at http://www.linuxjournal.com/article/8110

Upvotes: 3

Related Questions