aboutsummaryrefslogtreecommitdiffstats
path: root/ipc/msgutil.c
diff options
context:
space:
mode:
Diffstat (limited to 'ipc/msgutil.c')
-rw-r--r--ipc/msgutil.c42
1 files changed, 42 insertions, 0 deletions
diff --git a/ipc/msgutil.c b/ipc/msgutil.c
index 26143d377c95..5df8e4bf1db0 100644
--- a/ipc/msgutil.c
+++ b/ipc/msgutil.c
@@ -16,6 +16,7 @@
16#include <linux/msg.h> 16#include <linux/msg.h>
17#include <linux/ipc_namespace.h> 17#include <linux/ipc_namespace.h>
18#include <linux/utsname.h> 18#include <linux/utsname.h>
19#include <linux/proc_fs.h>
19#include <asm/uaccess.h> 20#include <asm/uaccess.h>
20 21
21#include "util.h" 22#include "util.h"
@@ -30,6 +31,7 @@ DEFINE_SPINLOCK(mq_lock);
30struct ipc_namespace init_ipc_ns = { 31struct ipc_namespace init_ipc_ns = {
31 .count = ATOMIC_INIT(1), 32 .count = ATOMIC_INIT(1),
32 .user_ns = &init_user_ns, 33 .user_ns = &init_user_ns,
34 .proc_inum = PROC_IPC_INIT_INO,
33}; 35};
34 36
35atomic_t nr_ipc_ns = ATOMIC_INIT(1); 37atomic_t nr_ipc_ns = ATOMIC_INIT(1);
@@ -100,7 +102,47 @@ out_err:
100 free_msg(msg); 102 free_msg(msg);
101 return ERR_PTR(err); 103 return ERR_PTR(err);
102} 104}
105#ifdef CONFIG_CHECKPOINT_RESTORE
106struct msg_msg *copy_msg(struct msg_msg *src, struct msg_msg *dst)
107{
108 struct msg_msgseg *dst_pseg, *src_pseg;
109 int len = src->m_ts;
110 int alen;
111
112 BUG_ON(dst == NULL);
113 if (src->m_ts > dst->m_ts)
114 return ERR_PTR(-EINVAL);
115
116 alen = len;
117 if (alen > DATALEN_MSG)
118 alen = DATALEN_MSG;
119
120 memcpy(dst + 1, src + 1, alen);
121
122 len -= alen;
123 dst_pseg = dst->next;
124 src_pseg = src->next;
125 while (len > 0) {
126 alen = len;
127 if (alen > DATALEN_SEG)
128 alen = DATALEN_SEG;
129 memcpy(dst_pseg + 1, src_pseg + 1, alen);
130 dst_pseg = dst_pseg->next;
131 len -= alen;
132 src_pseg = src_pseg->next;
133 }
134
135 dst->m_type = src->m_type;
136 dst->m_ts = src->m_ts;
103 137
138 return dst;
139}
140#else
141struct msg_msg *copy_msg(struct msg_msg *src, struct msg_msg *dst)
142{
143 return ERR_PTR(-ENOSYS);
144}
145#endif
104int store_msg(void __user *dest, struct msg_msg *msg, int len) 146int store_msg(void __user *dest, struct msg_msg *msg, int len)
105{ 147{
106 int alen; 148 int alen;