Hello, I am using e2fsprogs and found it very nice. I want to know datablocks for a given a given file. I was going through the document and did lots of google search, but I am not sure what is the best way to get this information. Which "e2fsprogs" function can give all the datablock IDs. There is one function i.e. ext2fs_block_iterate, but I am not sure how it works. It wasn't clear from the document. Can someone please help without getting angry on this simple question ? Mir -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://listman.redhat.com/archives/ext3-users/attachments/20100318/ddf04f28/attachment.htm>
On 2010-03-18, at 16:48, MirJafar Ali wrote:> I am using e2fsprogs and found it very nice. I want to know > datablocks for a given a given file. > I was going through the document and did lots of google search, but > I am not sure what is the best way to get this information. Which > "e2fsprogs" function can give all the datablock IDs. There is one > function i.e. ext2fs_block_iterate, but I am not sure how it works. > It wasn't clear from the > document.If you use "dumpe2fs -c -R 'stat /path/to/file' /dev/XXX", where /path/ to/file is the filesystem relative pathname, that will dump all of the blocks. On newer kernels you can also use "filefrag -v" to list the blocks, though the output format is less than ideal right now. Programatically, on a newer kernel you can use the fiemap() API to get the list of all blocks for any file, regardless of the filesystem type. Cheers, Andreas -- Andreas Dilger Sr. Staff Engineer, Lustre Group Sun Microsystems of Canada, Inc.
MirJafar Ali wrote:> Hello, > > I am using e2fsprogs and found it very nice. I want to know datablocks > for a given a given file. > I was going through the document and did lots of google search, but I am > not sure what is the > best way to get this information. Which "e2fsprogs" function can give > all the datablock IDs. There > is one function i.e. ext2fs_block_iterate, but I am not sure how it > works. It wasn't clear from the > document. > > Can someone please help without getting angry on this simple question ? > > Mir >>From the commandline, you can just use filefrag (-v)If you want to do it programatically, you can look at how filefrag uses the FIBMAP and/or FIEMAP ioctls. If you want to do it with the filesystem unmounted, you can look at how the debugfs "stat" command shows you the blocks. -Eric