MCPcopy Index your code
hub / github.com/F-Stack/f-stack / kern_socket

Function kern_socket

freebsd/kern/uipc_syscalls.c:132–172  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

130}
131
132int
133kern_socket(struct thread *td, int domain, int type, int protocol)
134{
135 struct socket *so;
136 struct file *fp;
137 int fd, error, oflag, fflag;
138
139 AUDIT_ARG_SOCKET(domain, type, protocol);
140
141 oflag = 0;
142 fflag = 0;
143 if ((type & SOCK_CLOEXEC) != 0) {
144 type &= ~SOCK_CLOEXEC;
145 oflag |= O_CLOEXEC;
146 }
147 if ((type & SOCK_NONBLOCK) != 0) {
148 type &= ~SOCK_NONBLOCK;
149 fflag |= FNONBLOCK;
150 }
151
152#ifdef MAC
153 error = mac_socket_check_create(td->td_ucred, domain, type, protocol);
154 if (error != 0)
155 return (error);
156#endif
157 error = falloc(td, &fp, &fd, oflag);
158 if (error != 0)
159 return (error);
160 /* An extra reference on `fp' has been held for us by falloc(). */
161 error = socreate(domain, &so, type, protocol, td->td_ucred, td);
162 if (error != 0) {
163 fdclose(td, fp, fd);
164 } else {
165 finit(fp, FREAD | FWRITE | fflag, DTYPE_SOCKET, so, &socketops);
166 if ((fflag & FNONBLOCK) != 0)
167 (void) fo_ioctl(fp, FIONBIO, &fflag, td->td_ucred, td);
168 td->td_retval[0] = fd;
169 }
170 fdrop(fp, td);
171 return (error);
172}
173
174int
175sys_bind(struct thread *td, struct bind_args *uap)

Callers 1

sys_socketFunction · 0.85

Calls 5

mac_socket_check_createFunction · 0.85
socreateFunction · 0.85
fdcloseFunction · 0.85
finitFunction · 0.85
fo_ioctlFunction · 0.85

Tested by

no test coverage detected