| 644 | } |
| 645 | |
| 646 | static int |
| 647 | sendfile_getsock(struct thread *td, int s, struct file **sock_fp, |
| 648 | struct socket **so) |
| 649 | { |
| 650 | int error; |
| 651 | |
| 652 | *sock_fp = NULL; |
| 653 | *so = NULL; |
| 654 | |
| 655 | /* |
| 656 | * The socket must be a stream socket and connected. |
| 657 | */ |
| 658 | error = getsock_cap(td, s, &cap_send_rights, |
| 659 | sock_fp, NULL, NULL); |
| 660 | if (error != 0) |
| 661 | return (error); |
| 662 | *so = (*sock_fp)->f_data; |
| 663 | if ((*so)->so_type != SOCK_STREAM) |
| 664 | return (EINVAL); |
| 665 | /* |
| 666 | * SCTP one-to-one style sockets currently don't work with |
| 667 | * sendfile(). So indicate EINVAL for now. |
| 668 | */ |
| 669 | if ((*so)->so_proto->pr_protocol == IPPROTO_SCTP) |
| 670 | return (EINVAL); |
| 671 | if (SOLISTENING(*so)) |
| 672 | return (ENOTCONN); |
| 673 | return (0); |
| 674 | } |
| 675 | |
| 676 | int |
| 677 | vn_sendfile(struct file *fp, int sockfd, struct uio *hdr_uio, |
no test coverage detected