Avoid shelling out to 'mkdir -p' by inlining the function.

Signed-off-by: David Scott <dave.scott@eu.citrix.com>
Create sparse files using open(), lseek() and write() instead of "dd"

Signed-off-by: David Scott <dave.scott@eu.citrix.com>
Invoke losetup commands using low-level Unix interface.

Signed-off-by: David Scott <dave.scott@eu.citrix.com>