This is a continuation of my question about reading the superblock.
Let's say I want to target the HFS+ file system in Mac OS X. How could I read sector 2 of the boot disk? As far as I know Unix only provides system calls to read from files, which are never stored at that location.
Does this require either 1) the program to run kernel mode, or 2) the program to be written in Assembly? I would prefer to avoid either of these restrictions, particularly the latter.
In Linux, you can read from the special device file /dev/sda
, assuming the hard drive you want to read is the first one. You need to be root to read this file. To read sector 2, you just seek to offset 2*SECTOR_SIZE
and read in SECTOR_SIZE
bytes.
I don't know if this device file is available on OS X. Check for interestingly named files under /dev
such as /dev/sda
or /dev/hda
.