Google Groups Home
Help | Sign in
dynamic size for ioctl parameter
There are currently too many topics in this group that display first. To make this topic appear first, remove this option from another topic.
There was an error processing your request. Please try again.
flag
  3 messages - Collapse all
The group you are posting to is a Usenet group. Messages posted to this group will make your email address visible to anyone on the Internet.
Your reply message has not been sent.
Your post was successful
non  
View profile
 More options Jul 6, 8:03 am
Newsgroups: comp.os.minix
From: non <ml.in.h...@gmail.com>
Date: Sun, 6 Jul 2008 05:03:15 -0700 (PDT)
Local: Sun, Jul 6 2008 8:03 am
Subject: 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()))


    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
J.F. de Smit  
View profile
 More options Jul 7, 3:34 am
Newsgroups: comp.os.minix
From: "J.F. de Smit" <jst...@keg.few.vu.nl>
Date: 7 Jul 2008 07:34:34 GMT
Local: Mon, Jul 7 2008 3:34 am
Subject: Re: dynamic size for ioctl parameter
non <ml.in.h...@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
jfds...@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


    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
non  
View profile
 More options Jul 7, 4:33 am
Newsgroups: comp.os.minix
From: non <ml.in.h...@gmail.com>
Date: Mon, 7 Jul 2008 01:33:54 -0700 (PDT)
Local: Mon, Jul 7 2008 4:33 am
Subject: Re: dynamic size for ioctl parameter

> <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.


    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
End of messages
« Back to Discussions « Newer topic     Older topic »

Create a group - Google Groups - Google Home - Terms of Service - Privacy Policy
©2008 Google