long compat_sys_msgrcv(int first, int second, int msgtyp, int third, int version, void __user *uptr) { struct compat_msgbuf __user *up; long type; int err; if (first < 0) return -EINVAL; if (second < 0) return -EINVAL; if (!version) { struct compat_ipc_kludge ipck; err = -EINVAL; if (!uptr) goto out; err = -EFAULT; if (copy_from_user (&ipck, uptr, sizeof(ipck))) goto out; uptr = compat_ptr(ipck.msgp); msgtyp = ipck.msgtyp; } up = uptr; err = do_msgrcv(first, &type, up->mtext, second, msgtyp, third); if (err < 0) goto out; if (put_user(type, &up->mtype)) err = -EFAULT; out: return err; }
SYSCALL_DEFINE5(msgrcv, int, msqid, struct msgbuf __user *, msgp, size_t, msgsz, long, msgtyp, int, msgflg) { long err, mtype; err = do_msgrcv(msqid, &mtype, msgp->mtext, msgsz, msgtyp, msgflg); if (err < 0) goto out; if (put_user(mtype, &msgp->mtype)) err = -EFAULT; out: return err; }
asmlinkage long sys_msgrcv(int msqid, struct msgbuf __user *msgp, size_t msgsz, long msgtyp, int msgflg) { long err, mtype; err = do_msgrcv(msqid, &mtype, msgp->mtext, msgsz, msgtyp, msgflg); if (err < 0) goto out; if (put_user(mtype, &msgp->mtype)) err = -EFAULT; out: return err; }