[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PATCH 14/15] qga: distinguish binary modes in "guest_file_
From: |
Michael Roth |
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 |
From: Laszlo Ersek <address@hidden>
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 <address@hidden>
Reviewed-by: Eric Blake <address@hidden>
Signed-off-by: Laszlo Ersek <address@hidden>
Reviewed-by: Luiz Capitulino <address@hidden>
Signed-off-by: Michael Roth <address@hidden>
(cherry picked from commit 8fe6bbca7176c9dfb35083a71bda95c1856e2ed5)
Signed-off-by: Michael Roth <address@hidden>
---
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
- [Qemu-devel] [PATCH 04/15] tap: properly initialize vhostfds, (continued)
- [Qemu-devel] [PATCH 04/15] tap: properly initialize vhostfds, Michael Roth, 2013/05/14
- [Qemu-devel] [PATCH 05/15] virtio-ccw: Check indicators location., Michael Roth, 2013/05/14
- [Qemu-devel] [PATCH 06/15] configure: Pick up libseccomp include path, Michael Roth, 2013/05/14
- [Qemu-devel] [PATCH 07/15] target-mips: Fix accumulator arguments to gen_helper_dmult(u), Michael Roth, 2013/05/14
- [Qemu-devel] [PATCH 08/15] tcg/optimize: fix setcond2 optimization, Michael Roth, 2013/05/14
- [Qemu-devel] [PATCH 09/15] qga: set umask 0077 when daemonizing (CVE-2013-2007), Michael Roth, 2013/05/14
- [Qemu-devel] [PATCH 10/15] tcg: Document tcg_qemu_tb_exec() and provide constants for low bit uses, Michael Roth, 2013/05/14
- [Qemu-devel] [PATCH 11/15] cpu-exec: wrap tcg_qemu_tb_exec() in a fn to restore the PC, Michael Roth, 2013/05/14
- [Qemu-devel] [PATCH 12/15] Handle CPU interrupts by inline checking of a flag, Michael Roth, 2013/05/14
- [Qemu-devel] [PATCH 13/15] translate-all.c: Remove cpu_unlink_tb(), Michael Roth, 2013/05/14
- [Qemu-devel] [PATCH 14/15] qga: distinguish binary modes in "guest_file_open_modes" map,
Michael Roth <=
- [Qemu-devel] [PATCH 15/15] qga: unlink just created guest-file if fchmod() or fdopen() fails on it, Michael Roth, 2013/05/14
- Re: [Qemu-devel] Patch Round-up for stable 1.4.2, freeze on Monday, Michael Tokarev, 2013/05/15
- Re: [Qemu-devel] Patch Round-up for stable 1.4.2, freeze on Monday, Brad Smith, 2013/05/15
- Re: [Qemu-devel] Patch Round-up for stable 1.4.2, freeze on Monday, Cole Robinson, 2013/05/15
- Re: [Qemu-devel] Patch Round-up for stable 1.4.2, freeze on Monday, Luiz Capitulino, 2013/05/17
- Re: [Qemu-devel] Patch Round-up for stable 1.4.2, freeze on Monday, Doug Goldstein, 2013/05/17