Reading and Writing to block devices is done through functions ... bread and block_read. The bread function takes arguments that specify a block device, block number on that device and its block size and return a buffer head structure that will contain a pointer to the appropriate block in memory. Block device drivers use this function. I believe block_read is a wrapper round bread. I think the filesystem functions use block_read as it takes arguments like struct inode* and struct file*, char* etc. You can check out fs/block_dev.c to know more. Regards, Bijoy. ----- Original Message ----- From: Ahmed A <ahmedcali@xxxxxxxxx> Date: Wednesday, September 15, 2004 8:43 am Subject: Re: Accessing a block device within kernel space.. > Hi Vinod, > > Thank you for your response. I have read Chap 13 of > ldd a few times. What I am looking for is pointers to > send read/write commands to a block device, not how to > write a block device driver. > > Regards, > Ahmed. > > --- Vinod Sreedharan <vinod.sreedharan@xxxxxxxxxxxxxx> > wrote: > > > > > >reads/writes to this block device, without any type > > of > > >caching, and without going through any layers (e.g > > >filesystem). > > > > I guess what you want to do is "raw I/O" > > > > >1) Allocate buffer_head structure > > >2) Allocate memory for data (read or write). > > > (This is where I need some pointers as to which > > >funstions to use, and where to allocate memory > > from). > > >3) Minimal initialization of buffer_head structure, > > so > > >make_generic_request can carry out the operation. > > > (Need some pointers here, as there are too many > > >fields in buffer_head structure). > > >4) Call generic_make_request(). > > >5) Upon completion of command, free memory. > > > > Not sure if you should work with buffer heads to do > > raw-IO. If you are talking of 2.4 kernel, kiobuf > > interfaces should be used. > > > > You may want to read Chapter 13 of the ldd book by > > Rubini for information. Its online in case you > > didn't know! > > > > Hope this helps. > > > > Thanks, > > Vinod > > > > >Steps 2 and 3 are where I am a bit lost at this > > point. > > > Can someone please point me to examples in the > > linux > > >kernel source where this is done, or examples of > > >applications that might do this. > > > > > >Thank you, > > >Ahmed. > > > > > > > > > > > > > > >_______________________________ > > >Do you Yahoo!? > > >Declare Yourself - Register online to vote today! > > >http://vote.yahoo.com > > > > > >-- > > >Kernelnewbies: Help each other learn about the > > Linux kernel. > > >Archive: > > http://mail.nl.linux.org/kernelnewbies/ > > >FAQ: http://kernelnewbies.org/faq/ > > > > > > > > > > _______________________________ > Do you Yahoo!? > Declare Yourself - Register online to vote today! > http://vote.yahoo.com > > -- > Kernelnewbies: Help each other learn about the Linux kernel. > Archive: http://mail.nl.linux.org/kernelnewbies/ > FAQ: http://kernelnewbies.org/faq/ > > -- Kernelnewbies: Help each other learn about the Linux kernel. Archive: http://mail.nl.linux.org/kernelnewbies/ FAQ: http://kernelnewbies.org/faq/