diff options
Diffstat (limited to 'ipc/shm.c')
-rw-r--r-- | ipc/shm.c | 26 |
1 files changed, 4 insertions, 22 deletions
@@ -56,9 +56,7 @@ struct shm_file_data { | |||
56 | static const struct file_operations shm_file_operations; | 56 | static const struct file_operations shm_file_operations; |
57 | static struct vm_operations_struct shm_vm_ops; | 57 | static struct vm_operations_struct shm_vm_ops; |
58 | 58 | ||
59 | static struct ipc_ids init_shm_ids; | 59 | #define shm_ids(ns) ((ns)->ids[IPC_SHM_IDS]) |
60 | |||
61 | #define shm_ids(ns) (*((ns)->ids[IPC_SHM_IDS])) | ||
62 | 60 | ||
63 | #define shm_unlock(shp) \ | 61 | #define shm_unlock(shp) \ |
64 | ipc_unlock(&(shp)->shm_perm) | 62 | ipc_unlock(&(shp)->shm_perm) |
@@ -72,14 +70,13 @@ static void shm_destroy (struct ipc_namespace *ns, struct shmid_kernel *shp); | |||
72 | static int sysvipc_shm_proc_show(struct seq_file *s, void *it); | 70 | static int sysvipc_shm_proc_show(struct seq_file *s, void *it); |
73 | #endif | 71 | #endif |
74 | 72 | ||
75 | static void __shm_init_ns(struct ipc_namespace *ns, struct ipc_ids *ids) | 73 | void shm_init_ns(struct ipc_namespace *ns) |
76 | { | 74 | { |
77 | ns->ids[IPC_SHM_IDS] = ids; | ||
78 | ns->shm_ctlmax = SHMMAX; | 75 | ns->shm_ctlmax = SHMMAX; |
79 | ns->shm_ctlall = SHMALL; | 76 | ns->shm_ctlall = SHMALL; |
80 | ns->shm_ctlmni = SHMMNI; | 77 | ns->shm_ctlmni = SHMMNI; |
81 | ns->shm_tot = 0; | 78 | ns->shm_tot = 0; |
82 | ipc_init_ids(ids); | 79 | ipc_init_ids(&ns->ids[IPC_SHM_IDS]); |
83 | } | 80 | } |
84 | 81 | ||
85 | /* | 82 | /* |
@@ -98,18 +95,6 @@ static void do_shm_rmid(struct ipc_namespace *ns, struct shmid_kernel *shp) | |||
98 | } | 95 | } |
99 | 96 | ||
100 | #ifdef CONFIG_IPC_NS | 97 | #ifdef CONFIG_IPC_NS |
101 | int shm_init_ns(struct ipc_namespace *ns) | ||
102 | { | ||
103 | struct ipc_ids *ids; | ||
104 | |||
105 | ids = kmalloc(sizeof(struct ipc_ids), GFP_KERNEL); | ||
106 | if (ids == NULL) | ||
107 | return -ENOMEM; | ||
108 | |||
109 | __shm_init_ns(ns, ids); | ||
110 | return 0; | ||
111 | } | ||
112 | |||
113 | void shm_exit_ns(struct ipc_namespace *ns) | 98 | void shm_exit_ns(struct ipc_namespace *ns) |
114 | { | 99 | { |
115 | struct shmid_kernel *shp; | 100 | struct shmid_kernel *shp; |
@@ -131,15 +116,12 @@ void shm_exit_ns(struct ipc_namespace *ns) | |||
131 | total++; | 116 | total++; |
132 | } | 117 | } |
133 | up_write(&shm_ids(ns).rw_mutex); | 118 | up_write(&shm_ids(ns).rw_mutex); |
134 | |||
135 | kfree(ns->ids[IPC_SHM_IDS]); | ||
136 | ns->ids[IPC_SHM_IDS] = NULL; | ||
137 | } | 119 | } |
138 | #endif | 120 | #endif |
139 | 121 | ||
140 | void __init shm_init (void) | 122 | void __init shm_init (void) |
141 | { | 123 | { |
142 | __shm_init_ns(&init_ipc_ns, &init_shm_ids); | 124 | shm_init_ns(&init_ipc_ns); |
143 | ipc_init_proc_interface("sysvipc/shm", | 125 | ipc_init_proc_interface("sysvipc/shm", |
144 | " key shmid perms size cpid lpid nattch uid gid cuid cgid atime dtime ctime\n", | 126 | " key shmid perms size cpid lpid nattch uid gid cuid cgid atime dtime ctime\n", |
145 | IPC_SHM_IDS, sysvipc_shm_proc_show); | 127 | IPC_SHM_IDS, sysvipc_shm_proc_show); |