Monday, November 06, 2006
Linux 2.6 Block Device Driver
Recently, I had to make an MMC card work under Linux 2.6.
I found a very simple block device driver on this page:
https://lwn.net/Articles/58719/
Source is here:
https://lwn.net/Articles/58720/
The article is about porting a block device from 2.4 to 2.6, but it gave a good description of Linux block devices in general.
The source implements a ram disk, but it is very easy to substitute your own code for your device.
To use the device, find its major_number in /proc/devices and create the device with:
mknod /dev/sbd0 b major_number minor_number
Usually the minor_number is the partition number.
Then you can mount it and use it.
I found a very simple block device driver on this page:
https://lwn.net/Articles/58719/
Source is here:
https://lwn.net/Articles/58720/
The article is about porting a block device from 2.4 to 2.6, but it gave a good description of Linux block devices in general.
The source implements a ram disk, but it is very easy to substitute your own code for your device.
To use the device, find its major_number in /proc/devices and create the device with:
mknod /dev/sbd0 b major_number minor_number
Usually the minor_number is the partition number.
Then you can mount it and use it.