Skip to content

Instantly share code, notes, and snippets.

@paranlee
Last active December 1, 2021 13:14
Show Gist options
  • Select an option

  • Save paranlee/e20c80b69e2e38878715305248b24446 to your computer and use it in GitHub Desktop.

Select an option

Save paranlee/e20c80b69e2e38878715305248b24446 to your computer and use it in GitHub Desktop.
/* https://elixir.bootlin.com/linux/v5.14.13/source/fs/open.c#L1224 */
SYSCALL_DEFINE3(open, const char __user *, filename, int, flags, umode_t, mode)
{
if (force_o_largefile())
flags |= O_LARGEFILE;
return do_sys_open(AT_FDCWD, filename, flags, mode);
}
/* /include/linux/syscalls.h::SYSCALL_DEFINE3 */
#define SYSCALL_DEFINE3(name, ...) SYSCALL_DEFINEx(3, _##name, __VA_ARGS__)
/* /include/linux/syscalls.h::SYSCALL_DEFINEx */
#define SYSCALL_DEFINEx(x, sname, ...) \
__SYSCALL_DEFINEx(x, sname, __VA_ARGS__)
#endif
/* /include/linux/syscalls.h::__SYSCALL_DEFINEx */
#define __SYSCALL_DEFINEx(x, name, ...) \
asmlinkage long sys##name(__SC_DECL##x(__VA_ARGS__)); \
static inline long SYSC##name(__SC_DECL##x(__VA_ARGS__)); \
asmlinkage long SyS##name(__SC_LONG##x(__VA_ARGS__)) \
{ \
__SC_TEST##x(__VA_ARGS__); \
return (long) SYSC##name(__SC_CAST##x(__VA_ARGS__)); \
} \
SYSCALL_ALIAS(sys##name, SyS##name); \
static inline long SYSC##name(__SC_DECL##x(__VA_ARGS__))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment