]>
Commit | Line | Data |
---|---|---|
1da177e4 LT |
1 | #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 | */ | |
1da177e4 LT |
7 | |
8 | #ifdef CONFIG_COMPAT | |
9 | ||
10 | #include <linux/stat.h> | |
11 | #include <linux/param.h> /* for HZ */ | |
12 | #include <linux/sem.h> | |
2dceba14 AB |
13 | #include <linux/socket.h> |
14 | #include <linux/if.h> | |
1da177e4 LT |
15 | |
16 | #include <asm/compat.h> | |
17 | #include <asm/siginfo.h> | |
3f2e05e9 | 18 | #include <asm/signal.h> |
1da177e4 LT |
19 | |
20 | #define compat_jiffies_to_clock_t(x) \ | |
21 | (((unsigned long)(x) * COMPAT_USER_HZ) / HZ) | |
22 | ||
202e5979 SR |
23 | typedef __compat_uid32_t compat_uid_t; |
24 | typedef __compat_gid32_t compat_gid_t; | |
25 | ||
5d0e5283 | 26 | struct compat_sel_arg_struct; |
1da177e4 LT |
27 | struct rusage; |
28 | ||
29 | struct compat_itimerspec { | |
30 | struct compat_timespec it_interval; | |
31 | struct compat_timespec it_value; | |
32 | }; | |
33 | ||
34 | struct compat_utimbuf { | |
35 | compat_time_t actime; | |
36 | compat_time_t modtime; | |
37 | }; | |
38 | ||
39 | struct compat_itimerval { | |
40 | struct compat_timeval it_interval; | |
41 | struct compat_timeval it_value; | |
42 | }; | |
43 | ||
44 | struct compat_tms { | |
45 | compat_clock_t tms_utime; | |
46 | compat_clock_t tms_stime; | |
47 | compat_clock_t tms_cutime; | |
48 | compat_clock_t tms_cstime; | |
49 | }; | |
50 | ||
88959ea9 SR |
51 | struct compat_timex { |
52 | compat_uint_t modes; | |
53 | compat_long_t offset; | |
54 | compat_long_t freq; | |
55 | compat_long_t maxerror; | |
56 | compat_long_t esterror; | |
57 | compat_int_t status; | |
58 | compat_long_t constant; | |
59 | compat_long_t precision; | |
60 | compat_long_t tolerance; | |
61 | struct compat_timeval time; | |
62 | compat_long_t tick; | |
63 | compat_long_t ppsfreq; | |
64 | compat_long_t jitter; | |
65 | compat_int_t shift; | |
66 | compat_long_t stabil; | |
67 | compat_long_t jitcnt; | |
68 | compat_long_t calcnt; | |
69 | compat_long_t errcnt; | |
70 | compat_long_t stbcnt; | |
153b5d05 | 71 | compat_int_t tai; |
88959ea9 SR |
72 | |
73 | compat_int_t :32; compat_int_t :32; compat_int_t :32; compat_int_t :32; | |
74 | compat_int_t :32; compat_int_t :32; compat_int_t :32; compat_int_t :32; | |
153b5d05 | 75 | compat_int_t :32; compat_int_t :32; compat_int_t :32; |
88959ea9 SR |
76 | }; |
77 | ||
1da177e4 LT |
78 | #define _COMPAT_NSIG_WORDS (_COMPAT_NSIG / _COMPAT_NSIG_BPW) |
79 | ||
80 | typedef struct { | |
81 | compat_sigset_word sig[_COMPAT_NSIG_WORDS]; | |
82 | } compat_sigset_t; | |
83 | ||
1da177e4 LT |
84 | extern int get_compat_timespec(struct timespec *, const struct compat_timespec __user *); |
85 | extern int put_compat_timespec(const struct timespec *, struct compat_timespec __user *); | |
86 | ||
87 | struct compat_iovec { | |
88 | compat_uptr_t iov_base; | |
89 | compat_size_t iov_len; | |
90 | }; | |
91 | ||
92 | struct compat_rlimit { | |
93 | compat_ulong_t rlim_cur; | |
94 | compat_ulong_t rlim_max; | |
95 | }; | |
96 | ||
97 | struct compat_rusage { | |
98 | struct compat_timeval ru_utime; | |
99 | struct compat_timeval ru_stime; | |
100 | compat_long_t ru_maxrss; | |
101 | compat_long_t ru_ixrss; | |
102 | compat_long_t ru_idrss; | |
103 | compat_long_t ru_isrss; | |
104 | compat_long_t ru_minflt; | |
105 | compat_long_t ru_majflt; | |
106 | compat_long_t ru_nswap; | |
107 | compat_long_t ru_inblock; | |
108 | compat_long_t ru_oublock; | |
109 | compat_long_t ru_msgsnd; | |
110 | compat_long_t ru_msgrcv; | |
111 | compat_long_t ru_nsignals; | |
112 | compat_long_t ru_nvcsw; | |
113 | compat_long_t ru_nivcsw; | |
114 | }; | |
115 | ||
116 | extern int put_compat_rusage(const struct rusage *, struct compat_rusage __user *); | |
117 | ||
118 | struct compat_siginfo; | |
119 | ||
120 | extern asmlinkage long compat_sys_waitid(int, compat_pid_t, | |
121 | struct compat_siginfo __user *, int, | |
122 | struct compat_rusage __user *); | |
123 | ||
124 | struct compat_dirent { | |
125 | u32 d_ino; | |
126 | compat_off_t d_off; | |
127 | u16 d_reclen; | |
128 | char d_name[256]; | |
129 | }; | |
130 | ||
2b1c6bd7 CH |
131 | struct compat_ustat { |
132 | compat_daddr_t f_tfree; | |
133 | compat_ino_t f_tinode; | |
134 | char f_fname[6]; | |
135 | char f_fpack[6]; | |
136 | }; | |
137 | ||
1da177e4 LT |
138 | typedef union compat_sigval { |
139 | compat_int_t sival_int; | |
140 | compat_uptr_t sival_ptr; | |
141 | } compat_sigval_t; | |
142 | ||
143 | #define COMPAT_SIGEV_PAD_SIZE ((SIGEV_MAX_SIZE/sizeof(int)) - 3) | |
144 | ||
145 | typedef struct compat_sigevent { | |
146 | compat_sigval_t sigev_value; | |
147 | compat_int_t sigev_signo; | |
148 | compat_int_t sigev_notify; | |
149 | union { | |
150 | compat_int_t _pad[COMPAT_SIGEV_PAD_SIZE]; | |
151 | compat_int_t _tid; | |
152 | ||
153 | struct { | |
154 | compat_uptr_t _function; | |
155 | compat_uptr_t _attribute; | |
156 | } _sigev_thread; | |
157 | } _sigev_un; | |
158 | } compat_sigevent_t; | |
159 | ||
2dceba14 AB |
160 | struct compat_ifmap { |
161 | compat_ulong_t mem_start; | |
162 | compat_ulong_t mem_end; | |
163 | unsigned short base_addr; | |
164 | unsigned char irq; | |
165 | unsigned char dma; | |
166 | unsigned char port; | |
167 | }; | |
168 | ||
7a50a240 AB |
169 | struct compat_if_settings |
170 | { | |
171 | unsigned int type; /* Type of physical device or protocol */ | |
172 | unsigned int size; /* Size of the data allocated by the caller */ | |
173 | compat_uptr_t ifs_ifsu; /* union of pointers */ | |
174 | }; | |
175 | ||
2dceba14 | 176 | struct compat_ifreq { |
7a50a240 AB |
177 | union { |
178 | char ifrn_name[IFNAMSIZ]; /* if name, e.g. "en0" */ | |
179 | } ifr_ifrn; | |
180 | union { | |
181 | struct sockaddr ifru_addr; | |
182 | struct sockaddr ifru_dstaddr; | |
183 | struct sockaddr ifru_broadaddr; | |
184 | struct sockaddr ifru_netmask; | |
185 | struct sockaddr ifru_hwaddr; | |
186 | short ifru_flags; | |
187 | compat_int_t ifru_ivalue; | |
188 | compat_int_t ifru_mtu; | |
189 | struct compat_ifmap ifru_map; | |
190 | char ifru_slave[IFNAMSIZ]; /* Just fits the size */ | |
2dceba14 | 191 | char ifru_newname[IFNAMSIZ]; |
7a50a240 AB |
192 | compat_caddr_t ifru_data; |
193 | struct compat_if_settings ifru_settings; | |
194 | } ifr_ifru; | |
2dceba14 AB |
195 | }; |
196 | ||
197 | struct compat_ifconf { | |
198 | compat_int_t ifc_len; /* size of buffer */ | |
199 | compat_caddr_t ifcbuf; | |
200 | }; | |
201 | ||
34f192c6 IM |
202 | struct compat_robust_list { |
203 | compat_uptr_t next; | |
204 | }; | |
205 | ||
206 | struct compat_robust_list_head { | |
207 | struct compat_robust_list list; | |
208 | compat_long_t futex_offset; | |
209 | compat_uptr_t list_op_pending; | |
210 | }; | |
211 | ||
212 | extern void compat_exit_robust_list(struct task_struct *curr); | |
213 | ||
214 | asmlinkage long | |
215 | compat_sys_set_robust_list(struct compat_robust_list_head __user *head, | |
216 | compat_size_t len); | |
217 | asmlinkage long | |
ba46df98 | 218 | compat_sys_get_robust_list(int pid, compat_uptr_t __user *head_ptr, |
34f192c6 | 219 | compat_size_t __user *len_ptr); |
1da177e4 LT |
220 | |
221 | long compat_sys_semctl(int first, int second, int third, void __user *uptr); | |
222 | long compat_sys_msgsnd(int first, int second, int third, void __user *uptr); | |
223 | long compat_sys_msgrcv(int first, int second, int msgtyp, int third, | |
224 | int version, void __user *uptr); | |
225 | long compat_sys_msgctl(int first, int second, void __user *uptr); | |
226 | long compat_sys_shmat(int first, int second, compat_uptr_t third, int version, | |
227 | void __user *uptr); | |
228 | long compat_sys_shmctl(int first, int second, void __user *uptr); | |
229 | long compat_sys_semtimedop(int semid, struct sembuf __user *tsems, | |
230 | unsigned nsems, const struct compat_timespec __user *timeout); | |
231 | asmlinkage long compat_sys_keyctl(u32 option, | |
232 | u32 arg2, u32 arg3, u32 arg4, u32 arg5); | |
2b1c6bd7 | 233 | asmlinkage long compat_sys_ustat(unsigned dev, struct compat_ustat __user *u32); |
1da177e4 LT |
234 | |
235 | asmlinkage ssize_t compat_sys_readv(unsigned long fd, | |
236 | const struct compat_iovec __user *vec, unsigned long vlen); | |
237 | asmlinkage ssize_t compat_sys_writev(unsigned long fd, | |
238 | const struct compat_iovec __user *vec, unsigned long vlen); | |
f3554f4b GH |
239 | asmlinkage ssize_t compat_sys_preadv(unsigned long fd, |
240 | const struct compat_iovec __user *vec, | |
601cc11d | 241 | unsigned long vlen, u32 pos_low, u32 pos_high); |
f3554f4b GH |
242 | asmlinkage ssize_t compat_sys_pwritev(unsigned long fd, |
243 | const struct compat_iovec __user *vec, | |
601cc11d | 244 | unsigned long vlen, u32 pos_low, u32 pos_high); |
1da177e4 LT |
245 | |
246 | int compat_do_execve(char * filename, compat_uptr_t __user *argv, | |
247 | compat_uptr_t __user *envp, struct pt_regs * regs); | |
248 | ||
249 | asmlinkage long compat_sys_select(int n, compat_ulong_t __user *inp, | |
250 | compat_ulong_t __user *outp, compat_ulong_t __user *exp, | |
251 | struct compat_timeval __user *tvp); | |
252 | ||
5d0e5283 CH |
253 | asmlinkage long compat_sys_old_select(struct compat_sel_arg_struct __user *arg); |
254 | ||
c202f298 | 255 | asmlinkage long compat_sys_wait4(compat_pid_t pid, |
7d61c459 AV |
256 | compat_uint_t __user *stat_addr, int options, |
257 | struct compat_rusage __user *ru); | |
c202f298 | 258 | |
1da177e4 LT |
259 | #define BITS_PER_COMPAT_LONG (8*sizeof(compat_long_t)) |
260 | ||
261 | #define BITS_TO_COMPAT_LONGS(bits) \ | |
262 | (((bits)+BITS_PER_COMPAT_LONG-1)/BITS_PER_COMPAT_LONG) | |
263 | ||
5fa3839a | 264 | long compat_get_bitmap(unsigned long *mask, const compat_ulong_t __user *umask, |
1da177e4 LT |
265 | unsigned long bitmap_size); |
266 | long compat_put_bitmap(compat_ulong_t __user *umask, unsigned long *mask, | |
267 | unsigned long bitmap_size); | |
268 | int copy_siginfo_from_user32(siginfo_t *to, struct compat_siginfo __user *from); | |
269 | int copy_siginfo_to_user32(struct compat_siginfo __user *to, siginfo_t *from); | |
270 | int get_compat_sigevent(struct sigevent *event, | |
271 | const struct compat_sigevent __user *u_event); | |
62ab4505 TG |
272 | long compat_sys_rt_tgsigqueueinfo(compat_pid_t tgid, compat_pid_t pid, int sig, |
273 | struct compat_siginfo __user *uinfo); | |
1da177e4 | 274 | |
643a6545 AM |
275 | static inline int compat_timeval_compare(struct compat_timeval *lhs, |
276 | struct compat_timeval *rhs) | |
277 | { | |
278 | if (lhs->tv_sec < rhs->tv_sec) | |
279 | return -1; | |
280 | if (lhs->tv_sec > rhs->tv_sec) | |
281 | return 1; | |
282 | return lhs->tv_usec - rhs->tv_usec; | |
283 | } | |
284 | ||
285 | static inline int compat_timespec_compare(struct compat_timespec *lhs, | |
286 | struct compat_timespec *rhs) | |
287 | { | |
288 | if (lhs->tv_sec < rhs->tv_sec) | |
289 | return -1; | |
290 | if (lhs->tv_sec > rhs->tv_sec) | |
291 | return 1; | |
292 | return lhs->tv_nsec - rhs->tv_nsec; | |
293 | } | |
294 | ||
83f5d126 DL |
295 | extern int get_compat_itimerspec(struct itimerspec *dst, |
296 | const struct compat_itimerspec __user *src); | |
297 | extern int put_compat_itimerspec(struct compat_itimerspec __user *dst, | |
298 | const struct itimerspec *src); | |
299 | ||
b418da16 CH |
300 | asmlinkage long compat_sys_gettimeofday(struct compat_timeval __user *tv, |
301 | struct timezone __user *tz); | |
302 | asmlinkage long compat_sys_settimeofday(struct compat_timeval __user *tv, | |
303 | struct timezone __user *tz); | |
304 | ||
3158e941 SR |
305 | asmlinkage long compat_sys_adjtimex(struct compat_timex __user *utp); |
306 | ||
bebfa101 | 307 | extern int compat_printk(const char *fmt, ...); |
0235497f | 308 | extern void sigset_from_compat(sigset_t *set, compat_sigset_t *compat); |
bebfa101 | 309 | |
3fd59397 SR |
310 | asmlinkage long compat_sys_migrate_pages(compat_pid_t pid, |
311 | compat_ulong_t maxnode, const compat_ulong_t __user *old_nodes, | |
312 | const compat_ulong_t __user *new_nodes); | |
313 | ||
032d82d9 RM |
314 | extern int compat_ptrace_request(struct task_struct *child, |
315 | compat_long_t request, | |
316 | compat_ulong_t addr, compat_ulong_t data); | |
317 | ||
c269f196 RM |
318 | extern long compat_arch_ptrace(struct task_struct *child, compat_long_t request, |
319 | compat_ulong_t addr, compat_ulong_t data); | |
320 | asmlinkage long compat_sys_ptrace(compat_long_t request, compat_long_t pid, | |
321 | compat_long_t addr, compat_long_t data); | |
c269f196 | 322 | |
f6dfb4fd DL |
323 | /* |
324 | * epoll (fs/eventpoll.c) compat bits follow ... | |
325 | */ | |
f6dfb4fd DL |
326 | struct epoll_event; |
327 | #define compat_epoll_event epoll_event | |
f6dfb4fd DL |
328 | asmlinkage long compat_sys_epoll_pwait(int epfd, |
329 | struct compat_epoll_event __user *events, | |
330 | int maxevents, int timeout, | |
331 | const compat_sigset_t __user *sigmask, | |
332 | compat_size_t sigsetsize); | |
333 | ||
c7887325 | 334 | asmlinkage long compat_sys_utimensat(unsigned int dfd, const char __user *filename, |
97416ce8 SR |
335 | struct compat_timespec __user *t, int flags); |
336 | ||
140ff8b0 SR |
337 | asmlinkage long compat_sys_signalfd(int ufd, |
338 | const compat_sigset_t __user *sigmask, | |
339 | compat_size_t sigsetsize); | |
4d672e7a DL |
340 | asmlinkage long compat_sys_timerfd_settime(int ufd, int flags, |
341 | const struct compat_itimerspec __user *utmr, | |
342 | struct compat_itimerspec __user *otmr); | |
343 | asmlinkage long compat_sys_timerfd_gettime(int ufd, | |
344 | struct compat_itimerspec __user *otmr); | |
140ff8b0 | 345 | |
4c696ba7 HC |
346 | asmlinkage long compat_sys_move_pages(pid_t pid, unsigned long nr_page, |
347 | __u32 __user *pages, | |
348 | const int __user *nodes, | |
349 | int __user *status, | |
350 | int flags); | |
c7887325 | 351 | asmlinkage long compat_sys_futimesat(unsigned int dfd, const char __user *filename, |
4c696ba7 | 352 | struct compat_timeval __user *t); |
c7887325 | 353 | asmlinkage long compat_sys_newfstatat(unsigned int dfd, const char __user * filename, |
4c696ba7 HC |
354 | struct compat_stat __user *statbuf, |
355 | int flag); | |
356 | asmlinkage long compat_sys_openat(unsigned int dfd, const char __user *filename, | |
357 | int flags, int mode); | |
358 | ||
b8373363 JM |
359 | extern ssize_t compat_rw_copy_check_uvector(int type, |
360 | const struct compat_iovec __user *uvector, unsigned long nr_segs, | |
361 | unsigned long fast_segs, struct iovec *fast_pointer, | |
362 | struct iovec **ret_pointer); | |
c41d68a5 PA |
363 | |
364 | extern void __user *compat_alloc_user_space(unsigned long len); | |
365 | ||
1da177e4 LT |
366 | #endif /* CONFIG_COMPAT */ |
367 | #endif /* _LINUX_COMPAT_H */ |