On Thu, Dec 31, 2015 at 10:20:17AM +0000, Ahtisham wani wrote: > Respected sir, > I have been researching on how btrfs works and manages files for a long > time. What I want to achieve here is to trace a path of a file starting > from superblock, then to root and so on. The problem is I dont know how to > do it. I have been using dd and hexdump but I dont know what to look for > and where to look for. I have been able to see some fragments of > superblock at 64K but I dont know how to use it to trace the tree of tree > roots node or its object_id. Any help is appreciated. Thanks
Start here: https://btrfs.wiki.kernel.org/index.php/Data_Structures This will give you the basic high-level data structures. You can explore those data structures fairly easily using btrfs-debug-tree. After that, you'll mostly have to start reading the code a little. fs/btrfs/ctree.h in the kernel sources is the place to get all of the data structures you'll need. Those will tell you the layout of the data items. To get from the superblock to the diagram on the data structures page, the first thing you'll need to do is read the list of system chunks at the end of the superblock. Those chunks contain the chunk tree, which contains the mapping from physical device addresses to internal (virtual) addresses. Everything else is done in terms of those virtual addresses. Once you have the chunk tree, you can start using the other addresses in the superblock to find the tree of tree roots, and then follow that into the other trees (at which point, you can start using the data structures page). Hugo. -- Hugo Mills | Comic Sans goes into a bar, and the barman says, "We hugo@... carfax.org.uk | don't serve your type here." http://carfax.org.uk/ | PGP: E2AB1DE4 |
signature.asc
Description: Digital signature