summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorSimon Rettberg2022-06-14 17:23:19 +0200
committerSimon Rettberg2022-06-14 17:23:19 +0200
commita59e4a337a82e32612fbc7fdd2e93287b826abf2 (patch)
tree4a0530edd50d8ce2e5546c54fb9d45af2fee4592 /src
parentUpdate README (diff)
downloaddnbd3-a59e4a337a82e32612fbc7fdd2e93287b826abf2.tar.gz
dnbd3-a59e4a337a82e32612fbc7fdd2e93287b826abf2.tar.xz
dnbd3-a59e4a337a82e32612fbc7fdd2e93287b826abf2.zip
[KERNEL] Adapt to Linux 5.18
Diffstat (limited to 'src')
-rw-r--r--src/kernel/blk.c4
-rw-r--r--src/kernel/sysfs.c11
2 files changed, 14 insertions, 1 deletions
diff --git a/src/kernel/blk.c b/src/kernel/blk.c
index 6e9952b..448f62f 100644
--- a/src/kernel/blk.c
+++ b/src/kernel/blk.c
@@ -466,7 +466,11 @@ int dnbd3_blk_add_device(dnbd3_device_t *dev, int minor)
}
#endif
+#if LINUX_VERSION_CODE < KERNEL_VERSION(5, 17, 0)
dev->disk->flags |= GENHD_FL_NO_PART_SCAN;
+#else
+ dev->disk->flags |= GENHD_FL_NO_PART;
+#endif
dev->disk->major = major;
dev->disk->first_minor = minor;
dev->disk->minors = 1;
diff --git a/src/kernel/sysfs.c b/src/kernel/sysfs.c
index 3e5febd..9deba96 100644
--- a/src/kernel/sysfs.c
+++ b/src/kernel/sysfs.c
@@ -145,9 +145,14 @@ struct attribute *device_attrs[] = {
&cur_server_addr.attr,
&alt_servers.attr,
&image_name.attr, &rid.attr,
- &update_available.attr, NULL,
+ &update_available.attr,
+ NULL,
};
+#if LINUX_VERSION_CODE >= KERNEL_VERSION(5, 15, 0)
+ATTRIBUTE_GROUPS(device);
+#endif
+
const struct sysfs_ops device_ops = {
.show = device_show,
};
@@ -158,7 +163,11 @@ void release(struct kobject *kobj)
}
struct kobj_type device_ktype = {
+#if LINUX_VERSION_CODE < KERNEL_VERSION(5, 15, 0)
.default_attrs = device_attrs,
+#else
+ .default_groups = device_groups,
+#endif
.sysfs_ops = &device_ops,
.release = release,
};