Re:

From: M. Warner Losh (imp_at_bsdimp.com)
Date: 09/29/05

  • Next message: Apache Xie: "How to use "offset" parameter in mmap() system call"
    Date: Wed, 28 Sep 2005 21:47:49 -0600 (MDT)
    To: nsrashmi@gmail.com
    
    

    In message: <9f9993160509280045586fb14d@mail.gmail.com>
                rashmi ns <nsrashmi@gmail.com> writes:
    : Hello All ,
    : I was trying to add a new ioctl cnd like
    : #define HDLCMODE _IOR('6',0xF,int)
    : when i try to uprintf the data which was sent from the user-space in the
    : device-driver-ioctl-routine i'll get a different value than which is passed.
    : Can anybody please tell me why this is happening . I pass the address of
    : integer from the user space as third arg to the ioctl call .
    : thanks and regards,

    Remember that there's a level of indirection here. For the userland
    call, you'll have something like:

          int i = 10;

          ioctl (fd, HDLCMODE, &i);

    in the kernel, this translates into a call to the driver's ioctl
    routine:

    int
    fooioctl(struct cdev *tp, u_long cmd, void *data, int flag, struct thread *t)
    {
            switch (cmd)
            {
            case HDLCMODE:
                 printf("this should be 10: %d\n", *(int *)data);
                 break;
    }

    Warner
    _______________________________________________
    freebsd-hackers@freebsd.org mailing list
    http://lists.freebsd.org/mailman/listinfo/freebsd-hackers
    To unsubscribe, send any mail to "freebsd-hackers-unsubscribe@freebsd.org"


  • Next message: Apache Xie: "How to use "offset" parameter in mmap() system call"