ananas

NFS statx() dirty fix

Sep 20th, 2019
137
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Diff 2.66 KB | None | 0 0
  1. --- nfs-utils-2.4.1/support/misc/xstat.c.orig   2019-06-10 17:34:37.000000000 +0300
  2. +++ nfs-utils-2.4.1/support/misc/xstat.c    2019-07-26 11:51:26.783999140 +0300
  3. @@ -8,91 +8,6 @@
  4.  #include "config.h"
  5.  #include "xstat.h"
  6.  
  7. -#ifdef HAVE_FSTATAT
  8. -#ifdef HAVE_STATX
  9. -
  10. -static void
  11. -statx_copy(struct stat *stbuf, const struct statx *stxbuf)
  12. -{
  13. -   stbuf->st_dev = makedev(stxbuf->stx_dev_major, stxbuf->stx_dev_minor);
  14. -   stbuf->st_ino = stxbuf->stx_ino;
  15. -   stbuf->st_mode = stxbuf->stx_mode;
  16. -   stbuf->st_nlink = stxbuf->stx_nlink;
  17. -   stbuf->st_uid = stxbuf->stx_uid;
  18. -   stbuf->st_gid = stxbuf->stx_gid;
  19. -   stbuf->st_rdev = makedev(stxbuf->stx_rdev_major, stxbuf->stx_rdev_minor);
  20. -   stbuf->st_size = stxbuf->stx_size;
  21. -   stbuf->st_blksize = stxbuf->stx_blksize;
  22. -   stbuf->st_blocks = stxbuf->stx_blocks;
  23. -   stbuf->st_atim.tv_sec = stxbuf->stx_atime.tv_sec;
  24. -   stbuf->st_atim.tv_nsec = stxbuf->stx_atime.tv_nsec;
  25. -   stbuf->st_mtim.tv_sec = stxbuf->stx_mtime.tv_sec;
  26. -   stbuf->st_mtim.tv_nsec = stxbuf->stx_mtime.tv_nsec;
  27. -   stbuf->st_ctim.tv_sec = stxbuf->stx_ctime.tv_sec;
  28. -   stbuf->st_ctim.tv_nsec = stxbuf->stx_ctime.tv_nsec;
  29. -}
  30. -
  31. -static int
  32. -statx_do_stat(int fd, const char *pathname, struct stat *statbuf, int flags)
  33. -{
  34. -   static int statx_supported = 1;
  35. -   struct statx stxbuf;
  36. -   int ret;
  37. -
  38. -   if (statx_supported) {
  39. -       ret = statx(fd, pathname, flags,
  40. -               STATX_BASIC_STATS,
  41. -               &stxbuf);
  42. -       if (ret == 0) {
  43. -           statx_copy(statbuf, &stxbuf);
  44. -           return 0;
  45. -       }
  46. -       if (errno == ENOSYS)
  47. -           statx_supported = 0;
  48. -   } else
  49. -       errno = ENOSYS;
  50. -   return -1;
  51. -}
  52. -
  53. -static int
  54. -statx_stat_nosync(int fd, const char *pathname, struct stat *statbuf, int flags)
  55. -{
  56. -   return statx_do_stat(fd, pathname, statbuf, flags | AT_STATX_DONT_SYNC);
  57. -}
  58. -
  59. -#else
  60. -
  61. -static int
  62. -statx_stat_nosync(int fd, const char *pathname, struct stat *statbuf, int flags)
  63. -{
  64. -   errno = ENOSYS;
  65. -   return -1;
  66. -}
  67. -
  68. -#endif /* HAVE_STATX */
  69. -
  70. -int xlstat(const char *pathname, struct stat *statbuf)
  71. -{
  72. -   if (statx_stat_nosync(AT_FDCWD, pathname, statbuf, AT_NO_AUTOMOUNT|
  73. -               AT_SYMLINK_NOFOLLOW) == 0)
  74. -       return 0;
  75. -   else if (errno != ENOSYS)
  76. -       return -1;
  77. -   return fstatat(AT_FDCWD, pathname, statbuf, AT_NO_AUTOMOUNT |
  78. -           AT_SYMLINK_NOFOLLOW);
  79. -}
  80. -
  81. -int xstat(const char *pathname, struct stat *statbuf)
  82. -{
  83. -   if (statx_stat_nosync(AT_FDCWD, pathname, statbuf, AT_NO_AUTOMOUNT) == 0)
  84. -       return 0;
  85. -   else if (errno != ENOSYS)
  86. -       return -1;
  87. -   return fstatat(AT_FDCWD, pathname, statbuf, AT_NO_AUTOMOUNT);
  88. -}
  89. -
  90. -#else
  91. -
  92.  int xlstat(const char *pathname, struct stat *statbuf)
  93.  {
  94.     return lstat(pathname, statbuf);
  95. @@ -102,4 +17,3 @@
  96.  {
  97.     return stat(pathname, statbuf);
  98.  }
  99. -#endif
Add Comment
Please, Sign In to add comment