MCPcopy Create free account
hub / github.com/Starry-OS/StarryOS / sys_sendmsg

Function sys_sendmsg

api/src/syscall/net/io.rs:59–82  ·  view source on GitHub ↗
(fd: i32, msg: UserConstPtr<msghdr>, flags: u32)

Source from the content-addressed store, hash-verified

57}
58
59pub fn sys_sendmsg(fd: i32, msg: UserConstPtr<msghdr>, flags: u32) -> AxResult<isize> {
60 let msg = msg.get_as_ref()?;
61 let mut cmsg = Vec::new();
62 if !msg.msg_control.is_null() {
63 let mut ptr = msg.msg_control as usize;
64 let ptr_end = ptr + msg.msg_controllen;
65 while ptr + size_of::<cmsghdr>() <= ptr_end {
66 let hdr = UserConstPtr::<cmsghdr>::from(ptr).get_as_ref()?;
67 if ptr_end - ptr < hdr.cmsg_len {
68 return Err(AxError::InvalidInput);
69 }
70 cmsg.push(Box::new(CMsg::parse(hdr)?) as CMsgData);
71 ptr += hdr.cmsg_len;
72 }
73 }
74 send_impl(
75 fd,
76 IoVectorBuf::new(msg.msg_iov as *const IoVec, msg.msg_iovlen)?.into_io(),
77 flags,
78 UserConstPtr::from(msg.msg_name as usize),
79 msg.msg_namelen as socklen_t,
80 cmsg,
81 )
82}
83
84fn recv_impl(
85 fd: i32,

Callers 1

handle_syscallFunction · 0.85

Calls 5

send_implFunction · 0.85
get_as_refMethod · 0.80
is_nullMethod · 0.80
pushMethod · 0.80
into_ioMethod · 0.80

Tested by

no test coverage detected