002-const-stdio.patch (1229B)
1 --- a/lib/commands/toolcontext.c 2 +++ b/lib/commands/toolcontext.c 3 @@ -1843,7 +1843,7 @@ struct cmd_context *create_toolcontext(u 4 /* FIXME Make this configurable? */ 5 reset_lvm_errno(1); 6 7 -#ifndef VALGRIND_POOL 8 +#if defined(__GLIBC__) && !defined(VALGRIND_POOL) 9 /* Set in/out stream buffering before glibc */ 10 if (set_buffering) { 11 /* Allocate 2 buffers */ 12 @@ -2224,7 +2224,7 @@ void destroy_toolcontext(struct cmd_cont 13 if (cmd->libmem) 14 dm_pool_destroy(cmd->libmem); 15 16 -#ifndef VALGRIND_POOL 17 +#if defined(__GLIBC__) && !defined(VALGRIND_POOL) 18 if (cmd->linebuffer) { 19 /* Reset stream buffering to defaults */ 20 if (is_valid_fd(STDIN_FILENO) && 21 --- a/tools/lvmcmdline.c 22 +++ b/tools/lvmcmdline.c 23 @@ -1815,6 +1815,7 @@ int lvm_split(char *str, int *argc, char 24 /* Make sure we have always valid filedescriptors 0,1,2 */ 25 static int _check_standard_fds(void) 26 { 27 +#ifdef __GLIBC__ 28 int err = is_valid_fd(STDERR_FILENO); 29 30 if (!is_valid_fd(STDIN_FILENO) && 31 @@ -1841,6 +1842,12 @@ static int _check_standard_fds(void) 32 strerror(errno)); 33 return 0; 34 } 35 +#else 36 + if (!is_valid_fd(STDERR_FILENO) || 37 + !is_valid_fd(STDOUT_FILENO) || 38 + !is_valid_fd(STDIN_FILENO)) 39 + return 0; 40 +#endif 41 42 return 1; 43 }