lkml.org 
[lkml]   [1999]   [Apr]   [28]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
SubjectRe: Physical Sectors for a File
Date
From
Brian Gerst writes:
> Yash Shitoot wrote:
> >
> > For a driver I am writing, I need to find the physical sectors
> > for a given file. I know the inode number for that file. Any help/
> > pointers would be appreciated.
>
> Try looking at the source to lilo, that also needs to make a block map
> of where the kernel image sits on the disk.

I haven't looked at how lilo does it from userland but if he's
writing a kernel driver I'd have thought the easiest way would be
int bmap(struct inode *inode, int block);
which takes an inode and the relative block number within the file
and returns the absolute block number of the block on the underlying
block device. It only works for "ordinary" filesystems that support
the VFS bmap method but that certainly covers things like ext2.

If you can assume that the block number of the block device is the
"physical" block you're after then you are home free. Otherwise (if
you're worried about bad block remapping, md, nbd or any other weird
block device) then you've got more to do.

--Malcolm

--
Malcolm Beattie <mbeattie@sable.ox.ac.uk>
Unix Systems Programmer
Oxford University Computing Services

-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.rutgers.edu
Please read the FAQ at http://www.tux.org/lkml/

\
 
 \ /
  Last update: 2005-03-22 13:51    [W:0.057 / U:0.132 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site