Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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.

like image 244
Ali asgar Avatar asked Jan 18 '26 08:01

Ali asgar


1 Answers

You want to enumerate /proc/mounts using getmntent_r

like image 77
MSalters Avatar answered Jan 19 '26 23:01

MSalters



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!