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 <asm/compat.h>
17 #include <asm/siginfo.h>
18 #include <asm/signal.h>
20 #define compat_jiffies_to_clock_t(x) \
21 (((unsigned long)(x) * COMPAT_USER_HZ) / HZ)
23 typedef __compat_uid32_t compat_uid_t
;
24 typedef __compat_gid32_t compat_gid_t
;
26 struct compat_sel_arg_struct
;
29 struct compat_itimerspec
{
30 struct compat_timespec it_interval
;
31 struct compat_timespec it_value
;
34 struct compat_utimbuf
{
36 compat_time_t modtime
;
39 struct compat_itimerval
{
40 struct compat_timeval it_interval
;
41 struct compat_timeval it_value
;
45 compat_clock_t tms_utime
;
46 compat_clock_t tms_stime
;
47 compat_clock_t tms_cutime
;
48 compat_clock_t tms_cstime
;
55 compat_long_t maxerror
;
56 compat_long_t esterror
;
58 compat_long_t constant
;
59 compat_long_t precision
;
60 compat_long_t tolerance
;
61 struct compat_timeval time
;
63 compat_long_t ppsfreq
;
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;
75 compat_int_t
:32; compat_int_t
:32; compat_int_t
:32;
78 #define _COMPAT_NSIG_WORDS (_COMPAT_NSIG / _COMPAT_NSIG_BPW)
81 compat_sigset_word sig
[_COMPAT_NSIG_WORDS
];
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
*);
88 compat_uptr_t iov_base
;
89 compat_size_t iov_len
;
92 struct compat_rlimit
{
93 compat_ulong_t rlim_cur
;
94 compat_ulong_t rlim_max
;
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
;
116 extern int put_compat_rusage(const struct rusage
*, struct compat_rusage __user
*);
118 struct compat_siginfo
;
120 extern asmlinkage
long compat_sys_waitid(int, compat_pid_t
,
121 struct compat_siginfo __user
*, int,
122 struct compat_rusage __user
*);
124 struct compat_dirent
{
131 struct compat_ustat
{
132 compat_daddr_t f_tfree
;
133 compat_ino_t f_tinode
;
138 typedef union compat_sigval
{
139 compat_int_t sival_int
;
140 compat_uptr_t sival_ptr
;
143 #define COMPAT_SIGEV_PAD_SIZE ((SIGEV_MAX_SIZE/sizeof(int)) - 3)
145 typedef struct compat_sigevent
{
146 compat_sigval_t sigev_value
;
147 compat_int_t sigev_signo
;
148 compat_int_t sigev_notify
;
150 compat_int_t _pad
[COMPAT_SIGEV_PAD_SIZE
];
154 compat_uptr_t _function
;
155 compat_uptr_t _attribute
;
160 struct compat_ifmap
{
161 compat_ulong_t mem_start
;
162 compat_ulong_t mem_end
;
163 unsigned short base_addr
;
169 struct compat_if_settings
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 */
176 struct compat_ifreq
{
178 char ifrn_name
[IFNAMSIZ
]; /* if name, e.g. "en0" */
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
;
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 */
191 char ifru_newname
[IFNAMSIZ
];
192 compat_caddr_t ifru_data
;
193 struct compat_if_settings ifru_settings
;
197 struct compat_ifconf
{
198 compat_int_t ifc_len
; /* size of buffer */
199 compat_caddr_t ifcbuf
;
202 struct compat_robust_list
{
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
;
212 extern void compat_exit_robust_list(struct task_struct
*curr
);
215 compat_sys_set_robust_list(struct compat_robust_list_head __user
*head
,
218 compat_sys_get_robust_list(int pid
, compat_uptr_t __user
*head_ptr
,
219 compat_size_t __user
*len_ptr
);
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
,
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
);
233 asmlinkage
long compat_sys_ustat(unsigned dev
, struct compat_ustat __user
*u32
);
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
);
239 asmlinkage ssize_t
compat_sys_preadv(unsigned long fd
,
240 const struct compat_iovec __user
*vec
,
241 unsigned long vlen
, u32 pos_low
, u32 pos_high
);
242 asmlinkage ssize_t
compat_sys_pwritev(unsigned long fd
,
243 const struct compat_iovec __user
*vec
,
244 unsigned long vlen
, u32 pos_low
, u32 pos_high
);
246 int compat_do_execve(char * filename
, compat_uptr_t __user
*argv
,
247 compat_uptr_t __user
*envp
, struct pt_regs
* regs
);
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
);
253 asmlinkage
long compat_sys_old_select(struct compat_sel_arg_struct __user
*arg
);
255 asmlinkage
long compat_sys_wait4(compat_pid_t pid
,
256 compat_uint_t __user
*stat_addr
, int options
,
257 struct compat_rusage __user
*ru
);
259 #define BITS_PER_COMPAT_LONG (8*sizeof(compat_long_t))
261 #define BITS_TO_COMPAT_LONGS(bits) \
262 (((bits)+BITS_PER_COMPAT_LONG-1)/BITS_PER_COMPAT_LONG)
264 long compat_get_bitmap(unsigned long *mask
, const compat_ulong_t __user
*umask
,
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
);
272 long compat_sys_rt_tgsigqueueinfo(compat_pid_t tgid
, compat_pid_t pid
, int sig
,
273 struct compat_siginfo __user
*uinfo
);
275 static inline int compat_timeval_compare(struct compat_timeval
*lhs
,
276 struct compat_timeval
*rhs
)
278 if (lhs
->tv_sec
< rhs
->tv_sec
)
280 if (lhs
->tv_sec
> rhs
->tv_sec
)
282 return lhs
->tv_usec
- rhs
->tv_usec
;
285 static inline int compat_timespec_compare(struct compat_timespec
*lhs
,
286 struct compat_timespec
*rhs
)
288 if (lhs
->tv_sec
< rhs
->tv_sec
)
290 if (lhs
->tv_sec
> rhs
->tv_sec
)
292 return lhs
->tv_nsec
- rhs
->tv_nsec
;
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
);
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
);
305 asmlinkage
long compat_sys_adjtimex(struct compat_timex __user
*utp
);
307 extern int compat_printk(const char *fmt
, ...);
308 extern void sigset_from_compat(sigset_t
*set
, compat_sigset_t
*compat
);
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
);
314 extern int compat_ptrace_request(struct task_struct
*child
,
315 compat_long_t request
,
316 compat_ulong_t addr
, compat_ulong_t data
);
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
);
324 * epoll (fs/eventpoll.c) compat bits follow ...
327 #define compat_epoll_event epoll_event
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
);
334 asmlinkage
long compat_sys_utimensat(unsigned int dfd
, char __user
*filename
,
335 struct compat_timespec __user
*t
, int flags
);
337 asmlinkage
long compat_sys_signalfd(int ufd
,
338 const compat_sigset_t __user
*sigmask
,
339 compat_size_t sigsetsize
);
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
);
346 asmlinkage
long compat_sys_move_pages(pid_t pid
, unsigned long nr_page
,
348 const int __user
*nodes
,
351 asmlinkage
long compat_sys_futimesat(unsigned int dfd
, char __user
*filename
,
352 struct compat_timeval __user
*t
);
353 asmlinkage
long compat_sys_newfstatat(unsigned int dfd
, char __user
* filename
,
354 struct compat_stat __user
*statbuf
,
356 asmlinkage
long compat_sys_openat(unsigned int dfd
, const char __user
*filename
,
357 int flags
, int mode
);
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
);
363 #endif /* CONFIG_COMPAT */
364 #endif /* _LINUX_COMPAT_H */