1

Lets say I have a user-defined syscall: foo (with code number 500).

To call it, I simply write in a C file:

syscall(SYS_code, args);

How can I call it using just foo(args)?

Marco Bonelli
  • 63,369
  • 21
  • 118
  • 128
Neeecu
  • 23
  • 1
  • 4
  • "How can I call it using just foo(args)?" - Create a function `foo`, which performs required system call. So other code could simply call `foo`. – Tsyvarev Oct 27 '20 at 21:39

1 Answers1

2

You cannot. Not unless you first convince the kernel developers that your syscall is worth being added, then it gets added, and then userspace libraries such as the standard C library (glibc on most Linux distributions) decide to implement a wrapper for it like they do for most of the syscalls.

In other words: since the above is impossible, all you can do is define the wrapper function yourself in your own program.

#define SYS_foo 500

long foo(int a, char *b) {
    return syscall(SYS_foo, a, b);
}
Marco Bonelli
  • 63,369
  • 21
  • 118
  • 128