]>
Commit | Line | Data |
---|---|---|
cb8fa61c | 1 | /* |
e99525f9 | 2 | * Copyright (C) 2002 - 2007 Jeff Dike (jdike@{linux.intel,addtoit}.com) |
1da177e4 LT |
3 | * Licensed under the GPL |
4 | */ | |
5 | ||
e99525f9 | 6 | #include <stddef.h> |
1da177e4 | 7 | #include <errno.h> |
e99525f9 | 8 | #include <fcntl.h> |
e99525f9 | 9 | #include "chan_user.h" |
37185b33 | 10 | #include <os.h> |
1da177e4 | 11 | |
b60745b9 | 12 | /* This address is used only as a unique identifier */ |
1da177e4 LT |
13 | static int null_chan; |
14 | ||
5e7672ec | 15 | static void *null_init(char *str, int device, const struct chan_opts *opts) |
1da177e4 | 16 | { |
e99525f9 | 17 | return &null_chan; |
1da177e4 LT |
18 | } |
19 | ||
20 | static int null_open(int input, int output, int primary, void *d, | |
21 | char **dev_out) | |
22 | { | |
e99525f9 JD |
23 | int fd; |
24 | ||
1da177e4 | 25 | *dev_out = NULL; |
e99525f9 JD |
26 | |
27 | fd = open(DEV_NULL, O_RDWR); | |
28 | return (fd < 0) ? -errno : fd; | |
1da177e4 LT |
29 | } |
30 | ||
31 | static int null_read(int fd, char *c_out, void *unused) | |
32 | { | |
e99525f9 | 33 | return -ENODEV; |
1da177e4 LT |
34 | } |
35 | ||
36 | static void null_free(void *data) | |
37 | { | |
38 | } | |
39 | ||
5e7672ec | 40 | const struct chan_ops null_ops = { |
1da177e4 LT |
41 | .type = "null", |
42 | .init = null_init, | |
43 | .open = null_open, | |
44 | .close = generic_close, | |
45 | .read = null_read, | |
46 | .write = generic_write, | |
47 | .console_write = generic_console_write, | |
48 | .window_size = generic_window_size, | |
49 | .free = null_free, | |
50 | .winch = 0, | |
51 | }; |