searchfs on APFS does not return all hard link entries

Originator:tempelmann
Number:rdar://34137842 Date Originated:August 29 2017
Status:Open Resolved:
Product:macOS Product Version:10.13 beta 8 (17A358a)
Classification:Other Bug Reproducible:Always
 
Summary:
When using the searchfs() function on an APFS volume that contains hard links, only one of the hard link entries is returned - the others are missing from the results.

Steps to Reproduce:
See attached archive. It contains an Xcode project with my "searchfs" tool and two disk images, HFS+ and APFS formatted.

Unpack and mount both images. Note that both contain a folder "hard and soft linked items", each with 3 times 3 files in it, some of them hard linked with each other (if you do not see any files inside this folder, it probably means you're using 10.12.6 - then please switch to 10.13 - I guess that's another bug in 10.12.6 that it's not able to show this directory, but I guess no one will bother with that any more).

Now use my tool "searchfs" to find all files containing "hardlinked" in their name. If you do this on the HFS volume, you get all 9 items listed, as expected:

$ Build/Products/Debug/searchfs "hardlinked" /Volumes/HFS4_small/
/Volumes/HFS4_small/hard and soft linked items/hardlinked-1-acoelomate.txt-softlink
/Volumes/HFS4_small/hard and soft linked items/hardlinked-1-acoelomate.txt-v1
/Volumes/HFS4_small/hard and soft linked items/hardlinked-1-acoelomate.txt-v2
/Volumes/HFS4_small/hard and soft linked items/hardlinked-2-bioscopic.txt-softlink
/Volumes/HFS4_small/hard and soft linked items/hardlinked-2-bioscopic.txt-v1
/Volumes/HFS4_small/hard and soft linked items/hardlinked-2-bioscopic.txt-v2
/Volumes/HFS4_small/hard and soft linked items/hardlinked-3-frondous.txt-softlink
/Volumes/HFS4_small/hard and soft linked items/hardlinked-3-frondous.txt-v1
/Volumes/HFS4_small/hard and soft linked items/hardlinked-3-frondous.txt-v2

But on the APFS volume, the second set of hard link entries are missing:

$ Build/Products/Debug/searchfs "hardlinked" /Volumes/APFS4_small/
/Volumes/APFS4_small/hard and soft linked items/hardlinked-1-unnative.txt-v1
/Volumes/APFS4_small/hard and soft linked items/hardlinked-1-unnative.txt-softlink
/Volumes/APFS4_small/hard and soft linked items/hardlinked-2-subpyramidal.txt-v1
/Volumes/APFS4_small/hard and soft linked items/hardlinked-2-subpyramidal.txt-softlink
/Volumes/APFS4_small/hard and soft linked items/hardlinked-3-dissonance.txt-v1
/Volumes/APFS4_small/hard and soft linked items/hardlinked-3-dissonance.txt-softlink

My tool has also the option "-l" to add the ATTR_CMNEXT_LINKID parameter (and the option "-i" to show the inode numbers instead of the resolved paths), but that makes no difference - 3 entries remain missing from the results.

Expected Results:
I should get all 9 matching dir entries, like it always worked on HFS volumes.

Comments


Please note: Reports posted here will not necessarily be seen by Apple. All problems should be submitted at bugreport.apple.com before they are posted here. Please only post information for Radars that you have filed yourself, and please do not include Apple confidential information in your posts. Thank you!