Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

dynamic size for ioctl parameter

16 views
Skip to first unread message

non

unread,
Jul 6, 2008, 8:03:15 AM7/6/08
to
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()))


J.F. de Smit

unread,
Jul 7, 2008, 3:34:34 AM7/7/08
to
non <ml.in...@gmail.com> wrote:
<snip icky macros>

> (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
jfd...@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

non

unread,
Jul 7, 2008, 4:33:54 AM7/7/08
to
> <snip icky macros>

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.


0 new messages