diff options
| -rw-r--r-- | net/socket.c | 56 |
1 files changed, 21 insertions, 35 deletions
diff --git a/net/socket.c b/net/socket.c index 3326d67482ac..4d08b50cad65 100644 --- a/net/socket.c +++ b/net/socket.c | |||
| @@ -845,25 +845,11 @@ static ssize_t sock_splice_read(struct file *file, loff_t *ppos, | |||
| 845 | return sock->ops->splice_read(sock, ppos, pipe, len, flags); | 845 | return sock->ops->splice_read(sock, ppos, pipe, len, flags); |
| 846 | } | 846 | } |
| 847 | 847 | ||
| 848 | static ssize_t do_sock_read(struct msghdr *msg, struct kiocb *iocb, | ||
| 849 | struct file *file, const struct iovec *iov, | ||
| 850 | unsigned long nr_segs) | ||
| 851 | { | ||
| 852 | struct socket *sock = file->private_data; | ||
| 853 | |||
| 854 | msg->msg_name = NULL; | ||
| 855 | msg->msg_namelen = 0; | ||
| 856 | msg->msg_control = NULL; | ||
| 857 | msg->msg_controllen = 0; | ||
| 858 | iov_iter_init(&msg->msg_iter, READ, iov, nr_segs, iocb->ki_nbytes); | ||
| 859 | msg->msg_flags = (file->f_flags & O_NONBLOCK) ? MSG_DONTWAIT : 0; | ||
| 860 | |||
| 861 | return __sock_recvmsg(iocb, sock, msg, iocb->ki_nbytes, msg->msg_flags); | ||
| 862 | } | ||
| 863 | |||
| 864 | static ssize_t sock_aio_read(struct kiocb *iocb, const struct iovec *iov, | 848 | static ssize_t sock_aio_read(struct kiocb *iocb, const struct iovec *iov, |
| 865 | unsigned long nr_segs, loff_t pos) | 849 | unsigned long nr_segs, loff_t pos) |
| 866 | { | 850 | { |
| 851 | struct file *file = iocb->ki_filp; | ||
| 852 | struct socket *sock = file->private_data; | ||
| 867 | struct msghdr msg; | 853 | struct msghdr msg; |
| 868 | 854 | ||
| 869 | if (pos != 0) | 855 | if (pos != 0) |
| @@ -872,36 +858,36 @@ static ssize_t sock_aio_read(struct kiocb *iocb, const struct iovec *iov, | |||
| 872 | if (iocb->ki_nbytes == 0) /* Match SYS5 behaviour */ | 858 | if (iocb->ki_nbytes == 0) /* Match SYS5 behaviour */ |
| 873 | return 0; | 859 | return 0; |
| 874 | 860 | ||
| 875 | return do_sock_read(&msg, iocb, iocb->ki_filp, iov, nr_segs); | 861 | msg.msg_name = NULL; |
| 876 | } | 862 | msg.msg_namelen = 0; |
| 877 | 863 | msg.msg_control = NULL; | |
| 878 | static ssize_t do_sock_write(struct msghdr *msg, struct kiocb *iocb, | 864 | msg.msg_controllen = 0; |
| 879 | struct file *file, const struct iovec *iov, | 865 | iov_iter_init(&msg.msg_iter, READ, iov, nr_segs, iocb->ki_nbytes); |
| 880 | unsigned long nr_segs) | 866 | msg.msg_flags = (file->f_flags & O_NONBLOCK) ? MSG_DONTWAIT : 0; |
| 881 | { | ||
| 882 | struct socket *sock = file->private_data; | ||
| 883 | |||
| 884 | msg->msg_name = NULL; | ||
| 885 | msg->msg_namelen = 0; | ||
| 886 | msg->msg_control = NULL; | ||
| 887 | msg->msg_controllen = 0; | ||
| 888 | iov_iter_init(&msg->msg_iter, WRITE, iov, nr_segs, iocb->ki_nbytes); | ||
| 889 | msg->msg_flags = (file->f_flags & O_NONBLOCK) ? MSG_DONTWAIT : 0; | ||
| 890 | if (sock->type == SOCK_SEQPACKET) | ||
| 891 | msg->msg_flags |= MSG_EOR; | ||
| 892 | 867 | ||
| 893 | return __sock_sendmsg(iocb, sock, msg, iocb->ki_nbytes); | 868 | return __sock_recvmsg(iocb, sock, &msg, iocb->ki_nbytes, msg.msg_flags); |
| 894 | } | 869 | } |
| 895 | 870 | ||
| 896 | static ssize_t sock_aio_write(struct kiocb *iocb, const struct iovec *iov, | 871 | static ssize_t sock_aio_write(struct kiocb *iocb, const struct iovec *iov, |
| 897 | unsigned long nr_segs, loff_t pos) | 872 | unsigned long nr_segs, loff_t pos) |
| 898 | { | 873 | { |
| 874 | struct file *file = iocb->ki_filp; | ||
| 875 | struct socket *sock = file->private_data; | ||
| 899 | struct msghdr msg; | 876 | struct msghdr msg; |
| 900 | 877 | ||
| 901 | if (pos != 0) | 878 | if (pos != 0) |
| 902 | return -ESPIPE; | 879 | return -ESPIPE; |
| 903 | 880 | ||
| 904 | return do_sock_write(&msg, iocb, iocb->ki_filp, iov, nr_segs); | 881 | msg.msg_name = NULL; |
| 882 | msg.msg_namelen = 0; | ||
| 883 | msg.msg_control = NULL; | ||
| 884 | msg.msg_controllen = 0; | ||
| 885 | iov_iter_init(&msg.msg_iter, WRITE, iov, nr_segs, iocb->ki_nbytes); | ||
| 886 | msg.msg_flags = (file->f_flags & O_NONBLOCK) ? MSG_DONTWAIT : 0; | ||
| 887 | if (sock->type == SOCK_SEQPACKET) | ||
| 888 | msg.msg_flags |= MSG_EOR; | ||
| 889 | |||
| 890 | return __sock_sendmsg(iocb, sock, &msg, iocb->ki_nbytes); | ||
| 905 | } | 891 | } |
| 906 | 892 | ||
| 907 | /* | 893 | /* |
