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 if((data = um_kmalloc(sizeof(*data))) == NULL) return(NULL);
39 *data = ((struct fd_chan) { .fd = n,
44 int fd_open(int input, int output, int primary, void *d, char **dev_out)
46 struct fd_chan *data = d;
48 if(data->raw && isatty(data->fd)){
49 tcgetattr(data->fd, &data->tt);
52 sprintf(data->str, "%d", data->fd);
57 void fd_close(int fd, void *d)
59 struct fd_chan *data = d;
61 if(data->raw && isatty(fd)){
62 tcsetattr(fd, TCSAFLUSH, &data->tt);
67 int fd_console_write(int fd, const char *buf, int n, void *d)
69 struct fd_chan *data = d;
71 return(generic_console_write(fd, buf, n, &data->tt));
74 struct chan_ops fd_ops = {
80 .write = generic_write,
81 .console_write = fd_console_write,
82 .window_size = generic_window_size,
88 * Overrides for Emacs so that we follow Linus's tabbing style.
89 * Emacs will notice this stuff at the end of the file and automatically
90 * adjust the settings for this buffer only. This must remain at the end
92 * ---------------------------------------------------------------------------
94 * c-file-style: "linux"