Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/sys/rump/librump/rumpkern Fool isatty() into thinking we're ...



details:   https://anonhg.NetBSD.org/src/rev/e6386c501f77
branches:  trunk
changeset: 789801:e6386c501f77
user:      pooka <pooka%NetBSD.org@localhost>
date:      Sun Sep 08 04:37:17 2013 +0000

description:
Fool isatty() into thinking we're a tty.

diffstat:

 sys/rump/librump/rumpkern/cons.c |  24 +++++++++++++++++++-----
 1 files changed, 19 insertions(+), 5 deletions(-)

diffs (72 lines):

diff -r fda3bc5364f0 -r e6386c501f77 sys/rump/librump/rumpkern/cons.c
--- a/sys/rump/librump/rumpkern/cons.c  Sun Sep 08 04:10:23 2013 +0000
+++ b/sys/rump/librump/rumpkern/cons.c  Sun Sep 08 04:37:17 2013 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: cons.c,v 1.2 2013/09/07 18:17:35 pooka Exp $   */
+/*     $NetBSD: cons.c,v 1.3 2013/09/08 04:37:17 pooka Exp $   */
 
 /*
  * Copyright (c) 2013 Antti Kantee.  All Rights Reserved.
@@ -31,19 +31,22 @@
  * environments where there is no Unix-like host (e.g. Xen DomU).
  * It's currently a truly half duplex console since there is support
  * only for writing to the console (there is no hypercall for reading
- * the host console).
+ * the host console).  The driver attempts to look like a tty just
+ * enough to fool isatty().  Let's see how far that gets us.
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: cons.c,v 1.2 2013/09/07 18:17:35 pooka Exp $");
+__KERNEL_RCSID(0, "$NetBSD: cons.c,v 1.3 2013/09/08 04:37:17 pooka Exp $");
 
 #include <sys/param.h>
 #include <sys/file.h>
 #include <sys/filedesc.h>
+#include <sys/ioctl.h>
 #include <sys/kernel.h>
 #include <sys/kmem.h>
 #include <sys/proc.h>
 #include <sys/stat.h>
+#include <sys/termios.h>
 
 #include <rump/rumpuser.h>
 
@@ -51,12 +54,13 @@
 
 static int rumpcons_write(struct file *, off_t *, struct uio *,
                          kauth_cred_t, int);
+static int rumpcons_ioctl(struct file *, u_long, void *);
 static int rumpcons_stat(struct file *, struct stat *);
 
 static const struct fileops rumpcons_fileops = {
        .fo_read = (void *)nullop,
        .fo_write = rumpcons_write,
-       .fo_ioctl = fbadop_ioctl,
+       .fo_ioctl = rumpcons_ioctl,
        .fo_fcntl = fnullop_fcntl,
        .fo_poll = fnullop_poll,
        .fo_stat = rumpcons_stat,
@@ -121,11 +125,21 @@
 }
 
 static int
+rumpcons_ioctl(struct file *fp, u_long cmd, void *data)
+{
+
+       if (cmd == TIOCGETA)
+               return 0;
+
+       return ENOTTY; /* considering how we are cheating, lol */
+}
+
+static int
 rumpcons_stat(struct file *fp, struct stat *sb)
 {
 
        memset(sb, 0, sizeof(*sb));
-       sb->st_mode = 0600;
+       sb->st_mode = 0600 | _S_IFCHR;
        sb->st_atimespec = sb->st_mtimespec = sb->st_ctimespec = boottime;
        sb->st_birthtimespec = boottime;
 



Home | Main Index | Thread Index | Old Index