1 # --- T2-COPYRIGHT-NOTE-BEGIN ---
2 # This copyright note is auto-generated by scripts/Create-CopyPatch.
4 # T2 SDE: package/*/lvm2/fix-stdio-usage.patch.musl
5 # Copyright (C) 2021 The T2 SDE Project
7 # More information can be found in the files COPYING and README.
9 # This patch file is dual-licensed. It is available under the license the
10 # patched project is licensed under, as long as it is an OpenSource license
11 # as defined at http://www.opensource.org/ (e.g. BSD, X11) or under the terms
12 # of the GNU General Public License as published by the Free Software
13 # Foundation; either version 2 of the License, or (at your option) any later
15 # --- T2-COPYRIGHT-NOTE-END ---
17 --- ./tools/lvmcmdline.c
18 +++ ./tools/lvmcmdline.c
20 int err = is_valid_fd(STDERR_FILENO);
22 if (!is_valid_fd(STDIN_FILENO) &&
23 - !(stdin = fopen(_PATH_DEVNULL, "r"))) {
24 + !freopen(_PATH_DEVNULL, "r", stdin)) {
26 perror("stdin stream open");
31 if (!is_valid_fd(STDOUT_FILENO) &&
32 - !(stdout = fopen(_PATH_DEVNULL, "w"))) {
33 + !freopen(_PATH_DEVNULL, "w", stdout)) {
35 perror("stdout stream open");
40 if (!is_valid_fd(STDERR_FILENO) &&
41 - !(stderr = fopen(_PATH_DEVNULL, "w"))) {
42 + !freopen(_PATH_DEVNULL, "w", stderr)) {
43 printf("stderr stream open: %s\n",
46 --- ./lib/commands/toolcontext.c.orig
47 +++ ./lib/commands/toolcontext.c
49 /* FIXME Make this configurable? */
52 -#ifndef VALGRIND_POOL
53 +#if !defined(VALGRIND_POOL) && defined(__GLIBC__)
54 /* Set in/out stream buffering before glibc */
56 /* Allocate 2 buffers */
58 dm_pool_destroy(cmd->libmem);
60 -#ifndef VALGRIND_POOL
61 +#if !defined(VALGRIND_POOL) && defined(__GLIBC__)
62 if (cmd->linebuffer) {
63 /* Reset stream buffering to defaults */