PHWinfo banniere

Titres
PORTAIL ANNUAIRE ARTICLES COMPARATEUR HÉBERGEURS DEVIS FORUMS RÉDUCTEUR D'URL
Précédent   PHWinfo > Autres forums > Forum Programmation & Conception > comp.lang.c > Problem with SYS_mount
S'inscrire FAQ Membres Recherche Messages du jour Marquer les forums comme lus
Problem with SYS_mount

Réponse
 
LinkBack Outils de la discussion
Vieux 05/05/2008, 22h14   #1
Sam Joseph
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Problem with SYS_mount

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.
  Réponse avec citation
Vieux 05/05/2008, 22h33   #2
Antoninus Twink
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: Problem with SYS_mount

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).

  Réponse avec citation
Vieux 05/05/2008, 22h47   #3
Eric Sosman
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: Problem with SYS_mount

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
  Réponse avec citation
Vieux 05/05/2008, 22h50   #4
Antoninus Twink
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: Problem with SYS_mount

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

  Réponse avec citation
Vieux 05/05/2008, 22h56   #5
Richard Tobin
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: Problem with SYS_mount

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
  Réponse avec citation
Vieux 05/05/2008, 23h11   #6
Kenny McCormack
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: Problem with SYS_mount

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.

  Réponse avec citation
Vieux 05/05/2008, 23h24   #7
Ian Collins
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: Problem with SYS_mount

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.
  Réponse avec citation
Vieux 06/05/2008, 00h01   #8
Richard Tobin
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: Problem with SYS_mount

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
  Réponse avec citation
Réponse


Outils de la discussion

Règles de messages
Vous ne pouvez pas créer de nouvelles discussions
Vous ne pouvez pas envoyer des réponses
Vous ne pouvez pas envoyer des pièces jointes
Vous ne pouvez pas modifier vos messages

Les balises BB sont activées : oui
Les smileys sont activés : oui
La balise [IMG] est activée : oui
Le code HTML peut être employé : non
Trackbacks are oui
Pingbacks are oui
Refbacks are oui


Fuseau horaire GMT +1. Il est actuellement 12h51.


Édité par : vBulletin® version 3.7.3
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.2.0 RC5 Tous droits réservés.
Version française #16 par l'association vBulletin francophone
PHWinfo est un site Éducation Sans Frontières ©2000-2008
Ad Management by RedTyger
©Tous droits réservés par les parties respectives
Page generated in 0,12695 seconds with 16 queries