11 static char *conspath[] = {
24 * Get an fd for use with kbd/console ioctls.
25 * We try several things because opening /dev/console will fail
26 * if someone else used X (which does a chown on /dev/console).
30 is_a_console(int fd) {
35 && ioctl(fd, KDGKBTYPE, &arg) == 0
36 && ((arg == KB_101) || (arg == KB_84)));
40 open_a_console(const char *fnam) {
44 * For ioctl purposes we only need some fd and permissions
45 * do not matter. But setfont:activatemap() does a write.
47 fd = open(fnam, O_RDWR);
49 fd = open(fnam, O_WRONLY);
51 fd = open(fnam, O_RDONLY);
58 getfd(const char *fnam) {
62 if ((fd = open_a_console(fnam)) >= 0) {
67 fprintf(stderr, _("Couldn't open %s\n"), fnam);
71 for (i = 0; conspath[i]; i++) {
72 if ((fd = open_a_console(conspath[i])) >= 0) {
79 for (fd = 0; fd < 3; fd++)
84 _("Couldn't get a file descriptor referring to the console\n"));