How to map physical sectors of a disk to files containing them on an HFS + volume on Mac OS X

I restored the hard drive using dd_rescue , which provides me with a list of all device sectors that it could not copy due to hardware errors.

I would like to take this list and write a tool to give me all the files containing these bad sectors so that I can delete them. I'm not sure which APIs I can use for this - in fact, I want to get a list of all the files on the disk and for each file, a list of the range of sectors that it occupies on the disk.

First of all, I assume that I will iterate over each directory entry on the disk and check if one of these damaged sectors overlaps the file. Maybe the best way.

+3
source share
3 answers

If you want to map the location of the file data to a physical block (sector), you can use the fcntl (2) call with F_LOG2PHYS. Not all file systems support this command, but HFS + does. Just use lseek to select the file offset, and you can return diskoffset from F_LOG2PHYS (it returns to struct log2phys in the l2p_devoffset field). See Fcntl.h for more details.

+2
source

API, HFS +, Apple XNU. hfsdebug, fs.

+1

, , , :

Mac OS X 10.6 fsck_hfs (8) (. -B). : , . -l -f.

BTW, hfsdebug PPC Rosetta , , Lion .

+1

Source: https://habr.com/ru/post/1716989/


All Articles