qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
* stat64 wrong on sparc64 user
@ 2023-03-28 11:48 Luca Bonissi
  2023-03-28 11:55 ` Thomas Huth
  2023-03-28 14:52 ` Richard Henderson
  0 siblings, 2 replies; 7+ messages in thread
From: Luca Bonissi @ 2023-03-28 11:48 UTC (permalink / raw)
  To: qemu-devel, Laurent Vivier

On qemu-sparc64 (userspace) the struct "target_stat64" is not correctly 
padded, so the field st_rdev is not correctly aligned and will report 
wrong major/minor (e.g. for /dev/zero it reports 0,0x10500000 instead of 
1,5).

Here patch to solve the issue (it also fixes incorrect size on some fields):

--- 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;
  	unsigned int	st_gid;
  	unsigned int	st_rdev;
@@ -1465,8 +1465,7 @@ struct target_stat {

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

  	uint64_t	st_ino;
  	uint64_t	st_nlink;
@@ -1476,14 +1475,13 @@ struct target_stat64 {
  	unsigned int	st_uid;
  	unsigned int	st_gid;

-	unsigned char	__pad2[6];
-	unsigned short	st_rdev;
+	unsigned int	__pad0;
+	uint64_t	st_rdev;

          int64_t		st_size;
  	int64_t		st_blksize;

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

  	abi_ulong	target_st_atime;
  	abi_ulong	target_st_atime_nsec;
@@ -1522,8 +1520,7 @@ struct target_stat {

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

  	uint64_t st_ino;

@@ -1533,8 +1530,7 @@ struct target_stat64 {
  	unsigned int	st_uid;
  	unsigned int	st_gid;

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

  	unsigned char	__pad3[8];



^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2023-03-30 11:14 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-03-28 11:48 stat64 wrong on sparc64 user Luca Bonissi
2023-03-28 11:55 ` Thomas Huth
2023-03-28 12:22   ` Luca Bonissi
2023-03-28 12:41     ` Thomas Huth
2023-03-29 16:22     ` Laurent Vivier
2023-03-30 11:13       ` Luca Bonissi
2023-03-28 14:52 ` Richard Henderson

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).