From: Richard Henderson <richard.henderson@linaro.org>
To: Luca Bonissi <qemu@bonslack.org>,
qemu-devel@nongnu.org, Laurent Vivier <laurent@vivier.eu>
Subject: Re: stat64 wrong on sparc64 user
Date: Tue, 28 Mar 2023 07:52:08 -0700 [thread overview]
Message-ID: <db7c2a6b-3457-b889-1476-486fb456613d@linaro.org> (raw)
In-Reply-To: <db07e036-cc5f-c9ad-b63c-10fdd5404830@bonslack.org>
On 3/28/23 04:48, Luca Bonissi wrote:
> 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;
All use of the normal C types is wrong for target structs.
You must use abi_{short,int,long} etc.
Otherwise, you may not get the alignment you're expecting.
r~
prev parent reply other threads:[~2023-03-28 14:53 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
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 message]
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=db7c2a6b-3457-b889-1476-486fb456613d@linaro.org \
--to=richard.henderson@linaro.org \
--cc=laurent@vivier.eu \
--cc=qemu-devel@nongnu.org \
--cc=qemu@bonslack.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).