[sheepdog] [PATCH 1/2] sbd: add support to compile against new kernel 3.12 and plus

Liu Yuan namei.unix at gmail.com
Fri May 30 15:24:26 CEST 2014


Signed-off-by: Liu Yuan <namei.unix at gmail.com>
---
 sbd/sbd.h                |  1 +
 sbd/sheep_block_device.c | 23 +++++++++++++++++++++++
 2 files changed, 24 insertions(+)

diff --git a/sbd/sbd.h b/sbd/sbd.h
index 5fb0a92..c6203ef 100644
--- a/sbd/sbd.h
+++ b/sbd/sbd.h
@@ -15,6 +15,7 @@
 #include <linux/blkdev.h>
 #include <linux/kthread.h>
 #include <linux/gfp.h>
+#include <linux/version.h>
 
 #include "sheepdog_proto.h"
 
diff --git a/sbd/sheep_block_device.c b/sbd/sheep_block_device.c
index 1067386..252b712 100644
--- a/sbd/sheep_block_device.c
+++ b/sbd/sheep_block_device.c
@@ -338,6 +338,27 @@ static ssize_t sbd_list(struct bus_type *bus, char *buf)
 	return ret;
 }
 
+#if LINUX_VERSION_CODE >= KERNEL_VERSION(3, 12, 0)
+
+static BUS_ATTR(add, S_IWUSR, NULL, sbd_add);
+static BUS_ATTR(remove, S_IWUSR, NULL, sbd_remove);
+static BUS_ATTR(list, S_IWUSR, sbd_list, NULL);
+
+static struct attribute *sbd_bus_attrs[] = {
+	&bus_attr_add.attr,
+	&bus_attr_remove.attr,
+	&bus_attr_list.attr,
+	NULL,
+};
+ATTRIBUTE_GROUPS(sbd_bus);
+
+static struct bus_type sbd_bus_type = {
+	.name		= "sbd",
+	.bus_groups	= sbd_bus_groups,
+};
+
+#else
+
 static struct bus_attribute sbd_bus_attrs[] = {
 	__ATTR(add, S_IWUSR, NULL, sbd_add),
 	__ATTR(remove, S_IWUSR, NULL, sbd_remove),
@@ -350,6 +371,8 @@ static struct bus_type sbd_bus_type = {
 	.bus_attrs	= sbd_bus_attrs,
 };
 
+#endif
+
 static void sbd_root_dev_release(struct device *dev)
 {
 }
-- 
1.8.1.2




More information about the sheepdog mailing list