public inbox for linux-msdos@vger.kernel.org
 help / color / mirror / Atom feed
From: Stas Sergeev <stsp@aknet.ru>
To: linux-msdos@vger.kernel.org
Subject: Re: Weird message.
Date: Sun, 20 Jul 2003 15:07:06 +0400	[thread overview]
Message-ID: <3F1A77DA.5040309@aknet.ru> (raw)

[-- Attachment #1: Type: text/plain, Size: 179 bytes --]

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?

[-- Attachment #2: dosemu_console.diff --]
[-- Type: text/plain, Size: 3785 bytes --]

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 <stdio.h>
+#include <stdlib.h>
+#include <unistd.h>
+#include <fcntl.h>
+#include <errno.h>
+#include <linux/kd.h>
+#include <sys/ioctl.h>
+#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)
 {

             reply	other threads:[~2003-07-20 11:07 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2003-07-20 11:07 Stas Sergeev [this message]
  -- strict thread matches above, loose matches on Subject: below --
2003-07-19 20:05 Weird message hector Colina

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=3F1A77DA.5040309@aknet.ru \
    --to=stsp@aknet.ru \
    --cc=linux-msdos@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox