[PATCH 12/13] mips64: ioctl

Atsushi Nemoto anemo at mba.ocn.ne.jp
Sun Sep 17 16:40:40 UTC 2006


The ioctl number must be sign-extended 32bit value for mips64 kernel.
Without this change, libc passes 0x0000000080000000 for ioctl request
0x80000000, but kernel expects 0xffffffff80000000 for the ioctl.

Since I do not know about other 64bit system, I think adding mips
specific ioctl.c would be better than touching the common one.  This
mips specific ioctl.c can be used for all MIPS ABI.

If the type of second argument of ioctl() was changed to int, this
patch is not needed.

-------------- next part --------------
diff -urNp uClibc-20060913/libc/sysdeps/linux/mips/Makefile.arch uClibc/libc/sysdeps/linux/mips/Makefile.arch
--- uClibc-20060913/libc/sysdeps/linux/mips/Makefile.arch	2006-09-13 16:10:30.000000000 +0900
+++ uClibc/libc/sysdeps/linux/mips/Makefile.arch	2006-09-14 09:11:47.000000000 +0900
@@ -6,7 +6,7 @@
 #
 
 CSRC := \
-	__longjmp.c  brk.c setjmp_aux.c mmap.c __syscall_error.c \
+	__longjmp.c  brk.c setjmp_aux.c mmap.c __syscall_error.c ioctl.c \
 	cacheflush.c pread_write.c sysmips.c _test_and_set.c sigaction.c
 
 SSRC := bsd-_setjmp.S bsd-setjmp.S setjmp.S clone.S syscall.S pipe.S
diff -urNp uClibc-20060913/libc/sysdeps/linux/mips/ioctl.c uClibc/libc/sysdeps/linux/mips/ioctl.c
--- uClibc-20060913/libc/sysdeps/linux/mips/ioctl.c	1970-01-01 09:00:00.000000000 +0900
+++ uClibc/libc/sysdeps/linux/mips/ioctl.c	2006-09-14 09:11:52.000000000 +0900
@@ -0,0 +1,32 @@
+/* vi: set sw=4 ts=4: */
+/*
+ * ioctl() for uClibc
+ *
+ * Copyright (C) 2000-2006 Erik Andersen <andersen at uclibc.org>
+ *
+ * Licensed under the LGPL v2.1, see the file COPYING.LIB in this tarball.
+ */
+
+#include "../common/syscalls.h"
+#include <stdarg.h>
+#include <sys/ioctl.h>
+
+libc_hidden_proto(ioctl)
+
+/* 'request' must be sign-extended 32bit value on n64 */
+#define __NR___syscall_ioctl __NR_ioctl
+static inline
+_syscall3(int, __syscall_ioctl, int, fd, int, request, void *, arg);
+
+int ioctl(int fd, unsigned long int request, ...)
+{
+    void *arg;
+    va_list list;
+
+    va_start(list, request);
+    arg = va_arg(list, void *);
+
+    va_end(list);
+    return __syscall_ioctl(fd, request, arg);
+}
+libc_hidden_def(ioctl)


More information about the uClibc mailing list