From: Michael Roth <mdroth@linux.vnet.ibm.com>
To: qemu-devel@nongnu.org
Cc: aliguori@us.ibm.com, qemu-stable@nongnu.org
Subject: [Qemu-devel] [PATCH 14/15] qga: distinguish binary modes in "guest_file_open_modes" map
Date: Tue, 14 May 2013 16:53:11 -0500 [thread overview]
Message-ID: <1368568392-2127-15-git-send-email-mdroth@linux.vnet.ibm.com> (raw)
In-Reply-To: <1368568392-2127-1-git-send-email-mdroth@linux.vnet.ibm.com>
From: Laszlo Ersek <lersek@redhat.com>
In Windows guests this may make a difference.
Since the original patch (commit c689b4f1) sought to be pedantic and to
consider theoretical corner cases of portability, we should fix it up
where it failed to come through in that pursuit.
Suggested-by: Eric Blake <eblake@redhat.com>
Reviewed-by: Eric Blake <eblake@redhat.com>
Signed-off-by: Laszlo Ersek <lersek@redhat.com>
Reviewed-by: Luiz Capitulino <lcapitulino@redhat.com>
Signed-off-by: Michael Roth <mdroth@linux.vnet.ibm.com>
(cherry picked from commit 8fe6bbca7176c9dfb35083a71bda95c1856e2ed5)
Signed-off-by: Michael Roth <mdroth@linux.vnet.ibm.com>
---
qga/commands-posix.c | 22 ++++++++++++++++------
1 file changed, 16 insertions(+), 6 deletions(-)
diff --git a/qga/commands-posix.c b/qga/commands-posix.c
index 08f3473..933c700 100644
--- a/qga/commands-posix.c
+++ b/qga/commands-posix.c
@@ -164,17 +164,27 @@ static GuestFileHandle *guest_file_handle_find(int64_t id, Error **err)
typedef const char * const ccpc;
+#ifndef O_BINARY
+#define O_BINARY 0
+#endif
+
/* http://pubs.opengroup.org/onlinepubs/9699919799/functions/fopen.html */
static const struct {
ccpc *forms;
int oflag_base;
} guest_file_open_modes[] = {
- { (ccpc[]){ "r", "rb", NULL }, O_RDONLY },
- { (ccpc[]){ "w", "wb", NULL }, O_WRONLY | O_CREAT | O_TRUNC },
- { (ccpc[]){ "a", "ab", NULL }, O_WRONLY | O_CREAT | O_APPEND },
- { (ccpc[]){ "r+", "rb+", "r+b", NULL }, O_RDWR },
- { (ccpc[]){ "w+", "wb+", "w+b", NULL }, O_RDWR | O_CREAT | O_TRUNC },
- { (ccpc[]){ "a+", "ab+", "a+b", NULL }, O_RDWR | O_CREAT | O_APPEND }
+ { (ccpc[]){ "r", NULL }, O_RDONLY },
+ { (ccpc[]){ "rb", NULL }, O_RDONLY | O_BINARY },
+ { (ccpc[]){ "w", NULL }, O_WRONLY | O_CREAT | O_TRUNC },
+ { (ccpc[]){ "wb", NULL }, O_WRONLY | O_CREAT | O_TRUNC | O_BINARY },
+ { (ccpc[]){ "a", NULL }, O_WRONLY | O_CREAT | O_APPEND },
+ { (ccpc[]){ "ab", NULL }, O_WRONLY | O_CREAT | O_APPEND | O_BINARY },
+ { (ccpc[]){ "r+", NULL }, O_RDWR },
+ { (ccpc[]){ "rb+", "r+b", NULL }, O_RDWR | O_BINARY },
+ { (ccpc[]){ "w+", NULL }, O_RDWR | O_CREAT | O_TRUNC },
+ { (ccpc[]){ "wb+", "w+b", NULL }, O_RDWR | O_CREAT | O_TRUNC | O_BINARY },
+ { (ccpc[]){ "a+", NULL }, O_RDWR | O_CREAT | O_APPEND },
+ { (ccpc[]){ "ab+", "a+b", NULL }, O_RDWR | O_CREAT | O_APPEND | O_BINARY }
};
static int
--
1.7.9.5
next prev parent reply other threads:[~2013-05-14 21:56 UTC|newest]
Thread overview: 27+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-05-14 21:52 [Qemu-devel] Patch Round-up for stable 1.4.2, freeze on Monday Michael Roth
2013-05-14 21:52 ` [Qemu-devel] [PATCH 01/15] nbd: unlock mutex in nbd_co_send_request() error path Michael Roth
2013-05-14 21:52 ` [Qemu-devel] [PATCH 02/15] qdev: Fix QOM unrealize behavior Michael Roth
2013-05-14 21:53 ` [Qemu-devel] [PATCH 03/15] rng random backend: check for -EAGAIN errors on read Michael Roth
2013-05-14 21:53 ` [Qemu-devel] [PATCH 04/15] tap: properly initialize vhostfds Michael Roth
2013-05-14 21:53 ` [Qemu-devel] [PATCH 05/15] virtio-ccw: Check indicators location Michael Roth
2013-05-14 21:53 ` [Qemu-devel] [PATCH 06/15] configure: Pick up libseccomp include path Michael Roth
2013-05-14 21:53 ` [Qemu-devel] [PATCH 07/15] target-mips: Fix accumulator arguments to gen_helper_dmult(u) Michael Roth
2013-05-14 21:53 ` [Qemu-devel] [PATCH 08/15] tcg/optimize: fix setcond2 optimization Michael Roth
2013-05-14 21:53 ` [Qemu-devel] [PATCH 09/15] qga: set umask 0077 when daemonizing (CVE-2013-2007) Michael Roth
2013-05-14 21:53 ` [Qemu-devel] [PATCH 10/15] tcg: Document tcg_qemu_tb_exec() and provide constants for low bit uses Michael Roth
2013-05-14 21:53 ` [Qemu-devel] [PATCH 11/15] cpu-exec: wrap tcg_qemu_tb_exec() in a fn to restore the PC Michael Roth
2013-05-14 21:53 ` [Qemu-devel] [PATCH 12/15] Handle CPU interrupts by inline checking of a flag Michael Roth
2013-05-14 21:53 ` [Qemu-devel] [PATCH 13/15] translate-all.c: Remove cpu_unlink_tb() Michael Roth
2013-05-14 21:53 ` Michael Roth [this message]
2013-05-14 21:53 ` [Qemu-devel] [PATCH 15/15] qga: unlink just created guest-file if fchmod() or fdopen() fails on it Michael Roth
2013-05-15 4:49 ` [Qemu-devel] Patch Round-up for stable 1.4.2, freeze on Monday Michael Tokarev
2013-05-15 4:51 ` Michael Tokarev
2013-05-15 14:09 ` Brad Smith
2013-05-15 16:25 ` mdroth
2013-05-15 21:48 ` Cole Robinson
2013-05-16 17:20 ` mdroth
2013-05-17 12:43 ` Luiz Capitulino
2013-05-17 15:46 ` Doug Goldstein
2013-05-17 19:08 ` mdroth
2013-05-17 20:43 ` [Qemu-devel] [Qemu-stable] " Josh Durgin
2013-05-17 21:01 ` mdroth
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=1368568392-2127-15-git-send-email-mdroth@linux.vnet.ibm.com \
--to=mdroth@linux.vnet.ibm.com \
--cc=aliguori@us.ibm.com \
--cc=qemu-devel@nongnu.org \
--cc=qemu-stable@nongnu.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).