FSCatalogSearch returns invalid file references on APFS volumes

Originator:tempelmann
Number:rdar://33454922 Date Originated:July 21 2017
Status:Dupe of 33428180 Resolved:
Product:macOS Product Version:10.12.6 and 10.13b3
Classification:Bug Reproducible:Always
 
APFS breaks code that works just fine with HFS+ volumes, even on latest 10.12.6 and 10.13b3:

When using FSCatalogSearch to search an APFS volume, the returned FSRefs are not valid, even though the returned Names are valid. Using the same function on any other kind of volume (AFP, HFS, HFS+) does work.

Please consider this a regression and fix this in 10.13 and possibly in an upcoming 10.12.x version as well. It breaks any existing app using this FSCatalogSearch, and there's no warning. Just because it's deprecated doesn't mean it should just break like this.

Steps to Reproduce:
Attached is a test project.
It performs a catalog search, looking for partial file names.
If you run it, providing the path to a APFS volume, it'll print "(null)" for all matches because the FSRefs cannot be resolved.
Running the same on a AFP or HFS volume works, printing the found item paths as expected.

Here's a sample output when searching a HFS volume (here: root vol):

$ ./catsearch .png /
Search for files & folders in volume: /
Search for names of files & folders containing substring: .png
Got 8 items:
/Library/DropboxHelperTools/Dropbox_u501/DropboxBundle.bundle/Contents/Resources/._disabled.png
/Library/DropboxHelperTools/Dropbox_u501/DropboxBundle.bundle/Contents/Resources/._pressed.png
/Library/DropboxHelperTools/Dropbox_u501/DropboxBundle.bundle/Contents/Resources/._sidebar_blue.png
/Library/DropboxHelperTools/Dropbox_u501/DropboxBundle.bundle/Contents/Resources/._toolbar_large.png
/Library/DropboxHelperTools/Dropbox_u501/DropboxBundle.bundle/Contents/Resources/._unpressed.png
/Library/DropboxHelperTools/Dropbox_u501/DropboxBundle.bundle/Contents/Resources/disabled.png
/Library/DropboxHelperTools/Dropbox_u501/DropboxBundle.bundle/Contents/Resources/pressed.png
/Library/Desktop Pictures/Solid Colors/.thumbnails/Solid Gray Dark.png

And output from searching a APFS vol:

$ ./catsearch .png /Volumes/APFS1
Search for files & folders in volume: /Volumes/APFS1
Search for names of files & folders containing substring: .png
Got 8 items:
(null)
(null)
(null)
(null)
(null)
(null)
(null)
(null)

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!