From patchwork Wed Aug 8 00:01:09 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Geoff Levand X-Patchwork-Id: 954748 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.ozlabs.org (lists.ozlabs.org [IPv6:2401:3900:2:1::3]) (using TLSv1.2 with cipher ADH-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 41lWlN3FQ0z9s3q for ; Wed, 8 Aug 2018 10:01:52 +1000 (AEST) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=infradead.org Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=infradead.org header.i=@infradead.org header.b="j7IdO3f5"; dkim-atps=neutral Received: from lists.ozlabs.org (lists.ozlabs.org [IPv6:2401:3900:2:1::3]) by lists.ozlabs.org (Postfix) with ESMTP id 41lWlN1fq3zDqrM for ; Wed, 8 Aug 2018 10:01:52 +1000 (AEST) Authentication-Results: lists.ozlabs.org; dmarc=none (p=none dis=none) header.from=infradead.org Authentication-Results: lists.ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=infradead.org header.i=@infradead.org header.b="j7IdO3f5"; dkim-atps=neutral X-Original-To: Petitboot@lists.ozlabs.org Delivered-To: Petitboot@lists.ozlabs.org Authentication-Results: lists.ozlabs.org; spf=none (mailfrom) smtp.mailfrom=infradead.org (client-ip=2001:8b0:10b:1231::1; helo=merlin.infradead.org; envelope-from=geoff@infradead.org; receiver=) Authentication-Results: lists.ozlabs.org; dmarc=none (p=none dis=none) header.from=infradead.org Authentication-Results: lists.ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=infradead.org header.i=@infradead.org header.b="j7IdO3f5"; dkim-atps=neutral Received: from merlin.infradead.org (merlin.infradead.org [IPv6:2001:8b0:10b:1231::1]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by lists.ozlabs.org (Postfix) with ESMTPS id 41lWkj0Bz5zDqhV for ; Wed, 8 Aug 2018 10:01:13 +1000 (AEST) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=merlin.20170209; h=Date:Cc:To:Subject:From:References: In-Reply-To:Message-Id:Sender:Reply-To:MIME-Version:Content-Type: Content-Transfer-Encoding:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Id: List-Help:List-Unsubscribe:List-Subscribe:List-Post:List-Owner:List-Archive; bh=dUK4h1D0KyCwWgRstAN68lJJz7lYJjI6+70kTj6bp50=; b=j7IdO3f5NyD9qHBLuFNDQ+QKf o+2QurIl+kKj1oLIWPHbznltZX02Bxd8cZGO+wDo/i0hTWRVVBzE42VYAlMfgjDoa3wF0VTsyHE8u qKs+twSKarBaDPDHLsLuHw5+6BGjCRf9ieD1VZVrDq3jurPWO3zZhwDTYCWw/sgHohU0U+/W9CdnM 5qDPUIxZF8bKRW3B1K6ta5bI6n9LwAYnjpJnz90UOsays9iLBomQmWhPyn0OrrC9d6YixajfJRxpA m+fuHnUQDU2o6YcxH91v0StFwq/760D5dcG1ocFe2VsZoDZk6E8s8gwPcqMgTOYWThfYpBu6Ibgo4 fpqUWGlCw==; Received: from geoff by merlin.infradead.org with local (Exim 4.90_1 #2 (Red Hat Linux)) id 1fnBuX-0004Th-Gn; Wed, 08 Aug 2018 00:01:09 +0000 Message-Id: <9f7d6097fdaaf72b67a27f6c635cac7184c0f007.1533686335.git.geoff@infradead.org> In-Reply-To: References: From: Geoff Levand Patch-Date: Tue, 7 Aug 2018 16:54:47 -0700 Subject: [PATCH v1 1/6] docker: Add strace for interactive debugging To: Samuel Mendoza-Jonas Date: Wed, 08 Aug 2018 00:01:09 +0000 X-BeenThere: petitboot@lists.ozlabs.org X-Mailman-Version: 2.1.27 Precedence: list List-Id: Petitboot bootloader development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Petitboot@lists.ozlabs.org MIME-Version: 1.0 Errors-To: petitboot-bounces+incoming=patchwork.ozlabs.org@lists.ozlabs.org Sender: "Petitboot" Signed-off-by: Geoff Levand --- docker/Dockerfile.builder | 5 +++-- docker/build-pb | 2 +- docker/builder-include | 2 +- 3 files changed, 5 insertions(+), 4 deletions(-) diff --git a/docker/Dockerfile.builder b/docker/Dockerfile.builder index 40ed73f..4bf89d3 100644 --- a/docker/Dockerfile.builder +++ b/docker/Dockerfile.builder @@ -17,13 +17,14 @@ RUN apt-get update && apt-get install -y \ gcc \ git \ libtool \ - libuv-dev \ libdevmapper-dev \ libfdt-dev \ - libncurses-dev \ libgpgme11-dev \ + libncurses-dev \ libssl-dev \ + libuv-dev \ pkg-config \ + strace \ && rm -rf /var/lib/apt/lists/* CMD /bin/bash diff --git a/docker/build-pb b/docker/build-pb index 6ed2af6..1d87fb4 100755 --- a/docker/build-pb +++ b/docker/build-pb @@ -105,7 +105,7 @@ docker_user_args="-u $(id -u):$(id -g)" if [[ -n "${interactive}" ]]; then cd "${TOP_DIR}" - docker_args="${docker_base_args}" + docker_args="${docker_base_args} --privileged" run_cmd "docker run -it ${docker_args} ${DOCKER_TAG} /bin/bash" exit fi diff --git a/docker/builder-include b/docker/builder-include index d2d94a4..4f42e2c 100644 --- a/docker/builder-include +++ b/docker/builder-include @@ -50,7 +50,7 @@ show_tag () { echo "${DOCKER_TAG}" } -: ${VERSION:="2"} +: ${VERSION:="3"} : ${ARCH_TAG:="$(arch_tag)"} : ${DOCKER_NAME:="pb-builder"} : ${DOCKER_TAG:="${DOCKER_NAME}:${VERSION}${ARCH_TAG}"} From patchwork Wed Aug 8 00:01:09 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Geoff Levand X-Patchwork-Id: 954747 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.ozlabs.org (lists.ozlabs.org [IPv6:2401:3900:2:1::3]) (using TLSv1.2 with cipher ADH-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 41lWlD379cz9s3q for ; Wed, 8 Aug 2018 10:01:44 +1000 (AEST) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=infradead.org Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=infradead.org header.i=@infradead.org header.b="jmV+YrTz"; dkim-atps=neutral Received: from lists.ozlabs.org (lists.ozlabs.org [IPv6:2401:3900:2:1::3]) by lists.ozlabs.org (Postfix) with ESMTP id 41lWlD1SrfzDqC8 for ; Wed, 8 Aug 2018 10:01:44 +1000 (AEST) Authentication-Results: lists.ozlabs.org; dmarc=none (p=none dis=none) header.from=infradead.org Authentication-Results: lists.ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=infradead.org header.i=@infradead.org header.b="jmV+YrTz"; dkim-atps=neutral X-Original-To: Petitboot@lists.ozlabs.org Delivered-To: Petitboot@lists.ozlabs.org Authentication-Results: lists.ozlabs.org; spf=none (mailfrom) smtp.mailfrom=infradead.org (client-ip=2001:8b0:10b:1231::1; helo=merlin.infradead.org; envelope-from=geoff@infradead.org; receiver=) Authentication-Results: lists.ozlabs.org; dmarc=none (p=none dis=none) header.from=infradead.org Authentication-Results: lists.ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=infradead.org header.i=@infradead.org header.b="jmV+YrTz"; dkim-atps=neutral Received: from merlin.infradead.org (merlin.infradead.org [IPv6:2001:8b0:10b:1231::1]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by lists.ozlabs.org (Postfix) with ESMTPS id 41lWkj0F6QzDqhb for ; Wed, 8 Aug 2018 10:01:13 +1000 (AEST) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=merlin.20170209; h=Date:Cc:To:Subject:From:References: In-Reply-To:Message-Id:Sender:Reply-To:MIME-Version:Content-Type: Content-Transfer-Encoding:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Id: List-Help:List-Unsubscribe:List-Subscribe:List-Post:List-Owner:List-Archive; bh=Y7RYeBy2KgsJQSKfS55MrnqnWlsC+PEsLvyNVJG6Ii4=; b=jmV+YrTzlQO0ZF7MATJP8xbq+ 940EwjiM+h52PBmL3DJc3ejqAVpRNUvx0HAEeMg2wm6fxonSfeVT2+WUPG8IL1koFhl0xoz0rMj1e sEF8Pekk+aM9jtHHSI0m/I+HDuytvl6J4+gDg876Mh6MvGFrSppSC4Aht0j8KiDEEL+u3nspvdcTI hdG6hL618mm6oWnjw9KNKTi/Fak6xBqxmkIM2lAneoiaQw5w/0X2iKKxrDv8KcQ/bYJGVxcAhLVcu 596PXRkDqdfPS85GeJSZG8LsSur4pyTepk+4cEsHRL5l1373SVR62I3yM1SczjSlspeOVB6/PoHrz WBO0rox2A==; Received: from geoff by merlin.infradead.org with local (Exim 4.90_1 #2 (Red Hat Linux)) id 1fnBuX-0004Tl-MI; Wed, 08 Aug 2018 00:01:09 +0000 Message-Id: In-Reply-To: References: From: Geoff Levand Patch-Date: Tue, 7 Aug 2018 16:54:47 -0700 Subject: [PATCH v1 2/6] discover/platform: Use pb_log_fn To: Samuel Mendoza-Jonas Date: Wed, 08 Aug 2018 00:01:09 +0000 X-BeenThere: petitboot@lists.ozlabs.org X-Mailman-Version: 2.1.27 Precedence: list List-Id: Petitboot bootloader development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Petitboot@lists.ozlabs.org MIME-Version: 1.0 Errors-To: petitboot-bounces+incoming=patchwork.ozlabs.org@lists.ozlabs.org Sender: "Petitboot" Signed-off-by: Geoff Levand --- discover/platform.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/discover/platform.c b/discover/platform.c index 767f66e..237da3a 100644 --- a/discover/platform.c +++ b/discover/platform.c @@ -153,7 +153,7 @@ void config_set_defaults(struct config *config) config->debug = config_debug_on_cmdline(); lang = setlocale(LC_ALL, NULL); - pb_log("lang: %s\n", lang); + pb_log_fn("lang: %s\n", lang); if (lang && strlen(lang)) config->lang = talloc_strdup(config, lang); else From patchwork Wed Aug 8 00:01:09 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Geoff Levand X-Patchwork-Id: 954749 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.ozlabs.org (lists.ozlabs.org [IPv6:2401:3900:2:1::3]) (using TLSv1.2 with cipher ADH-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 41lWlW4Fp2z9s3q for ; Wed, 8 Aug 2018 10:01:59 +1000 (AEST) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=infradead.org Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=infradead.org header.i=@infradead.org header.b="gpXji+qU"; dkim-atps=neutral Received: from lists.ozlabs.org (lists.ozlabs.org [IPv6:2401:3900:2:1::3]) by lists.ozlabs.org (Postfix) with ESMTP id 41lWlW2KXVzDqrN for ; Wed, 8 Aug 2018 10:01:59 +1000 (AEST) Authentication-Results: lists.ozlabs.org; dmarc=none (p=none dis=none) header.from=infradead.org Authentication-Results: lists.ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=infradead.org header.i=@infradead.org header.b="gpXji+qU"; dkim-atps=neutral X-Original-To: Petitboot@lists.ozlabs.org Delivered-To: Petitboot@lists.ozlabs.org Authentication-Results: lists.ozlabs.org; spf=none (mailfrom) smtp.mailfrom=infradead.org (client-ip=2001:8b0:10b:1231::1; helo=merlin.infradead.org; envelope-from=geoff@infradead.org; receiver=) Authentication-Results: lists.ozlabs.org; dmarc=none (p=none dis=none) header.from=infradead.org Authentication-Results: lists.ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=infradead.org header.i=@infradead.org header.b="gpXji+qU"; dkim-atps=neutral Received: from merlin.infradead.org (merlin.infradead.org [IPv6:2001:8b0:10b:1231::1]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by lists.ozlabs.org (Postfix) with ESMTPS id 41lWkj0MMZzDqk8 for ; Wed, 8 Aug 2018 10:01:14 +1000 (AEST) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=merlin.20170209; h=Date:Cc:To:Subject:From:References: In-Reply-To:Message-Id:Sender:Reply-To:MIME-Version:Content-Type: Content-Transfer-Encoding:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Id: List-Help:List-Unsubscribe:List-Subscribe:List-Post:List-Owner:List-Archive; bh=O5uYGcvNpRrDfYHmCxgxT4UKA+ngRIhqlO/Tj9i7AEg=; b=gpXji+qUG4uuploiS+Qhn5xnz XqFvqqoIQuMi6ONJXusYlxRIfchyHHo8Y1247/qZ4KfzoSJJnPL7Nw9RTuhgbfuCPCG1dJVVfVLtC QrhqtjyDZxVp6AriwEQ9/8YvC6hgPOJFqKYRZDa6aGOHxla49b7u+DXtjS+JlEoJWpK3+KUZw10Ec yQLtmP9DaGxgLQHaB3sF1sCQNL9/WyJ+INHmKnN9OmI7wtADAAo7XFj+bF7Rgyzs7fKejYkaRARnW x9/l3CgDKoLm2b3wzFeTe2SVUbqjW0uZZavsLib6Yn5i9+QOLcugCGoEp/dN9O1KPcp7NnJgMzXuj 6pf69V1sA==; Received: from geoff by merlin.infradead.org with local (Exim 4.90_1 #2 (Red Hat Linux)) id 1fnBuX-0004Tp-Rp; Wed, 08 Aug 2018 00:01:09 +0000 Message-Id: In-Reply-To: References: From: Geoff Levand Patch-Date: Tue, 7 Aug 2018 16:54:47 -0700 Subject: [PATCH v1 3/6] pb_log: Break out timestamp To: Samuel Mendoza-Jonas Date: Wed, 08 Aug 2018 00:01:09 +0000 X-BeenThere: petitboot@lists.ozlabs.org X-Mailman-Version: 2.1.27 Precedence: list List-Id: Petitboot bootloader development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Petitboot@lists.ozlabs.org MIME-Version: 1.0 Errors-To: petitboot-bounces+incoming=patchwork.ozlabs.org@lists.ozlabs.org Sender: "Petitboot" Fixes double timestamp on pb_log_fn, pb_debug_fn. Signed-off-by: Geoff Levand --- lib/log/log.c | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/lib/log/log.c b/lib/log/log.c index 5466d81..98b38dd 100644 --- a/lib/log/log.c +++ b/lib/log/log.c @@ -9,7 +9,7 @@ static FILE *logf; static bool debug; -static void __log(const char *fmt, va_list ap) +static void __log_timestamp(void) { char hms[20] = {'\0'}; time_t t; @@ -17,10 +17,15 @@ static void __log(const char *fmt, va_list ap) if (!logf) return; - /* Add timestamp */ t = time(NULL); strftime(hms, sizeof(hms), "%T", localtime(&t)); fprintf(logf, "[%s] ", hms); +} + +static void __log(const char *fmt, va_list ap) +{ + if (!logf) + return; vfprintf(logf, fmt, ap); fflush(logf); @@ -30,6 +35,7 @@ void pb_log(const char *fmt, ...) { va_list ap; va_start(ap, fmt); + __log_timestamp(); __log(fmt, ap); va_end(ap); } From patchwork Wed Aug 8 00:01:10 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Geoff Levand X-Patchwork-Id: 954751 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.ozlabs.org (lists.ozlabs.org [203.11.71.2]) (using TLSv1.2 with cipher ADH-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 41lWlr5lSnz9s3q for ; Wed, 8 Aug 2018 10:02:16 +1000 (AEST) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=infradead.org Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=infradead.org header.i=@infradead.org header.b="S1J+SdJR"; dkim-atps=neutral Received: from lists.ozlabs.org (lists.ozlabs.org [IPv6:2401:3900:2:1::3]) by lists.ozlabs.org (Postfix) with ESMTP id 41lWlr43knzDqhb for ; Wed, 8 Aug 2018 10:02:16 +1000 (AEST) Authentication-Results: lists.ozlabs.org; dmarc=none (p=none dis=none) header.from=infradead.org Authentication-Results: lists.ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=infradead.org header.i=@infradead.org header.b="S1J+SdJR"; dkim-atps=neutral X-Original-To: Petitboot@lists.ozlabs.org Delivered-To: Petitboot@lists.ozlabs.org Authentication-Results: lists.ozlabs.org; spf=none (mailfrom) smtp.mailfrom=infradead.org (client-ip=2001:8b0:10b:1231::1; helo=merlin.infradead.org; envelope-from=geoff@infradead.org; receiver=) Authentication-Results: lists.ozlabs.org; dmarc=none (p=none dis=none) header.from=infradead.org Authentication-Results: lists.ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=infradead.org header.i=@infradead.org header.b="S1J+SdJR"; dkim-atps=neutral Received: from merlin.infradead.org (merlin.infradead.org [IPv6:2001:8b0:10b:1231::1]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by lists.ozlabs.org (Postfix) with ESMTPS id 41lWkj0KDYzDqjk for ; Wed, 8 Aug 2018 10:01:14 +1000 (AEST) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=merlin.20170209; h=Date:Cc:To:Subject:From:References: In-Reply-To:Message-Id:Sender:Reply-To:MIME-Version:Content-Type: Content-Transfer-Encoding:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Id: List-Help:List-Unsubscribe:List-Subscribe:List-Post:List-Owner:List-Archive; bh=2Dz4JAeAvWaxAZaWrFamf3olbTHpVFvoNyNQbNBIJGY=; b=S1J+SdJRtauKe8aifrNnrFzna 8AZlIh+cgRd24kYzJhgHJl+FG+ZkYVv/tmDC14YpdkYuhrfj2rwQ3jb71mpA646+FHKUVji3kHYVs dCsMK1G4iAmiWEBRAj3pogov4SznI7HPHC32vgjYW1EU0O8R+cnSdAnszjdK7jL8MnsNJx7XsKEUL OWK136vP9VfRT//gw6yDXjZfmyQfX+XxW9AZa2T/cAAE/HFELWdD73DZIU8wLN7R5Z1K7EnHDZy45 roBBzyUmxBXN95itF3i+tHlVboYaEeJ3Yi3GgWIxXRvmbuqaqrvNU2lpi4HJwgRmGX8AfjZ5MEDtS GgL/xdKmQ==; Received: from geoff by merlin.infradead.org with local (Exim 4.90_1 #2 (Red Hat Linux)) id 1fnBuY-0004Tt-0s; Wed, 08 Aug 2018 00:01:10 +0000 Message-Id: <2107a14b9727454c3a515b3c8c1912c30abbf25e.1533686335.git.geoff@infradead.org> In-Reply-To: References: From: Geoff Levand Patch-Date: Tue, 7 Aug 2018 16:54:47 -0700 Subject: [PATCH v1 4/6] lib/talloc: Fix TALLOC_ABORT To: Samuel Mendoza-Jonas Date: Wed, 08 Aug 2018 00:01:10 +0000 X-BeenThere: petitboot@lists.ozlabs.org X-Mailman-Version: 2.1.27 Precedence: list List-Id: Petitboot bootloader development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Petitboot@lists.ozlabs.org MIME-Version: 1.0 Errors-To: petitboot-bounces+incoming=patchwork.ozlabs.org@lists.ozlabs.org Sender: "Petitboot" The current TALLOC_ABORT macro had a number of problems. Failures were not going to the pb log, but only to stderr. If the object passed in was not a talloc object the printing of an object name would be printing random data. The use of a macro obscured the code. To clean this up, remove all reference to TALLOC_ABORT and put the logging and abort calls directly into talloc_chunk_from_ptr. Signed-off-by: Geoff Levand --- lib/talloc/talloc.c | 21 +++++++-------------- 1 file changed, 7 insertions(+), 14 deletions(-) diff --git a/lib/talloc/talloc.c b/lib/talloc/talloc.c index d3e2065..6e2fb2f 100644 --- a/lib/talloc/talloc.c +++ b/lib/talloc/talloc.c @@ -40,13 +40,7 @@ #include #include #include - -#if !defined(NDEBUG) #include -#define TALLOC_ABORT(reason) do{ \ - fprintf(stderr, "%s: name: %s\n", __func__, tc->name); \ - assert(0 && reason);} while (0) -#endif #ifdef HAVE_SYS_TYPES_H #include @@ -66,6 +60,7 @@ #include #endif +#include "log/log.h" #include "talloc.h" /* use this to force every realloc to change the pointer, to stress test @@ -78,12 +73,6 @@ #define TALLOC_MAGIC_FREE 0x7faebef3 #define TALLOC_MAGIC_REFERENCE ((const char *)1) -/* by default we abort when given a bad pointer (such as when talloc_free() is - * called on a pointer that came from malloc() */ -#ifndef TALLOC_ABORT -#define TALLOC_ABORT(reason) abort() -#endif - #ifndef discard_const_p #if defined(__intptr_t_defined) || defined(HAVE_INTPTR_T) # define discard_const_p(type, ptr) ((type *)((intptr_t)(ptr))) @@ -126,9 +115,13 @@ static struct talloc_chunk *talloc_chunk_from_ptr(const void *ptr) struct talloc_chunk *tc = discard_const_p(struct talloc_chunk, ptr)-1; if (tc->u.magic != TALLOC_MAGIC) { if (tc->u.magic == TALLOC_MAGIC_FREE) { - TALLOC_ABORT("Bad talloc magic value - double free"); + pb_log_fn("Failed: Bad talloc magic value - double free, for name: %s\n", + tc->name); + fprintf(stderr, "%s: name: %s\n", __func__, tc->name); + assert(0 && "Bad talloc magic value - double free"); } else { - TALLOC_ABORT("Bad talloc magic value - unknown value"); + pb_log_fn("Failed: Bad talloc magic value - unknown value\n"); + assert(0 && "Bad talloc magic value - unknown value"); } } From patchwork Wed Aug 8 00:01:10 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Geoff Levand X-Patchwork-Id: 954750 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.ozlabs.org (lists.ozlabs.org [203.11.71.2]) (using TLSv1.2 with cipher ADH-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 41lWlh6rv2z9s3q for ; Wed, 8 Aug 2018 10:02:08 +1000 (AEST) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=infradead.org Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=infradead.org header.i=@infradead.org header.b="kFij+gQ7"; dkim-atps=neutral Received: from lists.ozlabs.org (lists.ozlabs.org [IPv6:2401:3900:2:1::3]) by lists.ozlabs.org (Postfix) with ESMTP id 41lWlh5PYlzDqp5 for ; Wed, 8 Aug 2018 10:02:08 +1000 (AEST) Authentication-Results: lists.ozlabs.org; dmarc=none (p=none dis=none) header.from=infradead.org Authentication-Results: lists.ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=infradead.org header.i=@infradead.org header.b="kFij+gQ7"; dkim-atps=neutral X-Original-To: Petitboot@lists.ozlabs.org Delivered-To: Petitboot@lists.ozlabs.org Authentication-Results: lists.ozlabs.org; spf=none (mailfrom) smtp.mailfrom=infradead.org (client-ip=2001:8b0:10b:1231::1; helo=merlin.infradead.org; envelope-from=geoff@infradead.org; receiver=) Authentication-Results: lists.ozlabs.org; dmarc=none (p=none dis=none) header.from=infradead.org Authentication-Results: lists.ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=infradead.org header.i=@infradead.org header.b="kFij+gQ7"; dkim-atps=neutral Received: from merlin.infradead.org (merlin.infradead.org [IPv6:2001:8b0:10b:1231::1]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by lists.ozlabs.org (Postfix) with ESMTPS id 41lWkj06gDzDqgZ for ; Wed, 8 Aug 2018 10:01:14 +1000 (AEST) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=merlin.20170209; h=Date:Cc:To:Subject:From:References: In-Reply-To:Message-Id:Sender:Reply-To:MIME-Version:Content-Type: Content-Transfer-Encoding:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Id: List-Help:List-Unsubscribe:List-Subscribe:List-Post:List-Owner:List-Archive; bh=Cw2ELv5qn1hBA1xzVVn0tYUZQG+UPeLZOupNK+z5MUk=; b=kFij+gQ7azxPbGoUr77v5fAl4 FUSgNKMF9H7WPARVz0hRnPRs2iLyCKLnvlEtbZQOj+Le/08QoQI+eSYQYUXtMv1oSswuchg3cFoik XajKi/vfJBvl+vuPVj6Sv+AO3XHI76gCb3jKQ4o+IQwdV9NKP1Qbt03ZuIiUOMcljIJnClfAbKMWD Tju7BEufpCnKinYXDQM5vcME9Tk6TbQapecN5YvugNvfpWlGtfVMo0+0iQbJJt8gAiNgIejRvIZ+O 0+V0/Y0q5ghzR4rw/7MTfCNJZflK7pdMtuAhH82EN8cm69XMJRC0hbiGBZBxaizlfyvaizqNUBCZM Y7gRRToyA==; Received: from geoff by merlin.infradead.org with local (Exim 4.90_1 #2 (Red Hat Linux)) id 1fnBuY-0004Tx-6F; Wed, 08 Aug 2018 00:01:10 +0000 Message-Id: In-Reply-To: References: From: Geoff Levand Patch-Date: Tue, 7 Aug 2018 16:54:47 -0700 Subject: [PATCH v1 5/6] discover/platforms: Fix param_list talloc failure To: Samuel Mendoza-Jonas Date: Wed, 08 Aug 2018 00:01:10 +0000 X-BeenThere: petitboot@lists.ozlabs.org X-Mailman-Version: 2.1.27 Precedence: list List-Id: Petitboot bootloader development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Petitboot@lists.ozlabs.org MIME-Version: 1.0 Errors-To: petitboot-bounces+incoming=patchwork.ozlabs.org@lists.ozlabs.org Sender: "Petitboot" Signed-off-by: Geoff Levand --- discover/platform-arm64.c | 9 +++++---- discover/platform-powerpc.c | 17 +++++++++-------- 2 files changed, 14 insertions(+), 12 deletions(-) diff --git a/discover/platform-arm64.c b/discover/platform-arm64.c index 9cd6641..a70298a 100644 --- a/discover/platform-arm64.c +++ b/discover/platform-arm64.c @@ -39,7 +39,7 @@ static const char *efi_vars_guid = "fb78ab4b-bd43-41a0-99a2-4e74bef9169b"; struct platform_arm64 { - struct param_list params; + struct param_list *params; struct ipmi *ipmi; }; @@ -103,7 +103,7 @@ static void get_active_consoles(struct config *config) static int load_config(struct platform *p, struct config *config) { - struct param_list *pl = &to_platform_arm64(p)->params; + struct param_list *pl = to_platform_arm64(p)->params; parse_nvram(pl); config_populate_all(config, pl); @@ -221,7 +221,7 @@ static void params_update_all(struct param_list *pl, static int save_config(struct platform *p, struct config *config) { - struct param_list *pl = &to_platform_arm64(p)->params; + struct param_list *pl = to_platform_arm64(p)->params; struct config *defaults; defaults = talloc_zero(NULL, struct config); @@ -259,7 +259,8 @@ static bool probe(struct platform *p, void *ctx) } platform = talloc_zero(ctx, struct platform_arm64); - param_list_init(&platform->params, common_known_params()); + platform->params = talloc_zero(platform, struct param_list); + param_list_init(platform->params, common_known_params()); p->platform_data = platform; diff --git a/discover/platform-powerpc.c b/discover/platform-powerpc.c index 84e18cc..2929077 100644 --- a/discover/platform-powerpc.c +++ b/discover/platform-powerpc.c @@ -25,7 +25,7 @@ static const char *sysparams_dir = "/sys/firmware/opal/sysparams/"; static const char *devtree_dir = "/proc/device-tree/"; struct platform_powerpc { - struct param_list params; + struct param_list *params; struct ipmi *ipmi; bool ipmi_bootdev_persistent; int (*get_ipmi_bootdev)( @@ -89,13 +89,13 @@ static int parse_nvram_params(struct platform_powerpc *platform, if (namelen == 0) continue; - if (!param_list_is_known_n(&platform->params, name, namelen)) + if (!param_list_is_known_n(platform->params, name, namelen)) continue; *value = '\0'; value++; - param_list_set(&platform->params, name, value, false); + param_list_set(platform->params, name, value, false); } return 0; @@ -145,7 +145,7 @@ static int write_nvram(struct platform_powerpc *platform) process->path = "nvram"; process->argv = argv; - param_list_for_each(&platform->params, param) { + param_list_for_each(platform->params, param) { char *paramstr; if (!param->modified) @@ -562,7 +562,7 @@ static void get_ipmi_network_override(struct platform_powerpc *platform, if (!rc && persistent) { /* Write this new config to NVRAM */ - params_update_network_values(&platform->params, + params_update_network_values(platform->params, "petitboot,network", config); rc = write_nvram(platform); if (rc) @@ -612,7 +612,7 @@ static int load_config(struct platform *p, struct config *config) if (rc) pb_log_fn("Failed to parse nvram\n"); - config_populate_all(config, &platform->params); + config_populate_all(config, platform->params); if (platform->get_ipmi_bootdev) { bool bootdev_persistent; @@ -649,7 +649,7 @@ static int save_config(struct platform *p, struct config *config) defaults = talloc_zero(platform, struct config); config_set_defaults(defaults); - params_update_all(&platform->params, config, defaults); + params_update_all(platform->params, config, defaults); talloc_free(defaults); return write_nvram(platform); @@ -713,7 +713,8 @@ static bool probe(struct platform *p, void *ctx) return false; platform = talloc_zero(ctx, struct platform_powerpc); - param_list_init(&platform->params, common_known_params()); + platform->params = talloc_zero(platform, struct param_list); + param_list_init(platform->params, common_known_params()); p->platform_data = platform; From patchwork Wed Aug 8 00:01:10 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Geoff Levand X-Patchwork-Id: 954745 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.ozlabs.org (lists.ozlabs.org [203.11.71.2]) (using TLSv1.2 with cipher ADH-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 41lWkv3Ly3z9s3q for ; Wed, 8 Aug 2018 10:01:27 +1000 (AEST) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=infradead.org Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=infradead.org header.i=@infradead.org header.b="nw6lPo2m"; dkim-atps=neutral Received: from lists.ozlabs.org (lists.ozlabs.org [IPv6:2401:3900:2:1::3]) by lists.ozlabs.org (Postfix) with ESMTP id 41lWkv0P2dzDqgw for ; Wed, 8 Aug 2018 10:01:27 +1000 (AEST) Authentication-Results: lists.ozlabs.org; dmarc=none (p=none dis=none) header.from=infradead.org Authentication-Results: lists.ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=infradead.org header.i=@infradead.org header.b="nw6lPo2m"; dkim-atps=neutral X-Original-To: Petitboot@lists.ozlabs.org Delivered-To: Petitboot@lists.ozlabs.org Authentication-Results: lists.ozlabs.org; spf=none (mailfrom) smtp.mailfrom=infradead.org (client-ip=2001:8b0:10b:1231::1; helo=merlin.infradead.org; envelope-from=geoff@infradead.org; receiver=) Authentication-Results: lists.ozlabs.org; dmarc=none (p=none dis=none) header.from=infradead.org Authentication-Results: lists.ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=infradead.org header.i=@infradead.org header.b="nw6lPo2m"; dkim-atps=neutral Received: from merlin.infradead.org (merlin.infradead.org [IPv6:2001:8b0:10b:1231::1]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by lists.ozlabs.org (Postfix) with ESMTPS id 41lWkj08ryzDqgw for ; Wed, 8 Aug 2018 10:01:13 +1000 (AEST) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=merlin.20170209; h=Date:Cc:To:Subject:From:References: In-Reply-To:Message-Id:Sender:Reply-To:MIME-Version:Content-Type: Content-Transfer-Encoding:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Id: List-Help:List-Unsubscribe:List-Subscribe:List-Post:List-Owner:List-Archive; bh=Sfwx09zvuOq+4bmX5wwAMbExLx9Y4rz8UA1+Frf+0jQ=; b=nw6lPo2mqeo1HH78O2WlA8eV3 yedHN1e0SiMNrfsnJUqSSnobfnzTp5JphOV+uc4lITz2B4rK7jOJ2+DRcEU6Bjga+1J7iJFmtlRL6 IejUJndafydjncLvCQ1z3muWyfSmTrI5VcN1SpV5SwEXJDoQzq/zEYWvPfXwz9mVL+DcikkWk9lbw EDgvbwi1v4hMa3qgMP04y13k1vm7bYcq6se60JUyDI6Wnpw08IGEmgCFf2+wsLI0h88Pvy0hsOwC8 +YapHY5TtuvujFSilVK/WGas03MgLX/qfFMhySCNBVoPv1TuiE/VNGextbYjQflpFyIuj/UmCTqPM qXd935U2Q==; Received: from geoff by merlin.infradead.org with local (Exim 4.90_1 #2 (Red Hat Linux)) id 1fnBuY-0004U1-BS; Wed, 08 Aug 2018 00:01:10 +0000 Message-Id: <6bac383be03d9d2219306f03b0d8421558ef732a.1533686335.git.geoff@infradead.org> In-Reply-To: References: From: Geoff Levand Patch-Date: Tue, 7 Aug 2018 16:54:47 -0700 Subject: [PATCH v1 6/6] lib/efi: Add check for ioctl_iflags support To: Samuel Mendoza-Jonas Date: Wed, 08 Aug 2018 00:01:10 +0000 X-BeenThere: petitboot@lists.ozlabs.org X-Mailman-Version: 2.1.27 Precedence: list List-Id: Petitboot bootloader development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Petitboot@lists.ozlabs.org MIME-Version: 1.0 Errors-To: petitboot-bounces+incoming=patchwork.ozlabs.org@lists.ozlabs.org Sender: "Petitboot" The efi tests may use a filesystem which does not support ioctl_iflags. Add a check and skip the ioctl_iflags operations if not supported. Signed-off-by: Geoff Levand --- lib/efi/efivar.c | 19 +++++++++++++++++-- 1 file changed, 17 insertions(+), 2 deletions(-) diff --git a/lib/efi/efivar.c b/lib/efi/efivar.c index 21c5d34..91b2507 100644 --- a/lib/efi/efivar.c +++ b/lib/efi/efivar.c @@ -83,17 +83,32 @@ int efi_del_variable(const char *guidstr, const char *name) return -1; rc = ioctl(fd, FS_IOC_GETFLAGS, &flag); - if (rc == -1) + if (rc == -1 && errno == ENOTTY) { + pb_debug_fn("'%s' does not support ioctl_iflags.\n", + efivarfs_path); + goto delete; + } else if (rc == -1) { + pb_log_fn("FS_IOC_GETFLAGS failed: (%d) %s\n", errno, + strerror(errno)); goto exit; + } flag &= ~FS_IMMUTABLE_FL; rc = ioctl(fd, FS_IOC_SETFLAGS, &flag); - if (rc == -1) + if (rc == -1) { + pb_log_fn("FS_IOC_SETFLAGS failed: (%d) %s\n", errno, + strerror(errno)); goto exit; + } +delete: close(fd); fd = 0; rc = unlink(path); + if (rc == -1) { + pb_log_fn("unlink failed: (%d) %s\n", errno, strerror(errno)); + goto exit; + } exit: talloc_free(path); close(fd);