dynamic size for ioctl parameter - Minix

This is a discussion on dynamic size for ioctl parameter - Minix ; hi all! struct A { int dummy; }; _IORW('x', 1, struct A) works fine. now i've to submit a data-structure which size is not know at compile time. like: struct B { int size; char *buffer; } _IORW('x', 1, struct ...

+ Reply to Thread
Results 1 to 3 of 3

Thread: dynamic size for ioctl parameter

  1. dynamic size for ioctl parameter

    hi all!

    struct A {
    int dummy;
    };


    _IORW('x', 1, struct A)

    works fine.

    now i've to submit a data-structure which size is not know at compile
    time. like:

    struct B {
    int size;
    char *buffer;
    }

    _IORW('x', 1, struct B) does not work, because only sizeof(struct B)
    bytes are granted to submit.
    think I need something like:

    #define _IORWxx(x,y,t) ((x << 8) | y | ((t->size) & _IOCPARM_MASK)
    << 16) | _IOC_INOUT)
    (which does clearly not work!)

    (was: #define _IORW(x,y,t) ((x << 8) | y | ((sizeof(t) &
    _IOCPARM_MASK) << 16) | _IOC_INOUT))

    ideas?


    thx.
    markus

    (in linux they transfer the ioctl request at a constant size and
    access B->size bytes from client afterwards. (copy_from_user()))







  2. Re: dynamic size for ioctl parameter

    non wrote:


    > (in linux they transfer the ioctl request at a constant size and
    > access B->size bytes from client afterwards. (copy_from_user()))


    Minix is no different. Message size is fixed (and very limited). I don't
    know the exact size, but it's less than 100 bytes. If you want to pass
    larger amounts of data (such as character buffers), you'll need to put a
    pointer and a buffer size into the message and then use kernel calls
    and/or kernel routines to read/copy the data after the context switch.
    Look at the implementation of the read() system call for examples.

    Regards,

    Jens

    --
    Jens de Smit
    Student Computer Science | Vrije Universiteit Amsterdam
    jfdsmit@few.vu.nl | http://www.few.vu.nl/~jfdsmit
    "[In the end, people] get furious at IT that the goddamn magic isn't working"
    -- Stewart Dean

  3. Re: dynamic size for ioctl parameter

    >

    yeah

    > Minix is no different. Message size is fixed (and very limited). I don't
    > know the exact size, but it's less than 100 bytes. If you want to pass
    > larger amounts of data (such as character buffers), you'll need to put a
    > pointer and a buffer size into the message and then use kernel calls
    > and/or kernel routines to read/copy the data after the context switch.
    > Look at the implementation of the read() system call for examples.


    i think, this is the way ioctl requests work. after a ioctl call minix
    assembles a (small) message (with pointer and size as mentioned from
    you) and you copy your request parameter by sys_safecopyfrom().
    other way around, back to the upper problem, i guess eg struct A can
    have arbitrary (huge) constant size, but not dynamic.

    i'm going to add a constant size char buffer to struct A, which is big
    enough to hold any possible parameter.



+ Reply to Thread