* [Qemu-devel] [PATCH v2] qga: fix append file open modes for win32
@ 2015-11-10 23:19 Kirk Allan
2015-11-11 16:23 ` Michael Roth
0 siblings, 1 reply; 2+ messages in thread
From: Kirk Allan @ 2015-11-10 23:19 UTC (permalink / raw)
To: qemu-devel; +Cc: pbonzini, Kirk Allan, mdroth, qemu-stable
For append file open modes, use FILE_APPEND_DATA for the desired access
for writing at the end of the file.
Version 2:
For "a+", "ab+", and "a+b" modes use FILE_APPEND_DATA|GENERIC_READ.
ORing in GENERIC_READ starts a read at the begining of the file. All
writes will append to the end fo the file.
Added white space to maintain the alignment of the guest_file_open_modes[].
Signed-off-by: Kirk Allan <kallan@suse.com>
---
qga/commands-win32.c | 28 ++++++++++++++--------------
1 file changed, 14 insertions(+), 14 deletions(-)
diff --git a/qga/commands-win32.c b/qga/commands-win32.c
index a5306e7..5a75c3d 100644
--- a/qga/commands-win32.c
+++ b/qga/commands-win32.c
@@ -66,20 +66,20 @@ typedef struct OpenFlags {
DWORD creation_disposition;
} OpenFlags;
static OpenFlags guest_file_open_modes[] = {
- {"r", GENERIC_READ, OPEN_EXISTING},
- {"rb", GENERIC_READ, OPEN_EXISTING},
- {"w", GENERIC_WRITE, CREATE_ALWAYS},
- {"wb", GENERIC_WRITE, CREATE_ALWAYS},
- {"a", GENERIC_WRITE, OPEN_ALWAYS },
- {"r+", GENERIC_WRITE|GENERIC_READ, OPEN_EXISTING},
- {"rb+", GENERIC_WRITE|GENERIC_READ, OPEN_EXISTING},
- {"r+b", GENERIC_WRITE|GENERIC_READ, OPEN_EXISTING},
- {"w+", GENERIC_WRITE|GENERIC_READ, CREATE_ALWAYS},
- {"wb+", GENERIC_WRITE|GENERIC_READ, CREATE_ALWAYS},
- {"w+b", GENERIC_WRITE|GENERIC_READ, CREATE_ALWAYS},
- {"a+", GENERIC_WRITE|GENERIC_READ, OPEN_ALWAYS },
- {"ab+", GENERIC_WRITE|GENERIC_READ, OPEN_ALWAYS },
- {"a+b", GENERIC_WRITE|GENERIC_READ, OPEN_ALWAYS }
+ {"r", GENERIC_READ, OPEN_EXISTING},
+ {"rb", GENERIC_READ, OPEN_EXISTING},
+ {"w", GENERIC_WRITE, CREATE_ALWAYS},
+ {"wb", GENERIC_WRITE, CREATE_ALWAYS},
+ {"a", FILE_APPEND_DATA, OPEN_ALWAYS },
+ {"r+", GENERIC_WRITE|GENERIC_READ, OPEN_EXISTING},
+ {"rb+", GENERIC_WRITE|GENERIC_READ, OPEN_EXISTING},
+ {"r+b", GENERIC_WRITE|GENERIC_READ, OPEN_EXISTING},
+ {"w+", GENERIC_WRITE|GENERIC_READ, CREATE_ALWAYS},
+ {"wb+", GENERIC_WRITE|GENERIC_READ, CREATE_ALWAYS},
+ {"w+b", GENERIC_WRITE|GENERIC_READ, CREATE_ALWAYS},
+ {"a+", FILE_APPEND_DATA|GENERIC_READ, OPEN_ALWAYS },
+ {"ab+", FILE_APPEND_DATA|GENERIC_READ, OPEN_ALWAYS },
+ {"a+b", FILE_APPEND_DATA|GENERIC_READ, OPEN_ALWAYS }
};
static OpenFlags *find_open_flag(const char *mode_str)
--
1.8.5.6
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [Qemu-devel] [PATCH v2] qga: fix append file open modes for win32
2015-11-10 23:19 [Qemu-devel] [PATCH v2] qga: fix append file open modes for win32 Kirk Allan
@ 2015-11-11 16:23 ` Michael Roth
0 siblings, 0 replies; 2+ messages in thread
From: Michael Roth @ 2015-11-11 16:23 UTC (permalink / raw)
To: Kirk Allan, qemu-devel; +Cc: pbonzini, qemu-stable
Quoting Kirk Allan (2015-11-10 17:19:11)
> For append file open modes, use FILE_APPEND_DATA for the desired access
> for writing at the end of the file.
>
> Version 2:
> For "a+", "ab+", and "a+b" modes use FILE_APPEND_DATA|GENERIC_READ.
> ORing in GENERIC_READ starts a read at the begining of the file. All
> writes will append to the end fo the file.
>
> Added white space to maintain the alignment of the guest_file_open_modes[].
>
> Signed-off-by: Kirk Allan <kallan@suse.com>
Thanks, applied to qga tree with changes discussed in v1 thread:
https://github.com/mdroth/qemu/commits/qga
> ---
> qga/commands-win32.c | 28 ++++++++++++++--------------
> 1 file changed, 14 insertions(+), 14 deletions(-)
>
> diff --git a/qga/commands-win32.c b/qga/commands-win32.c
> index a5306e7..5a75c3d 100644
> --- a/qga/commands-win32.c
> +++ b/qga/commands-win32.c
> @@ -66,20 +66,20 @@ typedef struct OpenFlags {
> DWORD creation_disposition;
> } OpenFlags;
> static OpenFlags guest_file_open_modes[] = {
> - {"r", GENERIC_READ, OPEN_EXISTING},
> - {"rb", GENERIC_READ, OPEN_EXISTING},
> - {"w", GENERIC_WRITE, CREATE_ALWAYS},
> - {"wb", GENERIC_WRITE, CREATE_ALWAYS},
> - {"a", GENERIC_WRITE, OPEN_ALWAYS },
> - {"r+", GENERIC_WRITE|GENERIC_READ, OPEN_EXISTING},
> - {"rb+", GENERIC_WRITE|GENERIC_READ, OPEN_EXISTING},
> - {"r+b", GENERIC_WRITE|GENERIC_READ, OPEN_EXISTING},
> - {"w+", GENERIC_WRITE|GENERIC_READ, CREATE_ALWAYS},
> - {"wb+", GENERIC_WRITE|GENERIC_READ, CREATE_ALWAYS},
> - {"w+b", GENERIC_WRITE|GENERIC_READ, CREATE_ALWAYS},
> - {"a+", GENERIC_WRITE|GENERIC_READ, OPEN_ALWAYS },
> - {"ab+", GENERIC_WRITE|GENERIC_READ, OPEN_ALWAYS },
> - {"a+b", GENERIC_WRITE|GENERIC_READ, OPEN_ALWAYS }
> + {"r", GENERIC_READ, OPEN_EXISTING},
> + {"rb", GENERIC_READ, OPEN_EXISTING},
> + {"w", GENERIC_WRITE, CREATE_ALWAYS},
> + {"wb", GENERIC_WRITE, CREATE_ALWAYS},
> + {"a", FILE_APPEND_DATA, OPEN_ALWAYS },
> + {"r+", GENERIC_WRITE|GENERIC_READ, OPEN_EXISTING},
> + {"rb+", GENERIC_WRITE|GENERIC_READ, OPEN_EXISTING},
> + {"r+b", GENERIC_WRITE|GENERIC_READ, OPEN_EXISTING},
> + {"w+", GENERIC_WRITE|GENERIC_READ, CREATE_ALWAYS},
> + {"wb+", GENERIC_WRITE|GENERIC_READ, CREATE_ALWAYS},
> + {"w+b", GENERIC_WRITE|GENERIC_READ, CREATE_ALWAYS},
> + {"a+", FILE_APPEND_DATA|GENERIC_READ, OPEN_ALWAYS },
> + {"ab+", FILE_APPEND_DATA|GENERIC_READ, OPEN_ALWAYS },
> + {"a+b", FILE_APPEND_DATA|GENERIC_READ, OPEN_ALWAYS }
> };
>
> static OpenFlags *find_open_flag(const char *mode_str)
> --
> 1.8.5.6
>
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2015-11-11 16:23 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-11-10 23:19 [Qemu-devel] [PATCH v2] qga: fix append file open modes for win32 Kirk Allan
2015-11-11 16:23 ` Michael Roth
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).