Some functions to perform losetup behaviour in c code