public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH] work around duff ABIs
@ 2002-10-20  4:31 Matthew Wilcox
  2002-10-20  4:45 ` John Levon
                   ` (3 more replies)
  0 siblings, 4 replies; 11+ messages in thread
From: Matthew Wilcox @ 2002-10-20  4:31 UTC (permalink / raw)
  To: Alexander Viro, linux-kernel


*sigh*.  i hate this kind of bullshit.  please, don't anyone ever try
to pass 64-bit args through the syscall interface again.

Index: fs/read_write.c
===================================================================
RCS file: /var/cvs/linux-2.5/fs/read_write.c,v
retrieving revision 1.5
diff -u -p -r1.5 read_write.c
--- fs/read_write.c	17 Oct 2002 20:43:22 -0000	1.5
+++ fs/read_write.c	20 Oct 2002 04:22:15 -0000
@@ -14,6 +14,7 @@
 #include <linux/security.h>
 #include <linux/module.h>
 
+#include <asm/byteorder.h>
 #include <asm/uaccess.h>
 
 struct file_operations generic_ro_fops = {
@@ -285,9 +286,15 @@ asmlinkage ssize_t sys_write(unsigned in
 	return ret;
 }
 
-asmlinkage ssize_t sys_pread64(unsigned int fd, char *buf,
-			     size_t count, loff_t pos)
+#ifdef __BIG_ENDIAN
+asmlinkage ssize_t sys_pread64(unsigned int fd, char *buf, size_t count,
+				unsigned int high, unsigned int low)
+#else
+asmlinkage ssize_t sys_pread64(unsigned int fd, char *buf, size_t count,
+				unsigned int low, unsigned int high)
+#endif
 {
+	loff_t pos = (loff_t)high << 32 | low;
 	struct file *file;
 	ssize_t ret = -EBADF;
 
@@ -303,9 +310,15 @@ asmlinkage ssize_t sys_pread64(unsigned 
 	return ret;
 }
 
-asmlinkage ssize_t sys_pwrite64(unsigned int fd, const char *buf,
-			      size_t count, loff_t pos)
+#ifdef __BIG_ENDIAN
+asmlinkage ssize_t sys_pwrite64(unsigned int fd, const char *buf, size_t count,
+				unsigned int high, unsigned int low)
+#else
+asmlinkage ssize_t sys_pwrite64(unsigned int fd, const char *buf, size_t count,
+				unsigned int low, unsigned int high)
+#endif
 {
+	loff_t pos = (loff_t)high << 32 | low;
 	struct file *file;
 	ssize_t ret = -EBADF;
 
Index: fs/open.c
===================================================================
RCS file: /var/cvs/linux-2.5/fs/open.c,v
retrieving revision 1.4
diff -u -p -r1.4 open.c
--- fs/open.c	17 Oct 2002 20:43:22 -0000	1.4
+++ fs/open.c	20 Oct 2002 04:22:16 -0000
@@ -18,6 +18,7 @@
 #include <linux/backing-dev.h>
 #include <linux/security.h>
 
+#include <asm/byteorder.h>
 #include <asm/uaccess.h>
 
 #define special_file(m) (S_ISCHR(m)||S_ISBLK(m)||S_ISFIFO(m)||S_ISSOCK(m))
@@ -205,18 +206,34 @@ asmlinkage long sys_ftruncate(unsigned i
 	return do_sys_ftruncate(fd, length, 1);
 }
 
-/* LFS versions of truncate are only needed on 32 bit machines */
+/*
+ * LFS versions of truncate are only needed on 32 bit machines.  PA-RISC
+ * and MIPS ABIs specify 64-bit alignment for 64-bit quantities, but glibc
+ * ignores this and passes 64-bit quantities in misaligned registers.
+ */
 #if BITS_PER_LONG == 32
-asmlinkage long sys_truncate64(const char * path, loff_t length)
+#ifdef __BIG_ENDIAN
+asmlinkage long sys_truncate64(const char * path, unsigned int high, unsigned int low)
 {
-	return do_sys_truncate(path, length);
+	return do_sys_truncate(path, (loff_t)high << 32 | low);
 }
 
-asmlinkage long sys_ftruncate64(unsigned int fd, loff_t length)
+asmlinkage long sys_ftruncate64(unsigned int fd, unsigned int high, unsigned int low)
 {
-	return do_sys_ftruncate(fd, length, 0);
+	return do_sys_ftruncate(fd, (loff_t)high << 32 | low, 0);
 }
-#endif
+#else	/* !__BIG_ENDIAN */
+asmlinkage long sys_truncate64(const char * path, unsigned int low, unsigned int high)
+{
+	return do_sys_truncate(path, (loff_t)high << 32 | low);
+}
+
+asmlinkage long sys_ftruncate64(unsigned int fd, unsigned int low, unsigned int high)
+{
+	return do_sys_ftruncate(fd, (loff_t)high << 32 | low, 0);
+}
+#endif	/* !__BIG_ENDIAN */
+#endif	/* BITS_PER_LONG == 32 */
 
 #if !(defined(__alpha__) || defined(__ia64__))
 

-- 
Revolutions do not require corporate support.

^ permalink raw reply	[flat|nested] 11+ messages in thread

end of thread, other threads:[~2002-11-04  5:04 UTC | newest]

Thread overview: 11+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2002-10-20  4:31 [PATCH] work around duff ABIs Matthew Wilcox
2002-10-20  4:45 ` John Levon
2002-10-20  4:51 ` Erik Andersen
2002-10-20 12:51   ` Matthew Wilcox
2002-10-21 12:14     ` Alan Cox
2002-10-22  4:43     ` Erik Andersen
2002-10-22 13:04       ` Matthew Wilcox
2002-10-21 12:13 ` Alan Cox
2002-10-21 13:48   ` Matthew Wilcox
2002-10-21 16:26     ` Alan Cox
2002-11-04  5:10 ` Richard Henderson

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox