1 | Windows open(2) implementations opens files in text mode by default and | 1 | Windows open(2) implementation opens files in text mode by default and |
---|---|---|---|
2 | needs a Windows-only O_BINARY flag to open files as binary. Qemu already | 2 | needs a Windows-only O_BINARY flag to open files as binary. QEMU already |
3 | knows about that flag in osdep.h, so we can just add it to the | 3 | knows about that flag in osdep and it is defined to 0 on non-Windows, |
4 | host_flags for better compatibility when running qemu on Windows. | 4 | so we can just add it to the host_flags for better compatibility. |
5 | 5 | ||
6 | Signed-off-by: Evgeny Iakovlev <eiakovlev@linux.microsoft.com> | 6 | Signed-off-by: Evgeny Iakovlev <eiakovlev@linux.microsoft.com> |
7 | Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org> | ||
8 | Reviewed-by: Bin Meng <bmeng.cn@gmail.com> | ||
7 | --- | 9 | --- |
8 | semihosting/syscalls.c | 2 ++ | 10 | semihosting/syscalls.c | 8 ++++---- |
9 | 1 file changed, 2 insertions(+) | 11 | 1 file changed, 4 insertions(+), 4 deletions(-) |
10 | 12 | ||
11 | diff --git a/semihosting/syscalls.c b/semihosting/syscalls.c | 13 | diff --git a/semihosting/syscalls.c b/semihosting/syscalls.c |
12 | index XXXXXXX..XXXXXXX 100644 | 14 | index XXXXXXX..XXXXXXX 100644 |
13 | --- a/semihosting/syscalls.c | 15 | --- a/semihosting/syscalls.c |
14 | +++ b/semihosting/syscalls.c | 16 | +++ b/semihosting/syscalls.c |
15 | @@ -XXX,XX +XXX,XX @@ static void host_open(CPUState *cs, gdb_syscall_complete_cb complete, | 17 | @@ -XXX,XX +XXX,XX @@ static void host_open(CPUState *cs, gdb_syscall_complete_cb complete, |
16 | host_flags |= O_EXCL; | 18 | { |
19 | CPUArchState *env G_GNUC_UNUSED = cs->env_ptr; | ||
20 | char *p; | ||
21 | - int ret, host_flags; | ||
22 | + int ret, host_flags = O_BINARY; | ||
23 | |||
24 | ret = validate_lock_user_string(&p, cs, fname, fname_len); | ||
25 | if (ret < 0) { | ||
26 | @@ -XXX,XX +XXX,XX @@ static void host_open(CPUState *cs, gdb_syscall_complete_cb complete, | ||
17 | } | 27 | } |
18 | 28 | ||
19 | + host_flags |= O_BINARY; | 29 | if (gdb_flags & GDB_O_WRONLY) { |
20 | + | 30 | - host_flags = O_WRONLY; |
21 | ret = open(p, host_flags, mode); | 31 | + host_flags |= O_WRONLY; |
22 | if (ret < 0) { | 32 | } else if (gdb_flags & GDB_O_RDWR) { |
23 | complete(cs, -1, errno); | 33 | - host_flags = O_RDWR; |
34 | + host_flags |= O_RDWR; | ||
35 | } else { | ||
36 | - host_flags = O_RDONLY; | ||
37 | + host_flags |= O_RDONLY; | ||
38 | } | ||
39 | if (gdb_flags & GDB_O_CREAT) { | ||
40 | host_flags |= O_CREAT; | ||
24 | -- | 41 | -- |
25 | 2.34.1 | 42 | 2.34.1 |
43 | |||
44 | diff view generated by jsdifflib |