MODULE_VERSION() macro
Subsystems (2)
PATCH 1/1 MODULE_VERSION() macro
Comments welcome!
Name: Add a MODULE_VERSION macro
Author: Rusty Russell
Depends: Misc/qemu-page-offset.patch.gz
Status: Tested on 2.6.0-test4-bk9
D: At the kernel summit, various people asked for a MODULE_VERSION
D: macro to store module strings (for later access through sysfs).
D: A simple md4 is needed to identify changes in modules which,
D: inevitably, do not update the version. It skips whitespace and
D: comments, and includes #includes in the same dir.
D:
D: The module versions should be set according to this definition,
D: based on the RPM one. Violators will be shot.
D:
D: [<epoch>`:']<version>[`-'<extraversion>] D: <epoch>: A (small) unsigned integer which allows you to start versions D: anew. If not mentioned, it's zero. eg. "2:1.0" is after D: "1:2.0". D: <version>: The <version> may contain only alphanumerics. D: <extraversion>: Like <version>, but inserted for local D: customizations, eg "rh3" or "rusty1".
D:
D: Comparison of two versions (assuming same epoch):
D:
D: Split each into all-digit and all-alphabetical parts. Compare each
D: one one at a time: digit parts numerically, alphabetical in ASCII
D: order.
include/linux/module.h +17 -0
@@ -123,6 +123,23 @@ extern const struct gtype##_id __mod_##g#define MODULE_DEVICE_TABLE (type,name) \ MODULE_GENERIC_TABLE(type##_device,name) +/* Version of form [<epoch>:]<version>[-<extra-version>]. +<epoch>: A (small) unsigned integer which allows you to start versions +anew. If not mentioned, it's zero. eg. "2:1.0" is after +"1:2.0". +<version>: The <version> may contain only alphanumerics and the +character `.'. Ordered by numeric sort for numeric parts, +ascii sort for ascii parts (as per RPM or DEB algorithm). +<extraversion>: Like <version>, but inserted for local +customizations, eg "rh3" or "rusty1". + +Using this automatically adds a checksum of the .c files and the +local headers to the end. Use MODULE_VERSION("") if you want just +this. Macro includes room for this. +*/ +#define MODULE_VERSION (_version) \ + MODULE_INFO(version, _version "\0xxxxxxxxxxxxxxxxxxxxxxxx") +/* Given an address, look for it in the exception tables */ const struct exception_table_entry *search_exception_tables (unsigned long add);
scripts/Makefile +1 -1
@@ -12,7 +12,7 @@ host-progs := fixdep split-include conma mk_elfconfig pnmtologo always := $(host-progs) empty.o -modpost-objs := modpost.o file2alias.o +modpost-objs := modpost.o file2alias.o sumversion.o subdir-$(CONFIG_MODVERSIONS) += genksyms
scripts/Makefile.build +2 -4
@@ -54,8 +54,6 @@ endif # We keep a list of all modules in $(MODVERDIR) -touch-module = @echo $(@:.o=.ko) > $(MODVERDIR)/$(@F:.o=.mod) - __build: $(if $(KBUILD_BUILTIN),$(builtin-target) $(lib-target) $(extra-y)) \ $(if $(KBUILD_MODULES),$(obj-m)) \ $(subdir-ym) $(always)
@@ -168,7 +166,7 @@ endef $(single-used-m): %.o: %.c FORCE $(call if_changed_rule,cc_o_c) - $(touch-module) + @{ echo $(@:.o=.ko); echo $<; } > $(MODVERDIR)/$(@F:.o=.mod) quiet_cmd_cc_lst_c = MKLST $@ cmd_cc_lst_c = $(CC) $(c_flags) -g -c -o $*.o $< && \
@@ -263,7 +261,7 @@ $(multi-used-y) : %.o: $(multi-objs-y) F $(multi-used-m) : %.o: $(multi-objs-m) FORCE $(call if_changed,link_multi-m) - $(touch-module) + @{ echo $(@:.o=.ko); echo $(link_multi_deps:.o=.c); } > $(MODVERDIR)/$(@F:.o=.mod) targets += $(multi-used-y) $(multi-used-m)
scripts/Makefile.modpost +2 -1
@@ -10,10 +10,11 @@ include scripts/Makefile.lib # -__modules := $(shell cat /dev/null $(wildcard $(MODVERDIR)/*.mod)) +__modules := $(shell head -q -n1 /dev/null $(wildcard $(MODVERDIR)/*.mod)) modules := $(patsubst %.o,%.ko,$(wildcard $(__modules:.ko=.o))) ifneq ($(filter-out $(modules),$(__modules)),) + $(warning Trouble: $(__modules) ) $(warning *** Uh-oh, you have stale module entries. You messed with SUBDIRS,) $(warning do not complain if something goes wrong.) endif
scripts/modpost.c +34 -18
105 lines not on this page · raw message
scripts/modpost.h +10 -0
@@ -80,9 +80,19 @@ struct elf_info {Elf_Sym *symtab_start;Elf_Sym *symtab_stop;const char *strtab; +char *modinfo; +unsigned int modinfo_len; };void handle_moddevtable (struct module *mod,struct elf_info *info,Elf_Sym *sym,const char *symname);void add_moddevtable (struct buffer *buf,struct module *mod); + +void maybe_frob_version (const char *modfilename, +void *modinfo, +unsigned long modinfo_len, +unsigned long modinfo_offset); + +void *grab_file (const char *filename,unsigned long *size); +void release_file (void *file,unsigned long size);
scripts/sumversion.c +510 -0
510 lines not on this page · raw message
--
Anyone who quotes me in their sig is an idiot. -- Rusty Russell.