-
Notifications
You must be signed in to change notification settings - Fork 13
Support for reading snapshot metadata (WIP) #34
base: master
Are you sure you want to change the base?
Conversation
So, have you figured out how to locate the snapshots? Is there an anchor you can find, with its own btree? Or are snapshots just mixed-in with the main tree, and with different tags or versions? |
They're present in the same omap tree alongside all the other versions, so you get, for instance, a (oid=1026,xid=67) mapped to one block and a (oid=1026,xid=81) mapped to another block. So essentially, all my existing logic for locating even the most recent copy of objects is wrong if there are any snapshots present, so I'm glad I tried testing this. I had a TODO on the code where I'm mapping oid to block number about the version number being important, and it's more important than I thought. I just don't know...how to do the lookup efficiently without just reading it all into a giant hashmap up-front. (The naïve implementation is: read all the rows, and take the highest xid which is not higher than the xid of the snapshot. How many entries can be in an omap table anyway? :)) |
Have you had a look at the apfs-fuse code? Maybe you can learn some tricks from it |
Solving part of the confusion - omap_key doesn't actually contain oid - the oid is in the header already parsed. Actually, in my own model, the omap keys aren't mixed in with the file table keys, but I've been unable to figure out whether they should or should not be. What I do know is that history keys have the exact opposite structure of omap keys, meaning that under the structure currently in this ksy file, both of those would be kind=0x0. After removing the
So all the oid values are grouped together and the xids are in numerical order, meaning you can still binary search if that helps performance. |
The snapshot metadata table is a bit of a weird one though.
What's weird is this:
I would have thought that If I change the calculation to this:
Now I get -1, even though the top 4 bits wouldn't be set. :) I know JavaScript is bad at arithmetic, but I somehow thought that kaitai IDE would have to have worked around that in order to do anything correctly at all. |
* Fixing contents of `omap_val` - it doesn't contain an oid at all (but the way the values were packed hid the problem really well!) * Maths for computing `obj_id` for a file key have to use `|`, not `+`, otherwise negative values break, and negative values are used in the snapshot info block. * Naming a value which is the reference to the volume superblock for the snapshot. * Marking some other unknown stuff which is clearly obj references as `ref_obj`.
More stuff that is semi-known:
|
I am now working on updating my code to use the latest ksy files. Is this pull request still valid, or have later changed superseded this? |
I did some refactoring so that these PRs got conflicts and I never tested them, but they might still be valid. |
Many unknown values, still investigating.