1 #ifndef _LINUX_COMPAT_H
2 #define _LINUX_COMPAT_H
4 * These are the type definitions for the architecture specific
5 * syscall compatibility layer.
10 #include <linux/stat.h>
11 #include <linux/param.h> /* for HZ */
12 #include <linux/sem.h>
13 #include <linux/socket.h>
16 #include <linux/aio_abi.h> /* for aio_context_t */
18 #include <asm/compat.h>
19 #include <asm/siginfo.h>
20 #include <asm/signal.h>
22 #ifndef COMPAT_USE_64BIT_TIME
23 #define COMPAT_USE_64BIT_TIME 0
26 #define compat_jiffies_to_clock_t(x) \
27 (((unsigned long)(x) * COMPAT_USER_HZ) / HZ)
29 typedef __compat_uid32_t compat_uid_t;
30 typedef __compat_gid32_t compat_gid_t;
32 struct compat_sel_arg_struct;
35 struct compat_itimerspec {
36 struct compat_timespec it_interval;
37 struct compat_timespec it_value;
40 struct compat_utimbuf {
42 compat_time_t modtime;
45 struct compat_itimerval {
46 struct compat_timeval it_interval;
47 struct compat_timeval it_value;
51 compat_clock_t tms_utime;
52 compat_clock_t tms_stime;
53 compat_clock_t tms_cutime;
54 compat_clock_t tms_cstime;
61 compat_long_t maxerror;
62 compat_long_t esterror;
64 compat_long_t constant;
65 compat_long_t precision;
66 compat_long_t tolerance;
67 struct compat_timeval time;
69 compat_long_t ppsfreq;
79 compat_int_t:32; compat_int_t:32; compat_int_t:32; compat_int_t:32;
80 compat_int_t:32; compat_int_t:32; compat_int_t:32; compat_int_t:32;
81 compat_int_t:32; compat_int_t:32; compat_int_t:32;
84 #define _COMPAT_NSIG_WORDS (_COMPAT_NSIG / _COMPAT_NSIG_BPW)
87 compat_sigset_word sig[_COMPAT_NSIG_WORDS];
91 * These functions operate strictly on struct compat_time*
93 extern int get_compat_timespec(struct timespec *,
94 const struct compat_timespec __user *);
95 extern int put_compat_timespec(const struct timespec *,
96 struct compat_timespec __user *);
97 extern int get_compat_timeval(struct timeval *,
98 const struct compat_timeval __user *);
99 extern int put_compat_timeval(const struct timeval *,
100 struct compat_timeval __user *);
102 * These functions operate on 32- or 64-bit specs depending on
103 * COMPAT_USE_64BIT_TIME, hence the void user pointer arguments and the
104 * naming as compat_get/put_ rather than get/put_compat_.
106 extern int compat_get_timespec(struct timespec *, const void __user *);
107 extern int compat_put_timespec(const struct timespec *, void __user *);
108 extern int compat_get_timeval(struct timeval *, const void __user *);
109 extern int compat_put_timeval(const struct timeval *, void __user *);
111 struct compat_iovec {
112 compat_uptr_t iov_base;
113 compat_size_t iov_len;
116 struct compat_rlimit {
117 compat_ulong_t rlim_cur;
118 compat_ulong_t rlim_max;
121 struct compat_rusage {
122 struct compat_timeval ru_utime;
123 struct compat_timeval ru_stime;
124 compat_long_t ru_maxrss;
125 compat_long_t ru_ixrss;
126 compat_long_t ru_idrss;
127 compat_long_t ru_isrss;
128 compat_long_t ru_minflt;
129 compat_long_t ru_majflt;
130 compat_long_t ru_nswap;
131 compat_long_t ru_inblock;
132 compat_long_t ru_oublock;
133 compat_long_t ru_msgsnd;
134 compat_long_t ru_msgrcv;
135 compat_long_t ru_nsignals;
136 compat_long_t ru_nvcsw;
137 compat_long_t ru_nivcsw;
140 extern int put_compat_rusage(const struct rusage *,
141 struct compat_rusage __user *);
143 struct compat_siginfo;
145 extern asmlinkage long compat_sys_waitid(int, compat_pid_t,
146 struct compat_siginfo __user *, int,
147 struct compat_rusage __user *);
149 struct compat_dirent {
156 struct compat_ustat {
157 compat_daddr_t f_tfree;
158 compat_ino_t f_tinode;
163 typedef union compat_sigval {
164 compat_int_t sival_int;
165 compat_uptr_t sival_ptr;
168 #define COMPAT_SIGEV_PAD_SIZE ((SIGEV_MAX_SIZE/sizeof(int)) - 3)
170 typedef struct compat_sigevent {
171 compat_sigval_t sigev_value;
172 compat_int_t sigev_signo;
173 compat_int_t sigev_notify;
175 compat_int_t _pad[COMPAT_SIGEV_PAD_SIZE];
179 compat_uptr_t _function;
180 compat_uptr_t _attribute;
185 struct compat_ifmap {
186 compat_ulong_t mem_start;
187 compat_ulong_t mem_end;
188 unsigned short base_addr;
194 struct compat_if_settings {
195 unsigned int type; /* Type of physical device or protocol */
196 unsigned int size; /* Size of the data allocated by the caller */
197 compat_uptr_t ifs_ifsu; /* union of pointers */
200 struct compat_ifreq {
202 char ifrn_name[IFNAMSIZ]; /* if name, e.g. "en0" */
205 struct sockaddr ifru_addr;
206 struct sockaddr ifru_dstaddr;
207 struct sockaddr ifru_broadaddr;
208 struct sockaddr ifru_netmask;
209 struct sockaddr ifru_hwaddr;
211 compat_int_t ifru_ivalue;
212 compat_int_t ifru_mtu;
213 struct compat_ifmap ifru_map;
214 char ifru_slave[IFNAMSIZ]; /* Just fits the size */
215 char ifru_newname[IFNAMSIZ];
216 compat_caddr_t ifru_data;
217 struct compat_if_settings ifru_settings;
221 struct compat_ifconf {
222 compat_int_t ifc_len; /* size of buffer */
223 compat_caddr_t ifcbuf;
226 struct compat_robust_list {
230 struct compat_robust_list_head {
231 struct compat_robust_list list;
232 compat_long_t futex_offset;
233 compat_uptr_t list_op_pending;
236 struct compat_statfs;
237 struct compat_statfs64;
238 struct compat_old_linux_dirent;
239 struct compat_linux_dirent;
240 struct linux_dirent64;
241 struct compat_msghdr;
242 struct compat_mmsghdr;
243 struct compat_sysinfo;
244 struct compat_sysctl_args;
245 struct compat_kexec_segment;
246 struct compat_mq_attr;
247 struct compat_msgbuf;
249 extern void compat_exit_robust_list(struct task_struct *curr);
252 compat_sys_set_robust_list(struct compat_robust_list_head __user *head,
255 compat_sys_get_robust_list(int pid, compat_uptr_t __user *head_ptr,
256 compat_size_t __user *len_ptr);
258 #ifdef CONFIG_ARCH_WANT_OLD_COMPAT_IPC
259 long compat_sys_semctl(int first, int second, int third, void __user *uptr);
260 long compat_sys_msgsnd(int first, int second, int third, void __user *uptr);
261 long compat_sys_msgrcv(int first, int second, int msgtyp, int third,
262 int version, void __user *uptr);
263 long compat_sys_shmat(int first, int second, compat_uptr_t third, int version,
266 long compat_sys_semctl(int semid, int semnum, int cmd, int arg);
267 long compat_sys_msgsnd(int msqid, struct compat_msgbuf __user *msgp,
268 size_t msgsz, int msgflg);
269 long compat_sys_msgrcv(int msqid, struct compat_msgbuf __user *msgp,
270 size_t msgsz, long msgtyp, int msgflg);
271 long compat_sys_shmat(int shmid, compat_uptr_t shmaddr, int shmflg);
273 long compat_sys_msgctl(int first, int second, void __user *uptr);
274 long compat_sys_shmctl(int first, int second, void __user *uptr);
275 long compat_sys_semtimedop(int semid, struct sembuf __user *tsems,
276 unsigned nsems, const struct compat_timespec __user *timeout);
277 asmlinkage long compat_sys_keyctl(u32 option,
278 u32 arg2, u32 arg3, u32 arg4, u32 arg5);
279 asmlinkage long compat_sys_ustat(unsigned dev, struct compat_ustat __user *u32);
281 asmlinkage ssize_t compat_sys_readv(unsigned long fd,
282 const struct compat_iovec __user *vec, unsigned long vlen);
283 asmlinkage ssize_t compat_sys_writev(unsigned long fd,
284 const struct compat_iovec __user *vec, unsigned long vlen);
285 asmlinkage ssize_t compat_sys_preadv(unsigned long fd,
286 const struct compat_iovec __user *vec,
287 unsigned long vlen, u32 pos_low, u32 pos_high);
288 asmlinkage ssize_t compat_sys_pwritev(unsigned long fd,
289 const struct compat_iovec __user *vec,
290 unsigned long vlen, u32 pos_low, u32 pos_high);
292 int compat_do_execve(char *filename, compat_uptr_t __user *argv,
293 compat_uptr_t __user *envp, struct pt_regs *regs);
295 asmlinkage long compat_sys_select(int n, compat_ulong_t __user *inp,
296 compat_ulong_t __user *outp, compat_ulong_t __user *exp,
297 struct compat_timeval __user *tvp);
299 asmlinkage long compat_sys_old_select(struct compat_sel_arg_struct __user *arg);
301 asmlinkage long compat_sys_wait4(compat_pid_t pid,
302 compat_uint_t __user *stat_addr, int options,
303 struct compat_rusage __user *ru);
305 #define BITS_PER_COMPAT_LONG (8*sizeof(compat_long_t))
307 #define BITS_TO_COMPAT_LONGS(bits) \
308 (((bits)+BITS_PER_COMPAT_LONG-1)/BITS_PER_COMPAT_LONG)
310 long compat_get_bitmap(unsigned long *mask, const compat_ulong_t __user *umask,
311 unsigned long bitmap_size);
312 long compat_put_bitmap(compat_ulong_t __user *umask, unsigned long *mask,
313 unsigned long bitmap_size);
314 int copy_siginfo_from_user32(siginfo_t *to, struct compat_siginfo __user *from);
315 int copy_siginfo_to_user32(struct compat_siginfo __user *to, siginfo_t *from);
316 int get_compat_sigevent(struct sigevent *event,
317 const struct compat_sigevent __user *u_event);
318 long compat_sys_rt_tgsigqueueinfo(compat_pid_t tgid, compat_pid_t pid, int sig,
319 struct compat_siginfo __user *uinfo);
321 static inline int compat_timeval_compare(struct compat_timeval *lhs,
322 struct compat_timeval *rhs)
324 if (lhs->tv_sec < rhs->tv_sec)
326 if (lhs->tv_sec > rhs->tv_sec)
328 return lhs->tv_usec - rhs->tv_usec;
331 static inline int compat_timespec_compare(struct compat_timespec *lhs,
332 struct compat_timespec *rhs)
334 if (lhs->tv_sec < rhs->tv_sec)
336 if (lhs->tv_sec > rhs->tv_sec)
338 return lhs->tv_nsec - rhs->tv_nsec;
341 extern int get_compat_itimerspec(struct itimerspec *dst,
342 const struct compat_itimerspec __user *src);
343 extern int put_compat_itimerspec(struct compat_itimerspec __user *dst,
344 const struct itimerspec *src);
346 asmlinkage long compat_sys_gettimeofday(struct compat_timeval __user *tv,
347 struct timezone __user *tz);
348 asmlinkage long compat_sys_settimeofday(struct compat_timeval __user *tv,
349 struct timezone __user *tz);
351 asmlinkage long compat_sys_adjtimex(struct compat_timex __user *utp);
353 extern int compat_printk(const char *fmt, ...);
354 extern void sigset_from_compat(sigset_t *set, compat_sigset_t *compat);
356 asmlinkage long compat_sys_migrate_pages(compat_pid_t pid,
357 compat_ulong_t maxnode, const compat_ulong_t __user *old_nodes,
358 const compat_ulong_t __user *new_nodes);
360 extern int compat_ptrace_request(struct task_struct *child,
361 compat_long_t request,
362 compat_ulong_t addr, compat_ulong_t data);
364 extern long compat_arch_ptrace(struct task_struct *child, compat_long_t request,
365 compat_ulong_t addr, compat_ulong_t data);
366 asmlinkage long compat_sys_ptrace(compat_long_t request, compat_long_t pid,
367 compat_long_t addr, compat_long_t data);
370 * epoll (fs/eventpoll.c) compat bits follow ...
373 #define compat_epoll_event epoll_event
374 asmlinkage long compat_sys_epoll_pwait(int epfd,
375 struct compat_epoll_event __user *events,
376 int maxevents, int timeout,
377 const compat_sigset_t __user *sigmask,
378 compat_size_t sigsetsize);
380 asmlinkage long compat_sys_utime(const char __user *filename,
381 struct compat_utimbuf __user *t);
382 asmlinkage long compat_sys_utimensat(unsigned int dfd,
383 const char __user *filename,
384 struct compat_timespec __user *t,
387 asmlinkage long compat_sys_time(compat_time_t __user *tloc);
388 asmlinkage long compat_sys_stime(compat_time_t __user *tptr);
389 asmlinkage long compat_sys_signalfd(int ufd,
390 const compat_sigset_t __user *sigmask,
391 compat_size_t sigsetsize);
392 asmlinkage long compat_sys_timerfd_settime(int ufd, int flags,
393 const struct compat_itimerspec __user *utmr,
394 struct compat_itimerspec __user *otmr);
395 asmlinkage long compat_sys_timerfd_gettime(int ufd,
396 struct compat_itimerspec __user *otmr);
398 asmlinkage long compat_sys_move_pages(pid_t pid, unsigned long nr_page,
400 const int __user *nodes,
403 asmlinkage long compat_sys_futimesat(unsigned int dfd,
404 const char __user *filename,
405 struct compat_timeval __user *t);
406 asmlinkage long compat_sys_utimes(const char __user *filename,
407 struct compat_timeval __user *t);
408 asmlinkage long compat_sys_newstat(const char __user *filename,
409 struct compat_stat __user *statbuf);
410 asmlinkage long compat_sys_newlstat(const char __user *filename,
411 struct compat_stat __user *statbuf);
412 asmlinkage long compat_sys_newfstatat(unsigned int dfd,
413 const char __user *filename,
414 struct compat_stat __user *statbuf,
416 asmlinkage long compat_sys_newfstat(unsigned int fd,
417 struct compat_stat __user *statbuf);
418 asmlinkage long compat_sys_statfs(const char __user *pathname,
419 struct compat_statfs __user *buf);
420 asmlinkage long compat_sys_fstatfs(unsigned int fd,
421 struct compat_statfs __user *buf);
422 asmlinkage long compat_sys_statfs64(const char __user *pathname,
424 struct compat_statfs64 __user *buf);
425 asmlinkage long compat_sys_fstatfs64(unsigned int fd, compat_size_t sz,
426 struct compat_statfs64 __user *buf);
427 asmlinkage long compat_sys_fcntl64(unsigned int fd, unsigned int cmd,
429 asmlinkage long compat_sys_fcntl(unsigned int fd, unsigned int cmd,
431 asmlinkage long compat_sys_io_setup(unsigned nr_reqs, u32 __user *ctx32p);
432 asmlinkage long compat_sys_io_getevents(aio_context_t ctx_id,
433 unsigned long min_nr,
435 struct io_event __user *events,
436 struct compat_timespec __user *timeout);
437 asmlinkage long compat_sys_io_submit(aio_context_t ctx_id, int nr,
439 asmlinkage long compat_sys_mount(const char __user *dev_name,
440 const char __user *dir_name,
441 const char __user *type, unsigned long flags,
442 const void __user *data);
443 asmlinkage long compat_sys_old_readdir(unsigned int fd,
444 struct compat_old_linux_dirent __user *,
446 asmlinkage long compat_sys_getdents(unsigned int fd,
447 struct compat_linux_dirent __user *dirent,
449 asmlinkage long compat_sys_getdents64(unsigned int fd,
450 struct linux_dirent64 __user *dirent,
452 asmlinkage long compat_sys_vmsplice(int fd, const struct compat_iovec __user *,
453 unsigned int nr_segs, unsigned int flags);
454 asmlinkage long compat_sys_open(const char __user *filename, int flags,
456 asmlinkage long compat_sys_openat(unsigned int dfd, const char __user *filename,
457 int flags, umode_t mode);
458 asmlinkage long compat_sys_open_by_handle_at(int mountdirfd,
459 struct file_handle __user *handle,
461 asmlinkage long compat_sys_pselect6(int n, compat_ulong_t __user *inp,
462 compat_ulong_t __user *outp,
463 compat_ulong_t __user *exp,
464 struct compat_timespec __user *tsp,
466 asmlinkage long compat_sys_ppoll(struct pollfd __user *ufds,
468 struct compat_timespec __user *tsp,
469 const compat_sigset_t __user *sigmask,
470 compat_size_t sigsetsize);
471 asmlinkage long compat_sys_signalfd4(int ufd,
472 const compat_sigset_t __user *sigmask,
473 compat_size_t sigsetsize, int flags);
474 asmlinkage long compat_sys_get_mempolicy(int __user *policy,
475 compat_ulong_t __user *nmask,
476 compat_ulong_t maxnode,
478 compat_ulong_t flags);
479 asmlinkage long compat_sys_set_mempolicy(int mode, compat_ulong_t __user *nmask,
480 compat_ulong_t maxnode);
481 asmlinkage long compat_sys_mbind(compat_ulong_t start, compat_ulong_t len,
483 compat_ulong_t __user *nmask,
484 compat_ulong_t maxnode, compat_ulong_t flags);
486 asmlinkage long compat_sys_setsockopt(int fd, int level, int optname,
487 char __user *optval, unsigned int optlen);
488 asmlinkage long compat_sys_sendmsg(int fd, struct compat_msghdr __user *msg,
490 asmlinkage long compat_sys_sendmmsg(int fd, struct compat_mmsghdr __user *mmsg,
491 unsigned vlen, unsigned int flags);
492 asmlinkage long compat_sys_recvmsg(int fd, struct compat_msghdr __user *msg,
494 asmlinkage long compat_sys_recv(int fd, void __user *buf, size_t len,
496 asmlinkage long compat_sys_recvfrom(int fd, void __user *buf, size_t len,
497 unsigned flags, struct sockaddr __user *addr,
498 int __user *addrlen);
499 asmlinkage long compat_sys_recvmmsg(int fd, struct compat_mmsghdr __user *mmsg,
500 unsigned vlen, unsigned int flags,
501 struct compat_timespec __user *timeout);
502 asmlinkage long compat_sys_nanosleep(struct compat_timespec __user *rqtp,
503 struct compat_timespec __user *rmtp);
504 asmlinkage long compat_sys_getitimer(int which,
505 struct compat_itimerval __user *it);
506 asmlinkage long compat_sys_setitimer(int which,
507 struct compat_itimerval __user *in,
508 struct compat_itimerval __user *out);
509 asmlinkage long compat_sys_times(struct compat_tms __user *tbuf);
510 asmlinkage long compat_sys_setrlimit(unsigned int resource,
511 struct compat_rlimit __user *rlim);
512 asmlinkage long compat_sys_getrlimit(unsigned int resource,
513 struct compat_rlimit __user *rlim);
514 asmlinkage long compat_sys_getrusage(int who, struct compat_rusage __user *ru);
515 asmlinkage long compat_sys_sched_setaffinity(compat_pid_t pid,
517 compat_ulong_t __user *user_mask_ptr);
518 asmlinkage long compat_sys_sched_getaffinity(compat_pid_t pid,
520 compat_ulong_t __user *user_mask_ptr);
521 asmlinkage long compat_sys_timer_create(clockid_t which_clock,
522 struct compat_sigevent __user *timer_event_spec,
523 timer_t __user *created_timer_id);
524 asmlinkage long compat_sys_timer_settime(timer_t timer_id, int flags,
525 struct compat_itimerspec __user *new,
526 struct compat_itimerspec __user *old);
527 asmlinkage long compat_sys_timer_gettime(timer_t timer_id,
528 struct compat_itimerspec __user *setting);
529 asmlinkage long compat_sys_clock_settime(clockid_t which_clock,
530 struct compat_timespec __user *tp);
531 asmlinkage long compat_sys_clock_gettime(clockid_t which_clock,
532 struct compat_timespec __user *tp);
533 asmlinkage long compat_sys_clock_adjtime(clockid_t which_clock,
534 struct compat_timex __user *tp);
535 asmlinkage long compat_sys_clock_getres(clockid_t which_clock,
536 struct compat_timespec __user *tp);
537 asmlinkage long compat_sys_clock_nanosleep(clockid_t which_clock, int flags,
538 struct compat_timespec __user *rqtp,
539 struct compat_timespec __user *rmtp);
540 asmlinkage long compat_sys_rt_sigtimedwait(compat_sigset_t __user *uthese,
541 struct compat_siginfo __user *uinfo,
542 struct compat_timespec __user *uts, compat_size_t sigsetsize);
543 asmlinkage long compat_sys_rt_sigsuspend(compat_sigset_t __user *unewset,
544 compat_size_t sigsetsize);
545 asmlinkage long compat_sys_sysinfo(struct compat_sysinfo __user *info);
546 asmlinkage long compat_sys_ioctl(unsigned int fd, unsigned int cmd,
548 asmlinkage long compat_sys_futex(u32 __user *uaddr, int op, u32 val,
549 struct compat_timespec __user *utime, u32 __user *uaddr2,
551 asmlinkage long compat_sys_getsockopt(int fd, int level, int optname,
552 char __user *optval, int __user *optlen);
553 asmlinkage long compat_sys_kexec_load(unsigned long entry,
554 unsigned long nr_segments,
555 struct compat_kexec_segment __user *,
556 unsigned long flags);
557 asmlinkage long compat_sys_mq_getsetattr(mqd_t mqdes,
558 const struct compat_mq_attr __user *u_mqstat,
559 struct compat_mq_attr __user *u_omqstat);
560 asmlinkage long compat_sys_mq_notify(mqd_t mqdes,
561 const struct compat_sigevent __user *u_notification);
562 asmlinkage long compat_sys_mq_open(const char __user *u_name,
563 int oflag, compat_mode_t mode,
564 struct compat_mq_attr __user *u_attr);
565 asmlinkage long compat_sys_mq_timedsend(mqd_t mqdes,
566 const char __user *u_msg_ptr,
567 size_t msg_len, unsigned int msg_prio,
568 const struct compat_timespec __user *u_abs_timeout);
569 asmlinkage ssize_t compat_sys_mq_timedreceive(mqd_t mqdes,
570 char __user *u_msg_ptr,
571 size_t msg_len, unsigned int __user *u_msg_prio,
572 const struct compat_timespec __user *u_abs_timeout);
573 asmlinkage long compat_sys_socketcall(int call, u32 __user *args);
574 asmlinkage long compat_sys_sysctl(struct compat_sysctl_args __user *args);
576 extern ssize_t compat_rw_copy_check_uvector(int type,
577 const struct compat_iovec __user *uvector,
578 unsigned long nr_segs,
579 unsigned long fast_segs, struct iovec *fast_pointer,
580 struct iovec **ret_pointer,
583 extern void __user *compat_alloc_user_space(unsigned long len);
585 asmlinkage ssize_t compat_sys_process_vm_readv(compat_pid_t pid,
586 const struct compat_iovec __user *lvec,
587 unsigned long liovcnt, const struct compat_iovec __user *rvec,
588 unsigned long riovcnt, unsigned long flags);
589 asmlinkage ssize_t compat_sys_process_vm_writev(compat_pid_t pid,
590 const struct compat_iovec __user *lvec,
591 unsigned long liovcnt, const struct compat_iovec __user *rvec,
592 unsigned long riovcnt, unsigned long flags);
596 #define is_compat_task() (0)
598 #endif /* CONFIG_COMPAT */
599 #endif /* _LINUX_COMPAT_H */