summaryrefslogtreecommitdiff
path: root/system/lvm2/fix-stdio-usage.patch
diff options
context:
space:
mode:
Diffstat (limited to 'system/lvm2/fix-stdio-usage.patch')
-rw-r--r--system/lvm2/fix-stdio-usage.patch55
1 files changed, 30 insertions, 25 deletions
diff --git a/system/lvm2/fix-stdio-usage.patch b/system/lvm2/fix-stdio-usage.patch
index 39ba2e1b4..2b3f0a91f 100644
--- a/system/lvm2/fix-stdio-usage.patch
+++ b/system/lvm2/fix-stdio-usage.patch
@@ -1,6 +1,28 @@
---- ./tools/lvmcmdline.c
-+++ ./tools/lvmcmdline.c
-@@ -1252,7 +1252,7 @@
+From 4cf08811e112100a2b10c60047f3c537ad21d674 Mon Sep 17 00:00:00 2001
+From: David Seifert <soap@gentoo.org>
+Date: Sat, 28 Jan 2023 14:22:42 +0100
+Subject: [PATCH] Use `freopen()` on {stdin,stdout,stderr}
+
+* ISO C does not guarantee that the standard streams are modifiable
+ lvalues. Glibc even calls out this behaviour as non-portable:
+ https://www.gnu.org/software/libc/manual/html_node/Standard-Streams.html
+--- a/lib/log/log.c
++++ b/lib/log/log.c
+@@ -208,7 +208,11 @@ int reopen_standard_stream(FILE **stream, const char *mode)
+
+ _check_and_replace_standard_log_streams(old_stream, new_stream);
+
++#ifdef __GLIBC__
+ *stream = new_stream;
++#else
++ freopen(NULL, mode, *stream);
++#endif
+ return 1;
+ }
+
+--- a/tools/lvmcmdline.c
++++ b/tools/lvmcmdline.c
+@@ -3422,7 +3422,7 @@ static int _check_standard_fds(void)
int err = is_valid_fd(STDERR_FILENO);
if (!is_valid_fd(STDIN_FILENO) &&
@@ -9,7 +31,7 @@
if (err)
perror("stdin stream open");
else
-@@ -1262,7 +1262,7 @@
+@@ -3432,7 +3432,7 @@ static int _check_standard_fds(void)
}
if (!is_valid_fd(STDOUT_FILENO) &&
@@ -18,7 +40,7 @@
if (err)
perror("stdout stream open");
/* else no stdout */
-@@ -1270,7 +1270,7 @@
+@@ -3440,7 +3440,7 @@ static int _check_standard_fds(void)
}
if (!is_valid_fd(STDERR_FILENO) &&
@@ -27,23 +49,6 @@
printf("stderr stream open: %s\n",
strerror(errno));
return 0;
---- ./lib/commands/toolcontext.c.orig
-+++ ./lib/commands/toolcontext.c
-@@ -1860,7 +1860,7 @@
- /* FIXME Make this configurable? */
- reset_lvm_errno(1);
-
--#ifndef VALGRIND_POOL
-+#if !defined(VALGRIND_POOL) && defined(__GLIBC__)
- /* Set in/out stream buffering before glibc */
- if (set_buffering) {
- /* Allocate 2 buffers */
-@@ -2241,7 +2241,7 @@
- if (cmd->libmem)
- dm_pool_destroy(cmd->libmem);
-
--#ifndef VALGRIND_POOL
-+#if !defined(VALGRIND_POOL) && defined(__GLIBC__)
- if (cmd->linebuffer) {
- /* Reset stream buffering to defaults */
- if (is_valid_fd(STDIN_FILENO) &&
+--
+2.39.2
+