tst-aio8.c 756 B

123456789101112131415161718192021222324252627282930313233343536373839
  1. #include <aio.h>
  2. #include <errno.h>
  3. #include <fcntl.h>
  4. #include <stdio.h>
  5. #include <string.h>
  6. #include <unistd.h>
  7. static int
  8. do_test (void)
  9. {
  10. int fd = open ("/dev/full", O_RDWR);
  11. if (fd == -1)
  12. {
  13. puts ("could not open /dev/full");
  14. return 0;
  15. }
  16. struct aiocb req;
  17. req.aio_fildes = fd;
  18. req.aio_lio_opcode = LIO_WRITE;
  19. req.aio_reqprio = 0;
  20. req.aio_buf = (void *) "hello";
  21. req.aio_nbytes = 5;
  22. req.aio_offset = 0;
  23. req.aio_sigevent.sigev_notify = SIGEV_NONE;
  24. struct aiocb *list[1];
  25. list[0] = &req;
  26. int r = lio_listio (LIO_WAIT, list, 1, NULL);
  27. int e = errno;
  28. printf ("r = %d, e = %d (%s)\n", r, e, strerror (e));
  29. return r != -1 || e != EIO;
  30. }
  31. #define TEST_FUNCTION do_test ()
  32. #include "../test-skeleton.c"