linux/include/linux/compat.h
<<
>>
Prefs
   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 */
   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>
  16#include <asm/signal.h>
  17
  18#define compat_jiffies_to_clock_t(x)    \
  19                (((unsigned long)(x) * COMPAT_USER_HZ) / HZ)
  20
  21typedef __compat_uid32_t        compat_uid_t;
  22typedef __compat_gid32_t        compat_gid_t;
  23
  24struct 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
  48struct 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;
  68
  69        compat_int_t :32; compat_int_t :32; compat_int_t :32; compat_int_t :32;
  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;
  72};
  73
  74#define _COMPAT_NSIG_WORDS      (_COMPAT_NSIG / _COMPAT_NSIG_BPW)
  75
  76typedef struct {
  77        compat_sigset_word      sig[_COMPAT_NSIG_WORDS];
  78} compat_sigset_t;
  79
  80extern int cp_compat_stat(struct kstat *, struct compat_stat __user *);
  81extern 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
 150struct 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
 166compat_sys_get_robust_list(int pid, compat_uptr_t __user *head_ptr,
 167                           compat_size_t __user *len_ptr);
 168
 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
 194#define BITS_PER_COMPAT_LONG    (8*sizeof(compat_long_t))
 195
 196#define BITS_TO_COMPAT_LONGS(bits) \
 197        (((bits)+BITS_PER_COMPAT_LONG-1)/BITS_PER_COMPAT_LONG)
 198
 199long compat_get_bitmap(unsigned long *mask, const compat_ulong_t __user *umask,
 200                       unsigned long bitmap_size);
 201long compat_put_bitmap(compat_ulong_t __user *umask, unsigned long *mask,
 202                       unsigned long bitmap_size);
 203int copy_siginfo_from_user32(siginfo_t *to, struct compat_siginfo __user *from);
 204int copy_siginfo_to_user32(struct compat_siginfo __user *to, siginfo_t *from);
 205int get_compat_sigevent(struct sigevent *event,
 206                const struct compat_sigevent __user *u_event);
 207
 208static inline int compat_timeval_compare(struct compat_timeval *lhs,
 209                                        struct compat_timeval *rhs)
 210{
 211        if (lhs->tv_sec < rhs->tv_sec)
 212                return -1;
 213        if (lhs->tv_sec > rhs->tv_sec)
 214                return 1;
 215        return lhs->tv_usec - rhs->tv_usec;
 216}
 217
 218static inline int compat_timespec_compare(struct compat_timespec *lhs,
 219                                        struct compat_timespec *rhs)
 220{
 221        if (lhs->tv_sec < rhs->tv_sec)
 222                return -1;
 223        if (lhs->tv_sec > rhs->tv_sec)
 224                return 1;
 225        return lhs->tv_nsec - rhs->tv_nsec;
 226}
 227
 228extern int get_compat_itimerspec(struct itimerspec *dst,
 229                                 const struct compat_itimerspec __user *src);
 230extern int put_compat_itimerspec(struct compat_itimerspec __user *dst,
 231                                 const struct itimerspec *src);
 232
 233asmlinkage long compat_sys_adjtimex(struct compat_timex __user *utp);
 234
 235extern int compat_printk(const char *fmt, ...);
 236extern void sigset_from_compat(sigset_t *set, compat_sigset_t *compat);
 237
 238asmlinkage long compat_sys_migrate_pages(compat_pid_t pid,
 239                compat_ulong_t maxnode, const compat_ulong_t __user *old_nodes,
 240                const compat_ulong_t __user *new_nodes);
 241
 242/*
 243 * epoll (fs/eventpoll.c) compat bits follow ...
 244 */
 245#ifndef CONFIG_HAS_COMPAT_EPOLL_EVENT
 246struct epoll_event;
 247#define compat_epoll_event      epoll_event
 248#else
 249asmlinkage long compat_sys_epoll_ctl(int epfd, int op, int fd,
 250                        struct compat_epoll_event __user *event);
 251asmlinkage long compat_sys_epoll_wait(int epfd,
 252                        struct compat_epoll_event __user *events,
 253                        int maxevents, int timeout);
 254#endif
 255asmlinkage long compat_sys_epoll_pwait(int epfd,
 256                        struct compat_epoll_event __user *events,
 257                        int maxevents, int timeout,
 258                        const compat_sigset_t __user *sigmask,
 259                        compat_size_t sigsetsize);
 260
 261asmlinkage long compat_sys_utimensat(unsigned int dfd, char __user *filename,
 262                                struct compat_timespec __user *t, int flags);
 263
 264asmlinkage long compat_sys_signalfd(int ufd,
 265                                const compat_sigset_t __user *sigmask,
 266                                compat_size_t sigsetsize);
 267asmlinkage long compat_sys_timerfd(int ufd, int clockid, int flags,
 268                                const struct compat_itimerspec __user *utmr);
 269
 270#endif /* CONFIG_COMPAT */
 271#endif /* _LINUX_COMPAT_H */
 272