projects/linux·blob master · refs

39 lines · 956 B

1// SPDX-License-Identifier: GPL-2.0
2// Copyright (C) 2026 Pablo Hugen <[email protected]>
3
4#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
5
6#include <linux/module.h>
7#include <linux/kernel.h>
8#include <linux/proc_fs.h>
9#include <linux/seq_file.h>
10
11static struct proc_dir_entry *pde;
12
13static noinline int test_klp_mod_target_show(struct seq_file *m, void *v)
14{
15 seq_printf(m, "%s: %s\n", THIS_MODULE->name, "original output");
16 return 0;
17}
18
19static int test_klp_mod_target_init(void)
20{
21 pr_info("%s\n", __func__);
22 pde = proc_create_single("test_klp_mod_target", 0, NULL,
23 test_klp_mod_target_show);
24 if (!pde)
25 return -ENOMEM;
26 return 0;
27}
28
29static void test_klp_mod_target_exit(void)
30{
31 pr_info("%s\n", __func__);
32 proc_remove(pde);
33}
34
35module_init(test_klp_mod_target_init);
36module_exit(test_klp_mod_target_exit);
37MODULE_LICENSE("GPL");
38MODULE_AUTHOR("Pablo Hugen <[email protected]>");
39MODULE_DESCRIPTION("Livepatch test: target module with proc entry");