From owner-svn-src-head@freebsd.org Wed Jun 13 12:44:46 2018 Return-Path: Delivered-To: svn-src-head@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 174CA1007369; Wed, 13 Jun 2018 12:44:46 +0000 (UTC) (envelope-from bde@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id C0ED480B0D; Wed, 13 Jun 2018 12:44:45 +0000 (UTC) (envelope-from bde@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 9E16F199A9; Wed, 13 Jun 2018 12:44:45 +0000 (UTC) (envelope-from bde@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id w5DCijxn013784; Wed, 13 Jun 2018 12:44:45 GMT (envelope-from bde@FreeBSD.org) Received: (from bde@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id w5DCijH8013783; Wed, 13 Jun 2018 12:44:45 GMT (envelope-from bde@FreeBSD.org) Message-Id: <201806131244.w5DCijH8013783@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: bde set sender to bde@FreeBSD.org using -f From: Bruce Evans Date: Wed, 13 Jun 2018 12:44:45 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r335057 - head/sys/compat/linux X-SVN-Group: head X-SVN-Commit-Author: bde X-SVN-Commit-Paths: head/sys/compat/linux X-SVN-Commit-Revision: 335057 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.26 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 13 Jun 2018 12:44:46 -0000 Author: bde Date: Wed Jun 13 12:44:45 2018 New Revision: 335057 URL: https://svnweb.freebsd.org/changeset/base/335057 Log: Oops, r335053 had an old version of the comment about 16-bit linux dev_t translation. Modified: head/sys/compat/linux/linux_stats.c Modified: head/sys/compat/linux/linux_stats.c ============================================================================== --- head/sys/compat/linux/linux_stats.c Wed Jun 13 12:33:47 2018 (r335056) +++ head/sys/compat/linux/linux_stats.c Wed Jun 13 12:44:45 2018 (r335057) @@ -130,18 +130,20 @@ translate_fd_major_minor(struct thread *td, int fd, st /* * l_dev_t has the same encoding as dev_t in the latter's low 16 bits, so - * don't bother going through major() and minor(). Keep doing blind - * truncation, as for other fields. The previous version didn't even do - * blind truncation after dev_t was expanded to 64 bits. It failed to - * mask out bits 8-15 in minor(). These bits can only be nonzero in th - * 64-bit version. + * truncation of a dev_t to 16 bits gives the same result as unpacking + * using major() and minor() and repacking in the l_dev_t format. This + * detail is hidden in dev_to_ldev(). Overflow in conversions of dev_t's + * are not checked for, as for other fields. * - * This is only used for st_dev. st_dev is for the mounted-on device so - * it can't be a device that needs very special translation. The translation - * of blind truncation is done here. st_rdev is supposed to be specially - * translated in callers, with the blind truncation done there too and - * st_rdev in the native struct state abused to hold the linux st_rdev. - * Callers do the last step using an open-coded Linux makedev(). + * dev_to_ldev() is only used for translating st_dev. When we convert + * st_rdev for copying it out, it isn't really a dev_t, but has already + * been translated to an l_dev_t in a nontrivial way. Translating it + * again would be illogical but would have no effect since the low 16 + * bits have the same encoding. + * + * The nontrivial translation for st_rdev renumbers some devices, but not + * ones that can be mounted on, so it is consistent with the translation + * for st_dev except when the renumbering or truncation causes conflicts. */ #define dev_to_ldev(d) ((uint16_t)(d))