Talk About Network

Google


Register and Login
Nick
Password
Register create new account Sign up is FREE and you can post replies, new topics, bookmark posts and more!
Recover lost password


Programming > C > Re: Problem wit...
Latest [ Topics | Posts ] Archive Post A New Topic Post a Reply
<< Topic < Post Post 2 of 29 Topic 26075 of 26977
Post > Topic >>

Re: Problem with SYS_mount

by Antoninus Twink <nospam@[EMAIL PROTECTED] > May 5, 2008 at 11:33 PM

On  5 May 2008 at 21:14, Sam Joseph wrote:
> I need to mount a loopback file system. I'm using SYS_mount, but it 
> always fails with ENOTDIR. Am I doing something silly? Here's the 
> offending line:
>
> if(syscall(SYS_mount,
>    "/home/sam/mnt/", "/home/sam/myfile.img", "-o loop" ))
>          perror("Mount failure/ ");

There are so many problems with your code and approach that it's hard to
know where to begin!

First of all, the prototype for the system call is
asmlinkage long sys_mount(char __user *dev_name, char __user* dir_name,
  char __user *type, unsigned long flags, void __user *data);

So your code has the first two arguments the wrong way round, and the
last two arguments are missing. The third argument is, unfortunately,
much too naive: while the mount(8) command is happy to accept options
like "-o loop", the mount system call isn't.

But you shouldn't be using the mount system call at all! The mount
program does some other fairly complicated work besides executing a
system call, and you'd need to re-do all that by hand. Why bother? Just
run mount(8).

If you really want to work programatically, you can open one of the loop
devices, perform an ioctl on it (request LOOP_SET_FD with extra argument
"/home/sam/myfile.img"), then use mount(2).
 




 29 Posts in Topic:
Problem with SYS_mount
Sam Joseph <spamtrap@[  2008-05-05 22:14:10 
Re: Problem with SYS_mount
Antoninus Twink <nospa  2008-05-05 23:33:53 
Re: Problem with SYS_mount
Eric Sosman <Eric.Sosm  2008-05-05 17:47:28 
Re: Problem with SYS_mount
richard@[EMAIL PROTECTED]  2008-05-05 21:56:08 
Re: Problem with SYS_mount
Ian Collins <ian-news@  2008-05-06 10:24:50 
Re: Problem with SYS_mount
richard@[EMAIL PROTECTED]  2008-05-05 23:01:18 
Re: Problem with SYS_mount
Ian Collins <ian-news@  2008-05-06 11:05:29 
Re: Problem with SYS_mount
richard@[EMAIL PROTECTED]  2008-05-05 23:27:11 
Re: Problem with SYS_mount
CBFalconer <cbfalconer  2008-05-05 19:30:31 
Re: Problem with SYS_mount
richard@[EMAIL PROTECTED]  2008-05-05 23:55:50 
Re: Problem with SYS_mount
gazelle@[EMAIL PROTECTED]  2008-05-05 22:11:58 
Re: Problem with SYS_mount
jacob navia <jacob@[EM  2008-05-06 07:45:39 
Re: Problem with SYS_mount
gazelle@[EMAIL PROTECTED]  2008-05-06 13:47:59 
Re: Problem with SYS_mount
Antoninus Twink <nospa  2008-05-07 00:14:47 
Re: Problem with SYS_mount
Sam Joseph <spamtrap@[  2008-05-07 08:13:02 
Re: Problem with SYS_mount
gazelle@[EMAIL PROTECTED]  2008-05-07 09:19:55 
Re: Problem with SYS_mount
CBFalconer <cbfalconer  2008-05-07 12:11:02 
Re: Problem with SYS_mount
roberson@[EMAIL PROTECTED  2008-05-07 16:57:50 
Re: Problem with SYS_mount
gazelle@[EMAIL PROTECTED]  2008-05-07 18:17:04 
Re: Problem with SYS_mount
Eric Sosman <Eric.Sosm  2008-05-07 13:22:07 
Re: Problem with SYS_mount
Antoninus Twink <nospa  2008-05-05 23:50:41 
Re: Problem with SYS_mount
Eligiusz Narutowicz<el  2008-05-06 14:15:42 
Re: Problem with SYS_mount
Ian Collins <ian-news@  2008-05-07 07:10:39 
Re: Problem with SYS_mount
Eligiusz Narutowicz<el  2008-05-06 15:50:37 
Re: Problem with SYS_mount
roberson@[EMAIL PROTECTED  2008-05-06 14:19:18 
Re: Problem with SYS_mount
Nick Keighley <nick_ke  2008-05-06 07:16:28 
Re: Problem with SYS_mount
CBFalconer <cbfalconer  2008-05-06 19:47:53 
Re: Problem with SYS_mount
Eligiusz Narutowicz<el  2008-05-07 12:08:36 
Re: Problem with SYS_mount
CBFalconer <cbfalconer  2008-05-07 12:06:53 

Post A Reply:
  Go here to Signup

AddThis Feed Button


About - Advertising - Contact - Frequently Asked Questions - Privacy Policy - Terms of Use - Signup

Contact
tan12V112 Sat Jul 26 3:42:46 CDT 2008.