compat.h 4.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217
  1. #ifndef _ASM_COMPAT_H
  2. #define _ASM_COMPAT_H
  3. /*
  4. * Architecture specific compatibility types
  5. */
  6. #include <linux/types.h>
  7. #include <asm/page.h>
  8. #define COMPAT_USER_HZ 100
  9. typedef u32 compat_size_t;
  10. typedef s32 compat_ssize_t;
  11. typedef s32 compat_time_t;
  12. typedef s32 compat_clock_t;
  13. typedef s32 compat_suseconds_t;
  14. typedef s32 compat_pid_t;
  15. typedef s32 __compat_uid_t;
  16. typedef s32 __compat_gid_t;
  17. typedef __compat_uid_t __compat_uid32_t;
  18. typedef __compat_gid_t __compat_gid32_t;
  19. typedef u32 compat_mode_t;
  20. typedef u32 compat_ino_t;
  21. typedef u32 compat_dev_t;
  22. typedef s32 compat_off_t;
  23. typedef s64 compat_loff_t;
  24. typedef u32 compat_nlink_t;
  25. typedef s32 compat_ipc_pid_t;
  26. typedef s32 compat_daddr_t;
  27. typedef s32 compat_caddr_t;
  28. typedef struct {
  29. s32 val[2];
  30. } compat_fsid_t;
  31. typedef s32 compat_timer_t;
  32. typedef s32 compat_key_t;
  33. typedef s32 compat_int_t;
  34. typedef s32 compat_long_t;
  35. typedef u32 compat_uint_t;
  36. typedef u32 compat_ulong_t;
  37. struct compat_timespec {
  38. compat_time_t tv_sec;
  39. s32 tv_nsec;
  40. };
  41. struct compat_timeval {
  42. compat_time_t tv_sec;
  43. s32 tv_usec;
  44. };
  45. struct compat_stat {
  46. compat_dev_t st_dev;
  47. s32 st_pad1[3];
  48. compat_ino_t st_ino;
  49. compat_mode_t st_mode;
  50. compat_nlink_t st_nlink;
  51. __compat_uid_t st_uid;
  52. __compat_gid_t st_gid;
  53. compat_dev_t st_rdev;
  54. s32 st_pad2[2];
  55. compat_off_t st_size;
  56. s32 st_pad3;
  57. compat_time_t st_atime;
  58. s32 st_atime_nsec;
  59. compat_time_t st_mtime;
  60. s32 st_mtime_nsec;
  61. compat_time_t st_ctime;
  62. s32 st_ctime_nsec;
  63. s32 st_blksize;
  64. s32 st_blocks;
  65. s32 st_pad4[14];
  66. };
  67. struct compat_flock {
  68. short l_type;
  69. short l_whence;
  70. compat_off_t l_start;
  71. compat_off_t l_len;
  72. s32 l_sysid;
  73. compat_pid_t l_pid;
  74. short __unused;
  75. s32 pad[4];
  76. };
  77. #define F_GETLK64 33
  78. #define F_SETLK64 34
  79. #define F_SETLKW64 35
  80. struct compat_flock64 {
  81. short l_type;
  82. short l_whence;
  83. compat_loff_t l_start;
  84. compat_loff_t l_len;
  85. compat_pid_t l_pid;
  86. };
  87. struct compat_statfs {
  88. int f_type;
  89. int f_bsize;
  90. int f_frsize;
  91. int f_blocks;
  92. int f_bfree;
  93. int f_files;
  94. int f_ffree;
  95. int f_bavail;
  96. compat_fsid_t f_fsid;
  97. int f_namelen;
  98. int f_spare[6];
  99. };
  100. #define COMPAT_RLIM_INFINITY 0x7fffffffUL
  101. typedef u32 compat_old_sigset_t; /* at least 32 bits */
  102. #define _COMPAT_NSIG 128 /* Don't ask !$@#% ... */
  103. #define _COMPAT_NSIG_BPW 32
  104. typedef u32 compat_sigset_word;
  105. #define COMPAT_OFF_T_MAX 0x7fffffff
  106. #define COMPAT_LOFF_T_MAX 0x7fffffffffffffffL
  107. /*
  108. * A pointer passed in from user mode. This should not
  109. * be used for syscall parameters, just declare them
  110. * as pointers because the syscall entry code will have
  111. * appropriately comverted them already.
  112. */
  113. typedef u32 compat_uptr_t;
  114. static inline void __user *compat_ptr(compat_uptr_t uptr)
  115. {
  116. return (void __user *)(long)uptr;
  117. }
  118. static inline compat_uptr_t ptr_to_compat(void __user *uptr)
  119. {
  120. return (u32)(unsigned long)uptr;
  121. }
  122. static inline void __user *compat_alloc_user_space(long len)
  123. {
  124. struct pt_regs *regs = (struct pt_regs *)
  125. ((unsigned long) current_thread_info() + THREAD_SIZE - 32) - 1;
  126. return (void __user *) (regs->regs[29] - len);
  127. }
  128. struct compat_ipc64_perm {
  129. compat_key_t key;
  130. __compat_uid32_t uid;
  131. __compat_gid32_t gid;
  132. __compat_uid32_t cuid;
  133. __compat_gid32_t cgid;
  134. compat_mode_t mode;
  135. unsigned short seq;
  136. unsigned short __pad2;
  137. compat_ulong_t __unused1;
  138. compat_ulong_t __unused2;
  139. };
  140. struct compat_semid64_ds {
  141. struct compat_ipc64_perm sem_perm;
  142. compat_time_t sem_otime;
  143. compat_time_t sem_ctime;
  144. compat_ulong_t sem_nsems;
  145. compat_ulong_t __unused1;
  146. compat_ulong_t __unused2;
  147. };
  148. struct compat_msqid64_ds {
  149. struct compat_ipc64_perm msg_perm;
  150. #ifndef CONFIG_CPU_LITTLE_ENDIAN
  151. compat_ulong_t __unused1;
  152. #endif
  153. compat_time_t msg_stime;
  154. #ifdef CONFIG_CPU_LITTLE_ENDIAN
  155. compat_ulong_t __unused1;
  156. #endif
  157. #ifndef CONFIG_CPU_LITTLE_ENDIAN
  158. compat_ulong_t __unused2;
  159. #endif
  160. compat_time_t msg_rtime;
  161. #ifdef CONFIG_CPU_LITTLE_ENDIAN
  162. compat_ulong_t __unused2;
  163. #endif
  164. #ifndef CONFIG_CPU_LITTLE_ENDIAN
  165. compat_ulong_t __unused3;
  166. #endif
  167. compat_time_t msg_ctime;
  168. #ifdef CONFIG_CPU_LITTLE_ENDIAN
  169. compat_ulong_t __unused3;
  170. #endif
  171. compat_ulong_t msg_cbytes;
  172. compat_ulong_t msg_qnum;
  173. compat_ulong_t msg_qbytes;
  174. compat_pid_t msg_lspid;
  175. compat_pid_t msg_lrpid;
  176. compat_ulong_t __unused4;
  177. compat_ulong_t __unused5;
  178. };
  179. struct compat_shmid64_ds {
  180. struct compat_ipc64_perm shm_perm;
  181. compat_size_t shm_segsz;
  182. compat_time_t shm_atime;
  183. compat_time_t shm_dtime;
  184. compat_time_t shm_ctime;
  185. compat_pid_t shm_cpid;
  186. compat_pid_t shm_lpid;
  187. compat_ulong_t shm_nattch;
  188. compat_ulong_t __unused1;
  189. compat_ulong_t __unused2;
  190. };
  191. #endif /* _ASM_COMPAT_H */