On 11/16/06, Rajat Jain <rajat.noida.india@xxxxxxxxx> wrote:
> Hello Friends, > > I want to find first sector of the hard disk partation using C. Means detail > information of that hard disk ie what is start sector and end sector of the > partation. So that after finding that sector I can read/write on that > sector. > > Please help me. > Read and parse the MBR ... !
Yes, this can be done from user-space, but if want to get this information in kernel then you can get the start and end sector of any partition through : Get struct block_device of you desired drive (like /dev/hda). Can use function lookup_bdev() for this. From block_device (which you got from lookup_bdev function) you can get each partition information like: ............ struct block_device *bdev = lookup_bdev("/dev/hda"); sector_t start_sector = bdev->bd_disk->part[<partition_minor_like_1_for_hda1>]->start_sect; sector_t num_sectors = bdev->bd_disk->part[<partition_minor_like_1_for_hda1>]->nr_sects; ............ And now end_sector = start_sector + num_sector .... -- Fawad Lateef -- Kernelnewbies: Help each other learn about the Linux kernel. Archive: http://mail.nl.linux.org/kernelnewbies/ FAQ: http://kernelnewbies.org/faq/