From owner-freebsd-arch@FreeBSD.ORG Mon Apr 12 23:49:23 2010 Return-Path: Delivered-To: freebsd-arch@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 61A48106566B for ; Mon, 12 Apr 2010 23:49:23 +0000 (UTC) (envelope-from bright@elvis.mu.org) Received: from elvis.mu.org (elvis.mu.org [192.203.228.196]) by mx1.freebsd.org (Postfix) with ESMTP id 553518FC1B for ; Mon, 12 Apr 2010 23:49:23 +0000 (UTC) Received: by elvis.mu.org (Postfix, from userid 1192) id 857C41A3C86; Mon, 12 Apr 2010 16:33:30 -0700 (PDT) Date: Mon, 12 Apr 2010 16:33:30 -0700 From: Alfred Perlstein To: d@delphij.net Message-ID: <20100412233330.GC19003@elvis.mu.org> References: <4BC39E93.7060906@delphij.net> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <4BC39E93.7060906@delphij.net> User-Agent: Mutt/1.4.2.3i Cc: freebsd-arch@freebsd.org Subject: Re: _IOWR when errno != 0 X-BeenThere: freebsd-arch@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Discussion related to FreeBSD architecture List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 12 Apr 2010 23:49:23 -0000 * Xin LI [100412 15:28] wrote: > -----BEGIN PGP SIGNED MESSAGE----- > Hash: SHA1 > > Hi, > > Is there a sane way to copyout ioctl request when the returning errno != > 0? Looking at the code, currently, in sys/kern/sys_generic.c, we have: > > =========== > error = kern_ioctl(td, uap->fd, com, data); > > if (error == 0 && (com & IOC_OUT)) > error = copyout(data, uap->data, (u_int)size); > =========== > > Is there any objection if I change it to something like: > > =========== > saved_error = kern_ioctl(td, uap->fd, com, data); > > if (com & IOC_OUT) > error = copyout(data, uap->data, (u_int)size); > if (saved_error) > error = saved_error; > =========== Is this for linux compat? I'm not sure this would work, it might seriously break userland compat. Have you looked around/queiried what the expected outcome is from a bad ioctl? By default the buffer will be zero'd this might be unexpected by apps. (all or nothing) -- - Alfred Perlstein .- AMA, VMOA #5191, 03 vmax, 92 gs500, 85 ch250 .- FreeBSD committer