title: How does one map physical sectors of a disk to the files that contain them on an HFS+ volume on Mac OS X
body: <p>I've been recovering a hard disk using <a href="http://www.garloff.de/kurt/linux/ddrescue/" rel="nofollow noreferrer">dd_rescue</a>, which provides me a list of all of the device sectors it could not copy due to hardware errors.</p>
  
  <p>I'd like to take that list, and write a tool to give me all of the files that contain these bad sectors so I can delete them. I'm not sure what APIs I can use to do this--essentially i want to get a list of all files on disk and for each file, a list of the ranges of sectors it occupies on disk.</p>
  
  <p>My first guess is that I will iterate over each directory entry on the disk and check to see if the file overlaps one of these bad sectors. Maybe there's a better way.</p>