Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 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 | */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 7 | |
| 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 Howells | 3f2e05e | 2006-10-02 14:12:31 +0100 | [diff] [blame] | 16 | #include <asm/signal.h> |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 17 | |
| 18 | #define compat_jiffies_to_clock_t(x) \ |
| 19 | (((unsigned long)(x) * COMPAT_USER_HZ) / HZ) |
| 20 | |
Stephen Rothwell | 202e597 | 2005-09-06 15:16:40 -0700 | [diff] [blame] | 21 | typedef __compat_uid32_t compat_uid_t; |
| 22 | typedef __compat_gid32_t compat_gid_t; |
| 23 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 24 | struct rusage; |
| 25 | |
| 26 | struct compat_itimerspec { |
| 27 | struct compat_timespec it_interval; |
| 28 | struct compat_timespec it_value; |
| 29 | }; |
| 30 | |
| 31 | struct compat_utimbuf { |
| 32 | compat_time_t actime; |
| 33 | compat_time_t modtime; |
| 34 | }; |
| 35 | |
| 36 | struct compat_itimerval { |
| 37 | struct compat_timeval it_interval; |
| 38 | struct compat_timeval it_value; |
| 39 | }; |
| 40 | |
| 41 | struct 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 Rothwell | 88959ea | 2006-03-26 01:37:27 -0800 | [diff] [blame] | 48 | struct 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 Zippel | 153b5d0 | 2008-05-01 04:34:37 -0700 | [diff] [blame] | 68 | compat_int_t tai; |
Stephen Rothwell | 88959ea | 2006-03-26 01:37:27 -0800 | [diff] [blame] | 69 | |
| 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 Zippel | 153b5d0 | 2008-05-01 04:34:37 -0700 | [diff] [blame] | 72 | compat_int_t :32; compat_int_t :32; compat_int_t :32; |
Stephen Rothwell | 88959ea | 2006-03-26 01:37:27 -0800 | [diff] [blame] | 73 | }; |
| 74 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 75 | #define _COMPAT_NSIG_WORDS (_COMPAT_NSIG / _COMPAT_NSIG_BPW) |
| 76 | |
| 77 | typedef struct { |
| 78 | compat_sigset_word sig[_COMPAT_NSIG_WORDS]; |
| 79 | } compat_sigset_t; |
| 80 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 81 | extern int get_compat_timespec(struct timespec *, const struct compat_timespec __user *); |
| 82 | extern int put_compat_timespec(const struct timespec *, struct compat_timespec __user *); |
| 83 | |
| 84 | struct compat_iovec { |
| 85 | compat_uptr_t iov_base; |
| 86 | compat_size_t iov_len; |
| 87 | }; |
| 88 | |
| 89 | struct compat_rlimit { |
| 90 | compat_ulong_t rlim_cur; |
| 91 | compat_ulong_t rlim_max; |
| 92 | }; |
| 93 | |
| 94 | struct 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 | |
| 113 | extern int put_compat_rusage(const struct rusage *, struct compat_rusage __user *); |
| 114 | |
| 115 | struct compat_siginfo; |
| 116 | |
| 117 | extern asmlinkage long compat_sys_waitid(int, compat_pid_t, |
| 118 | struct compat_siginfo __user *, int, |
| 119 | struct compat_rusage __user *); |
| 120 | |
| 121 | struct compat_dirent { |
| 122 | u32 d_ino; |
| 123 | compat_off_t d_off; |
| 124 | u16 d_reclen; |
| 125 | char d_name[256]; |
| 126 | }; |
| 127 | |
Christoph Hellwig | 2b1c6bd | 2008-11-28 10:09:09 +0100 | [diff] [blame] | 128 | struct compat_ustat { |
| 129 | compat_daddr_t f_tfree; |
| 130 | compat_ino_t f_tinode; |
| 131 | char f_fname[6]; |
| 132 | char f_fpack[6]; |
| 133 | }; |
| 134 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 135 | typedef union compat_sigval { |
| 136 | compat_int_t sival_int; |
| 137 | compat_uptr_t sival_ptr; |
| 138 | } compat_sigval_t; |
| 139 | |
| 140 | #define COMPAT_SIGEV_PAD_SIZE ((SIGEV_MAX_SIZE/sizeof(int)) - 3) |
| 141 | |
| 142 | typedef struct compat_sigevent { |
| 143 | compat_sigval_t sigev_value; |
| 144 | compat_int_t sigev_signo; |
| 145 | compat_int_t sigev_notify; |
| 146 | union { |
| 147 | compat_int_t _pad[COMPAT_SIGEV_PAD_SIZE]; |
| 148 | compat_int_t _tid; |
| 149 | |
| 150 | struct { |
| 151 | compat_uptr_t _function; |
| 152 | compat_uptr_t _attribute; |
| 153 | } _sigev_thread; |
| 154 | } _sigev_un; |
| 155 | } compat_sigevent_t; |
| 156 | |
Ingo Molnar | 34f192c | 2006-03-27 01:16:24 -0800 | [diff] [blame] | 157 | struct compat_robust_list { |
| 158 | compat_uptr_t next; |
| 159 | }; |
| 160 | |
| 161 | struct compat_robust_list_head { |
| 162 | struct compat_robust_list list; |
| 163 | compat_long_t futex_offset; |
| 164 | compat_uptr_t list_op_pending; |
| 165 | }; |
| 166 | |
| 167 | extern void compat_exit_robust_list(struct task_struct *curr); |
| 168 | |
| 169 | asmlinkage long |
| 170 | compat_sys_set_robust_list(struct compat_robust_list_head __user *head, |
| 171 | compat_size_t len); |
| 172 | asmlinkage long |
Al Viro | ba46df9 | 2006-10-10 22:46:07 +0100 | [diff] [blame] | 173 | compat_sys_get_robust_list(int pid, compat_uptr_t __user *head_ptr, |
Ingo Molnar | 34f192c | 2006-03-27 01:16:24 -0800 | [diff] [blame] | 174 | compat_size_t __user *len_ptr); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 175 | |
| 176 | long compat_sys_semctl(int first, int second, int third, void __user *uptr); |
| 177 | long compat_sys_msgsnd(int first, int second, int third, void __user *uptr); |
| 178 | long compat_sys_msgrcv(int first, int second, int msgtyp, int third, |
| 179 | int version, void __user *uptr); |
| 180 | long compat_sys_msgctl(int first, int second, void __user *uptr); |
| 181 | long compat_sys_shmat(int first, int second, compat_uptr_t third, int version, |
| 182 | void __user *uptr); |
| 183 | long compat_sys_shmctl(int first, int second, void __user *uptr); |
| 184 | long compat_sys_semtimedop(int semid, struct sembuf __user *tsems, |
| 185 | unsigned nsems, const struct compat_timespec __user *timeout); |
| 186 | asmlinkage long compat_sys_keyctl(u32 option, |
| 187 | u32 arg2, u32 arg3, u32 arg4, u32 arg5); |
Christoph Hellwig | 2b1c6bd | 2008-11-28 10:09:09 +0100 | [diff] [blame] | 188 | asmlinkage long compat_sys_ustat(unsigned dev, struct compat_ustat __user *u32); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 189 | |
| 190 | asmlinkage ssize_t compat_sys_readv(unsigned long fd, |
| 191 | const struct compat_iovec __user *vec, unsigned long vlen); |
| 192 | asmlinkage ssize_t compat_sys_writev(unsigned long fd, |
| 193 | const struct compat_iovec __user *vec, unsigned long vlen); |
| 194 | |
| 195 | int compat_do_execve(char * filename, compat_uptr_t __user *argv, |
| 196 | compat_uptr_t __user *envp, struct pt_regs * regs); |
| 197 | |
| 198 | asmlinkage long compat_sys_select(int n, compat_ulong_t __user *inp, |
| 199 | compat_ulong_t __user *outp, compat_ulong_t __user *exp, |
| 200 | struct compat_timeval __user *tvp); |
| 201 | |
Thomas Gleixner | c202f29 | 2008-01-30 13:30:08 +0100 | [diff] [blame] | 202 | asmlinkage long compat_sys_wait4(compat_pid_t pid, |
Al Viro | 7d61c45 | 2008-03-29 03:09:28 +0000 | [diff] [blame] | 203 | compat_uint_t __user *stat_addr, int options, |
| 204 | struct compat_rusage __user *ru); |
Thomas Gleixner | c202f29 | 2008-01-30 13:30:08 +0100 | [diff] [blame] | 205 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 206 | #define BITS_PER_COMPAT_LONG (8*sizeof(compat_long_t)) |
| 207 | |
| 208 | #define BITS_TO_COMPAT_LONGS(bits) \ |
| 209 | (((bits)+BITS_PER_COMPAT_LONG-1)/BITS_PER_COMPAT_LONG) |
| 210 | |
Stephen Rothwell | 5fa3839 | 2006-10-28 10:38:46 -0700 | [diff] [blame] | 211 | long compat_get_bitmap(unsigned long *mask, const compat_ulong_t __user *umask, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 212 | unsigned long bitmap_size); |
| 213 | long compat_put_bitmap(compat_ulong_t __user *umask, unsigned long *mask, |
| 214 | unsigned long bitmap_size); |
| 215 | int copy_siginfo_from_user32(siginfo_t *to, struct compat_siginfo __user *from); |
| 216 | int copy_siginfo_to_user32(struct compat_siginfo __user *to, siginfo_t *from); |
| 217 | int get_compat_sigevent(struct sigevent *event, |
| 218 | const struct compat_sigevent __user *u_event); |
| 219 | |
Andrew Morton | 643a654 | 2006-02-11 17:55:52 -0800 | [diff] [blame] | 220 | static inline int compat_timeval_compare(struct compat_timeval *lhs, |
| 221 | struct compat_timeval *rhs) |
| 222 | { |
| 223 | if (lhs->tv_sec < rhs->tv_sec) |
| 224 | return -1; |
| 225 | if (lhs->tv_sec > rhs->tv_sec) |
| 226 | return 1; |
| 227 | return lhs->tv_usec - rhs->tv_usec; |
| 228 | } |
| 229 | |
| 230 | static inline int compat_timespec_compare(struct compat_timespec *lhs, |
| 231 | struct compat_timespec *rhs) |
| 232 | { |
| 233 | if (lhs->tv_sec < rhs->tv_sec) |
| 234 | return -1; |
| 235 | if (lhs->tv_sec > rhs->tv_sec) |
| 236 | return 1; |
| 237 | return lhs->tv_nsec - rhs->tv_nsec; |
| 238 | } |
| 239 | |
Davide Libenzi | 83f5d12 | 2007-05-10 22:23:18 -0700 | [diff] [blame] | 240 | extern int get_compat_itimerspec(struct itimerspec *dst, |
| 241 | const struct compat_itimerspec __user *src); |
| 242 | extern int put_compat_itimerspec(struct compat_itimerspec __user *dst, |
| 243 | const struct itimerspec *src); |
| 244 | |
Christoph Hellwig | b418da1 | 2008-10-15 22:02:06 -0700 | [diff] [blame] | 245 | asmlinkage long compat_sys_gettimeofday(struct compat_timeval __user *tv, |
| 246 | struct timezone __user *tz); |
| 247 | asmlinkage long compat_sys_settimeofday(struct compat_timeval __user *tv, |
| 248 | struct timezone __user *tz); |
| 249 | |
Stephen Rothwell | 3158e94 | 2006-03-26 01:37:29 -0800 | [diff] [blame] | 250 | asmlinkage long compat_sys_adjtimex(struct compat_timex __user *utp); |
| 251 | |
Andi Kleen | bebfa10 | 2006-06-26 13:56:52 +0200 | [diff] [blame] | 252 | extern int compat_printk(const char *fmt, ...); |
Linus Torvalds | 0235497 | 2006-10-02 14:05:20 -0700 | [diff] [blame] | 253 | extern void sigset_from_compat(sigset_t *set, compat_sigset_t *compat); |
Andi Kleen | bebfa10 | 2006-06-26 13:56:52 +0200 | [diff] [blame] | 254 | |
Stephen Rothwell | 3fd5939 | 2006-11-02 22:07:24 -0800 | [diff] [blame] | 255 | asmlinkage long compat_sys_migrate_pages(compat_pid_t pid, |
| 256 | compat_ulong_t maxnode, const compat_ulong_t __user *old_nodes, |
| 257 | const compat_ulong_t __user *new_nodes); |
| 258 | |
Roland McGrath | 032d82d | 2008-01-30 13:31:47 +0100 | [diff] [blame] | 259 | extern int compat_ptrace_request(struct task_struct *child, |
| 260 | compat_long_t request, |
| 261 | compat_ulong_t addr, compat_ulong_t data); |
| 262 | |
Roland McGrath | c269f19 | 2008-01-30 13:31:48 +0100 | [diff] [blame] | 263 | extern long compat_arch_ptrace(struct task_struct *child, compat_long_t request, |
| 264 | compat_ulong_t addr, compat_ulong_t data); |
| 265 | asmlinkage long compat_sys_ptrace(compat_long_t request, compat_long_t pid, |
| 266 | compat_long_t addr, compat_long_t data); |
Roland McGrath | c269f19 | 2008-01-30 13:31:48 +0100 | [diff] [blame] | 267 | |
Davide Libenzi | f6dfb4f | 2007-03-07 20:41:21 -0800 | [diff] [blame] | 268 | /* |
| 269 | * epoll (fs/eventpoll.c) compat bits follow ... |
| 270 | */ |
Davide Libenzi | f6dfb4f | 2007-03-07 20:41:21 -0800 | [diff] [blame] | 271 | struct epoll_event; |
| 272 | #define compat_epoll_event epoll_event |
Davide Libenzi | f6dfb4f | 2007-03-07 20:41:21 -0800 | [diff] [blame] | 273 | asmlinkage long compat_sys_epoll_pwait(int epfd, |
| 274 | struct compat_epoll_event __user *events, |
| 275 | int maxevents, int timeout, |
| 276 | const compat_sigset_t __user *sigmask, |
| 277 | compat_size_t sigsetsize); |
| 278 | |
Stephen Rothwell | 97416ce | 2007-05-09 02:32:35 -0700 | [diff] [blame] | 279 | asmlinkage long compat_sys_utimensat(unsigned int dfd, char __user *filename, |
| 280 | struct compat_timespec __user *t, int flags); |
| 281 | |
Stephen Rothwell | 140ff8b | 2007-05-14 13:47:47 +1000 | [diff] [blame] | 282 | asmlinkage long compat_sys_signalfd(int ufd, |
| 283 | const compat_sigset_t __user *sigmask, |
| 284 | compat_size_t sigsetsize); |
Davide Libenzi | 4d672e7 | 2008-02-04 22:27:26 -0800 | [diff] [blame] | 285 | asmlinkage long compat_sys_timerfd_settime(int ufd, int flags, |
| 286 | const struct compat_itimerspec __user *utmr, |
| 287 | struct compat_itimerspec __user *otmr); |
| 288 | asmlinkage long compat_sys_timerfd_gettime(int ufd, |
| 289 | struct compat_itimerspec __user *otmr); |
Stephen Rothwell | 140ff8b | 2007-05-14 13:47:47 +1000 | [diff] [blame] | 290 | |
Heiko Carstens | 4c696ba | 2009-01-14 14:13:53 +0100 | [diff] [blame] | 291 | asmlinkage long compat_sys_move_pages(pid_t pid, unsigned long nr_page, |
| 292 | __u32 __user *pages, |
| 293 | const int __user *nodes, |
| 294 | int __user *status, |
| 295 | int flags); |
| 296 | asmlinkage long compat_sys_futimesat(unsigned int dfd, char __user *filename, |
| 297 | struct compat_timeval __user *t); |
| 298 | asmlinkage long compat_sys_newfstatat(unsigned int dfd, char __user * filename, |
| 299 | struct compat_stat __user *statbuf, |
| 300 | int flag); |
| 301 | asmlinkage long compat_sys_openat(unsigned int dfd, const char __user *filename, |
| 302 | int flags, int mode); |
| 303 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 304 | #endif /* CONFIG_COMPAT */ |
| 305 | #endif /* _LINUX_COMPAT_H */ |