From mboxrd@z Thu Jan 1 00:00:00 1970 From: Stas Sergeev Subject: Re: Weird message. Date: Sun, 20 Jul 2003 15:07:06 +0400 Sender: linux-msdos-owner@vger.kernel.org Message-ID: <3F1A77DA.5040309@aknet.ru> Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="------------020302060101020600010409" Return-path: List-Id: To: linux-msdos@vger.kernel.org This is a multi-part message in MIME format. --------------020302060101020600010409 Content-Type: text/plain; charset=us-ascii; format=flowed Content-Transfer-Encoding: 7bit Hello. hector Colina wrote: > Well, when starting dosemu, i get the message: "no > console". What is it? Try the updated getfd code (here is the patch) and maybe that will help? --------------020302060101020600010409 Content-Type: text/plain; name="dosemu_console.diff" Content-Transfer-Encoding: 7bit Content-Disposition: inline; filename="dosemu_console.diff" diff -urN dosemu-1.1.5.5/src/plugin/kbd_unicode/Makefile dosemu-1.1.5.5-kbd/src/plugin/kbd_unicode/Makefile --- dosemu-1.1.5.5/src/plugin/kbd_unicode/Makefile Sun Jul 20 14:25:40 2003 +++ dosemu-1.1.5.5-kbd/src/plugin/kbd_unicode/Makefile Sun Jul 20 14:31:19 2003 @@ -21,7 +21,7 @@ CFILES:=dosemu_keys.c keynum.c -CFILES := serv_xlat.c serv_backend.c serv_8042.c keymaps.c keyb_raw.c \ +CFILES := serv_xlat.c serv_backend.c serv_8042.c keymaps.c keyb_raw.c getfd.c \ keyb_clients.c prestroke.c $(X_CFILES) keyb_none.c keyboard.c \ $(CFILES) diff -urN dosemu-1.1.5.5/src/plugin/kbd_unicode/getfd.c dosemu-1.1.5.5-kbd/src/plugin/kbd_unicode/getfd.c --- dosemu-1.1.5.5/src/plugin/kbd_unicode/getfd.c Thu Jan 1 03:00:00 1970 +++ dosemu-1.1.5.5-kbd/src/plugin/kbd_unicode/getfd.c Sun Jul 20 14:38:13 2003 @@ -0,0 +1,67 @@ +#include +#include +#include +#include +#include +#include +#include +#include "getfd.h" + +/* + * getfd.c + * + * Get an fd for use with kbd/console ioctls. + * We try several things because opening /dev/console will fail + * if someone else used X (which does a chown on /dev/console). + */ + +static int +is_a_console(int fd) { + char arg; + + arg = 0; + return (ioctl(fd, KDGKBTYPE, &arg) == 0 + && ((arg == KB_101) || (arg == KB_84))); +} + +static int +open_a_console(char *fnam) { + int fd; + + fd = open(fnam, O_RDONLY); + if (fd < 0 && errno == EACCES) + fd = open(fnam, O_WRONLY); + if (fd < 0) + return -1; + if (!is_a_console(fd)) { + close(fd); + return -1; + } + return fd; +} + +int getfd() { + int fd; + + fd = open_a_console("/dev/tty"); + if (fd >= 0) + return fd; + + fd = open_a_console("/dev/tty0"); + if (fd >= 0) + return fd; + + fd = open_a_console("/dev/vc/0"); + if (fd >= 0) + return fd; + + fd = open_a_console("/dev/console"); + if (fd >= 0) + return fd; + + for (fd = 0; fd < 3; fd++) + if (is_a_console(fd)) + return fd; + + return -1; +} diff -urN dosemu-1.1.5.5/src/plugin/kbd_unicode/getfd.h dosemu-1.1.5.5-kbd/src/plugin/kbd_unicode/getfd.h --- dosemu-1.1.5.5/src/plugin/kbd_unicode/getfd.h Thu Jan 1 03:00:00 1970 +++ dosemu-1.1.5.5-kbd/src/plugin/kbd_unicode/getfd.h Fri Oct 11 15:09:01 2002 @@ -0,0 +1 @@ +extern int getfd(void); diff -urN dosemu-1.1.5.5/src/plugin/kbd_unicode/keymaps.c dosemu-1.1.5.5-kbd/src/plugin/kbd_unicode/keymaps.c --- dosemu-1.1.5.5/src/plugin/kbd_unicode/keymaps.c Sat Jun 7 12:10:12 2003 +++ dosemu-1.1.5.5-kbd/src/plugin/kbd_unicode/keymaps.c Sun Jul 20 14:28:59 2003 @@ -20,10 +20,8 @@ #include "keymaps.h" #include "keyb_clients.h" #include "keynum.h" +#include "getfd.h" -static int is_a_console(int); -static int open_a_console(char *); -static int getfd(void); static int read_kbd_table(struct keytable_entry *); @@ -2099,43 +2097,6 @@ {0} }; - -/* - * Look for a console. This is based on code in getfd.c from the kbd-0.99 package - * (see loadkeys(1)). - */ - -static int is_a_console(int fd) -{ - char arg = 0; - - return ioctl(fd, KDGKBTYPE, &arg) == 0 && (arg == KB_101 || arg == KB_84); -} - -static int open_a_console(char *fnam) -{ - int fd; - - fd = open(fnam, O_RDONLY); - if(fd < 0 && errno == EACCES) fd = open(fnam, O_WRONLY); - if(fd < 0 || ! is_a_console(fd)) return -1; - - return fd; -} - -static int getfd() -{ - int fd, i; - char *t[] = { "", "", "", "/dev/tty", "/dev/tty0", "/dev/console" }; - - for(i = 0; i < sizeof t / sizeof *t; i++) { - if(!*t[i] && is_a_console(i)) return i; - if(*t[i] && (fd = open_a_console(t[i])) >= 0) return fd; - } - - return -1; -} - #if 0 static char* pretty_keysym(t_keysym d) { --------------020302060101020600010409--