LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Programming (https://www.linuxquestions.org/questions/programming-9/)
-   -   Mount program (https://www.linuxquestions.org/questions/programming-9/mount-program-359752/)

vijirin 09-03-2005 03:27 AM

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

mschutte 09-03-2005 04:46 AM

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;
}


exvor 09-03-2005 07:17 AM

Never mind :p

vijirin 09-04-2005 11:13 PM

hi
it gives the following error
"Error:22 (Invalid Argument)

vijirin 09-06-2005 09:11 AM

helo
why no reply, u asked the error no
plz help

r0b0 09-06-2005 02:45 PM

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

# mount /dev/hda1 /mnt -t vfat

vijirin 09-06-2005 11:02 PM

yes i can mount at the terminal but using program it is not working...

kjordan 09-07-2005 12:40 AM

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


All times are GMT -5. The time now is 11:59 AM.