diff -urN linux-2.6.5.old/kernel/Makefile linux-2.6.5/kernel/Makefile --- linux-2.6.5.old/kernel/Makefile 2004-05-09 13:07:08.000000000 -0500 +++ linux-2.6.5/kernel/Makefile 2004-05-09 14:10:12.000000000 -0500 @@ -20,6 +20,8 @@ obj-$(CONFIG_COMPAT) += compat.o obj-$(CONFIG_IKCONFIG) += configs.o obj-$(CONFIG_IKCONFIG_PROC) += configs.o +obj-$(CONFIG_IKPATCHES) += patches.o +obj-$(CONFIG_IKPATCHES_PROC) += patches.o obj-$(CONFIG_STOP_MACHINE) += stop_machine.o obj-$(CONFIG_AUDIT) += audit.o obj-$(CONFIG_AUDITSYSCALL) += auditsc.o @@ -62,3 +64,35 @@ targets += config_data.h $(obj)/config_data.h: $(obj)/config_data.gz FORCE $(call if_changed,ikconfiggz) + + + +# patches.o uses generated files - dependecies must be listed explicitly +$(obj)/patches.o: $(obj)/ikpatches.h + +ifdef CONFIG_IKCONFIG_PROC +$(obj)/patches.o: $(obj)/patches_data.h +endif + +# ikpatches.h contains all the kernel's patches data - generated +# from .patches. Info from ikpatches.h can be extracted from the +# kernel binary. + +quiet_cmd_ikpatches = IKCFG $@ + cmd_ikpatches = $(CONFIG_SHELL) $< .patches > $@ + +targets += ikpatches.h +$(obj)/ikpatches.h: scripts/mkpatches .patches FORCE + $(call if_changed,ikpatches) + +# patches_data.h contains the same information as ikpatches.h but gzipped. +# Info from patches_data can be extracted from /proc/patches* +targets += patches_data.gz +$(obj)/patches_data.gz: .patches FORCE + $(call if_changed,gzip) + +quiet_cmd_ikpatchesgz = IKCFG $@ + cmd_ikpatchesgz = cat $< | scripts/bin2c kernel_patches_data > $@ +targets += patches_data.h +$(obj)/patches_data.h: $(obj)/patches_data.gz FORCE + $(call if_changed,ikpatchesgz) diff -urN linux-2.6.5.old/kernel/patches.c linux-2.6.5/kernel/patches.c --- linux-2.6.5.old/kernel/patches.c 1969-12-31 19:00:00.000000000 -0500 +++ linux-2.6.5/kernel/patches.c 2004-05-09 13:49:07.000000000 -0500 @@ -0,0 +1,108 @@ +/* + * kernel/patches.c + * Echo the kernel's .patches file present when building the kernel + * + * Copyright (C) 2004 Jon Oberheide + * Copyright (C) 2002 Khalid Aziz + * Copyright (C) 2002 Randy Dunlap + * Copyright (C) 2002 Al Stone + * Copyright (C) 2002 Hewlett-Packard Company + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or (at + * your option) any later version. + * + * This program is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE, GOOD TITLE or + * NON INFRINGEMENT. See the GNU General Public License for more + * details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + */ + +#include +#include +#include +#include +#include +#include +#include + +/**************************************************/ +/* the actual current .patches file */ + +/* This one is for extraction from the kernel binary file image. */ +#include "ikpatches.h" + +#ifdef CONFIG_IKPATCHES_PROC + +/* This is the data that can be read from /proc/patches.gz. */ +#include "patches_data.h" + +/**************************************************/ +/* globals and useful constants */ + +static const char IKPATCHES_VERSION[] __initdata = "0.7"; + +static ssize_t +ikpatches_read_current(struct file *file, char __user *buf, + size_t len, loff_t * offset) +{ + loff_t pos = *offset; + ssize_t count; + + if (pos >= kernel_patches_data_size) + return 0; + + count = min(len, (size_t)(kernel_patches_data_size - pos)); + if(copy_to_user(buf, kernel_patches_data + pos, count)) + return -EFAULT; + + *offset += count; + return count; +} + +static struct file_operations ikpatches_file_ops = { + .owner = THIS_MODULE, + .read = ikpatches_read_current, +}; + +/***************************************************/ +/* ikpatches_init: start up everything we need to */ + +static int __init ikpatches_init(void) +{ + struct proc_dir_entry *entry; + + /* create the current patches file */ + entry = create_proc_entry("patches.gz", S_IFREG | S_IRUGO, + &proc_root); + if (!entry) + return -ENOMEM; + + entry->proc_fops = &ikpatches_file_ops; + entry->size = kernel_patches_data_size; + + return 0; +} + +/***************************************************/ +/* ikpatches_cleanup: clean up our mess */ + +static void __exit ikpatches_cleanup(void) +{ + remove_proc_entry("patches.gz", &proc_root); +} + +module_init(ikpatches_init); +module_exit(ikpatches_cleanup); + +MODULE_LICENSE("GPL"); +MODULE_AUTHOR("Jon Oberheide"); +MODULE_DESCRIPTION("Echo the kernel's .patches file present while building the kernel"); + +#endif /* CONFIG_IKPATCHES_PROC */