Centos stream 9 backports but AlmaLinux and Rocky Linux don't

CentOS Stream release 9:

linux/uio_mrf.c:129:19: error: assignment of read-only member ‘vm_flags’

129 | vma->vm_flags |= VM_IO | VM_RESERVED;

It seems that Centos Stream backports the vm_flags_set() wrapper for old kernel versions, so older than KERNEL_VERSION(6, 3, 0). But, AlmaLinux and Rocky Linux don’t.

How can I distinguish Centos Stream from AlmaLinux and Rocky Linux so I can write a compatible kernel driver for all? As far as I can see, all three distros use the same macros e.g.

#define LINUX_VERSION_CODE 331264
#define LINUX_VERSION_MAJOR 5
#define LINUX_VERSION_PATCHLEVEL 14
#define LINUX_VERSION_SUBLEVEL 0
#define RHEL_MAJOR 9
#define RHEL_MINOR 6
#define RHEL_RELEASE_CODE 2310
#define RHEL_RELEASE "522"

Is there any macro specific to Centos Stream only?

CentOS Stream should be seen as a possible and quite likely ‘future’ of AlmaLinux and Rocky Linux. The kernel there will always be months in advance of whatever Alma and Rocky have so eventually the backport you see in CentOS Stream kernels will show up in Alma/Rocky in around 6 months depending on “dot” release cycles.

I don’t know of any macros which would help you distinguish from the source code level. You would need to do so from the packaging level or higher.

1 Like

May be not what you are looking for, but perhaps load /etc/os-release in the Makefile?

include /etc/os-release

build:
	gcc -DEL_DISTRO=\"$(ID)\" -o test test.c
#include <stdio.h>

int main() {
	printf("distro is %s\n", EL_DISTRO);
}