Help answer threads with 0 replies.
Go Back > Forums > Non-*NIX Forums > Programming
User Name
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.


  Search this Thread
Old 05-14-2008, 06:05 PM   #1
Registered: Oct 2007
Distribution: Arch x86_64
Posts: 606

Rep: Reputation: 67
Use kernel programs like mount from c++

Is there a better way to execute commands from c++ than system("CMD")?

For example, rather than calling
system("mount -t cifs -ouid="+user+" "+share+" "+mountpoint);
Can I just call whatever functions are used by /bin/mount and pass my options as paramters?
#import <libmount>

mount("cifs", user, share, mountpoint);

Last edited by Meson; 05-14-2008 at 06:06 PM.
Old 05-14-2008, 06:51 PM   #2
Senior Member
Registered: Jan 2005
Location: Canada
Distribution: ubuntu
Posts: 2,539

Rep: Reputation: 59
this looks like your answer: if you have the source code for mount on your machine, you could always take a look at that.
Old 05-15-2008, 09:10 AM   #3
LQ Newbie
Registered: Sep 2004
Location: Ottawa, ON, Canada
Distribution: debian
Posts: 12

Rep: Reputation: 1

from the manpage of MOUNT(2) (in case you're not familiar with that, you can look at it by typing "man 2 mount"):

#include <sys/mount.h>

int mount(const char *source, const char *target,
const char *filesystemtype, unsigned long mountflags,
const void *data);

i think this is what you're looking for.


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
kernel not compatible,,,need to work on programs of kernel-2-2.4 ace.adi Linux - Newbie 3 03-01-2007 08:04 PM
compiling kernel problem --- Kernel panic: unable to mount root fs ........ anthonymts123 Linux - General 5 07-31-2006 03:29 AM
programs still think i have old kernel wr3ck3d Linux - General 1 03-01-2003 01:14 PM

All times are GMT -5. The time now is 10:30 AM.

Main Menu
Write for LQ is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration