|
|
|
#1 |
|
Messages: n/a
Hébergeur: |
Hello,
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/ "); Thanks. |
|
|
|
#2 |
|
Messages: n/a
Hébergeur: |
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). |
|
|
|
#3 |
|
Messages: n/a
Hébergeur: |
Antoninus Twink wrote:
> 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); > [...] Drivel. Nonsense. Idiocy. To the O.P.: Your question is not about the C language, but about the system interfaces provided by (it seems) some flavor of Unix or POSIX. The details of how to get that system to do something and about the necessary preconditions and failure modes are all specific to the system, not to the language you address it with. So look for a forum where the experts on your system hang out, and try asking there. Here, as you've seen, you're likely to get drivel, nonsense, and idiocy. -- Eric.Sosman@sun.com |
|
|
|
#4 |
|
Messages: n/a
Hébergeur: |
On 5 May 2008 at 21:47, Eric Sosman wrote:
> Antoninus Twink wrote: >> 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); >> [...] > > Drivel. Nonsense. Idiocy. What on earth are you talking about? If (as is very likely) the OP is using Linux, he can check for himself by examining /usr/src/linux/include/linux/syscalls.h |
|
|
|
#5 |
|
Messages: n/a
Hébergeur: |
In article <1210023910.891654@news1nwk>,
Eric Sosman <Eric.Sosman@sun.com> wrote: >> 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); >> [...] > Drivel. Nonsense. Idiocy. I guess the OP's question concerns Linux, in which case it would certainly make more sense to ask in a Linux group. But as far as I can tell, Twink's response was fairly accurate. -- Richard -- :wq |
|
|
|
#6 |
|
Messages: n/a
Hébergeur: |
In article <1210023910.891654@news1nwk>,
Eric Sosman <Eric.Sosman@sun.com> wrote a bunch of Drivel. Nonsense. Idiocy.: .... > Here, as you've seen, you're likely to get drivel, >nonsense, and idiocy. > >-- >Eric.Sosman@sun.com Straight from the source. |
|
|
|
#7 |
|
Messages: n/a
Hébergeur: |
Richard Tobin wrote:
> In article <1210023910.891654@news1nwk>, > Eric Sosman <Eric.Sosman@sun.com> wrote: > >>> 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); >>> [...] > >> Drivel. Nonsense. Idiocy. > > I guess the OP's question concerns Linux, in which case it > would certainly make more sense to ask in a Linux group. But > as far as I can tell, Twink's response was fairly accurate. > That the problem, isn't it? "as far as I can tell" isn't good enough, post here you might get one opinion, post in the correct place, you will get informed answers. -- Ian Collins. |
|
|
|
#8 |
|
Messages: n/a
Hébergeur: |
In article <689fpiF2qkckmU1@mid.individual.net>,
Ian Collins <ian-news@hotmail.com> wrote: >That the problem, isn't it? "as far as I can tell" isn't good enough, >post here you might get one opinion, post in the correct place, you will >get informed answers. There's a better chance of accurate answers (and wrong answers being corrected) in a Linux group, which is why I said it would make more sense to ask there. But I was responding to Eric accusation, not to the original poster. Eric made his accusation here in comp.lang.c, and I don't see why it should go unchallenged just because he posted it in this newsgroup. -- Richard -- :wq |
|
![]() |
| Outils de la discussion | |
|
|