0005-Add-src-internal-statx.h.patch 2.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394
  1. From eca94dccba29fb2862884472ae8d30672480f8f4 Mon Sep 17 00:00:00 2001
  2. From: Stefan O'Rear <sorear@fastmail.com>
  3. Date: Thu, 3 Sep 2020 03:45:08 -0400
  4. Subject: [PATCH 05/16] Add src/internal/statx.h
  5. We need to make internal syscalls to SYS_statx when SYS_fstatat is not
  6. available without changing the musl API.
  7. ---
  8. src/internal/statx.h | 28 ++++++++++++++++++++++++++++
  9. src/stat/fstatat.c | 28 ++--------------------------
  10. 2 files changed, 30 insertions(+), 26 deletions(-)
  11. create mode 100644 src/internal/statx.h
  12. diff --git a/src/internal/statx.h b/src/internal/statx.h
  13. new file mode 100644
  14. index 00000000..46b16f62
  15. --- /dev/null
  16. +++ b/src/internal/statx.h
  17. @@ -0,0 +1,28 @@
  18. +struct statx {
  19. + uint32_t stx_mask;
  20. + uint32_t stx_blksize;
  21. + uint64_t stx_attributes;
  22. + uint32_t stx_nlink;
  23. + uint32_t stx_uid;
  24. + uint32_t stx_gid;
  25. + uint16_t stx_mode;
  26. + uint16_t pad1;
  27. + uint64_t stx_ino;
  28. + uint64_t stx_size;
  29. + uint64_t stx_blocks;
  30. + uint64_t stx_attributes_mask;
  31. + struct {
  32. + int64_t tv_sec;
  33. + uint32_t tv_nsec;
  34. + int32_t pad;
  35. + } stx_atime, stx_btime, stx_ctime, stx_mtime;
  36. + uint32_t stx_rdev_major;
  37. + uint32_t stx_rdev_minor;
  38. + uint32_t stx_dev_major;
  39. + uint32_t stx_dev_minor;
  40. + uint64_t spare[14];
  41. +};
  42. +
  43. +#define STATX_TYPE 0x001U
  44. +#define STATX_SIZE 0x200U
  45. +#define STATX_BASIC_STATS 0x7ffU
  46. diff --git a/src/stat/fstatat.c b/src/stat/fstatat.c
  47. index de165b5c..230a83fc 100644
  48. --- a/src/stat/fstatat.c
  49. +++ b/src/stat/fstatat.c
  50. @@ -7,37 +7,13 @@
  51. #include <sys/sysmacros.h>
  52. #include "syscall.h"
  53. #include "kstat.h"
  54. -
  55. -struct statx {
  56. - uint32_t stx_mask;
  57. - uint32_t stx_blksize;
  58. - uint64_t stx_attributes;
  59. - uint32_t stx_nlink;
  60. - uint32_t stx_uid;
  61. - uint32_t stx_gid;
  62. - uint16_t stx_mode;
  63. - uint16_t pad1;
  64. - uint64_t stx_ino;
  65. - uint64_t stx_size;
  66. - uint64_t stx_blocks;
  67. - uint64_t stx_attributes_mask;
  68. - struct {
  69. - int64_t tv_sec;
  70. - uint32_t tv_nsec;
  71. - int32_t pad;
  72. - } stx_atime, stx_btime, stx_ctime, stx_mtime;
  73. - uint32_t stx_rdev_major;
  74. - uint32_t stx_rdev_minor;
  75. - uint32_t stx_dev_major;
  76. - uint32_t stx_dev_minor;
  77. - uint64_t spare[14];
  78. -};
  79. +#include "statx.h"
  80. static int fstatat_statx(int fd, const char *restrict path, struct stat *restrict st, int flag)
  81. {
  82. struct statx stx;
  83. - int ret = __syscall(SYS_statx, fd, path, flag, 0x7ff, &stx);
  84. + int ret = __syscall(SYS_statx, fd, path, flag, STATX_BASIC_STATS, &stx);
  85. if (ret) return ret;
  86. *st = (struct stat){
  87. --
  88. 2.29.2