Skip to contentSkip to conversation

Generic compat_sys_fallocate

PATCH In review Kyle McMartin 2 participants 4 messages Sep 28, 2007 1 message not in the archive

Subsystems (4)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 Generic compat_sys_fallocate

Basically everyone is using the same sys32_fallocate. Delete a whole bunch of archdep code and move the compat wrapper to fs/compat.c

---

NOTE: Patch hunk in scall64-o32.S depends on a patch going in through Ralf's linux-mips tree.

---
 arch/mips/kernel/linux32.c        |    7 -------
 arch/mips/kernel/scall64-o32.S    |    2 +-
 arch/powerpc/kernel/sys_ppc32.c   |    7 -------
 arch/sparc64/kernel/sys_sparc32.c |    6 ------
 arch/x86_64/ia32/ia32entry.S      |    2 +-
 arch/x86_64/ia32/sys_ia32.c       |    7 -------
 fs/compat.c                       |   10 ++++++++++
 include/linux/compat.h            |    2 ++
 8 files changed, 14 insertions(+), 29 deletions(-)
arch/mips/kernel/linux32.c +0 -7
index 135d9a5..c37568d 100644
@@ -566,13 +566,6 @@ asmlinkage long sys32_fadvise64_64(int fd, int __pad,
 			flags);
 }
 
-asmlinkage long sys32_fallocate(int fd, int mode, unsigned offset_a2,
-	unsigned offset_a3, unsigned len_a4, unsigned len_a5)
-{
-	return sys_fallocate(fd, mode, merge_64(offset_a2, offset_a3),
-	                     merge_64(len_a4, len_a5));
-}
-
 save_static_function(sys32_clone);
 static int noinline __used
 _sys32_clone(nabi_no_regargs struct pt_regs regs)
arch/mips/kernel/scall64-o32.S +1 -1
index dd68afc..bb724cc 100644
@@ -525,5 +525,5 @@ sys_call_table:
 	PTR	compat_sys_signalfd
 	PTR	compat_sys_timerfd
 	PTR	sys_eventfd
-	PTR	sys32_fallocate			/* 4320 */
+	PTR	compat_sys_fallocate		/* 4320 */
 	.size	sys_call_table,.-sys_call_table
arch/powerpc/kernel/sys_ppc32.c +0 -7
index bd85b5f..b42cbf1 100644
@@ -773,13 +773,6 @@ asmlinkage int compat_sys_truncate64(const char __user * path, u32 reg4,
 	return sys_truncate(path, (high << 32) | low);
 }
 
-asmlinkage long compat_sys_fallocate(int fd, int mode, u32 offhi, u32 offlo,
-				     u32 lenhi, u32 lenlo)
-{
-	return sys_fallocate(fd, mode, ((loff_t)offhi << 32) | offlo,
-			     ((loff_t)lenhi << 32) | lenlo);
-}
-
 asmlinkage int compat_sys_ftruncate64(unsigned int fd, u32 reg4, unsigned long high,
 				 unsigned long low)
 {
arch/sparc64/kernel/sys_sparc32.c +0 -6
index e8dce90..5d60883 100644
@@ -1028,9 +1028,3 @@ long compat_sync_file_range(int fd, unsigned long off_high, unsigned long off_lo
 				   flags);
 }
 
-asmlinkage long compat_sys_fallocate(int fd, int mode, u32 offhi, u32 offlo,
-				     u32 lenhi, u32 lenlo)
-{
-	return sys_fallocate(fd, mode, ((loff_t)offhi << 32) | offlo,
-			     ((loff_t)lenhi << 32) | lenlo);
-}
arch/x86_64/ia32/ia32entry.S +1 -1
index 18b2318..28d8fff 100644
@@ -732,5 +732,5 @@ ia32_sys_call_table:
 	.quad compat_sys_signalfd
 	.quad compat_sys_timerfd
 	.quad sys_eventfd
-	.quad sys32_fallocate
+	.quad compat_sys_fallocate
 ia32_syscall_end:
arch/x86_64/ia32/sys_ia32.c +0 -7
index bee96d6..ca8deac 100644
@@ -880,10 +880,3 @@ asmlinkage long sys32_fadvise64(int fd, unsigned offset_lo, unsigned offset_hi,
 				len, advice);
 }
 
-asmlinkage long sys32_fallocate(int fd, int mode, unsigned offset_lo,
-				unsigned offset_hi, unsigned len_lo,
-				unsigned len_hi)
-{
-	return sys_fallocate(fd, mode, ((u64)offset_hi << 32) | offset_lo,
-			     ((u64)len_hi << 32) | len_lo);
-}
fs/compat.c +10 -0
index 15078ce..2629a25 100644
@@ -2226,3 +2226,13 @@ asmlinkage long compat_sys_timerfd(int ufd, int clockid, int flags,
 }
 
 #endif /* CONFIG_TIMERFD */
+
+asmlinkage long compat_sys_fallocate(int fd, int mode,
+				     u32 offset_lo, u32 offset_hi,
+				     u32 len_lo, u32 len_hi)
+{
+	u64 offset = ((u64)offset_hi << 32) | offset_lo;
+	u64 len = ((u64)len_hi << 32) | len_hi;
+
+	return sys_fallocate(fd, mode, offset, len);
+}
include/linux/compat.h +2 -0
index 0e69d2c..a770c6c 100644
@@ -266,6 +266,8 @@ asmlinkage long compat_sys_signalfd(int ufd,
                                 compat_size_t sigsetsize);
 asmlinkage long compat_sys_timerfd(int ufd, int clockid, int flags,
 				const struct compat_itimerspec __user *utmr);
+asmlinkage long compat_sys_fallocate(int fd, int mode, u32 offset_lo,
+				u32 offset_hi, u32 len_lo, u32 len_hi);
 
 #endif /* CONFIG_COMPAT */
 #endif /* _LINUX_COMPAT_H */
Signature · 1 line
1.5.3.2

A message that is not in the archive (sent off-list or not yet received): [email protected]

#2 lore raw
Quoted 4 lines · Arnd Bergmann

This code assumes little-endian register ordering for 64 bit arguments. AFAICS, this is wrong at aleast on mipseb and powerpc.

Yeah, you're right. I've an idea for how to fix this, will update patch soon.

Cheers,
Kyle

#3 lore raw
In reply to Kyle McMartin
Quoted 21 lines · Kyle McMartin

Basically everyone is using the same sys32_fallocate. Delete a whole bunch of archdep code and move the compat wrapper to fs/compat.c

arch/sparc64/kernel/sys_sparc32.c +0 -6
@@ -1028,9 +1028,3 @@ long compat_sync_file_range(int fd, unsigned long off_high, unsigned long off_lo
 				   flags);
 }
 
-asmlinkage long compat_sys_fallocate(int fd, int mode, u32 offhi, u32 offlo,
-				     u32 lenhi, u32 lenlo)
-{
-	return sys_fallocate(fd, mode, ((loff_t)offhi << 32) | offlo,
-			     ((loff_t)lenhi << 32) | lenlo);
-}
arch/x86_64/ia32/sys_ia32.c +0 -0
index bee96d6..ca8deac 100644

arch/x86_64/ia32/sys_ia32.c asmlinkage long sys32_fadvise64(int fd, unsigned offset_lo, unsigned offset_hi, · line 889

Quoted 10 lines
arch/x86_64/ia32/sys_ia32.c +0 -7
@@ -880,10 +880,3 @@ asmlinkage long sys32_fadvise64(int fd, unsigned offset_lo, unsigned offset_hi,
 				len, advice);
 }
 
-asmlinkage long sys32_fallocate(int fd, int mode, unsigned offset_lo,
-				unsigned offset_hi, unsigned len_lo,
-				unsigned len_hi)
-{
-	return sys_fallocate(fd, mode, ((u64)offset_hi << 32) | offset_lo,
-			     ((u64)len_hi << 32) | len_lo);
-}

These are not identical... the least and most significant parts seem to get passed in a different way on little and big endian machines. Maybe it would be worth to have something like compat_merge_64() which does the right thing?

#4 lore raw
Quoted 6 lines · Heiko Carstens

These are not identical... the least and most significant parts seem to get passed in a different way on little and big endian machines. Maybe it would be worth to have something like compat_merge_64() which does the right thing?

yeah, that's what i've just done.

cheers,
Kyle