help in block drivers

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hello All
I have some doubts in working with  block drivers. I have a "sbd_device.c" a sample block driver file and a small application that does a read request to this driver. I am working on linux-2.6.9.

After insmod'ing the driver i have run my application. My doubt is, though i have given only one read() in appln.c , it does many requests to the driver. I could not understand why the "sbd_request " is called even though i have given only one read call from user space file.

In the below user space file, i tried changing the buf size from 1 to 512  but the number of read requests done driver are same.

int fd =  -1,  buf[1], count = 1,  ret,  i=0;  
fd = open("/dev/sbd_dev0", O_RDWR);
if(fd < 0)
printf("Could not open /dev/sbd_device\n");
else
{
 printf("\nOpened device file : \n");

 printf("\nSending a Read.... \n");
 ret = read(fd, buf, count);
 printf("\n1. The value ret = %x\n", ret);
 for(i=0; i<count;i++)
    printf("buf[%d] = 0x%x\n",i, buf[i]);
    printf("\n\n");

and the dmesg ouput is:Init module...
 sbd_dev0:sbd_request
Calling sbd_transfer
Doing a read from device
 unknown partition table
sbd_request
Calling sbd_transfer
Doing a read from device
Calling sbd_transfer
Doing a read from device
Calling sbd_transfer
Doing a read from device
Calling sbd_transfer
...
....Does around 20 times.

And also in the driver, in the function sbd_request() how does the driver get the parameters  like sector, current_nr_sectors and buffer. From user space we just give the size of data transfer but not the sector etc.
sbd_transfer(&sbd_device, req->sector,  req->current_nr_sectors,  req->buffer,  rq_data_dir(req));

Anyone please help me in clearing this basic doubts so that i could move furhter fastly.

Thanks in advance
Rahul







[Index of Archives]     [Newbies FAQ]     [Linux Kernel Mentors]     [Linux Kernel Development]     [IETF Annouce]     [Git]     [Networking]     [Security]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux RAID]     [Linux SCSI]     [Linux ACPI]
  Powered by Linux