GNU Linux-libre 4.14.266-gnu1
[releases.git] / include / linux / shm.h
1 /* SPDX-License-Identifier: GPL-2.0 */
2 #ifndef _LINUX_SHM_H_
3 #define _LINUX_SHM_H_
4
5 #include <linux/list.h>
6 #include <asm/page.h>
7 #include <uapi/linux/shm.h>
8 #include <asm/shmparam.h>
9
10 struct shmid_kernel /* private to the kernel */
11 {       
12         struct kern_ipc_perm    shm_perm;
13         struct file             *shm_file;
14         unsigned long           shm_nattch;
15         unsigned long           shm_segsz;
16         time64_t                shm_atim;
17         time64_t                shm_dtim;
18         time64_t                shm_ctim;
19         pid_t                   shm_cprid;
20         pid_t                   shm_lprid;
21         struct user_struct      *mlock_user;
22
23         /*
24          * The task created the shm object, for
25          * task_lock(shp->shm_creator)
26          */
27         struct task_struct      *shm_creator;
28
29         /*
30          * List by creator. task_lock(->shm_creator) required for read/write.
31          * If list_empty(), then the creator is dead already.
32          */
33         struct list_head        shm_clist;
34         struct ipc_namespace    *ns;
35 } __randomize_layout;
36
37 /* shm_mode upper byte flags */
38 #define SHM_DEST        01000   /* segment will be destroyed on last detach */
39 #define SHM_LOCKED      02000   /* segment will not be swapped */
40
41 #ifdef CONFIG_SYSVIPC
42 struct sysv_shm {
43         struct list_head shm_clist;
44 };
45
46 long do_shmat(int shmid, char __user *shmaddr, int shmflg, unsigned long *addr,
47               unsigned long shmlba);
48 bool is_file_shm_hugepages(struct file *file);
49 void exit_shm(struct task_struct *task);
50 #define shm_init_task(task) INIT_LIST_HEAD(&(task)->sysvshm.shm_clist)
51 #else
52 struct sysv_shm {
53         /* empty */
54 };
55
56 static inline long do_shmat(int shmid, char __user *shmaddr,
57                             int shmflg, unsigned long *addr,
58                             unsigned long shmlba)
59 {
60         return -ENOSYS;
61 }
62 static inline bool is_file_shm_hugepages(struct file *file)
63 {
64         return false;
65 }
66 static inline void exit_shm(struct task_struct *task)
67 {
68 }
69 static inline void shm_init_task(struct task_struct *task)
70 {
71 }
72 #endif
73
74 #endif /* _LINUX_SHM_H_ */