From: Matthew Wilcox <willy@debian.org>
To: Alexander Viro <viro@math.psu.edu>, linux-kernel@vger.kernel.org
Subject: [PATCH] work around duff ABIs
Date: Sun, 20 Oct 2002 05:31:47 +0100 [thread overview]
Message-ID: <20021020053147.C5285@parcelfarce.linux.theplanet.co.uk> (raw)
*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.
next reply other threads:[~2002-10-20 4:25 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2002-10-20 4:31 Matthew Wilcox [this message]
2002-10-20 4:45 ` [PATCH] work around duff ABIs 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
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20021020053147.C5285@parcelfarce.linux.theplanet.co.uk \
--to=willy@debian.org \
--cc=linux-kernel@vger.kernel.org \
--cc=viro@math.psu.edu \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox