Problem with SYS_mount

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Sam Joseph

    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.
  • Antoninus Twink

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

    Comment

    • Eric Sosman

      #3
      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

      Comment

      • Antoninus Twink

        #4
        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

        Comment

        • Richard Tobin

          #5
          Re: Problem with SYS_mount

          In article <1210023910.891 654@news1nwk>,
          Eric Sosman <Eric.Sosman@su n.comwrote:
          >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

          Comment

          • Kenny McCormack

            #6
            Re: Problem with SYS_mount

            In article <1210023910.891 654@news1nwk>,
            Eric Sosman <Eric.Sosman@su n.comwrote a bunch of Drivel. Nonsense. Idiocy.:
            ....
            Here, as you've seen, you're likely to get drivel,
            >nonsense, and idiocy.
            >
            >--
            >Eric.Sosman@su n.com
            Straight from the source.

            Comment

            • Ian Collins

              #7
              Re: Problem with SYS_mount

              Richard Tobin wrote:
              In article <1210023910.891 654@news1nwk>,
              Eric Sosman <Eric.Sosman@su n.comwrote:
              >
              >>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.

              Comment

              • Richard Tobin

                #8
                Re: Problem with SYS_mount

                In article <689fpiF2qkckmU 1@mid.individua l.net>,
                Ian Collins <ian-news@hotmail.co mwrote:
                >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

                Comment

                • Ian Collins

                  #9
                  Re: Problem with SYS_mount

                  Richard Tobin wrote:
                  In article <689fpiF2qkckmU 1@mid.individua l.net>,
                  Ian Collins <ian-news@hotmail.co mwrote:
                  >
                  >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.
                  >
                  Well in standard C (this is c.l.c, right?) terms,

                  asmlinkage long sys_mount(char __user *dev_name, char __user* dir_name,
                  char __user *type, unsigned long flags, void __user *data);

                  is Drivel. Nonsense. Idiocy!

                  --
                  Ian Collins.

                  Comment

                  • Richard Tobin

                    #10
                    Re: Problem with SYS_mount

                    In article <689i5pF2qkckmU 4@mid.individua l.net>,
                    Ian Collins <ian-news@hotmail.co mwrote:
                    >Well in standard C (this is c.l.c, right?) terms,
                    >
                    >asmlinkage long sys_mount(char __user *dev_name, char __user* dir_name,
                    char __user *type, unsigned long flags, void __user *data);
                    >
                    >is Drivel. Nonsense. Idiocy!
                    C&V please. I can't find any of those terms in my copy of the standard.

                    -- Richard
                    --
                    :wq

                    Comment

                    • CBFalconer

                      #11
                      Re: Problem with SYS_mount

                      Richard Tobin wrote:
                      Eric Sosman <Eric.Sosman@su n.comwrote:
                      >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.
                      >
                      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.
                      I have no idea, since Twink is plonked here. However the question,
                      and thus an answer to it, are all off-topic for c.l.c. They are
                      probably topical on a group that deals with the OPs system.

                      Answering off-topic questions is no way to get off plonk lists.

                      --
                      [mail]: Chuck F (cbfalconer at maineline dot net)
                      [page]: <http://cbfalconer.home .att.net>
                      Try the download section.

                      ** Posted from http://www.teranews.com **

                      Comment

                      • Richard Tobin

                        #12
                        Re: Problem with SYS_mount

                        In article <481F9897.7C546 AE@yahoo.com>,
                        CBFalconer <cbfalconer@mai neline.netwrote :
                        >Answering off-topic questions is no way to get off plonk lists.
                        I am sure Twink will take note of this and act accordingly.

                        -- Richard
                        --
                        :wq

                        Comment

                        • jacob navia

                          #13
                          Re: Problem with SYS_mount

                          Eric Sosman wrote:

                          [drivel snipped]
                          Here, as you've seen, you're likely to get drivel,
                          nonsense, and idiocy.
                          >
                          You are the best example of that. Your post contains only that

                          --
                          jacob navia
                          jacob at jacob point remcomp point fr
                          logiciels/informatique

                          Comment

                          • Eligiusz Narutowicz

                            #14
                            Re: Problem with SYS_mount

                            Ian Collins <ian-news@hotmail.co mwrites:
                            Richard Tobin wrote:
                            >In article <1210023910.891 654@news1nwk>,
                            >Eric Sosman <Eric.Sosman@su n.comwrote:
                            >>
                            >>>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,
                            Who cares if YOU can tell or not?

                            He got an accurate answer I can be sure to tell you. You do not know?
                            Then do not comment I think is best.

                            Comment

                            • Kenny McCormack

                              #15
                              Re: Problem with SYS_mount

                              In article <fvora7$s6l$1@a ioe.org>, jacob navia <jacob@nospam.o rgwrote:
                              >Eric Sosman wrote:
                              >
                              >[drivel snipped]
                              >
                              > Here, as you've seen, you're likely to get drivel,
                              >nonsense, and idiocy.
                              >>
                              >
                              >You are the best example of that. Your post contains only that
                              Indeed. True of Sosman in general.

                              It was truly satisfying to see him finally come clean about his posting
                              style.

                              Comment

                              Working...