I'm trying to mount an ISO file in a C++ program in linux
I'm aware of the linux command to achieve this, i.e mount -o loop ~/Test.iso /mnt/myISO
But the mount(2) man page states the following prototype for mounting :
int mount(const char *source, const char *target,
const char *filesystemtype, unsigned long mountflags,
const void *data);
How do I specify the loop option here ?
--
Also, is it good (/acceptable) practice in general, in linux programming to use system shell calls from C++ to achieve tasks such as these ?
Here is a code, that also creates loop device for you. Be aware not to use such code in production, as there is no single check on return values, exceptions etc :).
based on:
http://man7.org/linux/man-pages/man4/loop.4.html
https://linux.die.net/man/2/mount
small example
upd: after unmount you need free loop: