002-const-stdio.patch 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243
  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. -#ifndef VALGRIND_POOL
  7. +#if defined(__GLIBC__) && !defined(VALGRIND_POOL)
  8. /* Set in/out stream buffering before glibc */
  9. if (set_buffering) {
  10. /* Allocate 2 buffers */
  11. @@ -2224,7 +2224,7 @@ void destroy_toolcontext(struct cmd_cont
  12. if (cmd->libmem)
  13. dm_pool_destroy(cmd->libmem);
  14. -#ifndef VALGRIND_POOL
  15. +#if defined(__GLIBC__) && !defined(VALGRIND_POOL)
  16. if (cmd->linebuffer) {
  17. /* Reset stream buffering to defaults */
  18. if (is_valid_fd(STDIN_FILENO) &&
  19. --- a/tools/lvmcmdline.c
  20. +++ b/tools/lvmcmdline.c
  21. @@ -1815,6 +1815,7 @@ int lvm_split(char *str, int *argc, char
  22. /* Make sure we have always valid filedescriptors 0,1,2 */
  23. static int _check_standard_fds(void)
  24. {
  25. +#ifdef __GLIBC__
  26. int err = is_valid_fd(STDERR_FILENO);
  27. if (!is_valid_fd(STDIN_FILENO) &&
  28. @@ -1841,6 +1842,12 @@ static int _check_standard_fds(void)
  29. strerror(errno));
  30. return 0;
  31. }
  32. +#else
  33. + if (!is_valid_fd(STDERR_FILENO) ||
  34. + !is_valid_fd(STDOUT_FILENO) ||
  35. + !is_valid_fd(STDIN_FILENO))
  36. + return 0;
  37. +#endif
  38. return 1;
  39. }