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

Function ff_sendmsg

lib/ff_syscall_wrapper.c:1216–1256  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1214}
1215
1216ssize_t
1217ff_sendmsg(int s, const struct msghdr *msg, int flags)
1218{
1219 int rc, ret;
1220 struct sockaddr_storage freebsd_sa;
1221 struct msghdr freebsd_msg;
1222 struct cmsghdr *freebsd_cmsg = NULL;
1223
1224 freebsd_msg.msg_name = &freebsd_sa;
1225 if ((__DECONST(struct linux_msghdr *, msg))->msg_control) {
1226 freebsd_cmsg = malloc((__DECONST(struct linux_msghdr *, msg))->msg_controllen, NULL, 0);
1227 if (freebsd_cmsg == NULL) {
1228 rc = ENOMEM;
1229 goto kern_fail;
1230 }
1231 }
1232 freebsd_msg.msg_control = freebsd_cmsg;
1233
1234 ret = linux2freebsd_msghdr((const struct linux_msghdr *)msg, &freebsd_msg, 1);
1235 if (ret < 0) {
1236 rc = EINVAL;
1237 goto kern_fail;
1238 }
1239
1240 rc = sendit(curthread, s, &freebsd_msg, flags);
1241 if (rc)
1242 goto kern_fail;
1243
1244 rc = curthread->td_retval[0];
1245
1246 freebsd2linux_msghdr(__DECONST(struct linux_msghdr *, msg), &freebsd_msg, 1);
1247
1248 if (freebsd_cmsg) {
1249 free(freebsd_cmsg, NULL);
1250 }
1251
1252 return (rc);
1253kern_fail:
1254 ff_os_errno(rc);
1255 return (-1);
1256}
1257
1258
1259ssize_t

Callers 2

sendmsgFunction · 0.85
ff_sys_sendmsgFunction · 0.85

Calls 5

mallocFunction · 0.85
linux2freebsd_msghdrFunction · 0.85
senditFunction · 0.85
ff_os_errnoFunction · 0.85
freeFunction · 0.70

Tested by

no test coverage detected