Skip to content

Commit

Permalink
Merge pull request #3 from jimin-kiim/assignment-5
Browse files Browse the repository at this point in the history
Assignment 5 Creating and Calling Own System Call
  • Loading branch information
jimin-kiim authored Oct 14, 2023
2 parents 6005afb + d09769e commit c3cac7f
Show file tree
Hide file tree
Showing 5 changed files with 23 additions and 3 deletions.
1 change: 1 addition & 0 deletions linux-5.4.214/include/linux/syscalls.h
Original file line number Diff line number Diff line change
Expand Up @@ -1222,6 +1222,7 @@ asmlinkage long sys_old_mmap(struct mmap_arg_struct __user *arg);
*/
asmlinkage long sys_ni_syscall(void);

asmlinkage long sys_mycall(void);
#endif /* CONFIG_ARCH_HAS_SYSCALL_WRAPPER */


Expand Down
6 changes: 4 additions & 2 deletions linux-5.4.214/include/uapi/asm-generic/unistd.h
Original file line number Diff line number Diff line change
Expand Up @@ -850,10 +850,12 @@ __SYSCALL(__NR_pidfd_open, sys_pidfd_open)
#define __NR_clone3 435
__SYSCALL(__NR_clone3, sys_clone3)
#endif
#define __NR_mycall 460
__SYSCALL(__NR_mycall, sys_mycall)

#undef __NR_syscalls
#define __NR_syscalls 436

//#define __NR_syscalls 436
#define __NR_syscalls 461
/*
* 32 bit systems traditionally used different
* syscalls for off_t and loff_t arguments, while
Expand Down
2 changes: 1 addition & 1 deletion linux-5.4.214/kernel/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ obj-y = fork.o exec_domain.o panic.o \
extable.o params.o \
kthread.o sys_ni.o nsproxy.o \
notifier.o ksysfs.o cred.o reboot.o \
async.o range.o smpboot.o ucount.o
async.o range.o smpboot.o ucount.o my_syscall.o

obj-$(CONFIG_MODULES) += kmod.o
obj-$(CONFIG_MULTIUSER) += groups.o
Expand Down
7 changes: 7 additions & 0 deletions linux-5.4.214/kernel/my_syscall.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
#include <linux/syscalls.h>

SYSCALL_DEFINE0(mycall)
{
printk("System Call Example!\n");
return 0;
}
10 changes: 10 additions & 0 deletions syscall_example.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
#include <stdio.h>
#include <sys/syscall.h>

int main(void)
{
long ret = syscall(460);
printf("System Call returned: %ld\n", ret);

return 0;
}

0 comments on commit c3cac7f

Please sign in to comment.