#include <poll.h>
#include <debug.h>
#include "socket.h"
+#include <process.h>
int sys_socket(int domain, int type, int protocol)
{
return(ret_val);
}
-int sys_close(int sockfd)
+int sys_close(int procfd)
{
- return(-ENOSYS);
+ process_t *cproc;
+ int ret_val;
+
+ /*
+ * The fd that was passed is a per-process "procfd", but soclose() needs
+ * the global "sockfd" - so we have to look it up first.
+ */
+
+ cproc = process_get_current();
+ ret_val = -EFAULT;
+
+ if(cproc) {
+ ret_val = process_flookup(cproc, procfd);
+
+ /*
+ * If ret_val is not negative, it holds the sockfd to be
+ * closed. Otherwise it holds an error number that we're
+ * going to return to the caller.
+ */
+ if(ret_val >= 0) {
+ dbg_printf("soclose(0x%08x)\n", ret_val);
+ ret_val = soclose(ret_val);
+ }
+ }
+
+ return(ret_val);
}
int sys_sendto(int sockfd, const void *buf, size_t len, int flags,