Re: how to use the function copyout()

From: Scott Long (scottl_at_samsco.org)
Date: 07/26/05

  • Next message: Scott Long: "Re: await & asleep"
    Date: Tue, 26 Jul 2005 09:39:13 -0600
    To: Felix-KM@yandex.ru
    
    

    Felix-KM wrote:
    >>I think that could work (only an idea, not tested):
    >>
    >>
    >>struct Region
    >>{
    >> void * p;
    >> size_t s;
    >>};
    >>
    >>
    >>#define IOBIG _IOWR ('b', 123, struct Region)
    >>
    >>
    >>userland:
    >>
    >> char data[1000];
    >> struct Region r;
    >>
    >> r.p = data;
    >> r.s = sizeof data;
    >> int error = ioctl (fd, IOBIG, &r);
    >>
    >>
    >>kernel:
    >> int my_ioctl(..., caddr_t data, ...)
    >> {
    >> ...
    >> char data[1000];
    >> ...
    >> return copyout(data, ((struct Region *) data)->p, ((struct Region *)
    >>data)->s);
    >> }
    >>
    >>
    >>Have a try and tell us if it works.
    >>
    >>
    >>Norbert
    >>
    >
    >
    > Yes! Now the program works!
    > I have changed the code in this way:
    >
    > struct Region
    > {
    > void * p;
    > size_t s;
    > };
    >
    > #define IOBIG _IOWR ('b', 123, struct Region)
    >

    Unless your ioctl handler is going to modify values in the Region struct
    and pass them back out to userland, you should just use _IOR instead of
    _IORW.

    Scott
    _______________________________________________
    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: Scott Long: "Re: await & asleep"