Skip to contentSkip to conversation

pread/pwrite

parisc-linux Matthew Wilcox 2 participants 2 messages Apr 10, 2001 – Apr 11, 2001

lore
Share & tools
lore
#0 lore raw

Could those who're having problems with pread/pwrite try the following patch?

Index: fs/read_write.c
===================================================================
RCS file: /home/cvs/parisc/linux/fs/read_write.c,v retrieving revision 1.6

read_write.c +36 -4
diff -u -p -r1.6 read_write.c
@@ -315,8 +315,8 @@ bad_file:
    lseek back to original location.  They fail just like lseek does on
    non-seekable files.  */
 
-asmlinkage ssize_t sys_pread(unsigned int fd, char * buf,
-			     size_t count, loff_t pos)
+static inline
+ssize_t do_pread(unsigned int fd, char * buf, size_t count, loff_t pos)
 {
 	ssize_t ret;
 	struct file * file;
@@ -346,8 +346,8 @@ bad_file:
 	return ret;
 }
 
-asmlinkage ssize_t sys_pwrite(unsigned int fd, const char * buf,
-			      size_t count, loff_t pos)
+static inline
+ssize_t do_pwrite(unsigned int fd, const char * buf, size_t count, loff_t pos)
 {
 	ssize_t ret;
 	struct file * file;
@@ -377,3 +377,35 @@ out:
 bad_file:
 	return ret;
 }
+
+#if BITS_PER_LONG == 32
+#ifdef __BIG_ENDIAN
+#define LOFF_T(high, low) unsigned int high, unsigned int low
+#else
+#define LOFF_T(high, low) unsigned int low, unsigned int high
+#endif
+
+asmlinkage
+ssize_t sys_pread(unsigned int fd, char *buf, size_t count, LOFF_T(high, low))
+{
+	return do_pread(fd, buf, count, (loff_t)high << 32 | low);
+}
+
+ssize_t sys_pwrite(unsigned int fd, char *buf, size_t count, LOFF_T(high, low))
+{
+	return do_pwrite(fd, buf, count, (loff_t)high << 32 | low);
+}
+
+
+#else /* BITS_PER_LONG != 32 */
+asmlinkage
+ssize_t sys_pread(unsigned int fd, char *buf, size_t count, loff_t pos)
+{
+	return do_pread(fd, buf, count, pos);
+}
+
+ssize_t sys_pwrite(unsigned int fd, char *buf, size_t count, loff_t pos)
+{
+	return do_pwrite(fd, buf, count, pos);
+}
+#endif
Signature · 1 line
Revolutions do not require corporate support.
#1 lore raw

Hi Willy,

Quoted 1 line

Could those who're having problems with pread/pwrite try the following patch?

I don't see how this is supposed to work with a 32 bit userspace and 64
bit kernel. Do we also need syscall wrappers for pread/pwrite, something like this:

Index: arch/parisc/kernel/sys_parisc32.c
===================================================================
RCS file: /home/cvs/parisc/linux/arch/parisc/kernel/sys_parisc32.c,v retrieving revision 1.4

sys_parisc32.c +16 -0
diff -u -r1.4 sys_parisc32.c
@@ -2727,3 +2727,19 @@
 	}
 	sys_fcntl(fd, cmd, arg);
 }
+
+
+asmlinkage int sys32_pread(int fd, void *buf, size_t count, unsigned int high, unsigned int low)
+{
+	extern asmlinkage ssize_t sys_pread(unsigned int, char *, size_t, loff_t);
+
+	return sys_pread(fd, buf, count, (loff_t)high << 32 | low);
+}
+
+asmlinkage int sys32_pwrite(int fd, void *buf, size_t count, unsigned int high, unsigned int low)
+{
+	extern asmlinkage ssize_t sys_pwrite(unsigned int, char *, size_t, loff_t);
+
+	return sys_pwrite(fd, buf, count, (loff_t)high << 32 | low);
+}
+

Index: arch/parisc/kernel/syscall.S
===================================================================
RCS file: /home/cvs/parisc/linux/arch/parisc/kernel/syscall.S,v retrieving revision 1.60

syscall.S +2 -2
diff -u -r1.60 syscall.S
@@ -441,8 +441,8 @@
 	ENTRY_SAME(getitimer)	/* 105 */
 	ENTRY_SAME(capget)
 	ENTRY_SAME(capset)
-	ENTRY_SAME(pread)
-	ENTRY_SAME(pwrite)
+	ENTRY_DIFF(pread)
+	ENTRY_DIFF(pwrite)
 	ENTRY_SAME(getcwd)		/* 110 */
 	ENTRY_SAME(vhangup)
 	ENTRY_SAME(fstat64)