Changeset 1770 in MondoRescue for branches/stable/mindi-busybox/libbb/get_console.c
- Timestamp:
- Nov 6, 2007, 11:01:53 AM (16 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/stable/mindi-busybox/libbb/get_console.c
r821 r1770 9 9 */ 10 10 11 #include <stdio.h> 12 #include <errno.h> 13 #include <fcntl.h> 14 #include <unistd.h> 15 #include <sys/ioctl.h> 11 //#include <sys/ioctl.h> 16 12 #include "libbb.h" 17 18 13 19 14 … … 48 43 int get_console_fd(void) 49 44 { 45 static const char *const console_names[] = { 46 DEV_CONSOLE, CURRENT_VC, CURRENT_TTY 47 }; 48 50 49 int fd; 51 52 static const char * const choise_console_names[] = {53 CONSOLE_DEV, CURRENT_VC, CURRENT_TTY54 };55 50 56 51 for (fd = 2; fd >= 0; fd--) { 57 52 int fd4name; 58 int choi se_fd;53 int choice_fd; 59 54 char arg; 60 55 61 fd4name = open_a_console(c hoise_console_names[fd]);62 63 choi se_fd = fd4name >= 0 ? fd4name : fd;56 fd4name = open_a_console(console_names[fd]); 57 chk_std: 58 choice_fd = (fd4name >= 0 ? fd4name : fd); 64 59 65 60 arg = 0; 66 if (ioctl(choi se_fd, KDGKBTYPE, &arg) == 0)67 return choi se_fd;68 if (fd4name >= 0) {61 if (ioctl(choice_fd, KDGKBTYPE, &arg) == 0) 62 return choice_fd; 63 if (fd4name >= 0) { 69 64 close(fd4name); 70 65 fd4name = -1; … … 73 68 } 74 69 75 bb_error_msg(" Couldn't get a file descriptor referring to theconsole");70 bb_error_msg("cannot get file descriptor referring to console"); 76 71 return fd; /* total failure */ 77 72 }
Note:
See TracChangeset
for help on using the changeset viewer.