0001-ZTS-small-fix-for-SEEK_DATA-SEEK_HOLE-tests.patch 2.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970
  1. From 2ccefd4aff98cf355c7d13b3f92bb4d390dfa522 Mon Sep 17 00:00:00 2001
  2. From: Tino Reichardt <milky-zfs@mcmilk.de>
  3. Date: Sun, 4 Aug 2024 11:58:13 +0200
  4. Subject: [PATCH] ZTS: small fix for SEEK_DATA/SEEK_HOLE tests
  5. Some libc's like uClibc lag the proper definition of SEEK_DATA
  6. and SEEK_HOLE. Since we have only two files in ZTS which use
  7. these definitons, let's define them by hand:
  8. ```
  9. #ifndef SEEK_DATA
  10. #define SEEK_DATA 3
  11. #endif
  12. #ifndef SEEK_HOLE
  13. #define SEEK_HOLE 4
  14. #endif
  15. ```
  16. There should be no failures, because:
  17. - FreeBSD has support for SEEK_DATA/SEEK_HOLE since FreeBSD 8
  18. - Linux has it since Linux 3.1
  19. - the libc will submit the parameters unchanged to the kernel
  20. Signed-off-by: Tino Reichardt <milky-zfs@mcmilk.de>
  21. Signed-off-by: José Luis Salvador Rufo <salvador.joseluis@gmail.com>
  22. Upstream: https://github.com/openzfs/zfs/commit/bd949b10bed3d99e3b40249d9c8d74a0b4304774
  23. ---
  24. tests/zfs-tests/cmd/mmap_seek.c | 10 ++++++++++
  25. tests/zfs-tests/tests/functional/cp_files/seekflood.c | 7 +++++++
  26. 2 files changed, 17 insertions(+)
  27. diff --git a/tests/zfs-tests/cmd/mmap_seek.c b/tests/zfs-tests/cmd/mmap_seek.c
  28. index 7be92d109565..2d250554a13f 100644
  29. --- a/tests/zfs-tests/cmd/mmap_seek.c
  30. +++ b/tests/zfs-tests/cmd/mmap_seek.c
  31. @@ -35,6 +35,16 @@
  32. #include <linux/fs.h>
  33. #endif
  34. +/* some older uClibc's lack the defines, so we'll manually define them */
  35. +#ifdef __UCLIBC__
  36. +#ifndef SEEK_DATA
  37. +#define SEEK_DATA 3
  38. +#endif
  39. +#ifndef SEEK_HOLE
  40. +#define SEEK_HOLE 4
  41. +#endif
  42. +#endif
  43. +
  44. static void
  45. seek_data(int fd, off_t offset, off_t expected)
  46. {
  47. diff --git a/tests/zfs-tests/tests/functional/cp_files/seekflood.c b/tests/zfs-tests/tests/functional/cp_files/seekflood.c
  48. index 02c2c8e6eca5..f832db85970d 100644
  49. --- a/tests/zfs-tests/tests/functional/cp_files/seekflood.c
  50. +++ b/tests/zfs-tests/tests/functional/cp_files/seekflood.c
  51. @@ -36,6 +36,13 @@
  52. #include <sys/stat.h>
  53. #include <sys/wait.h>
  54. +/* some older uClibc's lack the defines, so we'll manually define them */
  55. +#ifdef __UCLIBC__
  56. +#ifndef SEEK_DATA
  57. +#define SEEK_DATA 3
  58. +#endif
  59. +#endif
  60. +
  61. #define DATASIZE (4096)
  62. char data[DATASIZE];