compat.h 7.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257
  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. #ifdef CONFIG_COMPAT
  8. #include <linux/stat.h>
  9. #include <linux/param.h> /* for HZ */
  10. #include <linux/sem.h>
  11. #include <asm/compat.h>
  12. #include <asm/siginfo.h>
  13. #include <asm/signal.h>
  14. #define compat_jiffies_to_clock_t(x) \
  15. (((unsigned long)(x) * COMPAT_USER_HZ) / HZ)
  16. typedef __compat_uid32_t compat_uid_t;
  17. typedef __compat_gid32_t compat_gid_t;
  18. struct rusage;
  19. struct compat_itimerspec {
  20. struct compat_timespec it_interval;
  21. struct compat_timespec it_value;
  22. };
  23. struct compat_utimbuf {
  24. compat_time_t actime;
  25. compat_time_t modtime;
  26. };
  27. struct compat_itimerval {
  28. struct compat_timeval it_interval;
  29. struct compat_timeval it_value;
  30. };
  31. struct compat_tms {
  32. compat_clock_t tms_utime;
  33. compat_clock_t tms_stime;
  34. compat_clock_t tms_cutime;
  35. compat_clock_t tms_cstime;
  36. };
  37. struct compat_timex {
  38. compat_uint_t modes;
  39. compat_long_t offset;
  40. compat_long_t freq;
  41. compat_long_t maxerror;
  42. compat_long_t esterror;
  43. compat_int_t status;
  44. compat_long_t constant;
  45. compat_long_t precision;
  46. compat_long_t tolerance;
  47. struct compat_timeval time;
  48. compat_long_t tick;
  49. compat_long_t ppsfreq;
  50. compat_long_t jitter;
  51. compat_int_t shift;
  52. compat_long_t stabil;
  53. compat_long_t jitcnt;
  54. compat_long_t calcnt;
  55. compat_long_t errcnt;
  56. compat_long_t stbcnt;
  57. compat_int_t :32; compat_int_t :32; compat_int_t :32; compat_int_t :32;
  58. compat_int_t :32; compat_int_t :32; compat_int_t :32; compat_int_t :32;
  59. compat_int_t :32; compat_int_t :32; compat_int_t :32; compat_int_t :32;
  60. };
  61. #define _COMPAT_NSIG_WORDS (_COMPAT_NSIG / _COMPAT_NSIG_BPW)
  62. typedef struct {
  63. compat_sigset_word sig[_COMPAT_NSIG_WORDS];
  64. } compat_sigset_t;
  65. extern int cp_compat_stat(struct kstat *, struct compat_stat __user *);
  66. extern int get_compat_timespec(struct timespec *, const struct compat_timespec __user *);
  67. extern int put_compat_timespec(const struct timespec *, struct compat_timespec __user *);
  68. struct compat_iovec {
  69. compat_uptr_t iov_base;
  70. compat_size_t iov_len;
  71. };
  72. struct compat_rlimit {
  73. compat_ulong_t rlim_cur;
  74. compat_ulong_t rlim_max;
  75. };
  76. struct compat_rusage {
  77. struct compat_timeval ru_utime;
  78. struct compat_timeval ru_stime;
  79. compat_long_t ru_maxrss;
  80. compat_long_t ru_ixrss;
  81. compat_long_t ru_idrss;
  82. compat_long_t ru_isrss;
  83. compat_long_t ru_minflt;
  84. compat_long_t ru_majflt;
  85. compat_long_t ru_nswap;
  86. compat_long_t ru_inblock;
  87. compat_long_t ru_oublock;
  88. compat_long_t ru_msgsnd;
  89. compat_long_t ru_msgrcv;
  90. compat_long_t ru_nsignals;
  91. compat_long_t ru_nvcsw;
  92. compat_long_t ru_nivcsw;
  93. };
  94. extern int put_compat_rusage(const struct rusage *, struct compat_rusage __user *);
  95. struct compat_siginfo;
  96. extern asmlinkage long compat_sys_waitid(int, compat_pid_t,
  97. struct compat_siginfo __user *, int,
  98. struct compat_rusage __user *);
  99. struct compat_dirent {
  100. u32 d_ino;
  101. compat_off_t d_off;
  102. u16 d_reclen;
  103. char d_name[256];
  104. };
  105. typedef union compat_sigval {
  106. compat_int_t sival_int;
  107. compat_uptr_t sival_ptr;
  108. } compat_sigval_t;
  109. #define COMPAT_SIGEV_PAD_SIZE ((SIGEV_MAX_SIZE/sizeof(int)) - 3)
  110. typedef struct compat_sigevent {
  111. compat_sigval_t sigev_value;
  112. compat_int_t sigev_signo;
  113. compat_int_t sigev_notify;
  114. union {
  115. compat_int_t _pad[COMPAT_SIGEV_PAD_SIZE];
  116. compat_int_t _tid;
  117. struct {
  118. compat_uptr_t _function;
  119. compat_uptr_t _attribute;
  120. } _sigev_thread;
  121. } _sigev_un;
  122. } compat_sigevent_t;
  123. struct compat_robust_list {
  124. compat_uptr_t next;
  125. };
  126. struct compat_robust_list_head {
  127. struct compat_robust_list list;
  128. compat_long_t futex_offset;
  129. compat_uptr_t list_op_pending;
  130. };
  131. extern void compat_exit_robust_list(struct task_struct *curr);
  132. asmlinkage long
  133. compat_sys_set_robust_list(struct compat_robust_list_head __user *head,
  134. compat_size_t len);
  135. asmlinkage long
  136. compat_sys_get_robust_list(int pid, compat_uptr_t __user *head_ptr,
  137. compat_size_t __user *len_ptr);
  138. long compat_sys_semctl(int first, int second, int third, void __user *uptr);
  139. long compat_sys_msgsnd(int first, int second, int third, void __user *uptr);
  140. long compat_sys_msgrcv(int first, int second, int msgtyp, int third,
  141. int version, void __user *uptr);
  142. long compat_sys_msgctl(int first, int second, void __user *uptr);
  143. long compat_sys_shmat(int first, int second, compat_uptr_t third, int version,
  144. void __user *uptr);
  145. long compat_sys_shmctl(int first, int second, void __user *uptr);
  146. long compat_sys_semtimedop(int semid, struct sembuf __user *tsems,
  147. unsigned nsems, const struct compat_timespec __user *timeout);
  148. asmlinkage long compat_sys_keyctl(u32 option,
  149. u32 arg2, u32 arg3, u32 arg4, u32 arg5);
  150. asmlinkage ssize_t compat_sys_readv(unsigned long fd,
  151. const struct compat_iovec __user *vec, unsigned long vlen);
  152. asmlinkage ssize_t compat_sys_writev(unsigned long fd,
  153. const struct compat_iovec __user *vec, unsigned long vlen);
  154. int compat_do_execve(char * filename, compat_uptr_t __user *argv,
  155. compat_uptr_t __user *envp, struct pt_regs * regs);
  156. asmlinkage long compat_sys_select(int n, compat_ulong_t __user *inp,
  157. compat_ulong_t __user *outp, compat_ulong_t __user *exp,
  158. struct compat_timeval __user *tvp);
  159. #define BITS_PER_COMPAT_LONG (8*sizeof(compat_long_t))
  160. #define BITS_TO_COMPAT_LONGS(bits) \
  161. (((bits)+BITS_PER_COMPAT_LONG-1)/BITS_PER_COMPAT_LONG)
  162. long compat_get_bitmap(unsigned long *mask, const compat_ulong_t __user *umask,
  163. unsigned long bitmap_size);
  164. long compat_put_bitmap(compat_ulong_t __user *umask, unsigned long *mask,
  165. unsigned long bitmap_size);
  166. int copy_siginfo_from_user32(siginfo_t *to, struct compat_siginfo __user *from);
  167. int copy_siginfo_to_user32(struct compat_siginfo __user *to, siginfo_t *from);
  168. int get_compat_sigevent(struct sigevent *event,
  169. const struct compat_sigevent __user *u_event);
  170. static inline int compat_timeval_compare(struct compat_timeval *lhs,
  171. struct compat_timeval *rhs)
  172. {
  173. if (lhs->tv_sec < rhs->tv_sec)
  174. return -1;
  175. if (lhs->tv_sec > rhs->tv_sec)
  176. return 1;
  177. return lhs->tv_usec - rhs->tv_usec;
  178. }
  179. static inline int compat_timespec_compare(struct compat_timespec *lhs,
  180. struct compat_timespec *rhs)
  181. {
  182. if (lhs->tv_sec < rhs->tv_sec)
  183. return -1;
  184. if (lhs->tv_sec > rhs->tv_sec)
  185. return 1;
  186. return lhs->tv_nsec - rhs->tv_nsec;
  187. }
  188. asmlinkage long compat_sys_adjtimex(struct compat_timex __user *utp);
  189. extern int compat_printk(const char *fmt, ...);
  190. extern void sigset_from_compat(sigset_t *set, compat_sigset_t *compat);
  191. asmlinkage long compat_sys_migrate_pages(compat_pid_t pid,
  192. compat_ulong_t maxnode, const compat_ulong_t __user *old_nodes,
  193. const compat_ulong_t __user *new_nodes);
  194. /*
  195. * epoll (fs/eventpoll.c) compat bits follow ...
  196. */
  197. #ifndef CONFIG_HAS_COMPAT_EPOLL_EVENT
  198. struct epoll_event;
  199. #define compat_epoll_event epoll_event
  200. #else
  201. asmlinkage long compat_sys_epoll_ctl(int epfd, int op, int fd,
  202. struct compat_epoll_event __user *event);
  203. asmlinkage long compat_sys_epoll_wait(int epfd,
  204. struct compat_epoll_event __user *events,
  205. int maxevents, int timeout);
  206. #endif
  207. asmlinkage long compat_sys_epoll_pwait(int epfd,
  208. struct compat_epoll_event __user *events,
  209. int maxevents, int timeout,
  210. const compat_sigset_t __user *sigmask,
  211. compat_size_t sigsetsize);
  212. #endif /* CONFIG_COMPAT */
  213. #endif /* _LINUX_COMPAT_H */