Dear all,
Currently I'm working on a C program (OS = ubuntu 9.0.4)in which a USB key will
be mounted and umounted for several times. I read the man page
of the mount system call.
I use the following test code
Code:
#include <sys/mount.h>
int main(int argc, char *argv[])
{
if (mount("/dev/sdg1", "/media/flashCorsaire/", "fuseblk",
MS_MGC_VAL,"rw,nosuid,nodev,allow_other,blksize=4096") != 0)
{
fprintf(stderr, "Error: The program doesn't seem to be able ");
fprintf(stderr, "to control the USB device\n");
fprintf(stderr, "%s\n", strerror(errno));
return 1;
}
return 0;
}
Whether the USB key has already been mounted or not, when I run this program as root I get
the following error message:
Code:
Error: The program doesn't seem to be able to control the USB device
Invalid argument
I don't really understand what is invalid argument in my code, because here is the line that I put
in /etc/fstab:
Code:
/dev/sdg1 /media/flashCorsaire auto defaults 0 0
And also here is what I see in /etc/mtab when I connect the USB to my PC
Code:
/dev/sdg1 /media/flashCorsaire fuseblk rw,nosuid,nodev,allow_other,blksize=4096 0 0
Therefore the file system is 'fuseblk' and options are rw,nosuid,nodev,allow_other,blksize=4096
So what's the problem? Where did I make a mistake in the code that generates this error
message?
Thanks in advance,
Kind Regards,
Dariyoosh