LinuxQuestions.org
Review your favorite Linux distribution.
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 09-03-2005, 03:27 AM   #1
vijirin
LQ Newbie
 
Registered: Sep 2005
Posts: 20

Rep: Reputation: 0
Mount program


hi
i want to mount a hard disk programmaticallly, i wrote the code,it works well in linux 2.4 kernel, but when i run the same code in 2.6 it is not mounting . the code is given below


#include <stdio.h>
#include <sys/mount.h>

int main()
{
int mounting;
mounting = mount("/dev/hda1", "/mnt","vfat", MS_MGC_VAL," ");
printf("%d", mounting);
return 0;
}

is there anything i have to change in the code... plz help
the value printed is -1....
viji
 
Old 09-03-2005, 04:46 AM   #2
mschutte
Member
 
Registered: Jan 2005
Location: Innsbruck, Austria
Distribution: Debian GNU/Linux Lenny
Posts: 68

Rep: Reputation: 15
Please tell us the error number:
Code:
#include <stdio.h>
#include <sys/mount.h>
#include <errno.h>
#include <string.h>

int main()
{
int mounting;
mounting = mount("/dev/hda1", "/mnt","vfat", MS_MGC_VAL," ");
printf("%d", mounting);
if (mounting != 0)
  printf("Error: %d (%s)\n", errno, strerror(errno));
return 0;
}
 
Old 09-03-2005, 07:17 AM   #3
exvor
Senior Member
 
Registered: Jul 2004
Location: Phoenix, Arizona
Distribution: Gentoo, LFS, Debian,Ubuntu
Posts: 1,537

Rep: Reputation: 87
Never mind
 
Old 09-04-2005, 11:13 PM   #4
vijirin
LQ Newbie
 
Registered: Sep 2005
Posts: 20

Original Poster
Rep: Reputation: 0
hi
it gives the following error
"Error:22 (Invalid Argument)
 
Old 09-06-2005, 09:11 AM   #5
vijirin
LQ Newbie
 
Registered: Sep 2005
Posts: 20

Original Poster
Rep: Reputation: 0
helo
why no reply, u asked the error no
plz help
 
Old 09-06-2005, 02:45 PM   #6
r0b0
Member
 
Registered: Aug 2004
Location: Europe
Posts: 608

Rep: Reputation: 50
Can you mount the partition from shell using the same parameters?, e.g.:

# mount /dev/hda1 /mnt -t vfat
 
Old 09-06-2005, 11:02 PM   #7
vijirin
LQ Newbie
 
Registered: Sep 2005
Posts: 20

Original Poster
Rep: Reputation: 0
yes i can mount at the terminal but using program it is not working...
 
Old 09-07-2005, 12:40 AM   #8
kjordan
Member
 
Registered: Jul 2004
Distribution: LFS, I felt the itch and scratched it
Posts: 227

Rep: Reputation: 31
Use 0 or NULL instead of " " for the last argument if you don't want to pass any data parameters to the filesystem.
 
  


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
mount: RPC: Program not registered ritesh_aladdin Linux - Networking 7 10-01-2005 10:14 AM
mount: RPC: Program not registered Harry Seldon Linux - Networking 3 09-05-2005 03:05 PM
Program to mount .cue/.bin files? hydro Linux - Software 13 05-15-2005 06:52 PM
Mount RPC : Program not registered phonecian Linux - Networking 2 08-29-2003 05:51 AM
mount: RPC: Program not registered madenan Linux - Software 2 08-16-2003 02:39 PM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 04:01 PM.

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
Open Source Consulting | Domain Registration