11 #include "libcommon.h"
13 static const char *conspath[] = {
26 * Get an fd for use with kbd/console ioctls.
27 * We try several things because opening /dev/console will fail
28 * if someone else used X (which does a chown on /dev/console).
37 return (isatty(fd) && ioctl(fd, KDGKBTYPE, &arg) == 0 && ((arg == KB_101) || (arg == KB_84)));
41 open_a_console(const char *fnam)
46 * For ioctl purposes we only need some fd and permissions
47 * do not matter. But setfont:activatemap() does a write.
49 fd = open(fnam, O_RDWR);
51 fd = open(fnam, O_WRONLY);
53 fd = open(fnam, O_RDONLY);
60 getfd(const char *fnam)
65 if ((fd = open_a_console(fnam)) >= 0) {
70 fprintf(stderr, _("Couldn't open %s\n"), fnam);
74 for (i = 0; conspath[i]; i++) {
75 if ((fd = open_a_console(conspath[i])) >= 0) {
82 for (fd = 0; fd < 3; fd++)
87 _("Couldn't get a file descriptor referring to the console\n"));