LinuxQuestions.org
LinuxAnswers - the LQ Linux tutorial section.
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
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.

Notices



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

Rep: Reputation: 66
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
Code:
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?
Code:
#import <libmount>

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

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

Rep: Reputation: 59
this looks like your answer: http://linux.about.com/od/commands/l/blcmdl2_mount.htm. 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
heby
LQ Newbie
 
Registered: Sep 2004
Location: Ottawa, ON, Canada
Distribution: debian
Posts: 12

Rep: Reputation: 1
Mount(2)

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

SYNOPSIS
#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.
 
  


Reply


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 11:19 AM.

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