Skip to contentSkip to conversation

backports: add backport version to all modules

PATCH In review Johannes Berg 2 participants 2 messages Apr 9, 2013

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 backports: add backport version to all modules

From: Johannes Berg <[email protected]>

We print out the backports version at runtime, but it can also be useful to be able to determine it from the installed modules.

As we already override module_init() to make all our backported modules depend on compat.ko (in order to do exactly this -- print out the version at runtime) also add some MODULE_VERSION directives to it.

This results in, for example for mac80211, this:

$ /sbin/modinfo .../net/mac80211/mac80211.ko
filename:       .../net/mac80211/mac80211.ko
license:        GPL
description:    IEEE 802.11 subsystem
version:        backported from: Linux (next-20130405-0-g7df052b)
version:        backports: 6e0475b
srcversion:     6C298E6033E34EA8E223D7B
depends:        cfg80211,compat
vermagic:       3.8.0 SMP mod_unload modversions
parm:           max_nullfunc_tries:Maximum nullfunc tx tries before disconnecting (reason 4). (int)
parm:           max_probe_tries:Maximum probe tries before disconnecting (reason 4). (int)
parm:           probe_wait_ms:Maximum time(ms) to wait for probe response before disconnecting (reason 4). (int)
parm:           ieee80211_default_rc_algo:Default rate control algorithm for mac80211 to use (charp)
---
 backport/Makefile.kernel            | 3 +++
 backport/compat/Makefile            | 3 ---
 backport/include/linux/compat-2.6.h | 6 +++++-
 3 files changed, 8 insertions(+), 4 deletions(-)
backport/Makefile.kernel +3 -0
index 4d00bda..54a1218 100644
@@ -9,6 +9,9 @@ NOSTDINC_FLAGS := \
 	-I$(M)/include/drm \
 	-include $(M)/include/linux/compat-2.6.h \
 	$(call backport-cc-disable-warning, unused-but-set-variable) \
+	-DBACKPORTS_VERSION=\"$(BACKPORTS_VERSION)\" \
+	-DBACKPORTED_KERNEL_VERSION=\"$(BACKPORTED_KERNEL_VERSION)\" \
+	-DBACKPORTED_KERNEL_NAME=\"$(BACKPORTED_KERNEL_NAME)\" \
 	$(CFLAGS)
 
 obj-y += compat/
backport/compat/Makefile +0 -3
index 62dd531..499d4c0 100644
@@ -1,7 +1,4 @@
 ccflags-y += -I$(src)
-ccflags-y += -DBACKPORTS_VERSION=\"$(BACKPORTS_VERSION)\"
-ccflags-y += -DBACKPORTED_KERNEL_VERSION=\"$(BACKPORTED_KERNEL_VERSION)\"
-ccflags-y += -DBACKPORTED_KERNEL_NAME=\"$(BACKPORTED_KERNEL_NAME)\"
 obj-m += compat.o
 compat-y += main.o
 
backport/include/linux/compat-2.6.h +5 -1
index 57a1c13..408fc60 100644
@@ -38,7 +38,11 @@ void backport_dependency_symbol(void);
 		backport_dependency_symbol();				\
 		return initfn();					\
 	}								\
-	int init_module(void) __attribute__((alias("__init_backport")));
+	int init_module(void) __attribute__((alias("__init_backport")));\
+	MODULE_VERSION("backports: " BACKPORTS_VERSION);		\
+	MODULE_VERSION("backported from: " 				\
+			BACKPORTED_KERNEL_NAME " ("			\
+			BACKPORTED_KERNEL_VERSION ")");
 
 /*
  * Each compat file represents compatibility code for new kernel
Signature · 1 line
1.8.0
#1 lore raw
Quoted 27 lines · Johannes Berg

From: Johannes Berg <[email protected]>

We print out the backports version at runtime, but it can also be useful to be able to determine it from the installed modules.

As we already override module_init() to make all our backported modules depend on compat.ko (in order to do exactly this -- print out the version at runtime) also add some MODULE_VERSION directives to it.

This results in, for example for mac80211, this:

$ /sbin/modinfo .../net/mac80211/mac80211.ko
filename:       .../net/mac80211/mac80211.ko
license:        GPL
description:    IEEE 802.11 subsystem
version:        backported from: Linux (next-20130405-0-g7df052b)
version:        backports: 6e0475b
srcversion:     6C298E6033E34EA8E223D7B
depends:        cfg80211,compat
vermagic:       3.8.0 SMP mod_unload modversions
parm:           max_nullfunc_tries:Maximum nullfunc tx tries before disconnecting (reason 4). (int)
parm:           max_probe_tries:Maximum probe tries before disconnecting (reason 4). (int)
parm:           probe_wait_ms:Maximum time(ms) to wait for probe response before disconnecting (reason 4). (int)
parm:           ieee80211_default_rc_algo:Default rate control algorithm for mac80211 to use (charp)
Quoted 1 line

Fuck-yeah: Luis R. Rodriguez <[email protected]>

Luis