MCPcopy Create free account
hub / github.com/LemonOSProject/LemonOS / SysSend

Function SysSend

Kernel/src/arch/x86_64/syscalls.cpp:1328–1353  ·  view source on GitHub ↗

* SysSend (sockfd, buf, len, flags) - Send data through a socket * sockfd - Socket file descriptor * buf - data * len - data length * flags - flags * * On Success - return amount of data sent * On Failure - return -1 */

Source from the content-addressed store, hash-verified

1326 * On Failure - return -1
1327 */
1328long SysSend(regs64_t* r){
1329 process_t* proc = Scheduler::GetCurrentProcess();
1330 fs_fd_t* handle = proc->fileDescriptors.get_at(SC_ARG0(r));
1331
1332 uint8_t* buffer = (uint8_t*)(SC_ARG1(r));
1333 size_t len = SC_ARG2(r);
1334 uint64_t flags = SC_ARG3(r);
1335
1336 if(!handle){
1337 Log::Warning("sys_send: Invalid file descriptor: ", SC_ARG0(r));
1338 return -1;
1339 }
1340
1341 if((handle->node->flags & FS_NODE_TYPE) != FS_NODE_SOCKET){
1342 Log::Warning("sys_send: File (Descriptor: %d) is not a socket", SC_ARG0(r));
1343 return -2;
1344 }
1345
1346 if(!Memory::CheckUsermodePointer(SC_ARG1(r), len, proc->addressSpace)){
1347 Log::Warning("sys_send: Invalid buffer ptr");
1348 return -3;
1349 }
1350
1351 Socket* sock = (Socket*)handle->node;
1352 return sock->Send(buffer, len, flags);
1353}
1354
1355/*
1356 * SysSendTo (sockfd, buf, len, flags, destaddr, addrlen) - Send data through a socket

Callers

nothing calls this directly

Calls 5

GetCurrentProcessFunction · 0.85
WarningFunction · 0.85
CheckUsermodePointerFunction · 0.85
get_atMethod · 0.80
SendMethod · 0.45

Tested by

no test coverage detected