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

Function SysSocket

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

* SysSocket (domain, type, protocol) - Create socket * domain - socket domain * type - socket type * protcol - socket protocol * * On Success - return file descriptor * On Failure - return -1 */

Source from the content-addressed store, hash-verified

1152 * On Failure - return -1
1153 */
1154long SysSocket(regs64_t* r){
1155 int domain = SC_ARG0(r);
1156 int type = SC_ARG1(r);
1157 int protocol = SC_ARG2(r);
1158
1159 Socket* sock = Socket::CreateSocket(domain, type, protocol);
1160
1161 if(!sock) return -1;
1162
1163 fs_fd_t* fDesc = fs::Open(sock, 0);
1164
1165 if(type & SOCK_NONBLOCK) fDesc->mode |= O_NONBLOCK;
1166
1167 int fd = Scheduler::GetCurrentProcess()->fileDescriptors.get_length();
1168
1169 Scheduler::GetCurrentProcess()->fileDescriptors.add_back(fDesc);
1170
1171 return fd;
1172}
1173
1174/*
1175 * SysBind (sockfd, addr, addrlen) - Bind address to socket

Callers

nothing calls this directly

Calls 4

GetCurrentProcessFunction · 0.85
OpenFunction · 0.50
get_lengthMethod · 0.45
add_backMethod · 0.45

Tested by

no test coverage detected