[orbis-kernel] Implement basic sys_socketex

Implement sys_socketclose
This commit is contained in:
Ivan Chikish 2023-07-19 18:04:26 +03:00
parent cea6052e54
commit 76db5849a0
8 changed files with 74 additions and 8 deletions

View file

@ -607,7 +607,7 @@ SysResult sys_netabort(Thread *thread /* TODO */);
SysResult sys_netgetsockinfo(Thread *thread /* TODO */);
SysResult sys_socketex(Thread *thread, ptr<const char> name, sint domain,
sint type, sint protocol);
SysResult sys_socketclose(Thread *thread /* TODO */);
SysResult sys_socketclose(Thread *thread, sint fd);
SysResult sys_netgetiflist(Thread *thread /* TODO */);
SysResult sys_kqueueex(Thread *thread /* TODO */);
SysResult sys_mtypeprotect(Thread *thread /* TODO */);

View file

@ -30,6 +30,8 @@ struct ProcessOps {
SysResult (*open)(Thread *thread, ptr<const char> path, sint flags,
sint mode);
SysResult (*socket)(Thread *thread, ptr<const char> name, sint domain,
sint type, sint protocol);
SysResult (*close)(Thread *thread, sint fd);
SysResult (*ioctl)(Thread *thread, sint fd, ulong com, caddr_t argp);
SysResult (*write)(Thread *thread, sint fd, ptr<const void> data, ulong size);

View file

@ -16,6 +16,7 @@ orbis::SysResult orbis::sys_fcntl(Thread *thread, sint fd, sint cmd,
return ErrorCode::NOSYS;
}
orbis::SysResult orbis::sys_close(Thread *thread, sint fd) {
ORBIS_LOG_NOTICE(__FUNCTION__, fd);
if (auto close = thread->tproc->ops->close) {
return close(thread, fd);
}

View file

@ -75,6 +75,7 @@ orbis::SysResult orbis::sys_freebsd6_ftruncate(Thread *thread, sint fd, sint,
}
orbis::SysResult orbis::sys_ioctl(Thread *thread, sint fd, ulong com,
caddr_t data) {
ORBIS_LOG_WARNING(__FUNCTION__, fd, com);
if (auto ioctl = thread->tproc->ops->ioctl) {
return ioctl(thread, fd, com, data);
}

View file

@ -22,10 +22,20 @@ orbis::SysResult orbis::sys_netgetsockinfo(Thread *thread /* TODO */) {
}
orbis::SysResult orbis::sys_socketex(Thread *thread, ptr<const char> name,
sint domain, sint type, sint protocol) {
return {};
ORBIS_LOG_TODO(__FUNCTION__, name, domain, type, protocol);
if (auto socket = thread->tproc->ops->socket) {
return socket(thread, name, domain, type, protocol);
}
return ErrorCode::NOSYS;
}
orbis::SysResult orbis::sys_socketclose(Thread *thread /* TODO */) {
return {};
orbis::SysResult orbis::sys_socketclose(Thread *thread, sint fd) {
// This syscall is identical to sys_close
ORBIS_LOG_NOTICE(__FUNCTION__, fd);
if (auto close = thread->tproc->ops->close) {
return close(thread, fd);
}
return ErrorCode::NOSYS;
}
orbis::SysResult orbis::sys_netgetiflist(Thread *thread /* TODO */) {
return ErrorCode::NOSYS;