qemu-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Qemu-devel] [PATCH] qga: fix append file open modes for win32


From: Michael Roth
Subject: Re: [Qemu-devel] [PATCH] qga: fix append file open modes for win32
Date: Tue, 10 Nov 2015 09:40:59 -0600
User-agent: alot/0.3.6

Quoting Kirk Allan (2015-11-09 15:49:05)
> For append file open modes, use FILE_APPEND_DATA for the desired access for 
> writing at the end of the file.
> 
> Signed-off-by: Kirk Allan <address@hidden>
> ---
>  qga/commands-win32.c | 8 ++++----
>  1 file changed, 4 insertions(+), 4 deletions(-)
> 
> diff --git a/qga/commands-win32.c b/qga/commands-win32.c
> index a5306e7..0a23b9b 100644
> --- a/qga/commands-win32.c
> +++ b/qga/commands-win32.c
> @@ -70,16 +70,16 @@ static OpenFlags guest_file_open_modes[] = {
>      {"rb",  GENERIC_READ,               OPEN_EXISTING},
>      {"w",   GENERIC_WRITE,              CREATE_ALWAYS},
>      {"wb",  GENERIC_WRITE,              CREATE_ALWAYS},
> -    {"a",   GENERIC_WRITE,              OPEN_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+",  GENERIC_WRITE|GENERIC_READ, OPEN_ALWAYS  },
> -    {"ab+", GENERIC_WRITE|GENERIC_READ, OPEN_ALWAYS  },
> -    {"a+b", GENERIC_WRITE|GENERIC_READ, OPEN_ALWAYS  }
> +    {"a+",  FILE_APPEND_DATA,           OPEN_ALWAYS  },
> +    {"ab+", FILE_APPEND_DATA,           OPEN_ALWAYS  },
> +    {"a+b", FILE_APPEND_DATA,           OPEN_ALWAYS  }

Cc'ing address@hidden

Thanks for catching this, accidentally truncating files is
certainly not good...

I hit an issue testing this though, this does fix the append
case, but a+, ab+, a+b all imply append+read, while
FILE_APPEND_DATA only grants append access.

FILE_APPEND_DATA|GENERIC_READ seems to work, but I'm not
finding much official documentation on what's valid with
FILE_APPEND_DATA. Do you have a reference that might
confirm this is valid usage? The only reference to
FILE_APPEND_DATA I saw was a single comment in:

https://msdn.microsoft.com/en-us/library/windows/desktop/aa363858(v=vs.85).aspx

I'd like to get this in soon for 2.5 (hard freeze / rc0 is thursday).

>  };
> 
>  static OpenFlags *find_open_flag(const char *mode_str)
> -- 
> 1.8.5.6
> 




reply via email to

[Prev in Thread] Current Thread [Next in Thread]