How to transfer the data returned by FIBMAP to LBA sectors on disk?

I need to determine the range (sectors) of the sector occupied by a file on disk (for Linux). Suppose this is a simple disk (without RAID) with an MBR or GPT partition table.

I found out that I can get the file position in the file system using FIBMAP ioctl. How to convert the data returned by FIBMAP to LBA sectors of a disk? thank you

+4
source share
1 answer

I don't have an exact answer, but if you look at the hdparm source code, you can figure it out. If you use hdparm --fibmap /dir1/dir2/foo , it will output the pieces of the file to the file offset lines, start LBA, stop LBA and sector length. Hope this helps.

0
source

All Articles