OpenVZ Forum - RDF feed
type: channel
items: [PATCH v7 02/10] ipc: "use key as id" functionality for resource get system call i

[PATCH v7 02/10] ipc: "use key as id" functionality for resource get system call i
type: item
description: This patch introduces new IPC resource get request flag IPC_PRESET, which should be interpreted as a request to try to allocate IPC slot with number, starting from value resented by key. IOW, kernel will try allocate new segment in specified slot. Note: if desired slot is not emply, then next free slot will be used. Signed-off-by: Stanislav Kinsbursky <skinsbursky@parallels.com> --- include/uapi/linux/ipc.h | 1 + ipc/msg.c | 4 +++- ipc/sem.c | 4 +++- ipc/shm.c | 4 +++- ipc/util.c | 18 +++++++++++++++--- ipc/util.h | 3 ++- 6 files changed, 27 insertions(+), 7 deletions(-) diff --git a/include/uapi/linux/ipc.h b/include/uapi/linux/ipc.h index de08dd4..f5f52b6 100644 --- a/include/uapi/linux/ipc.h +++ b/include/uapi/linux/ipc.h @@ -24,6 +24,7 @@ struct ipc_perm #define IPC_CREAT 00001000 /* create if key is nonexistent */ #define IPC_EXCL 00002000 /* fail if key exists */ #define IPC_NOWAIT 00004000 /* return error on wait */ +#define IPC_PRESET 00040000 /* use key as id */ /* these fields are used by the DIPC package so the kernel as standard should avoid using them if possible */ diff --git a/ipc/msg.c b/ipc/msg.c index 2f272fa..2f44946 100644 --- a/ipc/msg.c +++ b/ipc/msg.c @@ -190,6 +190,7 @@ static int newque(struct ipc_namespace *ns, struct ipc_params *params) msq->q_perm.mode = msgflg & S_IRWXUGO; msq->q_perm.key = key; + msq->q_perm.id = (msgflg & IPC_PRESET) ? key : 0; msq->q_perm.security = NULL; retval = security_msg_queue_alloc(msq); @@ -201,7 +202,8 @@ static int newque(struct ipc_namespace *ns, struct ipc_params *params) /* * ipc_addid() locks msq */ - id = ipc_addid(&msg_ids(ns), &msq->q_perm, ns->msg_ctlmni); + id = ipc_addid(&msg_ids(ns), &msq->q_perm, ns->msg_ctlmni, + msgflg & IPC_PRESET); if (id < 0) { security_msg_queue_free(msq); ipc_rcu_putref(msq); diff --git a/ipc/sem.c b/ipc/sem.c index 58d31f1..10e9085 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_per…
creator: Stanislav Kinsbursky
date: 2012-10-18T10:22:46-00:00