diff --git a/fs/vfs/main.c b/fs/vfs/main.c
index 774c182a09a439aa82fda37b74f20fd4c2201421..a9897cba66ca0f753d73d3e9880c28abaa619533 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 49b773c1f84ef31f19f0935e0dc41ca85f37a7b7..faa621029687c2f3289dd2b1afe72dc3d66a0f9a 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");