2 * Copyright (C) 2001 Jeff Dike (jdike@karaya.com)
3 * Licensed under the GPL
10 #include "chan_user.h"
11 #include "user_util.h"
21 static void *tty_chan_init(char *str
, int device
, struct chan_opts
*opts
)
23 struct tty_chan
*data
;
26 printk("tty_init : channel type 'tty' must specify "
32 data
= um_kmalloc(sizeof(*data
));
35 *data
= ((struct tty_chan
) { .dev
= str
,
41 static int tty_open(int input
, int output
, int primary
, void *d
,
44 struct tty_chan
*data
= d
;
47 fd
= os_open_file(data
->dev
, of_set_rw(OPENFLAGS(), input
, output
), 0);
48 if(fd
< 0) return(fd
);
50 CATCH_EINTR(err
= tcgetattr(fd
, &data
->tt
));
63 static int tty_console_write(int fd
, const char *buf
, int n
, void *d
)
65 struct tty_chan
*data
= d
;
67 return(generic_console_write(fd
, buf
, n
, &data
->tt
));
70 struct chan_ops tty_ops
= {
72 .init
= tty_chan_init
,
74 .close
= generic_close
,
76 .write
= generic_write
,
77 .console_write
= tty_console_write
,
78 .window_size
= generic_window_size
,
84 * Overrides for Emacs so that we follow Linus's tabbing style.
85 * Emacs will notice this stuff at the end of the file and automatically
86 * adjust the settings for this buffer only. This must remain at the end
88 * ---------------------------------------------------------------------------
90 * c-file-style: "linux"