qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: "Kirill A. Shutemov" <kirill@shutemov.name>
To: qemu-devel@nongnu.org
Cc: "Kirill A. Shutemov" <kirill@shutemov.name>
Subject: [Qemu-devel] [PATCH] Fix fstatat64()/newfstatat() syscall implementation
Date: Wed,  3 Dec 2008 13:29:37 +0200	[thread overview]
Message-ID: <1228303789-25653-2-git-send-email-kirill@shutemov.name> (raw)
In-Reply-To: <1228303789-25653-1-git-send-email-kirill@shutemov.name>

There are two different syscall names for the same goal.

On systems with sizeof(long) == 64 it calls newfstatat.
On systems with sizeof(long) == 32 it calls fstatat64.

Signed-off-by: Kirill A. Shutemov <kirill@shutemov.name>
---
 linux-user/syscall.c |   29 +++++++++++++++++++++++++----
 1 files changed, 25 insertions(+), 4 deletions(-)

diff --git a/linux-user/syscall.c b/linux-user/syscall.c
index 4065917..dc65a77 100644
--- a/linux-user/syscall.c
+++ b/linux-user/syscall.c
@@ -169,6 +169,7 @@ static type name (type1 arg1,type2 arg2,type3 arg3,type4 arg4,type5 arg5,	\
 #define __NR_sys_linkat __NR_linkat
 #define __NR_sys_mkdirat __NR_mkdirat
 #define __NR_sys_mknodat __NR_mknodat
+#define __NR_sys_newfstatat __NR_newfstatat
 #define __NR_sys_openat __NR_openat
 #define __NR_sys_readlinkat __NR_readlinkat
 #define __NR_sys_renameat __NR_renameat
@@ -210,7 +211,8 @@ _syscall4(int,sys_fchmodat,int,dirfd,const char *,pathname,
 _syscall5(int,sys_fchownat,int,dirfd,const char *,pathname,
           uid_t,owner,gid_t,group,int,flags)
 #endif
-#if defined(TARGET_NR_fstatat64) && defined(__NR_fstatat64)
+#if (defined(TARGET_NR_fstatat64) || defined(TARGET_NR_newfstatat)) && \
+        defined(__NR_fstatat64)
 _syscall4(int,sys_fstatat64,int,dirfd,const char *,pathname,
           struct stat *,buf,int,flags)
 #endif
@@ -241,6 +243,11 @@ _syscall3(int,sys_mkdirat,int,dirfd,const char *,pathname,mode_t,mode)
 _syscall4(int,sys_mknodat,int,dirfd,const char *,pathname,
           mode_t,mode,dev_t,dev)
 #endif
+#if (defined(TARGET_NR_newfstatat) || defined(TARGET_NR_fstatat64) ) && \
+        defined(__NR_newfstatat)
+_syscall4(int,sys_newfstatat,int,dirfd,const char *,pathname,
+          struct stat *,buf,int,flags)
+#endif
 #if defined(TARGET_NR_openat) && defined(__NR_openat)
 _syscall4(int,sys_openat,int,dirfd,const char *,pathname,int,flags,mode_t,mode)
 #endif
@@ -3246,7 +3253,7 @@ static inline abi_long host_to_target_timespec(abi_ulong target_addr,
     return 0;
 }
 
-#ifdef TARGET_NR_stat64
+#if defined(TARGET_NR_stat64) || defined(TARGET_NR_newfstatat)
 static inline abi_long host_to_target_stat64(void *cpu_env,
                                              abi_ulong target_addr,
                                              struct stat *host_st)
@@ -3278,11 +3285,15 @@ static inline abi_long host_to_target_stat64(void *cpu_env,
     } else
 #endif
     {
+#if TARGET_LONG_BITS == 64
+        struct target_stat *target_st;
+#else
         struct target_stat64 *target_st;
+#endif
 
         if (!lock_user_struct(VERIFY_WRITE, target_st, target_addr, 0))
             return -TARGET_EFAULT;
-        memset(target_st, 0, sizeof(struct target_stat64));
+        memset(target_st, 0, sizeof(*target_st));
         __put_user(host_st->st_dev, &target_st->st_dev);
         __put_user(host_st->st_ino, &target_st->st_ino);
 #ifdef TARGET_STAT64_HAS_BROKEN_ST_INO
@@ -5373,11 +5384,21 @@ abi_long do_syscall(void *cpu_env, int num, abi_long arg1,
             ret = host_to_target_stat64(cpu_env, arg2, &st);
         break;
 #endif
-#if defined(TARGET_NR_fstatat64) && defined(__NR_fstatat64)
+#if (defined(TARGET_NR_fstatat64) || defined(TARGET_NR_newfstatat)) && \
+        (defined(__NR_fstatat64) || defined(__NR_newfstatat))
+#ifdef TARGET_NR_fstatat64
     case TARGET_NR_fstatat64:
+#endif
+#ifdef TARGET_NR_newfstatat
+    case TARGET_NR_newfstatat:
+#endif
         if (!(p = lock_user_string(arg2)))
             goto efault;
+#ifdef __NR_fstatat64
         ret = get_errno(sys_fstatat64(arg1, path(p), &st, arg4));
+#else
+        ret = get_errno(sys_newfstatat(arg1, path(p), &st, arg4));
+#endif
         if (!is_error(ret))
             ret = host_to_target_stat64(cpu_env, arg3, &st);
         break;
-- 
1.6.0.2.GIT

  reply	other threads:[~2008-12-03 11:28 UTC|newest]

Thread overview: 48+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-12-03 11:29 [Qemu-devel] [PATCH] Introduce --enable-binfmt-misc configure option Kirill A. Shutemov
2008-12-03 11:29 ` Kirill A. Shutemov [this message]
2008-12-03 11:29   ` [Qemu-devel] [PATCH] Move abi_* typedefs into qemu-types.h Kirill A. Shutemov
2008-12-03 11:29     ` [Qemu-devel] [PATCH] linux-user: Safety belt for h2g Kirill A. Shutemov
2008-12-03 11:29       ` [Qemu-devel] [PATCH] linux-user: Introduce h2g_valid Kirill A. Shutemov
2008-12-03 11:29         ` [Qemu-devel] [PATCH] linux-user: Fix h2g usage in page_find_alloc Kirill A. Shutemov
2008-12-03 11:29           ` [Qemu-devel] [PATCH] Rewrite mmap_find_vma() to work fine on 64-bit hosts with 32-bit targets Kirill A. Shutemov
2008-12-03 11:29             ` [Qemu-devel] [PATCH] mmap: add check if requested memory area fits target address space Kirill A. Shutemov
2008-12-03 11:29               ` [Qemu-devel] [PATCH] mremap(): handle MREMAP_FIXED and MREMAP_MAYMOVE correctly Kirill A. Shutemov
2008-12-03 11:29                 ` [Qemu-devel] [PATCH] Fix and cleanup IPCOP_sem* ipc calls handling Kirill A. Shutemov
2008-12-03 11:29                   ` [Qemu-devel] [PATCH] Implement sem* syscalls Kirill A. Shutemov
2008-12-03 11:29                     ` [Qemu-devel] [PATCH] Fix and cleanup IPCOP_shm* ipc calls handling Kirill A. Shutemov
2008-12-03 11:29                       ` [Qemu-devel] [PATCH] Implement shm* syscalls Kirill A. Shutemov
2008-12-03 11:29                         ` [Qemu-devel] [PATCH] shmat(): use mmap_find_vma to find free memory area Kirill A. Shutemov
2008-12-06 19:51                 ` [Qemu-devel] [PATCH] mremap(): handle MREMAP_FIXED and MREMAP_MAYMOVE correctly Edgar E. Iglesias
2008-12-06 20:03                   ` Kirill A. Shutemov
2008-12-08 18:17                 ` Aurelien Jarno
2008-12-06 19:46               ` [Qemu-devel] [PATCH] mmap: add check if requested memory area fits target address space Edgar E. Iglesias
2008-12-06 20:00                 ` Kirill A. Shutemov
2008-12-08 18:16               ` Aurelien Jarno
2008-12-03 12:34             ` [Qemu-devel] [PATCH] Rewrite mmap_find_vma() to work fine on 64-bit hosts with 32-bit targets Paul Brook
2008-12-03 12:43               ` Christoph Egger
2008-12-03 12:48                 ` Paul Brook
2008-12-03 12:50               ` Kirill A. Shutemov
2008-12-08 20:48                 ` Kirill A. Shutemov
2008-12-08 20:54                   ` Martin Mohring
2008-12-08 20:59                   ` Martin Mohring
2008-12-08 21:57                     ` Kirill A. Shutemov
2008-12-08 21:02                   ` Martin Mohring
2008-12-08 22:14                     ` [Qemu-devel] qemu and glibc version Kirill A. Shutemov
2008-12-09 12:25                     ` [Qemu-devel] [PATCH] Rewrite mmap_find_vma() to work fine on 64-bit hosts with 32-bit targets Robert Reif
2008-12-09 13:26                       ` Kirill A. Shutemov
2008-12-08 23:42                   ` Paul Brook
2008-12-09  6:20                     ` Kirill A. Shutemov
2008-12-06 20:08           ` [Qemu-devel] [PATCH] linux-user: Fix h2g usage in page_find_alloc Edgar E. Iglesias
2008-12-06 20:13             ` Kirill A. Shutemov
2008-12-08 18:16           ` Aurelien Jarno
2008-12-08 18:15         ` [Qemu-devel] [PATCH] linux-user: Introduce h2g_valid Aurelien Jarno
2008-12-06 20:04       ` [Qemu-devel] [PATCH] linux-user: Safety belt for h2g Edgar E. Iglesias
2008-12-08 18:15       ` Aurelien Jarno
2008-12-08 19:25         ` Andreas Färber
2008-12-09  7:34         ` Jan Kiszka
2008-12-07 21:56     ` [Qemu-devel] [PATCH] Move abi_* typedefs into qemu-types.h Aurelien Jarno
2008-12-08  6:09       ` Kirill A. Shutemov
2008-12-08 18:13     ` Aurelien Jarno
2009-01-12 14:18 ` [Qemu-devel] [PATCH] Introduce --enable-binfmt-misc configure option Riku Voipio
  -- strict thread matches above, loose matches on Subject: below --
2008-10-13 10:10 [Qemu-devel] [PATCH] Add readahead syscall Kirill A. Shutemov
2008-10-13 10:10 ` [Qemu-devel] [PATCH] Fix getdents* syscalls Kirill A. Shutemov
2008-10-13 10:10   ` [Qemu-devel] [PATCH] Fix and cleanup IPCOP_msg* ipc calls handling Kirill A. Shutemov
2008-10-13 10:10     ` [Qemu-devel] [PATCH] Implement msg* syscalls Kirill A. Shutemov
2008-10-13 10:10       ` [Qemu-devel] [PATCH] Fix and cleanup IPCOP_sem* ipc calls handling Kirill A. Shutemov
2008-10-13 10:10         ` [Qemu-devel] [PATCH] Implement sem* syscalls Kirill A. Shutemov
2008-10-13 10:10           ` [Qemu-devel] [PATCH] Fix and cleanup IPCOP_shm* ipc calls handling Kirill A. Shutemov
2008-10-13 10:10             ` [Qemu-devel] [PATCH] Implement shm* syscalls Kirill A. Shutemov
2008-10-13 10:10               ` [Qemu-devel] [PATCH] Fix fstatat64()/newfstatat() syscall implementation Kirill A. Shutemov
2008-10-08 18:54 [Qemu-devel] [PATCH] Add readahead syscall Kirill A. Shutemov
2008-10-08 18:54 ` [Qemu-devel] [PATCH] Fix getdents* syscalls Kirill A. Shutemov
2008-10-08 18:54   ` [Qemu-devel] [PATCH] Fix and cleanup IPCOP_msg* ipc calls handling Kirill A. Shutemov
2008-10-08 18:54     ` [Qemu-devel] [PATCH] Implement msg* syscalls Kirill A. Shutemov
2008-10-08 18:54       ` [Qemu-devel] [PATCH] Fix and cleanup IPCOP_sem* ipc calls handling Kirill A. Shutemov
2008-10-08 18:54         ` [Qemu-devel] [PATCH] Implement sem* syscalls Kirill A. Shutemov
2008-10-08 18:54           ` [Qemu-devel] [PATCH] Fix and cleanup IPCOP_shm* ipc calls handling Kirill A. Shutemov
2008-10-08 18:54             ` [Qemu-devel] [PATCH] Implement shm* syscalls Kirill A. Shutemov
2008-10-08 18:54               ` [Qemu-devel] [PATCH] Fix fstatat64()/newfstatat() syscall implementation Kirill A. Shutemov

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=1228303789-25653-2-git-send-email-kirill@shutemov.name \
    --to=kirill@shutemov.name \
    --cc=qemu-devel@nongnu.org \
    /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;
as well as URLs for NNTP newsgroup(s).