11 #ifndef _LINUX_SYSCALLS_H
12 #define _LINUX_SYSCALLS_H
26 struct mmap_arg_struct;
41 struct sel_arg_struct;
63 struct old_linux_dirent;
67 #include <linux/types.h>
69 #include <linux/capability.h>
70 #include <linux/list.h>
72 #include <linux/sem.h>
73 #include <asm/siginfo.h>
74 #include <asm/signal.h>
76 #include <linux/quota.h>
80 #define __SC_DECL1(t1, a1) t1 a1
81 #define __SC_DECL2(t2, a2, ...) t2 a2, __SC_DECL1(__VA_ARGS__)
82 #define __SC_DECL3(t3, a3, ...) t3 a3, __SC_DECL2(__VA_ARGS__)
83 #define __SC_DECL4(t4, a4, ...) t4 a4, __SC_DECL3(__VA_ARGS__)
84 #define __SC_DECL5(t5, a5, ...) t5 a5, __SC_DECL4(__VA_ARGS__)
85 #define __SC_DECL6(t6, a6, ...) t6 a6, __SC_DECL5(__VA_ARGS__)
87 #define __SC_LONG1(t1, a1) long a1
88 #define __SC_LONG2(t2, a2, ...) long a2, __SC_LONG1(__VA_ARGS__)
89 #define __SC_LONG3(t3, a3, ...) long a3, __SC_LONG2(__VA_ARGS__)
90 #define __SC_LONG4(t4, a4, ...) long a4, __SC_LONG3(__VA_ARGS__)
91 #define __SC_LONG5(t5, a5, ...) long a5, __SC_LONG4(__VA_ARGS__)
92 #define __SC_LONG6(t6, a6, ...) long a6, __SC_LONG5(__VA_ARGS__)
94 #define __SC_CAST1(t1, a1) (t1) a1
95 #define __SC_CAST2(t2, a2, ...) (t2) a2, __SC_CAST1(__VA_ARGS__)
96 #define __SC_CAST3(t3, a3, ...) (t3) a3, __SC_CAST2(__VA_ARGS__)
97 #define __SC_CAST4(t4, a4, ...) (t4) a4, __SC_CAST3(__VA_ARGS__)
98 #define __SC_CAST5(t5, a5, ...) (t5) a5, __SC_CAST4(__VA_ARGS__)
99 #define __SC_CAST6(t6, a6, ...) (t6) a6, __SC_CAST5(__VA_ARGS__)
101 #define __SC_TEST(type) BUILD_BUG_ON(sizeof(type) > sizeof(long))
102 #define __SC_TEST1(t1, a1) __SC_TEST(t1)
103 #define __SC_TEST2(t2, a2, ...) __SC_TEST(t2); __SC_TEST1(__VA_ARGS__)
104 #define __SC_TEST3(t3, a3, ...) __SC_TEST(t3); __SC_TEST2(__VA_ARGS__)
105 #define __SC_TEST4(t4, a4, ...) __SC_TEST(t4); __SC_TEST3(__VA_ARGS__)
106 #define __SC_TEST5(t5, a5, ...) __SC_TEST(t5); __SC_TEST4(__VA_ARGS__)
107 #define __SC_TEST6(t6, a6, ...) __SC_TEST(t6); __SC_TEST5(__VA_ARGS__)
109 #ifdef CONFIG_FTRACE_SYSCALLS
110 #define __SC_STR_ADECL1(t, a) #a
111 #define __SC_STR_ADECL2(t, a, ...) #a, __SC_STR_ADECL1(__VA_ARGS__)
112 #define __SC_STR_ADECL3(t, a, ...) #a, __SC_STR_ADECL2(__VA_ARGS__)
113 #define __SC_STR_ADECL4(t, a, ...) #a, __SC_STR_ADECL3(__VA_ARGS__)
114 #define __SC_STR_ADECL5(t, a, ...) #a, __SC_STR_ADECL4(__VA_ARGS__)
115 #define __SC_STR_ADECL6(t, a, ...) #a, __SC_STR_ADECL5(__VA_ARGS__)
117 #define __SC_STR_TDECL1(t, a) #t
118 #define __SC_STR_TDECL2(t, a, ...) #t, __SC_STR_TDECL1(__VA_ARGS__)
119 #define __SC_STR_TDECL3(t, a, ...) #t, __SC_STR_TDECL2(__VA_ARGS__)
120 #define __SC_STR_TDECL4(t, a, ...) #t, __SC_STR_TDECL3(__VA_ARGS__)
121 #define __SC_STR_TDECL5(t, a, ...) #t, __SC_STR_TDECL4(__VA_ARGS__)
122 #define __SC_STR_TDECL6(t, a, ...) #t, __SC_STR_TDECL5(__VA_ARGS__)
129 #define SYSCALL_TRACE_ENTER_EVENT(sname) \
130 static struct syscall_metadata __syscall_meta_##sname; \
131 static struct ftrace_event_call __used \
132 event_enter_##sname = { \
133 .name = "sys_enter"#sname, \
134 .class = &event_class_syscall_enter, \
135 .event.funcs = &enter_syscall_print_funcs, \
136 .data = (void *)&__syscall_meta_##sname,\
137 .flags = TRACE_EVENT_FL_CAP_ANY, \
139 static struct ftrace_event_call __used \
140 __attribute__((section("_ftrace_events"))) \
141 *__event_enter_##sname = &event_enter_##sname;
143 #define SYSCALL_TRACE_EXIT_EVENT(sname) \
144 static struct syscall_metadata __syscall_meta_##sname; \
145 static struct ftrace_event_call __used \
146 event_exit_##sname = { \
147 .name = "sys_exit"#sname, \
148 .class = &event_class_syscall_exit, \
149 .event.funcs = &exit_syscall_print_funcs, \
150 .data = (void *)&__syscall_meta_##sname,\
151 .flags = TRACE_EVENT_FL_CAP_ANY, \
153 static struct ftrace_event_call __used \
154 __attribute__((section("_ftrace_events"))) \
155 *__event_exit_##sname = &event_exit_##sname;
157 #define SYSCALL_METADATA(sname, nb) \
158 SYSCALL_TRACE_ENTER_EVENT(sname); \
159 SYSCALL_TRACE_EXIT_EVENT(sname); \
160 static struct syscall_metadata __used \
161 __syscall_meta_##sname = { \
162 .name = "sys"#sname, \
165 .types = types_##sname, \
166 .args = args_##sname, \
167 .enter_event = &event_enter_##sname, \
168 .exit_event = &event_exit_##sname, \
169 .enter_fields = LIST_HEAD_INIT(__syscall_meta_##sname.enter_fields), \
171 static struct syscall_metadata __used \
172 __attribute__((section("__syscalls_metadata"))) \
173 *__p_syscall_meta_##sname = &__syscall_meta_##sname;
175 #define SYSCALL_DEFINE0(sname) \
176 SYSCALL_TRACE_ENTER_EVENT(_##sname); \
177 SYSCALL_TRACE_EXIT_EVENT(_##sname); \
178 static struct syscall_metadata __used \
179 __syscall_meta__##sname = { \
180 .name = "sys_"#sname, \
183 .enter_event = &event_enter__##sname, \
184 .exit_event = &event_exit__##sname, \
185 .enter_fields = LIST_HEAD_INIT(__syscall_meta__##sname.enter_fields), \
187 static struct syscall_metadata __used \
188 __attribute__((section("__syscalls_metadata"))) \
189 *__p_syscall_meta_##sname = &__syscall_meta__##sname; \
190 asmlinkage long sys_##sname(void)
192 #define SYSCALL_DEFINE0(name) asmlinkage long sys_##name(void)
195 #define SYSCALL_DEFINE1(name, ...) SYSCALL_DEFINEx(1, _##name, __VA_ARGS__)
196 #define SYSCALL_DEFINE2(name, ...) SYSCALL_DEFINEx(2, _##name, __VA_ARGS__)
197 #define SYSCALL_DEFINE3(name, ...) SYSCALL_DEFINEx(3, _##name, __VA_ARGS__)
198 #define SYSCALL_DEFINE4(name, ...) SYSCALL_DEFINEx(4, _##name, __VA_ARGS__)
199 #define SYSCALL_DEFINE5(name, ...) SYSCALL_DEFINEx(5, _##name, __VA_ARGS__)
200 #define SYSCALL_DEFINE6(name, ...) SYSCALL_DEFINEx(6, _##name, __VA_ARGS__)
203 #define SYSCALL_ALIAS(alias, name) \
204 asm ("\t.globl " #alias "\n\t.set " #alias ", " #name "\n" \
205 "\t.globl ." #alias "\n\t.set ." #alias ", ." #name)
207 #if defined(CONFIG_ALPHA) || defined(CONFIG_MIPS)
208 #define SYSCALL_ALIAS(alias, name) \
209 asm ( #alias " = " #name "\n\t.globl " #alias)
211 #define SYSCALL_ALIAS(alias, name) \
212 asm ("\t.globl " #alias "\n\t.set " #alias ", " #name)
216 #ifdef CONFIG_FTRACE_SYSCALLS
217 #define SYSCALL_DEFINEx(x, sname, ...) \
218 static const char *types_##sname[] = { \
219 __SC_STR_TDECL##x(__VA_ARGS__) \
221 static const char *args_##sname[] = { \
222 __SC_STR_ADECL##x(__VA_ARGS__) \
224 SYSCALL_METADATA(sname, x); \
225 __SYSCALL_DEFINEx(x, sname, __VA_ARGS__)
227 #define SYSCALL_DEFINEx(x, sname, ...) \
228 __SYSCALL_DEFINEx(x, sname, __VA_ARGS__)
231 #ifdef CONFIG_HAVE_SYSCALL_WRAPPERS
233 #define SYSCALL_DEFINE(name) static inline long SYSC_##name
235 #define __SYSCALL_DEFINEx(x, name, ...) \
236 asmlinkage long sys##name(__SC_DECL##x(__VA_ARGS__)); \
237 static inline long SYSC##name(__SC_DECL##x(__VA_ARGS__)); \
238 asmlinkage long SyS##name(__SC_LONG##x(__VA_ARGS__)) \
240 __SC_TEST##x(__VA_ARGS__); \
241 return (long) SYSC##name(__SC_CAST##x(__VA_ARGS__)); \
243 SYSCALL_ALIAS(sys##name, SyS##name); \
244 static inline long SYSC##name(__SC_DECL##x(__VA_ARGS__))
248 #define SYSCALL_DEFINE(name) asmlinkage long sys_##name
249 #define __SYSCALL_DEFINEx(x, name, ...) \
250 asmlinkage long sys##name(__SC_DECL##x(__VA_ARGS__))
307 struct sigevent __user *timer_event_spec,
308 timer_t __user * created_timer_id);
337 unsigned long __user *user_mask_ptr);
339 unsigned long __user *user_mask_ptr);
354 unsigned long flags);
370 const char __user *uargs);
375 sigset_t __user *oset,
size_t sigsetsize);
417 struct stat __user *statbuf);
419 struct stat __user *statbuf);
422 #if BITS_PER_LONG == 32
424 struct stat64 __user *statbuf);
427 struct stat64 __user *statbuf);
450 const char __user *
name);
452 const char __user *
name);
459 unsigned long old_len,
unsigned long new_len,
460 unsigned long flags,
unsigned long new_addr);
462 unsigned long prot,
unsigned long pgoff,
463 unsigned long flags);
474 unsigned char __user * vec);
477 const char __user *put_old);
482 const char __user *newname);
486 const char __user *newname);
491 #if BITS_PER_LONG == 32
493 unsigned int cmd,
unsigned long arg);
512 struct iocb __user * __user *);
520 char __user *
buf,
int bufsiz);
540 asmlinkage long sys_setreuid16(old_uid_t ruid, old_uid_t euid);
542 asmlinkage long sys_setresuid16(old_uid_t ruid, old_uid_t euid, old_uid_t suid);
543 asmlinkage long sys_getresuid16(old_uid_t __user *ruid,
544 old_uid_t __user *euid, old_uid_t __user *suid);
545 asmlinkage long sys_setresgid16(old_gid_t
rgid, old_gid_t egid, old_gid_t sgid);
547 old_gid_t __user *egid, old_gid_t __user *sgid);
550 asmlinkage long sys_getgroups16(
int gidsetsize, old_gid_t __user *grouplist);
551 asmlinkage long sys_setgroups16(
int gidsetsize, old_gid_t __user *grouplist);
561 struct timeval __user *utimes);
570 const struct iovec __user *vec,
575 const struct iovec __user *vec,
582 unsigned long vlen,
unsigned long pos_l,
unsigned long pos_h);
584 unsigned long vlen,
unsigned long pos_l,
unsigned long pos_h);
601 char __user *optval,
int optlen);
603 char __user *optval,
int __user *optlen);
615 unsigned int vlen,
unsigned flags);
618 struct sockaddr __user *,
int __user *);
621 unsigned int vlen,
unsigned flags,
637 int maxevents,
int timeout);
639 int maxevents,
int timeout,
650 struct rlimit __user *rlim);
651 #if defined(COMPAT_RLIM_OLD_INFINITY) || !(defined(CONFIG_IA64))
655 struct rlimit __user *rlim);
657 const struct rlimit64 __user *new_rlim,
664 size_t msgsz,
int msgflg);
666 size_t msgsz,
long msgtyp,
int msgflg);
675 const struct timespec __user *timeout);
681 unsigned long third,
void __user *
ptr,
long fifth);
692 unsigned long off,
unsigned long len,
695 unsigned long off,
unsigned long len,
699 unsigned long arg4,
unsigned long arg5);
705 unsigned long arg1,
unsigned long arg2);
713 const char __user *_description,
714 const void __user *_payload,
716 key_serial_t destringid);
719 const char __user *_description,
720 const char __user *_callout_info,
721 key_serial_t destringid);
724 unsigned long arg4,
unsigned long arg5);
729 unsigned long maxnode);
731 const unsigned long __user *
from,
732 const unsigned long __user *to);
734 const void __user * __user *
pages,
735 const int __user *nodes,
740 unsigned long __user *nmask,
741 unsigned long maxnode,
744 unsigned long __user *nmask,
745 unsigned long maxnode,
746 unsigned long addr,
unsigned long flags);
755 __u32 __user *ustatus);
764 int newdfd,
const char __user * newname);
766 int newdfd,
const char __user *newname,
int flags);
768 int newdfd,
const char __user * newname);
770 struct timeval __user *utimes);
779 struct stat __user *statbuf,
int flag);
789 int fd_out, loff_t __user *off_out,
790 size_t len,
unsigned int flags);
793 unsigned long nr_segs,
unsigned int flags);
803 size_t __user *len_ptr);
830 #ifndef CONFIG_GENERIC_KERNEL_EXECVE
833 #define kernel_execve(filename, argv, envp) \
834 do_execve(filename, \
835 (const char __user *const __user *)argv, \
836 (const char __user *const __user *)envp, \
846 unsigned long prot,
unsigned long flags,
847 unsigned long fd,
unsigned long pgoff);
851 int __user *mnt_id,
int flag);
857 const struct iovec __user *lvec,
858 unsigned long liovcnt,
859 const struct iovec __user *rvec,
860 unsigned long riovcnt,
861 unsigned long flags);
863 const struct iovec __user *lvec,
864 unsigned long liovcnt,
865 const struct iovec __user *rvec,
866 unsigned long riovcnt,
867 unsigned long flags);
870 unsigned long idx1,
unsigned long idx2);