mapping of ioctl to its definition

The name of the pictureThe name of the pictureThe name of the pictureClash Royale CLAN TAG#URR8PPP











up vote
0
down vote

favorite












The prototype of ioctl in linux driver modules is



int ioctl(struct inode *i, struct file *f, unsigned int cmd, unsigned long arg);


or



long ioctl(struct file *f, unsigned int cmd, unsigned long arg);


but inside sys/ioctl.h it is



int ioctl(int fd, int request, void *argp);


The first argument type is different, is there any module between ioctl calling program and driver that converts this argument(From file descriptor to file structure pointer)?



How this mapping works?(From file descriptor to file).







share|improve this question























    up vote
    0
    down vote

    favorite












    The prototype of ioctl in linux driver modules is



    int ioctl(struct inode *i, struct file *f, unsigned int cmd, unsigned long arg);


    or



    long ioctl(struct file *f, unsigned int cmd, unsigned long arg);


    but inside sys/ioctl.h it is



    int ioctl(int fd, int request, void *argp);


    The first argument type is different, is there any module between ioctl calling program and driver that converts this argument(From file descriptor to file structure pointer)?



    How this mapping works?(From file descriptor to file).







    share|improve this question





















      up vote
      0
      down vote

      favorite









      up vote
      0
      down vote

      favorite











      The prototype of ioctl in linux driver modules is



      int ioctl(struct inode *i, struct file *f, unsigned int cmd, unsigned long arg);


      or



      long ioctl(struct file *f, unsigned int cmd, unsigned long arg);


      but inside sys/ioctl.h it is



      int ioctl(int fd, int request, void *argp);


      The first argument type is different, is there any module between ioctl calling program and driver that converts this argument(From file descriptor to file structure pointer)?



      How this mapping works?(From file descriptor to file).







      share|improve this question











      The prototype of ioctl in linux driver modules is



      int ioctl(struct inode *i, struct file *f, unsigned int cmd, unsigned long arg);


      or



      long ioctl(struct file *f, unsigned int cmd, unsigned long arg);


      but inside sys/ioctl.h it is



      int ioctl(int fd, int request, void *argp);


      The first argument type is different, is there any module between ioctl calling program and driver that converts this argument(From file descriptor to file structure pointer)?



      How this mapping works?(From file descriptor to file).









      share|improve this question










      share|improve this question




      share|improve this question









      asked May 2 at 13:27









      Xter

      65




      65




















          1 Answer
          1






          active

          oldest

          votes

















          up vote
          0
          down vote



          accepted










          In $kernel_root/fs/ioctl.c (in 4.13) there's:



          SYSCALL_DEFINE3(ioctl, unsigned int, fd, unsigned int, cmd, unsigned long, arg)


          That SYSCALL_DEFINE3 is a macro that takes those parameters and expands it to the appropriate signature for the system call. That function is the logical entry point for the ioctl system call from user space. That function, in turn, looks up the struct fd corresponding to the given file descriptor and calls do_vfs_ioctl passing the struct file associated with the struct fd. The call will wind through the VFS layer before it reaches a driver, but that should give you a place to start looking.






          share|improve this answer





















            Your Answer







            StackExchange.ready(function()
            var channelOptions =
            tags: "".split(" "),
            id: "106"
            ;
            initTagRenderer("".split(" "), "".split(" "), channelOptions);

            StackExchange.using("externalEditor", function()
            // Have to fire editor after snippets, if snippets enabled
            if (StackExchange.settings.snippets.snippetsEnabled)
            StackExchange.using("snippets", function()
            createEditor();
            );

            else
            createEditor();

            );

            function createEditor()
            StackExchange.prepareEditor(
            heartbeatType: 'answer',
            convertImagesToLinks: false,
            noModals: false,
            showLowRepImageUploadWarning: true,
            reputationToPostImages: null,
            bindNavPrevention: true,
            postfix: "",
            onDemand: true,
            discardSelector: ".discard-answer"
            ,immediatelyShowMarkdownHelp:true
            );



            );








             

            draft saved


            draft discarded


















            StackExchange.ready(
            function ()
            StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f441321%2fmapping-of-ioctl-to-its-definition%23new-answer', 'question_page');

            );

            Post as a guest






























            1 Answer
            1






            active

            oldest

            votes








            1 Answer
            1






            active

            oldest

            votes









            active

            oldest

            votes






            active

            oldest

            votes








            up vote
            0
            down vote



            accepted










            In $kernel_root/fs/ioctl.c (in 4.13) there's:



            SYSCALL_DEFINE3(ioctl, unsigned int, fd, unsigned int, cmd, unsigned long, arg)


            That SYSCALL_DEFINE3 is a macro that takes those parameters and expands it to the appropriate signature for the system call. That function is the logical entry point for the ioctl system call from user space. That function, in turn, looks up the struct fd corresponding to the given file descriptor and calls do_vfs_ioctl passing the struct file associated with the struct fd. The call will wind through the VFS layer before it reaches a driver, but that should give you a place to start looking.






            share|improve this answer

























              up vote
              0
              down vote



              accepted










              In $kernel_root/fs/ioctl.c (in 4.13) there's:



              SYSCALL_DEFINE3(ioctl, unsigned int, fd, unsigned int, cmd, unsigned long, arg)


              That SYSCALL_DEFINE3 is a macro that takes those parameters and expands it to the appropriate signature for the system call. That function is the logical entry point for the ioctl system call from user space. That function, in turn, looks up the struct fd corresponding to the given file descriptor and calls do_vfs_ioctl passing the struct file associated with the struct fd. The call will wind through the VFS layer before it reaches a driver, but that should give you a place to start looking.






              share|improve this answer























                up vote
                0
                down vote



                accepted







                up vote
                0
                down vote



                accepted






                In $kernel_root/fs/ioctl.c (in 4.13) there's:



                SYSCALL_DEFINE3(ioctl, unsigned int, fd, unsigned int, cmd, unsigned long, arg)


                That SYSCALL_DEFINE3 is a macro that takes those parameters and expands it to the appropriate signature for the system call. That function is the logical entry point for the ioctl system call from user space. That function, in turn, looks up the struct fd corresponding to the given file descriptor and calls do_vfs_ioctl passing the struct file associated with the struct fd. The call will wind through the VFS layer before it reaches a driver, but that should give you a place to start looking.






                share|improve this answer













                In $kernel_root/fs/ioctl.c (in 4.13) there's:



                SYSCALL_DEFINE3(ioctl, unsigned int, fd, unsigned int, cmd, unsigned long, arg)


                That SYSCALL_DEFINE3 is a macro that takes those parameters and expands it to the appropriate signature for the system call. That function is the logical entry point for the ioctl system call from user space. That function, in turn, looks up the struct fd corresponding to the given file descriptor and calls do_vfs_ioctl passing the struct file associated with the struct fd. The call will wind through the VFS layer before it reaches a driver, but that should give you a place to start looking.







                share|improve this answer













                share|improve this answer



                share|improve this answer











                answered May 2 at 14:01









                Andy Dalton

                4,7561520




                4,7561520






















                     

                    draft saved


                    draft discarded


























                     


                    draft saved


                    draft discarded














                    StackExchange.ready(
                    function ()
                    StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f441321%2fmapping-of-ioctl-to-its-definition%23new-answer', 'question_page');

                    );

                    Post as a guest













































































                    Popular posts from this blog

                    How to check contact read email or not when send email to Individual?

                    Bahrain

                    Postfix configuration issue with fips on centos 7; mailgun relay