From owner-svn-src-stable-11@freebsd.org Sun Apr 22 00:26:36 2018 Return-Path: Delivered-To: svn-src-stable-11@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 1696FFB0B1C; Sun, 22 Apr 2018 00:26:36 +0000 (UTC) (envelope-from kevans@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 BFEE780735; Sun, 22 Apr 2018 00:26:35 +0000 (UTC) (envelope-from kevans@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 BAD0C653C; Sun, 22 Apr 2018 00:26:35 +0000 (UTC) (envelope-from kevans@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id w3M0QZjU073327; Sun, 22 Apr 2018 00:26:35 GMT (envelope-from kevans@FreeBSD.org) Received: (from kevans@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id w3M0QZRY073326; Sun, 22 Apr 2018 00:26:35 GMT (envelope-from kevans@FreeBSD.org) Message-Id: <201804220026.w3M0QZRY073326@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: kevans set sender to kevans@FreeBSD.org using -f From: Kyle Evans Date: Sun, 22 Apr 2018 00:26:35 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-11@freebsd.org Subject: svn commit: r332864 - stable/11/etc/rc.d X-SVN-Group: stable-11 X-SVN-Commit-Author: kevans X-SVN-Commit-Paths: stable/11/etc/rc.d X-SVN-Commit-Revision: 332864 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable-11@freebsd.org X-Mailman-Version: 2.1.25 Precedence: list List-Id: SVN commit messages for only the 11-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 22 Apr 2018 00:26:36 -0000 Author: kevans Date: Sun Apr 22 00:26:35 2018 New Revision: 332864 URL: https://svnweb.freebsd.org/changeset/base/332864 Log: MFC r332773: Fix ddb rc script r288291 added a call to limits(1), which isn't available before partitions are mounted. This broke the ddb rc script, which does not provide its own start_cmd. Alleviate the situation here by providing a start_cmd. We still have other problems with diskless setups that need to be considered, but this is a start. PR: 206291 Modified: stable/11/etc/rc.d/ddb Directory Properties: stable/11/ (props changed) Modified: stable/11/etc/rc.d/ddb ============================================================================== --- stable/11/etc/rc.d/ddb Sat Apr 21 20:48:03 2018 (r332863) +++ stable/11/etc/rc.d/ddb Sun Apr 22 00:26:35 2018 (r332864) @@ -15,6 +15,7 @@ desc="DDB kernel debugger" rcvar="ddb_enable" command="/sbin/${name}" start_precmd="ddb_prestart" +start_cmd="ddb_start" stop_cmd=":" ddb_prestart() @@ -23,6 +24,11 @@ ddb_prestart() if [ -z "`sysctl -Nq debug.ddb.scripting.scripts`" ]; then return 1 fi +} + +ddb_start() +{ + ${command} ${command_args} } load_rc_config $name From owner-svn-src-stable-11@freebsd.org Mon Apr 23 08:51:42 2018 Return-Path: Delivered-To: svn-src-stable-11@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 BB7B5FA8B4B; Mon, 23 Apr 2018 08:51:42 +0000 (UTC) (envelope-from ram@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 719E784FF7; Mon, 23 Apr 2018 08:51:42 +0000 (UTC) (envelope-from ram@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 53D0A21E5F; Mon, 23 Apr 2018 08:51:42 +0000 (UTC) (envelope-from ram@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id w3N8pg9U056764; Mon, 23 Apr 2018 08:51:42 GMT (envelope-from ram@FreeBSD.org) Received: (from ram@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id w3N8pgrJ056762; Mon, 23 Apr 2018 08:51:42 GMT (envelope-from ram@FreeBSD.org) Message-Id: <201804230851.w3N8pgrJ056762@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: ram set sender to ram@FreeBSD.org using -f From: Ram Kishore Vegesna Date: Mon, 23 Apr 2018 08:51:42 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-11@freebsd.org Subject: svn commit: r332883 - stable/11/sys/dev/ocs_fc X-SVN-Group: stable-11 X-SVN-Commit-Author: ram X-SVN-Commit-Paths: stable/11/sys/dev/ocs_fc X-SVN-Commit-Revision: 332883 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable-11@freebsd.org X-Mailman-Version: 2.1.25 Precedence: list List-Id: SVN commit messages for only the 11-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 23 Apr 2018 08:51:42 -0000 Author: ram Date: Mon Apr 23 08:51:41 2018 New Revision: 332883 URL: https://svnweb.freebsd.org/changeset/base/332883 Log: MFC r332471, r332646: Check if STACK is defined before using the stack(9). Moved opts-stack.h include before all other includes. Approved by: mav Modified: stable/11/sys/dev/ocs_fc/ocs_os.c stable/11/sys/dev/ocs_fc/ocs_os.h Directory Properties: stable/11/ (props changed) Modified: stable/11/sys/dev/ocs_fc/ocs_os.c ============================================================================== --- stable/11/sys/dev/ocs_fc/ocs_os.c Mon Apr 23 08:23:10 2018 (r332882) +++ stable/11/sys/dev/ocs_fc/ocs_os.c Mon Apr 23 08:51:41 2018 (r332883) @@ -37,9 +37,6 @@ */ #include "ocs.h" -#include -#include -#include /* for debug of memory allocations */ static MALLOC_DEFINE(M_OCS, "OCS", "OneCore Storage data"); @@ -855,11 +852,13 @@ void ocs_intr_enable(ocs_os_handle_t os) void ocs_print_stack(void) { +#if defined(STACK) struct stack st; stack_zero(&st); stack_save(&st); stack_print(&st); +#endif } void ocs_abort(void) Modified: stable/11/sys/dev/ocs_fc/ocs_os.h ============================================================================== --- stable/11/sys/dev/ocs_fc/ocs_os.h Mon Apr 23 08:23:10 2018 (r332882) +++ stable/11/sys/dev/ocs_fc/ocs_os.h Mon Apr 23 08:51:41 2018 (r332883) @@ -39,11 +39,11 @@ #ifndef _OCS_OS_H #define _OCS_OS_H -typedef struct ocs_softc ocs_t; - /*************************************************************************** * OS specific includes */ +#include "opt_stack.h" + #include #include #include @@ -78,6 +78,8 @@ typedef struct ocs_softc ocs_t; #include #include +#include /* for debug of memory allocations */ + /* OCS_OS_MAX_ISR_TIME_MSEC - maximum time driver code should spend in an interrupt * or kernel thread context without yielding */ @@ -151,6 +153,8 @@ typedef struct ocs_softc ocs_t; /*************************************************************************** * Platform specific operations */ + +typedef struct ocs_softc ocs_t; /** * @ingroup os From owner-svn-src-stable-11@freebsd.org Mon Apr 23 09:01:26 2018 Return-Path: Delivered-To: svn-src-stable-11@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 ED61DFA98E5; Mon, 23 Apr 2018 09:01:25 +0000 (UTC) (envelope-from ram@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 9A49A874BD; Mon, 23 Apr 2018 09:01:25 +0000 (UTC) (envelope-from ram@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 9558821FCB; Mon, 23 Apr 2018 09:01:25 +0000 (UTC) (envelope-from ram@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id w3N91PH8058114; Mon, 23 Apr 2018 09:01:25 GMT (envelope-from ram@FreeBSD.org) Received: (from ram@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id w3N91PKm058113; Mon, 23 Apr 2018 09:01:25 GMT (envelope-from ram@FreeBSD.org) Message-Id: <201804230901.w3N91PKm058113@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: ram set sender to ram@FreeBSD.org using -f From: Ram Kishore Vegesna Date: Mon, 23 Apr 2018 09:01:25 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-11@freebsd.org Subject: svn commit: r332884 - stable/11/share/misc X-SVN-Group: stable-11 X-SVN-Commit-Author: ram X-SVN-Commit-Paths: stable/11/share/misc X-SVN-Commit-Revision: 332884 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable-11@freebsd.org X-Mailman-Version: 2.1.25 Precedence: list List-Id: SVN commit messages for only the 11-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 23 Apr 2018 09:01:26 -0000 Author: ram Date: Mon Apr 23 09:01:25 2018 New Revision: 332884 URL: https://svnweb.freebsd.org/changeset/base/332884 Log: MFC r332386, r332430: Updated mentors information. Added entry in the correct section. Approved by: mav Modified: stable/11/share/misc/committers-src.dot Directory Properties: stable/11/ (props changed) Modified: stable/11/share/misc/committers-src.dot ============================================================================== --- stable/11/share/misc/committers-src.dot Mon Apr 23 08:51:41 2018 (r332883) +++ stable/11/share/misc/committers-src.dot Mon Apr 23 09:01:25 2018 (r332884) @@ -282,6 +282,7 @@ pkelsey [label="Patrick Kelsey\pkelsey@FreeBSD.org\n20 pluknet [label="Sergey Kandaurov\npluknet@FreeBSD.org\n2010/10/05"] ps [label="Paul Saab\nps@FreeBSD.org\n2000/02/23"] qingli [label="Qing Li\nqingli@FreeBSD.org\n2005/04/13"] +ram [label="Ram Kishore Vegesna\nram@FreeBSD.org\n2018/04/04"] ray [label="Aleksandr Rybalko\nray@FreeBSD.org\n2011/05/25"] rdivacky [label="Roman Divacky\nrdivacky@FreeBSD.org\n2008/03/13"] remko [label="Remko Lodder\nremko@FreeBSD.org\n2007/02/23"] @@ -629,6 +630,7 @@ kan -> kib ken -> asomers ken -> chuck +ken -> ram ken -> slm kib -> ae @@ -671,6 +673,7 @@ markm -> sheldonh mav -> ae mav -> eugen +mav -> ram mdf -> gleb From owner-svn-src-stable-11@freebsd.org Mon Apr 23 13:47:31 2018 Return-Path: Delivered-To: svn-src-stable-11@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 1CAAAFBD700; Mon, 23 Apr 2018 13:47:31 +0000 (UTC) (envelope-from gjb@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 C4E8D7FCBB; Mon, 23 Apr 2018 13:47:30 +0000 (UTC) (envelope-from gjb@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 BF7F425059; Mon, 23 Apr 2018 13:47:30 +0000 (UTC) (envelope-from gjb@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id w3NDlUao000615; Mon, 23 Apr 2018 13:47:30 GMT (envelope-from gjb@FreeBSD.org) Received: (from gjb@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id w3NDlUWh000611; Mon, 23 Apr 2018 13:47:30 GMT (envelope-from gjb@FreeBSD.org) Message-Id: <201804231347.w3NDlUWh000611@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: gjb set sender to gjb@FreeBSD.org using -f From: Glen Barber Date: Mon, 23 Apr 2018 13:47:30 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-11@freebsd.org Subject: svn commit: r332888 - in stable: 10/release/arm 11/release/arm X-SVN-Group: stable-11 X-SVN-Commit-Author: gjb X-SVN-Commit-Paths: in stable: 10/release/arm 11/release/arm X-SVN-Commit-Revision: 332888 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable-11@freebsd.org X-Mailman-Version: 2.1.25 Precedence: list List-Id: SVN commit messages for only the 11-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 23 Apr 2018 13:47:31 -0000 Author: gjb Date: Mon Apr 23 13:47:29 2018 New Revision: 332888 URL: https://svnweb.freebsd.org/changeset/base/332888 Log: MFC r332674: Increase the msdosfs partition size on arm SoC images where the current size may not be sufficiently large for development and/or testing. PR: 227548 Sponsored by: The FreeBSD Foundation Modified: stable/11/release/arm/BEAGLEBONE.conf stable/11/release/arm/GUMSTIX.conf stable/11/release/arm/PANDABOARD.conf stable/11/release/arm/RPI-B.conf Directory Properties: stable/11/ (props changed) Changes in other areas also in this revision: Modified: stable/10/release/arm/BEAGLEBONE.conf stable/10/release/arm/GUMSTIX.conf stable/10/release/arm/PANDABOARD.conf stable/10/release/arm/RPI-B.conf Directory Properties: stable/10/ (props changed) Modified: stable/11/release/arm/BEAGLEBONE.conf ============================================================================== --- stable/11/release/arm/BEAGLEBONE.conf Mon Apr 23 12:23:05 2018 (r332887) +++ stable/11/release/arm/BEAGLEBONE.conf Mon Apr 23 13:47:29 2018 (r332888) @@ -7,7 +7,7 @@ EMBEDDED_TARGET_ARCH="armv6" EMBEDDED_TARGET="arm" EMBEDDEDBUILD=1 EMBEDDEDPORTS="sysutils/u-boot-beaglebone" -FAT_SIZE="2m" +FAT_SIZE="41m" FAT_TYPE="12" IMAGE_SIZE="1G" KERNEL="BEAGLEBONE" Modified: stable/11/release/arm/GUMSTIX.conf ============================================================================== --- stable/11/release/arm/GUMSTIX.conf Mon Apr 23 12:23:05 2018 (r332887) +++ stable/11/release/arm/GUMSTIX.conf Mon Apr 23 13:47:29 2018 (r332888) @@ -7,7 +7,7 @@ EMBEDDED_TARGET_ARCH="arm" EMBEDDED_TARGET="arm" EMBEDDEDBUILD=1 EMBEDDEDPORTS="sysutils/u-boot-duovero" -FAT_SIZE="2m" +FAT_SIZE="41m" FAT_TYPE="12" IMAGE_SIZE="1G" KERNEL="GUMSTIX" Modified: stable/11/release/arm/PANDABOARD.conf ============================================================================== --- stable/11/release/arm/PANDABOARD.conf Mon Apr 23 12:23:05 2018 (r332887) +++ stable/11/release/arm/PANDABOARD.conf Mon Apr 23 13:47:29 2018 (r332888) @@ -7,7 +7,7 @@ EMBEDDED_TARGET_ARCH="armv6" EMBEDDED_TARGET="arm" EMBEDDEDBUILD=1 EMBEDDEDPORTS="sysutils/u-boot-pandaboard" -FAT_SIZE="2m" +FAT_SIZE="41m" FAT_TYPE="12" IMAGE_SIZE="1G" KERNEL="PANDABOARD" Modified: stable/11/release/arm/RPI-B.conf ============================================================================== --- stable/11/release/arm/RPI-B.conf Mon Apr 23 12:23:05 2018 (r332887) +++ stable/11/release/arm/RPI-B.conf Mon Apr 23 13:47:29 2018 (r332888) @@ -7,7 +7,7 @@ EMBEDDED_TARGET_ARCH="armv6" EMBEDDED_TARGET="arm" EMBEDDEDBUILD=1 EMBEDDEDPORTS="sysutils/u-boot-rpi sysutils/rpi-firmware" -FAT_SIZE="17m" +FAT_SIZE="41m" FAT_TYPE="16" IMAGE_SIZE="1G" KERNEL="RPI-B" From owner-svn-src-stable-11@freebsd.org Mon Apr 23 14:22:17 2018 Return-Path: Delivered-To: svn-src-stable-11@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 60FD0F89D3F; Mon, 23 Apr 2018 14:22:17 +0000 (UTC) (envelope-from jtl@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 0EDD168F04; Mon, 23 Apr 2018 14:22:17 +0000 (UTC) (envelope-from jtl@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 0700625686; Mon, 23 Apr 2018 14:22:17 +0000 (UTC) (envelope-from jtl@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id w3NEMGhO019418; Mon, 23 Apr 2018 14:22:16 GMT (envelope-from jtl@FreeBSD.org) Received: (from jtl@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id w3NEMG5q019417; Mon, 23 Apr 2018 14:22:16 GMT (envelope-from jtl@FreeBSD.org) Message-Id: <201804231422.w3NEMG5q019417@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: jtl set sender to jtl@FreeBSD.org using -f From: "Jonathan T. Looney" Date: Mon, 23 Apr 2018 14:22:16 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-11@freebsd.org Subject: svn commit: r332889 - stable/11/sys/netinet X-SVN-Group: stable-11 X-SVN-Commit-Author: jtl X-SVN-Commit-Paths: stable/11/sys/netinet X-SVN-Commit-Revision: 332889 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable-11@freebsd.org X-Mailman-Version: 2.1.25 Precedence: list List-Id: SVN commit messages for only the 11-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 23 Apr 2018 14:22:17 -0000 Author: jtl Date: Mon Apr 23 14:22:16 2018 New Revision: 332889 URL: https://svnweb.freebsd.org/changeset/base/332889 Log: MFC r331745 (by np): Fix RSS build (broken in r331309). Sponsored by: Chelsio Communications PR: 227691 Pointy-hat to: jtl Modified: stable/11/sys/netinet/in_pcb.c Directory Properties: stable/11/ (props changed) Modified: stable/11/sys/netinet/in_pcb.c ============================================================================== --- stable/11/sys/netinet/in_pcb.c Mon Apr 23 13:47:29 2018 (r332888) +++ stable/11/sys/netinet/in_pcb.c Mon Apr 23 14:22:16 2018 (r332889) @@ -1807,9 +1807,9 @@ in_pcblookup_group(struct inpcbinfo *pcbinfo, struct i found: if (lookupflags & INPLOOKUP_WLOCKPCB) - locked = TRY_INP_WLOCK(inp); + locked = INP_TRY_WLOCK(inp); else if (lookupflags & INPLOOKUP_RLOCKPCB) - locked = TRY_INP_RLOCK(inp); + locked = INP_TRY_RLOCK(inp); else panic("%s: locking bug", __func__); if (!locked) From owner-svn-src-stable-11@freebsd.org Tue Apr 24 00:47:18 2018 Return-Path: Delivered-To: svn-src-stable-11@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 CC77FFAF9A5; Tue, 24 Apr 2018 00:47:18 +0000 (UTC) (envelope-from emaste@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 6D824763B2; Tue, 24 Apr 2018 00:47:18 +0000 (UTC) (envelope-from emaste@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 5DC983DC6; Tue, 24 Apr 2018 00:47:18 +0000 (UTC) (envelope-from emaste@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id w3O0lIXK035664; Tue, 24 Apr 2018 00:47:18 GMT (envelope-from emaste@FreeBSD.org) Received: (from emaste@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id w3O0lI6V035663; Tue, 24 Apr 2018 00:47:18 GMT (envelope-from emaste@FreeBSD.org) Message-Id: <201804240047.w3O0lI6V035663@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: emaste set sender to emaste@FreeBSD.org using -f From: Ed Maste Date: Tue, 24 Apr 2018 00:47:18 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-11@freebsd.org Subject: svn commit: r332899 - stable/11/lib/clang/include/lld/Common X-SVN-Group: stable-11 X-SVN-Commit-Author: emaste X-SVN-Commit-Paths: stable/11/lib/clang/include/lld/Common X-SVN-Commit-Revision: 332899 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable-11@freebsd.org X-Mailman-Version: 2.1.25 Precedence: list List-Id: SVN commit messages for only the 11-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 24 Apr 2018 00:47:19 -0000 Author: emaste Date: Tue Apr 24 00:47:17 2018 New Revision: 332899 URL: https://svnweb.freebsd.org/changeset/base/332899 Log: MFC r332649: lld: add a __FreeBSD_version-style identifier to version This will faciliate a WITH_SYSTEM_LINKER option. MFC r332803: lld: use correct number of digits in __FreeBSD_version-style ID __FreeBSD_version-style IDs should have 5 digits following the major. Also, use 11xxxxx for stable/11. Sponsored by: The FreeBSD Foundation Modified: stable/11/lib/clang/include/lld/Common/Version.inc Directory Properties: stable/11/ (props changed) Modified: stable/11/lib/clang/include/lld/Common/Version.inc ============================================================================== --- stable/11/lib/clang/include/lld/Common/Version.inc Mon Apr 23 23:07:57 2018 (r332898) +++ stable/11/lib/clang/include/lld/Common/Version.inc Tue Apr 24 00:47:17 2018 (r332899) @@ -4,5 +4,7 @@ #define LLD_VERSION_STRING "6.0.0" #define LLD_VERSION_MAJOR 6 #define LLD_VERSION_MINOR 0 -#define LLD_REVISION_STRING "326565" + #define LLD_REPOSITORY_STRING "FreeBSD" +// - +#define LLD_REVISION_STRING "326565-1100001" From owner-svn-src-stable-11@freebsd.org Tue Apr 24 03:06:06 2018 Return-Path: Delivered-To: svn-src-stable-11@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 5A873FB5F6E; Tue, 24 Apr 2018 03:06:06 +0000 (UTC) (envelope-from dexuan@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 F1FD175D88; Tue, 24 Apr 2018 03:06:05 +0000 (UTC) (envelope-from dexuan@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 D27E85663; Tue, 24 Apr 2018 03:06:05 +0000 (UTC) (envelope-from dexuan@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id w3O365Ym006302; Tue, 24 Apr 2018 03:06:05 GMT (envelope-from dexuan@FreeBSD.org) Received: (from dexuan@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id w3O365pm006301; Tue, 24 Apr 2018 03:06:05 GMT (envelope-from dexuan@FreeBSD.org) Message-Id: <201804240306.w3O365pm006301@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: dexuan set sender to dexuan@FreeBSD.org using -f From: Dexuan Cui Date: Tue, 24 Apr 2018 03:06:05 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-11@freebsd.org Subject: svn commit: r332903 - stable/11/sys/dev/hyperv/storvsc X-SVN-Group: stable-11 X-SVN-Commit-Author: dexuan X-SVN-Commit-Paths: stable/11/sys/dev/hyperv/storvsc X-SVN-Commit-Revision: 332903 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable-11@freebsd.org X-Mailman-Version: 2.1.25 Precedence: list List-Id: SVN commit messages for only the 11-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 24 Apr 2018 03:06:06 -0000 Author: dexuan Date: Tue Apr 24 03:06:05 2018 New Revision: 332903 URL: https://svnweb.freebsd.org/changeset/base/332903 Log: MFC: 332385 r332385: hyperv/storvsc: storvsc_io_done(): do not use CAM_SEL_TIMEOUT CAM_SEL_TIMEOUT was introduced in https://reviews.freebsd.org/D7521 (r304251), which claimed: "VM shall response to CAM layer with CAM_SEL_TIMEOUT to filter those invalid LUNs. Never use CAM_DEV_NOT_THERE which will block LUN scan for LUN number higher than 7." But it turns out this is not correct: I think what really filters the invalid LUNs in r304251 is that: before r304251, we could set the CAM_REQ_CMP without checking vm_srb->srb_status at all: ccb->ccb_h.status |= CAM_REQ_CMP. r304251 checks vm_srb->srb_status and sets ccb->ccb_h.status properly, so the invalid LUNs are filtered. I changed my code version to r304251 but replaced the CAM_SEL_TIMEOUT with CAM_DEV_NOT_THERE, and I confirmed the invalid LUNs can also be filtered, and I successfully hot-added and hot-removed 8 disks to/from the VM without any issue. CAM_SEL_TIMEOUT has an unwanted side effect -- see cam_periph_error(): For a selection timeout, we consider all of the LUNs on the target to be gone. If the status is CAM_DEV_NOT_THERE, then we only get rid of the device(s) specified by the path in the original CCB. This means: for a VM with a valid LUN on 3:0:0:0, when the VM inquires 3:0:0:1 and the host reports 3:0:0:1 doesn't exist and storvsc returns CAM_SEL_TIMEOUT to the CAM layer, CAM will detech 3:0:0:0 as well: this is the bug I reported recently: https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=226583 PR: 226583 Reviewed by: mav Sponsored by: Microsoft Differential Revision: https://reviews.freebsd.org/D14690 Modified: stable/11/sys/dev/hyperv/storvsc/hv_storvsc_drv_freebsd.c Directory Properties: stable/11/ (props changed) Modified: stable/11/sys/dev/hyperv/storvsc/hv_storvsc_drv_freebsd.c ============================================================================== --- stable/11/sys/dev/hyperv/storvsc/hv_storvsc_drv_freebsd.c Tue Apr 24 01:22:57 2018 (r332902) +++ stable/11/sys/dev/hyperv/storvsc/hv_storvsc_drv_freebsd.c Tue Apr 24 03:06:05 2018 (r332903) @@ -2172,20 +2172,7 @@ storvsc_io_done(struct hv_storvsc_request *reqp) scsi_op_desc(cmd->opcode, NULL)); } } - - /* - * XXX For a selection timeout, all of the LUNs - * on the target will be gone. It works for SCSI - * disks, but does not work for IDE disks. - * - * For CAM_DEV_NOT_THERE, CAM will only get - * rid of the device(s) specified by the path. - */ - if (storvsc_get_storage_type(sc->hs_dev) == - DRIVER_STORVSC) - ccb->ccb_h.status |= CAM_SEL_TIMEOUT; - else - ccb->ccb_h.status |= CAM_DEV_NOT_THERE; + ccb->ccb_h.status |= CAM_DEV_NOT_THERE; } else { ccb->ccb_h.status |= CAM_REQ_CMP; } From owner-svn-src-stable-11@freebsd.org Tue Apr 24 10:07:16 2018 Return-Path: Delivered-To: svn-src-stable-11@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 38223FC2291; Tue, 24 Apr 2018 10:07:16 +0000 (UTC) (envelope-from riggs@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 B162278EA1; Tue, 24 Apr 2018 10:07:14 +0000 (UTC) (envelope-from riggs@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 67BE411B29; Tue, 24 Apr 2018 10:07:13 +0000 (UTC) (envelope-from riggs@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id w3OA7DQt016903; Tue, 24 Apr 2018 10:07:13 GMT (envelope-from riggs@FreeBSD.org) Received: (from riggs@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id w3OA7Dwx016902; Tue, 24 Apr 2018 10:07:13 GMT (envelope-from riggs@FreeBSD.org) Message-Id: <201804241007.w3OA7Dwx016902@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: riggs set sender to riggs@FreeBSD.org using -f From: Thomas Zander Date: Tue, 24 Apr 2018 10:07:13 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-11@freebsd.org Subject: svn commit: r332924 - stable/11/sys/dev/bktr X-SVN-Group: stable-11 X-SVN-Commit-Author: riggs X-SVN-Commit-Paths: stable/11/sys/dev/bktr X-SVN-Commit-Revision: 332924 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable-11@freebsd.org X-Mailman-Version: 2.1.25 Precedence: list List-Id: SVN commit messages for only the 11-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 24 Apr 2018 10:07:16 -0000 Author: riggs (ports committer) Date: Tue Apr 24 10:07:13 2018 New Revision: 332924 URL: https://svnweb.freebsd.org/changeset/base/332924 Log: MFC r332861: Remove unused definition bl_dfp; fix build with bktr compiled into kernel Approved by: cognet Modified: stable/11/sys/dev/bktr/msp34xx.c Directory Properties: stable/11/ (props changed) Modified: stable/11/sys/dev/bktr/msp34xx.c ============================================================================== --- stable/11/sys/dev/bktr/msp34xx.c Tue Apr 24 10:07:07 2018 (r332923) +++ stable/11/sys/dev/bktr/msp34xx.c Tue Apr 24 10:07:13 2018 (r332924) @@ -109,10 +109,6 @@ #define VIDEO_SOUND_LANG2 8 #define DFP_COUNT 0x41 -static const int bl_dfp[] = { - 0x00, 0x01, 0x02, 0x03, 0x06, 0x08, 0x09, 0x0a, - 0x0b, 0x0d, 0x0e, 0x10 -}; struct msp3400c { int simple; From owner-svn-src-stable-11@freebsd.org Tue Apr 24 12:17:29 2018 Return-Path: Delivered-To: svn-src-stable-11@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 84F58FA22B5; Tue, 24 Apr 2018 12:17:29 +0000 (UTC) (envelope-from emaste@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 37F1674BE2; Tue, 24 Apr 2018 12:17:29 +0000 (UTC) (envelope-from emaste@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 1A32E12FAC; Tue, 24 Apr 2018 12:17:29 +0000 (UTC) (envelope-from emaste@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id w3OCHSf6081280; Tue, 24 Apr 2018 12:17:28 GMT (envelope-from emaste@FreeBSD.org) Received: (from emaste@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id w3OCHSex081278; Tue, 24 Apr 2018 12:17:28 GMT (envelope-from emaste@FreeBSD.org) Message-Id: <201804241217.w3OCHSex081278@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: emaste set sender to emaste@FreeBSD.org using -f From: Ed Maste Date: Tue, 24 Apr 2018 12:17:28 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-11@freebsd.org Subject: svn commit: r332929 - stable/11/usr.sbin/pwd_mkdb X-SVN-Group: stable-11 X-SVN-Commit-Author: emaste X-SVN-Commit-Paths: stable/11/usr.sbin/pwd_mkdb X-SVN-Commit-Revision: 332929 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable-11@freebsd.org X-Mailman-Version: 2.1.25 Precedence: list List-Id: SVN commit messages for only the 11-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 24 Apr 2018 12:17:29 -0000 Author: emaste Date: Tue Apr 24 12:17:28 2018 New Revision: 332929 URL: https://svnweb.freebsd.org/changeset/base/332929 Log: pwd_mkdb: add legacy support deprecation notice MFC r332789: pwd_mkdb: warn that legacy support is deprecated (if specified) r283981 switched pwd_mkdb to emit only v4 database entries by default, and introduced a -l (legacy) option emit v3 entries in addition. The commit message claims that legacy support will be removed in 12.0, so emit a warning now if it is used. MFC r332875: pwd_mkdb: add deprecation notice in manpage too Followon to r332789; as reported on the -current and -stable lists and in review D15144 the -l option will be removed before FreeBSD 12.0. Relnotes: Yes Sponsored by: The FreeBSD Foundation Modified: stable/11/usr.sbin/pwd_mkdb/pwd_mkdb.8 stable/11/usr.sbin/pwd_mkdb/pwd_mkdb.c Directory Properties: stable/11/ (props changed) Modified: stable/11/usr.sbin/pwd_mkdb/pwd_mkdb.8 ============================================================================== --- stable/11/usr.sbin/pwd_mkdb/pwd_mkdb.8 Tue Apr 24 10:32:25 2018 (r332928) +++ stable/11/usr.sbin/pwd_mkdb/pwd_mkdb.8 Tue Apr 24 12:17:28 2018 (r332929) @@ -28,7 +28,7 @@ .\" @(#)pwd_mkdb.8 8.1 (Berkeley) 6/6/93 .\" $FreeBSD$ .\" -.Dd February 5, 2014 +.Dd April 24, 2018 .Dt PWD_MKDB 8 .Os .Sh NAME @@ -129,6 +129,11 @@ which enables generation of legacy format .Pq v3 entries. The legacy format entries are endianness dependent. +The +.Fl l +option is deprecated and is not present in +.Fx 12.0 +and later. .Pp The following options may be specified and will affect the generation of legacy entries. Modified: stable/11/usr.sbin/pwd_mkdb/pwd_mkdb.c ============================================================================== --- stable/11/usr.sbin/pwd_mkdb/pwd_mkdb.c Tue Apr 24 10:32:25 2018 (r332928) +++ stable/11/usr.sbin/pwd_mkdb/pwd_mkdb.c Tue Apr 24 12:17:28 2018 (r332929) @@ -164,6 +164,8 @@ main(int argc, char *argv[]) if (argc != 1 || (username && (*username == '+' || *username == '-'))) usage(); + if (lflag) + warnx("legacy (v3) database format support is deprecated"); /* * This could be changed to allow the user to interrupt. From owner-svn-src-stable-11@freebsd.org Tue Apr 24 14:35:39 2018 Return-Path: Delivered-To: svn-src-stable-11@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 C8409FA766C; Tue, 24 Apr 2018 14:35:39 +0000 (UTC) (envelope-from markj@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 7386B73B2F; Tue, 24 Apr 2018 14:35:39 +0000 (UTC) (envelope-from markj@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 6BEB614697; Tue, 24 Apr 2018 14:35:39 +0000 (UTC) (envelope-from markj@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id w3OEZd3j052642; Tue, 24 Apr 2018 14:35:39 GMT (envelope-from markj@FreeBSD.org) Received: (from markj@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id w3OEZdmo052641; Tue, 24 Apr 2018 14:35:39 GMT (envelope-from markj@FreeBSD.org) Message-Id: <201804241435.w3OEZdmo052641@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: markj set sender to markj@FreeBSD.org using -f From: Mark Johnston Date: Tue, 24 Apr 2018 14:35:39 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-11@freebsd.org Subject: svn commit: r332935 - stable/11/sys/vm X-SVN-Group: stable-11 X-SVN-Commit-Author: markj X-SVN-Commit-Paths: stable/11/sys/vm X-SVN-Commit-Revision: 332935 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable-11@freebsd.org X-Mailman-Version: 2.1.25 Precedence: list List-Id: SVN commit messages for only the 11-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 24 Apr 2018 14:35:40 -0000 Author: markj Date: Tue Apr 24 14:35:39 2018 New Revision: 332935 URL: https://svnweb.freebsd.org/changeset/base/332935 Log: MFC r332658: Ensure that m and skip_m belong to the same object. Modified: stable/11/sys/vm/vm_page.c Directory Properties: stable/11/ (props changed) Modified: stable/11/sys/vm/vm_page.c ============================================================================== --- stable/11/sys/vm/vm_page.c Tue Apr 24 14:02:46 2018 (r332934) +++ stable/11/sys/vm/vm_page.c Tue Apr 24 14:35:39 2018 (r332935) @@ -3733,6 +3733,8 @@ vm_page_ps_test(vm_page_t m, int flags, vm_page_t skip int i, npages; object = m->object; + if (skip_m != NULL && skip_m->object != object) + return (false); VM_OBJECT_ASSERT_LOCKED(object); npages = atop(pagesizes[m->psind]); From owner-svn-src-stable-11@freebsd.org Tue Apr 24 15:04:08 2018 Return-Path: Delivered-To: svn-src-stable-11@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 249B1FA8626; Tue, 24 Apr 2018 15:04:08 +0000 (UTC) (envelope-from markj@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 C8E9B7BCD5; Tue, 24 Apr 2018 15:04:07 +0000 (UTC) (envelope-from markj@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 C3DDF14B88; Tue, 24 Apr 2018 15:04:07 +0000 (UTC) (envelope-from markj@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id w3OF47Jc067784; Tue, 24 Apr 2018 15:04:07 GMT (envelope-from markj@FreeBSD.org) Received: (from markj@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id w3OF47FR067782; Tue, 24 Apr 2018 15:04:07 GMT (envelope-from markj@FreeBSD.org) Message-Id: <201804241504.w3OF47FR067782@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: markj set sender to markj@FreeBSD.org using -f From: Mark Johnston Date: Tue, 24 Apr 2018 15:04:07 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-11@freebsd.org Subject: svn commit: r332939 - in stable/11/sys/cddl: contrib/opensolaris/uts/common/dtrace dev/dtrace X-SVN-Group: stable-11 X-SVN-Commit-Author: markj X-SVN-Commit-Paths: in stable/11/sys/cddl: contrib/opensolaris/uts/common/dtrace dev/dtrace X-SVN-Commit-Revision: 332939 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable-11@freebsd.org X-Mailman-Version: 2.1.25 Precedence: list List-Id: SVN commit messages for only the 11-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 24 Apr 2018 15:04:08 -0000 Author: markj Date: Tue Apr 24 15:04:07 2018 New Revision: 332939 URL: https://svnweb.freebsd.org/changeset/base/332939 Log: MFC r332364: Assert that dtrace_probe() doesn't re-enter itself. Modified: stable/11/sys/cddl/contrib/opensolaris/uts/common/dtrace/dtrace.c stable/11/sys/cddl/dev/dtrace/dtrace_cddl.h Directory Properties: stable/11/ (props changed) Modified: stable/11/sys/cddl/contrib/opensolaris/uts/common/dtrace/dtrace.c ============================================================================== --- stable/11/sys/cddl/contrib/opensolaris/uts/common/dtrace/dtrace.c Tue Apr 24 14:55:22 2018 (r332938) +++ stable/11/sys/cddl/contrib/opensolaris/uts/common/dtrace/dtrace.c Tue Apr 24 15:04:07 2018 (r332939) @@ -7116,6 +7116,44 @@ dtrace_store_by_ref(dtrace_difo_t *dp, caddr_t tomax, } /* + * Disables interrupts and sets the per-thread inprobe flag. When DEBUG is + * defined, we also assert that we are not recursing unless the probe ID is an + * error probe. + */ +static dtrace_icookie_t +dtrace_probe_enter(dtrace_id_t id) +{ + dtrace_icookie_t cookie; + + cookie = dtrace_interrupt_disable(); + + /* + * Unless this is an ERROR probe, we are not allowed to recurse in + * dtrace_probe(). Recursing into DTrace probe usually means that a + * function is instrumented that should not have been instrumented or + * that the ordering guarantee of the records will be violated, + * resulting in unexpected output. If there is an exception to this + * assertion, a new case should be added. + */ + ASSERT(curthread->t_dtrace_inprobe == 0 || + id == dtrace_probeid_error); + curthread->t_dtrace_inprobe = 1; + + return (cookie); +} + +/* + * Disables interrupts and clears the per-thread inprobe flag. + */ +static void +dtrace_probe_exit(dtrace_icookie_t cookie) +{ + + curthread->t_dtrace_inprobe = 0; + dtrace_interrupt_enable(cookie); +} + +/* * If you're looking for the epicenter of DTrace, you just found it. This * is the function called by the provider to fire a probe -- from which all * subsequent probe-context DTrace activity emanates. @@ -7149,7 +7187,7 @@ dtrace_probe(dtrace_id_t id, uintptr_t arg0, uintptr_t return; #endif - cookie = dtrace_interrupt_disable(); + cookie = dtrace_probe_enter(id); probe = dtrace_probes[id - 1]; cpuid = curcpu; onintr = CPU_ON_INTR(CPU); @@ -7160,7 +7198,7 @@ dtrace_probe(dtrace_id_t id, uintptr_t arg0, uintptr_t * We have hit in the predicate cache; we know that * this predicate would evaluate to be false. */ - dtrace_interrupt_enable(cookie); + dtrace_probe_exit(cookie); return; } @@ -7172,7 +7210,7 @@ dtrace_probe(dtrace_id_t id, uintptr_t arg0, uintptr_t /* * We don't trace anything if we're panicking. */ - dtrace_interrupt_enable(cookie); + dtrace_probe_exit(cookie); return; } @@ -7858,7 +7896,7 @@ dtrace_probe(dtrace_id_t id, uintptr_t arg0, uintptr_t if (vtime) curthread->t_dtrace_start = dtrace_gethrtime(); - dtrace_interrupt_enable(cookie); + dtrace_probe_exit(cookie); } /* Modified: stable/11/sys/cddl/dev/dtrace/dtrace_cddl.h ============================================================================== --- stable/11/sys/cddl/dev/dtrace/dtrace_cddl.h Tue Apr 24 14:55:22 2018 (r332938) +++ stable/11/sys/cddl/dev/dtrace/dtrace_cddl.h Tue Apr 24 15:04:07 2018 (r332939) @@ -46,6 +46,7 @@ typedef struct kdtrace_proc { typedef struct kdtrace_thread { u_int8_t td_dtrace_stop; /* Indicates a DTrace-desired stop */ u_int8_t td_dtrace_sig; /* Signal sent via DTrace's raise() */ + u_int8_t td_dtrace_inprobe; /* Are we in a probe? */ u_int td_predcache; /* DTrace predicate cache */ u_int64_t td_dtrace_vtime; /* DTrace virtual time */ u_int64_t td_dtrace_start; /* DTrace slice start time */ @@ -97,6 +98,7 @@ typedef struct kdtrace_thread { #define t_dtrace_start td_dtrace->td_dtrace_start #define t_dtrace_stop td_dtrace->td_dtrace_stop #define t_dtrace_sig td_dtrace->td_dtrace_sig +#define t_dtrace_inprobe td_dtrace->td_dtrace_inprobe #define t_predcache td_dtrace->td_predcache #define t_dtrace_ft td_dtrace->td_dtrace_ft #define t_dtrace_on td_dtrace->td_dtrace_on From owner-svn-src-stable-11@freebsd.org Tue Apr 24 16:45:14 2018 Return-Path: Delivered-To: svn-src-stable-11@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 E7051FAB90F; Tue, 24 Apr 2018 16:45:13 +0000 (UTC) (envelope-from ian@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 964F37484E; Tue, 24 Apr 2018 16:45:13 +0000 (UTC) (envelope-from ian@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 9130C15BB6; Tue, 24 Apr 2018 16:45:13 +0000 (UTC) (envelope-from ian@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id w3OGjDCf017647; Tue, 24 Apr 2018 16:45:13 GMT (envelope-from ian@FreeBSD.org) Received: (from ian@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id w3OGjD2I017646; Tue, 24 Apr 2018 16:45:13 GMT (envelope-from ian@FreeBSD.org) Message-Id: <201804241645.w3OGjD2I017646@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: ian set sender to ian@FreeBSD.org using -f From: Ian Lepore Date: Tue, 24 Apr 2018 16:45:13 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-11@freebsd.org Subject: svn commit: r332941 - stable/11/sys/dev/wl X-SVN-Group: stable-11 X-SVN-Commit-Author: ian X-SVN-Commit-Paths: stable/11/sys/dev/wl X-SVN-Commit-Revision: 332941 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable-11@freebsd.org X-Mailman-Version: 2.1.25 Precedence: list List-Id: SVN commit messages for only the 11-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 24 Apr 2018 16:45:14 -0000 Author: ian Date: Tue Apr 24 16:45:13 2018 New Revision: 332941 URL: https://svnweb.freebsd.org/changeset/base/332941 Log: Fix wl(4) after r332288, using the same fix applied in r332331. This driver no longer exists in head, so this is a direct commit to 11-stable. Modified: stable/11/sys/dev/wl/if_wl.c Modified: stable/11/sys/dev/wl/if_wl.c ============================================================================== --- stable/11/sys/dev/wl/if_wl.c Tue Apr 24 15:59:39 2018 (r332940) +++ stable/11/sys/dev/wl/if_wl.c Tue Apr 24 16:45:13 2018 (r332941) @@ -1426,7 +1426,7 @@ wlioctl(struct ifnet *ifp, u_long cmd, caddr_t data) /* read out the number of used cache elements */ case SIOCGWLCITEM: WL_LOCK(sc); - ifr_data_get_ptr(ifr) = (caddr_t) sc->w_sigitems; + ifr->ifr_ifru.ifru_data = (caddr_t) sc->w_sigitems; WL_UNLOCK(sc); break; From owner-svn-src-stable-11@freebsd.org Tue Apr 24 17:00:09 2018 Return-Path: Delivered-To: svn-src-stable-11@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 63A01FABEF2; Tue, 24 Apr 2018 17:00:09 +0000 (UTC) (envelope-from ian@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 0C38977935; Tue, 24 Apr 2018 17:00:09 +0000 (UTC) (envelope-from ian@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 DCE4F15D5B; Tue, 24 Apr 2018 17:00:08 +0000 (UTC) (envelope-from ian@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id w3OH08vs022803; Tue, 24 Apr 2018 17:00:08 GMT (envelope-from ian@FreeBSD.org) Received: (from ian@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id w3OH08v4022796; Tue, 24 Apr 2018 17:00:08 GMT (envelope-from ian@FreeBSD.org) Message-Id: <201804241700.w3OH08v4022796@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: ian set sender to ian@FreeBSD.org using -f From: Ian Lepore Date: Tue, 24 Apr 2018 17:00:08 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-11@freebsd.org Subject: svn commit: r332942 - in stable/11: share/man/man4 sys/dev/spibus sys/modules/spigen sys/sys X-SVN-Group: stable-11 X-SVN-Commit-Author: ian X-SVN-Commit-Paths: in stable/11: share/man/man4 sys/dev/spibus sys/modules/spigen sys/sys X-SVN-Commit-Revision: 332942 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable-11@freebsd.org X-Mailman-Version: 2.1.25 Precedence: list List-Id: SVN commit messages for only the 11-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 24 Apr 2018 17:00:09 -0000 Author: ian Date: Tue Apr 24 17:00:08 2018 New Revision: 332942 URL: https://svnweb.freebsd.org/changeset/base/332942 Log: MFC r331868, r332046, r332194-r332196, r332198, r332219, r332231, r332233, r332240, r332258-r332259, r332261, r332292 r331868: Add opt_platform.h for several modules that have #ifdef FDT in the source. Submitted by: Andre Albsmeier r332046: Add a missing MODULE_DEPEND(). r332194: Add support for writing/changing spi device ivars. The SPI mode (polarity and phase) and the maximum bus speed can be changed. The chip select number cannot be changed, because the device instances which are children of spibus are inherently associated with the chip select number they were instantiated for. r332195: A couple minor improvements to spibus.c... - Change the description string to "SPI bus" (was "spibus bus"). - This is the default driver for a SPI bus, not a generic implementation, so return the probe value that indicates such. - Use device_delete_children() at detach time, instead of a local loop to enumerate the children and detach each one individually. r332196: Return BUS_PROBE_DEFAULT, not zero, because this is not the one driver implementation that must be used, it's just the base system default driver. Also add a comment noting that we're being more liberal about the bus frequency property than the dts binding documents require. r332198: Arrange the list of generated sources as 1-per-line alphbetical, and add the files required when building for FDT-based systems. r332219: Remove the existing identify() hack to force-add a spigen device on FDT-based systems, and instead add proper FDT probe code. Because this driver is freebsd-specific and just provides generic userland access to run spibus transactions, there is no bindings document to mandate a compatible string, so just arbitrarily use "freebsd,spigen". r332231: Generate a spibus_set_[ivarname]() convenience function for each ivar, now that they can be set. r332233: Add an ioctl to get/set the SPI transfer mode. Also, make the bus clock frequency ioctl actually set the corresponding ivar instead of just storing the value locally in the softc (and then not using it for anything). Also, return the correct error code if the ioctl cmd is not recognized. r332240: Add the ioctl definitions for spigen get/set spi mode. Should have been part of r332233. r332258: Don't check for impossible NULL return from malloc(..., M_WAITOK). r332259: Cast the data pointer to the correct type for the data being accessed (as opposed to one that accidentally worked on the one arch I test-compiled for on my first try). Reported by: np@, O. Hartmann Pointy hat: ian@ r332261: Add a manpage for spigen(4). r332292: Allow hinted attachment on FDT-based systems. Instead of returning ENXIO when the FDT data doesn't enable the device instance, return BUS_PROBE_NOWILDCARD, the same as for non-FDT systems. Added: stable/11/share/man/man4/spigen.4 - copied unchanged from r332261, head/share/man/man4/spigen.4 Modified: stable/11/sys/dev/spibus/ofw_spibus.c stable/11/sys/dev/spibus/spibus.c stable/11/sys/dev/spibus/spibusvar.h stable/11/sys/dev/spibus/spigen.c stable/11/sys/modules/spigen/Makefile stable/11/sys/sys/spigenio.h Directory Properties: stable/11/ (props changed) Copied: stable/11/share/man/man4/spigen.4 (from r332261, head/share/man/man4/spigen.4) ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ stable/11/share/man/man4/spigen.4 Tue Apr 24 17:00:08 2018 (r332942, copy of r332261, head/share/man/man4/spigen.4) @@ -0,0 +1,206 @@ +.\" +.\" Copyright (c) 2018 Ian Lepore +.\" All rights reserved. +.\" +.\" Redistribution and use in source and binary forms, with or without +.\" modification, are permitted provided that the following conditions +.\" are met: +.\" +.\" 1. Redistributions of source code must retain the above copyright +.\" notice, this list of conditions and the following disclaimer. +.\" 2. Redistributions in binary form must reproduce the above copyright +.\" notice, this list of conditions and the following disclaimer in the +.\" documentation and/or other materials provided with the distribution. +.\" +.\" THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR +.\" IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES +.\" OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. +.\" IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, +.\" INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT +.\" NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +.\" DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +.\" THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +.\" (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF +.\" THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +.\" +.\" $FreeBSD$ +.\" +.Dd April 7, 2018 +.Dt SPIGEN 4 +.Os +.Sh NAME +.Nm spigen +.Nd SPI generic I/O device driver +.Sh SYNOPSIS +To compile this driver into the kernel, +place the following lines in your +kernel configuration file: +.Bd -ragged -offset indent +.Cd "device spi" +.Cd "device spibus" +.Cd "device spigen" +.Ed +.Pp +Alternatively, to load the driver as a +module at boot time, place the following line in +.Xr loader.conf 5 : +.Bd -literal -offset indent +spigen_load="YES" +.Ed +.Sh DESCRIPTION +The +.Nm +driver provides direct access to a slave device on the SPI bus. +Each instance of a +.Nm +device is associated with a single chip-select +line on the bus, and all I/O performed through that instance is done +with that chip-select line asserted. +.Pp +SPI data transfers are inherently bi-directional; there are not separate +read and write operations. +When commands and data are sent to a device, data also comes back from +the device, although in some cases the data may not be useful (or even +documented or predictable for some devices). +Likewise on a read operation, whatever data is in the buffer at the start +of the operation is sent to (and typically ignored by) the device, with each +outgoing byte then replaced in the buffer by the corresponding incoming byte. +Thus, all buffers passed to the transfer functions are both input and +output buffers. +.Pp +The +.Nm +driver provides access to the SPI slave device with the following +.Xr ioctl 2 +calls, defined in +.In sys/spigenio.h : +.Bl -tag -width indent +.It Dv SPIGENIOC_TRANSFER Pq Vt "struct spigen_transfer" +Transfer a command and optional associated data to/from the device, +using the buffers described by the st_command and st_data fields in the +.Vt spigen_transfer . +Set +.Vt st_data.iov_len +to zero if there is no data associated with the command. +.Bd -literal +struct spigen_transfer { + struct iovec st_command; + struct iovec st_data; +}; +.Ed +.It Dv SPIGENIOC_TRANSFER_MMAPPED Pq Vt "spigen_transfer_mmapped" +Transfer a command and optional associated data to/from the device. +The buffers for the transfer are a previously-mmap'd region. +The length of the command and data within that region are described by the +.Vt stm_command_length +and +.Vt stm_data_length +fields of +.Vt spigen_transfer_mmapped . +If +.Vt stm_data_length +is non-zero, the data appears in the memory region immediately +following the command (that is, at offset +.Vt stm_command_length +from the start of the mapped region). +.Bd -literal +struct spigen_transfer_mmapped { + size_t stm_command_length; + size_t stm_data_length; +}; +.Ed +.It Dv SPIGENIOC_GET_CLOCK_SPEED Pq Vt uint32_t +Get the maximum clock speed (bus frequency in Hertz) to be used +when communicating with this slave device. +.It Dv SPIGENIOC_SET_CLOCK_SPEED Pq Vt uint32_t +Set the maximum clock speed (bus frequency in Hertz) to be used +when communicating with this slave device. +The setting remains in effect for subsequent transfers; it +is not necessary to reset this before each transfer. +The actual bus frequency may be lower due to hardware limitiations +of the SPI bus controller device. +.It Dv SPIGENIOC_GET_SPI_MODE Pq Vt uint32_t +Get the SPI mode (clock polarity and phase) to be used +when communicating with this device. +.It Dv SPIGENIOC_SET_SPI_MODE Pq Vt uint32_t +Set the SPI mode (clock polarity and phase) to be used +when communicating with this device. +The setting remains in effect for subsequent transfers; it +is not necessary to reset this before each transfer. +.El +.Sh HINTS CONFIGURATION +On a +.Xr device.hints 5 +based system, such as +.Li MIPS , +these values are configurable for +.Nm : +.Bl -tag -width indent +.It Va hint.spigen.%d.at +The spibus the +.Nm +instance is attached to. +.It Va hint.spigen.%d.clock +The maximum bus frequency to use when communicating with this device. +Actual bus speed may be lower, depending on the capabilities of the SPI +bus controller hardware. +.It Va hint.spigen.%d.cs +The chip-select number to assert when performing I/O for this device. +Set the high bit (1 << 31) to invert the logic level of the chip select line. +.It Va hint.spigen.%d.mode +The SPI mode (0-3) to use when communicating with this device. +.El +.Sh FDT CONFIGURATION +On an +.Xr fdt 4 +based system, the spigen device is defined as a slave device subnode +of the SPI bus controller node. +All properties documented in the +.Va spibus.txt +bindings document can be used with the +.Nm +device. +The most commonly-used ones are documented below. +.Pp +The following properties are required in the +.Nm +device subnode: +.Bl -tag -width indent +.It Va compatible +Must be the string "freebsd,spigen". +.It Va reg +Chip select address of device. +.It Va spi-max-frequency +The maximum bus frequency to use when communicating with this slave device. +Actual bus speed may be lower, depending on the capabilities of the SPI +bus controller hardware. +.El +.Pp +The following properties are optional for the +.Nm +device subnode: +.Bl -tag -width indent +.It Va spi-cpha +Empty property indicating the slave device requires shifted clock +phase (CPHA) mode. +.It Va spi-cpol +Empty property indicating the slave device requires inverse clock +polarity (CPOL) mode. +.It Va spi-cs-high +Empty property indicating the slave device requires chip select active high. +.El +.Sh FILES +.Bl -tag -width -compact +.It Pa /dev/spigen* +.El +.Sh SEE ALSO +.Xr fdt 4 , +.Xr device.hints 5 +.Sh HISTORY +The +.Nm +driver +appeared in +.Fx 11.0 . +FDT support appeared in +.Fx 11.2 . Modified: stable/11/sys/dev/spibus/ofw_spibus.c ============================================================================== --- stable/11/sys/dev/spibus/ofw_spibus.c Tue Apr 24 16:45:13 2018 (r332941) +++ stable/11/sys/dev/spibus/ofw_spibus.c Tue Apr 24 17:00:08 2018 (r332942) @@ -69,7 +69,7 @@ ofw_spibus_probe(device_t dev) return (ENXIO); device_set_desc(dev, "OFW SPI bus"); - return (0); + return (BUS_PROBE_DEFAULT); } static int @@ -105,6 +105,10 @@ ofw_spibus_attach(device_t dev) /* * Get the maximum clock frequency for device, zero means * use the default bus speed. + * + * XXX Note that the current (2018-04-07) dts bindings say that + * spi-max-frequency is a required property (but says nothing of + * how to interpret a value of zero). */ if (OF_getencprop(child, "spi-max-frequency", &clock, sizeof(clock)) == -1) Modified: stable/11/sys/dev/spibus/spibus.c ============================================================================== --- stable/11/sys/dev/spibus/spibus.c Tue Apr 24 16:45:13 2018 (r332941) +++ stable/11/sys/dev/spibus/spibus.c Tue Apr 24 17:00:08 2018 (r332942) @@ -49,8 +49,9 @@ __FBSDID("$FreeBSD$"); static int spibus_probe(device_t dev) { - device_set_desc(dev, "spibus bus"); - return (BUS_PROBE_GENERIC); + + device_set_desc(dev, "SPI bus"); + return (BUS_PROBE_DEFAULT); } static int @@ -70,16 +71,11 @@ spibus_attach(device_t dev) static int spibus_detach(device_t dev) { - int err, ndevs, i; - device_t *devlist; + int err; if ((err = bus_generic_detach(dev)) != 0) return (err); - if ((err = device_get_children(dev, &devlist, &ndevs)) != 0) - return (err); - for (i = 0; i < ndevs; i++) - device_delete_child(dev, devlist[i]); - free(devlist, M_TEMP); + device_delete_children(dev); return (0); } @@ -160,6 +156,37 @@ spibus_read_ivar(device_t bus, device_t child, int whi return (0); } +static int +spibus_write_ivar(device_t bus, device_t child, int which, uintptr_t value) +{ + struct spibus_ivar *devi = SPIBUS_IVAR(child); + + if (devi == NULL || device_get_parent(child) != bus) + return (EDOOFUS); + + switch (which) { + case SPIBUS_IVAR_CLOCK: + /* Any non-zero value is allowed for max clock frequency. */ + if (value == 0) + return (EINVAL); + devi->clock = (uint32_t)value; + break; + case SPIBUS_IVAR_CS: + /* Chip select cannot be changed. */ + return (EINVAL); + case SPIBUS_IVAR_MODE: + /* Valid SPI modes are 0-3. */ + if (value > 3) + return (EINVAL); + devi->mode = (uint32_t)value; + break; + default: + return (EINVAL); + } + + return (0); +} + static device_t spibus_add_child(device_t dev, u_int order, const char *name, int unit) { @@ -211,6 +238,7 @@ static device_method_t spibus_methods[] = { DEVMETHOD(bus_print_child, spibus_print_child), DEVMETHOD(bus_probe_nomatch, spibus_probe_nomatch), DEVMETHOD(bus_read_ivar, spibus_read_ivar), + DEVMETHOD(bus_write_ivar, spibus_write_ivar), DEVMETHOD(bus_child_pnpinfo_str, spibus_child_pnpinfo_str), DEVMETHOD(bus_child_location_str, spibus_child_location_str), DEVMETHOD(bus_hinted_child, spibus_hinted_child), Modified: stable/11/sys/dev/spibus/spibusvar.h ============================================================================== --- stable/11/sys/dev/spibus/spibusvar.h Tue Apr 24 16:45:13 2018 (r332941) +++ stable/11/sys/dev/spibus/spibusvar.h Tue Apr 24 17:00:08 2018 (r332942) @@ -60,8 +60,14 @@ spibus_get_ ## A(device_t dev, T *t) \ { \ return BUS_READ_IVAR(device_get_parent(dev), dev, \ SPIBUS_IVAR_ ## B, (uintptr_t *) t); \ +} \ +static inline int \ +spibus_set_ ## A(device_t dev, T t) \ +{ \ + return BUS_WRITE_IVAR(device_get_parent(dev), dev, \ + SPIBUS_IVAR_ ## B, (uintptr_t) t); \ } - + SPIBUS_ACCESSOR(cs, CS, uint32_t) SPIBUS_ACCESSOR(mode, MODE, uint32_t) SPIBUS_ACCESSOR(clock, CLOCK, uint32_t) Modified: stable/11/sys/dev/spibus/spigen.c ============================================================================== --- stable/11/sys/dev/spibus/spigen.c Tue Apr 24 16:45:13 2018 (r332941) +++ stable/11/sys/dev/spibus/spigen.c Tue Apr 24 17:00:08 2018 (r332942) @@ -50,7 +50,12 @@ __FBSDID("$FreeBSD$"); #include #include +#include +#ifdef FDT +#include +#endif + #include "spibus_if.h" #define SPIGEN_OPEN (1 << 0) @@ -60,7 +65,6 @@ struct spigen_softc { device_t sc_dev; struct cdev *sc_cdev; struct mtx sc_mtx; - uint32_t sc_clock_speed; uint32_t sc_command_length_max; /* cannot change while mmapped */ uint32_t sc_data_length_max; /* cannot change while mmapped */ vm_object_t sc_mmap_buffer; /* command, then data */ @@ -70,24 +74,27 @@ struct spigen_softc { int sc_flags; }; -#ifdef FDT -static void -spigen_identify(driver_t *driver, device_t parent) -{ - if (device_find_child(parent, "spigen", -1) != NULL) - return; - if (BUS_ADD_CHILD(parent, 0, "spigen", -1) == NULL) - device_printf(parent, "add child failed\n"); -} -#endif - static int spigen_probe(device_t dev) { + int rv; + /* + * By default we only bid to attach if specifically added by our parent + * (usually via hint.spigen.#.at=busname). On FDT systems we bid as the + * default driver based on being configured in the FDT data. + */ + rv = BUS_PROBE_NOWILDCARD; + +#ifdef FDT + if (ofw_bus_status_okay(dev) && + ofw_bus_is_compatible(dev, "freebsd,spigen")) + rv = BUS_PROBE_DEFAULT; +#endif + device_set_desc(dev, "SPI Generic IO"); - return (BUS_PROBE_NOWILDCARD); + return (rv); } static int spigen_open(struct cdev *, int, int, struct thread *); @@ -238,15 +245,9 @@ spigen_transfer(struct cdev *cdev, struct spigen_trans #endif transfer.tx_cmd = transfer.rx_cmd = malloc(st->st_command.iov_len, M_DEVBUF, M_WAITOK); - if (transfer.tx_cmd == NULL) - return (ENOMEM); if (st->st_data.iov_len > 0) { transfer.tx_data = transfer.rx_data = malloc(st->st_data.iov_len, M_DEVBUF, M_WAITOK); - if (transfer.tx_data == NULL) { - free(transfer.tx_cmd, M_DEVBUF); - return (ENOMEM); - } } else transfer.tx_data = transfer.rx_data = NULL; @@ -316,7 +317,6 @@ spigen_ioctl(struct cdev *cdev, u_long cmd, caddr_t da struct thread *td) { device_t dev = cdev->si_drv1; - struct spigen_softc *sc = device_get_softc(dev); int error; switch (cmd) { @@ -327,20 +327,20 @@ spigen_ioctl(struct cdev *cdev, u_long cmd, caddr_t da error = spigen_transfer_mmapped(cdev, (struct spigen_transfer_mmapped *)data); break; case SPIGENIOC_GET_CLOCK_SPEED: - mtx_lock(&sc->sc_mtx); - *(uint32_t *)data = sc->sc_clock_speed; - /* XXX TODO: implement spibus ivar call */ - mtx_unlock(&sc->sc_mtx); - error = 0; + error = spibus_get_clock(dev, (uint32_t *)data); break; case SPIGENIOC_SET_CLOCK_SPEED: - mtx_lock(&sc->sc_mtx); - sc->sc_clock_speed = *(uint32_t *)data; - mtx_unlock(&sc->sc_mtx); - error = 0; + error = spibus_set_clock(dev, *(uint32_t *)data); break; + case SPIGENIOC_GET_SPI_MODE: + error = spibus_get_mode(dev, (uint32_t *)data); + break; + case SPIGENIOC_SET_SPI_MODE: + error = spibus_set_mode(dev, *(uint32_t *)data); + break; default: - error = EOPNOTSUPP; + error = ENOTTY; + break; } return (error); } @@ -439,9 +439,6 @@ static devclass_t spigen_devclass; static device_method_t spigen_methods[] = { /* Device interface */ -#ifdef FDT - DEVMETHOD(device_identify, spigen_identify), -#endif DEVMETHOD(device_probe, spigen_probe), DEVMETHOD(device_attach, spigen_attach), DEVMETHOD(device_detach, spigen_detach), @@ -456,3 +453,4 @@ static driver_t spigen_driver = { }; DRIVER_MODULE(spigen, spibus, spigen_driver, spigen_devclass, 0, 0); +MODULE_DEPEND(spigen, spibus, 1, 1, 1); Modified: stable/11/sys/modules/spigen/Makefile ============================================================================== --- stable/11/sys/modules/spigen/Makefile Tue Apr 24 16:45:13 2018 (r332941) +++ stable/11/sys/modules/spigen/Makefile Tue Apr 24 17:00:08 2018 (r332942) @@ -3,6 +3,16 @@ .PATH: ${SRCTOP}/sys/dev/spibus KMOD= spigen SRCS= spigen.c -SRCS+= device_if.h bus_if.h opt_platform.h spibus_if.h + +# Generated files... +SRCS+= \ + bus_if.h \ + device_if.h \ + opt_platform.h \ + spibus_if.h \ + +.if !empty(OPT_FDT) +SRCS+= ofw_bus_if.h +.endif .include Modified: stable/11/sys/sys/spigenio.h ============================================================================== --- stable/11/sys/sys/spigenio.h Tue Apr 24 16:45:13 2018 (r332941) +++ stable/11/sys/sys/spigenio.h Tue Apr 24 17:00:08 2018 (r332942) @@ -48,5 +48,7 @@ struct spigen_transfer_mmapped { struct spigen_transfer_mmapped) #define SPIGENIOC_GET_CLOCK_SPEED _IOR(SPIGENIOC_BASE, 2, uint32_t) #define SPIGENIOC_SET_CLOCK_SPEED _IOW(SPIGENIOC_BASE, 3, uint32_t) +#define SPIGENIOC_GET_SPI_MODE _IOR(SPIGENIOC_BASE, 4, uint32_t) +#define SPIGENIOC_SET_SPI_MODE _IOW(SPIGENIOC_BASE, 5, uint32_t) #endif /* !_SYS_SPIGENIO_H_ */ From owner-svn-src-stable-11@freebsd.org Tue Apr 24 17:13:32 2018 Return-Path: Delivered-To: svn-src-stable-11@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 1EEA0FAC634; Tue, 24 Apr 2018 17:13:32 +0000 (UTC) (envelope-from ian@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 B4F1A7B5F1; Tue, 24 Apr 2018 17:13:31 +0000 (UTC) (envelope-from ian@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 AA3F11608A; Tue, 24 Apr 2018 17:13:31 +0000 (UTC) (envelope-from ian@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id w3OHDVIB032399; Tue, 24 Apr 2018 17:13:31 GMT (envelope-from ian@FreeBSD.org) Received: (from ian@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id w3OHDVjv032397; Tue, 24 Apr 2018 17:13:31 GMT (envelope-from ian@FreeBSD.org) Message-Id: <201804241713.w3OHDVjv032397@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: ian set sender to ian@FreeBSD.org using -f From: Ian Lepore Date: Tue, 24 Apr 2018 17:13:31 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-11@freebsd.org Subject: svn commit: r332943 - stable/11/usr.sbin/daemon X-SVN-Group: stable-11 X-SVN-Commit-Author: ian X-SVN-Commit-Paths: stable/11/usr.sbin/daemon X-SVN-Commit-Revision: 332943 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable-11@freebsd.org X-Mailman-Version: 2.1.25 Precedence: list List-Id: SVN commit messages for only the 11-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 24 Apr 2018 17:13:32 -0000 Author: ian Date: Tue Apr 24 17:13:31 2018 New Revision: 332943 URL: https://svnweb.freebsd.org/changeset/base/332943 Log: MFC r332518, r332527 r332518: Add an option to daemon(8) to specify a delay between restarts of a supervised program. The existing -r option has a hard-coded delay of one second. This change adds a -R option which takes a delay in seconds. This can be used to prevent log spam and rapid restarts, similar to init(8)'s behavior of adding a delay between rapid restarts when it's supervising a program. r332527: Fix cut-and-pasted line to have the right option letter. Modified: stable/11/usr.sbin/daemon/daemon.8 stable/11/usr.sbin/daemon/daemon.c Directory Properties: stable/11/ (props changed) Modified: stable/11/usr.sbin/daemon/daemon.8 ============================================================================== --- stable/11/usr.sbin/daemon/daemon.8 Tue Apr 24 17:00:08 2018 (r332942) +++ stable/11/usr.sbin/daemon/daemon.8 Tue Apr 24 17:13:31 2018 (r332943) @@ -26,7 +26,7 @@ .\" .\" $FreeBSD$ .\" -.Dd October 22, 2016 +.Dd April 15, 2018 .Dt DAEMON 8 .Os .Sh NAME @@ -44,6 +44,7 @@ .Op Fl s Ar syslog_priority .Op Fl T Ar syslog_tag .Op Fl l Ar syslog_facility +.Op Fl R Ar restart_delay_seconds .Ar command arguments ... .Sh DESCRIPTION The @@ -114,7 +115,11 @@ regardless of whether the .Fl u option is used or not. .It Fl r -Supervise and restart the program if it has been terminated. +Supervise and restart the program after a one-second delay if it has +been terminated. +.It Fl R restart_delay_seconds +Supervise and restart the program after the specified delay +if it has been terminated. .It Fl t Ar title Set the title for the daemon process. The default is the daemonized invocation. Modified: stable/11/usr.sbin/daemon/daemon.c ============================================================================== --- stable/11/usr.sbin/daemon/daemon.c Tue Apr 24 17:00:08 2018 (r332942) +++ stable/11/usr.sbin/daemon/daemon.c Tue Apr 24 17:13:31 2018 (r332943) @@ -99,7 +99,7 @@ main(int argc, char *argv[]) dosyslog = 0; outfn = NULL; title = NULL; - while ((ch = getopt(argc, argv, "cfSp:P:ru:o:s:l:t:l:m:T:")) != -1) { + while ((ch = getopt(argc, argv, "cfSp:P:ru:o:s:l:t:l:m:R:T:")) != -1) { switch (ch) { case 'c': nochdir = 0; @@ -130,6 +130,11 @@ main(int argc, char *argv[]) case 'r': restart = 1; break; + case 'R': + restart = strtol(optarg, &p, 0); + if (p == optarg || restart < 1) + errx(6, "invalid restart delay"); + break; case 's': logpri = get_log_mapping(optarg, prioritynames); if (logpri == -1) @@ -359,7 +364,7 @@ restart: goto exit; } if (restart && !terminate) { - daemon_sleep(1, 0); + daemon_sleep(restart, 0); close(pfd[0]); pfd[0] = -1; goto restart; @@ -558,7 +563,7 @@ usage(void) "usage: daemon [-cfrS] [-p child_pidfile] [-P supervisor_pidfile]\n" " [-u user] [-o output_file] [-t title]\n" " [-l syslog_facility] [-s syslog_priority]\n" - " [-T syslog_tag] [-m output_mask]\n" + " [-T syslog_tag] [-m output_mask] [-R restart_delay_secs]\n" "command arguments ...\n"); exit(1); } From owner-svn-src-stable-11@freebsd.org Tue Apr 24 17:33:30 2018 Return-Path: Delivered-To: svn-src-stable-11@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 AA9C7FACE27; Tue, 24 Apr 2018 17:33:30 +0000 (UTC) (envelope-from benno@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 56A327ED01; Tue, 24 Apr 2018 17:33:30 +0000 (UTC) (envelope-from benno@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 51A03163CC; Tue, 24 Apr 2018 17:33:30 +0000 (UTC) (envelope-from benno@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id w3OHXUTm042364; Tue, 24 Apr 2018 17:33:30 GMT (envelope-from benno@FreeBSD.org) Received: (from benno@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id w3OHXUwP042363; Tue, 24 Apr 2018 17:33:30 GMT (envelope-from benno@FreeBSD.org) Message-Id: <201804241733.w3OHXUwP042363@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: benno set sender to benno@FreeBSD.org using -f From: Benno Rice Date: Tue, 24 Apr 2018 17:33:30 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-11@freebsd.org Subject: svn commit: r332946 - stable/11/usr.bin X-SVN-Group: stable-11 X-SVN-Commit-Author: benno X-SVN-Commit-Paths: stable/11/usr.bin X-SVN-Commit-Revision: 332946 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable-11@freebsd.org X-Mailman-Version: 2.1.25 Precedence: list List-Id: SVN commit messages for only the 11-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 24 Apr 2018 17:33:30 -0000 Author: benno Date: Tue Apr 24 17:33:30 2018 New Revision: 332946 URL: https://svnweb.freebsd.org/changeset/base/332946 Log: MFC r331949, r332437, r332438 r331949: Add the etdump utility for dumping El Torito boot catalog information. This can be used to check existing images but will be used in the future to find EFI ESP images placed in El Torito catalogs so they can be used for hybrid boot purposes. r332427: Check the return value of fseek. r332438: Remove a debugging printf that crept in. Sponsored by: iXsystems, Inc. Modified: stable/11/usr.bin/Makefile Modified: stable/11/usr.bin/Makefile ============================================================================== --- stable/11/usr.bin/Makefile Tue Apr 24 17:31:20 2018 (r332945) +++ stable/11/usr.bin/Makefile Tue Apr 24 17:33:30 2018 (r332946) @@ -41,6 +41,7 @@ SUBDIR= alias \ elfdump \ enigma \ env \ + etdump \ expand \ false \ fetch \ From owner-svn-src-stable-11@freebsd.org Tue Apr 24 17:35:15 2018 Return-Path: Delivered-To: svn-src-stable-11@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 D65E8FACEC7; Tue, 24 Apr 2018 17:35:14 +0000 (UTC) (envelope-from benno@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 8A3237EE93; Tue, 24 Apr 2018 17:35:14 +0000 (UTC) (envelope-from benno@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 84C8F163CE; Tue, 24 Apr 2018 17:35:14 +0000 (UTC) (envelope-from benno@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id w3OHZEtZ042488; Tue, 24 Apr 2018 17:35:14 GMT (envelope-from benno@FreeBSD.org) Received: (from benno@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id w3OHZECo042482; Tue, 24 Apr 2018 17:35:14 GMT (envelope-from benno@FreeBSD.org) Message-Id: <201804241735.w3OHZECo042482@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: benno set sender to benno@FreeBSD.org using -f From: Benno Rice Date: Tue, 24 Apr 2018 17:35:14 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-11@freebsd.org Subject: svn commit: r332947 - stable/11/usr.bin/etdump X-SVN-Group: stable-11 X-SVN-Commit-Author: benno X-SVN-Commit-Paths: stable/11/usr.bin/etdump X-SVN-Commit-Revision: 332947 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable-11@freebsd.org X-Mailman-Version: 2.1.25 Precedence: list List-Id: SVN commit messages for only the 11-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 24 Apr 2018 17:35:15 -0000 Author: benno Date: Tue Apr 24 17:35:13 2018 New Revision: 332947 URL: https://svnweb.freebsd.org/changeset/base/332947 Log: Actually MFC r331949, r332437, r332438 (Previous commit didn't have new files added.) r331949: Add the etdump utility for dumping El Torito boot catalog information. This can be used to check existing images but will be used in the future to find EFI ESP images placed in El Torito catalogs so they can be used for hybrid boot purposes. r332427: Check the return value of fseek. r332438: Remove a debugging printf that crept in. Sponsored by: iXsystems, Inc. Pointy hat to: benno Added: stable/11/usr.bin/etdump/ stable/11/usr.bin/etdump/Makefile (contents, props changed) stable/11/usr.bin/etdump/etdump.1 (contents, props changed) stable/11/usr.bin/etdump/etdump.c (contents, props changed) stable/11/usr.bin/etdump/etdump.h (contents, props changed) stable/11/usr.bin/etdump/output_shell.c (contents, props changed) stable/11/usr.bin/etdump/output_text.c (contents, props changed) Added: stable/11/usr.bin/etdump/Makefile ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ stable/11/usr.bin/etdump/Makefile Tue Apr 24 17:35:13 2018 (r332947) @@ -0,0 +1,14 @@ +# $FreeBSD$ + +PROG= etdump + +MAKEFS_SRC= ${SRCTOP}/usr.sbin/makefs + +CFLAGS+= -I${SRCTOP}/sys/fs/cd9660 -I${MAKEFS_SRC} \ + -I${MAKEFS_SRC}/cd9660 + +.PATH: ${MAKEFS_SRC}/cd9660 + +SRCS= etdump.c output_shell.c output_text.c cd9660_conversion.c + +.include Added: stable/11/usr.bin/etdump/etdump.1 ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ stable/11/usr.bin/etdump/etdump.1 Tue Apr 24 17:35:13 2018 (r332947) @@ -0,0 +1,104 @@ +.\" Copyright (c) 2018 iXsystems, Inc +.\" All rights reserved. +.\" +.\" Redistribution and use in source and binary forms, with or without +.\" modification, are permitted provided that the following conditions +.\" are met: +.\" 1. Redistributions of source code must retain the above copyright +.\" notice, this list of conditions and the following disclaimer. +.\" 2. Redistributions in binary form must reproduce the above copyright +.\" notice, this list of conditions and the following disclaimer in the +.\" documentation and/or other materials provided with the distribution. +.\" +.\" THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND +.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +.\" ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE +.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL +.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS +.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) +.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT +.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY +.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF +.\" SUCH DAMAGE. +.\" +.\" $FreeBSD$ +.\" +.Dd April 3, 2018 +.Dt ETDUMP 8 +.Os +.Sh NAME +.Nm etdump +.Nd Dump El Torito boot catalog information from ISO images +.Sh SYNOPSIS +.Nm +.Op Fl f Ar format +.Op Fl o Ar file +.Ar +.Sh DESCRIPTION +This program reads El Torito boot catalog information from an ISO image and +outputs it in various formats. +It can be used to check the catalog in an image or to output catalog data in +a format that can be used by other tools such as shell scripts. +.Pp +Supported options are: +.Bl -tag -width flag +.It Fl f Ar format Fl -format Ar format +Select the output format. +Supported output formats are: +.Bl -tag -width shell -offset indent +.It Sy text +Human-readable text (default) +.It Sy shell +Each boot entry is emitted as a string suitable for passing to a sh-compatible +eval command. +The variables emitted are: +.Bl -tag -width et_platform -offset indent +.It et_platform +The platform ID from the section header. +Set to 'default' for the initial (default) entry. +.It et_system +The system ID from the boot entry. +.It et_lba +The starting LBA (2048-byte blocks) of the boot image. +.It et_sectors +The number of sectors (512-byte sectors) that comprise the boot image. +.El +.El +.It Fl o Ar file Fl -output Ar file +Write output to +.Ar file . +If '-' is specified then standard out is used. +.El +.Sh EXAMPLES +To see what entries are in a given boot catalog run +.Nm +passing the filename of the image as an argument like so: +.Bd -literal -offset indent +% etdump bootonly.iso +Image in bootonly.iso +Default entry + System i386 + Start LBA 420 (0x1a4), sector count 4 (0x4) + Media type: no emulation + +Section header: efi, final + Section entry + System i386 + Start LBA 20 (0x14), sector count 1600 (0x640) + Media type: no emulation +.Ed +.Pp +To use the output in a shell script a for loop can be used to iterate over the +entries returned using eval: +.Bd -literal -offset indent +for entry in `etdump --format shell bootonly.iso`; do + eval $entry + echo $et_platform $et_system $et_lba $et_sectors +done +.Ed +.Sh HISTORY +The +.Nm +utility first appeared in +.Fx 12.0 . Added: stable/11/usr.bin/etdump/etdump.c ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ stable/11/usr.bin/etdump/etdump.c Tue Apr 24 17:35:13 2018 (r332947) @@ -0,0 +1,269 @@ +/*- + * Copyright (c) 2018 iXsystems, Inc. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + */ + +#include +__FBSDID("$FreeBSD$"); + +#include +#include +#include +#include +#include + +#include "cd9660.h" +#include "cd9660_eltorito.h" + +#include "etdump.h" + +const char * +system_id_string(u_char system_id) +{ + + switch (system_id) { + case ET_SYS_X86: + return ("i386"); + case ET_SYS_PPC: + return ("powerpc"); + case ET_SYS_MAC: + return ("mac"); + case ET_SYS_EFI: + return ("efi"); + default: + return ("invalid"); + } +} + +const char * +media_type_string(u_char media_type) +{ + + switch (media_type) { + case ET_MEDIA_NOEM: + return ("no emulation"); + case ET_MEDIA_12FDD: + return ("1.2MB FDD"); + case ET_MEDIA_144FDD: + return ("1.44MB FDD"); + case ET_MEDIA_288FDD: + return ("2.88MB FDD"); + case ET_MEDIA_HDD: + return ("HDD"); + default: + return ("invalid"); + } +} + +static int +read_sector(FILE *iso, daddr_t sector, char *buffer) +{ + + if (fseek(iso, sector * ISO_DEFAULT_BLOCK_SIZE, SEEK_SET) != 0) { + return (errno); + } + if (fread(buffer, ISO_DEFAULT_BLOCK_SIZE, 1, iso) != 1) { + return (errno); + } + return (0); +} + +static bool +boot_catalog_valid(char *entry) +{ + boot_catalog_validation_entry *ve; + int16_t checksum, sum; + unsigned char *csptr; + size_t i; + + ve = (boot_catalog_validation_entry *)entry; + + checksum = isonum_721(ve->checksum); + cd9660_721(0, ve->checksum); + csptr = (unsigned char *)ve; + + for (i = sum = 0; i < sizeof(*ve); i += 2) { + sum += (int16_t)csptr[i]; + sum += 256 * (int16_t)csptr[i + 1]; + } + if (sum + checksum != 0) { + return (false); + } + + cd9660_721(checksum, ve->checksum); + return (true); +} + +static int +dump_section(char *buffer, size_t offset, FILE *outfile, const char *filename, + struct outputter *outputter) +{ + boot_catalog_section_header *sh; + u_char platform_id; + int i; + size_t entry_offset; + boot_catalog_section_entry *entry; + + sh = (boot_catalog_section_header *)&buffer[offset]; + if (outputter->output_section != NULL) { + outputter->output_section(outfile, filename, sh); + } + + platform_id = sh->platform_id[0]; + + if (outputter->output_entry != NULL) { + for (i = 1; i <= (int)sh->num_section_entries[0]; i++) { + entry_offset = offset + i * ET_BOOT_ENTRY_SIZE; + entry = + (boot_catalog_section_entry *)&buffer[entry_offset]; + outputter->output_entry(outfile, filename, entry, + platform_id, false); + } + } + + return (1 + (int)sh->num_section_entries[0]); +} + +static void +dump_eltorito(FILE *iso, const char *filename, FILE *outfile, + struct outputter *outputter) +{ + char buffer[ISO_DEFAULT_BLOCK_SIZE], *entry; + boot_volume_descriptor *bvd; + daddr_t boot_catalog; + size_t offset; + int entry_count; + + if (read_sector(iso, 17, buffer) != 0) + err(1, "failed to read from image"); + + bvd = (boot_volume_descriptor *)buffer; + if (memcmp(bvd->identifier, ISO_VOLUME_DESCRIPTOR_STANDARD_ID, 5) != 0) + warnx("%s: not a valid ISO", filename); + if (bvd->boot_record_indicator[0] != ISO_VOLUME_DESCRIPTOR_BOOT) + warnx("%s: not an El Torito bootable ISO", filename); + if (memcmp(bvd->boot_system_identifier, ET_ID, 23) != 0) + warnx("%s: not an El Torito bootable ISO", filename); + + boot_catalog = isonum_731(bvd->boot_catalog_pointer); + + if (read_sector(iso, boot_catalog, buffer) != 0) + err(1, "failed to read from image"); + + entry = buffer; + offset = 0; + + if (!boot_catalog_valid(entry)) + warnx("%s: boot catalog checksum is invalid", filename); + + if (outputter->output_image != NULL) + outputter->output_image(outfile, filename, bvd); + + offset += ET_BOOT_ENTRY_SIZE; + entry = &buffer[offset]; + if (outputter->output_entry != NULL) + outputter->output_entry(outfile, filename, + (boot_catalog_section_entry *)entry, 0, true); + + offset += ET_BOOT_ENTRY_SIZE; + + while (offset < ISO_DEFAULT_BLOCK_SIZE) { + entry = &buffer[offset]; + + if ((uint8_t)entry[0] != ET_SECTION_HEADER_MORE && + (uint8_t)entry[0] != ET_SECTION_HEADER_LAST) + break; + + entry_count = dump_section(buffer, offset, outfile, filename, + outputter); + + offset += entry_count * ET_BOOT_ENTRY_SIZE; + } +} + +static void +usage(const char *progname) +{ + char *path; + + path = strdup(progname); + + fprintf(stderr, "usage: %s [-f format] [-o filename] filename [...]\n", + basename(path)); + fprintf(stderr, "\tsupported output formats: shell, text\n"); + exit(1); +} + +int +main(int argc, char **argv) +{ + int ch, i; + FILE *outfile, *iso; + struct outputter *outputter; + + outfile = stdout; + outputter = output_text; + + static struct option longopts[] = { + { "format", required_argument, NULL, 'f' }, + { "output", required_argument, NULL, 'o' }, + { NULL, 0, NULL, 0 }, + }; + + while ((ch = getopt_long(argc, argv, "f:o:", longopts, NULL)) != -1) { + switch (ch) { + case 'f': + if (strcmp(optarg, "shell") == 0) + outputter = output_shell; + else if (strcmp(optarg, "text") == 0) + outputter = output_text; + else + usage(argv[0]); + break; + case 'o': + if (strcmp(optarg, "-") == 0) { + outfile = stdout; + } else if ((outfile = fopen(optarg, "w")) == NULL) { + err(1, "unable to open %s for output", optarg); + } + break; + default: + usage(argv[0]); + } + } + + argc -= optind; + argv += optind; + + for (i = 0; i < argc; i++) { + if (strcmp(argv[i], "-") == 0) { + iso = stdin; + } else { + iso = fopen(argv[i], "r"); + if (iso == NULL) + err(1, "could not open %s", argv[1]); + } + dump_eltorito(iso, argv[i], outfile, outputter); + } +} Added: stable/11/usr.bin/etdump/etdump.h ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ stable/11/usr.bin/etdump/etdump.h Tue Apr 24 17:35:13 2018 (r332947) @@ -0,0 +1,49 @@ +/*- + * Copyright (c) 2018 iXsystems, Inc. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + * + * $FreeBSD$ + */ + +#ifndef _ETDUMP_H_ +#define _ETDUMP_H_ + +struct outputter { + void (*output_image)(FILE *outfile, const char *filename, + boot_volume_descriptor *bvd); + void (*output_section)(FILE *outfile, const char *filename, + boot_catalog_section_header *bcsh); + void (*output_entry)(FILE *outfile, const char *filename, + boot_catalog_section_entry *bcse, + u_char platform_id, bool initial); +}; + +extern struct outputter *output_text; +extern struct outputter *output_shell; + +const char *system_id_string(u_char system_id); +const char *media_type_string(u_char media_type); + +#endif /* _ETDUMP_H_ */ + Added: stable/11/usr.bin/etdump/output_shell.c ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ stable/11/usr.bin/etdump/output_shell.c Tue Apr 24 17:35:13 2018 (r332947) @@ -0,0 +1,69 @@ +/*- + * Copyright (c) 2018 iXsystems, Inc. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + */ + +#include +__FBSDID("$FreeBSD$"); + +#include +#include + +#include "cd9660.h" +#include "cd9660_eltorito.h" + +#include "etdump.h" + +static void +output_entry(FILE *outfile, const char *filename __unused, + boot_catalog_section_entry *bcse, u_char platform_id, bool initial) +{ + const char *platform; + + switch (bcse->boot_indicator[0]) { + case ET_BOOTABLE: + break; + case ET_NOT_BOOTABLE: + default: + return; + } + + if (initial) + platform = "default"; + else + platform = system_id_string(platform_id); + + fprintf(outfile, + "et_platform=%s;et_system=%s;et_lba=%d;et_sectors=%d\n", + platform, system_id_string(bcse->system_type[0]), + isonum_731(bcse->load_rba), isonum_721(bcse->sector_count)); +} + +static struct outputter _output_shell = { + .output_image = NULL, + .output_section = NULL, + .output_entry = output_entry, +}; + +struct outputter *output_shell = &_output_shell; Added: stable/11/usr.bin/etdump/output_text.c ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ stable/11/usr.bin/etdump/output_text.c Tue Apr 24 17:35:13 2018 (r332947) @@ -0,0 +1,97 @@ +/*- + * Copyright (c) 2018 iXsystems, Inc. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + */ + +#include +__FBSDID("$FreeBSD$"); + +#include +#include + +#include "cd9660.h" +#include "cd9660_eltorito.h" + +#include "etdump.h" + +static void +output_image(FILE *outfile, const char *filename, boot_volume_descriptor *bvd __unused) +{ + + fprintf(outfile, "Image in %s\n", filename); +} + +static void +output_section(FILE *outfile, const char *filename __unused, + boot_catalog_section_header *bcsh) +{ + + fprintf(outfile, "\nSection header: %s", + system_id_string(bcsh->platform_id[0])); + + if (bcsh->header_indicator[0] == ET_SECTION_HEADER_LAST) + fprintf(outfile, ", final\n"); + else + fprintf(outfile, "\n"); +} + +static void +output_entry(FILE *outfile, const char *filename __unused, + boot_catalog_section_entry *bcse, u_char platform_id __unused, + bool initial) +{ + const char *indent; + + switch (bcse->boot_indicator[0]) { + case ET_BOOTABLE: + break; + case ET_NOT_BOOTABLE: + default: + return; + } + + if (initial) { + fprintf(outfile, "Default entry\n"); + indent = "\t"; + } else { + fprintf(outfile, "\tSection entry\n"); + indent = "\t\t"; + } + + fprintf(outfile, "%sSystem %s\n", indent, + system_id_string(bcse->system_type[0])); + fprintf(outfile, "%sStart LBA %d (0x%x), sector count %d (0x%x)\n", + indent, isonum_731(bcse->load_rba), isonum_731(bcse->load_rba), + isonum_721(bcse->sector_count), isonum_721(bcse->sector_count)); + fprintf(outfile, "%sMedia type: %s\n", indent, + media_type_string(bcse->media_type[0])); +} + +static struct outputter _output_text = { + .output_image = output_image, + .output_section = output_section, + .output_entry = output_entry, +}; + +struct outputter *output_text = &_output_text; From owner-svn-src-stable-11@freebsd.org Tue Apr 24 17:37:31 2018 Return-Path: Delivered-To: svn-src-stable-11@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 E229EFACF9D; Tue, 24 Apr 2018 17:37:30 +0000 (UTC) (envelope-from lidl@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 93F807F128; Tue, 24 Apr 2018 17:37:30 +0000 (UTC) (envelope-from lidl@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 76285163D1; Tue, 24 Apr 2018 17:37:30 +0000 (UTC) (envelope-from lidl@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id w3OHbUgu042738; Tue, 24 Apr 2018 17:37:30 GMT (envelope-from lidl@FreeBSD.org) Received: (from lidl@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id w3OHbUmj042734; Tue, 24 Apr 2018 17:37:30 GMT (envelope-from lidl@FreeBSD.org) Message-Id: <201804241737.w3OHbUmj042734@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: lidl set sender to lidl@FreeBSD.org using -f From: Kurt Lidl Date: Tue, 24 Apr 2018 17:37:30 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-11@freebsd.org Subject: svn commit: r332948 - stable/11/contrib/top X-SVN-Group: stable-11 X-SVN-Commit-Author: lidl X-SVN-Commit-Paths: stable/11/contrib/top X-SVN-Commit-Revision: 332948 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable-11@freebsd.org X-Mailman-Version: 2.1.25 Precedence: list List-Id: SVN commit messages for only the 11-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 24 Apr 2018 17:37:31 -0000 Author: lidl Date: Tue Apr 24 17:37:29 2018 New Revision: 332948 URL: https://svnweb.freebsd.org/changeset/base/332948 Log: MFC r332671: top: fix warnings from clang/gcc Add includes for and where necessary, and rename a few internal functions to have a "top_" prefix to avoid clashes with standard names from curses.h/termcap.h headers. Top now compiles without warnings on both gcc and clang. Modified: stable/11/contrib/top/display.c stable/11/contrib/top/screen.c stable/11/contrib/top/screen.h stable/11/contrib/top/top.c Directory Properties: stable/11/ (props changed) Modified: stable/11/contrib/top/display.c ============================================================================== --- stable/11/contrib/top/display.c Tue Apr 24 17:35:13 2018 (r332947) +++ stable/11/contrib/top/display.c Tue Apr 24 17:37:29 2018 (r332948) @@ -32,7 +32,9 @@ #include +#include #include +#include #include #include @@ -255,7 +257,7 @@ double *avenrun; register int i; /* i_loadave also clears the screen, since it is first */ - clear(); + top_clear(); /* mpid == -1 implies this system doesn't have an _mpid */ if (mpid != -1) @@ -796,7 +798,7 @@ i_message() } if (next_msg[0] != '\0') { - standout(next_msg); + top_standout(next_msg); msglen = strlen(next_msg); next_msg[0] = '\0'; } @@ -1076,7 +1078,7 @@ caddr_t a1, a2, a3; i = strlen(next_msg); if ((type & MT_delayed) == 0) { - type & MT_standout ? standout(next_msg) : + type & MT_standout ? top_standout(next_msg) : fputs(next_msg, stdout); (void) clear_eol(msglen - i); msglen = i; @@ -1088,7 +1090,7 @@ caddr_t a1, a2, a3; { if ((type & MT_delayed) == 0) { - type & MT_standout ? standout(next_msg) : fputs(next_msg, stdout); + type & MT_standout ? top_standout(next_msg) : fputs(next_msg, stdout); msglen = strlen(next_msg); next_msg[0] = '\0'; } Modified: stable/11/contrib/top/screen.c ============================================================================== --- stable/11/contrib/top/screen.c Tue Apr 24 17:35:13 2018 (r332947) +++ stable/11/contrib/top/screen.c Tue Apr 24 17:37:29 2018 (r332948) @@ -45,6 +45,8 @@ # endif # endif #endif +#include +#include #include "screen.h" #include "boolean.h" @@ -432,10 +434,7 @@ get_screensize() } void -standout(msg) - -char *msg; - +top_standout(char *msg) { if (smart_terminal) { @@ -450,8 +449,7 @@ char *msg; } void -clear() - +top_clear() { if (smart_terminal) { @@ -460,10 +458,7 @@ clear() } int -clear_eol(len) - -int len; - +clear_eol(int len) { if (smart_terminal && !overstrike && len > 0) { @@ -496,12 +491,8 @@ go_home() /* This has to be defined as a subroutine for tputs (instead of a macro) */ -void -putstdout(ch) - -char ch; - +int +putstdout(int ch) { - putchar(ch); + return putchar(ch); } - Modified: stable/11/contrib/top/screen.h ============================================================================== --- stable/11/contrib/top/screen.h Tue Apr 24 17:35:13 2018 (r332947) +++ stable/11/contrib/top/screen.h Tue Apr 24 17:37:29 2018 (r332948) @@ -28,10 +28,10 @@ extern int screen_length; extern int screen_width; /* a function that puts a single character on stdout */ -void putstdout(char ch); +int putstdout(int ch); int clear_eol(int len); -void standout(char *msg); -void clear(void); +void top_standout(char *msg); +void top_clear(void); void go_home(void); void reinit_screen(void); void get_screensize(void); Modified: stable/11/contrib/top/top.c ============================================================================== --- stable/11/contrib/top/top.c Tue Apr 24 17:35:13 2018 (r332947) +++ stable/11/contrib/top/top.c Tue Apr 24 17:37:29 2018 (r332948) @@ -39,6 +39,7 @@ char *copyright = #include #include +#include #include #include #include @@ -79,7 +80,7 @@ int pcpu_stats = No; sigret_t leave(); sigret_t tstop(); #ifdef SIGWINCH -sigret_t winch(); +sigret_t top_winch(int); #endif volatile sig_atomic_t leaveflag; @@ -681,7 +682,7 @@ char *argv[]; (void) signal(SIGQUIT, leave); (void) signal(SIGTSTP, tstop); #ifdef SIGWINCH - (void) signal(SIGWINCH, winch); + (void) signal(SIGWINCH, top_winch); #endif #ifdef SIGRELSE sigrelse(SIGINT); @@ -896,7 +897,7 @@ restart: max_topn = display_resize(); /* reset the signal handler */ - (void) signal(SIGWINCH, winch); + (void) signal(SIGWINCH, top_winch); reset_display(); winchflag = 0; @@ -970,9 +971,9 @@ restart: case CMD_help1: /* help */ case CMD_help2: reset_display(); - clear(); + top_clear(); show_help(); - standout("Hit any key to continue: "); + top_standout("Hit any key to continue: "); fflush(stdout); (void) read(0, &ch, 1); break; @@ -988,9 +989,9 @@ restart: else { reset_display(); - clear(); + top_clear(); show_errors(); - standout("Hit any key to continue: "); + top_standout("Hit any key to continue: "); fflush(stdout); (void) read(0, &ch, 1); } @@ -1299,10 +1300,7 @@ int i; } #ifdef SIGWINCH -sigret_t winch(i) /* SIGWINCH handler */ - -int i; - +sigret_t top_winch(int i) /* SIGWINCH handler */ { winchflag = 1; } From owner-svn-src-stable-11@freebsd.org Tue Apr 24 17:53:29 2018 Return-Path: Delivered-To: svn-src-stable-11@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 A320FFAD8BF; Tue, 24 Apr 2018 17:53:29 +0000 (UTC) (envelope-from benno@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 5CCDB842FF; Tue, 24 Apr 2018 17:53:28 +0000 (UTC) (envelope-from benno@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 5477E1672B; Tue, 24 Apr 2018 17:53:28 +0000 (UTC) (envelope-from benno@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id w3OHrSwU052913; Tue, 24 Apr 2018 17:53:28 GMT (envelope-from benno@FreeBSD.org) Received: (from benno@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id w3OHrS9D052911; Tue, 24 Apr 2018 17:53:28 GMT (envelope-from benno@FreeBSD.org) Message-Id: <201804241753.w3OHrS9D052911@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: benno set sender to benno@FreeBSD.org using -f From: Benno Rice Date: Tue, 24 Apr 2018 17:53:28 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-11@freebsd.org Subject: svn commit: r332952 - stable/11/usr.bin/mkimg X-SVN-Group: stable-11 X-SVN-Commit-Author: benno X-SVN-Commit-Paths: stable/11/usr.bin/mkimg X-SVN-Commit-Revision: 332952 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable-11@freebsd.org X-Mailman-Version: 2.1.25 Precedence: list List-Id: SVN commit messages for only the 11-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 24 Apr 2018 17:53:29 -0000 Author: benno Date: Tue Apr 24 17:53:27 2018 New Revision: 332952 URL: https://svnweb.freebsd.org/changeset/base/332952 Log: MFC r332436, r332440 r332436: Add the ability to specify absolute and relative offsets to size partitions. To create hybrid boot media we want to specify a partition at a known location. This extends the syntax of size partitions to include an optional offset that can be absolute or relative. It also introduces validation to make sure that this hasn't resulted in overlapping partitions. I haven't added this to the file and process partition specifications yet but the mechanics are designed such that if someone comes up with a good way of specifying the offset it will be fairly easy to add in. r332440: Fix a conditional that got mucked up. Sponsored by: iXsystems, Inc. Modified: stable/11/usr.bin/mkimg/mkimg.c stable/11/usr.bin/mkimg/scheme.h Modified: stable/11/usr.bin/mkimg/mkimg.c ============================================================================== --- stable/11/usr.bin/mkimg/mkimg.c Tue Apr 24 17:53:16 2018 (r332951) +++ stable/11/usr.bin/mkimg/mkimg.c Tue Apr 24 17:53:27 2018 (r332952) @@ -35,6 +35,7 @@ __FBSDID("$FreeBSD$"); #include #include #include +#include #include #include #include @@ -170,13 +171,14 @@ usage(const char *why) print_schemes(1); fputc('\n', stderr); fprintf(stderr, " partition specification:\n"); - fprintf(stderr, "\t[/]::\t- empty partition of given " - "size\n"); - fprintf(stderr, "\t[/]:=\t- partition content and size " - "are determined\n\t\t\t\t by the named file\n"); - fprintf(stderr, "\t[/]:-\t- partition content and size " - "are taken from\n\t\t\t\t the output of the command to run\n"); - fprintf(stderr, "\t-\t\t\t- unused partition entry\n"); + fprintf(stderr, "\t[/]::[:[+]]\t- " + "empty partition of given size and\n\t\t\t\t\t" + " optional relative or absolute offset\n"); + fprintf(stderr, "\t[/]:=\t\t- partition content and size " + "are\n\t\t\t\t\t determined by the named file\n"); + fprintf(stderr, "\t[/]:-\t\t- partition content and size " + "are taken\n\t\t\t\t\t from the output of the command to run\n"); + fprintf(stderr, "\t-\t\t\t\t- unused partition entry\n"); fprintf(stderr, "\t where:\n"); fprintf(stderr, "\t\t\t- scheme neutral partition type\n"); fprintf(stderr, "\t\t\t- optional scheme-dependent partition " @@ -397,12 +399,48 @@ capacity_resize(lba_t end) } static void +mkimg_validate(void) +{ + struct part *part, *part2; + lba_t start, end, start2, end2; + int i, j; + + i = 0; + + TAILQ_FOREACH(part, &partlist, link) { + start = part->block; + end = part->block + part->size; + j = i + 1; + part2 = TAILQ_NEXT(part, link); + if (part2 == NULL) + break; + + TAILQ_FOREACH_FROM(part2, &partlist, link) { + start2 = part2->block; + end2 = part2->block + part2->size; + + if ((start >= start2 && start < end2) || + (end > start2 && end <= end2)) { + errx(1, "partition %d overlaps partition %d", + i, j); + } + + j++; + } + + i++; + } +} + +static void mkimg(void) { FILE *fp; struct part *part; - lba_t block; - off_t bytesize; + lba_t block, blkoffset; + off_t bytesize, byteoffset; + char *size, *offset; + bool abs_offset; int error, fd; /* First check partition information */ @@ -413,17 +451,46 @@ mkimg(void) } block = scheme_metadata(SCHEME_META_IMG_START, 0); + abs_offset = false; TAILQ_FOREACH(part, &partlist, link) { - block = scheme_metadata(SCHEME_META_PART_BEFORE, block); - if (verbose) - fprintf(stderr, "partition %d: starting block %llu " - "... ", part->index + 1, (long long)block); - part->block = block; + byteoffset = blkoffset = 0; + abs_offset = false; + + /* Look for an offset. Set size too if we can. */ switch (part->kind) { case PART_KIND_SIZE: - if (expand_number(part->contents, &bytesize) == -1) + offset = part->contents; + size = strsep(&offset, ":"); + if (expand_number(size, &bytesize) == -1) error = errno; + if (offset != NULL) { + if (*offset != '+') + abs_offset = true; + else + offset++; + if (expand_number(offset, &byteoffset) == -1) + error = errno; + } break; + } + + /* Work out exactly where the partition starts. */ + blkoffset = (byteoffset + secsz - 1) / secsz; + if (abs_offset) { + part->block = scheme_metadata(SCHEME_META_PART_ABSOLUTE, + blkoffset); + } else { + block = scheme_metadata(SCHEME_META_PART_BEFORE, + block + blkoffset); + part->block = block; + } + + if (verbose) + fprintf(stderr, "partition %d: starting block %llu " + "... ", part->index + 1, (long long)part->block); + + /* Pull in partition contents, set size if we haven't yet. */ + switch (part->kind) { case PART_KIND_FILE: fd = open(part->contents, O_RDONLY, 0); if (fd != -1) { @@ -449,10 +516,25 @@ mkimg(void) bytesize = part->size * secsz; fprintf(stderr, "size %llu bytes (%llu blocks)\n", (long long)bytesize, (long long)part->size); + if (abs_offset) { + fprintf(stderr, + " location %llu bytes (%llu blocks)\n", + (long long)byteoffset, + (long long)blkoffset); + } else if (blkoffset > 0) { + fprintf(stderr, + " offset %llu bytes (%llu blocks)\n", + (long long)byteoffset, + (long long)blkoffset); + } } - block = scheme_metadata(SCHEME_META_PART_AFTER, - part->block + part->size); + if (!abs_offset) { + block = scheme_metadata(SCHEME_META_PART_AFTER, + part->block + part->size); + } } + + mkimg_validate(); block = scheme_metadata(SCHEME_META_IMG_END, block); error = image_set_size(block); Modified: stable/11/usr.bin/mkimg/scheme.h ============================================================================== --- stable/11/usr.bin/mkimg/scheme.h Tue Apr 24 17:53:16 2018 (r332951) +++ stable/11/usr.bin/mkimg/scheme.h Tue Apr 24 17:53:27 2018 (r332952) @@ -65,10 +65,11 @@ struct mkimg_scheme { const char *description; struct mkimg_alias *aliases; lba_t (*metadata)(u_int, lba_t); -#define SCHEME_META_IMG_START 1 -#define SCHEME_META_IMG_END 2 -#define SCHEME_META_PART_BEFORE 3 -#define SCHEME_META_PART_AFTER 4 +#define SCHEME_META_IMG_START 1 +#define SCHEME_META_IMG_END 2 +#define SCHEME_META_PART_BEFORE 3 +#define SCHEME_META_PART_AFTER 4 +#define SCHEME_META_PART_ABSOLUTE 5 int (*write)(lba_t, void *); u_int nparts; u_int labellen; From owner-svn-src-stable-11@freebsd.org Tue Apr 24 18:10:05 2018 Return-Path: Delivered-To: svn-src-stable-11@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 04EA1FADFF3; Tue, 24 Apr 2018 18:10:05 +0000 (UTC) (envelope-from benno@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 AAB6D683FF; Tue, 24 Apr 2018 18:10:04 +0000 (UTC) (envelope-from benno@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 A522C168DC; Tue, 24 Apr 2018 18:10:04 +0000 (UTC) (envelope-from benno@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id w3OIA4v0058375; Tue, 24 Apr 2018 18:10:04 GMT (envelope-from benno@FreeBSD.org) Received: (from benno@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id w3OIA4cU058374; Tue, 24 Apr 2018 18:10:04 GMT (envelope-from benno@FreeBSD.org) Message-Id: <201804241810.w3OIA4cU058374@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: benno set sender to benno@FreeBSD.org using -f From: Benno Rice Date: Tue, 24 Apr 2018 18:10:04 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-11@freebsd.org Subject: svn commit: r332953 - stable/11/stand/i386/gptboot X-SVN-Group: stable-11 X-SVN-Commit-Author: benno X-SVN-Commit-Paths: stable/11/stand/i386/gptboot X-SVN-Commit-Revision: 332953 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable-11@freebsd.org X-Mailman-Version: 2.1.25 Precedence: list List-Id: SVN commit messages for only the 11-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 24 Apr 2018 18:10:05 -0000 Author: benno Date: Tue Apr 24 18:10:04 2018 New Revision: 332953 URL: https://svnweb.freebsd.org/changeset/base/332953 Log: MFC r332082 Use consistent whitespace. Sponsored by: iXsystems, Inc. Modified: stable/11/stand/i386/gptboot/gptboot.c Directory Properties: stable/11/ (props changed) Modified: stable/11/stand/i386/gptboot/gptboot.c ============================================================================== --- stable/11/stand/i386/gptboot/gptboot.c Tue Apr 24 17:53:27 2018 (r332952) +++ stable/11/stand/i386/gptboot/gptboot.c Tue Apr 24 18:10:04 2018 (r332953) @@ -132,87 +132,93 @@ xfsread(ufs_ino_t inode, void *buf, size_t nbyte) static void bios_getmem(void) { - uint64_t size; + uint64_t size; - /* Parse system memory map */ - v86.ebx = 0; - do { - v86.ctl = V86_FLAGS; - v86.addr = MEM_EXT; /* int 0x15 function 0xe820*/ - v86.eax = 0xe820; - v86.ecx = sizeof(struct bios_smap); - v86.edx = SMAP_SIG; - v86.es = VTOPSEG(&smap); - v86.edi = VTOPOFF(&smap); - v86int(); - if ((v86.efl & 1) || (v86.eax != SMAP_SIG)) - break; - /* look for a low-memory segment that's large enough */ - if ((smap.type == SMAP_TYPE_MEMORY) && (smap.base == 0) && - (smap.length >= (512 * 1024))) - bios_basemem = smap.length; - /* look for the first segment in 'extended' memory */ - if ((smap.type == SMAP_TYPE_MEMORY) && (smap.base == 0x100000)) { - bios_extmem = smap.length; - } + /* Parse system memory map */ + v86.ebx = 0; + do { + v86.ctl = V86_FLAGS; + v86.addr = MEM_EXT; /* int 0x15 function 0xe820*/ + v86.eax = 0xe820; + v86.ecx = sizeof(struct bios_smap); + v86.edx = SMAP_SIG; + v86.es = VTOPSEG(&smap); + v86.edi = VTOPOFF(&smap); + v86int(); + if ((v86.efl & 1) || (v86.eax != SMAP_SIG)) + break; + /* look for a low-memory segment that's large enough */ + if ((smap.type == SMAP_TYPE_MEMORY) && (smap.base == 0) && + (smap.length >= (512 * 1024))) + bios_basemem = smap.length; + /* look for the first segment in 'extended' memory */ + if ((smap.type == SMAP_TYPE_MEMORY) && + (smap.base == 0x100000)) { + bios_extmem = smap.length; + } - /* - * Look for the largest segment in 'extended' memory beyond - * 1MB but below 4GB. - */ - if ((smap.type == SMAP_TYPE_MEMORY) && (smap.base > 0x100000) && - (smap.base < 0x100000000ull)) { - size = smap.length; + /* + * Look for the largest segment in 'extended' memory beyond + * 1MB but below 4GB. + */ + if ((smap.type == SMAP_TYPE_MEMORY) && + (smap.base > 0x100000) && (smap.base < 0x100000000ull)) { + size = smap.length; - /* - * If this segment crosses the 4GB boundary, truncate it. - */ - if (smap.base + size > 0x100000000ull) - size = 0x100000000ull - smap.base; + /* + * If this segment crosses the 4GB boundary, + * truncate it. + */ + if (smap.base + size > 0x100000000ull) + size = 0x100000000ull - smap.base; - if (size > high_heap_size) { - high_heap_size = size; - high_heap_base = smap.base; - } - } - } while (v86.ebx != 0); + if (size > high_heap_size) { + high_heap_size = size; + high_heap_base = smap.base; + } + } + } while (v86.ebx != 0); - /* Fall back to the old compatibility function for base memory */ - if (bios_basemem == 0) { - v86.ctl = 0; - v86.addr = 0x12; /* int 0x12 */ - v86int(); + /* Fall back to the old compatibility function for base memory */ + if (bios_basemem == 0) { + v86.ctl = 0; + v86.addr = 0x12; /* int 0x12 */ + v86int(); - bios_basemem = (v86.eax & 0xffff) * 1024; - } + bios_basemem = (v86.eax & 0xffff) * 1024; + } - /* Fall back through several compatibility functions for extended memory */ - if (bios_extmem == 0) { - v86.ctl = V86_FLAGS; - v86.addr = 0x15; /* int 0x15 function 0xe801*/ - v86.eax = 0xe801; - v86int(); - if (!(v86.efl & 1)) { - bios_extmem = ((v86.ecx & 0xffff) + ((v86.edx & 0xffff) * 64)) * 1024; + /* + * Fall back through several compatibility functions for extended + * memory + */ + if (bios_extmem == 0) { + v86.ctl = V86_FLAGS; + v86.addr = 0x15; /* int 0x15 function 0xe801*/ + v86.eax = 0xe801; + v86int(); + if (!(v86.efl & 1)) { + bios_extmem = ((v86.ecx & 0xffff) + + ((v86.edx & 0xffff) * 64)) * 1024; + } } - } - if (bios_extmem == 0) { - v86.ctl = 0; - v86.addr = 0x15; /* int 0x15 function 0x88*/ - v86.eax = 0x8800; - v86int(); - bios_extmem = (v86.eax & 0xffff) * 1024; - } + if (bios_extmem == 0) { + v86.ctl = 0; + v86.addr = 0x15; /* int 0x15 function 0x88*/ + v86.eax = 0x8800; + v86int(); + bios_extmem = (v86.eax & 0xffff) * 1024; + } - /* - * If we have extended memory and did not find a suitable heap - * region in the SMAP, use the last 3MB of 'extended' memory as a - * high heap candidate. - */ - if (bios_extmem >= HEAP_MIN && high_heap_size < HEAP_MIN) { - high_heap_size = HEAP_MIN; - high_heap_base = bios_extmem + 0x100000 - HEAP_MIN; - } + /* + * If we have extended memory and did not find a suitable heap + * region in the SMAP, use the last 3MB of 'extended' memory as a + * high heap candidate. + */ + if (bios_extmem >= HEAP_MIN && high_heap_size < HEAP_MIN) { + high_heap_size = HEAP_MIN; + high_heap_base = bios_extmem + 0x100000 - HEAP_MIN; + } } static int @@ -371,207 +377,215 @@ exit(int x) static void load(void) { - union { - struct exec ex; - Elf32_Ehdr eh; - } hdr; - static Elf32_Phdr ep[2]; - static Elf32_Shdr es[2]; - caddr_t p; - ufs_ino_t ino; - uint32_t addr, x; - int fmt, i, j; + union { + struct exec ex; + Elf32_Ehdr eh; + } hdr; + static Elf32_Phdr ep[2]; + static Elf32_Shdr es[2]; + caddr_t p; + ufs_ino_t ino; + uint32_t addr, x; + int fmt, i, j; - if (!(ino = lookup(kname))) { - if (!ls) { - printf("%s: No %s on %u:%s(%up%u)\n", BOOTPROG, - kname, dsk.drive & DRV_MASK, dev_nm[dsk.type], dsk.unit, - dsk.part); - } - return; - } - if (xfsread(ino, &hdr, sizeof(hdr))) - return; - if (N_GETMAGIC(hdr.ex) == ZMAGIC) - fmt = 0; - else if (IS_ELF(hdr.eh)) - fmt = 1; - else { - printf("Invalid %s\n", "format"); - return; - } - if (fmt == 0) { - addr = hdr.ex.a_entry & 0xffffff; - p = PTOV(addr); - fs_off = PAGE_SIZE; - if (xfsread(ino, p, hdr.ex.a_text)) - return; - p += roundup2(hdr.ex.a_text, PAGE_SIZE); - if (xfsread(ino, p, hdr.ex.a_data)) - return; - p += hdr.ex.a_data + roundup2(hdr.ex.a_bss, PAGE_SIZE); - bootinfo.bi_symtab = VTOP(p); - memcpy(p, &hdr.ex.a_syms, sizeof(hdr.ex.a_syms)); - p += sizeof(hdr.ex.a_syms); - if (hdr.ex.a_syms) { - if (xfsread(ino, p, hdr.ex.a_syms)) + if (!(ino = lookup(kname))) { + if (!ls) { + printf("%s: No %s on %u:%s(%up%u)\n", BOOTPROG, + kname, dsk.drive & DRV_MASK, dev_nm[dsk.type], + dsk.unit, + dsk.part); + } return; - p += hdr.ex.a_syms; - if (xfsread(ino, p, sizeof(int))) - return; - x = *(uint32_t *)p; - p += sizeof(int); - x -= sizeof(int); - if (xfsread(ino, p, x)) - return; - p += x; } - } else { - fs_off = hdr.eh.e_phoff; - for (j = i = 0; i < hdr.eh.e_phnum && j < 2; i++) { - if (xfsread(ino, ep + j, sizeof(ep[0]))) + if (xfsread(ino, &hdr, sizeof(hdr))) return; - if (ep[j].p_type == PT_LOAD) - j++; - } - for (i = 0; i < 2; i++) { - p = PTOV(ep[i].p_paddr & 0xffffff); - fs_off = ep[i].p_offset; - if (xfsread(ino, p, ep[i].p_filesz)) + if (N_GETMAGIC(hdr.ex) == ZMAGIC) + fmt = 0; + else if (IS_ELF(hdr.eh)) + fmt = 1; + else { + printf("Invalid %s\n", "format"); return; } - p += roundup2(ep[1].p_memsz, PAGE_SIZE); - bootinfo.bi_symtab = VTOP(p); - if (hdr.eh.e_shnum == hdr.eh.e_shstrndx + 3) { - fs_off = hdr.eh.e_shoff + sizeof(es[0]) * - (hdr.eh.e_shstrndx + 1); - if (xfsread(ino, &es, sizeof(es))) - return; - for (i = 0; i < 2; i++) { - memcpy(p, &es[i].sh_size, sizeof(es[i].sh_size)); - p += sizeof(es[i].sh_size); - fs_off = es[i].sh_offset; - if (xfsread(ino, p, es[i].sh_size)) - return; - p += es[i].sh_size; - } + if (fmt == 0) { + addr = hdr.ex.a_entry & 0xffffff; + p = PTOV(addr); + fs_off = PAGE_SIZE; + if (xfsread(ino, p, hdr.ex.a_text)) + return; + p += roundup2(hdr.ex.a_text, PAGE_SIZE); + if (xfsread(ino, p, hdr.ex.a_data)) + return; + p += hdr.ex.a_data + roundup2(hdr.ex.a_bss, PAGE_SIZE); + bootinfo.bi_symtab = VTOP(p); + memcpy(p, &hdr.ex.a_syms, sizeof(hdr.ex.a_syms)); + p += sizeof(hdr.ex.a_syms); + if (hdr.ex.a_syms) { + if (xfsread(ino, p, hdr.ex.a_syms)) + return; + p += hdr.ex.a_syms; + if (xfsread(ino, p, sizeof(int))) + return; + x = *(uint32_t *)p; + p += sizeof(int); + x -= sizeof(int); + if (xfsread(ino, p, x)) + return; + p += x; + } + } else { + fs_off = hdr.eh.e_phoff; + for (j = i = 0; i < hdr.eh.e_phnum && j < 2; i++) { + if (xfsread(ino, ep + j, sizeof(ep[0]))) + return; + if (ep[j].p_type == PT_LOAD) + j++; + } + for (i = 0; i < 2; i++) { + p = PTOV(ep[i].p_paddr & 0xffffff); + fs_off = ep[i].p_offset; + if (xfsread(ino, p, ep[i].p_filesz)) + return; + } + p += roundup2(ep[1].p_memsz, PAGE_SIZE); + bootinfo.bi_symtab = VTOP(p); + if (hdr.eh.e_shnum == hdr.eh.e_shstrndx + 3) { + fs_off = hdr.eh.e_shoff + sizeof(es[0]) * + (hdr.eh.e_shstrndx + 1); + if (xfsread(ino, &es, sizeof(es))) + return; + for (i = 0; i < 2; i++) { + memcpy(p, &es[i].sh_size, + sizeof(es[i].sh_size)); + p += sizeof(es[i].sh_size); + fs_off = es[i].sh_offset; + if (xfsread(ino, p, es[i].sh_size)) + return; + p += es[i].sh_size; + } + } + addr = hdr.eh.e_entry & 0xffffff; } - addr = hdr.eh.e_entry & 0xffffff; - } - bootinfo.bi_esymtab = VTOP(p); - bootinfo.bi_kernelname = VTOP(kname); - bootinfo.bi_bios_dev = dsk.drive; + bootinfo.bi_esymtab = VTOP(p); + bootinfo.bi_kernelname = VTOP(kname); + bootinfo.bi_bios_dev = dsk.drive; #ifdef LOADER_GELI_SUPPORT - geliargs.size = sizeof(geliargs); - explicit_bzero(gelipw, sizeof(gelipw)); - gelibuf = malloc(sizeof(struct keybuf) + (GELI_MAX_KEYS * sizeof(struct keybuf_ent))); - geli_fill_keybuf(gelibuf); - geliargs.notapw = '\0'; - geliargs.keybuf_sentinel = KEYBUF_SENTINEL; - geliargs.keybuf = gelibuf; + geliargs.size = sizeof(geliargs); + explicit_bzero(gelipw, sizeof(gelipw)); + gelibuf = malloc(sizeof(struct keybuf) + + (GELI_MAX_KEYS * sizeof(struct keybuf_ent))); + geli_fill_keybuf(gelibuf); + geliargs.notapw = '\0'; + geliargs.keybuf_sentinel = KEYBUF_SENTINEL; + geliargs.keybuf = gelibuf; #endif - __exec((caddr_t)addr, RB_BOOTINFO | (opts & RBX_MASK), - MAKEBOOTDEV(dev_maj[dsk.type], dsk.part + 1, dsk.unit, 0xff), - KARGS_FLAGS_EXTARG, 0, 0, VTOP(&bootinfo) + __exec((caddr_t)addr, RB_BOOTINFO | (opts & RBX_MASK), + MAKEBOOTDEV(dev_maj[dsk.type], dsk.part + 1, dsk.unit, 0xff), + KARGS_FLAGS_EXTARG, 0, 0, VTOP(&bootinfo) #ifdef LOADER_GELI_SUPPORT - , geliargs + , geliargs #endif - ); + ); } static int parse_cmds(char *cmdstr, int *dskupdated) { - char *arg = cmdstr; - char *ep, *p, *q; - const char *cp; - unsigned int drv; - int c, i, j; + char *arg = cmdstr; + char *ep, *p, *q; + const char *cp; + unsigned int drv; + int c, i, j; - *dskupdated = 0; - while ((c = *arg++)) { - if (c == ' ' || c == '\t' || c == '\n') - continue; - for (p = arg; *p && *p != '\n' && *p != ' ' && *p != '\t'; p++); - ep = p; - if (*p) - *p++ = 0; - if (c == '-') { - while ((c = *arg++)) { - if (c == 'P') { - if (*(uint8_t *)PTOV(0x496) & 0x10) { - cp = "yes"; - } else { - opts |= OPT_SET(RBX_DUAL) | OPT_SET(RBX_SERIAL); - cp = "no"; - } - printf("Keyboard: %s\n", cp); - continue; - } else if (c == 'S') { - j = 0; - while ((unsigned int)(i = *arg++ - '0') <= 9) - j = j * 10 + i; - if (j > 0 && i == -'0') { - comspeed = j; - break; - } - /* Fall through to error below ('S' not in optstr[]). */ + *dskupdated = 0; + while ((c = *arg++)) { + if (c == ' ' || c == '\t' || c == '\n') + continue; + for (p = arg; *p && *p != '\n' && *p != ' ' && *p != '\t'; p++); + ep = p; + if (*p) + *p++ = 0; + if (c == '-') { + while ((c = *arg++)) { + if (c == 'P') { + if (*(uint8_t *)PTOV(0x496) & 0x10) { + cp = "yes"; + } else { + opts |= OPT_SET(RBX_DUAL) | + OPT_SET(RBX_SERIAL); + cp = "no"; + } + printf("Keyboard: %s\n", cp); + continue; + } else if (c == 'S') { + j = 0; + while ((unsigned int)(i = *arg++ - '0') + <= 9) + j = j * 10 + i; + if (j > 0 && i == -'0') { + comspeed = j; + break; + } + /* + * Fall through to error below + * ('S' not in optstr[]). + */ + } + for (i = 0; c != optstr[i]; i++) + if (i == NOPT - 1) + return -1; + opts ^= OPT_SET(flags[i]); + } + ioctrl = OPT_CHECK(RBX_DUAL) ? (IO_SERIAL|IO_KEYBOARD) : + OPT_CHECK(RBX_SERIAL) ? IO_SERIAL : IO_KEYBOARD; + if (ioctrl & IO_SERIAL) { + if (sio_init(115200 / comspeed) != 0) + ioctrl &= ~IO_SERIAL; + } + } else { + for (q = arg--; *q && *q != '('; q++); + if (*q) { + drv = -1; + if (arg[1] == ':') { + drv = *arg - '0'; + if (drv > 9) + return (-1); + arg += 2; + } + if (q - arg != 2) + return -1; + for (i = 0; arg[0] != dev_nm[i][0] || + arg[1] != dev_nm[i][1]; i++) + if (i == NDEV - 1) + return -1; + dsk.type = i; + arg += 3; + dsk.unit = *arg - '0'; + if (arg[1] != 'p' || dsk.unit > 9) + return -1; + arg += 2; + dsk.part = *arg - '0'; + if (dsk.part < 1 || dsk.part > 9) + return -1; + arg++; + if (arg[0] != ')') + return -1; + arg++; + if (drv == -1) + drv = dsk.unit; + dsk.drive = (dsk.type <= TYPE_MAXHARD + ? DRV_HARD : 0) + drv; + *dskupdated = 1; + } + if ((i = ep - arg)) { + if ((size_t)i >= sizeof(kname)) + return -1; + memcpy(kname, arg, i + 1); + } } - for (i = 0; c != optstr[i]; i++) - if (i == NOPT - 1) - return -1; - opts ^= OPT_SET(flags[i]); - } - ioctrl = OPT_CHECK(RBX_DUAL) ? (IO_SERIAL|IO_KEYBOARD) : - OPT_CHECK(RBX_SERIAL) ? IO_SERIAL : IO_KEYBOARD; - if (ioctrl & IO_SERIAL) { - if (sio_init(115200 / comspeed) != 0) - ioctrl &= ~IO_SERIAL; - } - } else { - for (q = arg--; *q && *q != '('; q++); - if (*q) { - drv = -1; - if (arg[1] == ':') { - drv = *arg - '0'; - if (drv > 9) - return (-1); - arg += 2; - } - if (q - arg != 2) - return -1; - for (i = 0; arg[0] != dev_nm[i][0] || - arg[1] != dev_nm[i][1]; i++) - if (i == NDEV - 1) - return -1; - dsk.type = i; - arg += 3; - dsk.unit = *arg - '0'; - if (arg[1] != 'p' || dsk.unit > 9) - return -1; - arg += 2; - dsk.part = *arg - '0'; - if (dsk.part < 1 || dsk.part > 9) - return -1; - arg++; - if (arg[0] != ')') - return -1; - arg++; - if (drv == -1) - drv = dsk.unit; - dsk.drive = (dsk.type <= TYPE_MAXHARD - ? DRV_HARD : 0) + drv; - *dskupdated = 1; - } - if ((i = ep - arg)) { - if ((size_t)i >= sizeof(kname)) - return -1; - memcpy(kname, arg, i + 1); - } + arg = p; } - arg = p; - } - return 0; + return 0; } static int From owner-svn-src-stable-11@freebsd.org Tue Apr 24 18:11:34 2018 Return-Path: Delivered-To: svn-src-stable-11@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 27D2DFAE349; Tue, 24 Apr 2018 18:11:34 +0000 (UTC) (envelope-from benno@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 C9575688A1; Tue, 24 Apr 2018 18:11:33 +0000 (UTC) (envelope-from benno@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 C45D916927; Tue, 24 Apr 2018 18:11:33 +0000 (UTC) (envelope-from benno@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id w3OIBXbW061504; Tue, 24 Apr 2018 18:11:33 GMT (envelope-from benno@FreeBSD.org) Received: (from benno@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id w3OIBXDf061503; Tue, 24 Apr 2018 18:11:33 GMT (envelope-from benno@FreeBSD.org) Message-Id: <201804241811.w3OIBXDf061503@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: benno set sender to benno@FreeBSD.org using -f From: Benno Rice Date: Tue, 24 Apr 2018 18:11:33 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-11@freebsd.org Subject: svn commit: r332954 - stable/11/stand/i386/gptboot X-SVN-Group: stable-11 X-SVN-Commit-Author: benno X-SVN-Commit-Paths: stable/11/stand/i386/gptboot X-SVN-Commit-Revision: 332954 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable-11@freebsd.org X-Mailman-Version: 2.1.25 Precedence: list List-Id: SVN commit messages for only the 11-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 24 Apr 2018 18:11:34 -0000 Author: benno Date: Tue Apr 24 18:11:33 2018 New Revision: 332954 URL: https://svnweb.freebsd.org/changeset/base/332954 Log: MFC r332083: Various style(9) fixes. Sponsored by: iXsystems, Inc. Modified: stable/11/stand/i386/gptboot/gptboot.c Directory Properties: stable/11/ (props changed) Modified: stable/11/stand/i386/gptboot/gptboot.c ============================================================================== --- stable/11/stand/i386/gptboot/gptboot.c Tue Apr 24 18:10:04 2018 (r332953) +++ stable/11/stand/i386/gptboot/gptboot.c Tue Apr 24 18:11:33 2018 (r332954) @@ -370,6 +370,7 @@ main(void) void exit(int x) { + while (1); __unreachable(); } @@ -491,12 +492,13 @@ load(void) static int parse_cmds(char *cmdstr, int *dskupdated) { - char *arg = cmdstr; + char *arg; char *ep, *p, *q; const char *cp; unsigned int drv; int c, i, j; + arg = cmdstr; *dskupdated = 0; while ((c = *arg++)) { if (c == ' ' || c == '\t' || c == '\n') @@ -533,7 +535,7 @@ parse_cmds(char *cmdstr, int *dskupdated) } for (i = 0; c != optstr[i]; i++) if (i == NOPT - 1) - return -1; + return (-1); opts ^= OPT_SET(flags[i]); } ioctrl = OPT_CHECK(RBX_DUAL) ? (IO_SERIAL|IO_KEYBOARD) : @@ -553,23 +555,23 @@ parse_cmds(char *cmdstr, int *dskupdated) arg += 2; } if (q - arg != 2) - return -1; + return (-1); for (i = 0; arg[0] != dev_nm[i][0] || arg[1] != dev_nm[i][1]; i++) if (i == NDEV - 1) - return -1; + return (-1); dsk.type = i; arg += 3; dsk.unit = *arg - '0'; if (arg[1] != 'p' || dsk.unit > 9) - return -1; + return (-1); arg += 2; dsk.part = *arg - '0'; if (dsk.part < 1 || dsk.part > 9) - return -1; + return (-1); arg++; if (arg[0] != ')') - return -1; + return (-1); arg++; if (drv == -1) drv = dsk.unit; @@ -579,13 +581,13 @@ parse_cmds(char *cmdstr, int *dskupdated) } if ((i = ep - arg)) { if ((size_t)i >= sizeof(kname)) - return -1; + return (-1); memcpy(kname, arg, i + 1); } } arg = p; } - return 0; + return (0); } static int @@ -617,7 +619,9 @@ vdev_read(void *vdev __unused, void *priv, off_t off, char *p; daddr_t lba; unsigned int nb; - struct dsk *dskp = (struct dsk *) priv; + struct dsk *dskp; + + dskp = (struct dsk *)priv; if ((off & (DEV_BSIZE - 1)) || (bytes & (DEV_BSIZE - 1))) return (-1); From owner-svn-src-stable-11@freebsd.org Tue Apr 24 18:13:29 2018 Return-Path: Delivered-To: svn-src-stable-11@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 778B5FAE522; Tue, 24 Apr 2018 18:13:29 +0000 (UTC) (envelope-from benno@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 25A0368BC8; Tue, 24 Apr 2018 18:13:29 +0000 (UTC) (envelope-from benno@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 2080B16A7A; Tue, 24 Apr 2018 18:13:29 +0000 (UTC) (envelope-from benno@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id w3OIDTX7063082; Tue, 24 Apr 2018 18:13:29 GMT (envelope-from benno@FreeBSD.org) Received: (from benno@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id w3OIDSxA063079; Tue, 24 Apr 2018 18:13:28 GMT (envelope-from benno@FreeBSD.org) Message-Id: <201804241813.w3OIDSxA063079@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: benno set sender to benno@FreeBSD.org using -f From: Benno Rice Date: Tue, 24 Apr 2018 18:13:28 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-11@freebsd.org Subject: svn commit: r332955 - in stable/11: stand/i386 stand/i386/isoboot stand/libsa sys/fs/cd9660 X-SVN-Group: stable-11 X-SVN-Commit-Author: benno X-SVN-Commit-Paths: in stable/11: stand/i386 stand/i386/isoboot stand/libsa sys/fs/cd9660 X-SVN-Commit-Revision: 332955 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable-11@freebsd.org X-Mailman-Version: 2.1.25 Precedence: list List-Id: SVN commit messages for only the 11-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 24 Apr 2018 18:13:29 -0000 Author: benno Date: Tue Apr 24 18:13:28 2018 New Revision: 332955 URL: https://svnweb.freebsd.org/changeset/base/332955 Log: MFC r332084 Add isoboot(8) for booting BIOS systems from HDDs containing ISO images. This is part of a project for adding the ability to create hybrid CD/USB boot images. In the BIOS case when booting from something that isn't a CD we need some extra boot code to actually find our next stage (loader) within an ISO9660 filesystem. This code will reside in a GPT partition (similar to gptboot(8) from which it is derived) and looks for /boot/loader in an ISO9660 filesystem on the image. Sponsored by: iXsystems, Inc. Added: stable/11/stand/i386/isoboot/ - copied from r332084, head/stand/i386/isoboot/ stable/11/stand/libsa/cd9660read.c - copied unchanged from r332084, head/stand/libsa/cd9660read.c Modified: stable/11/stand/i386/Makefile stable/11/sys/fs/cd9660/iso.h Directory Properties: stable/11/ (props changed) Modified: stable/11/stand/i386/Makefile ============================================================================== --- stable/11/stand/i386/Makefile Tue Apr 24 18:11:33 2018 (r332954) +++ stable/11/stand/i386/Makefile Tue Apr 24 18:13:28 2018 (r332955) @@ -5,7 +5,7 @@ NO_OBJ=t .include SUBDIR.yes= mbr pmbr boot0 boot0sio btx boot2 cdboot gptboot \ - libi386 + isoboot libi386 SUBDIR.${MK_LOADER_FIREWIRE}+= libfirewire Copied: stable/11/stand/libsa/cd9660read.c (from r332084, head/stand/libsa/cd9660read.c) ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ stable/11/stand/libsa/cd9660read.c Tue Apr 24 18:13:28 2018 (r332955, copy of r332084, head/stand/libsa/cd9660read.c) @@ -0,0 +1,364 @@ +/* + * Copyright (C) 1996 Wolfgang Solfrank. + * Copyright (C) 1996 TooLs GmbH. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. All advertising materials mentioning features or use of this software + * must display the following acknowledgement: + * This product includes software developed by TooLs GmbH. + * 4. The name of TooLs GmbH may not be used to endorse or promote products + * derived from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY TOOLS GMBH ``AS IS'' AND ANY EXPRESS OR + * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES + * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. + * IN NO EVENT SHALL TOOLS GMBH BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, + * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; + * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, + * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR + * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF + * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +/* Originally derived from libsa/cd9660.c: */ +/* $NetBSD: cd9660.c,v 1.5 1997/06/26 19:11:33 drochner Exp $ */ + +#include +__FBSDID("$FreeBSD$"); + +#include +#include + +static uint64_t cd9660_lookup(const char *); +static ssize_t cd9660_fsread(uint64_t, void *, size_t); + +#define SUSP_CONTINUATION "CE" +#define SUSP_PRESENT "SP" +#define SUSP_STOP "ST" +#define SUSP_EXTREF "ER" +#define RRIP_NAME "NM" + +typedef struct { + ISO_SUSP_HEADER h; + u_char signature [ISODCL ( 5, 6)]; + u_char len_skp [ISODCL ( 7, 7)]; /* 711 */ +} ISO_SUSP_PRESENT; + +static int +read_iso_block(void *buffer, daddr_t blkno) +{ + + return (drvread(&dsk, buffer, blkno * 4, 4)); +} + +static ISO_SUSP_HEADER * +susp_lookup_record(const char *identifier, struct iso_directory_record *dp, + int lenskip) +{ + static char susp_buffer[ISO_DEFAULT_BLOCK_SIZE]; + ISO_SUSP_HEADER *sh; + ISO_RRIP_CONT *shc; + char *p, *end; + int error; + + p = dp->name + isonum_711(dp->name_len) + lenskip; + /* Names of even length have a padding byte after the name. */ + if ((isonum_711(dp->name_len) & 1) == 0) + p++; + end = (char *)dp + isonum_711(dp->length); + while (p + 3 < end) { + sh = (ISO_SUSP_HEADER *)p; + if (bcmp(sh->type, identifier, 2) == 0) + return (sh); + if (bcmp(sh->type, SUSP_STOP, 2) == 0) + return (NULL); + if (bcmp(sh->type, SUSP_CONTINUATION, 2) == 0) { + shc = (ISO_RRIP_CONT *)sh; + error = read_iso_block(susp_buffer, + isonum_733(shc->location)); + + /* Bail if it fails. */ + if (error != 0) + return (NULL); + p = susp_buffer + isonum_733(shc->offset); + end = p + isonum_733(shc->length); + } else { + /* Ignore this record and skip to the next. */ + p += isonum_711(sh->length); + + /* Avoid infinite loops with corrupted file systems */ + if (isonum_711(sh->length) == 0) + return (NULL); + } + } + return (NULL); +} + +static const char * +rrip_lookup_name(struct iso_directory_record *dp, int lenskip, size_t *len) +{ + ISO_RRIP_ALTNAME *p; + + if (len == NULL) + return (NULL); + + p = (ISO_RRIP_ALTNAME *)susp_lookup_record(RRIP_NAME, dp, lenskip); + if (p == NULL) + return (NULL); + switch (*p->flags) { + case ISO_SUSP_CFLAG_CURRENT: + *len = 1; + return ("."); + case ISO_SUSP_CFLAG_PARENT: + *len = 2; + return (".."); + case 0: + *len = isonum_711(p->h.length) - 5; + return ((char *)p + 5); + default: + /* + * We don't handle hostnames or continued names as they are + * too hard, so just bail and use the default name. + */ + return (NULL); + } +} + +static int +rrip_check(struct iso_directory_record *dp, int *lenskip) +{ + ISO_SUSP_PRESENT *sp; + ISO_RRIP_EXTREF *er; + char *p; + + /* First, see if we can find a SP field. */ + p = dp->name + isonum_711(dp->name_len); + if (p > (char *)dp + isonum_711(dp->length)) { + return (0); + } + sp = (ISO_SUSP_PRESENT *)p; + if (bcmp(sp->h.type, SUSP_PRESENT, 2) != 0) { + return (0); + } + if (isonum_711(sp->h.length) != sizeof(ISO_SUSP_PRESENT)) { + return (0); + } + if (sp->signature[0] != 0xbe || sp->signature[1] != 0xef) { + return (0); + } + *lenskip = isonum_711(sp->len_skp); + + /* + * Now look for an ER field. If RRIP is present, then there must + * be at least one of these. It would be more pedantic to walk + * through the list of fields looking for a Rock Ridge ER field. + */ + er = (ISO_RRIP_EXTREF *)susp_lookup_record(SUSP_EXTREF, dp, 0); + if (er == NULL) { + return (0); + } + return (1); +} + +static int +dirmatch(const char *path, struct iso_directory_record *dp, int use_rrip, + int lenskip) +{ + size_t len; + const char *cp = NULL, *name = NULL; + int i, icase; + + if (use_rrip) + cp = rrip_lookup_name(dp, lenskip, &len); + else + cp = NULL; + if (cp == NULL) { + len = isonum_711(dp->name_len); + cp = dp->name; + icase = 1; + } else + icase = 0; + name = cp; + for (i = len; --i >= 0; path++, cp++) { + if (!*path || *path == '/') + break; + if (*path == *cp) + continue; + if (!icase && toupper(*path) == *cp) + continue; + return 0; + } + if (*path && *path != '/') { + return 0; + } + /* + * Allow stripping of trailing dots and the version number. + * Note that this will find the first instead of the last version + * of a file. + */ + if (i >= 0 && (*cp == ';' || *cp == '.')) { + /* This is to prevent matching of numeric extensions */ + if (*cp == '.' && cp[1] != ';') { + return 0; + } + while (--i >= 0) + if (*++cp != ';' && (*cp < '0' || *cp > '9')) { + return 0; + } + } + return 1; +} + +static uint64_t +cd9660_lookup(const char *path) +{ + static char blkbuf[ISO_DEFAULT_BLOCK_SIZE]; + struct iso_primary_descriptor *vd; + struct iso_directory_record rec; + struct iso_directory_record *dp = NULL; + size_t dsize, off; + daddr_t bno, boff; + int rc, first, use_rrip, lenskip; + uint64_t cookie; + + for (bno = 16;; bno++) { + rc = read_iso_block(blkbuf, bno); + vd = (struct iso_primary_descriptor *)blkbuf; + + if (bcmp(vd->id, ISO_STANDARD_ID, sizeof vd->id) != 0) + return (0); + if (isonum_711(vd->type) == ISO_VD_END) + return (0); + if (isonum_711(vd->type) == ISO_VD_PRIMARY) + break; + } + + rec = *(struct iso_directory_record *) vd->root_directory_record; + if (*path == '/') path++; /* eat leading '/' */ + + first = 1; + use_rrip = 0; + while (*path) { + bno = isonum_733(rec.extent) + isonum_711(rec.ext_attr_length); + dsize = isonum_733(rec.size); + off = 0; + boff = 0; + + while (off < dsize) { + if ((off % ISO_DEFAULT_BLOCK_SIZE) == 0) { + rc = read_iso_block(blkbuf, bno + boff); + if (rc) { + return (0); + } + boff++; + dp = (struct iso_directory_record *) blkbuf; + } + if (isonum_711(dp->length) == 0) { + /* skip to next block, if any */ + off = boff * ISO_DEFAULT_BLOCK_SIZE; + continue; + } + + /* See if RRIP is in use. */ + if (first) + use_rrip = rrip_check(dp, &lenskip); + + if (dirmatch(path, dp, use_rrip, + first ? 0 : lenskip)) { + first = 0; + break; + } else + first = 0; + + dp = (struct iso_directory_record *) + ((char *) dp + isonum_711(dp->length)); + /* If the new block has zero length, it is padding. */ + if (isonum_711(dp->length) == 0) { + /* Skip to next block, if any. */ + off = boff * ISO_DEFAULT_BLOCK_SIZE; + continue; + } + off += isonum_711(dp->length); + } + if (off >= dsize) { + return (0); + } + + rec = *dp; + while (*path && *path != '/') /* look for next component */ + path++; + if (*path) path++; /* skip '/' */ + } + + if ((isonum_711(rec.flags) & 2) != 0) { + return (0); + } + + cookie = isonum_733(rec.extent) + isonum_711(rec.ext_attr_length); + cookie = (cookie << 32) | isonum_733(rec.size); + + return (cookie); +} + +static ssize_t +cd9660_fsread(uint64_t cookie, void *buf, size_t nbytes) +{ + static char blkbuf[ISO_DEFAULT_BLOCK_SIZE]; + static daddr_t curstart = 0, curblk = 0; + daddr_t blk, blk_off; + off_t byte_off; + size_t size, remaining, n; + char *s; + + size = cookie & 0xffffffff; + blk = (cookie >> 32) & 0xffffffff; + + /* Make sure we're looking at the right file. */ + if (((blk << 32) | size) != cookie) { + return (-1); + } + + if (blk != curstart) { + curstart = blk; + fs_off = 0; + } + + size -= fs_off; + if (size < nbytes) { + nbytes = size; + } + remaining = nbytes; + s = buf; + + while (remaining > 0) { + blk_off = fs_off >> ISO_DEFAULT_BLOCK_SHIFT; + byte_off = fs_off & (ISO_DEFAULT_BLOCK_SIZE - 1); + + if (curblk != curstart + blk_off) { + curblk = curstart + blk_off; + read_iso_block(blkbuf, curblk); + } + + if (remaining < ISO_DEFAULT_BLOCK_SIZE - byte_off) { + n = remaining; + } else { + n = ISO_DEFAULT_BLOCK_SIZE - byte_off; + } + memcpy(s, blkbuf + byte_off, n); + remaining -= n; + s += n; + + fs_off += n; + } + + return (nbytes); +} Modified: stable/11/sys/fs/cd9660/iso.h ============================================================================== --- stable/11/sys/fs/cd9660/iso.h Tue Apr 24 18:11:33 2018 (r332954) +++ stable/11/sys/fs/cd9660/iso.h Tue Apr 24 18:13:28 2018 (r332955) @@ -93,7 +93,8 @@ struct iso_primary_descriptor { char application_data [ISODCL (884, 1395)]; char unused5 [ISODCL (1396, 2048)]; }; -#define ISO_DEFAULT_BLOCK_SIZE 2048 +#define ISO_DEFAULT_BLOCK_SHIFT 11 +#define ISO_DEFAULT_BLOCK_SIZE (1 << ISO_DEFAULT_BLOCK_SHIFT) /* * Used by Microsoft Joliet extension to ISO9660. Almost the same From owner-svn-src-stable-11@freebsd.org Tue Apr 24 18:19:31 2018 Return-Path: Delivered-To: svn-src-stable-11@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 5F568FAE978; Tue, 24 Apr 2018 18:19:31 +0000 (UTC) (envelope-from benno@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 0CDEF6B066; Tue, 24 Apr 2018 18:19:31 +0000 (UTC) (envelope-from benno@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 04B3D16A83; Tue, 24 Apr 2018 18:19:31 +0000 (UTC) (envelope-from benno@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id w3OIJUvM063334; Tue, 24 Apr 2018 18:19:30 GMT (envelope-from benno@FreeBSD.org) Received: (from benno@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id w3OIJUfk063331; Tue, 24 Apr 2018 18:19:30 GMT (envelope-from benno@FreeBSD.org) Message-Id: <201804241819.w3OIJUfk063331@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: benno set sender to benno@FreeBSD.org using -f From: Benno Rice Date: Tue, 24 Apr 2018 18:19:30 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-11@freebsd.org Subject: svn commit: r332956 - stable/11/stand/common X-SVN-Group: stable-11 X-SVN-Commit-Author: benno X-SVN-Commit-Paths: stable/11/stand/common X-SVN-Commit-Revision: 332956 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable-11@freebsd.org X-Mailman-Version: 2.1.25 Precedence: list List-Id: SVN commit messages for only the 11-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 24 Apr 2018 18:19:31 -0000 Author: benno Date: Tue Apr 24 18:19:30 2018 New Revision: 332956 URL: https://svnweb.freebsd.org/changeset/base/332956 Log: MFC r332085 Add an ISO9660 "partition table" type to loader. When booted via isoboot(8) loader will be handed a disk that simply contains an ISO9660 image. Currently this confuses it greatly. Teach it how to spot that it's in this situation and that ISO9660 has one "partition" covering the whole disk. Sponsored by: iXsystems, Inc. Modified: stable/11/stand/common/disk.c stable/11/stand/common/part.c stable/11/stand/common/part.h Directory Properties: stable/11/ (props changed) Modified: stable/11/stand/common/disk.c ============================================================================== --- stable/11/stand/common/disk.c Tue Apr 24 18:13:28 2018 (r332955) +++ stable/11/stand/common/disk.c Tue Apr 24 18:19:30 2018 (r332956) @@ -270,6 +270,9 @@ disk_open(struct disk_devdesc *dev, uint64_t mediasize dev->d_offset = part.start; od->entrysize = part.end - part.start + 1; } + } else if (ptable_gettype(od->table) == PTABLE_ISO9660) { + dev->d_offset = 0; + od->entrysize = mediasize; } else if (slice >= 0) { /* Try to get information about partition */ if (slice == 0) Modified: stable/11/stand/common/part.c ============================================================================== --- stable/11/stand/common/part.c Tue Apr 24 18:13:28 2018 (r332955) +++ stable/11/stand/common/part.c Tue Apr 24 18:19:30 2018 (r332956) @@ -37,6 +37,8 @@ __FBSDID("$FreeBSD$"); #include #include +#include + #include #include #include @@ -97,6 +99,7 @@ static struct parttypes { { PART_LINUX, "Linux" }, { PART_LINUX_SWAP, "Linux swap" }, { PART_DOS, "DOS/Windows" }, + { PART_ISO9660, "ISO9660" }, }; const char * @@ -603,6 +606,45 @@ out: } #endif /* LOADER_VTOC8_SUPPORT */ +#define cdb2devb(bno) ((bno) * ISO_DEFAULT_BLOCK_SIZE / table->sectorsize) + +static struct ptable * +ptable_iso9660read(struct ptable *table, void *dev, diskread_t dread) +{ + uint8_t *buf; + struct iso_primary_descriptor *vd; + struct pentry *entry; + + buf = malloc(table->sectorsize); + if (buf == NULL) + return (table); + + if (dread(dev, buf, 1, cdb2devb(16)) != 0) { + DEBUG("read failed"); + ptable_close(table); + table = NULL; + goto out; + } + vd = (struct iso_primary_descriptor *)buf; + if (bcmp(vd->id, ISO_STANDARD_ID, sizeof vd->id) != 0) + goto out; + + entry = malloc(sizeof(*entry)); + if (entry == NULL) + goto out; + entry->part.start = 0; + entry->part.end = table->sectors; + entry->part.type = PART_ISO9660; + entry->part.index = 0; + STAILQ_INSERT_TAIL(&table->entries, entry, entry); + + table->type = PTABLE_ISO9660; + +out: + free(buf); + return (table); +} + struct ptable * ptable_open(void *dev, uint64_t sectors, uint16_t sectorsize, diskread_t *dread) @@ -633,6 +675,11 @@ ptable_open(void *dev, uint64_t sectors, uint16_t sect table->sectorsize = sectorsize; table->type = PTABLE_NONE; STAILQ_INIT(&table->entries); + + if (ptable_iso9660read(table, dev, dread) != NULL) { + if (table->type == PTABLE_ISO9660) + goto out; + } #ifdef LOADER_VTOC8_SUPPORT if (be16dec(buf + offsetof(struct vtoc8, magic)) == VTOC_MAGIC) { Modified: stable/11/stand/common/part.h ============================================================================== --- stable/11/stand/common/part.h Tue Apr 24 18:13:28 2018 (r332955) +++ stable/11/stand/common/part.h Tue Apr 24 18:19:30 2018 (r332956) @@ -36,7 +36,8 @@ enum ptable_type { PTABLE_BSD, PTABLE_MBR, PTABLE_GPT, - PTABLE_VTOC8 + PTABLE_VTOC8, + PTABLE_ISO9660 }; enum partition_type { @@ -52,6 +53,7 @@ enum partition_type { PART_LINUX, PART_LINUX_SWAP, PART_DOS, + PART_ISO9660 }; struct ptable_entry { From owner-svn-src-stable-11@freebsd.org Wed Apr 25 01:12:42 2018 Return-Path: Delivered-To: svn-src-stable-11@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 95F24FB98CC; Wed, 25 Apr 2018 01:12:41 +0000 (UTC) (envelope-from benno@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 2684D729AA; Wed, 25 Apr 2018 01:12:41 +0000 (UTC) (envelope-from benno@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 212A42262E; Wed, 25 Apr 2018 01:12:41 +0000 (UTC) (envelope-from benno@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id w3P1CfT2074258; Wed, 25 Apr 2018 01:12:41 GMT (envelope-from benno@FreeBSD.org) Received: (from benno@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id w3P1Cfkg074256; Wed, 25 Apr 2018 01:12:41 GMT (envelope-from benno@FreeBSD.org) Message-Id: <201804250112.w3P1Cfkg074256@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: benno set sender to benno@FreeBSD.org using -f From: Benno Rice Date: Wed, 25 Apr 2018 01:12:41 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-11@freebsd.org Subject: svn commit: r332977 - in stable/11/usr.sbin/makefs: . cd9660 X-SVN-Group: stable-11 X-SVN-Commit-Author: benno X-SVN-Commit-Paths: in stable/11/usr.sbin/makefs: . cd9660 X-SVN-Commit-Revision: 332977 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable-11@freebsd.org X-Mailman-Version: 2.1.25 Precedence: list List-Id: SVN commit messages for only the 11-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 25 Apr 2018 01:12:42 -0000 Author: benno Date: Wed Apr 25 01:12:40 2018 New Revision: 332977 URL: https://svnweb.freebsd.org/changeset/base/332977 Log: MFC r314117 makefs: eliminate global cd9660 structure For diff reduction with NetBSD NetBSD file versions: cd9660.c 1.39 cd9660.h 1.19 cd9660/cd9660_debug.c 1.12 cd9660/cd9660_eltorito.c 1.20 cd9660/cd9660_write.c 1.16 cd9660/iso9660_rrip.c 1.12 cd9660/iso9660_rrip.h 1.6 Sponsored by: iXsystems, Inc. Modified: stable/11/usr.sbin/makefs/cd9660.c stable/11/usr.sbin/makefs/cd9660.h stable/11/usr.sbin/makefs/cd9660/cd9660_debug.c stable/11/usr.sbin/makefs/cd9660/cd9660_eltorito.c stable/11/usr.sbin/makefs/cd9660/cd9660_write.c stable/11/usr.sbin/makefs/cd9660/iso9660_rrip.c stable/11/usr.sbin/makefs/cd9660/iso9660_rrip.h Directory Properties: stable/11/ (props changed) Modified: stable/11/usr.sbin/makefs/cd9660.c ============================================================================== --- stable/11/usr.sbin/makefs/cd9660.c Tue Apr 24 23:22:45 2018 (r332976) +++ stable/11/usr.sbin/makefs/cd9660.c Wed Apr 25 01:12:40 2018 (r332977) @@ -110,58 +110,59 @@ __FBSDID("$FreeBSD$"); #include "cd9660/iso9660_rrip.h" #include "cd9660/cd9660_archimedes.h" -/* - * Global variables - */ -iso9660_disk diskStructure; - -static void cd9660_finalize_PVD(void); +static void cd9660_finalize_PVD(iso9660_disk *); static cd9660node *cd9660_allocate_cd9660node(void); -static void cd9660_set_defaults(void); +static void cd9660_set_defaults(iso9660_disk *); static int cd9660_arguments_set_string(const char *, const char *, int, char, char *); static void cd9660_populate_iso_dir_record( struct _iso_directory_record_cd9660 *, u_char, u_char, u_char, const char *); -static void cd9660_setup_root_node(void); -static int cd9660_setup_volume_descriptors(void); +static void cd9660_setup_root_node(iso9660_disk *); +static int cd9660_setup_volume_descriptors(iso9660_disk *); #if 0 static int cd9660_fill_extended_attribute_record(cd9660node *); #endif static void cd9660_sort_nodes(cd9660node *); -static int cd9660_translate_node_common(cd9660node *); -static int cd9660_translate_node(fsnode *, cd9660node *); +static int cd9660_translate_node_common(iso9660_disk *, cd9660node *); +static int cd9660_translate_node(iso9660_disk *, fsnode *, cd9660node *); static int cd9660_compare_filename(const char *, const char *); static void cd9660_sorted_child_insert(cd9660node *, cd9660node *); -static int cd9660_handle_collisions(cd9660node *, int); -static cd9660node *cd9660_rename_filename(cd9660node *, int, int); -static void cd9660_copy_filenames(cd9660node *); +static int cd9660_handle_collisions(iso9660_disk *, cd9660node *, int); +static cd9660node *cd9660_rename_filename(iso9660_disk *, cd9660node *, int, + int); +static void cd9660_copy_filenames(iso9660_disk *, cd9660node *); static void cd9660_sorting_nodes(cd9660node *); static int cd9660_count_collisions(cd9660node *); -static cd9660node *cd9660_rrip_move_directory(cd9660node *); -static int cd9660_add_dot_records(cd9660node *); +static cd9660node *cd9660_rrip_move_directory(iso9660_disk *, cd9660node *); +static int cd9660_add_dot_records(iso9660_disk *, cd9660node *); -static void cd9660_convert_structure(fsnode *, cd9660node *, int, +static void cd9660_convert_structure(iso9660_disk *, fsnode *, cd9660node *, int, int *, int *); static void cd9660_free_structure(cd9660node *); -static int cd9660_generate_path_table(void); -static int cd9660_level1_convert_filename(const char *, char *, int); -static int cd9660_level2_convert_filename(const char *, char *, int); +static int cd9660_generate_path_table(iso9660_disk *); +static int cd9660_level1_convert_filename(iso9660_disk *, const char *, char *, + int); +static int cd9660_level2_convert_filename(iso9660_disk *, const char *, char *, + int); #if 0 -static int cd9660_joliet_convert_filename(const char *, char *, int); +static int cd9660_joliet_convert_filename(iso9660_disk *, const char *, char *, + int); #endif -static int cd9660_convert_filename(const char *, char *, int); -static void cd9660_populate_dot_records(cd9660node *); -static int64_t cd9660_compute_offsets(cd9660node *, int64_t); +static int cd9660_convert_filename(iso9660_disk *, const char *, char *, int); +static void cd9660_populate_dot_records(iso9660_disk *, cd9660node *); +static int64_t cd9660_compute_offsets(iso9660_disk *, cd9660node *, int64_t); #if 0 static int cd9660_copy_stat_info(cd9660node *, cd9660node *, int); #endif -static cd9660node *cd9660_create_virtual_entry(const char *, cd9660node *, int, - int); -static cd9660node *cd9660_create_file(const char *, cd9660node *, cd9660node *); -static cd9660node *cd9660_create_directory(const char *, cd9660node *, +static cd9660node *cd9660_create_virtual_entry(iso9660_disk *, const char *, + cd9660node *, int, int); +static cd9660node *cd9660_create_file(iso9660_disk *, const char *, + cd9660node *, cd9660node *); +static cd9660node *cd9660_create_directory(iso9660_disk *, const char *, + cd9660node *, cd9660node *); +static cd9660node *cd9660_create_special_directory(iso9660_disk *, u_char, cd9660node *); -static cd9660node *cd9660_create_special_directory(u_char, cd9660node *); /* @@ -192,72 +193,79 @@ int cd9660_defaults_set = 0; * Set default values for cd9660 extension to makefs */ static void -cd9660_set_defaults(void) +cd9660_set_defaults(iso9660_disk *diskStructure) { /*Fix the sector size for now, though the spec allows for other sizes*/ - diskStructure.sectorSize = 2048; + diskStructure->sectorSize = 2048; /* Set up defaults in our own structure */ - diskStructure.verbose_level = 0; - diskStructure.keep_bad_images = 0; - diskStructure.follow_sym_links = 0; - diskStructure.isoLevel = 2; + diskStructure->verbose_level = 0; + diskStructure->keep_bad_images = 0; + diskStructure->follow_sym_links = 0; + diskStructure->isoLevel = 2; - diskStructure.rock_ridge_enabled = 0; - diskStructure.rock_ridge_renamed_dir_name = 0; - diskStructure.rock_ridge_move_count = 0; - diskStructure.rr_moved_dir = 0; + diskStructure->rock_ridge_enabled = 0; + diskStructure->rock_ridge_renamed_dir_name = 0; + diskStructure->rock_ridge_move_count = 0; + diskStructure->rr_moved_dir = 0; - diskStructure.archimedes_enabled = 0; - diskStructure.chrp_boot = 0; + diskStructure->archimedes_enabled = 0; + diskStructure->chrp_boot = 0; - diskStructure.include_padding_areas = 1; + diskStructure->include_padding_areas = 1; /* Spec breaking functionality */ - diskStructure.allow_deep_trees = - diskStructure.allow_start_dot = - diskStructure.allow_max_name = - diskStructure.allow_illegal_chars = - diskStructure.allow_lowercase = - diskStructure.allow_multidot = - diskStructure.omit_trailing_period = 0; + diskStructure->allow_deep_trees = + diskStructure->allow_start_dot = + diskStructure->allow_max_name = + diskStructure->allow_illegal_chars = + diskStructure->allow_lowercase = + diskStructure->allow_multidot = + diskStructure->omit_trailing_period = 0; /* Make sure the PVD is clear */ - memset(&diskStructure.primaryDescriptor, 0, 2048); + memset(&diskStructure->primaryDescriptor, 0, 2048); - memset(diskStructure.primaryDescriptor.publisher_id, 0x20,128); - memset(diskStructure.primaryDescriptor.preparer_id, 0x20,128); - memset(diskStructure.primaryDescriptor.application_id, 0x20,128); - memset(diskStructure.primaryDescriptor.copyright_file_id, 0x20,37); - memset(diskStructure.primaryDescriptor.abstract_file_id, 0x20,37); - memset(diskStructure.primaryDescriptor.bibliographic_file_id, 0x20,37); + memset(diskStructure->primaryDescriptor.publisher_id, 0x20,128); + memset(diskStructure->primaryDescriptor.preparer_id, 0x20,128); + memset(diskStructure->primaryDescriptor.application_id, 0x20,128); + memset(diskStructure->primaryDescriptor.copyright_file_id, 0x20,37); + memset(diskStructure->primaryDescriptor.abstract_file_id, 0x20,37); + memset(diskStructure->primaryDescriptor.bibliographic_file_id, 0x20,37); - strcpy(diskStructure.primaryDescriptor.system_id, "FreeBSD"); + strcpy(diskStructure->primaryDescriptor.system_id, "FreeBSD"); cd9660_defaults_set = 1; /* Boot support: Initially disabled */ - diskStructure.has_generic_bootimage = 0; - diskStructure.generic_bootimage = NULL; + diskStructure->has_generic_bootimage = 0; + diskStructure->generic_bootimage = NULL; - diskStructure.boot_image_directory = 0; - /*memset(diskStructure.boot_descriptor, 0, 2048);*/ + diskStructure->boot_image_directory = 0; + /*memset(diskStructure->boot_descriptor, 0, 2048);*/ - diskStructure.is_bootable = 0; - TAILQ_INIT(&diskStructure.boot_images); - LIST_INIT(&diskStructure.boot_entries); + diskStructure->is_bootable = 0; + TAILQ_INIT(&diskStructure->boot_images); + LIST_INIT(&diskStructure->boot_entries); } void -cd9660_prep_opts(fsinfo_t *fsopts __unused) +cd9660_prep_opts(fsinfo_t *fsopts) { - cd9660_set_defaults(); + iso9660_disk *diskStructure; + + if ((diskStructure = calloc(1, sizeof(*diskStructure))) == NULL) + err(EXIT_FAILURE, "%s: calloc", __func__); + + fsopts->fs_specific = diskStructure; + + cd9660_set_defaults(diskStructure); } void -cd9660_cleanup_opts(fsinfo_t *fsopts __unused) +cd9660_cleanup_opts(fsinfo_t *fsopts) { - + free(fsopts->fs_specific); } static int @@ -296,20 +304,19 @@ cd9660_parse_opts(const char *option, fsinfo_t *fsopts { char *var, *val; int rv; + iso9660_disk *diskStructure = fsopts->fs_specific; + /* Set up allowed options - integer options ONLY */ option_t cd9660_options[] = { - { "l", &diskStructure.isoLevel, 1, 2, "ISO Level" }, - { "isolevel", &diskStructure.isoLevel, 1, 2, "ISO Level" }, - { "verbose", &diskStructure.verbose_level, 0, 2, + { "l", &diskStructure->isoLevel, 1, 2, "ISO Level" }, + { "isolevel", &diskStructure->isoLevel, 1, 2, "ISO Level" }, + { "verbose", &diskStructure->verbose_level, 0, 2, "Turns on verbose output" }, - { "v", &diskStructure.verbose_level, 0 , 2, + { "v", &diskStructure->verbose_level, 0 , 2, "Turns on verbose output"}, { .name = NULL } }; - if (cd9660_defaults_set == 0) - cd9660_set_defaults(); - /* * Todo : finish implementing this, and make a function that * parses them @@ -336,33 +343,33 @@ cd9660_parse_opts(const char *option, fsinfo_t *fsopts /* First handle options with no parameters */ if (strcmp(var, "h") == 0) { - diskStructure.displayHelp = 1; + diskStructure->displayHelp = 1; rv = 1; } else if (CD9660_IS_COMMAND_ARG_DUAL(var, "S", "follow-symlinks")) { /* this is not handled yet */ - diskStructure.follow_sym_links = 1; + diskStructure->follow_sym_links = 1; rv = 1; } else if (CD9660_IS_COMMAND_ARG_DUAL(var, "L", "label")) { rv = cd9660_arguments_set_string(val, "Disk Label", 32, 'd', - diskStructure.primaryDescriptor.volume_id); + diskStructure->primaryDescriptor.volume_id); } else if (CD9660_IS_COMMAND_ARG_DUAL(var, "A", "applicationid")) { rv = cd9660_arguments_set_string(val, "Application Identifier", 128, 'a', - diskStructure.primaryDescriptor.application_id); + diskStructure->primaryDescriptor.application_id); } else if(CD9660_IS_COMMAND_ARG_DUAL(var, "P", "publisher")) { rv = cd9660_arguments_set_string(val, "Publisher Identifier", - 128, 'a', diskStructure.primaryDescriptor.publisher_id); + 128, 'a', diskStructure->primaryDescriptor.publisher_id); } else if (CD9660_IS_COMMAND_ARG_DUAL(var, "p", "preparer")) { rv = cd9660_arguments_set_string(val, "Preparer Identifier", - 128, 'a', diskStructure.primaryDescriptor.preparer_id); + 128, 'a', diskStructure->primaryDescriptor.preparer_id); } else if (CD9660_IS_COMMAND_ARG_DUAL(var, "V", "volumeid")) { rv = cd9660_arguments_set_string(val, "Volume Set Identifier", - 128, 'a', diskStructure.primaryDescriptor.volume_set_id); + 128, 'a', diskStructure->primaryDescriptor.volume_set_id); /* Boot options */ } else if (CD9660_IS_COMMAND_ARG_DUAL(var, "B", "bootimage")) { if (val == NULL) warnx("error: The Boot Image parameter requires a valid boot information string"); else - rv = cd9660_add_boot_disk(val); + rv = cd9660_add_boot_disk(diskStructure, val); } else if (CD9660_IS_COMMAND_ARG(var, "bootimagedir")) { /* * XXXfvdl this is unused. @@ -371,7 +378,7 @@ cd9660_parse_opts(const char *option, fsinfo_t *fsopts errx(1, "error: The Boot Image Directory parameter" " requires a directory name\n"); else { - if ((diskStructure.boot_image_directory = + if ((diskStructure->boot_image_directory = malloc(strlen(val) + 1)) == NULL) { CD9660_MEM_ALLOC_ERROR("cd9660_parse_opts"); exit(1); @@ -379,40 +386,40 @@ cd9660_parse_opts(const char *option, fsinfo_t *fsopts /* BIG TODO: Add the max length function here */ cd9660_arguments_set_string(val, "Boot Image Directory", - 12 , 'd', diskStructure.boot_image_directory); + 12 , 'd', diskStructure->boot_image_directory); } } else if (CD9660_IS_COMMAND_ARG_DUAL(var, "G", "generic-bootimage")) { if (val == NULL) warnx("error: The Boot Image parameter requires a valid boot information string"); else - rv = cd9660_add_generic_bootimage(val); + rv = cd9660_add_generic_bootimage(diskStructure, val); } else if (CD9660_IS_COMMAND_ARG(var, "no-trailing-padding")) - diskStructure.include_padding_areas = 0; + diskStructure->include_padding_areas = 0; /* RRIP */ else if (CD9660_IS_COMMAND_ARG_DUAL(var, "R", "rockridge")) - diskStructure.rock_ridge_enabled = 1; + diskStructure->rock_ridge_enabled = 1; else if (CD9660_IS_COMMAND_ARG_DUAL(var, "A", "archimedes")) - diskStructure.archimedes_enabled = 1; + diskStructure->archimedes_enabled = 1; else if (CD9660_IS_COMMAND_ARG(var, "chrp-boot")) - diskStructure.chrp_boot = 1; + diskStructure->chrp_boot = 1; else if (CD9660_IS_COMMAND_ARG_DUAL(var, "K", "keep-bad-images")) - diskStructure.keep_bad_images = 1; + diskStructure->keep_bad_images = 1; else if (CD9660_IS_COMMAND_ARG(var, "allow-deep-trees")) - diskStructure.allow_deep_trees = 1; + diskStructure->allow_deep_trees = 1; else if (CD9660_IS_COMMAND_ARG(var, "allow-max-name")) - diskStructure.allow_max_name = 1; + diskStructure->allow_max_name = 1; else if (CD9660_IS_COMMAND_ARG(var, "allow-illegal-chars")) - diskStructure.allow_illegal_chars = 1; + diskStructure->allow_illegal_chars = 1; else if (CD9660_IS_COMMAND_ARG(var, "allow-lowercase")) - diskStructure.allow_lowercase = 1; + diskStructure->allow_lowercase = 1; else if (CD9660_IS_COMMAND_ARG(var,"allow-multidot")) - diskStructure.allow_multidot = 1; + diskStructure->allow_multidot = 1; else if (CD9660_IS_COMMAND_ARG(var, "omit-trailing-period")) - diskStructure.omit_trailing_period = 1; + diskStructure->omit_trailing_period = 1; else if (CD9660_IS_COMMAND_ARG(var, "no-emul-boot") || CD9660_IS_COMMAND_ARG(var, "no-boot") || CD9660_IS_COMMAND_ARG(var, "hard-disk-boot")) { - cd9660_eltorito_add_boot_option(var, 0); + cd9660_eltorito_add_boot_option(diskStructure, var, 0); /* End of flag variables */ } else if (CD9660_IS_COMMAND_ARG(var, "boot-load-segment")) { @@ -420,7 +427,8 @@ cd9660_parse_opts(const char *option, fsinfo_t *fsopts warnx("Option `%s' doesn't contain a value", var); rv = 0; } else { - cd9660_eltorito_add_boot_option(var, val); + cd9660_eltorito_add_boot_option(diskStructure, var, + val); } } else { if (val == NULL) { @@ -453,19 +461,20 @@ cd9660_makefs(const char *image, const char *dir, fsno int64_t totalSpace; int error; cd9660node *real_root; + iso9660_disk *diskStructure = fsopts->fs_specific; - if (diskStructure.verbose_level > 0) + if (diskStructure->verbose_level > 0) printf("cd9660_makefs: ISO level is %i\n", - diskStructure.isoLevel); - if (diskStructure.isoLevel < 2 && - diskStructure.allow_multidot) + diskStructure->isoLevel); + if (diskStructure->isoLevel < 2 && + diskStructure->allow_multidot) errx(1, "allow-multidot requires iso level of 2\n"); assert(image != NULL); assert(dir != NULL); assert(root != NULL); - if (diskStructure.displayHelp) { + if (diskStructure->displayHelp) { /* * Display help here - probably want to put it in * a separate function @@ -473,7 +482,7 @@ cd9660_makefs(const char *image, const char *dir, fsno return; } - if (diskStructure.verbose_level > 0) + if (diskStructure->verbose_level > 0) printf("cd9660_makefs: image %s directory %s root %p\n", image, dir, root); @@ -497,11 +506,12 @@ cd9660_makefs(const char *image, const char *dir, fsno ISO_FILENAME_MAXLENGTH_WITH_PADDING); real_root->level = 0; - diskStructure.rootNode = real_root; + diskStructure->rootNode = real_root; real_root->type = CD9660_TYPE_DIR; error = 0; real_root->node = root; - cd9660_convert_structure(root, real_root, 1, &numDirectories, &error); + cd9660_convert_structure(diskStructure, root, real_root, 1, + &numDirectories, &error); if (TAILQ_EMPTY(&real_root->cn_children)) { errx(1, "cd9660_makefs: converted directory is empty. " @@ -509,109 +519,111 @@ cd9660_makefs(const char *image, const char *dir, fsno } else if (error != 0) { errx(1, "cd9660_makefs: tree conversion failed\n"); } else { - if (diskStructure.verbose_level > 0) + if (diskStructure->verbose_level > 0) printf("cd9660_makefs: tree converted\n"); } /* Add the dot and dot dot records */ - cd9660_add_dot_records(real_root); + cd9660_add_dot_records(diskStructure, real_root); - cd9660_setup_root_node(); + cd9660_setup_root_node(diskStructure); - if (diskStructure.verbose_level > 0) + if (diskStructure->verbose_level > 0) printf("cd9660_makefs: done converting tree\n"); /* non-SUSP extensions */ - if (diskStructure.archimedes_enabled) - archimedes_convert_tree(diskStructure.rootNode); + if (diskStructure->archimedes_enabled) + archimedes_convert_tree(diskStructure->rootNode); /* Rock ridge / SUSP init pass */ - if (diskStructure.rock_ridge_enabled) { - cd9660_susp_initialize(diskStructure.rootNode, - diskStructure.rootNode, NULL); + if (diskStructure->rock_ridge_enabled) { + cd9660_susp_initialize(diskStructure, diskStructure->rootNode, + diskStructure->rootNode, NULL); } /* Build path table structure */ - diskStructure.pathTableLength = cd9660_generate_path_table(); + diskStructure->pathTableLength = cd9660_generate_path_table( + diskStructure); - pathTableSectors = CD9660_BLOCKS(diskStructure.sectorSize, - diskStructure.pathTableLength); + pathTableSectors = CD9660_BLOCKS(diskStructure->sectorSize, + diskStructure->pathTableLength); - firstAvailableSector = cd9660_setup_volume_descriptors(); - if (diskStructure.is_bootable) { - firstAvailableSector = cd9660_setup_boot(firstAvailableSector); + firstAvailableSector = cd9660_setup_volume_descriptors(diskStructure); + if (diskStructure->is_bootable) { + firstAvailableSector = cd9660_setup_boot(diskStructure, + firstAvailableSector); if (firstAvailableSector < 0) errx(1, "setup_boot failed"); } /* LE first, then BE */ - diskStructure.primaryLittleEndianTableSector = firstAvailableSector; - diskStructure.primaryBigEndianTableSector = - diskStructure.primaryLittleEndianTableSector + pathTableSectors; + diskStructure->primaryLittleEndianTableSector = firstAvailableSector; + diskStructure->primaryBigEndianTableSector = + diskStructure->primaryLittleEndianTableSector + pathTableSectors; /* Set the secondary ones to -1, not going to use them for now */ - diskStructure.secondaryBigEndianTableSector = -1; - diskStructure.secondaryLittleEndianTableSector = -1; + diskStructure->secondaryBigEndianTableSector = -1; + diskStructure->secondaryLittleEndianTableSector = -1; - diskStructure.dataFirstSector = - diskStructure.primaryBigEndianTableSector + pathTableSectors; - if (diskStructure.verbose_level > 0) + diskStructure->dataFirstSector = + diskStructure->primaryBigEndianTableSector + pathTableSectors; + if (diskStructure->verbose_level > 0) printf("cd9660_makefs: Path table conversion complete. " "Each table is %i bytes, or %" PRIu64 " sectors.\n", - diskStructure.pathTableLength, pathTableSectors); + diskStructure->pathTableLength, pathTableSectors); - startoffset = diskStructure.sectorSize*diskStructure.dataFirstSector; + startoffset = diskStructure->sectorSize*diskStructure->dataFirstSector; - totalSpace = cd9660_compute_offsets(real_root, startoffset); + totalSpace = cd9660_compute_offsets(diskStructure, real_root, startoffset); - diskStructure.totalSectors = diskStructure.dataFirstSector + - CD9660_BLOCKS(diskStructure.sectorSize, totalSpace); + diskStructure->totalSectors = diskStructure->dataFirstSector + + CD9660_BLOCKS(diskStructure->sectorSize, totalSpace); /* Disabled until pass 1 is done */ - if (diskStructure.rock_ridge_enabled) { - diskStructure.susp_continuation_area_start_sector = - diskStructure.totalSectors; - diskStructure.totalSectors += - CD9660_BLOCKS(diskStructure.sectorSize, - diskStructure.susp_continuation_area_size); - cd9660_susp_finalize(diskStructure.rootNode); + if (diskStructure->rock_ridge_enabled) { + diskStructure->susp_continuation_area_start_sector = + diskStructure->totalSectors; + diskStructure->totalSectors += + CD9660_BLOCKS(diskStructure->sectorSize, + diskStructure->susp_continuation_area_size); + cd9660_susp_finalize(diskStructure, diskStructure->rootNode); } - cd9660_finalize_PVD(); + cd9660_finalize_PVD(diskStructure); /* Add padding sectors, just for testing purposes right now */ - /* diskStructure.totalSectors+=150; */ + /* diskStructure->totalSectors+=150; */ /* Debugging output */ - if (diskStructure.verbose_level > 0) { + if (diskStructure->verbose_level > 0) { printf("cd9660_makefs: Sectors 0-15 reserved\n"); printf("cd9660_makefs: Primary path tables starts in sector %" - PRId64 "\n", diskStructure.primaryLittleEndianTableSector); + PRId64 "\n", diskStructure->primaryLittleEndianTableSector); printf("cd9660_makefs: File data starts in sector %" - PRId64 "\n", diskStructure.dataFirstSector); + PRId64 "\n", diskStructure->dataFirstSector); printf("cd9660_makefs: Total sectors: %" - PRId64 "\n", diskStructure.totalSectors); + PRId64 "\n", diskStructure->totalSectors); } /* * Add padding sectors at the end * TODO: Clean this up and separate padding */ - if (diskStructure.include_padding_areas) - diskStructure.totalSectors += 150; + if (diskStructure->include_padding_areas) + diskStructure->totalSectors += 150; - cd9660_write_image(image); + cd9660_write_image(diskStructure, image); - if (diskStructure.verbose_level > 1) { - debug_print_volume_descriptor_information(); - debug_print_tree(real_root,0); + if (diskStructure->verbose_level > 1) { + debug_print_volume_descriptor_information(diskStructure); + debug_print_tree(diskStructure, real_root, 0); debug_print_path_tree(real_root); } /* Clean up data structures */ cd9660_free_structure(real_root); - if (diskStructure.verbose_level > 0) + if (diskStructure->verbose_level > 0) printf("cd9660_makefs: done\n"); } @@ -619,76 +631,77 @@ cd9660_makefs(const char *image, const char *dir, fsno typedef int (*cd9660node_func)(cd9660node *); static void -cd9660_finalize_PVD(void) +cd9660_finalize_PVD(iso9660_disk *diskStructure) { time_t tstamp = stampst.st_ino ? stampst.st_mtime : time(NULL); /* root should be a fixed size of 34 bytes since it has no name */ - memcpy(diskStructure.primaryDescriptor.root_directory_record, - diskStructure.rootNode->dot_record->isoDirRecord, 34); + memcpy(diskStructure->primaryDescriptor.root_directory_record, + diskStructure->rootNode->dot_record->isoDirRecord, 34); /* In RRIP, this might be longer than 34 */ - diskStructure.primaryDescriptor.root_directory_record[0] = 34; + diskStructure->primaryDescriptor.root_directory_record[0] = 34; /* Set up all the important numbers in the PVD */ - cd9660_bothendian_dword(diskStructure.totalSectors, - (unsigned char *)diskStructure.primaryDescriptor.volume_space_size); + cd9660_bothendian_dword(diskStructure->totalSectors, + (unsigned char *)diskStructure->primaryDescriptor.volume_space_size); cd9660_bothendian_word(1, - (unsigned char *)diskStructure.primaryDescriptor.volume_set_size); + (unsigned char *)diskStructure->primaryDescriptor.volume_set_size); cd9660_bothendian_word(1, (unsigned char *) - diskStructure.primaryDescriptor.volume_sequence_number); - cd9660_bothendian_word(diskStructure.sectorSize, + diskStructure->primaryDescriptor.volume_sequence_number); + cd9660_bothendian_word(diskStructure->sectorSize, (unsigned char *) - diskStructure.primaryDescriptor.logical_block_size); - cd9660_bothendian_dword(diskStructure.pathTableLength, - (unsigned char *)diskStructure.primaryDescriptor.path_table_size); + diskStructure->primaryDescriptor.logical_block_size); + cd9660_bothendian_dword(diskStructure->pathTableLength, + (unsigned char *)diskStructure->primaryDescriptor.path_table_size); - cd9660_731(diskStructure.primaryLittleEndianTableSector, - (u_char *)diskStructure.primaryDescriptor.type_l_path_table); - cd9660_732(diskStructure.primaryBigEndianTableSector, - (u_char *)diskStructure.primaryDescriptor.type_m_path_table); + cd9660_731(diskStructure->primaryLittleEndianTableSector, + (u_char *)diskStructure->primaryDescriptor.type_l_path_table); + cd9660_732(diskStructure->primaryBigEndianTableSector, + (u_char *)diskStructure->primaryDescriptor.type_m_path_table); - diskStructure.primaryDescriptor.file_structure_version[0] = 1; + diskStructure->primaryDescriptor.file_structure_version[0] = 1; /* Pad all strings with spaces instead of nulls */ - cd9660_pad_string_spaces(diskStructure.primaryDescriptor.volume_id, 32); - cd9660_pad_string_spaces(diskStructure.primaryDescriptor.system_id, 32); - cd9660_pad_string_spaces(diskStructure.primaryDescriptor.volume_set_id, + cd9660_pad_string_spaces(diskStructure->primaryDescriptor.volume_id, 32); + cd9660_pad_string_spaces(diskStructure->primaryDescriptor.system_id, 32); + cd9660_pad_string_spaces(diskStructure->primaryDescriptor.volume_set_id, 128); - cd9660_pad_string_spaces(diskStructure.primaryDescriptor.publisher_id, + cd9660_pad_string_spaces(diskStructure->primaryDescriptor.publisher_id, 128); - cd9660_pad_string_spaces(diskStructure.primaryDescriptor.preparer_id, + cd9660_pad_string_spaces(diskStructure->primaryDescriptor.preparer_id, 128); - cd9660_pad_string_spaces(diskStructure.primaryDescriptor.application_id, + cd9660_pad_string_spaces(diskStructure->primaryDescriptor.application_id, 128); cd9660_pad_string_spaces( - diskStructure.primaryDescriptor.copyright_file_id, 37); + diskStructure->primaryDescriptor.copyright_file_id, 37); cd9660_pad_string_spaces( - diskStructure.primaryDescriptor.abstract_file_id, 37); + diskStructure->primaryDescriptor.abstract_file_id, 37); cd9660_pad_string_spaces( - diskStructure.primaryDescriptor.bibliographic_file_id, 37); + diskStructure->primaryDescriptor.bibliographic_file_id, 37); /* Setup dates */ cd9660_time_8426( - (unsigned char *)diskStructure.primaryDescriptor.creation_date, + (unsigned char *)diskStructure->primaryDescriptor.creation_date, tstamp); cd9660_time_8426( - (unsigned char *)diskStructure.primaryDescriptor.modification_date, + (unsigned char *)diskStructure->primaryDescriptor.modification_date, tstamp); #if 0 - cd9660_set_date(diskStructure.primaryDescriptor.expiration_date, + cd9660_set_date(diskStructure->primaryDescriptor.expiration_date, tstamp); #endif - memset(diskStructure.primaryDescriptor.expiration_date, '0', 16); - diskStructure.primaryDescriptor.expiration_date[16] = 0; + memset(diskStructure->primaryDescriptor.expiration_date, '0', 16); + diskStructure->primaryDescriptor.expiration_date[16] = 0; + cd9660_time_8426( - (unsigned char *)diskStructure.primaryDescriptor.effective_date, + (unsigned char *)diskStructure->primaryDescriptor.effective_date, tstamp); /* make this sane */ - cd9660_time_915(diskStructure.rootNode->dot_record->isoDirRecord->date, + cd9660_time_915(diskStructure->rootNode->dot_record->isoDirRecord->date, tstamp); } @@ -712,16 +725,16 @@ cd9660_populate_iso_dir_record(struct _iso_directory_r } static void -cd9660_setup_root_node(void) +cd9660_setup_root_node(iso9660_disk *diskStructure) { - cd9660_populate_iso_dir_record(diskStructure.rootNode->isoDirRecord, + cd9660_populate_iso_dir_record(diskStructure->rootNode->isoDirRecord, 0, ISO_FLAG_DIRECTORY, 1, "\0"); } /*********** SUPPORT FUNCTIONS ***********/ static int -cd9660_setup_volume_descriptors(void) +cd9660_setup_volume_descriptors(iso9660_disk *diskStructure) { /* Boot volume descriptor should come second */ int sector = 16; @@ -735,17 +748,17 @@ cd9660_setup_volume_descriptors(void) } temp->volumeDescriptorData = - (unsigned char *)&diskStructure.primaryDescriptor; + (unsigned char *)&diskStructure->primaryDescriptor; temp->volumeDescriptorData[0] = ISO_VOLUME_DESCRIPTOR_PVD; temp->volumeDescriptorData[6] = 1; temp->sector = sector; memcpy(temp->volumeDescriptorData + 1, ISO_VOLUME_DESCRIPTOR_STANDARD_ID, 5); - diskStructure.firstVolumeDescriptor = temp; + diskStructure->firstVolumeDescriptor = temp; sector++; /* Set up boot support if enabled. BVD must reside in sector 17 */ - if (diskStructure.is_bootable) { + if (diskStructure->is_bootable) { if ((t = malloc(sizeof(volume_descriptor))) == NULL) { CD9660_MEM_ALLOC_ERROR( "cd9660_setup_volume_descriptors"); @@ -760,9 +773,9 @@ cd9660_setup_volume_descriptors(void) temp = t; memset(t->volumeDescriptorData, 0, 2048); t->sector = 17; - if (diskStructure.verbose_level > 0) + if (diskStructure->verbose_level > 0) printf("Setting up boot volume descriptor\n"); - cd9660_setup_boot_volume_descriptor(t); + cd9660_setup_boot_volume_descriptor(diskStructure, t); sector++; } @@ -808,7 +821,7 @@ cd9660_fill_extended_attribute_record(cd9660node *node #endif static int -cd9660_translate_node_common(cd9660node *newnode) +cd9660_translate_node_common(iso9660_disk *diskStructure, cd9660node *newnode) { time_t tstamp = stampst.st_ino ? stampst.st_mtime : time(NULL); int test; @@ -818,7 +831,7 @@ cd9660_translate_node_common(cd9660node *newnode) /* Now populate the isoDirRecord structure */ memset(temp, 0, ISO_FILENAME_MAXLENGTH_WITH_PADDING); - test = cd9660_convert_filename(newnode->node->name, + test = cd9660_convert_filename(diskStructure, newnode->node->name, temp, !(S_ISDIR(newnode->node->type))); flag = ISO_FLAG_CLEAR; @@ -852,10 +865,11 @@ cd9660_translate_node_common(cd9660node *newnode) * @returns int 0 on failure, 1 on success */ static int -cd9660_translate_node(fsnode *node, cd9660node *newnode) +cd9660_translate_node(iso9660_disk *diskStructure, fsnode *node, + cd9660node *newnode) { if (node == NULL) { - if (diskStructure.verbose_level > 0) + if (diskStructure->verbose_level > 0) printf("cd9660_translate_node: NULL node passed, " "returning\n"); return 0; @@ -873,7 +887,7 @@ cd9660_translate_node(fsnode *node, cd9660node *newnod if (!(S_ISDIR(node->type))) newnode->fileDataLength = node->inode->st.st_size; - if (cd9660_translate_node_common(newnode) == 0) + if (cd9660_translate_node_common(diskStructure, newnode) == 0) return 0; /* Finally, overwrite some of the values that are set by default */ @@ -1007,7 +1021,8 @@ cd9660_sorted_child_insert(cd9660node *parent, cd9660n * where n represents the files respective place in the ordering */ static int -cd9660_handle_collisions(cd9660node *colliding, int past) +cd9660_handle_collisions(iso9660_disk *diskStructure, cd9660node *colliding, + int past) { cd9660node *iter, *next, *prev; int skip; @@ -1042,14 +1057,16 @@ cd9660_handle_collisions(cd9660node *colliding, int pa temp_past--; } skip += past; - iter = cd9660_rename_filename(iter, skip, delete_chars); + iter = cd9660_rename_filename(diskStructure, iter, skip, + delete_chars); } return flag; } static cd9660node * -cd9660_rename_filename(cd9660node *iter, int num, int delete_chars) +cd9660_rename_filename(iso9660_disk *diskStructure, cd9660node *iter, int num, + int delete_chars) { int i = 0; int numbts, digit, digits, temp, powers, count; @@ -1057,14 +1074,14 @@ cd9660_rename_filename(cd9660node *iter, int num, int int maxlength; char *tmp; - if (diskStructure.verbose_level > 0) + if (diskStructure->verbose_level > 0) printf("Rename_filename called\n"); - assert(1 <= diskStructure.isoLevel && diskStructure.isoLevel <= 2); + assert(1 <= diskStructure->isoLevel && diskStructure->isoLevel <= 2); /* TODO : A LOT of chanes regarding 8.3 filenames */ - if (diskStructure.isoLevel == 1) + if (diskStructure->isoLevel == 1) maxlength = 8; - else if (diskStructure.isoLevel == 2) + else if (diskStructure->isoLevel == 2) maxlength = 31; else maxlength = ISO_FILENAME_MAXLENGTH_BEFORE_VERSION; @@ -1110,7 +1127,7 @@ cd9660_rename_filename(cd9660node *iter, int num, int */ /* - if (diskStructure.isoLevel == 1) { + if (diskStructure->isoLevel == 1) { numbts = 8 - digits - delete_chars; if (dot < 0) { @@ -1162,7 +1179,7 @@ cd9660_rename_filename(cd9660node *iter, int num, int /* Todo: Figure out why these functions are nec. */ static void -cd9660_copy_filenames(cd9660node *node) +cd9660_copy_filenames(iso9660_disk *diskStructure, cd9660node *node) { cd9660node *cn; @@ -1170,12 +1187,12 @@ cd9660_copy_filenames(cd9660node *node) return; if (TAILQ_FIRST(&node->cn_children)->isoDirRecord == NULL) { - debug_print_tree(diskStructure.rootNode, 0); + debug_print_tree(diskStructure, diskStructure->rootNode, 0); exit(1); } TAILQ_FOREACH(cn, &node->cn_children, cn_next_child) { - cd9660_copy_filenames(cn); + cd9660_copy_filenames(diskStructure, cn); memcpy(cn->o_name, cn->isoDirRecord->name, ISO_FILENAME_MAXLENGTH_WITH_PADDING); } @@ -1242,7 +1259,7 @@ cd9660_count_collisions(cd9660node *copy) } static cd9660node * -cd9660_rrip_move_directory(cd9660node *dir) +cd9660_rrip_move_directory(iso9660_disk *diskStructure, cd9660node *dir) { char newname[9]; cd9660node *tfile; @@ -1253,28 +1270,29 @@ cd9660_rrip_move_directory(cd9660node *dir) * 2) Point the virtual file to the new directory * 3) Point the relocated directory to its old parent * 4) Move the directory specified by dir into rr_moved_dir, - * and rename it to "diskStructure.rock_ridge_move_count" (as a string) + * and rename it to "diskStructure->rock_ridge_move_count" (as a string) */ /* First see if the moved directory even exists */ - if (diskStructure.rr_moved_dir == NULL) { - diskStructure.rr_moved_dir = - cd9660_create_directory(ISO_RRIP_DEFAULT_MOVE_DIR_NAME, - diskStructure.rootNode, dir); - if (diskStructure.rr_moved_dir == NULL) + if (diskStructure->rr_moved_dir == NULL) { + diskStructure->rr_moved_dir = cd9660_create_directory( + diskStructure, ISO_RRIP_DEFAULT_MOVE_DIR_NAME, + diskStructure->rootNode, dir); + if (diskStructure->rr_moved_dir == NULL) return 0; - cd9660_time_915(diskStructure.rr_moved_dir->isoDirRecord->date, + cd9660_time_915(diskStructure->rr_moved_dir->isoDirRecord->date, stampst.st_ino ? stampst.st_mtime : start_time.tv_sec); } /* Create a file with the same ORIGINAL name */ - tfile = cd9660_create_file(dir->node->name, dir->parent, dir); + tfile = cd9660_create_file(diskStructure, dir->node->name, dir->parent, + dir); if (tfile == NULL) return NULL; - diskStructure.rock_ridge_move_count++; + diskStructure->rock_ridge_move_count++; snprintf(newname, sizeof(newname), "%08i", - diskStructure.rock_ridge_move_count); + diskStructure->rock_ridge_move_count); /* Point to old parent */ dir->rr_real_parent = dir->parent; @@ -1288,13 +1306,13 @@ cd9660_rrip_move_directory(cd9660node *dir) } /* Point to new parent */ - dir->parent = diskStructure.rr_moved_dir; + dir->parent = diskStructure->rr_moved_dir; /* Point the file to the moved directory */ tfile->rr_relocated = dir; /* Actually move the directory */ - cd9660_sorted_child_insert(diskStructure.rr_moved_dir, dir); + cd9660_sorted_child_insert(diskStructure->rr_moved_dir, dir); /* TODO: Inherit permissions / ownership (basically the entire inode) */ @@ -1308,7 +1326,7 @@ cd9660_rrip_move_directory(cd9660node *dir) } static int -cd9660_add_dot_records(cd9660node *root) +cd9660_add_dot_records(iso9660_disk *diskStructure, cd9660node *root) { struct cd9660_children_head *head = &root->cn_children; cd9660node *cn; @@ -1317,10 +1335,11 @@ cd9660_add_dot_records(cd9660node *root) if ((cn->type & CD9660_TYPE_DIR) == 0) continue; /* Recursion first */ - cd9660_add_dot_records(cn); + cd9660_add_dot_records(diskStructure, cn); } - cd9660_create_special_directory(CD9660_TYPE_DOT, root); - cd9660_create_special_directory(CD9660_TYPE_DOTDOT, root); + cd9660_create_special_directory(diskStructure, CD9660_TYPE_DOT, root); + cd9660_create_special_directory(diskStructure, CD9660_TYPE_DOTDOT, + root); return 1; } @@ -1335,8 +1354,8 @@ cd9660_add_dot_records(cd9660node *root) * @param int* Running count of the number of directories that are being created */ static void -cd9660_convert_structure(fsnode *root, cd9660node *parent_node, int level, - int *numDirectories, int *error) +cd9660_convert_structure(iso9660_disk *diskStructure, fsnode *root, + cd9660node *parent_node, int level, int *numDirectories, int *error) { fsnode *iterator = root; cd9660node *this_node; @@ -1379,7 +1398,8 @@ cd9660_convert_structure(fsnode *root, cd9660node *par /* Translate the node, including its filename */ this_node->parent = parent_node; - cd9660_translate_node(iterator, this_node); + cd9660_translate_node(diskStructure, iterator, + this_node); this_node->level = level; if (S_ISDIR(iterator->type)) { @@ -1393,14 +1413,14 @@ cd9660_convert_structure(fsnode *root, cd9660node *par * allowed as per ISO spec */ if (level == 8) { - if ((!diskStructure.allow_deep_trees) && - (!diskStructure.rock_ridge_enabled)) { + if ((!diskStructure->allow_deep_trees) && + (!diskStructure->rock_ridge_enabled)) { warnx("error: found entry " "with depth greater " "than 8."); (*error) = 1; return; - } else if (diskStructure. + } else if (diskStructure-> rock_ridge_enabled) { working_level = 3; /* @@ -1410,6 +1430,7 @@ cd9660_convert_structure(fsnode *root, cd9660node *par this_node->level = working_level - 1; if (cd9660_rrip_move_directory( + diskStructure, this_node) == NULL) { warnx("Failure in " "cd9660_rrip_" @@ -1424,8 +1445,8 @@ cd9660_convert_structure(fsnode *root, cd9660node *par /* Do the recursive call on the children */ if (iterator->child != NULL) { - cd9660_convert_structure( - iterator->child, this_node, + cd9660_convert_structure(diskStructure, + iterator->child, this_node, working_level, numDirectories, error); @@ -1464,10 +1485,11 @@ cd9660_convert_structure(fsnode *root, cd9660node *par /* cd9660_handle_collisions(first_node); */ /* TODO: need cleanup */ *** DIFF OUTPUT TRUNCATED AT 1000 LINES *** From owner-svn-src-stable-11@freebsd.org Wed Apr 25 01:20:26 2018 Return-Path: Delivered-To: svn-src-stable-11@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 90FF7FB9A08; Wed, 25 Apr 2018 01:20:26 +0000 (UTC) (envelope-from benno@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 458CD744DF; Wed, 25 Apr 2018 01:20:26 +0000 (UTC) (envelope-from benno@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 3B97F22634; Wed, 25 Apr 2018 01:20:26 +0000 (UTC) (envelope-from benno@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id w3P1KQPW074611; Wed, 25 Apr 2018 01:20:26 GMT (envelope-from benno@FreeBSD.org) Received: (from benno@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id w3P1KPrR074606; Wed, 25 Apr 2018 01:20:25 GMT (envelope-from benno@FreeBSD.org) Message-Id: <201804250120.w3P1KPrR074606@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: benno set sender to benno@FreeBSD.org using -f From: Benno Rice Date: Wed, 25 Apr 2018 01:20:25 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-11@freebsd.org Subject: svn commit: r332978 - stable/11/usr.sbin/makefs X-SVN-Group: stable-11 X-SVN-Commit-Author: benno X-SVN-Commit-Paths: stable/11/usr.sbin/makefs X-SVN-Commit-Revision: 332978 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable-11@freebsd.org X-Mailman-Version: 2.1.25 Precedence: list List-Id: SVN commit messages for only the 11-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 25 Apr 2018 01:20:26 -0000 Author: benno Date: Wed Apr 25 01:20:25 2018 New Revision: 332978 URL: https://svnweb.freebsd.org/changeset/base/332978 Log: MFC r315304 makefs: sync option parsing with NetBSD - add support for parsing different types; not just int - homogenize option parsing - fix single letter parsing - remove duplicated code NetBSD revisions: cd9660.c 1.36 1.37 1.38 1.41 1.42 1.43 ffs.c 1.50 1.51 1.52 1.53 1.56 1.57 makefs.c 1.36 1.37 1.38 1.39 1.40 1.42 1.43 1.44 1.46 makefs.h 1.28 1.29 1.31 1.32 Sponsored by: iXsystems, Inc. Modified: stable/11/usr.sbin/makefs/cd9660.c stable/11/usr.sbin/makefs/cd9660.h stable/11/usr.sbin/makefs/ffs.c stable/11/usr.sbin/makefs/makefs.c stable/11/usr.sbin/makefs/makefs.h Directory Properties: stable/11/ (props changed) Modified: stable/11/usr.sbin/makefs/cd9660.c ============================================================================== --- stable/11/usr.sbin/makefs/cd9660.c Wed Apr 25 01:12:40 2018 (r332977) +++ stable/11/usr.sbin/makefs/cd9660.c Wed Apr 25 01:20:25 2018 (r332978) @@ -257,7 +257,70 @@ cd9660_prep_opts(fsinfo_t *fsopts) if ((diskStructure = calloc(1, sizeof(*diskStructure))) == NULL) err(EXIT_FAILURE, "%s: calloc", __func__); +#define OPT_STR(letter, name, desc) \ + { letter, name, NULL, OPT_STRBUF, 0, 0, desc } + +#define OPT_NUM(letter, name, field, min, max, desc) \ + { letter, name, &diskStructure->field, \ + sizeof(diskStructure->field) == 8 ? OPT_INT64 : \ + (sizeof(diskStructure->field) == 4 ? OPT_INT32 : \ + (sizeof(diskStructure->field) == 2 ? OPT_INT16 : OPT_INT8)), \ + min, max, desc } + +#define OPT_BOOL(letter, name, field, desc) \ + OPT_NUM(letter, name, field, 0, 1, desc) + + const option_t cd9660_options[] = { + OPT_NUM('l', "isolevel", isoLevel, + 1, 2, "ISO Level"), + OPT_NUM('v', "verbose", verbose_level, + 0, 2, "Turns on verbose output"), + + OPT_BOOL('h', "help", displayHelp, + "Show help message"), + OPT_BOOL('S', "follow-symlinks", follow_sym_links, + "Resolve symlinks in pathnames"), + OPT_BOOL('R', "rockridge", rock_ridge_enabled, + "Enable Rock-Ridge extensions"), + OPT_BOOL('C', "chrp-boot", chrp_boot, + "Enable CHRP boot"), + OPT_BOOL('K', "keep-bad-images", keep_bad_images, + "Keep bad images"), + OPT_BOOL('D', "allow-deep-trees", allow_deep_trees, + "Allow trees more than 8 levels"), + OPT_BOOL('a', "allow-max-name", allow_max_name, + "Allow 37 char filenames (unimplemented)"), + OPT_BOOL('i', "allow-illegal-chars", allow_illegal_chars, + "Allow illegal characters in filenames"), + OPT_BOOL('d', "allow-multidot", allow_multidot, + "Allow multiple periods in filenames"), + OPT_BOOL('o', "omit-trailing-period", omit_trailing_period, + "Omit trailing periods in filenames"), + OPT_BOOL('\0', "allow-lowercase", allow_lowercase, + "Allow lowercase characters in filenames"), + OPT_BOOL('\0', "archimedes", archimedes_enabled, + "Enable Archimedes structure"), + OPT_BOOL('\0', "no-trailing-padding", include_padding_areas, + "Include padding areas"), + + OPT_STR('A', "applicationid", "Application Identifier"), + OPT_STR('P', "publisher", "Publisher Identifier"), + OPT_STR('p', "preparer", "Preparer Identifier"), + OPT_STR('L', "label", "Disk Label"), + OPT_STR('V', "volumeid", "Volume Set Identifier"), + OPT_STR('B', "bootimage", "Boot image parameter"), + OPT_STR('G', "generic-bootimage", "Generic boot image param"), + OPT_STR('\0', "bootimagedir", "Boot image directory"), + OPT_STR('\0', "no-emul-boot", "No boot emulation"), + OPT_STR('\0', "no-boot", "No boot support"), + OPT_STR('\0', "hard-disk-boot", "Boot from hard disk"), + OPT_STR('\0', "boot-load-segment", "Boot load segment"), + + { .name = NULL } + }; + fsopts->fs_specific = diskStructure; + fsopts->fs_options = copy_opts(cd9660_options); cd9660_set_defaults(diskStructure); } @@ -266,6 +329,7 @@ void cd9660_cleanup_opts(fsinfo_t *fsopts) { free(fsopts->fs_specific); + free(fsopts->fs_options); } static int @@ -302,144 +366,106 @@ cd9660_arguments_set_string(const char *val, const cha int cd9660_parse_opts(const char *option, fsinfo_t *fsopts) { - char *var, *val; - int rv; + int rv, i; iso9660_disk *diskStructure = fsopts->fs_specific; + option_t *cd9660_options = fsopts->fs_options; + char buf[1024]; + const char *name, *desc; - /* Set up allowed options - integer options ONLY */ - option_t cd9660_options[] = { - { "l", &diskStructure->isoLevel, 1, 2, "ISO Level" }, - { "isolevel", &diskStructure->isoLevel, 1, 2, "ISO Level" }, - { "verbose", &diskStructure->verbose_level, 0, 2, - "Turns on verbose output" }, - { "v", &diskStructure->verbose_level, 0 , 2, - "Turns on verbose output"}, - { .name = NULL } - }; - - /* - * Todo : finish implementing this, and make a function that - * parses them - */ - /* - string_option_t cd9660_string_options[] = { - { "L", "Label", &diskStructure.primaryDescriptor.volume_id, 1, 32, "Disk Label", ISO_STRING_FILTER_DCHARS }, - { NULL } - } - */ - assert(option != NULL); if (debug & DEBUG_FS_PARSE_OPTS) printf("cd9660_parse_opts: got `%s'\n", option); - if ((var = strdup(option)) == NULL) - err(1, "allocating memory for copy of option string"); - rv = 1; + i = set_option(cd9660_options, option, buf, sizeof(buf)); + if (i == -1) + return 0; - val = strchr(var, '='); - if (val != NULL) - *val++ = '\0'; + if (cd9660_options[i].name == NULL) + abort(); - /* First handle options with no parameters */ - if (strcmp(var, "h") == 0) { - diskStructure->displayHelp = 1; - rv = 1; - } else if (CD9660_IS_COMMAND_ARG_DUAL(var, "S", "follow-symlinks")) { - /* this is not handled yet */ - diskStructure->follow_sym_links = 1; - rv = 1; - } else if (CD9660_IS_COMMAND_ARG_DUAL(var, "L", "label")) { - rv = cd9660_arguments_set_string(val, "Disk Label", 32, 'd', - diskStructure->primaryDescriptor.volume_id); - } else if (CD9660_IS_COMMAND_ARG_DUAL(var, "A", "applicationid")) { - rv = cd9660_arguments_set_string(val, "Application Identifier", 128, 'a', - diskStructure->primaryDescriptor.application_id); - } else if(CD9660_IS_COMMAND_ARG_DUAL(var, "P", "publisher")) { - rv = cd9660_arguments_set_string(val, "Publisher Identifier", - 128, 'a', diskStructure->primaryDescriptor.publisher_id); - } else if (CD9660_IS_COMMAND_ARG_DUAL(var, "p", "preparer")) { - rv = cd9660_arguments_set_string(val, "Preparer Identifier", - 128, 'a', diskStructure->primaryDescriptor.preparer_id); - } else if (CD9660_IS_COMMAND_ARG_DUAL(var, "V", "volumeid")) { - rv = cd9660_arguments_set_string(val, "Volume Set Identifier", - 128, 'a', diskStructure->primaryDescriptor.volume_set_id); + name = cd9660_options[i].name; + desc = cd9660_options[i].desc; + switch (cd9660_options[i].letter) { + case 'h': + case 'S': + rv = 0; /* this is not handled yet */ + break; + case 'L': + rv = cd9660_arguments_set_string(buf, desc, 32, 'd', + diskStructure->primaryDescriptor.volume_id); + break; + case 'A': + rv = cd9660_arguments_set_string(buf, desc, 128, 'a', + diskStructure->primaryDescriptor.application_id); + break; + case 'P': + rv = cd9660_arguments_set_string(buf, desc, 128, 'a', + diskStructure->primaryDescriptor.publisher_id); + break; + case 'p': + rv = cd9660_arguments_set_string(buf, desc, 128, 'a', + diskStructure->primaryDescriptor.preparer_id); + break; + case 'V': + rv = cd9660_arguments_set_string(buf, desc, 128, 'a', + diskStructure->primaryDescriptor.volume_set_id); + break; /* Boot options */ - } else if (CD9660_IS_COMMAND_ARG_DUAL(var, "B", "bootimage")) { - if (val == NULL) - warnx("error: The Boot Image parameter requires a valid boot information string"); - else - rv = cd9660_add_boot_disk(diskStructure, val); - } else if (CD9660_IS_COMMAND_ARG(var, "bootimagedir")) { - /* - * XXXfvdl this is unused. - */ - if (val == NULL) - errx(1, "error: The Boot Image Directory parameter" - " requires a directory name\n"); - else { - if ((diskStructure->boot_image_directory = - malloc(strlen(val) + 1)) == NULL) { - CD9660_MEM_ALLOC_ERROR("cd9660_parse_opts"); - exit(1); - } - - /* BIG TODO: Add the max length function here */ - cd9660_arguments_set_string(val, "Boot Image Directory", - 12 , 'd', diskStructure->boot_image_directory); - } - } else if (CD9660_IS_COMMAND_ARG_DUAL(var, "G", "generic-bootimage")) { - if (val == NULL) - warnx("error: The Boot Image parameter requires a valid boot information string"); - else - rv = cd9660_add_generic_bootimage(diskStructure, val); - } else if (CD9660_IS_COMMAND_ARG(var, "no-trailing-padding")) - diskStructure->include_padding_areas = 0; - /* RRIP */ - else if (CD9660_IS_COMMAND_ARG_DUAL(var, "R", "rockridge")) - diskStructure->rock_ridge_enabled = 1; - else if (CD9660_IS_COMMAND_ARG_DUAL(var, "A", "archimedes")) - diskStructure->archimedes_enabled = 1; - else if (CD9660_IS_COMMAND_ARG(var, "chrp-boot")) - diskStructure->chrp_boot = 1; - else if (CD9660_IS_COMMAND_ARG_DUAL(var, "K", "keep-bad-images")) - diskStructure->keep_bad_images = 1; - else if (CD9660_IS_COMMAND_ARG(var, "allow-deep-trees")) - diskStructure->allow_deep_trees = 1; - else if (CD9660_IS_COMMAND_ARG(var, "allow-max-name")) - diskStructure->allow_max_name = 1; - else if (CD9660_IS_COMMAND_ARG(var, "allow-illegal-chars")) - diskStructure->allow_illegal_chars = 1; - else if (CD9660_IS_COMMAND_ARG(var, "allow-lowercase")) - diskStructure->allow_lowercase = 1; - else if (CD9660_IS_COMMAND_ARG(var,"allow-multidot")) - diskStructure->allow_multidot = 1; - else if (CD9660_IS_COMMAND_ARG(var, "omit-trailing-period")) - diskStructure->omit_trailing_period = 1; - else if (CD9660_IS_COMMAND_ARG(var, "no-emul-boot") || - CD9660_IS_COMMAND_ARG(var, "no-boot") || - CD9660_IS_COMMAND_ARG(var, "hard-disk-boot")) { - cd9660_eltorito_add_boot_option(diskStructure, var, 0); - - /* End of flag variables */ - } else if (CD9660_IS_COMMAND_ARG(var, "boot-load-segment")) { - if (val == NULL) { - warnx("Option `%s' doesn't contain a value", var); + case 'B': + if (buf[0] == '\0') { + warnx("The Boot Image parameter requires a valid boot" + "information string"); rv = 0; - } else { - cd9660_eltorito_add_boot_option(diskStructure, var, - val); - } - } else { - if (val == NULL) { - warnx("Option `%s' doesn't contain a value", var); + } else + rv = cd9660_add_boot_disk(diskStructure, buf); + break; + case 'G': + if (buf[0] == '\0') { + warnx("The Generic Boot Image parameter requires a" + " valid boot information string"); rv = 0; } else - rv = set_option(cd9660_options, var, val); + rv = cd9660_add_generic_bootimage(diskStructure, buf); + break; + default: + if (strcmp(name, "bootimagedir") == 0) { + /* + * XXXfvdl this is unused. + */ + if (buf[0] == '\0') { + warnx("The Boot Image Directory parameter" + " requires a directory name\n"); + rv = 0; + } else { + diskStructure->boot_image_directory = + malloc(strlen(buf) + 1); + if (diskStructure->boot_image_directory == NULL) + err(1, "malloc"); + /* BIG TODO: Add the max length function here */ + rv = cd9660_arguments_set_string(buf, desc, 12, + 'd', diskStructure->boot_image_directory); + } + } else if (strcmp(name, "no-emul-boot") == 0 || + strcmp(name, "no-boot") == 0 || + strcmp(name, "hard-disk-boot") == 0) { + /* RRIP */ + cd9660_eltorito_add_boot_option(diskStructure, name, 0); + rv = 1; + } else if (strcmp(name, "boot-load-segment") == 0) { + if (buf[0] == '\0') { + warnx("Option `%s' doesn't contain a value", + name); + rv = 0; + } else { + cd9660_eltorito_add_boot_option(diskStructure, + name, buf); + rv = 1; + } + } else + rv = 1; } - - free(var); - return (rv); + return rv; } /* Modified: stable/11/usr.sbin/makefs/cd9660.h ============================================================================== --- stable/11/usr.sbin/makefs/cd9660.h Wed Apr 25 01:12:40 2018 (r332977) +++ stable/11/usr.sbin/makefs/cd9660.h Wed Apr 25 01:20:25 2018 (r332978) @@ -122,12 +122,6 @@ typedef struct { #define CD9660_MEM_ALLOC_ERROR(_F) \ err(EXIT_FAILURE, "%s, %s l. %d", _F, __FILE__, __LINE__) -#define CD9660_IS_COMMAND_ARG_DUAL(var,short,long)\ - (strcmp((var),(short)) == 0) || (strcmp((var),(long))==0) - -#define CD9660_IS_COMMAND_ARG(var,arg)\ - (strcmp((var),(arg)) == 0) - #define CD9660_TYPE_FILE 0x01 #define CD9660_TYPE_DIR 0x02 #define CD9660_TYPE_DOT 0x04 Modified: stable/11/usr.sbin/makefs/ffs.c ============================================================================== --- stable/11/usr.sbin/makefs/ffs.c Wed Apr 25 01:12:40 2018 (r332977) +++ stable/11/usr.sbin/makefs/ffs.c Wed Apr 25 01:20:25 2018 (r332978) @@ -144,7 +144,6 @@ static void *ffs_build_dinode2(struct ufs2_dinode *, int sectorsize; /* XXX: for buf.c::getblk() */ - /* publicly visible functions */ void @@ -155,7 +154,33 @@ ffs_prep_opts(fsinfo_t *fsopts) if ((ffs_opts = calloc(1, sizeof(ffs_opt_t))) == NULL) err(1, "Allocating memory for ffs_options"); - fsopts->fs_specific = ffs_opts; + const option_t ffs_options[] = { + { 'b', "bsize", &ffs_opts->bsize, OPT_INT32, + 1, INT_MAX, "block size" }, + { 'f', "fsize", &ffs_opts->fsize, OPT_INT32, + 1, INT_MAX, "fragment size" }, + { 'd', "density", &ffs_opts->density, OPT_INT32, + 1, INT_MAX, "bytes per inode" }, + { 'm', "minfree", &ffs_opts->minfree, OPT_INT32, + 0, 99, "minfree" }, + { 'M', "maxbpg", &ffs_opts->maxbpg, OPT_INT32, + 1, INT_MAX, "max blocks per file in a cg" }, + { 'a', "avgfilesize", &ffs_opts->avgfilesize, OPT_INT32, + 1, INT_MAX, "expected average file size" }, + { 'n', "avgfpdir", &ffs_opts->avgfpdir, OPT_INT32, + 1, INT_MAX, "expected # of files per directory" }, + { 'x', "extent", &ffs_opts->maxbsize, OPT_INT32, + 1, INT_MAX, "maximum # extent size" }, + { 'g', "maxbpcg", &ffs_opts->maxblkspercg, OPT_INT32, + 1, INT_MAX, "max # of blocks per group" }, + { 'v', "version", &ffs_opts->version, OPT_INT32, + 1, 2, "UFS version" }, + { 'o', "optimization", NULL, OPT_STRBUF, + 0, 0, "Optimization (time|space)" }, + { 'l', "label", ffs_opts->label, OPT_STRARRAY, + 1, sizeof(ffs_opts->label), "UFS label" }, + { .name = NULL } + }; ffs_opts->bsize= -1; ffs_opts->fsize= -1; @@ -168,45 +193,25 @@ ffs_prep_opts(fsinfo_t *fsopts) ffs_opts->avgfilesize= -1; ffs_opts->avgfpdir= -1; ffs_opts->version = 1; + + fsopts->fs_specific = ffs_opts; + fsopts->fs_options = copy_opts(ffs_options); } void ffs_cleanup_opts(fsinfo_t *fsopts) { - if (fsopts->fs_specific) - free(fsopts->fs_specific); + free(fsopts->fs_specific); + free(fsopts->fs_options); } int ffs_parse_opts(const char *option, fsinfo_t *fsopts) { ffs_opt_t *ffs_opts = fsopts->fs_specific; + option_t *ffs_options = fsopts->fs_options; + char buf[1024]; - option_t ffs_options[] = { - { "bsize", &ffs_opts->bsize, 1, INT_MAX, - "block size" }, - { "fsize", &ffs_opts->fsize, 1, INT_MAX, - "fragment size" }, - { "density", &ffs_opts->density, 1, INT_MAX, - "bytes per inode" }, - { "minfree", &ffs_opts->minfree, 0, 99, - "minfree" }, - { "maxbpg", &ffs_opts->maxbpg, 1, INT_MAX, - "max blocks per file in a cg" }, - { "avgfilesize", &ffs_opts->avgfilesize,1, INT_MAX, - "expected average file size" }, - { "avgfpdir", &ffs_opts->avgfpdir, 1, INT_MAX, - "expected # of files per directory" }, - { "extent", &ffs_opts->maxbsize, 1, INT_MAX, - "maximum # extent size" }, - { "maxbpcg", &ffs_opts->maxblkspercg,1, INT_MAX, - "max # of blocks per group" }, - { "version", &ffs_opts->version, 1, 2, - "UFS version" }, - { .name = NULL } - }; - - char *var, *val; int rv; assert(option != NULL); @@ -216,36 +221,28 @@ ffs_parse_opts(const char *option, fsinfo_t *fsopts) if (debug & DEBUG_FS_PARSE_OPTS) printf("ffs_parse_opts: got `%s'\n", option); - if ((var = strdup(option)) == NULL) - err(1, "Allocating memory for copy of option string"); - rv = 0; + rv = set_option(ffs_options, option, buf, sizeof(buf)); + if (rv == -1) + return 0; - if ((val = strchr(var, '=')) == NULL) { - warnx("Option `%s' doesn't contain a value", var); - goto leave_ffs_parse_opts; - } - *val++ = '\0'; + if (ffs_options[rv].name == NULL) + abort(); - if (strcmp(var, "optimization") == 0) { - if (strcmp(val, "time") == 0) { + switch (ffs_options[rv].letter) { + case 'o': + if (strcmp(buf, "time") == 0) { ffs_opts->optimization = FS_OPTTIME; - } else if (strcmp(val, "space") == 0) { + } else if (strcmp(buf, "space") == 0) { ffs_opts->optimization = FS_OPTSPACE; } else { - warnx("Invalid optimization `%s'", val); - goto leave_ffs_parse_opts; + warnx("Invalid optimization `%s'", buf); + return 0; } - rv = 1; - } else if (strcmp(var, "label") == 0) { - strlcpy(ffs_opts->label, val, sizeof(ffs_opts->label)); - rv = 1; - } else - rv = set_option(ffs_options, var, val); - - leave_ffs_parse_opts: - if (var) - free(var); - return (rv); + break; + default: + break; + } + return 1; } Modified: stable/11/usr.sbin/makefs/makefs.c ============================================================================== --- stable/11/usr.sbin/makefs/makefs.c Wed Apr 25 01:12:40 2018 (r332977) +++ stable/11/usr.sbin/makefs/makefs.c Wed Apr 25 01:20:25 2018 (r332978) @@ -51,6 +51,7 @@ __FBSDID("$FreeBSD$"); #include #include #include +#include #include "makefs.h" #include "mtree.h" @@ -84,7 +85,7 @@ struct stat stampst; static fstype_t *get_fstype(const char *); static int get_tstamp(const char *, struct stat *); -static void usage(void); +static void usage(fstype_t *, fsinfo_t *); int main(int, char *[]); int @@ -140,7 +141,7 @@ main(int argc, char *argv[]) #endif } else { warnx("Invalid endian `%s'.", optarg); - usage(); + usage(fstype, &fsoptions); } break; @@ -209,7 +210,7 @@ main(int argc, char *argv[]) if (*p == '\0') errx(1, "Empty option"); if (! fstype->parse_options(p, &fsoptions)) - usage(); + usage(fstype, &fsoptions); } break; } @@ -262,7 +263,7 @@ main(int argc, char *argv[]) case '?': default: - usage(); + usage(fstype, &fsoptions); /* NOTREACHED */ } @@ -277,7 +278,7 @@ main(int argc, char *argv[]) argv += optind; if (argc < 2) - usage(); + usage(fstype, &fsoptions); /* -x must be accompanied by -F */ if (fsoptions.onlyspec != 0 && specfile == NULL) @@ -343,21 +344,84 @@ main(int argc, char *argv[]) /* NOTREACHED */ } +int +set_option(const option_t *options, const char *option, char *buf, size_t len) +{ + char *var, *val; + int retval; + assert(option != NULL); + + if ((var = strdup(option)) == NULL) { + err(EXIT_FAILURE, "Allocating memory for copy of option string"); + } + + for (val = var; *val; val++) + if (*val == '=') { + *val++ = '\0'; + break; + } + retval = set_option_var(options, var, val, buf, len); + free(var); + return retval; +} + int -set_option(option_t *options, const char *var, const char *val) +set_option_var(const option_t *options, const char *var, const char *val, + char *buf, size_t len) { - int i; + char *s; + size_t i; +#define NUM(type) \ + if (!*val) { \ + *(type *)options[i].value = 1; \ + break; \ + } \ + *(type *)options[i].value = (type)strsuftoll(options[i].desc, val, \ + options[i].minimum, options[i].maximum); break + for (i = 0; options[i].name != NULL; i++) { - if (strcmp(options[i].name, var) != 0) + if (var[1] == '\0') { + if (options[i].letter != var[0]) + continue; + } else if (strcmp(options[i].name, var) != 0) continue; - *options[i].value = (int)strsuftoll(options[i].desc, val, - options[i].minimum, options[i].maximum); - return (1); + switch (options[i].type) { + case OPT_BOOL: + *(bool *)options[i].value = 1; + break; + case OPT_STRARRAY: + strlcpy((void *)options[i].value, val, (size_t) + options[i].maximum); + break; + case OPT_STRPTR: + if ((s = strdup(val)) == NULL) + err(1, NULL); + *(char **)options[i].value = s; + break; + case OPT_STRBUF: + if (buf == NULL) + abort(); + strlcpy(buf, val, len); + break; + case OPT_INT64: + NUM(uint64_t); + case OPT_INT32: + NUM(uint32_t); + case OPT_INT16: + NUM(uint16_t); + case OPT_INT8: + NUM(uint8_t); + default: + warnx("Unknown type %d in option %s", options[i].type, + val); + return 0; + } + return i; } warnx("Unknown option `%s'", var); - return (0); + return -1; } @@ -372,6 +436,20 @@ get_fstype(const char *type) return (NULL); } +option_t * +copy_opts(const option_t *o) +{ + size_t i; + void *rv; + + for (i = 0; o[i].name; i++) + continue; + i++; + if ((rv = calloc(i, sizeof(*o))) == NULL) + err(1, "calloc"); + return memcpy(rv, o, i * sizeof(*o)); +} + static int get_tstamp(const char *b, struct stat *st) { @@ -399,17 +477,29 @@ get_tstamp(const char *b, struct stat *st) } static void -usage(void) +usage(fstype_t *fstype, fsinfo_t *fsoptions) { const char *prog; prog = getprogname(); fprintf(stderr, -"usage: %s [-xZ] [-B endian] [-b free-blocks] [-d debug-mask]\n" +"Usage: %s [-xZ] [-B endian] [-b free-blocks] [-d debug-mask]\n" "\t[-F mtree-specfile] [-f free-files] [-M minimum-size] [-m maximum-size]\n" "\t[-N userdb-dir] [-o fs-options] [-R roundup-size] [-S sector-size]\n" "\t[-s image-size] [-T ] [-t fs-type]\n" "\timage-file directory | manifest [extra-directory ...]\n", prog); + + if (fstype) { + size_t i; + option_t *o = fsoptions->fs_options; + + fprintf(stderr, "\n%s specific options:\n", fstype->type); + for (i = 0; o[i].name != NULL; i++) + fprintf(stderr, "\t%c%c%20.20s\t%s\n", + o[i].letter ? o[i].letter : ' ', + o[i].letter ? ',' : ' ', + o[i].name, o[i].desc); + } exit(1); } Modified: stable/11/usr.sbin/makefs/makefs.h ============================================================================== --- stable/11/usr.sbin/makefs/makefs.h Wed Apr 25 01:12:40 2018 (r332977) +++ stable/11/usr.sbin/makefs/makefs.h Wed Apr 25 01:20:25 2018 (r332978) @@ -106,11 +106,37 @@ typedef struct _fsnode { #define FSNODE_F_OPTIONAL 0x02 /* fsnode is optional */ /* + * option_t - contains option name, description, pointer to location to store + * result, and range checks for the result. Used to simplify fs specific + * option setting + */ +typedef enum { + OPT_STRARRAY, + OPT_STRPTR, + OPT_STRBUF, + OPT_BOOL, + OPT_INT8, + OPT_INT16, + OPT_INT32, + OPT_INT64 +} opttype_t; + +typedef struct { + char letter; /* option letter NUL for none */ + const char *name; /* option name */ + void *value; /* where to stuff the value */ + opttype_t type; /* type of entry */ + long long minimum; /* minimum for value */ + long long maximum; /* maximum for value */ + const char *desc; /* option description */ +} option_t; + +/* * fsinfo_t - contains various settings and parameters pertaining to * the image, including current settings, global options, and fs * specific options */ -typedef struct { +typedef struct makefs_fsinfo { /* current settings */ off_t size; /* total size */ off_t inodes; /* number of inodes */ @@ -135,30 +161,20 @@ typedef struct { int sparse; /* sparse image, don't fill it with zeros */ void *fs_specific; /* File system specific additions. */ + option_t *fs_options; /* File system specific options */ } fsinfo_t; -/* - * option_t - contains option name, description, pointer to location to store - * result, and range checks for the result. Used to simplify fs specific - * option setting - */ -typedef struct { - const char *name; /* option name */ - int *value; /* where to stuff the value */ - int minimum; /* minimum for value */ - int maximum; /* maximum for value */ - const char *desc; /* option description */ -} option_t; - - void apply_specfile(const char *, const char *, fsnode *, int); void dump_fsnodes(fsnode *); const char * inode_type(mode_t); fsnode * read_mtree(const char *, fsnode *); -int set_option(option_t *, const char *, const char *); +int set_option(const option_t *, const char *, char *, size_t); +int set_option_var(const option_t *, const char *, const char *, + char *, size_t); fsnode * walk_dir(const char *, const char *, fsnode *, fsnode *); void free_fsnodes(fsnode *); +option_t * copy_opts(const option_t *); void ffs_prep_opts(fsinfo_t *); int ffs_parse_opts(const char *, fsinfo_t *); From owner-svn-src-stable-11@freebsd.org Wed Apr 25 01:30:31 2018 Return-Path: Delivered-To: svn-src-stable-11@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 BD855FB9DED; Wed, 25 Apr 2018 01:30:30 +0000 (UTC) (envelope-from benno@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 6D76574A25; Wed, 25 Apr 2018 01:30:30 +0000 (UTC) (envelope-from benno@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 683FF227BD; Wed, 25 Apr 2018 01:30:30 +0000 (UTC) (envelope-from benno@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id w3P1UUZZ079819; Wed, 25 Apr 2018 01:30:30 GMT (envelope-from benno@FreeBSD.org) Received: (from benno@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id w3P1UTEh079816; Wed, 25 Apr 2018 01:30:29 GMT (envelope-from benno@FreeBSD.org) Message-Id: <201804250130.w3P1UTEh079816@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: benno set sender to benno@FreeBSD.org using -f From: Benno Rice Date: Wed, 25 Apr 2018 01:30:29 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-11@freebsd.org Subject: svn commit: r332979 - stable/11/lib/libnetbsd X-SVN-Group: stable-11 X-SVN-Commit-Author: benno X-SVN-Commit-Paths: stable/11/lib/libnetbsd X-SVN-Commit-Revision: 332979 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable-11@freebsd.org X-Mailman-Version: 2.1.25 Precedence: list List-Id: SVN commit messages for only the 11-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 25 Apr 2018 01:30:31 -0000 Author: benno Date: Wed Apr 25 01:30:29 2018 New Revision: 332979 URL: https://svnweb.freebsd.org/changeset/base/332979 Log: MFC r316572 libnetbsd: add emalloc and friends These are error-checked versions of memory allocation routines used by NetBSD code, and are being added to facilitate updates to makefs. Sponsored by: iXsystems, Inc. Added: stable/11/lib/libnetbsd/efun.c - copied unchanged from r316572, head/lib/libnetbsd/efun.c Modified: stable/11/lib/libnetbsd/Makefile stable/11/lib/libnetbsd/util.h Directory Properties: stable/11/ (props changed) Modified: stable/11/lib/libnetbsd/Makefile ============================================================================== --- stable/11/lib/libnetbsd/Makefile Wed Apr 25 01:20:25 2018 (r332978) +++ stable/11/lib/libnetbsd/Makefile Wed Apr 25 01:30:29 2018 (r332979) @@ -7,7 +7,7 @@ LIB= netbsd CFLAGS+= -I${.CURDIR} -SRCS+= sockaddr_snprintf.c strsuftoll.c util.c util.h +SRCS+= efun.c sockaddr_snprintf.c strsuftoll.c util.c util.h INTERNALLIB= Copied: stable/11/lib/libnetbsd/efun.c (from r316572, head/lib/libnetbsd/efun.c) ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ stable/11/lib/libnetbsd/efun.c Wed Apr 25 01:30:29 2018 (r332979, copy of r316572, head/lib/libnetbsd/efun.c) @@ -0,0 +1,160 @@ +/* $NetBSD: efun.c,v 1.10 2015/07/26 02:20:30 kamil Exp $ */ +/* $FreeBSD$ */ + +/*- + * Copyright (c) 2006 The NetBSD Foundation, Inc. + * All rights reserved. + * + * This code is derived from software contributed to The NetBSD Foundation + * by Christos Zoulas. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS + * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED + * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS + * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + */ + +#if HAVE_NBTOOL_CONFIG_H +#include "nbtool_config.h" +#endif + +#include +#ifdef __RCSID +__RCSID("$NetBSD: efun.c,v 1.10 2015/07/26 02:20:30 kamil Exp $"); +#endif + +#include +#include +#include +#include +#include +#include +#include +#include + +static void (*efunc)(int, const char *, ...) = err; + +void (* +esetfunc(void (*ef)(int, const char *, ...)))(int, const char *, ...) +{ + void (*of)(int, const char *, ...) = efunc; + efunc = ef == NULL ? (void (*)(int, const char *, ...))exit : ef; + return of; +} + +size_t +estrlcpy(char *dst, const char *src, size_t len) +{ + size_t rv; + if ((rv = strlcpy(dst, src, len)) >= len) { + errno = ENAMETOOLONG; + (*efunc)(1, + "Cannot copy string; %zu chars needed %zu provided", + rv, len); + } + return rv; +} + +size_t +estrlcat(char *dst, const char *src, size_t len) +{ + size_t rv; + if ((rv = strlcat(dst, src, len)) >= len) { + errno = ENAMETOOLONG; + (*efunc)(1, + "Cannot append to string; %zu chars needed %zu provided", + rv, len); + } + return rv; +} + +char * +estrdup(const char *s) +{ + char *d = strdup(s); + if (d == NULL) + (*efunc)(1, "Cannot copy string"); + return d; +} + +char * +estrndup(const char *s, size_t len) +{ + char *d = strndup(s, len); + if (d == NULL) + (*efunc)(1, "Cannot copy string"); + return d; +} + +void * +emalloc(size_t n) +{ + void *p = malloc(n); + if (p == NULL && n != 0) + (*efunc)(1, "Cannot allocate %zu bytes", n); + return p; +} + +void * +ecalloc(size_t n, size_t s) +{ + void *p = calloc(n, s); + if (p == NULL && n != 0 && s != 0) + (*efunc)(1, "Cannot allocate %zu blocks of size %zu", n, s); + return p; +} + +void * +erealloc(void *p, size_t n) +{ + void *q = realloc(p, n); + if (q == NULL && n != 0) + (*efunc)(1, "Cannot re-allocate %zu bytes", n); + return q; +} + +FILE * +efopen(const char *p, const char *m) +{ + FILE *fp = fopen(p, m); + if (fp == NULL) + (*efunc)(1, "Cannot open `%s'", p); + return fp; +} + +int +easprintf(char ** __restrict ret, const char * __restrict format, ...) +{ + int rv; + va_list ap; + va_start(ap, format); + if ((rv = vasprintf(ret, format, ap)) == -1) + (*efunc)(1, "Cannot format string"); + va_end(ap); + return rv; +} + +int +evasprintf(char ** __restrict ret, const char * __restrict format, va_list ap) +{ + int rv; + if ((rv = vasprintf(ret, format, ap)) == -1) + (*efunc)(1, "Cannot format string"); + return rv; +} Modified: stable/11/lib/libnetbsd/util.h ============================================================================== --- stable/11/lib/libnetbsd/util.h Wed Apr 25 01:20:25 2018 (r332978) +++ stable/11/lib/libnetbsd/util.h Wed Apr 25 01:30:29 2018 (r332979) @@ -36,6 +36,19 @@ #include #include +void (*esetfunc(void (*)(int, const char *, ...)))(int, const char *, ...); +size_t estrlcpy(char *, const char *, size_t); +size_t estrlcat(char *, const char *, size_t); +char *estrdup(const char *); +char *estrndup(const char *, size_t); +void *emalloc(size_t); +void *ecalloc(size_t, size_t); +void *erealloc(void *, size_t); +struct __sFILE *efopen(const char *, const char *); +int easprintf(char ** __restrict, const char * __restrict, ...) + __printflike(2, 3); +int evasprintf(char ** __restrict, const char * __restrict, __va_list) + __printflike(2, 0); char *flags_to_string(u_long flags, const char *def); int sockaddr_snprintf(char *, size_t, const char *, const struct sockaddr *); From owner-svn-src-stable-11@freebsd.org Wed Apr 25 01:35:07 2018 Return-Path: Delivered-To: svn-src-stable-11@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 9BFB4FB9FEE; Wed, 25 Apr 2018 01:35:07 +0000 (UTC) (envelope-from benno@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 47DCB774F7; Wed, 25 Apr 2018 01:35:07 +0000 (UTC) (envelope-from benno@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 4284E22958; Wed, 25 Apr 2018 01:35:07 +0000 (UTC) (envelope-from benno@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id w3P1Z7J6084507; Wed, 25 Apr 2018 01:35:07 GMT (envelope-from benno@FreeBSD.org) Received: (from benno@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id w3P1Z6Xt084500; Wed, 25 Apr 2018 01:35:06 GMT (envelope-from benno@FreeBSD.org) Message-Id: <201804250135.w3P1Z6Xt084500@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: benno set sender to benno@FreeBSD.org using -f From: Benno Rice Date: Wed, 25 Apr 2018 01:35:06 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-11@freebsd.org Subject: svn commit: r332980 - in stable/11/usr.sbin/makefs: . cd9660 ffs X-SVN-Group: stable-11 X-SVN-Commit-Author: benno X-SVN-Commit-Paths: in stable/11/usr.sbin/makefs: . cd9660 ffs X-SVN-Commit-Revision: 332980 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable-11@freebsd.org X-Mailman-Version: 2.1.25 Precedence: list List-Id: SVN commit messages for only the 11-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 25 Apr 2018 01:35:07 -0000 Author: benno Date: Wed Apr 25 01:35:06 2018 New Revision: 332980 URL: https://svnweb.freebsd.org/changeset/base/332980 Log: MFC r307927 Be more precise when including headers so that we're less likely to depend on namespace pollution and as such become more portable. This means including headers like or , but also making sure we include system/host headers before local headers. While here: define ENOATTR as ENOMSG in mtree.c. There is no ENOATTR on Linux. With this, makefs is ready for compilation on macOS and Linux. Sponsored by: iXsystems, Inc. Modified: stable/11/usr.sbin/makefs/cd9660.c stable/11/usr.sbin/makefs/cd9660/cd9660_archimedes.c stable/11/usr.sbin/makefs/cd9660/iso9660_rrip.c stable/11/usr.sbin/makefs/ffs/ffs_bswap.c stable/11/usr.sbin/makefs/ffs/ffs_subr.c stable/11/usr.sbin/makefs/mtree.c stable/11/usr.sbin/makefs/walk.c Directory Properties: stable/11/ (props changed) Modified: stable/11/usr.sbin/makefs/cd9660.c ============================================================================== --- stable/11/usr.sbin/makefs/cd9660.c Wed Apr 25 01:30:29 2018 (r332979) +++ stable/11/usr.sbin/makefs/cd9660.c Wed Apr 25 01:35:06 2018 (r332980) @@ -100,10 +100,11 @@ #include __FBSDID("$FreeBSD$"); -#include -#include #include #include +#include +#include +#include #include "makefs.h" #include "cd9660.h" Modified: stable/11/usr.sbin/makefs/cd9660/cd9660_archimedes.c ============================================================================== --- stable/11/usr.sbin/makefs/cd9660/cd9660_archimedes.c Wed Apr 25 01:30:29 2018 (r332979) +++ stable/11/usr.sbin/makefs/cd9660/cd9660_archimedes.c Wed Apr 25 01:35:06 2018 (r332980) @@ -42,9 +42,11 @@ #include __FBSDID("$FreeBSD$"); +#include #include #include #include +#include #include #include "makefs.h" Modified: stable/11/usr.sbin/makefs/cd9660/iso9660_rrip.c ============================================================================== --- stable/11/usr.sbin/makefs/cd9660/iso9660_rrip.c Wed Apr 25 01:30:29 2018 (r332979) +++ stable/11/usr.sbin/makefs/cd9660/iso9660_rrip.c Wed Apr 25 01:35:06 2018 (r332980) @@ -37,14 +37,16 @@ * defined in iso9660_rrip.h */ -#include "makefs.h" -#include "cd9660.h" -#include "iso9660_rrip.h" +#include +__FBSDID("$FreeBSD$"); + #include +#include #include -#include -__FBSDID("$FreeBSD$"); +#include "makefs.h" +#include "cd9660.h" +#include "iso9660_rrip.h" static void cd9660_rrip_initialize_inode(cd9660node *); static int cd9660_susp_handle_continuation(iso9660_disk *, cd9660node *); Modified: stable/11/usr.sbin/makefs/ffs/ffs_bswap.c ============================================================================== --- stable/11/usr.sbin/makefs/ffs/ffs_bswap.c Wed Apr 25 01:30:29 2018 (r332979) +++ stable/11/usr.sbin/makefs/ffs/ffs_bswap.c Wed Apr 25 01:35:06 2018 (r332980) @@ -40,17 +40,18 @@ __FBSDID("$FreeBSD$"); #include #endif -#include -#include "ffs/ufs_bswap.h" -#include - #if !defined(_KERNEL) #include +#include #include #include #include #define panic(x) printf("%s\n", (x)), abort() #endif + +#include +#include "ffs/ufs_bswap.h" +#include #define fs_old_postbloff fs_spare5[0] #define fs_old_rotbloff fs_spare5[1] Modified: stable/11/usr.sbin/makefs/ffs/ffs_subr.c ============================================================================== --- stable/11/usr.sbin/makefs/ffs/ffs_subr.c Wed Apr 25 01:30:29 2018 (r332979) +++ stable/11/usr.sbin/makefs/ffs/ffs_subr.c Wed Apr 25 01:35:06 2018 (r332980) @@ -35,6 +35,7 @@ __FBSDID("$FreeBSD$"); #include +#include #include #include Modified: stable/11/usr.sbin/makefs/mtree.c ============================================================================== --- stable/11/usr.sbin/makefs/mtree.c Wed Apr 25 01:30:29 2018 (r332979) +++ stable/11/usr.sbin/makefs/mtree.c Wed Apr 25 01:35:06 2018 (r332980) @@ -46,10 +46,15 @@ __FBSDID("$FreeBSD$"); #include #include #include +#include #include #include #include "makefs.h" + +#ifndef ENOATTR +#define ENOATTR ENOMSG +#endif #define IS_DOT(nm) ((nm)[0] == '.' && (nm)[1] == '\0') #define IS_DOTDOT(nm) ((nm)[0] == '.' && (nm)[1] == '.' && (nm)[2] == '\0') Modified: stable/11/usr.sbin/makefs/walk.c ============================================================================== --- stable/11/usr.sbin/makefs/walk.c Wed Apr 25 01:30:29 2018 (r332979) +++ stable/11/usr.sbin/makefs/walk.c Wed Apr 25 01:35:06 2018 (r332980) @@ -42,6 +42,7 @@ __FBSDID("$FreeBSD$"); #include +#include #include #include From owner-svn-src-stable-11@freebsd.org Wed Apr 25 01:48:17 2018 Return-Path: Delivered-To: svn-src-stable-11@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 6BAC2FBA233; Wed, 25 Apr 2018 01:48:17 +0000 (UTC) (envelope-from benno@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 18649790CA; Wed, 25 Apr 2018 01:48:17 +0000 (UTC) (envelope-from benno@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 0EDD622AE1; Wed, 25 Apr 2018 01:48:17 +0000 (UTC) (envelope-from benno@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id w3P1mGiH089412; Wed, 25 Apr 2018 01:48:16 GMT (envelope-from benno@FreeBSD.org) Received: (from benno@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id w3P1mFDg089401; Wed, 25 Apr 2018 01:48:15 GMT (envelope-from benno@FreeBSD.org) Message-Id: <201804250148.w3P1mFDg089401@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: benno set sender to benno@FreeBSD.org using -f From: Benno Rice Date: Wed, 25 Apr 2018 01:48:15 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-11@freebsd.org Subject: svn commit: r332981 - in stable/11/usr.sbin/makefs: . cd9660 ffs X-SVN-Group: stable-11 X-SVN-Commit-Author: benno X-SVN-Commit-Paths: in stable/11/usr.sbin/makefs: . cd9660 ffs X-SVN-Commit-Revision: 332981 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable-11@freebsd.org X-Mailman-Version: 2.1.25 Precedence: list List-Id: SVN commit messages for only the 11-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 25 Apr 2018 01:48:17 -0000 Author: benno Date: Wed Apr 25 01:48:15 2018 New Revision: 332981 URL: https://svnweb.freebsd.org/changeset/base/332981 Log: MFC r316579 makefs: use emalloc and friends The emalloc set of error-checking memory allocation routines were added to libnetbsd in r316572. Use them in makefs to reduce differences with NetBSD. NetBSD revs: cd9660.c 1.39 ffs.c 1.56 makefs.c 1.42 walk.c 1.27 cd9660/cd9660_archimedes.c 1.2 cd9660/cd9660_eltorito.c 1.20 cd9660/cd9660_write.c 1.16 cd9660/iso9660_rrip.c 1.12 ffs/buf.c 1.17 ffs/mkfs.c 1.26 Sponsored by: iXsystems, Inc. Modified: stable/11/usr.sbin/makefs/cd9660.c stable/11/usr.sbin/makefs/cd9660/cd9660_archimedes.c stable/11/usr.sbin/makefs/cd9660/cd9660_eltorito.c stable/11/usr.sbin/makefs/cd9660/cd9660_write.c stable/11/usr.sbin/makefs/cd9660/iso9660_rrip.c stable/11/usr.sbin/makefs/ffs.c stable/11/usr.sbin/makefs/ffs/buf.c stable/11/usr.sbin/makefs/ffs/mkfs.c stable/11/usr.sbin/makefs/makefs.c stable/11/usr.sbin/makefs/mtree.c stable/11/usr.sbin/makefs/walk.c Directory Properties: stable/11/ (props changed) Modified: stable/11/usr.sbin/makefs/cd9660.c ============================================================================== --- stable/11/usr.sbin/makefs/cd9660.c Wed Apr 25 01:35:06 2018 (r332980) +++ stable/11/usr.sbin/makefs/cd9660.c Wed Apr 25 01:48:15 2018 (r332981) @@ -105,6 +105,7 @@ __FBSDID("$FreeBSD$"); #include #include #include +#include #include "makefs.h" #include "cd9660.h" @@ -173,10 +174,8 @@ static cd9660node *cd9660_create_special_directory(iso static cd9660node * cd9660_allocate_cd9660node(void) { - cd9660node *temp; + cd9660node *temp = ecalloc(1, sizeof(*temp)); - if ((temp = calloc(1, sizeof(cd9660node))) == NULL) - err(EXIT_FAILURE, "%s: calloc", __func__); TAILQ_INIT(&temp->cn_children); temp->parent = temp->dot_record = temp->dot_dot_record = NULL; temp->ptnext = temp->ptprev = temp->ptlast = NULL; @@ -253,11 +252,8 @@ cd9660_set_defaults(iso9660_disk *diskStructure) void cd9660_prep_opts(fsinfo_t *fsopts) { - iso9660_disk *diskStructure; + iso9660_disk *diskStructure = ecalloc(1, sizeof(*diskStructure)); - if ((diskStructure = calloc(1, sizeof(*diskStructure))) == NULL) - err(EXIT_FAILURE, "%s: calloc", __func__); - #define OPT_STR(letter, name, desc) \ { letter, name, NULL, OPT_STRBUF, 0, 0, desc } @@ -440,9 +436,7 @@ cd9660_parse_opts(const char *option, fsinfo_t *fsopts rv = 0; } else { diskStructure->boot_image_directory = - malloc(strlen(buf) + 1); - if (diskStructure->boot_image_directory == NULL) - err(1, "malloc"); + emalloc(strlen(buf) + 1); /* BIG TODO: Add the max length function here */ rv = cd9660_arguments_set_string(buf, desc, 12, 'd', diskStructure->boot_image_directory); @@ -522,12 +516,7 @@ cd9660_makefs(const char *image, const char *dir, fsno /* Actually, we now need to add the REAL root node, at level 0 */ real_root = cd9660_allocate_cd9660node(); - if ((real_root->isoDirRecord = - malloc( sizeof(iso_directory_record_cd9660) )) == NULL) { - CD9660_MEM_ALLOC_ERROR("cd9660_makefs"); - exit(1); - } - + real_root->isoDirRecord = emalloc(sizeof(*real_root->isoDirRecord)); /* Leave filename blank for root */ memset(real_root->isoDirRecord->name, 0, ISO_FILENAME_MAXLENGTH_WITH_PADDING); @@ -769,11 +758,7 @@ cd9660_setup_volume_descriptors(iso9660_disk *diskStru volume_descriptor *temp, *t; /* Set up the PVD */ - if ((temp = malloc(sizeof(volume_descriptor))) == NULL) { - CD9660_MEM_ALLOC_ERROR("cd9660_setup_volume_descriptors"); - exit(1); - } - + temp = emalloc(sizeof(*temp)); temp->volumeDescriptorData = (unsigned char *)&diskStructure->primaryDescriptor; temp->volumeDescriptorData[0] = ISO_VOLUME_DESCRIPTOR_PVD; @@ -786,19 +771,10 @@ cd9660_setup_volume_descriptors(iso9660_disk *diskStru sector++; /* Set up boot support if enabled. BVD must reside in sector 17 */ if (diskStructure->is_bootable) { - if ((t = malloc(sizeof(volume_descriptor))) == NULL) { - CD9660_MEM_ALLOC_ERROR( - "cd9660_setup_volume_descriptors"); - exit(1); - } - if ((t->volumeDescriptorData = malloc(2048)) == NULL) { - CD9660_MEM_ALLOC_ERROR( - "cd9660_setup_volume_descriptors"); - exit(1); - } + t = emalloc(sizeof(*t)); + t->volumeDescriptorData = ecalloc(1, 2048); temp->next = t; temp = t; - memset(t->volumeDescriptorData, 0, 2048); t->sector = 17; if (diskStructure->verbose_level > 0) printf("Setting up boot volume descriptor\n"); @@ -807,17 +783,9 @@ cd9660_setup_volume_descriptors(iso9660_disk *diskStru } /* Set up the terminator */ - if ((t = malloc(sizeof(volume_descriptor))) == NULL) { - CD9660_MEM_ALLOC_ERROR("cd9660_setup_volume_descriptors"); - exit(1); - } - if ((t->volumeDescriptorData = malloc(2048)) == NULL) { - CD9660_MEM_ALLOC_ERROR("cd9660_setup_volume_descriptors"); - exit(1); - } - + t = emalloc(sizeof(*t)); + t->volumeDescriptorData = ecalloc(1, 2048); temp->next = t; - memset(t->volumeDescriptorData, 0, 2048); t->volumeDescriptorData[0] = ISO_VOLUME_DESCRIPTOR_TERMINATOR; t->next = NULL; t->volumeDescriptorData[6] = 1; @@ -837,12 +805,7 @@ cd9660_setup_volume_descriptors(iso9660_disk *diskStru static int cd9660_fill_extended_attribute_record(cd9660node *node) { - if ((node->isoExtAttributes = - malloc(sizeof(struct iso_extended_attributes))) == NULL) { - CD9660_MEM_ALLOC_ERROR("cd9660_fill_extended_attribute_record"); - exit(1); - }; - + node->isoExtAttributes = emalloc(sizeof(*node->isoExtAttributes)); return 1; } #endif @@ -901,12 +864,7 @@ cd9660_translate_node(iso9660_disk *diskStructure, fsn "returning\n"); return 0; } - if ((newnode->isoDirRecord = - malloc(sizeof(iso_directory_record_cd9660))) == NULL) { - CD9660_MEM_ALLOC_ERROR("cd9660_translate_node"); - return 0; - } - + newnode->isoDirRecord = emalloc(sizeof(*newnode->isoDirRecord)); /* Set the node pointer */ newnode->node = node; @@ -1113,7 +1071,7 @@ cd9660_rename_filename(iso9660_disk *diskStructure, cd else maxlength = ISO_FILENAME_MAXLENGTH_BEFORE_VERSION; - tmp = malloc(ISO_FILENAME_MAXLENGTH_WITH_PADDING); + tmp = emalloc(ISO_FILENAME_MAXLENGTH_WITH_PADDING); while (i < num && iter) { powers = 1; @@ -1552,9 +1510,7 @@ struct ptq_entry } *n; #define PTQUEUE_NEW(n,s,r,t){\ - n = malloc(sizeof(struct s)); \ - if (n == NULL) \ - return r; \ + n = emalloc(sizeof(struct s)); \ n->node = t;\ } @@ -2006,25 +1962,10 @@ cd9660_create_virtual_entry(iso9660_disk *diskStructur if (temp == NULL) return NULL; - if ((tfsnode = malloc(sizeof(fsnode))) == NULL) { - CD9660_MEM_ALLOC_ERROR("cd9660_create_virtual_entry"); - return NULL; - } + tfsnode = emalloc(sizeof(*tfsnode)); + tfsnode->name = estrdup(name); + temp->isoDirRecord = emalloc(sizeof(*temp->isoDirRecord)); - /* Assume for now name is a valid length */ - if ((tfsnode->name = malloc(strlen(name) + 1)) == NULL) { - CD9660_MEM_ALLOC_ERROR("cd9660_create_virtual_entry"); - return NULL; - } - - if ((temp->isoDirRecord = - malloc(sizeof(iso_directory_record_cd9660))) == NULL) { - CD9660_MEM_ALLOC_ERROR("cd9660_create_virtual_entry"); - return NULL; - } - - strcpy(tfsnode->name, name); - cd9660_convert_filename(diskStructure, tfsnode->name, temp->isoDirRecord->name, file); @@ -2075,8 +2016,7 @@ cd9660_create_file(iso9660_disk *diskStructure, const temp->type = CD9660_TYPE_FILE | CD9660_TYPE_VIRTUAL; - if ((temp->node->inode = calloc(1, sizeof(fsinode))) == NULL) - return NULL; + temp->node->inode = ecalloc(1, sizeof(*temp->node->inode)); *temp->node->inode = *me->node->inode; if (cd9660_translate_node_common(diskStructure, temp) == 0) @@ -2103,8 +2043,7 @@ cd9660_create_directory(iso9660_disk *diskStructure, c temp->type = CD9660_TYPE_DIR | CD9660_TYPE_VIRTUAL; - if ((temp->node->inode = calloc(1, sizeof(fsinode))) == NULL) - return NULL; + temp->node->inode = ecalloc(1, sizeof(*temp->node->inode)); *temp->node->inode = *me->node->inode; if (cd9660_translate_node_common(diskStructure, temp) == 0) @@ -2172,10 +2111,7 @@ cd9660_add_generic_bootimage(iso9660_disk *diskStructu return 0; } - if ((diskStructure->generic_bootimage = strdup(bootimage)) == NULL) { - warn("%s: strdup", __func__); - return 0; - } + diskStructure->generic_bootimage = estrdup(bootimage); /* Get information about the file */ if (lstat(diskStructure->generic_bootimage, &stbuf) == -1) Modified: stable/11/usr.sbin/makefs/cd9660/cd9660_archimedes.c ============================================================================== --- stable/11/usr.sbin/makefs/cd9660/cd9660_archimedes.c Wed Apr 25 01:35:06 2018 (r332980) +++ stable/11/usr.sbin/makefs/cd9660/cd9660_archimedes.c Wed Apr 25 01:48:15 2018 (r332981) @@ -42,12 +42,11 @@ #include __FBSDID("$FreeBSD$"); -#include #include #include #include -#include #include +#include #include "makefs.h" #include "cd9660.h" @@ -95,11 +94,8 @@ archimedes_convert_node(cd9660node *node) return; if (type == -1) type = 0; - assert(sizeof(struct ISO_ARCHIMEDES) == 32); - if ((arc = calloc(1, sizeof(struct ISO_ARCHIMEDES))) == NULL) { - CD9660_MEM_ALLOC_ERROR("archimedes_convert_node"); - exit(1); - } + assert(sizeof(*arc) == 32); + arc = ecalloc(1, sizeof(*arc)); stamp = riscos_date(node->node->inode->st.st_mtime); Modified: stable/11/usr.sbin/makefs/cd9660/cd9660_eltorito.c ============================================================================== --- stable/11/usr.sbin/makefs/cd9660/cd9660_eltorito.c Wed Apr 25 01:35:06 2018 (r332980) +++ stable/11/usr.sbin/makefs/cd9660/cd9660_eltorito.c Wed Apr 25 01:48:15 2018 (r332981) @@ -36,6 +36,7 @@ #include "cd9660.h" #include "cd9660_eltorito.h" +#include #include __FBSDID("$FreeBSD$"); @@ -75,10 +76,7 @@ cd9660_add_boot_disk(iso9660_disk *diskStructure, cons } /* First decode the boot information */ - if ((temp = strdup(boot_info)) == NULL) { - warn("%s: strdup", __func__); - return 0; - } + temp = estrdup(boot_info); sysname = temp; filename = strchr(sysname, ';'); @@ -95,12 +93,7 @@ cd9660_add_boot_disk(iso9660_disk *diskStructure, cons printf("Found bootdisk with system %s, and filename %s\n", sysname, filename); } - if ((new_image = malloc(sizeof(*new_image))) == NULL) { - warn("%s: malloc", __func__); - free(temp); - return 0; - } - (void)memset(new_image, 0, sizeof(*new_image)); + new_image = ecalloc(1, sizeof(*new_image)); new_image->loadSegment = 0; /* default for now */ /* Decode System */ @@ -120,12 +113,7 @@ cd9660_add_boot_disk(iso9660_disk *diskStructure, cons } - if ((new_image->filename = strdup(filename)) == NULL) { - warn("%s: strdup", __func__); - free(temp); - free(new_image); - return 0; - } + new_image->filename = estrdup(filename); free(temp); @@ -228,12 +216,7 @@ cd9660_eltorito_add_boot_option(iso9660_disk *diskStru static struct boot_catalog_entry * cd9660_init_boot_catalog_entry(void) { - struct boot_catalog_entry *temp; - - if ((temp = malloc(sizeof(*temp))) == NULL) - return NULL; - - return memset(temp, 0, sizeof(*temp)); + return ecalloc(1, sizeof(struct boot_catalog_entry)); } static struct boot_catalog_entry * @@ -246,11 +229,6 @@ cd9660_boot_setup_validation_entry(char sys) int i; entry = cd9660_init_boot_catalog_entry(); - if (entry == NULL) { - warnx("Error: memory allocation failed in " - "cd9660_boot_setup_validation_entry"); - return 0; - } ve = &entry->entry_data.VE; ve->header_id[0] = 1; Modified: stable/11/usr.sbin/makefs/cd9660/cd9660_write.c ============================================================================== --- stable/11/usr.sbin/makefs/cd9660/cd9660_write.c Wed Apr 25 01:35:06 2018 (r332980) +++ stable/11/usr.sbin/makefs/cd9660/cd9660_write.c Wed Apr 25 01:48:15 2018 (r332981) @@ -40,6 +40,8 @@ #include __FBSDID("$FreeBSD$"); +#include + static int cd9660_write_volume_descriptors(iso9660_disk *, FILE *); static int cd9660_write_path_table(iso9660_disk *, FILE *, off_t, int); static int cd9660_write_path_tables(iso9660_disk *, FILE *); @@ -174,14 +176,8 @@ cd9660_write_path_table(iso9660_disk *diskStructure, F path_table_entry temp_entry; cd9660node *ptcur; - buffer = malloc(diskStructure->sectorSize * path_table_sectors); - if (buffer == NULL) { - warnx("%s: Memory allocation error allocating buffer", - __func__); - return 0; - } + buffer = ecalloc(path_table_sectors, diskStructure->sectorSize); buffer_head = buffer; - memset(buffer, 0, diskStructure->sectorSize * path_table_sectors); ptcur = diskStructure->rootNode; @@ -280,16 +276,8 @@ cd9660_write_file(iso9660_disk *diskStructure, FILE *f /* Todo : clean up variables */ - temp_file_name = malloc(CD9660MAXPATH + 1); - if (temp_file_name == NULL) - err(EXIT_FAILURE, "%s: malloc", __func__); - - memset(temp_file_name, 0, CD9660MAXPATH + 1); - - buf = malloc(diskStructure->sectorSize); - if (buf == NULL) - err(EXIT_FAILURE, "%s: malloc", __func__); - + temp_file_name = ecalloc(CD9660MAXPATH + 1, 1); + buf = emalloc(diskStructure->sectorSize); if ((writenode->level != 0) && !(writenode->node->type & S_IFDIR)) { fsinode *inode = writenode->node->inode; @@ -448,10 +436,7 @@ cd9660_copy_file(iso9660_disk *diskStructure, FILE *fd int buf_size = diskStructure->sectorSize; char *buf; - buf = malloc(buf_size); - if (buf == NULL) - err(EXIT_FAILURE, "%s: malloc", __func__); - + buf = emalloc(buf_size); if ((rf = fopen(filename, "rb")) == NULL) { warn("%s: cannot open %s", __func__, filename); free(buf); Modified: stable/11/usr.sbin/makefs/cd9660/iso9660_rrip.c ============================================================================== --- stable/11/usr.sbin/makefs/cd9660/iso9660_rrip.c Wed Apr 25 01:35:06 2018 (r332980) +++ stable/11/usr.sbin/makefs/cd9660/iso9660_rrip.c Wed Apr 25 01:48:15 2018 (r332981) @@ -47,6 +47,7 @@ __FBSDID("$FreeBSD$"); #include "makefs.h" #include "cd9660.h" #include "iso9660_rrip.h" +#include static void cd9660_rrip_initialize_inode(cd9660node *); static int cd9660_susp_handle_continuation(iso9660_disk *, cd9660node *); @@ -460,11 +461,7 @@ cd9660node_susp_create_node(int susp_type, int entry_t { struct ISO_SUSP_ATTRIBUTES* temp; - if ((temp = malloc(sizeof(struct ISO_SUSP_ATTRIBUTES))) == NULL) { - CD9660_MEM_ALLOC_ERROR("cd9660node_susp_create_node"); - exit(1); - } - + temp = emalloc(sizeof(*temp)); temp->susp_type = susp_type; temp->entry_type = entry_type; temp->last_in_suf = 0; Modified: stable/11/usr.sbin/makefs/ffs.c ============================================================================== --- stable/11/usr.sbin/makefs/ffs.c Wed Apr 25 01:35:06 2018 (r332980) +++ stable/11/usr.sbin/makefs/ffs.c Wed Apr 25 01:48:15 2018 (r332981) @@ -82,6 +82,7 @@ __FBSDID("$FreeBSD$"); #include #include #include +#include #include "makefs.h" #include "ffs.h" @@ -149,11 +150,8 @@ int sectorsize; /* XXX: for buf.c::getblk() */ void ffs_prep_opts(fsinfo_t *fsopts) { - ffs_opt_t *ffs_opts; + ffs_opt_t *ffs_opts = ecalloc(1, sizeof(*ffs_opts)); - if ((ffs_opts = calloc(1, sizeof(ffs_opt_t))) == NULL) - err(1, "Allocating memory for ffs_options"); - const option_t ffs_options[] = { { 'b', "bsize", &ffs_opts->bsize, OPT_INT32, 1, INT_MAX, "block size" }, @@ -518,10 +516,7 @@ ffs_create_image(const char *image, fsinfo_t *fsopts) printf("zero-ing image `%s', %lld sectors, " "using %d byte chunks\n", image, (long long)bufrem, bufsize); - if ((buf = calloc(1, bufsize)) == NULL) { - warn("Can't create buffer for sector"); - return (-1); - } + buf = ecalloc(1, bufsize); } while (bufrem > 0) { i = write(fsopts->fd, buf, MIN(bufsize, bufrem)); @@ -923,8 +918,7 @@ ffs_write_file(union dinode *din, uint32_t ino, void * goto write_inode_and_leave; /* mmm, cheating */ if (isfile) { - if ((fbuf = malloc(ffs_opts->bsize)) == NULL) - err(1, "Allocating memory for write buffer"); + fbuf = emalloc(ffs_opts->bsize); if ((ffd = open((char *)buf, O_RDONLY, 0444)) == -1) { warn("Can't open `%s' for reading", (char *)buf); goto leave_ffs_write_file; @@ -1051,8 +1045,7 @@ ffs_make_dirbuf(dirbuf_t *dbuf, const char *name, fsno if (debug & DEBUG_FS_MAKE_DIRBUF) printf("ffs_make_dirbuf: growing buf to %d\n", dbuf->size + DIRBLKSIZ); - if ((newbuf = realloc(dbuf->buf, dbuf->size + DIRBLKSIZ)) == NULL) - err(1, "Allocating memory for directory buffer"); + newbuf = erealloc(dbuf->buf, dbuf->size + DIRBLKSIZ); dbuf->buf = newbuf; dbuf->size += DIRBLKSIZ; memset(dbuf->buf + dbuf->size - DIRBLKSIZ, 0, DIRBLKSIZ); @@ -1103,10 +1096,7 @@ ffs_write_inode(union dinode *dp, uint32_t ino, const assert (isclr(cg_inosused_swap(cgp, fsopts->needswap), cgino)); - buf = malloc(fs->fs_bsize); - if (buf == NULL) - errx(1, "ffs_write_inode: cg %d: can't alloc inode block", cg); - + buf = emalloc(fs->fs_bsize); dp1 = (struct ufs1_dinode *)buf; dp2 = (struct ufs2_dinode *)buf; Modified: stable/11/usr.sbin/makefs/ffs/buf.c ============================================================================== --- stable/11/usr.sbin/makefs/ffs/buf.c Wed Apr 25 01:35:06 2018 (r332980) +++ stable/11/usr.sbin/makefs/ffs/buf.c Wed Apr 25 01:48:15 2018 (r332981) @@ -48,6 +48,7 @@ __FBSDID("$FreeBSD$"); #include #include #include +#include #include "makefs.h" @@ -207,9 +208,7 @@ getblk(struct vnode *vp, daddr_t blkno, int size, int } } if (bp == NULL) { - if ((bp = calloc(1, sizeof(struct buf))) == NULL) - err(1, "getblk: calloc"); - + bp = ecalloc(1, sizeof(*bp)); bp->b_bufsize = 0; bp->b_blkno = bp->b_lblkno = blkno; bp->b_fd = fd; @@ -219,9 +218,7 @@ getblk(struct vnode *vp, daddr_t blkno, int size, int } bp->b_bcount = size; if (bp->b_data == NULL || bp->b_bcount > bp->b_bufsize) { - n = realloc(bp->b_data, size); - if (n == NULL) - err(1, "getblk: realloc b_data %ld", bp->b_bcount); + n = erealloc(bp->b_data, size); bp->b_data = n; bp->b_bufsize = size; } Modified: stable/11/usr.sbin/makefs/ffs/mkfs.c ============================================================================== --- stable/11/usr.sbin/makefs/ffs/mkfs.c Wed Apr 25 01:35:06 2018 (r332980) +++ stable/11/usr.sbin/makefs/ffs/mkfs.c Wed Apr 25 01:48:15 2018 (r332981) @@ -50,6 +50,7 @@ __FBSDID("$FreeBSD$"); #include #include #include +#include #include "makefs.h" #include "ffs.h" @@ -403,8 +404,7 @@ ffs_mkfs(const char *fsys, const fsinfo_t *fsopts, tim blks = howmany(size, sblock.fs_fsize); if (sblock.fs_contigsumsize > 0) size += sblock.fs_ncg * sizeof(int32_t); - if ((space = (char *)calloc(1, size)) == NULL) - err(1, "memory allocation error for cg summaries"); + space = ecalloc(1, size); sblock.fs_csp = space; space = (char *)space + sblock.fs_cssize; if (sblock.fs_contigsumsize > 0) { @@ -492,11 +492,7 @@ ffs_mkfs(const char *fsys, const fsinfo_t *fsopts, tim iobufsize = SBLOCKSIZE + 3 * sblock.fs_bsize; else iobufsize = 4 * sblock.fs_bsize; - if ((iobuf = malloc(iobufsize)) == NULL) { - printf("Cannot allocate I/O buffer\n"); - exit(38); - } - memset(iobuf, 0, iobufsize); + iobuf = ecalloc(1, iobufsize); /* * Make a copy of the superblock into the buffer that we will be * writing out in each cylinder group. @@ -562,8 +558,7 @@ ffs_write_superblock(struct fs *fs, const fsinfo_t *fs size = fs->fs_cssize; blks = howmany(size, fs->fs_fsize); space = (void *)fs->fs_csp; - if ((wrbuf = malloc(size)) == NULL) - err(1, "ffs_write_superblock: malloc %d", size); + wrbuf = emalloc(size); for (i = 0; i < blks; i+= fs->fs_frag) { size = fs->fs_bsize; if (i + fs->fs_frag > blks) Modified: stable/11/usr.sbin/makefs/makefs.c ============================================================================== --- stable/11/usr.sbin/makefs/makefs.c Wed Apr 25 01:35:06 2018 (r332980) +++ stable/11/usr.sbin/makefs/makefs.c Wed Apr 25 01:48:15 2018 (r332981) @@ -52,6 +52,7 @@ __FBSDID("$FreeBSD$"); #include #include #include +#include #include "makefs.h" #include "mtree.h" @@ -352,10 +353,7 @@ set_option(const option_t *options, const char *option assert(option != NULL); - if ((var = strdup(option)) == NULL) { - err(EXIT_FAILURE, "Allocating memory for copy of option string"); - } - + var = estrdup(option); for (val = var; *val; val++) if (*val == '=') { *val++ = '\0'; @@ -396,8 +394,7 @@ set_option_var(const option_t *options, const char *va options[i].maximum); break; case OPT_STRPTR: - if ((s = strdup(val)) == NULL) - err(1, NULL); + s = estrdup(val); *(char **)options[i].value = s; break; case OPT_STRBUF: @@ -440,14 +437,11 @@ option_t * copy_opts(const option_t *o) { size_t i; - void *rv; for (i = 0; o[i].name; i++) continue; i++; - if ((rv = calloc(i, sizeof(*o))) == NULL) - err(1, "calloc"); - return memcpy(rv, o, i * sizeof(*o)); + return memcpy(ecalloc(i, sizeof(*o)), o, i * sizeof(*o)); } static int Modified: stable/11/usr.sbin/makefs/mtree.c ============================================================================== --- stable/11/usr.sbin/makefs/mtree.c Wed Apr 25 01:35:06 2018 (r332980) +++ stable/11/usr.sbin/makefs/mtree.c Wed Apr 25 01:48:15 2018 (r332981) @@ -48,6 +48,7 @@ __FBSDID("$FreeBSD$"); #include #include #include +#include #include #include "makefs.h" @@ -83,14 +84,11 @@ mtree_file_push(const char *name, FILE *fp) { struct mtree_fileinfo *fi; - fi = malloc(sizeof(*fi)); - if (fi == NULL) - return (ENOMEM); - + fi = emalloc(sizeof(*fi)); if (strcmp(name, "-") == 0) - fi->name = strdup("(stdin)"); + fi->name = estrdup("(stdin)"); else - fi->name = strdup(name); + fi->name = estrdup(name); if (fi->name == NULL) { free(fi); return (ENOMEM); @@ -176,7 +174,7 @@ mtree_file_path(fsnode *node) } sbuf_cat(sb, rp[depth]); sbuf_finish(sb); - res = strdup(sbuf_data(sb)); + res = estrdup(sbuf_data(sb)); sbuf_delete(sb); if (res == NULL) errno = ENOMEM; @@ -206,8 +204,8 @@ mtree_resolve(const char *spec, int *istemp) quoted = (subst || c == '\'') ? 1 : 0; if (!subst) { - res = strdup(spec + quoted); - if (res != NULL && quoted) + res = estrdup(spec + quoted); + if (quoted) res[len - 2] = '\0'; return (res); } @@ -263,25 +261,18 @@ mtree_resolve(const char *spec, int *istemp) } error = ENOMEM; - var = calloc(p - v, 1); - if (var == NULL) - break; - + var = ecalloc(p - v, 1); memcpy(var, v + 1, p - v - 1); if (strcmp(var, ".CURDIR") == 0) { res = getcwd(NULL, 0); if (res == NULL) break; } else if (strcmp(var, ".PROG") == 0) { - res = strdup(getprogname()); - if (res == NULL) - break; + res = estrdup(getprogname()); } else { v = getenv(var); if (v != NULL) { - res = strdup(v); - if (res == NULL) - break; + res = estrdup(v); } else res = NULL; } @@ -433,25 +424,12 @@ create_node(const char *name, u_int type, fsnode *pare { fsnode *n; - n = calloc(1, sizeof(*n)); - if (n == NULL) - return (NULL); - - n->name = strdup(name); - if (n->name == NULL) { - free(n); - return (NULL); - } - + n = ecalloc(1, sizeof(*n)); + n->name = estrdup(name); n->type = (type == 0) ? global->type : type; n->parent = parent; - n->inode = calloc(1, sizeof(*n->inode)); - if (n->inode == NULL) { - free(n->name); - free(n); - return (NULL); - } + n->inode = ecalloc(1, sizeof(*n->inode)); /* Assign global options/defaults. */ bcopy(global->inode, n->inode, sizeof(*n->inode)); @@ -542,7 +520,7 @@ read_mtree_keywords(FILE *fp, fsnode *node) error = ENOATTR; break; } - node->contents = strdup(value); + node->contents = estrdup(value); } else error = ENOSYS; break; @@ -589,7 +567,7 @@ read_mtree_keywords(FILE *fp, fsnode *node) error = ENOATTR; break; } - node->symlink = malloc(strlen(value) + 1); + node->symlink = emalloc(strlen(value) + 1); if (node->symlink == NULL) { error = errno; break; Modified: stable/11/usr.sbin/makefs/walk.c ============================================================================== --- stable/11/usr.sbin/makefs/walk.c Wed Apr 25 01:35:06 2018 (r332980) +++ stable/11/usr.sbin/makefs/walk.c Wed Apr 25 01:48:15 2018 (r332981) @@ -204,8 +204,7 @@ walk_dir(const char *root, const char *dir, fsnode *pa if (llen == -1) err(1, "Readlink `%s'", path); slink[llen] = '\0'; - if ((cur->symlink = strdup(slink)) == NULL) - err(1, "Memory allocation error"); + cur->symlink = estrdup(slink); } } assert(first != NULL); @@ -223,11 +222,10 @@ create_fsnode(const char *root, const char *path, cons { fsnode *cur; - if ((cur = calloc(1, sizeof(fsnode))) == NULL || - (cur->path = strdup(path)) == NULL || - (cur->name = strdup(name)) == NULL || - (cur->inode = calloc(1, sizeof(fsinode))) == NULL) - err(1, "Memory allocation error"); + cur = ecalloc(1, sizeof(*cur)); + cur->path = estrdup(path); + cur->name = estrdup(name); + cur->inode = ecalloc(1, sizeof(*cur->inode)); cur->root = root; cur->type = stbuf->st_mode & S_IFMT; cur->inode->nlink = 1; @@ -458,9 +456,7 @@ apply_specdir(const char *dir, NODE *specnode, fsnode if (curfsnode->type == S_IFLNK) { assert(curnode->slink != NULL); /* for symlinks, copy the target */ - if ((curfsnode->symlink = - strdup(curnode->slink)) == NULL) - err(1, "Memory allocation error"); + curfsnode->symlink = estrdup(curnode->slink); } } apply_specentry(dir, curnode, curfsnode); @@ -516,8 +512,7 @@ apply_specentry(const char *dir, NODE *specnode, fsnod assert(specnode->slink != NULL); ASEPRINT("symlink", "%s", dirnode->symlink, specnode->slink); free(dirnode->symlink); - if ((dirnode->symlink = strdup(specnode->slink)) == NULL) - err(1, "Memory allocation error"); + dirnode->symlink = estrdup(specnode->slink); } if (specnode->flags & F_TIME) { ASEPRINT("time", "%ld", @@ -666,10 +661,7 @@ link_check(fsinode *entry) htused = 0; ohtable = htable; - htable = calloc(htmask+1, sizeof(*htable)); - if (!htable) - err(1, "Memory allocation error"); - + htable = ecalloc(htmask+1, sizeof(*htable)); /* populate newly allocated hashtable */ if (ohtable) { int i; From owner-svn-src-stable-11@freebsd.org Wed Apr 25 01:54:25 2018 Return-Path: Delivered-To: svn-src-stable-11@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 B535BFBA48F; Wed, 25 Apr 2018 01:54:25 +0000 (UTC) (envelope-from cperciva@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 60BBE7A567; Wed, 25 Apr 2018 01:54:25 +0000 (UTC) (envelope-from cperciva@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 54D0622C6C; Wed, 25 Apr 2018 01:54:25 +0000 (UTC) (envelope-from cperciva@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id w3P1sPht094600; Wed, 25 Apr 2018 01:54:25 GMT (envelope-from cperciva@FreeBSD.org) Received: (from cperciva@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id w3P1sP8x094599; Wed, 25 Apr 2018 01:54:25 GMT (envelope-from cperciva@FreeBSD.org) Message-Id: <201804250154.w3P1sP8x094599@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: cperciva set sender to cperciva@FreeBSD.org using -f From: Colin Percival Date: Wed, 25 Apr 2018 01:54:25 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-11@freebsd.org Subject: svn commit: r332982 - stable/11/release/tools X-SVN-Group: stable-11 X-SVN-Commit-Author: cperciva X-SVN-Commit-Paths: stable/11/release/tools X-SVN-Commit-Revision: 332982 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable-11@freebsd.org X-Mailman-Version: 2.1.25 Precedence: list List-Id: SVN commit messages for only the 11-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 25 Apr 2018 01:54:25 -0000 Author: cperciva Date: Wed Apr 25 01:54:24 2018 New Revision: 332982 URL: https://svnweb.freebsd.org/changeset/base/332982 Log: MFC r332663: Move panic-related settings from sysctl.conf to loader.conf so that they apply if an EC2 instance panics while booting. Sponsored by: https://www.patreon.com/cperciva Modified: stable/11/release/tools/ec2.conf Directory Properties: stable/11/ (props changed) Modified: stable/11/release/tools/ec2.conf ============================================================================== --- stable/11/release/tools/ec2.conf Wed Apr 25 01:48:15 2018 (r332981) +++ stable/11/release/tools/ec2.conf Wed Apr 25 01:54:24 2018 (r332982) @@ -60,9 +60,9 @@ vm_extra_pre_umount() { # The EC2 console is output-only, so while printing a backtrace can # be useful, there's no point dropping into a debugger or waiting # for a keypress. - echo 'debug.trace_on_panic=1' >> ${DESTDIR}/etc/sysctl.conf - echo 'debug.debugger_on_panic=0' >> ${DESTDIR}/etc/sysctl.conf - echo 'kern.panic_reboot_wait_time=0' >> ${DESTDIR}/etc/sysctl.conf + echo 'debug.trace_on_panic=1' >> ${DESTDIR}/boot/loader.conf + echo 'debug.debugger_on_panic=0' >> ${DESTDIR}/boot/loader.conf + echo 'kern.panic_reboot_wait_time=0' >> ${DESTDIR}/boot/loader.conf # The console is not interactive, so we might as well boot quickly. echo 'autoboot_delay="-1"' >> ${DESTDIR}/boot/loader.conf From owner-svn-src-stable-11@freebsd.org Wed Apr 25 01:59:17 2018 Return-Path: Delivered-To: svn-src-stable-11@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 D889DFBA561; Wed, 25 Apr 2018 01:59:16 +0000 (UTC) (envelope-from benno@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 854777A78D; Wed, 25 Apr 2018 01:59:16 +0000 (UTC) (envelope-from benno@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 8026A22C6E; Wed, 25 Apr 2018 01:59:16 +0000 (UTC) (envelope-from benno@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id w3P1xGl3094844; Wed, 25 Apr 2018 01:59:16 GMT (envelope-from benno@FreeBSD.org) Received: (from benno@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id w3P1xGNs094840; Wed, 25 Apr 2018 01:59:16 GMT (envelope-from benno@FreeBSD.org) Message-Id: <201804250159.w3P1xGNs094840@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: benno set sender to benno@FreeBSD.org using -f From: Benno Rice Date: Wed, 25 Apr 2018 01:59:16 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-11@freebsd.org Subject: svn commit: r332983 - in stable/11/usr.sbin/makefs: . cd9660 X-SVN-Group: stable-11 X-SVN-Commit-Author: benno X-SVN-Commit-Paths: in stable/11/usr.sbin/makefs: . cd9660 X-SVN-Commit-Revision: 332983 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable-11@freebsd.org X-Mailman-Version: 2.1.25 Precedence: list List-Id: SVN commit messages for only the 11-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 25 Apr 2018 01:59:17 -0000 Author: benno Date: Wed Apr 25 01:59:15 2018 New Revision: 332983 URL: https://svnweb.freebsd.org/changeset/base/332983 Log: MFC r331463 (partial), r331467, r331468, r331843 r331463, r331467, and r331468 are all replaced by r331843 but are included for completeness' sake. r331463 also contained a change to release/amd64/mkisoimages.sh which I've left out since those changes were also obsoleted by a later commit which will be merged later. r331843: Synchronise with NetBSD's version of EFI handling for El Torito images. Sponsored by: iXsystems, Inc. Modified: stable/11/usr.sbin/makefs/cd9660.c stable/11/usr.sbin/makefs/cd9660/cd9660_eltorito.c stable/11/usr.sbin/makefs/cd9660/cd9660_eltorito.h stable/11/usr.sbin/makefs/makefs.8 Directory Properties: stable/11/ (props changed) Modified: stable/11/usr.sbin/makefs/cd9660.c ============================================================================== --- stable/11/usr.sbin/makefs/cd9660.c Wed Apr 25 01:54:24 2018 (r332982) +++ stable/11/usr.sbin/makefs/cd9660.c Wed Apr 25 01:59:15 2018 (r332983) @@ -312,6 +312,7 @@ cd9660_prep_opts(fsinfo_t *fsopts) OPT_STR('\0', "no-boot", "No boot support"), OPT_STR('\0', "hard-disk-boot", "Boot from hard disk"), OPT_STR('\0', "boot-load-segment", "Boot load segment"), + OPT_STR('\0', "platformid", "Section Header Platform ID"), { .name = NULL } }; @@ -447,7 +448,8 @@ cd9660_parse_opts(const char *option, fsinfo_t *fsopts /* RRIP */ cd9660_eltorito_add_boot_option(diskStructure, name, 0); rv = 1; - } else if (strcmp(name, "boot-load-segment") == 0) { + } else if (strcmp(name, "boot-load-segment") == 0 || + strcmp(name, "platformid") == 0) { if (buf[0] == '\0') { warnx("Option `%s' doesn't contain a value", name); Modified: stable/11/usr.sbin/makefs/cd9660/cd9660_eltorito.c ============================================================================== --- stable/11/usr.sbin/makefs/cd9660/cd9660_eltorito.c Wed Apr 25 01:54:24 2018 (r332982) +++ stable/11/usr.sbin/makefs/cd9660/cd9660_eltorito.c Wed Apr 25 01:59:15 2018 (r332983) @@ -1,4 +1,4 @@ -/* $NetBSD: cd9660_eltorito.c,v 1.17 2011/06/23 02:35:56 enami Exp $ */ +/* $NetBSD: cd9660_eltorito.c,v 1.23 2018/03/28 06:48:55 nonaka Exp $ */ /*- * SPDX-License-Identifier: BSD-2-Clause-NetBSD @@ -47,16 +47,19 @@ __FBSDID("$FreeBSD$"); #define ELTORITO_DPRINTF(__x) #endif +#include + static struct boot_catalog_entry *cd9660_init_boot_catalog_entry(void); static struct boot_catalog_entry *cd9660_boot_setup_validation_entry(char); static struct boot_catalog_entry *cd9660_boot_setup_default_entry( struct cd9660_boot_image *); static struct boot_catalog_entry *cd9660_boot_setup_section_head(char); -static struct boot_catalog_entry *cd9660_boot_setup_validation_entry(char); #if 0 static u_char cd9660_boot_get_system_type(struct cd9660_boot_image *); #endif +static struct cd9660_boot_image *default_boot_image; + int cd9660_add_boot_disk(iso9660_disk *diskStructure, const char *boot_info) { @@ -171,9 +174,15 @@ cd9660_add_boot_disk(iso9660_disk *diskStructure, cons new_image->serialno = diskStructure->image_serialno++; + new_image->platform_id = new_image->system; + /* TODO : Need to do anything about the boot image in the tree? */ diskStructure->is_bootable = 1; + /* First boot image is initial/default entry. */ + if (default_boot_image == NULL) + default_boot_image = new_image; + return 1; } @@ -207,6 +216,13 @@ cd9660_eltorito_add_boot_option(iso9660_disk *diskStru warn("%s: strtoul", __func__); return 0; } + } else if (strcmp(option_string, "platformid") == 0) { + if (strcmp(value, "efi") == 0) + image->platform_id = ET_SYS_EFI; + else { + warn("%s: unknown platform: %s", __func__, value); + return 0; + } } else { return 0; } @@ -229,6 +245,7 @@ cd9660_boot_setup_validation_entry(char sys) int i; entry = cd9660_init_boot_catalog_entry(); + entry->entry_type = ET_ENTRY_VE; ve = &entry->entry_data.VE; ve->header_id[0] = 1; @@ -263,6 +280,7 @@ cd9660_boot_setup_default_entry(struct cd9660_boot_ima if (default_entry == NULL) return NULL; + default_entry->entry_type = ET_ENTRY_IE; ie = &default_entry->entry_data.IE; ie->boot_indicator[0] = disk->bootable; @@ -290,8 +308,12 @@ cd9660_boot_setup_section_head(char platform) if (entry == NULL) return NULL; + entry->entry_type = ET_ENTRY_SH; sh = &entry->entry_data.SH; - /* More by default. The last one will manually be set to 0x91 */ + /* + * More by default. + * The last one will manually be set to ET_SECTION_HEADER_LAST + */ sh->header_indicator[0] = ET_SECTION_HEADER_MORE; sh->platform_id[0] = platform; sh->num_section_entries[0] = 0; @@ -306,6 +328,7 @@ cd9660_boot_setup_section_entry(struct cd9660_boot_ima if ((entry = cd9660_init_boot_catalog_entry()) == NULL) return NULL; + entry->entry_type = ET_ENTRY_SE; se = &entry->entry_data.SE; se->boot_indicator[0] = ET_BOOTABLE; @@ -338,12 +361,12 @@ cd9660_setup_boot(iso9660_disk *diskStructure, int fir int used_sectors; int num_entries = 0; int catalog_sectors; - struct boot_catalog_entry *x86_head, *mac_head, *ppc_head, + struct boot_catalog_entry *x86_head, *mac_head, *ppc_head, *efi_head, *valid_entry, *default_entry, *temp, *head, **headp, *next; struct cd9660_boot_image *tmp_disk; headp = NULL; - x86_head = mac_head = ppc_head = NULL; + x86_head = mac_head = ppc_head = efi_head = NULL; /* If there are no boot disks, don't bother building boot information */ if (TAILQ_EMPTY(&diskStructure->boot_images)) @@ -387,14 +410,25 @@ cd9660_setup_boot(iso9660_disk *diskStructure, int fir sector = first_sector + catalog_sectors; TAILQ_FOREACH(tmp_disk, &diskStructure->boot_images, image_list) { tmp_disk->sector = sector; - sector += tmp_disk->num_sectors; + sector += tmp_disk->num_sectors / + (diskStructure->sectorSize / 512); } LIST_INSERT_HEAD(&diskStructure->boot_entries, valid_entry, ll_struct); /* Step 1b: Initial/default entry */ /* TODO : PARAM */ - tmp_disk = TAILQ_FIRST(&diskStructure->boot_images); + if (default_boot_image != NULL) { + struct cd9660_boot_image *tcbi; + TAILQ_FOREACH(tcbi, &diskStructure->boot_images, image_list) { + if (tcbi == default_boot_image) { + tmp_disk = tcbi; + break; + } + } + } + if (tmp_disk == NULL) + tmp_disk = TAILQ_FIRST(&diskStructure->boot_images); default_entry = cd9660_boot_setup_default_entry(tmp_disk); if (default_entry == NULL) { warnx("Error: memory allocation failed in cd9660_setup_boot"); @@ -405,14 +439,18 @@ cd9660_setup_boot(iso9660_disk *diskStructure, int fir /* Todo: multiple default entries? */ - tmp_disk = TAILQ_NEXT(tmp_disk, image_list); + tmp_disk = TAILQ_FIRST(&diskStructure->boot_images); + head = NULL; temp = default_entry; /* If multiple boot images are given : */ - while (tmp_disk != NULL) { + for (; tmp_disk != NULL; tmp_disk = TAILQ_NEXT(tmp_disk, image_list)) { + if (tmp_disk == default_boot_image) + continue; + /* Step 2: Section header */ - switch (tmp_disk->system) { + switch (tmp_disk->platform_id) { case ET_SYS_X86: headp = &x86_head; break; @@ -422,6 +460,9 @@ cd9660_setup_boot(iso9660_disk *diskStructure, int fir case ET_SYS_MAC: headp = &mac_head; break; + case ET_SYS_EFI: + headp = &efi_head; + break; default: warnx("%s: internal error: unknown system type", __func__); @@ -430,7 +471,7 @@ cd9660_setup_boot(iso9660_disk *diskStructure, int fir if (*headp == NULL) { head = - cd9660_boot_setup_section_head(tmp_disk->system); + cd9660_boot_setup_section_head(tmp_disk->platform_id); if (head == NULL) { warnx("Error: memory allocation failed in " "cd9660_setup_boot"); @@ -455,9 +496,17 @@ cd9660_setup_boot(iso9660_disk *diskStructure, int fir head = next; LIST_INSERT_AFTER(head, temp, ll_struct); - tmp_disk = TAILQ_NEXT(tmp_disk, image_list); } + /* Find the last Section Header entry and mark it as the last. */ + head = NULL; + LIST_FOREACH(next, &diskStructure->boot_entries, ll_struct) { + if (next->entry_type == ET_ENTRY_SH) + head = next; + } + if (head != NULL) + head->entry_data.SH.header_indicator[0] = ET_SECTION_HEADER_LAST; + /* TODO: Remaining boot disks when implemented */ return first_sector + used_sectors; @@ -558,13 +607,13 @@ cd9660_write_apm_partition_entry(FILE *fd, int idx, in apm32 = 0; /* pmLgDataStart */ - fwrite(&apm32, sizeof(apm32), 1, fd); + fwrite(&apm32, sizeof(apm32), 1, fd); /* pmDataCnt */ apm32 = htobe32(nsectors); - fwrite(&apm32, sizeof(apm32), 1, fd); + fwrite(&apm32, sizeof(apm32), 1, fd); /* pmPartStatus */ apm32 = htobe32(part_status); - fwrite(&apm32, sizeof(apm32), 1, fd); + fwrite(&apm32, sizeof(apm32), 1, fd); return 0; } @@ -681,8 +730,9 @@ cd9660_write_boot(iso9660_disk *diskStructure, FILE *f t->num_sectors * (diskStructure->sectorSize / 512), 512, "CD Boot", "Apple_Bootstrap"); } + /* Write ISO9660 descriptor, enclosing the whole disk */ - cd9660_write_apm_partition_entry(fd, 2 + apm_partitions, + cd9660_write_apm_partition_entry(fd, 2 + apm_partitions, total_parts, 0, diskStructure->totalSectors * (diskStructure->sectorSize / 512), 512, "ISO9660", "CD_ROM_Mode_1"); @@ -690,4 +740,3 @@ cd9660_write_boot(iso9660_disk *diskStructure, FILE *f return 0; } - Modified: stable/11/usr.sbin/makefs/cd9660/cd9660_eltorito.h ============================================================================== --- stable/11/usr.sbin/makefs/cd9660/cd9660_eltorito.h Wed Apr 25 01:54:24 2018 (r332982) +++ stable/11/usr.sbin/makefs/cd9660/cd9660_eltorito.h Wed Apr 25 01:59:15 2018 (r332983) @@ -1,4 +1,4 @@ -/* $NetBSD: cd9660_eltorito.h,v 1.5 2009/07/04 14:31:38 ahoka Exp $ */ +/* $NetBSD: cd9660_eltorito.h,v 1.6 2017/01/24 11:22:43 nonaka Exp $ */ /*- * SPDX-License-Identifier: BSD-2-Clause-NetBSD @@ -44,6 +44,7 @@ #define ET_SYS_X86 0 #define ET_SYS_PPC 1 #define ET_SYS_MAC 2 +#define ET_SYS_EFI 0xef /* Platform ID at section header entry */ #define ET_BOOT_ENTRY_SIZE 0x20 @@ -149,6 +150,7 @@ struct cd9660_boot_image { u_char targetMode; u_char system; u_char bootable; + u_char platform_id; /* for section header entry */ /* * If the boot image exists in the filesystem * already, this is a pointer to that node. For the sake Modified: stable/11/usr.sbin/makefs/makefs.8 ============================================================================== --- stable/11/usr.sbin/makefs/makefs.8 Wed Apr 25 01:54:24 2018 (r332982) +++ stable/11/usr.sbin/makefs/makefs.8 Wed Apr 25 01:59:15 2018 (r332983) @@ -35,7 +35,7 @@ .\" .\" $FreeBSD$ .\" -.Dd April 6, 2017 +.Dd March 30, 2018 .Dt MAKEFS 8 .Os .Sh NAME @@ -386,6 +386,8 @@ ElTorito image. Do not pad the image (apparently Linux needs the padding). .It Sy omit-trailing-period Omit trailing periods in filenames. +.It Sy platformid +Set platform ID of section header entry of the boot image. .It Sy preparer Preparer ID of the image. .It Sy publisher From owner-svn-src-stable-11@freebsd.org Wed Apr 25 02:11:11 2018 Return-Path: Delivered-To: svn-src-stable-11@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 71F59FBA7CA for ; Wed, 25 Apr 2018 02:11:11 +0000 (UTC) (envelope-from pfg@FreeBSD.org) Received: from sonic301-16.consmr.mail.bf2.yahoo.com (sonic301-16.consmr.mail.bf2.yahoo.com [74.6.129.55]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id D8CB67D4BB for ; Wed, 25 Apr 2018 02:11:10 +0000 (UTC) (envelope-from pfg@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=yahoo.com; s=s2048; t=1524622270; bh=ltfgjc3bNoeFjhdd7FfeawZpEUUnqunN+EU9tZmKxd8=; h=Subject:To:References:From:Date:In-Reply-To:From:Subject; b=qubKxHbjCKaOKOLq9ZhFJ4HsjsY08GaADAOJ4qL/AJaBNRnpo8GEhHcNMUfA+EEXJBuQtkGZHUdNamV2olBNeIlu/GCraURPrXxwhMc3ERrkiomeA4LqvyKemAD9H9cw1TNcqd7sqlPcoK4UbUM0D1iP58xO6dsBJKeKrRZasPTN0BIRkMstYQD3sC5/gogsA5xM+NArahP0rHcV4YjQRNSBQaTMzeDd4bzAN65o7XO3HEDu0L0JQ4/kv1yL2T5YOH7WedPo3YC5SPLpy38Tn8Ih0ZbaJNk+hYJfkvKiD/eL6HbrP+aQEGZrQSbwd97NaO49VM3yyvy67m+bKYWDig== X-YMail-OSG: 8EK.63sVM1m9vMJ.UHsVWJyIfngrG8f8iXVBf7MfimMc4XHhdCqR7NGYaW0xRra ev5p3bJP2H5uj.hU8f6NTDjgUfHy_f93CDnSSxgsBbbqh.iZG5rDj2e6bDMkmOE.pICMSKkFFqLx cKflIuDDpcpcEOosvTLltckTjaFW8mf0P4pSKDZ3eroFRGGFwvBDY_e1mnufNU8MCcy6ndVRZplY hT0BUhVw9f8qCtGYTexwUJgUeYJCcl8d8cV75bzFmQPCOhmlcemf0Z1wccou9PJzP3Yem9QGeMqk 5VXw5u6dBjb7fy4aX1iaxp2f.kBMDuurNvU.HjLaWZOkoFZo05Zk3QtpShKiq9GhAsCBtucYr812 GZQbf6qFhGO10CHR.cRm6BdFJ5DdTQSUAAX71CfLWnPsZxY7qbcK5E9R2465TVfGlOmcy_crH.Yd WgpuP_5UaWfDLZSHIfn32fkVfqjTbRxzacAjrXqhrBs24UaZN.GEkjNeAnpdggGq8Q7pvLUWAVtl uy2MtSVJbPP7Rc8BE.isf6_veMR7jnZmQjFTiF.apLjlmxdxr_ljUsu9qT.jf5zuDTiKpZR11eL8 1wp62A_wPw1.ShFRz0jZW9.24oM4_zjamX2_C Received: from sonic.gate.mail.ne1.yahoo.com by sonic301.consmr.mail.bf2.yahoo.com with HTTP; Wed, 25 Apr 2018 02:11:10 +0000 Received: from 181.52.72.201 (EHLO [192.168.0.6]) ([181.52.72.201]) by smtp431.mail.bf1.yahoo.com (Oath Hermes SMTP Server) with ESMTPA ID 5f62a8a795b61142a4fe2afd4fa50620; Wed, 25 Apr 2018 01:50:56 +0000 (UTC) Subject: Re: svn commit: r332980 - in stable/11/usr.sbin/makefs: . cd9660 ffs To: Benno Rice , src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-11@freebsd.org References: <201804250135.w3P1Z6Xt084500@repo.freebsd.org> From: Pedro Giffuni Organization: FreeBSD Project Message-ID: Date: Tue, 24 Apr 2018 20:50:55 -0500 User-Agent: Mozilla/5.0 (Windows NT 10.0; WOW64; rv:52.0) Gecko/20100101 Thunderbird/52.7.0 MIME-Version: 1.0 In-Reply-To: <201804250135.w3P1Z6Xt084500@repo.freebsd.org> Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 7bit Content-Language: en-US X-BeenThere: svn-src-stable-11@freebsd.org X-Mailman-Version: 2.1.25 Precedence: list List-Id: SVN commit messages for only the 11-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 25 Apr 2018 02:11:11 -0000 On 24/04/2018 20:35, Benno Rice wrote: > Author: benno > Date: Wed Apr 25 01:35:06 2018 > New Revision: 332980 > URL: https://svnweb.freebsd.org/changeset/base/332980 > > Log: > MFC r307927 > > Be more precise when including headers so that we're less likely to > depend on namespace pollution and as such become more portable. This > means including headers like or , but also > making sure we include system/host headers before local headers. > > While here: define ENOATTR as ENOMSG in mtree.c. There is no ENOATTR > on Linux. > Nope. ... > Modified: stable/11/usr.sbin/makefs/mtree.c > ============================================================================== > --- stable/11/usr.sbin/makefs/mtree.c Wed Apr 25 01:30:29 2018 (r332979) > +++ stable/11/usr.sbin/makefs/mtree.c Wed Apr 25 01:35:06 2018 (r332980) > @@ -46,10 +46,15 @@ __FBSDID("$FreeBSD$"); > #include > #include > #include > +#include > #include > #include > > #include "makefs.h" > + > +#ifndef ENOATTR > +#define ENOATTR ENOMSG > +#endif > > #define IS_DOT(nm) ((nm)[0] == '.' && (nm)[1] == '\0') > #define IS_DOTDOT(nm) ((nm)[0] == '.' && (nm)[1] == '.' && (nm)[2] == '\0') This should be ENODATA, see r326282 for reference. Cheers, Pedro. From owner-svn-src-stable-11@freebsd.org Wed Apr 25 02:15:36 2018 Return-Path: Delivered-To: svn-src-stable-11@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 8815FFBA9B5; Wed, 25 Apr 2018 02:15:36 +0000 (UTC) (envelope-from benno@FreeBSD.org) Received: from out3-smtp.messagingengine.com (out3-smtp.messagingengine.com [66.111.4.27]) (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 2E3787D8D6; Wed, 25 Apr 2018 02:15:36 +0000 (UTC) (envelope-from benno@FreeBSD.org) Received: from compute1.internal (compute1.nyi.internal [10.202.2.41]) by mailout.nyi.internal (Postfix) with ESMTP id 9CF5121B23; Tue, 24 Apr 2018 22:15:35 -0400 (EDT) Received: from mailfrontend2 ([10.202.2.163]) by compute1.internal (MEProxy); Tue, 24 Apr 2018 22:15:35 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:content-type:date:from:in-reply-to :message-id:mime-version:references:subject:to:x-me-sender :x-me-sender:x-sasl-enc; s=fm2; bh=/ZWLU/0cA/4uaW9pcNDBxeaqdMO8B 948nVKIYnIPugo=; b=LJW+I0vvHe58xBEo0AZyaEC5Ifc8yl7qBHM/kHlZG6WzN KG7TXV+AYmc1uQtImJwwntwMpQCTyHASovgGMJfI/UCK4wrStJtLzAuzNsFGrAwE muqQuiaNIh0k9CIkg+O0Tb2NadPYSHL6TarhHOKdJDbYp/LkDEcUQidypHNO3ZXb /q3Fb3qrUXco3EuXxHi+M2jJoYRYldUQfJDOAa9q5Fgh6QWZ2Cg0JVQoRKBGFzqL JRgBVUZUJkek79d4JADfHTN++/3i7BZk2xmcYTQXp56wued2iCQsCmlqTUVUFj6k EcqpPOEV2YVbaPHMVqsODNQWnR6Ld6VMFMotSXPoA== X-ME-Sender: Received: from [10.0.0.153] (c-73-121-138-58.hsd1.tn.comcast.net [73.121.138.58]) by mail.messagingengine.com (Postfix) with ESMTPA id AE11A1025E; Tue, 24 Apr 2018 22:15:34 -0400 (EDT) From: Benno Rice Message-Id: <4E691A4E-6391-4A7D-BD8E-C2773C564AC2@FreeBSD.org> Mime-Version: 1.0 (Mac OS X Mail 11.3 \(3445.6.18\)) Subject: Re: svn commit: r332980 - in stable/11/usr.sbin/makefs: . cd9660 ffs Date: Tue, 24 Apr 2018 22:15:33 -0400 In-Reply-To: Cc: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-11@freebsd.org To: Pedro Giffuni References: <201804250135.w3P1Z6Xt084500@repo.freebsd.org> X-Mailer: Apple Mail (2.3445.6.18) Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable X-Content-Filtered-By: Mailman/MimeDel 2.1.25 X-BeenThere: svn-src-stable-11@freebsd.org X-Mailman-Version: 2.1.25 Precedence: list List-Id: SVN commit messages for only the 11-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 25 Apr 2018 02:15:36 -0000 > On Apr 24, 2018, at 9:50 PM, Pedro Giffuni wrote: >=20 >=20 >=20 > On 24/04/2018 20:35, Benno Rice wrote: >> Author: benno >> Date: Wed Apr 25 01:35:06 2018 >> New Revision: 332980 >> URL: https://svnweb.freebsd.org/changeset/base/332980 >>=20 >> Log: >> MFC r307927 >> Be more precise when including headers so that we're less = likely to >> depend on namespace pollution and as such become more portable. = This >> means including headers like or , but also >> making sure we include system/host headers before local headers. >> While here: define ENOATTR as ENOMSG in mtree.c. There is no = ENOATTR >> on Linux. >> =20 > Nope. > ... >=20 >> Modified: stable/11/usr.sbin/makefs/mtree.c >> = =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D >> --- stable/11/usr.sbin/makefs/mtree.c Wed Apr 25 01:30:29 2018 = (r332979) >> +++ stable/11/usr.sbin/makefs/mtree.c Wed Apr 25 01:35:06 2018 = (r332980) >> @@ -46,10 +46,15 @@ __FBSDID("$FreeBSD$"); >> #include >> #include >> #include >> +#include >> #include >> #include >> #include "makefs.h" >> + >> +#ifndef ENOATTR >> +#define ENOATTR ENOMSG >> +#endif >> #define IS_DOT(nm) ((nm)[0] =3D=3D '.' && (nm)[1] =3D=3D = '\0') >> #define IS_DOTDOT(nm) ((nm)[0] =3D=3D '.' && (nm)[1] =3D=3D = '.' && (nm)[2] =3D=3D '\0') >=20 > This should be ENODATA, see r326282 for reference. This is an old change I MFC=E2=80=99ed but did not originally author. = Merging it reduced conflicts with other changes I needed to merge in = order to merge the EFI changes for El Torito. I=E2=80=99m more than = happy if someone wants to fix this up in head. Thanks, Benno.= From owner-svn-src-stable-11@freebsd.org Wed Apr 25 02:42:29 2018 Return-Path: Delivered-To: svn-src-stable-11@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 A43EEFBB280 for ; Wed, 25 Apr 2018 02:42:29 +0000 (UTC) (envelope-from pfg@FreeBSD.org) Received: from sonic303-35.consmr.mail.gq1.yahoo.com (sonic303-35.consmr.mail.gq1.yahoo.com [98.137.64.216]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 115ED85BB3 for ; Wed, 25 Apr 2018 02:42:28 +0000 (UTC) (envelope-from pfg@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=yahoo.com; s=s2048; t=1524624147; bh=CdqphuehXMbNsPN9zULhocC5NCViPvyvvNoby0wNSgw=; h=Subject:To:Cc:References:From:Date:In-Reply-To:From:Subject; b=cTdiZLp/rqgxX4yylBUOm7dGhoZ3886r53P+q4JlC3hMJpVCWgEuGU3j5RRoykYRcXOZ7VDBt22lKAe6iVO4C8GBr0DbePFuyBuCnZbfNDOMmjB/hNYVhw7eyS5opnpRlj0aP8+9OW9K1fV0JVtRP9kMXiHLjO5ks2g+xAM3sLEORXXLOpaejUIgjX5VbPZaZe6IMk/HfOcqQOkYXoVy77mr3CadAe49KgKqF3o2iEKtgYGyqoT17PsJHo7mm1V9MFCZo9caQ2kh48JWt228EJ3aYvrxNk5KY3z5y/w4G7N88YO2xJ2XNLTEwsE/3Sp+CwKTKPLz9K0NXrhxeVqWFQ== X-YMail-OSG: HXeLUlMVM1nhj.cTiU2NSQZNKtUKlrkwzKJOj3QX65UFJF9UQxI8IMLpbcX6CN. e__PXFTgdH7a6KbfpMXealUMMwZa6_78odDNRraIPOoOrH6AMF26_Hv8fPAcTR6h_HJVMcGBdLCx WruUUHIO5Lw1VJRvy18J7o1WDi26tM1UfS3ZWHT.q57ksNoLLVuo6KqoEQgQPEI_g4RrlH8YQIsn EGi6fW1ZEJCLg00YWLXlEsmPk_5qVJuuSdxiHDLoe6bz9aiuHnbePnplxba0zH7Ws9EeU16pBtMd TSFJGotr2SM_AkAO5c7jXLQz3JHRbGMVOnr9eG1npS.Vr_wNQleJMLKeyBD0rftrwhVFRBOa.R_O RYyOpQvJm2rJBseHxBJjEXZl95kMiUVRzqvIDr6WzKdg5Gp40WbUehSn.V0hnUBs7lGH3u3xynLX MQGZAIS0U4lpN1hDQn.8wtJmdTyQ9xphVHjfvFihdBph_iCN4xEPRGhJ9PgPFqz0PlQsr0BRl65h IBlpO6GzgBfbVNYAluUNBfPSXvAkdoCpRwzgl8uQs7_JzUlyTOogOliOSJ6RlJGparPP01dv7xWI u1nESYTO41yW_rym4p89Rg50B8rwcvskM1nku Received: from sonic.gate.mail.ne1.yahoo.com by sonic303.consmr.mail.gq1.yahoo.com with HTTP; Wed, 25 Apr 2018 02:42:27 +0000 Received: from 181.52.72.201 (EHLO [192.168.0.6]) ([181.52.72.201]) by smtp403.mail.gq1.yahoo.com (Oath Hermes SMTP Server) with ESMTPA ID b4b12013f2c7d866bef0253f43d72af1; Wed, 25 Apr 2018 02:42:23 +0000 (UTC) Subject: Re: svn commit: r332980 - in stable/11/usr.sbin/makefs: . cd9660 ffs To: Benno Rice Cc: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-11@freebsd.org References: <201804250135.w3P1Z6Xt084500@repo.freebsd.org> <4E691A4E-6391-4A7D-BD8E-C2773C564AC2@FreeBSD.org> From: Pedro Giffuni Message-ID: Date: Tue, 24 Apr 2018 21:42:21 -0500 User-Agent: Mozilla/5.0 (X11; FreeBSD amd64; rv:52.0) Gecko/20100101 Thunderbird/52.7.0 MIME-Version: 1.0 In-Reply-To: <4E691A4E-6391-4A7D-BD8E-C2773C564AC2@FreeBSD.org> Content-Language: en-US Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 8bit X-Content-Filtered-By: Mailman/MimeDel 2.1.25 X-BeenThere: svn-src-stable-11@freebsd.org X-Mailman-Version: 2.1.25 Precedence: list List-Id: SVN commit messages for only the 11-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 25 Apr 2018 02:42:30 -0000 On 04/24/18 21:15, Benno Rice wrote: > > >> On Apr 24, 2018, at 9:50 PM, Pedro Giffuni > > wrote: >> >> >> >> On 24/04/2018 20:35, Benno Rice wrote: >>> Author: benno >>> Date: Wed Apr 25 01:35:06 2018 >>> New Revision: 332980 >>> URL: https://svnweb.freebsd.org/changeset/base/332980 >>> >>> Log: >>>   MFC r307927 >>>       Be more precise when including headers so that we're less >>> likely to >>>    depend on namespace pollution and as such become more portable. This >>>    means including headers like or , but also >>>    making sure we include system/host headers before local headers. >>>       While here: define ENOATTR as ENOMSG in mtree.c. There is no >>> ENOATTR >>>    on Linux. >>> >> Nope. >> ... >> >>> Modified: stable/11/usr.sbin/makefs/mtree.c >>> ============================================================================== >>> --- stable/11/usr.sbin/makefs/mtree.cWed Apr 25 01:30:29 2018(r332979) >>> +++ stable/11/usr.sbin/makefs/mtree.cWed Apr 25 01:35:06 2018(r332980) >>> @@ -46,10 +46,15 @@ __FBSDID("$FreeBSD$"); >>>  #include >>>  #include >>>  #include >>> +#include >>>  #include >>>  #include >>>    #include "makefs.h" >>> + >>> +#ifndef ENOATTR >>> +#defineENOATTRENOMSG >>> +#endif >>>    #defineIS_DOT(nm)((nm)[0] == '.' && (nm)[1] == '\0') >>>  #defineIS_DOTDOT(nm)((nm)[0] == '.' && (nm)[1] == '.' && (nm)[2] == >>> '\0') >> >> This should be ENODATA, see r326282 for reference. > > This is an old change I MFC’ed but did not originally author. Merging > it reduced conflicts with other changes I needed to merge in order to > merge the EFI changes for El Torito. I’m more than happy if someone > wants to fix this up in head. > I see, good find then ;). Thanks, Pedro. From owner-svn-src-stable-11@freebsd.org Wed Apr 25 06:29:08 2018 Return-Path: Delivered-To: svn-src-stable-11@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 84206FBE1FB; Wed, 25 Apr 2018 06:29:08 +0000 (UTC) (envelope-from hselasky@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 3301B6B003; Wed, 25 Apr 2018 06:29:08 +0000 (UTC) (envelope-from hselasky@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 299D725774; Wed, 25 Apr 2018 06:29:08 +0000 (UTC) (envelope-from hselasky@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id w3P6T8qK029534; Wed, 25 Apr 2018 06:29:08 GMT (envelope-from hselasky@FreeBSD.org) Received: (from hselasky@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id w3P6T879029533; Wed, 25 Apr 2018 06:29:08 GMT (envelope-from hselasky@FreeBSD.org) Message-Id: <201804250629.w3P6T879029533@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: hselasky set sender to hselasky@FreeBSD.org using -f From: Hans Petter Selasky Date: Wed, 25 Apr 2018 06:29:07 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-11@freebsd.org Subject: svn commit: r332987 - stable/11/contrib/ofed/libibverbs X-SVN-Group: stable-11 X-SVN-Commit-Author: hselasky X-SVN-Commit-Paths: stable/11/contrib/ofed/libibverbs X-SVN-Commit-Revision: 332987 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable-11@freebsd.org X-Mailman-Version: 2.1.25 Precedence: list List-Id: SVN commit messages for only the 11-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 25 Apr 2018 06:29:08 -0000 Author: hselasky Date: Wed Apr 25 06:29:07 2018 New Revision: 332987 URL: https://svnweb.freebsd.org/changeset/base/332987 Log: MFC r332869: Remove the "load drivers" logic from libibverbs. The "load drivers" logic in the libibverbs configuration file is relevant for Linux only. Sponsored by: Mellanox Technologies Modified: stable/11/contrib/ofed/libibverbs/init.c Directory Properties: stable/11/ (props changed) Modified: stable/11/contrib/ofed/libibverbs/init.c ============================================================================== --- stable/11/contrib/ofed/libibverbs/init.c Wed Apr 25 02:43:53 2018 (r332986) +++ stable/11/contrib/ofed/libibverbs/init.c Wed Apr 25 06:29:07 2018 (r332987) @@ -80,89 +80,10 @@ static struct ibv_driver *head_driver, *tail_driver; static int find_sysfs_devs(void) { -#ifdef __linux__ char class_path[IBV_SYSFS_PATH_MAX]; - DIR *class_dir; - struct dirent *dent; struct ibv_sysfs_dev *sysfs_dev = NULL; char value[8]; int ret = 0; - - if (!check_snprintf(class_path, sizeof(class_path), - "%s/class/infiniband_verbs", ibv_get_sysfs_path())) - return ENOMEM; - - class_dir = opendir(class_path); - if (!class_dir) - return ENOSYS; - - while ((dent = readdir(class_dir))) { - struct stat buf; - - if (dent->d_name[0] == '.') - continue; - - if (!sysfs_dev) - sysfs_dev = malloc(sizeof *sysfs_dev); - if (!sysfs_dev) { - ret = ENOMEM; - goto out; - } - - if (!check_snprintf(sysfs_dev->sysfs_path, sizeof sysfs_dev->sysfs_path, - "%s/%s", class_path, dent->d_name)) - continue; - - if (stat(sysfs_dev->sysfs_path, &buf)) { - fprintf(stderr, PFX "Warning: couldn't stat '%s'.\n", - sysfs_dev->sysfs_path); - continue; - } - - if (!S_ISDIR(buf.st_mode)) - continue; - - if (!check_snprintf(sysfs_dev->sysfs_name, sizeof sysfs_dev->sysfs_name, - "%s", dent->d_name)) - continue; - - if (ibv_read_sysfs_file(sysfs_dev->sysfs_path, "ibdev", - sysfs_dev->ibdev_name, - sizeof sysfs_dev->ibdev_name) < 0) { - fprintf(stderr, PFX "Warning: no ibdev class attr for '%s'.\n", - dent->d_name); - continue; - } - - if (!check_snprintf( - sysfs_dev->ibdev_path, sizeof(sysfs_dev->ibdev_path), - "%s/class/infiniband/%s", ibv_get_sysfs_path(), - sysfs_dev->ibdev_name)) - continue; - - sysfs_dev->next = sysfs_dev_list; - sysfs_dev->have_driver = 0; - if (ibv_read_sysfs_file(sysfs_dev->sysfs_path, "abi_version", - value, sizeof value) > 0) - sysfs_dev->abi_ver = strtol(value, NULL, 10); - else - sysfs_dev->abi_ver = 0; - - sysfs_dev_list = sysfs_dev; - sysfs_dev = NULL; - } - - out: - if (sysfs_dev) - free(sysfs_dev); - - closedir(class_dir); - return ret; -#else - char class_path[IBV_SYSFS_PATH_MAX]; - struct ibv_sysfs_dev *sysfs_dev = NULL; - char value[8]; - int ret = 0; int i; snprintf(class_path, sizeof class_path, "%s/class/infiniband_verbs", @@ -208,7 +129,6 @@ static int find_sysfs_devs(void) free(sysfs_dev); return ret; -#endif } void verbs_register_driver(const char *name, @@ -233,185 +153,6 @@ void verbs_register_driver(const char *name, tail_driver = driver; } -#define __IBV_QUOTE(x) #x -#define IBV_QUOTE(x) __IBV_QUOTE(x) -#define DLOPEN_TRAILER "-" IBV_QUOTE(IBV_DEVICE_LIBRARY_EXTENSION) ".so" - -static void load_driver(const char *name) -{ - char *so_name; - void *dlhandle; - - /* If the name is an absolute path then open that path after appending - the trailer suffix */ - if (name[0] == '/') { - if (asprintf(&so_name, "%s" DLOPEN_TRAILER, name) < 0) - goto out_asprintf; - dlhandle = dlopen(so_name, RTLD_NOW); - if (!dlhandle) - goto out_dlopen; - free(so_name); - return; - } - - /* If configured with a provider plugin path then try that next */ - if (sizeof(VERBS_PROVIDER_DIR) > 1) { - if (asprintf(&so_name, VERBS_PROVIDER_DIR "/lib%s" DLOPEN_TRAILER, name) < - 0) - goto out_asprintf; - dlhandle = dlopen(so_name, RTLD_NOW); - free(so_name); - if (dlhandle) - return; - } - - /* Otherwise use the system libary search path. This is the historical - behavior of libibverbs */ - if (asprintf(&so_name, "lib%s" DLOPEN_TRAILER, name) < 0) - goto out_asprintf; - dlhandle = dlopen(so_name, RTLD_NOW); - if (!dlhandle) - goto out_dlopen; - free(so_name); - return; - -out_asprintf: - fprintf(stderr, PFX "Warning: couldn't load driver '%s'.\n", name); - return; -out_dlopen: - fprintf(stderr, PFX "Warning: couldn't load driver '%s': %s\n", so_name, - dlerror()); - free(so_name); - return; -} - -static void load_drivers(void) -{ - struct ibv_driver_name *name, *next_name; - const char *env; - char *list, *env_name; - - /* - * Only use drivers passed in through the calling user's - * environment if we're not running setuid. - */ - if (getuid() == geteuid()) { - if ((env = getenv("RDMAV_DRIVERS"))) { - list = strdupa(env); - while ((env_name = strsep(&list, ":;"))) - load_driver(env_name); - } else if ((env = getenv("IBV_DRIVERS"))) { - list = strdupa(env); - while ((env_name = strsep(&list, ":;"))) - load_driver(env_name); - } - } - - for (name = driver_name_list, next_name = name ? name->next : NULL; - name; - name = next_name, next_name = name ? name->next : NULL) { - load_driver(name->name); - free(name->name); - free(name); - } -} - -static void read_config_file(const char *path) -{ - FILE *conf; - char *line = NULL; - char *config; - char *field; - size_t buflen = 0; - ssize_t len; - - conf = fopen(path, "r" STREAM_CLOEXEC); - if (!conf) { - fprintf(stderr, PFX "Warning: couldn't read config file %s.\n", - path); - return; - } - - while ((len = getline(&line, &buflen, conf)) != -1) { - config = line + strspn(line, "\t "); - if (config[0] == '\n' || config[0] == '#') - continue; - - field = strsep(&config, "\n\t "); - - if (strcmp(field, "driver") == 0 && config != NULL) { - struct ibv_driver_name *driver_name; - - config += strspn(config, "\t "); - field = strsep(&config, "\n\t "); - - driver_name = malloc(sizeof *driver_name); - if (!driver_name) { - fprintf(stderr, PFX "Warning: couldn't allocate " - "driver name '%s'.\n", field); - continue; - } - - driver_name->name = strdup(field); - if (!driver_name->name) { - fprintf(stderr, PFX "Warning: couldn't allocate " - "driver name '%s'.\n", field); - free(driver_name); - continue; - } - - driver_name->next = driver_name_list; - driver_name_list = driver_name; - } else - fprintf(stderr, PFX "Warning: ignoring bad config directive " - "'%s' in file '%s'.\n", field, path); - } - - if (line) - free(line); - fclose(conf); -} - -static void read_config(void) -{ - DIR *conf_dir; - struct dirent *dent; - char *path; - - conf_dir = opendir(IBV_CONFIG_DIR); - if (!conf_dir) { - fprintf(stderr, PFX "Warning: couldn't open config directory '%s'.\n", - IBV_CONFIG_DIR); - return; - } - - while ((dent = readdir(conf_dir))) { - struct stat buf; - - if (asprintf(&path, "%s/%s", IBV_CONFIG_DIR, dent->d_name) < 0) { - fprintf(stderr, PFX "Warning: couldn't read config file %s/%s.\n", - IBV_CONFIG_DIR, dent->d_name); - goto out; - } - - if (stat(path, &buf)) { - fprintf(stderr, PFX "Warning: couldn't stat config file '%s'.\n", - path); - goto next; - } - - if (!S_ISREG(buf.st_mode)) - goto next; - - read_config_file(path); -next: - free(path); - } - -out: - closedir(conf_dir); -} - static struct ibv_device *try_driver(struct ibv_driver *driver, struct ibv_sysfs_dev *sysfs_dev) { @@ -565,8 +306,6 @@ int ibverbs_init(struct ibv_device ***list) check_memlock_limit(); - read_config(); - ret = find_sysfs_devs(); if (ret) return -ret; @@ -602,8 +341,6 @@ int ibverbs_init(struct ibv_device ***list) } dlclose(hand); } - - load_drivers(); for (sysfs_dev = sysfs_dev_list; sysfs_dev; sysfs_dev = sysfs_dev->next) { if (sysfs_dev->have_driver) From owner-svn-src-stable-11@freebsd.org Wed Apr 25 12:21:15 2018 Return-Path: Delivered-To: svn-src-stable-11@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 447C5FA470B; Wed, 25 Apr 2018 12:21:15 +0000 (UTC) (envelope-from kib@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 E99CF789F7; Wed, 25 Apr 2018 12:21:14 +0000 (UTC) (envelope-from kib@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 CB4FBF65; Wed, 25 Apr 2018 12:21:14 +0000 (UTC) (envelope-from kib@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id w3PCLEoA004848; Wed, 25 Apr 2018 12:21:14 GMT (envelope-from kib@FreeBSD.org) Received: (from kib@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id w3PCLDbT004837; Wed, 25 Apr 2018 12:21:13 GMT (envelope-from kib@FreeBSD.org) Message-Id: <201804251221.w3PCLDbT004837@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: kib set sender to kib@FreeBSD.org using -f From: Konstantin Belousov Date: Wed, 25 Apr 2018 12:21:13 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-11@freebsd.org Subject: svn commit: r332991 - in stable/11: sbin/ifconfig sys/net sys/sys X-SVN-Group: stable-11 X-SVN-Commit-Author: kib X-SVN-Commit-Paths: in stable/11: sbin/ifconfig sys/net sys/sys X-SVN-Commit-Revision: 332991 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable-11@freebsd.org X-Mailman-Version: 2.1.25 Precedence: list List-Id: SVN commit messages for only the 11-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 25 Apr 2018 12:21:15 -0000 Author: kib Date: Wed Apr 25 12:21:13 2018 New Revision: 332991 URL: https://svnweb.freebsd.org/changeset/base/332991 Log: MFC r331622: Allow to specify PCP on packets not belonging to any VLAN. Sponsored by: Mellanox Technologies Modified: stable/11/sbin/ifconfig/af_link.c stable/11/sbin/ifconfig/ifconfig.c stable/11/sys/net/ethernet.h stable/11/sys/net/if.c stable/11/sys/net/if.h stable/11/sys/net/if_ethersubr.c stable/11/sys/net/if_var.h stable/11/sys/net/if_vlan.c stable/11/sys/net/if_vlan_var.h stable/11/sys/sys/priv.h stable/11/sys/sys/sockio.h Directory Properties: stable/11/ (props changed) Modified: stable/11/sbin/ifconfig/af_link.c ============================================================================== --- stable/11/sbin/ifconfig/af_link.c Wed Apr 25 07:51:45 2018 (r332990) +++ stable/11/sbin/ifconfig/af_link.c Wed Apr 25 12:21:13 2018 (r332991) @@ -58,70 +58,73 @@ static void link_status(int s __unused, const struct ifaddrs *ifa) { /* XXX no const 'cuz LLADDR is defined wrong */ - struct sockaddr_dl *sdl = (struct sockaddr_dl *) ifa->ifa_addr; + struct sockaddr_dl *sdl; char *ether_format, *format_char; + struct ifreq ifr; + int n, rc, sock_hw; + static const u_char laggaddr[6] = {0}; - if (sdl != NULL && sdl->sdl_alen > 0) { - if ((sdl->sdl_type == IFT_ETHER || - sdl->sdl_type == IFT_L2VLAN || - sdl->sdl_type == IFT_BRIDGE) && - sdl->sdl_alen == ETHER_ADDR_LEN) { - ether_format = ether_ntoa((struct ether_addr *)LLADDR(sdl)); - if (f_ether != NULL && strcmp(f_ether, "dash") == 0) { - for (format_char = strchr(ether_format, ':'); - format_char != NULL; - format_char = strchr(ether_format, ':')) - *format_char = '-'; - } - printf("\tether %s\n", ether_format); - } else { - int n = sdl->sdl_nlen > 0 ? sdl->sdl_nlen + 1 : 0; + sdl = (struct sockaddr_dl *) ifa->ifa_addr; + if (sdl == NULL || sdl->sdl_alen == 0) + return; - printf("\tlladdr %s\n", link_ntoa(sdl) + n); + if ((sdl->sdl_type == IFT_ETHER || sdl->sdl_type == IFT_L2VLAN || + sdl->sdl_type == IFT_BRIDGE) && sdl->sdl_alen == ETHER_ADDR_LEN) { + ether_format = ether_ntoa((struct ether_addr *)LLADDR(sdl)); + if (f_ether != NULL && strcmp(f_ether, "dash") == 0) { + for (format_char = strchr(ether_format, ':'); + format_char != NULL; + format_char = strchr(ether_format, ':')) + *format_char = '-'; } - /* Best-effort (i.e. failures are silent) to get original - * hardware address, as read by NIC driver at attach time. Only - * applies to Ethernet NICs (IFT_ETHER). However, laggX - * interfaces claim to be IFT_ETHER, and re-type their component - * Ethernet NICs as IFT_IEEE8023ADLAG. So, check for both. If - * the MAC is zeroed, then it's actually a lagg. - */ - if ((sdl->sdl_type == IFT_ETHER || - sdl->sdl_type == IFT_IEEE8023ADLAG) && - sdl->sdl_alen == ETHER_ADDR_LEN) { - struct ifreq ifr; - int sock_hw; - int rc; - static const u_char laggaddr[6] = {0}; + printf("\tether %s\n", ether_format); + } else { + n = sdl->sdl_nlen > 0 ? sdl->sdl_nlen + 1 : 0; + printf("\tlladdr %s\n", link_ntoa(sdl) + n); + } - strncpy(ifr.ifr_name, ifa->ifa_name, - sizeof(ifr.ifr_name)); - memcpy(&ifr.ifr_addr, ifa->ifa_addr, - sizeof(ifa->ifa_addr->sa_len)); - ifr.ifr_addr.sa_family = AF_LOCAL; - if ((sock_hw = socket(AF_LOCAL, SOCK_DGRAM, 0)) < 0) { - warn("socket(AF_LOCAL,SOCK_DGRAM)"); - return; - } - rc = ioctl(sock_hw, SIOCGHWADDR, &ifr); - close(sock_hw); - if (rc != 0) { - return; - } - if (memcmp(ifr.ifr_addr.sa_data, laggaddr, sdl->sdl_alen) == 0) { - return; - } - ether_format = ether_ntoa((const struct ether_addr *) - &ifr.ifr_addr.sa_data); - if (f_ether != NULL && strcmp(f_ether, "dash") == 0) { - for (format_char = strchr(ether_format, ':'); - format_char != NULL; - format_char = strchr(ether_format, ':')) - *format_char = '-'; - } - printf("\thwaddr %s\n", ether_format); - } + /* + * Best-effort (i.e. failures are silent) to get original + * hardware address, as read by NIC driver at attach time. Only + * applies to Ethernet NICs (IFT_ETHER). However, laggX + * interfaces claim to be IFT_ETHER, and re-type their component + * Ethernet NICs as IFT_IEEE8023ADLAG. So, check for both. If + * the MAC is zeroed, then it's actually a lagg. + */ + if ((sdl->sdl_type != IFT_ETHER && + sdl->sdl_type != IFT_IEEE8023ADLAG) || + sdl->sdl_alen != ETHER_ADDR_LEN) + return; + + strncpy(ifr.ifr_name, ifa->ifa_name, sizeof(ifr.ifr_name)); + memcpy(&ifr.ifr_addr, ifa->ifa_addr, sizeof(ifa->ifa_addr->sa_len)); + ifr.ifr_addr.sa_family = AF_LOCAL; + if ((sock_hw = socket(AF_LOCAL, SOCK_DGRAM, 0)) < 0) { + warn("socket(AF_LOCAL,SOCK_DGRAM)"); + return; } + rc = ioctl(sock_hw, SIOCGHWADDR, &ifr); + close(sock_hw); + if (rc != 0) + return; + + if (memcmp(ifr.ifr_addr.sa_data, laggaddr, sdl->sdl_alen) == 0) + goto pcp; + + ether_format = ether_ntoa((const struct ether_addr *) + &ifr.ifr_addr.sa_data); + if (f_ether != NULL && strcmp(f_ether, "dash") == 0) { + for (format_char = strchr(ether_format, ':'); + format_char != NULL; + format_char = strchr(ether_format, ':')) + *format_char = '-'; + } + printf("\thwaddr %s\n", ether_format); + +pcp: + if (ioctl(s, SIOCGLANPCP, (caddr_t)&ifr) == 0 && + ifr.ifr_lan_pcp != IFNET_PCP_NONE) + printf("\tpcp %d\n", ifr.ifr_lan_pcp); } static void Modified: stable/11/sbin/ifconfig/ifconfig.c ============================================================================== --- stable/11/sbin/ifconfig/ifconfig.c Wed Apr 25 07:51:45 2018 (r332990) +++ stable/11/sbin/ifconfig/ifconfig.c Wed Apr 25 12:21:13 2018 (r332991) @@ -1078,6 +1078,32 @@ setifmtu(const char *val, int dummy __unused, int s, } static void +setifpcp(const char *val, int arg __unused, int s, const struct afswtch *afp) +{ + u_long ul; + char *endp; + + ul = strtoul(val, &endp, 0); + if (*endp != '\0') + errx(1, "invalid value for pcp"); + if (ul > 7) + errx(1, "value for pcp out of range"); + ifr.ifr_lan_pcp = ul; + if (ioctl(s, SIOCSLANPCP, (caddr_t)&ifr) == -1) + err(1, "SIOCSLANPCP"); +} + +static void +disableifpcp(const char *val, int arg __unused, int s, + const struct afswtch *afp) +{ + + ifr.ifr_lan_pcp = IFNET_PCP_NONE; + if (ioctl(s, SIOCSLANPCP, (caddr_t)&ifr) == -1) + err(1, "SIOCSLANPCP"); +} + +static void setifname(const char *val, int dummy __unused, int s, const struct afswtch *afp) { @@ -1434,6 +1460,8 @@ static struct cmd basic_cmds[] = { DEF_CMD("-txcsum", -IFCAP_TXCSUM, setifcap), DEF_CMD("netcons", IFCAP_NETCONS, setifcap), DEF_CMD("-netcons", -IFCAP_NETCONS, setifcap), + DEF_CMD_ARG("pcp", setifpcp), + DEF_CMD("-pcp", 0, disableifpcp), DEF_CMD("polling", IFCAP_POLLING, setifcap), DEF_CMD("-polling", -IFCAP_POLLING, setifcap), DEF_CMD("tso6", IFCAP_TSO6, setifcap), Modified: stable/11/sys/net/ethernet.h ============================================================================== --- stable/11/sys/net/ethernet.h Wed Apr 25 07:51:45 2018 (r332990) +++ stable/11/sys/net/ethernet.h Wed Apr 25 12:21:13 2018 (r332991) @@ -382,6 +382,20 @@ struct ether_vlan_header { } \ } while (0) +/* + * Names for 802.1q priorities ("802.1p"). Notice that in this scheme, + * (0 < 1), allowing default 0-tagged traffic to take priority over background + * tagged traffic. + */ +#define IEEE8021Q_PCP_BK 1 /* Background (lowest) */ +#define IEEE8021Q_PCP_BE 0 /* Best effort (default) */ +#define IEEE8021Q_PCP_EE 2 /* Excellent effort */ +#define IEEE8021Q_PCP_CA 3 /* Critical applications */ +#define IEEE8021Q_PCP_VI 4 /* Video, < 100ms latency */ +#define IEEE8021Q_PCP_VO 5 /* Video, < 10ms latency */ +#define IEEE8021Q_PCP_IC 6 /* Internetwork control */ +#define IEEE8021Q_PCP_NC 7 /* Network control (highest) */ + #ifdef _KERNEL struct ifnet; @@ -403,6 +417,8 @@ extern char *ether_sprintf(const u_int8_t *); void ether_vlan_mtap(struct bpf_if *, struct mbuf *, void *, u_int); struct mbuf *ether_vlanencap(struct mbuf *, uint16_t); +bool ether_8021q_frame(struct mbuf **mp, struct ifnet *ife, struct ifnet *p, + uint16_t vid, uint8_t pcp); #ifdef _SYS_EVENTHANDLER_H_ /* new ethernet interface attached event */ Modified: stable/11/sys/net/if.c ============================================================================== --- stable/11/sys/net/if.c Wed Apr 25 07:51:45 2018 (r332990) +++ stable/11/sys/net/if.c Wed Apr 25 12:21:13 2018 (r332991) @@ -550,6 +550,7 @@ if_alloc(u_char type) for (int i = 0; i < IFCOUNTERS; i++) ifp->if_counters[i] = counter_u64_alloc(M_WAITOK); ifp->if_get_counter = if_get_counter_default; + ifp->if_pcp = IFNET_PCP_NONE; ifnet_setbyindex(ifp->if_index, ifp); return (ifp); } Modified: stable/11/sys/net/if.h ============================================================================== --- stable/11/sys/net/if.h Wed Apr 25 07:51:45 2018 (r332990) +++ stable/11/sys/net/if.h Wed Apr 25 12:21:13 2018 (r332991) @@ -416,6 +416,7 @@ struct ifreq { #define ifr_index ifr_ifru.ifru_index /* interface index */ #define ifr_fib ifr_ifru.ifru_fib /* interface fib */ #define ifr_vlan_pcp ifr_ifru.ifru_vlan_pcp /* VLAN priority */ +#define ifr_lan_pcp ifr_ifru.ifru_vlan_pcp /* VLAN priority */ }; #define _SIZEOF_ADDR_IFREQ(ifr) \ @@ -566,6 +567,8 @@ struct ifrsshash { uint16_t ifrh_spare1; uint32_t ifrh_types; /* RSS_TYPE_ */ }; + +#define IFNET_PCP_NONE 0xff /* PCP disabled */ #endif /* __BSD_VISIBLE */ Modified: stable/11/sys/net/if_ethersubr.c ============================================================================== --- stable/11/sys/net/if_ethersubr.c Wed Apr 25 07:51:45 2018 (r332990) +++ stable/11/sys/net/if_ethersubr.c Wed Apr 25 12:21:13 2018 (r332991) @@ -45,6 +45,7 @@ #include #include #include +#include #include #include #include @@ -433,6 +434,19 @@ bad: if (m != NULL) return ether_output_frame(ifp, m); } +static bool +ether_set_pcp(struct mbuf **mp, struct ifnet *ifp, uint8_t pcp) +{ + struct ether_header *eh; + + eh = mtod(*mp, struct ether_header *); + if (ntohs(eh->ether_type) == ETHERTYPE_VLAN || + ether_8021q_frame(mp, ifp, ifp, 0, pcp)) + return (true); + if_inc_counter(ifp, IFCOUNTER_OERRORS, 1); + return (false); +} + /* * Ethernet link layer output routine to send a raw frame to the device. * @@ -442,13 +456,17 @@ bad: if (m != NULL) int ether_output_frame(struct ifnet *ifp, struct mbuf *m) { - int i; + int error; + uint8_t pcp; - if (PFIL_HOOKED(&V_link_pfil_hook)) { - i = pfil_run_hooks(&V_link_pfil_hook, &m, ifp, PFIL_OUT, 0, - NULL); + pcp = ifp->if_pcp; + if (pcp != IFNET_PCP_NONE && !ether_set_pcp(&m, ifp, pcp)) + return (0); - if (i != 0) + if (PFIL_HOOKED(&V_link_pfil_hook)) { + error = pfil_run_hooks(&V_link_pfil_hook, &m, ifp, + PFIL_OUT, 0, NULL); + if (error != 0) return (EACCES); if (m == NULL) @@ -1100,6 +1118,22 @@ ether_ioctl(struct ifnet *ifp, u_long command, caddr_t ifp->if_mtu = ifr->ifr_mtu; } break; + + case SIOCSLANPCP: + error = priv_check(curthread, PRIV_NET_SETLANPCP); + if (error != 0) + break; + if (ifr->ifr_lan_pcp > 7 && + ifr->ifr_lan_pcp != IFNET_PCP_NONE) + error = EINVAL; + else + ifp->if_pcp = ifr->ifr_lan_pcp; + break; + + case SIOCGLANPCP: + ifr->ifr_lan_pcp = ifp->if_pcp; + break; + default: error = EINVAL; /* XXX netbsd has ENOTTY??? */ break; @@ -1246,6 +1280,87 @@ ether_vlanencap(struct mbuf *m, uint16_t tag) evl->evl_encap_proto = htons(ETHERTYPE_VLAN); evl->evl_tag = htons(tag); return (m); +} + +static SYSCTL_NODE(_net_link, IFT_L2VLAN, vlan, CTLFLAG_RW, 0, + "IEEE 802.1Q VLAN"); +static SYSCTL_NODE(_net_link_vlan, PF_LINK, link, CTLFLAG_RW, 0, + "for consistency"); + +static VNET_DEFINE(int, soft_pad); +#define V_soft_pad VNET(soft_pad) +SYSCTL_INT(_net_link_vlan, OID_AUTO, soft_pad, CTLFLAG_RW | CTLFLAG_VNET, + &VNET_NAME(soft_pad), 0, + "pad short frames before tagging"); + +/* + * For now, make preserving PCP via an mbuf tag optional, as it increases + * per-packet memory allocations and frees. In the future, it would be + * preferable to reuse ether_vtag for this, or similar. + */ +int vlan_mtag_pcp = 0; +SYSCTL_INT(_net_link_vlan, OID_AUTO, mtag_pcp, CTLFLAG_RW, + &vlan_mtag_pcp, 0, + "Retain VLAN PCP information as packets are passed up the stack"); + +bool +ether_8021q_frame(struct mbuf **mp, struct ifnet *ife, struct ifnet *p, + uint16_t vid, uint8_t pcp) +{ + struct m_tag *mtag; + int n; + uint16_t tag; + static const char pad[8]; /* just zeros */ + + /* + * Pad the frame to the minimum size allowed if told to. + * This option is in accord with IEEE Std 802.1Q, 2003 Ed., + * paragraph C.4.4.3.b. It can help to work around buggy + * bridges that violate paragraph C.4.4.3.a from the same + * document, i.e., fail to pad short frames after untagging. + * E.g., a tagged frame 66 bytes long (incl. FCS) is OK, but + * untagging it will produce a 62-byte frame, which is a runt + * and requires padding. There are VLAN-enabled network + * devices that just discard such runts instead or mishandle + * them somehow. + */ + if (V_soft_pad && p->if_type == IFT_ETHER) { + for (n = ETHERMIN + ETHER_HDR_LEN - (*mp)->m_pkthdr.len; + n > 0; n -= sizeof(pad)) { + if (!m_append(*mp, min(n, sizeof(pad)), pad)) + break; + } + if (n > 0) { + m_freem(*mp); + *mp = NULL; + if_printf(ife, "cannot pad short frame"); + return (false); + } + } + + /* + * If underlying interface can do VLAN tag insertion itself, + * just pass the packet along. However, we need some way to + * tell the interface where the packet came from so that it + * knows how to find the VLAN tag to use, so we attach a + * packet tag that holds it. + */ + if (vlan_mtag_pcp && (mtag = m_tag_locate(*mp, MTAG_8021Q, + MTAG_8021Q_PCP_OUT, NULL)) != NULL) + tag = EVL_MAKETAG(vid, *(uint8_t *)(mtag + 1), 0); + else + tag = EVL_MAKETAG(vid, pcp, 0); + if (p->if_capenable & IFCAP_VLAN_HWTAGGING) { + (*mp)->m_pkthdr.ether_vtag = tag; + (*mp)->m_flags |= M_VLANTAG; + } else { + *mp = ether_vlanencap(*mp, tag); + if (*mp == NULL) { + if_printf(ife, "unable to prepend 802.1Q header"); + return (false); + } + } + return (true); } DECLARE_MODULE(ether, ether_mod, SI_SUB_INIT_IF, SI_ORDER_ANY); Modified: stable/11/sys/net/if_var.h ============================================================================== --- stable/11/sys/net/if_var.h Wed Apr 25 07:51:45 2018 (r332990) +++ stable/11/sys/net/if_var.h Wed Apr 25 12:21:13 2018 (r332991) @@ -313,7 +313,12 @@ struct ifnet { */ void *if_pspare[3]; /* packet pacing / general use */ void *if_hw_addr; /* hardware link-level address */ - int if_ispare[4]; /* packet pacing / general use */ + + /* Ethernet PCP */ + uint8_t if_pcp; + + uint8_t if_bspare[3]; + int if_ispare[3]; /* packet pacing / general use */ }; /* for compatibility with other BSDs */ Modified: stable/11/sys/net/if_vlan.c ============================================================================== --- stable/11/sys/net/if_vlan.c Wed Apr 25 07:51:45 2018 (r332990) +++ stable/11/sys/net/if_vlan.c Wed Apr 25 12:21:13 2018 (r332991) @@ -195,26 +195,8 @@ static struct { {0, NULL} }; -SYSCTL_DECL(_net_link); -static SYSCTL_NODE(_net_link, IFT_L2VLAN, vlan, CTLFLAG_RW, 0, - "IEEE 802.1Q VLAN"); -static SYSCTL_NODE(_net_link_vlan, PF_LINK, link, CTLFLAG_RW, 0, - "for consistency"); +extern int vlan_mtag_pcp; -static VNET_DEFINE(int, soft_pad); -#define V_soft_pad VNET(soft_pad) -SYSCTL_INT(_net_link_vlan, OID_AUTO, soft_pad, CTLFLAG_RW | CTLFLAG_VNET, - &VNET_NAME(soft_pad), 0, "pad short frames before tagging"); - -/* - * For now, make preserving PCP via an mbuf tag optional, as it increases - * per-packet memory allocations and frees. In the future, it would be - * preferable to reuse ether_vtag for this, or similar. - */ -static int vlan_mtag_pcp = 0; -SYSCTL_INT(_net_link_vlan, OID_AUTO, mtag_pcp, CTLFLAG_RW, &vlan_mtag_pcp, 0, - "Retain VLAN PCP information as packets are passed up the stack"); - static const char vlanname[] = "vlan"; static MALLOC_DEFINE(M_VLAN, vlanname, "802.1Q Virtual LAN Interface"); @@ -1163,8 +1145,6 @@ vlan_transmit(struct ifnet *ifp, struct mbuf *m) { struct ifvlan *ifv; struct ifnet *p; - struct m_tag *mtag; - uint16_t tag; int error, len, mcast; VLAN_LOCK_READER; @@ -1193,59 +1173,10 @@ vlan_transmit(struct ifnet *ifp, struct mbuf *m) return (ENETDOWN); } - /* - * Pad the frame to the minimum size allowed if told to. - * This option is in accord with IEEE Std 802.1Q, 2003 Ed., - * paragraph C.4.4.3.b. It can help to work around buggy - * bridges that violate paragraph C.4.4.3.a from the same - * document, i.e., fail to pad short frames after untagging. - * E.g., a tagged frame 66 bytes long (incl. FCS) is OK, but - * untagging it will produce a 62-byte frame, which is a runt - * and requires padding. There are VLAN-enabled network - * devices that just discard such runts instead or mishandle - * them somehow. - */ - if (V_soft_pad && p->if_type == IFT_ETHER) { - static char pad[8]; /* just zeros */ - int n; - - for (n = ETHERMIN + ETHER_HDR_LEN - m->m_pkthdr.len; - n > 0; n -= sizeof(pad)) - if (!m_append(m, min(n, sizeof(pad)), pad)) - break; - - if (n > 0) { - if_printf(ifp, "cannot pad short frame\n"); - if_inc_counter(ifp, IFCOUNTER_OERRORS, 1); - VLAN_RUNLOCK(); - m_freem(m); - return (0); - } - } - - /* - * If underlying interface can do VLAN tag insertion itself, - * just pass the packet along. However, we need some way to - * tell the interface where the packet came from so that it - * knows how to find the VLAN tag to use, so we attach a - * packet tag that holds it. - */ - if (vlan_mtag_pcp && (mtag = m_tag_locate(m, MTAG_8021Q, - MTAG_8021Q_PCP_OUT, NULL)) != NULL) - tag = EVL_MAKETAG(ifv->ifv_vid, *(uint8_t *)(mtag + 1), 0); - else - tag = ifv->ifv_tag; - if (p->if_capenable & IFCAP_VLAN_HWTAGGING) { - m->m_pkthdr.ether_vtag = tag; - m->m_flags |= M_VLANTAG; - } else { - m = ether_vlanencap(m, tag); - if (m == NULL) { - if_printf(ifp, "unable to prepend VLAN header\n"); - if_inc_counter(ifp, IFCOUNTER_OERRORS, 1); - VLAN_RUNLOCK(); - return (0); - } + if (!ether_8021q_frame(&m, ifp, p, ifv->ifv_vid, ifv->ifv_pcp)) { + if_inc_counter(ifp, IFCOUNTER_OERRORS, 1); + VLAN_RUNLOCK(); + return (0); } /* Modified: stable/11/sys/net/if_vlan_var.h ============================================================================== --- stable/11/sys/net/if_vlan_var.h Wed Apr 25 07:51:45 2018 (r332990) +++ stable/11/sys/net/if_vlan_var.h Wed Apr 25 12:21:13 2018 (r332991) @@ -73,22 +73,8 @@ struct vlanreq { #define SIOCSETVLAN SIOCSIFGENERIC #define SIOCGETVLAN SIOCGIFGENERIC -#define SIOCGVLANPCP _IOWR('i', 152, struct ifreq) /* Get VLAN PCP */ -#define SIOCSVLANPCP _IOW('i', 153, struct ifreq) /* Set VLAN PCP */ - -/* - * Names for 802.1q priorities ("802.1p"). Notice that in this scheme, - * (0 < 1), allowing default 0-tagged traffic to take priority over background - * tagged traffic. - */ -#define IEEE8021Q_PCP_BK 1 /* Background (lowest) */ -#define IEEE8021Q_PCP_BE 0 /* Best effort (default) */ -#define IEEE8021Q_PCP_EE 2 /* Excellent effort */ -#define IEEE8021Q_PCP_CA 3 /* Critical applications */ -#define IEEE8021Q_PCP_VI 4 /* Video, < 100ms latency */ -#define IEEE8021Q_PCP_VO 5 /* Video, < 10ms latency */ -#define IEEE8021Q_PCP_IC 6 /* Internetwork control */ -#define IEEE8021Q_PCP_NC 7 /* Network control (highest) */ +#define SIOCGVLANPCP SIOCGLANPCP /* Get VLAN PCP */ +#define SIOCSVLANPCP SIOCSLANPCP /* Set VLAN PCP */ #ifdef _KERNEL /* Modified: stable/11/sys/sys/priv.h ============================================================================== --- stable/11/sys/sys/priv.h Wed Apr 25 07:51:45 2018 (r332990) +++ stable/11/sys/sys/priv.h Wed Apr 25 12:21:13 2018 (r332991) @@ -342,7 +342,8 @@ #define PRIV_NET_SETIFDESCR 418 /* Set interface description. */ #define PRIV_NET_SETIFFIB 419 /* Set interface fib. */ #define PRIV_NET_VXLAN 420 /* Administer vxlan. */ -#define PRIV_NET_SETVLANPCP 421 /* Set VLAN priority. */ +#define PRIV_NET_SETLANPCP 421 /* Set LAN priority. */ +#define PRIV_NET_SETVLANPCP PRIV_NET_SETLANPCP /* Alias Set VLAN priority */ /* * 802.11-related privileges. Modified: stable/11/sys/sys/sockio.h ============================================================================== --- stable/11/sys/sys/sockio.h Wed Apr 25 07:51:45 2018 (r332990) +++ stable/11/sys/sys/sockio.h Wed Apr 25 12:21:13 2018 (r332991) @@ -138,4 +138,7 @@ #define SIOCGIFRSSHASH _IOWR('i', 151, struct ifrsshash)/* get the current RSS type/func settings */ +#define SIOCGLANPCP _IOWR('i', 152, struct ifreq) /* Get (V)LAN PCP */ +#define SIOCSLANPCP _IOW('i', 153, struct ifreq) /* Set (V)LAN PCP */ + #endif /* !_SYS_SOCKIO_H_ */ From owner-svn-src-stable-11@freebsd.org Wed Apr 25 12:23:36 2018 Return-Path: Delivered-To: svn-src-stable-11@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 35EA7FA4A56; Wed, 25 Apr 2018 12:23:36 +0000 (UTC) (envelope-from kib@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 C3FA678DA9; Wed, 25 Apr 2018 12:23:35 +0000 (UTC) (envelope-from kib@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 BED1E10C5; Wed, 25 Apr 2018 12:23:35 +0000 (UTC) (envelope-from kib@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id w3PCNZTU008658; Wed, 25 Apr 2018 12:23:35 GMT (envelope-from kib@FreeBSD.org) Received: (from kib@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id w3PCNZnY008657; Wed, 25 Apr 2018 12:23:35 GMT (envelope-from kib@FreeBSD.org) Message-Id: <201804251223.w3PCNZnY008657@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: kib set sender to kib@FreeBSD.org using -f From: Konstantin Belousov Date: Wed, 25 Apr 2018 12:23:35 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-11@freebsd.org Subject: svn commit: r332992 - stable/11/sys/i386/i386 X-SVN-Group: stable-11 X-SVN-Commit-Author: kib X-SVN-Commit-Paths: stable/11/sys/i386/i386 X-SVN-Commit-Revision: 332992 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable-11@freebsd.org X-Mailman-Version: 2.1.25 Precedence: list List-Id: SVN commit messages for only the 11-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 25 Apr 2018 12:23:36 -0000 Author: kib Date: Wed Apr 25 12:23:35 2018 New Revision: 332992 URL: https://svnweb.freebsd.org/changeset/base/332992 Log: MFC r332737: For fatal traps other than pagefaults, print raw fault error codes. Modified: stable/11/sys/i386/i386/trap.c Directory Properties: stable/11/ (props changed) Modified: stable/11/sys/i386/i386/trap.c ============================================================================== --- stable/11/sys/i386/i386/trap.c Wed Apr 25 12:21:13 2018 (r332991) +++ stable/11/sys/i386/i386/trap.c Wed Apr 25 12:23:35 2018 (r332992) @@ -909,6 +909,8 @@ trap_fatal(frame, eva) "", code & PGEX_RSV ? "reserved bits in PTE" : code & PGEX_P ? "protection violation" : "page not present"); + } else { + printf("error code = %#x\n", code); } printf("instruction pointer = 0x%x:0x%x\n", frame->tf_cs & 0xffff, frame->tf_eip); From owner-svn-src-stable-11@freebsd.org Wed Apr 25 18:53:04 2018 Return-Path: Delivered-To: svn-src-stable-11@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 B82AFFACB4D; Wed, 25 Apr 2018 18:53:03 +0000 (UTC) (envelope-from benno@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 398936AF28; Wed, 25 Apr 2018 18:53:03 +0000 (UTC) (envelope-from benno@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 3418D53ED; Wed, 25 Apr 2018 18:53:03 +0000 (UTC) (envelope-from benno@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id w3PIr3QK014223; Wed, 25 Apr 2018 18:53:03 GMT (envelope-from benno@FreeBSD.org) Received: (from benno@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id w3PIr39A014222; Wed, 25 Apr 2018 18:53:03 GMT (envelope-from benno@FreeBSD.org) Message-Id: <201804251853.w3PIr39A014222@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: benno set sender to benno@FreeBSD.org using -f From: Benno Rice Date: Wed, 25 Apr 2018 18:53:03 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-11@freebsd.org Subject: svn commit: r333006 - stable/11/release/amd64 X-SVN-Group: stable-11 X-SVN-Commit-Author: benno X-SVN-Commit-Paths: stable/11/release/amd64 X-SVN-Commit-Revision: 333006 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable-11@freebsd.org X-Mailman-Version: 2.1.25 Precedence: list List-Id: SVN commit messages for only the 11-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 25 Apr 2018 18:53:04 -0000 Author: benno Date: Wed Apr 25 18:53:02 2018 New Revision: 333006 URL: https://svnweb.freebsd.org/changeset/base/333006 Log: MFC r332345, r332346, r332661, r333005 r332345: Fix makefs invocation after r331843. r332346: Fix the position of $bootable so that -o platformid=efi applies correctly. r332661: Generate hybrid ISO images for amd64. This keeps the existing El Torito entries for BIOS and UEFI boot code and adds a GPT in the ISO image's System Area containing boot code for BIOS that will load /boot/loader from the ISO filesystem and execute it. We then use etdump to find the EFI System Partition image in the El Torito catalog and add an entry to the GPT that allows EFI to find it. r333005: Allow etdump, makefs and mkimg to be overridden. Recent changes to makefs and mkimg have led to situations where the disconnect between this script and the versions installed on the host cause failures. Provide a way to work around this that doesn't require the installation of new versions to the host system if that's not desired. With this change mkisoimages.sh will honour the $ETDUMP, $MAKEFS and $MKIMG environment variables but fall back to the previous behaviour of finding them within $PATH. Sponsored by: iXsystems, Inc. Modified: stable/11/release/amd64/mkisoimages.sh Directory Properties: stable/11/ (props changed) Modified: stable/11/release/amd64/mkisoimages.sh ============================================================================== --- stable/11/release/amd64/mkisoimages.sh Wed Apr 25 18:47:52 2018 (r333005) +++ stable/11/release/amd64/mkisoimages.sh Wed Apr 25 18:53:02 2018 (r333006) @@ -23,6 +23,18 @@ # extra-bits-dir, if provided, contains additional files to be merged # into base-bits-dir as part of making the image. +if [ -z $ETDUMP ]; then + ETDUMP=etdump +fi + +if [ -z $MAKEFS ]; then + MAKEFS=makefs +fi + +if [ -z $MKIMG ]; then + MKIMG=mkimg +fi + if [ "x$1" = "x-b" ]; then # This is highly x86-centric and will be used directly below. bootable="-o bootimage=i386;$4/boot/cdboot -o no-emul-boot" @@ -38,7 +50,7 @@ if [ "x$1" = "x-b" ]; then umount efi rmdir efi mdconfig -d -u $device - bootable="-o bootimage=i386;efiboot.img -o no-emul-boot $bootable" + bootable="$bootable -o bootimage=i386;efiboot.img -o no-emul-boot -o platformid=efi" shift else @@ -55,6 +67,32 @@ NAME="$1"; shift publisher="The FreeBSD Project. http://www.FreeBSD.org/" echo "/dev/iso9660/$LABEL / cd9660 ro 0 0" > "$1/etc/fstab" -makefs -t cd9660 $bootable -o rockridge -o label="$LABEL" -o publisher="$publisher" "$NAME" "$@" +$MAKEFS -t cd9660 $bootable -o rockridge -o label="$LABEL" -o publisher="$publisher" "$NAME" "$@" rm -f "$1/etc/fstab" rm -f efiboot.img + +if [ "$bootable" != "" ]; then + # Look for the EFI System Partition image we dropped in the ISO image. + for entry in `$ETDUMP --format shell $NAME`; do + eval $entry + if [ "$et_platform" = "efi" ]; then + espstart=`expr $et_lba \* 2048` + espsize=`expr $et_sectors \* 512` + espparam="-p efi::$espsize:$espstart" + break + fi + done + + # Create a GPT image containing the partitions we need for hybrid boot. + imgsize=`stat -f %z $NAME` + $MKIMG -s gpt \ + --capacity $imgsize \ + -b $4/boot/pmbr \ + $espparam \ + -p freebsd-boot:=$4/boot/isoboot \ + -o hybrid.img + + # Drop the PMBR, GPT, and boot code into the System Area of the ISO. + dd if=hybrid.img of=$NAME bs=32k count=1 conv=notrunc + rm -f hybrid.img +fi From owner-svn-src-stable-11@freebsd.org Wed Apr 25 18:58:39 2018 Return-Path: Delivered-To: svn-src-stable-11@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 E2B57FACD19; Wed, 25 Apr 2018 18:58:38 +0000 (UTC) (envelope-from benno@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 919DD6C4DA; Wed, 25 Apr 2018 18:58:38 +0000 (UTC) (envelope-from benno@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 8C8D353FE; Wed, 25 Apr 2018 18:58:38 +0000 (UTC) (envelope-from benno@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id w3PIwc4j014565; Wed, 25 Apr 2018 18:58:38 GMT (envelope-from benno@FreeBSD.org) Received: (from benno@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id w3PIwcGp014564; Wed, 25 Apr 2018 18:58:38 GMT (envelope-from benno@FreeBSD.org) Message-Id: <201804251858.w3PIwcGp014564@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: benno set sender to benno@FreeBSD.org using -f From: Benno Rice Date: Wed, 25 Apr 2018 18:58:38 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-11@freebsd.org Subject: svn commit: r333008 - stable/11/usr.bin/etdump X-SVN-Group: stable-11 X-SVN-Commit-Author: benno X-SVN-Commit-Paths: stable/11/usr.bin/etdump X-SVN-Commit-Revision: 333008 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable-11@freebsd.org X-Mailman-Version: 2.1.25 Precedence: list List-Id: SVN commit messages for only the 11-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 25 Apr 2018 18:58:39 -0000 Author: benno Date: Wed Apr 25 18:58:38 2018 New Revision: 333008 URL: https://svnweb.freebsd.org/changeset/base/333008 Log: MFC r333007 Update release version of FreeBSD. Sponsored by: iXsystems, Inc. Modified: stable/11/usr.bin/etdump/etdump.1 Directory Properties: stable/11/ (props changed) Modified: stable/11/usr.bin/etdump/etdump.1 ============================================================================== --- stable/11/usr.bin/etdump/etdump.1 Wed Apr 25 18:56:27 2018 (r333007) +++ stable/11/usr.bin/etdump/etdump.1 Wed Apr 25 18:58:38 2018 (r333008) @@ -24,7 +24,7 @@ .\" .\" $FreeBSD$ .\" -.Dd April 3, 2018 +.Dd April 25, 2018 .Dt ETDUMP 8 .Os .Sh NAME @@ -101,4 +101,4 @@ done The .Nm utility first appeared in -.Fx 12.0 . +.Fx 11.2 From owner-svn-src-stable-11@freebsd.org Thu Apr 26 16:41:00 2018 Return-Path: Delivered-To: svn-src-stable-11@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 3B997FB25D5; Thu, 26 Apr 2018 16:41:00 +0000 (UTC) (envelope-from ian@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 D8DF76EB63; Thu, 26 Apr 2018 16:40:59 +0000 (UTC) (envelope-from ian@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 CDF511A97F; Thu, 26 Apr 2018 16:40:59 +0000 (UTC) (envelope-from ian@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id w3QGexkY069818; Thu, 26 Apr 2018 16:40:59 GMT (envelope-from ian@FreeBSD.org) Received: (from ian@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id w3QGex1V069817; Thu, 26 Apr 2018 16:40:59 GMT (envelope-from ian@FreeBSD.org) Message-Id: <201804261640.w3QGex1V069817@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: ian set sender to ian@FreeBSD.org using -f From: Ian Lepore Date: Thu, 26 Apr 2018 16:40:59 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-11@freebsd.org Subject: svn commit: r333018 - stable/11/sys/dev/gpio X-SVN-Group: stable-11 X-SVN-Commit-Author: ian X-SVN-Commit-Paths: stable/11/sys/dev/gpio X-SVN-Commit-Revision: 333018 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable-11@freebsd.org X-Mailman-Version: 2.1.25 Precedence: list List-Id: SVN commit messages for only the 11-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 26 Apr 2018 16:41:00 -0000 Author: ian Date: Thu Apr 26 16:40:59 2018 New Revision: 333018 URL: https://svnweb.freebsd.org/changeset/base/333018 Log: MFC r308767 by br: Make gpiobus early driver at BUS_PAS_BUS. The gpiobus driver is attached explicitly and generally should be at the same pass as its parent. Making it use BUS_PAS_BUS ensures that it attaches immediately after parent adds it (assuming the parent itself attached at BUS_PAS_BUS and above). Submitted by: kan Sponsored by: DARPA, AFRL Modified: stable/11/sys/dev/gpio/gpiobus.c Directory Properties: stable/11/ (props changed) Modified: stable/11/sys/dev/gpio/gpiobus.c ============================================================================== --- stable/11/sys/dev/gpio/gpiobus.c Thu Apr 26 13:18:24 2018 (r333017) +++ stable/11/sys/dev/gpio/gpiobus.c Thu Apr 26 16:40:59 2018 (r333018) @@ -855,5 +855,6 @@ driver_t gpiobus_driver = { devclass_t gpiobus_devclass; -DRIVER_MODULE(gpiobus, gpio, gpiobus_driver, gpiobus_devclass, 0, 0); +EARLY_DRIVER_MODULE(gpiobus, gpio, gpiobus_driver, gpiobus_devclass, 0, 0, + BUS_PASS_BUS + BUS_PASS_ORDER_MIDDLE); MODULE_VERSION(gpiobus, 1); From owner-svn-src-stable-11@freebsd.org Fri Apr 27 01:21:53 2018 Return-Path: Delivered-To: svn-src-stable-11@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 11B26FBD6E7; Fri, 27 Apr 2018 01:21:53 +0000 (UTC) (envelope-from emaste@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 B0AC4815FD; Fri, 27 Apr 2018 01:21:52 +0000 (UTC) (envelope-from emaste@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 AA4EF1FD04; Fri, 27 Apr 2018 01:21:52 +0000 (UTC) (envelope-from emaste@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id w3R1Lq7O037606; Fri, 27 Apr 2018 01:21:52 GMT (envelope-from emaste@FreeBSD.org) Received: (from emaste@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id w3R1Lqk5037605; Fri, 27 Apr 2018 01:21:52 GMT (envelope-from emaste@FreeBSD.org) Message-Id: <201804270121.w3R1Lqk5037605@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: emaste set sender to emaste@FreeBSD.org using -f From: Ed Maste Date: Fri, 27 Apr 2018 01:21:52 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-11@freebsd.org Subject: svn commit: r333048 - stable/11/stand/i386 X-SVN-Group: stable-11 X-SVN-Commit-Author: emaste X-SVN-Commit-Paths: stable/11/stand/i386 X-SVN-Commit-Revision: 333048 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable-11@freebsd.org X-Mailman-Version: 2.1.25 Precedence: list List-Id: SVN commit messages for only the 11-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 27 Apr 2018 01:21:53 -0000 Author: emaste Date: Fri Apr 27 01:21:52 2018 New Revision: 333048 URL: https://svnweb.freebsd.org/changeset/base/333048 Log: MFC r332090: stand: pass --no-rosegment for i386 bits when linking with lld btxld does not correctly handle input with other than 2 PT_LOAD segments. Passing --no-rosegment lets lld produce output eqivalent to ld.bfd: 2 PT_LOAD segments and no PT_GNU_RELRO. PR: 225775 Sponsored by: The FreeBSD Foundation Modified: stable/11/stand/i386/Makefile.inc Directory Properties: stable/11/ (props changed) Modified: stable/11/stand/i386/Makefile.inc ============================================================================== --- stable/11/stand/i386/Makefile.inc Fri Apr 27 00:12:00 2018 (r333047) +++ stable/11/stand/i386/Makefile.inc Fri Apr 27 01:21:52 2018 (r333048) @@ -2,8 +2,13 @@ # # $FreeBSD$ +.sinclude + LOADER_ADDRESS?=0x200000 LDFLAGS+= -nostdlib +.if defined(LINKER_TYPE) && ${LINKER_TYPE} == "lld" +LDFLAGS+= -Wl,--no-rosegment +.endif # BTX components BTXDIR= ${BOOTOBJ}/i386/btx From owner-svn-src-stable-11@freebsd.org Fri Apr 27 02:39:37 2018 Return-Path: Delivered-To: svn-src-stable-11@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 C10A8FBEA18; Fri, 27 Apr 2018 02:39:36 +0000 (UTC) (envelope-from nyan@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 6B5B470BE6; Fri, 27 Apr 2018 02:39:36 +0000 (UTC) (envelope-from nyan@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 6146020915; Fri, 27 Apr 2018 02:39:36 +0000 (UTC) (envelope-from nyan@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id w3R2daKD074136; Fri, 27 Apr 2018 02:39:36 GMT (envelope-from nyan@FreeBSD.org) Received: (from nyan@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id w3R2daCL074134; Fri, 27 Apr 2018 02:39:36 GMT (envelope-from nyan@FreeBSD.org) Message-Id: <201804270239.w3R2daCL074134@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: nyan set sender to nyan@FreeBSD.org using -f From: Takahashi Yoshihiro Date: Fri, 27 Apr 2018 02:39:36 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-11@freebsd.org Subject: svn commit: r333049 - in stable/11/stand/pc98: boot2 libpc98 X-SVN-Group: stable-11 X-SVN-Commit-Author: nyan X-SVN-Commit-Paths: in stable/11/stand/pc98: boot2 libpc98 X-SVN-Commit-Revision: 333049 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable-11@freebsd.org X-Mailman-Version: 2.1.25 Precedence: list List-Id: SVN commit messages for only the 11-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 27 Apr 2018 02:39:37 -0000 Author: nyan Date: Fri Apr 27 02:39:36 2018 New Revision: 333049 URL: https://svnweb.freebsd.org/changeset/base/333049 Log: whitespace changes to reduce diffs from i386. still broken pc98 boot. Modified: stable/11/stand/pc98/boot2/boot2.c stable/11/stand/pc98/libpc98/bioscd.c stable/11/stand/pc98/libpc98/biosdisk.c Modified: stable/11/stand/pc98/boot2/boot2.c ============================================================================== --- stable/11/stand/pc98/boot2/boot2.c Fri Apr 27 01:21:52 2018 (r333048) +++ stable/11/stand/pc98/boot2/boot2.c Fri Apr 27 02:39:36 2018 (r333049) @@ -71,20 +71,20 @@ extern uint32_t _end; static const char optstr[NOPT] = "DhaCcdgmnpqrsv"; /* Also 'P', 'S' */ static const unsigned char flags[NOPT] = { - RBX_DUAL, - RBX_SERIAL, - RBX_ASKNAME, - RBX_CDROM, - RBX_CONFIG, - RBX_KDB, - RBX_GDB, - RBX_MUTE, - RBX_NOINTR, - RBX_PAUSE, - RBX_QUIET, - RBX_DFLTROOT, - RBX_SINGLE, - RBX_VERBOSE + RBX_DUAL, + RBX_SERIAL, + RBX_ASKNAME, + RBX_CDROM, + RBX_CONFIG, + RBX_KDB, + RBX_GDB, + RBX_MUTE, + RBX_NOINTR, + RBX_PAUSE, + RBX_QUIET, + RBX_DFLTROOT, + RBX_SINGLE, + RBX_VERBOSE }; static const char *const dev_nm[NDEV] = {"ad", "da", "fd"}; @@ -92,15 +92,15 @@ static const unsigned char dev_maj[NDEV] = {30, 4, 2}; static const unsigned char dev_daua[NDEV] = {0x80, 0xa0, 0x90}; static struct dsk { - unsigned daua; - unsigned type; - unsigned disk; - unsigned unit; - unsigned head; - unsigned sec; - uint8_t slice; - uint8_t part; - unsigned start; + unsigned daua; + unsigned type; + unsigned disk; + unsigned unit; + unsigned head; + unsigned sec; + uint8_t slice; + uint8_t part; + unsigned start; } dsk; static char cmd[512], cmddup[512], knamebuf[1024]; static const char *kname; @@ -128,18 +128,19 @@ static void memcpy(void *, const void *, int); static void memcpy(void *dst, const void *src, int len) { - const char *s = src; - char *d = dst; + const char *s = src; + char *d = dst; - while (len--) - *d++ = *s++; + while (len--) + *d++ = *s++; } static inline int strcmp(const char *s1, const char *s2) { - for (; *s1 == *s2 && *s1; s1++, s2++); - return (unsigned char)*s1 - (unsigned char)*s2; + + for (; *s1 == *s2 && *s1; s1++, s2++); + return ((unsigned char)*s1 - (unsigned char)*s2); } #define UFS_SMALL_CGBASE @@ -148,52 +149,53 @@ strcmp(const char *s1, const char *s2) static inline int xfsread(ufs_ino_t inode, void *buf, size_t nbyte) { - if ((size_t)fsread(inode, buf, nbyte) != nbyte) { - printf("Invalid %s\n", "format"); - return -1; - } - return 0; + + if ((size_t)fsread(inode, buf, nbyte) != nbyte) { + printf("Invalid %s\n", "format"); + return (-1); + } + return (0); } static inline void getstr(void) { - char *s; - int c; + char *s; + int c; - s = cmd; - for (;;) { - switch (c = xgetc(0)) { - case 0: - break; - case '\177': - case '\b': - if (s > cmd) { - s--; - printf("\b \b"); - } - break; - case '\n': - case '\r': - *s = 0; - return; - default: - if (s - cmd < sizeof(cmd) - 1) - *s++ = c; - putchar(c); + s = cmd; + for (;;) { + switch (c = xgetc(0)) { + case 0: + break; + case '\177': + case '\b': + if (s > cmd) { + s--; + printf("\b \b"); + } + break; + case '\n': + case '\r': + *s = 0; + return; + default: + if (s - cmd < sizeof(cmd) - 1) + *s++ = c; + putchar(c); + } } - } } static inline void putc(int c) { - v86.ctl = V86_ADDR | V86_CALLF | V86_FLAGS; - v86.addr = PUTCORG; /* call to putc in boot1 */ - v86.eax = c; - v86int(); - v86.ctl = V86_FLAGS; + v86.ctl = V86_ADDR | V86_CALLF | V86_FLAGS; + v86.addr = PUTCORG; /* call to putc in boot1 */ + v86.eax = c; + v86int(); + v86.ctl = V86_FLAGS; } static inline int @@ -322,482 +324,491 @@ int main(void) { #ifdef GET_BIOSGEOM - int i; + int i; #endif - uint8_t autoboot; - ufs_ino_t ino; - size_t nbyte; + uint8_t autoboot; + ufs_ino_t ino; + size_t nbyte; - dmadat = (void *)(roundup2(__base + (int32_t)&_end, 0x10000) - __base); - v86.ctl = V86_FLAGS; - v86.efl = PSL_RESERVED_DEFAULT | PSL_I; - dsk.daua = *(uint8_t *)PTOV(0x584); - dsk.disk = dsk.daua & DRV_DISK; - dsk.unit = dsk.daua & DRV_UNIT; - if (dsk.disk == 0x80) - dsk.type = TYPE_AD; - else if (dsk.disk == 0xa0) - dsk.type = TYPE_DA; - else /* if (dsk.disk == 0x30 || dsk.disk == 0x90) */ - dsk.type = TYPE_FD; - dsk.slice = check_slice(); + dmadat = (void *)(roundup2(__base + (int32_t)&_end, 0x10000) - __base); + v86.ctl = V86_FLAGS; + v86.efl = PSL_RESERVED_DEFAULT | PSL_I; + dsk.daua = *(uint8_t *)PTOV(0x584); + dsk.disk = dsk.daua & DRV_DISK; + dsk.unit = dsk.daua & DRV_UNIT; + if (dsk.disk == 0x80) + dsk.type = TYPE_AD; + else if (dsk.disk == 0xa0) + dsk.type = TYPE_DA; + else /* if (dsk.disk == 0x30 || dsk.disk == 0x90) */ + dsk.type = TYPE_FD; + dsk.slice = check_slice(); #ifdef GET_BIOSGEOM - for (i = 0; i < N_BIOS_GEOM; i++) - bootinfo.bi_bios_geom[i] = bd_getbigeom(i); + for (i = 0; i < N_BIOS_GEOM; i++) + bootinfo.bi_bios_geom[i] = bd_getbigeom(i); #endif - bootinfo.bi_version = BOOTINFO_VERSION; - bootinfo.bi_size = sizeof(bootinfo); + bootinfo.bi_version = BOOTINFO_VERSION; + bootinfo.bi_size = sizeof(bootinfo); - /* Process configuration file */ + /* Process configuration file */ - autoboot = 1; + autoboot = 1; - if ((ino = lookup(PATH_CONFIG)) || - (ino = lookup(PATH_DOTCONFIG))) { - nbyte = fsread(ino, cmd, sizeof(cmd) - 1); - cmd[nbyte] = '\0'; - } + if ((ino = lookup(PATH_CONFIG)) || + (ino = lookup(PATH_DOTCONFIG))) { + nbyte = fsread(ino, cmd, sizeof(cmd) - 1); + cmd[nbyte] = '\0'; + } - if (*cmd) { - memcpy(cmddup, cmd, sizeof(cmd)); - if (parse()) - autoboot = 0; - if (!OPT_CHECK(RBX_QUIET)) - printf("%s: %s", PATH_CONFIG, cmddup); - /* Do not process this command twice */ - *cmd = 0; - } + if (*cmd) { + memcpy(cmddup, cmd, sizeof(cmd)); + if (parse()) + autoboot = 0; + if (!OPT_CHECK(RBX_QUIET)) + printf("%s: %s", PATH_CONFIG, cmddup); + /* Do not process this command twice */ + *cmd = 0; + } - /* - * Try to exec stage 3 boot loader. If interrupted by a keypress, - * or in case of failure, try to load a kernel directly instead. - */ + /* + * Try to exec stage 3 boot loader. If interrupted by a keypress, + * or in case of failure, try to load a kernel directly instead. + */ - if (!kname) { - kname = PATH_LOADER; - if (autoboot && !keyhit(3*SECOND)) { - load(); - kname = PATH_KERNEL; + if (!kname) { + kname = PATH_LOADER; + if (autoboot && !keyhit(3*SECOND)) { + load(); + kname = PATH_KERNEL; + } } - } - /* Present the user with the boot2 prompt. */ + /* Present the user with the boot2 prompt. */ - for (;;) { - if (!autoboot || !OPT_CHECK(RBX_QUIET)) - printf("\nFreeBSD/pc98 boot\n" - "Default: %u:%s(%u,%c)%s\n" - "boot: ", - dsk.unit, dev_nm[dsk.type], dsk.unit, - 'a' + dsk.part, kname); - if (DO_SIO) - sio_flush(); - if (!autoboot || keyhit(3*SECOND)) - getstr(); - else if (!autoboot || !OPT_CHECK(RBX_QUIET)) - putchar('\n'); - autoboot = 0; - if (parse()) - putchar('\a'); - else - load(); - } + for (;;) { + if (!autoboot || !OPT_CHECK(RBX_QUIET)) + printf("\nFreeBSD/pc98 boot\n" + "Default: %u:%s(%u,%c)%s\n" + "boot: ", + dsk.unit, dev_nm[dsk.type], dsk.unit, + 'a' + dsk.part, kname); + if (DO_SIO) + sio_flush(); + if (!autoboot || keyhit(3*SECOND)) + getstr(); + else if (!autoboot || !OPT_CHECK(RBX_QUIET)) + putchar('\n'); + autoboot = 0; + if (parse()) + putchar('\a'); + else + load(); + } } /* XXX - Needed for btxld to link the boot2 binary; do not remove. */ void exit(int x) { + } static void load(void) { - union { - struct exec ex; - Elf32_Ehdr eh; - } hdr; - static Elf32_Phdr ep[2]; - static Elf32_Shdr es[2]; - caddr_t p; - ufs_ino_t ino; - uint32_t addr; - int k; - uint8_t i, j; + union { + struct exec ex; + Elf32_Ehdr eh; + } hdr; + static Elf32_Phdr ep[2]; + static Elf32_Shdr es[2]; + caddr_t p; + ufs_ino_t ino; + uint32_t addr; + int k; + uint8_t i, j; - if (!(ino = lookup(kname))) { - if (!ls) - printf("No %s\n", kname); - return; - } - if (xfsread(ino, &hdr, sizeof(hdr))) - return; - - if (N_GETMAGIC(hdr.ex) == ZMAGIC) { - addr = hdr.ex.a_entry & 0xffffff; - p = PTOV(addr); - fs_off = PAGE_SIZE; - if (xfsread(ino, p, hdr.ex.a_text)) - return; - p += roundup2(hdr.ex.a_text, PAGE_SIZE); - if (xfsread(ino, p, hdr.ex.a_data)) - return; - } else if (IS_ELF(hdr.eh)) { - fs_off = hdr.eh.e_phoff; - for (j = k = 0; k < hdr.eh.e_phnum && j < 2; k++) { - if (xfsread(ino, ep + j, sizeof(ep[0]))) + if (!(ino = lookup(kname))) { + if (!ls) + printf("No %s\n", kname); return; - if (ep[j].p_type == PT_LOAD) - j++; } - for (i = 0; i < 2; i++) { - p = PTOV(ep[i].p_paddr & 0xffffff); - fs_off = ep[i].p_offset; - if (xfsread(ino, p, ep[i].p_filesz)) + if (xfsread(ino, &hdr, sizeof(hdr))) return; - } - p += roundup2(ep[1].p_memsz, PAGE_SIZE); - bootinfo.bi_symtab = VTOP(p); - if (hdr.eh.e_shnum == hdr.eh.e_shstrndx + 3) { - fs_off = hdr.eh.e_shoff + sizeof(es[0]) * - (hdr.eh.e_shstrndx + 1); - if (xfsread(ino, &es, sizeof(es))) + + if (N_GETMAGIC(hdr.ex) == ZMAGIC) { + addr = hdr.ex.a_entry & 0xffffff; + p = PTOV(addr); + fs_off = PAGE_SIZE; + if (xfsread(ino, p, hdr.ex.a_text)) + return; + p += roundup2(hdr.ex.a_text, PAGE_SIZE); + if (xfsread(ino, p, hdr.ex.a_data)) + return; + } else if (IS_ELF(hdr.eh)) { + fs_off = hdr.eh.e_phoff; + for (j = k = 0; k < hdr.eh.e_phnum && j < 2; k++) { + if (xfsread(ino, ep + j, sizeof(ep[0]))) + return; + if (ep[j].p_type == PT_LOAD) + j++; + } + for (i = 0; i < 2; i++) { + p = PTOV(ep[i].p_paddr & 0xffffff); + fs_off = ep[i].p_offset; + if (xfsread(ino, p, ep[i].p_filesz)) + return; + } + p += roundup2(ep[1].p_memsz, PAGE_SIZE); + bootinfo.bi_symtab = VTOP(p); + if (hdr.eh.e_shnum == hdr.eh.e_shstrndx + 3) { + fs_off = hdr.eh.e_shoff + sizeof(es[0]) * + (hdr.eh.e_shstrndx + 1); + if (xfsread(ino, &es, sizeof(es))) + return; + for (i = 0; i < 2; i++) { + *(Elf32_Word *)p = es[i].sh_size; + p += sizeof(es[i].sh_size); + fs_off = es[i].sh_offset; + if (xfsread(ino, p, es[i].sh_size)) + return; + p += es[i].sh_size; + } + } + addr = hdr.eh.e_entry & 0xffffff; + bootinfo.bi_esymtab = VTOP(p); + } else { + printf("Invalid %s\n", "format"); return; - for (i = 0; i < 2; i++) { - *(Elf32_Word *)p = es[i].sh_size; - p += sizeof(es[i].sh_size); - fs_off = es[i].sh_offset; - if (xfsread(ino, p, es[i].sh_size)) - return; - p += es[i].sh_size; - } } - addr = hdr.eh.e_entry & 0xffffff; - bootinfo.bi_esymtab = VTOP(p); - } else { - printf("Invalid %s\n", "format"); - return; - } - bootinfo.bi_kernelname = VTOP(kname); - bootinfo.bi_bios_dev = dsk.daua; - __exec((caddr_t)addr, RB_BOOTINFO | (opts & RBX_MASK), - MAKEBOOTDEV(dev_maj[dsk.type], dsk.slice, dsk.unit, dsk.part), - 0, 0, 0, VTOP(&bootinfo)); + bootinfo.bi_kernelname = VTOP(kname); + bootinfo.bi_bios_dev = dsk.daua; + __exec((caddr_t)addr, RB_BOOTINFO | (opts & RBX_MASK), + MAKEBOOTDEV(dev_maj[dsk.type], dsk.slice, dsk.unit, dsk.part), + 0, 0, 0, VTOP(&bootinfo)); } static int parse() { - char *arg = cmd; - char *ep, *p, *q; - const char *cp; - unsigned int drv; - int c, i, j; - size_t k; + char *arg = cmd; + char *ep, *p, *q; + const char *cp; + unsigned int drv; + int c, i, j; + size_t k; - while ((c = *arg++)) { - if (c == ' ' || c == '\t' || c == '\n') - continue; - for (p = arg; *p && *p != '\n' && *p != ' ' && *p != '\t'; p++); - ep = p; - if (*p) - *p++ = 0; - if (c == '-') { - while ((c = *arg++)) { - if (c == 'P') { - if (*(uint8_t *)PTOV(0x481) & 0x48) { - cp = "yes"; - } else { - opts |= OPT_SET(RBX_DUAL) | OPT_SET(RBX_SERIAL); - cp = "no"; - } - printf("Keyboard: %s\n", cp); - continue; + while ((c = *arg++)) { + if (c == ' ' || c == '\t' || c == '\n') + continue; + for (p = arg; *p && *p != '\n' && *p != ' ' && *p != '\t'; p++); + ep = p; + if (*p) + *p++ = 0; + if (c == '-') { + while ((c = *arg++)) { + if (c == 'P') { + if (*(uint8_t *)PTOV(0x481) & 0x48) { + cp = "yes"; + } else { + opts |= OPT_SET(RBX_DUAL) | + OPT_SET(RBX_SERIAL); + cp = "no"; + } + printf("Keyboard: %s\n", cp); + continue; #if SERIAL - } else if (c == 'S') { - j = 0; - while ((unsigned int)(i = *arg++ - '0') <= 9) - j = j * 10 + i; - if (j > 0 && i == -'0') { - comspeed = j; - break; - } - /* Fall through to error below ('S' not in optstr[]). */ + } else if (c == 'S') { + j = 0; + while ((unsigned int)(i = *arg++ - '0') <= 9) + j = j * 10 + i; + if (j > 0 && i == -'0') { + comspeed = j; + break; + } + /* + * Fall through to error below + * ('S' not in optstr[]). + */ #endif - } - for (i = 0; c != optstr[i]; i++) - if (i == NOPT - 1) - return -1; - opts ^= OPT_SET(flags[i]); - } + } + for (i = 0; c != optstr[i]; i++) + if (i == NOPT - 1) + return (-1); + opts ^= OPT_SET(flags[i]); + } #if SERIAL - ioctrl = OPT_CHECK(RBX_DUAL) ? (IO_SERIAL|IO_KEYBOARD) : - OPT_CHECK(RBX_SERIAL) ? IO_SERIAL : IO_KEYBOARD; - if (DO_SIO) { - if (sio_init(115200 / comspeed) != 0) - ioctrl &= ~IO_SERIAL; - } + ioctrl = OPT_CHECK(RBX_DUAL) ? (IO_SERIAL|IO_KEYBOARD) : + OPT_CHECK(RBX_SERIAL) ? IO_SERIAL : IO_KEYBOARD; + if (DO_SIO) { + if (sio_init(115200 / comspeed) != 0) + ioctrl &= ~IO_SERIAL; + } #endif - } else { - for (q = arg--; *q && *q != '('; q++); - if (*q) { - drv = -1; - if (arg[1] == ':') { - drv = *arg - '0'; - if (drv > 9) - return (-1); - arg += 2; + } else { + for (q = arg--; *q && *q != '('; q++); + if (*q) { + drv = -1; + if (arg[1] == ':') { + drv = *arg - '0'; + if (drv > 9) + return (-1); + arg += 2; + } + if (q - arg != 2) + return (-1); + for (i = 0; arg[0] != dev_nm[i][0] || + arg[1] != dev_nm[i][1]; i++) + if (i == NDEV - 1) + return (-1); + dsk.type = i; + arg += 3; + dsk.unit = *arg - '0'; + if (arg[1] != ',' || dsk.unit > 9) + return (-1); + arg += 2; + dsk.slice = WHOLE_DISK_SLICE; + if (arg[1] == ',') { + dsk.slice = *arg - '0' + 1; + if (dsk.slice > PC98_NPARTS + 1) + return (-1); + arg += 2; + } + if (arg[1] != ')') + return (-1); + dsk.part = *arg - 'a'; + if (dsk.part > 7) + return (-1); + arg += 2; + if (drv == -1) + drv = dsk.unit; + dsk.disk = dev_daua[dsk.type]; + dsk.daua = dsk.disk | dsk.unit; + dsk_meta = 0; + } + k = ep - arg; + if (k > 0) { + if (k >= sizeof(knamebuf)) + return (-1); + memcpy(knamebuf, arg, k + 1); + kname = knamebuf; + } } - if (q - arg != 2) - return -1; - for (i = 0; arg[0] != dev_nm[i][0] || - arg[1] != dev_nm[i][1]; i++) - if (i == NDEV - 1) - return -1; - dsk.type = i; - arg += 3; - dsk.unit = *arg - '0'; - if (arg[1] != ',' || dsk.unit > 9) - return -1; - arg += 2; - dsk.slice = WHOLE_DISK_SLICE; - if (arg[1] == ',') { - dsk.slice = *arg - '0' + 1; - if (dsk.slice > PC98_NPARTS + 1) - return -1; - arg += 2; - } - if (arg[1] != ')') - return -1; - dsk.part = *arg - 'a'; - if (dsk.part > 7) - return (-1); - arg += 2; - if (drv == -1) - drv = dsk.unit; - dsk.disk = dev_daua[dsk.type]; - dsk.daua = dsk.disk | dsk.unit; - dsk_meta = 0; - } - k = ep - arg; - if (k > 0) { - if (k >= sizeof(knamebuf)) - return -1; - memcpy(knamebuf, arg, k + 1); - kname = knamebuf; - } + arg = p; } - arg = p; - } - return 0; + return (0); } static int dskread(void *buf, unsigned lba, unsigned nblk) { - struct pc98_partition *dp; - struct disklabel *d; - char *sec; - unsigned i; - uint8_t sl; - u_char *p; - const char *reason; + struct pc98_partition *dp; + struct disklabel *d; + char *sec; + unsigned i; + uint8_t sl; + u_char *p; + const char *reason; - if (!dsk_meta) { - sec = dmadat->secbuf; - set_dsk(); - if (dsk.type == TYPE_FD) - goto unsliced; - if (drvread(sec, PC98_BBSECTOR)) - return -1; - dp = (void *)(sec + PC98_PARTOFF); - sl = dsk.slice; - if (sl < BASE_SLICE) { - for (i = 0; i < PC98_NPARTS; i++) - if (dp[i].dp_mid == DOSMID_386BSD) { - sl = BASE_SLICE + i; - break; + if (!dsk_meta) { + sec = dmadat->secbuf; + set_dsk(); + if (dsk.type == TYPE_FD) + goto unsliced; + if (drvread(sec, PC98_BBSECTOR)) + return -1; + dp = (void *)(sec + PC98_PARTOFF); + sl = dsk.slice; + if (sl < BASE_SLICE) { + for (i = 0; i < PC98_NPARTS; i++) + if (dp[i].dp_mid == DOSMID_386BSD) { + sl = BASE_SLICE + i; + break; + } + dsk.slice = sl; } - dsk.slice = sl; + if (sl != WHOLE_DISK_SLICE) { + dp += sl - BASE_SLICE; + if (dp->dp_mid != DOSMID_386BSD) { + reason = "slice"; + goto error; + } + dsk.start = dp->dp_scyl * dsk.head * dsk.sec + + dp->dp_shd * dsk.sec + dp->dp_ssect; + } + if (drvread(sec, dsk.start + LABELSECTOR)) + return -1; + d = (void *)(sec + LABELOFFSET); + if (d->d_magic != DISKMAGIC || d->d_magic2 != DISKMAGIC) { + if (dsk.part != RAW_PART) { + reason = "label"; + goto error; + } + } else { + if (dsk.part >= d->d_npartitions || + !d->d_partitions[dsk.part].p_size) { + reason = "partition"; + goto error; + } + dsk.start += d->d_partitions[dsk.part].p_offset; + dsk.start -= d->d_partitions[RAW_PART].p_offset; + } + unsliced: ; } - if (sl != WHOLE_DISK_SLICE) { - dp += sl - BASE_SLICE; - if (dp->dp_mid != DOSMID_386BSD) { - reason = "slice"; - goto error; - } - dsk.start = dp->dp_scyl * dsk.head * dsk.sec + - dp->dp_shd * dsk.sec + dp->dp_ssect; + for (p = buf; nblk; p += 512, lba++, nblk--) { + if ((i = drvread(p, dsk.start + lba))) + return (i); } - if (drvread(sec, dsk.start + LABELSECTOR)) - return -1; - d = (void *)(sec + LABELOFFSET); - if (d->d_magic != DISKMAGIC || d->d_magic2 != DISKMAGIC) { - if (dsk.part != RAW_PART) { - reason = "label"; - goto error; - } - } else { - if (dsk.part >= d->d_npartitions || - !d->d_partitions[dsk.part].p_size) { - reason = "partition"; - goto error; - } - dsk.start += d->d_partitions[dsk.part].p_offset; - dsk.start -= d->d_partitions[RAW_PART].p_offset; - } - unsliced: ; - } - for (p = buf; nblk; p += 512, lba++, nblk--) { - if ((i = drvread(p, dsk.start + lba))) - return i; - } - return 0; + return (0); error: - printf("Invalid %s\n", reason); - return -1; + printf("Invalid %s\n", reason); + return (-1); } static void printf(const char *fmt,...) { - va_list ap; - static char buf[10]; - char *s; - unsigned u; - int c; + va_list ap; + static char buf[10]; + char *s; + unsigned u; + int c; - va_start(ap, fmt); - while ((c = *fmt++)) { - if (c == '%') { - c = *fmt++; - switch (c) { - case 'c': - putchar(va_arg(ap, int)); - continue; - case 's': - for (s = va_arg(ap, char *); *s; s++) - putchar(*s); - continue; - case 'u': - u = va_arg(ap, unsigned); - s = buf; - do - *s++ = '0' + u % 10U; - while (u /= 10U); - while (--s >= buf) - putchar(*s); - continue; - } + va_start(ap, fmt); + while ((c = *fmt++)) { + if (c == '%') { + c = *fmt++; + switch (c) { + case 'c': + putchar(va_arg(ap, int)); + continue; + case 's': + for (s = va_arg(ap, char *); *s; s++) + putchar(*s); + continue; + case 'u': + u = va_arg(ap, unsigned); + s = buf; + do + *s++ = '0' + u % 10U; + while (u /= 10U); + while (--s >= buf) + putchar(*s); + continue; + } + } + putchar(c); } - putchar(c); - } - va_end(ap); - return; + va_end(ap); + return; } static void putchar(int c) { - if (c == '\n') - xputc('\r'); - xputc(c); + + if (c == '\n') + xputc('\r'); + xputc(c); } static int drvread(void *buf, unsigned lba) { - static unsigned c = 0x2d5c7c2f; - unsigned bpc, x, cyl, head, sec; + static unsigned c = 0x2d5c7c2f; + unsigned bpc, x, cyl, head, sec; - bpc = dsk.sec * dsk.head; - cyl = lba / bpc; - x = lba % bpc; - head = x / dsk.sec; - sec = x % dsk.sec; - - if (!OPT_CHECK(RBX_QUIET)) { - xputc(c = c << 8 | c >> 24); - xputc('\b'); - } - v86.ctl = V86_ADDR | V86_CALLF | V86_FLAGS; - v86.addr = READORG; /* call to read in boot1 */ - v86.ecx = cyl; - v86.edx = (head << 8) | sec; - v86.edi = lba; - v86.ebx = 512; - v86.es = VTOPSEG(buf); - v86.ebp = VTOPOFF(buf); - v86int(); - v86.ctl = V86_FLAGS; - if (V86_CY(v86.efl)) { - printf("error %u c/h/s %u/%u/%u lba %u\n", v86.eax >> 8 & 0xff, - cyl, head, sec, lba); - return -1; - } - return 0; + bpc = dsk.sec * dsk.head; + cyl = lba / bpc; + x = lba % bpc; + head = x / dsk.sec; + sec = x % dsk.sec; + + if (!OPT_CHECK(RBX_QUIET)) { + xputc(c = c << 8 | c >> 24); + xputc('\b'); + } + v86.ctl = V86_ADDR | V86_CALLF | V86_FLAGS; + v86.addr = READORG; /* call to read in boot1 */ + v86.ecx = cyl; + v86.edx = (head << 8) | sec; + v86.edi = lba; + v86.ebx = 512; + v86.es = VTOPSEG(buf); + v86.ebp = VTOPOFF(buf); + v86int(); + v86.ctl = V86_FLAGS; + if (V86_CY(v86.efl)) { + printf("error %u c/h/s %u/%u/%u lba %u\n", v86.eax >> 8 & 0xff, + cyl, head, sec, lba); + return (-1); + } + return (0); } static inline void delay(void) { - int i; + int i; - i = 800; - do { - outb(0x5f, 0); /* about 600ns */ - } while (--i >= 0); + i = 800; + do { + outb(0x5f, 0); /* about 600ns */ + } while (--i >= 0); } static int keyhit(unsigned sec) { - unsigned i; + unsigned i; - if (OPT_CHECK(RBX_NOINTR)) - return 0; - for (i = 0; i < sec * 1000; i++) { - if (xgetc(1)) - return 1; - delay(); - } - return 0; + if (OPT_CHECK(RBX_NOINTR)) + return (0); + for (i = 0; i < sec * 1000; i++) { + if (xgetc(1)) + return (1); + delay(); + } + return (0); } static int xputc(int c) { - if (DO_KBD) - putc(c); - if (DO_SIO) - sio_putc(c); - return c; + + if (DO_KBD) + putc(c); + if (DO_SIO) + sio_putc(c); + return (c); *** DIFF OUTPUT TRUNCATED AT 1000 LINES *** From owner-svn-src-stable-11@freebsd.org Fri Apr 27 03:52:52 2018 Return-Path: Delivered-To: svn-src-stable-11@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 D1079FBFB7A; Fri, 27 Apr 2018 03:52:51 +0000 (UTC) (envelope-from kevans@freebsd.org) Received: from smtp.freebsd.org (smtp.freebsd.org [96.47.72.83]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client CN "smtp.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 77D2B815F5; Fri, 27 Apr 2018 03:52:51 +0000 (UTC) (envelope-from kevans@freebsd.org) Received: from mail-lf0-f43.google.com (mail-lf0-f43.google.com [209.85.215.43]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (Client CN "smtp.gmail.com", Issuer "Google Internet Authority G2" (verified OK)) (Authenticated sender: kevans) by smtp.freebsd.org (Postfix) with ESMTPSA id 307E022513; Fri, 27 Apr 2018 03:52:51 +0000 (UTC) (envelope-from kevans@freebsd.org) Received: by mail-lf0-f43.google.com with SMTP id y14-v6so309215lfy.12; Thu, 26 Apr 2018 20:52:51 -0700 (PDT) X-Gm-Message-State: ALQs6tBfv8qp9WMjktGy8R/FwRECnCethyL3vWMCS+7r5KB6s8OxkY9w 05j5baIVkdYmSfUtfkKaLfF3LFGRCPFhyszIf8I= X-Google-Smtp-Source: AB8JxZogld8MYnAPexBE6UnKGHKZMZtl0otKOSU1t1V9s/60ZxsCaPvM1J/VCQbhZhTZnVswFs4s0pJ/pZX5r/2wEPA= X-Received: by 2002:a19:2902:: with SMTP id p2-v6mr288188lfp.99.1524801169498; Thu, 26 Apr 2018 20:52:49 -0700 (PDT) MIME-Version: 1.0 References: <201804270239.w3R2daCL074134@repo.freebsd.org> In-Reply-To: <201804270239.w3R2daCL074134@repo.freebsd.org> Reply-To: BYOND.Lenox@gmail.com From: Kyle Evans Date: Fri, 27 Apr 2018 03:52:38 +0000 X-Gmail-Original-Message-ID: Message-ID: Subject: Re: svn commit: r333049 - in stable/11/stand/pc98: boot2 libpc98 To: Takahashi Yoshihiro Cc: src-committers , svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-11@freebsd.org Content-Type: text/plain; charset="UTF-8" X-Content-Filtered-By: Mailman/MimeDel 2.1.25 X-BeenThere: svn-src-stable-11@freebsd.org X-Mailman-Version: 2.1.25 Precedence: list List-Id: SVN commit messages for only the 11-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 27 Apr 2018 03:52:52 -0000 On Thu, Apr 26, 2018 at 9:39 PM, Takahashi Yoshihiro wrote: > Author: nyan > Date: Fri Apr 27 02:39:36 2018 > New Revision: 333049 > URL: https://svnweb.freebsd.org/changeset/base/333049 > > Log: > whitespace changes to reduce diffs from i386. > still broken pc98 boot. Hi Takahashi, Sorry about this. =( I tried to at least get it back into a buildable state, but I don't have the hardware to test it unfortunately. I realize now that I should have coordinated with you before-hand to step pc98 through the stand/ mess gracefully. What kind of breakage does it exhibit? Thanks, Kyle Evans > > Modified: > stable/11/stand/pc98/boot2/boot2.c > stable/11/stand/pc98/libpc98/bioscd.c > stable/11/stand/pc98/libpc98/biosdisk.c > From owner-svn-src-stable-11@freebsd.org Fri Apr 27 04:11:29 2018 Return-Path: Delivered-To: svn-src-stable-11@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 C23E0FBFF81 for ; Fri, 27 Apr 2018 04:11:29 +0000 (UTC) (envelope-from wlosh@bsdimp.com) Received: from mail-io0-x233.google.com (mail-io0-x233.google.com [IPv6:2607:f8b0:4001:c06::233]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (Client CN "smtp.gmail.com", Issuer "Google Internet Authority G2" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4B5E4845B1 for ; Fri, 27 Apr 2018 04:11:29 +0000 (UTC) (envelope-from wlosh@bsdimp.com) Received: by mail-io0-x233.google.com with SMTP id r22-v6so992597ioc.12 for ; Thu, 26 Apr 2018 21:11:29 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bsdimp-com.20150623.gappssmtp.com; s=20150623; h=mime-version:sender:in-reply-to:references:from:date:message-id :subject:to:cc; bh=0/wdZ2OxVBfpezOdfMVxbMejs87+wISfX7hX39K0++M=; b=BKoi3rmE4g7dHZ2n3thTWq0fv+AxrBRw+PiSeACIA6+/DxLoRm8uK0u9Z1E6noM3RO M8v+7GeezDZV0y8zkRWrkdD9D6AR2RYHdO5AL/G83jwaKt1KFIWh3t4C4EiO1aoa/iG9 /c/B5xTyTee3AOVILGRyueuGfCQbisCyGuR3LF7GvweDeRgSBz6R7OalZJWP2D++NZWG nYHhcl6V3yE/OnfJPgXJKg0oIuBJ8NT200cWWxONsjJAmxgDkjLgjOQejQ8BWCbF0apw rV27j+jFOYBbOY8CgNJ8Y4bEwEhzjT/RozZU1B4FUmH9cTHBolYGymqI2LgNeGCIJLHY +FdQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:sender:in-reply-to:references:from :date:message-id:subject:to:cc; bh=0/wdZ2OxVBfpezOdfMVxbMejs87+wISfX7hX39K0++M=; b=DqRg/CtOGGLa4AfxBQE2+Pmy3Y5X3+mzOqtoRxZB524WqR6pAlOP+K+XQ3viNP1I3b rkQaWRll4n/KDY4dJMRhwTfQ5/YyN8X74zDN35MRtOedZfq+beqxKDyRR9O2dKBmvVs5 GS2uhCRtOkTQLNtZcWvfhRXMZnL27IJOev2zM1rTlgzn3gKEfclJxUM4YuLD5maRAolw D7VonGGfL+bOIX799gtGPpX+vKKH+b6k0sg1s47IuRVOxOl1yFM+UemxUdiuG2PXQIQL uLtwwTvN03B6TOJkinIngI1nZqrLjPJiktJFzC+8v1eLSdN8DhLs8PQZKxaAJy0aFnsF Y6eg== X-Gm-Message-State: ALQs6tA/50KrZ72wBAbyfFI0c+oGPf3XIB6dY4D5xN7aLAQ0eiOEJmSI RgmSOXlUlsiLeDxhoAu+tTE1pFZ4ytsXEp68jjFmtA== X-Google-Smtp-Source: AB8JxZpAD4h5XYqTZI0fhU4gF3KeapWtUMvIS6Jyh+IGTN2VqVSJ4Xsz4aavQnU76vgCeT8n77fpojj6acU24PPnpTw= X-Received: by 2002:a6b:be01:: with SMTP id o1-v6mr601945iof.299.1524802288492; Thu, 26 Apr 2018 21:11:28 -0700 (PDT) MIME-Version: 1.0 Sender: wlosh@bsdimp.com Received: by 2002:a4f:a65a:0:0:0:0:0 with HTTP; Thu, 26 Apr 2018 21:11:27 -0700 (PDT) X-Originating-IP: [2603:300b:6:5100:1052:acc7:f9de:2b6d] In-Reply-To: References: <201804270239.w3R2daCL074134@repo.freebsd.org> From: Warner Losh Date: Thu, 26 Apr 2018 22:11:27 -0600 X-Google-Sender-Auth: 5QKUW7GLlkUtyupuoo4zvwSZRIc Message-ID: Subject: Re: svn commit: r333049 - in stable/11/stand/pc98: boot2 libpc98 To: Kyle Evans Cc: Takahashi Yoshihiro , src-committers , svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-11@freebsd.org Content-Type: text/plain; charset="UTF-8" X-Content-Filtered-By: Mailman/MimeDel 2.1.25 X-BeenThere: svn-src-stable-11@freebsd.org X-Mailman-Version: 2.1.25 Precedence: list List-Id: SVN commit messages for only the 11-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 27 Apr 2018 04:11:30 -0000 On Thu, Apr 26, 2018 at 9:52 PM, Kyle Evans wrote: > On Thu, Apr 26, 2018 at 9:39 PM, Takahashi Yoshihiro > wrote: > > Author: nyan > > Date: Fri Apr 27 02:39:36 2018 > > New Revision: 333049 > > URL: https://svnweb.freebsd.org/changeset/base/333049 > > > > Log: > > whitespace changes to reduce diffs from i386. > > still broken pc98 boot. > > Hi Takahashi, > > Sorry about this. =( I tried to at least get it back into a buildable > state, but I don't have the hardware to test it unfortunately. I realize > now that I should have coordinated with you before-hand to step pc98 > through the stand/ mess gracefully. > > What kind of breakage does it exhibit? > I still haven't gotten rid of my pc98 gear, though FreeBSD 8 or 9 is the last version I updated to. Warner > Thanks, > > Kyle Evans > > > > > Modified: > > stable/11/stand/pc98/boot2/boot2.c > > stable/11/stand/pc98/libpc98/bioscd.c > > stable/11/stand/pc98/libpc98/biosdisk.c > > > > From owner-svn-src-stable-11@freebsd.org Fri Apr 27 05:19:30 2018 Return-Path: Delivered-To: svn-src-stable-11@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 00441FC0EA7; Fri, 27 Apr 2018 05:19:30 +0000 (UTC) (envelope-from nyan@FreeBSD.org) Received: from sakura.ccs.furiru.org (sakura.ccs.furiru.org [IPv6:2001:2f0:104:8060::1]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client CN "sakura.ccs.furiru.org", Issuer "sakura.ccs.furiru.org" (not verified)) by mx1.freebsd.org (Postfix) with ESMTPS id 4D22E719E0; Fri, 27 Apr 2018 05:19:29 +0000 (UTC) (envelope-from nyan@FreeBSD.org) Authentication-Results: ccs.furiru.org; spf=softfail smtp.mailfrom=nyan@FreeBSD.org; sender-id=softfail header.From=nyan@FreeBSD.org; dkim=none; dkim-adsp=none header.From=nyan@FreeBSD.org Received: from localhost (sakura.ccs.furiru.org [IPv6:2001:2f0:104:8060:0:0:0:1]) by sakura.ccs.furiru.org (unknown) with ESMTP id w3R5JOlj083100; Fri, 27 Apr 2018 14:19:25 +0900 (JST) (envelope-from nyan@FreeBSD.org) Date: Fri, 27 Apr 2018 14:19:18 +0900 (JST) Message-Id: <20180427.141918.1816180817680740069.nyan@FreeBSD.org> To: BYOND.Lenox@gmail.com Cc: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-11@freebsd.org Subject: Re: svn commit: r333049 - in stable/11/stand/pc98: boot2 libpc98 From: TAKAHASHI Yoshihiro In-Reply-To: References: <201804270239.w3R2daCL074134@repo.freebsd.org> X-Mailer: Mew version 6.3 on Emacs 25.3 / Mule 6.0 (HANACHIRUSATO) Mime-Version: 1.0 Content-Type: Text/Plain; charset=us-ascii Content-Transfer-Encoding: 7bit X-BeenThere: svn-src-stable-11@freebsd.org X-Mailman-Version: 2.1.25 Precedence: list List-Id: SVN commit messages for only the 11-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 27 Apr 2018 05:19:30 -0000 In article Kyle Evans writes: > On Thu, Apr 26, 2018 at 9:39 PM, Takahashi Yoshihiro > wrote: >> Author: nyan >> Date: Fri Apr 27 02:39:36 2018 >> New Revision: 333049 >> URL: https://svnweb.freebsd.org/changeset/base/333049 >> >> Log: >> whitespace changes to reduce diffs from i386. >> still broken pc98 boot. > > Hi Takahashi, > > Sorry about this. =( I tried to at least get it back into a buildable > state, but I don't have the hardware to test it unfortunately. I realize > now that I should have coordinated with you before-hand to step pc98 > through the stand/ mess gracefully. > > What kind of breakage does it exhibit? No problem. I also don't test stable/11 on pc98 for a long time. Please run build-test for pc98 if possible. I got the following error. cc -O2 -pipe -nostdinc -I/usr/obj/pc98.i386/home/nyan/FreeBSD/11/stand/libsa -I/home/nyan/FreeBSD/11/stand/libsa -D_STANDALONE -I/home/nyan/FreeBSD/11/sys -Ddouble=jagged-little-pill -Dfloat=floaty-mcfloatface -DLOADER_DISK_SUPPORT -ffreestanding -mno-mmx -mno-sse -mno-avx -msoft-float -march=i386 -I. -DCOMPORT=0x238 -DCOMSPEED=9600 -DTERM_EMU -Dalloca=__builtin_alloca -I/home/nyan/FreeBSD/11/stand/ficl -I/home/nyan/FreeBSD/11/stand/ficl/i386 -I/home/nyan/FreeBSD/11/stand/common -I/home/nyan/FreeBSD/11/stand/common -I/home/nyan/FreeBSD/11/stand/pc98/btx/lib -I/home/nyan/FreeBSD/11/stand/i386/libi386 -I/home/nyan/FreeBSD/11/sys -D__printf__=__freebsd_kprintf__ -MD -MF.depend.biosdisk.o -MTbiosdisk.o -std=gnu99 -Wno-pointer-sign -Wno-empty-body -Wno-string-plus-int -Wno-unused-const-variable -Wno-tautological-compare -Wno-unused-value -Wno-parentheses-equality -Wno-unused-function -Wno-enum-conversion -Wno-unused-local-typedef -Wno-address-of-packed-member -Wno-switch -Wno-switch-enum -Wno-knr-promoted-parameter -Wno-parentheses -Qunused-arguments -c /home/nyan/FreeBSD/11/stand/pc98/libpc98/biosdisk.c -o biosdisk.o /home/nyan/FreeBSD/11/stand/pc98/libpc98/biosdisk.c:467:62: error: no member named 'data' in 'struct i386_devdesc::(anonymous at /home/nyan/FreeBSD/11/stand/i386/libi386/libi386.h:39:2)' ((struct i386_devdesc *)(f->f_devdata))->d_kind.biosdisk.data = od; ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ^ /home/nyan/FreeBSD/11/stand/pc98/libpc98/biosdisk.c:734:70: error: no member named 'data' in 'struct i386_devdesc::(anonymous at /home/nyan/FreeBSD/11/stand/i386/libi386/libi386.h:39:2)' struct open_disk *od = (struct open_disk *)(dev->d_kind.biosdisk.data); ~~~~~~~~~~~~~~~~~~~~ ^ /home/nyan/FreeBSD/11/stand/pc98/libpc98/biosdisk.c:764:70: error: no member named 'data' in 'struct i386_devdesc::(anonymous at /home/nyan/FreeBSD/11/stand/i386/libi386/libi386.h:39:2)' struct open_disk *od = (struct open_disk *)(dev->d_kind.biosdisk.data); ~~~~~~~~~~~~~~~~~~~~ ^ /home/nyan/FreeBSD/11/stand/pc98/libpc98/biosdisk.c:776:99: error: no member named 'data' in 'struct i386_devdesc::(anonymous at /home/nyan/FreeBSD/11/stand/i386/libi386/libi386.h:39:2)' ...open_disk *)(((struct i386_devdesc *)devdata)->d_kind.biosdisk.data); ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ^ 4 errors generated. *** Error code 1 Stop. make[5]: stopped in /home/nyan/FreeBSD/11/stand/pc98/libpc98 *** Error code 1 Stop. make[4]: stopped in /home/nyan/FreeBSD/11/stand/pc98 *** Error code 1 Stop. make[3]: stopped in /home/nyan/FreeBSD/11/stand *** Error code 1 Stop. make[2]: stopped in /home/nyan/FreeBSD/11 *** Error code 1 Stop. make[1]: stopped in /home/nyan/FreeBSD/11 *** Error code 1 Stop. make: stopped in /home/nyan/FreeBSD/11 --- Takahashi Yoshihiro From owner-svn-src-stable-11@freebsd.org Fri Apr 27 08:56:18 2018 Return-Path: Delivered-To: svn-src-stable-11@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 4925DFC5005; Fri, 27 Apr 2018 08:56:18 +0000 (UTC) (envelope-from kib@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 E75CE7D827; Fri, 27 Apr 2018 08:56:17 +0000 (UTC) (envelope-from kib@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 DCBDB24532; Fri, 27 Apr 2018 08:56:17 +0000 (UTC) (envelope-from kib@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id w3R8uHFt064706; Fri, 27 Apr 2018 08:56:17 GMT (envelope-from kib@FreeBSD.org) Received: (from kib@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id w3R8uH8j064704; Fri, 27 Apr 2018 08:56:17 GMT (envelope-from kib@FreeBSD.org) Message-Id: <201804270856.w3R8uH8j064704@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: kib set sender to kib@FreeBSD.org using -f From: Konstantin Belousov Date: Fri, 27 Apr 2018 08:56:17 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-11@freebsd.org Subject: svn commit: r333053 - in stable/11/sys: i386/include x86/x86 X-SVN-Group: stable-11 X-SVN-Commit-Author: kib X-SVN-Commit-Paths: in stable/11/sys: i386/include x86/x86 X-SVN-Commit-Revision: 333053 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable-11@freebsd.org X-Mailman-Version: 2.1.25 Precedence: list List-Id: SVN commit messages for only the 11-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 27 Apr 2018 08:56:18 -0000 Author: kib Date: Fri Apr 27 08:56:17 2018 New Revision: 333053 URL: https://svnweb.freebsd.org/changeset/base/333053 Log: MFC r332970: Use IS_BSP() macro. MFC r332989 (by lwhsu): Add i386 IS_BSP(). Modified: stable/11/sys/i386/include/pcpu.h stable/11/sys/x86/x86/mca.c Directory Properties: stable/11/ (props changed) Modified: stable/11/sys/i386/include/pcpu.h ============================================================================== --- stable/11/sys/i386/include/pcpu.h Fri Apr 27 05:37:35 2018 (r333052) +++ stable/11/sys/i386/include/pcpu.h Fri Apr 27 08:56:17 2018 (r333053) @@ -242,6 +242,8 @@ __curpcb(void) } #define curpcb (__curpcb()) +#define IS_BSP() (PCPU_GET(cpuid) == 0) + #else /* !lint || defined(__GNUCLIKE_ASM) && defined(__GNUCLIKE___TYPEOF) */ #error "this file needs to be ported to your compiler" Modified: stable/11/sys/x86/x86/mca.c ============================================================================== --- stable/11/sys/x86/x86/mca.c Fri Apr 27 05:37:35 2018 (r333052) +++ stable/11/sys/x86/x86/mca.c Fri Apr 27 08:56:17 2018 (r333053) @@ -1040,7 +1040,7 @@ _mca_init(int boot) if (mcg_cap & MCG_CAP_CTL_P) /* Enable MCA features. */ wrmsr(MSR_MCG_CTL, MCG_CTL_ENABLE); - if (PCPU_GET(cpuid) == 0 && boot) + if (IS_BSP() && boot) mca_setup(mcg_cap); /* From owner-svn-src-stable-11@freebsd.org Fri Apr 27 11:00:13 2018 Return-Path: Delivered-To: svn-src-stable-11@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 49AF6FA4E48; Fri, 27 Apr 2018 11:00:13 +0000 (UTC) (envelope-from ae@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 ED00277681; Fri, 27 Apr 2018 11:00:12 +0000 (UTC) (envelope-from ae@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 E3DC725843; Fri, 27 Apr 2018 11:00:12 +0000 (UTC) (envelope-from ae@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id w3RB0CSL025418; Fri, 27 Apr 2018 11:00:12 GMT (envelope-from ae@FreeBSD.org) Received: (from ae@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id w3RB0Cdk025417; Fri, 27 Apr 2018 11:00:12 GMT (envelope-from ae@FreeBSD.org) Message-Id: <201804271100.w3RB0Cdk025417@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: ae set sender to ae@FreeBSD.org using -f From: "Andrey V. Elsukov" Date: Fri, 27 Apr 2018 11:00:12 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-11@freebsd.org Subject: svn commit: r333056 - stable/11/sys/net X-SVN-Group: stable-11 X-SVN-Commit-Author: ae X-SVN-Commit-Paths: stable/11/sys/net X-SVN-Commit-Revision: 333056 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable-11@freebsd.org X-Mailman-Version: 2.1.25 Precedence: list List-Id: SVN commit messages for only the 11-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 27 Apr 2018 11:00:13 -0000 Author: ae Date: Fri Apr 27 11:00:12 2018 New Revision: 333056 URL: https://svnweb.freebsd.org/changeset/base/333056 Log: MFC r332812: Add dead_bpf_if structure, that should be used as fake bpf_if during ifnet detach. Since destroying interface is not atomic operation and due to the lack of synhronization during destroy, it is possible, that in the time between bpfdetach() and if_free() some queued on destroying interface mbuf will be used by ether_input_internal() and bpf_peers_present() can dereference NULL bpf_if pointer. To protect from this, assign pointer to empty bpf_if_ext structure instead of NULL pointer after bpfdetach(). MFC r332949 (by markj): Use dead_bpf_if instead of bp_null. This fixes a -Wunused error when DEV_BPF and NETGRAPH_BPF are not defined. Also remove a stray semicolon added in r332812. Modified: stable/11/sys/net/bpf.c Directory Properties: stable/11/ (props changed) Modified: stable/11/sys/net/bpf.c ============================================================================== --- stable/11/sys/net/bpf.c Fri Apr 27 09:25:27 2018 (r333055) +++ stable/11/sys/net/bpf.c Fri Apr 27 11:00:12 2018 (r333056) @@ -96,6 +96,10 @@ __FBSDID("$FreeBSD$"); MALLOC_DEFINE(M_BPF, "BPF", "BPF data"); +static struct bpf_if_ext dead_bpf_if = { + .bif_dlist = LIST_HEAD_INITIALIZER() +}; + struct bpf_if { #define bif_next bif_ext.bif_next #define bif_dlist bif_ext.bif_dlist @@ -2638,7 +2642,7 @@ bpfdetach(struct ifnet *ifp) */ BPFIF_WLOCK(bp); bp->bif_flags |= BPFIF_FLAG_DYING; - *bp->bif_bpf = NULL; + *bp->bif_bpf = (struct bpf_if *)&dead_bpf_if; BPFIF_WUNLOCK(bp); CTR4(KTR_NET, "%s: sheduling free for encap %d (%p) for if %p", @@ -2957,13 +2961,13 @@ bpf_stats_sysctl(SYSCTL_HANDLER_ARGS) SYSINIT(bpfdev,SI_SUB_DRIVERS,SI_ORDER_MIDDLE,bpf_drvinit,NULL); #else /* !DEV_BPF && !NETGRAPH_BPF */ + /* * NOP stubs to allow bpf-using drivers to load and function. * * A 'better' implementation would allow the core bpf functionality * to be loaded at runtime. */ -static struct bpf_if bp_null; void bpf_tap(struct bpf_if *bp, u_char *pkt, u_int pktlen) @@ -2991,7 +2995,7 @@ void bpfattach2(struct ifnet *ifp, u_int dlt, u_int hdrlen, struct bpf_if **driverp) { - *driverp = &bp_null; + *driverp = (struct bpf_if *)&dead_bpf_if; } void From owner-svn-src-stable-11@freebsd.org Fri Apr 27 12:50:18 2018 Return-Path: Delivered-To: svn-src-stable-11@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 18E69FA7449; Fri, 27 Apr 2018 12:50:18 +0000 (UTC) (envelope-from rmacklem@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 BA6B76D260; Fri, 27 Apr 2018 12:50:17 +0000 (UTC) (envelope-from rmacklem@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 B0B702697E; Fri, 27 Apr 2018 12:50:17 +0000 (UTC) (envelope-from rmacklem@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id w3RCoH5p080397; Fri, 27 Apr 2018 12:50:17 GMT (envelope-from rmacklem@FreeBSD.org) Received: (from rmacklem@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id w3RCoHKu080396; Fri, 27 Apr 2018 12:50:17 GMT (envelope-from rmacklem@FreeBSD.org) Message-Id: <201804271250.w3RCoHKu080396@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: rmacklem set sender to rmacklem@FreeBSD.org using -f From: Rick Macklem Date: Fri, 27 Apr 2018 12:50:17 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-11@freebsd.org Subject: svn commit: r333060 - stable/11/sys/fs/nfsserver X-SVN-Group: stable-11 X-SVN-Commit-Author: rmacklem X-SVN-Commit-Paths: stable/11/sys/fs/nfsserver X-SVN-Commit-Revision: 333060 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable-11@freebsd.org X-Mailman-Version: 2.1.25 Precedence: list List-Id: SVN commit messages for only the 11-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 27 Apr 2018 12:50:18 -0000 Author: rmacklem Date: Fri Apr 27 12:50:17 2018 New Revision: 333060 URL: https://svnweb.freebsd.org/changeset/base/333060 Log: MFC: r332790 Fix OpenDowngrade for NFSv4.1 if a client sets the OPEN_SHARE_ACCESS_WANT* bits. The NFSv4.1 RFC specifies that the OPEN_SHARE_ACCESS_WANT bits can be set in the OpenDowngrade share_access argument and are basically ignored. I do not know of a extant NFSv4.1 client that does this, but this little patch fixes it just in case. It also changes the error from NFSERR_BADXDR to NFSERR_INVAL since the NFSv4.1 RFC specifies this as the error to be returned if bogus bits are set. (The NFSv4.0 RFC didn't specify any error for this, so the error reply can be changed for NFSv4.0 as well.) Found by inspection while looking at a problem with OpenDowngrade reported for the ESXi 6.5 NFSv4.1 client. Modified: stable/11/sys/fs/nfsserver/nfs_nfsdserv.c Directory Properties: stable/11/ (props changed) Modified: stable/11/sys/fs/nfsserver/nfs_nfsdserv.c ============================================================================== --- stable/11/sys/fs/nfsserver/nfs_nfsdserv.c Fri Apr 27 12:44:20 2018 (r333059) +++ stable/11/sys/fs/nfsserver/nfs_nfsdserv.c Fri Apr 27 12:50:17 2018 (r333060) @@ -3235,6 +3235,8 @@ nfsrvd_opendowngrade(struct nfsrv_descript *nd, __unus tl += (NFSX_STATEIDOTHER / NFSX_UNSIGNED); stp->ls_seq = fxdr_unsigned(u_int32_t, *tl++); i = fxdr_unsigned(int, *tl++); + if ((nd->nd_flag & ND_NFSV41) != 0) + i &= ~NFSV4OPEN_WANTDELEGMASK; switch (i) { case NFSV4OPEN_ACCESSREAD: stp->ls_flags = (NFSLCK_READACCESS | NFSLCK_DOWNGRADE); @@ -3247,7 +3249,7 @@ nfsrvd_opendowngrade(struct nfsrv_descript *nd, __unus NFSLCK_DOWNGRADE); break; default: - nd->nd_repstat = NFSERR_BADXDR; + nd->nd_repstat = NFSERR_INVAL; } i = fxdr_unsigned(int, *tl); switch (i) { @@ -3263,7 +3265,7 @@ nfsrvd_opendowngrade(struct nfsrv_descript *nd, __unus stp->ls_flags |= (NFSLCK_READDENY | NFSLCK_WRITEDENY); break; default: - nd->nd_repstat = NFSERR_BADXDR; + nd->nd_repstat = NFSERR_INVAL; } clientid.lval[0] = stp->ls_stateid.other[0]; From owner-svn-src-stable-11@freebsd.org Fri Apr 27 12:57:40 2018 Return-Path: Delivered-To: svn-src-stable-11@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 3E98DFA7773; Fri, 27 Apr 2018 12:57:40 +0000 (UTC) (envelope-from rmacklem@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 DC6516E769; Fri, 27 Apr 2018 12:57:39 +0000 (UTC) (envelope-from rmacklem@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 D12F426B1A; Fri, 27 Apr 2018 12:57:39 +0000 (UTC) (envelope-from rmacklem@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id w3RCvdRP085595; Fri, 27 Apr 2018 12:57:39 GMT (envelope-from rmacklem@FreeBSD.org) Received: (from rmacklem@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id w3RCvd30085594; Fri, 27 Apr 2018 12:57:39 GMT (envelope-from rmacklem@FreeBSD.org) Message-Id: <201804271257.w3RCvd30085594@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: rmacklem set sender to rmacklem@FreeBSD.org using -f From: Rick Macklem Date: Fri, 27 Apr 2018 12:57:39 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-11@freebsd.org Subject: svn commit: r333061 - stable/11/sys/fs/nfsclient X-SVN-Group: stable-11 X-SVN-Commit-Author: rmacklem X-SVN-Commit-Paths: stable/11/sys/fs/nfsclient X-SVN-Commit-Revision: 333061 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable-11@freebsd.org X-Mailman-Version: 2.1.25 Precedence: list List-Id: SVN commit messages for only the 11-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 27 Apr 2018 12:57:40 -0000 Author: rmacklem Date: Fri Apr 27 12:57:39 2018 New Revision: 333061 URL: https://svnweb.freebsd.org/changeset/base/333061 Log: MFC: r332813 Fix use of pointer after being set NULL. Using a pointer after setting it NULL is probably not a good plan. Spotted by inspection during changes for Flexible File Layout Ioerr handling. This code path obviously isn't normally executed. Modified: stable/11/sys/fs/nfsclient/nfs_clport.c Directory Properties: stable/11/ (props changed) Modified: stable/11/sys/fs/nfsclient/nfs_clport.c ============================================================================== --- stable/11/sys/fs/nfsclient/nfs_clport.c Fri Apr 27 12:50:17 2018 (r333060) +++ stable/11/sys/fs/nfsclient/nfs_clport.c Fri Apr 27 12:57:39 2018 (r333061) @@ -1391,8 +1391,8 @@ nfssvc_nfscl(struct thread *td, struct nfssvc_args *ua NFSMNTP_CANCELRPCS); mtx_unlock(&nmp->nm_mtx); } else { - nmp = NULL; mtx_unlock(&nmp->nm_mtx); + nmp = NULL; } break; } From owner-svn-src-stable-11@freebsd.org Fri Apr 27 18:07:32 2018 Return-Path: Delivered-To: svn-src-stable-11@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 2F8BDFAEC76; Fri, 27 Apr 2018 18:07:32 +0000 (UTC) (envelope-from jhb@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 CF64B7618C; Fri, 27 Apr 2018 18:07:31 +0000 (UTC) (envelope-from jhb@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 C95CD1E79; Fri, 27 Apr 2018 18:07:31 +0000 (UTC) (envelope-from jhb@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id w3RI7V5v046293; Fri, 27 Apr 2018 18:07:31 GMT (envelope-from jhb@FreeBSD.org) Received: (from jhb@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id w3RI7Vd8046289; Fri, 27 Apr 2018 18:07:31 GMT (envelope-from jhb@FreeBSD.org) Message-Id: <201804271807.w3RI7Vd8046289@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: jhb set sender to jhb@FreeBSD.org using -f From: John Baldwin Date: Fri, 27 Apr 2018 18:07:31 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-11@freebsd.org Subject: svn commit: r333069 - in stable/11: etc/mtree sys/kern sys/sys tests/sys tests/sys/capsicum X-SVN-Group: stable-11 X-SVN-Commit-Author: jhb X-SVN-Commit-Paths: in stable/11: etc/mtree sys/kern sys/sys tests/sys tests/sys/capsicum X-SVN-Commit-Revision: 333069 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable-11@freebsd.org X-Mailman-Version: 2.1.25 Precedence: list List-Id: SVN commit messages for only the 11-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 27 Apr 2018 18:07:32 -0000 Author: jhb Date: Fri Apr 27 18:07:31 2018 New Revision: 333069 URL: https://svnweb.freebsd.org/changeset/base/333069 Log: MFC 332657: Properly do a deep copy of the ioctls capability array for fget_cap(). fget_cap() tries to do a cheaper snapshot of a file descriptor without holding the file descriptor lock. This snapshot does not do a deep copy of the ioctls capability array, but instead uses a different return value to inform the caller to retry the copy with the lock held. However, filecaps_copy() was returning 1 to indicate that a retry was required, and fget_cap() was checking for 0 (actually '!filecaps_copy()'). As a result, fget_cap() did not do a deep copy of the ioctls array and just reused the original pointer. This cause multiple file descriptor entries to think they owned the same pointer and eventually resulted in duplicate frees. The only code path that I'm aware of that triggers this is to create a listen socket that has a restricted list of ioctls and then call accept() which calls fget_cap() with a valid filecaps structure from getsock_cap(). To fix, change the return value of filecaps_copy() to return true if it succeeds in copying the caps and false if it fails because the lock is required. I find this more intuitive than fixing the caller in this case. While here, change the return type from 'int' to 'bool'. Finally, make filecaps_copy() more robust in the failure case by not copying any of the source filecaps structure over. This avoids the possibility of leaking a pointer into a structure if a similar future caller doesn't properly handle the return value from filecaps_copy() at the expense of one more branch. I also added a test case that panics before this change and now passes. Added: stable/11/tests/sys/capsicum/ - copied from r332657, head/tests/sys/capsicum/ Modified: stable/11/etc/mtree/BSD.tests.dist stable/11/sys/kern/kern_descrip.c stable/11/sys/sys/filedesc.h stable/11/tests/sys/Makefile Directory Properties: stable/11/ (props changed) Modified: stable/11/etc/mtree/BSD.tests.dist ============================================================================== --- stable/11/etc/mtree/BSD.tests.dist Fri Apr 27 17:20:23 2018 (r333068) +++ stable/11/etc/mtree/BSD.tests.dist Fri Apr 27 18:07:31 2018 (r333069) @@ -420,6 +420,8 @@ .. aio .. + capsicum + .. fifo .. file Modified: stable/11/sys/kern/kern_descrip.c ============================================================================== --- stable/11/sys/kern/kern_descrip.c Fri Apr 27 17:20:23 2018 (r333068) +++ stable/11/sys/kern/kern_descrip.c Fri Apr 27 18:07:31 2018 (r333069) @@ -1446,16 +1446,16 @@ filecaps_init(struct filecaps *fcaps) * Note that if the table was not locked, the caller has to check the relevant * sequence counter to determine whether the operation was successful. */ -int +bool filecaps_copy(const struct filecaps *src, struct filecaps *dst, bool locked) { size_t size; + if (src->fc_ioctls != NULL && !locked) + return (false); *dst = *src; if (src->fc_ioctls == NULL) - return (0); - if (!locked) - return (1); + return (true); KASSERT(src->fc_nioctls > 0, ("fc_ioctls != NULL, but fc_nioctls=%hd", src->fc_nioctls)); @@ -1463,7 +1463,7 @@ filecaps_copy(const struct filecaps *src, struct filec size = sizeof(src->fc_ioctls[0]) * src->fc_nioctls; dst->fc_ioctls = malloc(size, M_FILECAPS, M_WAITOK); bcopy(src->fc_ioctls, dst->fc_ioctls, size); - return (0); + return (true); } /* Modified: stable/11/sys/sys/filedesc.h ============================================================================== --- stable/11/sys/sys/filedesc.h Fri Apr 27 17:20:23 2018 (r333068) +++ stable/11/sys/sys/filedesc.h Fri Apr 27 18:07:31 2018 (r333069) @@ -153,7 +153,7 @@ enum { struct thread; void filecaps_init(struct filecaps *fcaps); -int filecaps_copy(const struct filecaps *src, struct filecaps *dst, +bool filecaps_copy(const struct filecaps *src, struct filecaps *dst, bool locked); void filecaps_move(struct filecaps *src, struct filecaps *dst); void filecaps_free(struct filecaps *fcaps); Modified: stable/11/tests/sys/Makefile ============================================================================== --- stable/11/tests/sys/Makefile Fri Apr 27 17:20:23 2018 (r333068) +++ stable/11/tests/sys/Makefile Fri Apr 27 18:07:31 2018 (r333069) @@ -4,6 +4,7 @@ TESTSDIR= ${TESTSBASE}/sys TESTS_SUBDIRS+= acl TESTS_SUBDIRS+= aio +TESTS_SUBDIRS+= capsicum TESTS_SUBDIRS+= fifo TESTS_SUBDIRS+= file TESTS_SUBDIRS+= fs From owner-svn-src-stable-11@freebsd.org Fri Apr 27 19:21:42 2018 Return-Path: Delivered-To: svn-src-stable-11@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 0C28DFB0120; Fri, 27 Apr 2018 19:21:42 +0000 (UTC) (envelope-from dim@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 A5BA487A1E; Fri, 27 Apr 2018 19:21:41 +0000 (UTC) (envelope-from dim@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 A03E92B1F; Fri, 27 Apr 2018 19:21:41 +0000 (UTC) (envelope-from dim@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id w3RJLft0083370; Fri, 27 Apr 2018 19:21:41 GMT (envelope-from dim@FreeBSD.org) Received: (from dim@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id w3RJLdp6083349; Fri, 27 Apr 2018 19:21:39 GMT (envelope-from dim@FreeBSD.org) Message-Id: <201804271921.w3RJLdp6083349@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: dim set sender to dim@FreeBSD.org using -f From: Dimitry Andric Date: Fri, 27 Apr 2018 19:21:39 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-11@freebsd.org Subject: svn commit: r333070 - in stable/11: contrib/llvm/include/llvm/CodeGen contrib/llvm/lib/CodeGen contrib/llvm/lib/Target/X86 contrib/llvm/lib/Target/X86/Disassembler contrib/llvm/tools/clang/include/... X-SVN-Group: stable-11 X-SVN-Commit-Author: dim X-SVN-Commit-Paths: in stable/11: contrib/llvm/include/llvm/CodeGen contrib/llvm/lib/CodeGen contrib/llvm/lib/Target/X86 contrib/llvm/lib/Target/X86/Disassembler contrib/llvm/tools/clang/include/clang/Driver contrib/llvm... X-SVN-Commit-Revision: 333070 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable-11@freebsd.org X-Mailman-Version: 2.1.25 Precedence: list List-Id: SVN commit messages for only the 11-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 27 Apr 2018 19:21:42 -0000 Author: dim Date: Fri Apr 27 19:21:39 2018 New Revision: 333070 URL: https://svnweb.freebsd.org/changeset/base/333070 Log: MFC r332833: Recommit r332501, with an additional upstream fix for "Cannot lower EFLAGS copy that lives out of a basic block!" errors on i386. Pull in r325446 from upstream clang trunk (by me): [X86] Add 'sahf' CPU feature to frontend Summary: Make clang accept `-msahf` (and `-mno-sahf`) flags to activate the `+sahf` feature for the backend, for bug 36028 (Incorrect use of pushf/popf enables/disables interrupts on amd64 kernels). This was originally submitted in bug 36037 by Jonathan Looney . As described there, GCC also uses `-msahf` for this feature, and the backend already recognizes the `+sahf` feature. All that is needed is to teach clang to pass this on to the backend. The mapping of feature support onto CPUs may not be complete; rather, it was chosen to match LLVM's idea of which CPUs support this feature (see lib/Target/X86/X86.td). I also updated the affected test case (CodeGen/attr-target-x86.c) to match the emitted output. Reviewers: craig.topper, coby, efriedma, rsmith Reviewed By: craig.topper Subscribers: emaste, cfe-commits Differential Revision: https://reviews.llvm.org/D43394 Pull in r328944 from upstream llvm trunk (by Chandler Carruth): [x86] Expose more of the condition conversion routines in the public API for X86's instruction information. I've now got a second patch under review that needs these same APIs. This bit is nicely orthogonal and obvious, so landing it. NFC. Pull in r329414 from upstream llvm trunk (by Craig Topper): [X86] Merge itineraries for CLC, CMC, and STC. These are very simple flag setting instructions that appear to only be a single uop. They're unlikely to need this separation. Pull in r329657 from upstream llvm trunk (by Chandler Carruth): [x86] Introduce a pass to begin more systematically fixing PR36028 and similar issues. The key idea is to lower COPY nodes populating EFLAGS by scanning the uses of EFLAGS and introducing dedicated code to preserve the necessary state in a GPR. In the vast majority of cases, these uses are cmovCC and jCC instructions. For such cases, we can very easily save and restore the necessary information by simply inserting a setCC into a GPR where the original flags are live, and then testing that GPR directly to feed the cmov or conditional branch. However, things are a bit more tricky if arithmetic is using the flags. This patch handles the vast majority of cases that seem to come up in practice: adc, adcx, adox, rcl, and rcr; all without taking advantage of partially preserved EFLAGS as LLVM doesn't currently model that at all. There are a large number of operations that techinaclly observe EFLAGS currently but shouldn't in this case -- they typically are using DF. Currently, they will not be handled by this approach. However, I have never seen this issue come up in practice. It is already pretty rare to have these patterns come up in practical code with LLVM. I had to resort to writing MIR tests to cover most of the logic in this pass already. I suspect even with its current amount of coverage of arithmetic users of EFLAGS it will be a significant improvement over the current use of pushf/popf. It will also produce substantially faster code in most of the common patterns. This patch also removes all of the old lowering for EFLAGS copies, and the hack that forced us to use a frame pointer when EFLAGS copies were found anywhere in a function so that the dynamic stack adjustment wasn't a problem. None of this is needed as we now lower all of these copies directly in MI and without require stack adjustments. Lots of thanks to Reid who came up with several aspects of this approach, and Craig who helped me work out a couple of things tripping me up while working on this. Differential Revision: https://reviews.llvm.org/D45146 Pull in r329673 from upstream llvm trunk (by Chandler Carruth): [x86] Model the direction flag (DF) separately from the rest of EFLAGS. This cleans up a number of operations that only claimed te use EFLAGS due to using DF. But no instructions which we think of us setting EFLAGS actually modify DF (other than things like popf) and so this needlessly creates uses of EFLAGS that aren't really there. In fact, DF is so restrictive it is pretty easy to model. Only STD, CLD, and the whole-flags writes (WRFLAGS and POPF) need to model this. I've also somewhat cleaned up some of the flag management instruction definitions to be in the correct .td file. Adding this extra register also uncovered a failure to use the correct datatype to hold X86 registers, and I've corrected that as necessary here. Differential Revision: https://reviews.llvm.org/D45154 Pull in r330264 from upstream llvm trunk (by Chandler Carruth): [x86] Fix PR37100 by teaching the EFLAGS copy lowering to rewrite uses across basic blocks in the limited cases where it is very straight forward to do so. This will also be useful for other places where we do some limited EFLAGS propagation across CFG edges and need to handle copy rewrites afterward. I think this is rapidly approaching the maximum we can and should be doing here. Everything else begins to require either heroic analysis to prove how to do PHI insertion manually, or somehow managing arbitrary PHI-ing of EFLAGS with general PHI insertion. Neither of these seem at all promising so if those cases come up, we'll almost certainly need to rewrite the parts of LLVM that produce those patterns. We do now require dominator trees in order to reliably diagnose patterns that would require PHI nodes. This is a bit unfortunate but it seems better than the completely mysterious crash we would get otherwise. Differential Revision: https://reviews.llvm.org/D45673 Together, these should ensure clang does not use pushf/popf sequences to save and restore flags, avoiding problems with unrelated flags (such as the interrupt flag) being restored unexpectedly. Requested by: jtl PR: 225330 MFC r332898: Pull in r329771 from upstream llvm trunk (by Craig Topper): [X86] In X86FlagsCopyLowering, when rewriting a memory setcc we need to emit an explicit MOV8mr instruction. Previously the code only knew how to handle setcc to a register. This should fix a crash in the chromium build. This fixes various assertion failures while building ports targeting i386: * www/firefox: isReg() && "This is not a register operand!" * www/iridium, www/qt5-webengine: (I.atEnd() || std::next(I) == def_instr_end()) && "getVRegDef assumes a single definition or no definition" * devel/powerpc64-gcc: FromReg != ToReg && "Cannot replace a reg with itself" Reported by: jbeich PR: 225330, 227686, 227698, 227699 Added: stable/11/contrib/llvm/lib/Target/X86/X86FlagsCopyLowering.cpp - copied, changed from r332833, head/contrib/llvm/lib/Target/X86/X86FlagsCopyLowering.cpp Modified: stable/11/contrib/llvm/include/llvm/CodeGen/MachineBasicBlock.h stable/11/contrib/llvm/lib/CodeGen/MachineBasicBlock.cpp stable/11/contrib/llvm/lib/Target/X86/Disassembler/X86Disassembler.cpp stable/11/contrib/llvm/lib/Target/X86/X86.h stable/11/contrib/llvm/lib/Target/X86/X86ISelLowering.cpp stable/11/contrib/llvm/lib/Target/X86/X86ISelLowering.h stable/11/contrib/llvm/lib/Target/X86/X86InstrCompiler.td stable/11/contrib/llvm/lib/Target/X86/X86InstrInfo.cpp stable/11/contrib/llvm/lib/Target/X86/X86InstrInfo.h stable/11/contrib/llvm/lib/Target/X86/X86InstrInfo.td stable/11/contrib/llvm/lib/Target/X86/X86InstrSystem.td stable/11/contrib/llvm/lib/Target/X86/X86RegisterInfo.td stable/11/contrib/llvm/lib/Target/X86/X86Schedule.td stable/11/contrib/llvm/lib/Target/X86/X86ScheduleAtom.td stable/11/contrib/llvm/lib/Target/X86/X86TargetMachine.cpp stable/11/contrib/llvm/tools/clang/include/clang/Driver/Options.td stable/11/contrib/llvm/tools/clang/lib/Basic/Targets/X86.cpp stable/11/contrib/llvm/tools/clang/lib/Basic/Targets/X86.h stable/11/lib/clang/freebsd_cc_version.h stable/11/lib/clang/libllvm/Makefile Directory Properties: stable/11/ (props changed) Modified: stable/11/contrib/llvm/include/llvm/CodeGen/MachineBasicBlock.h ============================================================================== --- stable/11/contrib/llvm/include/llvm/CodeGen/MachineBasicBlock.h Fri Apr 27 18:07:31 2018 (r333069) +++ stable/11/contrib/llvm/include/llvm/CodeGen/MachineBasicBlock.h Fri Apr 27 19:21:39 2018 (r333070) @@ -449,6 +449,13 @@ class MachineBasicBlock (public) /// Replace successor OLD with NEW and update probability info. void replaceSuccessor(MachineBasicBlock *Old, MachineBasicBlock *New); + /// Copy a successor (and any probability info) from original block to this + /// block's. Uses an iterator into the original blocks successors. + /// + /// This is useful when doing a partial clone of successors. Afterward, the + /// probabilities may need to be normalized. + void copySuccessor(MachineBasicBlock *Orig, succ_iterator I); + /// Transfers all the successors from MBB to this machine basic block (i.e., /// copies all the successors FromMBB and remove all the successors from /// FromMBB). Modified: stable/11/contrib/llvm/lib/CodeGen/MachineBasicBlock.cpp ============================================================================== --- stable/11/contrib/llvm/lib/CodeGen/MachineBasicBlock.cpp Fri Apr 27 18:07:31 2018 (r333069) +++ stable/11/contrib/llvm/lib/CodeGen/MachineBasicBlock.cpp Fri Apr 27 19:21:39 2018 (r333070) @@ -646,6 +646,14 @@ void MachineBasicBlock::replaceSuccessor(MachineBasicB removeSuccessor(OldI); } +void MachineBasicBlock::copySuccessor(MachineBasicBlock *Orig, + succ_iterator I) { + if (Orig->Probs.empty()) + addSuccessor(*I, Orig->getSuccProbability(I)); + else + addSuccessorWithoutProb(*I); +} + void MachineBasicBlock::addPredecessor(MachineBasicBlock *Pred) { Predecessors.push_back(Pred); } Modified: stable/11/contrib/llvm/lib/Target/X86/Disassembler/X86Disassembler.cpp ============================================================================== --- stable/11/contrib/llvm/lib/Target/X86/Disassembler/X86Disassembler.cpp Fri Apr 27 18:07:31 2018 (r333069) +++ stable/11/contrib/llvm/lib/Target/X86/Disassembler/X86Disassembler.cpp Fri Apr 27 19:21:39 2018 (r333070) @@ -265,13 +265,10 @@ MCDisassembler::DecodeStatus X86GenericDisassembler::g /// @param reg - The Reg to append. static void translateRegister(MCInst &mcInst, Reg reg) { #define ENTRY(x) X86::x, - uint8_t llvmRegnums[] = { - ALL_REGS - 0 - }; + static constexpr MCPhysReg llvmRegnums[] = {ALL_REGS}; #undef ENTRY - uint8_t llvmRegnum = llvmRegnums[reg]; + MCPhysReg llvmRegnum = llvmRegnums[reg]; mcInst.addOperand(MCOperand::createReg(llvmRegnum)); } Modified: stable/11/contrib/llvm/lib/Target/X86/X86.h ============================================================================== --- stable/11/contrib/llvm/lib/Target/X86/X86.h Fri Apr 27 18:07:31 2018 (r333069) +++ stable/11/contrib/llvm/lib/Target/X86/X86.h Fri Apr 27 19:21:39 2018 (r333070) @@ -66,6 +66,9 @@ FunctionPass *createX86OptimizeLEAs(); /// Return a pass that transforms setcc + movzx pairs into xor + setcc. FunctionPass *createX86FixupSetCC(); +/// Return a pass that lowers EFLAGS copy pseudo instructions. +FunctionPass *createX86FlagsCopyLoweringPass(); + /// Return a pass that expands WinAlloca pseudo-instructions. FunctionPass *createX86WinAllocaExpander(); Copied and modified: stable/11/contrib/llvm/lib/Target/X86/X86FlagsCopyLowering.cpp (from r332833, head/contrib/llvm/lib/Target/X86/X86FlagsCopyLowering.cpp) ============================================================================== --- head/contrib/llvm/lib/Target/X86/X86FlagsCopyLowering.cpp Fri Apr 20 18:20:55 2018 (r332833, copy source) +++ stable/11/contrib/llvm/lib/Target/X86/X86FlagsCopyLowering.cpp Fri Apr 27 19:21:39 2018 (r333070) @@ -770,8 +770,27 @@ void X86FlagsCopyLoweringPass::rewriteSetCC(MachineBas if (!CondReg) CondReg = promoteCondToReg(TestMBB, TestPos, TestLoc, Cond); - // Rewriting this is trivial: we just replace the register and remove the - // setcc. - MRI->replaceRegWith(SetCCI.getOperand(0).getReg(), CondReg); + // Rewriting a register def is trivial: we just replace the register and + // remove the setcc. + if (!SetCCI.mayStore()) { + assert(SetCCI.getOperand(0).isReg() && + "Cannot have a non-register defined operand to SETcc!"); + MRI->replaceRegWith(SetCCI.getOperand(0).getReg(), CondReg); + SetCCI.eraseFromParent(); + return; + } + + // Otherwise, we need to emit a store. + auto MIB = BuildMI(*SetCCI.getParent(), SetCCI.getIterator(), + SetCCI.getDebugLoc(), TII->get(X86::MOV8mr)); + // Copy the address operands. + for (int i = 0; i < X86::AddrNumOperands; ++i) + MIB.add(SetCCI.getOperand(i)); + + MIB.addReg(CondReg); + + MIB->setMemRefs(SetCCI.memoperands_begin(), SetCCI.memoperands_end()); + SetCCI.eraseFromParent(); + return; } Modified: stable/11/contrib/llvm/lib/Target/X86/X86ISelLowering.cpp ============================================================================== --- stable/11/contrib/llvm/lib/Target/X86/X86ISelLowering.cpp Fri Apr 27 18:07:31 2018 (r333069) +++ stable/11/contrib/llvm/lib/Target/X86/X86ISelLowering.cpp Fri Apr 27 19:21:39 2018 (r333070) @@ -27781,11 +27781,16 @@ X86TargetLowering::EmitInstrWithCustomInserter(Machine MI.getOpcode() == X86::RDFLAGS32 ? X86::PUSHF32 : X86::PUSHF64; unsigned Pop = MI.getOpcode() == X86::RDFLAGS32 ? X86::POP32r : X86::POP64r; MachineInstr *Push = BuildMI(*BB, MI, DL, TII->get(PushF)); - // Permit reads of the FLAGS register without it being defined. + // Permit reads of the EFLAGS and DF registers without them being defined. // This intrinsic exists to read external processor state in flags, such as // the trap flag, interrupt flag, and direction flag, none of which are // modeled by the backend. + assert(Push->getOperand(2).getReg() == X86::EFLAGS && + "Unexpected register in operand!"); Push->getOperand(2).setIsUndef(); + assert(Push->getOperand(3).getReg() == X86::DF && + "Unexpected register in operand!"); + Push->getOperand(3).setIsUndef(); BuildMI(*BB, MI, DL, TII->get(Pop), MI.getOperand(0).getReg()); MI.eraseFromParent(); // The pseudo is gone now. @@ -37827,25 +37832,6 @@ bool X86TargetLowering::isTypeDesirableForOp(unsigned case ISD::XOR: return false; } -} - -/// This function checks if any of the users of EFLAGS copies the EFLAGS. We -/// know that the code that lowers COPY of EFLAGS has to use the stack, and if -/// we don't adjust the stack we clobber the first frame index. -/// See X86InstrInfo::copyPhysReg. -static bool hasCopyImplyingStackAdjustment(const MachineFunction &MF) { - const MachineRegisterInfo &MRI = MF.getRegInfo(); - return any_of(MRI.reg_instructions(X86::EFLAGS), - [](const MachineInstr &RI) { return RI.isCopy(); }); -} - -void X86TargetLowering::finalizeLowering(MachineFunction &MF) const { - if (hasCopyImplyingStackAdjustment(MF)) { - MachineFrameInfo &MFI = MF.getFrameInfo(); - MFI.setHasCopyImplyingStackAdjustment(true); - } - - TargetLoweringBase::finalizeLowering(MF); } /// This method query the target whether it is beneficial for dag combiner to Modified: stable/11/contrib/llvm/lib/Target/X86/X86ISelLowering.h ============================================================================== --- stable/11/contrib/llvm/lib/Target/X86/X86ISelLowering.h Fri Apr 27 18:07:31 2018 (r333069) +++ stable/11/contrib/llvm/lib/Target/X86/X86ISelLowering.h Fri Apr 27 19:21:39 2018 (r333070) @@ -1099,9 +1099,6 @@ namespace llvm { bool lowerInterleavedStore(StoreInst *SI, ShuffleVectorInst *SVI, unsigned Factor) const override; - - void finalizeLowering(MachineFunction &MF) const override; - protected: std::pair findRepresentativeClass(const TargetRegisterInfo *TRI, Modified: stable/11/contrib/llvm/lib/Target/X86/X86InstrCompiler.td ============================================================================== --- stable/11/contrib/llvm/lib/Target/X86/X86InstrCompiler.td Fri Apr 27 18:07:31 2018 (r333069) +++ stable/11/contrib/llvm/lib/Target/X86/X86InstrCompiler.td Fri Apr 27 19:21:39 2018 (r333070) @@ -473,7 +473,7 @@ let Defs = [EAX, ECX, EDX, FP0, FP1, FP2, FP3, FP4, FP ST0, ST1, ST2, ST3, ST4, ST5, ST6, ST7, MM0, MM1, MM2, MM3, MM4, MM5, MM6, MM7, XMM0, XMM1, XMM2, XMM3, XMM4, XMM5, XMM6, XMM7, - XMM8, XMM9, XMM10, XMM11, XMM12, XMM13, XMM14, XMM15, EFLAGS], + XMM8, XMM9, XMM10, XMM11, XMM12, XMM13, XMM14, XMM15, EFLAGS, DF], usesCustomInserter = 1, Uses = [ESP, SSP] in { def TLS_addr32 : I<0, Pseudo, (outs), (ins i32mem:$sym), "# TLS_addr32", @@ -493,7 +493,7 @@ let Defs = [RAX, RCX, RDX, RSI, RDI, R8, R9, R10, R11, ST0, ST1, ST2, ST3, ST4, ST5, ST6, ST7, MM0, MM1, MM2, MM3, MM4, MM5, MM6, MM7, XMM0, XMM1, XMM2, XMM3, XMM4, XMM5, XMM6, XMM7, - XMM8, XMM9, XMM10, XMM11, XMM12, XMM13, XMM14, XMM15, EFLAGS], + XMM8, XMM9, XMM10, XMM11, XMM12, XMM13, XMM14, XMM15, EFLAGS, DF], usesCustomInserter = 1, Uses = [RSP, SSP] in { def TLS_addr64 : I<0, Pseudo, (outs), (ins i64mem:$sym), "# TLS_addr64", @@ -509,7 +509,7 @@ def TLS_base_addr64 : I<0, Pseudo, (outs), (ins i64mem // For i386, the address of the thunk is passed on the stack, on return the // address of the variable is in %eax. %ecx is trashed during the function // call. All other registers are preserved. -let Defs = [EAX, ECX, EFLAGS], +let Defs = [EAX, ECX, EFLAGS, DF], Uses = [ESP, SSP], usesCustomInserter = 1 in def TLSCall_32 : I<0, Pseudo, (outs), (ins i32mem:$sym), @@ -522,7 +522,7 @@ def TLSCall_32 : I<0, Pseudo, (outs), (ins i32mem:$sym // %rdi. The lowering will do the right thing with RDI. // On return the address of the variable is in %rax. All other // registers are preserved. -let Defs = [RAX, EFLAGS], +let Defs = [RAX, EFLAGS, DF], Uses = [RSP, SSP], usesCustomInserter = 1 in def TLSCall_64 : I<0, Pseudo, (outs), (ins i64mem:$sym), Modified: stable/11/contrib/llvm/lib/Target/X86/X86InstrInfo.cpp ============================================================================== --- stable/11/contrib/llvm/lib/Target/X86/X86InstrInfo.cpp Fri Apr 27 18:07:31 2018 (r333069) +++ stable/11/contrib/llvm/lib/Target/X86/X86InstrInfo.cpp Fri Apr 27 19:21:39 2018 (r333070) @@ -5782,7 +5782,7 @@ bool X86InstrInfo::findCommutedOpIndices(MachineInstr return false; } -static X86::CondCode getCondFromBranchOpc(unsigned BrOpc) { +X86::CondCode X86::getCondFromBranchOpc(unsigned BrOpc) { switch (BrOpc) { default: return X86::COND_INVALID; case X86::JE_1: return X86::COND_E; @@ -5805,7 +5805,7 @@ static X86::CondCode getCondFromBranchOpc(unsigned BrO } /// Return condition code of a SET opcode. -static X86::CondCode getCondFromSETOpc(unsigned Opc) { +X86::CondCode X86::getCondFromSETOpc(unsigned Opc) { switch (Opc) { default: return X86::COND_INVALID; case X86::SETAr: case X86::SETAm: return X86::COND_A; @@ -6130,7 +6130,7 @@ void X86InstrInfo::replaceBranchWithTailCall( if (!I->isBranch()) assert(0 && "Can't find the branch to replace!"); - X86::CondCode CC = getCondFromBranchOpc(I->getOpcode()); + X86::CondCode CC = X86::getCondFromBranchOpc(I->getOpcode()); assert(BranchCond.size() == 1); if (CC != BranchCond[0].getImm()) continue; @@ -6237,7 +6237,7 @@ bool X86InstrInfo::AnalyzeBranchImpl( } // Handle conditional branches. - X86::CondCode BranchCode = getCondFromBranchOpc(I->getOpcode()); + X86::CondCode BranchCode = X86::getCondFromBranchOpc(I->getOpcode()); if (BranchCode == X86::COND_INVALID) return true; // Can't handle indirect branch. @@ -6433,7 +6433,7 @@ unsigned X86InstrInfo::removeBranch(MachineBasicBlock if (I->isDebugValue()) continue; if (I->getOpcode() != X86::JMP_1 && - getCondFromBranchOpc(I->getOpcode()) == X86::COND_INVALID) + X86::getCondFromBranchOpc(I->getOpcode()) == X86::COND_INVALID) break; // Remove the branch. I->eraseFromParent(); @@ -6710,102 +6710,12 @@ void X86InstrInfo::copyPhysReg(MachineBasicBlock &MBB, return; } - bool FromEFLAGS = SrcReg == X86::EFLAGS; - bool ToEFLAGS = DestReg == X86::EFLAGS; - int Reg = FromEFLAGS ? DestReg : SrcReg; - bool is32 = X86::GR32RegClass.contains(Reg); - bool is64 = X86::GR64RegClass.contains(Reg); - - if ((FromEFLAGS || ToEFLAGS) && (is32 || is64)) { - int Mov = is64 ? X86::MOV64rr : X86::MOV32rr; - int Push = is64 ? X86::PUSH64r : X86::PUSH32r; - int PushF = is64 ? X86::PUSHF64 : X86::PUSHF32; - int Pop = is64 ? X86::POP64r : X86::POP32r; - int PopF = is64 ? X86::POPF64 : X86::POPF32; - int AX = is64 ? X86::RAX : X86::EAX; - - if (!Subtarget.hasLAHFSAHF()) { - assert(Subtarget.is64Bit() && - "Not having LAHF/SAHF only happens on 64-bit."); - // Moving EFLAGS to / from another register requires a push and a pop. - // Notice that we have to adjust the stack if we don't want to clobber the - // first frame index. See X86FrameLowering.cpp - usesTheStack. - if (FromEFLAGS) { - BuildMI(MBB, MI, DL, get(PushF)); - BuildMI(MBB, MI, DL, get(Pop), DestReg); - } - if (ToEFLAGS) { - BuildMI(MBB, MI, DL, get(Push)) - .addReg(SrcReg, getKillRegState(KillSrc)); - BuildMI(MBB, MI, DL, get(PopF)); - } - return; - } - - // The flags need to be saved, but saving EFLAGS with PUSHF/POPF is - // inefficient. Instead: - // - Save the overflow flag OF into AL using SETO, and restore it using a - // signed 8-bit addition of AL and INT8_MAX. - // - Save/restore the bottom 8 EFLAGS bits (CF, PF, AF, ZF, SF) to/from AH - // using LAHF/SAHF. - // - When RAX/EAX is live and isn't the destination register, make sure it - // isn't clobbered by PUSH/POP'ing it before and after saving/restoring - // the flags. - // This approach is ~2.25x faster than using PUSHF/POPF. - // - // This is still somewhat inefficient because we don't know which flags are - // actually live inside EFLAGS. Were we able to do a single SETcc instead of - // SETO+LAHF / ADDB+SAHF the code could be 1.02x faster. - // - // PUSHF/POPF is also potentially incorrect because it affects other flags - // such as TF/IF/DF, which LLVM doesn't model. - // - // Notice that we have to adjust the stack if we don't want to clobber the - // first frame index. - // See X86ISelLowering.cpp - X86::hasCopyImplyingStackAdjustment. - - const TargetRegisterInfo &TRI = getRegisterInfo(); - MachineBasicBlock::LivenessQueryResult LQR = - MBB.computeRegisterLiveness(&TRI, AX, MI); - // We do not want to save and restore AX if we do not have to. - // Moreover, if we do so whereas AX is dead, we would need to set - // an undef flag on the use of AX, otherwise the verifier will - // complain that we read an undef value. - // We do not want to change the behavior of the machine verifier - // as this is usually wrong to read an undef value. - if (MachineBasicBlock::LQR_Unknown == LQR) { - LivePhysRegs LPR(TRI); - LPR.addLiveOuts(MBB); - MachineBasicBlock::iterator I = MBB.end(); - while (I != MI) { - --I; - LPR.stepBackward(*I); - } - // AX contains the top most register in the aliasing hierarchy. - // It may not be live, but one of its aliases may be. - for (MCRegAliasIterator AI(AX, &TRI, true); - AI.isValid() && LQR != MachineBasicBlock::LQR_Live; ++AI) - LQR = LPR.contains(*AI) ? MachineBasicBlock::LQR_Live - : MachineBasicBlock::LQR_Dead; - } - bool AXDead = (Reg == AX) || (MachineBasicBlock::LQR_Dead == LQR); - if (!AXDead) - BuildMI(MBB, MI, DL, get(Push)).addReg(AX, getKillRegState(true)); - if (FromEFLAGS) { - BuildMI(MBB, MI, DL, get(X86::SETOr), X86::AL); - BuildMI(MBB, MI, DL, get(X86::LAHF)); - BuildMI(MBB, MI, DL, get(Mov), Reg).addReg(AX); - } - if (ToEFLAGS) { - BuildMI(MBB, MI, DL, get(Mov), AX).addReg(Reg, getKillRegState(KillSrc)); - BuildMI(MBB, MI, DL, get(X86::ADD8ri), X86::AL) - .addReg(X86::AL) - .addImm(INT8_MAX); - BuildMI(MBB, MI, DL, get(X86::SAHF)); - } - if (!AXDead) - BuildMI(MBB, MI, DL, get(Pop), AX); - return; + if (SrcReg == X86::EFLAGS || DestReg == X86::EFLAGS) { + // FIXME: We use a fatal error here because historically LLVM has tried + // lower some of these physreg copies and we want to ensure we get + // reasonable bug reports if someone encounters a case no other testing + // found. This path should be removed after the LLVM 7 release. + report_fatal_error("Unable to copy EFLAGS physical register!"); } DEBUG(dbgs() << "Cannot copy " << RI.getName(SrcReg) @@ -7465,9 +7375,9 @@ bool X86InstrInfo::optimizeCompareInstr(MachineInstr & if (IsCmpZero || IsSwapped) { // We decode the condition code from opcode. if (Instr.isBranch()) - OldCC = getCondFromBranchOpc(Instr.getOpcode()); + OldCC = X86::getCondFromBranchOpc(Instr.getOpcode()); else { - OldCC = getCondFromSETOpc(Instr.getOpcode()); + OldCC = X86::getCondFromSETOpc(Instr.getOpcode()); if (OldCC != X86::COND_INVALID) OpcIsSET = true; else @@ -9413,8 +9323,9 @@ bool X86InstrInfo:: isSafeToMoveRegClassDefs(const TargetRegisterClass *RC) const { // FIXME: Return false for x87 stack register classes for now. We can't // allow any loads of these registers before FpGet_ST0_80. - return !(RC == &X86::CCRRegClass || RC == &X86::RFP32RegClass || - RC == &X86::RFP64RegClass || RC == &X86::RFP80RegClass); + return !(RC == &X86::CCRRegClass || RC == &X86::DFCCRRegClass || + RC == &X86::RFP32RegClass || RC == &X86::RFP64RegClass || + RC == &X86::RFP80RegClass); } /// Return a virtual register initialized with the Modified: stable/11/contrib/llvm/lib/Target/X86/X86InstrInfo.h ============================================================================== --- stable/11/contrib/llvm/lib/Target/X86/X86InstrInfo.h Fri Apr 27 18:07:31 2018 (r333069) +++ stable/11/contrib/llvm/lib/Target/X86/X86InstrInfo.h Fri Apr 27 19:21:39 2018 (r333070) @@ -77,6 +77,12 @@ unsigned getSETFromCond(CondCode CC, bool HasMemoryOpe unsigned getCMovFromCond(CondCode CC, unsigned RegBytes, bool HasMemoryOperand = false); +// Turn jCC opcode into condition code. +CondCode getCondFromBranchOpc(unsigned Opc); + +// Turn setCC opcode into condition code. +CondCode getCondFromSETOpc(unsigned Opc); + // Turn CMov opcode into condition code. CondCode getCondFromCMovOpc(unsigned Opc); Modified: stable/11/contrib/llvm/lib/Target/X86/X86InstrInfo.td ============================================================================== --- stable/11/contrib/llvm/lib/Target/X86/X86InstrInfo.td Fri Apr 27 18:07:31 2018 (r333069) +++ stable/11/contrib/llvm/lib/Target/X86/X86InstrInfo.td Fri Apr 27 19:21:39 2018 (r333070) @@ -1235,18 +1235,18 @@ let mayLoad = 1, mayStore = 1, usesCustomInserter = 1, let mayLoad = 1, mayStore = 1, usesCustomInserter = 1, SchedRW = [WriteRMW] in { - let Defs = [ESP, EFLAGS], Uses = [ESP] in + let Defs = [ESP, EFLAGS, DF], Uses = [ESP] in def WRFLAGS32 : PseudoI<(outs), (ins GR32:$src), [(int_x86_flags_write_u32 GR32:$src)]>, Requires<[Not64BitMode]>; - let Defs = [RSP, EFLAGS], Uses = [RSP] in + let Defs = [RSP, EFLAGS, DF], Uses = [RSP] in def WRFLAGS64 : PseudoI<(outs), (ins GR64:$src), [(int_x86_flags_write_u64 GR64:$src)]>, Requires<[In64BitMode]>; } -let Defs = [ESP, EFLAGS], Uses = [ESP], mayLoad = 1, hasSideEffects=0, +let Defs = [ESP, EFLAGS, DF], Uses = [ESP], mayLoad = 1, hasSideEffects=0, SchedRW = [WriteLoad] in { def POPF16 : I<0x9D, RawFrm, (outs), (ins), "popf{w}", [], IIC_POP_F>, OpSize16; @@ -1254,7 +1254,7 @@ def POPF32 : I<0x9D, RawFrm, (outs), (ins), "popf{l| OpSize32, Requires<[Not64BitMode]>; } -let Defs = [ESP], Uses = [ESP, EFLAGS], mayStore = 1, hasSideEffects=0, +let Defs = [ESP], Uses = [ESP, EFLAGS, DF], mayStore = 1, hasSideEffects=0, SchedRW = [WriteStore] in { def PUSHF16 : I<0x9C, RawFrm, (outs), (ins), "pushf{w}", [], IIC_PUSH_F>, OpSize16; @@ -1294,10 +1294,10 @@ def PUSH64i32 : Ii32S<0x68, RawFrm, (outs), (ins i64i Requires<[In64BitMode]>; } -let Defs = [RSP, EFLAGS], Uses = [RSP], mayLoad = 1, hasSideEffects=0 in +let Defs = [RSP, EFLAGS, DF], Uses = [RSP], mayLoad = 1, hasSideEffects=0 in def POPF64 : I<0x9D, RawFrm, (outs), (ins), "popfq", [], IIC_POP_FD>, OpSize32, Requires<[In64BitMode]>, Sched<[WriteLoad]>; -let Defs = [RSP], Uses = [RSP, EFLAGS], mayStore = 1, hasSideEffects=0 in +let Defs = [RSP], Uses = [RSP, EFLAGS, DF], mayStore = 1, hasSideEffects=0 in def PUSHF64 : I<0x9C, RawFrm, (outs), (ins), "pushfq", [], IIC_PUSH_F>, OpSize32, Requires<[In64BitMode]>, Sched<[WriteStore]>; @@ -1382,8 +1382,7 @@ def BSR64rm : RI<0xBD, MRMSrcMem, (outs GR64:$dst), ( } // Defs = [EFLAGS] let SchedRW = [WriteMicrocoded] in { -// These uses the DF flag in the EFLAGS register to inc or dec EDI and ESI -let Defs = [EDI,ESI], Uses = [EDI,ESI,EFLAGS] in { +let Defs = [EDI,ESI], Uses = [EDI,ESI,DF] in { def MOVSB : I<0xA4, RawFrmDstSrc, (outs), (ins dstidx8:$dst, srcidx8:$src), "movsb\t{$src, $dst|$dst, $src}", [], IIC_MOVS>; def MOVSW : I<0xA5, RawFrmDstSrc, (outs), (ins dstidx16:$dst, srcidx16:$src), @@ -1394,36 +1393,33 @@ def MOVSQ : RI<0xA5, RawFrmDstSrc, (outs), (ins dstidx "movsq\t{$src, $dst|$dst, $src}", [], IIC_MOVS>; } -// These uses the DF flag in the EFLAGS register to inc or dec EDI and ESI -let Defs = [EDI], Uses = [AL,EDI,EFLAGS] in +let Defs = [EDI], Uses = [AL,EDI,DF] in def STOSB : I<0xAA, RawFrmDst, (outs), (ins dstidx8:$dst), "stosb\t{%al, $dst|$dst, al}", [], IIC_STOS>; -let Defs = [EDI], Uses = [AX,EDI,EFLAGS] in +let Defs = [EDI], Uses = [AX,EDI,DF] in def STOSW : I<0xAB, RawFrmDst, (outs), (ins dstidx16:$dst), "stosw\t{%ax, $dst|$dst, ax}", [], IIC_STOS>, OpSize16; -let Defs = [EDI], Uses = [EAX,EDI,EFLAGS] in +let Defs = [EDI], Uses = [EAX,EDI,DF] in def STOSL : I<0xAB, RawFrmDst, (outs), (ins dstidx32:$dst), "stos{l|d}\t{%eax, $dst|$dst, eax}", [], IIC_STOS>, OpSize32; -let Defs = [RDI], Uses = [RAX,RDI,EFLAGS] in +let Defs = [RDI], Uses = [RAX,RDI,DF] in def STOSQ : RI<0xAB, RawFrmDst, (outs), (ins dstidx64:$dst), "stosq\t{%rax, $dst|$dst, rax}", [], IIC_STOS>; -// These uses the DF flag in the EFLAGS register to inc or dec EDI and ESI -let Defs = [EDI,EFLAGS], Uses = [AL,EDI,EFLAGS] in +let Defs = [EDI,EFLAGS], Uses = [AL,EDI,DF] in def SCASB : I<0xAE, RawFrmDst, (outs), (ins dstidx8:$dst), "scasb\t{$dst, %al|al, $dst}", [], IIC_SCAS>; -let Defs = [EDI,EFLAGS], Uses = [AX,EDI,EFLAGS] in +let Defs = [EDI,EFLAGS], Uses = [AX,EDI,DF] in def SCASW : I<0xAF, RawFrmDst, (outs), (ins dstidx16:$dst), "scasw\t{$dst, %ax|ax, $dst}", [], IIC_SCAS>, OpSize16; -let Defs = [EDI,EFLAGS], Uses = [EAX,EDI,EFLAGS] in +let Defs = [EDI,EFLAGS], Uses = [EAX,EDI,DF] in def SCASL : I<0xAF, RawFrmDst, (outs), (ins dstidx32:$dst), "scas{l|d}\t{$dst, %eax|eax, $dst}", [], IIC_SCAS>, OpSize32; -let Defs = [EDI,EFLAGS], Uses = [RAX,EDI,EFLAGS] in +let Defs = [EDI,EFLAGS], Uses = [RAX,EDI,DF] in def SCASQ : RI<0xAF, RawFrmDst, (outs), (ins dstidx64:$dst), "scasq\t{$dst, %rax|rax, $dst}", [], IIC_SCAS>; -// These uses the DF flag in the EFLAGS register to inc or dec EDI and ESI -let Defs = [EDI,ESI,EFLAGS], Uses = [EDI,ESI,EFLAGS] in { +let Defs = [EDI,ESI,EFLAGS], Uses = [EDI,ESI,DF] in { def CMPSB : I<0xA6, RawFrmDstSrc, (outs), (ins dstidx8:$dst, srcidx8:$src), "cmpsb\t{$dst, $src|$src, $dst}", [], IIC_CMPS>; def CMPSW : I<0xA7, RawFrmDstSrc, (outs), (ins dstidx16:$dst, srcidx16:$src), @@ -2070,8 +2066,7 @@ def DATA32_PREFIX : I<0x66, RawFrm, (outs), (ins), "d } // SchedRW // Repeat string operation instruction prefixes -// These use the DF flag in the EFLAGS register to inc or dec ECX -let Defs = [ECX], Uses = [ECX,EFLAGS], SchedRW = [WriteMicrocoded] in { +let Defs = [ECX], Uses = [ECX,DF], SchedRW = [WriteMicrocoded] in { // Repeat (used with INS, OUTS, MOVS, LODS and STOS) def REP_PREFIX : I<0xF3, RawFrm, (outs), (ins), "rep", []>; // Repeat while not equal (used with CMPS and SCAS) @@ -2080,24 +2075,22 @@ def REPNE_PREFIX : I<0xF2, RawFrm, (outs), (ins), "re // String manipulation instructions let SchedRW = [WriteMicrocoded] in { -// These uses the DF flag in the EFLAGS register to inc or dec EDI and ESI -let Defs = [AL,ESI], Uses = [ESI,EFLAGS] in +let Defs = [AL,ESI], Uses = [ESI,DF] in def LODSB : I<0xAC, RawFrmSrc, (outs), (ins srcidx8:$src), "lodsb\t{$src, %al|al, $src}", [], IIC_LODS>; -let Defs = [AX,ESI], Uses = [ESI,EFLAGS] in +let Defs = [AX,ESI], Uses = [ESI,DF] in def LODSW : I<0xAD, RawFrmSrc, (outs), (ins srcidx16:$src), "lodsw\t{$src, %ax|ax, $src}", [], IIC_LODS>, OpSize16; -let Defs = [EAX,ESI], Uses = [ESI,EFLAGS] in +let Defs = [EAX,ESI], Uses = [ESI,DF] in def LODSL : I<0xAD, RawFrmSrc, (outs), (ins srcidx32:$src), "lods{l|d}\t{$src, %eax|eax, $src}", [], IIC_LODS>, OpSize32; -let Defs = [RAX,ESI], Uses = [ESI,EFLAGS] in +let Defs = [RAX,ESI], Uses = [ESI,DF] in def LODSQ : RI<0xAD, RawFrmSrc, (outs), (ins srcidx64:$src), "lodsq\t{$src, %rax|rax, $src}", [], IIC_LODS>; } let SchedRW = [WriteSystem] in { -// These uses the DF flag in the EFLAGS register to inc or dec EDI and ESI -let Defs = [ESI], Uses = [DX,ESI,EFLAGS] in { +let Defs = [ESI], Uses = [DX,ESI,DF] in { def OUTSB : I<0x6E, RawFrmSrc, (outs), (ins srcidx8:$src), "outsb\t{$src, %dx|dx, $src}", [], IIC_OUTS>; def OUTSW : I<0x6F, RawFrmSrc, (outs), (ins srcidx16:$src), @@ -2106,8 +2099,7 @@ def OUTSL : I<0x6F, RawFrmSrc, (outs), (ins srcidx32:$ "outs{l|d}\t{$src, %dx|dx, $src}", [], IIC_OUTS>, OpSize32; } -// These uses the DF flag in the EFLAGS register to inc or dec EDI and ESI -let Defs = [EDI], Uses = [DX,EDI,EFLAGS] in { +let Defs = [EDI], Uses = [DX,EDI,DF] in { def INSB : I<0x6C, RawFrmDst, (outs), (ins dstidx8:$dst), "insb\t{%dx, $dst|$dst, dx}", [], IIC_INS>; def INSW : I<0x6D, RawFrmDst, (outs), (ins dstidx16:$dst), @@ -2117,18 +2109,21 @@ def INSL : I<0x6D, RawFrmDst, (outs), (ins dstidx32:$d } } -// Flag instructions -let SchedRW = [WriteALU] in { -def CLC : I<0xF8, RawFrm, (outs), (ins), "clc", [], IIC_CLC>; -def STC : I<0xF9, RawFrm, (outs), (ins), "stc", [], IIC_STC>; -def CLI : I<0xFA, RawFrm, (outs), (ins), "cli", [], IIC_CLI>; -def STI : I<0xFB, RawFrm, (outs), (ins), "sti", [], IIC_STI>; +// EFLAGS management instructions. +let SchedRW = [WriteALU], Defs = [EFLAGS], Uses = [EFLAGS] in { +def CLC : I<0xF8, RawFrm, (outs), (ins), "clc", [], IIC_CLC_CMC_STC>; +def STC : I<0xF9, RawFrm, (outs), (ins), "stc", [], IIC_CLC_CMC_STC>; +def CMC : I<0xF5, RawFrm, (outs), (ins), "cmc", [], IIC_CLC_CMC_STC>; +} + +// DF management instructions. +// FIXME: These are a bit more expensive than CLC and STC. We should consider +// adjusting their schedule bucket. +let SchedRW = [WriteALU], Defs = [DF] in { def CLD : I<0xFC, RawFrm, (outs), (ins), "cld", [], IIC_CLD>; def STD : I<0xFD, RawFrm, (outs), (ins), "std", [], IIC_STD>; -def CMC : I<0xF5, RawFrm, (outs), (ins), "cmc", [], IIC_CMC>; - -def CLTS : I<0x06, RawFrm, (outs), (ins), "clts", [], IIC_CLTS>, TB; } + // Table lookup instructions let Uses = [AL,EBX], Defs = [AL], hasSideEffects = 0, mayLoad = 1 in Modified: stable/11/contrib/llvm/lib/Target/X86/X86InstrSystem.td ============================================================================== --- stable/11/contrib/llvm/lib/Target/X86/X86InstrSystem.td Fri Apr 27 18:07:31 2018 (r333069) +++ stable/11/contrib/llvm/lib/Target/X86/X86InstrSystem.td Fri Apr 27 19:21:39 2018 (r333070) @@ -693,6 +693,19 @@ let Uses = [RAX, RBX, RCX, RDX], Defs = [RAX, RBX, RCX } // SchedRW //===----------------------------------------------------------------------===// +// TS flag control instruction. +let SchedRW = [WriteSystem] in { +def CLTS : I<0x06, RawFrm, (outs), (ins), "clts", [], IIC_CLTS>, TB; +} + +//===----------------------------------------------------------------------===// +// IF (inside EFLAGS) management instructions. +let SchedRW = [WriteSystem], Uses = [EFLAGS], Defs = [EFLAGS] in { +def CLI : I<0xFA, RawFrm, (outs), (ins), "cli", [], IIC_CLI>; +def STI : I<0xFB, RawFrm, (outs), (ins), "sti", [], IIC_STI>; +} + +//===----------------------------------------------------------------------===// // RDPID Instruction let SchedRW = [WriteSystem] in { def RDPID32 : I<0xC7, MRM7r, (outs GR32:$src), (ins), Modified: stable/11/contrib/llvm/lib/Target/X86/X86RegisterInfo.td ============================================================================== --- stable/11/contrib/llvm/lib/Target/X86/X86RegisterInfo.td Fri Apr 27 18:07:31 2018 (r333069) +++ stable/11/contrib/llvm/lib/Target/X86/X86RegisterInfo.td Fri Apr 27 19:21:39 2018 (r333070) @@ -251,9 +251,19 @@ def ST7 : X86Reg<"st(7)", 7>, DwarfRegNum<[40, 19, 18] // Floating-point status word def FPSW : X86Reg<"fpsw", 0>; -// Status flags register +// Status flags register. +// +// Note that some flags that are commonly thought of as part of the status +// flags register are modeled separately. Typically this is due to instructions +// reading and updating those flags independently of all the others. We don't +// want to create false dependencies between these instructions and so we use +// a separate register to model them. def EFLAGS : X86Reg<"flags", 0>; +// The direction flag. +def DF : X86Reg<"DF", 0>; + + // Segment registers def CS : X86Reg<"cs", 1>; def DS : X86Reg<"ds", 3>; @@ -494,6 +504,10 @@ def CCR : RegisterClass<"X86", [i32], 32, (add EFLAGS) let isAllocatable = 0; } def FPCCR : RegisterClass<"X86", [i16], 16, (add FPSW)> { + let CopyCost = -1; // Don't allow copying of status registers. + let isAllocatable = 0; +} +def DFCCR : RegisterClass<"X86", [i32], 32, (add DF)> { let CopyCost = -1; // Don't allow copying of status registers. let isAllocatable = 0; } Modified: stable/11/contrib/llvm/lib/Target/X86/X86Schedule.td ============================================================================== --- stable/11/contrib/llvm/lib/Target/X86/X86Schedule.td Fri Apr 27 18:07:31 2018 (r333069) +++ stable/11/contrib/llvm/lib/Target/X86/X86Schedule.td Fri Apr 27 19:21:39 2018 (r333070) @@ -608,12 +608,10 @@ def IIC_CMPXCHG_8B : InstrItinClass; def IIC_CMPXCHG_16B : InstrItinClass; def IIC_LODS : InstrItinClass; def IIC_OUTS : InstrItinClass; -def IIC_CLC : InstrItinClass; +def IIC_CLC_CMC_STC : InstrItinClass; def IIC_CLD : InstrItinClass; def IIC_CLI : InstrItinClass; -def IIC_CMC : InstrItinClass; def IIC_CLTS : InstrItinClass; -def IIC_STC : InstrItinClass; def IIC_STI : InstrItinClass; def IIC_STD : InstrItinClass; def IIC_XLAT : InstrItinClass; Modified: stable/11/contrib/llvm/lib/Target/X86/X86ScheduleAtom.td ============================================================================== --- stable/11/contrib/llvm/lib/Target/X86/X86ScheduleAtom.td Fri Apr 27 18:07:31 2018 (r333069) +++ stable/11/contrib/llvm/lib/Target/X86/X86ScheduleAtom.td Fri Apr 27 19:21:39 2018 (r333070) @@ -514,12 +514,10 @@ def AtomItineraries : ProcessorItineraries< InstrItinData] >, InstrItinData] >, InstrItinData] >, - InstrItinData] >, + InstrItinData] >, InstrItinData] >, InstrItinData] >, - InstrItinData] >, InstrItinData] >, - InstrItinData] >, InstrItinData] >, InstrItinData] >, InstrItinData] >, Modified: stable/11/contrib/llvm/lib/Target/X86/X86TargetMachine.cpp ============================================================================== --- stable/11/contrib/llvm/lib/Target/X86/X86TargetMachine.cpp Fri Apr 27 18:07:31 2018 (r333069) +++ stable/11/contrib/llvm/lib/Target/X86/X86TargetMachine.cpp Fri Apr 27 19:21:39 2018 (r333070) @@ -62,6 +62,7 @@ void initializeX86CallFrameOptimizationPass(PassRegist void initializeX86CmovConverterPassPass(PassRegistry &); void initializeX86ExecutionDepsFixPass(PassRegistry &); void initializeX86DomainReassignmentPass(PassRegistry &); +void initializeX86FlagsCopyLoweringPassPass(PassRegistry &); } // end namespace llvm @@ -80,6 +81,7 @@ extern "C" void LLVMInitializeX86Target() { initializeX86CmovConverterPassPass(PR); initializeX86ExecutionDepsFixPass(PR); initializeX86DomainReassignmentPass(PR); + initializeX86FlagsCopyLoweringPassPass(PR); } static std::unique_ptr createTLOF(const Triple &TT) { @@ -415,6 +417,7 @@ void X86PassConfig::addPreRegAlloc() { addPass(createX86CallFrameOptimization()); } + addPass(createX86FlagsCopyLoweringPass()); addPass(createX86WinAllocaExpander()); } void X86PassConfig::addMachineSSAOptimization() { Modified: stable/11/contrib/llvm/tools/clang/include/clang/Driver/Options.td ============================================================================== --- stable/11/contrib/llvm/tools/clang/include/clang/Driver/Options.td Fri Apr 27 18:07:31 2018 (r333069) +++ stable/11/contrib/llvm/tools/clang/include/clang/Driver/Options.td Fri Apr 27 19:21:39 2018 (r333070) @@ -2559,6 +2559,8 @@ def mrtm : Flag<["-"], "mrtm">, Group, Group; def mrdseed : Flag<["-"], "mrdseed">, Group; def mno_rdseed : Flag<["-"], "mno-rdseed">, Group; +def msahf : Flag<["-"], "msahf">, Group; +def mno_sahf : Flag<["-"], "mno-sahf">, Group; def msgx : Flag<["-"], "msgx">, Group; def mno_sgx : Flag<["-"], "mno-sgx">, Group; def msha : Flag<["-"], "msha">, Group; Modified: stable/11/contrib/llvm/tools/clang/lib/Basic/Targets/X86.cpp ============================================================================== --- stable/11/contrib/llvm/tools/clang/lib/Basic/Targets/X86.cpp Fri Apr 27 18:07:31 2018 (r333069) +++ stable/11/contrib/llvm/tools/clang/lib/Basic/Targets/X86.cpp Fri Apr 27 19:21:39 2018 (r333070) @@ -198,6 +198,7 @@ bool X86TargetInfo::initFeatureMap( LLVM_FALLTHROUGH; case CK_Core2: setFeatureEnabledImpl(Features, "ssse3", true); + setFeatureEnabledImpl(Features, "sahf", true); LLVM_FALLTHROUGH; case CK_Yonah: case CK_Prescott: @@ -239,6 +240,7 @@ bool X86TargetInfo::initFeatureMap( setFeatureEnabledImpl(Features, "ssse3", true); setFeatureEnabledImpl(Features, "fxsr", true); setFeatureEnabledImpl(Features, "cx16", true); + setFeatureEnabledImpl(Features, "sahf", true); break; case CK_KNM: @@ -269,6 +271,7 @@ bool X86TargetInfo::initFeatureMap( setFeatureEnabledImpl(Features, "xsaveopt", true); setFeatureEnabledImpl(Features, "xsave", true); setFeatureEnabledImpl(Features, "movbe", true); + setFeatureEnabledImpl(Features, "sahf", true); break; case CK_K6_2: @@ -282,6 +285,7 @@ bool X86TargetInfo::initFeatureMap( setFeatureEnabledImpl(Features, "sse4a", true); setFeatureEnabledImpl(Features, "lzcnt", true); setFeatureEnabledImpl(Features, "popcnt", true); + setFeatureEnabledImpl(Features, "sahf", true); LLVM_FALLTHROUGH; case CK_K8SSE3: setFeatureEnabledImpl(Features, "sse3", true); @@ -315,6 +319,7 @@ bool X86TargetInfo::initFeatureMap( setFeatureEnabledImpl(Features, "prfchw", true); setFeatureEnabledImpl(Features, "cx16", true); setFeatureEnabledImpl(Features, "fxsr", true); + setFeatureEnabledImpl(Features, "sahf", true); break; case CK_ZNVER1: @@ -338,6 +343,7 @@ bool X86TargetInfo::initFeatureMap( setFeatureEnabledImpl(Features, "prfchw", true); setFeatureEnabledImpl(Features, "rdrnd", true); setFeatureEnabledImpl(Features, "rdseed", true); + setFeatureEnabledImpl(Features, "sahf", true); setFeatureEnabledImpl(Features, "sha", true); setFeatureEnabledImpl(Features, "sse4a", true); setFeatureEnabledImpl(Features, "xsave", true); @@ -372,6 +378,7 @@ bool X86TargetInfo::initFeatureMap( setFeatureEnabledImpl(Features, "cx16", true); setFeatureEnabledImpl(Features, "fxsr", true); setFeatureEnabledImpl(Features, "xsave", true); + setFeatureEnabledImpl(Features, "sahf", true); break; } if (!TargetInfo::initFeatureMap(Features, Diags, CPU, FeaturesVec)) @@ -768,6 +775,8 @@ bool X86TargetInfo::handleTargetFeatures(std::vector(Feature) @@ -1240,6 +1249,7 @@ bool X86TargetInfo::isValidFeatureName(StringRef Name) .Case("rdrnd", true) .Case("rdseed", true) .Case("rtm", true) + .Case("sahf", true) .Case("sgx", true) .Case("sha", true) .Case("shstk", true) @@ -1313,6 +1323,7 @@ bool X86TargetInfo::hasFeature(StringRef Feature) cons .Case("retpoline", HasRetpoline) .Case("retpoline-external-thunk", HasRetpolineExternalThunk) .Case("rtm", HasRTM) + .Case("sahf", HasLAHFSAHF) .Case("sgx", HasSGX) .Case("sha", HasSHA) .Case("shstk", HasSHSTK) Modified: stable/11/contrib/llvm/tools/clang/lib/Basic/Targets/X86.h ============================================================================== --- stable/11/contrib/llvm/tools/clang/lib/Basic/Targets/X86.h Fri Apr 27 18:07:31 2018 (r333069) +++ stable/11/contrib/llvm/tools/clang/lib/Basic/Targets/X86.h Fri Apr 27 19:21:39 2018 (r333070) @@ -98,6 +98,7 @@ class LLVM_LIBRARY_VISIBILITY X86TargetInfo : public T bool HasPREFETCHWT1 = false; bool HasRetpoline = false; bool HasRetpolineExternalThunk = false; + bool HasLAHFSAHF = false; /// \brief Enumeration of all of the X86 CPUs supported by Clang. /// Modified: stable/11/lib/clang/freebsd_cc_version.h ============================================================================== --- stable/11/lib/clang/freebsd_cc_version.h Fri Apr 27 18:07:31 2018 (r333069) +++ stable/11/lib/clang/freebsd_cc_version.h Fri Apr 27 19:21:39 2018 (r333070) @@ -1,3 +1,3 @@ /* $FreeBSD$ */ -#define FREEBSD_CC_VERSION 1100507 +#define FREEBSD_CC_VERSION 1100508 Modified: stable/11/lib/clang/libllvm/Makefile ============================================================================== --- stable/11/lib/clang/libllvm/Makefile Fri Apr 27 18:07:31 2018 (r333069) +++ stable/11/lib/clang/libllvm/Makefile Fri Apr 27 19:21:39 2018 (r333070) @@ -1042,6 +1042,7 @@ SRCS_MIN+= Target/X86/X86FastISel.cpp SRCS_MIN+= Target/X86/X86FixupBWInsts.cpp SRCS_MIN+= Target/X86/X86FixupLEAs.cpp SRCS_MIN+= Target/X86/X86FixupSetCC.cpp +SRCS_MIN+= Target/X86/X86FlagsCopyLowering.cpp SRCS_MIN+= Target/X86/X86FloatingPoint.cpp SRCS_MIN+= Target/X86/X86FrameLowering.cpp SRCS_MIN+= Target/X86/X86ISelDAGToDAG.cpp From owner-svn-src-stable-11@freebsd.org Sat Apr 28 00:16:55 2018 Return-Path: Delivered-To: svn-src-stable-11@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 D2EA6FB52EE; Sat, 28 Apr 2018 00:16:55 +0000 (UTC) (envelope-from jhb@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 80860824DB; Sat, 28 Apr 2018 00:16:55 +0000 (UTC) (envelope-from jhb@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 7B4CC5E44; Sat, 28 Apr 2018 00:16:55 +0000 (UTC) (envelope-from jhb@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id w3S0Gta3038386; Sat, 28 Apr 2018 00:16:55 GMT (envelope-from jhb@FreeBSD.org) Received: (from jhb@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id w3S0GtkU038385; Sat, 28 Apr 2018 00:16:55 GMT (envelope-from jhb@FreeBSD.org) Message-Id: <201804280016.w3S0GtkU038385@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: jhb set sender to jhb@FreeBSD.org using -f From: John Baldwin Date: Sat, 28 Apr 2018 00:16:55 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-11@freebsd.org Subject: svn commit: r333080 - in stable: 10/sys/dev/acpica 11/sys/dev/acpica X-SVN-Group: stable-11 X-SVN-Commit-Author: jhb X-SVN-Commit-Paths: in stable: 10/sys/dev/acpica 11/sys/dev/acpica X-SVN-Commit-Revision: 333080 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable-11@freebsd.org X-Mailman-Version: 2.1.25 Precedence: list List-Id: SVN commit messages for only the 11-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 28 Apr 2018 00:16:56 -0000 Author: jhb Date: Sat Apr 28 00:16:54 2018 New Revision: 333080 URL: https://svnweb.freebsd.org/changeset/base/333080 Log: MFC 332733: Workaround fixed I/O port resources encoded as I/O port ranges in _CRS. ACPI I/O port descriptors use _MIN and _MAX fields to specify the set of allowable base (start) addresses for an I/O port resource along with a _LEN field specifying the length. A fixed resource is supposed to be encoded with _MIN == _MAX, but some buggy firmwares instead set _MAX to the end of the fixed range. Relocating I/O ranges only make sense in _PRS (possible resource settings), not in _CRS (current resource settings), so if an I/O port range with _MAX set set to the end of the range is present in _CRS, treat it as a fixed I/O port resource starting at _MIN. PR: 224096 Modified: stable/11/sys/dev/acpica/acpi_resource.c Directory Properties: stable/11/ (props changed) Changes in other areas also in this revision: Modified: stable/10/sys/dev/acpica/acpi_resource.c Directory Properties: stable/10/ (props changed) Modified: stable/11/sys/dev/acpica/acpi_resource.c ============================================================================== --- stable/11/sys/dev/acpica/acpi_resource.c Fri Apr 27 22:15:18 2018 (r333079) +++ stable/11/sys/dev/acpica/acpi_resource.c Sat Apr 28 00:16:54 2018 (r333080) @@ -525,6 +525,24 @@ acpi_res_set_iorange(device_t dev, void *context, uint if (cp == NULL) return; + + /* + * XXX: Some BIOSes contain buggy _CRS entries where fixed I/O + * ranges have the maximum base address (_MAX) to the end of the + * I/O range instead of the start. These are then treated as a + * relocatable I/O range rather than a fixed I/O resource. As a + * workaround, treat I/O resources encoded this way as fixed I/O + * ports. + */ + if (high == (low + length)) { + if (bootverbose) + device_printf(dev, + "_CRS has fixed I/O port range defined as relocatable\n"); + + bus_set_resource(dev, SYS_RES_IOPORT, cp->ar_nio++, low, length); + return; + } + device_printf(dev, "I/O range not supported\n"); } From owner-svn-src-stable-11@freebsd.org Sat Apr 28 02:32:06 2018 Return-Path: Delivered-To: svn-src-stable-11@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 7B2CCFBA090; Sat, 28 Apr 2018 02:32:06 +0000 (UTC) (envelope-from pfg@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 288F77D5E2; Sat, 28 Apr 2018 02:32:06 +0000 (UTC) (envelope-from pfg@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 235A47656; Sat, 28 Apr 2018 02:32:06 +0000 (UTC) (envelope-from pfg@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id w3S2W6CP008042; Sat, 28 Apr 2018 02:32:06 GMT (envelope-from pfg@FreeBSD.org) Received: (from pfg@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id w3S2W6At008041; Sat, 28 Apr 2018 02:32:06 GMT (envelope-from pfg@FreeBSD.org) Message-Id: <201804280232.w3S2W6At008041@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: pfg set sender to pfg@FreeBSD.org using -f From: "Pedro F. Giffuni" Date: Sat, 28 Apr 2018 02:32:06 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-11@freebsd.org Subject: svn commit: r333082 - stable/11/usr.sbin/makefs X-SVN-Group: stable-11 X-SVN-Commit-Author: pfg X-SVN-Commit-Paths: stable/11/usr.sbin/makefs X-SVN-Commit-Revision: 333082 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable-11@freebsd.org X-Mailman-Version: 2.1.25 Precedence: list List-Id: SVN commit messages for only the 11-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 28 Apr 2018 02:32:06 -0000 Author: pfg Date: Sat Apr 28 02:32:05 2018 New Revision: 333082 URL: https://svnweb.freebsd.org/changeset/base/333082 Log: MFC r332986: makefs: Use ENODATA instead of ENOMSG as a translation for missing ENOATTR. This is consistent with what some linux filesystems do and has been adopted in our linuxulator. Modified: stable/11/usr.sbin/makefs/mtree.c Directory Properties: stable/11/ (props changed) Modified: stable/11/usr.sbin/makefs/mtree.c ============================================================================== --- stable/11/usr.sbin/makefs/mtree.c Sat Apr 28 01:14:16 2018 (r333081) +++ stable/11/usr.sbin/makefs/mtree.c Sat Apr 28 02:32:05 2018 (r333082) @@ -54,7 +54,7 @@ __FBSDID("$FreeBSD$"); #include "makefs.h" #ifndef ENOATTR -#define ENOATTR ENOMSG +#define ENOATTR ENODATA #endif #define IS_DOT(nm) ((nm)[0] == '.' && (nm)[1] == '\0')