From 5f48865286c64f68708c63f960e7de26140fcd95 Mon Sep 17 00:00:00 2001
From: Christoph Hellwig <hch@cloudius-systems.com>
Date: Mon, 21 Jan 2013 11:56:04 +0100
Subject: [PATCH] wire up ioctl()

---
 fs/vfs/main.c | 19 ++++++++++++-------
 runtime.cc    |  5 -----
 2 files changed, 12 insertions(+), 12 deletions(-)

diff --git a/fs/vfs/main.c b/fs/vfs/main.c
index 774c182a0..a9897cba6 100755
--- a/fs/vfs/main.c
+++ b/fs/vfs/main.c
@@ -284,19 +284,24 @@ ssize_t writev(int fd, const struct iovec *iov, int iovcnt)
 	return pwritev(fd, iov, iovcnt, -1);
 }
 
-#if 0
-static int
-fs_ioctl(struct task *t, struct ioctl_msg *msg)
+int ioctl(int fd, int request, unsigned long arg)
 {
 	struct task *t = main_task;
 	file_t fp;
+	int error;
 
-	if ((fp = task_getfp(t, msg->fd)) == NULL)
-		return EBADF;
+	error = EBADF;
+	if ((fp = task_getfp(t, fd)) == NULL)
+		goto out_errno;
 
-	return sys_ioctl(fp, msg->request, msg->buf);
+	error = sys_ioctl(fp, request, (void *)arg);
+	if (error)
+		goto out_errno;
+	return 0;
+out_errno:
+	errno = error;
+	return -1;
 }
-#endif
 
 int fsync(int fd)
 {
diff --git a/runtime.cc b/runtime.cc
index 49b773c1f..faa621029 100644
--- a/runtime.cc
+++ b/runtime.cc
@@ -197,11 +197,6 @@ static struct __locale_struct c_locale = {
     c_locale_array + 128, // __ctype_b
 };
 
-int ioctl(int fd, unsigned long request, ...)
-{
-    UNIMPLEMENTED("ioctl");
-}
-
 int poll(struct pollfd *fds, nfds_t nfds, int timeout)
 {
     UNIMPLEMENTED("poll");
-- 
GitLab