i am trying to write a linux program that uses the c++ mount function (code below), however, the mount operation requires permmissions, and running the program throws the errno 'Operation not permitted' (printed using perror) tried some SO solutions but non was helpful, the alternative is to use the system("sudo mount..") but i prefer the c++ function. is ther a way to use this function with permmissions?
IDE: Clion 2020.2.4
relevant code below
int returnValue = mount(sourcePath,targetPath,"", MS_SHARED, ""); //mounting the device
if (returnValue==0){
//mount completed
//somecode
}else{
//mount failed
std::cout<<"mount failed\n";
perror("");
}
output
mount failed
Operation not permitted