lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20090922162658.GB7973@bit.office.eurotux.com>
Date:	Tue, 22 Sep 2009 17:26:58 +0100
From:	Luciano Rocha <luciano@...otux.com>
To:	Brian McGrew <brian@...ionpro.com>
Cc:	linux-kernel@...r.kernel.org
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@...otux.com>
Eurotux Informática, S.A. <http://www.eurotux.com/>

Content of type "application/pgp-signature" skipped

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ