From owner-freebsd-hackers@freebsd.org Thu Nov 30 00:58:53 2017 Return-Path: Delivered-To: freebsd-hackers@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 24385DEF4AD for ; Thu, 30 Nov 2017 00:58:53 +0000 (UTC) (envelope-from brooks@spindle.one-eyed-alien.net) Received: from spindle.one-eyed-alien.net (spindle.one-eyed-alien.net [199.48.129.229]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id E68B86C71E for ; Thu, 30 Nov 2017 00:58:52 +0000 (UTC) (envelope-from brooks@spindle.one-eyed-alien.net) Received: by spindle.one-eyed-alien.net (Postfix, from userid 3001) id 95C7A5A9F15; Thu, 30 Nov 2017 00:58:45 +0000 (UTC) Date: Thu, 30 Nov 2017 00:58:45 +0000 From: Brooks Davis To: Farhan Khan Cc: freebsd-hackers@freebsd.org Subject: Re: What does kern_ioctl do? Message-ID: <20171130005845.GA54229@spindle.one-eyed-alien.net> References: MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha1; protocol="application/pgp-signature"; boundary="tKW2IUtsqtDRztdT" Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.9.1 (2017-09-22) X-BeenThere: freebsd-hackers@freebsd.org X-Mailman-Version: 2.1.25 Precedence: list List-Id: Technical Discussions relating to FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 30 Nov 2017 00:58:53 -0000 --tKW2IUtsqtDRztdT Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable On Wed, Nov 29, 2017 at 07:29:55PM -0500, Farhan Khan wrote: > Does anyone know what kern_ioctl does? >=20 > It is called by sys_ioctl and located in > /usr/src/sys/kern/sys_generic.c. OpenBSD and NetBSD do not have this > function, so its FreeBSD-specific, but I do not understand its > purpose. Generally speaking, kern_() functions are the actual implementation with sys_() handling the conversion from struct _args and possiably performing some argument checking to regular f= unction arguments. The kern_ versions exist to allow multiple callers to use the implementation. In the case of kern_ioctl() a few callers want to effectively perform an ioctl. In other cases, the kern_ function is there to allow the freebsd32_ function to translate arguments before calling kern_ rather than duplicating the guts of sys_. A good example of this is kern_openat() which is used by most compatibility layers and by implements both open(2) and openat(2). -- Brooks --tKW2IUtsqtDRztdT Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- iQEcBAEBAgAGBQJaH1fEAAoJEKzQXbSebgfAfYgIAIUHkpbuFwlws0YzuYKPYoOY J6RJ0fuYEmPo/1U7HaamZdDPQx8IqRRC6h5yLdp9q6/g7Av/3GG/iOWia/lhMDZs pygi3F5pGcfj63vdn65p96r4YR4F5fgxcrlBaz/wwvbzAdS+gT8i49pjxjZXfcri sFP+7hWSv5de00+7TxWKaov1fWCJb+BetiVmlhtJ3hpu9mEQ+Kd8Ug0ZQDlSFBJh jTfcFL0nOq8qHV/37OpfkYE9cSRqRC6+mu9N3QvGA4z52LCn7xBSFGgY5DDmiJ6P DcChJ7KKLSod6F8uON4a3VZKsn54ivmXCNEzYYErjLb8tvs2EzLhSjUcgl8sxAw= =/wVi -----END PGP SIGNATURE----- --tKW2IUtsqtDRztdT--