sgan81 / apfs-fuse

FUSE driver for APFS (Apple File System)
GNU General Public License v2.0
1.78k stars 164 forks source link

Cannot access certain files (regression?) #129

Closed Andrew-Coppin closed 4 years ago

Andrew-Coppin commented 4 years ago

I recently stumbled across an odd problem. I have a disk image with 2 files I cannot access. For example:

localhost:~ # ls -l /mnt/root/usr/share/zsh/5.3/functions/                                                                                                                                                                                                                                                              [952/952]
ls: cannot access '/mnt/root/usr/share/zsh/5.3/functions/VCS_INFO_get_data_darcs': No such file or directory
total 0
-rw-r--r-- 1 root root    246 Aug 18  2018 VCS_INFO_adjust
-rw-r--r-- 1 root root    827 Aug 18  2018 VCS_INFO_bydir_detect
-rw-r--r-- 1 root root    294 Aug 18  2018 VCS_INFO_check_com
-rw-r--r-- 1 root root    326 Aug 18  2018 VCS_INFO_detect_bzr
-rw-r--r-- 1 root root    335 Aug 18  2018 VCS_INFO_detect_cdv
-rw-r--r-- 1 root root    325 Aug 18  2018 VCS_INFO_detect_cvs
-rw-r--r-- 1 root root    333 Aug 18  2018 VCS_INFO_detect_darcs
-rw-r--r-- 1 root root    341 Aug 18  2018 VCS_INFO_detect_fossil
-rw-r--r-- 1 root root    657 Aug 18  2018 VCS_INFO_detect_git
-rw-r--r-- 1 root root    692 Aug 18  2018 VCS_INFO_detect_hg
-rw-r--r-- 1 root root    336 Aug 18  2018 VCS_INFO_detect_mtn
-rw-r--r-- 1 root root   2358 Aug 18  2018 VCS_INFO_detect_p4
-rw-r--r-- 1 root root   1468 Aug 18  2018 VCS_INFO_detect_svk
-rw-r--r-- 1 root root    354 Aug 18  2018 VCS_INFO_detect_svn
-rw-r--r-- 1 root root    345 Aug 18  2018 VCS_INFO_detect_tla
-rw-r--r-- 1 root root   3703 Aug 18  2018 VCS_INFO_formats
-rw-r--r-- 1 root root    233 Aug 18  2018 VCS_INFO_get_cmd
-rw-r--r-- 1 root root   3492 Aug 18  2018 VCS_INFO_get_data_bzr
-rw-r--r-- 1 root root    305 Aug 18  2018 VCS_INFO_get_data_cdv
-rw-r--r-- 1 root root    512 Aug 18  2018 VCS_INFO_get_data_cvs
-????????? ? ?    ?         ?            ? VCS_INFO_get_data_darcs
-rw-r--r-- 1 root root    654 Aug 18  2018 VCS_INFO_get_data_fossil
-rw-r--r-- 1 root root  11142 Aug 18  2018 VCS_INFO_get_data_git
-rw-r--r-- 1 root root   9020 Aug 18  2018 VCS_INFO_get_data_hg
-rw-r--r-- 1 root root    410 Aug 18  2018 VCS_INFO_get_data_mtn
-rw-r--r-- 1 root root   1108 Aug 18  2018 VCS_INFO_get_data_p4
-rw-r--r-- 1 root root    728 Aug 18  2018 VCS_INFO_get_data_svk
-rw-r--r-- 1 root root   2113 Aug 18  2018 VCS_INFO_get_data_svn
-rw-r--r-- 1 root root    479 Aug 18  2018 VCS_INFO_get_data_tla
-rw-r--r-- 1 root root    373 Aug 18  2018 VCS_INFO_hexdump
-rw-r--r-- 1 root root   1678 Aug 18  2018 VCS_INFO_hook

However, if I revert to a (much) older commit, now I can access these files perfectly. So this seems like some kind of regression.

Using commit 309ecb030f38edac4c10fa741a004c5eb7a23e15:

localhost:~ # mount.apfs -d 7 /dev/sda2 /mnt
Device /dev/sda2 opened. Size is 61199056896
Found more recent xid 42530 than superblock 0 contained (42510).
apfs_lookup: ino=1 name=root => Lookup hashed key: key=10376293541461622785 hash=3060917253 name='root'
72 6F 6F 74 root
Lookup: id = 2
OK
    apfs_stat_internal => OK
apfs_lookup: ino=2 name=usr => Lookup hashed key: key=9000000000000002 hash=18FE3404 name='usr'
75 73 72 usr
Lookup: id = 3000AACF3
OK
    apfs_stat_internal => OK
apfs_lookup: ino=3000AACF3 name=share => Lookup hashed key: key=90000003000AACF3 hash=FCC0DC06 name='share'
73 68 61 72 65 share
Lookup: id = 3000ACDB5
OK
    apfs_stat_internal => OK
apfs_lookup: ino=3000ACDB5 name=zsh => Lookup hashed key: key=90000003000ACDB5 hash=D8D4D804 name='zsh'
7A 73 68 zsh
Lookup: id = 3000B2E25
OK
    apfs_stat_internal => OK
apfs_lookup: ino=3000B2E25 name=5.3 => Lookup hashed key: key=90000003000B2E25 hash=BA4E2004 name='5.3'
35 2E 33 5.3
Lookup: id = 3000B2E26
OK
    apfs_stat_internal => OK
apfs_lookup: ino=3000B2E26 name=functions => Lookup hashed key: key=90000003000B2E26 hash=BB6CB40A name='functions'
66 75 6E 63 74 69 6F 6E 73 functions
Lookup: id = 3000B2E27
OK
    apfs_stat_internal => OK
apfs_lookup: ino=3000B2E27 name=VCS_INFO_get_data_darcs => Lookup hashed key: key=90000003000B2E27 hash=D7CCF018 name='VCS_INFO_get_data_darcs'
56 43 53 5F 49 4E 46 4F 5F 67 65 74 5F 64 61 74 61 5F 64 61 72 63 73 VCS_INFO_get_data_darcs
Lookup failed!
FAIL

Using commit 0ca2e1f5cdfe32613b662713dd9b87ddb82a96e7:

localhost:~ # mount.apfs -d 7 /dev/sda2 /mnt
Device /dev/sda2 opened. Size is 61199056896
Found more recent xid 42530 than superblock 0 contained (42510).
apfs_lookup: ino=1 name=root => OK
    apfs_stat_internal => OK
apfs_lookup: ino=2 name=usr => OK
    apfs_stat_internal => OK
apfs_lookup: ino=12885601523 name=share => OK
    apfs_stat_internal => OK
apfs_lookup: ino=12885609909 name=zsh => OK
    apfs_stat_internal => OK
apfs_lookup: ino=12885634597 name=5.3 => OK
    apfs_stat_internal => OK
apfs_lookup: ino=12885634598 name=functions => OK
    apfs_stat_internal => OK
apfs_lookup: ino=12885634599 name=VCS_INFO_get_data_darcs => OK
GetAttribute: type=1
Attr is link: size = 292, size on disk = 4096
Attribute is link:
  obj id  : 12885634641
  size    : 292
  on disk : 4096
  unk@18  : 0
  unk@20  : 292
  unk@28  : 0
No inode found for this attribute.
ReadFile(inode=12885634641,offs=0,size=4096)
Key: inode=9223372049740410449, offset=0
Value: size=4096, block=4617105, xts_iv=0
dumping start of attribute content
0000: 66 70 6D 63 07 00 00 00 37 01 00 00 00 00 00 00 - fpmc....7.......
0010: EE 23 23 20 76 69 6D 3A 66 74 3D 7A 73 68 0A 00 - .## vim:ft=zsh..
0020: 0E E0 28 64 61 72 63 73 20 73 75 70 70 6F 72 74 - ..(darcs support
0030: 20 62 79 3A 20 46 72 61 6E 6B 20 54 65 72 62 65 -  by: Frank Terbe
    apfs_stat_internal => OK

I did a Git bisect, and discovered the following:

0ca2e1f5cdfe32613b662713dd9b87ddb82a96e7: Works. a56d0b7c9624431ea72a18605f40079f8b5d16c8: Works. 713430b18deb6025e4cf5020ca3e5c2262df7135: Doesn't compile. cc70cb9a8488cb6e43048b992dbf82b905231277: Doesn't compile. 9de1a6c77f1fdc9702503d9e2d1a1bf400c6483f: Doesn't compile. 4a5bb16df28f441d046e4b569d45248377f8bd0f: Cannot access the files. 0eb5f2386b3d67e482e2119c67e0d0b8d2e6824b: Cannot access the files.

I found the -d 7 option makes the program print some debugging info, but... I don't really know what I'm doing. If there's any further debugging info I can supply, let me know.

sgan81 commented 4 years ago

Oh dear, 2 files with the same filename CRC ... thanks, I have enough information, will look into it.

sgan81 commented 4 years ago

Thank you very much for reporting this issue. It should be fixed now, please test it and let me know if it works.

Andrew-Coppin commented 4 years ago

I just tried ee71aa5; it does indeed appear to fix the issue. Thank you.