# --- T2-COPYRIGHT-NOTE-BEGIN --- # This copyright note is auto-generated by scripts/Create-CopyPatch. # # T2 SDE: package/*/lvm2/fix-stdio-usage.patch.musl # Copyright (C) 2021 The T2 SDE Project # # More information can be found in the files COPYING and README. # # This patch file is dual-licensed. It is available under the license the # patched project is licensed under, as long as it is an OpenSource license # as defined at http://www.opensource.org/ (e.g. BSD, X11) or under the terms # of the GNU General Public License as published by the Free Software # Foundation; either version 2 of the License, or (at your option) any later # version. # --- T2-COPYRIGHT-NOTE-END --- --- ./tools/lvmcmdline.c +++ ./tools/lvmcmdline.c @@ -1252,7 +1252,7 @@ int err = is_valid_fd(STDERR_FILENO); if (!is_valid_fd(STDIN_FILENO) && - !(stdin = fopen(_PATH_DEVNULL, "r"))) { + !freopen(_PATH_DEVNULL, "r", stdin)) { if (err) perror("stdin stream open"); else @@ -1262,7 +1262,7 @@ } if (!is_valid_fd(STDOUT_FILENO) && - !(stdout = fopen(_PATH_DEVNULL, "w"))) { + !freopen(_PATH_DEVNULL, "w", stdout)) { if (err) perror("stdout stream open"); /* else no stdout */ @@ -1270,7 +1270,7 @@ } if (!is_valid_fd(STDERR_FILENO) && - !(stderr = fopen(_PATH_DEVNULL, "w"))) { + !freopen(_PATH_DEVNULL, "w", stderr)) { 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,5 +2241,5 @@ dm_pool_destroy(cmd->libmem); -#ifndef VALGRIND_POOL +#if !defined(VALGRIND_POOL) && defined(__GLIBC__) if (cmd->linebuffer) { /* Reset stream buffering to defaults */