aboutsummaryrefslogtreecommitdiffstats
path: root/ipc
diff options
context:
space:
mode:
authorPierre Peiffer <pierre.peiffer@bull.net>2008-04-29 04:00:35 -0400
committerLinus Torvalds <torvalds@linux-foundation.org>2008-04-29 11:06:12 -0400
commit48dea404ed01869313f1908cca8a15774dcd8ee5 (patch)
treec4c50c9032556cf96b21f8704e4544998769b6b9 /ipc
parent02d15c43225afb2ebb6d700144285175a1c4abd9 (diff)
IPC: use ipc_buildid() directly from ipc_addid()
By continuing to consolidate a little the IPC code, each id can be built directly in ipc_addid() instead of having it built from each callers of ipc_addid() And I also remove shm_addid() in order to have, as much as possible, the same code for shm/sem/msg. [akpm@linux-foundation.org: coding-style fixes] Signed-off-by: Pierre Peiffer <pierre.peiffer@bull.net> Cc: Nadia Derbey <Nadia.Derbey@bull.net> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Diffstat (limited to 'ipc')
-rw-r--r--ipc/msg.c2
-rw-r--r--ipc/sem.c2
-rw-r--r--ipc/shm.c10
-rw-r--r--ipc/util.c1
4 files changed, 2 insertions, 13 deletions
diff --git a/ipc/msg.c b/ipc/msg.c
index 46585a05473e..805ee08ec8bb 100644
--- a/ipc/msg.c
+++ b/ipc/msg.c
@@ -70,7 +70,6 @@ struct msg_sender {
70#define msg_ids(ns) ((ns)->ids[IPC_MSG_IDS]) 70#define msg_ids(ns) ((ns)->ids[IPC_MSG_IDS])
71 71
72#define msg_unlock(msq) ipc_unlock(&(msq)->q_perm) 72#define msg_unlock(msq) ipc_unlock(&(msq)->q_perm)
73#define msg_buildid(id, seq) ipc_buildid(id, seq)
74 73
75static void freeque(struct ipc_namespace *, struct kern_ipc_perm *); 74static void freeque(struct ipc_namespace *, struct kern_ipc_perm *);
76static int newque(struct ipc_namespace *, struct ipc_params *); 75static int newque(struct ipc_namespace *, struct ipc_params *);
@@ -186,7 +185,6 @@ static int newque(struct ipc_namespace *ns, struct ipc_params *params)
186 return id; 185 return id;
187 } 186 }
188 187
189 msq->q_perm.id = msg_buildid(id, msq->q_perm.seq);
190 msq->q_stime = msq->q_rtime = 0; 188 msq->q_stime = msq->q_rtime = 0;
191 msq->q_ctime = get_seconds(); 189 msq->q_ctime = get_seconds();
192 msq->q_cbytes = msq->q_qnum = 0; 190 msq->q_cbytes = msq->q_qnum = 0;
diff --git a/ipc/sem.c b/ipc/sem.c
index 0b45a4d383c6..08da8648925d 100644
--- a/ipc/sem.c
+++ b/ipc/sem.c
@@ -91,7 +91,6 @@
91 91
92#define sem_unlock(sma) ipc_unlock(&(sma)->sem_perm) 92#define sem_unlock(sma) ipc_unlock(&(sma)->sem_perm)
93#define sem_checkid(sma, semid) ipc_checkid(&sma->sem_perm, semid) 93#define sem_checkid(sma, semid) ipc_checkid(&sma->sem_perm, semid)
94#define sem_buildid(id, seq) ipc_buildid(id, seq)
95 94
96static int newary(struct ipc_namespace *, struct ipc_params *); 95static int newary(struct ipc_namespace *, struct ipc_params *);
97static void freeary(struct ipc_namespace *, struct kern_ipc_perm *); 96static void freeary(struct ipc_namespace *, struct kern_ipc_perm *);
@@ -268,7 +267,6 @@ static int newary(struct ipc_namespace *ns, struct ipc_params *params)
268 } 267 }
269 ns->used_sems += nsems; 268 ns->used_sems += nsems;
270 269
271 sma->sem_perm.id = sem_buildid(id, sma->sem_perm.seq);
272 sma->sem_base = (struct sem *) &sma[1]; 270 sma->sem_base = (struct sem *) &sma[1];
273 /* sma->sem_pending = NULL; */ 271 /* sma->sem_pending = NULL; */
274 sma->sem_pending_last = &sma->sem_pending; 272 sma->sem_pending_last = &sma->sem_pending;
diff --git a/ipc/shm.c b/ipc/shm.c
index e636910454a9..3e4aff982546 100644
--- a/ipc/shm.c
+++ b/ipc/shm.c
@@ -60,7 +60,6 @@ static struct vm_operations_struct shm_vm_ops;
60 60
61#define shm_unlock(shp) \ 61#define shm_unlock(shp) \
62 ipc_unlock(&(shp)->shm_perm) 62 ipc_unlock(&(shp)->shm_perm)
63#define shm_buildid(id, seq) ipc_buildid(id, seq)
64 63
65static int newseg(struct ipc_namespace *, struct ipc_params *); 64static int newseg(struct ipc_namespace *, struct ipc_params *);
66static void shm_open(struct vm_area_struct *vma); 65static void shm_open(struct vm_area_struct *vma);
@@ -169,12 +168,6 @@ static inline void shm_rmid(struct ipc_namespace *ns, struct shmid_kernel *s)
169 ipc_rmid(&shm_ids(ns), &s->shm_perm); 168 ipc_rmid(&shm_ids(ns), &s->shm_perm);
170} 169}
171 170
172static inline int shm_addid(struct ipc_namespace *ns, struct shmid_kernel *shp)
173{
174 return ipc_addid(&shm_ids(ns), &shp->shm_perm, ns->shm_ctlmni);
175}
176
177
178 171
179/* This is called by fork, once for every shm attach. */ 172/* This is called by fork, once for every shm attach. */
180static void shm_open(struct vm_area_struct *vma) 173static void shm_open(struct vm_area_struct *vma)
@@ -416,7 +409,7 @@ static int newseg(struct ipc_namespace *ns, struct ipc_params *params)
416 if (IS_ERR(file)) 409 if (IS_ERR(file))
417 goto no_file; 410 goto no_file;
418 411
419 id = shm_addid(ns, shp); 412 id = ipc_addid(&shm_ids(ns), &shp->shm_perm, ns->shm_ctlmni);
420 if (id < 0) { 413 if (id < 0) {
421 error = id; 414 error = id;
422 goto no_id; 415 goto no_id;
@@ -428,7 +421,6 @@ static int newseg(struct ipc_namespace *ns, struct ipc_params *params)
428 shp->shm_ctim = get_seconds(); 421 shp->shm_ctim = get_seconds();
429 shp->shm_segsz = size; 422 shp->shm_segsz = size;
430 shp->shm_nattch = 0; 423 shp->shm_nattch = 0;
431 shp->shm_perm.id = shm_buildid(id, shp->shm_perm.seq);
432 shp->shm_file = file; 424 shp->shm_file = file;
433 /* 425 /*
434 * shmid gets reported as "inode#" in /proc/pid/maps. 426 * shmid gets reported as "inode#" in /proc/pid/maps.
diff --git a/ipc/util.c b/ipc/util.c
index fd1b50da9db8..cb017c7b9370 100644
--- a/ipc/util.c
+++ b/ipc/util.c
@@ -231,6 +231,7 @@ int ipc_addid(struct ipc_ids* ids, struct kern_ipc_perm* new, int size)
231 if(ids->seq > ids->seq_max) 231 if(ids->seq > ids->seq_max)
232 ids->seq = 0; 232 ids->seq = 0;
233 233
234 new->id = ipc_buildid(id, new->seq);
234 spin_lock_init(&new->lock); 235 spin_lock_init(&new->lock);
235 new->deleted = 0; 236 new->deleted = 0;
236 rcu_read_lock(); 237 rcu_read_lock();