From 0775dfc24c229a821ec67f918b12d3b2dacd7b8a Mon Sep 17 00:00:00 2001 Message-Id: <0775dfc24c229a821ec67f918b12d3b2dacd7b8a.1369221838.git.minovotn@redhat.com> In-Reply-To: <44d9306ede26ea2881e6c1f104b901be647022a8.1369221838.git.minovotn@redhat.com> References: <44d9306ede26ea2881e6c1f104b901be647022a8.1369221838.git.minovotn@redhat.com> From: Laszlo Ersek Date: Fri, 17 May 2013 22:31:26 +0200 Subject: [PATCH 7/8] qga: distinguish binary modes in "guest_file_open_modes" map RH-Author: Laszlo Ersek Message-id: <1368829887-15218-3-git-send-email-lersek@redhat.com> Patchwork-id: 51424 O-Subject: [RHEL-6.5 qemu-kvm PATCH v2 2/3] qga: distinguish binary modes in "guest_file_open_modes" map Bugzilla: 953932 RH-Acked-by: Eric Blake RH-Acked-by: Paolo Bonzini RH-Acked-by: Luiz Capitulino 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 Reviewed-by: Eric Blake Signed-off-by: Laszlo Ersek Reviewed-by: Luiz Capitulino Signed-off-by: Michael Roth (cherry picked from commit 8fe6bbca7176c9dfb35083a71bda95c1856e2ed5) --- qga/commands-posix.c | 22 ++++++++++++++++------ 1 files changed, 16 insertions(+), 6 deletions(-) Signed-off-by: Michal Novotny --- 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 3ebb29b..e2a3c43 100644 --- a/qga/commands-posix.c +++ b/qga/commands-posix.c @@ -243,17 +243,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.11.7