setlogcons.c 761 B

12345678910111213141516171819202122232425262728293031323334
  1. /*
  2. * setlogcons: Send kernel messages to the current console or to console N
  3. *
  4. * Copyright (C) 2006 by Jan Kiszka <jan.kiszka@web.de>
  5. *
  6. * Based on setlogcons (kbd-1.12) by Andries E. Brouwer
  7. *
  8. * Licensed under GPLv2 or later, see file LICENSE in this tarball for details.
  9. */
  10. #include <stdio.h>
  11. #include <stdlib.h>
  12. #include <fcntl.h>
  13. #include <sys/ioctl.h>
  14. #include "busybox.h"
  15. extern int setlogcons_main(int argc, char **argv)
  16. {
  17. struct {
  18. char fn;
  19. char subarg;
  20. } arg;
  21. arg.fn = 11; /* redirect kernel messages */
  22. arg.subarg = 0; /* to specified console (current as default) */
  23. if (argc == 2)
  24. arg.subarg = atoi(argv[1]);
  25. if (ioctl(bb_xopen("/dev/tty1", O_RDONLY), TIOCLINUX, &arg))
  26. bb_perror_msg_and_die("TIOCLINUX");;
  27. return 0;
  28. }