lvm2-2.02.145-mkdev.patch 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128
  1. https://bugs.gentoo.org/580062
  2. From 2a1d0fa8ea765604cd8274aac5aa7876f1c145c9 Mon Sep 17 00:00:00 2001
  3. From: Mike Frysinger <vapier@gentoo.org>
  4. Date: Tue, 19 Apr 2016 23:53:22 -0400
  5. Subject: [PATCH] convert major/minor/makedev handling
  6. Most of the files in here use MAJOR/MINOR/MKDEV macros, but a few
  7. missed it. Update the defines in those files to match them.
  8. ---
  9. daemons/cmirrord/functions.c | 16 ++++++++++++----
  10. daemons/dmeventd/plugins/snapshot/dmeventd_snapshot.c | 12 ++++++++++--
  11. lib/filters/filter-sysfs.c | 6 ++++--
  12. 3 files changed, 26 insertions(+), 8 deletions(-)
  13. diff --git a/daemons/cmirrord/functions.c b/daemons/cmirrord/functions.c
  14. index e9d3c09..5b3cb38 100644
  15. --- a/daemons/cmirrord/functions.c
  16. +++ b/daemons/cmirrord/functions.c
  17. @@ -20,6 +20,14 @@
  18. #include <time.h>
  19. #include <unistd.h>
  20. +#ifdef __linux__
  21. +# include "kdev_t.h"
  22. +#else
  23. +# define MAJOR(x) major((x))
  24. +# define MINOR(x) minor((x))
  25. +# define MKDEV(x,y) makedev((x),(y))
  26. +#endif
  27. +
  28. #define BYTE_SHIFT 3
  29. /*
  30. @@ -333,8 +341,8 @@ static int find_disk_path(char *major_minor_str, char *path_rtn, int *unlink_pat
  31. continue;
  32. }
  33. if (S_ISBLK(statbuf.st_mode) &&
  34. - (major(statbuf.st_rdev) == major) &&
  35. - (minor(statbuf.st_rdev) == minor)) {
  36. + (MAJOR(statbuf.st_rdev) == major) &&
  37. + (MINOR(statbuf.st_rdev) == minor)) {
  38. LOG_DBG(" %s: YES", dep->d_name);
  39. if (closedir(dp))
  40. LOG_DBG("Unable to closedir /dev/mapper %s",
  41. @@ -1451,7 +1459,7 @@ static int disk_status_info(struct log_c *lc, struct dm_ulog_request *rq)
  42. }
  43. r = sprintf(data, "3 clustered-disk %d:%d %c",
  44. - major(statbuf.st_rdev), minor(statbuf.st_rdev),
  45. + MAJOR(statbuf.st_rdev), MINOR(statbuf.st_rdev),
  46. (lc->log_dev_failed) ? 'D' : 'A');
  47. if (r < 0)
  48. return r;
  49. @@ -1514,7 +1522,7 @@ static int disk_status_table(struct log_c *lc, struct dm_ulog_request *rq)
  50. }
  51. r = sprintf(data, "clustered-disk %d:%d %u %s%s ",
  52. - major(statbuf.st_rdev), minor(statbuf.st_rdev),
  53. + MAJOR(statbuf.st_rdev), MINOR(statbuf.st_rdev),
  54. lc->region_size,
  55. (lc->sync == DEFAULTSYNC) ? "" :
  56. (lc->sync == NOSYNC) ? "nosync " : "sync ",
  57. diff --git a/daemons/dmeventd/plugins/snapshot/dmeventd_snapshot.c b/daemons/dmeventd/plugins/snapshot/dmeventd_snapshot.c
  58. index 7b060ed..4098203 100644
  59. --- a/daemons/dmeventd/plugins/snapshot/dmeventd_snapshot.c
  60. +++ b/daemons/dmeventd/plugins/snapshot/dmeventd_snapshot.c
  61. @@ -20,6 +20,14 @@
  62. #include <stdarg.h>
  63. #include <pthread.h>
  64. +#ifdef __linux__
  65. +# include "kdev_t.h"
  66. +#else
  67. +# define MAJOR(x) major((x))
  68. +# define MINOR(x) minor((x))
  69. +# define MKDEV(x,y) makedev((x),(y))
  70. +#endif
  71. +
  72. /* First warning when snapshot is 80% full. */
  73. #define WARNING_THRESH (DM_PERCENT_1 * 80)
  74. /* Run a check every 5%. */
  75. @@ -148,8 +156,8 @@ static void _umount(const char *device, int major, int minor)
  76. continue; /* can't stat, skip this one */
  77. if (S_ISBLK(st.st_mode) &&
  78. - major(st.st_rdev) == major &&
  79. - minor(st.st_rdev) == minor) {
  80. + MAJOR(st.st_rdev) == major &&
  81. + MINOR(st.st_rdev) == minor) {
  82. log_error("Unmounting invalid snapshot %s from %s.", device, words[1]);
  83. if (!_run(UMOUNT_COMMAND, "-fl", words[1], NULL))
  84. log_error("Failed to umount snapshot %s from %s: %s.",
  85. diff --git a/lib/filters/filter-sysfs.c b/lib/filters/filter-sysfs.c
  86. index 3115f86..5f76e8b 100644
  87. --- a/lib/filters/filter-sysfs.c
  88. +++ b/lib/filters/filter-sysfs.c
  89. @@ -19,6 +19,8 @@
  90. #include <dirent.h>
  91. +#include "kdev_t.h"
  92. +
  93. static int _locate_sysfs_blocks(const char *sysfs_dir, char *path, size_t len,
  94. unsigned *sysfs_depth)
  95. {
  96. @@ -120,7 +122,7 @@ static struct dev_set *_dev_set_create(struct dm_pool *mem,
  97. static unsigned _hash_dev(dev_t dev)
  98. {
  99. - return (major(dev) ^ minor(dev)) & (SET_BUCKETS - 1);
  100. + return (MAJOR(dev) ^ MINOR(dev)) & (SET_BUCKETS - 1);
  101. }
  102. /*
  103. @@ -171,7 +173,7 @@ static int _parse_dev(const char *file, FILE *fp, dev_t *result)
  104. return 0;
  105. }
  106. - *result = makedev(major, minor);
  107. + *result = MKDEV(major, minor);
  108. return 1;
  109. }
  110. --
  111. 2.7.4