Skip to contentSkip to conversation

linux-user: fix fallocate

PATCH In review Alexander Graf 2 participants 3 messages Feb 6, 2012

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 linux-user: fix fallocate

Fallocate gets off_t parameters passed in, so we should also read them out accordingly.

---
 linux-user/syscall.c |    3 ++-
 1 files changed, 2 insertions(+), 1 deletions(-)
linux-user/syscall.c +2 -1
index ee8899e..ca63594 100644
@@ -8237,7 +8237,8 @@ abi_long do_syscall(void *cpu_env, int num, abi_long arg1,
 #endif /* CONFIG_EVENTFD  */
 #if defined(CONFIG_FALLOCATE) && defined(TARGET_NR_fallocate)
     case TARGET_NR_fallocate:
-        ret = get_errno(fallocate(arg1, arg2, arg3, arg4));
+        ret = get_errno(fallocate(arg1, arg2, target_offset64(arg3, arg4),
+                                  target_offset64(arg5, arg6)));
         break;
 #endif
 #if defined(CONFIG_SYNC_FILE_RANGE)
Signature · 1 line
1.6.0.2
#1 lore raw
Quoted 15 lines · Alexander Graf

Fallocate gets off_t parameters passed in, so we should also read them out accordingly.

---
 linux-user/syscall.c |    3 ++-

 1 files changed, 2 insertions(+), 1 deletions(-)
linux-user/syscall.c +0 -0
index ee8899e..ca63594 100644
@@ -8237,7 +8237,8 @@ abi_long do_syscall(void *cpu_env, int num, abi_long arg1,
  #endif /* CONFIG_EVENTFD  */
  #if defined(CONFIG_FALLOCATE) && defined(TARGET_NR_fallocate)
Quoted 7 lines

    case TARGET_NR_fallocate:
-        ret = get_errno(fallocate(arg1, arg2, arg3, arg4));
+        ret = get_errno(fallocate(arg1, arg2, target_offset64(arg3, arg4),
+                                  target_offset64(arg5, arg6))); break;
 #endif
 #if defined(CONFIG_SYNC_FILE_RANGE)

This needs to be guarded with a TARGET_ABI_BITS == 32 conditional:
64 bit guests want the original version.

-- PMM

#2 lore raw
Quoted 18 lines · Peter Maydell
Quoted 17 lines · Alexander Graf

Fallocate gets off_t parameters passed in, so we should also read them out accordingly.

---
 linux-user/syscall.c |    3 ++-
 1 files changed, 2 insertions(+), 1 deletions(-)
linux-user/syscall.c +0 -1
index ee8899e..ca63594 100644
@@ -8237,7 +8237,8 @@ abi_long do_syscall(void *cpu_env, int num, abi_long arg1,
 #endif /* CONFIG_EVENTFD  */
 #if defined(CONFIG_FALLOCATE) && defined(TARGET_NR_fallocate)
    case TARGET_NR_fallocate:
-        ret = get_errno(fallocate(arg1, arg2, arg3, arg4));
Quoted 8 lines

linux-user/syscall.c abi_long do_syscall(void *cpu_env, int num, abi_long arg1, · line 8244

Quoted 5 lines
linux-user/syscall.c +2 -0
+        ret = get_errno(fallocate(arg1, arg2, target_offset64(arg3, arg4),
+                                  target_offset64(arg5, arg6)));
        break;
 #endif
 #if defined(CONFIG_SYNC_FILE_RANGE)

This needs to be guarded with a TARGET_ABI_BITS == 32 conditional:
64 bit guests want the original version.

Good point. Thanks!

Alex