c++linuxlinux-kernelfilesystemsmount-point

How to check if filesystem is already mounted using C/C++


Hi I am writing an application which mounts cgroup as shown below

mount("cgroup", "/sys/fs/cgroup", "tmpfs",0,NULL);

I am able to do this but I want to add a check to know if this is already mounted, how do I do that using C/C++? Is there any API or system API to get mount information. I do not want to use system() call.


Solution

  • You want to enumerate /proc/mounts using getmntent_r