616-mips_fix_stat_time.patch 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123
  1. --- a/libc/sysdeps/linux/common/xstatconv.c
  2. +++ b/libc/sysdeps/linux/common/xstatconv.c
  3. @@ -39,9 +39,12 @@ void __xstat_conv(struct kernel_stat *kb
  4. buf->st_size = kbuf->st_size;
  5. buf->st_blksize = kbuf->st_blksize;
  6. buf->st_blocks = kbuf->st_blocks;
  7. - buf->st_atim = kbuf->st_atim;
  8. - buf->st_mtim = kbuf->st_mtim;
  9. - buf->st_ctim = kbuf->st_ctim;
  10. + buf->st_atim.tv_sec = kbuf->st_atim.tv_sec;
  11. + buf->st_atim.tv_nsec = kbuf->st_atim.tv_nsec;
  12. + buf->st_mtim.tv_sec = kbuf->st_mtim.tv_sec;
  13. + buf->st_mtim.tv_nsec = kbuf->st_mtim.tv_nsec;
  14. + buf->st_ctim.tv_sec = kbuf->st_ctim.tv_sec;
  15. + buf->st_ctim.tv_nsec = kbuf->st_ctim.tv_nsec;
  16. }
  17. void __xstat32_conv(struct kernel_stat64 *kbuf, struct stat *buf)
  18. @@ -58,9 +61,12 @@ void __xstat32_conv(struct kernel_stat64
  19. buf->st_size = kbuf->st_size;
  20. buf->st_blksize = kbuf->st_blksize;
  21. buf->st_blocks = kbuf->st_blocks;
  22. - buf->st_atim = kbuf->st_atim;
  23. - buf->st_mtim = kbuf->st_mtim;
  24. - buf->st_ctim = kbuf->st_ctim;
  25. + buf->st_atim.tv_sec = kbuf->st_atim.tv_sec;
  26. + buf->st_atim.tv_nsec = kbuf->st_atim.tv_nsec;
  27. + buf->st_mtim.tv_sec = kbuf->st_mtim.tv_sec;
  28. + buf->st_mtim.tv_nsec = kbuf->st_mtim.tv_nsec;
  29. + buf->st_ctim.tv_sec = kbuf->st_ctim.tv_sec;
  30. + buf->st_ctim.tv_nsec = kbuf->st_ctim.tv_nsec;
  31. }
  32. #ifdef __UCLIBC_HAS_LFS__
  33. @@ -82,9 +88,12 @@ void __xstat64_conv(struct kernel_stat64
  34. buf->st_size = kbuf->st_size;
  35. buf->st_blksize = kbuf->st_blksize;
  36. buf->st_blocks = kbuf->st_blocks;
  37. - buf->st_atim = kbuf->st_atim;
  38. - buf->st_mtim = kbuf->st_mtim;
  39. - buf->st_ctim = kbuf->st_ctim;
  40. + buf->st_atim.tv_sec = kbuf->st_atim.tv_sec;
  41. + buf->st_atim.tv_nsec = kbuf->st_atim.tv_nsec;
  42. + buf->st_mtim.tv_sec = kbuf->st_mtim.tv_sec;
  43. + buf->st_mtim.tv_nsec = kbuf->st_mtim.tv_nsec;
  44. + buf->st_ctim.tv_sec = kbuf->st_ctim.tv_sec;
  45. + buf->st_ctim.tv_nsec = kbuf->st_ctim.tv_nsec;
  46. }
  47. #endif /* __UCLIBC_HAS_LFS__ */
  48. --- a/libc/sysdeps/linux/mips/bits/kernel_stat.h
  49. +++ b/libc/sysdeps/linux/mips/bits/kernel_stat.h
  50. @@ -8,6 +8,18 @@
  51. #include <sgidefs.h>
  52. #if _MIPS_SIM == _MIPS_SIM_ABI64
  53. +typedef struct {
  54. + unsigned int tv_sec;
  55. + unsigned int tv_nsec;
  56. +} __ktimespec_t;
  57. +#else
  58. +typedef struct {
  59. + time_t tv_sec;
  60. + unsigned long tv_nsec;
  61. +} __ktimespec_t;
  62. +#endif
  63. +
  64. +#if _MIPS_SIM == _MIPS_SIM_ABI64
  65. /* The memory layout is the same as of struct stat64 of the 32-bit kernel. */
  66. struct kernel_stat {
  67. __kernel_dev_t st_dev;
  68. @@ -20,9 +32,9 @@ struct kernel_stat {
  69. __kernel_dev_t st_rdev;
  70. unsigned int st_pad2[3];
  71. __kernel_off_t st_size;
  72. - struct timespec st_atim;
  73. - struct timespec st_mtim;
  74. - struct timespec st_ctim;
  75. + __ktimespec_t st_atim;
  76. + __ktimespec_t st_mtim;
  77. + __ktimespec_t st_ctim;
  78. unsigned int st_blksize;
  79. unsigned int reserved3;
  80. unsigned long st_blocks;
  81. @@ -41,9 +53,9 @@ struct kernel_stat {
  82. unsigned int st_rdev;
  83. unsigned int st_pad2[3];
  84. unsigned long long st_size;
  85. - struct timespec st_atim;
  86. - struct timespec st_mtim;
  87. - struct timespec st_ctim;
  88. + __ktimespec_t st_atim;
  89. + __ktimespec_t st_mtim;
  90. + __ktimespec_t st_ctim;
  91. unsigned int st_blksize;
  92. unsigned int reserved3;
  93. unsigned long long st_blocks;
  94. @@ -62,9 +74,9 @@ struct kernel_stat {
  95. long st_pad2[2];
  96. __kernel_off_t st_size;
  97. long st_pad3;
  98. - struct timespec st_atim;
  99. - struct timespec st_mtim;
  100. - struct timespec st_ctim;
  101. + __ktimespec_t st_atim;
  102. + __ktimespec_t st_mtim;
  103. + __ktimespec_t st_ctim;
  104. long st_blksize;
  105. long st_blocks;
  106. long st_pad4[14];
  107. @@ -81,9 +93,9 @@ struct kernel_stat64 {
  108. unsigned long st_rdev;
  109. unsigned long st_pad1[3]; /* Reserved for st_rdev expansion */
  110. long long st_size;
  111. - struct timespec st_atim;
  112. - struct timespec st_mtim;
  113. - struct timespec st_ctim;
  114. + __ktimespec_t st_atim;
  115. + __ktimespec_t st_mtim;
  116. + __ktimespec_t st_ctim;
  117. unsigned long st_blksize;
  118. unsigned long st_pad2;
  119. long long st_blocks;