From a59e4a337a82e32612fbc7fdd2e93287b826abf2 Mon Sep 17 00:00:00 2001 From: Simon Rettberg Date: Tue, 14 Jun 2022 17:23:19 +0200 Subject: [KERNEL] Adapt to Linux 5.18 --- README.md | 2 +- src/kernel/blk.c | 4 ++++ src/kernel/sysfs.c | 11 ++++++++++- 3 files changed, 15 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index c0116b9..f80ddb8 100644 --- a/README.md +++ b/README.md @@ -11,7 +11,7 @@ This repository contains the source code for the following dnbd3 components: The dnbd3 components can be built for the following Linux kernel versions and Unix distributions: - - Generic/Vanilla Kernel **4.9** to **5.15** + - Generic/Vanilla Kernel **4.9** to **5.18** - Archlinux with **Linux kernel 5.15.x** or **5.10.x** - Raspberry Pi OS with **Linux kernel 5.4.x** - Ubuntu 20.04 with **Linux kernel 5.4.x** 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, }; -- cgit v1.2.3-55-g7522