lvm2: fix musl patches; apply unconditionally

Alpine's version of the first patch no longer applied, because we're
on a newer lvm2 version.

The fixes in both of these patches are either Musl-specific, or
shouldn't negatively affect Glibc, so change to applying them
unconditionally so they don't bitrot in future.

+56 -7
+3 -7
pkgs/os-specific/linux/lvm2/default.nix
··· 67 sed -i 's|^#define LVM_CONFIGURE_LINE.*$|#define LVM_CONFIGURE_LINE "<removed>"|g' ./include/configure.h 68 ''; 69 70 - 71 - patches = lib.optionals stdenv.hostPlatform.isMusl [ 72 - (fetchpatch { 73 - name = "fix-stdio-usage.patch"; 74 - url = "https://git.alpinelinux.org/aports/plain/main/lvm2/fix-stdio-usage.patch?h=3.7-stable&id=31bd4a8c2dc00ae79a821f6fe0ad2f23e1534f50"; 75 - sha256 = "0m6wr6qrvxqi2d2h054cnv974jq1v65lqxy05g1znz946ga73k3p"; 76 - }) 77 (fetchpatch { 78 name = "mallinfo.patch"; 79 url = "https://git.alpinelinux.org/aports/plain/main/lvm2/mallinfo.patch?h=3.7-stable&id=31bd4a8c2dc00ae79a821f6fe0ad2f23e1534f50";
··· 67 sed -i 's|^#define LVM_CONFIGURE_LINE.*$|#define LVM_CONFIGURE_LINE "<removed>"|g' ./include/configure.h 68 ''; 69 70 + patches = [ 71 + # Musl fixes from Alpine. 72 + ./fix-stdio-usage.patch 73 (fetchpatch { 74 name = "mallinfo.patch"; 75 url = "https://git.alpinelinux.org/aports/plain/main/lvm2/mallinfo.patch?h=3.7-stable&id=31bd4a8c2dc00ae79a821f6fe0ad2f23e1534f50";
+53
pkgs/os-specific/linux/lvm2/fix-stdio-usage.patch
···
··· 1 + diff --git a/lib/commands/toolcontext.c b/lib/commands/toolcontext.c 2 + index 296618686..96343eeb7 100644 3 + --- a/lib/commands/toolcontext.c 4 + +++ b/lib/commands/toolcontext.c 5 + @@ -1619,7 +1619,7 @@ struct cmd_context *create_toolcontext(unsigned is_clvmd, 6 + /* FIXME Make this configurable? */ 7 + reset_lvm_errno(1); 8 + 9 + -#ifndef VALGRIND_POOL 10 + +#if !defined(VALGRIND_POOL) && defined(__GLIBC__) 11 + /* Set in/out stream buffering before glibc */ 12 + if (set_buffering 13 + #ifdef SYS_gettid 14 + @@ -2006,7 +2006,7 @@ void destroy_toolcontext(struct cmd_context *cmd) 15 + 16 + if (cmd->pending_delete_mem) 17 + dm_pool_destroy(cmd->pending_delete_mem); 18 + -#ifndef VALGRIND_POOL 19 + +#if !defined(VALGRIND_POOL) && defined(__GLIBC__) 20 + if (cmd->linebuffer) { 21 + /* Reset stream buffering to defaults */ 22 + if (is_valid_fd(STDIN_FILENO) && 23 + diff --git a/tools/lvmcmdline.c b/tools/lvmcmdline.c 24 + index d97ff5720..bbbda82bd 100644 25 + --- a/tools/lvmcmdline.c 26 + +++ b/tools/lvmcmdline.c 27 + @@ -3342,7 +3342,7 @@ static int _check_standard_fds(void) 28 + int err = is_valid_fd(STDERR_FILENO); 29 + 30 + if (!is_valid_fd(STDIN_FILENO) && 31 + - !(stdin = fopen(_PATH_DEVNULL, "r"))) { 32 + + !freopen(_PATH_DEVNULL, "r", stdin)) { 33 + if (err) 34 + perror("stdin stream open"); 35 + else 36 + @@ -3352,7 +3352,7 @@ static int _check_standard_fds(void) 37 + } 38 + 39 + if (!is_valid_fd(STDOUT_FILENO) && 40 + - !(stdout = fopen(_PATH_DEVNULL, "w"))) { 41 + + !freopen(_PATH_DEVNULL, "w", stdout)) { 42 + if (err) 43 + perror("stdout stream open"); 44 + /* else no stdout */ 45 + @@ -3360,7 +3360,7 @@ static int _check_standard_fds(void) 46 + } 47 + 48 + if (!is_valid_fd(STDERR_FILENO) && 49 + - !(stderr = fopen(_PATH_DEVNULL, "w"))) { 50 + + !freopen(_PATH_DEVNULL, "w", stderr)) { 51 + printf("stderr stream open: %s\n", 52 + strerror(errno)); 53 + return 0;