MCPcopy Create free account
hub / github.com/F-Stack/f-stack / sendfile_getsock

Function sendfile_getsock

freebsd/kern/kern_sendfile.c:646–674  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

644}
645
646static int
647sendfile_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
676int
677vn_sendfile(struct file *fp, int sockfd, struct uio *hdr_uio,

Callers 1

vn_sendfileFunction · 0.85

Calls 1

getsock_capFunction · 0.85

Tested by

no test coverage detected