On Thu, Apr 28, 2016 at 7:28 AM, Manoj Rao <linux@manojrajarao.com> wrote:
Hi All,
I'm looking for a way to get a filename associated with a given physical block (ideally what I'd like is a mapping of filename <=> all the allocated blocks for this file).
If you have not done already, this could be a good starting point. Look at FIBMAP IOCTL. Here is one usage of FIEMAP, demonstrated via hdparam. # hdparm --fibmap <your file name>
Is there a recommended way to do this already in kernel? if not, then where should I start looking to add changes?
Not sure about what would be the Recommended method. But this could be done in user-space vs doing it in kernel space. For example, consider cases like single file restore - there will be a requirement to figure out the logical - physical block allocation for a file which could be achieved through... Read superblock Read dentry - Home into the required inode (file) Read inode - to figure out the location of block. Note: This is not generic - and would require changes as layout is different for filesystems. Thanks Arshad