null.c 1.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  1. /*
  2. * Copyright (C) 2002 Jeff Dike (jdike@karaya.com)
  3. * Licensed under the GPL
  4. */
  5. #include <stdlib.h>
  6. #include <errno.h>
  7. #include "chan_user.h"
  8. #include "os.h"
  9. static int null_chan;
  10. static void *null_init(char *str, int device, struct chan_opts *opts)
  11. {
  12. return(&null_chan);
  13. }
  14. static int null_open(int input, int output, int primary, void *d,
  15. char **dev_out)
  16. {
  17. *dev_out = NULL;
  18. return(os_open_file(DEV_NULL, of_rdwr(OPENFLAGS()), 0));
  19. }
  20. static int null_read(int fd, char *c_out, void *unused)
  21. {
  22. return(-ENODEV);
  23. }
  24. static void null_free(void *data)
  25. {
  26. }
  27. struct chan_ops null_ops = {
  28. .type = "null",
  29. .init = null_init,
  30. .open = null_open,
  31. .close = generic_close,
  32. .read = null_read,
  33. .write = generic_write,
  34. .console_write = generic_console_write,
  35. .window_size = generic_window_size,
  36. .free = null_free,
  37. .winch = 0,
  38. };
  39. /*
  40. * Overrides for Emacs so that we follow Linus's tabbing style.
  41. * Emacs will notice this stuff at the end of the file and automatically
  42. * adjust the settings for this buffer only. This must remain at the end
  43. * of the file.
  44. * ---------------------------------------------------------------------------
  45. * Local variables:
  46. * c-file-style: "linux"
  47. * End:
  48. */