Messages in this thread | | | Date | Tue, 22 Sep 2009 17:26:58 +0100 | From | Luciano Rocha <> | Subject | Re: (un)mount ramfs from C code |
| |
On Tue, Sep 22, 2009 at 09:04:15AM -0700, Brian McGrew wrote: > Good morning all! > > So I'm using a ramfs for temporary files, thank you whoever designed that, > it works great! > > I can mkdir, mount, chmoud, readand write and then umount the thing from the > command line just fine. > > What I need now is some method from within my C/C++ code to determine if the > ramfs is mounted, if not, then mount it so I can use it and unmount it when > I'm done, without making a system call.
You mean without using system(3), right? System call is how your program interacts with the outside world.
The relevant system calls are: - mount(2): mount("none", "/mnt", "ramfs", 0, NULL); - umount(2): umount("/mnt");
The function(section) is the standard Unix way of specifying the manual section of the function. Use it like this: $ man 2 mount
About checking whether it is already mounted, you could parse the file /proc/mounts, or check the result of statfs(2).
Regards, Luciano Rocha
-- Luciano Rocha <luciano@eurotux.com> Eurotux Informática, S.A. <http://www.eurotux.com/> [unhandled content-type:application/pgp-signature] | |