2007-10-16 04:27:34 -04:00
|
|
|
/*
|
2007-10-16 04:26:41 -04:00
|
|
|
* Copyright (C) 2002 - 2007 Jeff Dike (jdike@{linux.intel,addtoit}.com)
|
2005-04-16 18:20:36 -04:00
|
|
|
* Licensed under the GPL
|
|
|
|
*/
|
|
|
|
|
2007-10-16 04:26:41 -04:00
|
|
|
#include <stddef.h>
|
2005-04-16 18:20:36 -04:00
|
|
|
#include <errno.h>
|
2007-10-16 04:26:41 -04:00
|
|
|
#include <fcntl.h>
|
|
|
|
#include "chan_user.h"
|
2007-10-16 04:27:34 -04:00
|
|
|
#include "os.h"
|
2005-04-16 18:20:36 -04:00
|
|
|
|
2007-10-19 19:23:03 -04:00
|
|
|
/* This address is used only as a unique identifier */
|
2005-04-16 18:20:36 -04:00
|
|
|
static int null_chan;
|
|
|
|
|
2006-09-27 04:50:33 -04:00
|
|
|
static void *null_init(char *str, int device, const struct chan_opts *opts)
|
2005-04-16 18:20:36 -04:00
|
|
|
{
|
2007-10-16 04:26:41 -04:00
|
|
|
return &null_chan;
|
2005-04-16 18:20:36 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
static int null_open(int input, int output, int primary, void *d,
|
|
|
|
char **dev_out)
|
|
|
|
{
|
2007-10-16 04:26:41 -04:00
|
|
|
int fd;
|
|
|
|
|
2005-04-16 18:20:36 -04:00
|
|
|
*dev_out = NULL;
|
2007-10-16 04:26:41 -04:00
|
|
|
|
|
|
|
fd = open(DEV_NULL, O_RDWR);
|
|
|
|
return (fd < 0) ? -errno : fd;
|
2005-04-16 18:20:36 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
static int null_read(int fd, char *c_out, void *unused)
|
|
|
|
{
|
2007-10-16 04:26:41 -04:00
|
|
|
return -ENODEV;
|
2005-04-16 18:20:36 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
static void null_free(void *data)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2006-09-27 04:50:33 -04:00
|
|
|
const struct chan_ops null_ops = {
|
2005-04-16 18:20:36 -04:00
|
|
|
.type = "null",
|
|
|
|
.init = null_init,
|
|
|
|
.open = null_open,
|
|
|
|
.close = generic_close,
|
|
|
|
.read = null_read,
|
|
|
|
.write = generic_write,
|
|
|
|
.console_write = generic_console_write,
|
|
|
|
.window_size = generic_window_size,
|
|
|
|
.free = null_free,
|
|
|
|
.winch = 0,
|
|
|
|
};
|