2 * Copyright (C) 2001 Jeff Dike (jdike@karaya.com)
3 * Licensed under the GPL
11 #include "user_util.h"
12 #include "chan_user.h"
18 char str[sizeof("1234567890\0")];
21 void *fd_init(char *str, int device, struct chan_opts *opts)
28 printk("fd_init : channel type 'fd' must specify a file "
33 n = strtoul(str, &end, 0);
34 if((*end != '\0') || (end == str)){
35 printk("fd_init : couldn't parse file descriptor '%s'\n", str);
38 data = um_kmalloc(sizeof(*data));
39 if(data == NULL) return(NULL);
40 *data = ((struct fd_chan) { .fd = n,
45 int fd_open(int input, int output, int primary, void *d, char **dev_out)
47 struct fd_chan *data = d;
49 if(data->raw && isatty(data->fd)){
50 tcgetattr(data->fd, &data->tt);
53 sprintf(data->str, "%d", data->fd);
58 void fd_close(int fd, void *d)
60 struct fd_chan *data = d;
62 if(data->raw && isatty(fd)){
63 tcsetattr(fd, TCSAFLUSH, &data->tt);
68 int fd_console_write(int fd, const char *buf, int n, void *d)
70 struct fd_chan *data = d;
72 return(generic_console_write(fd, buf, n, &data->tt));
75 struct chan_ops fd_ops = {
81 .write = generic_write,
82 .console_write = fd_console_write,
83 .window_size = generic_window_size,
89 * Overrides for Emacs so that we follow Linus's tabbing style.
90 * Emacs will notice this stuff at the end of the file and automatically
91 * adjust the settings for this buffer only. This must remain at the end
93 * ---------------------------------------------------------------------------
95 * c-file-style: "linux"