Commit 51eeacaa authored by Stanislav Kinsbursky's avatar Stanislav Kinsbursky Committed by Linus Torvalds

ipc: simplify message copying

Remove the redundant and confusing fill_copy().  Also add copy_msg()
check for error.  In this case exit from the function have to be done
instead of break, because further code interprets any error as EAGAIN.

Also define copy_msg() for the case when CONFIG_CHECKPOINT_RESTORE is
disabled.
Signed-off-by: default avatarStanislav Kinsbursky <skinsbursky@parallels.com>
Cc: "Eric W. Biederman" <ebiederm@xmission.com>
Cc: James Morris <jmorris@namei.org>
Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
parent b30efe27
...@@ -770,16 +770,6 @@ static long do_msg_fill(void __user *dest, struct msg_msg *msg, size_t bufsz) ...@@ -770,16 +770,6 @@ static long do_msg_fill(void __user *dest, struct msg_msg *msg, size_t bufsz)
} }
#ifdef CONFIG_CHECKPOINT_RESTORE #ifdef CONFIG_CHECKPOINT_RESTORE
static inline struct msg_msg *fill_copy(unsigned long copy_nr,
unsigned long msg_nr,
struct msg_msg *msg,
struct msg_msg *copy)
{
if (copy_nr == msg_nr)
return copy_msg(msg, copy);
return NULL;
}
static inline struct msg_msg *prepare_copy(void __user *buf, size_t bufsz, static inline struct msg_msg *prepare_copy(void __user *buf, size_t bufsz,
int msgflg, long *msgtyp, int msgflg, long *msgtyp,
unsigned long *copy_number) unsigned long *copy_number)
...@@ -803,8 +793,6 @@ static inline void free_copy(struct msg_msg *copy) ...@@ -803,8 +793,6 @@ static inline void free_copy(struct msg_msg *copy)
free_msg(copy); free_msg(copy);
} }
#else #else
#define fill_copy(copy_nr, msg_nr, msg, copy) NULL
static inline struct msg_msg *prepare_copy(void __user *buf, size_t bufsz, static inline struct msg_msg *prepare_copy(void __user *buf, size_t bufsz,
int msgflg, long *msgtyp, int msgflg, long *msgtyp,
unsigned long *copy_number) unsigned long *copy_number)
...@@ -868,11 +856,16 @@ long do_msgrcv(int msqid, void __user *buf, size_t bufsz, long msgtyp, ...@@ -868,11 +856,16 @@ long do_msgrcv(int msqid, void __user *buf, size_t bufsz, long msgtyp,
walk_msg->m_type != 1) { walk_msg->m_type != 1) {
msgtyp = walk_msg->m_type - 1; msgtyp = walk_msg->m_type - 1;
} else if (msgflg & MSG_COPY) { } else if (msgflg & MSG_COPY) {
msg = fill_copy(copy_number, if (copy_number == msg_counter) {
msg_counter, /*
walk_msg, copy); * Found requested message.
if (msg) * Copy it.
*/
msg = copy_msg(msg, copy);
if (IS_ERR(msg))
goto out_unlock;
break; break;
}
} else } else
break; break;
msg_counter++; msg_counter++;
......
...@@ -140,6 +140,11 @@ struct msg_msg *copy_msg(struct msg_msg *src, struct msg_msg *dst) ...@@ -140,6 +140,11 @@ struct msg_msg *copy_msg(struct msg_msg *src, struct msg_msg *dst)
return dst; return dst;
} }
#else
struct msg_msg *copy_msg(struct msg_msg *src, struct msg_msg *dst)
{
return ERR_PTR(-ENOSYS);
}
#endif #endif
int store_msg(void __user *dest, struct msg_msg *msg, int len) int store_msg(void __user *dest, struct msg_msg *msg, int len)
{ {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment