From: Matthias Kruk Date: Sat, 5 Oct 2019 07:13:21 +0000 (+0900) Subject: Add dummy soshutdown() function and call it from sys_shutdown() X-Git-Url: https://git.corax.cc/?a=commitdiff_plain;h=eea8def926b27aae2e472f1d56ec5e55de5f2277;p=corax Add dummy soshutdown() function and call it from sys_shutdown() --- diff --git a/kernel/core/cxnet.c b/kernel/core/cxnet.c index 364996b..2d0be44 100644 --- a/kernel/core/cxnet.c +++ b/kernel/core/cxnet.c @@ -21,7 +21,10 @@ int sys_socket(int domain, int type, int protocol) * to do here. */ ret_val = socreate(domain, type, protocol); + +#if FEATURE(DEBUG_NET) dbg_printf("socreate(0x%08x, 0x%08x, 0x%08x) = 0x%08x\n", domain, type, protocol, ret_val); +#endif /* FEATURE(DEBUG_NET) */ return(ret_val); } @@ -48,7 +51,10 @@ int sys_close(int procfd) * going to return to the caller. */ if(ret_val >= 0) { +#if FEATURE(DEBUG_NET) dbg_printf("soclose(0x%08x)\n", ret_val); +#endif /* FEATURE(DEBUG_NET) */ + ret_val = soclose(ret_val); } } @@ -176,9 +182,25 @@ gtfo: return(ret_val); } -int sys_shutdown(int sockfd, int how) +int sys_shutdown(int procfd, int how) { - return(-ENOSYS); + process_t *cproc; + int ret_val; + + ret_val = -EFAULT; + cproc = process_get_current(); + + if(cproc) { + /* attempt to look up the system-wide sockfd for this procfd */ + ret_val = process_flookup(cproc, procfd); + + /* pass on the arguments to soshutdown(), if the lookup was successful */ + if(!ret_val) { + ret_val = soshutdown(ret_val, how); + } + } + + return(ret_val); } int sys_select(int nfds, fd_set *readfds, fd_set *writefds, diff --git a/kernel/core/socket.c b/kernel/core/socket.c index 35157ea..bde7f1d 100644 --- a/kernel/core/socket.c +++ b/kernel/core/socket.c @@ -283,3 +283,8 @@ int sogetopt(int sockfd, int opt, void *data, size_t *dlen) { return(-ENOSYS); } + +int soshutdown(int sockfd, int how) +{ + return(-ENOSYS); +} diff --git a/kernel/core/socket.h b/kernel/core/socket.h index fb68146..e06a8c4 100644 --- a/kernel/core/socket.h +++ b/kernel/core/socket.h @@ -26,5 +26,6 @@ int sofree(int); int sosetopt(int, int, const void*, size_t); int sogetopt(int, int, void*, size_t*); +int soshutdown(int, int); #endif /* __SOCKET_H */