- msg.msg_accrights = 0;
- msg.msg_accrightslen = 0;
- recvit(uap->s, &msg, uap->flags, (caddr_t)0, (caddr_t)0);
+ msg.msg_control = 0;
+ msg.msg_flags = uap->flags;
+ RETURN (recvit(uap->s, &msg, (caddr_t)0));
+}
+
+/*
+ * Old recvmsg. This code takes advantage of the fact that the old msghdr
+ * overlays the new one, missing only the flags, and with the (old) access
+ * rights where the control fields are now.
+ */
+orecvmsg()
+{
+ register struct a {
+ int s;
+ struct omsghdr *msg;
+ int flags;
+ } *uap = (struct a *)u.u_ap;
+ struct msghdr msg;
+ struct iovec aiov[MSG_MAXIOVLEN];
+ int error;
+
+ if (error = copyin((caddr_t)uap->msg, (caddr_t)&msg,
+ sizeof (struct omsghdr)))
+ RETURN (error);
+ if ((u_int)msg.msg_iovlen >= sizeof (aiov) / sizeof (aiov[0]))
+ RETURN (EMSGSIZE);
+ msg.msg_flags = uap->flags | MSG_COMPAT;
+ if (error = copyin((caddr_t)msg.msg_iov, (caddr_t)aiov,
+ (unsigned)(msg.msg_iovlen * sizeof (aiov[0]))))
+ RETURN (error);
+ msg.msg_iov = aiov;
+ error = recvit(uap->s, &msg, (caddr_t)&uap->msg->msg_namelen);
+
+ if (msg.msg_controllen && error == 0)
+ error = copyout((caddr_t)&msg.msg_controllen,
+ (caddr_t)&uap->msg->msg_accrightslen, sizeof (int));
+ RETURN (error);