Get disk block device descriptor bdget_disk and Partition Block device descriptor bdev

Source: Internet
Author: User

First read the code and comments:

/**
* Bdget_disk-Do bdget () by gendisk and Partition Number
* @ Disk: gendisk of interest
* @ Partno: Partition Number
*
* Find partition @ partno from @ disk, do bdget () on it.
*
* Context:
* Don't care.
*
* Returns:
* Resulting block_device on success, null on failure.
*/

Struct block_device * bdget_disk (struct gendisk * disk, int partno)
{
Struct hd_struct * part;
Struct block_device * bdev = NULL;

Part = disk_get_part (disk, partno );
If (Part)
Bdev = bdget (part_devt (part ));
Disk_put_part (part );

Return bdev;
}

The bdget_disk function provides the generic disk descriptor pointer and Partition Number, and returns the block device descriptor pointer corresponding to the partition.

If the input Partition Number is 0 during the call, the system obtains the entire disk block device.

To obtain the block device descriptor of a partition, you must use the bdev file system. Inode is searched or allocated in the bdev File System Based on the partition number, and the block device descriptor is associated with inode. The function call relationship is as follows:

Sd_probe ()

| ___ Add_disk ()

|__ Register_disk ()

|__ Bdget_dev ()

|__ Bdget ()

 

 

Bdev file system Introduction Reference:

Http://blog.csdn.net/a954423389/article/details/6870967

 

 

 

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.