Skip site navigation (1)Skip section navigation (2)
Date:      Sat, 06 May 2000 12:58:10 -0700
From:      Jake Burkholder <jburkhol@home.com>
To:        Alexander Langer <alex@big.endian.de>
Cc:        hackers@FreeBSD.ORG
Subject:   Re: problem with ioctl handler in a module 
Message-ID:  <20000506195810.31B4ABCA7@io.yi.org>
In-Reply-To: Message from Alexander Langer <alex@big.endian.de>  of "Sat, 06 May 2000 20:09:40 %2B0200." <20000506200940.A8087@cichlids.cichlids.com> 

next in thread | previous in thread | raw e-mail | index | archive | help
> Hello!
> 
> I have:
> 
> int ziva_ioctl(dev_t dev, u_long cmd, caddr_t arg, int flag, struct
> proc* pr)
> 
> when this function catches a ioctl from userspace, called as:
> 	int foo = 199;
> 	ioctl(fd, 10, &foo);
> 
> the u_long cmd contains 10, which is correct (so the ioctl-handler is
> called correctly).
> 
> However, I can't get the value of the int.
> 
> I tried something like:
> 	if (*((int *) arg) == 199)
> 		<bleh>.
> 
> But this doesn't work, <bleh> is not executed. Somehow, I can't access 
> the memory this way.
> 
> Anyone knows, what I'm doing wrong?

The request parameter to ioctl needs to contain length information.

I think you want something like:

#define ZIVA_IOCTL   _IOW('c', 10, int)

int foo = 199;
ioctl(fd, ZIVA_IOCTL, &foo);

Then arg should be right.  See iocomm.h.



To Unsubscribe: send mail to majordomo@FreeBSD.org
with "unsubscribe freebsd-hackers" in the body of the message




Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20000506195810.31B4ABCA7>