linux - Why is the kernel using the default block driver instead of my driver's code? -
I wrote a block driver program that creates a dummy block device ( I compiled the driver program, I put the module and created the Output is: I'm surprised: I did not have the has implemented this These are my questions: simply You will find the sbd0 ). I registered all device operations for that block device: (see
include / linux / blkdev.h in the 2.6.32 kernel source)
static structure block_device_operations sbd_ops = {.owner = THIS_MODULE, .open = sbd_open, .octl = sbd_ioctl, .getgeo = sbd_getgeo, .locked_ioctl = sbd_locked_ioctl, .compat_ioctl = sbd_compat_ioctl, .direct_access = sbd_direct_access, .media_changed = sbd_media_changed, .revalidate_disk = sbd_revalidate_disk};
/ dev / sbd0 . Now I want to test my driver code. So I wrote an application below.
fd = open ("/ dev / sbd0", O_RDONLY); Retvl = IOCLL (FD, BLKBSZ, and Blocks); Trying to get the logical block size
4096
For ioctl has not implemented BLKBSZGET . This did not implement my
sbd_ioctl , instead it used the default driver and gave me results. It has been executed for
open ,
off calls
sbd_open and
sbd_close (which I have applied). And then I tried:
retval = ioctl (fd, hdio_getGEO, and geoinfo);
sbd_getgeo but I thought it would call
sbd_ioctl .
ioctl (fd, hdio_getGEO, ..)
did not invoke. .ctl call , but it has been applied to
.getgeo . How is this possible?
ioctl sending is handled
blkdev_ioctl By the function, which will process directly on some ioctls without calling a specific routine of your driver.
for HDIO_GETGEO , it calls your driver
getgeo function directly (3.13.6 from kernel, much later than 2.6.32 Change does not appear):
[...] / * * First we need to set startect, driver * wants to override it. * / Mameset (and ground, 0, size (ground)); Geo.start = get_start_sect (bdev); Rate = disk-> FPS-> Getgeo (BDV, and Geo);
block_size (bdev)) , which for
BLKBSZGET and [...]
bdev- & gt; Bd_block_size .
blkdev_ioctl in the
block / ioctl.c if you need to know what happens to other ioctls.
Comments
Post a Comment