shm.h 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  1. #ifndef _LINUX_SHM_H_
  2. #define _LINUX_SHM_H_
  3. #include <linux/list.h>
  4. #include <asm/page.h>
  5. #include <uapi/linux/shm.h>
  6. #include <asm/shmparam.h>
  7. struct shmid_kernel /* private to the kernel */
  8. {
  9. struct kern_ipc_perm shm_perm;
  10. struct file *shm_file;
  11. unsigned long shm_nattch;
  12. unsigned long shm_segsz;
  13. time64_t shm_atim;
  14. time64_t shm_dtim;
  15. time64_t shm_ctim;
  16. pid_t shm_cprid;
  17. pid_t shm_lprid;
  18. struct user_struct *mlock_user;
  19. /* The task created the shm object. NULL if the task is dead. */
  20. struct task_struct *shm_creator;
  21. struct list_head shm_clist; /* list by creator */
  22. } __randomize_layout;
  23. /* shm_mode upper byte flags */
  24. #define SHM_DEST 01000 /* segment will be destroyed on last detach */
  25. #define SHM_LOCKED 02000 /* segment will not be swapped */
  26. #ifdef CONFIG_SYSVIPC
  27. struct sysv_shm {
  28. struct list_head shm_clist;
  29. };
  30. long do_shmat(int shmid, char __user *shmaddr, int shmflg, unsigned long *addr,
  31. unsigned long shmlba);
  32. bool is_file_shm_hugepages(struct file *file);
  33. void exit_shm(struct task_struct *task);
  34. #define shm_init_task(task) INIT_LIST_HEAD(&(task)->sysvshm.shm_clist)
  35. #else
  36. struct sysv_shm {
  37. /* empty */
  38. };
  39. static inline long do_shmat(int shmid, char __user *shmaddr,
  40. int shmflg, unsigned long *addr,
  41. unsigned long shmlba)
  42. {
  43. return -ENOSYS;
  44. }
  45. static inline bool is_file_shm_hugepages(struct file *file)
  46. {
  47. return false;
  48. }
  49. static inline void exit_shm(struct task_struct *task)
  50. {
  51. }
  52. static inline void shm_init_task(struct task_struct *task)
  53. {
  54. }
  55. #endif
  56. #endif /* _LINUX_SHM_H_ */