'Mac analyzing disk for free sectors

I need to read hard disk sectors. Specifically, I am trying to write a function as follow:

findFreeBlocks - analyze disk structures and find two uninterrupted free blocks of a given length.

int findFreeBlocks(char * drivePath, DWORD sectorsNeeded, u_int64_t *freeSector1, u_int64_t *freeSector2)

Parameters: [IN] drivePath – path to a logical drive [IN] sectorsNeeded – length of needed free block in sectors (sector = 512 bytes) [OUT] freeSector1 – the first sector of the first found free block [OUT] freeSector2 – the first sector of the second found free block

Return: 0 – if success, error code – if error

Can someone point me APIs that will help me do this? I have experience with Objective-c but C/C++ can work too (and I am guessing it will be that since this is very low level). Thanks



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source