compat.h 4.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165
  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. #include <linux/config.h>
  8. #ifdef CONFIG_COMPAT
  9. #include <linux/stat.h>
  10. #include <linux/param.h> /* for HZ */
  11. #include <linux/sem.h>
  12. #include <asm/compat.h>
  13. #include <asm/siginfo.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. #define _COMPAT_NSIG_WORDS (_COMPAT_NSIG / _COMPAT_NSIG_BPW)
  38. typedef struct {
  39. compat_sigset_word sig[_COMPAT_NSIG_WORDS];
  40. } compat_sigset_t;
  41. extern int cp_compat_stat(struct kstat *, struct compat_stat __user *);
  42. extern int get_compat_timespec(struct timespec *, const struct compat_timespec __user *);
  43. extern int put_compat_timespec(const struct timespec *, struct compat_timespec __user *);
  44. struct compat_iovec {
  45. compat_uptr_t iov_base;
  46. compat_size_t iov_len;
  47. };
  48. struct compat_rlimit {
  49. compat_ulong_t rlim_cur;
  50. compat_ulong_t rlim_max;
  51. };
  52. struct compat_rusage {
  53. struct compat_timeval ru_utime;
  54. struct compat_timeval ru_stime;
  55. compat_long_t ru_maxrss;
  56. compat_long_t ru_ixrss;
  57. compat_long_t ru_idrss;
  58. compat_long_t ru_isrss;
  59. compat_long_t ru_minflt;
  60. compat_long_t ru_majflt;
  61. compat_long_t ru_nswap;
  62. compat_long_t ru_inblock;
  63. compat_long_t ru_oublock;
  64. compat_long_t ru_msgsnd;
  65. compat_long_t ru_msgrcv;
  66. compat_long_t ru_nsignals;
  67. compat_long_t ru_nvcsw;
  68. compat_long_t ru_nivcsw;
  69. };
  70. extern int put_compat_rusage(const struct rusage *, struct compat_rusage __user *);
  71. struct compat_siginfo;
  72. extern asmlinkage long compat_sys_waitid(int, compat_pid_t,
  73. struct compat_siginfo __user *, int,
  74. struct compat_rusage __user *);
  75. struct compat_dirent {
  76. u32 d_ino;
  77. compat_off_t d_off;
  78. u16 d_reclen;
  79. char d_name[256];
  80. };
  81. typedef union compat_sigval {
  82. compat_int_t sival_int;
  83. compat_uptr_t sival_ptr;
  84. } compat_sigval_t;
  85. #define COMPAT_SIGEV_PAD_SIZE ((SIGEV_MAX_SIZE/sizeof(int)) - 3)
  86. typedef struct compat_sigevent {
  87. compat_sigval_t sigev_value;
  88. compat_int_t sigev_signo;
  89. compat_int_t sigev_notify;
  90. union {
  91. compat_int_t _pad[COMPAT_SIGEV_PAD_SIZE];
  92. compat_int_t _tid;
  93. struct {
  94. compat_uptr_t _function;
  95. compat_uptr_t _attribute;
  96. } _sigev_thread;
  97. } _sigev_un;
  98. } compat_sigevent_t;
  99. long compat_sys_semctl(int first, int second, int third, void __user *uptr);
  100. long compat_sys_msgsnd(int first, int second, int third, void __user *uptr);
  101. long compat_sys_msgrcv(int first, int second, int msgtyp, int third,
  102. int version, void __user *uptr);
  103. long compat_sys_msgctl(int first, int second, void __user *uptr);
  104. long compat_sys_shmat(int first, int second, compat_uptr_t third, int version,
  105. void __user *uptr);
  106. long compat_sys_shmctl(int first, int second, void __user *uptr);
  107. long compat_sys_semtimedop(int semid, struct sembuf __user *tsems,
  108. unsigned nsems, const struct compat_timespec __user *timeout);
  109. asmlinkage long compat_sys_keyctl(u32 option,
  110. u32 arg2, u32 arg3, u32 arg4, u32 arg5);
  111. asmlinkage ssize_t compat_sys_readv(unsigned long fd,
  112. const struct compat_iovec __user *vec, unsigned long vlen);
  113. asmlinkage ssize_t compat_sys_writev(unsigned long fd,
  114. const struct compat_iovec __user *vec, unsigned long vlen);
  115. int compat_do_execve(char * filename, compat_uptr_t __user *argv,
  116. compat_uptr_t __user *envp, struct pt_regs * regs);
  117. asmlinkage long compat_sys_select(int n, compat_ulong_t __user *inp,
  118. compat_ulong_t __user *outp, compat_ulong_t __user *exp,
  119. struct compat_timeval __user *tvp);
  120. #define BITS_PER_COMPAT_LONG (8*sizeof(compat_long_t))
  121. #define BITS_TO_COMPAT_LONGS(bits) \
  122. (((bits)+BITS_PER_COMPAT_LONG-1)/BITS_PER_COMPAT_LONG)
  123. long compat_get_bitmap(unsigned long *mask, compat_ulong_t __user *umask,
  124. unsigned long bitmap_size);
  125. long compat_put_bitmap(compat_ulong_t __user *umask, unsigned long *mask,
  126. unsigned long bitmap_size);
  127. int copy_siginfo_from_user32(siginfo_t *to, struct compat_siginfo __user *from);
  128. int copy_siginfo_to_user32(struct compat_siginfo __user *to, siginfo_t *from);
  129. int get_compat_sigevent(struct sigevent *event,
  130. const struct compat_sigevent __user *u_event);
  131. #endif /* CONFIG_COMPAT */
  132. #endif /* _LINUX_COMPAT_H */