From owner-freebsd-arch@FreeBSD.ORG Thu Apr 15 06:41:55 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 BC00B106566C for ; Thu, 15 Apr 2010 06:41:55 +0000 (UTC) (envelope-from pjd@garage.freebsd.pl) Received: from mail.garage.freebsd.pl (chello089077043238.chello.pl [89.77.43.238]) by mx1.freebsd.org (Postfix) with ESMTP id 0A9018FC18 for ; Thu, 15 Apr 2010 06:41:53 +0000 (UTC) Received: by mail.garage.freebsd.pl (Postfix, from userid 65534) id D420045CAC; Thu, 15 Apr 2010 08:41:51 +0200 (CEST) Received: from localhost (chello089077043238.chello.pl [89.77.43.238]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by mail.garage.freebsd.pl (Postfix) with ESMTP id 786C645685; Thu, 15 Apr 2010 08:41:46 +0200 (CEST) Date: Thu, 15 Apr 2010 08:41:49 +0200 From: Pawel Jakub Dawidek To: d@delphij.net Message-ID: <20100415064149.GB2252@garage.freebsd.pl> References: <4BC39E93.7060906@delphij.net> Mime-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha1; protocol="application/pgp-signature"; boundary="+g7M9IMkV8truYOl" Content-Disposition: inline In-Reply-To: <4BC39E93.7060906@delphij.net> User-Agent: Mutt/1.4.2.3i X-PGP-Key-URL: http://people.freebsd.org/~pjd/pjd.asc X-OS: FreeBSD 9.0-CURRENT i386 X-Spam-Checker-Version: SpamAssassin 3.0.4 (2005-06-05) on mail.garage.freebsd.pl X-Spam-Level: X-Spam-Status: No, score=-0.6 required=4.5 tests=BAYES_00,RCVD_IN_SORBS_DUL autolearn=no version=3.0.4 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: Thu, 15 Apr 2010 06:41:55 -0000 --+g7M9IMkV8truYOl Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable On Mon, Apr 12, 2010 at 03:28:35PM -0700, Xin LI wrote: > -----BEGIN PGP SIGNED MESSAGE----- > Hash: SHA1 >=20 > Hi, >=20 > Is there a sane way to copyout ioctl request when the returning errno !=3D > 0? Looking at the code, currently, in sys/kern/sys_generic.c, we have: >=20 > =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D > error =3D kern_ioctl(td, uap->fd, com, data); >=20 > if (error =3D=3D 0 && (com & IOC_OUT)) > error =3D copyout(data, uap->data, (u_int)size); > =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D >=20 > Is there any objection if I change it to something like: >=20 > =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D > saved_error =3D kern_ioctl(td, uap->fd, com, data); >=20 > if (com & IOC_OUT) > error =3D copyout(data, uap->data, (u_int)size); > if (saved_error) > error =3D saved_error; > =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D I'd like to note that OpenSolaris does copy data back even if an error occurs. I needed to change ZFS to return 0 for ioctl(2) and return an error within zfs_cmd structure. I think FreeBSD way is better, BTW. ioctl(2) can fail for other reasons, for example data pointer is invalid, so we return EFAULT and we are unable to copy data back in that case anyway. --=20 Pawel Jakub Dawidek http://www.wheelsystems.com pjd@FreeBSD.org http://www.FreeBSD.org FreeBSD committer Am I Evil? Yes, I Am! --+g7M9IMkV8truYOl Content-Type: application/pgp-signature Content-Disposition: inline -----BEGIN PGP SIGNATURE----- Version: GnuPG v2.0.14 (FreeBSD) iEYEARECAAYFAkvGtSwACgkQForvXbEpPzTcNACg3Iq+vXbNNUIv2Irudz1D7rE3 gjUAoOUhQ2PkIM0C2u6I2OL2gPLkTnZ/ =y1Ws -----END PGP SIGNATURE----- --+g7M9IMkV8truYOl--