blob: 3fd2194ff57324670062c5cfc12f95d05fd75f22 [file] [log] [blame]
Linus Torvalds1da177e2005-04-16 15:20:36 -07001#ifndef _LINUX_COMPAT_H
2#define _LINUX_COMPAT_H
3/*
4 * These are the type definitions for the architecture specific
5 * syscall compatibility layer.
6 */
Linus Torvalds1da177e2005-04-16 15:20:36 -07007
8#ifdef CONFIG_COMPAT
9
10#include <linux/stat.h>
11#include <linux/param.h> /* for HZ */
12#include <linux/sem.h>
13
14#include <asm/compat.h>
15#include <asm/siginfo.h>
David Howells3f2e05e2006-10-02 14:12:31 +010016#include <asm/signal.h>
Linus Torvalds1da177e2005-04-16 15:20:36 -070017
18#define compat_jiffies_to_clock_t(x) \
19 (((unsigned long)(x) * COMPAT_USER_HZ) / HZ)
20
Stephen Rothwell202e5972005-09-06 15:16:40 -070021typedef __compat_uid32_t compat_uid_t;
22typedef __compat_gid32_t compat_gid_t;
23
Linus Torvalds1da177e2005-04-16 15:20:36 -070024struct rusage;
25
26struct compat_itimerspec {
27 struct compat_timespec it_interval;
28 struct compat_timespec it_value;
29};
30
31struct compat_utimbuf {
32 compat_time_t actime;
33 compat_time_t modtime;
34};
35
36struct compat_itimerval {
37 struct compat_timeval it_interval;
38 struct compat_timeval it_value;
39};
40
41struct compat_tms {
42 compat_clock_t tms_utime;
43 compat_clock_t tms_stime;
44 compat_clock_t tms_cutime;
45 compat_clock_t tms_cstime;
46};
47
Stephen Rothwell88959ea2006-03-26 01:37:27 -080048struct compat_timex {
49 compat_uint_t modes;
50 compat_long_t offset;
51 compat_long_t freq;
52 compat_long_t maxerror;
53 compat_long_t esterror;
54 compat_int_t status;
55 compat_long_t constant;
56 compat_long_t precision;
57 compat_long_t tolerance;
58 struct compat_timeval time;
59 compat_long_t tick;
60 compat_long_t ppsfreq;
61 compat_long_t jitter;
62 compat_int_t shift;
63 compat_long_t stabil;
64 compat_long_t jitcnt;
65 compat_long_t calcnt;
66 compat_long_t errcnt;
67 compat_long_t stbcnt;
Roman Zippel153b5d02008-05-01 04:34:37 -070068 compat_int_t tai;
Stephen Rothwell88959ea2006-03-26 01:37:27 -080069
70 compat_int_t :32; compat_int_t :32; compat_int_t :32; compat_int_t :32;
71 compat_int_t :32; compat_int_t :32; compat_int_t :32; compat_int_t :32;
Roman Zippel153b5d02008-05-01 04:34:37 -070072 compat_int_t :32; compat_int_t :32; compat_int_t :32;
Stephen Rothwell88959ea2006-03-26 01:37:27 -080073};
74
Linus Torvalds1da177e2005-04-16 15:20:36 -070075#define _COMPAT_NSIG_WORDS (_COMPAT_NSIG / _COMPAT_NSIG_BPW)
76
77typedef struct {
78 compat_sigset_word sig[_COMPAT_NSIG_WORDS];
79} compat_sigset_t;
80
Linus Torvalds1da177e2005-04-16 15:20:36 -070081extern int get_compat_timespec(struct timespec *, const struct compat_timespec __user *);
82extern int put_compat_timespec(const struct timespec *, struct compat_timespec __user *);
83
84struct compat_iovec {
85 compat_uptr_t iov_base;
86 compat_size_t iov_len;
87};
88
89struct compat_rlimit {
90 compat_ulong_t rlim_cur;
91 compat_ulong_t rlim_max;
92};
93
94struct compat_rusage {
95 struct compat_timeval ru_utime;
96 struct compat_timeval ru_stime;
97 compat_long_t ru_maxrss;
98 compat_long_t ru_ixrss;
99 compat_long_t ru_idrss;
100 compat_long_t ru_isrss;
101 compat_long_t ru_minflt;
102 compat_long_t ru_majflt;
103 compat_long_t ru_nswap;
104 compat_long_t ru_inblock;
105 compat_long_t ru_oublock;
106 compat_long_t ru_msgsnd;
107 compat_long_t ru_msgrcv;
108 compat_long_t ru_nsignals;
109 compat_long_t ru_nvcsw;
110 compat_long_t ru_nivcsw;
111};
112
113extern int put_compat_rusage(const struct rusage *, struct compat_rusage __user *);
114
115struct compat_siginfo;
116
117extern asmlinkage long compat_sys_waitid(int, compat_pid_t,
118 struct compat_siginfo __user *, int,
119 struct compat_rusage __user *);
120
121struct compat_dirent {
122 u32 d_ino;
123 compat_off_t d_off;
124 u16 d_reclen;
125 char d_name[256];
126};
127
128typedef union compat_sigval {
129 compat_int_t sival_int;
130 compat_uptr_t sival_ptr;
131} compat_sigval_t;
132
133#define COMPAT_SIGEV_PAD_SIZE ((SIGEV_MAX_SIZE/sizeof(int)) - 3)
134
135typedef struct compat_sigevent {
136 compat_sigval_t sigev_value;
137 compat_int_t sigev_signo;
138 compat_int_t sigev_notify;
139 union {
140 compat_int_t _pad[COMPAT_SIGEV_PAD_SIZE];
141 compat_int_t _tid;
142
143 struct {
144 compat_uptr_t _function;
145 compat_uptr_t _attribute;
146 } _sigev_thread;
147 } _sigev_un;
148} compat_sigevent_t;
149
Ingo Molnar34f192c2006-03-27 01:16:24 -0800150struct compat_robust_list {
151 compat_uptr_t next;
152};
153
154struct compat_robust_list_head {
155 struct compat_robust_list list;
156 compat_long_t futex_offset;
157 compat_uptr_t list_op_pending;
158};
159
160extern void compat_exit_robust_list(struct task_struct *curr);
161
162asmlinkage long
163compat_sys_set_robust_list(struct compat_robust_list_head __user *head,
164 compat_size_t len);
165asmlinkage long
Al Viroba46df92006-10-10 22:46:07 +0100166compat_sys_get_robust_list(int pid, compat_uptr_t __user *head_ptr,
Ingo Molnar34f192c2006-03-27 01:16:24 -0800167 compat_size_t __user *len_ptr);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700168
169long compat_sys_semctl(int first, int second, int third, void __user *uptr);
170long compat_sys_msgsnd(int first, int second, int third, void __user *uptr);
171long compat_sys_msgrcv(int first, int second, int msgtyp, int third,
172 int version, void __user *uptr);
173long compat_sys_msgctl(int first, int second, void __user *uptr);
174long compat_sys_shmat(int first, int second, compat_uptr_t third, int version,
175 void __user *uptr);
176long compat_sys_shmctl(int first, int second, void __user *uptr);
177long compat_sys_semtimedop(int semid, struct sembuf __user *tsems,
178 unsigned nsems, const struct compat_timespec __user *timeout);
179asmlinkage long compat_sys_keyctl(u32 option,
180 u32 arg2, u32 arg3, u32 arg4, u32 arg5);
181
182asmlinkage ssize_t compat_sys_readv(unsigned long fd,
183 const struct compat_iovec __user *vec, unsigned long vlen);
184asmlinkage ssize_t compat_sys_writev(unsigned long fd,
185 const struct compat_iovec __user *vec, unsigned long vlen);
186
187int compat_do_execve(char * filename, compat_uptr_t __user *argv,
188 compat_uptr_t __user *envp, struct pt_regs * regs);
189
190asmlinkage long compat_sys_select(int n, compat_ulong_t __user *inp,
191 compat_ulong_t __user *outp, compat_ulong_t __user *exp,
192 struct compat_timeval __user *tvp);
193
Thomas Gleixnerc202f292008-01-30 13:30:08 +0100194asmlinkage long compat_sys_wait4(compat_pid_t pid,
Al Viro7d61c452008-03-29 03:09:28 +0000195 compat_uint_t __user *stat_addr, int options,
196 struct compat_rusage __user *ru);
Thomas Gleixnerc202f292008-01-30 13:30:08 +0100197
Linus Torvalds1da177e2005-04-16 15:20:36 -0700198#define BITS_PER_COMPAT_LONG (8*sizeof(compat_long_t))
199
200#define BITS_TO_COMPAT_LONGS(bits) \
201 (((bits)+BITS_PER_COMPAT_LONG-1)/BITS_PER_COMPAT_LONG)
202
Stephen Rothwell5fa38392006-10-28 10:38:46 -0700203long compat_get_bitmap(unsigned long *mask, const compat_ulong_t __user *umask,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700204 unsigned long bitmap_size);
205long compat_put_bitmap(compat_ulong_t __user *umask, unsigned long *mask,
206 unsigned long bitmap_size);
207int copy_siginfo_from_user32(siginfo_t *to, struct compat_siginfo __user *from);
208int copy_siginfo_to_user32(struct compat_siginfo __user *to, siginfo_t *from);
209int get_compat_sigevent(struct sigevent *event,
210 const struct compat_sigevent __user *u_event);
211
Andrew Morton643a6542006-02-11 17:55:52 -0800212static inline int compat_timeval_compare(struct compat_timeval *lhs,
213 struct compat_timeval *rhs)
214{
215 if (lhs->tv_sec < rhs->tv_sec)
216 return -1;
217 if (lhs->tv_sec > rhs->tv_sec)
218 return 1;
219 return lhs->tv_usec - rhs->tv_usec;
220}
221
222static inline int compat_timespec_compare(struct compat_timespec *lhs,
223 struct compat_timespec *rhs)
224{
225 if (lhs->tv_sec < rhs->tv_sec)
226 return -1;
227 if (lhs->tv_sec > rhs->tv_sec)
228 return 1;
229 return lhs->tv_nsec - rhs->tv_nsec;
230}
231
Davide Libenzi83f5d122007-05-10 22:23:18 -0700232extern int get_compat_itimerspec(struct itimerspec *dst,
233 const struct compat_itimerspec __user *src);
234extern int put_compat_itimerspec(struct compat_itimerspec __user *dst,
235 const struct itimerspec *src);
236
Christoph Hellwigb418da12008-10-15 22:02:06 -0700237asmlinkage long compat_sys_gettimeofday(struct compat_timeval __user *tv,
238 struct timezone __user *tz);
239asmlinkage long compat_sys_settimeofday(struct compat_timeval __user *tv,
240 struct timezone __user *tz);
241
Stephen Rothwell3158e942006-03-26 01:37:29 -0800242asmlinkage long compat_sys_adjtimex(struct compat_timex __user *utp);
243
Andi Kleenbebfa102006-06-26 13:56:52 +0200244extern int compat_printk(const char *fmt, ...);
Linus Torvalds02354972006-10-02 14:05:20 -0700245extern void sigset_from_compat(sigset_t *set, compat_sigset_t *compat);
Andi Kleenbebfa102006-06-26 13:56:52 +0200246
Stephen Rothwell3fd59392006-11-02 22:07:24 -0800247asmlinkage long compat_sys_migrate_pages(compat_pid_t pid,
248 compat_ulong_t maxnode, const compat_ulong_t __user *old_nodes,
249 const compat_ulong_t __user *new_nodes);
250
Roland McGrath032d82d2008-01-30 13:31:47 +0100251extern int compat_ptrace_request(struct task_struct *child,
252 compat_long_t request,
253 compat_ulong_t addr, compat_ulong_t data);
254
Roland McGrathc269f192008-01-30 13:31:48 +0100255extern long compat_arch_ptrace(struct task_struct *child, compat_long_t request,
256 compat_ulong_t addr, compat_ulong_t data);
257asmlinkage long compat_sys_ptrace(compat_long_t request, compat_long_t pid,
258 compat_long_t addr, compat_long_t data);
Roland McGrathc269f192008-01-30 13:31:48 +0100259
Davide Libenzif6dfb4f2007-03-07 20:41:21 -0800260/*
261 * epoll (fs/eventpoll.c) compat bits follow ...
262 */
Davide Libenzif6dfb4f2007-03-07 20:41:21 -0800263struct epoll_event;
264#define compat_epoll_event epoll_event
Davide Libenzif6dfb4f2007-03-07 20:41:21 -0800265asmlinkage long compat_sys_epoll_pwait(int epfd,
266 struct compat_epoll_event __user *events,
267 int maxevents, int timeout,
268 const compat_sigset_t __user *sigmask,
269 compat_size_t sigsetsize);
270
Stephen Rothwell97416ce2007-05-09 02:32:35 -0700271asmlinkage long compat_sys_utimensat(unsigned int dfd, char __user *filename,
272 struct compat_timespec __user *t, int flags);
273
Stephen Rothwell140ff8b2007-05-14 13:47:47 +1000274asmlinkage long compat_sys_signalfd(int ufd,
275 const compat_sigset_t __user *sigmask,
276 compat_size_t sigsetsize);
Davide Libenzi4d672e72008-02-04 22:27:26 -0800277asmlinkage long compat_sys_timerfd_settime(int ufd, int flags,
278 const struct compat_itimerspec __user *utmr,
279 struct compat_itimerspec __user *otmr);
280asmlinkage long compat_sys_timerfd_gettime(int ufd,
281 struct compat_itimerspec __user *otmr);
Stephen Rothwell140ff8b2007-05-14 13:47:47 +1000282
Heiko Carstens4c696ba2009-01-14 14:13:53 +0100283asmlinkage long compat_sys_move_pages(pid_t pid, unsigned long nr_page,
284 __u32 __user *pages,
285 const int __user *nodes,
286 int __user *status,
287 int flags);
288asmlinkage long compat_sys_futimesat(unsigned int dfd, char __user *filename,
289 struct compat_timeval __user *t);
290asmlinkage long compat_sys_newfstatat(unsigned int dfd, char __user * filename,
291 struct compat_stat __user *statbuf,
292 int flag);
293asmlinkage long compat_sys_openat(unsigned int dfd, const char __user *filename,
294 int flags, int mode);
295
Linus Torvalds1da177e2005-04-16 15:20:36 -0700296#endif /* CONFIG_COMPAT */
297#endif /* _LINUX_COMPAT_H */