LWN.net Logo

Creating BIO structure

Creating BIO structure

Posted Feb 17, 2005 4:48 UTC (Thu) by explorer (guest, #27894)
Parent article: Driver porting: the BIO structure

Hi,
I want to create my own bio structure to write the data to a block disk.

I have block device details in terms of dev_t, I have data in my driver allocated pages.

How I can achieve this?

* Use bio_alloc to get bio
* Using bio_add_page add my own buffer (got using page_alloc) to the bio structure
* Construct the block_device *bi_bdev structure { Actually I have dev_t type for my block device, how I can get corresponding block_device structure?), construct the gendisk structure
* submit_bio

Is there any way to get block_disk structure from dev_t type? get_bdisk returns an object of type block_disk, but its gendisk structure is empty.

Regards,
Explorer


(Log in to post comments)

Creating BIO structure

Posted Feb 22, 2005 17:28 UTC (Tue) by vabank (guest, #28037) [Link]

there are fs/block_dev.c entry point:
struct block_device *open_by_devnum(dev_t dev, unsigned mode)

Creating BIO structure

Posted Feb 23, 2005 7:14 UTC (Wed) by explorer (guest, #27894) [Link]

Hi vabank,

Thanks for your reply.

I have already tested that api open_by_devnum.
But it oops.

The problem is open_by_devnum(block_device *bd, int mode)
calls blkdev_get function which makes use of bd->bd_inode field to get the block device structure.

How I can get the inode field for a dev_t structure?

Sorry for the inconvenience.

Regards,
Explorer.

Copyright © 2013, Eklektix, Inc.
Comments and public postings are copyrighted by their creators.
Linux is a registered trademark of Linus Torvalds