/* /dev/null data sink */

#include <stddef.h>
#include <device.h>

#ifndef mkdev
#define mkdev(a,b)	((((a) << 8) & 0xff00)|((b) & 0x00ff))
#endif

static long null_open(const char *name, int flags, unsigned mode)
{
	return(mkdev('N',0));
}

static long null_close(int fd) 
{
    return 0;
}

static long null_read(int fd, void *buf, long nbytes)
{
    return 0;
}

static long null_write(int fd, void *buf, long nbytes)
{
    return nbytes;
}

static struct _device	null_dev =
	{"NUL:", "null", mkdev('N', 0),
		 null_open, null_close, null_read, null_write, NULL, NULL };

void install_null()
{
    _install_device(&null_dev);
}
