[CRIU] [PATCH v2 7/8] ipc: add new flag for preset sem id on
creation
Stanislav Kinsbursky
skinsbursky at parallels.com
Wed Feb 8 08:18:40 EST 2012
This patch is required for checkpoint/restore of IPC semaphores.
The patch makes IPC_PRESET flag enterpreted as an order to use passed key as
the id of new segment to create on sys_shmget() call. IOW, kernel will try
allocate new segment in specified slot. If slot is not emply, them -EEXIST
returned.
Note: key and id will be identical for such segment after creation.
Signed-off-by: Stanislav Kinsbursky <skinsbursky at parallels.com>
---
ipc/sem.c | 6 ++++++
1 files changed, 6 insertions(+), 0 deletions(-)
diff --git a/ipc/sem.c b/ipc/sem.c
index 5215a81..ea5aa17 100644
--- a/ipc/sem.c
+++ b/ipc/sem.c
@@ -306,6 +306,7 @@ static int newary(struct ipc_namespace *ns, struct ipc_params *params)
sma->sem_perm.mode = (semflg & S_IRWXUGO);
sma->sem_perm.key = key;
+ sma->sem_perm.id = 0;
sma->sem_perm.security = NULL;
retval = security_sem_alloc(sma);
@@ -314,6 +315,11 @@ static int newary(struct ipc_namespace *ns, struct ipc_params *params)
return retval;
}
+ if (semflg & IPC_PRESET) {
+ sma->sem_perm.id = key;
+ sma->sem_perm.seq = (unsigned long) key / SEQ_MULTIPLIER;
+ }
+
id = ipc_addid(&sem_ids(ns), &sma->sem_perm, ns->sc_semmni);
if (id < 0) {
security_sem_free(sma);
More information about the CRIU
mailing list