[Devel] [PATCH v3 09/10] ipc: add new MSG_SET_COPY command for sys_msgctl() call
Stanislav Kinsbursky
skinsbursky at parallels.com
Fri Aug 10 07:26:07 PDT 2012
New MSG_SET_COPY allows to set specified queue copy counter to passed value.
Passed "struct msqid_ds *buf" interpreted as pointer to unsigned int in this
case.
---
include/linux/msg.h | 1 +
ipc/compat.c | 3 +++
ipc/msg.c | 18 ++++++++++++++++++
3 files changed, 22 insertions(+), 0 deletions(-)
diff --git a/include/linux/msg.h b/include/linux/msg.h
index 07a5e1e..4e9ddf4 100644
--- a/include/linux/msg.h
+++ b/include/linux/msg.h
@@ -7,6 +7,7 @@
#define MSG_STAT 11
#define MSG_INFO 12
#define MSG_SET 13
+#define MSG_SET_COPY 14
/* msgrcv options */
#define MSG_NOERROR 010000 /* no error if message is too big */
diff --git a/ipc/compat.c b/ipc/compat.c
index 6b07f5c..9e5acc7 100644
--- a/ipc/compat.c
+++ b/ipc/compat.c
@@ -481,6 +481,9 @@ long compat_sys_msgctl(int first, int second, void __user *uptr)
case IPC_INFO:
case IPC_RMID:
case MSG_INFO:
+#ifdef CONFIG_CHECKPOINT_RESTORE
+ case MSG_SET_COPY:
+#endif
err = sys_msgctl(first, second, uptr);
break;
diff --git a/ipc/msg.c b/ipc/msg.c
index 44ba0ce..c63b22e 100644
--- a/ipc/msg.c
+++ b/ipc/msg.c
@@ -579,6 +579,24 @@ SYSCALL_DEFINE3(msgctl, int, msqid, int, cmd, struct msqid_ds __user *, buf)
case MSG_SET:
err = msgctl_down(ns, msqid, cmd, buf, version);
return err;
+#ifdef CONFIG_CHECKPOINT_RESTORE
+ case MSG_SET_COPY:
+ {
+ int copy_cnt;
+
+ if (!buf)
+ return -EFAULT;
+ if (get_user(copy_cnt, (unsigned int *)buf))
+ return -EFAULT;
+
+ msq = msg_lock(ns, msqid);
+ if (IS_ERR(msq))
+ return PTR_ERR(msq);
+ msq->q_copy_cnt = copy_cnt;
+ err = 0;
+ break;
+ }
+#endif
default:
return -EINVAL;
}
More information about the Devel
mailing list