summaryrefslogtreecommitdiff
blob: f91dccd5c188948ae94848e1f0c8a0e832f5c78a (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
https://bugs.gentoo.org/580062

From 2a1d0fa8ea765604cd8274aac5aa7876f1c145c9 Mon Sep 17 00:00:00 2001
From: Mike Frysinger <vapier@gentoo.org>
Date: Tue, 19 Apr 2016 23:53:22 -0400
Subject: [PATCH] convert major/minor/makedev handling

Most of the files in here use MAJOR/MINOR/MKDEV macros, but a few
missed it.  Update the defines in those files to match them.
---
 daemons/cmirrord/functions.c                          | 16 ++++++++++++----
 daemons/dmeventd/plugins/snapshot/dmeventd_snapshot.c | 12 ++++++++++--
 lib/filters/filter-sysfs.c                            |  6 ++++--
 3 files changed, 26 insertions(+), 8 deletions(-)

diff --git a/daemons/cmirrord/functions.c b/daemons/cmirrord/functions.c
index e9d3c09..5b3cb38 100644
--- a/daemons/cmirrord/functions.c
+++ b/daemons/cmirrord/functions.c
@@ -20,6 +20,14 @@
 #include <time.h>
 #include <unistd.h>
 
+#ifdef __linux__
+#  include "kdev_t.h"
+#else
+#  define MAJOR(x) major((x))
+#  define MINOR(x) minor((x))
+#  define MKDEV(x,y) makedev((x),(y))
+#endif
+
 #define BYTE_SHIFT 3
 
 /*
@@ -333,8 +341,8 @@ static int find_disk_path(char *major_minor_str, char *path_rtn, int *unlink_pat
 			continue;
 		}
 		if (S_ISBLK(statbuf.st_mode) &&
-		    (major(statbuf.st_rdev) == major) &&
-		    (minor(statbuf.st_rdev) == minor)) {
+		    (MAJOR(statbuf.st_rdev) == major) &&
+		    (MINOR(statbuf.st_rdev) == minor)) {
 			LOG_DBG("  %s: YES", dep->d_name);
 			if (closedir(dp))
 				LOG_DBG("Unable to closedir /dev/mapper %s",
@@ -1451,7 +1459,7 @@ static int disk_status_info(struct log_c *lc, struct dm_ulog_request *rq)
 	}
 
 	r = sprintf(data, "3 clustered-disk %d:%d %c",
-		    major(statbuf.st_rdev), minor(statbuf.st_rdev),
+		    MAJOR(statbuf.st_rdev), MINOR(statbuf.st_rdev),
 		    (lc->log_dev_failed) ? 'D' : 'A');
 	if (r < 0)
 		return r;
@@ -1514,7 +1522,7 @@ static int disk_status_table(struct log_c *lc, struct dm_ulog_request *rq)
 	}
 
 	r = sprintf(data, "clustered-disk %d:%d %u %s%s ",
-		    major(statbuf.st_rdev), minor(statbuf.st_rdev),
+		    MAJOR(statbuf.st_rdev), MINOR(statbuf.st_rdev),
 		    lc->region_size,
 		    (lc->sync == DEFAULTSYNC) ? "" :
 		    (lc->sync == NOSYNC) ? "nosync " : "sync ",
diff --git a/daemons/dmeventd/plugins/snapshot/dmeventd_snapshot.c b/daemons/dmeventd/plugins/snapshot/dmeventd_snapshot.c
index 7b060ed..4098203 100644
--- a/daemons/dmeventd/plugins/snapshot/dmeventd_snapshot.c
+++ b/daemons/dmeventd/plugins/snapshot/dmeventd_snapshot.c
@@ -20,6 +20,14 @@
 #include <stdarg.h>
 #include <pthread.h>
 
+#ifdef __linux__
+#  include "kdev_t.h"
+#else
+#  define MAJOR(x) major((x))
+#  define MINOR(x) minor((x))
+#  define MKDEV(x,y) makedev((x),(y))
+#endif
+
 /* First warning when snapshot is 80% full. */
 #define WARNING_THRESH	(DM_PERCENT_1 * 80)
 /* Run a check every 5%. */
@@ -148,8 +156,8 @@ static void _umount(const char *device, int major, int minor)
 			continue; /* can't stat, skip this one */
 
 		if (S_ISBLK(st.st_mode) &&
-		    major(st.st_rdev) == major &&
-		    minor(st.st_rdev) == minor) {
+		    MAJOR(st.st_rdev) == major &&
+		    MINOR(st.st_rdev) == minor) {
 			log_error("Unmounting invalid snapshot %s from %s.", device, words[1]);
 			if (!_run(UMOUNT_COMMAND, "-fl", words[1], NULL))
 				log_error("Failed to umount snapshot %s from %s: %s.",
diff --git a/lib/filters/filter-sysfs.c b/lib/filters/filter-sysfs.c
index 3115f86..5f76e8b 100644
--- a/lib/filters/filter-sysfs.c
+++ b/lib/filters/filter-sysfs.c
@@ -19,6 +19,8 @@
 
 #include <dirent.h>
 
+#include "kdev_t.h"
+
 static int _locate_sysfs_blocks(const char *sysfs_dir, char *path, size_t len,
 				unsigned *sysfs_depth)
 {
@@ -120,7 +122,7 @@ static struct dev_set *_dev_set_create(struct dm_pool *mem,
 
 static unsigned _hash_dev(dev_t dev)
 {
-	return (major(dev) ^ minor(dev)) & (SET_BUCKETS - 1);
+	return (MAJOR(dev) ^ MINOR(dev)) & (SET_BUCKETS - 1);
 }
 
 /*
@@ -171,7 +173,7 @@ static int _parse_dev(const char *file, FILE *fp, dev_t *result)
 		return 0;
 	}
 
-	*result = makedev(major, minor);
+	*result = MKDEV(major, minor);
 	return 1;
 }
 
-- 
2.7.4