qemu-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: stat64 wrong on sparc64 user


From: Luca Bonissi
Subject: Re: stat64 wrong on sparc64 user
Date: Thu, 30 Mar 2023 13:13:58 +0200
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.8.0

On 29/03/23 18:22, Laurent Vivier wrote:
Le 28/03/2023 à 14:22, Luca Bonissi a écrit :
On 28/03/23 13:55, Thomas Huth wrote:
On 28/03/2023 13.48, Luca Bonissi wrote:
--- qemu-20230327/linux-user/syscall_defs.h    2023-03-27 15:41:42.000000000 +0200 +++ qemu-20230327/linux-user/syscall_defs.h.new    2023-03-27 21:43:25.615115126 +0200
@@ -1450,7 +1450,7 @@ struct target_stat {
      unsigned int    st_dev;
      abi_ulong    st_ino;
      unsigned int    st_mode;
-    unsigned int    st_nlink;
+    short int    st_nlink;
      unsigned int    st_uid;



To have automatic alignment according to target ABI, you must use abi_XXX type (see include/exec/user/abitypes.h)


I tried to keep as much as possibile the source code untouched, but no problem to change all fields with abi_XXX. Tested for sparc and sparc64:

--- qemu-20230327/linux-user/syscall_defs.h.orig 2023-03-27 15:41:42.000000000 +0200 +++ qemu-20230327/linux-user/syscall_defs.h 2023-03-30 12:52:46.308640526 +0200
@@ -1447,13 +1447,13 @@ struct target_eabi_stat64 {

 #elif defined(TARGET_SPARC64) && !defined(TARGET_ABI32)
 struct target_stat {
-       unsigned int    st_dev;
+       abi_uint        st_dev;
        abi_ulong       st_ino;
-       unsigned int    st_mode;
-       unsigned int    st_nlink;
-       unsigned int    st_uid;
-       unsigned int    st_gid;
-       unsigned int    st_rdev;
+       abi_uint        st_mode;
+       abi_short       st_nlink;
+       abi_uint        st_uid;
+       abi_uint        st_gid;
+       abi_uint        st_rdev;
        abi_long        st_size;
        abi_long        target_st_atime;
        abi_long        target_st_mtime;
@@ -1465,25 +1465,23 @@ struct target_stat {

 #define TARGET_HAS_STRUCT_STAT64
 struct target_stat64 {
-       unsigned char   __pad0[6];
-       unsigned short  st_dev;
+       abi_ullong      st_dev;

-       uint64_t        st_ino;
-       uint64_t        st_nlink;
+       abi_ullong      st_ino;
+       abi_ullong      st_nlink;

-       unsigned int    st_mode;
+       abi_uint        st_mode;

-       unsigned int    st_uid;
-       unsigned int    st_gid;
+       abi_uint        st_uid;
+       abi_uint        st_gid;

-       unsigned char   __pad2[6];
-       unsigned short  st_rdev;
+       abi_uint        __pad0;
+       abi_ullong      st_rdev;

-        int64_t                st_size;
-       int64_t         st_blksize;
+       abi_llong       st_size;
+       abi_llong       st_blksize;

-       unsigned char   __pad4[4];
-       unsigned int    st_blocks;
+       abi_llong       st_blocks;

        abi_ulong       target_st_atime;
        abi_ulong       target_st_atime_nsec;
@@ -1501,13 +1499,13 @@ struct target_stat64 {

 #define TARGET_STAT_HAVE_NSEC
 struct target_stat {
-       unsigned short  st_dev;
+       abi_ushort      st_dev;
        abi_ulong       st_ino;
-       unsigned short  st_mode;
-       short           st_nlink;
-       unsigned short  st_uid;
-       unsigned short  st_gid;
-       unsigned short  st_rdev;
+       abi_ushort      st_mode;
+       abi_short       st_nlink;
+       abi_ushort      st_uid;
+       abi_ushort      st_gid;
+       abi_ushort      st_rdev;
        abi_long        st_size;
        abi_long        target_st_atime;
        abi_ulong       target_st_atime_nsec;
@@ -1522,39 +1520,37 @@ struct target_stat {

 #define TARGET_HAS_STRUCT_STAT64
 struct target_stat64 {
-       unsigned char   __pad0[6];
-       unsigned short  st_dev;
+       abi_ullong st_dev;

-       uint64_t st_ino;
+       abi_ullong st_ino;

-       unsigned int    st_mode;
-       unsigned int    st_nlink;
+       abi_uint        st_mode;
+       abi_uint        st_nlink;

-       unsigned int    st_uid;
-       unsigned int    st_gid;
+       abi_uint        st_uid;
+       abi_uint        st_gid;

-       unsigned char   __pad2[6];
-       unsigned short  st_rdev;
+       abi_ullong        st_rdev;

        unsigned char   __pad3[8];

-        int64_t        st_size;
-       unsigned int    st_blksize;
+        abi_llong      st_size;
+       abi_uint        st_blksize;

        unsigned char   __pad4[8];
-       unsigned int    st_blocks;
+       abi_uint        st_blocks;

-       unsigned int    target_st_atime;
-       unsigned int    target_st_atime_nsec;
+       abi_uint        target_st_atime;
+       abi_uint        target_st_atime_nsec;

-       unsigned int    target_st_mtime;
-       unsigned int    target_st_mtime_nsec;
+       abi_uint        target_st_mtime;
+       abi_uint        target_st_mtime_nsec;

-       unsigned int    target_st_ctime;
-       unsigned int    target_st_ctime_nsec;
+       abi_uint        target_st_ctime;
+       abi_uint        target_st_ctime_nsec;

-       unsigned int    __unused1;
-       unsigned int    __unused2;
+       abi_uint        __unused1;
+       abi_uint        __unused2;
 };

 #elif defined(TARGET_PPC)







reply via email to

[Prev in Thread] Current Thread [Next in Thread]