From: Laurent Vivier <laurent@vivier.eu>
To: Tony Garnock-Jones <tony.garnock-jones@glasgow.ac.uk>,
qemu-devel@nongnu.org
Cc: qemu-trivial@nongnu.org, Riku Voipio <riku.voipio@iki.fi>,
qemu-stable@nongnu.org
Subject: Re: [Qemu-devel] [PATCH] linux-user: write(fd, NULL, 0) parity with linux's treatment of same
Date: Sun, 9 Sep 2018 10:22:23 +0200 [thread overview]
Message-ID: <f7076ae9-da04-7dbc-8acf-ebe5b948c4ed@vivier.eu> (raw)
In-Reply-To: <20180908182205.GB409@mornington.dcs.gla.ac.uk>
Le 08/09/2018 à 20:22, Tony Garnock-Jones a écrit :
> Bring linux-user write(2) handling into line with linux for the case
> of a 0-byte write with a NULL buffer. Based on a patch originally
> written by Zhuowei Zhang.
>
> Addresses https://bugs.launchpad.net/qemu/+bug/1716292.
>
> From Zhuowei Zhang's patch (https://lists.gnu.org/archive/html/qemu-devel/2017-09/msg08073.html):
>
> Linux returns success for the special case of calling write with a
> zero-length NULL buffer: compiling and running
>
> int main() {
> ssize_t ret = write(STDOUT_FILENO, NULL, 0);
> fprintf(stderr, "write returned %ld\n", ret);
> return 0;
> }
>
> gives "write returned 0" when run directly, but "write returned
> -1" in QEMU.
>
> This commit checks for this situation and returns success if
> found.
>
> Subsequent discussion raised the following questions (and my answers):
>
> - Q. Should TARGET_NR_read pass through to safe_read in this
> situation too?
> A. I'm wary of changing unrelated code to the specific problem I'm
> addressing. TARGET_NR_read is already consistent with Linux for
> this case.
>
> - Q. Do pread64/pwrite64 need to be changed similarly?
> A. Experiment suggests not: both linux and linux-user yield -1 for
> NULL 0-length reads/writes.
>
> Signed-off-by: Tony Garnock-Jones <tonygarnockjones@gmail.com>
> ---
> linux-user/syscall.c | 3 +++
> 1 file changed, 3 insertions(+)
Reviewed-by: Laurent Vivier <laurent@vivier.eu>
next prev parent reply other threads:[~2018-09-09 8:22 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-09-08 18:22 [Qemu-devel] [PATCH] linux-user: write(fd, NULL, 0) parity with linux's treatment of same Tony Garnock-Jones
2018-09-09 1:42 ` Philippe Mathieu-Daudé
2018-09-09 8:22 ` Laurent Vivier [this message]
2019-01-03 18:31 ` Peter Maydell
2019-01-08 18:59 ` Peter Maydell
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=f7076ae9-da04-7dbc-8acf-ebe5b948c4ed@vivier.eu \
--to=laurent@vivier.eu \
--cc=qemu-devel@nongnu.org \
--cc=qemu-stable@nongnu.org \
--cc=qemu-trivial@nongnu.org \
--cc=riku.voipio@iki.fi \
--cc=tony.garnock-jones@glasgow.ac.uk \
/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).