Skip to content

Commit

Permalink
linux-user: Fix stat64 syscall for SPARC64
Browse files Browse the repository at this point in the history
Some targets use a stat64 structure for the stat64 syscall while others
use a stat structure. SPARC64 used the wrong kind.

Instead of extending the conditional compilation in syscall.c, now a
macro TARGET_HAS_STRUCT_STAT64 is defined whenever a target has a
target_stat64.

Signed-off-by: Stefan Weil <[email protected]>
Reviewed-by: Erik de Castro Lopo <[email protected]>
  • Loading branch information
stweil committed Nov 7, 2013
1 parent bdf523e commit 20d155b
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 3 deletions.
6 changes: 3 additions & 3 deletions linux-user/syscall.c
Original file line number Diff line number Diff line change
Expand Up @@ -4870,10 +4870,10 @@ static inline abi_long host_to_target_stat64(void *cpu_env,
} else
#endif
{
#if TARGET_ABI_BITS == 64 && !defined(TARGET_ALPHA)
struct target_stat *target_st;
#else
#if defined(TARGET_HAS_STRUCT_STAT64)
struct target_stat64 *target_st;
#else
struct target_stat *target_st;
#endif

if (!lock_user_struct(VERIFY_WRITE, target_st, target_addr, 0))
Expand Down
14 changes: 14 additions & 0 deletions linux-user/syscall_defs.h
Original file line number Diff line number Diff line change
Expand Up @@ -1178,6 +1178,7 @@ struct target_stat {
/* This matches struct stat64 in glibc2.1, hence the absolutely
* insane amounts of padding around dev_t's.
*/
#define TARGET_HAS_STRUCT_STAT64
struct target_stat64 {
unsigned short st_dev;
unsigned char __pad0[10];
Expand Down Expand Up @@ -1213,6 +1214,7 @@ struct target_stat64 {
} QEMU_PACKED;

#ifdef TARGET_ARM
#define TARGET_HAS_STRUCT_STAT64
struct target_eabi_stat64 {
unsigned long long st_dev;
unsigned int __pad1;
Expand Down Expand Up @@ -1262,6 +1264,7 @@ struct target_stat {
abi_ulong __unused4[2];
};

#define TARGET_HAS_STRUCT_STAT64
struct target_stat64 {
unsigned char __pad0[6];
unsigned short st_dev;
Expand Down Expand Up @@ -1317,6 +1320,7 @@ struct target_stat {
abi_ulong __unused4[2];
};

#define TARGET_HAS_STRUCT_STAT64
struct target_stat64 {
unsigned char __pad0[6];
unsigned short st_dev;
Expand Down Expand Up @@ -1384,6 +1388,8 @@ struct target_stat {
#endif
};

#if !defined(TARGET_PPC64) || defined(TARGET_ABI32)
#define TARGET_HAS_STRUCT_STAT64
struct QEMU_PACKED target_stat64 {
unsigned long long st_dev;
unsigned long long st_ino;
Expand All @@ -1406,6 +1412,7 @@ struct QEMU_PACKED target_stat64 {
unsigned int __unused4;
unsigned int __unused5;
};
#endif

#elif defined(TARGET_MICROBLAZE)

Expand All @@ -1431,6 +1438,7 @@ struct target_stat {
};

/* FIXME: Microblaze no-mmu user-space has a difference stat64 layout... */
#define TARGET_HAS_STRUCT_STAT64
struct QEMU_PACKED target_stat64 {
uint64_t st_dev;
#define TARGET_STAT64_HAS_BROKEN_ST_INO 1
Expand Down Expand Up @@ -1486,6 +1494,7 @@ struct target_stat {
/* This matches struct stat64 in glibc2.1, hence the absolutely
* insane amounts of padding around dev_t's.
*/
#define TARGET_HAS_STRUCT_STAT64
struct target_stat64 {
unsigned long long st_dev;
unsigned char __pad1[2];
Expand Down Expand Up @@ -1594,6 +1603,7 @@ struct target_stat {
* struct stat of the 64-bit kernel.
*/

#define TARGET_HAS_STRUCT_STAT64
struct target_stat64 {
unsigned int st_dev;
unsigned int st_pad0[3]; /* Reserved for st_dev expansion */
Expand Down Expand Up @@ -1665,6 +1675,7 @@ struct target_stat {
* struct stat of the 64-bit kernel.
*/

#define TARGET_HAS_STRUCT_STAT64
struct target_stat64 {
abi_ulong st_dev;
abi_ulong st_pad0[3]; /* Reserved for st_dev expansion */
Expand Down Expand Up @@ -1721,6 +1732,7 @@ struct target_stat {
unsigned int st_gen;
};

#define TARGET_HAS_STRUCT_STAT64
struct target_stat64 {
abi_ulong st_dev;
abi_ulong st_ino;
Expand Down Expand Up @@ -1770,6 +1782,7 @@ struct target_stat {
/* This matches struct stat64 in glibc2.1, hence the absolutely
* insane amounts of padding around dev_t's.
*/
#define TARGET_HAS_STRUCT_STAT64
struct QEMU_PACKED target_stat64 {
unsigned long long st_dev;
unsigned char __pad0[4];
Expand Down Expand Up @@ -1897,6 +1910,7 @@ struct target_stat {
unsigned int __unused5;
};

#define TARGET_HAS_STRUCT_STAT64
struct target_stat64 {
uint64_t st_dev;
uint64_t st_ino;
Expand Down

0 comments on commit 20d155b

Please sign in to comment.