Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- From 3c3820f88d5315af4c52b5f30d749c9d315fef61 Mon Sep 17 00:00:00 2001
- From: student <student@ReliableEmbeddedSystems.com>
- Date: Wed, 27 Sep 2017 07:34:41 -0500
- Subject: [PATCH] introduce new syscall
- Signed-off-by: student <student@ReliableEmbeddedSystems.com>
- ---
- arch/x86/entry/syscalls/syscall_32.tbl | 1 +
- arch/x86/entry/syscalls/syscall_64.tbl | 1 +
- kernel/sys.c | 19 +++++++++++++++++++
- 3 files changed, 21 insertions(+)
- diff --git a/arch/x86/entry/syscalls/syscall_32.tbl b/arch/x86/entry/syscalls/syscall_32.tbl
- index 448ac21..0a54704 100644
- --- a/arch/x86/entry/syscalls/syscall_32.tbl
- +++ b/arch/x86/entry/syscalls/syscall_32.tbl
- @@ -391,3 +391,4 @@
- 382 i386 pkey_free sys_pkey_free
- 383 i386 statx sys_statx
- 384 i386 arch_prctl sys_arch_prctl compat_sys_arch_prctl
- +385 i386 my_syscall sys_my_syscall
- diff --git a/arch/x86/entry/syscalls/syscall_64.tbl b/arch/x86/entry/syscalls/syscall_64.tbl
- index 5aef183..6ac6529 100644
- --- a/arch/x86/entry/syscalls/syscall_64.tbl
- +++ b/arch/x86/entry/syscalls/syscall_64.tbl
- @@ -339,6 +339,7 @@
- 330 common pkey_alloc sys_pkey_alloc
- 331 common pkey_free sys_pkey_free
- 332 common statx sys_statx
- +333 common my_syscall sys_my_syscall
- #
- # x32-specific system call numbers start at 512 to avoid cache impact
- diff --git a/kernel/sys.c b/kernel/sys.c
- index 2855ee7..ab5d7ef 100644
- --- a/kernel/sys.c
- +++ b/kernel/sys.c
- @@ -2552,3 +2552,22 @@ COMPAT_SYSCALL_DEFINE1(sysinfo, struct compat_sysinfo __user *, info)
- return 0;
- }
- #endif /* CONFIG_COMPAT */
- +
- +
- +/* Adding a dynamical system call */
- +struct my_sc_struct {
- + long (*fun)(unsigned long p1);
- +} my_sc = {
- + NULL};
- +EXPORT_SYMBOL(my_sc);
- +
- +SYSCALL_DEFINE1(my_syscall, unsigned long, p1)
- +{
- + struct my_sc_struct *s = (struct my_sc_struct *)&my_sc;
- +
- + pr_info("Entering my_syscall with p1 = %ld at jiffies=%ld\n",
- + p1, jiffies);
- + if (!s || !s->fun)
- + return -ENOSYS;
- + return s->fun(p1);
- +}
- --
- 2.11.0
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement