Skip to content

added APFS pattern #400

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 4 commits into
base: master
Choose a base branch
from

Conversation

HrantTadevosyan
Copy link
Contributor

@HrantTadevosyan HrantTadevosyan commented May 17, 2025

  • Tested on 1G+ samples

For Reviewers

This should parse the container, volume superblocks. It should be able to identify the root, snapshot trees, the user can iterate over the B+Trees with helper functions. Individual blocks can be verified as well with these helper functions. Additionally, there are space manager, reaper and bitmap parsed structures. Lastly, it will try to find the root directory of the first volume in the container.

Unfortunately, I can not add <1M sample file for unit tests, since I don't know how'd I do it. The tools that I use allow only 1G+ disks to be created.

References

@paxcut
Copy link
Collaborator

paxcut commented Jun 17, 2025

Can you talk a bit about how you create the disk files that explains why they need to be so big? From what I have read, it may be possible to extract the file system that are stored in dmg installations made using apfs which could be as small as kilobytes. I have a couple virtual machines running catalina and older versions that may be used to create small disks and fill them with files. my computer is really old and can have trouble when I use those vms so I avoid them if possible.

Copy link
Collaborator

@paxcut paxcut left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I noticed a possible runtime error in the pattern. I posted details and a possible resolution.


fn omap_node_lookup(paddr_t off, u64 block_size, oid_t oid, xid_t xid) {
while (true) {
btree_node_phys_t<block_size, 0> node @ off;
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I see you are passing a value of 0 to several instances of btree_node_phys_t for the second template argument. Later on you use this argument to set the last template argument of kvgen_t struct called vol_incomp which then is used to test this conditional

  if (vol_incomp.APFS_INCOMPAT_CASE_INSENSITIVE ||
                        vol_incomp.APFS_INCOMPAT_NORMALIZATION_INSENSITIVE) {

When you pass 0 as template argument the type of the variable will become u32 or something like that instead of apfs_incompatible_features_t which it needs to be or else the if statement will return a runtime error. You need to make sure the conditional is never evaluated when you pass 0 as a template argument or you could define a variable

apfs_incompatible_features_t zero = 0;

and then use btree_node_phys_t<block_size, zero> node @ off; instead of using 0 and also change all the other cases where 0 is being used. This way you don't need to worry about the conditional.

@HrantTadevosyan
Copy link
Contributor Author

  • I use VirtualBuddy, which does not allow me to create <1G disks. But... I see this issue in their repo:
    Allow disk size to be smaller than 1GB netbox-community/netbox#14692
    Most likely I have to update my old VirtualBuddy.... in future. c;

  • Oh that's a very good catch. I have never seen that error on my sample disks. But good point. I'll fix it once I come back to this. I'll tag you, once I push my changes (for you to double check).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants