null.c 1.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  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. /* This address is used only as a unique identifer */
  10. static int null_chan;
  11. static void *null_init(char *str, int device, const struct chan_opts *opts)
  12. {
  13. return(&null_chan);
  14. }
  15. static int null_open(int input, int output, int primary, void *d,
  16. char **dev_out)
  17. {
  18. *dev_out = NULL;
  19. return(os_open_file(DEV_NULL, of_rdwr(OPENFLAGS()), 0));
  20. }
  21. static int null_read(int fd, char *c_out, void *unused)
  22. {
  23. return(-ENODEV);
  24. }
  25. static void null_free(void *data)
  26. {
  27. }
  28. const struct chan_ops null_ops = {
  29. .type = "null",
  30. .init = null_init,
  31. .open = null_open,
  32. .close = generic_close,
  33. .read = null_read,
  34. .write = generic_write,
  35. .console_write = generic_console_write,
  36. .window_size = generic_window_size,
  37. .free = null_free,
  38. .winch = 0,
  39. };
  40. /*
  41. * Overrides for Emacs so that we follow Linus's tabbing style.
  42. * Emacs will notice this stuff at the end of the file and automatically
  43. * adjust the settings for this buffer only. This must remain at the end
  44. * of the file.
  45. * ---------------------------------------------------------------------------
  46. * Local variables:
  47. * c-file-style: "linux"
  48. * End:
  49. */