From owner-freebsd-hackers@FreeBSD.ORG Tue Jul 26 15:39:36 2005 Return-Path: X-Original-To: freebsd-hackers@freebsd.org Delivered-To: freebsd-hackers@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id B438016A41F for ; Tue, 26 Jul 2005 15:39:36 +0000 (GMT) (envelope-from scottl@samsco.org) Received: from pooker.samsco.org (pooker.samsco.org [168.103.85.57]) by mx1.FreeBSD.org (Postfix) with ESMTP id 32F7E43D49 for ; Tue, 26 Jul 2005 15:39:36 +0000 (GMT) (envelope-from scottl@samsco.org) Received: from [192.168.254.11] (junior.samsco.home [192.168.254.11]) (authenticated bits=0) by pooker.samsco.org (8.13.3/8.13.3) with ESMTP id j6QFmqdY096268; Tue, 26 Jul 2005 09:48:53 -0600 (MDT) (envelope-from scottl@samsco.org) Message-ID: <42E65921.8060400@samsco.org> Date: Tue, 26 Jul 2005 09:39:13 -0600 From: Scott Long User-Agent: Mozilla/5.0 (X11; U; FreeBSD i386; en-US; rv:1.7.8) Gecko/20050615 X-Accept-Language: en-us, en MIME-Version: 1.0 To: Felix-KM@yandex.ru References: <000001c59129$6099b560$4801a8c0@ws-ew-3.W2KDEMIG> <42E5EA4F.00000A.07557@colgate.yandex.ru> In-Reply-To: <42E5EA4F.00000A.07557@colgate.yandex.ru> Content-Type: text/plain; charset=us-ascii; format=flowed Content-Transfer-Encoding: 7bit X-Spam-Status: No, score=-2.8 required=3.8 tests=ALL_TRUSTED autolearn=failed version=3.0.2 X-Spam-Checker-Version: SpamAssassin 3.0.2 (2004-11-16) on pooker.samsco.org Cc: NKoch@demig.de, freebsd-hackers@freebsd.org Subject: Re: how to use the function copyout() X-BeenThere: freebsd-hackers@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Technical Discussions relating to FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 26 Jul 2005 15:39:36 -0000 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