From mboxrd@z Thu Jan  1 00:00:00 1970
Return-Path: <gentoo-commits+bounces-963537-garchives=archives.gentoo.org@lists.gentoo.org>
Received: from lists.gentoo.org (pigeon.gentoo.org [208.92.234.80])
	(using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits))
	(No client certificate requested)
	by finch.gentoo.org (Postfix) with ESMTPS id 1744E139694
	for <garchives@archives.gentoo.org>; Tue, 25 Jul 2017 19:10:16 +0000 (UTC)
Received: from pigeon.gentoo.org (localhost [127.0.0.1])
	by pigeon.gentoo.org (Postfix) with SMTP id 79036E0E47;
	Tue, 25 Jul 2017 19:10:15 +0000 (UTC)
Received: from smtp.gentoo.org (smtp.gentoo.org [IPv6:2001:470:ea4a:1:5054:ff:fec7:86e4])
	(using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits))
	(No client certificate requested)
	by pigeon.gentoo.org (Postfix) with ESMTPS id 49D15E0E47
	for <gentoo-commits@lists.gentoo.org>; Tue, 25 Jul 2017 19:10:15 +0000 (UTC)
Received: from oystercatcher.gentoo.org (unknown [IPv6:2a01:4f8:202:4333:225:90ff:fed9:fc84])
	(using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits))
	(No client certificate requested)
	by smtp.gentoo.org (Postfix) with ESMTPS id 434E33416D0
	for <gentoo-commits@lists.gentoo.org>; Tue, 25 Jul 2017 19:10:14 +0000 (UTC)
Received: from localhost.localdomain (localhost [IPv6:::1])
	by oystercatcher.gentoo.org (Postfix) with ESMTP id B65D1291E
	for <gentoo-commits@lists.gentoo.org>; Tue, 25 Jul 2017 19:10:12 +0000 (UTC)
From: "Lars Wendler" <polynomial-c@gentoo.org>
To: gentoo-commits@lists.gentoo.org
Content-Transfer-Encoding: 8bit
Content-type: text/plain; charset=UTF-8
Reply-To: gentoo-dev@lists.gentoo.org, "Lars Wendler" <polynomial-c@gentoo.org>
Message-ID: <1501009808.733d38aedc6fd00fffba83e5fd07c4e3e6588b64.polynomial-c@gentoo>
Subject: [gentoo-commits] repo/gentoo:master commit in: sys-fs/xfsprogs/files/, sys-fs/xfsprogs/
X-VCS-Repository: repo/gentoo
X-VCS-Files: sys-fs/xfsprogs/files/xfsprogs-4.12.0-fix_musl.patch sys-fs/xfsprogs/xfsprogs-4.12.0.ebuild
X-VCS-Directories: sys-fs/xfsprogs/ sys-fs/xfsprogs/files/
X-VCS-Committer: polynomial-c
X-VCS-Committer-Name: Lars Wendler
X-VCS-Revision: 733d38aedc6fd00fffba83e5fd07c4e3e6588b64
X-VCS-Branch: master
Date: Tue, 25 Jul 2017 19:10:12 +0000 (UTC)
Precedence: bulk
List-Post: <mailto:gentoo-commits@lists.gentoo.org>
List-Help: <mailto:gentoo-commits+help@lists.gentoo.org>
List-Unsubscribe: <mailto:gentoo-commits+unsubscribe@lists.gentoo.org>
List-Subscribe: <mailto:gentoo-commits+subscribe@lists.gentoo.org>
List-Id: Gentoo Linux mail <gentoo-commits.gentoo.org>
X-BeenThere: gentoo-commits@lists.gentoo.org
X-Archives-Salt: 003f5be7-78b0-484c-8252-e81576cc1b5d
X-Archives-Hash: 194682183952789bdf2f8420f7bb7969

commit:     733d38aedc6fd00fffba83e5fd07c4e3e6588b64
Author:     Lars Wendler <polynomial-c <AT> gentoo <DOT> org>
AuthorDate: Tue Jul 25 19:09:51 2017 +0000
Commit:     Lars Wendler <polynomial-c <AT> gentoo <DOT> org>
CommitDate: Tue Jul 25 19:10:08 2017 +0000
URL:        https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=733d38ae

sys-fs/xfsprogs: Added musl fix.

Package-Manager: Portage-2.3.6, Repoman-2.3.3

 .../xfsprogs/files/xfsprogs-4.12.0-fix_musl.patch  | 117 +++++++++++++++++++++
 sys-fs/xfsprogs/xfsprogs-4.12.0.ebuild             |   1 +
 2 files changed, 118 insertions(+)

diff --git a/sys-fs/xfsprogs/files/xfsprogs-4.12.0-fix_musl.patch b/sys-fs/xfsprogs/files/xfsprogs-4.12.0-fix_musl.patch
new file mode 100644
index 00000000000..efc57e4f693
--- /dev/null
+++ b/sys-fs/xfsprogs/files/xfsprogs-4.12.0-fix_musl.patch
@@ -0,0 +1,117 @@
+From 21253610f9ef87db8e2a75b863b7fcfbd0cdb421 Mon Sep 17 00:00:00 2001
+From: "Darrick J. Wong" <darrick.wong@oracle.com>
+Date: Tue, 25 Jul 2017 13:45:01 -0500
+Subject: [PATCH] In patch 4944defad4 ("xfs_db: redirect printfs when
+ metadumping to stdout"), we solved the problem of xfs_db printfs ending up in
+ the metadump stream by reassigning stdout for the duration of a stdout
+ metadump.  Unfortunately, musl doesn't allow stdout to be reassigned (in
+ their view "extern FILE *stdout" means "extern FILE * const stdout"), so we
+ abandon the old approach in favor of playing games with dup() to switch the
+ raw file descriptors.
+
+While we're at it, fix a regression where an unconverted outf test
+allows progress info to end up in the metadump stream.
+
+Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
+---
+ db/metadump.c | 47 ++++++++++++++++++++++++++++++++++++-----------
+ 1 file changed, 36 insertions(+), 11 deletions(-)
+
+diff --git a/db/metadump.c b/db/metadump.c
+index 96641e0..4e2f648 100644
+--- a/db/metadump.c
++++ b/db/metadump.c
+@@ -78,6 +78,7 @@ static int		obfuscate = 1;
+ static int		zero_stale_data = 1;
+ static int		show_warnings = 0;
+ static int		progress_since_warning = 0;
++static bool		stdout_metadump;
+ 
+ void
+ metadump_init(void)
+@@ -137,7 +138,7 @@ print_progress(const char *fmt, ...)
+ 	va_end(ap);
+ 	buf[sizeof(buf)-1] = '\0';
+ 
+-	f = (outf == stdout) ? stderr : stdout;
++	f = stdout_metadump ? stderr : stdout;
+ 	fprintf(f, "\r%-59s", buf);
+ 	fflush(f);
+ 	progress_since_warning = 1;
+@@ -2750,7 +2751,8 @@ metadump_f(
+ 	xfs_agnumber_t	agno;
+ 	int		c;
+ 	int		start_iocur_sp;
+-	bool		stdout_metadump = false;
++	int		outfd = -1;
++	int		ret;
+ 	char		*p;
+ 
+ 	exitcode = 1;
+@@ -2870,16 +2872,35 @@ metadump_f(
+ 		 * metadump operation so that dbprintf and other messages
+ 		 * are sent to the console instead of polluting the
+ 		 * metadump stream.
++		 *
++		 * We get to do this the hard way because musl doesn't
++		 * allow reassignment of stdout.
+ 		 */
+-		outf = stdout;
+-		stdout = stderr;
++		fflush(stdout);
++		outfd = dup(STDOUT_FILENO);
++		if (outfd < 0) {
++			perror("opening dump stream");
++			goto out;
++		}
++		ret = dup2(STDERR_FILENO, STDOUT_FILENO);
++		if (ret < 0) {
++			perror("redirecting stdout");
++			close(outfd);
++			goto out;
++		}
++		outf = fdopen(outfd, "a");
++		if (outf == NULL) {
++			fprintf(stderr, "cannot create dump stream\n");
++			dup2(outfd, 1);
++			close(outfd);
++			goto out;
++		}
+ 		stdout_metadump = true;
+ 	} else {
+ 		outf = fopen(argv[optind], "wb");
+ 		if (outf == NULL) {
+ 			print_warning("cannot create dump file");
+-			free(metablock);
+-			return 0;
++			goto out;
+ 		}
+ 	}
+ 
+@@ -2907,15 +2928,19 @@ metadump_f(
+ 	if (progress_since_warning)
+ 		fputc('\n', stdout_metadump ? stderr : stdout);
+ 
+-	if (stdout_metadump)
+-		stdout = outf;
+-	else
+-		fclose(outf);
++	if (stdout_metadump) {
++		fflush(outf);
++		fflush(stdout);
++		ret = dup2(outfd, STDOUT_FILENO);
++		if (ret < 0)
++			perror("un-redirecting stdout");
++	}
++	fclose(outf);
+ 
+ 	/* cleanup iocur stack */
+ 	while (iocur_sp > start_iocur_sp)
+ 		pop_cur();
+-
++out:
+ 	free(metablock);
+ 
+ 	return 0;
+-- 
+2.13.3

diff --git a/sys-fs/xfsprogs/xfsprogs-4.12.0.ebuild b/sys-fs/xfsprogs/xfsprogs-4.12.0.ebuild
index 0cfd1dd972a..4736e0b82b6 100644
--- a/sys-fs/xfsprogs/xfsprogs-4.12.0.ebuild
+++ b/sys-fs/xfsprogs/xfsprogs-4.12.0.ebuild
@@ -31,6 +31,7 @@ PATCHES=(
 	"${FILESDIR}"/${PN}-4.12.0-sharedlibs.patch
 	"${FILESDIR}"/${PN}-4.7.0-libxcmd-link.patch
 	"${FILESDIR}"/${PN}-4.9.0-underlinking.patch
+	"${FILESDIR}"/${PN}-4.12.0-fix_musl.patch
 )
 
 pkg_setup() {