Include the source code diff in the update module and export it via sysfs.
[ksplice.git] / kmodsrc / primary.c
blob65bb84d1ffe2799458f1af78ff2d595cec72a2f6
1 /* Copyright (C) 2008 Jeffrey Brian Arnold <jbarnold@mit.edu>
3 * This program is free software; you can redistribute it and/or modify
4 * it under the terms of the GNU General Public License, version 2.
6 * This program is distributed in the hope that it will be useful,
7 * but WITHOUT ANY WARRANTY; without even the implied warranty of
8 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
9 * GNU General Public License for more details.
11 * You should have received a copy of the GNU General Public License
12 * along with this program; if not, write to the Free Software
13 * Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, MA
14 * 02110-1301, USA.
17 #ifdef KSPLICE_STANDALONE
18 #include "ksplice.h"
19 #else
20 #include <linux/ksplice.h>
21 #endif
23 MODULE_LICENSE("GPL v2");
25 #undef _STR
26 #define _STR(x) #x
27 #undef STR
28 #define STR(x) _STR(x)
30 #define _PASTE(x, y) x##y
31 #define PASTE(x, y) _PASTE(x, y)
32 #define KSPLICE_UNIQ(s) PASTE(s##_, KSPLICE_ID)
34 extern const struct ksplice_reloc ksplice_relocs[], ksplice_relocs_end[];
35 extern const struct ksplice_size ksplice_sizes[], ksplice_sizes_end[];
36 extern struct ksplice_patch ksplice_patches[], ksplice_patches_end[];
37 extern const char ksplice_source_diff[], ksplice_source_diff_end[];
38 #ifdef KSPLICE_NEED_PARAINSTRUCTIONS
39 extern struct paravirt_patch_site parainstructions[], parainstructions_end[];
40 #endif
42 LIST_HEAD(reloc_addrmaps);
43 LIST_HEAD(reloc_namevals);
44 LIST_HEAD(safety_records);
46 static int debug;
47 module_param(debug, int, 0600);
49 #define pack KSPLICE_UNIQ(pack)
50 struct module_pack pack = {
51 .name = "ksplice_" STR(KSPLICE_ID),
52 #ifdef KSPLICE_TARGET
53 .target_name = STR(KSPLICE_TARGET),
54 #else
55 .target_name = NULL,
56 #endif
57 .target = NULL,
58 .map_printk = MAP_PRINTK,
59 .primary = THIS_MODULE,
60 .primary_relocs = ksplice_relocs,
61 .primary_relocs_end = ksplice_relocs_end,
62 .primary_sizes = ksplice_sizes,
63 .primary_sizes_end = ksplice_sizes_end,
64 .patches = ksplice_patches,
65 .patches_end = ksplice_patches_end,
66 .source_diff = ksplice_source_diff,
67 .source_diff_end = ksplice_source_diff_end,
68 #ifdef KSPLICE_NEED_PARAINSTRUCTIONS
69 .primary_parainstructions = parainstructions,
70 .primary_parainstructions_end = parainstructions_end,
71 #endif
72 .reloc_addrmaps = &reloc_addrmaps,
73 .reloc_namevals = &reloc_namevals,
74 .safety_records = &safety_records,
76 EXPORT_SYMBOL_GPL(pack);
78 static int init_primary(void)
80 pack.debug = &debug;
81 return 0;
84 static void cleanup_primary(void)
86 cleanup_ksplice_module(&pack);
89 #define helper_init_module KSPLICE_UNIQ(helper_init_module)
90 int helper_init_module(void)
92 return init_ksplice_module(&pack);
94 EXPORT_SYMBOL_GPL(helper_init_module);
96 module_init(init_primary);
97 module_exit(cleanup_primary);